:root {
  --bg: #14110d;
  --bg-raised: #1c1812;
  --panel: #1b1712;
  --panel-2: #221e18;
  --line: #3a3224;
  --gold: #e4b34c;
  --gold-dim: #a07828;
  --text: #efe6d6;
  --muted: #9a8b70;
  --ember: #d86a3a;
  --leaf: #8fbe72;
  --paper: #f3ead8;
  --ink: #1c1610;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
  --sans: "Figtree", "Source Sans 3", system-ui, sans-serif;
  --serif: "Fraunces", Georgia, serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  --ui-fg: var(--text);
  --ui-bg: var(--panel-2);
  --ui-muted: var(--muted);
  --ui-line: var(--line);
  --ui-accent: var(--gold);
  --ui-accent-fg: #1a1408;
  --ui-danger: var(--ember);
  --ui-danger-fg: #fff;
  --ui-overlay: rgba(8, 6, 4, 0.55);
  --ui-shadow: var(--shadow);
  --ui-font: var(--sans);
  --ui-serif: var(--serif);
}

* { box-sizing: border-box; }
html, body, #root {
  height: 100%;
  max-height: 100%;
  margin: 0;
  overflow: hidden;
}
body {
  background:
    radial-gradient(900px 420px at 8% -10%, rgba(228, 179, 76, 0.12), transparent 50%),
    var(--bg);
  color: var(--text);
  font-family: var(--sans);
  color-scheme: dark;
  overscroll-behavior: none;
}

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
code, pre { font-family: var(--mono); }

.shell {
  height: 100%;
  min-width: 0;
  overflow: hidden;
  position: relative;
}
.workspace {
  height: 100%;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
  display: grid;
  grid-template-rows: auto 1fr auto;
}

.top {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.7rem 0.9rem;
  border-bottom: 1px solid var(--line);
  background: rgba(20, 17, 13, 0.92);
  backdrop-filter: blur(12px);
  min-width: 0;
  position: relative;
  z-index: 20;
}

.brand { display: flex; align-items: center; gap: 0.7rem; min-width: 0; }
.brand > svg { flex: none; }
.brand svg { width: 1.7rem; height: 1.7rem; color: var(--gold); }
.wordmark { font-family: var(--serif); font-size: 1.15rem; letter-spacing: 0.01em; }
.tagline { margin: 0; color: var(--muted); font-size: 0.72rem; letter-spacing: 0.08em; text-transform: uppercase; }

.beta-pop { flex: none; }
.beta-badge {
  border: 0;
  border-radius: 4px;
  background: #c3382a;
  color: #fff8f5;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  line-height: 1;
  padding: 0.22rem 0.42rem 0.2rem;
}
.beta-badge:hover { background: #d44334; }
.beta-badge[aria-expanded="true"] { background: #a82f24; }
.beta-pop .ui-popover-panel {
  min-width: 16rem;
  max-width: 20rem;
}
.beta-copy p {
  margin: 0;
  font-size: 0.84rem;
  line-height: 1.45;
  color: var(--text);
}
.beta-copy p + p { margin-top: 0.6rem; }

.history-pop { flex: none; }
.history-btn { position: relative; }
.history-count {
  position: absolute;
  top: -0.15rem;
  right: -0.15rem;
  min-width: 0.95rem;
  height: 0.95rem;
  padding: 0 0.22rem;
  border-radius: 99px;
  background: var(--gold);
  color: #1a1408;
  font-size: 0.58rem;
  font-weight: 700;
  line-height: 0.95rem;
  text-align: center;
}
.history-pop .ui-popover-panel {
  min-width: 18rem;
  max-width: min(24rem, calc(100vw - 1.5rem));
  max-height: min(22rem, calc(100dvh - 5rem));
  padding: 0.65rem 0.7rem 0.7rem;
  display: flex;
  flex-direction: column;
}
.history-copy { min-height: 0; display: flex; flex-direction: column; }
.history-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.6rem;
  margin-bottom: 0.45rem;
}
.history-title {
  font-family: var(--serif);
  font-size: 1.05rem;
  font-weight: 560;
  margin: 0;
}
.history-list {
  list-style: none;
  padding: 0;
  margin: 0;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
}
.history-item {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  padding: 0.45rem 0;
  border-top: 1px solid var(--line);
}
.history-item:first-child { border-top: 0; padding-top: 0.15rem; }
.history-text { min-width: 0; flex: 1; }
.history-label {
  font-size: 0.82rem;
  line-height: 1.35;
  overflow-wrap: anywhere;
}
.history-age { font-size: 0.72rem; color: var(--muted); margin-top: 0.12rem; }
.history-item .ui-btn { flex: none; margin-left: auto; }
.empty-history {
  margin: 0.15rem 0 0;
  font-size: 0.84rem;
  line-height: 1.45;
}
.history-foot {
  display: flex;
  justify-content: flex-end;
  margin-top: 0.45rem;
  padding-top: 0.45rem;
  border-top: 1px solid var(--line);
}

.project-context { display: flex; align-items: center; gap: 4px; min-width: 0; }
.project { flex: 0 1 auto; min-width: 0; max-width: 16rem; }
.project:has(.project-local) { max-width: none; }
.project-local {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0.55rem;
  min-width: 0;
}
.project-local .project-name {
  width: auto;
}
.runtime-tag {
  flex: none;
  white-space: nowrap;
  font-size: 0.68rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}
/* The project menu is app chrome, not an OS-native select. */
.project-picker { display: block; min-width: 0; }
.project-trigger, .project-name {
  width: 100%; min-width: 8rem; max-width: 16rem;
  background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 8px; padding: 0.42rem 0.65rem;
}
.project-trigger {
  display: flex; align-items: center; gap: 0.55rem;
  appearance: none; text-align: left; font-size: 0.9rem;
}
.project-trigger svg { width: 17px; height: 17px; flex: none; color: var(--muted); }
.project-trigger-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.project-trigger .project-chevron { margin-left: auto; width: 14px; }
.project-trigger:hover, .project-trigger[aria-expanded="true"] { border-color: var(--gold-dim); }
.project-trigger:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }
.project-name { display: block; }
.project-menu.ui-popover-panel {
  position: fixed; width: min(360px, calc(100vw - 24px));
  min-width: 0; max-width: none; padding: 0;
  display: flex; flex-direction: column; overflow: hidden;
  border-radius: 12px; background: var(--panel-2);
}
.project-menu-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; padding: 18px 18px 14px; }
.project-menu-heading h2 { margin: 0; font-size: 1rem; font-weight: 600; }
.project-menu-heading > span { color: var(--muted); font-size: 0.75rem; white-space: nowrap; }
.project-search { position: relative; margin: 0 12px; }
.project-search > svg { position: absolute; left: 11px; top: 11px; width: 16px; height: 16px; color: var(--muted); pointer-events: none; }
.project-search input { width: 100%; min-width: 0; padding: 10px 12px 10px 34px; background: var(--panel); border: 1px solid var(--line); border-radius: 7px; font-size: 0.85rem; outline: none; }
.project-search input:focus { border-color: var(--gold-dim); }
.project-sort-label { padding: 16px 18px 8px; color: var(--muted); font-size: 0.73rem; }
.project-options { list-style: none; padding: 0 6px 6px; margin: 0; overflow-y: auto; min-height: 0; max-height: 340px; overscroll-behavior: contain; }
.project-options li + li { border-top: 1px solid rgba(154, 139, 112, 0.12); }
.project-option { display: flex; flex-direction: column; gap: 5px; width: 100%; padding: 13px 12px; text-align: left; background: transparent; border: 0; border-radius: 7px; }
.project-option:hover, .project-option:focus-visible { background: rgba(228, 179, 76, 0.07); outline: none; }
.project-option:focus-visible { box-shadow: inset 0 0 0 1px var(--gold-dim); }
.project-option.is-current { background: rgba(228, 179, 76, 0.045); }
.project-option-top { display: flex; align-items: center; gap: 12px; width: 100%; }
.project-option-name { font-size: 0.93rem; font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.project-current { display: flex; align-items: center; gap: 4px; margin-left: auto; flex: none; color: var(--gold); font-size: 0.7rem; }
.project-current svg { width: 13px; height: 13px; }
.project-edited { color: var(--text); opacity: 0.8; font-size: 0.78rem; }
.project-created { color: var(--muted); font-size: 0.73rem; }
.project-empty { margin: 0; padding: 26px 18px; color: var(--muted); text-align: center; font-size: 0.85rem; }
.project-menu-footer { border-top: 1px solid var(--line); padding: 8px; flex: none; }
.project-menu-footer button { display: flex; align-items: center; gap: 9px; width: 100%; border: 0; background: transparent; border-radius: 6px; padding: 9px; color: var(--gold); font-size: 0.85rem; text-align: left; }
.project-menu-footer button:hover, .project-menu-footer button:focus-visible { background: rgba(228, 179, 76, 0.07); outline: 1px solid var(--gold-dim); }
.project-menu-footer svg { width: 16px; height: 16px; }

.actions { display: flex; gap: 0.45rem; align-items: center; margin-left: auto; }
.ghost, .primary, .danger, .icon-btn, .tiny {
  border-radius: 999px;
  border: 1px solid var(--line);
  background: transparent;
  padding: 0.38rem 0.8rem;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}
.ghost:hover, .tiny:hover, .icon-btn:hover { border-color: var(--gold-dim); }
.primary {
  background: var(--gold);
  color: #1a1408;
  border-color: var(--gold);
  font-weight: 600;
}
.danger { background: var(--ember); border-color: var(--ember); color: white; }
.icon-btn.delete-project:hover {
  border-color: var(--ember);
  color: #ffd1c2;
}
.icon-btn { padding: 0.38rem; }
.icon-btn svg, .ghost svg, .primary svg { width: 1rem; height: 1rem; }
/* Workshop toolbar: quiet tools, separated utilities, one primary action. */
.actions { gap: 12px; flex: none; }
.toolbar-group { display: flex; align-items: center; gap: 4px; }
.toolbar-group + .toolbar-utilities { border-left: 1px solid var(--line); padding-left: 12px; }
:is(.actions, .project-context) .icon-btn, .actions > .primary, .actions .add-ui-btn {
  height: 34px;
  border-radius: 7px;
  white-space: nowrap;
  justify-content: center;
}
:is(.actions, .project-context) .icon-btn { width: 34px; padding: 0; border-color: transparent; color: var(--muted); }
.actions .add-ui-btn { border-color: transparent; font-size: 0.85rem; padding: 0 10px; }
:is(.actions, .project-context) .icon-btn:hover, .actions .add-ui-btn:hover,
:is(.actions, .project-context) .icon-btn[aria-expanded="true"] {
  background: var(--panel-2);
  border-color: var(--line);
  color: var(--text);
}
:is(.actions, .project-context) button:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.actions .run-btn { padding: 0 16px; font-size: 0.85rem; }
.project-actions { display: flex; }
.project-actions .ui-popover-panel { min-width: 210px; padding: 6px; }
.project-action-heading { margin: 7px 10px 9px; color: var(--muted); font-size: 0.72rem; }
.project-action-list > button {
  display: flex; align-items: center; gap: 10px; width: 100%;
  border: 0; border-radius: 5px; padding: 10px; background: transparent;
  text-align: left; font-size: 0.85rem;
}
.project-action-list > button:hover, .project-action-list > button:focus-visible { background: var(--panel); }
.project-action-list svg { width: 16px; height: 16px; color: var(--muted); }
.project-action-list .delete-project, .project-action-list .delete-project svg { color: #efa38b; }
.project-action-divider { height: 1px; background: var(--line); margin: 5px; }
.tree-tools .icon-btn { padding: 0.18rem; }
.tree-tools .icon-btn svg { width: 0.85rem; height: 0.85rem; }
.small { padding: 0.2rem 0.55rem; font-size: 0.78rem; }
.tiny {
  justify-content: center;
  line-height: 1;
  padding: 0.28em 0.65em 0.32em;
  font-size: 0.7rem;
  letter-spacing: 0;
  text-transform: none;
  color: var(--muted);
}
.tree-tools .tiny {
  min-height: 1.5rem;
}
.tiny svg {
  width: 0.85rem;
  height: 0.85rem;
  display: block;
  flex: none;
}
.tree-ops .tiny {
  padding: 0.18rem;
  border-radius: 6px;
}
.tree-ops .tiny svg { width: 0.85rem; height: 0.85rem; display: block; }

.stage {
  min-height: 0;
  min-width: 0;
  overflow: hidden;
  display: flex;
  flex-direction: row;
  align-items: stretch;
}

.sidebar, .repl, .preview {
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: var(--panel);
}

.editor {
  min-width: 0;
  min-height: 0;
  overflow: visible;
  display: flex;
  flex-direction: column;
  background: var(--panel);
}

/* Saved pane widths are preferences: shrink them when the window gets
   narrower so the preview header and its Live control remain on screen. */
.sidebar,
.preview {
  flex: 0 1 auto;
}
.main {
  flex: 1 1 0;
  min-width: 12rem;
  min-height: 0;
  overflow: hidden;
  display: grid;
  grid-template-rows: minmax(0, 1fr) minmax(7.5rem, 13rem);
}

.splitter {
  position: relative;
  z-index: 2;
  flex: 0 0 0.4rem;
  width: 0.4rem;
  cursor: col-resize;
  touch-action: none;
  user-select: none;
  background: transparent;
}
.splitter::after {
  content: "";
  position: absolute;
  inset: 0 -0.35rem;
}
.stage.is-dragging .splitter::before {
  width: 2px;
  background: var(--gold);
}
.stage.is-dragging {
  cursor: col-resize;
  user-select: none;
}
.stage.is-dragging iframe {
  pointer-events: none;
}

@media (min-width: 768px) {
  .stage.is-files-closed > .sidebar,
  .stage.is-files-closed > .splitter-files {
    display: none;
  }
  .stage.is-preview-closed > .preview,
  .stage.is-preview-closed > .splitter-preview {
    display: none;
  }
}
.editor { border-bottom: 1px solid var(--line); }

.pane-head {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  box-sizing: border-box;
  height: 2.5rem;
  min-height: 2.5rem;
  max-height: 2.5rem;
  padding: 0 0.7rem;
  border-bottom: 1px solid var(--line);
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  flex: none;
}
.pane-start,
.pane-end {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  min-width: 0;
}
.pane-start { flex: 1; }
.pane-end { flex: none; margin-left: auto; }
.pane-head .pane-hide {
  padding: 0.18rem;
  color: var(--muted);
}
.pane-head .pane-hide svg {
  width: 0.85rem;
  height: 0.85rem;
}

.pane-rail {
  flex: 0 0 1.65rem;
  width: 1.65rem;
  align-self: stretch;
  border: 0;
  background: var(--panel);
  color: var(--muted);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 0.55rem 0 0;
  cursor: pointer;
}
.pane-rail-files { border-right: 1px solid var(--line); }
.pane-rail-preview { border-left: 1px solid var(--line); }
.pane-rail:hover {
  color: var(--gold);
  background: var(--panel-2);
}
.pane-rail svg { width: 0.95rem; height: 0.95rem; }
.pane-head .ns, .file-path {
  text-transform: none;
  letter-spacing: 0;
  color: var(--text);
  font-family: var(--mono);
  font-size: 0.78rem;
}
.file-path {
  min-width: 0;
  overflow: visible;
}
.tree-tools { display: flex; gap: 0.25rem; }
.tree-tools .sidebar-add {
  width: 1.55rem;
  height: 1.55rem;
  padding: 0.25rem;
  border-radius: 6px;
}
.tree-tools .sidebar-add svg { width: 0.95rem; height: 0.95rem; }

.dot {
  width: 0.4rem; height: 0.4rem; border-radius: 99px;
  background: var(--gold); display: inline-block;
}

.editor-host, .empty-editor, .media-host { flex: 1; min-height: 0; min-width: 0; overflow: hidden; }
.editor-host .cm-editor { height: 100%; min-width: 0; }
.editor-host .cm-scroller { padding-bottom: 2.5rem; }
.editor-tool[aria-pressed="true"] {
  color: var(--gold);
  background: rgba(228, 179, 76, 0.1);
  border-color: var(--gold-dim);
}
.cm-panel.cm-search {
  color-scheme: dark;
  padding: 0.45rem 0.65rem;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  font-family: var(--sans);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.2);
}
.cm-editor .cm-search input {
  min-height: 1.65rem;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--panel);
  color: var(--text);
  padding: 0.2rem 0.4rem;
  outline: none;
}
.cm-editor .cm-search input:focus { border-color: var(--gold-dim); box-shadow: 0 0 0 2px rgba(228, 179, 76, 0.14); }
.cm-editor .cm-search button {
  background-image: none;
  border: 1px solid transparent;
  border-radius: 5px;
  background: transparent;
  color: var(--muted);
  padding: 0.2rem 0.4rem;
}
.cm-editor .cm-search button:hover, .cm-editor .cm-search button:focus-visible {
  background: var(--panel);
  border-color: var(--line);
  color: var(--text);
}
.cm-search label, .cm-search .cm-button { color: var(--muted); }
.cm-searchMatch { background: rgba(228, 179, 76, 0.28); outline: 1px solid rgba(228, 179, 76, 0.5); }
.cm-searchMatch-selected { background: var(--gold); color: var(--ink); }
.media-host {
  overflow: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  gap: 0.55rem;
  box-sizing: border-box;
}
.media-image {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 6px;
  background:
    linear-gradient(45deg, rgba(255,255,255,0.07) 25%, transparent 25%) 0 0 / 12px 12px,
    linear-gradient(45deg, transparent 75%, rgba(255,255,255,0.07) 75%) 6px 6px / 12px 12px;
}
.media-binary { color: var(--muted); text-align: center; }
.cm-tooltip {
  background: var(--panel-2) !important;
  border: 1px solid var(--line) !important;
  color: var(--text);
  font-family: var(--mono);
  font-size: 0.78rem;
  border-radius: 8px;
  box-shadow: var(--shadow);
  z-index: 200;
  pointer-events: auto;
}
#cm-tooltips {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 200;
  overflow: visible;
}
/* Modal above help. Help at 330 used to cover Cancel on narrow previews,
   and those clicks toggled Help instead of closing the dialog. */
.ui-overlay { z-index: 400; }
.cm-tooltip-autocomplete > ul {
  max-height: 16rem;
  background: var(--panel-2);
}
.cm-tooltip-autocomplete li {
  color: var(--text);
}
.cm-tooltip-autocomplete li[aria-selected] {
  background: rgba(228, 179, 76, 0.16);
  color: var(--gold);
}
.cm-completionDetail { color: var(--muted); }
.cm-completionMatchedText { text-decoration: none; color: var(--gold); }
.cm-evalight-doc { min-width: 16rem; max-width: 28rem; }
.cm-evalight-doc-head {
  color: var(--gold);
  padding: 0.45rem 0.65rem 0.15rem;
  font-size: 0.8rem;
}
.cm-evalight-doc-ns {
  color: var(--muted);
  padding: 0 0.65rem 0.15rem;
  font-size: 0.72rem;
}
.cm-evalight-doc pre {
  margin: 0;
  padding: 0.2rem 0.65rem 0.55rem;
  white-space: pre-wrap;
  color: var(--text);
  font-family: var(--mono);
  font-size: 0.78rem;
  line-height: 1.45;
}
.empty-editor, .empty-tree, .empty {
  padding: 1.2rem;
  color: var(--muted);
}
.pill {
  font-size: 0.68rem;
  border: 1px solid var(--gold-dim);
  color: var(--gold);
  border-radius: 99px;
  padding: 0.05rem 0.45rem;
}

.repl-log { flex: 1; overflow: auto; padding: 0.5rem 0.7rem; }
.repl-line { display: grid; grid-template-columns: 1.1rem 1fr; gap: 0.4rem; margin: 0.2rem 0; }
.repl-line pre { margin: 0; white-space: pre-wrap; font-size: 0.8rem; line-height: 1.4; }
.repl-line.is-in { color: var(--gold); }
.repl-line.is-err { color: var(--ember); }
.gutter { color: var(--muted); font-family: var(--mono); font-size: 0.8rem; line-height: 1.4; }
.repl-input {
  display: grid;
  grid-template-columns: 1.1rem 1fr;
  gap: 0.4rem;
  align-items: start;
  padding: 0.45rem 0.7rem 0.6rem;
  border-top: 1px solid var(--line);
}
.repl-input .gutter { display: block; }
.repl-input textarea {
  display: block;
  appearance: none;
  -webkit-appearance: none;
  min-width: 0;
  min-height: 1.4em;
  max-height: 10em;
  resize: none;
  overflow-y: auto;
  background: transparent;
  border: 0;
  outline: none;
  margin: 0;
  padding: 0;
  color: inherit;
  font: 400 0.8rem/1.4 var(--mono);
  field-sizing: content;
}

.preview-frame { position: relative; flex: 1; min-height: 0; min-width: 0; background: var(--paper); overflow: hidden; }
.preview-native {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 1.15rem 1.05rem 1.4rem;
  background: var(--panel-2);
  color: var(--text);
}
.preview-native .eyebrow {
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-size: 0.68rem;
  color: var(--gold);
  margin: 0 0 0.45rem;
}
.preview-native h2 {
  font-family: var(--serif);
  font-weight: 560;
  font-size: 1.35rem;
  margin: 0 0 0.5rem;
}
.preview-native .lede {
  color: var(--muted);
  line-height: 1.45;
  margin: 0 0 1rem;
  font-size: 0.9rem;
}
.preview-native-error {
  margin: 0 0 1rem;
  white-space: pre-wrap;
  font-family: var(--mono);
  font-size: 0.78rem;
  line-height: 1.45;
  color: var(--ember);
}
.preview-capture {
  display: block;
  width: 100%;
  border-radius: 8px;
  border: 1px solid var(--line);
  margin: 0 0 1rem;
  background: #0b0a08;
}
.preview-native-window {
  border: 1px solid var(--line);
  border-radius: 10px;
  min-height: 9rem;
  margin: 0 0 1rem;
  background:
    linear-gradient(180deg, rgba(228, 179, 76, 0.08), transparent 42%),
    #16130f;
  padding: 0.7rem 0.8rem 0.9rem;
}
.preview-native-chrome {
  display: block;
  height: 0.55rem;
  width: 3.2rem;
  border-radius: 999px;
  background: var(--line);
  margin-bottom: 0.75rem;
}
.preview-native-window p {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.45;
}
.preview-native-meta {
  margin: 0;
  display: grid;
  gap: 0.35rem;
  font-size: 0.8rem;
}
.preview-native-meta div {
  display: grid;
  grid-template-columns: 4.5rem 1fr;
  gap: 0.5rem;
}
.preview-native-meta dt { color: var(--muted); margin: 0; }
.preview-native-meta dd { margin: 0; font-family: var(--mono); }
.preview-frame iframe {
  width: 100%;
  height: 100%;
  border: 0;
  min-width: 0;
  display: block;
  background: var(--paper);
}
.preview-banner {
  position: absolute;
  inset: 0;
  z-index: 1;
  padding: 1.25rem 1.1rem;
  background: var(--paper);
  color: var(--ink);
  overflow: auto;
}
.preview-banner p {
  margin: 0 0 0.7rem;
  font-weight: 600;
  color: var(--ink);
}
.preview-banner pre {
  margin: 0;
  white-space: pre-wrap;
  font-family: var(--mono);
  font-size: 0.78rem;
  line-height: 1.45;
  color: var(--ember);
}
.live { display: flex; align-items: center; gap: 0.35rem; text-transform: none; letter-spacing: 0; }
.live.is-disabled { opacity: 0.55; }
.live input:disabled { cursor: default; }
.preview-error { color: var(--ember); text-transform: none; }

.help {
  position: fixed;
  right: 1rem;
  top: 4.2rem;
  width: min(24rem, calc(100vw - 2rem));
  max-height: calc(100dvh - 5.2rem);
  display: flex;
  flex-direction: column;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 1rem 1.1rem 1.15rem;
  box-shadow: var(--shadow);
  z-index: 300;
  pointer-events: auto;
  overflow: hidden;
}
.help-head { display: flex; align-items: flex-start; gap: 0.75rem; padding-right: 2rem; flex: 0 0 auto; }
.help h2 { font-family: var(--serif); margin: 0; font-size: 1.2rem; flex: 1; min-width: 0; }
.help-body {
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
}
.help p { color: var(--muted); line-height: 1.5; }
.help-licenses {
  color: var(--muted);
  font-size: 0.85rem;
  text-decoration: underline;
  text-underline-offset: 0.16em;
}
.help-licenses:hover { color: var(--gold); }
.shortcuts { list-style: none; padding: 0; }
.shortcuts li { display: flex; gap: 0.6rem; align-items: center; margin: 0.45rem 0; }
.keys { display: flex; gap: 0.2rem; }
kbd {
  font-family: var(--mono);
  font-size: 0.72rem;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 4px;
  padding: 0.05rem 0.35rem;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(8, 6, 4, 0.55);
  display: grid;
  place-items: center;
  z-index: 6;
}
.modal {
  width: min(28rem, calc(100vw - 2rem));
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 1.1rem;
  box-shadow: var(--shadow);
}
.modal h2 { font-family: var(--serif); margin: 0 0 0.4rem; }
.modal input {
  width: 100%;
  margin: 0.6rem 0 1rem;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.55rem 0.7rem;
}
.modal-actions { display: flex; justify-content: flex-end; gap: 0.4rem; }

.kit-list {
  list-style: none;
  margin: 0.8rem 0 0;
  padding: 0;
  display: grid;
  gap: 0.55rem;
}
.kit-list li {
  display: flex;
  align-items: flex-start;
  gap: 0.8rem;
  padding: 0.55rem 0;
  border-top: 1px solid var(--line);
}
.kit-list li:first-child { border-top: 0; padding-top: 0; }
.kit-title { font-weight: 600; }
.kit-list .muted { margin: 0.15rem 0 0; font-size: 0.8rem; }
.kit-list .ui-btn { flex: none; margin-left: auto; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 1.2rem;
  transform: translateX(-50%);
  background: var(--panel-2);
  border: 1px solid var(--line);
  padding: 0.5rem 0.9rem;
  border-radius: 999px;
  z-index: 410;
  pointer-events: auto;
}
.toast.err { border-color: var(--ember); color: #ffd1c2; }

.boot {
  height: 100%;
  display: grid;
  place-content: center;
  text-align: center;
  gap: 0.8rem;
}
.boot svg { width: 2.4rem; height: 2.4rem; color: var(--gold); margin: 0 auto; }

.mobile-tabs { display: none; border-top: 1px solid var(--line); }
.mobile-tabs button {
  flex: 1;
  background: var(--panel);
  border: 0;
  padding: 0.7rem;
  color: var(--muted);
}
.mobile-tabs button.is-active { color: var(--gold); }

.muted { color: var(--muted); }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 767px) {
  .splitter,
  .pane-hide,
  .pane-rail {
    display: none !important;
  }
  .sidebar,
  .preview {
    width: auto !important;
    flex-basis: auto !important;
    flex: 1 1 auto;
  }
  .main { min-width: 0; flex: 1 1 auto; }
  .sidebar, .main, .preview { display: none; }
  .tab-files .sidebar,
  .tab-editor .main,
  .tab-repl .main,
  .tab-preview .preview { display: flex; }
  .tab-editor .repl, .tab-repl .editor { display: none; }
  .tab-editor .main, .tab-repl .main { display: grid; grid-template-rows: 1fr; }
  .tab-repl .main { grid-template-rows: 1fr; }
  .mobile-tabs { display: flex; }

  .top { flex-wrap: wrap; gap: 0.6rem; }
  .brand { flex: 1; }
  .project-context { max-width: 48%; }
  .project { display: block; max-width: 100%; }
  .project-trigger { min-width: 7rem; }
  .actions { width: 100%; justify-content: space-between; gap: 8px; }
  .toolbar-utilities { margin-left: auto; }
  .toolbar-group + .toolbar-utilities { padding-left: 8px; }
  .project-actions .ui-popover-panel { left: auto; right: 0; }
  .actions .run-btn { padding: 0 12px; }
  .history-pop .ui-popover-panel {
    position: fixed; top: calc(100% + 8px); left: 12px; right: 12px;
    min-width: 0; max-width: none;
  }
}

@media (max-width: 380px) {
  .brand > svg { display: none; }
  .brand { gap: 8px; }
  .project-trigger { min-width: 0; }
}



.project-menu-content { display: contents; }

.help-popover-panel { padding: 0; border: 0; background: transparent; box-shadow: none; }
.help-popover-panel .help { position: relative; top: auto; right: auto; max-height: calc(100dvh - 6rem); }
.help-head { padding-right: 0; }

/* Popover positioning and viewport bounds are shared by ui.popover. */
.beta-pop .ui-popover-panel { min-width: min(16rem, calc(100vw - 24px)); max-width: min(20rem, calc(100vw - 24px)); }
.help-popover-panel { width: min(24rem, calc(100vw - 24px)); max-width: calc(100vw - 24px); }
.help-popover-panel .help { width: 100%; max-height: inherit; box-sizing: border-box; }

.help-shortcuts {
  margin: 1rem 0;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
}
.help-shortcuts h3 { margin: 0 0 .85rem; color: var(--text); font-size: .84rem; font-weight: 650; }
.help-shortcuts .shortcuts { margin: 0; }
.help-shortcuts .shortcuts li { align-items: flex-start; margin: .8rem 0 0; font-size: .8rem; line-height: 1.5; }
.help-shortcuts .shortcuts li:first-child { margin-top: 0; }
.help-shortcuts .keys { flex: 0 0 5.6rem; padding-top: 1px; }
@media (max-width: 380px) {
  .help-shortcuts { padding: .8rem; }
  .help-shortcuts .shortcuts li { flex-direction: column; gap: .3rem; }
  .help-shortcuts .keys { flex-basis: auto; }
}

/* Keep utility labels while the desktop toolbar has room for them. */
.toolbar-label { display: none; }
@media (min-width: 1000px) {
  .actions .toolbar-tool { width: auto; padding: 0 10px; color: var(--text); font-size: .85rem; }
  .toolbar-label { display: inline; }
}
.sidebar-add svg { width: 18px; height: 18px; }
