/* KaloLab design system.
   Rules: flat charcoal surfaces (#12141A page, #1A1D24 cards, 1px #2A2E39 borders); off-white titles, slate body text;
   ONE calm accent (a muted blue, never neon) used only for primary actions, active/selected states
   and key metrics; no blur and no glow.
   Red and amber appear only to mark errors and warnings. Numbers are set in monospace.
   Badges are filled (green for active, dark gray for secondary); secondary buttons are subtle dark
   surfaces and destructive ones are red-text ghosts, never outlined red boxes. */

:root {
  /* no Inter / Roboto / Open Sans. Display: DIN 1451 lettering where the system has it. */
  --font-ui: "IBM Plex Sans", "Segoe UI", -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
  /* titles only: the one loud element per screen */
  --font-display: "IBM Plex Serif", Georgia, "Times New Roman", serif;
  /* small caps-style labels, column headers, badges */
  --font-label: "IBM Plex Sans", "Segoe UI", -apple-system, "Helvetica Neue", Arial, sans-serif;
  --font-code: "JetBrains Mono", "Cascadia Code", "Cascadia Mono", "SF Mono", Consolas, "Liberation Mono", monospace;
  --radius: 0;
  --radius-sm: 0;
  --side-w: 248px;
  --dock-w: 440px;
  --code-size: 13.5px;
  --code-line: 21px;
  --pad: 24px;            /* minimum padding inside cards and dialogs */
}

:root, :root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #12141A;          /* page background: dark slate/charcoal, never black */
  --surface: #1A1D24;     /* cards, bars, panels */
  --surface-2: #1A1D24;   /* editor, dialogs, menus: same card surface, set apart by borders */
  --surface-3: #22262F;   /* chips, pressed and hovered rows */
  --hover: #22262F;
  --line: #2A2E39;        /* the 1px border */
  --line-strong: #2A2E39;
  --text: #F3F4F6;        /* titles and primary text */
  --text-2: #9CA3AF;      /* secondary body text */
  --muted: #9CA3AF;
  --faint: #6B7280;       /* tertiary: line numbers, hints */
  --accent: #D9A441;      /* the one accent: ochre, for active and selected states */
  --accent-ink: #12141A;
  --accent-soft: rgba(217, 164, 65, 0.14);
  --accent-line: rgba(217, 164, 65, 0.55);
  --accent-glow: none;
  --primary: #E9E4D8;     /* primary actions: paper on the dark page */
  --primary-ink: #12141A;
  /* status colors: only for errors and warnings, never decoration */
  --rose: #F87171;
  --rose-soft: rgba(248, 113, 113, 0.10);
  --warn: #E0B341;
  --warn-soft: rgba(224, 179, 65, 0.10);
  /* former secondary hues are neutral now: there is one accent */
  --teal: #9CA3AF;
  --teal-soft: rgba(156, 163, 175, 0.12);
  --violet: #9CA3AF;
  --remote: #E5E7EB;      /* other people's cursors and avatars */
  /* badges: filled, never outlined */
  --badge-bg: #262933;    /* secondary badge ("Can edit") */
  --badge-text: #D1D5DB;
  --ok-bg: rgba(34, 197, 94, 0.12);  /* active badge ("Open now"), live and passing states */
  --ok-text: #7BC99A;
  /* buttons that aren't primary: subtle dark surfaces, or ghost for destructive actions */
  --control: #262933;
  --control-hover: #2F3340;
  --danger-hover: rgba(248, 113, 113, 0.10);
  --shadow: none;          /* no soft shadows: floating panels get a hard border */
  --float-line: #3A3F4C;
  --plot-bg: #1A1D24;
  --plot-grid: rgba(243, 244, 246, 0.07);
  --plot-axis: #6B7280;
  /* syntax: near-monochrome, strings take a muted tint of the accent */
  --syn-kw: #F3F4F6;
  --syn-str: #A9C9A4;
  --syn-num: #E5E7EB;
  --syn-com: #6B7280;
  --syn-fn: #D1D5DB;
  --syn-op: #9CA3AF;
  --syn-const: #F3F4F6;
  --syn-section: #F3F4F6;
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #F4F2EC;          /* paper */
  --surface: #FFFFFF;
  --surface-2: #FFFFFF;
  --surface-3: #EDEAE2;
  --hover: #ECEEF2;
  --line: #DAD5C9;
  --line-strong: #DADDE3;
  --text: #14171F;
  --text-2: #4B5563;
  --muted: #4B5563;
  --faint: #9CA3AF;
  --accent: #A16207;      /* ochre, deep enough for text on paper */
  --accent-ink: #FFFFFF;
  --accent-soft: rgba(161, 98, 7, 0.10);
  --accent-line: rgba(161, 98, 7, 0.45);
  --accent-glow: none;
  --primary: #1E3A5F;     /* primary actions: institutional navy ink */
  --primary-ink: #FFFFFF;
  --rose: #D32F2F;
  --rose-soft: rgba(211, 47, 47, 0.07);
  --warn: #A16207;
  --warn-soft: rgba(161, 98, 7, 0.08);
  --teal: #4B5563;
  --teal-soft: rgba(75, 85, 99, 0.10);
  --violet: #4B5563;
  --remote: #374151;
  --badge-bg: #EDEAE2;   /* warm, to sit on paper */
  --badge-text: #3D3A33;
  --ok-bg: rgba(22, 163, 74, 0.12);
  --ok-text: #15803D;
  --control: #EDEAE2;
  --control-hover: #E3DED2;
  --danger-hover: rgba(211, 47, 47, 0.08);
  --shadow: none;
  --float-line: #BCC2CC;
  --plot-bg: #FFFFFF;
  --plot-grid: rgba(17, 19, 24, 0.08);
  --plot-axis: #9CA3AF;
  --syn-kw: #111318;
  --syn-str: #3E6F3A;
  --syn-num: #1F2937;
  --syn-com: #9CA3AF;
  --syn-fn: #374151;
  --syn-op: #4B5563;
  --syn-const: #111318;
  --syn-section: #111318;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 13px/1.45 var(--font-ui);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
button { font: inherit; color: inherit; }
input, textarea { font: inherit; color: inherit; }
code, kbd, pre { font-family: var(--font-code); }
kbd {
  font-size: 10.5px;
  padding: 1px 5px;
  border: 1px solid var(--line-strong);
  border-bottom-width: 2px;
  border-radius: 0;
  color: var(--muted);
  background: var(--surface);
  white-space: nowrap;
}
[hidden] { display: none !important; }
::selection { background: var(--accent-soft); }
.muted { color: var(--muted); }

/* scrollbars */
* { scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 0; border: 3px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- layout ---------- */
.app {
  display: grid;
  height: 100vh;
  grid-template-columns: 48px var(--side-w) 5px minmax(320px, 1fr) 5px var(--dock-w);
  grid-template-rows: 46px auto minmax(0, 1fr) 26px;
  grid-template-areas:
    "top top top top top top"
    "ribbon ribbon ribbon ribbon ribbon ribbon"
    "rail side s1 stage s2 dock"
    "status status status status status status";
}
.app.dock-hidden { grid-template-columns: 48px var(--side-w) 5px minmax(320px, 1fr) 0 0; }
.app.dock-hidden .dock, .app.dock-hidden .splitter[data-split="dock"] { display: none; }
.app.side-hidden { grid-template-columns: 48px 0 0 minmax(320px, 1fr) 5px var(--dock-w); }
.app.side-hidden.dock-hidden { grid-template-columns: 48px 0 0 minmax(320px, 1fr) 0 0; }
.app.side-hidden .side, .app.side-hidden .splitter[data-split="side"] { display: none; }

.topbar { grid-area: top; }
.rail { grid-area: rail; }
.side { grid-area: side; }
.splitter[data-split="side"] { grid-area: s1; }
.stage { grid-area: stage; }
.splitter[data-split="dock"] { grid-area: s2; }
.dock { grid-area: dock; }
.statusbar { grid-area: status; }

/* ---------- top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 12px 0 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  min-width: 0;
}
.brand { display: flex; align-items: center; gap: 9px; width: 260px; flex: none; }
.brand-name { font-size: 15px; letter-spacing: 0.2px; font-weight: 600; color: var(--text-2); }
.brand-name b { color: var(--text); font-weight: 750; }
.search-trigger {
  flex: 1 1 auto;
  max-width: 520px;
  margin: 0 auto;
  display: flex; align-items: center; gap: 10px;
  height: 30px;
  padding: 0 8px 0 12px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 0;
  color: var(--muted);
  cursor: pointer;
  text-align: left;
  min-width: 0;
}
.search-trigger span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-trigger:hover { border-color: var(--line-strong); color: var(--text-2); }
.run-controls { display: flex; align-items: center; gap: 6px; flex: none; }
.sep { width: 1px; height: 20px; background: var(--line); margin: 0 4px; }

.btn {
  display: inline-flex; align-items: center; gap: 7px;
  height: 30px; padding: 0 12px;
  border: 1px solid var(--line-strong);
  background: var(--surface-2);
  border-radius: 0;
  cursor: pointer;
  font-weight: 550;
  font-size: 12.5px;
  transition: background .12s, border-color .12s, color .12s, opacity .12s;
}
.btn:hover:not(:disabled) { background: var(--hover); }
.btn:disabled { opacity: 0.45; cursor: default; }
.btn kbd { border-color: transparent; background: rgba(0, 0, 0, 0.18); color: inherit; opacity: 0.75; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.btn.primary:hover:not(:disabled) { filter: brightness(1.08); background: var(--primary); }
.btn.danger:not(:disabled) { color: var(--rose); border-color: color-mix(in srgb, var(--rose) 50%, var(--line)); background: var(--rose-soft); }
.icon-btn {
  display: inline-grid; place-items: center;
  width: 30px; height: 30px;
  border: 0; border-radius: 0;
  background: transparent; color: var(--muted);
  cursor: pointer;
}
.icon-btn:hover { background: var(--hover); color: var(--text); }
.icon-btn.small { width: 24px; height: 24px; }

/* ---------- rail ---------- */
.rail {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 10px 0;
  background: var(--surface);
  border-right: 1px solid var(--line);
}
.rail-btn {
  position: relative;
  width: 36px; height: 36px;
  display: grid; place-items: center;
  border: 0; background: transparent; color: var(--faint);
  border-radius: 0;
  cursor: pointer;
}
.rail-btn:hover { color: var(--text-2); background: var(--hover); }
.rail-btn.active { color: var(--text); background: var(--surface-3); }
.rail-btn.active::before {
  content: ""; position: absolute; left: -6px; top: 8px; bottom: 8px; width: 3px;
  border-radius: 0; background: var(--accent);
}
.rail-spacer { flex: 1; }

/* ---------- side panels ---------- */
.side { background: var(--surface); border-right: 1px solid var(--line); min-width: 0; overflow: hidden; display: flex; flex-direction: column; }
.panel { display: flex; flex-direction: column; min-height: 0; flex: 1; }
.panel-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 10px 6px 14px; }
.panel-head h2 { margin: 0; font-size: 11px; font-weight: 700; letter-spacing: 0.9px; text-transform: uppercase; color: var(--muted); }
.panel-actions { display: flex; gap: 2px; }
.panel-sub { padding: 0 14px 8px; font: 11.5px var(--font-code); color: var(--faint); }
.panel-search { padding: 0 10px 8px; }
.panel-search input {
  width: 100%; height: 28px; padding: 0 10px;
  border-radius: 0; border: 1px solid var(--line); background: var(--bg); outline: none;
}
.panel-search input:focus { border-color: var(--accent-line); }

.file-list, .history-list { list-style: none; margin: 0; padding: 0 6px 10px; overflow: auto; flex: 1; }
.file-item {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 8px; border-radius: 0;
  cursor: pointer; color: var(--text-2);
  user-select: none;
}
.file-item:hover { background: var(--hover); }
.file-item.active { background: var(--accent-soft); color: var(--text); }
.file-item .ficon { width: 16px; height: 16px; flex: none; display: grid; place-items: center; font: 700 9px var(--font-code); border-radius: 0; }
.file-item .ficon.m { background: color-mix(in srgb, var(--accent) 20%, transparent); color: var(--accent); }
.file-item .ficon.d { background: color-mix(in srgb, var(--teal) 18%, transparent); color: var(--teal); }
.file-item .fname { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-item .factions { display: none; gap: 0; }
.file-item:hover .factions { display: flex; }
.file-item .factions button { width: 22px; height: 22px; }
.file-empty { padding: 10px 14px; color: var(--muted); }

.var-list { overflow: auto; flex: 1; padding: 0 6px 10px; }
.var-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 64px;
  grid-template-rows: auto auto;
  gap: 1px 10px;
  padding: 7px 8px;
  border-radius: 0;
  cursor: pointer;
}
.var-row:hover { background: var(--hover); }
.var-row .vname { font: 600 12.5px var(--font-code); color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.var-row .vmeta { font-size: 11px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.var-row .vmeta b { font-weight: 600; color: var(--text-2); font-family: var(--font-code); }
.var-row .vprev { grid-row: 1 / 3; grid-column: 2; align-self: center; justify-self: end; font: 11.5px var(--font-code); color: var(--text-2); text-align: right; max-width: 64px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.var-row canvas { display: block; }
.var-empty { padding: 14px; color: var(--muted); line-height: 1.6; }
.var-empty code { color: var(--accent); }

.docs-list { overflow: auto; flex: 1; padding: 0 6px 10px; }
.docs-cat { font-size: 10.5px; font-weight: 700; letter-spacing: 0.8px; text-transform: uppercase; color: var(--faint); padding: 12px 8px 4px; }
.docs-item { padding: 5px 8px; border-radius: 0; cursor: pointer; }
.docs-item:hover { background: var(--hover); }
.docs-item .dn { font: 600 12.5px var(--font-code); color: var(--syn-fn); }
.docs-item .dd { font-size: 11.5px; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.docs-item.open { background: var(--surface-3); }
.docs-item .dsig { font: 11.5px var(--font-code); color: var(--text-2); margin: 6px 0 4px; white-space: pre-wrap; }
.docs-item .dfull { font-size: 12px; color: var(--text-2); }
.docs-item .dactions { display: flex; gap: 6px; margin-top: 8px; }
.docs-item .dactions button { height: 24px; font-size: 11.5px; padding: 0 8px; }

.history-item { padding: 4px 8px; border-radius: 0; cursor: pointer; font: 12px var(--font-code); color: var(--text-2); white-space: pre; overflow: hidden; text-overflow: ellipsis; }
.history-item:hover { background: var(--hover); color: var(--text); }

/* ---------- splitters ---------- */
.splitter { background: transparent; position: relative; z-index: 3; }
.splitter.v { cursor: col-resize; }
.splitter.h { cursor: row-resize; height: 5px; }
.splitter::after { content: ""; position: absolute; transition: background .15s; }
.splitter.v::after { left: 2px; width: 1px; top: 0; bottom: 0; }
.splitter.h::after { top: 2px; height: 1px; left: 0; right: 0; }
.splitter:hover::after, .splitter.dragging::after { background: var(--accent-line); }
.splitter.v:hover::after, .splitter.v.dragging::after { left: 1px; width: 3px; }
.splitter.h:hover::after, .splitter.h.dragging::after { top: 1px; height: 3px; }
body.resizing { user-select: none; }
body.resizing * { cursor: inherit !important; }

/* ---------- stage ---------- */
.stage { display: grid; grid-template-rows: var(--editor-h, 55%) 5px minmax(0, 1fr); min-width: 0; min-height: 0; background: var(--bg); }
.editor-pane { grid-row: 1; display: flex; flex-direction: column; min-height: 0; background: var(--surface-2); border-bottom: 1px solid var(--line); }
.editor-tabs { display: flex; align-items: stretch; height: 34px; background: var(--surface); border-bottom: 1px solid var(--line); overflow-x: auto; overflow-y: hidden; flex: none; scrollbar-width: none; }
.editor-tabs::-webkit-scrollbar { display: none; }
.etab {
  display: flex; align-items: center; gap: 7px;
  padding: 0 8px 0 14px;
  border-right: 1px solid var(--line);
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
  font-size: 12.5px;
  position: relative;
  user-select: none;
}
.etab:hover { color: var(--text-2); background: var(--hover); }
.etab.active { color: var(--text); background: var(--surface-2); }
.etab.active::after { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 2px; background: var(--accent); }
.etab .dirty { width: 7px; height: 7px; border-radius: 0; background: var(--accent); }
.etab .x { width: 18px; height: 18px; display: grid; place-items: center; border-radius: 0; border: 0; background: none; color: var(--faint); cursor: pointer; padding: 0; }
.etab .x:hover { background: var(--line); color: var(--text); }
.etab-new { border: 0; background: none; color: var(--faint); padding: 0 12px; cursor: pointer; font-size: 16px; }
.etab-new:hover { color: var(--text); }
.editor-host { position: relative; flex: 1; min-height: 0; }

/* ---------- code editor ---------- */
.ke { position: absolute; inset: 0; display: flex; font: var(--code-size)/var(--code-line) var(--font-code); }
.ke-gutter {
  flex: none; width: 52px; overflow: hidden; position: relative;
  color: var(--faint); text-align: right; user-select: none;
  background: var(--surface-2);
  border-right: 1px solid var(--line);
}
.ke-gutter-inner { position: absolute; left: 0; right: 0; top: 0; padding: 10px 12px 10px 0; }
.ke-gutter .ln { height: var(--code-line); position: relative; }
.ke-gutter .ln.cur { color: var(--text-2); }
.ke-gutter .ln.err { color: var(--rose); }
.ke-gutter .ln.err::before { content: ""; position: absolute; left: 6px; top: 7px; width: 7px; height: 7px; border-radius: 0; background: var(--rose); }
.ke-scroll { position: relative; flex: 1; overflow: auto; }
.ke-layer { position: relative; min-height: 100%; }
.ke-pre, .ke-input {
  margin: 0; padding: 10px 16px 40px 14px; border: 0;
  font: inherit; letter-spacing: 0; tab-size: 4;
  white-space: pre; word-wrap: normal; overflow-wrap: normal;
}
.ke-pre { position: relative; pointer-events: none; color: var(--text); min-height: 100%; }
.ke-input {
  position: absolute; inset: 0; width: 100%; height: 100%;
  resize: none; outline: none; background: transparent;
  color: transparent; caret-color: var(--accent);
  overflow: hidden;
}
.ke-input::selection { background: color-mix(in srgb, var(--accent) 28%, transparent); color: transparent; }
.ke-bands { position: absolute; left: 0; right: 0; top: 0; pointer-events: none; }
.ke-band { position: absolute; left: 0; right: 0; }
.ke-band.section { background: var(--accent-soft); border-left: 2px solid var(--accent-line); opacity: 0.6; }
.ke-band.curline { background: rgba(127, 140, 160, 0.06); }
.ke-band.errline { background: var(--rose-soft); border-left: 2px solid var(--rose); }
.ke-band.sectionrule { height: 1px; background: var(--accent-line); opacity: 0.6; }
.ke-band.flash { background: var(--teal-soft); transition: opacity .6s; }

/* syntax colours */
.t-kw { color: var(--syn-kw); font-weight: 550; }
.t-str { color: var(--syn-str); }
.t-num { color: var(--syn-num); }
.t-com { color: var(--syn-com); font-style: italic; }
.t-sec { color: var(--syn-section); font-weight: 700; font-style: normal; }
.t-fn { color: var(--syn-fn); }
.t-const { color: var(--syn-const); }
.t-op { color: var(--syn-op); }
.t-cmd { color: var(--syn-fn); }

/* ---------- console ---------- */
.console-pane { grid-row: 3; display: flex; flex-direction: column; min-height: 0; background: var(--bg); }
.stage > .splitter { grid-row: 2; }
.console-head { display: flex; align-items: center; gap: 10px; height: 32px; padding: 0 8px 0 14px; border-bottom: 1px solid var(--line); background: var(--surface); flex: none; }
.console-title { font-size: 11px; font-weight: 700; letter-spacing: 0.9px; text-transform: uppercase; color: var(--muted); }
.console-head .panel-actions { margin-left: auto; }
.kernel-state { display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--muted); }
.kernel-state i, .status-item .dot { width: 7px; height: 7px; border-radius: 0; background: var(--faint); display: inline-block; }
.kernel-state.idle i, .status-item.idle .dot { background: var(--teal); }
.kernel-state.busy i, .status-item.busy .dot { background: var(--accent); animation: pulse 1s ease-in-out infinite; }
.kernel-state.input i { background: var(--violet); animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: 0.35; transform: scale(0.75); } }

.transcript { flex: 1; overflow: auto; padding: 8px 0 12px; font: var(--code-size)/1.55 var(--font-code); }
.entry { padding: 6px 14px 8px; border-left: 2px solid transparent; position: relative; }
.entry + .entry { border-top: 1px dashed color-mix(in srgb, var(--line) 70%, transparent); }
.entry.running { border-left-color: var(--accent); background: linear-gradient(90deg, var(--accent-soft), transparent 40%); }
.entry.failed { border-left-color: var(--rose); }
.entry-head { display: flex; align-items: flex-start; gap: 8px; }
.prompt-glyph { color: var(--accent); font-weight: 700; user-select: none; flex: none; width: 10px; }
.entry-code { flex: 1; white-space: pre-wrap; word-break: break-word; cursor: pointer; color: var(--text); min-width: 0; }
.entry-code:hover { text-decoration: underline dotted var(--faint); text-underline-offset: 3px; }
.entry-source { font-family: var(--font-ui); font-size: 11.5px; color: var(--muted); }
.entry-source b { color: var(--text-2); font-weight: 600; }
.entry-meta { flex: none; font: 10.5px var(--font-ui); color: var(--faint); padding-top: 2px; display: inline-flex; gap: 6px; align-items: center; }
.entry-meta .ok { color: var(--teal); }
.entry-out { margin: 4px 0 0 18px; }
.out-text { white-space: pre-wrap; word-break: break-word; color: var(--text-2); margin: 0; }
/* bake: a progress bar that rewrites itself, then Play buttons */
.out-progress { color: var(--text); font-variant-numeric: tabular-nums; white-space: pre; overflow-x: auto; }
.out-actions { display: flex; gap: 8px; margin: 8px 0 4px; }
.out-actions .btn { height: 28px; padding: 0 12px; font-size: 12px; }
.out-val { margin: 3px 0; }
.out-val.inline { white-space: pre-wrap; color: var(--text-2); }
.out-val .vn { color: var(--text); font-weight: 600; }
.out-val .eq { color: var(--faint); }
.out-val .badge { display: inline-block; font: 600 10.5px var(--font-ui); color: var(--muted); border: 1px solid var(--line-strong); padding: 0 6px; border-radius: 0; margin-left: 6px; vertical-align: 1px; }
.out-val pre { margin: 3px 0 0; color: var(--text-2); white-space: pre; overflow-x: auto; padding: 6px 10px; background: var(--surface); border: 1px solid var(--line); border-radius: 0; max-height: 360px; }
/* a table result: a real table, so selecting it and pasting into a spreadsheet gives rows and columns */
.out-tablehead { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.tbl-tools { margin-left: auto; display: inline-flex; gap: 6px; }
.tbl-btn { font: 11px var(--font-ui); color: var(--muted); background: transparent; border: 1px solid var(--line-strong); padding: 1px 8px; border-radius: 0; cursor: pointer; }
.tbl-btn:hover { color: var(--text); background: var(--surface); }
.out-tablewrap { margin: 4px 0 0; max-height: 420px; overflow: auto; border: 1px solid var(--line); background: var(--surface); user-select: text; }
.out-table { border-collapse: collapse; font: 12px var(--font-mono, ui-monospace, monospace); color: var(--text-2); white-space: nowrap; }
.out-table th, .out-table td { padding: 3px 12px; border-bottom: 1px solid var(--line); border-right: 1px solid var(--line); text-align: left; }
.out-table th { position: sticky; top: 0; background: var(--surface); color: var(--text); font-weight: 600; border-bottom: 1px solid var(--line-strong); }
.out-table th.num, .out-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.out-table tr:last-child td { border-bottom: 0; }
.out-table th:last-child, .out-table td:last-child { border-right: 0; }
.out-tablemore { font: 11px var(--font-ui); color: var(--faint); padding: 3px 0; }
.out-warn { color: var(--warn); background: var(--warn-soft); border-left: 2px solid var(--warn); padding: 4px 10px; margin: 4px 0; border-radius: 0; white-space: pre-wrap; font-family: var(--font-ui); font-size: 12.5px; }
.out-warn::before { content: "Warning  "; font-weight: 700; }
.out-err { margin: 6px 0 2px; border: 1px solid color-mix(in srgb, var(--rose) 35%, var(--line)); background: var(--rose-soft); border-radius: 0; overflow: hidden; font-family: var(--font-ui); }
.out-err .em { padding: 8px 12px 6px; color: var(--rose); font-weight: 600; font-size: 13px; white-space: pre-wrap; }
.out-err .ew { padding: 0 12px 6px; color: var(--muted); font-size: 11.5px; }
.out-err .ew a { color: var(--text-2); cursor: pointer; text-decoration: underline dotted; }
.out-err .ex { margin: 0 12px 8px; padding: 6px 10px; background: var(--surface); border-radius: 0; font: 12.5px/1.6 var(--font-code); white-space: pre; overflow-x: auto; color: var(--text-2); }
.out-err .ex .caret { color: var(--rose); font-weight: 700; }
.out-err .ex .lno { color: var(--faint); user-select: none; }
.out-err .eh { padding: 7px 12px; border-top: 1px solid color-mix(in srgb, var(--rose) 18%, var(--line)); color: var(--text-2); font-size: 12.5px; display: flex; gap: 8px; }
.out-err .eh::before { content: "Hint"; flex: none; height: fit-content; margin-top: 1px; font: 700 10px/1.5 var(--font-ui); letter-spacing: 0.3px; color: var(--accent-ink); background: var(--accent); border-radius: 0; padding: 0 5px; }
.out-err .eh b { color: var(--accent); font-weight: 650; }
.out-stop { display: inline-flex; align-items: center; gap: 8px; margin: 4px 0; font: 12px var(--font-ui); color: var(--text-2); }
.out-stop::before { content: ""; width: 9px; height: 9px; border-radius: 0; background: var(--rose); }
.entry.stopped { border-left-color: var(--line-strong); }
.out-fig { display: inline-flex; flex-direction: column; margin: 6px 8px 2px 0; border: 1px solid var(--line); border-radius: 0; overflow: hidden; cursor: pointer; background: var(--plot-bg); transition: border-color .12s, transform .12s; }
.out-fig:hover { border-color: var(--accent-line); transform: translateY(-1px); }
.out-fig img { display: block; width: 220px; height: auto; }
.out-fig span { font: 10.5px var(--font-ui); color: var(--muted); padding: 3px 8px; border-top: 1px solid var(--line); background: var(--surface); }
.out-input { display: flex; gap: 8px; align-items: center; margin: 4px 0; }
.out-input label { color: var(--violet); }
.out-input input { flex: 1; height: 26px; padding: 0 8px; border: 1px solid var(--violet); border-radius: 0; background: var(--surface); font-family: var(--font-code); outline: none; }
.out-more { color: var(--accent); cursor: pointer; font: 11.5px var(--font-ui); margin-top: 2px; display: inline-block; }

.welcome { padding: 18px 18px 10px; font-family: var(--font-ui); color: var(--text-2); }
.welcome h1 { margin: 0 0 4px; font-size: 18px; font-weight: 700; color: var(--text); letter-spacing: -0.2px; }
.welcome h1 span { color: var(--accent); }
.welcome p { margin: 4px 0 10px; color: var(--muted); max-width: 70ch; }
.welcome .chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { font: 12px var(--font-code); padding: 4px 10px; border: 1px solid var(--line-strong); border-radius: 0; background: var(--surface); cursor: pointer; color: var(--text-2); }
.chip:hover { border-color: var(--accent-line); color: var(--text); background: var(--accent-soft); }

.console-input { position: relative; border-top: 1px solid var(--line); background: var(--surface); flex: none; display: flex; align-items: flex-start; padding: 0 0 0 14px; }
.console-input .prompt-glyph { padding-top: 9px; font: 700 var(--code-size)/var(--code-line) var(--font-code); }
.ci-wrap { position: relative; flex: 1; min-height: 40px; max-height: 40vh; overflow: auto; font: var(--code-size)/var(--code-line) var(--font-code); }
.ci-wrap .ke-pre, .ci-wrap .ke-input { padding: 9px 14px 10px 8px; white-space: pre-wrap; word-break: break-word; }
.ci-wrap .ke-pre { min-height: 0; }
.ci-placeholder { position: absolute; left: 8px; top: 9px; color: var(--faint); pointer-events: none; font: inherit; }

/* completion popup */
.completion {
  position: fixed; z-index: 60; min-width: 240px; max-width: 420px; max-height: 260px; overflow: auto;
  background: var(--surface-2); border: 1px solid var(--line-strong); border-radius: 0; box-shadow: var(--shadow);
  padding: 4px; font: 12.5px var(--font-code);
}
.completion .ci { display: flex; gap: 10px; align-items: baseline; padding: 4px 8px; border-radius: 0; cursor: pointer; }
.completion .ci.sel { background: var(--accent-soft); }
.completion .ci .k { flex: none; font: 600 9.5px var(--font-ui); width: 22px; text-align: center; border-radius: 0; padding: 1px 0; }
.completion .ci .k.v { color: var(--teal); background: var(--teal-soft); }
.completion .ci .k.f { color: var(--syn-fn); background: color-mix(in srgb, var(--syn-fn) 12%, transparent); }
.completion .ci .k.u { color: var(--accent); background: var(--accent-soft); }
.completion .ci .k.w { color: var(--syn-kw); background: color-mix(in srgb, var(--syn-kw) 12%, transparent); }
.completion .ci .n { color: var(--text); }
.completion .ci .d { color: var(--muted); font-family: var(--font-ui); font-size: 11px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.sig-hint { position: fixed; z-index: 59; background: var(--surface-2); border: 1px solid var(--line-strong); border-radius: 0; box-shadow: var(--shadow); padding: 5px 9px; font: 12px var(--font-code); color: var(--text-2); max-width: 520px; pointer-events: none; }
.sig-hint .d { display: block; font: 11.5px var(--font-ui); color: var(--muted); margin-top: 2px; }

/* ---------- dock (figures + inspector) ---------- */
.dock { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--surface); border-left: 1px solid var(--line); }
.dock-head { display: flex; align-items: center; height: 34px; border-bottom: 1px solid var(--line); padding-right: 6px; flex: none; }
.figure-tabs { display: flex; flex: 1; min-width: 0; overflow-x: auto; scrollbar-width: none; height: 100%; }
.figure-tabs::-webkit-scrollbar { display: none; }
.ftab { display: flex; align-items: center; gap: 6px; padding: 0 12px; height: 100%; border: 0; border-right: 1px solid var(--line); background: none; color: var(--muted); cursor: pointer; white-space: nowrap; font-size: 12px; position: relative; }
.ftab:hover { color: var(--text-2); background: var(--hover); }
.ftab.active { color: var(--text); background: var(--surface-2); }
.ftab.active::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; background: var(--teal); }
.ftab .fnum { font: 600 10px var(--font-code); color: var(--teal); }
.figure-host { position: relative; flex: 1; min-height: 120px; background: var(--plot-bg); }
.figure-host canvas.plot { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
.figure-empty { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 2px; text-align: center; color: var(--text-2); padding: 20px; }
.figure-empty p { margin: 2px 0; }
.figure-empty code { color: var(--accent); font-size: 12px; }
.plot-tip {
  position: absolute; z-index: 5; pointer-events: none;
  background: var(--surface-2); border: 1px solid var(--line-strong); border-radius: 0; box-shadow: var(--shadow);
  padding: 4px 8px; font: 11.5px/1.45 var(--font-code); color: var(--text); white-space: pre;
}
.plot-tip i { display: inline-block; width: 8px; height: 8px; border-radius: 0; margin-right: 6px; vertical-align: 0; }
.plot-hint { position: absolute; right: 8px; bottom: 6px; font: 10.5px var(--font-ui); color: var(--faint); pointer-events: none; opacity: 0; transition: opacity .3s; }
.figure-host:hover .plot-hint { opacity: 1; }

.inspector { display: flex; flex-direction: column; border-top: 1px solid var(--line); height: 42%; min-height: 140px; }
.inspector-head { display: flex; align-items: center; justify-content: space-between; height: 32px; padding: 0 6px 0 12px; border-bottom: 1px solid var(--line); flex: none; }
.inspector-title { font: 600 12.5px var(--font-code); }
.inspector-title small { font: 11px var(--font-ui); color: var(--muted); margin-left: 6px; }
.inspector-body { flex: 1; overflow: auto; }
.grid-table { border-collapse: separate; border-spacing: 0; font: 12px var(--font-code); }
.grid-table th { position: sticky; top: 0; background: var(--surface-3); color: var(--muted); font-weight: 600; font-size: 11px; padding: 3px 10px; border-bottom: 1px solid var(--line); border-right: 1px solid var(--line); z-index: 1; text-align: right; }
.grid-table th.rh { position: sticky; left: 0; z-index: 2; }
.grid-table td { padding: 3px 10px; border-bottom: 1px solid var(--line); border-right: 1px solid var(--line); text-align: right; white-space: nowrap; color: var(--text-2); }
.grid-table td.rh { position: sticky; left: 0; background: var(--surface-3); color: var(--muted); font-weight: 600; font-size: 11px; }
.grid-table tr:hover td:not(.rh) { background: var(--hover); }
.inspector-note { padding: 8px 12px; color: var(--muted); font-size: 11.5px; }
.inspector-text { padding: 10px 12px; font: 12.5px var(--font-code); white-space: pre-wrap; }

/* ---------- status bar ---------- */
.statusbar { display: flex; align-items: center; gap: 2px; padding: 0 8px; background: var(--surface); border-top: 1px solid var(--line); font-size: 11.5px; color: var(--muted); }
.status-item { display: inline-flex; align-items: center; gap: 6px; padding: 0 8px; height: 100%; white-space: nowrap; }
.status-spacer { flex: 1; }
#status-isolated.on { color: var(--teal); }

/* ---------- overlays ---------- */
.overlay { position: fixed; inset: 0; z-index: 100; background: rgba(5, 7, 10, 0.5); backdrop-filter: blur(2px); display: grid; justify-items: center; align-items: start; padding-top: 12vh; }
:root[data-theme="light"] .overlay { background: rgba(60, 50, 30, 0.18); }
.palette { width: min(640px, calc(100vw - 32px)); background: var(--surface-2); border: 1px solid var(--line-strong); border-radius: 0; box-shadow: var(--shadow); overflow: hidden; }
.palette input { width: 100%; height: 48px; padding: 0 18px; border: 0; border-bottom: 1px solid var(--line); background: transparent; outline: none; font-size: 15px; }
.palette-list { list-style: none; margin: 0; padding: 6px; max-height: 50vh; overflow: auto; }
.pi { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 0; cursor: pointer; }
.pi.sel { background: var(--accent-soft); }
.pi .pk { flex: none; font: 600 9.5px var(--font-ui); letter-spacing: 0.5px; text-transform: uppercase; padding: 2px 6px; border-radius: 0; color: var(--muted); border: 1px solid var(--line-strong); min-width: 62px; text-align: center; }
.pi .pk.fn { color: var(--syn-fn); }
.pi .pk.file { color: var(--teal); }
.pi .pk.cmd { color: var(--accent); }
.pi .pn { font: 13px var(--font-code); color: var(--text); white-space: nowrap; }
.pi .pd { color: var(--muted); font-size: 12px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.pi .pn mark { background: none; color: var(--accent); font-weight: 700; }
.palette-foot { display: flex; gap: 16px; padding: 8px 14px; border-top: 1px solid var(--line); color: var(--muted); font-size: 11.5px; }
.palette-foot kbd { margin-right: 3px; }

.dialog { width: min(440px, calc(100vw - 32px)); background: var(--surface-2); border: 1px solid var(--line-strong); border-radius: 0; box-shadow: var(--shadow); padding: 18px 18px 14px; }
.dialog h3 { margin: 0 0 10px; font-size: 15px; }
.dialog input[type=text] { width: 100%; height: 34px; padding: 0 10px; border: 1px solid var(--line-strong); border-radius: 0; background: var(--bg); outline: none; font-family: var(--font-code); }
.dialog input[type=text]:focus { border-color: var(--accent-line); }
.dialog p { margin: 0 0 8px; color: var(--text-2); }
.dialog table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.dialog td { padding: 4px 0; color: var(--text-2); }
.dialog td:first-child { width: 46%; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

.toast-host { position: fixed; right: 16px; bottom: 40px; z-index: 120; display: flex; flex-direction: column; gap: 8px; }
.toast { background: var(--surface-2); border: 1px solid var(--line-strong); border-left: 3px solid var(--teal); border-radius: 0; box-shadow: var(--shadow); padding: 8px 14px; font-size: 12.5px; animation: toast-in .18s ease-out; max-width: 360px; }
.toast.err { border-left-color: var(--rose); }
@keyframes toast-in { from { opacity: 0; transform: translateY(6px); } }

/* ---------- narrow screens ---------- */
@media (max-width: 1100px) {
  :root { --dock-w: 360px; --side-w: 210px; }
  .brand { width: auto; }
  .search-trigger span { display: none; }
  .search-trigger { flex: 0 0 auto; margin: 0 auto 0 0; }
}
@media (max-width: 820px) {
  .app, .app.dock-hidden, .app.side-hidden, .app.side-hidden.dock-hidden {
    grid-template-columns: 44px minmax(0, 1fr);
    grid-template-rows: 46px auto minmax(0, 1fr) minmax(0, 0.8fr) 26px;
    grid-template-areas: "top top" "ribbon ribbon" "rail stage" "rail dock" "status status";
  }
  .side, .splitter.v { display: none !important; }
  .app.show-side { grid-template-areas: "top top" "rail side" "rail dock" "status status"; }
  .app.show-side .side { display: flex !important; }
  .app.show-side .stage { display: none; }
  .dock { border-left: 0; border-top: 1px solid var(--line); }
  .app.dock-hidden .dock { display: none; }
  .app.dock-hidden { grid-template-rows: 46px auto minmax(0, 1fr) 0 26px; }
  .brand-name, .run-controls kbd, #section-btn, .sep { display: none; }
  .topbar { gap: 8px; padding: 0 8px; }
  .statusbar #status-cursor, .statusbar #status-isolated, .statusbar #status-figs { display: none; }
  .inspector { height: 50%; }
}

/* ---------- template gallery ---------- */
[data-cat="start"] { --cat: var(--text-2); }
[data-cat="data"] { --cat: var(--teal); }
[data-cat="signal"] { --cat: var(--violet); }
[data-cat="sim"] { --cat: var(--accent); }
[data-cat="math"] { --cat: #4fa3f7; }
[data-cat="eng"] { --cat: #8cc84b; }
[data-cat="fun"] { --cat: var(--rose); }
#templates { padding-top: 6vh; }
.tpl {
  width: min(1120px, calc(100vw - 32px)); height: min(760px, 86vh);
  display: flex; flex-direction: column;
  background: var(--surface-2); border: 1px solid var(--line-strong); border-radius: 0; box-shadow: var(--shadow); overflow: hidden;
}
.tpl-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; padding: 18px 18px 10px 22px; }
.tpl-head h3 { margin: 0 0 3px; font-size: 17px; letter-spacing: -0.2px; }
.tpl-head p { margin: 0; color: var(--muted); font-size: 12.5px; }
.tpl-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; padding: 6px 22px 12px; border-bottom: 1px solid var(--line); }
.tpl-bar input { flex: 0 1 300px; height: 32px; padding: 0 12px; border: 1px solid var(--line-strong); border-radius: 0; background: var(--bg); outline: none; }
.tpl-bar input:focus { border-color: var(--accent-line); }
.tpl-cats { display: flex; flex-wrap: wrap; gap: 6px; }
.tpl-cat { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 11px; border-radius: 0; border: 1px solid var(--line); background: transparent; color: var(--text-2); cursor: pointer; font-size: 12px; }
.tpl-cat span { font-size: 10.5px; color: var(--faint); }
.tpl-cat:hover { border-color: var(--line-strong); color: var(--text); }
.tpl-cat.active { background: var(--accent-soft); border-color: var(--accent-line); color: var(--text); }
.tpl-main { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr); }
.tpl-grid { overflow: auto; padding: 14px; display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); align-content: start; gap: 10px; border-right: 1px solid var(--line); }
.tpl-card {
  display: flex; gap: 11px; align-items: flex-start; text-align: left;
  padding: 12px; border-radius: 0; border: 1px solid var(--line); background: var(--surface); cursor: pointer;
  transition: border-color .12s, background .12s, transform .12s;
}
.tpl-card:hover { border-color: var(--line-strong); transform: translateY(-1px); }
.tpl-card.active { border-color: color-mix(in srgb, var(--cat) 60%, var(--line)); background: color-mix(in srgb, var(--cat) 7%, var(--surface)); }
.tpl-icon { flex: none; width: 38px; height: 38px; display: grid; place-items: center; border-radius: 0; color: var(--cat); background: color-mix(in srgb, var(--cat) 14%, transparent); }
.tpl-body { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.tpl-title { font-weight: 650; font-size: 13px; color: var(--text); }
.tpl-desc { font-size: 11.5px; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.tpl-meta { display: flex; gap: 8px; align-items: center; margin-top: 3px; font: 10.5px var(--font-code); color: var(--faint); overflow: hidden; white-space: nowrap; }
.tpl-level { font: 600 10px var(--font-ui); color: var(--cat); }
.tpl-empty { grid-column: 1 / -1; padding: 30px; text-align: center; color: var(--muted); }
.tpl-preview { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.tpl-ph { padding: 16px 20px 10px; border-left: 3px solid var(--cat); }
.tpl-kicker { font: 700 10.5px var(--font-ui); letter-spacing: 0.7px; text-transform: uppercase; color: var(--cat); }
.tpl-ph h4 { margin: 4px 0 4px; font-size: 16px; }
.tpl-ph p { margin: 0 0 8px; color: var(--text-2); font-size: 12.5px; }
.tpl-tags { display: flex; flex-wrap: wrap; gap: 5px; }
.tpl-tags span { font: 11px var(--font-code); padding: 1px 7px; border-radius: 0; background: var(--surface-3); color: var(--text-2); }
.tpl-files { display: flex; gap: 2px; padding: 0 14px; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.tpl-file { position: relative; height: 32px; padding: 0 10px; border: 0; background: none; color: var(--muted); cursor: pointer; font: 12px var(--font-code); white-space: nowrap; }
.tpl-file:hover { color: var(--text); }
.tpl-file.active { color: var(--text); box-shadow: inset 0 -2px 0 var(--cat); }
.tpl-file i { display: inline-block; width: 6px; height: 6px; border-radius: 0; background: var(--warn); margin-left: 6px; vertical-align: 1px; }
.tpl-code { flex: 1; min-height: 0; margin: 0; overflow: auto; padding: 12px 16px; background: var(--bg); font: 12.5px/1.6 var(--font-code); white-space: pre; tab-size: 4; }
.tpl-actions { display: flex; align-items: center; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--line); }
.tpl-note { flex: 1; font-size: 11.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.editor-empty { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 10px; text-align: center; color: var(--muted); padding: 20px; }
.editor-empty h3 { margin: 0; color: var(--text); font-size: 15px; }
.editor-empty p { margin: 0; max-width: 46ch; }
.editor-empty .row { display: flex; gap: 8px; margin-top: 6px; }
@media (max-width: 820px) {
  #templates { padding-top: 2vh; }
  .tpl { height: 94vh; }
  .tpl-main { grid-template-columns: 1fr; grid-template-rows: minmax(0, 0.7fr) minmax(0, 1.3fr); }
  .tpl-ph p, .tpl-tags { display: none; }
  .tpl-grid { border-right: 0; border-bottom: 1px solid var(--line); grid-template-columns: 1fr; }
  .tpl-head p { display: none; }
}

/* ---------- accounts ---------- */
.account { position: relative; display: flex; align-items: center; }
.google-btn {
  display: inline-flex; align-items: center; gap: 9px; height: 30px; padding: 0 12px 0 9px;
  border: 1px solid var(--line-strong); background: var(--surface-2); color: var(--text); cursor: pointer;
  font: 550 12.5px var(--font-ui); white-space: nowrap;
}
.google-btn:hover { background: var(--hover); border-color: var(--text-2); }
.google-btn svg { flex: none; }
.avatar-btn { display: inline-flex; align-items: center; gap: 8px; height: 30px; padding: 0 8px 0 3px; border: 1px solid transparent; background: none; color: var(--text-2); cursor: pointer; font-size: 12.5px; }
.avatar-btn:hover, .avatar-btn[aria-expanded="true"] { border-color: var(--line-strong); background: var(--hover); color: var(--text); }
.avatar { width: 24px; height: 24px; display: grid; place-items: center; background: var(--accent); color: var(--accent-ink); font: 700 11px var(--font-ui); letter-spacing: 0.3px; }
.avatar-name { max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-menu {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 70; width: 270px;
  background: var(--surface-2); border: 1px solid var(--line-strong); box-shadow: var(--shadow); padding: 12px;
}
.account-menu .who { display: flex; gap: 10px; align-items: center; padding-bottom: 10px; border-bottom: 1px solid var(--line); }
.account-menu .who .avatar { width: 34px; height: 34px; font-size: 13px; }
.account-menu .who b { display: block; font-size: 13px; color: var(--text); }
.account-menu .who div span { font-size: 11.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; display: block; max-width: 200px; }
.account-menu p { margin: 10px 0; font-size: 12px; color: var(--text-2); display: flex; gap: 8px; }
.account-menu p::before { content: ""; flex: none; width: 7px; height: 7px; margin-top: 5px; background: var(--teal); }
.account-menu .btn { width: 100%; justify-content: center; }
#status-account { cursor: pointer; }
#status-account.guest { color: var(--warn); }
#status-account.user { color: var(--teal); }
.panel-sub.guest { color: var(--warn); font-family: var(--font-ui); line-height: 1.45; }
.panel-sub.guest a { color: var(--text); cursor: pointer; text-decoration: underline; }
.panel-sub.user { font-family: var(--font-ui); }
@media (max-width: 820px) { .avatar-name, .google-btn span { display: none; } .google-btn { padding: 0 8px; } }

/* workspaces in the account menu */
.account-menu { width: 300px; }
.ws-section { padding: 10px 0 2px; border-bottom: 1px solid var(--line); }
.ws-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; font: 700 10.5px var(--font-ui); letter-spacing: 0.8px; text-transform: uppercase; color: var(--muted); }
.ws-new { border: 1px solid var(--line-strong); background: none; color: var(--text-2); font: 600 11px var(--font-ui); padding: 2px 8px; cursor: pointer; text-transform: none; letter-spacing: 0; }
.ws-new:hover { color: var(--text); border-color: var(--accent-line); }
.ws-list { list-style: none; margin: 0 0 8px; padding: 0; max-height: 220px; overflow: auto; }
.ws-item { display: flex; align-items: center; gap: 8px; padding: 6px; cursor: pointer; color: var(--text-2); font-size: 12.5px; }
.ws-item:hover { background: var(--hover); color: var(--text); }
.ws-item.active { background: var(--accent-soft); color: var(--text); cursor: default; }
.ws-mark { width: 7px; height: 7px; flex: none; border: 1px solid var(--line-strong); }
.ws-item.active .ws-mark { background: var(--accent); border-color: var(--accent); }
.ws-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ws-meta { font: 10.5px var(--font-code); color: var(--faint); }
.ws-act { display: none; border: 0; background: none; color: var(--muted); cursor: pointer; width: 20px; height: 20px; padding: 0; }
.ws-act:hover { color: var(--text); background: var(--line); }
.ws-item:hover .ws-act { display: inline-block; }
.ws-loading { padding: 6px; color: var(--muted); font-size: 12px; }
.ws-opt { display: flex; align-items: center; gap: 8px; padding: 3px 0; color: var(--text-2); cursor: pointer; }
.panel-sub.user a { color: var(--accent); cursor: pointer; font-weight: 600; text-decoration: none; }
.panel-sub.user a::after { content: " ▾"; font-size: 9px; }
.ws-opt input { appearance: none; -webkit-appearance: none; margin: 0; width: 13px; height: 13px; border: 1px solid var(--line-strong); background: var(--bg); cursor: pointer; flex: none; }
.ws-opt input:checked { background: var(--accent); border-color: var(--accent); box-shadow: inset 0 0 0 2px var(--surface-2); }

/* sharing: "Shared with you" and the Share dialog */
.ws-name small { display: block; font-size: 10.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; }
.ws-act svg { vertical-align: middle; }
.panel-sub.user .ro { color: var(--warn); font-weight: 600; }
.share { width: 100%; }
.share-form { display: grid; gap: 8px; margin: 10px 0 4px; }
.share-form-row { display: flex; gap: 8px; }
.share-form-row .btn { flex: 1; justify-content: center; }
.share input[type=email], .share input[type=text] { width: 100%; height: 32px; padding: 0 10px; border: 1px solid var(--line-strong); border-radius: 0; background: var(--bg); color: var(--text); outline: none; font: 12.5px var(--font-ui); }
.share input:focus, .share select:focus { border-color: var(--accent-line); }
.share select { height: 32px; padding: 0 6px; border: 1px solid var(--line-strong); border-radius: 0; background: var(--bg); color: var(--text); font: 12px var(--font-ui); cursor: pointer; }
.share-new { display: flex; gap: 8px; margin: 8px 0 0; }
.share-new input[type=text] { font-family: var(--font-code); font-size: 11.5px; }
.share-h { margin: 16px 0 6px; font: 700 10.5px var(--font-ui); letter-spacing: 0.8px; text-transform: uppercase; color: var(--muted); }
.share-list { list-style: none; margin: 0; padding: 0; max-height: 240px; overflow: auto; border-top: 1px solid var(--line); }
.share-row { display: flex; align-items: center; gap: 10px; padding: 7px 2px; border-bottom: 1px solid var(--line); }
.share-row .avatar { width: 28px; height: 28px; flex: none; }
.share-row .avatar.ghost { background: none; border: 1px dashed var(--line-strong); color: var(--muted); }
.share-who { flex: 1; min-width: 0; }
.share-who b { display: block; font-size: 12.5px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.share-who span { display: block; font-size: 11px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.share-tag { font-size: 11.5px; color: var(--muted); padding-right: 4px; }
.share-row select { height: 26px; }
.share-row .ws-act { display: inline-block; flex: none; }
.dialog:has(.share) { width: min(480px, calc(100vw - 32px)); }

#share-btn[hidden] { display: none; }
@media (max-width: 820px) { #share-btn span { display: none; } }

/* ---------- collaboration ---------- */
/* folders in the file tree */
.file-item { padding-left: calc(8px + var(--depth, 0) * 14px); }
.file-item.folder .ficon.fold { width: auto; background: none; color: var(--muted); display: inline-flex; gap: 2px; align-items: center; }
.file-item.folder .caret { width: 9px; font-size: 9px; color: var(--faint); }
.file-item.folder .fname { color: var(--text-2); font-weight: 550; }
.file-item.drop, .file-list.drop-root { outline: 1px dashed var(--accent-line); outline-offset: -1px; background: var(--accent-soft); }

/* people here now */
.presence { display: flex; align-items: center; cursor: pointer; padding-right: 2px; }
.presence[hidden] { display: none; }
.pavatar { width: 24px; height: 24px; display: inline-grid; place-items: center; flex: none; background: var(--pc, var(--muted)); color: #fff; font: 700 10px var(--font-ui); letter-spacing: 0.2px; border: 2px solid var(--surface); margin-left: -6px; text-shadow: 0 1px 1px rgba(0,0,0,.25); }
.presence .pavatar:first-child { margin-left: 0; }
.pavatar.more { background: var(--surface-3); color: var(--text-2); text-shadow: none; }
.pavatar.small { width: 22px; height: 22px; margin: 0; font-size: 9.5px; border: 0; }
.pavatar.tiny { width: 15px; height: 15px; font-size: 7.5px; border-width: 1px; margin-left: -4px; }
.pmarks { display: inline-flex; padding-left: 4px; flex: none; }
.pmarks .pavatar.tiny:first-child { margin-left: 0; }
.here-list { list-style: none; margin: 0; padding: 0; }
.here-list li { display: flex; gap: 10px; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--line); }
.here-list li .pavatar { margin: 0; width: 28px; height: 28px; }
.here-list b { display: block; font-size: 13px; color: var(--text); }
.here-list span { font-size: 11.5px; color: var(--muted); }
.etab .remote-mark { width: 7px; height: 7px; background: var(--rose); }
.etab.remote span:first-child { color: var(--rose); }
@media (max-width: 820px) { #projects-btn span { display: none; } .presence { display: none; } }

/* wide dialogs: history, conflicts, snippets */
.dialog:has(.wide) { width: min(860px, calc(100vw - 32px)); }
.muted { color: var(--muted); }
.hist { display: grid; grid-template-columns: 210px minmax(0, 1fr); gap: 12px; height: min(60vh, 520px); }
.hlist { list-style: none; margin: 0; padding: 0; overflow: auto; border: 1px solid var(--line); }
.hrow { padding: 7px 10px; cursor: pointer; border-bottom: 1px solid var(--line); }
.hrow b { display: block; font-size: 12.5px; color: var(--text); font-weight: 600; }
.hrow span { font-size: 11px; color: var(--muted); }
.hrow:hover { background: var(--hover); }
.hrow.sel { background: var(--accent-soft); box-shadow: inset 2px 0 0 var(--accent); }
.hempty { padding: 10px; color: var(--muted); font-size: 12px; }
.hview { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.hbar { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; min-height: 30px; }
.hnote { font-size: 12px; color: var(--muted); }
.hsp { flex: 1; }
.hmode { display: flex; align-items: center; gap: 5px; font-size: 12px; color: var(--text-2); cursor: pointer; white-space: nowrap; }
.hpre { flex: 1; overflow: auto; border: 1px solid var(--line); background: var(--bg); font: 12.5px/1.55 var(--font-code); min-height: 0; }
.conflict .hpre { max-height: 46vh; }
.hcode { margin: 0; padding: 8px 12px; white-space: pre; }
.diff-line { display: grid; grid-template-columns: 34px 34px 16px 1fr; white-space: pre; }
.diff-line .ln { color: var(--faint); text-align: right; padding-right: 6px; user-select: none; font-size: 11px; }
.diff-line .mk { color: var(--muted); user-select: none; }
.diff-line code { font: inherit; padding-right: 12px; }
.diff-line.add { background: color-mix(in srgb, var(--teal) 14%, transparent); }
.diff-line.add .mk { color: var(--teal); }
.diff-line.del { background: var(--rose-soft); }
.diff-line.del .mk { color: var(--rose); }
.diff-fold { padding: 3px 12px; color: var(--faint); background: var(--surface); font-size: 11px; font-family: var(--font-ui); }
.diff-same { padding: 12px; color: var(--muted); font-family: var(--font-ui); }
@media (max-width: 700px) { .hist { grid-template-columns: 1fr; grid-template-rows: 140px 1fr; height: 70vh; } }

.del-list { list-style: none; margin: 8px 0 0; padding: 0; max-height: 50vh; overflow: auto; border-top: 1px solid var(--line); }
.del-list li { display: flex; align-items: center; gap: 10px; padding: 8px 2px; border-bottom: 1px solid var(--line); }
.del-list li div { flex: 1; min-width: 0; }
.del-list b { display: block; font: 12.5px var(--font-code); color: var(--text); overflow: hidden; text-overflow: ellipsis; }
.del-list span { font-size: 11px; color: var(--muted); }

/* activity panel */
.activity-list { list-style: none; margin: 0; padding: 0 6px 10px; overflow: auto; flex: 1; }
.act { display: flex; gap: 8px; padding: 7px 6px; border-bottom: 1px solid var(--line); font-size: 12px; color: var(--text-2); line-height: 1.4; }
.act div { min-width: 0; overflow-wrap: anywhere; }
.act .awho { color: var(--text); font-weight: 600; }
.act a { color: var(--accent); cursor: pointer; font-family: var(--font-code); font-size: 11.5px; }
.act a:hover { text-decoration: underline; }
.act .acount { color: var(--muted); font-size: 11px; }
.act .atime { display: block; color: var(--faint); font-size: 10.5px; margin-top: 1px; }
.act-empty { padding: 10px 6px; color: var(--muted); font-size: 12px; line-height: 1.5; }

.ws-opt input[type=checkbox] { appearance: none; -webkit-appearance: none; margin: 0; width: 13px; height: 13px; border: 1px solid var(--line-strong); background: var(--bg); cursor: pointer; flex: none; }
.ws-opt input[type=checkbox]:checked { background: var(--accent); border-color: var(--accent); box-shadow: inset 0 0 0 2px var(--surface-2); }
.ws-opt input:disabled { opacity: 0.4; cursor: default; }
.share-new a.btn { text-decoration: none; }
a.ws-act { display: inline-grid; place-items: center; text-decoration: none; }

/* ---------- live editing ---------- */
.ke-remote { position: absolute; inset: 0; pointer-events: none; z-index: 1; }
.ke-rsel { position: absolute; background: color-mix(in srgb, var(--rc) 22%, transparent); }
.ke-rcaret { position: absolute; width: 2px; margin-left: -1px; background: var(--rc); }
.ke-rcaret span { position: absolute; left: -1px; bottom: 100%; padding: 0 4px; background: var(--rc); color: #fff; font: 600 10px/15px var(--font-ui); white-space: nowrap; opacity: 0.92; text-shadow: 0 1px 1px rgba(0,0,0,.25); }
.ke.readonly .ke-input { cursor: default; }
.etab .live-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--teal); box-shadow: 0 0 0 2px var(--teal-soft); }
.etab .sync { width: 6px; height: 6px; border-radius: 50%; border: 1.5px solid var(--teal); border-top-color: transparent; animation: kl-spin 0.8s linear infinite; }
@keyframes kl-spin { to { transform: rotate(360deg); } }
.panel-sub.view { font-family: var(--font-ui); line-height: 1.5; color: var(--text-2); }
.panel-sub.view a { color: var(--accent); cursor: pointer; }
.panel-sub.view .ro { color: var(--warn); }

/* ---------- gutter markers (extensions) ---------- */
.ke-gutter .ln.mk-error { color: var(--rose); box-shadow: inset 3px 0 0 var(--rose); }
.ke-gutter .ln.mk-warn { color: var(--warn); box-shadow: inset 3px 0 0 var(--warn); }
.ke-gutter .ln.mk-info { box-shadow: inset 3px 0 0 var(--line-strong); }
.ke-gutter .ln[title] { cursor: help; pointer-events: auto; }

/* ---------- editor bar: tabs + extension actions ---------- */
.editor-bar { display: flex; align-items: stretch; flex: none; background: var(--surface); border-bottom: 1px solid var(--line); min-width: 0; }
.editor-bar .editor-tabs { flex: 1; min-width: 0; border-bottom: 0; }
.ext-actions { display: flex; align-items: center; gap: 2px; padding: 0 6px; flex: none; }
.ext-actions:empty { display: none; }
.ext-act { height: 24px; min-width: 24px; display: inline-grid; place-items: center; padding: 0 8px; border: 1px solid transparent; background: none; color: var(--text-2); font: 600 11.5px var(--font-ui); cursor: pointer; }
.ext-act.icon { padding: 0; width: 26px; }
.ext-act:hover { background: var(--hover); color: var(--text); border-color: var(--line); }
.ext-act.on { background: var(--accent-soft); color: var(--text); border-color: var(--accent-line); }
.ext-preview { position: absolute; inset: 0; z-index: 5; overflow: auto; background: var(--surface-2); }

/* rail badges and extension panels */
.rail-badge { position: absolute; top: 3px; right: 2px; min-width: 15px; height: 15px; padding: 0 3px; display: grid; place-items: center; background: var(--rose); color: #fff; font: 700 9px/1 var(--font-ui); }
.rail-badge[hidden] { display: none; }
.ext-panel-body { flex: 1; overflow: auto; padding: 0 6px 10px; display: flex; flex-direction: column; gap: 6px; }
.ext-empty { color: var(--muted); font-size: 12px; line-height: 1.5; padding: 4px 6px; margin: 0; }
.ext-sub { font-size: 11.5px; color: var(--muted); padding: 2px 6px; }
.ext-row { display: flex; align-items: center; gap: 10px; padding: 2px 4px; }
.ext-list { list-style: none; margin: 0; padding: 0; }
.prob { display: grid; grid-template-columns: 16px 1fr auto; gap: 6px; padding: 6px; cursor: pointer; font-size: 12px; color: var(--text-2); border-bottom: 1px solid var(--line); align-items: start; }
.prob:hover { background: var(--hover); color: var(--text); }
.prob .psev { width: 16px; height: 16px; display: grid; place-items: center; font: 700 10px var(--font-ui); color: #fff; background: var(--faint); }
.prob.error .psev { background: var(--rose); }
.prob.warn .psev { background: var(--warn); color: #1a1203; }
.prob .pline { color: var(--faint); font: 10.5px var(--font-code); white-space: nowrap; }
.tsum { font-size: 12px; }
.tsum .ok { color: var(--teal); }
.tsum .bad { color: var(--rose); }
.tres { display: grid; grid-template-columns: 18px 1fr; gap: 6px; padding: 6px; border-bottom: 1px solid var(--line); cursor: pointer; font-size: 12px; }
.tres:hover { background: var(--hover); }
.tres .tmark { font-weight: 700; text-align: center; }
.tres.ok .tmark { color: var(--teal); }
.tres.bad .tmark { color: var(--rose); }
.tres.run .tmark { color: var(--muted); }
.tres .tname b { display: block; color: var(--text); font-weight: 600; }
.tres .tname span { display: block; font-size: 11px; color: var(--muted); }
.tres .tname em { display: block; font-style: normal; color: var(--rose); font: 11.5px var(--font-code); margin-top: 3px; white-space: pre-wrap; }

/* data viewer */
.dv-bar { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; gap: 12px; padding: 8px 12px; background: var(--surface); border-bottom: 1px solid var(--line); font-size: 12px; color: var(--muted); }
.dv-bar b { color: var(--text); font-family: var(--font-code); }
.dv-bar .sp { flex: 1; }
.dv { border-collapse: collapse; font: 12px var(--font-code); min-width: 100%; }
.dv th, .dv td { border: 1px solid var(--line); padding: 3px 8px; text-align: left; white-space: nowrap; }
.dv thead th { background: var(--surface-3); color: var(--text); cursor: pointer; font-family: var(--font-ui); font-weight: 600; }
.dv thead th.sorted::after { content: " " attr(data-dir); color: var(--accent); }
.dv td.n { text-align: right; }
.dv .rn { color: var(--faint); text-align: right; background: var(--surface); }
.dv-stats td { background: var(--surface); vertical-align: top; font-size: 10.5px; color: var(--muted); }
.dv-stats td span { display: block; }
.dv-stats .miss { color: var(--warn); }
.lnk { border: 0; background: none; padding: 0; margin-top: 2px; color: var(--accent); cursor: pointer; font: 600 11px var(--font-ui); }

/* markdown preview */
.md { max-width: 820px; margin: 0 auto; padding: 18px 28px 40px; font-size: 14px; line-height: 1.6; color: var(--text); }
.md h1, .md h2, .md h3 { line-height: 1.25; margin: 1.2em 0 0.5em; }
.md h1 { font-size: 1.7em; border-bottom: 1px solid var(--line); padding-bottom: 0.3em; }
.md h2 { font-size: 1.35em; border-bottom: 1px solid var(--line); padding-bottom: 0.2em; }
.md code { font-family: var(--font-code); font-size: 0.9em; background: var(--surface-3); padding: 1px 4px; }
.md pre.md-code { background: var(--bg); border: 1px solid var(--line); padding: 10px 12px; overflow: auto; font: 12.5px/1.55 var(--font-code); }
.md blockquote { margin: 0.8em 0; padding: 2px 14px; border-left: 3px solid var(--accent-line); color: var(--text-2); }
.md table { border-collapse: collapse; margin: 0.8em 0; }
.md th, .md td { border: 1px solid var(--line); padding: 4px 10px; }
.md th { background: var(--surface-3); }
.md a { color: var(--accent); }
.md li.task { list-style: none; margin-left: -1.2em; }
.md .box { display: inline-block; width: 11px; height: 11px; border: 1px solid var(--line-strong); margin-right: 7px; vertical-align: -1px; }
.md .box.on { background: var(--teal); border-color: var(--teal); }
.md hr { border: 0; border-top: 1px solid var(--line); margin: 1.4em 0; }

/* snippets picker */
.snip-q { width: 100%; height: 32px; padding: 0 10px; border: 1px solid var(--line-strong); background: var(--bg); color: var(--text); outline: none; font: 13px var(--font-ui); margin-bottom: 8px; }
.snip-grid { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 10px; height: min(50vh, 380px); }
.snip-list { list-style: none; margin: 0; padding: 0; overflow: auto; border: 1px solid var(--line); }
.snip-list li { padding: 6px 10px; cursor: pointer; display: flex; justify-content: space-between; gap: 8px; font-size: 12.5px; }
.snip-list li span { color: var(--faint); font: 11px var(--font-code); }
.snip-list li.sel { background: var(--accent-soft); box-shadow: inset 2px 0 0 var(--accent); }
.snip-list li.none { color: var(--muted); cursor: default; }
.snip-pre { margin: 0; padding: 10px 12px; overflow: auto; border: 1px solid var(--line); background: var(--bg); font: 12.5px/1.55 var(--font-code); }

.pj-card { display: flex; flex-direction: column; gap: 8px; padding: 14px; background: var(--surface); border: 1px solid var(--line); min-width: 0; }
.pj-card:hover { border-color: var(--line-strong); }
.pj-card.current { border-color: var(--accent-line); box-shadow: inset 3px 0 0 var(--accent); }
.pj-card-top { display: flex; gap: 10px; align-items: center; min-width: 0; }
.pj-ico { width: 34px; height: 34px; flex: none; display: grid; place-items: center; background: var(--surface-3); color: var(--text-2); }
.pj-ico .avatar { width: 34px; height: 34px; font-size: 12px; }
.pj-card-t { min-width: 0; }
.pj-card-t b { display: block; font-size: 14px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pj-card-t span { display: block; font-size: 11.5px; color: var(--muted); margin-top: 1px; }
.pj-desc { margin: 0; font-size: 12.5px; color: var(--text-2); line-height: 1.45; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.pj-badges { display: flex; flex-wrap: wrap; gap: 4px; }
.pj-badge { font: 600 10.5px var(--font-ui); padding: 1px 6px; background: var(--surface-3); color: var(--text-2); }
.pj-badge.now { background: var(--accent-soft); color: var(--accent); }
.pj-badge.pub { background: var(--teal-soft); color: var(--teal); }
.pj-acts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: auto; padding-top: 4px; align-items: center; }
.pj-acts .btn { height: 26px; padding: 0 10px; font-size: 12px; }
.ext-card.on { border-color: color-mix(in srgb, var(--teal) 45%, transparent); }
.ext-on { font-size: 11.5px; color: var(--teal); font-weight: 600; }
.pubset label { display: block; margin: 10px 0 0; font: 700 10.5px var(--font-ui); letter-spacing: 0.8px; text-transform: uppercase; color: var(--muted); }
.pubset input[type=text], .pubset textarea { display: block; width: 100%; margin-top: 6px; padding: 7px 10px; border: 1px solid var(--line-strong); background: var(--bg); color: var(--text); outline: none; font: 13px var(--font-ui); text-transform: none; letter-spacing: 0; resize: vertical; }
.pubset .share-new { margin-top: 12px; }
.pubset .share-new input { font-family: var(--font-code); font-size: 11.5px; }
.am-now { display: flex; justify-content: space-between; gap: 10px; padding: 10px 0 8px; font-size: 12px; color: var(--muted); }
.am-now b { color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-menu .btn.primary { margin-bottom: 4px; }
.brand { cursor: pointer; }
@media (max-width: 760px) {
  .snip-grid { grid-template-columns: 1fr; grid-template-rows: 150px 1fr; }
}

/* the tab row scrolls instead of widening the editor */
.editor-pane, .console-pane { min-width: 0; }

/* =====================================================================================
   Design rules (see the top of this file). Kept together so the system stays enforceable:
   the accent appears only on primary actions, active/selected states and key metrics.
   ===================================================================================== */

/* ---- no blur, no decorative glow ---- */
.overlay, :root[data-theme="light"] .overlay { background: rgba(18, 20, 26, 0.78); backdrop-filter: none; -webkit-backdrop-filter: none; }
:root[data-theme="light"] .overlay { background: rgba(17, 19, 24, 0.32); }
.entry.running { background: none; }
.out-fig:hover { transform: none; }

/* ---- buttons: the glow lives here, on primary actions, while hovered or pressed ---- */
.btn { font-weight: 600; letter-spacing: 0.1px; }
.btn:hover:not(:disabled) { border-color: var(--faint); }
.btn.primary { font-weight: 700; }
/* primary: a slightly deeper shade on hover, no glow */
.btn.primary:hover:not(:disabled) { filter: brightness(0.92); background: var(--primary); border-color: var(--primary); box-shadow: none; }
.btn.primary:active:not(:disabled) { filter: brightness(0.86); }
.btn.danger:not(:disabled):hover { border-color: var(--rose); }
.btn:focus-visible, .icon-btn:focus-visible, .pj-tab:focus-visible { outline: 1px solid var(--accent-line); outline-offset: 1px; }
.btn kbd { background: rgba(0, 0, 0, 0.16); }

/* ---- typography: crisp headings, monospaced numbers ---- */
h1, h2, h3, .pj-title, .dialog h3, .tpl-head h3, .welcome h1 { color: var(--text); letter-spacing: -0.02em; }
.dialog h3 { font-size: 16px; font-weight: 750; margin-bottom: 14px; }
.panel-head h2 { color: var(--text); font-weight: 700; }
#status-vars, #status-figs, #status-cursor, .entry-meta, .ws-meta, .pj-card-t span, .tres .tname span, .act .atime,
.hrow span, .del-list span, .share-who span, .pline, .ftab .fnum, .rail-badge, .dv-stats, .pub-list span {
  font-family: var(--font-code); font-variant-numeric: tabular-nums; letter-spacing: 0;
}
.pj-card-t span, .share-who span { font-size: 11px; }

/* ---- cards: flat, one hairline border, generous padding, never nested ---- */
.dialog { padding: var(--pad); border-color: var(--line); }
.dialog-actions { margin-top: var(--pad); }
.account-menu { padding: 20px var(--pad) var(--pad); border-color: var(--line); }
.pj-card { padding: var(--pad); gap: 12px; border-color: var(--line); }
.pj-card:hover { border-color: var(--faint); }
.pj-acts { padding-top: 8px; }
.palette, .completion, .sig-hint, .toast, .tpl { border-color: var(--line); }
.toast { border-left: 1px solid var(--line); padding: 12px 16px; }
.toast.err { border-left: 3px solid var(--rose); }

/* ---- active and selected states: the accent ---- */
.etab .live-dot { background: var(--ok-text); box-shadow: none; }
.etab .sync { border-color: var(--ok-text); border-top-color: transparent; }
.kernel-state.idle i, .status-item.idle .dot { background: var(--ok-text); }
.ftab.active::after { background: var(--accent); }
.ke-band.flash { background: var(--accent-soft); }
.ext-card.on { border-color: var(--accent-line); }
.ext-on, .tsum .ok, .tres.ok .tmark { color: var(--ok-text); }
.md .box.on { background: var(--accent); border-color: var(--accent); }
.diff-line.add { background: var(--ok-bg); }
.diff-line.add .mk { color: var(--ok-text); }
.tpl-card.active { border-color: var(--accent-line); background: var(--surface); }
.tpl-file.active { box-shadow: inset 0 -2px 0 var(--accent); }

/* ---- everything else is neutral (no accent as decoration) ---- */
[data-cat] { --cat: var(--muted) !important; }
.file-item .ficon.m, .file-item .ficon.d { background: var(--surface-3); color: var(--text-2); }
.etab .dirty { background: var(--text); }
.avatar, .pavatar { background: var(--surface-3); color: var(--text); border-color: var(--surface); text-shadow: none; }
.pavatar.more { color: var(--text-2); }
.ke-rcaret span { color: var(--bg); text-shadow: none; }
#status-account.user, #status-isolated.on { color: var(--muted); }
.account-menu p::before { background: var(--line); }
.pj-badge.pub { background: var(--surface-3); color: var(--text); }
.ke-band.sectionrule { background: var(--line); opacity: 1; }
.ke-band.section { border-left-color: var(--line); }
.entry-meta .ok { color: var(--muted); }
.chip:hover { border-color: var(--faint); background: var(--surface-3); }
.var-empty code, .figure-empty code, .out-eh b, .out-err .eh b, .welcome h1 span, .pj-brand b, .brand-name b { color: var(--text); }
.completion .ci .k.u, .pi .pk.cmd { color: var(--text-2); background: var(--surface-3); }
/* links: off-white, underlined, rather than colored */
.panel-sub.user a, .panel-sub.view a, .act a, .lnk, .md a, .out-more, .panel-sub.guest a {
  color: var(--text); text-decoration: underline; text-decoration-color: var(--faint); text-underline-offset: 2px;
}
.panel-sub.user a:hover, .panel-sub.view a:hover, .act a:hover, .lnk:hover, .md a:hover, .out-more:hover { text-decoration-color: var(--text); }
.md blockquote { border-left-color: var(--line); }

.pj-ico { background: var(--surface-3); }
@media (max-width: 760px) {
  .pj-card { padding: 20px; }
}

/* toggle switches: the accent marks the "on" state */
.switch { display: inline-flex; align-items: center; gap: 10px; padding: 0; border: 0; background: none; cursor: pointer; color: var(--text-2); font: 600 12px var(--font-ui); }
.switch:disabled { opacity: 0.45; cursor: default; }
.switch-track { position: relative; width: 34px; height: 18px; flex: none; background: var(--surface-3); border: 1px solid var(--line); transition: background .15s, border-color .15s; }
.switch-knob { position: absolute; top: 2px; left: 2px; width: 12px; height: 12px; background: var(--text-2); transition: transform .15s, background .15s; }
.switch[aria-checked="true"] .switch-track { background: var(--accent); border-color: var(--accent); }
.switch[aria-checked="true"] .switch-knob { transform: translateX(16px); background: var(--accent-ink); }
.switch[aria-checked="true"] .switch-label { color: var(--text); }
.switch:hover:not(:disabled) .switch-track { border-color: var(--faint); }
.switch:focus-visible { outline: 1px solid var(--accent-line); outline-offset: 3px; }
/* extension cards stay neutral; the switch shows the state. Their subtitles are words, not numbers. */
.ext-card.on { border-color: var(--line); }
.ext-card .pj-card-t span { font-family: var(--font-ui); font-size: 11.5px; }

/* =====================================================================================
   Components: badges, buttons and the project card (second design brief, applied app-wide)
   ===================================================================================== */

/* ---- badges: filled, high contrast, never outlined ---- */
.pj-badge, .share-tag, .out-val .badge {
  display: inline-flex; align-items: center; height: 22px; padding: 0 8px;
  background: var(--badge-bg); color: var(--badge-text); border: 0;
  font: 600 11px/1 var(--font-ui); letter-spacing: 0.1px; white-space: nowrap;
}
.pj-badge.now { background: var(--ok-bg); color: var(--ok-text); }
.pj-badge.pub { background: var(--badge-bg); color: var(--badge-text); }
.share-tag { margin-right: 4px; }
.out-val .badge { height: 20px; font-size: 10.5px; vertical-align: 1px; }

/* ---- buttons ---- */
/* secondary: a subtle dark surface, no outline */
.btn { background: var(--control); border-color: transparent; color: var(--text); }
.btn:hover:not(:disabled) { background: var(--control-hover); border-color: transparent; }
/* destructive (Leave, Delete, Stop, Make private): a ghost with red text */
.btn.danger:not(:disabled) { background: transparent; border-color: transparent; color: var(--rose); }
.btn.danger:not(:disabled):hover { background: var(--danger-hover); border-color: transparent; color: var(--rose); }
.btn.danger:disabled { background: transparent; border-color: transparent; }
/* primary keeps the accent (and its hover glow) */
.btn.primary { border-color: var(--primary); }

/* ---- the project card: identity, then tags, then actions ---- */
.pj-card { gap: 0; padding: var(--pad); background: var(--surface); border: 1px solid var(--line); }
.pj-card:hover { border-color: var(--line); background: var(--surface); }
.pj-card.current { border-color: var(--line); box-shadow: inset 2px 0 0 var(--accent); }
.pj-card-top { display: grid; grid-template-columns: 40px minmax(0, 1fr); gap: 14px; align-items: center; }
.pj-ico { width: 40px; height: 40px; background: var(--badge-bg); color: var(--badge-text); }
.pj-ico .avatar { width: 40px; height: 40px; font-size: 13px; background: var(--badge-bg); color: var(--text); }
.pj-card-t b { font-size: 15px; font-weight: 700; color: var(--text); letter-spacing: -0.01em; line-height: 1.3; }
.pj-card-t span { margin-top: 3px; color: var(--muted); }
.pj-desc { margin-top: 14px; color: var(--muted); }
.pj-badges { margin-top: 16px; gap: 6px; }
.pj-acts { margin-top: auto; padding-top: 16px; gap: 8px; }
.pj-badges + .pj-acts, .pj-desc + .pj-acts, .pj-card-top + .pj-acts { margin-top: 20px; border-top: 1px solid var(--line); }
.pj-acts .btn { height: 30px; padding: 0 12px; font-size: 12.5px; }
.pj-acts .btn.danger { margin-left: auto; }
.pj-acts .btn.danger ~ .btn.danger { margin-left: 0; }
.ext-card .pj-card-t { display: block; }
.ext-card .pj-acts { border-top: 1px solid var(--line); margin-top: 20px; }

/* =====================================================================================
   Projects page (/projects): a document manager — top bar, sidebar, recent strip, list/grid
   ===================================================================================== */
body.pj-page { overflow: hidden; background: var(--bg); }
#projects { height: 100%; }
.pm { height: 100vh; height: 100dvh; display: grid; grid-template-columns: 232px minmax(0, 1fr); grid-template-rows: 52px minmax(0, 1fr); background: var(--bg); }

/* top bar */
.pm-top { grid-column: 1 / -1; display: flex; align-items: center; gap: 16px; padding: 0 16px; background: var(--surface); border-bottom: 1px solid var(--line); min-width: 0; }
.pm-logo { display: flex; align-items: center; gap: 9px; width: 200px; flex: none; color: var(--text); text-decoration: none; font: 600 16px var(--font-ui); letter-spacing: -0.2px; }
.pm-logo b { font-weight: 800; }
.pm-search { flex: 1 1 auto; max-width: 560px; margin: 0 auto; display: flex; align-items: center; gap: 8px; height: 34px; padding: 0 12px; background: var(--bg); border: 1px solid var(--line); color: var(--faint); }
.pm-search:focus-within { border-color: var(--accent-line); }
.pm-search input { flex: 1; min-width: 0; height: 100%; border: 0; outline: none; background: none; color: var(--text); font: 13px var(--font-ui); }
.pm-search input::placeholder { color: var(--faint); font-style: italic; }
.pm-top-r { display: flex; align-items: center; gap: 10px; flex: none; }
.pm-back { display: inline-flex; align-items: center; gap: 4px; height: 30px; padding: 0 12px; background: var(--control); color: var(--text-2); text-decoration: none; font-size: 12.5px; max-width: 260px; overflow: hidden; white-space: nowrap; }
.pm-back b { color: var(--text); font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.pm-back:hover { background: var(--control-hover); color: var(--text); }
.pm-user { display: inline-flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--text); }
.pm-user .avatar { width: 28px; height: 28px; font-size: 11px; background: var(--badge-bg); color: var(--text); }

/* sidebar */
.pm-side { display: flex; flex-direction: column; gap: 14px; padding: 16px 12px; background: var(--surface); border-right: 1px solid var(--line); min-height: 0; overflow: auto; }
.pm-create { position: relative; }
.pm-create-btn { width: 100%; height: 36px; justify-content: center; font-size: 13px; }
.pm-caret { font-size: 10px; opacity: 0.85; }
.pm-menu { position: absolute; left: 0; right: 0; top: calc(100% + 6px); z-index: 20; display: flex; flex-direction: column; padding: 6px; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); }
.pm-menu button { display: flex; align-items: center; gap: 12px; padding: 10px; border: 0; background: none; color: var(--text-2); cursor: pointer; text-align: left; }
.pm-menu button:hover { background: var(--hover); color: var(--text); }
.pm-menu b { display: block; color: var(--text); font-size: 13px; font-weight: 600; }
.pm-menu small { display: block; color: var(--muted); font-size: 11.5px; margin-top: 1px; }
.pm-nav { display: flex; flex-direction: column; gap: 1px; }
.pm-nav-i { display: flex; align-items: center; gap: 11px; height: 34px; padding: 0 10px; border: 0; background: none; color: var(--text-2); font: 500 13px var(--font-ui); cursor: pointer; text-align: left; }
.pm-nav-i svg { flex: none; color: var(--faint); }
.pm-nav-i:hover { background: var(--hover); color: var(--text); }
.pm-nav-i.active { background: var(--accent-soft); color: var(--accent); font-weight: 650; }
.pm-nav-i.active svg { color: var(--accent); }
.pm-foot { margin-top: auto; padding: 8px 10px 2px; border-top: 1px solid var(--line); color: var(--muted); font-size: 11.5px; line-height: 1.4; overflow-wrap: anywhere; }

/* main column */
.pm-main { min-width: 0; min-height: 0; overflow: auto; padding: 24px 32px 48px; }
.pm-head { display: flex; align-items: center; gap: 16px; }
.pm-title { flex: 1; display: flex; align-items: center; gap: 10px; margin: 0; font-size: 20px; font-weight: 750; letter-spacing: -0.02em; color: var(--text); }
.pm-title svg { color: var(--muted); }
.pm-sub { margin: 6px 0 22px; color: var(--muted); font-size: 13px; max-width: 80ch; }
.pm-sub:empty { display: none; }
.pm-views { display: flex; gap: 2px; padding: 2px; background: var(--surface); border: 1px solid var(--line); }
.pm-views .icon-btn { width: 30px; height: 26px; color: var(--muted); }
.pm-views .icon-btn.on { background: var(--accent-soft); color: var(--accent); }
.pm-empty { color: var(--muted); font-size: 13px; padding: 8px 0; }
.pm-note { margin-top: 24px; color: var(--muted); font-size: 13px; line-height: 1.55; max-width: 70ch; }
.pm-note p { margin: 0 0 10px; }
.pm-h { margin: 22px 0 10px; font: 700 11px var(--font-ui); letter-spacing: 0.7px; text-transform: uppercase; color: var(--muted); }
.pm-h:first-child { margin-top: 0; }

/* thumbnails */
.pm-thumb { width: 48px; height: 48px; flex: none; display: grid; place-items: center; background: var(--badge-bg); color: var(--text-2); }
.pm-thumb .avatar { width: 100%; height: 100%; font-size: 13px; background: none; color: var(--text); }
.pm-thumb.sm { width: 34px; height: 34px; }
.pm-thumb.sm svg { width: 18px; height: 18px; }
.pm-thumb.sm .avatar { font-size: 11px; }

/* "Recently edited" strip */
.pm-group { margin-bottom: 24px; }
.pm-group-h { display: inline-flex; align-items: center; gap: 6px; margin-bottom: 12px; padding: 2px 4px 2px 0; border: 0; background: none; color: var(--text); font: 650 13px var(--font-ui); cursor: pointer; }
.pm-group-h svg { color: var(--muted); transition: transform .15s; }
.pm-group-h.open svg { transform: rotate(90deg); }
.pm-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 10px; }
.pm-tile { display: flex; align-items: center; gap: 12px; padding: 10px; background: var(--surface); border: 1px solid var(--line); cursor: pointer; min-width: 0; outline: none; }
.pm-tile:hover { border-color: var(--faint); }
.pm-tile:focus-visible, .pm-tile.selected { border-color: var(--accent-line); }
.pm-tile.current { box-shadow: inset 2px 0 0 var(--accent); }
.pm-tile-t { min-width: 0; }
.pm-tile-t b { display: block; color: var(--text); font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pm-tile-t small { display: block; margin-top: 2px; color: var(--muted); font: 11.5px var(--font-code); font-variant-numeric: tabular-nums; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* grid view */
.pm-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.pm-tile.large { flex-direction: column; align-items: stretch; gap: 14px; padding: var(--pad); cursor: default; }
.pm-tile.large { display: grid; grid-template-columns: 48px minmax(0, 1fr); grid-template-areas: "thumb title" "desc desc" "badges badges" "acts acts"; column-gap: 14px; row-gap: 0; align-items: center; }
.pm-tile.large .pm-thumb { grid-area: thumb; }
.pm-tile.large .pm-tile-t { grid-area: title; }
.pm-tile.large .pm-tile-t b { font-size: 15px; font-weight: 700; }
.pm-tile.large .pm-desc { grid-area: desc; margin: 14px 0 0; color: var(--muted); font-size: 12.5px; line-height: 1.45; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.pm-tile.large .pm-badges { grid-area: badges; margin-top: 14px; }
.pm-tile-acts { grid-area: acts; display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }
.pm-tile-acts .btn { height: 30px; padding: 0 12px; font-size: 12.5px; }
.pm-tile-acts .btn.danger { margin-left: auto; }
.pm-tile-acts .btn.danger ~ .btn.danger { margin-left: 0; }
.pm-badges { display: inline-flex; flex-wrap: wrap; gap: 6px; }

/* list view */
.pm-table { background: var(--surface); border: 1px solid var(--line); }
.pm-tr { position: relative; display: grid; grid-template-columns: minmax(240px, 2.6fr) minmax(120px, 1fr) minmax(110px, 1fr) minmax(110px, 1fr) minmax(80px, 0.7fr); align-items: center; min-height: 52px; padding: 0 12px; border-bottom: 1px solid var(--line); background: var(--surface); outline: none; }
.pm-tr:last-child { border-bottom: 0; }
.pm-th { min-height: 38px; background: var(--surface); position: sticky; top: -24px; z-index: 1; }
.pm-tr:not(.pm-th):hover { background: var(--hover); }
/* solid (not translucent) so the action overlay can sit on top cleanly */
.pm-tr.selected, .pm-tr:focus-visible { background: color-mix(in srgb, var(--accent) 14%, var(--surface)); }
.pm-tr.current { box-shadow: inset 2px 0 0 var(--accent); }
.pm-td { min-width: 0; padding: 6px 8px; color: var(--text-2); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pm-th .pm-td { display: flex; align-items: center; gap: 4px; border: 0; background: none; color: var(--muted); font: 600 11.5px var(--font-ui); letter-spacing: 0.2px; text-align: left; cursor: pointer; }
.pm-th .pm-td:hover, .pm-th .pm-td.sorted { color: var(--text); }
.pm-dir { font-size: 9px; color: var(--accent); }
.pm-td.num { font-family: var(--font-code); font-variant-numeric: tabular-nums; font-size: 12px; }
.pm-td.c-title { display: flex; align-items: center; gap: 12px; }
.pm-name { min-width: 0; padding: 0; border: 0; background: none; color: var(--text); font: 600 13px var(--font-ui); cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: left; }
.pm-name:hover { text-decoration: underline; text-underline-offset: 2px; }
.pm-td.c-title .pm-badges { flex-wrap: nowrap; }
.pm-th .c-acts { display: none; }
/* row actions appear over the right end of the row on hover, selection or keyboard focus */
.pm-td.c-acts { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); display: flex; gap: 6px; padding: 0 0 0 24px; overflow: visible; background: inherit; opacity: 0; pointer-events: none; transition: opacity .12s; }
.pm-tr:hover .c-acts, .pm-tr.selected .c-acts, .pm-tr:focus-within .c-acts { opacity: 1; pointer-events: auto; }
.pm-td.c-acts .btn { height: 28px; padding: 0 10px; font-size: 12px; }

/* extensions: cards in a flat grid */
.pm-ext { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }

@media (max-width: 900px) {
  .pm-tr { grid-template-columns: minmax(200px, 2fr) minmax(110px, 1fr) minmax(100px, 1fr); }
  .pm-td.c-modifiedBy, .pm-td.c-bytes { display: none; }
}
@media (max-width: 760px) {
  .pm { grid-template-columns: 1fr; grid-template-rows: 52px auto minmax(0, 1fr); }
  .pm-logo { width: auto; }
  .pm-logo span, .pm-back, .pm-user-n { display: none; }
  .pm-side { flex-direction: row; align-items: center; gap: 8px; padding: 8px; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--line); }
  .pm-create-btn { width: auto; padding: 0 14px; }
  .pm-menu { right: auto; width: 260px; }
  .pm-nav { flex-direction: row; }
  .pm-nav-i { flex: none; }
  .pm-foot { display: none; }
  .pm-main { padding: 18px 16px 32px; }
  /* rows stack: name and badges, then the actions */
  .pm-tr { grid-template-columns: minmax(0, 1fr); padding: 10px 12px; }
  .pm-td.c-mtime, .pm-td.c-owner, .pm-td.c-modifiedBy, .pm-td.c-bytes { display: none; }
  .pm-th { display: none; }
  .pm-td.c-title { flex-wrap: wrap; row-gap: 6px; }
  .pm-td.c-title .pm-badges { flex-wrap: wrap; }
  .pm-td.c-acts { position: static; transform: none; opacity: 1; pointer-events: auto; flex-wrap: wrap; justify-content: flex-start; padding: 0 0 0 54px; background: none; }
  .pm-td.c-acts:empty { display: none; }
  .pm-tiles { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
}

/* =====================================================================================
   Anti-slop pass. Reference: a research lab's printed report — Swiss grid, hairline rules,
   IBM Plex Serif titles over Plex Sans text, ink and paper with a single ochre accent
   (ui-ux-pro-max: "Minimalism & Swiss Style" + "Research Lab" palette + Plex pairing). Forbidden (see docs/DESIGN.md): Inter / Roboto / Open Sans, gradients, soft drop
   shadows, rows of feature cards, decorative glyphs, filler copy.
   Spacing: an 8px base; every margin, padding and row height is a multiple of 8 (4 for hairlines).
   ===================================================================================== */

/* ---- type: DIN for names, titles and labels; the UI sans for reading ---- */
.brand-name, .pm-logo, .pm-title, .dialog h3, .tpl-head h3, .pm-mono, .pm-ext-t b, .welcome-l b {
  font-family: var(--font-display);
}
.panel-head h2, .console-title, .ws-head, .share-h, .pm-h, .pm-th .pm-td, .pm-group-h,
.pj-badge, .share-tag, .switch-label {
  font-family: var(--font-label);
}
.panel-head h2, .console-title, .ws-head, .share-h, .pm-h { font-size: 11px; font-weight: 600; letter-spacing: 0.1em; }
.brand-name { font-size: 18px; font-weight: 500; letter-spacing: 0; }
.brand-name b, .pm-logo b { font-weight: 700; }
.pm-logo { font-size: 19px; font-weight: 500; letter-spacing: 0; }
.dialog h3 { font-size: 20px; font-weight: 600; letter-spacing: -0.01em; }
.pj-badge, .share-tag { font-size: 12px; font-weight: 600; letter-spacing: 0.02em; }

/* ---- the one loud thing on the Projects page: the section title ---- */
.pm-title { font-size: 40px; line-height: 1.05; font-weight: 600; letter-spacing: -0.015em; gap: 0; }
.pm-sub { margin: 8px 0 32px; font-size: 13px; }

/* ---- no soft shadows: floating things get a hard 1px border ---- */
.dialog, .palette, .completion, .sig-hint, .toast, .account-menu, .pm-menu, .tpl, .snip-list {
  box-shadow: none; border-color: var(--float-line);
}
.pm-menu { box-shadow: none; }

/* ---- Projects page on the 8px grid ---- */
.pm { grid-template-rows: 48px minmax(0, 1fr); }
.pm-top { gap: 16px; }
.pm-search { height: 32px; }
.pm-back { height: 32px; }
.pm-side { gap: 16px; padding: 16px; }
.pm-create-btn { height: 40px; }
.pm-menu { top: calc(100% + 8px); padding: 8px; }
.pm-menu button { gap: 16px; padding: 8px; }
.pm-nav { gap: 0; }
.pm-nav-i { height: 32px; gap: 8px; padding: 0 8px; }
.pm-foot { padding: 8px 8px 0; }
.pm-main { padding: 32px 40px 48px; }
.pm-head { gap: 16px; align-items: flex-end; }
.pm-views .icon-btn { width: 32px; height: 24px; }
.pm-group { margin-bottom: 32px; }
.pm-group-h { margin-bottom: 16px; gap: 8px; font-size: 13px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); }
.pm-tiles { gap: 8px; }
.pm-tile { gap: 16px; padding: 8px; }
.pm-grid { gap: 16px; }
.pm-tr { min-height: 48px; padding: 0 8px; }
.pm-th { min-height: 40px; top: -32px; }
.pm-th .pm-td { font-size: 12px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; }
.pm-td { padding: 8px; }
.pm-td.c-title { gap: 16px; }
.pm-thumb { width: 48px; height: 48px; }
.pm-thumb.sm { width: 32px; height: 32px; }
.pm-badges { gap: 8px; }
.pj-badge, .share-tag { height: 24px; padding: 0 8px; }
.pm-h { margin: 32px 0 8px; }
.pm-tile.large { column-gap: 16px; }
.pm-tile.large .pm-desc { margin-top: 16px; }
.pm-tile.large .pm-badges { margin-top: 16px; }
.pm-tile-acts { margin-top: 24px; padding-top: 16px; gap: 8px; }

/* monogram thumbnails: two letters in DIN instead of the same icon on every project */
.pm-mono { font-size: 18px; font-weight: 600; font-style: italic; letter-spacing: 0; color: var(--text); }
.pm-thumb.sm .pm-mono { font-size: 13px; }

/* extensions: a plain list, not a wall of cards */
.pm-ext-list { border-top: 1px solid var(--line); }
.pm-ext-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 24px; align-items: center; padding: 16px 0; border-bottom: 1px solid var(--line); }
.pm-ext-t b { display: block; font: 600 17px var(--font-display); color: var(--text); }
.pm-ext-t p { margin: 4px 0 8px; max-width: 72ch; color: var(--muted); font-size: 13px; line-height: 1.5; }
.pm-ext-t span { display: block; color: var(--faint); font: 12px var(--font-code); }
.pm-ext-row .switch { flex-direction: row; gap: 8px; }
.pm-ext-row .switch-label { min-width: 24px; text-align: right; font-size: 13px; }

/* ---- the console welcome: three quiet lines, examples as plain links ---- */
.welcome { padding: 16px 16px 8px; }
.welcome p { margin: 0 0 8px; color: var(--muted); max-width: 80ch; }
.welcome .welcome-l { color: var(--text-2); }
.welcome kbd { margin-right: 4px; }
.welcome-k { display: flex; flex-wrap: wrap; gap: 4px 16px; }
.welcome .chips { display: inline; }
.welcome .chip, .welcome .chip:hover { display: inline; padding: 0; margin: 0 16px 0 8px; border: 0; background: none; color: var(--text); font: 12px var(--font-code); text-decoration: underline; text-decoration-color: var(--faint); text-underline-offset: 3px; cursor: pointer; }
.welcome .chip:hover { text-decoration-color: var(--text); }

@media (max-width: 760px) {
  .pm-title { font-size: 32px; }
  .pm-main { padding: 24px 16px 32px; }
  .pm { grid-template-rows: 48px auto minmax(0, 1fr); }
}

/* =====================================================================================
   Projects: drives as collections, folders, figure thumbnails
   ===================================================================================== */
.pm-crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 2px; margin: 0 0 8px; font-size: 13px; color: var(--muted); }
.pm-crumbs[hidden] { display: none; }
.pm-crumbs a { padding: 2px 4px; color: var(--muted); text-decoration: none; border: 1px dashed transparent; }
.pm-crumbs a:hover { color: var(--text); }
.pm-crumbs a.drop { border-color: var(--accent-line); color: var(--text); }
.pm-crumbs [aria-current] { padding: 2px 4px; color: var(--text-2); }
.pm-crumbs svg { color: var(--faint); }
.pm-head-acts { display: flex; gap: 8px; margin-left: auto; }
.pm-head-acts:empty { display: none; }
.pm-head-acts + .pm-views { margin-left: 0; }
.pm-head-acts .btn { height: 30px; padding: 0 12px; font-size: 12.5px; }

/* the latest figure, or a monogram when there is none yet */
.pm-thumb.img { background: var(--surface-3); overflow: hidden; }
.pm-thumb img { display: block; width: 100%; height: 100%; object-fit: cover; }
.pm-thumb.sm { width: 56px; height: 35px; }
.pm-thumb.folder { background: none; color: var(--text-2); }
.pm-thumb.preview { width: 100%; height: auto; aspect-ratio: 16 / 10; }
.pm-thumb.preview svg { width: 32px; height: 32px; }
.pm-thumb.preview .pm-mono { font-size: 28px; }
.pm-thumb.preview .avatar { font-size: 22px; }

/* recently edited: a picture over the name */
.pm-tile.small { flex-direction: column; align-items: stretch; gap: 0; padding: 0; }
.pm-tile.small .pm-tile-t { padding: 8px 10px 10px; }
.pm-tile.small .pm-thumb.preview { border-bottom: 1px solid var(--line); }

/* grid cards: picture on top, then title, badges, actions */
.pm-tile.large { display: flex; flex-direction: column; align-items: stretch; gap: 0; padding: 0; }
.pm-tile.large .pm-thumb.preview { border-bottom: 1px solid var(--line); }
.pm-tile.large .pm-tile-t { padding: 16px var(--pad) 0; }
.pm-tile.large .pm-desc { margin: 12px var(--pad) 0; }
.pm-tile.large .pm-badges { margin: 12px var(--pad) 0; }
.pm-tile.large .pm-tile-acts { margin: 16px var(--pad) 0; padding: 16px 0 var(--pad); }
.pm-tile.large.is-folder .pm-thumb.preview { aspect-ratio: auto; height: 88px; justify-content: start; padding-left: var(--pad); }

/* drag a project onto a folder */
.pm-tr.dragging, .pm-tile.dragging { opacity: 0.5; }
.pm-tr.drop, .pm-tile.drop { outline: 1px dashed var(--accent-line); outline-offset: -1px; background: var(--accent-soft); }
.pm-tr.is-folder .pm-name { font-weight: 600; }
.pm-move { display: grid; gap: 6px; font-size: 13px; color: var(--muted); }
.pm-move select { height: 34px; padding: 0 8px; background: var(--surface-2); color: var(--text); border: 1px solid var(--line); font: inherit; }

/* the editor's Extensions panel: this workspace's extensions, one switch each */
.ext-list { overflow-y: auto; padding: 0 0 16px; }
.ext-cat { margin: 16px 12px 4px; font: 600 11px var(--font-label); letter-spacing: 0.1em; text-transform: uppercase; color: var(--faint); }
.ext-row { display: grid; grid-template-columns: 20px minmax(0, 1fr) auto; gap: 12px; align-items: start; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.ext-ic { color: var(--muted); padding-top: 1px; }
.ext-row.on .ext-ic { color: var(--accent); }
.ext-t b { display: block; font-size: 13px; font-weight: 600; color: var(--text); }
.ext-t p { margin: 2px 0 0; color: var(--muted); font-size: 12px; line-height: 1.45; }
.ext-row .switch { margin-top: 1px; }
.rail-btn .li { width: 20px; height: 20px; }

/* baked animation player: pre-rendered frames over the figure dock */
.bake-player { position: absolute; inset: 0; z-index: 5; display: flex; flex-direction: column; background: var(--plot-bg); outline: none; }
.bake-player canvas { flex: 1; min-height: 0; width: 100%; display: block; }
.bp-bar { display: flex; align-items: center; gap: 8px; height: 40px; padding: 0 8px; border-top: 1px solid var(--line); background: var(--surface); }
.bp-seek { flex: 1; min-width: 60px; accent-color: var(--accent); }
.bp-pos { font: 12px var(--font-code); font-variant-numeric: tabular-nums; color: var(--muted); min-width: 72px; text-align: right; }
.bp-fps { height: 26px; padding: 0 4px; background: var(--surface-2); color: var(--text); border: 1px solid var(--line); font: 12px var(--font-ui); }
.bp-loop.on { color: var(--accent); background: var(--accent-soft); }

/* review comments: gutter markers and the Comments panel */
.ke-gutter .ln.cm { pointer-events: auto; cursor: pointer; color: var(--accent); }
.ke-gutter .ln.cm::after { content: ""; position: absolute; left: 4px; top: 50%; width: 6px; height: 6px; margin-top: -3px; background: var(--accent); }
.cm-toggle { display: flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--muted); cursor: pointer; }
.cm-list { overflow-y: auto; padding: 0 12px 16px; }
.cm-empty { margin: 12px 2px; color: var(--muted); font-size: 12.5px; line-height: 1.5; }
.cm-file { margin: 16px 0 6px; font: 600 11px var(--font-code); color: var(--faint); letter-spacing: 0.02em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cm-thread, .cm-new { padding: 10px 12px; margin-bottom: 8px; background: var(--surface); border: 1px solid var(--line); }
.cm-thread.focus { border-color: var(--accent-line); }
.cm-thread.resolved { opacity: 0.7; }
.cm-line { display: flex; gap: 8px; align-items: baseline; width: 100%; padding: 0; margin: 0 0 8px; background: none; border: 0; color: var(--muted); font: 11.5px var(--font-code); cursor: pointer; text-align: left; }
.cm-line span { flex: none; }
.cm-line code { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-2); }
.cm-line:hover { color: var(--accent); }
.cm-msg + .cm-msg { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); }
.cm-who { display: flex; align-items: center; gap: 8px; font-size: 12px; }
.cm-who b { color: var(--text); font-weight: 600; }
.cm-who time { margin-left: auto; color: var(--faint); font: 11px var(--font-code); }
.cm-av { width: 20px; height: 20px; font-size: 9px; }
.cm-text { margin: 6px 0 0; color: var(--text); font-size: 13px; line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere; }
.cm-state { margin: 8px 0 0; color: var(--ok-text, var(--muted)); font-size: 11.5px; }
.cm-acts { display: flex; gap: 6px; margin-top: 10px; }
.cm-acts .btn { height: 26px; padding: 0 10px; font-size: 12px; }
.cm-acts .btn.danger { margin-left: auto; }
.cm-where { color: var(--muted); font: 11.5px var(--font-code); }
.cm-quote { margin: 6px 0 8px; padding: 6px 8px; background: var(--surface-3); color: var(--text-2); font: 12px var(--font-code); white-space: pre; overflow: hidden; text-overflow: ellipsis; }
.cm-new textarea, .cm-reply textarea { display: block; width: 100%; resize: vertical; min-height: 56px; padding: 8px; background: var(--surface-2); color: var(--text); border: 1px solid var(--line); font: 13px/1.45 var(--font-ui); }
.cm-new textarea:focus, .cm-reply textarea:focus { outline: none; border-color: var(--accent-line); }
.cm-reply { margin-top: 10px; }
.cm-new .cm-acts { justify-content: flex-end; }

/* ---------- debugger ---------- */
.ke-gutter .ln { cursor: pointer; }
.ke-gutter .ln:hover::before { content: ""; position: absolute; left: 5px; top: 6px; width: 9px; height: 9px; background: var(--rose); opacity: 0.3; }
.ke-gutter .ln.bp::before { content: ""; position: absolute; left: 5px; top: 6px; width: 9px; height: 9px; background: var(--rose); opacity: 1; }
.ke-gutter .ln.bp { color: var(--rose); }
.ke-gutter .ln.paused { color: var(--accent); font-weight: 700; }
.ke-gutter .ln.paused::after { content: ""; position: absolute; left: 15px; top: 5px; border: 5.5px solid transparent; border-left: 7px solid var(--accent); }
.ke-band.pausedline { background: var(--accent-soft); border-left: 2px solid var(--accent); }
.debug-bar { display: flex; align-items: center; gap: 4px; margin-left: 8px; min-width: 0; }
.debug-bar .dbg-where { font-size: 11.5px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 320px; margin-right: 6px; }
.debug-bar .dbg-where b { color: var(--accent); font-weight: 650; }
.debug-bar .dbg-stack { height: 24px; max-width: 200px; background: var(--bg); color: var(--text-2); border: 1px solid var(--line-strong); font: 11.5px var(--font-ui); border-radius: 0; }
.debug-bar .btn.small { height: 24px; padding: 0 9px; font-size: 11.5px; gap: 6px; }
.debug-bar .dbg-quit { color: var(--rose); }
.dbg-onerror.on { color: var(--rose); background: var(--rose-soft); }
body.debug-paused .console-head { background: color-mix(in srgb, var(--accent) 7%, var(--surface)); }
body.debug-paused #console-input .prompt-glyph { color: var(--accent); }
@media (max-width: 820px) { .debug-bar .dbg-where, .debug-bar .dbg-stack { display: none; } }

/* a line of code in a dialog (open a binary file: "Run it") */
.dlg-code { margin: 8px 0; padding: 10px 12px; background: var(--surface-3); color: var(--text); font: 13px var(--font-code); white-space: pre-wrap; overflow-wrap: anywhere; }

/* editor display options (VIEW tab): wrap long lines, hide line numbers; auto-height blocks (live view) */
.ke.wrap .ke-pre, .ke.wrap .ke-input { white-space: pre-wrap; word-break: break-all; overflow-wrap: anywhere; }
.ke.no-ln .ke-gutter { display: none; }
.ke.auto { position: relative; inset: auto; height: 100%; }
.ke.auto .ke-scroll { overflow-x: auto; overflow-y: hidden; }
.ke.auto .ke-pre, .ke.auto .ke-input { padding-bottom: 10px; }

/* =====================================================================================
   Toolstrip: HOME / LIVE EDITOR / VIEW
   ===================================================================================== */
.ribbon { grid-area: ribbon; background: var(--surface); border-bottom: 1px solid var(--line); min-width: 0; user-select: none; }
.rb-tabs { display: flex; align-items: flex-end; height: 28px; padding: 0 8px; background: var(--bg); border-bottom: 1px solid var(--line); }
.rb-tab { height: 27px; padding: 0 16px; margin-bottom: -1px; border: 1px solid transparent; border-bottom: 0; background: none; color: var(--muted); font: 600 11px var(--font-label); letter-spacing: 0.08em; cursor: pointer; }
.rb-tab:hover { color: var(--text); }
.rb-tab.on { background: var(--surface); color: var(--text); border-color: var(--line); box-shadow: inset 0 2px 0 var(--accent); }
.rb-fill { flex: 1; }
.rb-collapse { align-self: center; color: var(--muted); }
.rb-collapse svg { width: 14px; height: 14px; }
.ribbon.collapsed .rb-panel { display: none; }
.ribbon.collapsed .rb-collapse { transform: rotate(180deg); }
.rb-panel { display: flex; align-items: stretch; height: 88px; padding: 4px 4px 0; overflow-x: auto; overflow-y: hidden; scrollbar-width: thin; }
.rb-group { display: flex; flex-direction: column; flex: none; padding: 0 6px; border-right: 1px solid var(--line); }
.rb-items { flex: 1; display: flex; align-items: flex-start; gap: 2px; }
.rb-cap { height: 16px; text-align: center; font: 600 9.5px var(--font-label); letter-spacing: 0.1em; color: var(--faint); white-space: nowrap; }
.rb-col { display: flex; flex-direction: column; gap: 1px; }
.rb-iconrow { display: flex; gap: 1px; margin-top: 3px; }
.rb-btn { display: flex; align-items: center; gap: 6px; padding: 0 6px; background: none; border: 1px solid transparent; color: var(--text); font: 11.5px var(--font-ui); cursor: pointer; white-space: nowrap; }
.rb-btn svg { flex: none; }
.rb-btn:hover:not(:disabled) { background: var(--surface-3); border-color: var(--line); }
.rb-btn:focus-visible { outline: none; border-color: var(--accent-line); }
.rb-btn:disabled { opacity: 0.4; cursor: default; }
.rb-btn.on { background: var(--accent-soft); border-color: var(--accent-line); }
.rb-btn.lg { flex-direction: column; justify-content: flex-start; gap: 3px; min-width: 52px; max-width: 76px; height: 66px; padding: 5px 4px 2px; text-align: center; }
.rb-btn.lg svg { width: 26px; height: 26px; }
.rb-btn.lg .rb-label { line-height: 1.2; white-space: normal; }
.rb-btn.sm { height: 21px; }
.rb-btn.sm svg { width: 16px; height: 16px; }
.rb-btn.icon { width: 26px; height: 24px; justify-content: center; padding: 0; }
.rb-btn.icon svg { width: 18px; height: 18px; }
.rb-caret { width: 8px !important; height: 8px !important; margin-left: 3px; vertical-align: middle; color: var(--muted); }
.rb-text { gap: 4px; padding-top: 2px; }
.rb-select select { width: 136px; height: 24px; padding: 0 6px; background: var(--surface-2); color: var(--text); border: 1px solid var(--line); font: 12px var(--font-ui); }
.rb-menu { position: fixed; z-index: 2000; min-width: 190px; padding: 4px 0; background: var(--surface); border: 1px solid var(--line-strong); }
.rb-menu button { display: flex; align-items: center; gap: 6px; width: 100%; padding: 6px 14px; background: none; border: 0; color: var(--text); font: 12.5px var(--font-ui); text-align: left; cursor: pointer; }
.rb-menu button:hover:not(:disabled), .rb-menu button:focus-visible { background: var(--surface-3); outline: none; }
.rb-menu button:disabled { color: var(--faint); cursor: default; }
.rb-sep { height: 1px; margin: 4px 0; background: var(--line); }
.rb-check { width: 14px; color: var(--accent); }

/* =====================================================================================
   Live view: a script as text, code and output
   ===================================================================================== */
.lv { flex: 1; min-height: 0; overflow: auto; background: var(--bg); }
.lv[hidden], .editor-host[hidden] { display: none; }
.lv-empty { padding: 24px; color: var(--muted); }
.lv-doc { max-width: 1400px; padding: 16px 0 64px; }
.lv-sec { padding: 4px 0 12px; border-bottom: 1px solid var(--line); }
.lv-sec:last-child { border-bottom: 0; }
.lv-title, .lv-heading { margin: 10px 24px 6px 68px; outline: none; }
.lv-title { font: 600 26px/1.2 var(--font-display); color: var(--accent); }
.lv-heading { font: 600 18px/1.3 var(--font-ui); color: var(--text); }
.lv-title:empty::before, .lv-heading:empty::before { content: attr(data-placeholder); color: var(--faint); }
.lv-row { display: grid; grid-template-columns: minmax(0, 1fr); gap: 0 16px; padding: 2px 24px 2px 68px; }
.lv.out-right .lv-row.lv-code { grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); }
.lv-textview { min-height: 22px; padding: 4px 0; color: var(--text); font: 14px/1.6 var(--font-ui); cursor: text; outline: none; }
.lv-textview:focus-visible, .lv-textview:hover { background: color-mix(in srgb, var(--surface-3) 50%, transparent); }
.lv-textview p { margin: 0; }
.lv-textview .lv-gap { height: 10px; }
.lv-textview ul, .lv-textview ol { margin: 2px 0; padding-left: 22px; }
.lv-textview code { font: 13px var(--font-code); background: var(--surface-3); padding: 0 4px; }
.lv-textview a { color: var(--accent); }
.lv-ph { color: var(--faint); }
.lv-textedit { width: 100%; min-height: 30px; padding: 4px 6px; resize: none; overflow: hidden; background: var(--surface); color: var(--text); border: 1px solid var(--accent-line); font: 14px/1.6 var(--font-ui); outline: none; }
.lv-codebox { margin: 6px 0; background: var(--surface-2); border: 1px solid var(--line); min-width: 0; }
.lv-codebox:focus-within { border-color: var(--accent-line); }
.lv-ed { position: relative; margin-left: -54px; }
.lv-ed .ke-gutter { background: transparent; }
.lv.hide-code .lv-codebox { display: none; }
.lv-controls { display: flex; flex-wrap: wrap; gap: 6px 18px; padding: 8px 12px; border-bottom: 1px solid var(--line); background: var(--surface); }
.lv-controls[hidden] { display: none; }
.lv-ctl { display: flex; align-items: center; gap: 8px; font: 12.5px var(--font-ui); color: var(--text-2); }
.lv-ctl-n { font: 600 12.5px var(--font-code); color: var(--text); }
.lv-ctl input[type=range] { width: 160px; accent-color: var(--accent); }
.lv-ctl output { min-width: 32px; font: 12.5px var(--font-code); color: var(--text); }
.lv-ctl select, .lv-ctl input[type=text] { height: 24px; padding: 0 6px; background: var(--surface-2); color: var(--text); border: 1px solid var(--line); font: 12.5px var(--font-ui); }
.lv-ctl input[type=checkbox] { accent-color: var(--accent); }
.lv-out { min-width: 0; padding: 6px 0; }
.lv-out:empty { padding: 0; }
.lv-out.running::before { content: "Running…"; color: var(--muted); font: 12px var(--font-ui); }
.lv-o { margin: 0 0 6px; padding: 6px 10px; background: var(--surface); border: 1px solid var(--line); font: 12.5px/1.5 var(--font-code); color: var(--text); white-space: pre-wrap; overflow-x: auto; }
.lv-o-text { border-color: transparent; background: none; padding: 2px 0; }
.lv-o-val pre { margin: 2px 0 0; font: inherit; white-space: pre; }
.lv-o-h b { font-weight: 600; }
.lv-o-h span { color: var(--muted); font-style: italic; }
.lv-o-warn { border-color: color-mix(in srgb, var(--warn) 40%, transparent); color: var(--warn); }
.lv-o-err { border-color: color-mix(in srgb, var(--rose) 50%, transparent); color: var(--rose); font-family: var(--font-ui); white-space: normal; }
.lv-o-fig { padding: 4px; background: var(--plot-bg); }
.lv-o-fig img { display: block; max-width: 100%; height: auto; cursor: zoom-in; }

/* find and replace */
.findbar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 6px 8px; background: var(--surface); border-bottom: 1px solid var(--line); }
.findbar[hidden] { display: none; }
.findbar input[type=search], .findbar input[type=text] { width: 180px; height: 26px; padding: 0 8px; background: var(--surface-2); color: var(--text); border: 1px solid var(--line); font: 12.5px var(--font-code); }
.findbar input:focus { outline: none; border-color: var(--accent-line); }
.fb-opt { display: flex; align-items: center; gap: 4px; font: 12px var(--font-ui); color: var(--muted); }
.fb-count { min-width: 70px; font: 12px var(--font-code); color: var(--muted); }
.findbar .btn { height: 26px; padding: 0 10px; font-size: 12px; }

/* outline */
.outline-list { list-style: none; margin: 0; padding: 4px 0; overflow-y: auto; }
.outline-list button { display: flex; align-items: baseline; gap: 8px; width: 100%; padding: 6px 14px; background: none; border: 0; color: var(--text-2); font: 13px var(--font-ui); text-align: left; cursor: pointer; }
.outline-list button:hover { background: var(--surface-3); color: var(--text); }
.outline-list button span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.outline-list button small { color: var(--faint); font: 11px var(--font-code); }
.outline-list .ol-title { color: var(--accent); font-weight: 600; }

/* preferences */
.prefs { display: grid; gap: 12px; min-width: 320px; }
.prefs label { display: flex; align-items: center; justify-content: space-between; gap: 16px; font: 13px var(--font-ui); color: var(--text-2); }
.prefs label.chk { justify-content: flex-start; gap: 8px; }
.prefs select { height: 28px; padding: 0 6px; background: var(--surface-2); color: var(--text); border: 1px solid var(--line); font: 12.5px var(--font-ui); }
.prefs input[type=checkbox] { accent-color: var(--accent); }

/* Print / Export to PDF: just the script (the live view if it's showing) */
@media print {
  body.printing .app > :not(.stage), body.printing .console-pane, body.printing .splitter, body.printing .editor-bar, body.printing .findbar { display: none !important; }
  body.printing .app { display: block; height: auto; }
  body.printing .stage, body.printing .editor-pane { display: block; height: auto; border: 0; }
  body.printing .lv { overflow: visible; }
  body.printing .lv-row { break-inside: avoid; }
  body.printing .editor-host { height: auto; }
  body.printing .ke { position: static; }
  body.printing .ke-scroll { overflow: visible; }
}

/* first lines of a file too big for the editor (openLargeText) */
.large-preview { font: 12px/1.5 var(--font-code); background: var(--bg); border: 1px solid var(--line); padding: 8px 10px; max-height: 220px; overflow: auto; white-space: pre; margin: 0; }

/* ---------- Device panel (MicroPython boards) ---------- */
.dev-body { display: flex; flex-direction: column; gap: 10px; padding: 10px 12px; min-height: 0; flex: 1; overflow: hidden; }
.dev-status { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--text-2); }
.dev-status.ok { color: var(--text); }
.dev-dot { width: 8px; height: 8px; background: var(--faint); flex: none; }
.dev-status.ok .dev-dot { background: #22c55e; }
.dev-status.warn .dev-dot { background: var(--warn); }
.dev-actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.dev-actions .btn svg { margin-right: 5px; vertical-align: -2px; }
.dev-note { font-size: 12px; color: var(--text-2); margin: 0; line-height: 1.5; }
.dev-files-head { display: flex; align-items: center; justify-content: space-between; font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--faint); }
.dev-files { max-height: 160px; overflow: auto; margin: 0; }
.dev-file { display: flex; align-items: center; gap: 6px; padding: 3px 4px; }
.dev-file .fname { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--font-code); font-size: 12.5px; }
.dev-size { color: var(--faint); font-size: 11px; font-variant-numeric: tabular-nums; }
.dev-file .factions { display: none; gap: 2px; }
.dev-file:hover .factions { display: flex; }
.dev-term { flex: 1; min-height: 120px; margin: 0; overflow: auto; background: var(--bg); border: 1px solid var(--line); padding: 8px 10px; font: 12px/1.45 var(--font-code); white-space: pre-wrap; word-break: break-word; color: var(--text); }
.dev-term .dev-err { color: var(--rose); }
.dev-term .dev-note { color: var(--faint); font-size: 12px; }
.dev-input { display: flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--bg); padding: 0 4px 0 8px; }
.dev-input .prompt-glyph { color: var(--accent); font: 12px var(--font-code); }
.dev-input input { flex: 1; min-width: 0; background: transparent; border: 0; outline: 0; color: var(--text); font: 12.5px var(--font-code); padding: 7px 0; }
.dev-steps { padding-left: 18px; line-height: 1.55; }
.dev-steps ul { padding-left: 16px; margin: 4px 0; columns: 2; }
.side .panel[data-panel="ext-device"] { display: flex; flex-direction: column; }  /* the Device extension's panel */
.side .panel[data-panel="ext-device"][hidden] { display: none; }
.dev-link { background: none; border: 0; padding: 0; font: inherit; color: var(--accent); cursor: pointer; text-decoration: underline; }
.dev-link:hover { color: var(--text); }
.dev-field { display: flex; flex-direction: column; gap: 4px; margin: 10px 0 0; font-size: 12.5px; color: var(--text-2); }
.dev-field select { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--line-strong); padding: 5px 6px; }
.dev-sketch { display: flex; flex-direction: column; gap: 2px; padding: 8px 0 4px; border-top: 1px solid var(--line); }
.dev-sketch-head { font-size: 12px; font-weight: 600; color: var(--text); }
.dev-sketch .dev-field { margin-top: 6px; }
.dev-row { display: flex; gap: 6px; align-items: center; }
.dev-row select { flex: 1; min-width: 0; }
.dev-inline { display: flex; gap: 6px; align-items: center; font-size: 12.5px; color: var(--text-2); }
.dev-inline select, .dev-row select { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--line-strong); padding: 4px 6px; }
.dev-libsearch input { width: 100%; box-sizing: border-box; margin: 6px 0; font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--line-strong); padding: 6px 8px; }
.dev-libs { list-style: none; margin: 0; padding: 0; max-height: 260px; overflow: auto; }
.dev-libs li { padding: 6px 2px; border-bottom: 1px solid var(--line); font-size: 12.5px; }
.dev-libs label { display: flex; gap: 8px; align-items: flex-start; cursor: pointer; }
