/* ==========================================================================
   Text2Workflow — design system
   Zinc/slate substrate, indigo→violet accent. Every colour is a token so the
   SVG renderer in render.js and the DOM read from the same palette.
   ========================================================================== */

:root {
  /* --- neutral scale (zinc) --- */
  --zinc-950: #09090b;
  --zinc-925: #0d0d0f;
  --zinc-900: #131316;
  --zinc-875: #17171a;
  --zinc-850: #1c1c20;
  --zinc-800: #27272a;
  --zinc-750: #323236;
  --zinc-700: #3f3f46;
  --zinc-600: #52525b;
  --zinc-500: #71717a;
  --zinc-400: #a1a1aa;
  --zinc-300: #d4d4d8;
  --zinc-200: #e4e4e7;
  --zinc-100: #f4f4f5;

  /* --- accent --- */
  --indigo-950: #1a1836;
  --indigo-900: #241f52;
  --indigo-600: #4f46e5;
  --indigo-500: #6366f1;
  --indigo-400: #818cf8;
  --indigo-300: #a5b4fc;
  --violet-500: #8b5cf6;
  --violet-400: #a78bfa;
  --violet-300: #c4b5fd;

  /* --- semantic --- */
  --emerald-500: #10b981; --emerald-400: #34d399; --emerald-300: #6ee7b7; --emerald-950: #052e21;
  --amber-500:   #f59e0b; --amber-400:   #fbbf24; --amber-300:   #fcd34d; --amber-950:   #2e1f04;
  --rose-500:    #f43f5e; --rose-400:    #fb7185; --rose-300:    #fda4af; --rose-950:    #340d17;
  --sky-400:     #38bdf8; --sky-300:     #7dd3fc; --sky-950:     #082438;
  --teal-400:    #2dd4bf; --teal-300:    #5eead4; --teal-950:    #052e2b;

  /* --- surfaces --- */
  --bg:          var(--zinc-950);
  --surface:     var(--zinc-900);
  --surface-2:   var(--zinc-875);
  --surface-3:   var(--zinc-850);
  --line:        rgba(39, 39, 42, 0.8);   /* zinc-800/80 */
  --line-strong: var(--zinc-750);

  --text:      var(--zinc-100);
  --text-2:    var(--zinc-300);
  --text-dim:  var(--zinc-400);
  --text-faint:var(--zinc-500);

  /* --- diagram tokens consumed by render.js --- */
  --lane:        #0b0b0d;
  --lane-alt:    #101013;
  --lane-rule:   rgba(63, 63, 70, 0.5);
  --lane-header: #141417;

  --edge:      #52525b;
  --edge-yes:  var(--emerald-500);
  --edge-no:   #52525b;
  --edge-back: var(--amber-500);

  --n-start:  #06251b;  --n-start-line: var(--emerald-500); --n-start-text: var(--emerald-300);
  --n-end:    #1a1836;  --n-end-line:   var(--indigo-500);  --n-end-text:   var(--indigo-300);
  --n-stop:   #340d17;  --n-stop-line:  var(--rose-500);    --n-stop-text:  var(--rose-300);
  --n-gate:   #2e1f04;  --n-gate-line:  var(--amber-500);   --n-gate-text:  var(--amber-300);
  --n-merge:  #1b1b1f;  --n-merge-line: var(--zinc-600);    --n-merge-text: var(--zinc-400);
  --n-human:  #241f52;  --n-human-line: var(--violet-500);  --n-human-text: var(--violet-300);
  --n-notify: #082438;  --n-notify-line:var(--sky-400);     --n-notify-text:var(--sky-300);
  --n-system: #052e2b;  --n-system-line:var(--teal-400);    --n-system-text:var(--teal-300);
  --n-audit:  #2e1f04;  --n-audit-line: var(--amber-400);   --n-audit-text: var(--amber-300);

  --r-sm: 6px; --r: 10px; --r-lg: 14px;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", "Menlo", Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, Helvetica, sans-serif;

  --shadow-lift: 0 1px 0 rgba(255,255,255,0.03) inset, 0 8px 24px -12px rgba(0,0,0,0.9);
  --glow-indigo: 0 0 0 1px rgba(99,102,241,0.35), 0 0 22px -6px rgba(99,102,241,0.55);
}

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 13.5px;
  line-height: 1.5;
  letter-spacing: -0.005em;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

::selection { background: rgba(99,102,241,0.35); }

/* thin, unobtrusive scrollbars everywhere */
* { scrollbar-width: thin; scrollbar-color: var(--zinc-750) transparent; }
*::-webkit-scrollbar { width: 9px; height: 9px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: var(--zinc-800); border-radius: 99px; border: 2px solid transparent; background-clip: content-box; }
*::-webkit-scrollbar-thumb:hover { background: var(--zinc-700); background-clip: content-box; }

/* ==========================================================================
   Topbar
   ========================================================================== */

.topbar {
  height: 52px;
  display: flex; align-items: center; gap: 14px;
  padding: 0 16px;
  border-bottom: 1px solid var(--line);
  background: rgba(9, 9, 11, 0.72);
  backdrop-filter: blur(12px) saturate(150%);
  -webkit-backdrop-filter: blur(12px) saturate(150%);
  position: relative; z-index: 40;
}

.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.logo {
  width: 26px; height: 26px; border-radius: 7px; flex: none;
  display: grid; place-items: center;
  background: linear-gradient(140deg, var(--indigo-500), var(--violet-500));
  box-shadow: 0 0 0 1px rgba(255,255,255,0.08) inset, 0 4px 14px -6px var(--indigo-500);
  font: 700 11px var(--mono); color: #fff; letter-spacing: -0.5px;
}
.brand h1 { font-size: 14px; margin: 0; font-weight: 600; letter-spacing: -0.02em; white-space: nowrap; }
.brand .sub {
  color: var(--text-faint); font-size: 12px; white-space: nowrap;
  padding-left: 12px; margin-left: 2px; border-left: 1px solid var(--line);
}

.topbar .spacer { flex: 1; }

.wf-chip {
  display: inline-flex; align-items: center; gap: 7px;
  font: 500 11.5px var(--mono); color: var(--text-dim);
  background: var(--surface-2); border: 1px solid var(--line);
  padding: 4px 9px; border-radius: 7px; white-space: nowrap;
}
.wf-chip b { color: var(--indigo-300); font-weight: 500; }

.status-pill {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 12px; font-weight: 550; padding: 5px 12px 5px 10px;
  border-radius: 999px; border: 1px solid var(--line-strong);
  background: var(--surface-2); color: var(--text-dim);
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
.status-pill .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--zinc-500); flex: none; }

.status-pill[data-status="blocked"]      { color: var(--rose-300);    border-color: rgba(244,63,94,0.3);  background: rgba(244,63,94,0.08); }
.status-pill[data-status="blocked"] .dot { background: var(--rose-500);    box-shadow: 0 0 0 0 rgba(244,63,94,0.65); animation: pulse-rose 2s infinite; }
.status-pill[data-status="needs-review"]      { color: var(--amber-300);   border-color: rgba(245,158,11,0.3); background: rgba(245,158,11,0.08); }
.status-pill[data-status="needs-review"] .dot { background: var(--amber-500);   box-shadow: 0 0 0 0 rgba(245,158,11,0.6); animation: pulse-amber 2.4s infinite; }
.status-pill[data-status="ready"]      { color: var(--emerald-300); border-color: rgba(16,185,129,0.3); background: rgba(16,185,129,0.08); }
.status-pill[data-status="ready"] .dot { background: var(--emerald-500); box-shadow: 0 0 0 0 rgba(16,185,129,0.6); animation: pulse-emerald 2.6s infinite; }

@keyframes pulse-rose    { 70% { box-shadow: 0 0 0 6px rgba(244,63,94,0); }  100% { box-shadow: 0 0 0 0 rgba(244,63,94,0); } }
@keyframes pulse-amber   { 70% { box-shadow: 0 0 0 6px rgba(245,158,11,0); } 100% { box-shadow: 0 0 0 0 rgba(245,158,11,0); } }
@keyframes pulse-emerald { 70% { box-shadow: 0 0 0 6px rgba(16,185,129,0); } 100% { box-shadow: 0 0 0 0 rgba(16,185,129,0); } }

/* ==========================================================================
   Workspace shell
   ========================================================================== */

.workspace {
  display: grid;
  grid-template-columns: minmax(380px, 30vw) 1fr;
  height: calc(100vh - 52px);
  min-height: 0;
}

.pane { min-width: 0; min-height: 0; display: flex; flex-direction: column; }
.pane-left  { border-right: 1px solid var(--line); background: var(--zinc-925); }
.pane-right { background: var(--bg); }

/* ==========================================================================
   Buttons & controls
   ========================================================================== */

button {
  font-family: inherit; font-size: 12.5px; font-weight: 550;
  border-radius: var(--r-sm); border: 1px solid var(--line-strong);
  background: var(--surface-3); color: var(--text-2);
  padding: 7px 12px; cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px;
  transition: background 130ms ease, border-color 130ms ease, color 130ms ease, transform 80ms ease;
}
button:hover  { background: var(--zinc-800); color: var(--text); border-color: var(--zinc-700); }
button:active { transform: translateY(0.5px); }
button:focus-visible { outline: none; box-shadow: var(--glow-indigo); }
button[disabled] { opacity: 0.4; cursor: not-allowed; }

button.primary {
  background: linear-gradient(180deg, var(--indigo-500), var(--indigo-600));
  border-color: var(--indigo-600); color: #fff; font-weight: 600;
  box-shadow: 0 1px 0 rgba(255,255,255,0.14) inset, 0 6px 18px -10px var(--indigo-500);
}
button.primary:hover { background: linear-gradient(180deg, #7075f5, var(--indigo-500)); border-color: var(--indigo-500); color: #fff; }

button.ghost { background: transparent; border-color: transparent; color: var(--text-faint); }
button.ghost:hover { background: var(--surface-3); color: var(--text-2); border-color: var(--line); }

button.tiny { padding: 4px 9px; font-size: 11.5px; }
button .kbd {
  font: 500 10px var(--mono); opacity: 0.75;
  border: 1px solid currentColor; border-radius: 4px; padding: 0 3px; margin-left: 2px;
}

/* ==========================================================================
   Prompt card
   ========================================================================== */

.prompt-block { padding: 14px; border-bottom: 1px solid var(--line); flex: none; }

.eyebrow {
  display: flex; align-items: center; gap: 8px;
  font: 700 10px var(--sans); text-transform: uppercase; letter-spacing: 0.1em;
  color: var(--text-faint); margin: 0 0 10px;
}
.eyebrow .idx {
  font-family: var(--mono); color: var(--indigo-400); font-weight: 600;
  background: var(--indigo-950); border: 1px solid rgba(99,102,241,0.25);
  border-radius: 5px; padding: 1px 5px; letter-spacing: 0;
}
.eyebrow .fill { flex: 1; height: 1px; background: var(--line); }

.prompt-shell {
  border: 1px solid var(--line-strong); border-radius: var(--r);
  background: var(--surface); overflow: hidden;
  transition: border-color 140ms ease, box-shadow 140ms ease;
}
.prompt-shell:focus-within { border-color: var(--indigo-500); box-shadow: var(--glow-indigo); }

textarea#utterance {
  display: block; width: 100%; min-height: 92px; max-height: 240px; resize: vertical;
  background: transparent; color: var(--text); border: none; outline: none;
  padding: 12px 13px 8px; font-family: var(--sans); font-size: 13.5px; line-height: 1.6;
}
textarea#utterance::placeholder { color: var(--zinc-600); }

.prompt-foot {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 11px; border-top: 1px solid var(--line);
  background: var(--surface-2); font: 500 11px var(--mono); color: var(--text-faint);
}
.prompt-foot .grow { flex: 1; }
.prompt-foot .meter { color: var(--zinc-600); font-variant-numeric: tabular-nums; }
.prompt-foot .meter b { color: var(--text-dim); font-weight: 500; }
.prompt-foot .meter[data-over="true"] b { color: var(--amber-400); }

.prompt-actions { display: flex; gap: 7px; margin-top: 10px; flex-wrap: wrap; }

.samples { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 12px; }
.chip {
  font-size: 11.5px; padding: 4px 10px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface-2);
  color: var(--text-faint); cursor: pointer; transition: all 130ms ease;
}
.chip:hover { color: var(--text-2); border-color: var(--zinc-700); }
.chip[aria-pressed="true"] {
  background: rgba(99,102,241,0.12); color: var(--indigo-300);
  border-color: rgba(99,102,241,0.4);
}

.sample-note {
  margin: 11px 0 0; font-size: 11.5px; color: var(--text-faint); line-height: 1.55;
  border-left: 2px solid var(--indigo-600); padding-left: 10px;
}
.sample-note b { color: var(--text-dim); font-weight: 600; }

/* ==========================================================================
   Clarification queue (scrolls)
   ========================================================================== */

.queue { flex: 1; overflow-y: auto; min-height: 120px; }
.queue-inner { padding: 14px; }

.question {
  border: 1px solid var(--line-strong); border-radius: var(--r);
  background: var(--surface); margin-bottom: 9px; overflow: hidden;
  box-shadow: var(--shadow-lift);
  animation: rise 220ms cubic-bezier(0.16, 1, 0.3, 1) both;
}
@keyframes rise { from { opacity: 0; transform: translateY(5px); } }

.question .qbar { height: 2px; }
.question.sev-blocker .qbar { background: linear-gradient(90deg, var(--rose-500), rgba(244,63,94,0)); }
.question.sev-warning .qbar { background: linear-gradient(90deg, var(--amber-500), rgba(245,158,11,0)); }

.question .qbody { padding: 12px 13px 13px; }
.question .qhead { display: flex; align-items: center; gap: 7px; margin-bottom: 7px; }
.question .qtitle { font-weight: 600; font-size: 12.5px; color: var(--text); }
.question .qprompt { font-size: 12.5px; margin: 0 0 3px; color: var(--text-2); line-height: 1.5; }
.question .qhelp { font-size: 11.5px; color: var(--text-faint); margin: 0 0 9px; }

.rule-tag {
  font: 600 9.5px var(--mono); letter-spacing: 0.04em; flex: none;
  padding: 2px 5px; border-radius: 4px;
  background: var(--surface-3); color: var(--text-faint); border: 1px solid var(--line);
}
.sev-blocker .rule-tag { color: var(--rose-300); border-color: rgba(244,63,94,0.28); background: rgba(244,63,94,0.09); }
.sev-warning .rule-tag { color: var(--amber-300); border-color: rgba(245,158,11,0.28); background: rgba(245,158,11,0.09); }

.options { display: flex; flex-direction: column; gap: 5px; margin-top: 9px; }
.option {
  text-align: left; padding: 8px 10px; font-size: 12px; line-height: 1.45;
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: var(--r-sm); color: var(--text-dim); width: 100%;
  justify-content: flex-start;
}
.option:hover {
  border-color: rgba(99,102,241,0.5); color: var(--text);
  background: rgba(99,102,241,0.1);
}
.option .idx {
  font: 600 9.5px var(--mono); color: var(--zinc-600); flex: none;
  width: 14px; height: 14px; display: grid; place-items: center;
  border: 1px solid var(--line-strong); border-radius: 4px;
}
.option:hover .idx { color: var(--indigo-300); border-color: rgba(99,102,241,0.45); }

.predicate-form { display: grid; grid-template-columns: 1fr 62px 1fr; gap: 5px; margin-top: 9px; }
.predicate-form input, .predicate-form select {
  background: var(--surface-2); border: 1px solid var(--line); color: var(--text);
  border-radius: var(--r-sm); padding: 7px 8px; font-family: var(--mono); font-size: 11.5px;
  min-width: 0; outline: none;
}
.predicate-form input:focus, .predicate-form select:focus { border-color: var(--indigo-500); box-shadow: var(--glow-indigo); }
.predicate-form input::placeholder { color: var(--zinc-600); }

.answered {
  display: flex; align-items: center; gap: 9px;
  font-size: 11.5px; padding: 8px 11px; margin-bottom: 5px;
  border: 1px solid var(--line); border-radius: var(--r-sm);
  background: var(--surface); position: relative;
}
.answered::before {
  content: ''; position: absolute; left: 0; top: 6px; bottom: 6px; width: 2px;
  background: var(--emerald-500); border-radius: 0 2px 2px 0;
}
.answered .a-body { flex: 1; min-width: 0; padding-left: 4px; }
.answered .a-q { color: var(--text-faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.answered .a-a { color: var(--emerald-300); font-family: var(--mono); font-size: 11px; margin-top: 2px; }

.empty-state {
  font-size: 12px; color: var(--text-faint); line-height: 1.6;
  border: 1px dashed var(--line-strong); border-radius: var(--r);
  padding: 20px 16px; text-align: center;
}
.empty-state .big { font-size: 20px; display: block; margin-bottom: 6px; }
.empty-state strong { color: var(--emerald-300); font-weight: 600; }

/* ==========================================================================
   Self-reflection execution log (terminal)
   ========================================================================== */

.reflection {
  flex: none; height: 236px; display: flex; flex-direction: column;
  border-top: 1px solid var(--line); background: #08080a;
  resize: vertical; overflow: hidden; min-height: 120px; max-height: 60vh;
}

.reflection-head {
  display: flex; align-items: center; gap: 8px; flex: none;
  padding: 8px 12px; border-bottom: 1px solid var(--line);
  background: rgba(19,19,22,0.8); backdrop-filter: blur(6px);
}
.reflection-head .title {
  font: 600 10px var(--sans); text-transform: uppercase; letter-spacing: 0.1em;
  color: var(--text-dim);
}
.reflection-head .live {
  display: inline-flex; align-items: center; gap: 5px;
  font: 600 9.5px var(--mono); letter-spacing: 0.06em;
  color: var(--zinc-600); padding: 2px 6px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface-2);
}
.reflection-head .live i { width: 5px; height: 5px; border-radius: 50%; background: var(--zinc-600); }
.reflection-head .live[data-running="true"] { color: var(--indigo-300); border-color: rgba(99,102,241,0.35); }
.reflection-head .live[data-running="true"] i { background: var(--indigo-400); animation: blink 900ms steps(2) infinite; }
@keyframes blink { 50% { opacity: 0.25; } }
.reflection-head .grow { flex: 1; }

.term {
  flex: 1; overflow-y: auto; padding: 8px 0 12px;
  font-family: var(--mono); font-size: 11px; line-height: 1.65;
}
.term-line {
  display: grid; grid-template-columns: 58px 76px 1fr; gap: 10px;
  padding: 1.5px 12px; white-space: pre-wrap; word-break: break-word;
  animation: fadein 160ms ease both;
}
@keyframes fadein { from { opacity: 0; } }
.term-line:hover { background: rgba(255,255,255,0.025); }
.term-line .t { color: var(--zinc-700); text-align: right; font-variant-numeric: tabular-nums; }
.term-line .agent { font-weight: 600; }
.term-line .msg { color: var(--zinc-400); }
.term-line .msg b { color: var(--zinc-200); font-weight: 500; }
.term-line .msg code { color: var(--indigo-300); }

.term-line[data-agent="ingest"]   .agent { color: var(--sky-400); }
.term-line[data-agent="grammar"]  .agent { color: var(--violet-400); }
.term-line[data-agent="compile"]  .agent { color: var(--teal-400); }
.term-line[data-agent="reflect"]  .agent { color: var(--indigo-400); }
.term-line[data-agent="ledger"]   .agent { color: var(--amber-400); }
.term-line[data-agent="resolve"]  .agent { color: var(--emerald-400); }

.term-line[data-level="ok"]    .msg b { color: var(--emerald-300); }
.term-line[data-level="warn"]  .msg { color: var(--amber-300); }
.term-line[data-level="error"] .msg { color: var(--rose-300); }
.term-line[data-level="head"]  { margin-top: 6px; }
.term-line[data-level="head"] .msg { color: var(--zinc-500); border-top: 1px solid var(--line); padding-top: 6px; }

.verdict {
  display: inline-flex; align-items: center; gap: 5px;
  font: 600 9.5px var(--mono); padding: 0 5px; border-radius: 4px;
  border: 1px solid transparent;
}
.verdict[data-v="PASS"] { color: var(--emerald-300); background: rgba(16,185,129,0.12); border-color: rgba(16,185,129,0.28); }
.verdict[data-v="FAIL"] { color: var(--rose-300);    background: rgba(244,63,94,0.12);  border-color: rgba(244,63,94,0.28); }
.verdict[data-v="NOTE"] { color: var(--amber-300);   background: rgba(245,158,11,0.12); border-color: rgba(245,158,11,0.28); }

.reflection-foot {
  flex: none; padding: 7px 12px; border-top: 1px solid var(--line);
  font: 500 10px var(--sans); color: var(--zinc-600); line-height: 1.5;
  background: var(--zinc-925);
}
.reflection-foot b { color: var(--zinc-500); font-weight: 600; }

/* ==========================================================================
   Tabs & panels
   ========================================================================== */

.tabbar {
  display: flex; align-items: center; gap: 1px; flex: none;
  padding: 0 12px; height: 42px;
  border-bottom: 1px solid var(--line);
  background: rgba(9,9,11,0.7); backdrop-filter: blur(10px);
  overflow-x: auto;
}
.tab {
  border: none; background: none; border-radius: var(--r-sm);
  color: var(--text-faint); padding: 6px 11px; font-size: 12.5px; font-weight: 500;
  white-space: nowrap; position: relative;
}
.tab:hover { background: var(--surface-2); color: var(--text-2); border-color: transparent; }
.tab[aria-selected="true"] { color: var(--text); background: var(--surface-3); }
.tab[aria-selected="true"]::after {
  content: ''; position: absolute; left: 11px; right: 11px; bottom: -12px; height: 2px;
  background: linear-gradient(90deg, var(--indigo-500), var(--violet-500)); border-radius: 2px;
}
.tab .badge {
  font: 600 9.5px var(--mono); padding: 1px 4px; border-radius: 4px; margin-left: 5px;
  background: var(--surface-3); color: var(--text-faint); border: 1px solid var(--line);
}
.tab .badge[data-tone="rose"]    { color: var(--rose-300);    background: rgba(244,63,94,0.12);  border-color: rgba(244,63,94,0.28); }
.tab .badge[data-tone="amber"]   { color: var(--amber-300);   background: rgba(245,158,11,0.12); border-color: rgba(245,158,11,0.28); }
.tab .badge[data-tone="emerald"] { color: var(--emerald-300); background: rgba(16,185,129,0.12); border-color: rgba(16,185,129,0.28); }

.tabpanel { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.tabpanel[hidden] { display: none; }

.toolbar {
  display: flex; align-items: center; gap: 6px; flex: none; flex-wrap: wrap;
  padding: 9px 14px; border-bottom: 1px solid var(--line); background: var(--zinc-925);
}
.toolbar .sep { width: 1px; height: 18px; background: var(--line); margin: 0 3px; }
.toolbar .hint {
  font-size: 11.5px; color: var(--text-faint); margin-left: auto;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 62%;
}
.toolbar .hint code { color: var(--indigo-300); font-family: var(--mono); font-size: 11px; }

.scroller { flex: 1; overflow: auto; min-height: 0; }

/* ==========================================================================
   Diagram
   ========================================================================== */

.diagram-scroll { padding: 18px; }
svg.swimlane { display: block; }

.lane-rule    { stroke: var(--lane-rule); stroke-width: 1; }
.lane-divider { stroke: var(--line-strong); stroke-width: 1; }
.lane-header  { fill: var(--lane-header); }
.lane-label   { fill: var(--zinc-200); font: 600 12.5px var(--sans); }
.lane-kind    { fill: var(--zinc-600); font: 600 9px var(--mono); letter-spacing: 0.12em; }

.edge { fill: none; stroke-width: 1.5; }
.edge-plain { stroke: var(--edge); }
.edge-yes   { stroke: var(--edge-yes); }
.edge-no    { stroke: var(--edge-no); stroke-dasharray: 4 4; }
.edge-back  { stroke: var(--edge-back); stroke-dasharray: 3 4; }

.edge-label     { font: 600 10px var(--sans); fill: var(--zinc-400); }
.edge-label-yes { fill: var(--emerald-400); }
.edge-label-no  { fill: var(--zinc-500); }
.edge-label-back{ fill: var(--amber-400); }
.edge-label-bg  { fill: var(--zinc-950); }

.node-label   { font: 550 11.5px var(--sans); }
.node-caption { font: 500 10.5px var(--sans); fill: var(--zinc-500); }
.node-icon    { font: 600 11px var(--sans); }
.node-badge   { font: 500 9px var(--mono); fill: var(--zinc-600); }
.gate-glyph   { font: 700 19px var(--sans); }
.event-glyph  { font: 600 12px var(--sans); }

.node { transition: opacity 140ms ease; }
.node .node-shape { transition: filter 140ms ease, stroke-width 140ms ease; }
.node:hover .node-shape { filter: brightness(1.35); }
.node:focus-visible { outline: none; }
.node:focus-visible .node-shape { stroke-width: 3; }
.node-highlight .node-shape { stroke-width: 2.75; filter: drop-shadow(0 0 9px currentColor) brightness(1.2); }

.legend {
  display: flex; flex-wrap: wrap; gap: 13px; flex: none;
  padding: 10px 16px; border-top: 1px solid var(--line);
  font-size: 11px; color: var(--text-faint); background: var(--zinc-925);
}
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; border: 1px solid; flex: none; }

/* ==========================================================================
   Code viewer with gutter
   ========================================================================== */

.code-view { display: flex; font-family: var(--mono); font-size: 11.5px; line-height: 1.72; min-height: 100%; }
.gutter {
  flex: none; padding: 14px 10px 24px; text-align: right; user-select: none;
  color: var(--zinc-700); background: var(--zinc-925);
  border-right: 1px solid var(--line); position: sticky; left: 0;
  font-variant-numeric: tabular-nums; min-width: 46px;
}
.code-body { flex: 1; padding: 14px 18px 24px; white-space: pre; overflow-x: auto; color: var(--zinc-400); }

.tk-key  { color: var(--indigo-300); }
.tk-str  { color: var(--emerald-300); }
.tk-num  { color: var(--amber-300); }
.tk-bool { color: var(--violet-300); }
.tk-punc { color: var(--zinc-600); }

/* ==========================================================================
   Tables
   ========================================================================== */

.table-wrap { overflow: auto; flex: 1; min-height: 0; }
table.grid { width: 100%; border-collapse: collapse; font-size: 12px; min-width: 780px; }
table.grid th {
  text-align: left; font: 700 9.5px var(--sans); text-transform: uppercase; letter-spacing: 0.09em;
  color: var(--text-faint); padding: 9px 14px;
  border-bottom: 1px solid var(--line-strong); background: var(--zinc-925);
  position: sticky; top: 0; z-index: 2; white-space: nowrap;
}
table.grid td { padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: top; color: var(--text-dim); }
table.grid tbody tr:hover td { background: var(--surface); }
table.grid td.mono { font-family: var(--mono); font-size: 11px; color: var(--indigo-300); }
table.grid td.phrase { color: var(--zinc-200); max-width: 300px; }
table.grid td.origin-clarification { color: var(--amber-300); font-style: italic; }
table.grid td.origin-structure { color: var(--zinc-600); font-style: italic; }

.tag {
  display: inline-block; font: 500 10.5px var(--mono);
  padding: 1.5px 6px; border-radius: 5px; border: 1px solid var(--line);
  background: var(--surface-2); color: var(--text-dim); white-space: nowrap;
}
.tag[data-kind="human"]  { color: var(--violet-300); border-color: rgba(139,92,246,0.28); background: rgba(139,92,246,0.1); }
.tag[data-kind="system"] { color: var(--teal-300);   border-color: rgba(45,212,191,0.28); background: rgba(45,212,191,0.1); }
.tag[data-kind="engine"] { color: var(--zinc-400); }

/* ==========================================================================
   Findings
   ========================================================================== */

.findings-list { padding: 14px; }
.finding {
  border: 1px solid var(--line); border-radius: var(--r);
  background: var(--surface); padding: 11px 13px; margin-bottom: 7px; font-size: 12px;
  position: relative; overflow: hidden;
}
.finding::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 2px; }
.finding.sev-blocker::before { background: var(--rose-500); }
.finding.sev-warning::before { background: var(--amber-500); }
.finding.sev-info::before    { background: var(--indigo-500); }
.finding .f-head { display: flex; gap: 7px; align-items: center; margin-bottom: 5px; }
.finding .f-title { font-weight: 600; color: var(--text); }
.finding .f-detail { color: var(--text-dim); line-height: 1.55; }
.finding .f-node {
  font: 500 10.5px var(--mono); color: var(--indigo-300); margin-left: auto;
  cursor: pointer; border: 1px solid rgba(99,102,241,0.25); border-radius: 5px;
  padding: 1.5px 6px; background: rgba(99,102,241,0.08); flex: none;
}
.finding .f-node:hover { background: rgba(99,102,241,0.18); }

.checks { display: grid; gap: 6px; padding: 14px; }
.check {
  display: flex; gap: 10px; align-items: flex-start; font-size: 12px;
  border: 1px solid var(--line); border-radius: var(--r-sm);
  background: var(--surface); padding: 9px 11px;
}
.check .tick { font: 700 11px var(--mono); flex: none; width: 15px; text-align: center; margin-top: 1px; }
.check[data-passed="true"]  .tick { color: var(--emerald-400); }
.check[data-passed="false"] .tick { color: var(--rose-400); }
.check .label { color: var(--text-2); flex: 1; }
.check[data-passed="false"] .label { color: var(--text); }
.check .n { font: 500 10.5px var(--mono); color: var(--zinc-600); flex: none; }

/* ==========================================================================
   Audit ledger
   ========================================================================== */

.ledger-entry {
  display: grid; grid-template-columns: 34px 1fr; gap: 12px;
  padding: 11px 16px; border-bottom: 1px solid var(--line); font-size: 12px;
  position: relative;
}
.ledger-entry:hover { background: var(--surface); }
.ledger-entry .seq { font: 500 10.5px var(--mono); color: var(--zinc-700); padding-top: 2px; }
.ledger-entry .ev {
  font: 600 11.5px var(--mono); color: var(--text);
  display: inline-flex; align-items: center; gap: 7px;
}
.ledger-entry .ev i { width: 5px; height: 5px; border-radius: 50%; background: var(--zinc-600); flex: none; }
.ledger-entry[data-kind="clarification"] .ev i { background: var(--emerald-500); }
.ledger-entry[data-kind="workflow"]      .ev i { background: var(--indigo-500); }
.ledger-entry[data-kind="validation"]    .ev i { background: var(--amber-500); }
.ledger-entry[data-kind="ledger"]        .ev i { background: var(--violet-500); }
.ledger-entry .meta { color: var(--zinc-600); font: 500 10.5px var(--mono); margin-top: 3px; }
.ledger-entry .detail { font: 400 10.5px var(--mono); color: var(--zinc-500); margin-top: 4px; word-break: break-word; }
.ledger-entry .hash { font: 400 10px var(--mono); color: var(--zinc-700); margin-top: 4px; }
.ledger-entry .hash b { color: var(--emerald-400); font-weight: 400; }

.banner {
  flex: none; margin: 0; padding: 10px 16px; font-size: 12px; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 8px;
}
.banner[data-valid="true"]  { background: rgba(16,185,129,0.08); color: var(--emerald-300); }
.banner[data-valid="false"] { background: rgba(244,63,94,0.08);  color: var(--rose-300); }

/* ==========================================================================
   Disclosures
   ========================================================================== */

.disclosure {
  flex: none; font-size: 11.5px; color: var(--text-faint); line-height: 1.65;
  padding: 13px 16px; border-top: 1px solid var(--line); background: var(--zinc-925);
}
.disclosure strong { color: var(--text-dim); font-weight: 600; }
.disclosure code { font-family: var(--mono); font-size: 11px; color: var(--indigo-300); }

.note-inline {
  font-size: 11.5px; color: var(--text-faint); line-height: 1.65;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r); padding: 11px 13px; margin: 14px;
}
.note-inline strong { color: var(--text-dim); }
.note-inline code { font-family: var(--mono); font-size: 11px; color: var(--indigo-300); }

/* ==========================================================================
   Toasts
   ========================================================================== */

.toast-host {
  position: fixed; bottom: 18px; right: 18px; z-index: 100;
  display: flex; flex-direction: column; gap: 8px; align-items: flex-end;
  pointer-events: none;
}
.toast {
  display: flex; align-items: center; gap: 9px;
  padding: 9px 13px; border-radius: var(--r);
  background: rgba(23,23,26,0.9); backdrop-filter: blur(14px) saturate(160%);
  -webkit-backdrop-filter: blur(14px) saturate(160%);
  border: 1px solid var(--line-strong); color: var(--text-2);
  font-size: 12.5px; box-shadow: 0 16px 40px -16px rgba(0,0,0,0.9);
  animation: toast-in 260ms cubic-bezier(0.16, 1, 0.3, 1) both;
  max-width: 380px;
}
.toast.out { animation: toast-out 200ms ease both; }
.toast i { width: 6px; height: 6px; border-radius: 50%; flex: none; background: var(--indigo-400); }
.toast[data-tone="ok"] i    { background: var(--emerald-400); }
.toast[data-tone="warn"] i  { background: var(--amber-400); }
.toast[data-tone="error"] i { background: var(--rose-400); }
.toast b { color: var(--text); font-weight: 600; }

@keyframes toast-in  { from { opacity: 0; transform: translateY(10px) scale(0.97); } }
@keyframes toast-out { to   { opacity: 0; transform: translateY(6px) scale(0.98); } }

/* ==========================================================================
   Responsive
   ========================================================================== */

@media (max-width: 1080px) {
  body { overflow: auto; }
  .workspace { grid-template-columns: 1fr; height: auto; }
  .pane-left { border-right: none; border-bottom: 1px solid var(--line); }
  .pane-right { min-height: 78vh; }
  .queue { overflow: visible; }
  .reflection { height: 260px; }
}

@media (max-width: 720px) {
  .brand .sub { display: none; }
  .wf-chip { display: none; }
  .topbar { padding: 0 12px; }
  .prompt-block { padding: 12px; }
  .queue-inner, .findings-list, .checks { padding: 12px; }
  .toolbar { padding: 8px 12px; }
  .toolbar .hint { flex-basis: 100%; margin-left: 0; max-width: 100%; }
  .term-line { grid-template-columns: 46px 64px 1fr; gap: 7px; padding-inline: 10px; }
}

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

/* ==========================================================================
   Plain / technical mode switch
   ========================================================================== */

.mode-switch {
  display: inline-flex; padding: 2px; gap: 2px;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px;
}
.mode-btn {
  border: none; background: transparent; color: var(--text-faint);
  padding: 4px 10px; font-size: 11.5px; font-weight: 550; border-radius: 6px;
}
.mode-btn:hover { background: transparent; color: var(--text-dim); border-color: transparent; }
.mode-btn[aria-pressed="true"] {
  background: var(--surface-3); color: var(--text);
  box-shadow: 0 1px 0 rgba(255,255,255,0.05) inset;
}

/* In plain mode the rule ids and node ids are hidden, not restyled — a
   non-technical reader should not see them at all. */
body[data-mode="plain"] .tech-only { display: none !important; }
body[data-mode="technical"] .plain-only { display: none !important; }

/* ==========================================================================
   Visual condition builder
   ========================================================================== */

.builder { margin-top: 10px; }

.builder-suggest { display: flex; flex-direction: column; gap: 5px; margin-bottom: 10px; }
.suggest-btn {
  justify-content: flex-start; width: 100%; text-align: left;
  background: rgba(16,185,129,0.08); border-color: rgba(16,185,129,0.3);
  color: var(--emerald-300); font-size: 12px; padding: 9px 11px;
}
.suggest-btn:hover { background: rgba(16,185,129,0.16); border-color: var(--emerald-500); color: var(--emerald-300); }
.suggest-btn .lead { font: 600 9.5px var(--mono); opacity: 0.7; letter-spacing: 0.05em; }

.builder-or {
  display: flex; align-items: center; gap: 9px; margin: 10px 0;
  font: 500 10px var(--sans); letter-spacing: 0.08em; text-transform: uppercase; color: var(--zinc-600);
}
.builder-or::before, .builder-or::after { content: ''; flex: 1; height: 1px; background: var(--line); }

.builder-row { display: grid; gap: 6px; margin-bottom: 7px; }
.builder-row > label {
  font: 600 9.5px var(--sans); text-transform: uppercase; letter-spacing: 0.08em; color: var(--zinc-600);
}

.builder select, .builder input {
  width: 100%; background: var(--surface-2); border: 1px solid var(--line);
  color: var(--text); border-radius: var(--r-sm); padding: 8px 9px;
  font-family: var(--sans); font-size: 12.5px; outline: none;
  appearance: none;
}
.builder select {
  background-image: linear-gradient(45deg, transparent 50%, var(--zinc-500) 50%), linear-gradient(135deg, var(--zinc-500) 50%, transparent 50%);
  background-position: calc(100% - 15px) 50%, calc(100% - 10px) 50%;
  background-size: 5px 5px, 5px 5px; background-repeat: no-repeat;
  padding-right: 28px;
}
.builder select:focus, .builder input:focus { border-color: var(--indigo-500); box-shadow: var(--glow-indigo); }
.builder input::placeholder { color: var(--zinc-600); }
.builder optgroup { color: var(--zinc-500); font-style: normal; font-size: 11px; }
.builder option { color: var(--text); background: var(--surface-2); }

.builder-value { display: grid; grid-template-columns: 1fr auto; gap: 6px; }
.builder-value.single { grid-template-columns: 1fr; }

.builder-readback {
  margin: 11px 0 0; padding: 10px 11px; border-radius: var(--r-sm);
  background: rgba(99,102,241,0.08); border: 1px solid rgba(99,102,241,0.22);
  font-size: 12px; color: var(--indigo-300); line-height: 1.5;
}
.builder-readback b { color: #fff; font-weight: 600; }
.builder-readback .lead { color: var(--zinc-500); font-weight: 500; }

.builder-advanced {
  margin-top: 9px; border-top: 1px solid var(--line); padding-top: 9px;
}
.builder-advanced > summary {
  font: 500 11px var(--sans); color: var(--zinc-600); cursor: pointer;
  list-style: none; display: flex; align-items: center; gap: 6px;
}
.builder-advanced > summary::-webkit-details-marker { display: none; }
.builder-advanced > summary::before { content: '▸'; font-size: 9px; transition: transform 120ms ease; }
.builder-advanced[open] > summary::before { transform: rotate(90deg); }
.builder-advanced > summary:hover { color: var(--text-dim); }
.builder-advanced .adv-body { margin-top: 8px; display: grid; gap: 6px; }
.builder-advanced input { font-family: var(--mono); font-size: 11.5px; }
.builder-advanced .adv-note { font-size: 11px; color: var(--zinc-600); line-height: 1.5; }

.option .hint {
  display: block; font-size: 10.5px; color: var(--zinc-600); margin-top: 2px;
}
.option:hover .hint { color: var(--zinc-500); }

/* ==========================================================================
   Simulator
   ========================================================================== */

.sim-grid {
  display: grid; grid-template-columns: minmax(260px, 320px) 1fr;
  gap: 0; align-items: start; min-height: 100%;
}
@media (max-width: 900px) { .sim-grid { grid-template-columns: 1fr; } }

.sim-inputs { padding: 16px; border-right: 1px solid var(--line); }
.sim-result { padding: 16px; min-width: 0; }
@media (max-width: 900px) { .sim-inputs { border-right: none; border-bottom: 1px solid var(--line); } }

.sim-field { margin-bottom: 14px; }
.sim-field > label {
  display: block; font-size: 12.5px; font-weight: 600; color: var(--text); margin-bottom: 3px;
}
.sim-field .why { display: block; font-size: 11px; color: var(--zinc-600); margin-bottom: 6px; line-height: 1.45; }
.sim-field .why code { color: var(--indigo-300); font-family: var(--mono); font-size: 10.5px; }

.sim-input-row { display: grid; grid-template-columns: 1fr auto; gap: 6px; }
.sim-input-row.single { grid-template-columns: 1fr; }
.sim-field input, .sim-field select {
  width: 100%; background: var(--surface-2); border: 1px solid var(--line);
  color: var(--text); border-radius: var(--r-sm); padding: 8px 10px;
  font-family: var(--sans); font-size: 13px; outline: none; appearance: none;
}
.sim-field input:focus, .sim-field select:focus { border-color: var(--indigo-500); box-shadow: var(--glow-indigo); }
.sim-field .unit {
  display: grid; place-items: center; padding: 0 10px; font: 500 11.5px var(--mono);
  color: var(--zinc-500); background: var(--surface-3); border: 1px solid var(--line); border-radius: var(--r-sm);
}

.choice-row { display: flex; gap: 6px; flex-wrap: wrap; }
.choice-btn {
  flex: 1; min-width: 92px; justify-content: center; font-size: 12.5px; padding: 9px 10px;
}
.choice-btn[aria-pressed="true"] {
  background: rgba(99,102,241,0.14); border-color: var(--indigo-500); color: var(--indigo-300);
}

.sim-verdict {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 13px; border-radius: var(--r); margin-bottom: 14px;
  border: 1px solid var(--line-strong); background: var(--surface);
  font-size: 12.5px; line-height: 1.55;
}
.sim-verdict .icon { font-size: 15px; line-height: 1.2; flex: none; }
.sim-verdict b { display: block; font-size: 13px; margin-bottom: 3px; }
.sim-verdict[data-status="complete"]    { border-color: rgba(16,185,129,0.35); background: rgba(16,185,129,0.07); }
.sim-verdict[data-status="complete"] b  { color: var(--emerald-300); }
.sim-verdict[data-status="terminated"]  { border-color: rgba(245,158,11,0.35); background: rgba(245,158,11,0.07); }
.sim-verdict[data-status="terminated"] b{ color: var(--amber-300); }
.sim-verdict[data-status="loop"]        { border-color: rgba(245,158,11,0.35); background: rgba(245,158,11,0.07); }
.sim-verdict[data-status="loop"] b      { color: var(--amber-300); }
.sim-verdict[data-status="needs-input"], .sim-verdict[data-status="blocked"],
.sim-verdict[data-status="stuck"], .sim-verdict[data-status="runaway"] {
  border-color: rgba(244,63,94,0.35); background: rgba(244,63,94,0.07);
}
.sim-verdict[data-status="needs-input"] b, .sim-verdict[data-status="blocked"] b,
.sim-verdict[data-status="stuck"] b, .sim-verdict[data-status="runaway"] b { color: var(--rose-300); }

.sim-steps { list-style: none; padding: 0; margin: 0; position: relative; }
.sim-steps::before {
  content: ''; position: absolute; left: 13px; top: 12px; bottom: 12px;
  width: 1px; background: var(--line);
}
.sim-step {
  display: grid; grid-template-columns: 28px 1fr; gap: 12px;
  padding: 8px 0; position: relative; cursor: pointer;
}
.sim-step .num {
  width: 27px; height: 27px; border-radius: 50%; display: grid; place-items: center;
  font: 600 11px var(--mono); background: var(--surface-3); color: var(--zinc-500);
  border: 1px solid var(--line-strong); position: relative; z-index: 1;
}
.sim-step .body { padding-top: 3px; min-width: 0; }
.sim-step .sname { font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.sim-step .swho {
  font: 500 10px var(--mono); color: var(--zinc-600); letter-spacing: 0.04em;
  text-transform: uppercase; margin-left: 7px;
}
.sim-step .snote { font-size: 12px; color: var(--text-faint); line-height: 1.5; margin-top: 2px; }

.sim-step[data-active="true"] .num {
  background: var(--indigo-500); color: #fff; border-color: var(--indigo-400);
  box-shadow: 0 0 0 4px rgba(99,102,241,0.18);
}
.sim-step[data-active="true"] .sname { color: var(--text); }
.sim-step[data-active="true"] .snote { color: var(--text-dim); }
.sim-step[data-terminal="finished"]  .num { background: rgba(16,185,129,0.15); color: var(--emerald-300); border-color: rgba(16,185,129,0.4); }
.sim-step[data-terminal="stopped"]   .num { background: rgba(244,63,94,0.15);  color: var(--rose-300);    border-color: rgba(244,63,94,0.4); }
.sim-step[data-terminal="loop"]      .num,
.sim-step[data-terminal="needs-input"] .num { background: rgba(245,158,11,0.15); color: var(--amber-300); border-color: rgba(245,158,11,0.4); }
.sim-step[data-repeat="true"] .swho::after { content: ' · repeat'; color: var(--amber-400); }

.sim-empty {
  border: 1px dashed var(--line-strong); border-radius: var(--r);
  padding: 26px 18px; text-align: center; color: var(--text-faint);
  font-size: 12.5px; line-height: 1.6;
}
.sim-empty .big { font-size: 22px; display: block; margin-bottom: 8px; }

/* ==========================================================================
   Simulation path highlighting in the diagram
   ========================================================================== */

.node-dim { opacity: 0.24; }
.node-live .node-shape { filter: brightness(1.06); }
.node-current .node-shape { stroke-width: 3; filter: drop-shadow(0 0 10px currentColor) brightness(1.3); }
.edge-dim { opacity: 0.16; }
.edge-live { stroke-width: 2.4; }

.step-marker-bg { fill: var(--indigo-500); stroke: var(--zinc-950); stroke-width: 2; }
.step-marker { font: 700 10px var(--mono); fill: #fff; }

/* ==========================================================================
   Blueprint: diagram sizes to its content, inspector takes the rest
   --------------------------------------------------------------------------
   The diagram is much wider than it is tall, so fitting it to the pane width
   always left a large empty band underneath. Rather than stretch the drawing,
   that space now holds the step inspector the toolbar has always promised.
   ========================================================================== */

#panel-diagram .diagram-scroll {
  flex: 0 1 auto;
  max-height: 60vh;
  overflow: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
}

.inspector {
  flex: 1 1 auto; min-height: 0; overflow-y: auto;
  border-top: 1px solid var(--line);
  background: var(--zinc-925);
  padding: 14px 18px 18px;
}

.insp-hint {
  display: flex; align-items: center; justify-content: center; gap: 9px;
  height: 100%; min-height: 90px; color: var(--zinc-600); font-size: 12.5px;
  text-align: center; padding: 10px;
}
.insp-hint .glyph { font-size: 15px; opacity: 0.8; }

.insp-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-bottom: 4px; }
.insp-head h3 { margin: 0; font-size: 14.5px; font-weight: 650; letter-spacing: -0.01em; }
.insp-head .who {
  font: 500 10px var(--mono); letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--zinc-500); border: 1px solid var(--line); border-radius: 5px; padding: 2px 6px;
}
.insp-head .id { font: 500 10.5px var(--mono); color: var(--zinc-700); margin-left: auto; }

.insp-lede { font-size: 12.5px; color: var(--text-dim); line-height: 1.55; margin: 0 0 12px; max-width: 74ch; }

.insp-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(212px, 1fr));
  gap: 10px; align-items: start;
}
.insp-card {
  border: 1px solid var(--line); border-radius: var(--r-sm);
  background: var(--surface); padding: 10px 11px; min-width: 0;
}
.insp-card > dt {
  font: 700 9.5px var(--sans); text-transform: uppercase; letter-spacing: 0.09em;
  color: var(--zinc-600); margin-bottom: 5px;
}
.insp-card > dd { margin: 0; font-size: 12.5px; color: var(--text-2); line-height: 1.5; word-break: break-word; }
.insp-card > dd.mono { font-family: var(--mono); font-size: 11.5px; color: var(--indigo-300); }
.insp-card > dd.quote { color: var(--zinc-300); font-style: italic; }
.insp-card > dd.none { color: var(--zinc-700); font-style: italic; }
.insp-card > dd + dd { margin-top: 4px; }
.insp-card .sub { display: block; font-size: 11px; color: var(--zinc-600); font-style: normal; margin-top: 3px; }

.insp-origin {
  display: inline-block; font: 600 9.5px var(--mono); letter-spacing: 0.05em;
  padding: 2px 6px; border-radius: 4px; margin-bottom: 6px;
}
.insp-origin[data-origin="utterance"]     { color: var(--emerald-300); background: rgba(16,185,129,0.1);  border: 1px solid rgba(16,185,129,0.28); }
.insp-origin[data-origin="clarification"] { color: var(--amber-300);   background: rgba(245,158,11,0.1);  border: 1px solid rgba(245,158,11,0.28); }
.insp-origin[data-origin="structure"]     { color: var(--zinc-500);    background: var(--surface-3);      border: 1px solid var(--line); }

.insp-summary { display: flex; flex-wrap: wrap; gap: 8px; }
.stat {
  border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface);
  padding: 8px 12px; min-width: 84px;
}
.stat b { display: block; font: 650 17px var(--sans); color: var(--text); letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.stat span { font: 600 9.5px var(--sans); text-transform: uppercase; letter-spacing: 0.08em; color: var(--zinc-600); }
.stat[data-tone="amber"] b { color: var(--amber-300); }

/* ==========================================================================
   Optional (already-defaulted) questions
   ========================================================================== */

.question.sev-info .qbar { background: linear-gradient(90deg, var(--indigo-500), rgba(99,102,241,0)); }
.sev-info .rule-tag { color: var(--indigo-300); border-color: rgba(99,102,241,0.28); background: rgba(99,102,241,0.09); }

.optional-block { margin-top: 12px; }
.optional-block > summary {
  list-style: none; cursor: pointer; display: flex; align-items: center; gap: 8px;
  font-size: 11.5px; color: var(--text-faint); padding: 8px 10px;
  border: 1px dashed var(--line-strong); border-radius: var(--r-sm);
  background: var(--surface-2);
}
.optional-block > summary::-webkit-details-marker { display: none; }
.optional-block > summary::after { content: '▸'; margin-left: auto; font-size: 9px; transition: transform 120ms ease; }
.optional-block[open] > summary::after { transform: rotate(90deg); }
.optional-block > summary:hover { color: var(--text-dim); border-color: var(--zinc-700); }
.optional-block .opt-count {
  font: 600 10px var(--mono); color: var(--indigo-300); flex: none;
  background: rgba(99,102,241,0.12); border: 1px solid rgba(99,102,241,0.3);
  border-radius: 4px; padding: 1px 5px;
}
.optional-block .opt-body { margin-top: 8px; }

/* ==========================================================================
   Export format picker
   ========================================================================== */

.format-picker { display: flex; gap: 4px; flex-wrap: wrap; }
.fmt {
  border: 1px solid var(--line); background: var(--surface-2); color: var(--text-faint);
  padding: 5px 10px; font-size: 11.5px; border-radius: 999px; white-space: nowrap;
}
.fmt:hover { color: var(--text-2); border-color: var(--zinc-700); background: var(--surface-3); }
.fmt[aria-selected="true"] {
  background: rgba(99,102,241,0.14); color: var(--indigo-300);
  border-color: rgba(99,102,241,0.45);
}
.fmt .ext { font-family: var(--mono); font-size: 9.5px; opacity: 0.6; margin-left: 5px; }

.export-note {
  flex: none; margin: 0; padding: 11px 16px; font-size: 11.5px; line-height: 1.6;
  color: var(--text-faint); background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.export-note strong { color: var(--text-dim); }
.export-note code { font-family: var(--mono); font-size: 11px; color: var(--indigo-300); }

/* ==========================================================================
   Resilience card in the inspector
   ========================================================================== */

.insp-card.resilience { grid-column: 1 / -1; }
.res-rows { display: grid; gap: 7px; }
.res-row { display: grid; grid-template-columns: 118px 1fr; gap: 10px; align-items: baseline; font-size: 12px; }
.res-row > .k {
  font: 600 9.5px var(--sans); text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--zinc-600); padding-top: 2px;
}
.res-row > .v { color: var(--text-2); line-height: 1.5; }
.res-row > .v .src {
  font: 600 9px var(--mono); letter-spacing: 0.05em; margin-left: 7px;
  padding: 1px 5px; border-radius: 4px; vertical-align: 1px;
}
.res-row > .v .src[data-src="default"]   { color: var(--zinc-500); background: var(--surface-3); border: 1px solid var(--line); }
.res-row > .v .src[data-src="clarified"] { color: var(--emerald-300); background: rgba(16,185,129,0.1); border: 1px solid rgba(16,185,129,0.3); }
.res-row > .v .warn { color: var(--amber-300); }
