/* ============================================================================
   Jarvis Desktop — Redesign Proposals
   Shared structural stylesheet.

   This file owns STRUCTURE only: the window chrome, the three shell layouts,
   and the anatomy of every component. It reads design decisions exclusively
   through custom properties, and never hard-codes a colour, a font, a radius
   or a spacing value.

   Each direction supplies those values in themes/<direction>.css. That split
   is what lets the three proposals be compared fairly: identical product
   scope, identical component anatomy, completely different design systems.

   ---- TOKEN CONTRACT -------------------------------------------------------
   colour     --bg --bg-sunken --surface --surface-2 --surface-3 --overlay
              --line --line-soft --line-strong --text --text-2 --text-3
              --accent --accent-fg --accent-hover --accent-ink --accent-soft --focus
   semantic   --ok --warn --danger --info --running (+ matching --*-soft)
   type       --font-ui --font-display --font-mono
              --fs-11 … --fs-32, --lh-tight --lh-body, --tr-tight --tr-wide
   space      --sp-1 … --sp-9  (density scale, direction-specific)
   radius     --r-xs --r-sm --r-md --r-lg --r-xl --r-full
   control    --h-xs --h-sm --h-md --h-lg  (min hit target is enforced here)
   elevation  --sh-1 --sh-2 --sh-3
   icon       --icon-stroke --icon-cap --icon-join
   motion     --dur-1 --dur-2 --dur-3 --ease
   ========================================================================== */

/* ---------------------------------------------------------------- reset -- */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font-ui);
  font-size: var(--fs-13);
  line-height: var(--lh-body);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-variant-ligatures: none;
}
h1, h2, h3, h4, p, figure, blockquote { margin: 0; }
ul, ol { margin: 0; padding: 0; list-style: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { background: none; border: 0; padding: 0; cursor: pointer; }
a { color: inherit; text-decoration: none; }
img, svg { display: block; }
[hidden] { display: none !important; }

::selection { background: var(--accent-soft); color: var(--text); }

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

/* --------------------------------------------------------- a11y / focus -- */
:focus { outline: none; }
:focus-visible,
.focusable:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip-link {
  position: absolute; left: var(--sp-4); top: -100px; z-index: 999;
  padding: var(--sp-2) var(--sp-4); background: var(--accent);
  color: var(--accent-ink); border-radius: var(--r-md); transition: top var(--dur-2) var(--ease);
}
.skip-link:focus { top: var(--sp-4); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important; animation-iteration-count: 1 !important;
    transition-duration: .001ms !important; scroll-behavior: auto !important;
  }
}

/* ----------------------------------------------------------- typography -- */
.t-display { font-family: var(--font-display); font-size: var(--fs-28); line-height: var(--lh-tight); letter-spacing: var(--tr-tight); font-weight: var(--fw-display); }
.t-h1      { font-family: var(--font-display); font-size: var(--fs-22); line-height: var(--lh-tight); letter-spacing: var(--tr-tight); font-weight: var(--fw-display); }
.t-h2      { font-size: var(--fs-16); line-height: var(--lh-tight); letter-spacing: var(--tr-tight); font-weight: 600; }
.t-h3      { font-size: var(--fs-14); line-height: var(--lh-tight); font-weight: 600; }
.t-body    { font-size: var(--fs-13); line-height: var(--lh-body); }
.t-meta    { font-size: var(--fs-12); line-height: var(--lh-body); color: var(--text-2); }
.t-micro   { font-size: var(--fs-11); line-height: var(--lh-body); color: var(--text-3); }
.t-eyebrow {
  font-size: var(--fs-11); font-weight: 600; letter-spacing: var(--tr-wide);
  text-transform: uppercase; color: var(--text-3);
}
.t-mono    { font-family: var(--font-mono); font-size: var(--fs-12); font-variant-numeric: tabular-nums; letter-spacing: 0; }
.t-num     { font-variant-numeric: tabular-nums; }
.muted     { color: var(--text-2); }
.dim       { color: var(--text-3); }
.truncate  { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.clamp-2   { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.clamp-3   { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }

/* icons inherit weight/terminals from the theme */
.ic { flex: none; }

/* ================================================================ SHELL == */
.app {
  height: 100vh; display: grid; overflow: hidden;
  grid-template-rows: var(--titlebar-h) 1fr;
  background: var(--bg);
}

/* -- window titlebar (Electron frame stand-in) ------------------------- */
.titlebar {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: 0 var(--sp-4); background: var(--bg-sunken);
  border-bottom: 1px solid var(--line-soft);
  -webkit-user-select: none; user-select: none;
}
.traffic { display: flex; gap: 8px; padding-right: var(--sp-3); }
.traffic i { width: 11px; height: 11px; border-radius: var(--r-full); background: var(--line-strong); }
.traffic i:nth-child(1) { background: #ff5f57; }
.traffic i:nth-child(2) { background: #febc2e; }
.traffic i:nth-child(3) { background: #28c840; }
.titlebar .tb-title {
  font-size: var(--fs-12); color: var(--text-2); letter-spacing: var(--tr-tight);
}
.titlebar .tb-center { flex: 1; display: flex; justify-content: center; min-width: 0; }
.titlebar .tb-right { display: flex; align-items: center; gap: var(--sp-1); }

/* -- shell body: three structurally different layouts ------------------ */
.shell { display: grid; min-height: 0; overflow: hidden; }

/* mode: rail — 56px product rail + contextual panel + content            */
/* Every mode renders the same children — rail, nav, main and (command) ops —
   so the shell can fold between them purely in CSS. Column widths do the work;
   a folded column is 0 and its element is hidden with visibility.            */
[data-mode="rail"] .shell    { grid-template-columns: var(--rail-w) var(--nav-w) minmax(0, 1fr); }
/* mode: studio — one warm sidebar, content breathes in a centred column  */
[data-mode="studio"] .shell  { grid-template-columns: 0 var(--nav-w) minmax(0, 1fr); }
/* mode: command — nav + content + persistent operations rail             */
[data-mode="command"] .shell { grid-template-columns: 0 var(--nav-w) minmax(0, 1fr) var(--ops-w); }

/* Folded columns use visibility, never display:none — removing a grid child
   would shift every later child into the wrong track. */
[data-mode="studio"] .rail, [data-mode="command"] .rail { visibility: hidden; }

[data-nav="collapsed"] .nav { visibility: hidden; }
[data-mode="rail"][data-nav="collapsed"] .shell    { grid-template-columns: var(--rail-w) 0 minmax(0, 1fr); }
[data-mode="studio"][data-nav="collapsed"] .shell  { grid-template-columns: var(--rail-w) 0 minmax(0, 1fr); }
[data-mode="command"][data-nav="collapsed"] .shell { grid-template-columns: var(--rail-w) 0 minmax(0, 1fr) var(--ops-w); }
[data-mode="studio"][data-nav="collapsed"] .rail,
[data-mode="command"][data-nav="collapsed"] .rail { visibility: visible; }

/* Operations rail: shown by default, foldable by the user (data-ops="off"),
   and folded automatically at compact widths unless explicitly pinned on. */
[data-mode="command"][data-ops="off"] .shell    { grid-template-columns: 0 var(--nav-w) minmax(0, 1fr) 0; }
[data-mode="command"][data-ops="off"][data-nav="collapsed"] .shell { grid-template-columns: var(--rail-w) 0 minmax(0, 1fr) 0; }
[data-mode="command"][data-ops="off"] .ops { visibility: hidden; }

/* ------------------------------------------------------------ rail ----- */
.rail {
  display: flex; flex-direction: column; align-items: center; gap: var(--sp-2);
  padding: var(--sp-3) 0; background: var(--bg-sunken);
  border-right: 1px solid var(--line-soft); overflow: hidden;
}
.rail-mark {
  display: grid; place-items: center; width: 34px; height: 34px;
  border-radius: var(--r-md); color: var(--accent-fg); margin-bottom: var(--sp-2);
}
.rail-group { display: flex; flex-direction: column; gap: var(--sp-1); width: 100%; align-items: center; }
.rail-sep { width: 22px; height: 1px; background: var(--line); margin: var(--sp-2) 0; }
.rail-btn {
  position: relative; display: grid; place-items: center;
  width: 38px; height: 38px; border-radius: var(--r-md);
  color: var(--text-3); transition: color var(--dur-1) var(--ease), background var(--dur-1) var(--ease);
}
.rail-btn:hover { color: var(--text); background: var(--surface-2); }
.rail-btn[aria-current="true"] { color: var(--accent-fg); background: var(--accent-soft); }
.rail-btn[aria-current="true"]::before {
  content: ""; position: absolute; left: -10px; top: 50%; transform: translateY(-50%);
  width: 3px; height: 18px; border-radius: var(--r-full); background: var(--accent);
}
.rail-spacer { flex: 1; }

/* ------------------------------------------------------------- nav ----- */
.nav {
  display: flex; flex-direction: column; min-height: 0; overflow: hidden;
  background: var(--bg-sunken); border-right: 1px solid var(--line-soft);
}
[data-mode="studio"] .nav { background: var(--surface); }
[data-nav="collapsed"] [data-mode="rail"] .nav { display: none; }
[data-mode="rail"][data-nav="collapsed"] .nav { display: none; }

.nav-head {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-4) var(--sp-4) var(--sp-3);
  min-height: var(--nav-head-h);
}
.nav-head .brandmark { color: var(--accent-fg); flex: none; }
.nav-head .nh-text { min-width: 0; flex: 1; }
.nav-head .nh-title { display: block; font-size: var(--fs-13); font-weight: 600; letter-spacing: var(--tr-tight); line-height: 1.25; }
.nav-head .nh-sub { display: block; font-size: var(--fs-11); color: var(--text-3); margin-top: 1px; line-height: 1.25; }
.nav-head > .ic { flex: none; color: var(--text-3); }

.nav-scroll { flex: 1; min-height: 0; overflow-y: auto; padding: 0 var(--sp-3) var(--sp-3); }
.nav-section { margin-top: var(--sp-4); }
.nav-section:first-child { margin-top: var(--sp-1); }
.nav-section-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 var(--sp-2) var(--sp-2); min-height: 20px;
}
.nav-item {
  display: flex; align-items: center; gap: var(--sp-3); width: 100%;
  min-height: var(--h-lg); padding: 0 var(--sp-2); border-radius: var(--r-md);
  color: var(--text-2); font-size: var(--fs-13); text-align: left;
  transition: background var(--dur-1) var(--ease), color var(--dur-1) var(--ease);
}
.nav-item .ic { color: var(--text-3); transition: color var(--dur-1) var(--ease); }
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item:hover .ic { color: var(--text-2); }
.nav-item[aria-current="page"] { background: var(--nav-active-bg); color: var(--nav-active-text); font-weight: var(--fw-nav-active); }
.nav-item[aria-current="page"] .ic { color: var(--nav-active-icon); }
.nav-item .label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-item .trail { font-size: var(--fs-11); color: var(--text-3); font-variant-numeric: tabular-nums; }
.nav-item.child { padding-left: var(--sp-6); min-height: var(--h-md); font-size: var(--fs-12); }
.nav-foot { border-top: 1px solid var(--line-soft); padding: var(--sp-3); }

.nav-user {
  display: flex; align-items: center; gap: var(--sp-3); width: 100%;
  padding: var(--sp-2); border-radius: var(--r-md); text-align: left;
  transition: background var(--dur-1) var(--ease);
}
.nav-user:hover { background: var(--surface-2); }
.nav-user .nu-text { min-width: 0; flex: 1; }
.nav-user .nu-name { display: block; font-size: var(--fs-12); font-weight: 600; line-height: 1.3; }
.nav-user .nu-org { display: block; font-size: var(--fs-11); color: var(--text-3); line-height: 1.3; }

/* ---------------------------------------------------------- content ---- */
.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--bg); overflow: hidden; }
[data-mode="rail"] .main { border-left: 1px solid transparent; }

.topbar {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: 0 var(--sp-5); min-height: var(--topbar-h); flex: none;
  border-bottom: 1px solid var(--line-soft); background: var(--surface);
}
.topbar .tb-crumbs { display: flex; align-items: center; gap: var(--sp-2); min-width: 0; }
.topbar .tb-spacer { flex: 1; }
.crumb { font-size: var(--fs-12); color: var(--text-2); }
.crumb.current { color: var(--text); font-weight: 600; }
.crumb-sep { color: var(--text-3); }

.scroll { flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; scroll-behavior: smooth; }
/* The extra bottom padding keeps the last row clear of the fixed review bar. */
.page {
  padding: var(--page-pad-y) var(--page-pad-x) calc(var(--page-pad-y) + 52px);
  max-width: var(--page-max); margin: 0 auto;
}
.page.wide { max-width: none; }

.page-head { display: flex; align-items: flex-start; gap: var(--sp-4); margin-bottom: var(--sp-5); }
.page-head .ph-text { flex: 1; min-width: 0; }
.page-head .ph-sub { margin-top: var(--sp-2); color: var(--text-2); font-size: var(--fs-13); max-width: 62ch; }
.page-head .ph-actions { display: flex; align-items: center; gap: var(--sp-2); flex: none; }

.section { margin-top: var(--sp-6); }
.section:first-child { margin-top: 0; }
.section-head {
  display: flex; align-items: baseline; gap: var(--sp-3);
  margin-bottom: var(--sp-3); padding-bottom: var(--sp-2);
}
.section-head .sh-title { font-size: var(--fs-13); font-weight: 600; letter-spacing: var(--tr-tight); }
.section-head .sh-count { font-size: var(--fs-11); color: var(--text-3); font-variant-numeric: tabular-nums; }
.section-head .sh-spacer { flex: 1; }

.toolbar {
  display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap;
  margin-bottom: var(--sp-4);
}
.toolbar .tb-spacer { flex: 1; }

/* --------------------------------------------------------- ops rail ---- */
.ops {
  display: flex; flex-direction: column; min-height: 0; overflow: hidden;
  background: var(--bg-sunken); border-left: 1px solid var(--line-soft);
}
.ops-head {
  display: flex; align-items: center; gap: var(--sp-2);
  padding: 0 var(--sp-4); min-height: var(--topbar-h); flex: none;
  border-bottom: 1px solid var(--line-soft);
}
.ops-scroll { flex: 1; min-height: 0; overflow-y: auto; padding: var(--sp-4); }
.ops-block { margin-bottom: var(--sp-5); }
.ops-block:last-child { margin-bottom: 0; }
.ops-block > .t-eyebrow { display: block; margin-bottom: var(--sp-3); }

/* ============================================================ COMPONENTS = */

/* ------------------------------------------------------------ button --- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
  height: var(--h-md); padding: 0 var(--sp-4); border-radius: var(--r-md);
  font-size: var(--fs-12); font-weight: var(--fw-btn); letter-spacing: var(--tr-btn);
  border: 1px solid var(--line); background: var(--surface-2); color: var(--text);
  white-space: nowrap; transition: background var(--dur-1) var(--ease),
    border-color var(--dur-1) var(--ease), color var(--dur-1) var(--ease),
    transform var(--dur-1) var(--ease), box-shadow var(--dur-1) var(--ease);
}
.btn:hover { background: var(--surface-3); border-color: var(--line-strong); }
.btn:active { transform: translateY(.5px); }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .45; pointer-events: none; }

.btn.primary {
  background: var(--accent); border-color: var(--accent); color: var(--accent-ink);
  box-shadow: var(--sh-accent);
}
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn.ghost:hover { background: var(--surface-2); color: var(--text); }
.btn.quiet { background: transparent; border-color: var(--line); }
.btn.quiet:hover { background: var(--surface-2); }
.btn.danger { color: var(--danger); border-color: var(--danger-line); background: var(--danger-soft); }
.btn.danger:hover { background: var(--danger-soft); border-color: var(--danger); }
.btn.sm { height: var(--h-sm); padding: 0 var(--sp-3); font-size: var(--fs-11); }
.btn.lg { height: var(--h-lg); padding: 0 var(--sp-5); font-size: var(--fs-13); }
.btn.block { width: 100%; }

.iconbtn {
  display: inline-grid; place-items: center; width: var(--h-md); height: var(--h-md);
  border-radius: var(--r-md); color: var(--text-2); border: 1px solid transparent;
  transition: background var(--dur-1) var(--ease), color var(--dur-1) var(--ease), border-color var(--dur-1) var(--ease);
}
.iconbtn:hover { background: var(--surface-2); color: var(--text); }
.iconbtn.bordered { border-color: var(--line); background: var(--surface-2); }
.iconbtn.bordered:hover { background: var(--surface-3); border-color: var(--line-strong); }
.iconbtn.sm { width: var(--h-sm); height: var(--h-sm); }
.iconbtn[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent-fg); }

/* trigger = a button that opens a menu (product switcher, selectors …) */
.trigger {
  display: inline-flex; align-items: center; gap: var(--sp-2);
  height: var(--h-sm); padding: 0 var(--sp-2) 0 var(--sp-3); border-radius: var(--r-md);
  border: 1px solid var(--line); background: var(--surface-2);
  font-size: var(--fs-12); color: var(--text-2); max-width: 100%;
  transition: background var(--dur-1) var(--ease), border-color var(--dur-1) var(--ease), color var(--dur-1) var(--ease);
}
.trigger:hover { background: var(--surface-3); color: var(--text); border-color: var(--line-strong); }
.trigger[aria-expanded="true"] { border-color: var(--accent); color: var(--text); }
.trigger .ic:last-child { color: var(--text-3); }
.trigger.bare { border-color: transparent; background: transparent; }
.trigger.bare:hover { background: var(--surface-2); border-color: transparent; }

/* ------------------------------------------------------- form fields --- */
.field { display: block; margin-bottom: var(--sp-4); }
.field:last-child { margin-bottom: 0; }
.field > .flabel {
  display: flex; align-items: center; gap: var(--sp-2);
  font-size: var(--fs-12); font-weight: 500; margin-bottom: var(--sp-2); color: var(--text);
}
.field .req { color: var(--danger); }
.field .fhint { margin-top: var(--sp-2); font-size: var(--fs-11); color: var(--text-3); }

.input, .textarea, .selectbox {
  display: flex; align-items: center; gap: var(--sp-2); width: 100%;
  height: var(--h-lg); padding: 0 var(--sp-3); border-radius: var(--r-md);
  border: 1px solid var(--line); background: var(--input-bg); color: var(--text);
  font-size: var(--fs-13); transition: border-color var(--dur-1) var(--ease), background var(--dur-1) var(--ease), box-shadow var(--dur-1) var(--ease);
}
.input::placeholder, .textarea::placeholder { color: var(--text-3); }
.input:hover, .textarea:hover, .selectbox:hover { border-color: var(--line-strong); }
.input:focus, .textarea:focus, .selectbox:focus-visible {
  border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); outline: none;
}
.textarea { height: auto; min-height: 92px; padding: var(--sp-3); resize: vertical; line-height: var(--lh-body); display: block; }
.selectbox { justify-content: space-between; text-align: left; cursor: pointer; }
.selectbox .sv { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.selectbox .sv.placeholder { color: var(--text-3); }

.searchbox { position: relative; display: flex; align-items: center; }
.searchbox .ic { position: absolute; left: var(--sp-3); color: var(--text-3); pointer-events: none; }
.searchbox .input { padding-left: calc(var(--sp-3) * 2 + 16px); }
.searchbox.sm .input { height: var(--h-md); font-size: var(--fs-12); }

.toggle {
  position: relative; flex: none; width: 38px; height: 22px; border-radius: var(--r-full);
  background: var(--line-strong); transition: background var(--dur-2) var(--ease);
}
.toggle::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px;
  border-radius: var(--r-full); background: var(--toggle-knob);
  transition: transform var(--dur-2) var(--ease);
}
.toggle[aria-checked="true"] { background: var(--accent); }
.toggle[aria-checked="true"]::after { transform: translateX(16px); }

.checkbox, .radio {
  display: grid; place-items: center; flex: none; width: 16px; height: 16px;
  border: 1.5px solid var(--line-strong); background: var(--input-bg);
  transition: background var(--dur-1) var(--ease), border-color var(--dur-1) var(--ease);
}
.checkbox { border-radius: var(--r-xs); }
.radio { border-radius: var(--r-full); }
.checkbox .ic, .radio i { opacity: 0; }
.checkbox[aria-checked="true"], .radio[aria-checked="true"] { background: var(--accent); border-color: var(--accent); }
.checkbox[aria-checked="true"] .ic { opacity: 1; color: var(--accent-ink); }
.radio[aria-checked="true"] { background: transparent; border-color: var(--accent); }
.radio i { width: 8px; height: 8px; border-radius: var(--r-full); background: var(--accent); }
.radio[aria-checked="true"] i { opacity: 1; }
.optrow { display: flex; align-items: center; gap: var(--sp-2); cursor: pointer; font-size: var(--fs-13); }

.segmented {
  display: inline-flex; padding: 2px; border-radius: var(--r-md);
  background: var(--surface-2); border: 1px solid var(--line);
}
.segmented button {
  display: inline-flex; align-items: center; gap: var(--sp-2);
  height: calc(var(--h-md) - 6px); padding: 0 var(--sp-3); border-radius: calc(var(--r-md) - 2px);
  font-size: var(--fs-12); color: var(--text-2); transition: background var(--dur-1) var(--ease), color var(--dur-1) var(--ease);
}
.segmented button:hover { color: var(--text); }
.segmented button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: var(--sh-1); font-weight: 500; }

/* ---------------------------------------------------------- tabs ------- */
.tabs { display: flex; align-items: center; gap: var(--sp-1); border-bottom: 1px solid var(--line-soft); margin-bottom: var(--sp-4); }
.tabs button {
  position: relative; height: 36px; padding: 0 var(--sp-3);
  font-size: var(--fs-13); color: var(--text-2); transition: color var(--dur-1) var(--ease);
}
.tabs button:hover { color: var(--text); }
.tabs button[aria-selected="true"] { color: var(--text); font-weight: 600; }
.tabs button[aria-selected="true"]::after {
  content: ""; position: absolute; left: var(--sp-2); right: var(--sp-2); bottom: -1px;
  height: 2px; border-radius: var(--r-full); background: var(--accent);
}
.tabs .tabs-spacer { flex: 1; }

.pills { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; }
.pill {
  display: inline-flex; align-items: center; gap: var(--sp-2);
  height: var(--h-sm); padding: 0 var(--sp-3); border-radius: var(--r-full);
  border: 1px solid var(--line); background: var(--surface-2);
  font-size: var(--fs-12); color: var(--text-2);
  transition: background var(--dur-1) var(--ease), color var(--dur-1) var(--ease), border-color var(--dur-1) var(--ease);
}
.pill:hover { color: var(--text); border-color: var(--line-strong); }
.pill[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent-line); color: var(--accent-fg); font-weight: 500; }
.pill .n { font-size: var(--fs-11); color: var(--text-3); font-variant-numeric: tabular-nums; }

/* --------------------------------------------------------- surfaces ---- */
.card {
  background: var(--surface); border: 1px solid var(--line-soft);
  border-radius: var(--r-lg); box-shadow: var(--sh-1);
}
.card.pad { padding: var(--sp-4); }
.card.interactive { transition: border-color var(--dur-2) var(--ease), box-shadow var(--dur-2) var(--ease), transform var(--dur-2) var(--ease); }
.card.interactive:hover { border-color: var(--line-strong); box-shadow: var(--sh-2); transform: translateY(-1px); }
.card-head { display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-4); border-bottom: 1px solid var(--line-soft); }
.card-head .ch-spacer { flex: 1; }
.card-body { padding: var(--sp-4); }
.card-foot { display: flex; align-items: center; gap: var(--sp-2); padding: var(--sp-3) var(--sp-4); border-top: 1px solid var(--line-soft); }

.panel { background: var(--surface-2); border: 1px solid var(--line-soft); border-radius: var(--r-md); padding: var(--sp-3); }
.notice {
  display: flex; align-items: flex-start; gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4); border-radius: var(--r-md);
  border: 1px solid var(--line-soft); background: var(--surface-2); font-size: var(--fs-12);
}
.notice .ic { margin-top: 1px; color: var(--text-3); }
.notice.info   { background: var(--info-soft);   border-color: var(--info-line); }
.notice.info .ic { color: var(--info); }
.notice.warn   { background: var(--warn-soft);   border-color: var(--warn-line); }
.notice.warn .ic { color: var(--warn); }
.notice.danger { background: var(--danger-soft); border-color: var(--danger-line); }
.notice.danger .ic { color: var(--danger); }
.notice .n-spacer { flex: 1; }

.grid { display: grid; gap: var(--sp-4); }
.grid.c2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.c3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.c4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid.auto { grid-template-columns: repeat(auto-fill, minmax(var(--grid-min, 260px), 1fr)); }
.row { display: flex; align-items: center; gap: var(--sp-3); }
.row.tight { gap: var(--sp-2); }
.row.top { align-items: flex-start; }
.spacer { flex: 1; }
.stack { display: flex; flex-direction: column; gap: var(--sp-3); }
.stack.tight { gap: var(--sp-2); }

/* ----------------------------------------------------------- badges ---- */
.badge {
  display: inline-flex; align-items: center; gap: 5px; height: 20px;
  padding: 0 var(--sp-2); border-radius: var(--r-sm);
  font-size: var(--fs-11); font-weight: 500; letter-spacing: var(--tr-wide);
  border: 1px solid var(--line); background: var(--surface-2); color: var(--text-2);
  white-space: nowrap;
}
.badge .dot { width: 6px; height: 6px; border-radius: var(--r-full); background: currentColor; flex: none; }
.badge.ok      { color: var(--ok);      background: var(--ok-soft);      border-color: var(--ok-line); }
.badge.warn    { color: var(--warn);    background: var(--warn-soft);    border-color: var(--warn-line); }
.badge.danger  { color: var(--danger);  background: var(--danger-soft);  border-color: var(--danger-line); }
.badge.info    { color: var(--info);    background: var(--info-soft);    border-color: var(--info-line); }
.badge.accent  { color: var(--accent-fg); background: var(--accent-soft); border-color: var(--accent-line); }
.badge.running { color: var(--running); background: var(--running-soft); border-color: var(--running-line); }
.badge.running .dot { animation: pulse-dot 1.6s var(--ease) infinite; }
@keyframes pulse-dot { 0%,100% { opacity: 1; } 50% { opacity: .35; } }

.kbd {
  display: inline-flex; align-items: center; justify-content: center; min-width: 20px; height: 20px;
  padding: 0 5px; border-radius: var(--r-xs); border: 1px solid var(--line-strong);
  border-bottom-width: 2px; background: var(--surface-2);
  font-family: var(--font-mono); font-size: var(--fs-11); color: var(--text-2);
}

.avatar {
  display: grid; place-items: center; flex: none; width: 28px; height: 28px;
  border-radius: var(--avatar-radius); background: var(--surface-3); color: var(--text-2);
  font-size: var(--fs-11); font-weight: 600; letter-spacing: var(--tr-wide);
  border: 1px solid var(--line);
}
.avatar.sm { width: 22px; height: 22px; font-size: var(--fs-10, 10px); }
.avatar.lg { width: 40px; height: 40px; font-size: var(--fs-14); }
.avatar.accent { background: var(--accent-soft); color: var(--accent-fg); border-color: var(--accent-line); }
.avatar.agent { background: var(--agent-bg); color: var(--agent-fg); border-color: var(--agent-line); }

.stackedavatars { display: flex; padding-left: 2px; }
.stackedavatars .avatar { box-shadow: 0 0 0 2px var(--surface); }
.stackedavatars .avatar + .avatar { margin-left: -7px; }

/* --------------------------------------------------- lists and tables -- */
.list { border: 1px solid var(--line-soft); border-radius: var(--r-lg); overflow: hidden; background: var(--surface); }
.list-row {
  display: flex; align-items: center; gap: var(--sp-3); width: 100%;
  padding: var(--sp-3) var(--sp-4); text-align: left;
  border-bottom: 1px solid var(--line-soft);
  transition: background var(--dur-1) var(--ease);
}
.list-row:last-child { border-bottom: 0; }
.list-row:hover { background: var(--surface-2); }
.list-row .lr-main { flex: 1; min-width: 0; }
.list-row .lr-title { font-size: var(--fs-13); font-weight: 500; display: flex; align-items: center; gap: var(--sp-2); min-width: 0; }
.list-row .lr-title.truncate { display: block; }
.list-row .lr-title > .badge { flex: none; }
.list-row .lr-sub { font-size: var(--fs-11); color: var(--text-3); margin-top: 2px; }
.list-row .lr-actions { display: flex; align-items: center; gap: var(--sp-1); flex: none; }
.list-row[aria-selected="true"] { background: var(--accent-soft); }

.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: var(--fs-12); }
.table th {
  text-align: left; font-size: var(--fs-11); font-weight: 600; color: var(--text-3);
  letter-spacing: var(--tr-wide); text-transform: uppercase;
  padding: var(--sp-2) var(--sp-3); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; background: var(--surface); z-index: 1; white-space: nowrap;
}
.table td { padding: var(--sp-3); border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
.table tbody tr { transition: background var(--dur-1) var(--ease); }
.table tbody tr:hover { background: var(--surface-2); }
.table td.num { text-align: right; font-variant-numeric: tabular-nums; font-family: var(--font-mono); }
.table-wrap { border: 1px solid var(--line-soft); border-radius: var(--r-lg); overflow: auto; background: var(--surface); max-height: 100%; }

.kv { display: grid; grid-template-columns: minmax(120px, auto) 1fr; gap: var(--sp-2) var(--sp-4); font-size: var(--fs-12); }
.kv dt { color: var(--text-3); }
.kv dd { margin: 0; font-family: var(--font-mono); font-size: var(--fs-11); color: var(--text-2); overflow-wrap: anywhere; }

.stat { padding: var(--sp-4); }
.stat .s-val { font-family: var(--font-display); font-size: var(--fs-28); line-height: 1.1; letter-spacing: var(--tr-tight); font-variant-numeric: tabular-nums; }
.stat .s-label { font-size: var(--fs-12); margin-top: var(--sp-2); font-weight: 500; }
.stat .s-sub { font-size: var(--fs-11); color: var(--text-3); margin-top: 2px; }
.stat .s-top { display: flex; align-items: flex-start; justify-content: space-between; }
.stat .s-top .ic { color: var(--text-3); }

.meter { height: 4px; border-radius: var(--r-full); background: var(--surface-3); overflow: hidden; }
.meter > i { display: block; height: 100%; border-radius: var(--r-full); background: var(--accent); }
.meter.ok > i { background: var(--ok); }
.meter.warn > i { background: var(--warn); }

/* --------------------------------------------------------- empty etc --- */
.empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: var(--sp-3); padding: var(--sp-8) var(--sp-5); text-align: center;
  border: 1px dashed var(--line); border-radius: var(--r-lg); background: var(--empty-bg);
}
.empty .e-icon {
  display: grid; place-items: center; width: 44px; height: 44px; border-radius: var(--r-lg);
  background: var(--surface-2); color: var(--text-3); border: 1px solid var(--line-soft);
}
.empty .e-title { font-size: var(--fs-13); font-weight: 600; }
.empty .e-sub { font-size: var(--fs-12); color: var(--text-3); max-width: 46ch; }

.spinner {
  width: 16px; height: 16px; border-radius: var(--r-full); flex: none;
  border: 2px solid var(--line-strong); border-top-color: var(--accent);
  animation: spin .7s linear infinite;
}
.spinner.lg { width: 26px; height: 26px; border-width: 2.5px; }
@keyframes spin { to { transform: rotate(360deg); } }

.skeleton {
  border-radius: var(--r-sm); background: linear-gradient(90deg, var(--surface-2), var(--surface-3), var(--surface-2));
  background-size: 200% 100%; animation: shimmer 1.4s var(--ease) infinite; height: 10px;
}
@keyframes shimmer { to { background-position: -200% 0; } }

.loading-block { display: flex; flex-direction: column; align-items: center; gap: var(--sp-3); padding: var(--sp-8); }

.progressbar { height: 3px; border-radius: var(--r-full); background: var(--surface-3); overflow: hidden; }
.progressbar > i { display: block; height: 100%; background: var(--accent); border-radius: var(--r-full); transition: width var(--dur-3) var(--ease); }
.progressbar.indeterminate > i { width: 35%; animation: indet 1.3s var(--ease) infinite; }
@keyframes indet { 0% { margin-left: -35%; } 100% { margin-left: 100%; } }

.codeblock {
  font-family: var(--font-mono); font-size: var(--fs-11); line-height: 1.65;
  padding: var(--sp-3); border-radius: var(--r-md); background: var(--code-bg);
  border: 1px solid var(--line-soft); color: var(--text-2);
  overflow: auto; max-height: 220px; white-space: pre-wrap; word-break: break-word;
}
.codeblock .c-dim { color: var(--text-3); }
.codeblock .c-ok { color: var(--ok); }
.codeblock .c-warn { color: var(--warn); }

/* ------------------------------------------------- overlays / menus ---- */
.scrim {
  position: fixed; inset: 0; z-index: 60; background: var(--scrim);
  backdrop-filter: blur(var(--scrim-blur)); animation: fade var(--dur-2) var(--ease);
}
@keyframes fade { from { opacity: 0; } }

.menu {
  position: fixed; z-index: 70; min-width: 200px; max-width: 340px;
  padding: var(--sp-2); border-radius: var(--r-lg);
  background: var(--overlay); border: 1px solid var(--line);
  box-shadow: var(--sh-3); animation: pop var(--dur-2) var(--ease);
  max-height: min(70vh, 520px); overflow-y: auto;
}
@keyframes pop { from { opacity: 0; transform: translateY(-4px) scale(.985); } }
.menu-label { padding: var(--sp-2) var(--sp-3) var(--sp-1); font-size: var(--fs-11); font-weight: 600; letter-spacing: var(--tr-wide); text-transform: uppercase; color: var(--text-3); }
.menu-item {
  display: flex; align-items: center; gap: var(--sp-3); width: 100%;
  min-height: var(--h-lg); padding: var(--sp-2) var(--sp-3); border-radius: var(--r-md);
  font-size: var(--fs-13); color: var(--text); text-align: left;
  transition: background var(--dur-1) var(--ease);
}
.menu-item:hover { background: var(--surface-2); }
.menu-item .ic { color: var(--text-3); flex: none; }
.menu-item .mi-main { flex: 1; min-width: 0; }
.menu-item .mi-sub { font-size: var(--fs-11); color: var(--text-3); margin-top: 1px; }
.menu-item .mi-trail { font-size: var(--fs-11); color: var(--text-3); flex: none; }
.menu-item[aria-checked="true"] { color: var(--accent-fg); }
.menu-item[aria-checked="true"] .ic.tick { color: var(--accent-fg); opacity: 1; }
.menu-item .ic.tick { opacity: 0; }
.menu-item.danger { color: var(--danger); }
.menu-item.danger .ic { color: var(--danger); }
.menu-sep { height: 1px; margin: var(--sp-2) var(--sp-1); background: var(--line-soft); }
.menu-search { padding: var(--sp-1) var(--sp-1) var(--sp-2); position: sticky; top: calc(var(--sp-2) * -1); background: var(--overlay); z-index: 1; }

.dialog-wrap { position: fixed; inset: 0; z-index: 80; display: grid; place-items: center; padding: var(--sp-6); }
.dialog {
  width: min(var(--dlg-w, 520px), 100%); max-height: calc(100vh - var(--sp-9));
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--overlay); border: 1px solid var(--line); border-radius: var(--r-xl);
  box-shadow: var(--sh-3); animation: dlg var(--dur-3) var(--ease);
}
@keyframes dlg { from { opacity: 0; transform: translateY(8px) scale(.985); } }
.dialog-head { display: flex; align-items: flex-start; gap: var(--sp-3); padding: var(--sp-5) var(--sp-5) var(--sp-4); }
.dialog-head .dh-text { flex: 1; min-width: 0; }
.dialog-head .dh-title { font-size: var(--fs-16); font-weight: 600; letter-spacing: var(--tr-tight); }
.dialog-head .dh-sub { margin-top: var(--sp-2); font-size: var(--fs-12); color: var(--text-2); }
.dialog-body { flex: 1; min-height: 0; overflow-y: auto; padding: 0 var(--sp-5) var(--sp-5); }
.dialog-foot {
  display: flex; align-items: center; gap: var(--sp-2); justify-content: flex-end;
  padding: var(--sp-4) var(--sp-5); border-top: 1px solid var(--line-soft); background: var(--surface-2);
}
.dialog-foot .df-spacer { flex: 1; }

.toasts { position: fixed; right: var(--sp-5); bottom: var(--sp-5); z-index: 90; display: flex; flex-direction: column; gap: var(--sp-2); align-items: flex-end; }
.toast {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4); border-radius: var(--r-md);
  background: var(--overlay); border: 1px solid var(--line); box-shadow: var(--sh-3);
  font-size: var(--fs-12); max-width: 380px; animation: toastin var(--dur-3) var(--ease);
}
@keyframes toastin { from { opacity: 0; transform: translateY(8px); } }
.toast .ic { color: var(--accent-fg); }
.toast.ok .ic { color: var(--ok); }
.toast.warn .ic { color: var(--warn); }

.tip {
  position: fixed; z-index: 95; padding: 5px var(--sp-2); border-radius: var(--r-sm);
  background: var(--tip-bg); color: var(--tip-fg); font-size: var(--fs-11);
  box-shadow: var(--sh-2); pointer-events: none; white-space: nowrap;
}

/* ============================================================== CHAT ==== */
.chat-hero { display: flex; flex-direction: column; align-items: center; padding: var(--sp-8) 0 var(--sp-6); }
.chat-hero .greeting { font-family: var(--font-display); font-size: var(--fs-28); letter-spacing: var(--tr-tight); font-weight: var(--fw-display); text-align: center; }
.chat-hero .greeting-sub { margin-top: var(--sp-3); color: var(--text-2); font-size: var(--fs-13); text-align: center; }

.composer {
  border: 1px solid var(--line); border-radius: var(--r-xl); background: var(--composer-bg);
  box-shadow: var(--sh-2); transition: border-color var(--dur-2) var(--ease), box-shadow var(--dur-2) var(--ease);
}
.composer:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft), var(--sh-2); }
.composer .c-input {
  width: 100%; min-height: 68px; padding: var(--sp-4) var(--sp-4) var(--sp-2);
  border: 0; background: none; resize: none; font-size: var(--fs-14); line-height: var(--lh-body);
}
.composer .c-input::placeholder { color: var(--text-3); }
.composer .c-bar { display: flex; align-items: center; gap: var(--sp-2); padding: var(--sp-2) var(--sp-3) var(--sp-3); flex-wrap: wrap; }
.composer .c-bar .spacer { flex: 1; min-width: var(--sp-4); }
.composer .c-send {
  display: grid; place-items: center; width: 30px; height: 30px; border-radius: var(--r-full);
  background: var(--accent); color: var(--accent-ink); flex: none;
  transition: transform var(--dur-1) var(--ease), background var(--dur-1) var(--ease);
}
.composer .c-send:hover { background: var(--accent-hover); transform: scale(1.05); }
.composer .c-context {
  display: flex; align-items: center; gap: var(--sp-2); padding: var(--sp-2) var(--sp-3);
  border-top: 1px solid var(--line-soft); font-size: var(--fs-11); color: var(--text-3); flex-wrap: wrap;
}

.assistant-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(232px, 1fr)); gap: var(--sp-3); }
.assistant-card {
  display: flex; align-items: flex-start; gap: var(--sp-3); padding: var(--sp-3);
  border: 1px solid var(--line-soft); border-radius: var(--r-lg); background: var(--surface);
  text-align: left; transition: border-color var(--dur-2) var(--ease), background var(--dur-2) var(--ease), transform var(--dur-2) var(--ease);
}
.assistant-card:hover { border-color: var(--accent-line); background: var(--surface-2); transform: translateY(-1px); }
.assistant-card .ac-main { min-width: 0; flex: 1; }
.assistant-card .ac-name { font-size: var(--fs-12); font-weight: 600; display: flex; align-items: center; gap: var(--sp-2); }
.assistant-card .ac-desc { font-size: var(--fs-11); color: var(--text-3); margin-top: 3px; }

.thread { display: flex; flex-direction: column; gap: var(--sp-5); padding-bottom: var(--sp-6); }
.msg { display: flex; gap: var(--sp-3); }
.msg .m-body { min-width: 0; flex: 1; }
.msg .m-head { display: flex; align-items: baseline; gap: var(--sp-2); margin-bottom: var(--sp-2); }
.msg .m-who { font-size: var(--fs-12); font-weight: 600; }
.msg .m-time { font-size: var(--fs-11); color: var(--text-3); }
.msg .m-text { font-size: var(--fs-13); line-height: 1.65; color: var(--text); }
.msg .m-text p + p { margin-top: var(--sp-3); }
.msg.user .m-text { padding: var(--sp-3) var(--sp-4); border-radius: var(--r-lg); background: var(--bubble-user); border: 1px solid var(--line-soft); }
.msg .m-actions { display: flex; gap: var(--sp-1); margin-top: var(--sp-3); opacity: 0; transition: opacity var(--dur-1) var(--ease); }
.msg:hover .m-actions { opacity: 1; }

.toolcall {
  margin-top: var(--sp-3); border: 1px solid var(--line-soft); border-radius: var(--r-md);
  background: var(--surface-2); overflow: hidden;
}
.toolcall .tc-head {
  display: flex; align-items: center; gap: var(--sp-2); width: 100%;
  padding: var(--sp-2) var(--sp-3); font-size: var(--fs-11); color: var(--text-2); text-align: left;
}
.toolcall .tc-head:hover { background: var(--surface-3); }
.toolcall .tc-name { font-family: var(--font-mono); color: var(--text); }
.toolcall .tc-body { padding: 0 var(--sp-3) var(--sp-3); }

/* ---------------------------------------------------------- workspace -- */
.split { display: grid; min-height: 0; }
/* card-shaped controls: valid flow content, still keyboard operable */
[role="button"] { cursor: pointer; }
[role="button"]:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.split.a { grid-template-columns: 300px minmax(0, 1fr); }
.split.b { grid-template-columns: 300px minmax(0, 1fr) 280px; }
.split > * { min-width: 0; overflow: hidden; }
.split-pane { display: flex; flex-direction: column; min-height: 0; border-right: 1px solid var(--line-soft); }
.split-pane:last-child { border-right: 0; border-left: 1px solid var(--line-soft); }
.split-pane .sp-head { display: flex; align-items: center; gap: var(--sp-2); padding: var(--sp-3) var(--sp-4); border-bottom: 1px solid var(--line-soft); min-height: 44px; }
.split-pane .sp-scroll { flex: 1; min-height: 0; overflow-y: auto; padding: var(--sp-3) var(--sp-3) calc(var(--sp-3) + 52px); }

.tabstrip { display: flex; align-items: center; gap: 2px; padding: var(--sp-2) var(--sp-3); border-bottom: 1px solid var(--line-soft); background: var(--surface-2); }
.tabchip {
  display: inline-flex; align-items: center; gap: var(--sp-2); height: 28px; padding: 0 var(--sp-2) 0 var(--sp-3);
  border-radius: var(--r-md); font-size: var(--fs-12); color: var(--text-2); max-width: 190px;
}
.tabchip:hover { background: var(--surface-3); color: var(--text); }
.tabchip[aria-selected="true"] { background: var(--surface); color: var(--text); border: 1px solid var(--line); }
.tabchip .x { display: grid; place-items: center; width: 18px; height: 18px; border-radius: var(--r-sm); color: var(--text-3); }
.tabchip .x:hover { background: var(--surface-3); color: var(--text); }

.filetree .ft-row {
  display: flex; align-items: center; gap: var(--sp-2); width: 100%;
  padding: var(--sp-2) var(--sp-2); border-radius: var(--r-sm); font-size: var(--fs-12);
  color: var(--text-2); text-align: left;
}
.filetree .ft-row:hover { background: var(--surface-2); color: var(--text); }
.filetree .ft-row[aria-selected="true"] { background: var(--accent-soft); color: var(--accent-fg); }
.filetree .ft-row .n { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.filetree .ft-row .c { font-size: var(--fs-11); color: var(--text-3); }

.thumb {
  aspect-ratio: 16 / 10; border-radius: var(--r-md); overflow: hidden;
  border: 1px solid var(--line-soft); background: var(--surface-2);
  display: grid; place-items: center; color: var(--text-3); position: relative;
}
.thumb .tlabel { font-family: var(--font-display); font-size: var(--fs-22); font-weight: var(--fw-display); color: var(--thumb-ink); }
.thumb.g1 { background: var(--thumb-g1); }
.thumb.g2 { background: var(--thumb-g2); }
.thumb.g3 { background: var(--thumb-g3); }
.thumb.g4 { background: var(--thumb-g4); }
.thumb.g5 { background: var(--thumb-g5); }
.thumb.g6 { background: var(--thumb-g6); }

.orgnode {
  display: inline-flex; flex-direction: column; gap: var(--sp-2); padding: var(--sp-3) var(--sp-4);
  border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface); box-shadow: var(--sh-1);
  min-width: 200px; text-align: left;
}
.orgcanvas {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: var(--sp-6);
  padding: var(--sp-7) var(--sp-5); border: 1px solid var(--line-soft); border-radius: var(--r-lg);
  background: var(--canvas-bg); background-image: radial-gradient(var(--canvas-dot) 1px, transparent 1px);
  background-size: 18px 18px; min-height: 380px;
}
.orgcanvas .connector { width: 1px; height: var(--sp-6); background: var(--line-strong); margin: calc(var(--sp-6) * -1) 0; }

/* review-mode banner shared by every prototype page */
.reviewbar {
  position: fixed; left: 50%; bottom: 14px; transform: translateX(-50%); z-index: 100;
  display: flex; align-items: center; gap: var(--sp-2);
  padding: 6px 8px 6px 14px; border-radius: var(--r-full);
  background: var(--overlay); border: 1px solid var(--line); box-shadow: var(--sh-3);
  font-size: var(--fs-11); color: var(--text-2); max-width: calc(100vw - 32px);
}
.reviewbar .rb-name { font-weight: 600; color: var(--text); }
.reviewbar .rb-sep { width: 1px; height: 16px; background: var(--line); }
.reviewbar a, .reviewbar button { color: var(--text-2); padding: 4px 8px; border-radius: var(--r-full); white-space: nowrap; }
.reviewbar a:hover, .reviewbar button:hover { background: var(--surface-2); color: var(--text); }
.reviewbar.hidden { opacity: 0; pointer-events: none; }

/* ========================================================= RESPONSIVE == */
/* compact desktop — the point at which secondary chrome starts folding    */
@media (max-width: 1380px) {
  [data-mode="command"][data-ops="auto"] .shell { grid-template-columns: 0 var(--nav-w) minmax(0, 1fr) 0; }
  [data-mode="command"][data-ops="auto"][data-nav="collapsed"] .shell { grid-template-columns: var(--rail-w) 0 minmax(0, 1fr) 0; }
  [data-mode="command"][data-ops="auto"] .ops { visibility: hidden; }
  .split.b { grid-template-columns: 260px minmax(0, 1fr); }
  .split.b > :last-child { display: none; }
}
/* Compact desktop: navigation always folds to the icon rail, in every mode.
   Selectors here match the specificity of the wider-breakpoint rules above,
   so ordering — not weight — decides. */
@media (max-width: 1180px) {
  :root { --page-pad-x: var(--sp-5); }
  .shell .nav { visibility: hidden; }
  [data-mode="rail"] .rail, [data-mode="studio"] .rail, [data-mode="command"] .rail { visibility: visible; }
  [data-mode="rail"] .shell    { grid-template-columns: var(--rail-w) 0 minmax(0, 1fr); }
  [data-mode="studio"] .shell  { grid-template-columns: var(--rail-w) 0 minmax(0, 1fr); }
  [data-mode="command"][data-ops="auto"] .shell,
  [data-mode="command"][data-ops="off"] .shell { grid-template-columns: var(--rail-w) 0 minmax(0, 1fr) 0; }
  [data-mode="command"][data-ops="on"] .shell  { grid-template-columns: var(--rail-w) 0 minmax(0, 1fr) var(--ops-w); }
  [data-mode="command"][data-ops="on"] .ops { visibility: visible; }
  .grid.c4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid.c3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .split.a { grid-template-columns: 240px minmax(0, 1fr); }
}
@media (max-width: 920px) {
  .grid.c2, .grid.c3, .grid.c4 { grid-template-columns: minmax(0, 1fr); }
  .page-head { flex-direction: column; }
  .split.a, .split.b { grid-template-columns: minmax(0, 1fr); }
  .split.a > :first-child, .split.b > :first-child { display: none; }
}
