/* ============================================================
   Institution OS — Stenson Law demo
   Design system: Animation Studio Kit (Purple Rain) — dark only
   Tokens sourced from kit.scottelling.com/kit/animation
   ============================================================ */

@font-face {
  font-family: "Outfit";
  src: url("assets/fonts/outfit-latin.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "JetBrains Mono";
  src: url("assets/fonts/jetbrains-mono-latin.woff2") format("woff2");
  font-weight: 100 800;
  font-style: normal;
  font-display: swap;
}

:root {
  color-scheme: dark;

  /* Surfaces */
  --background: oklch(0.15683 0.01057 285.12);
  --foreground: oklch(0.94481 0.00802 286.25);
  --card: oklch(0.20452 0.01782 284.72);
  --popover: oklch(0.24539 0.0246 284.44);
  --plane-1: oklch(0.1765 0.01438 284.83);
  --plane-2: oklch(0.20452 0.01782 284.72);
  --plane-3: oklch(0.24539 0.0246 284.44);
  --plane-pressed: oklch(0.16788 0.01665 284.46);
  --sidebar: var(--plane-1);

  /* Ink */
  --muted-foreground: oklch(1 0 0 / 0.56);
  --ink-faint: oklch(1 0 0 / 0.36);

  /* Accent + status */
  --primary: oklch(0.71998 0.17231 303.07);
  --primary-foreground: oklch(0.15683 0.01057 285.12);
  --primary-soft: oklch(0.71998 0.17231 303.07 / 0.13);
  --info: oklch(0.75854 0.1238 260.18);
  --info-soft: oklch(0.75854 0.1238 260.18 / 0.13);
  --warning: oklch(0.88878 0.16396 93.4);
  --warning-soft: oklch(0.88878 0.16396 93.4 / 0.12);
  --success: oklch(0.8628 0.15184 159.4);
  --success-soft: oklch(0.8628 0.15184 159.4 / 0.12);
  --danger: oklch(0.71161 0.18122 22.84);
  --danger-soft: oklch(0.71161 0.18122 22.84 / 0.13);

  --border: oklch(1 0 0 / 0.07);
  --border-strong: oklch(1 0 0 / 0.13);
  --input: var(--plane-3);
  --ring: var(--primary);

  /* Shape */
  --radius-control: 0.5625rem;
  --radius-card: 0.75rem;
  --radius-sheet: 1rem;

  /* Elevation */
  --shadow-control: inset 0 0 0 1px oklch(1 0 0 / 0.07);
  --shadow-panel: 0 18px 46px -18px oklch(0 0 0 / 0.9), inset 0 0 0 1px oklch(1 0 0 / 0.07);
  --shadow-pop: 0 24px 70px -24px oklch(0 0 0 / 0.95), inset 0 0 0 1px oklch(1 0 0 / 0.09);

  /* Type */
  --font-ui: "Outfit", ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

  /* Motion */
  --dur-micro: 120ms;
  --dur-short: 180ms;
  --dur-fade: 280ms;
  --dur-pop: 360ms;
  --dur-rise: 420ms;
  --ease: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-drawer: cubic-bezier(0.32, 0.72, 0, 1);

  /* Layout */
  --topbar-h: 58px;
  --rail-w: 292px;
  --inspector-w: 324px;
  --control-h: 40px;
  --control-sm: 32px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--background);
  color: var(--foreground);
  font-family: var(--font-ui);
  font-size: 14px;
  line-height: 1.45;
  letter-spacing: -0.008em;
  text-rendering: optimizeLegibility;
  overflow: hidden;
}
@media (-webkit-min-device-pixel-ratio: 1.5), (min-resolution: 1.5dppx) {
  body { -webkit-font-smoothing: antialiased; }
}
::selection { background: oklch(0.71998 0.17231 303.07 / 0.35); }
:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; border-radius: var(--radius-control); }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; padding: 0; }
svg { width: 1em; height: 1em; flex: none; }
input, textarea, select { font: inherit; color: inherit; }
b, strong { font-weight: 600; }
a { color: inherit; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: oklch(1 0 0 / 0.1); border-radius: 8px; border: 3px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: oklch(1 0 0 / 0.18); border: 3px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- keyframes ---------- */
@keyframes rise { from { opacity: 0; transform: translateY(7px); } to { opacity: 1; transform: none; } }
@keyframes pop  { from { opacity: 0; transform: scale(0.975); } to { opacity: 1; transform: none; } }
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }
@keyframes pulse-dot { 0%,100% { opacity: 1; } 50% { opacity: 0.35; } }
@keyframes blink { 0%,100% { opacity: 1; } 50% { opacity: 0; } }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px) scale(0.98); } to { opacity: 1; transform: none; } }
@keyframes typing-bounce { 0%,80%,100% { transform: none; opacity: .4; } 40% { transform: translateY(-3px); opacity: 1; } }
@keyframes bar-grow { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@keyframes modal-pop { from { opacity: 0; transform: translate(-50%, -50%) scale(0.975); } to { opacity: 1; transform: translate(-50%, -50%) scale(1); } }
@keyframes centerx-pop { from { opacity: 0; transform: translateX(-50%) scale(0.985); } to { opacity: 1; transform: translateX(-50%) scale(1); } }
@keyframes centerx-in { from { opacity: 0; transform: translateX(-50%) translateY(10px); } to { opacity: 1; transform: translateX(-50%) translateY(0); } }

.rise { animation: rise var(--dur-rise) var(--ease) both; }
.pop  { animation: pop var(--dur-pop) var(--ease) both; }
.fade { animation: fadein var(--dur-fade) var(--ease) both; }
[data-stagger] > * { animation: rise var(--dur-rise) var(--ease) both; }
[data-stagger] > *:nth-child(1) { animation-delay: 0ms; }
[data-stagger] > *:nth-child(2) { animation-delay: 40ms; }
[data-stagger] > *:nth-child(3) { animation-delay: 80ms; }
[data-stagger] > *:nth-child(4) { animation-delay: 120ms; }
[data-stagger] > *:nth-child(5) { animation-delay: 160ms; }
[data-stagger] > *:nth-child(6) { animation-delay: 200ms; }
[data-stagger] > *:nth-child(7) { animation-delay: 240ms; }
[data-stagger] > *:nth-child(8) { animation-delay: 280ms; }
[data-stagger] > *:nth-child(n+9) { animation-delay: 320ms; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-delay: 0ms !important; transition-duration: 0.01ms !important; }
}

/* ---------- app frame ---------- */
#app {
  display: grid;
  grid-template-rows: var(--topbar-h) 1fr;
  grid-template-columns: var(--rail-w) minmax(0, 1fr) var(--inspector-w);
  grid-template-areas: "topbar topbar topbar" "rail main inspector";
  height: 100vh;
  height: 100dvh;
}
#app.no-inspector { grid-template-columns: var(--rail-w) minmax(0, 1fr) 0; }
#app.no-inspector #inspector { display: none; }

/* ---------- topbar ---------- */
#topbar {
  grid-area: topbar;
  min-width: 0;
  display: flex; align-items: center; gap: 12px;
  padding: 0 14px;
  background: var(--sidebar);
  border-bottom: 1px solid var(--border);
  z-index: 40;
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-glyph {
  width: 34px; height: 34px; border-radius: var(--radius-control);
  background: var(--primary); color: var(--primary-foreground);
  display: grid; place-items: center; flex: none;
}
.brand-glyph svg { width: 18px; height: 18px; }
.brand-name { font-weight: 700; font-size: 14px; letter-spacing: -0.01em; white-space: nowrap; }
.brand-sub { font-family: var(--font-mono); font-size: 10px; color: var(--muted-foreground); white-space: nowrap; }

.switcher {
  display: flex; align-items: center; gap: 8px;
  height: var(--control-h); padding: 0 10px 0 12px;
  border-radius: var(--radius-control);
  background: var(--plane-2); box-shadow: var(--shadow-control);
  transition: background var(--dur-micro) var(--ease);
  max-width: 240px;
}
.switcher:hover { background: var(--plane-3); }
.switcher b { font-size: 13px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.switcher .chev { color: var(--muted-foreground); flex: none; }
.switcher-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--success); flex: none; }

.topbar-right { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.demo-chip {
  font-family: var(--font-mono); font-size: 10px; color: var(--muted-foreground);
  border: 1px dashed var(--border-strong); border-radius: 999px; padding: 4px 10px;
  white-space: nowrap;
}
.icon-btn {
  width: var(--control-h); height: var(--control-h);
  display: grid; place-items: center;
  border-radius: var(--radius-control);
  color: var(--muted-foreground);
  transition: background var(--dur-micro) var(--ease), color var(--dur-micro) var(--ease);
  position: relative;
}
.icon-btn:hover { background: var(--plane-3); color: var(--foreground); }
.icon-btn svg { width: 17px; height: 17px; }
.icon-btn .bubble {
  position: absolute; top: 6px; right: 6px;
  min-width: 15px; height: 15px; padding: 0 4px; border-radius: 999px;
  background: var(--primary); color: var(--primary-foreground);
  font-size: 9.5px; font-weight: 800; line-height: 15px; font-family: var(--font-mono);
}
.avatar-btn {
  width: 34px; height: 34px; border-radius: 50%;
  background: linear-gradient(135deg, oklch(0.45 0.12 303), oklch(0.32 0.08 280));
  color: var(--foreground); font-weight: 800; font-size: 12px;
  display: grid; place-items: center;
  box-shadow: var(--shadow-control);
}

/* ---------- omnibar ---------- */
#omni-wrap { flex: 1; display: flex; justify-content: center; min-width: 0; position: relative; }
#omnibar {
  width: min(620px, 100%);
  height: var(--control-h);
  display: flex; align-items: center; gap: 8px;
  background: var(--plane-2);
  border-radius: var(--radius-control);
  box-shadow: var(--shadow-control);
  padding: 0 6px 0 12px;
  transition: box-shadow var(--dur-short) var(--ease), background var(--dur-short) var(--ease);
}
#omnibar:focus-within { background: var(--plane-3); box-shadow: inset 0 0 0 1.5px var(--primary); }
#omnibar .spark { color: var(--primary); flex: none; }
#omnibar .spark svg { width: 16px; height: 16px; }
#omni-input { flex: 1; background: transparent; border: 0; outline: 0; font-size: 13.5px; min-width: 0; }
#omni-input::placeholder { color: var(--ink-faint); }
.kbd {
  font-family: var(--font-mono); font-size: 10px; color: var(--muted-foreground);
  border: 1px solid var(--border-strong); border-radius: 6px; padding: 2px 6px;
  background: var(--plane-1); flex: none;
}
#omni-send {
  height: 30px; padding: 0 12px; border-radius: 7px; flex: none;
  background: var(--primary); color: var(--primary-foreground);
  font-weight: 800; font-size: 12px;
  display: grid; place-items: center;
  transition: transform var(--dur-micro) var(--ease), opacity var(--dur-micro) var(--ease);
}
#omni-send:active { transform: translateY(1px); }

/* omnibar overlay (palette + answers) */
#omni-panel {
  position: fixed;
  top: calc(var(--topbar-h) + 8px);
  left: 50%; transform: translateX(-50%);
  width: min(680px, calc(100vw - 32px));
  max-height: min(620px, calc(100dvh - var(--topbar-h) - 32px));
  overflow: auto;
  background: var(--popover);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-pop);
  z-index: 60;
  animation: centerx-pop var(--dur-pop) var(--ease) both;
}
#omni-panel .section-label { padding: 12px 14px 6px; }
.section-label {
  font-family: var(--font-mono); font-size: 10px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.09em;
  color: var(--muted-foreground);
}
.omni-sug {
  display: flex; align-items: center; gap: 10px;
  width: 100%; text-align: left;
  padding: 9px 14px; font-size: 13.5px;
  transition: background var(--dur-micro) var(--ease);
}
.omni-sug:hover, .omni-sug.active { background: oklch(1 0 0 / 0.05); }
.omni-sug svg { width: 15px; height: 15px; color: var(--muted-foreground); flex: none; }
.omni-sug .hint { margin-left: auto; font-family: var(--font-mono); font-size: 10px; color: var(--ink-faint); }

.ai-answer { padding: 16px 18px 14px; }
.ai-answer-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.ai-answer-head .who { font-weight: 800; font-size: 12px; }
.ai-answer-head .spark { color: var(--primary); display: grid; }
.ai-answer-head .spark svg { width: 14px; height: 14px; }
.ai-answer-head time { margin-left: auto; font-family: var(--font-mono); font-size: 10px; color: var(--ink-faint); }
.ai-body { font-size: 13.5px; white-space: pre-wrap; }
.ai-body b, .chat-msg b { font-weight: 700; }
.caret { display: inline-block; width: 7px; height: 15px; background: var(--primary); vertical-align: -2px; margin-left: 2px; animation: blink 0.9s steps(1) infinite; border-radius: 2px; }
.ai-rows { margin-top: 12px; display: grid; gap: 6px; }
.ai-row {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  background: var(--plane-2); border-radius: var(--radius-control);
  padding: 9px 12px; box-shadow: var(--shadow-control);
  font-size: 13px;
  transition: background var(--dur-micro) var(--ease), transform var(--dur-micro) var(--ease);
}
.ai-row:hover { background: oklch(0.225 0.02 284.6); }
.ai-row .grow { flex: 1; min-width: 0; }
.ai-row .t { font-weight: 700; }
.ai-row .s { color: var(--muted-foreground); font-size: 12px; }
.ai-actions { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.ai-sources { display: flex; gap: 6px; margin-top: 12px; flex-wrap: wrap; }

/* ---------- left rail ---------- */
#rail {
  grid-area: rail;
  position: relative;
  background: var(--sidebar);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  min-height: 0;
  z-index: 30;
}
.rail-tabs { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 6px; padding: 12px 12px 8px; }
.rail-tab {
  display: grid; place-items: center; gap: 3px;
  padding: 9px 4px 7px;
  border-radius: var(--radius-control);
  color: var(--muted-foreground);
  font-size: 11px; font-weight: 700;
  box-shadow: var(--shadow-control);
  background: var(--plane-2);
  transition: background var(--dur-micro) var(--ease), color var(--dur-micro) var(--ease), box-shadow var(--dur-micro) var(--ease);
}
.rail-tab svg { width: 17px; height: 17px; }
.rail-tab:hover { color: var(--foreground); background: var(--plane-3); }
.rail-tab.active { color: var(--foreground); background: var(--plane-3); box-shadow: inset 0 0 0 1.5px var(--primary); }
.rail-search { margin: 4px 12px 8px; position: relative; }
.rail-search input {
  width: 100%; height: 34px;
  background: var(--plane-2); border: 0; border-radius: var(--radius-control);
  box-shadow: var(--shadow-control);
  padding: 0 10px 0 32px; font-size: 12.5px; outline: 0;
}
.rail-search input:focus { box-shadow: inset 0 0 0 1.5px var(--primary); }
.rail-search svg { position: absolute; left: 10px; top: 9px; width: 15px; height: 15px; color: var(--ink-faint); pointer-events: none; }
#rail-body { flex: 1; overflow-y: auto; padding: 2px 8px 12px; min-height: 0; }
.rail-foot {
  padding: 10px 14px; border-top: 1px solid var(--border);
  font-family: var(--font-mono); font-size: 9.5px; color: var(--ink-faint);
  display: flex; align-items: center; gap: 6px;
}
.rail-foot .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--success); animation: pulse-dot 2.4s var(--ease) infinite; }

.rail-group {
  margin: 0 2px 8px;
  background: var(--plane-2);
  border-radius: 11px;
  padding: 5px 6px 6px;
  box-shadow: var(--shadow-control);
}
.rail-group > .section-label { padding: 5px 8px 4px; display: flex; align-items: center; }
.rail-actions { margin: 2px 2px 8px; display: grid; gap: 6px; }
.group-toggle {
  width: 100%; text-align: left; gap: 6px; cursor: pointer;
  border-radius: 7px;
  transition: color var(--dur-micro) var(--ease), background var(--dur-micro) var(--ease);
}
.group-toggle:hover { color: var(--foreground); background: oklch(1 0 0 / 0.035); }
.group-toggle .chev { transition: transform var(--dur-short) var(--ease); }
.group-toggle .chev svg { width: 11px; height: 11px; }
.group-toggle.open .chev { transform: rotate(90deg); }
.group-toggle .gcount { margin-left: auto; font-size: 9.5px; background: var(--plane-3); border-radius: 999px; padding: 1px 7px; }
.tree-row, .rail-item {
  display: flex; align-items: center; gap: 8px;
  width: 100%; text-align: left;
  padding: 6px 8px; border-radius: 8px;
  font-size: 13px;
  color: oklch(1 0 0 / 0.78);
  transition: background var(--dur-micro) var(--ease), color var(--dur-micro) var(--ease);
  position: relative;
}
.tree-row:hover, .rail-item:hover { background: oklch(1 0 0 / 0.055); color: var(--foreground); }
.tree-row.active, .rail-item.active { background: var(--primary-soft); color: var(--foreground); }

.tree-row svg, .rail-item svg { width: 15px; height: 15px; color: var(--muted-foreground); flex: none; }
.tree-row.active svg, .rail-item.active svg { color: var(--primary); }
.tree-row .lbl, .rail-item .lbl { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 400; color: oklch(1 0 0 / 0.74); }
.rail-item .lbl b { font-weight: 500; color: oklch(1 0 0 / 0.88); }
.tree-row.active .lbl, .rail-item.active .lbl { color: var(--foreground); }
.tree-folder { font-weight: 600; color: var(--foreground); }
.tree-folder .lbl { font-weight: 600; color: var(--foreground); }
.tree-folder .chev { transition: transform var(--dur-short) var(--ease); color: var(--muted-foreground); }
.tree-folder.open .chev { transform: rotate(90deg); }
.tree-children { overflow: hidden; padding-left: 14px; }
.rail-item .meta { font-family: var(--font-mono); font-size: 9.5px; color: var(--ink-faint); flex: none; }
.rail-item .mini-badge {
  flex: none; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 999px;
  background: var(--primary); color: var(--primary-foreground);
  font-size: 9.5px; font-weight: 800; line-height: 16px; text-align: center; font-family: var(--font-mono);
}
.rail-item .dot-status { width: 7px; height: 7px; border-radius: 50%; flex: none; }

/* avatars */
.avv { border-radius: 50%; display: grid; place-items: center; font-weight: 800; flex: none; position: relative; }
.avv.human { background: linear-gradient(135deg, oklch(0.42 0.1 260), oklch(0.3 0.06 285)); }
.avv.agent { background: var(--plane-3); box-shadow: inset 0 0 0 1.5px oklch(0.71998 0.17231 303.07 / 0.55); color: oklch(0.85 0.09 303); }
.avv.s28 { width: 28px; height: 28px; font-size: 10px; }
.avv.s34 { width: 34px; height: 34px; font-size: 12px; }
.avv.s44 { width: 44px; height: 44px; font-size: 15px; }
.avv .ai-tick {
  position: absolute; right: -3px; bottom: -3px;
  font-size: 7px; font-weight: 800; font-family: var(--font-mono);
  background: var(--primary); color: var(--primary-foreground);
  border-radius: 4px; padding: 1px 3px; line-height: 1.2;
  border: 2px solid var(--sidebar);
}

/* ---------- main ---------- */
#main {
  grid-area: main;
  overflow-y: auto;
  min-width: 0;
  scroll-behavior: smooth;
}
.view { padding: 26px 30px 60px; max-width: 1120px; margin: 0 auto; }
.view-head { margin-bottom: 18px; }
.view-head h1 { margin: 0 0 4px; font-size: 26px; font-weight: 800; letter-spacing: -0.03em; line-height: 1.1; }
.view-head .sub { color: var(--muted-foreground); font-size: 13px; }
.view-head .crumbs { font-family: var(--font-mono); font-size: 10px; color: var(--ink-faint); margin-bottom: 10px; display: flex; align-items: center; gap: 6px; }
.view-head .crumbs a { text-decoration: none; color: var(--muted-foreground); }
.view-head .crumbs a:hover { color: var(--foreground); }
.head-row { display: flex; align-items: flex-end; gap: 14px; flex-wrap: wrap; }
.head-row .spacer { flex: 1; }

/* greeting (home) */
.greeting h1 { font-size: 30px; }
.stat-strip { display: flex; gap: 8px; flex-wrap: wrap; margin: 16px 0 22px; }
.stat-chip {
  display: flex; align-items: center; gap: 9px;
  background: var(--plane-2); border-radius: var(--radius-control);
  box-shadow: var(--shadow-control);
  padding: 9px 13px;
  transition: background var(--dur-micro) var(--ease), transform var(--dur-micro) var(--ease);
  text-align: left;
}
.stat-chip:hover { background: var(--plane-3); transform: translateY(-1px); }
.stat-chip b { font-size: 16px; font-weight: 700; letter-spacing: -0.02em; }
.stat-chip span { font-size: 11px; color: var(--muted-foreground); line-height: 1.2; }
.stat-chip.warn b { color: var(--warning); }
.stat-chip.danger b { color: var(--danger); }
.stat-chip.accent b { color: var(--primary); }

/* panel grid */
.panel-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.panel { background: var(--card); border-radius: var(--radius-card); box-shadow: var(--shadow-control); overflow: hidden; display: flex; flex-direction: column; min-width: 0; }
.panel.span2 { grid-column: span 2; }
.panel-head {
  display: flex; align-items: center; gap: 8px;
  padding: 13px 16px 9px;
}
.panel-head h3 { margin: 0; font-size: 16.5px; font-weight: 600; letter-spacing: -0.022em; display: flex; align-items: center; gap: 8px; }
.panel-head h3 svg { display: none; }
.panel-head .count {
  font-family: var(--font-mono); font-size: 10px; color: var(--muted-foreground);
  background: var(--plane-3); padding: 2px 7px; border-radius: 999px;
}
.panel-head .tools { margin-left: auto; display: flex; gap: 2px; }
.panel-head .tools .icon-btn { width: 26px; height: 26px; border-radius: 7px; }
.panel-head .tools .icon-btn svg { width: 13px; height: 13px; }
.panel-body { padding: 4px 8px 10px; }
.panel-body.padded { padding: 4px 14px 14px; }
.panel-foot { padding: 8px 14px 12px; margin-top: auto; }
.panel-foot a, .link-quiet { font-size: 12px; font-weight: 700; color: var(--primary); text-decoration: none; cursor: pointer; }
.panel-foot a:hover, .link-quiet:hover { text-decoration: underline; }

/* list rows in panels */
.row {
  display: flex; align-items: center; gap: 10px;
  width: 100%; text-align: left;
  padding: 8px 8px; border-radius: 9px;
  transition: background var(--dur-micro) var(--ease);
}
.row:hover { background: oklch(1 0 0 / 0.04); }
.row .num {
  width: 22px; height: 22px; flex: none; border-radius: 7px;
  display: grid; place-items: center;
  background: var(--plane-3); font-family: var(--font-mono); font-size: 10.5px; font-weight: 600;
  color: var(--muted-foreground);
}
.row .ic { width: 22px; height: 22px; flex: none; display: grid; place-items: center; }
.row .ic svg { width: 15px; height: 15px; color: var(--ink-faint); }
.row .ic.warn svg { color: var(--warning); }
.row .ic.danger svg { color: var(--danger); }
.row .ic.ok svg { color: var(--ink-faint); }
.row .ic.accent svg { color: var(--ink-faint); }
.row .grow { flex: 1; min-width: 0; }
.row .t { font-size: 13px; font-weight: 500; line-height: 1.3; }
.row .s { font-size: 11.5px; color: var(--muted-foreground); line-height: 1.35; margin-top: 1px; }
.row .end { flex: none; display: flex; align-items: center; gap: 6px; }

/* chips */
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 10.5px; font-weight: 450;
  font-family: var(--font-mono);
  padding: 2.5px 8px; border-radius: 999px;
  background: var(--plane-3); color: var(--muted-foreground);
  white-space: nowrap;
}
.chip.ok { background: var(--plane-3); color: oklch(0.78 0.07 159); }
.chip.warn { background: var(--warning-soft); color: var(--warning); }
.chip.danger { background: var(--danger-soft); color: var(--danger); }
.chip.info { background: var(--plane-3); color: var(--muted-foreground); }
.chip.accent { background: var(--plane-3); color: oklch(0.8 0.08 303); }
.chip.muted { opacity: 0.7; }
.chip .dot { width: 5px; height: 5px; border-radius: 50%; background: currentColor; }

/* buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: var(--control-h); padding: 0 16px;
  border-radius: var(--radius-control);
  font-weight: 650; font-size: 13px; letter-spacing: -0.008em;
  transition: transform var(--dur-micro) var(--ease), background var(--dur-micro) var(--ease), opacity var(--dur-micro) var(--ease), box-shadow var(--dur-micro) var(--ease);
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn svg { width: 15px; height: 15px; }
.btn.primary { background: var(--primary); color: var(--primary-foreground); }
.btn.primary:hover { opacity: 0.92; }
.btn.outline { box-shadow: inset 0 0 0 1px var(--border-strong); color: var(--foreground); }
.btn.outline:hover { background: var(--plane-3); }
.btn.ghost { color: var(--muted-foreground); }
.btn.ghost:hover { background: var(--plane-3); color: var(--foreground); }
.btn.danger { background: var(--danger-soft); color: var(--danger); box-shadow: inset 0 0 0 1px oklch(0.71161 0.18122 22.84 / 0.3); }
.btn.sm { height: var(--control-sm); padding: 0 12px; font-size: 12px; border-radius: 8px; }
.btn.xs { height: 26px; padding: 0 10px; font-size: 11px; border-radius: 7px; }

/* cards & tables */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th {
  text-align: left; font-family: var(--font-mono); font-size: 10px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted-foreground);
  padding: 8px 10px; border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
table.data td { padding: 9px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
table.data tr:last-child td { border-bottom: 0; }
table.data tr.clickable { cursor: pointer; transition: background var(--dur-micro) var(--ease); }
table.data tr.clickable:hover { background: oklch(1 0 0 / 0.035); }
table.data td .t { font-weight: 700; }
table.data td .s { color: var(--muted-foreground); font-size: 11.5px; }
.num-cell { font-family: var(--font-mono); font-size: 12px; white-space: nowrap; }

/* clocks */
.clock-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 16px; }
.clock {
  background: var(--card); border-radius: var(--radius-card); box-shadow: var(--shadow-control);
  padding: 13px 15px;
  position: relative; overflow: hidden;
}

.clock .k { font-family: var(--font-mono); font-size: 9.5px; text-transform: uppercase; letter-spacing: 0.09em; color: var(--muted-foreground); display: flex; align-items: center; gap: 6px; }
.clock .v { font-size: 17px; font-weight: 800; letter-spacing: -0.02em; margin: 5px 0 2px; }
.clock .d { font-size: 11.5px; color: var(--muted-foreground); line-height: 1.4; }

/* timeline */
.timeline { position: relative; margin: 4px 0 0; padding-left: 20px; }
.timeline::before { content: ""; position: absolute; left: 5px; top: 6px; bottom: 6px; width: 1.5px; background: var(--border-strong); }
.tl-item { position: relative; padding: 0 0 14px; }
.tl-item::before {
  content: ""; position: absolute; left: -20px; top: 5px;
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--plane-3); box-shadow: 0 0 0 3px var(--card), inset 0 0 0 2px var(--tl-color, var(--muted-foreground));
}
.tl-item .d { font-family: var(--font-mono); font-size: 10px; color: var(--ink-faint); }
.tl-item .t { font-size: 13px; margin-top: 1px; }

/* kanban */
.kanban { display: grid; grid-template-columns: repeat(4, minmax(210px, 1fr)); gap: 12px; overflow-x: auto; align-items: start; }
.kan-col { background: var(--plane-1); border-radius: var(--radius-card); padding: 10px; box-shadow: var(--shadow-control); min-width: 0; }
.kan-col > .section-label { display: flex; align-items: center; gap: 7px; padding: 2px 4px 10px; }
.kan-col > .section-label .n { margin-left: auto; background: var(--plane-3); border-radius: 999px; padding: 1px 7px; }
.kan-card {
  background: var(--card); border-radius: 10px; box-shadow: var(--shadow-control);
  padding: 11px 12px; margin-bottom: 8px;
  cursor: pointer;
  transition: transform var(--dur-micro) var(--ease), background var(--dur-micro) var(--ease);
  text-align: left; width: 100%;
}
.kan-card:hover { transform: translateY(-1px); background: oklch(0.22 0.019 284.7); }
.kan-card .t { font-weight: 550; font-size: 13px; }
.kan-card .s { font-size: 11.5px; color: var(--muted-foreground); margin-top: 3px; line-height: 1.4; }
.kan-card .foot { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }

/* doc reader */
.doc-surface {
  background: var(--card); border-radius: var(--radius-card); box-shadow: var(--shadow-control);
  padding: 30px 36px 40px; max-width: 780px;
}
.doc-surface h2 { font-size: 19px; font-weight: 800; letter-spacing: -0.02em; margin: 26px 0 10px; }
.doc-surface h2:first-child { margin-top: 0; }
.doc-surface h3 { font-size: 15px; font-weight: 800; margin: 20px 0 8px; }
.doc-surface p { margin: 0 0 12px; font-size: 14px; line-height: 1.62; color: oklch(1 0 0 / 0.84); }
.doc-surface ul, .doc-surface ol { margin: 0 0 12px; padding-left: 20px; }
.doc-surface li { margin-bottom: 5px; font-size: 14px; line-height: 1.55; color: oklch(1 0 0 / 0.84); }
.doc-surface blockquote {
  margin: 14px 0; padding: 12px 16px;
  background: var(--primary-soft); border-radius: 10px;
  font-size: 14.5px; font-weight: 600;
}
.doc-surface table { width: 100%; border-collapse: collapse; margin: 0 0 14px; font-size: 13px; }
.doc-surface th { text-align: left; font-family: var(--font-mono); font-size: 10px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted-foreground); padding: 7px 10px; border-bottom: 1px solid var(--border-strong); }
.doc-surface td { padding: 8px 10px; border-bottom: 1px solid var(--border); }
.doc-surface code { font-family: var(--font-mono); font-size: 12px; background: var(--plane-3); border-radius: 5px; padding: 1.5px 5px; }
.doc-surface .todo { display: flex; gap: 8px; align-items: baseline; }

/* chat view */
.chat-shell { display: flex; flex-direction: column; height: calc(100dvh - var(--topbar-h)); }
.chat-scroll { flex: 1; overflow-y: auto; padding: 24px 30px 10px; }
.chat-inner { max-width: 780px; margin: 0 auto; }
.chat-msg { display: flex; gap: 12px; margin-bottom: 20px; }
.chat-msg .bubble-wrap { flex: 1; min-width: 0; }
.chat-msg .who-line { display: flex; align-items: baseline; gap: 8px; margin-bottom: 3px; }
.chat-msg .who-line b { font-size: 12.5px; }
.chat-msg .who-line time { font-family: var(--font-mono); font-size: 9.5px; color: var(--ink-faint); }
.chat-msg .txt { font-size: 13.5px; line-height: 1.55; white-space: pre-wrap; color: oklch(1 0 0 / 0.88); }
.chat-msg.me .txt { background: var(--primary-soft); border-radius: 12px; padding: 10px 14px; display: inline-block; }
.typing { display: inline-flex; gap: 4px; padding: 8px 2px; }
.typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--muted-foreground); animation: typing-bounce 1.1s infinite; }
.typing i:nth-child(2) { animation-delay: 0.15s; }
.typing i:nth-child(3) { animation-delay: 0.3s; }
.chat-compose { padding: 12px 30px 18px; }
.chat-compose-inner {
  max-width: 780px; margin: 0 auto;
  display: flex; align-items: flex-end; gap: 8px;
  background: var(--plane-2); border-radius: var(--radius-card);
  box-shadow: var(--shadow-control);
  padding: 8px 8px 8px 14px;
}
.chat-compose-inner:focus-within { box-shadow: inset 0 0 0 1.5px var(--primary); }
.chat-compose textarea {
  flex: 1; background: transparent; border: 0; outline: 0; resize: none;
  font-size: 13.5px; line-height: 1.5; max-height: 120px; padding: 6px 0;
}

/* agent profile */
.profile-head { display: flex; gap: 16px; align-items: center; margin-bottom: 18px; flex-wrap: wrap; }
.profile-head .grow { flex: 1; min-width: 200px; }
.profile-head h1 { margin: 0; font-size: 24px; font-weight: 800; letter-spacing: -0.025em; }
.profile-head .sub { color: var(--muted-foreground); font-size: 13px; margin-top: 2px; }
.trust-ladder { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.trust-step {
  padding: 10px 12px; border-radius: var(--radius-control);
  background: var(--plane-1); box-shadow: var(--shadow-control);
  opacity: 0.45;
}
.trust-step.reached { opacity: 0.8; }
.trust-step.current { opacity: 1; background: var(--primary-soft); box-shadow: inset 0 0 0 1.5px var(--primary); }
.trust-step b { display: block; font-size: 12.5px; }
.trust-step span { font-size: 10.5px; color: var(--muted-foreground); line-height: 1.3; display: block; margin-top: 2px; }
.contract-cols { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
.contract-col { background: var(--plane-1); border-radius: var(--radius-card); padding: 12px 14px; box-shadow: var(--shadow-control); }
.contract-col ul { margin: 8px 0 0; padding: 0; list-style: none; }
.contract-col li { font-size: 12.5px; padding: 5px 0; border-bottom: 1px solid var(--border); color: oklch(1 0 0 / 0.82); display: flex; gap: 8px; }
.contract-col li:last-child { border-bottom: 0; }
.contract-col li::before { content: "·"; color: var(--muted-foreground); }
.contract-col.never li::before { content: "✕"; color: var(--danger); font-size: 10px; padding-top: 2px; }
.contract-col.never .section-label { color: var(--danger); }

/* charts */
.bars { display: grid; gap: 9px; }
.bar-line { display: grid; grid-template-columns: 118px 1fr 74px; gap: 10px; align-items: center; font-size: 12px; }
.bar-line .n { color: var(--muted-foreground); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-track { height: 20px; background: var(--plane-1); border-radius: 6px; overflow: hidden; position: relative; }
.bar-fill { height: 100%; border-radius: 6px; background: var(--primary); transform-origin: left; animation: bar-grow 0.7s var(--ease) both; }
.bar-fill.good { background: var(--success); }
.bar-fill.bad { background: var(--danger); }
.bar-fill.mid { background: var(--warning); }
.bar-line .v { font-family: var(--font-mono); font-size: 11px; text-align: right; white-space: nowrap; }

/* ad mock cards */
.ad-mocks { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.ad-mock {
  text-align: left;
  border-radius: var(--radius-card); overflow: hidden; box-shadow: var(--shadow-control);
  background: linear-gradient(160deg, oklch(0.26 0.04 290), oklch(0.17 0.02 270));
  aspect-ratio: 4/5;
  display: flex; flex-direction: column; justify-content: flex-end;
  padding: 14px; position: relative;
  transition: transform var(--dur-micro) var(--ease);
}
.ad-mock:hover { transform: translateY(-2px); }
.ad-mock.v2 { background: linear-gradient(160deg, oklch(0.3 0.09 303), oklch(0.16 0.03 290)); }
.ad-mock.v3 { background: linear-gradient(160deg, oklch(0.25 0.05 250), oklch(0.15 0.02 265)); }
.ad-mock .tag { position: absolute; top: 10px; left: 10px; }
.ad-mock h4 { margin: 0 0 4px; font-size: 17px; font-weight: 800; letter-spacing: -0.02em; line-height: 1.15; }
.ad-mock p { margin: 0 0 10px; font-size: 11px; color: oklch(1 0 0 / 0.75); }
.ad-mock .cta { align-self: flex-start; background: var(--foreground); color: var(--background); font-size: 11px; font-weight: 800; padding: 6px 12px; border-radius: 8px; }

/* ---------- inspector ---------- */
#inspector {
  grid-area: inspector;
  position: relative;
  background: var(--sidebar);
  border-left: 1px solid var(--border);
  display: flex; flex-direction: column;
  min-height: 0;
  z-index: 30;
}
.insp-head { display: flex; align-items: center; gap: 4px; padding: 10px 10px 0; }
.insp-tab {
  padding: 7px 12px; border-radius: var(--radius-control);
  font-size: 12px; font-weight: 800; color: var(--muted-foreground);
  transition: background var(--dur-micro) var(--ease), color var(--dur-micro) var(--ease);
}
.insp-tab:hover { color: var(--foreground); background: var(--plane-3); }
.insp-tab.active { color: var(--foreground); background: var(--plane-3); }
.insp-head .icon-btn { margin-left: auto; width: 30px; height: 30px; }
#insp-body { flex: 1; overflow-y: auto; padding: 12px 14px 20px; min-height: 0; }
.insp-section {
  background: var(--plane-2);
  border-radius: 11px;
  padding: 8px 11px 10px;
  margin-bottom: 8px;
  box-shadow: var(--shadow-control);
}
.insp-section > .section-label { margin-bottom: 8px; display: flex; align-items: center; gap: 6px; }
.kv { display: flex; justify-content: space-between; gap: 10px; padding: 6px 0; border-bottom: 1px solid var(--border); font-size: 12.5px; }
.kv:last-child { border-bottom: 0; }
.kv .k { color: var(--muted-foreground); flex: none; }
.kv .v { text-align: right; font-weight: 600; min-width: 0; }
.kv .v.mono { font-family: var(--font-mono); font-size: 11px; font-weight: 400; }
.insp-card { background: var(--plane-3); border-radius: var(--radius-card); box-shadow: var(--shadow-control); padding: 12px 13px; margin-bottom: 10px; }
.insp-card .t { font-weight: 700; font-size: 12.5px; line-height: 1.35; }
.insp-card .s { font-size: 11.5px; color: var(--muted-foreground); margin-top: 3px; line-height: 1.45; }
.flag-row { display: flex; align-items: center; gap: 8px; padding: 7px 0; font-size: 12.5px; border-bottom: 1px solid var(--border); }
.flag-row:last-child { border-bottom: 0; }
.flag-row svg { width: 13px; height: 13px; flex: none; }
.flag-row .grow { flex: 1; }
.flag-row.danger svg { color: var(--danger); }
.flag-row.warn svg { color: var(--warning); }
.flag-row.med svg { color: var(--ink-faint); }

/* browser widget */
.browser-frame { background: var(--plane-2); border-radius: var(--radius-card); box-shadow: var(--shadow-control); overflow: hidden; }
.browser-chrome { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-bottom: 1px solid var(--border); }
.browser-chrome .lights { display: flex; gap: 4px; }
.browser-chrome .lights i { width: 8px; height: 8px; border-radius: 50%; background: var(--plane-3); }
.browser-url {
  flex: 1; font-family: var(--font-mono); font-size: 10px; color: var(--muted-foreground);
  background: var(--plane-1); border-radius: 6px; padding: 4px 8px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.browser-shot { max-height: 420px; overflow-y: auto; }
.browser-shot img { width: 100%; display: block; }

/* ---------- modal ---------- */
#modal-root { position: fixed; inset: 0; z-index: 80; display: none; }
#modal-root.open { display: block; }
.modal-scrim { position: absolute; inset: 0; background: oklch(0.1 0.01 285 / 0.72); animation: fadein var(--dur-fade) var(--ease) both; }
.modal {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: min(660px, calc(100vw - 32px));
  max-height: calc(100dvh - 60px);
  background: var(--popover);
  border-radius: var(--radius-sheet);
  box-shadow: var(--shadow-pop);
  animation: modal-pop var(--dur-pop) var(--ease) both;
  display: flex; flex-direction: column;
  overflow: hidden;
}
.modal-head { padding: 18px 22px 0; }
.modal-head .over { font-family: var(--font-mono); font-size: 10px; text-transform: uppercase; letter-spacing: 0.09em; color: var(--muted-foreground); display: flex; align-items: center; gap: 8px; }
.modal-head h2 { margin: 6px 0 2px; font-size: 19px; font-weight: 800; letter-spacing: -0.02em; }
.modal-head .sub { font-size: 12.5px; color: var(--muted-foreground); line-height: 1.5; }
.modal-body { padding: 16px 22px; overflow-y: auto; }
.modal-foot { display: flex; gap: 10px; padding: 14px 22px 18px; border-top: 1px solid var(--border); align-items: center; }
.modal-foot .spacer { flex: 1; }
.draft-box {
  background: var(--plane-1); border-radius: var(--radius-card);
  box-shadow: var(--shadow-control);
  padding: 14px 16px; font-size: 13.5px; line-height: 1.6; white-space: pre-wrap;
  max-height: 240px; overflow-y: auto;
}
.modal textarea.draft-box { width: 100%; border: 0; outline: none; resize: vertical; font-family: var(--font-ui); color: var(--foreground); min-height: 140px; }
.src-list { display: grid; gap: 6px; margin-top: 8px; }
.src-line { display: flex; align-items: center; gap: 9px; font-size: 12.5px; }
.src-line svg { width: 13px; height: 13px; flex: none; }
.unc-line { display: flex; gap: 9px; font-size: 12.5px; color: oklch(1 0 0 / 0.8); padding: 5px 0; }
.unc-line svg { width: 13px; height: 13px; flex: none; color: var(--warning); margin-top: 2px; }

.modal-x {
  position: absolute; top: 12px; right: 12px; z-index: 2;
  width: 32px; height: 32px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--plane-3); color: var(--muted-foreground);
  transition: background var(--dur-micro) var(--ease), color var(--dur-micro) var(--ease);
}
.modal-x:hover { background: var(--danger-soft); color: var(--foreground); }
.modal-x svg { width: 14px; height: 14px; }

/* toast */
#toast-root { position: fixed; right: 18px; bottom: 18px; z-index: 90; display: grid; gap: 8px; }
.toast {
  display: flex; align-items: flex-start; gap: 10px;
  background: var(--popover); border-radius: var(--radius-card);
  box-shadow: var(--shadow-pop);
  padding: 12px 16px; width: 320px;
  animation: toast-in var(--dur-pop) var(--ease) both;
}
.toast svg { width: 16px; height: 16px; flex: none; margin-top: 1px; }
.toast.ok svg { color: var(--success); }
.toast.info svg { color: var(--info); }
.toast .t { font-weight: 700; font-size: 13px; }
.toast .s { font-size: 11.5px; color: var(--muted-foreground); margin-top: 2px; line-height: 1.4; }
.toast .rcp { font-family: var(--font-mono); font-size: 9.5px; color: var(--ink-faint); margin-top: 4px; }

/* popover (customize etc.) */
.popover-menu {
  position: fixed; z-index: 70;
  background: var(--popover); border-radius: var(--radius-card);
  box-shadow: var(--shadow-pop);
  padding: 8px; min-width: 230px;
  animation: pop var(--dur-pop) var(--ease) both;
}
.pop-item {
  display: flex; align-items: center; gap: 10px;
  width: 100%; text-align: left;
  padding: 8px 10px; border-radius: 8px; font-size: 13px;
  transition: background var(--dur-micro) var(--ease);
}
.pop-item:hover { background: oklch(1 0 0 / 0.05); }
.pop-item svg { width: 15px; height: 15px; color: var(--muted-foreground); }
.pop-item .sw {
  margin-left: auto;
  width: 30px; height: 18px; border-radius: 999px; background: var(--plane-1);
  position: relative; transition: background var(--dur-short) var(--ease);
  box-shadow: var(--shadow-control); flex: none;
}
.pop-item .sw::after {
  content: ""; position: absolute; top: 2.5px; left: 3px;
  width: 13px; height: 13px; border-radius: 50%;
  background: var(--muted-foreground);
  transition: transform var(--dur-short) var(--ease), background var(--dur-short) var(--ease);
}
.pop-item.on .sw { background: var(--primary); }
.pop-item.on .sw::after { transform: translateX(11px); background: var(--primary-foreground); }
.pop-sep { height: 1px; background: var(--border); margin: 6px 4px; }

/* empty states */
.empty { padding: 30px 20px; text-align: center; color: var(--muted-foreground); font-size: 13px; }
.empty svg { width: 24px; height: 24px; color: var(--ink-faint); margin-bottom: 8px; }

/* offer ladder */
.offer-ladder { display: grid; gap: 8px; }
.offer-step { display: grid; grid-template-columns: 76px 1fr auto; gap: 12px; align-items: center; padding: 10px 12px; background: var(--plane-1); border-radius: 10px; box-shadow: var(--shadow-control); }
.offer-step .d { font-family: var(--font-mono); font-size: 10px; color: var(--muted-foreground); }
.offer-step .amt { font-weight: 800; font-size: 15px; letter-spacing: -0.02em; font-family: var(--font-mono); }
.offer-step.ours .amt { color: var(--primary); }
.offer-step .note { font-size: 11.5px; color: var(--muted-foreground); }

/* mobile / responsive */
#hamburger, #insp-toggle-m { display: none; }
@media (max-width: 1280px) {
  :root { --rail-w: 260px; --inspector-w: 300px; }
}
@media (max-width: 1120px) {
  #app { grid-template-columns: var(--rail-w) minmax(0, 1fr) 0; grid-template-areas: "topbar topbar topbar" "rail main main"; }
  #inspector {
    position: fixed; top: var(--topbar-h); right: 0; bottom: 0;
    width: min(340px, 88vw);
    transform: translateX(105%);
    transition: transform 0.36s var(--ease-drawer);
    box-shadow: var(--shadow-pop);
  }
  #app.insp-open #inspector { transform: none; display: flex; }
  #app.no-inspector #inspector { display: flex; }
  #insp-toggle-m { display: grid; }
}
@media (max-width: 920px) {
  #app { grid-template-columns: minmax(0, 1fr); grid-template-areas: "topbar" "main"; }
  #topbar { gap: 8px; padding: 0 10px; }
  #topbar .kbd, #omni-send, #btn-help { display: none; }
  #omnibar { padding: 0 12px; }
  #omni-input::placeholder { font-size: 12.5px; }
  .switcher { max-width: 132px; padding: 0 8px 0 10px; flex: none; }
  .brand-glyph { width: 30px; height: 30px; }
  .avatar-btn { width: 30px; height: 30px; }
  #rail {
    position: fixed; top: var(--topbar-h); left: 0; bottom: 0;
    width: min(320px, 86vw);
    transform: translateX(-105%);
    transition: transform 0.36s var(--ease-drawer);
    box-shadow: var(--shadow-pop);
  }
  #app.rail-open #rail { transform: none; }
  #hamburger { display: grid; }
  .brand-name, .brand-sub { display: none; }
  .switcher { max-width: 150px; }
  .demo-chip { display: none; }
  .view { padding: 18px 16px 60px; }
  .panel-grid { grid-template-columns: minmax(0, 1fr); }
  .panel.span2 { grid-column: span 1; }
  .clock-row { grid-template-columns: 1fr; }
  .contract-cols { grid-template-columns: 1fr; }
  .ad-mocks { grid-template-columns: 1fr 1fr; }
  .kanban { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; }
  .kan-col { min-width: 240px; scroll-snap-align: start; }
  .doc-surface { padding: 20px 18px 28px; }
  .chat-scroll { padding: 18px 16px 8px; }
  .chat-compose { padding: 10px 12px 14px; }
  .greeting h1 { font-size: 24px; }
  .trust-ladder { grid-template-columns: 1fr 1fr; }
}

/* rail scrim for mobile */
#scrim {
  position: fixed; inset: 0; top: var(--topbar-h); z-index: 25;
  background: oklch(0.1 0.01 285 / 0.55);
  opacity: 0; pointer-events: none; transition: opacity var(--dur-fade) var(--ease);
}
#app.rail-open #scrim, #app.insp-open #scrim { opacity: 1; pointer-events: auto; }

/* ---------- inspector widgets ---------- */
.widget {
  background: var(--plane-2);
  border-radius: 11px;
  padding: 8px 11px 10px;
  margin-bottom: 8px;
  box-shadow: var(--shadow-control);
}
.widget.closed { padding-bottom: 8px; }
.w-head { display: flex; align-items: center; gap: 6px; margin-bottom: 6px; }
.w-head .section-label svg { display: none; }
.w-tools { margin-left: auto; display: flex; gap: 2px; opacity: 0; transition: opacity var(--dur-short) var(--ease); }
.widget:hover .w-tools { opacity: 1; }
.w-btn {
  width: 22px; height: 22px; display: grid; place-items: center;
  border-radius: 6px; color: var(--ink-faint);
  transition: background var(--dur-micro) var(--ease), color var(--dur-micro) var(--ease);
}
.w-btn:hover { background: var(--plane-3); color: var(--foreground); }
.w-btn svg { width: 11px; height: 11px; }
.w-body .flag-row { border-bottom: 1px solid var(--border); }
.w-body .flag-row:last-of-type { border-bottom: 0; }

/* ---------- calendar ---------- */
.cal-dow { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; margin-bottom: 6px; }
.cal-dow span { font-family: var(--font-mono); font-size: 9px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-faint); text-align: center; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-cell {
  min-height: 74px; background: var(--plane-1); border-radius: 9px;
  padding: 7px 8px; text-align: left; position: relative;
  display: flex; flex-direction: column; gap: 3px; align-items: flex-start;
  transition: background var(--dur-micro) var(--ease), transform var(--dur-micro) var(--ease);
}
.cal-cell.has-ev:hover { background: var(--plane-3); transform: translateY(-1px); cursor: pointer; }
.cal-cell.dim { background: transparent; }
.cal-cell.today { box-shadow: inset 0 0 0 1.5px var(--primary); }
.cal-cell.today .cal-num { color: var(--primary); font-weight: 800; }
.cal-num { font-family: var(--font-mono); font-size: 10.5px; color: var(--muted-foreground); }
.cal-dots { display: flex; gap: 3px; }
.cal-dots i { width: 5px; height: 5px; border-radius: 50%; display: block; }
.cal-first { font-size: 9.5px; line-height: 1.25; color: oklch(1 0 0 / 0.66); overflow: hidden; }
@media (max-width: 920px) {
  .cal-cell { min-height: 46px; padding: 5px 6px; }
  .cal-first { display: none; }
}

/* ---------- tour mode ---------- */
#tour-layer { position: fixed; inset: 0; z-index: 64; pointer-events: none; }
.tour-dot {
  position: fixed; width: 15px; height: 15px; border-radius: 50%;
  background: var(--primary);
  box-shadow: 0 0 0 4px oklch(0.71998 0.17231 303.07 / 0.22), 0 0 16px 3px oklch(0.71998 0.17231 303.07 / 0.65);
  pointer-events: auto; cursor: pointer;
  animation: tour-pulse 1.7s var(--ease) infinite;
  transition: transform var(--dur-micro) var(--ease);
}
.tour-dot:hover { transform: scale(1.35); animation-play-state: paused; }
@keyframes tour-pulse {
  0%, 100% { box-shadow: 0 0 0 4px oklch(0.71998 0.17231 303.07 / 0.22), 0 0 14px 2px oklch(0.71998 0.17231 303.07 / 0.55); }
  50% { box-shadow: 0 0 0 8px oklch(0.71998 0.17231 303.07 / 0.1), 0 0 24px 6px oklch(0.71998 0.17231 303.07 / 0.85); }
}
.tour-pop {
  position: fixed; z-index: 66;
  background: var(--popover); border-radius: var(--radius-card);
  box-shadow: var(--shadow-pop);
  padding: 14px 16px;
  animation: pop var(--dur-pop) var(--ease) both;
}
.tp-title { font-weight: 800; font-size: 13.5px; display: flex; align-items: center; gap: 7px; margin-bottom: 6px; }
.tp-title svg { color: var(--primary); width: 14px; height: 14px; }
.tp-body { font-size: 12.5px; line-height: 1.55; color: oklch(1 0 0 / 0.85); }
.tp-foot { margin-top: 10px; font-family: var(--font-mono); font-size: 9px; color: var(--ink-faint); }
#btn-help.tour-on { background: var(--primary); color: var(--primary-foreground); }
#btn-help.tour-on:hover { background: var(--primary); color: var(--primary-foreground); opacity: 0.9; }

#tour-bar {
  position: fixed; bottom: 14px; left: 50%; transform: translateX(-50%);
  z-index: 94;
  display: flex; align-items: center; gap: 10px;
  background: var(--popover); border-radius: 999px;
  box-shadow: var(--shadow-pop);
  padding: 8px 10px 8px 16px;
  max-width: calc(100vw - 20px);
  animation: centerx-in var(--dur-pop) var(--ease) both;
}
.tb-label { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 12px; white-space: nowrap; }
.tb-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--primary); animation: pulse-dot 1.6s var(--ease) infinite; flex: none; }
.tb-demos { display: flex; gap: 5px; overflow-x: auto; scrollbar-width: none; }
.tb-demos::-webkit-scrollbar { display: none; }
.tb-demo {
  white-space: nowrap; font-size: 11.5px; font-weight: 700;
  padding: 7px 12px; border-radius: 999px;
  background: var(--plane-3); color: oklch(1 0 0 / 0.85);
  transition: background var(--dur-micro) var(--ease), color var(--dur-micro) var(--ease);
}
.tb-demo:hover { background: var(--primary); color: var(--primary-foreground); }
.tb-close { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; color: var(--muted-foreground); flex: none; }
.tb-close:hover { background: var(--plane-3); color: var(--foreground); }
.tb-close svg { width: 13px; height: 13px; }

.tour-spot {
  position: fixed; z-index: 63; pointer-events: none;
  border-radius: 14px;
  box-shadow: 0 0 0 2.5px var(--primary), 0 0 0 7px oklch(0.71998 0.17231 303.07 / 0.16), 0 0 44px 4px oklch(0.71998 0.17231 303.07 / 0.4);
  animation: fadein var(--dur-fade) var(--ease) both;
}
.tour-narration {
  position: fixed; bottom: 14px; left: 50%; transform: translateX(-50%);
  z-index: 95;
  width: min(620px, calc(100vw - 20px));
  background: var(--popover); border-radius: var(--radius-sheet);
  box-shadow: var(--shadow-pop);
  padding: 14px 18px 12px;
  animation: centerx-in var(--dur-pop) var(--ease) both;
}
.tn-head { display: flex; align-items: center; gap: 8px; font-size: 12px; margin-bottom: 6px; }
.tn-count { margin-left: auto; font-family: var(--font-mono); font-size: 10px; color: var(--muted-foreground); }
.tn-say { font-size: 14px; line-height: 1.55; }
.tn-foot { display: flex; align-items: center; gap: 10px; margin-top: 12px; }
.tn-track { flex: 1; height: 3px; border-radius: 3px; background: var(--plane-1); overflow: hidden; }
.tn-fill { height: 100%; background: var(--primary); width: 0; animation-name: tn-progress; animation-timing-function: linear; animation-fill-mode: forwards; }
@keyframes tn-progress { from { width: 0; } to { width: 100%; } }
@media (max-width: 920px) {
  #tour-bar { bottom: 10px; padding: 6px 8px 6px 12px; }
  .tb-label span + *, .tb-label { font-size: 11px; }
  .tour-narration { bottom: 10px; padding: 12px 14px 10px; }
  .tn-say { font-size: 13px; }
}

/* ---------- animation studio ---------- */
.studio-rail { display: flex; align-items: center; gap: 6px; margin: 16px 0 6px; flex-wrap: wrap; }
.st-step {
  display: flex; align-items: center; gap: 7px;
  padding: 7px 13px; border-radius: 999px;
  background: var(--plane-2); box-shadow: var(--shadow-control);
  font-size: 11.5px; font-weight: 700; color: var(--muted-foreground);
}
.st-step .st-n {
  width: 17px; height: 17px; border-radius: 50%; display: grid; place-items: center;
  background: var(--plane-3); font-family: var(--font-mono); font-size: 9px;
}
.st-step.current { background: var(--primary-soft); color: var(--foreground); box-shadow: inset 0 0 0 1.5px var(--primary); }
.st-step.current .st-n { background: var(--primary); color: var(--primary-foreground); }
.st-step.done { color: var(--foreground); }
.st-step.done .st-n { background: var(--success-soft); color: var(--success); }
.st-link { width: 14px; height: 1.5px; background: var(--border-strong); flex: none; }

.dir-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.dir-card {
  position: relative; text-align: left;
  background: var(--plane-1); border-radius: var(--radius-card);
  box-shadow: var(--shadow-control);
  padding: 16px;
  display: flex; flex-direction: column; align-items: flex-start;
  transition: transform var(--dur-micro) var(--ease), background var(--dur-micro) var(--ease), box-shadow var(--dur-micro) var(--ease);
}
.dir-card:hover { transform: translateY(-2px); background: var(--plane-2); }
.dir-card.top { box-shadow: inset 0 0 0 1.5px var(--primary), var(--shadow-control); }
.dir-score { font-family: var(--font-mono); font-size: 26px; font-weight: 800; color: var(--primary); letter-spacing: -0.03em; }
.dir-name { font-weight: 650; font-size: 15px; margin-top: 2px; }
.dir-hook { font-size: 13px; color: oklch(1 0 0 / 0.85); margin-top: 8px; line-height: 1.45; min-height: 38px; }
.dir-angle { font-size: 11px; color: var(--muted-foreground); margin-top: 8px; }

.adplayer { width: min(250px, 100%); }
.ap-screen {
  position: relative; aspect-ratio: 9/16; border-radius: 14px; overflow: hidden;
  background: linear-gradient(165deg, oklch(0.24 0.05 295), oklch(0.13 0.02 275));
  box-shadow: var(--shadow-panel);
}
.ap-beat {
  position: absolute; inset: 0; padding: 22px 18px;
  display: flex; flex-direction: column; justify-content: center; gap: 8px;
  opacity: 0; transform: translateY(10px) scale(0.985);
  transition: opacity 0.32s var(--ease), transform 0.42s var(--ease);
  pointer-events: none;
}
.ap-beat.on { opacity: 1; transform: none; }
.ap-beat .ap-label {
  font-family: var(--font-mono); font-size: 8.5px; text-transform: uppercase;
  letter-spacing: 0.12em; color: oklch(0.82 0.12 303);
}
.ap-beat .ap-text { font-size: 19px; font-weight: 800; line-height: 1.18; letter-spacing: -0.02em; }
.ap-beat .ap-sub { font-size: 11px; color: oklch(1 0 0 / 0.75); line-height: 1.4; }
.ap-beat.b2 .ap-text { font-size: 30px; color: var(--primary); }
.ap-beat.b4 { background: linear-gradient(165deg, oklch(0.3 0.08 303 / 0.55), transparent); }
.ap-beat.b5 .ap-text { font-size: 26px; }
.ap-beat.b6 { background: linear-gradient(180deg, transparent, oklch(0.3 0.09 303 / 0.5)); justify-content: flex-end; padding-bottom: 34px; }
.ap-watermark {
  position: absolute; top: 10px; right: 10px;
  font-family: var(--font-mono); font-size: 7.5px; letter-spacing: 0.1em;
  color: oklch(1 0 0 / 0.4); text-transform: uppercase;
  border: 1px solid oklch(1 0 0 / 0.16); border-radius: 4px; padding: 3px 6px;
}
.ap-controls { display: flex; align-items: center; gap: 8px; margin-top: 10px; }
.ap-play {
  width: 30px; height: 30px; border-radius: 50%; flex: none;
  background: var(--primary); color: var(--primary-foreground);
  display: grid; place-items: center;
}
.ap-play svg { width: 13px; height: 13px; }
.ap-track { flex: 1; height: 4px; border-radius: 4px; background: var(--plane-1); overflow: hidden; }
.ap-fill { height: 100%; background: var(--primary); width: 0; transition: width 60ms linear; }
.ap-time { font-family: var(--font-mono); font-size: 9.5px; color: var(--muted-foreground); width: 34px; text-align: right; }

@media (max-width: 920px) {
  .dir-cards { grid-template-columns: 1fr; }
  .studio-rail { gap: 4px; }
  .st-step { font-size: 10px; padding: 6px 10px; }
  .st-link { display: none; }
}

/* ---------- sidebar resize handles ---------- */
.resizer {
  position: absolute; top: 0; bottom: 0; width: 9px;
  cursor: col-resize; z-index: 36;
  touch-action: none;
}
#rail-resizer { right: -4.5px; }
#insp-resizer { left: -4.5px; }
.resizer { transition: background var(--dur-short) var(--ease); border-radius: 4px; }
.resizer:hover, .resizer.active { background: oklch(0.71998 0.17231 303.07 / 0.12); }
body.resizing { cursor: col-resize; user-select: none; -webkit-user-select: none; }
body.resizing #main, body.resizing #rail, body.resizing #inspector { pointer-events: none; }
@media (max-width: 1120px) { #insp-resizer { display: none; } }
@media (max-width: 920px) { #rail-resizer { display: none; } }

/* ---------- collapsible inbox widgets ---------- */
.w-head { cursor: default; }
.w-title-btn {
  display: flex; align-items: center; gap: 6px;
  flex: 1; min-width: 0; text-align: left;
}
.w-title-btn .w-chev { display: grid; transition: transform var(--dur-short) var(--ease); color: var(--ink-faint); }
.w-title-btn .w-chev svg { width: 10px; height: 10px; }
.widget.closed .w-chev { transform: rotate(-90deg); }
.widget.closed .w-body { display: none; }
.widget.closed { margin-bottom: 10px; }

/* ---------- doc editor + file chat ---------- */
.doc-split { display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 14px; align-items: start; }
@media (max-width: 1140px) { .doc-split { grid-template-columns: minmax(0, 1fr); } }
.doc-editor {
  width: 100%; min-height: 62vh;
  background: var(--card); border: 0; outline: none;
  border-radius: var(--radius-card); box-shadow: var(--shadow-control);
  padding: 26px 28px;
  font-family: var(--font-mono); font-size: 12.5px; line-height: 1.75;
  color: oklch(1 0 0 / 0.88);
  resize: vertical;
  tab-size: 2;
}
.doc-editor:focus { box-shadow: inset 0 0 0 1.5px var(--primary); }
.doc-chat { position: sticky; top: 16px; display: flex; flex-direction: column; max-height: calc(100dvh - var(--topbar-h) - 56px); overflow: hidden; }
.dc-scroll { flex: 1; overflow-y: auto; padding: 2px 14px 10px; min-height: 180px; }
.dc-chips { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.dc-msg { margin-bottom: 12px; font-size: 12.5px; line-height: 1.55; }
.dc-msg.me {
  background: var(--primary-soft); border-radius: 10px;
  padding: 8px 12px; margin-left: 26px;
}
.dc-msg.ai .dc-who { font-family: var(--font-mono); font-size: 9px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-faint); margin-bottom: 3px; }
.dc-msg.ai .dc-txt { color: oklch(1 0 0 / 0.86); }
.dc-msg .ai-rows { margin-top: 8px; }
.dc-msg .ai-actions { margin-top: 8px; }
.dc-msg .ai-sources { margin-top: 8px; }
.dc-msg blockquote, .dc-msg .dc-txt br + b { margin: 6px 0; }
.dc-compose {
  display: flex; gap: 6px; align-items: center;
  padding: 10px 12px; border-top: 1px solid var(--border);
}
.dc-compose input {
  flex: 1; min-width: 0; height: 32px;
  background: var(--plane-1); border: 0; border-radius: 8px;
  box-shadow: var(--shadow-control);
  padding: 0 10px; font-size: 12px; outline: none;
}
.dc-compose input:focus { box-shadow: inset 0 0 0 1.5px var(--primary); }
