/* ==========================================================================
   AURA-PIE — stylesheet

   Palette is taken from the materials the tool is about: solder-mask green,
   ENIG gold, defect red, and the anodised graphite of bench instruments.
   Deliberately not a blue/violet "AI product" palette.

   Type: one grotesque family for reading, one monospace for data that is
   genuinely tabular (scores, ids, timestamps, measurements). Monospace is
   never used decoratively.
   ========================================================================== */

/* --- tokens --------------------------------------------------------------- */
:root {
  --font-ui: "Inter", "Inter var", -apple-system, BlinkMacSystemFont,
             "Segoe UI Variable Text", "Segoe UI", Roboto, "Helvetica Neue",
             Arial, "Noto Sans", sans-serif;
  --font-data: ui-monospace, "SF Mono", "JetBrains Mono", "Cascadia Mono",
               "Roboto Mono", Menlo, Consolas, monospace;

  /* minor-third scale off a 15px base */
  --t-xs: 0.75rem;    /* 12 */
  --t-sm: 0.8125rem;  /* 13 */
  --t-base: 0.9375rem;/* 15 */
  --t-md: 1.0625rem;  /* 17 */
  --t-lg: 1.3125rem;  /* 21 */
  --t-xl: 1.625rem;   /* 26 */
  --t-2xl: 2rem;      /* 32 */

  --lh-tight: 1.25;
  --lh-body: 1.6;

  --sp-1: 4px;  --sp-2: 8px;  --sp-3: 12px; --sp-4: 16px;
  --sp-5: 24px; --sp-6: 32px; --sp-7: 48px; --sp-8: 64px;

  --r-sm: 3px; --r-md: 6px; --r-lg: 10px;

  --rail-w: 268px;
  --panel-w: 380px;
  --strip-h: 46px;

  --ease: cubic-bezier(0.2, 0, 0.15, 1);
}

/* dark — anodised instrument housing */
[data-theme="dark"] {
  --bg:          #14181d;
  --bg-sunken:   #0f1216;
  --surface:     #191e25;
  --surface-2:   #1f252d;
  --surface-3:   #262d37;
  --line:        #2a323d;
  --line-strong: #3a4552;

  --ink:         #dee4ec;
  --ink-2:       #a4b0bf;
  --ink-3:       #6f7c8c;

  --accent:      #46b87a;   /* solder mask, brightened for dark ground */
  --accent-2:    #2f8f5b;
  --accent-ink:  #06130c;
  --accent-wash: rgba(70, 184, 122, 0.12);

  --gold:        #d5a44a;   /* ENIG pad */
  --gold-wash:   rgba(213, 164, 74, 0.13);
  --danger:      #e06a63;
  --danger-wash: rgba(224, 106, 99, 0.13);
  --info:        #61a5cf;

  --shadow-panel: 0 1px 2px rgba(0,0,0,.4), 0 12px 32px rgba(0,0,0,.42);
  --shadow-pop:   0 2px 6px rgba(0,0,0,.5), 0 20px 48px rgba(0,0,0,.55);
  --code-bg:     #0f1319;
  --scrim:       rgba(8, 10, 13, 0.72);
}

/* light — lab bench laminate, not cream */
[data-theme="light"] {
  --bg:          #f6f7f4;
  --bg-sunken:   #e9ece6;
  --surface:     #ffffff;
  --surface-2:   #f7f8f6;
  --surface-3:   #eceee9;
  --line:        #d8dcd5;
  --line-strong: #bcc2b9;

  --ink:         #1a1f25;
  --ink-2:       #4d5866;
  --ink-3:       #77828f;

  --accent:      #237a4c;
  --accent-2:    #1a5e3a;
  --accent-ink:  #ffffff;
  --accent-wash: rgba(35, 122, 76, 0.10);

  --gold:        #9a6c15;
  --gold-wash:   rgba(154, 108, 21, 0.11);
  --danger:      #b4322c;
  --danger-wash: rgba(180, 50, 44, 0.10);
  --info:        #1f6a94;

  --shadow-panel: 0 1px 2px rgba(31,41,51,.07), 0 10px 26px rgba(31,41,51,.09);
  --shadow-pop:   0 2px 6px rgba(31,41,51,.10), 0 18px 40px rgba(31,41,51,.16);
  --code-bg:     #f0f2ee;
  --scrim:       rgba(26, 31, 37, 0.42);
}

/* --- reset ---------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font-ui);
  font-size: var(--t-base);
  line-height: var(--lh-body);
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: none; padding: 0; }
a { color: var(--accent); text-underline-offset: 2px; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; line-height: var(--lh-tight); }
p { margin: 0 0 0.7em; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: var(--r-sm); }
::selection { background: var(--accent-wash); }
[hidden] { display: none !important; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 6px; border: 3px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: var(--ink-3); background-clip: content-box; }

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

/* --- shared primitives ---------------------------------------------------- */
.data { font-family: var(--font-data); font-variant-numeric: tabular-nums; font-size: var(--t-xs); }

.btn {
  display: inline-flex; align-items: center; gap: var(--sp-2);
  padding: 7px 13px; border-radius: var(--r-md);
  border: 1px solid var(--line);
  background: var(--surface-2); color: var(--ink);
  font-size: var(--t-sm); font-weight: 500;
  transition: background .12s var(--ease), border-color .12s var(--ease);
}
.btn:hover:not(:disabled) { background: var(--surface-3); border-color: var(--line-strong); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover:not(:disabled) { background: var(--accent-2); border-color: var(--accent-2); }
.btn-quiet { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn-quiet:hover:not(:disabled) { background: var(--surface-2); color: var(--ink); }
.btn-danger { color: var(--danger); border-color: var(--line); }
.btn-danger:hover:not(:disabled) { background: var(--danger-wash); border-color: var(--danger); }
.btn-sm { padding: 4px 9px; font-size: var(--t-xs); }
.btn-block { width: 100%; justify-content: center; }

.field { display: block; margin-bottom: var(--sp-4); }
.field > span { display: block; margin-bottom: 6px; font-size: var(--t-sm); color: var(--ink-2); }
.input, .select, .textarea {
  width: 100%; padding: 9px 11px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-md); color: var(--ink);
  transition: border-color .12s var(--ease), box-shadow .12s var(--ease);
}
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-wash);
}
.hint { font-size: var(--t-xs); color: var(--ink-3); margin-top: 5px; }

.tag {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 7px; border-radius: var(--r-sm);
  font-family: var(--font-data); font-size: 11px; letter-spacing: .01em;
  background: var(--surface-3); color: var(--ink-2);
  border: 1px solid var(--line);
}
.tag-accent { background: var(--accent-wash); color: var(--accent); border-color: transparent; }
.tag-gold   { background: var(--gold-wash);   color: var(--gold);   border-color: transparent; }
.tag-danger { background: var(--danger-wash); color: var(--danger); border-color: transparent; }

.alert {
  padding: 10px 12px; border-radius: var(--r-md); font-size: var(--t-sm);
  border: 1px solid var(--danger); background: var(--danger-wash); color: var(--ink);
  border-left-width: 3px;
}
.alert-ok { border-color: var(--accent); background: var(--accent-wash); }

.empty { padding: var(--sp-6) var(--sp-4); text-align: center; color: var(--ink-3); font-size: var(--t-sm); }

/* ==========================================================================
   Sign-in — a split screen. The left half is literally a board: solder-mask
   ground, copper routing, gold pads. It is the one place in the product where
   the material shows through, so everything else can stay quiet.
   ========================================================================== */
.auth { min-height: 100dvh; display: grid; grid-template-columns: 1.15fr 1fr; }

.auth-board {
  position: relative; overflow: hidden;
  display: flex; align-items: flex-end;
  padding: var(--sp-7) var(--sp-6);
  background: #0c3524;                 /* solder mask, both themes */
  color: #e6f2ea;
}
.auth-board svg { position: absolute; inset: 0; width: 100%; height: 100%; }
/* The routing is a backdrop, not a texture to read text through. Fade it out
   under the copy so the type sits on clean mask. */
.auth-board::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(to top,
    rgba(12,53,36,.98) 0%, rgba(12,53,36,.96) 30%,
    rgba(12,53,36,.55) 48%, rgba(12,53,36,0) 68%);
}
.trace   { stroke: #c98a4b; stroke-width: 1.4; fill: none; opacity: .38; }  /* copper */
.trace-2 { stroke: #8fd8ae; stroke-width: 1.1; opacity: .22; }
.via     { fill: #0c3524; stroke: #c98a4b; stroke-width: 1.4; opacity: .5; }
.pad     { fill: #e2b563; opacity: .5; }                                     /* ENIG */

.auth-board-content { position: relative; z-index: 1; max-width: 34rem; }
.auth-mark { display: flex; align-items: baseline; gap: 11px; margin-bottom: var(--sp-3); }
.auth-mark h1 { font-size: var(--t-2xl); letter-spacing: -.028em; font-weight: 640; color: #fff; }
.auth-mark .rev { font-family: var(--font-data); font-size: var(--t-xs); color: #e2b563; }
.auth-lede { font-size: var(--t-md); line-height: 1.5; color: #cfe4d8; margin-bottom: var(--sp-5); }
.auth-notes { list-style: none; margin: 0; padding: 0; display: grid; gap: 9px; }
.auth-notes li {
  display: flex; gap: 10px; align-items: baseline;
  font-size: var(--t-sm); color: #a9c9b8;
}
.auth-notes li::before {
  content: ""; flex: 0 0 auto; width: 7px; height: 7px; border-radius: 1px;
  background: #e2b563; transform: translateY(-1px);
}

.auth-form {
  position: relative; display: flex; flex-direction: column; justify-content: center;
  padding: var(--sp-7) var(--sp-6); background: var(--bg);
}
.auth-card { width: 100%; max-width: 25rem; margin: 0 auto; }
.auth-card h2 { font-size: var(--t-lg); letter-spacing: -.018em; margin-bottom: var(--sp-5); }
.auth-foot { margin-top: var(--sp-5); font-size: var(--t-xs); color: var(--ink-3); line-height: 1.55; }
.auth-theme { position: absolute; top: var(--sp-4); right: var(--sp-4); }

@media (max-width: 900px) {
  .auth { grid-template-columns: 1fr; }
  .auth-board { padding: var(--sp-6) var(--sp-5) var(--sp-5); min-height: 42vh; }
  .auth-lede { font-size: var(--t-base); margin-bottom: var(--sp-4); }
  .auth-notes { display: none; }
  .auth-form { padding: var(--sp-6) var(--sp-5) var(--sp-7); }
}

/* ==========================================================================
   Workspace
   ========================================================================== */
.app { display: flex; flex-direction: column; height: 100dvh; }

/* status strip — reads like the top bar of a bench instrument */
.strip {
  height: var(--strip-h); flex: 0 0 auto;
  display: flex; align-items: center; gap: var(--sp-3);
  padding: 0 var(--sp-4);
  background: var(--surface); border-bottom: 1px solid var(--line);
}
.strip-mark { display: flex; align-items: baseline; gap: 8px; margin-right: var(--sp-2); }
.strip-mark b { font-size: var(--t-base); font-weight: 620; letter-spacing: -.015em; }
.strip-mark span { font-family: var(--font-data); font-size: 10px; color: var(--ink-3); }
.strip-sep { width: 1px; height: 20px; background: var(--line); }
.strip-spacer { flex: 1; }

.picker {
  display: flex; align-items: center; gap: 6px;
  padding: 5px 9px; border: 1px solid var(--line); border-radius: var(--r-md);
  background: var(--surface-2); font-size: var(--t-sm);
}
.picker select { background: transparent; border: none; outline: none; font-size: var(--t-sm); max-width: 190px; }
.picker label { color: var(--ink-3); font-size: var(--t-xs); }

.gpu-readout { display: flex; align-items: center; gap: 7px; color: var(--ink-2); }
.led { width: 7px; height: 7px; border-radius: 50%; background: var(--ink-3); flex: 0 0 auto; }
.led-on { background: var(--accent); box-shadow: 0 0 0 3px var(--accent-wash); }
.led-busy { background: var(--gold); box-shadow: 0 0 0 3px var(--gold-wash); }
.led-off { background: var(--danger); box-shadow: 0 0 0 3px var(--danger-wash); }

.icon-btn {
  width: 32px; height: 32px; display: grid; place-items: center;
  border-radius: var(--r-md); color: var(--ink-2);
  transition: background .12s var(--ease), color .12s var(--ease);
}
.icon-btn:hover { background: var(--surface-3); color: var(--ink); }
.icon-btn svg { width: 17px; height: 17px; }

.body { flex: 1; display: flex; min-height: 0; }

/* --- left rail ------------------------------------------------------------ */
.rail {
  width: var(--rail-w); flex: 0 0 auto;
  display: flex; flex-direction: column; min-height: 0;
  background: var(--bg-sunken); border-right: 1px solid var(--line);
}
.rail-top { padding: var(--sp-3); display: grid; gap: var(--sp-2); }
.rail-search { position: relative; }
.rail-search .input { padding-left: 30px; font-size: var(--t-sm); background: var(--surface); }
.rail-search svg { position: absolute; left: 9px; top: 50%; transform: translateY(-50%); width: 14px; height: 14px; color: var(--ink-3); }

.rail-list { flex: 1; overflow-y: auto; padding: 0 var(--sp-2) var(--sp-3); }
.rail-group { padding: var(--sp-4) var(--sp-2) var(--sp-1); font-size: var(--t-xs); color: var(--ink-3); }

.session {
  display: block; width: 100%; text-align: left;
  padding: 8px 10px; border-radius: var(--r-md);
  border-left: 2px solid transparent;
  transition: background .12s var(--ease);
}
.session:hover { background: var(--surface-2); }
.session[aria-current="true"] { background: var(--surface-2); border-left-color: var(--accent); }
.session-title {
  display: block; font-size: var(--t-sm); color: var(--ink);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.session[aria-current="true"] .session-title { font-weight: 550; }
.session-meta {
  display: flex; align-items: center; gap: 7px; margin-top: 3px;
  font-family: var(--font-data); font-size: 11px; color: var(--ink-3);
}

.rail-foot { padding: var(--sp-3); border-top: 1px solid var(--line); }
.who { display: flex; align-items: center; gap: 9px; width: 100%; padding: 6px; border-radius: var(--r-md); }
.who:hover { background: var(--surface-2); }
.who-badge {
  width: 28px; height: 28px; flex: 0 0 auto; border-radius: var(--r-md);
  display: grid; place-items: center;
  background: var(--accent-wash); color: var(--accent);
  font-size: var(--t-sm); font-weight: 600;
}
.who-name { display: block; font-size: var(--t-sm); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.who-role { font-family: var(--font-data); font-size: 10px; color: var(--ink-3); }

/* --- conversation --------------------------------------------------------- */
.stage { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.scroll { flex: 1; overflow-y: auto; scroll-behavior: smooth; }
.thread { max-width: 760px; margin: 0 auto; padding: var(--sp-5) var(--sp-5) var(--sp-6); }

/* Turns are records in a log, not bubbles: a hairline rule owns the left edge
   and the speaker is named. The visual metaphor is an inspection notebook. */
.turn { padding: 0 0 var(--sp-5) var(--sp-4); border-left: 2px solid var(--line); position: relative; }
.turn + .turn { margin-top: var(--sp-2); }
.turn-q { border-left-color: var(--line-strong); }
.turn-a { border-left-color: var(--accent); }
.turn-head {
  display: flex; align-items: center; gap: var(--sp-2);
  margin-bottom: 7px; font-size: var(--t-xs); color: var(--ink-3);
}
.turn-who { font-weight: 600; color: var(--ink-2); font-size: var(--t-sm); }
.turn-q .turn-body { color: var(--ink); font-size: var(--t-md); line-height: 1.5; }
.turn-actions { margin-left: auto; display: flex; gap: 2px; opacity: 0; transition: opacity .12s var(--ease); }
.turn:hover .turn-actions, .turn:focus-within .turn-actions { opacity: 1; }

.caret {
  display: inline-block; width: 7px; height: 1.05em;
  background: var(--accent); vertical-align: -2px; margin-left: 2px;
  animation: blink 1.1s steps(1) infinite;
}
@keyframes blink { 50% { opacity: 0; } }

/* sources strip beneath an answer */
.cites { margin-top: var(--sp-3); border-top: 1px dashed var(--line); padding-top: var(--sp-2); }
.cites-head { display: flex; align-items: center; gap: var(--sp-2); font-size: var(--t-xs); color: var(--ink-3); }
.cite {
  display: flex; gap: var(--sp-2); align-items: baseline;
  padding: 5px 0; font-size: var(--t-sm); color: var(--ink-2);
}
.cite-n {
  flex: 0 0 auto; font-family: var(--font-data); font-size: 11px;
  color: var(--accent); background: var(--accent-wash);
  border-radius: var(--r-sm); padding: 1px 5px;
}
.cite-src { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cite-score { margin-left: auto; font-family: var(--font-data); font-size: 11px; color: var(--ink-3); }

/* welcome */
.welcome { max-width: 720px; margin: 0 auto; padding: var(--sp-8) var(--sp-5); }
.welcome h2 { font-size: var(--t-xl); letter-spacing: -.02em; margin-bottom: var(--sp-2); }
.welcome p { color: var(--ink-2); max-width: 60ch; }
.starters { display: grid; gap: var(--sp-2); margin-top: var(--sp-5); }
.starter {
  text-align: left; padding: 11px 14px; border-radius: var(--r-md);
  border: 1px solid var(--line); background: var(--surface);
  font-size: var(--t-sm); color: var(--ink-2);
  transition: border-color .12s var(--ease), color .12s var(--ease);
}
.starter:hover { border-color: var(--accent); color: var(--ink); }

/* composer */
.composer { flex: 0 0 auto; border-top: 1px solid var(--line); background: var(--surface); }
.composer-inner { max-width: 760px; margin: 0 auto; padding: var(--sp-3) var(--sp-5) var(--sp-4); }
.composer-box {
  display: flex; align-items: flex-end; gap: var(--sp-2);
  border: 1px solid var(--line); border-radius: var(--r-lg);
  background: var(--bg); padding: 8px 8px 8px 12px;
  transition: border-color .12s var(--ease), box-shadow .12s var(--ease);
}
.composer-box:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-wash); }
.composer-box textarea {
  flex: 1; resize: none; border: none; outline: none; background: none;
  max-height: 220px; padding: 6px 0; line-height: 1.55;
}
.composer-send {
  width: 32px; height: 32px; flex: 0 0 auto; border-radius: var(--r-md);
  display: grid; place-items: center;
  background: var(--accent); color: var(--accent-ink);
}
.composer-send:disabled { background: var(--surface-3); color: var(--ink-3); }
.composer-send svg { width: 16px; height: 16px; }
.composer-foot {
  display: flex; align-items: center; gap: var(--sp-3);
  margin-top: 7px; font-size: var(--t-xs); color: var(--ink-3);
}

/* --- inspector panel ------------------------------------------------------ */
.panel {
  width: var(--panel-w); flex: 0 0 auto;
  display: flex; flex-direction: column; min-height: 0;
  background: var(--surface); border-left: 1px solid var(--line);
}
.panel[hidden] { display: none; }
.panel-tabs { display: flex; gap: 2px; padding: var(--sp-2) var(--sp-3) 0; border-bottom: 1px solid var(--line); }
.panel-tab {
  padding: 8px 11px; font-size: var(--t-sm); color: var(--ink-3);
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.panel-tab:hover { color: var(--ink-2); }
.panel-tab[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--accent); font-weight: 550; }
.panel-close { margin-left: auto; }
.panel-view { flex: 1; overflow-y: auto; padding: var(--sp-4); }

.section-title { font-size: var(--t-sm); font-weight: 600; margin-bottom: var(--sp-2); }
.section + .section { margin-top: var(--sp-5); padding-top: var(--sp-5); border-top: 1px solid var(--line); }

.kv { display: grid; grid-template-columns: 1fr auto; gap: 5px var(--sp-3); font-size: var(--t-sm); }
.kv dt { color: var(--ink-3); }
.kv dd { margin: 0; font-family: var(--font-data); font-size: var(--t-xs); text-align: right; }

.doclist { display: grid; gap: 4px; }
.doc {
  display: flex; align-items: center; gap: var(--sp-2);
  padding: 7px 9px; border-radius: var(--r-md); background: var(--surface-2);
  font-size: var(--t-sm);
}
.doc-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doc-n { margin-left: auto; font-family: var(--font-data); font-size: 11px; color: var(--ink-3); }

.drop {
  border: 1.5px dashed var(--line-strong); border-radius: var(--r-lg);
  padding: var(--sp-5) var(--sp-4); text-align: center; color: var(--ink-3);
  font-size: var(--t-sm); transition: border-color .12s var(--ease), background .12s var(--ease);
}
.drop.over { border-color: var(--accent); background: var(--accent-wash); color: var(--ink); }

/* --- knowledge graph ------------------------------------------------------ */
.graph-wrap { display: block; }
.graph-bar {
  display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap;
  padding-bottom: var(--sp-3); border-bottom: 1px solid var(--line); margin-bottom: var(--sp-3);
}
.graph-canvas-wrap {
  position: relative; flex: 0 0 auto; height: 420px; border-radius: var(--r-md);
  background: var(--bg-sunken); border: 1px solid var(--line); overflow: hidden;
}
.graph-canvas-wrap canvas { display: block; width: 100%; height: 100%; cursor: grab; }
.graph-canvas-wrap canvas:active { cursor: grabbing; }
.legend { margin-top: var(--sp-3); }
.graph-tip {
  position: absolute; pointer-events: none; max-width: 260px;
  padding: 7px 9px; border-radius: var(--r-md);
  background: var(--surface); border: 1px solid var(--line-strong);
  box-shadow: var(--shadow-pop); font-size: var(--t-xs); line-height: 1.45;
  opacity: 0; transition: opacity .1s var(--ease);
}
.graph-tip.on { opacity: 1; }
.legend { display: flex; flex-wrap: wrap; gap: var(--sp-2) var(--sp-3); margin-top: var(--sp-3); }
.legend-item { display: flex; align-items: center; gap: 6px; font-size: var(--t-xs); color: var(--ink-2); }
.legend-swatch { width: 9px; height: 9px; border-radius: 50%; }

.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--sp-2); }
.stat {
  padding: 9px 11px; border-radius: var(--r-md);
  background: var(--surface-2); border: 1px solid var(--line);
}
.stat-n { font-family: var(--font-data); font-size: var(--t-lg); line-height: 1.15; }
.stat-l { font-size: var(--t-xs); color: var(--ink-3); margin-top: 2px; }

.concept-row {
  display: flex; align-items: center; gap: var(--sp-2);
  padding: 5px 0; font-size: var(--t-sm);
}
.concept-bar { flex: 1; height: 4px; border-radius: 2px; background: var(--surface-3); overflow: hidden; }
.concept-bar i { display: block; height: 100%; background: var(--accent); }
.concept-n { font-family: var(--font-data); font-size: 11px; color: var(--ink-3); min-width: 2.2em; text-align: right; }

/* thought trace */
.trace-list { display: grid; gap: 0; }
.trace-step { display: grid; grid-template-columns: 26px 1fr; gap: var(--sp-2); }
.trace-gutter { position: relative; display: grid; place-items: start center; padding-top: 5px; }
.trace-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); z-index: 1; }
.trace-step:not(:last-child) .trace-gutter::after {
  content: ""; position: absolute; top: 12px; bottom: -6px; width: 1px; background: var(--line);
}
.trace-body { padding-bottom: var(--sp-3); }
.trace-q { font-size: var(--t-sm); }
.trace-c { font-family: var(--font-data); font-size: 11px; color: var(--accent); }

/* --- markdown ------------------------------------------------------------- */
.md { font-size: var(--t-base); line-height: var(--lh-body); }
.md > :first-child { margin-top: 0; }
.md > :last-child { margin-bottom: 0; }
.md h1, .md h2, .md h3, .md h4 { margin: 1.15em 0 .45em; line-height: 1.3; }
.md h1 { font-size: var(--t-lg); }
.md h2 { font-size: var(--t-md); }
.md h3 { font-size: var(--t-base); }
.md ul, .md ol { margin: 0 0 .7em; padding-left: 1.35em; }
.md li { margin-bottom: .3em; }
.md li::marker { color: var(--ink-3); }
.md code {
  font-family: var(--font-data); font-size: .87em;
  background: var(--code-bg); border: 1px solid var(--line);
  border-radius: var(--r-sm); padding: 1px 5px;
}
.md pre {
  background: var(--code-bg); border: 1px solid var(--line);
  border-radius: var(--r-md); padding: 12px 14px; overflow-x: auto; margin: 0 0 .8em;
}
.md pre code { background: none; border: none; padding: 0; font-size: var(--t-sm); }
.md blockquote {
  margin: 0 0 .8em; padding: 2px 0 2px 14px;
  border-left: 2px solid var(--gold); color: var(--ink-2);
}
.md table { width: 100%; border-collapse: collapse; font-size: var(--t-sm); margin: 0 0 .8em; }
.md th { text-align: left; font-weight: 600; padding: 7px 10px; background: var(--surface-2); border-bottom: 1px solid var(--line-strong); }
.md td { padding: 7px 10px; border-bottom: 1px solid var(--line); }
.md hr { border: none; border-top: 1px solid var(--line); margin: 1.2em 0; }
.md .ref {
  font-family: var(--font-data); font-size: .78em; vertical-align: 2px;
  color: var(--accent); background: var(--accent-wash);
  border-radius: var(--r-sm); padding: 0 4px; margin: 0 1px;
}

/* --- modal ---------------------------------------------------------------- */
.modal-scrim {
  position: fixed; inset: 0; z-index: 60; background: var(--scrim);
  display: grid; place-items: center; padding: var(--sp-5);
}
.modal {
  width: 100%; max-width: 560px; max-height: 86dvh; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); box-shadow: var(--shadow-pop);
}
.modal-wide { max-width: 860px; }
.modal-head {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-4) var(--sp-5); border-bottom: 1px solid var(--line);
}
.modal-head h2 { font-size: var(--t-md); }
.modal-body { padding: var(--sp-5); }
.modal-foot {
  display: flex; justify-content: flex-end; gap: var(--sp-2);
  padding: var(--sp-3) var(--sp-5) var(--sp-4);
}

.table { width: 100%; border-collapse: collapse; font-size: var(--t-sm); }
.table th {
  text-align: left; font-weight: 600; color: var(--ink-2);
  padding: 8px 10px; border-bottom: 1px solid var(--line-strong);
}
.table td { padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }

/* --- toasts --------------------------------------------------------------- */
.toasts {
  position: fixed; z-index: 80; right: var(--sp-4); bottom: var(--sp-4);
  display: grid; gap: var(--sp-2); max-width: 380px;
}
.toast {
  padding: 10px 13px; border-radius: var(--r-md);
  background: var(--surface); border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  box-shadow: var(--shadow-pop); font-size: var(--t-sm);
}
.toast-error { border-left-color: var(--danger); }
.toast-warn { border-left-color: var(--gold); }

/* --- responsive ----------------------------------------------------------- */
.rail-toggle { display: none; }

@media (max-width: 1180px) {
  .panel { position: fixed; right: 0; top: var(--strip-h); bottom: 0; z-index: 40; box-shadow: var(--shadow-pop); }
}
@media (max-width: 860px) {
  :root { --rail-w: 260px; --panel-w: 100%; }
  .rail-toggle { display: grid; }
  .rail { position: fixed; left: 0; top: var(--strip-h); bottom: 0; z-index: 45; box-shadow: var(--shadow-pop); }
  .rail[hidden] { display: none; }
  .thread, .composer-inner { padding-left: var(--sp-4); padding-right: var(--sp-4); }
  .strip-hide-sm { display: none; }
}

/* --- small utilities ------------------------------------------------------
   A short, closed set. The Content-Security-Policy forbids inline style
   attributes, so anything static that needs a nudge gets a class here. */
.u-mb-4 { margin-bottom: var(--sp-4); }
.who-text { min-width: 0; text-align: left; }
.who-chevron { margin-left: auto; flex: 0 0 auto; }

/* --- session provenance header -------------------------------------------- */
.thread-head { padding-bottom: var(--sp-4); margin-bottom: var(--sp-4); border-bottom: 1px solid var(--line); }
.thread-head h2 { font-size: var(--t-lg); letter-spacing: -.018em; }
.thread-meta { display: flex; align-items: center; gap: var(--sp-2); margin-top: 5px; color: var(--ink-3); }
.thread-dot { width: 3px; height: 3px; border-radius: 50%; background: var(--ink-3); }

/* A knowledge graph of any size is unreadable in a side panel, so it can be
   opened at window scale. */
.graph-canvas-wrap.is-full { height: min(70vh, 720px); }
.modal.is-wide-graph .modal-body { padding-top: var(--sp-4); }

/* Screen-reader-only: kept in the accessibility tree, out of the layout. */
.visually-hidden {
  position: absolute; width: 1px; height: 1px; margin: -1px;
  padding: 0; border: 0; overflow: hidden; white-space: nowrap;
  clip: rect(0 0 0 0); clip-path: inset(50%);
}
label.btn { text-align: center; cursor: pointer; }

/* --- administrator oversight ---------------------------------------------- */
.modal-wide .stat-grid { grid-template-columns: repeat(3, 1fr); }
.modal-wide .graph-bar { flex-wrap: nowrap; align-items: center; }
.modal-wide .graph-bar .select { width: auto; min-width: 9rem; flex: 0 1 auto; }
.modal-wide .graph-bar .btn { flex: 0 0 auto; white-space: nowrap; }
.modal-wide .graph-canvas-wrap.is-full { height: min(52vh, 480px); }
.oversight-h { font-size: var(--t-sm); font-weight: 600; color: var(--ink-2);
  margin: var(--sp-5) 0 var(--sp-2); }
.oversight-table { border-top: 1px solid var(--line); }
.oversight-row {
  display: grid; grid-template-columns: 2.2fr .8fr .9fr 1fr 1.3fr;
  gap: var(--sp-3); align-items: center; width: 100%;
  padding: 9px 4px; border-bottom: 1px solid var(--line);
  font-size: var(--t-sm); text-align: left;
}
.oversight-head { color: var(--ink-3); font-size: var(--t-xs);
  text-transform: uppercase; letter-spacing: .04em; }
.oversight-click { background: none; border-width: 0 0 1px 0; cursor: pointer;
  color: inherit; font: inherit; }
.oversight-click:hover { background: var(--bg-sunken); }
.oversight-row .pill {
  margin-left: 6px; padding: 1px 6px; border-radius: 3px;
  background: var(--bg-sunken); border: 1px solid var(--line);
  font-family: var(--font-data); font-size: 10px; color: var(--ink-3);
}
.check { display: inline-flex; align-items: center; gap: 6px;
  font-size: var(--t-sm); color: var(--ink-2); }


/* --- token allowance readout ---------------------------------------------
   Only appears once half the allowance is gone, so it is a signal rather
   than decoration. */
.quota-readout {
  display: inline-flex; align-items: center; gap: 7px;
  margin-right: var(--sp-3); font-size: var(--t-xs); color: var(--ink-3);
}
.quota-bar {
  display: inline-block; width: 46px; height: 4px; border-radius: 2px;
  background: var(--line); overflow: hidden;
}
.quota-fill { display: block; height: 100%; background: var(--gold); }
.quota-readout.is-low { color: var(--danger); }
.quota-readout.is-low .quota-fill { background: var(--danger); }
