/* WebVM Workbench — dark-indigo design system (panes-everywhere layout). */

:root {
  --bg: #0a0a0c;
  --panel: #0d0d10;
  --well: #101014;
  --modal: #131318;
  --accent: #6e6af0;
  --accent-soft: rgba(110, 106, 240, 0.14);
  --nav-active: #c7c5fa;
  --link: #b3b0f7;
  --green: #46c98a;
  --green-bright: #5fd79a;
  --amber: #e0a84a;
  --coral: #ef6f64;

  --text: #f3f3f5;
  --t-body: rgba(243, 243, 245, 0.8);
  --t-2: rgba(243, 243, 245, 0.6);
  /* t-muted/t-faint carry real meaning at small sizes (shortcut hints, pane-count
     badges, section labels) — kept at or above ~4.5:1 against --bg so they clear
     WCAG AA for normal text, not just "quiet-looking". */
  --t-muted: rgba(243, 243, 245, 0.58);
  --t-faint: rgba(243, 243, 245, 0.48);

  --hair: rgba(255, 255, 255, 0.07);
  --hair-soft: rgba(255, 255, 255, 0.045);

  --sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, 'SF Mono', SFMono-Regular, Menlo, Monaco, 'Cascadia Code', monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--t-body);
  font-family: var(--sans);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

button { font-family: inherit; color: inherit; cursor: pointer; border: none; background: none; }
input, textarea, select { font-family: inherit; color: var(--text); }
code { font-family: var(--mono); font-size: 0.85em; color: var(--link); }

/* ── App shell ── */
.app { display: flex; flex-direction: column; height: 100dvh; overflow: hidden; }

.mobile-keybar { display: none; }

/* ── Buttons ── */
.btn {
  padding: 5px 11px;
  border-radius: 6px;
  font-size: 12.5px;
  color: var(--t-body);
  background: var(--well);
  border: 1px solid var(--hair);
  transition: background 0.12s, border-color 0.12s;
}
.btn:hover { background: #16161c; border-color: rgba(255, 255, 255, 0.12); }
.btn-accent { background: var(--accent); color: #fff; border-color: transparent; }
.btn-accent:hover { background: #7a76f2; }
.btn-danger { color: var(--coral); border-color: rgba(239, 111, 100, 0.25); }
.btn-danger:hover { background: rgba(239, 111, 100, 0.1); }

/* ── Top bar ── */
.topbar {
  height: 44px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 12px;
  background: var(--panel);
  border-bottom: 1px solid var(--hair);
}
.tb-left { display: flex; align-items: center; gap: 9px; flex-shrink: 0; }
.tb-brand { display: flex; }
.tb-sandbox {
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--t-body);
  padding: 2px 5px;
  border-radius: 5px;
  outline: none;
  white-space: nowrap;
  cursor: text;
}
.tb-sandbox:hover { background: var(--hair-soft); }
.tb-sandbox.editing { background: var(--well); box-shadow: inset 0 0 0 1px rgba(110, 106, 240, 0.5); }

.tb-center { flex: 1; min-width: 0; display: flex; align-items: center; overflow: hidden; }
.tb-right { display: flex; align-items: center; gap: 20px; flex-shrink: 0; }

.tb-status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
  color: var(--t-muted);
  font-size: 11px;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.tb-status[hidden] { display: none; }
.tb-status-item { display: inline-flex; align-items: center; gap: 5px; }
.tb-status-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--green-bright);
  opacity: 0.9;
}
.tb-status-dot.memory-only { background: var(--amber); opacity: 0.85; }

/* Workspace tabs (in the top bar) */
.ws-tabs {
  display: flex; align-items: center; gap: 2px; min-width: 0;
  overflow-x: auto; scrollbar-width: none;
  border-radius: 8px; transition: box-shadow 140ms ease, background 140ms ease;
}
.ws-tabs::-webkit-scrollbar { display: none; }
/* Drop target while dragging a pane header onto the strip. */
.ws-tabs.strip-drop {
  background: var(--accent-soft);
  box-shadow: inset -3px 0 0 0 var(--accent), 0 0 0 1px rgba(110, 106, 240, 0.35);
}
.ws-tab {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 9px;
  border-radius: 6px;
  font-size: 12.5px;
  color: var(--t-muted);
  cursor: pointer;
  white-space: nowrap;
  user-select: none;
}
.ws-tab:hover { background: var(--hair-soft); color: var(--t-body); }
.ws-tab:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.ws-tab.active { background: var(--well); color: var(--t-body); }
.ws-tab.dragging { opacity: .45; }
.ws-tab-icon { display: flex; color: var(--t-faint); flex-shrink: 0; }
.ws-tab.active .ws-tab-icon { color: var(--nav-active); }
.ws-tab:hover .ws-tab-icon { color: var(--t-muted); }
.ws-tab-label { outline: none; max-width: 160px; overflow: hidden; text-overflow: ellipsis; }
.ws-tab-label.editing {
  color: var(--text); text-overflow: clip; cursor: text;
  box-shadow: 0 0 0 1px rgba(110, 106, 240, 0.5); border-radius: 3px; padding: 0 3px;
}
.ws-tab-badge {
  font-size: 9.5px; font-weight: 600; letter-spacing: .02em;
  color: var(--t-faint); background: var(--hair-soft);
  padding: 1px 4px; border-radius: 4px; flex-shrink: 0;
}
.ws-tab.active .ws-tab-badge { color: var(--t-2); background: var(--hair); }
.ws-tab-close { font-size: 14px; line-height: 1; color: var(--t-faint); padding: 0 1px; }
.ws-tab-close:hover { color: var(--coral); }
.ws-tab-add {
  padding: 4px 8px; font-size: 15px; line-height: 1;
  color: var(--t-muted); border-radius: 6px;
}
.ws-tab-add:hover { background: var(--hair-soft); color: var(--t-body); }

/* Running port chips */
.tb-ports { display: flex; align-items: center; gap: 6px; }
.port-chip {
  display: flex; align-items: center; gap: 6px;
  padding: 3px 9px; border-radius: 20px;
  font-family: var(--mono); font-size: 12px; color: var(--t-2);
  background: var(--well); border: 1px solid var(--hair);
}
.port-chip:hover { color: var(--text); border-color: rgba(110, 106, 240, 0.4); }
.port-chip-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--green-bright); box-shadow: 0 0 5px rgba(95, 215, 154, 0.5);
}
.port-chip-more { font-family: var(--mono); font-size: 11.5px; color: var(--t-muted); padding: 0 2px; }

/* Mount chip / popover */
.tb-mount { display: flex; align-items: center; }
.mount-btn {
  display: flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; border-radius: 6px; color: var(--t-muted);
}
.mount-btn:hover { background: var(--hair-soft); color: var(--t-body); }
.mount-chip {
  display: flex; align-items: center; gap: 7px;
  padding: 4px 9px; border-radius: 6px;
  font-size: 12px; color: var(--t-2);
  background: var(--well); border: 1px solid var(--hair);
}
.mount-chip:hover { color: var(--text); border-color: rgba(255, 255, 255, 0.12); }
.mount-chip-icon { display: flex; color: var(--t-muted); }
.mount-chip-name { font-family: var(--mono); max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mount-dot { width: 7px; height: 7px; border-radius: 50%; }
.mount-dot.clean { background: var(--green); }
.mount-dot.sync { background: var(--amber); }
.mount-dot.err { background: var(--coral); }

.tb-cmdk {
  display: flex; align-items: center; padding: 4px 8px; border-radius: 6px;
  background: var(--well); border: 1px solid var(--hair);
}
.tb-cmdk:hover { border-color: rgba(255, 255, 255, 0.12); }
.tb-cmdk-key { font-size: 11px; font-weight: 600; color: var(--t-2); letter-spacing: 0.03em; }
.tb-share { padding: 6px 14px; border-radius: 7px; }

/* Mobile-only overflow trigger — see .tb-mobile-more rules in the mobile
   media query below for where it actually shows. */
.tb-mobile-more {
  display: none; align-items: center; justify-content: center;
  width: 30px; height: 30px; border-radius: 7px; color: var(--t-body); flex-shrink: 0;
}
.tb-mobile-more:hover { background: var(--hair-soft); }
.tb-mobile-more:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

/* ── Popover (mount) ── */
.popover {
  position: fixed;
  z-index: 9500;
  min-width: 240px;
  background: var(--modal);
  border: 1px solid var(--hair);
  border-radius: 10px;
  box-shadow: 0 20px 48px rgba(0, 0, 0, 0.5);
  padding: 6px;
}
.mount-pop-item { padding: 8px 8px 10px; border-bottom: 1px solid var(--hair-soft); }
.mount-pop-item:last-of-type { border-bottom: none; }
.mount-pop-path { font-family: var(--mono); font-size: 12px; color: var(--t-body); word-break: break-all; }
.mount-pop-state { font-size: 11.5px; color: var(--t-muted); margin-top: 3px; }
.mount-pop-actions { display: flex; gap: 6px; margin-top: 8px; }
.popover-btn {
  padding: 4px 9px; border-radius: 6px; font-size: 12px;
  color: var(--t-body); background: var(--well); border: 1px solid var(--hair);
}
.popover-btn:hover { background: #16161c; color: var(--text); }
.mount-pop-add { width: 100%; margin-top: 6px; text-align: center; }

/* ── Workspace / pane area ── */
.workspace {
  flex: 1;
  min-height: 0;
  position: relative;
  display: flex;
  flex-direction: column;
  padding: 10px;
  background: var(--bg);
}
.tab-bodies { flex: 1; min-height: 0; position: relative; }
.tab-body { width: 100%; height: 100%; display: flex; position: relative; }
.tab-body > .pane, .tab-body > .split { flex: 1 1 0; min-width: 0; min-height: 0; }
/* New-tab content fades in the same way panes spawn. */
.tab-body.tab-enter { animation: tabEnter 260ms cubic-bezier(.22, .9, .26, 1); }
@keyframes tabEnter { from { opacity: 0; transform: scale(.99); } to { opacity: 1; transform: none; } }

.ghost-hint {
  flex-shrink: 0;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11.5px;
  color: var(--t-faint);
  letter-spacing: 0.01em;
}

/* Mobile focused-pane-mode switcher — hidden on desktop (the split tree
   renders literally there); see the mobile media query for its real layout. */
.mobile-pane-switcher { display: none; }

/* ── Split panes — 6px gutters owned by dividers ── */
.split { display: flex; width: 100%; height: 100%; min-width: 0; min-height: 0; }
.split.row { flex-direction: row; }
.split.col { flex-direction: column; }
.split.animating > .pane,
.split.animating > .split { transition: flex-grow 180ms cubic-bezier(.22, .9, .26, 1); }

.pane {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background: #101014;
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 8px;
  transition: opacity 200ms cubic-bezier(.22, .9, .26, 1),
              transform 200ms cubic-bezier(.22, .9, .26, 1),
              box-shadow 160ms ease, border-color 160ms ease;
}
.pane.focused {
  border-color: rgba(110, 106, 240, 0.55);
  box-shadow: 0 0 0 3px rgba(110, 106, 240, 0.10);
}
.pane.spawning { opacity: 0; transform: scale(.965); }
.pane.closing { opacity: 0; transform: scale(.97); }

/* Per-pane header */
.pane-header {
  flex: 0 0 26px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 8px;
  background: rgba(255, 255, 255, 0.025);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  user-select: none;
}
.pane-header-left { display: flex; align-items: center; gap: 6px; min-width: 0; }
.pane-glyph { display: flex; color: rgba(255, 255, 255, 0.35); }
.pane-title {
  font-size: 11.5px; font-weight: 500;
  color: rgba(255, 255, 255, 0.55);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  outline: none;
}
.pane.focused .pane-title { color: rgba(255, 255, 255, 0.8); }
.pane-title.editing { color: var(--text); text-overflow: clip; box-shadow: 0 0 0 1px rgba(110, 106, 240, 0.5); border-radius: 3px; padding: 0 3px; }
.pane-zoom-pill {
  font-size: 9.5px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase;
  color: rgba(110, 106, 240, 0.9);
  background: rgba(110, 106, 240, 0.14);
  padding: 1px 5px; border-radius: 4px;
}
.pane-header-right { display: flex; align-items: center; gap: 2px; }
.pane-close, .pane-menu {
  display: flex; align-items: center; justify-content: center;
  width: 18px; height: 18px; border-radius: 4px;
  color: rgba(255, 255, 255, 0.55);
  transition: opacity 120ms ease, background 120ms ease, color 120ms ease;
}
/* Header controls stay hidden on idle unfocused panes but are ALWAYS visible on
   the focused pane and on hover — and are never suppressed mid-drag — so the
   close/menu affordances are reliably reachable. */
.pane-menu, .pane-close { opacity: 0; }
.pane-header:hover .pane-menu, .pane-header:hover .pane-close,
.pane.focused .pane-menu, .pane.focused .pane-close { opacity: .7; }
.pane-menu:hover { opacity: 1; color: var(--text); background: rgba(255, 255, 255, 0.08); }
.pane-close:hover { opacity: 1; color: var(--coral); background: rgba(239, 111, 100, 0.12); }

.pane-body { flex: 1; min-height: 0; min-width: 0; width: 100%; display: flex; }
.pane-body > * { flex: 1; min-width: 0; min-height: 0; }
/* iTerm-style: dim unfocused pane content */
.pane:not(.focused) .pane-body { opacity: .72; }
.pane-body { transition: opacity 160ms ease; }

/* Zoom (FLIP) */
.pane.zoom-anim {
  transition: left 240ms cubic-bezier(.22, .9, .26, 1),
              top 240ms cubic-bezier(.22, .9, .26, 1),
              width 240ms cubic-bezier(.22, .9, .26, 1),
              height 240ms cubic-bezier(.22, .9, .26, 1);
}
.pane.zoomed { box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5); }
.tab-body.has-zoom > .split,
.tab-body.has-zoom > .pane:not(.zoomed) { opacity: .3; transition: opacity 200ms ease; }

/* Dividers */
.divider { flex: 0 0 6px; position: relative; z-index: 2; }
.divider.row { cursor: col-resize; }
.divider.col { cursor: row-resize; }
.divider::before {
  content: ''; position: absolute; background: rgba(110, 106, 240, 0.5);
  opacity: 0; transition: opacity 120ms ease; border-radius: 2px;
}
.divider.row::before { top: 12%; bottom: 12%; left: 2px; width: 2px; }
.divider.col::before { left: 12%; right: 12%; top: 2px; height: 2px; }
.divider:hover::before, .divider.dragging::before { opacity: 1; }
.divider::after { content: ''; position: absolute; z-index: -1; }
.divider.row::after { top: 0; bottom: 0; left: -4px; right: -4px; }
.divider.col::after { left: 0; right: 0; top: -4px; bottom: -4px; }

/* Divider hover "+" — insert a pane at the divider midpoint */
.divider-plus {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%) scale(.6);
  z-index: 5; display: flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; border-radius: 50%;
  color: var(--t-2); background: var(--modal);
  border: 1px solid var(--hair); box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
  opacity: 0; pointer-events: none;
  transition: opacity 120ms ease, transform 120ms cubic-bezier(.22, .9, .26, 1),
              color 120ms ease, border-color 120ms ease, background 120ms ease;
}
.divider.show-plus .divider-plus { opacity: 1; pointer-events: auto; transform: translate(-50%, -50%) scale(1); }
.divider-plus:hover { color: #fff; background: var(--accent); border-color: transparent; }

/* Tab-body edge strips — dock a pane to a whole outer edge */
.edge-layer { position: absolute; inset: 0; z-index: 4; pointer-events: none; }
.edge-strip {
  position: absolute; z-index: 4; padding: 0;
  background: var(--accent); border-radius: 3px;
  opacity: 0; pointer-events: none;
  transition: opacity 120ms ease, box-shadow 120ms ease;
}
.edge-strip.edge-left, .edge-strip.edge-right { top: 12px; bottom: 12px; width: 4px; }
.edge-strip.edge-top, .edge-strip.edge-bottom { left: 12px; right: 12px; height: 4px; }
.edge-strip.edge-left { left: 0; }
.edge-strip.edge-right { right: 0; }
.edge-strip.edge-top { top: 0; }
.edge-strip.edge-bottom { bottom: 0; }
.edge-strip.near { opacity: .55; pointer-events: auto; cursor: pointer; }
.edge-strip.edge-left.near, .edge-strip.edge-right.near { width: 8px; }
.edge-strip.edge-top.near, .edge-strip.edge-bottom.near { height: 8px; }
.edge-strip.near:hover { opacity: 1; box-shadow: 0 0 12px rgba(110, 106, 240, 0.6); }

/* Drag-to-rearrange ghost + drop overlay */
.pane-ghost {
  position: fixed; z-index: 200; pointer-events: none;
  transform: translate(10px, 10px);
  padding: 4px 10px; border-radius: 7px;
  font-size: 11.5px; font-weight: 500; color: rgba(255, 255, 255, 0.85);
  background: rgba(30, 30, 38, 0.95); border: 1px solid rgba(110, 106, 240, 0.5);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}
.pane.dragging { opacity: .5; }
.drop-overlay { position: absolute; z-index: 60; pointer-events: none; }
.drop-zone {
  position: absolute;
  background: rgba(84, 214, 168, 0.20);
  border: 2px dashed rgba(96, 232, 184, 0.95);
  box-shadow: inset 0 0 0 1px rgba(96, 232, 184, 0.25);
  border-radius: 6px;
  transition: top 120ms ease, right 120ms ease, bottom 120ms ease, left 120ms ease;
}

/* While a pane/tab drag is in flight, suppress the focused-pane ring so it can't
   be mistaken for a second drop target — the dashed teal drop zone is the only
   drop indicator that should read during a drag. */
body.panes-dragging .pane.focused {
  border-color: rgba(255, 255, 255, 0.06);
  box-shadow: none;
}

/* ── Pane content: terminal ── */
.pane-terminal { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.pane-hint {
  flex-shrink: 0;
  margin: 6px 6px 0;
  padding: 7px 10px;
  border-radius: 7px;
  background: rgba(224, 168, 74, 0.08);
  border: 1px solid rgba(224, 168, 74, 0.2);
  color: var(--amber);
  font-size: 12px;
}
.pane-term-mount { flex: 1; min-height: 0; padding: 6px; }
.pane-term-mount .xterm { height: 100%; }
.term-scroll-latest { display: none; }

/* ── Pane content: embed ── */
.pane-embed { display: flex; height: 100%; min-height: 0; background: var(--well); }
.pane-embed-frame { flex: 1; width: 100%; height: 100%; border: 0; }

/* ── Pane content: files ── */
.pane-files { display: flex; flex-direction: row; height: 100%; min-height: 0; background: var(--well); }
.files-tree {
  width: 220px; flex-shrink: 0; overflow: auto;
  background: var(--panel); border-right: 1px solid var(--hair); padding: 8px 0;
}
.files-tree-inner { min-width: max-content; }
.files-divider { flex: 0 0 4px; cursor: col-resize; }
.files-divider:hover { background: var(--accent-soft); }
.file-row {
  display: flex; align-items: center; gap: 4px;
  padding: 3px 8px; font-family: var(--mono); font-size: 12.5px;
  color: var(--t-2); cursor: pointer; white-space: nowrap;
}
.file-row:hover { background: var(--hair-soft); color: var(--t-body); }
.file-row.selected { background: var(--accent-soft); color: var(--nav-active); }
.file-row.dir { color: var(--t-body); }
.file-toggle { width: 12px; color: var(--t-faint); font-size: 10px; }
.files-viewer { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.files-viewer-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 12px; border-bottom: 1px solid var(--hair);
}
.files-path { font-family: var(--mono); font-size: 12px; color: var(--t-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.files-editor {
  flex: 1; resize: none; border: none; outline: none;
  background: var(--bg); padding: 12px;
  font-family: var(--mono); font-size: 12.5px; line-height: 1.5; color: var(--text);
}

/* ── Pane content: preview ── */
.pane-preview { display: flex; flex-direction: column; height: 100%; min-height: 0; background: var(--well); }
.pv-bar { flex-shrink: 0; display: flex; align-items: center; gap: 6px; padding: 6px 8px; border-bottom: 1px solid var(--hair); }
.pv-select {
  flex: 1; min-width: 0; padding: 5px 8px; border-radius: 6px;
  background: var(--panel); border: 1px solid var(--hair);
  font-family: var(--mono); font-size: 12px; color: var(--t-body);
}
.pv-select:focus { outline: none; border-color: rgba(110, 106, 240, 0.5); }
.pv-btn {
  display: flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; border-radius: 6px; color: var(--t-muted);
  border: 1px solid var(--hair); background: var(--panel);
}
.pv-btn:hover { color: var(--t-body); border-color: rgba(255, 255, 255, 0.12); }
.pv-frame { flex: 1; min-height: 0; background: #fff; }
.pv-iframe { width: 100%; height: 100%; border: none; }
.pv-empty {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 6px; text-align: center; padding: 20px;
}
.empty-title { font-size: 15px; color: var(--t-body); }
.empty-sub { font-size: 12.5px; color: var(--t-muted); max-width: 380px; }

/* ── Shared form utilities (used by modals, terminals, boot-runner) ──
   The Settings pane now injects its own scoped styles (see settings-view.ts). */
.settings-label { display: block; font-size: 12px; color: var(--t-muted); margin-bottom: 6px; }
.settings-input {
  width: 100%; min-width: 0; padding: 8px 11px; border-radius: 7px;
  background: var(--well); border: 1px solid var(--hair); font-size: 13px; outline: none;
}
.settings-input:focus { border-color: rgba(110, 106, 240, 0.5); }
.settings-static { font-size: 13px; color: var(--t-body); }
.settings-note { font-size: 12px; color: var(--t-muted); margin: 4px 0 14px; line-height: 1.5; }

.btn-ghost { background: transparent; }
.btn-ghost:hover { background: var(--hair-soft); }

/* ── toasts ── */
.toast-host {
  position: fixed;
  right: 14px;
  bottom: 14px;
  z-index: 12000;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  max-width: min(380px, calc(100vw - 28px));
  min-height: 30px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 7px 6px 11px;
  border-radius: 999px;
  background: rgba(17, 17, 22, 0.82);
  border: 1px solid rgba(255, 255, 255, 0.09);
  color: var(--t-body);
  box-shadow: 0 10px 34px rgba(0, 0, 0, 0.38);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  opacity: 0;
  transform: translateY(7px) scale(0.98);
  transition: opacity 160ms ease, transform 180ms cubic-bezier(.22,.9,.26,1), border-color 120ms ease;
}
.toast.show { opacity: 1; transform: translateY(0) scale(1); }
.toast.leaving { opacity: 0; transform: translateY(5px) scale(0.98); }
.toast:hover { border-color: rgba(110, 106, 240, 0.28); }
.toast-text {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  line-height: 1.2;
}
.toast-action {
  flex-shrink: 0;
  padding: 3px 7px;
  border-radius: 999px;
  color: var(--nav-active);
  background: rgba(110, 106, 240, 0.16);
  font-size: 11.5px;
  line-height: 1.1;
}
.toast-action:hover { background: rgba(110, 106, 240, 0.24); color: var(--text); }
.toast-x {
  flex-shrink: 0;
  width: 19px;
  height: 19px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  color: var(--t-faint);
  font-size: 15px;
  line-height: 1;
}
.toast-x:hover { background: rgba(255, 255, 255, 0.06); color: var(--t-body); }

/* ── Command palette ── */
.palette-overlay {
  position: fixed; inset: 0; z-index: 9200;
  background: rgba(0, 0, 0, 0.45);
  display: flex; justify-content: center; align-items: flex-start;
  padding-top: 12vh;
}
.palette {
  width: 560px; max-width: calc(100vw - 32px); max-height: 64vh;
  display: flex; flex-direction: column;
  background: var(--modal); border: 1px solid var(--hair);
  border-radius: 12px; box-shadow: 0 24px 70px rgba(0, 0, 0, 0.55);
  overflow: hidden;
}
.palette-input {
  padding: 15px 18px; font-size: 15px; color: var(--text);
  background: transparent; border: none; outline: none;
  border-bottom: 1px solid var(--hair);
}
.palette-input::placeholder { color: var(--t-faint); }
.palette-list { flex: 1; min-height: 0; overflow-y: auto; padding: 6px; }
.palette-empty { padding: 20px; text-align: center; font-size: 13px; color: var(--t-muted); }
.palette-section {
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.09em;
  color: var(--t-faint); padding: 8px 10px 4px;
}
.palette-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 8px 10px; border-radius: 7px; text-align: left; color: var(--t-body);
}
.palette-item.selected { background: var(--accent-soft); }
.palette-item:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.palette-icon { display: flex; color: var(--t-muted); flex-shrink: 0; }
.palette-item.selected .palette-icon { color: var(--nav-active); }
.palette-label { flex: 1; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.palette-item.selected .palette-label { color: var(--text); }
.palette-hint {
  font-size: 11px; color: var(--t-faint); font-family: var(--mono);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 180px;
}
.palette-footer {
  flex-shrink: 0; padding: 8px 16px; border-top: 1px solid var(--hair);
  font-size: 10.5px; color: var(--t-faint);
}

/* ── Context menu ── */
.ctx-menu {
  position: fixed; z-index: 9600; min-width: 200px;
  background: var(--modal); border: 1px solid var(--hair);
  border-radius: 10px; box-shadow: 0 18px 48px rgba(0, 0, 0, 0.55);
  padding: 5px;
}
.ctx-item-wrap { position: relative; }
.ctx-item {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  width: 100%; padding: 6px 9px; border-radius: 6px;
  font-size: 12.5px; color: var(--t-body); text-align: left;
}
.ctx-item:hover, .ctx-item:focus-visible { background: var(--accent-soft); color: var(--text); }
.ctx-item:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.ctx-label { display: flex; align-items: center; gap: 8px; min-width: 0; }
.ctx-icon { display: flex; color: var(--t-muted); }
.ctx-item:hover .ctx-icon, .ctx-item:focus-visible .ctx-icon { color: var(--nav-active); }
.ctx-shortcut { font-size: 11px; color: var(--t-faint); font-family: var(--mono); }
.ctx-sep { height: 1px; background: var(--hair); margin: 4px 6px; }
.ctx-submenu {
  position: absolute; top: -5px; min-width: 180px;
  background: var(--modal); border: 1px solid var(--hair);
  border-radius: 10px; box-shadow: 0 18px 48px rgba(0, 0, 0, 0.55); padding: 5px;
}

/* ── Modals ── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex; align-items: center; justify-content: center; z-index: 9000;
}
.modal {
  width: 460px; max-width: calc(100vw - 32px);
  background: var(--modal); border: 1px solid var(--hair);
  border-radius: 12px; box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5); overflow: hidden;
}
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; border-bottom: 1px solid var(--hair);
}
.modal-title { font-size: 14px; color: var(--text); font-weight: 600; }
.modal-x { font-size: 18px; color: var(--t-muted); line-height: 1; }
.modal-x:hover { color: var(--text); }
.modal-tabs { display: flex; gap: 4px; padding: 12px 16px 0; }
.modal-tab { padding: 6px 12px; border-radius: 7px; font-size: 12.5px; color: var(--t-muted); }
.modal-tab.active { background: var(--accent-soft); color: var(--nav-active); }
.modal-pane { padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.share-row { display: flex; gap: 8px; }
.share-row .settings-input { flex: 1; }

/* Export & share: every option (Recreate from repository / Open WebVM / Share
   snapshot) is an evenly-weighted card — no single link should read as more
   "the" action than the others just because it happens to render first. */
.share-option {
  display: flex; flex-direction: column; gap: 8px;
  padding: 12px 14px; border-radius: 10px;
  background: var(--well); border: 1px solid var(--hair);
}
.share-option + .share-option { margin-top: 10px; }
.share-option-title { font-size: 13px; font-weight: 600; color: var(--text); }
.share-option-desc { font-size: 12px; color: var(--t-2); line-height: 1.5; }
.share-secondary-actions { display: flex; gap: 8px; }

/* ── Linkable envs: flight-plan interstitial ── */
.modal.flight-plan { width: 520px; }
.fp-plan {
  display: flex; flex-direction: column; gap: 6px;
  padding: 10px 12px; border-radius: 8px; background: var(--well); border: 1px solid var(--hair);
  font-family: var(--mono); font-size: 12.5px;
}
.fp-plan-row { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.fp-plan-marker { color: var(--accent); flex-shrink: 0; }
.fp-plan-label { color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fp-plan-detail { color: var(--t-faint); font-size: 11.5px; flex-shrink: 0; }
.fp-plan-row.from-link .fp-plan-label { color: var(--nav-active); }
.fp-plan-actions { display: flex; gap: 8px; justify-content: flex-end; }

/* ── Linkable envs: chromeless embed mode (?embed=1) ── */
body.embed .topbar { display: none; }

/* Templates tab rows */
.template-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 12px; border-radius: 8px; background: var(--well); border: 1px solid var(--hair);
}
.template-info { min-width: 0; }
.template-name { font-size: 13px; color: var(--text); font-weight: 500; }
.template-desc { font-size: 12px; color: var(--t-2); margin-top: 2px; }
.template-path { font-family: var(--mono); font-size: 11.5px; color: var(--t-faint); margin-top: 4px; }
.template-use { flex-shrink: 0; }

/* ── GitHub repo picker (import modal) ── */
.github-repo-list {
  display: flex; flex-direction: column; gap: 4px;
  max-height: 320px; overflow-y: auto;
}
.github-repo-row {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
  width: 100%; text-align: left; padding: 8px 10px;
  border-radius: 7px; border: 1px solid transparent; background: transparent;
  color: var(--text); cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease;
}
.github-repo-row:hover { background: var(--well); border-color: var(--hair); }
.github-repo-name { font-family: var(--mono); font-size: 12.5px; font-weight: 500; }
.github-repo-desc {
  font-size: 11.5px; color: var(--t-2);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%;
}

/* Boot skeleton styles are INLINED in webvm.html <head> so the first frame
   paints with zero network dependencies (see .boot-shell there). */

/* ── Error banner ── */
.error-banner {
  position: fixed; top: 12px; left: 50%; transform: translate(-50%, -20px); z-index: 11000;
  padding: 9px 16px; border-radius: 8px; font-size: 12.5px;
  background: rgba(239, 111, 100, 0.14); border: 1px solid rgba(239, 111, 100, 0.35); color: var(--coral);
  opacity: 0; pointer-events: none; transition: opacity 0.2s, transform 0.2s;
}
.error-banner.show { opacity: 1; transform: translate(-50%, 0); }
.error-banner.ok { background: rgba(70, 201, 138, 0.14); border-color: rgba(70, 201, 138, 0.35); color: var(--green-bright); }

/* ── Mobile terminal surface ── */
@media (max-width: 820px), (hover: none) and (pointer: coarse) {
  :root {
    --mobile-keybar-height: 48px;
    --mobile-keybar-safe: env(safe-area-inset-bottom, 0px);
    --mobile-dock-height: calc(var(--mobile-keybar-height) + var(--mobile-keybar-safe));
  }
  body.software-keyboard-open { --mobile-keybar-safe: 0px; }
  html, body { overscroll-behavior: none; touch-action: manipulation; }
  body { position: fixed; inset: 0; overflow: hidden; }
  .app {
    position: fixed;
    top: var(--visual-viewport-top, 0px);
    left: 0;
    width: 100%;
    height: calc(var(--visual-viewport-height, 100dvh) - env(keyboard-inset-height, 0px));
    padding-bottom: var(--mobile-dock-height);
  }
  .topbar {
    height: 38px;
    gap: 8px;
    padding: env(safe-area-inset-top, 0px) 8px 0;
    min-height: calc(38px + env(safe-area-inset-top, 0px));
  }
  body.software-keyboard-open .topbar { display: none; }
  .tb-brand, .tb-status-slot, .tb-ports, .tb-mount, .tb-cmdk, .tb-share { display: none; }
  .tb-left { max-width: 32%; }
  .tb-sandbox { max-width: 100%; overflow: hidden; text-overflow: ellipsis; font-size: 11px; }
  .tb-center { order: 2; }
  .tb-right { display: none; }
  /* .tb-right's status/ports/mount/⌘K/Share all vanish above — this is the one
     reachable stand-in, always visible instead of buried in the keybar tray. */
  .tb-mobile-more { display: flex; order: 3; }
  .ws-tab { min-height: 32px; padding: 5px 8px; }
  .ws-tab-close { display: none; }
  .workspace { padding: 0; }
  .ghost-hint { display: none !important; }
  .pane { border: 0; border-radius: 0; }
  .pane.focused { border: 0; box-shadow: none; }
  .pane:has(.pane-terminal) > .pane-header { display: none; }
  .pane-header { flex-basis: 24px; padding: 0 6px; }
  .pane-menu, .pane-close { width: 28px; height: 24px; opacity: .75; }
  .pane:not(.focused) .pane-body { opacity: 1; }
  .pane-term-mount { position: relative; padding: 4px 2px 2px 5px; touch-action: pan-x; }
  .pane-term-mount .xterm-helper-textarea,
  input, textarea { font-size: 16px !important; }

  /* ── Focused-pane mode ──
     A literal split tree at 390px squeezes every pane to a sliver (two panes
     ≈ 20 columns each, text wrapping mid-word). Below the breakpoint, render
     only the focused leaf and flatten the split wrappers so it fills the tab
     body — the tree/ratios themselves are untouched, so desktop and a
     ".split-override" escape hatch (below) both still see the real layout.
     `display: contents` un-boxes nested `.split` wraps; with only one visible
     flex item left in `.tab-body`, that item always fills 100% of the
     available space regardless of its own flex-grow ratio. */
  .tab-body:not(.split-override) .split { display: contents; }
  .tab-body:not(.split-override) .divider { display: none; }
  .tab-body:not(.split-override) .pane:not(.focused) { display: none; }
  /* The pane's own flex-grow is an inline style carrying its split ratio (e.g.
     0.5) — only overridable from a stylesheet with !important. Flexbox only
     distributes free space proportional to the SUM of grow factors in play;
     with one item left at grow 0.5 it fills just 50% of the tab body and
     leaves the rest blank, so this has to force grow to 1, not merely hide
     the siblings. */
  .tab-body:not(.split-override) .pane.focused { flex: 1 1 auto !important; }

  /* Pane switcher: "‹ 2 of 3 · Files ›" + a toggle back to the real split. */
  .mobile-pane-switcher {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 4px;
    height: 34px;
    padding: 0 4px;
    margin-bottom: 4px;
    border-radius: 8px;
    background: var(--panel);
    border: 1px solid var(--hair);
  }
  .mobile-pane-switcher[hidden] { display: none; }
  .mps-nav, .mps-split {
    display: flex; align-items: center; justify-content: center;
    width: 30px; height: 26px; border-radius: 6px; color: var(--t-body); flex-shrink: 0;
  }
  .mps-nav:disabled { color: var(--t-faint); pointer-events: none; }
  .mps-nav:active, .mps-split:active { background: var(--hair-soft); }
  .mps-split.active { color: var(--nav-active); background: var(--accent-soft); }
  .mps-label {
    flex: 1; min-width: 0; height: 26px; padding: 0 6px; border-radius: 6px;
    font-size: 12px; color: var(--t-2); text-align: center;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  }
  .mps-label:active { background: var(--hair-soft); }
  .mps-nav:focus-visible, .mps-label:focus-visible, .mps-split:focus-visible {
    outline: 2px solid var(--accent); outline-offset: -2px;
  }

  .mobile-keybar {
    position: fixed;
    z-index: 8800;
    left: 0;
    right: 0;
    bottom: max(var(--keyboard-offset, 0px), env(keyboard-inset-height, 0px));
    height: var(--mobile-dock-height);
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    gap: 4px;
    padding: 5px max(6px, env(safe-area-inset-right)) calc(5px + var(--mobile-keybar-safe)) max(6px, env(safe-area-inset-left));
    color: #f4f2ff;
    background: rgba(19, 19, 25, .94);
    border-top: 1px solid rgba(255, 255, 255, .12);
    box-shadow: 0 -10px 28px rgba(0, 0, 0, .28);
    backdrop-filter: blur(18px) saturate(1.2);
    -webkit-backdrop-filter: blur(18px) saturate(1.2);
  }
  .mobile-keybar-main, .mobile-keybar-primary, .mobile-keybar-secondary {
    display: flex;
    align-items: center;
    gap: 4px;
  }
  .mobile-keybar-main { width: 100%; }
  .mobile-keybar-primary { flex: 1; min-width: 0; justify-content: space-between; }
  .mobile-keybar-primary .mobile-key { flex: 1 1 0; min-width: 0; padding-inline: 2px; }
  .mobile-keybar-primary .mobile-key-modifier { flex-grow: 1.25; }
  .mobile-keybar-secondary {
    position: absolute;
    left: 5px;
    right: 5px;
    bottom: calc(var(--mobile-dock-height) + 5px);
    min-height: 46px;
    padding: 5px;
    overflow-x: auto;
    border: 1px solid rgba(255, 255, 255, .12);
    border-radius: 10px;
    background: rgba(19, 19, 25, .97);
    box-shadow: 0 -12px 32px rgba(0, 0, 0, .38);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
  }
  .mobile-keybar-secondary .mobile-key-action {
    color: var(--nav-active);
    background: rgba(110, 106, 240, .12);
    border-color: rgba(110, 106, 240, .24);
  }
  .mobile-keybar-secondary[hidden] { display: none; }
  .mobile-key {
    flex: 0 0 auto;
    min-width: 32px;
    height: 38px;
    padding: 0 7px;
    border: 1px solid rgba(255, 255, 255, .1);
    border-radius: 8px;
    color: rgba(255, 255, 255, .82);
    background: rgba(255, 255, 255, .065);
    font: 600 12px/1 var(--mono);
    letter-spacing: -.02em;
    -webkit-tap-highlight-color: transparent;
  }
  .mobile-key-modifier { min-width: 40px; }
  .mobile-key-more { min-width: 34px; padding: 0 5px; }
  .mobile-key:active, .mobile-key.active {
    color: #fff;
    background: var(--accent);
    border-color: rgba(255, 255, 255, .22);
    transform: translateY(1px);
  }
  .mobile-key.locked::after {
    content: '';
    position: absolute;
    left: 50%;
    bottom: 3px;
    width: 12px;
    height: 2px;
    border-radius: 2px;
    background: currentColor;
    transform: translateX(-50%);
  }
  .mobile-key { position: relative; }
  .mobile-key-interrupt {
    min-width: 38px;
    padding: 0 6px;
    color: #ffaaa3;
    border-color: rgba(239, 111, 100, .26);
    background: rgba(239, 111, 100, .1);
  }
  .term-scroll-latest {
    position: absolute;
    z-index: 12;
    right: 10px;
    bottom: 10px;
    display: flex;
    align-items: center;
    height: 30px;
    padding: 0 11px;
    border: 1px solid rgba(255, 255, 255, .13);
    border-radius: 999px;
    color: rgba(255, 255, 255, .82);
    background: rgba(24, 24, 31, .88);
    box-shadow: 0 8px 24px rgba(0, 0, 0, .35);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    font: 600 11px/1 var(--sans);
  }
  .term-scroll-latest[hidden] { display: none; }
  .mobile-keybar-status {
    position: absolute;
    left: 50%;
    bottom: calc(var(--mobile-dock-height) + 10px);
    z-index: 3;
    padding: 6px 10px;
    border: 1px solid rgba(255, 255, 255, .12);
    border-radius: 999px;
    color: rgba(255, 255, 255, .86);
    background: rgba(20, 20, 26, .92);
    box-shadow: 0 8px 24px rgba(0, 0, 0, .3);
    font: 600 11px/1 var(--sans);
    opacity: 0;
    pointer-events: none;
    transform: translate(-50%, 5px);
    transition: opacity 140ms ease, transform 180ms cubic-bezier(.22,.9,.26,1);
  }
  .mobile-keybar-status.show { opacity: 1; transform: translate(-50%, 0); }
  .toast-host { bottom: calc(var(--mobile-dock-height) + 8px); right: 8px; }
  .modal-overlay { align-items: flex-end; }
  .modal { width: 100%; max-width: 100%; max-height: 88%; border-radius: 14px 14px 0 0; }
  .palette-overlay { padding: 8px; align-items: flex-start; }
  .palette { width: 100%; max-width: 100%; max-height: calc(var(--visual-viewport-height, 100dvh) - 16px); }
}
