/* ContextOS Studio — no-code builder. Light navy, platform-engineer look. */

:root {
  --bg:          #f7f9fc;
  --bg-2:        #f8fafc;
  --surface:     #ffffff;
  --surface-2:   #f8fafc;
  --surface-3:   #f1f5f9;
  --border:      #d8dee9;
  --border-soft: #e8edf3;
  --text:        #0b1424;
  --text-dim:    #475569;
  --text-faint:  #94a3b8;
  --accent:      #1e3a8a;
  --accent-strong:#1e40af;
  --accent-soft: #e7eefb;
  --good:        #15803d;
  --good-soft:   #e7f7ed;
  --warn:        #b45309;
  --warn-soft:   #fbf3e0;
  --bad:         #b91c1c;
  --bad-soft:    #fbebea;
  --purple:      #6d28d9;
  --purple-soft: #f0ebfb;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --font: -apple-system, "Inter", "Segoe UI", system-ui, Arial, sans-serif;
  --radius: 8px;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.04);

  /* aliases so markup ported from the platform-engineer view works unchanged */
  --success:      var(--good);
  --success-soft: var(--good-soft);
  --review:       var(--warn);
  --review-soft:  var(--warn-soft);
  --danger:       var(--bad);
  --danger-soft:  var(--bad-soft);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 13.5px; line-height: 1.55;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

h1 { font-size: 21px; font-weight: 650; letter-spacing: -0.015em; margin: 0 0 4px; }
h2 { font-size: 16px; font-weight: 650; letter-spacing: -0.01em; margin: 0; }
a { color: var(--accent); text-decoration: none; }

.strong { font-weight: 600; }
.dim    { color: var(--text-dim); }
.small  { font-size: 12px; }
.xsmall { font-size: 10.5px; }
.mono   { font-family: var(--mono); font-size: 0.95em; }
.err-text { color: var(--bad); }
.row { display: inline-flex; align-items: center; }
.row.gap { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

/* ── controls ─────────────────────────────────────────────── */
button {
  font-family: inherit; font-size: 12.5px; font-weight: 500;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  border-radius: 7px;
  padding: 6px 12px; cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px;
  transition: background 0.12s, border-color 0.12s;
}
button:hover { background: var(--surface-3); border-color: var(--accent); }
button:disabled { opacity: 0.45; cursor: default; }
button:disabled:hover { background: var(--surface-2); border-color: var(--border); }
/* `a.ghost` shares the rule rather than getting a lookalike of its own.
 * The header's "Sign in" is a link because it goes somewhere — it should
 * be middle-clickable and bookmarkable — but it sits beside "Sign out",
 * which is a button because it does something, and two controls that
 * differ only in element must not differ in appearance. Anchors need the
 * `button` box model spelled out; they inherit none of it. */
a.ghost {
  font-family: inherit; font-size: 12.5px; font-weight: 500;
  border: 1px solid transparent; border-radius: 7px;
  display: inline-flex; align-items: center; gap: 6px;
  transition: background 0.12s, border-color 0.12s;
}
button.ghost, a.ghost { background: transparent; border-color: transparent; color: var(--text-dim); }
button.ghost:hover, a.ghost:hover { color: var(--text); background: var(--surface-2); border-color: var(--border); }
button.sm, a.ghost.sm { padding: 3px 9px; font-size: 11.5px; }
.icon-btn {
  padding: 4px; border-radius: 6px;
  background: transparent; border-color: transparent; color: var(--text-dim);
}
.icon-btn:hover { color: var(--text); background: var(--surface-3); }
.icon-btn.danger:hover { color: var(--bad); background: var(--bad-soft); border-color: transparent; }
.btn-link {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 12px; color: var(--accent); cursor: pointer;
}
.btn-link:hover { text-decoration: underline; }

input, select, textarea {
  font-family: inherit; font-size: 12.5px;
  border: 1px solid var(--border); border-radius: 7px;
  background: var(--bg-2); color: var(--text);
  padding: 7px 10px;
  width: 100%;
  transition: border-color 0.12s;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent-strong);
  box-shadow: 0 0 0 2px var(--accent-soft);
}
textarea { resize: vertical; min-height: 60px; }
textarea.mono { font-family: var(--mono); font-size: 11.5px; }
input::placeholder, textarea::placeholder { color: var(--text-faint); }
input[type="checkbox"], input[type="radio"] { width: auto; accent-color: var(--accent-strong); }

.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; }
.field-label {
  font-size: 10.5px; letter-spacing: 0.07em; text-transform: uppercase;
  color: var(--text-faint); font-weight: 600;
}
.field-hint { font-size: 11px; color: var(--text-faint); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }

/* ── pills & chips ────────────────────────────────────────── */
.pill {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 1.5px 8px; border-radius: 999px;
  background: var(--surface-3); color: var(--text-dim);
  font-size: 10.5px; font-weight: 600; letter-spacing: 0.02em;
  white-space: nowrap;
}
.pill.good   { background: var(--good-soft);   color: var(--good); }
.pill.warn   { background: var(--warn-soft);   color: var(--warn); }
.pill.bad    { background: var(--bad-soft);    color: var(--bad); }
.pill.accent { background: var(--accent-soft); color: var(--accent); }
.pill.purple { background: var(--purple-soft); color: var(--purple); }

.chip-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 6px;
  background: var(--surface-3); border: 1px solid var(--border-soft);
  font-size: 11px; color: var(--text-dim);
}
.chip.entity { color: var(--accent); border-color: #c7d7f5; background: var(--accent-soft); }
.chip-count {
  font-size: 9.5px; background: var(--surface-3);
  border-radius: 99px; padding: 0 5px; color: var(--text-dim);
}
.chip-btn {
  padding: 3px 10px; font-size: 11.5px; border-radius: 999px;
}
.chip-btn.used { opacity: 0.4; }
.count-chip {
  font-size: 10px; background: var(--surface-3); color: var(--text-dim);
  border-radius: 99px; padding: 1px 7px; margin-left: 4px; font-weight: 600;
}

.spinner {
  display: inline-block; width: 14px; height: 14px;
  border: 2px solid rgba(15,23,42,0.14);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex: none;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── topbar ───────────────────────────────────────────────── */
.app { display: flex; flex-direction: column; min-height: 100vh; }
.topbar {
  display: flex; align-items: center; gap: 20px;
  padding: 10px 20px;
  background: linear-gradient(135deg, #1e293b 0%, #1e3a8a 100%);
  color: #fff;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.18);
  position: sticky; top: 0; z-index: 40;
}
.brand-wrap { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  font-size: 20px; color: #fff;
  display: inline-flex; align-items: center;
}
.brand-mark img {
  width: 24px; height: 24px; border-radius: 5px; display: block;
}
.brand { font-size: 15px; font-weight: 700; letter-spacing: -0.01em; display: block; line-height: 1.2; }
.tag { font-size: 10.5px; color: rgba(255,255,255,0.62); display: block; }

.view-toggle {
  display: flex; gap: 4px;
  background: rgba(255,255,255,0.10);
  border: 1px solid rgba(255,255,255,0.16);
  border-radius: 9px; padding: 3px;
}
.view-tab {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 14px; border-radius: 7px;
  font-size: 12.5px; font-weight: 600; color: rgba(255,255,255,0.72);
  transition: all 0.15s;
}
.view-tab:hover { color: #fff; }
.view-tab.active { background: #fff; color: var(--accent); box-shadow: 0 1px 3px rgba(15,23,42,0.18); }

/* The count on the Governance tab — decisions waiting at the desk. Warm
   rather than alarming: a queue is work, not an incident. */
.gov-badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px;
  font-size: 10px; font-weight: 700; line-height: 1;
  background: var(--warn, #d97706); color: #fff;
}

.topbar-right {
  margin-left: auto;
  display: flex; align-items: center; gap: 18px;
}
.health-dots { display: flex; gap: 12px; align-items: center; }

/* The settings gear. A tab with no label, on the right rather than in
   the middle, because it is not one of the places people work — it is
   set once when the platform goes in and then left alone. Same active
   treatment as `.view-tab` so it reads as the same kind of control. */
.icon-tab {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; border-radius: 7px;
  color: rgba(255,255,255,0.72); transition: all 0.15s;
}
.icon-tab:hover { color: #fff; background: rgba(255,255,255,0.10); }
.icon-tab.active {
  background: #fff; color: var(--accent);
  box-shadow: 0 1px 3px rgba(15,23,42,0.18);
}

/* ── who is signed in ─────────────────────────────────────────
 * The topbar is a dark gradient and `.ghost` resolves to
 * `--text-dim`, a mid grey chosen against a white page — legible on
 * the body, all but invisible here. So the two controls that live up
 * here get the tone inverted rather than being restyled from scratch;
 * anything else drifts from the buttons in the body. */
.who {
  display: flex; align-items: center; gap: 9px;
  padding-left: 18px;
  border-left: 1px solid rgba(255,255,255,0.18);
}
.who-name {
  font-size: 12px; font-weight: 600; color: rgba(255,255,255,0.92);
  max-width: 168px; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap;
}
/* Stated, not implied. Admin is the role that can end an account and
 * unregister a store, and somebody who has forgotten they are holding
 * it is the person most likely to use it by accident. */
.who-role {
  font-size: 9.5px; font-weight: 700; letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 2px 6px; border-radius: 99px;
  background: rgba(255,255,255,0.16); color: #fff;
}
.topbar button.ghost, .topbar a.ghost { color: rgba(255,255,255,0.72); }
.topbar button.ghost:hover, .topbar a.ghost:hover {
  color: #fff;
  background: rgba(255,255,255,0.12);
  border-color: rgba(255,255,255,0.22);
}
.health-item { display: inline-flex; align-items: center; gap: 5px; }
.health-label { font-size: 10.5px; color: rgba(255,255,255,0.66); }
.health-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: rgba(255,255,255,0.45);
}
.health-dot.up   { background: #4ade80; }
.health-dot.down { background: #f87171; }
.health-dot.warn { background: #fbbf24; }
.health-dot.unknown { background: rgba(255,255,255,0.45); }

.main { flex: 1; display: flex; flex-direction: column; min-height: 0; }

/* ── engineer layout: dark rail + page shell ──────────────── */
:root { --rail-w: 252px; --topbar-h: 53px; }

.shell-with-rail {
  flex: 1;
  display: grid; grid-template-columns: var(--rail-w) minmax(0, 1fr);
  align-items: stretch; min-height: 0;
}
.shell-with-rail > .page-shell { min-width: 0; }

.rail {
  background: #0f172a;
  color: #e2e8f0;
  border-right: 1px solid #1e293b;
  display: flex; flex-direction: column;
  position: sticky; top: var(--topbar-h);
  height: calc(100vh - var(--topbar-h));
  overflow-y: scroll;
  scrollbar-width: thin;
  scrollbar-color: #475569 #0f172a;
}
.rail::-webkit-scrollbar { width: 10px; }
.rail::-webkit-scrollbar-track { background: #0f172a; }
.rail::-webkit-scrollbar-thumb {
  background: #334155; border-radius: 6px; border: 2px solid #0f172a;
}
.rail::-webkit-scrollbar-thumb:hover { background: #475569; }

.rail-brand { padding: 16px 18px 12px; border-bottom: 1px solid #1e293b; }
.rail-brand-title { font-size: 15px; font-weight: 700; color: #fff; letter-spacing: -0.01em; }
.rail-brand-sub { font-size: 10.5px; color: #94a3b8; margin-top: 2px; }

.rail-wf {
  padding: 12px 14px; border-bottom: 1px solid #1e293b;
  display: flex; flex-direction: column; gap: 6px;
}
.rail-wf-eyebrow {
  font-size: 9.5px; color: #94a3b8;
  text-transform: uppercase; letter-spacing: 0.08em;
}
.rail-wf-select {
  background: rgba(255,255,255,0.06); color: #fff;
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: 6px; padding: 6px 8px;
  font-family: inherit; font-size: 12.5px; cursor: pointer; width: 100%;
}
.rail-wf-select option { color: var(--text); background: var(--surface); }
.rail-wf-import {
  background: var(--accent); color: #fff; border: 1px solid var(--accent);
  border-radius: 6px; padding: 6px 10px;
  font-size: 12px; font-weight: 600; text-align: center;
}
.rail-wf-import:hover { background: #2748a8; border-color: #2748a8; color: #fff; }

.rail-nav { flex: 1; padding: 8px 0 14px; display: flex; flex-direction: column; gap: 1px; }
/* Two header levels. The zone is the louder of the two — brighter, larger,
 * with a rule above it — because it answers "which part of the product am
 * I in". The group answers "what am I doing to it" and is indented under
 * the zone so the nesting is visible without a tree control. */
.rail-zone {
  font-size: 10.5px; color: #94a3b8; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.13em;
  padding: 16px 18px 2px;
  margin-top: 6px;
  border-top: 1px solid rgba(255,255,255,0.07);
}
.rail-nav > .rail-zone:first-child { border-top: 0; margin-top: 0; padding-top: 6px; }
.rail-group {
  font-size: 9.5px; color: #64748b;
  text-transform: uppercase; letter-spacing: 0.1em;
  padding: 10px 18px 4px 28px;
}
.rail-btn {
  display: flex; align-items: center; gap: 10px;
  background: transparent; border: 0; border-radius: 0;
  color: #cbd5e1; padding: 8px 14px 8px 18px;
  font-size: 13px; text-align: left;
  border-left: 3px solid transparent;
}
.rail-btn:hover { background: rgba(255,255,255,0.04); color: #fff; border-color: transparent; border-left-color: transparent; }
.rail-btn.active {
  background: rgba(96,165,250,0.14); color: #fff;
  border-left-color: #60a5fa;
}
.rail-btn:disabled { opacity: 0.35; }
.rail-btn:disabled:hover { background: transparent; color: #cbd5e1; }
.rail-btn-label { flex: 1; min-width: 0; }
.rail-ic-wrap {
  display: inline-flex; align-items: center; justify-content: center;
  width: 18px; flex-shrink: 0; color: #94a3b8;
}
.rail-btn:hover .rail-ic-wrap { color: #fff; }
.rail-btn.active .rail-ic-wrap { color: #60a5fa; }

/* The Advanced drawer. Styled like a heading rather than like a nav row,
 * because it is not a place you can go — it opens the rows below it. The
 * rows themselves are the ordinary .rail-btn, dimmed one step and pushed
 * in, so that "these are off the main road" is legible without reading. */
.rail-adv-toggle {
  display: flex; align-items: center; gap: 10px; width: 100%;
  background: transparent; border: 0; border-top: 1px solid rgba(255,255,255,0.07);
  color: #94a3b8; padding: 14px 18px 8px;
  margin-top: 6px;
  font-size: 10.5px; font-weight: 700; text-align: left;
  text-transform: uppercase; letter-spacing: 0.13em;
}
.rail-adv-toggle:hover { color: #e2e8f0; }
.rail-adv-toggle:disabled { opacity: 0.35; }
.rail-adv-toggle:disabled:hover { color: #94a3b8; }
.rail-adv-count {
  font-size: 10px; letter-spacing: 0; font-weight: 600;
  color: #64748b; background: rgba(255,255,255,0.06);
  border-radius: 999px; padding: 1px 7px;
}
.rail-adv-toggle + .rail-btn, .rail-adv-toggle ~ .rail-btn {
  padding-left: 28px; color: #94a3b8; font-size: 12.5px;
}
.rail-adv-toggle ~ .rail-btn:hover { color: #fff; }
.rail-adv-toggle ~ .rail-btn.active { color: #fff; }

.rail-footer {
  border-top: 1px solid #1e293b; padding: 12px 14px;
  display: flex; flex-wrap: wrap; gap: 6px;
}
.rail-footer .status-pill { background: rgba(255,255,255,0.06); color: #cbd5e1; }

/* step completion tick — light by default, recoloured inside the rail */
.rail-step-dot {
  width: 20px; height: 20px; border-radius: 50%; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--surface-3); color: var(--text-dim);
  font-size: 10.5px; font-weight: 700;
}
.rail-step-dot.done { background: var(--good-soft); color: var(--good); }
.rail .rail-step-dot {
  width: 18px; height: 18px; font-size: 10px;
  background: rgba(255,255,255,0.07); color: #94a3b8;
}
.rail .rail-step-dot.done { background: rgba(74,222,128,0.16); color: #4ade80; }

/* project picker ────────────────────────────────────────────── */
.project-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px;
}
.project-tile {
  display: flex; flex-direction: column; gap: 6px; align-items: flex-start;
  text-align: left; padding: 16px;
  background: var(--surface); border: 1px solid var(--border-soft);
  border-radius: var(--radius); box-shadow: var(--shadow);
  font-size: 12.5px; color: var(--text-dim);
}
.project-tile:hover { border-color: var(--accent); background: var(--surface); }
.project-tile-name { font-size: 14px; font-weight: 650; color: var(--text); }
.project-tile-desc { line-height: 1.5; }

/* overview step grid ────────────────────────────────────────── */
.step-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 8px;
}
.step-tile {
  display: flex; align-items: center; gap: 10px; text-align: left;
  padding: 10px 12px;
  background: var(--surface-2); border: 1px solid var(--border-soft);
  border-radius: var(--radius);
}
.step-tile:hover { border-color: var(--accent); background: var(--surface-2); }
.step-tile.done { background: var(--good-soft); border-color: #cbe6d5; }
.step-tile-body { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.step-tile-name {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12.5px; font-weight: 600; color: var(--text);
}
.step-tile-group {
  font-size: 9.5px; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--text-faint);
}

/* prev / next step footer ───────────────────────────────────── */
.step-nav {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-top: 18px; padding-top: 16px;
  border-top: 1px solid var(--border-soft);
}
.workspace-empty {
  display: flex; align-items: center; justify-content: center;
  min-height: 60vh;
}
.workspace { padding: 24px 28px 80px; max-width: 1060px; }
.workspace-hero { margin-bottom: 22px; }
.workspace-hero-sub { color: var(--text-dim); font-size: 13px; margin-top: 2px; }

/* ── workspace sections ───────────────────────────────────── */
.ws-section {
  margin-bottom: 18px;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  scroll-margin-top: 70px;
  overflow: hidden;
}
.ws-section-hd {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-soft);
  background: var(--surface-2);
}
.ws-num {
  width: 30px; height: 30px; border-radius: 9px; flex: none;
  display: flex; align-items: center; justify-content: center;
  background: var(--surface-3); color: var(--text-dim);
  font-weight: 700; font-size: 13px;
}
.ws-num.done { background: var(--good-soft); color: var(--good); }
.ws-title-wrap { min-width: 0; }
.ws-sub { font-size: 12px; color: var(--text-dim); margin-top: 1px; }
.ws-extra { margin-left: auto; }
.ws-section-body { padding: 16px 18px; }

.panel {
  background: var(--bg-2);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 14px;
}
.panel-title {
  display: flex; align-items: center; gap: 7px;
  font-size: 12.5px; font-weight: 650; margin-bottom: 10px;
  color: var(--text);
}
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; align-items: start; }
.two-col.wide-left { grid-template-columns: 1.25fr 1fr; }
@media (max-width: 900px) { .two-col, .two-col.wide-left { grid-template-columns: 1fr; } }

.mini-label {
  font-size: 10.5px; font-weight: 700; letter-spacing: 0.07em;
  text-transform: uppercase; color: var(--text-faint);
  margin: 8px 0 6px;
}

/* ── empty states ─────────────────────────────────────────── */
.empty-state, .kg-empty, .runner-empty {
  text-align: center; padding: 28px 16px;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
}
.empty-icon { font-size: 26px; margin-bottom: 4px; opacity: 0.85; }
.empty-title { font-weight: 650; font-size: 13.5px; }
.empty-hint { color: var(--text-dim); font-size: 12px; max-width: 420px; line-height: 1.55; }

/* ── data section ─────────────────────────────────────────── */
.dropzone {
  border: 1.5px dashed var(--border);
  border-radius: var(--radius);
  padding: 26px 16px;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  color: var(--text-dim); cursor: pointer;
  transition: all 0.15s;
  background: var(--surface-2);
}
.dropzone:hover, .dropzone.drag {
  border-color: var(--accent-strong);
  background: var(--accent-soft);
  color: var(--text);
}
.dz-title { font-weight: 600; font-size: 13px; margin-top: 6px; }
.dz-hint { font-size: 11.5px; color: var(--text-faint); }

.data-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.data-table th {
  text-align: left; font-size: 10.5px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--text-faint); padding: 5px 10px 7px;
  border-bottom: 1px solid var(--border-soft);
}
.data-table td { padding: 8px 10px; border-bottom: 1px solid var(--border-soft); }
.data-table tr:last-child td { border-bottom: none; }
.data-table.compact td, .data-table.compact th { padding: 4px 8px; font-size: 11.5px; }

/* ── build wizard ─────────────────────────────────────────── */
.wizard { display: flex; flex-direction: column; gap: 12px; }
.wizard-step {
  background: var(--bg-2);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 14px;
}
.wizard-step-hd { display: flex; gap: 10px; align-items: flex-start; margin-bottom: 10px; }
.wizard-letter {
  width: 22px; height: 22px; border-radius: 6px; flex: none;
  display: flex; align-items: center; justify-content: center;
  background: var(--accent-soft); color: var(--accent);
  font-weight: 700; font-size: 12px;
}
.wizard-step-title { font-weight: 650; font-size: 13.5px; }
.wizard-step-sub { font-size: 12px; color: var(--text-dim); }
.wizard-step-body { min-width: 0; }

.option-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.option-card {
  border: 1.5px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 14px;
  cursor: pointer;
  background: var(--surface);
  transition: all 0.15s;
}
.option-card:hover { border-color: var(--border); }
.option-card.selected {
  border-color: var(--accent-strong);
  background: var(--accent-soft);
  box-shadow: 0 0 0 1px var(--accent-strong), 0 2px 8px rgba(30,58,138,0.12);
}
.option-card.disabled { opacity: 0.55; cursor: default; }
.option-icon { font-size: 20px; margin-bottom: 6px; }
.option-title { font-weight: 650; font-size: 13px; }
.option-desc { font-size: 11.5px; color: var(--text-dim); margin-top: 3px; line-height: 1.5; }

.ontology-grid { display: grid; grid-template-columns: 1fr 1.1fr; gap: 14px; margin-top: 12px; }
@media (max-width: 900px) { .ontology-grid { grid-template-columns: 1fr; } }

.stat-row { display: flex; gap: 10px; margin-top: 12px; flex-wrap: wrap; }
.stat {
  background: var(--surface); border: 1px solid var(--border-soft);
  border-radius: 9px; padding: 8px 16px; text-align: center; min-width: 96px;
}
.stat-val { font-size: 17px; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--accent); }
.stat-lbl { font-size: 10.5px; color: var(--text-faint); text-transform: uppercase; letter-spacing: 0.06em; }

.check-list, .radio-list { display: flex; flex-direction: column; gap: 5px; }
.check-row, .radio-row {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 10px; border-radius: 7px;
  border: 1px solid var(--border-soft); background: var(--surface);
  cursor: pointer; font-size: 12.5px;
}
.check-row:hover, .radio-row:hover { border-color: var(--border); }
.radio-row.active { border-color: var(--accent-strong); background: var(--accent-soft); }

.rules-list { margin-top: 12px; display: flex; flex-direction: column; gap: 5px; }
.rule-row {
  display: flex; gap: 10px; align-items: baseline;
  padding: 7px 10px; border-radius: 7px;
  background: var(--surface); border: 1px solid var(--border-soft);
  font-size: 12.5px;
}
.rule-idx {
  flex: none; font-size: 10px; font-weight: 700;
  color: var(--purple); background: var(--purple-soft);
  border-radius: 99px; padding: 1px 7px;
}

/* ── SSE console ──────────────────────────────────────────── */
.sse-console {
  margin-top: 12px;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  background: var(--text);
  color: #e2e8f0;
  overflow: hidden;
}
.sse-hd {
  display: flex; align-items: center; justify-content: space-between;
  padding: 9px 12px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.sse-title { display: inline-flex; align-items: center; gap: 8px; font-weight: 650; font-size: 12.5px; color: #e2e8f0; }
.progress-track { height: 4px; background: rgba(255,255,255,0.10); }
.progress-fill {
  height: 100%; background: var(--accent-strong);
  transition: width 0.4s ease;

}
.progress-fill.done { background: var(--good); }
.progress-fill.error { background: var(--bad); box-shadow: none; }
.sse-log {
  max-height: 220px; overflow-y: auto;
  padding: 10px 12px;
  font-family: var(--mono); font-size: 11px; line-height: 1.7;
}
.sse-line { display: flex; gap: 10px; align-items: baseline; color: #cbd5e1; }
.sse-line.err { color: #fca5a5; }
.sse-line.dim { color: #94a3b8; }
.sse-stage {
  flex: none; min-width: 72px;
  color: #93c5fd; font-size: 10px; text-transform: uppercase; letter-spacing: 0.05em;
}
.sse-counts { color: #94a3b8; font-size: 10px; margin-left: auto; white-space: nowrap; }
/* The run has stopped and is asking something. A warm edge, so a box that
   needs a person is visibly different from one that is just getting on
   with it — noticeable from across a desk without being an alarm. */
.sse-console.sse-waiting { border-color: var(--warn); }
.sse-console.sse-waiting .sse-hd { border-bottom-color: rgba(245,158,11,0.35); }
.sse-console.sse-waiting .progress-fill { background: var(--warn); }

/* ── hydration ────────────────────────────────────────────── */
.hydration-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
@media (max-width: 980px) { .hydration-grid { grid-template-columns: 1fr 1fr; } }
.hydra-card {
  background: var(--bg-2); border: 1px solid var(--border-soft);
  border-radius: var(--radius); padding: 14px;
  border-top: 2px solid var(--accent);
}
.hydra-card.kg    { border-top-color: #1e3a8a; }
.hydra-card.emb   { border-top-color: #15803d; }
.hydra-card.rules { border-top-color: #6d28d9; }
.hydra-card.mem   { border-top-color: #b45309; }
.hydra-icon { color: var(--text-dim); margin-bottom: 6px; }
.hydra-name { font-weight: 650; font-size: 12.5px; margin-bottom: 4px; }
.hydra-nums { display: flex; gap: 12px; font-size: 12px; color: var(--text-dim); }
.hydra-nums b { color: var(--text); font-size: 15px; font-variant-numeric: tabular-nums; }
.hydra-samples { margin-top: 8px; display: flex; flex-direction: column; gap: 4px; }
.hydra-sample {
  font-size: 11px; color: var(--text-dim); font-style: italic;
  border-left: 2px solid var(--purple); padding-left: 8px; line-height: 1.45;
}

.kg-viz { position: relative; }
.kg-legend {
  display: flex; flex-wrap: wrap; gap: 10px;
  padding-top: 8px; border-top: 1px solid var(--border-soft); margin-top: 6px;
}
.kg-legend-item { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; color: var(--text-dim); }
.kg-legend-item.dim { margin-left: auto; color: var(--text-faint); }
.kg-legend-dot { width: 8px; height: 8px; border-radius: 50%; }

.timeline { display: flex; flex-direction: column; gap: 6px; }
.timeline-row { display: flex; align-items: baseline; gap: 10px; font-size: 12.5px; }
.timeline-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--accent); flex: none; align-self: center;

}

/* ── updates ──────────────────────────────────────────────── */
.updates-feed { display: flex; flex-direction: column; gap: 6px; }
.update-row {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: 9px;
  background: var(--bg-2); border: 1px solid var(--border-soft);
  font-size: 12.5px;
}
.update-row.applied { opacity: 0.65; }

/* ── agents ───────────────────────────────────────────────── */
.tool-grid { display: flex; flex-direction: column; gap: 5px; max-height: 260px; overflow-y: auto; }
.tool-row {
  display: flex; gap: 9px; align-items: flex-start;
  padding: 7px 10px; border-radius: 8px;
  border: 1px solid var(--border-soft); background: var(--surface);
  cursor: pointer;
}
.tool-row:hover { border-color: var(--border); }
.tool-row.picked { border-color: var(--accent-strong); background: var(--accent-soft); }
.tool-row input { margin-top: 3px; }
.tool-info { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.tool-name { display: flex; align-items: center; gap: 7px; font-weight: 600; font-size: 12px; }
.tool-desc { font-size: 11px; color: var(--text-dim); line-height: 1.45; }

.agent-cards { display: flex; flex-direction: column; gap: 8px; }
.agent-card {
  background: var(--surface); border: 1px solid var(--border-soft);
  border-radius: var(--radius); padding: 12px;
}
.agent-card-hd { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.agent-name { font-weight: 650; font-size: 13px; }
.agent-role { font-size: 12px; color: var(--text-dim); margin-top: 2px; }

.sequence { display: flex; flex-direction: column; gap: 5px; }
.seq-row {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 10px; border-radius: 8px;
  background: var(--surface); border: 1px solid var(--border-soft);
  font-size: 12.5px;
}
.seq-idx {
  width: 20px; height: 20px; border-radius: 50%; flex: none;
  display: flex; align-items: center; justify-content: center;
  background: var(--accent-soft); color: var(--accent);
  font-size: 10.5px; font-weight: 700;
}
.seq-inline { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; margin-top: 6px; font-size: 11.5px; }
.seq-arrow { color: var(--text-faint); margin: 0 4px; }

/* ── experiences ──────────────────────────────────────────── */
.block-toggles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 7px; }
@media (max-width: 900px) { .block-toggles { grid-template-columns: 1fr 1fr; } }
.block-toggle {
  display: flex; flex-direction: column; align-items: flex-start; gap: 1px;
  padding: 8px 10px; text-align: left;
}
.block-toggle.on {
  border-color: var(--accent-strong);
  background: var(--accent-soft);
  box-shadow: 0 0 0 1px var(--accent-strong);
}
.switch-row {
  display: flex; align-items: center; gap: 8px;
  font-size: 12.5px; margin-top: 12px; cursor: pointer;
}

/* ── collapsible / json ───────────────────────────────────── */
.collapsible { margin-top: 8px; }
.collapsible-toggle {
  background: transparent; border-color: transparent;
  color: var(--text-dim); padding: 3px 4px; font-size: 11.5px;
}
.collapsible-toggle:hover { color: var(--text); background: transparent; border-color: transparent; }
.collapsible-body { padding: 6px 4px 2px; }
.json-block, pre {
  font-family: var(--mono); font-size: 10.5px; line-height: 1.5;
  background: var(--surface-2); border: 1px solid var(--border-soft);
  border-radius: 6px; padding: 10px;
  overflow: auto; max-height: 260px;
  color: var(--text-dim); white-space: pre-wrap;
  margin: 0;
}

/* ── persona view ─────────────────────────────────────────── */
.persona-wrap { padding: 26px 30px 60px; max-width: 1100px; margin: 0 auto; width: 100%; }
.persona-hero { margin-bottom: 22px; }
.persona-loading { display: flex; justify-content: center; padding: 80px 0; }

.exp-gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.exp-card {
  display: flex; flex-direction: column; gap: 6px;
  background: var(--surface); border: 1px solid var(--border-soft);
  border-radius: var(--radius); padding: 18px;
  color: var(--text);
  transition: all 0.15s;
  box-shadow: var(--shadow);
}
.exp-card:hover {
  border-color: var(--accent-strong);
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(15,23,42,0.10), 0 0 0 1px var(--accent-strong);
}
.exp-card-persona {
  font-size: 10.5px; font-weight: 700; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--accent);
}
.exp-card-name { font-size: 15px; font-weight: 650; }
.exp-card-desc { font-size: 12px; color: var(--text-dim); line-height: 1.5; flex: 1; }
.exp-card-foot { display: flex; align-items: center; justify-content: space-between; margin-top: 8px; }
.exp-open { font-size: 12px; color: var(--accent); font-weight: 600; }

/* ── runner ───────────────────────────────────────────────── */
/* Sized against the topbar's REAL height, not a guess. The old
   `calc(100vh - 53px)` hardcoded the topbar at 53px; the rendered bar
   is content-driven (logo + two-line brand + health dots) and comes out
   a few pixels taller, so the column overflowed by the difference and
   the input row's bottom edge slipped below the viewport. The `:has()`
   rule caps the app at the viewport only while a runner is on screen
   and lets the runner flex into whatever is left under the bar — exact
   at any topbar height, any zoom. The calc stays as a fallback for
   engines without `:has()`. */
.runner {
  display: flex; flex-direction: column;
  height: calc(100vh - var(--topbar-h));
  height: calc(100dvh - var(--topbar-h));
}
@supports selector(:has(*)) {
  .app:has(.runner) { height: 100vh; height: 100dvh; max-height: 100dvh; overflow: hidden; }
  .runner { height: auto; flex: 1; min-height: 0; }
}
.runner-hd {
  display: flex; align-items: center; gap: 18px;
  padding: 12px 22px;
  border-bottom: 1px solid var(--border-soft);
  background: var(--bg-2);
}
.runner-title { display: flex; align-items: center; gap: 10px; font-size: 14px; }
.runner-legend { margin-left: auto; display: flex; gap: 14px; }
.legend-item { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; color: var(--text-dim); }
.legend-swatch { width: 10px; height: 10px; border-radius: 3px; }
.legend-item.without .legend-swatch { background: var(--bad); }
.legend-item.with .legend-swatch { background: var(--good); }

.runner-body { flex: 1; display: flex; min-height: 0; }
.runner-stage { flex: 1; overflow-y: auto; padding: 20px 24px; min-width: 0; }
.runner-side {
  width: 320px; flex: none;
  border-left: 1px solid var(--border-soft);
  padding: 14px; overflow-y: auto;
  background: var(--bg-2);
}
.runner-empty { padding-top: 12vh; }

.runner-input {
  display: flex; gap: 10px;
  padding: 12px 22px;
  border-top: 1px solid var(--border-soft);
  background: var(--bg-2);
}
.runner-input input { flex: 1; padding: 10px 14px; font-size: 13.5px; border-radius: 10px; }
/* The presenter's cache switch, sitting in the input row. Plain text at
   the dim tone so it reads as a mode, not a call to action. */
.cache-toggle {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11px; color: var(--text-dim);
  white-space: nowrap; cursor: pointer; user-select: none;
}
.cache-toggle input { accent-color: var(--accent); margin: 0; cursor: pointer; }

.turn { margin-bottom: 26px; }
.turn-q {
  display: flex; align-items: center; gap: 9px;
  font-weight: 650; font-size: 14px; margin-bottom: 12px;
}
.turn-q-icon {
  width: 26px; height: 26px; border-radius: 50%; flex: none;
  display: flex; align-items: center; justify-content: center;
  background: var(--surface-3); color: var(--text-dim);
}
.turn-error {
  display: flex; align-items: center; gap: 8px;
  color: var(--bad); background: var(--bad-soft);
  border: 1px solid #f3c9c7;
  border-radius: 9px; padding: 10px 14px; font-size: 12.5px;
}

.compare-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; align-items: start; }
@media (max-width: 860px) { .compare-grid { grid-template-columns: 1fr; } }
.compare-panel {
  border-radius: var(--radius); padding: 14px;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  min-height: 90px;
}
.compare-panel.without { border-top: 2.5px solid var(--bad); }
.compare-panel.with    { border-top: 2.5px solid var(--good); }
.compare-panel.pending {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 120px; font-size: 12.5px;
}
.compare-hd { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.compare-label {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 10.5px; font-weight: 800; letter-spacing: 0.09em;
}
.compare-panel.without .compare-label { color: var(--bad); }
.compare-panel.with .compare-label { color: var(--good); }
.latency {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 10.5px; color: var(--text-faint);
  background: var(--surface-3); border-radius: 99px; padding: 2px 8px;
  font-variant-numeric: tabular-nums;
}
.answer-text { font-size: 13px; line-height: 1.65; white-space: pre-wrap; }
.ctx-list { margin: 4px 0 0; padding-left: 18px; font-size: 11.5px; color: var(--text-dim); }
.ctx-list li { margin-bottom: 7px; }
.no-ctx {
  display: inline-flex; align-items: center; gap: 5px;
  margin-top: 10px; font-size: 11px; color: var(--bad); opacity: 0.85;
}

/* Provenance — which team's data answered.
   The strip sits above the collapsible and is the only part of the
   evidence the audience sees without clicking, so it is styled to be
   read rather than skimmed past: a rule down the left, and the store
   names at full contrast while the counts stay dim. */
.ctx-prov {
  display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px;
  margin-top: 10px; padding: 6px 9px;
  font-size: 11px; line-height: 1.5;
  border-left: 2px solid var(--accent);
  background: var(--surface-3); border-radius: 0 6px 6px 0;
}
.ctx-prov-store { display: inline-flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.ctx-item { display: block; }
/* The provenance line under one item. Indented under its own text, not
   under the bullet, so a scan down the left edge reads the evidence and
   a scan down the indent reads where each piece came from. */
.ctx-sub {
  display: flex; flex-wrap: wrap; align-items: center; gap: 3px;
  margin-top: 2px; font-size: 10.5px; color: var(--text-faint);
}
.ctx-sub.warn { color: var(--warn, var(--bad)); }
.ctx-store { display: inline-flex; align-items: center; gap: 3px; color: var(--accent); }
.ctx-declared {
  display: inline-flex; align-items: center; gap: 3px;
  color: var(--good); font-weight: 600;
}

/* agent theatre */
.theatre { display: flex; flex-direction: column; gap: 7px; margin-bottom: 12px; }
.theatre-step {
  background: var(--bg-2);
  border: 1px solid var(--border-soft);
  border-left: 2.5px solid var(--good);
  border-radius: 9px; padding: 9px 12px;
  opacity: 0;
  animation: stepIn 0.4s ease forwards;
}
@keyframes stepIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.theatre-step-hd { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.theatre-agent {
  display: inline-flex; align-items: center; gap: 6px;
  font-weight: 650; font-size: 12px; color: var(--good);
}
.theatre-out { font-size: 12px; color: var(--text-dim); margin-top: 5px; line-height: 1.55; }

/* ── toasts ───────────────────────────────────────────────── */
.toast-host {
  position: fixed; bottom: 20px; right: 20px; z-index: 100;
  display: flex; flex-direction: column; gap: 8px; max-width: 380px;
}
.toast {
  display: flex; align-items: flex-start; gap: 9px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px; padding: 11px 14px;
  font-size: 12.5px; cursor: pointer;
  box-shadow: 0 8px 24px rgba(15,23,42,0.16);
  animation: toastIn 0.22s ease;
}
@keyframes toastIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.toast-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; margin-top: 5px; background: var(--accent); }
.toast-error   { border-color: var(--bad); }
.toast-error   .toast-dot { background: var(--bad); }
.toast-success { border-color: var(--good); }
.toast-success .toast-dot { background: var(--good); }
.toast-warn    { border-color: var(--warn); }
.toast-warn    .toast-dot { background: var(--warn); }

/* ── 8-step restructure additions ─────────────────────────── */

/* ── Connector catalog (step 1) — master/detail ───────────────
 * Left column is a fixed 320px because the tiles are deliberately
 * small and a fluid column would let them stretch back out; the
 * detail column takes the rest and is where anything wide goes.
 * `align-items: start` keeps the two panels independently tall
 * instead of stretching the shorter one into a field of blank. */
.conn-layout {
  display: grid; grid-template-columns: 320px minmax(0, 1fr);
  gap: 14px; align-items: start;
}
@media (max-width: 1100px) {
  .conn-layout { grid-template-columns: 1fr; }
}
.conn-detail { min-width: 0; }

.conn-search {
  width: 100%; margin-bottom: 10px; padding: 6px 10px;
  font-size: 12px;
}

.conn-group { margin-top: 12px; }
.conn-group:first-of-type { margin-top: 0; }

/* Two per row at 320px, single line each — the point of the tile is
 * recognition, not description; the description lives on the right. */
.conn-tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.conn-tile {
  display: flex; align-items: center; gap: 7px;
  padding: 7px 9px; text-align: left;
  background: var(--surface); border: 1px solid var(--border-soft);
  border-radius: 6px; cursor: pointer;
  font-size: 11.5px; font-weight: 500; color: var(--text);
  min-width: 0;
}
.conn-tile:hover { border-color: var(--accent); background: var(--surface-2); }
.conn-tile.selected {
  border-color: var(--accent); background: var(--accent-soft);
  color: var(--accent); font-weight: 600;
}
.conn-tile-icon { font-size: 13px; line-height: 1; flex: none; }
.conn-tile-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Connected-source list — same click target as a tile, more detail. */
.conn-list { display: flex; flex-direction: column; gap: 4px; }
.conn-row {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 9px; text-align: left; width: 100%;
  background: var(--surface); border: 1px solid var(--border-soft);
  border-radius: 6px; cursor: pointer; color: var(--text);
}
.conn-row:hover { border-color: var(--accent); background: var(--surface-2); }
.conn-row.selected { border-color: var(--accent); background: var(--accent-soft); }
.conn-row-icon { font-size: 13px; line-height: 1; flex: none; }
.conn-row-main { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.conn-row-name {
  font-size: 12px; font-weight: 600;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.conn-row-sub { font-size: 10.5px; color: var(--text-faint); }
.conn-row-dot {
  width: 7px; height: 7px; border-radius: 50%; flex: none;
  background: var(--text-faint);
}
.conn-row-dot.good { background: var(--good); }
.conn-row-dot.warn { background: var(--warn); }
.conn-row-dot.bad  { background: var(--bad); }

/* Destructive action — tinted, not filled: Remove sits next to Test
 * and a solid red button next to a neutral one reads as the primary. */
button.danger {
  color: var(--bad); border-color: #eccbc9; background: var(--bad-soft);
}
button.danger:hover:not(:disabled) {
  background: var(--bad); border-color: var(--bad); color: #fff;
}

/* Effective stores config hint (step 2) */
.effective-hint {
  margin-top: 10px; font-size: 11.5px; color: var(--text-faint);
  font-family: var(--mono);
}

/* Representation toggle chips (step 5) */
.rep-chip {
  padding: 2px 10px; border-radius: 999px;
  font-size: 11px; font-weight: 600; letter-spacing: 0.02em;
  border: 1px solid var(--border); background: var(--surface-2);
  color: var(--text-faint);
}
.rep-chip:hover { border-color: var(--accent); background: var(--surface-3); }
.rep-chip.on.kg      { color: #1e3a8a; border-color: #bcd0f2; background: #e7eefb; }
.rep-chip.on.vectors { color: #15803d; border-color: #b7e2c6; background: #e7f7ed; }
.rep-chip.on.rules   { color: #6d28d9; border-color: #d5c9f3; background: #f0ebfb; }

/* Coloured stage chips in the context-build SSE log (step 5) */
.sse-stage.st-kg       { color: #93c5fd; }
.sse-stage.st-vector   { color: #6ee7b7; }
.sse-stage.st-rules    { color: #d8b4fe; }
.sse-stage.st-semantic { color: #f9a8d4; }
.sse-stage.st-profile  { color: #fcd34d; }

/* Hydration grid now carries a 5th (semantic layer) card */
.hydration-grid { grid-template-columns: repeat(5, 1fr); }
@media (max-width: 1100px) { .hydration-grid { grid-template-columns: 1fr 1fr 1fr; } }
@media (max-width: 980px)  { .hydration-grid { grid-template-columns: 1fr 1fr; } }
.hydra-card.sem { border-top-color: #be185d; }

/* scrollbars */
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 5px; }
::-webkit-scrollbar-thumb:hover { background: var(--border); }
::-webkit-scrollbar-track { background: transparent; }


/* ══ shared primitives ported from the platform-engineer view ══════════════
   Added, not substituted: every pre-existing class above is untouched. These
   are the vocabulary the merged pages are written against. */

/* page shell + hero ─────────────────────────────────────────── */
.page-shell { padding: 22px 26px 32px; }
.page-hero { margin-bottom: 18px; }
.page-hero.compact { margin-bottom: 8px; }
.page-hero-eyebrow {
  font-size: 10.5px; color: var(--text-faint);
  text-transform: uppercase; letter-spacing: 0.08em;
}
.page-hero h1 { font-size: 22px; font-weight: 700; margin: 4px 0 6px; }
.page-hero-sub { font-size: 13px; color: var(--text-dim); line-height: 1.55; }
.page-hero-meta { margin-top: 8px; }
.page-hero-meta code {
  background: var(--surface-3); color: var(--text-dim);
  font-size: 11px; padding: 1px 6px; border-radius: 3px;
}

/* card ──────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
}
.card h3 { margin: 0 0 6px; font-size: 13px; font-weight: 600; }
.card .sub { color: var(--text-dim); font-size: 12px; margin-bottom: 8px; line-height: 1.55; }
.card-hd {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 12px; margin-bottom: 10px;
}
.card-hd h3 { margin: 0; }
.card.cta { background: var(--accent-soft); border-color: var(--accent); }
.card.cta button.primary.big {
  width: 100%; padding: 12px 16px; font-size: 14px; font-weight: 600; margin-top: 14px;
}

/* labels + key/value ────────────────────────────────────────── */
.label-small {
  font-size: 10px; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--text-faint);
  margin-bottom: 4px;
}
.kv-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 8px; }
.kv { display: flex; align-items: baseline; gap: 6px; margin-top: 6px; }

/* annotations + callouts ────────────────────────────────────── */
.annotation {
  border-radius: 6px; padding: 8px 10px; font-size: 11.5px; margin-top: 4px;
}
.annotation.bad  { background: var(--bad-soft);  color: var(--bad);  border-left: 3px solid var(--bad); }
.annotation.warn { background: var(--warn-soft); color: var(--warn); border-left: 3px solid var(--warn); }
.annotation.good { background: var(--good-soft); color: var(--good); border-left: 3px solid var(--good); }
.annotation.info { background: var(--surface-2); color: var(--text-dim); border-left: 3px solid var(--border); }

.callout {
  border-radius: var(--radius); padding: 10px 12px; margin: 8px 0 4px;
  font-size: 12.5px; line-height: 1.5;
}
.callout-title { font-weight: 600; margin-bottom: 4px; font-size: 12px; }
.callout.bad  { background: var(--bad-soft);  color: var(--bad);  border-left: 3px solid var(--bad); }
.callout.warn { background: var(--warn-soft); color: var(--warn); border-left: 3px solid var(--warn); }
.callout.good { background: var(--good-soft); color: var(--good); border-left: 3px solid var(--good); }
.callout.info { background: var(--surface-2); color: var(--text-dim); border-left: 3px solid var(--border); }
.callout.small { font-size: 11.5px; padding: 8px 10px; }
.callout-card {
  background: var(--accent-soft); border: 1px solid var(--accent);
  border-radius: var(--radius); padding: 12px 14px;
  font-size: 13px; line-height: 1.55; margin-top: 12px;
}
.callout-card b { color: var(--accent); }
.callout-card code {
  background: #fff; color: var(--accent);
  padding: 1px 6px; border-radius: 3px; font-size: 11.5px;
}

/* status pill — lives on the dark topbar ────────────────────── */
.status-pill {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 10.5px; color: rgba(255,255,255,0.85);
  background: rgba(255,255,255,0.08);
  border-radius: 999px; padding: 3px 9px;
}
.status-pill .dot { width: 7px; height: 7px; border-radius: 50%; background: rgba(255,255,255,0.45); }
.status-pill .dot.good { background: #4ade80; }
.status-pill .dot.warn { background: #fbbf24; }
.status-pill .dot.bad  { background: #f87171; }

/* primary button ────────────────────────────────────────────── */
button.primary {
  background: var(--accent); color: #fff; border-color: var(--accent); font-weight: 500;
}
button.primary:hover { background: #182d6e; border-color: #182d6e; }
.topbar button.primary { background: #fff; color: var(--accent); border-color: #fff; }
.topbar button.primary:hover { background: #e0e7ff; }

/* dark code block, for SQL and Cypher ───────────────────────── */
pre.sql-block {
  font-family: var(--mono); font-size: 12px;
  background: var(--text); color: #e2e8f0;
  border: 0; border-radius: 6px;
  padding: 12px 14px; margin: 8px 0 0;
  overflow: auto; white-space: pre-wrap;
  line-height: 1.55; max-height: 360px;
}

/* tabs ──────────────────────────────────────────────────────── */
.tabs { display: flex; flex-direction: column; gap: 12px; }
.tab-strip {
  display: flex; gap: 2px; align-items: center;
  border-bottom: 1px solid var(--border-soft);
}
.tab {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 12px; border: 0; border-radius: 0; background: transparent;
  font-size: 12.5px; font-weight: 600; color: var(--text-dim);
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tab:hover { color: var(--text); background: transparent; }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }

/* table wrapper ─────────────────────────────────────────────── */
.table-wrap {
  border: 1px solid var(--border-soft); border-radius: var(--radius);
  overflow: auto; background: var(--surface);
}
.table-wrap .data-table th { position: sticky; top: 0; z-index: 1; }

/* dialog ────────────────────────────────────────────────────── */
.dialog-backdrop {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(15, 23, 42, 0.38);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 60px 20px; overflow-y: auto;
}
.dialog {
  width: 100%; background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 12px 40px rgba(15, 23, 42, 0.22);
}
.dialog-hd {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
  padding: 16px 18px 12px; border-bottom: 1px solid var(--border-soft);
}
.dialog-sub { font-size: 12px; color: var(--text-dim); margin-top: 3px; }
.dialog-close { padding: 4px; border-color: transparent; background: transparent; color: var(--text-faint); }
.dialog-close:hover { color: var(--text); background: var(--surface-3); }
.dialog-body { padding: 16px 18px; }
.dialog-ft {
  display: flex; justify-content: flex-end; gap: 8px;
  padding: 12px 18px; border-top: 1px solid var(--border-soft);
  background: var(--surface-2);
  border-radius: 0 0 var(--radius) var(--radius);
}
.tab-body { min-width: 0; }

/* ═══════════════════════ Core · Memory page ══════════════════════ */

.mem-stats {
  display: grid; gap: 10px; margin-bottom: 16px;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}
.mem-stat {
  background: var(--surface); border: 1px solid var(--border-soft);
  border-radius: var(--radius); padding: 10px 12px; box-shadow: var(--shadow);
}
.mem-stat-value {
  font-size: 19px; font-weight: 650; letter-spacing: -0.02em;
  color: var(--accent-strong); line-height: 1.2;
}

/* Tone modifiers.
 *
 * The default accent is right for a neutral count — threads, terms,
 * sources. It is wrong for "3 drifted", which reads as an achievement
 * in confident blue. A tone is only applied when the number is
 * non-zero, so a healthy project stays calm rather than turning into
 * a wall of green ticks: colour here means "look at this", and if
 * everything is coloured then nothing is.
 */
.mem-stat.good  .mem-stat-value { color: var(--good); }
.mem-stat.warn  .mem-stat-value { color: var(--warn); }
.mem-stat.bad   .mem-stat-value { color: var(--bad); }
.mem-stat.quiet .mem-stat-value { color: var(--text-dim); }
.mem-stat.warn { border-color: var(--warn-soft); }
.mem-stat.bad  { border-color: var(--bad); }
.mem-stat-label {
  font-size: 10.5px; font-weight: 600; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--text-dim); margin-top: 2px;
}
.mem-stat-hint {
  font-size: 11px; color: var(--text-faint); margin-top: 4px; line-height: 1.4;
}

/* Thread list beside the open thread. Collapses to one column on narrow
   screens — the list is a navigation aid, not the content. */
.mem-split {
  display: grid; grid-template-columns: 260px minmax(0, 1fr);
  gap: 14px; align-items: start; margin-top: 14px;
}
@media (max-width: 900px) { .mem-split { grid-template-columns: 1fr; } }

.mem-list { display: flex; flex-direction: column; gap: 6px; }
.mem-thread {
  display: block; width: 100%; text-align: left; padding: 8px 10px;
  background: var(--surface); border: 1px solid var(--border-soft);
  border-radius: var(--radius); cursor: pointer; font: inherit;
}
.mem-thread:hover { border-color: var(--accent); background: var(--surface-2); }
.mem-thread.active {
  border-color: var(--accent-strong); background: var(--accent-soft);
}
.mem-thread-title {
  font-weight: 600; font-size: 12.5px; line-height: 1.35;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}
.mem-thread-meta {
  display: flex; align-items: center; gap: 6px; margin-top: 5px;
}
.mem-detail { display: flex; flex-direction: column; gap: 12px; min-width: 0; }

/* One turn: a numbered question with the answer that was recorded for
   it. The number matters — reading order is the whole point of a thread,
   and this page exists partly to make a mis-ordered recall visible. */
.mem-turns { display: flex; flex-direction: column; gap: 10px; }
.mem-turn { display: flex; gap: 10px; align-items: flex-start; }
.mem-turn-n {
  flex: 0 0 20px; height: 20px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent-strong);
  font-size: 10.5px; font-weight: 650;
  display: flex; align-items: center; justify-content: center;
}
.mem-turn-body {
  min-width: 0; flex: 1;
  border-left: 2px solid var(--border-soft); padding-left: 10px;
}
.mem-turn-q { font-weight: 600; }
.mem-turn-a {
  color: var(--text-dim); font-size: 12.5px; margin-top: 3px;
  white-space: pre-wrap; word-break: break-word;
}

/* The recall block verbatim. Monospaced and scrollable rather than
   prettified: this is prompt text, and reformatting it here would hide
   exactly the whitespace and labelling problems the panel is for. */
.mem-recall {
  margin: 0; padding: 10px 12px; max-height: 340px; overflow: auto;
  background: var(--surface-3); border: 1px solid var(--border-soft);
  border-radius: var(--radius); font-family: var(--mono); font-size: 11.5px;
  line-height: 1.5; white-space: pre-wrap; word-break: break-word;
}

.mem-handoffs { display: flex; flex-direction: column; gap: 10px; }
.mem-handoff {
  border: 1px solid var(--border-soft); border-radius: var(--radius);
  background: var(--surface); overflow: hidden;
}
.mem-handoff-hd {
  display: flex; align-items: center; gap: 7px; padding: 8px 10px;
  background: var(--surface-2); border-bottom: 1px solid var(--border-soft);
  font-size: 12.5px;
}
.mem-handoff-body {
  margin: 0; padding: 9px 12px; max-height: 200px; overflow: auto;
  font-family: var(--mono); font-size: 11.5px; line-height: 1.5;
  white-space: pre-wrap; word-break: break-word; color: var(--text-dim);
}

/* Memory strip in the persona runner. Sits under the header so the state
   of the conversation is visible without competing with the answers. */
.runner-memory {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 7px 22px; border-bottom: 1px solid var(--border-soft);
  background: var(--surface-2); font-size: 12px; flex: none;
}
.runner-memory .dim { display: inline-flex; align-items: center; gap: 5px; }

/* ── Configure | View ─────────────────────────────────────────
 *
 * The split every Context page uses. The segmented control is the
 * loudest thing between the page title and the content, because it is
 * the one control that changes what the whole page is about — a pair of
 * ordinary tabs reads as "more of the same, filtered", which is what the
 * tab strip *inside* each pane actually is. Two levels of switching on
 * one page need two visual weights or the reader loses track of which
 * one they just used.
 */
.cv { margin-top: 4px; }
.cv-bar {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  margin-bottom: 18px;
}
.cv-segs {
  display: inline-flex; padding: 3px; gap: 3px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 9px;
}
.cv-seg {
  display: flex; flex-direction: column; align-items: flex-start; gap: 1px;
  padding: 7px 14px; border: 1px solid transparent; border-radius: 7px;
  background: transparent; color: var(--text-dim);
  cursor: pointer; text-align: left; transition: background .12s, color .12s;
}
.cv-seg:hover { background: var(--surface-3); color: var(--text); }
.cv-seg.active {
  background: var(--surface); color: var(--text);
  border-color: var(--border);
  box-shadow: var(--shadow);
}
.cv-seg.active .cv-seg-label { color: var(--accent); }
.cv-seg-label { font-size: 12.5px; font-weight: 650; letter-spacing: .1px; }
.cv-seg-hint { font-size: 10.5px; color: var(--text-faint); }
.cv-aside { margin-left: auto; display: flex; align-items: center; gap: 8px; }
/* Present even though it carries no properties of its own: the pane
   is a real box in the layout, and a class in the markup with no rule
   in the stylesheet is indistinguishable from one that was deleted by
   accident. */
.cv-body { min-width: 0; }
.cv-actions {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin-top: 16px; padding-top: 14px;
  border-top: 1px solid var(--border-soft);
}

/* ── configuration panels ─────────────────────────────────────
 *
 * Two columns — where it lives, and what shape it is stored in. They sit
 * side by side because they are one decision made twice, not two
 * unrelated settings, and stacking them lost that.
 */
.cfg-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 18px;
  align-items: start;
}
@media (max-width: 860px) { .cfg-grid { grid-template-columns: 1fr; } }
.cfg-col { display: flex; flex-direction: column; gap: 7px; }
.cfg-opts { display: flex; flex-direction: column; gap: 6px; }
.cfg-opt {
  display: flex; flex-direction: column; gap: 3px; width: 100%;
  padding: 9px 11px; text-align: left; cursor: pointer;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; transition: border-color .12s, background .12s;
}
.cfg-opt:hover:not(:disabled) { border-color: var(--accent); background: var(--surface-2); }
.cfg-opt.selected {
  border-color: var(--accent-strong); background: var(--accent-soft);
  box-shadow: inset 2px 0 0 var(--accent-strong);
}
/* An unwired option is dimmed but never hidden and never disabled: it is
   a real part of the product and a legitimate thing to record. The dash
   border is the visual form of the word "declared". */
.cfg-opt.unwired { border-style: dashed; }
.cfg-opt.unwired:not(.selected) { background: transparent; }
.cfg-opt.unwired.selected {
  background: var(--warn-soft); border-color: var(--warn);
  box-shadow: inset 2px 0 0 var(--warn);
}
.cfg-opt:disabled { opacity: .5; cursor: default; }
.cfg-opt-hd {
  display: flex; align-items: center; gap: 8px; justify-content: space-between;
}
.cfg-opt-name { font-size: 12.5px; font-weight: 600; color: var(--text); }
.cfg-opt-detail { font-size: 11px; color: var(--text-dim); line-height: 1.45; }
.cfg-tunables {
  margin-top: 16px; padding-top: 14px;
  border-top: 1px dashed var(--border);
  display: flex; flex-direction: column; gap: 8px;
}
.cfg-tunable-row {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 12px;
}
.cfg-grid.muted, .cfg-tunables.muted { opacity: .45; }

.numfield { display: flex; flex-direction: column; gap: 4px; }
.numfield-hd { display: flex; align-items: baseline; gap: 6px; }
.numfield-unit {
  font-size: 10px; text-transform: uppercase; letter-spacing: .4px;
  color: var(--text-faint);
}
.numfield input { width: 100%; font-family: var(--mono); font-size: 12px; }
.numfield.disabled { opacity: .6; }

.switch { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; cursor: pointer; }
.switch input { accent-color: var(--accent); }

.kv { display: flex; align-items: baseline; gap: 8px; padding: 3px 0; }
.kv-k { font-size: 11px; color: var(--text-faint); min-width: 120px; }
.kv-v { font-size: 12.5px; color: var(--text); }

/* ── File artifact viewer ────────────────────────────────────────────
   A generated file is shown with its path and checksum in the header
   because those are the claim: the pane is not a rendering of some
   JSON, it is the thing on disk. The body scrolls rather than growing
   — a 400-term semantic model is thousands of lines and the controls
   above it must stay reachable. */
.fileblock {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2, var(--surface));
  overflow: hidden;
}
.fileblock-hd {
  display: flex; align-items: center; gap: 10px;
  justify-content: space-between; flex-wrap: wrap;
  padding: 7px 10px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.fileblock-path {
  font-size: 11px; color: var(--text-dim);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  max-width: 60%; direction: rtl; text-align: left;
}
.fileblock-meta { display: flex; align-items: center; gap: 10px; }
.fileblock-body {
  margin: 0; padding: 10px 12px;
  font-family: var(--mono, ui-monospace, SFMono-Regular, Menlo, monospace);
  font-size: 11px; line-height: 1.55;
  white-space: pre; overflow: auto;
  color: var(--text);
}
.fileblock-empty { padding: 14px 12px; }
button.ghost.xsmall, a.ghost.xsmall {
  font-size: 10.5px; padding: 2px 7px; border-radius: 5px;
  border: 1px solid var(--border); background: transparent;
  color: var(--text-dim); cursor: pointer;
  text-decoration: none; line-height: 1.6;
}
button.ghost.xsmall:hover, a.ghost.xsmall:hover {
  color: var(--text); border-color: var(--text-dim);
}
button.xsmall {
  font-size: 10.5px; padding: 3px 8px; border-radius: 5px; line-height: 1.6;
}

/* ═════════════════ Context · business-logic review ═══════════════════
   A rule is only worth approving if you can see where it came from, so
   the card leads with the sentence and keeps provenance one line below
   it: kind, file:line, how it was found, and how sure the finder was.
   The original snippet is one click away rather than always open — a
   queue of forty CASE expressions is unreadable if every one is
   expanded, and unusable if none of them can be. */
.rule-list { display: flex; flex-direction: column; gap: 8px; }
.rule {
  display: grid; grid-template-columns: 22px minmax(0, 1fr) auto;
  gap: 10px; align-items: start;
  padding: 10px 12px;
  background: var(--surface); border: 1px solid var(--border-soft);
  border-left: 3px solid var(--border);
  border-radius: var(--radius);
}
.rule.approved { border-left-color: var(--good); }
/* The View side ("Business logic in use") has no checkbox and no action
   buttons — just the rule body. Without this, the body falls into the
   22px checkbox column of the grid above and renders one character wide. */
.rule.plain { grid-template-columns: minmax(0, 1fr); }
.rule.rejected { border-left-color: var(--border); opacity: 0.62; }
.rule.proposed { border-left-color: var(--warn); }
.rule-pick { padding-top: 2px; }
.rule-body { min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.rule-text { font-size: 13px; line-height: 1.5; }
.rule-meta {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.rule-orig {
  margin: 2px 0 0; padding: 8px 10px; max-height: 160px; overflow: auto;
  background: var(--surface-2); border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  font-size: 11px; line-height: 1.5; white-space: pre-wrap; word-break: break-word;
  color: var(--text-dim);
}
.rule-actions {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  justify-content: flex-end;
}
@media (max-width: 820px) {
  .rule { grid-template-columns: 22px minmax(0, 1fr); }
  .rule-actions { grid-column: 2; justify-content: flex-start; }
}

/* Confidence is shown as a bar AND a number: the bar is scannable down
   a long queue, the number is what someone quotes back. */
.conf { display: inline-flex; align-items: center; gap: 6px; }
.conf-track {
  display: inline-block; width: 46px; height: 4px; border-radius: 2px;
  background: var(--surface-3); overflow: hidden;
}
.conf-fill { display: block; height: 100%; border-radius: 2px; }
.conf-fill.high { background: var(--good); }
.conf-fill.mid  { background: var(--warn); }
.conf-fill.low  { background: var(--text-faint); }
.conf-num { font-size: 10px; color: var(--text-faint); }

/* ═══════════════ Context · before / after hydration ══════════════════
   Two columns and an arrow, because the claim is a comparison. The
   before column ends on a zero that is styled as emphatically as the
   after column's total: that zero is the argument. A PDF on disk is not
   context — it becomes context when it is hydrated. */
.ba {
  display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  gap: 12px; align-items: stretch;
}
@media (max-width: 900px) {
  .ba { grid-template-columns: minmax(0, 1fr); }
  .ba-arrow { transform: rotate(90deg); padding: 4px 0; }
}
.ba-col {
  display: flex; flex-direction: column; gap: 10px;
  padding: 14px; border-radius: var(--radius);
  border: 1px solid var(--border-soft); background: var(--surface);
  box-shadow: var(--shadow);
}
.ba-col.before { background: var(--surface-2); }
.ba-col.after  { border-color: var(--accent); }
.ba-hd { display: flex; flex-direction: column; gap: 2px; }
.ba-when {
  font-size: 10.5px; font-weight: 700; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--text-faint);
}
.ba-col.after .ba-when { color: var(--accent-strong); }
.ba-what { font-size: 13px; font-weight: 650; }
.ba-lines { display: flex; flex-direction: column; gap: 6px; }
.ba-line {
  display: flex; justify-content: space-between; gap: 12px;
  font-size: 12px; padding-bottom: 5px;
  border-bottom: 1px dashed var(--border-soft);
}
.ba-line:last-child { border-bottom: none; padding-bottom: 0; }
.ba-k { color: var(--text-dim); }
.ba-v { text-align: right; font-variant-numeric: tabular-nums; }
.ba-total {
  display: flex; align-items: baseline; gap: 8px;
  padding: 10px 12px; border-radius: var(--radius);
  background: var(--accent-soft);
}
.ba-total.zero { background: var(--surface-3); }
.ba-total-n {
  font-size: 26px; font-weight: 700; letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums; color: var(--accent-strong);
  line-height: 1;
}
.ba-total.zero .ba-total-n { color: var(--text-faint); }
.ba-total-l {
  font-size: 11px; font-weight: 600; letter-spacing: 0.04em;
  text-transform: uppercase; color: var(--text-dim);
}
.ba-note { font-size: 11.5px; line-height: 1.5; color: var(--text-faint); }
.ba-arrow {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 4px; color: var(--text-faint);
  font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase;
}
.ba-src {
  display: flex; flex-direction: column; gap: 4px;
  padding-top: 8px; border-top: 1px solid var(--border-soft);
}
.ba-src-row { display: flex; justify-content: space-between; gap: 10px; }
.ba-quote {
  font-size: 11.5px; line-height: 1.5; color: var(--text-dim);
  font-style: italic;
}

/* ── Stores, probed now ──────────────────────────────────────────────
 *
 * Two stores side by side rather than stacked, because the question
 * being asked is "is anything down", and that is answered by a glance
 * across a row, not by a scroll. They collapse below 720px, where a
 * glance across is no longer possible anyway.
 */
.store-live {
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px;
}
.store-live-col {
  display: flex; flex-direction: column; gap: 6px;
  padding: 10px 12px; border: 1px solid var(--border-soft);
  border-radius: var(--radius); background: var(--surface-2);
}
@media (max-width: 720px) {
  .store-live { grid-template-columns: 1fr; }
}

/* ── platform Context Stores area ─────────────────────────────
 *
 * Five rules, all of them for things the registry screen needed and
 * nothing else in the app had. Anything it could reuse — .chip, .panel,
 * .kv-grid, .option-card, .mem-stat — it reuses, so a change to the
 * house style still reaches this page.
 */

/* A table cell that is also the way into the row. A <button> because it
   is one — styling an <a href="#"> to look like this would put a dead
   fragment in the address bar every time somebody opened a store. */
.linky {
  display: block; text-align: left; width: 100%;
  background: none; border: 0; padding: 0; cursor: pointer; color: inherit;
}
.linky:hover .strong { color: var(--accent); }

/* One warehouse in the list on a registry entry. */
.list-row {
  justify-content: space-between;
  padding: 7px 0; border-bottom: 1px solid var(--border-soft);
}
.list-row:last-child { border-bottom: 0; }
.row.between { display: flex; justify-content: space-between; width: 100%; }

/* The wizard's step strip, and the filter chips above the catalog. */
.chip.active {
  color: var(--accent); border-color: #c7d7f5; background: var(--accent-soft);
  font-weight: 650;
}
.chip.done { opacity: 0.75; }
button.chip { cursor: pointer; }

/* Readiness issues inside a callout: a list that does not fight the
   callout's own padding. */
ul.tight { margin: 4px 0 0; padding-left: 18px; }
ul.tight li { margin-bottom: 3px; line-height: 1.5; }

/* ── vertical stack ───────────────────────────────────────────
 * The counterpart to `.row.gap`, which is horizontal. Used by the
 * admin panels, where a column of cards each want the same breathing
 * room and none of them should have to know what the others are. */
.stack { display: flex; flex-direction: column; gap: 12px; }
.stack.tight { gap: 8px; }

/* ── boot ─────────────────────────────────────────────────────
 * On screen for one request — /api/auth/me — and only because the
 * alternative is mounting the studio and swapping it for a login
 * form a moment later. Centred and quiet, so that the common case
 * (it answers fast) does not read as a flash of something wrong. */
.boot-wrap {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center; gap: 11px;
  color: var(--text-faint); font-size: 12.5px;
}
.boot-note { color: var(--text-faint); }

/* ── the sign-in screen ───────────────────────────────────────
 * A page, not a modal — see the note at the top of views/account.js.
 * There is no topbar behind it on purpose: the header carries a view
 * switcher and health dots for an app this person cannot reach yet,
 * and offering navigation that 401s is worse than offering none. */
.auth-wrap {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: 32px 20px;
  background: var(--bg);
}
.auth-card {
  width: 100%; max-width: 396px;
  display: flex; flex-direction: column; gap: 14px;
  padding: 26px 28px 22px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 6px 24px rgba(15, 23, 42, 0.07);
}
.auth-brand { display: flex; align-items: center; gap: 9px; }
/* `.brand-mark` is white — it was written for the dark topbar, and this
   card is white. Scoped rather than changed, so the header keeps its. */
.auth-brand .brand-mark { color: var(--accent); font-size: 19px; }
.auth-brand-name {
  font-size: 13px; font-weight: 700; letter-spacing: -0.01em;
  color: var(--text);
}
.auth-title {
  margin: 4px 0 0;
  font-size: 19px; font-weight: 700; letter-spacing: -0.015em;
  color: var(--text);
}
.auth-sub { font-size: 12px; line-height: 1.55; color: var(--text-dim); }
/* Full width and unmistakable. This is the only action on the screen. */
.auth-submit {
  width: 100%;
  justify-content: center;
  margin-top: 4px; padding: 9px 14px; font-size: 13px;
}
.auth-back-link {
  width: 100%;
  justify-content: center;
  margin-top: 8px;
}
.auth-inline-link {
  display: inline;
  padding: 0;
  border: none;
  background: none;
  font: inherit;
  font-size: inherit;
  color: var(--accent, #5b8def);
  text-decoration: underline;
  cursor: pointer;
}
.auth-inline-link:disabled { opacity: 0.5; cursor: not-allowed; }
.auth-link-row {
  margin-top: 18px;
  padding-top: 6px;
  text-align: center;
  line-height: 1.65;
}
.auth-text-link {
  color: var(--accent, #5b8def);
  text-decoration: underline;
  font-weight: 500;
}
.auth-text-link:hover { opacity: 0.85; }
.auth-link-row .auth-text-link { margin: 0 0.4em; }
.auth-link-continued { margin-left: 0.15em; }
.auth-divider {
  margin: 20px 0 14px;
  border: none;
  border-top: 1px solid var(--border-soft);
}
.auth-section-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin: 0 0 10px;
}
.auth-foot {
  display: flex; align-items: flex-start; gap: 6px;
  padding-top: 12px; margin-top: 2px;
  border-top: 1px solid var(--border-soft);
  font-size: 11px; line-height: 1.5; color: var(--text-faint);
}
.auth-foot svg { flex: 0 0 auto; margin-top: 2px; }

.auth-role-toggle {
  display: flex;
  gap: 4px;
  margin: 12px 0 16px;
  padding: 3px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
}
.auth-role-tab {
  flex: 1;
  padding: 7px 10px;
  font-size: 12px;
  font-weight: 600;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
}
.auth-role-tab.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.08);
}
.auth-panel-form { display: flex; flex-direction: column; gap: 14px; }
.auth-panel-user { display: flex; flex-direction: column; gap: 14px; }


/* ── watching a build happen ──────────────────────────────────
   The console used to be a dark box with a log in it, and the log was
   the only way to find out how far along you were. It now has a light
   middle section: circles down the left, and whatever is happening in
   the middle. The dark strip at the top and the log at the bottom stay
   dark, so the box still reads as "a machine is doing something", and
   the light part reads as "and here is where you come in".            */

.sse-body {
  display: grid; grid-template-columns: 232px minmax(0, 1fr);
  gap: 18px;
  padding: 16px 18px;
  background: var(--surface);
  color: var(--text);
}
@media (max-width: 900px) { .sse-body { grid-template-columns: 1fr; } }
.sse-body.solo { grid-template-columns: minmax(0, 1fr); }
.sse-main { min-width: 0; }
/* One line of "what it is doing right now", in words, above the
   picture. The same sentence is in the log; it is repeated here because
   the log is closed by default and this is the one line worth reading. */
.sse-now {
  font-size: 12px; line-height: 1.5; color: var(--text-dim);
  margin-bottom: 10px;
}

/* ── the circles ────────────────────────────────────────────── */
.stage-rail { list-style: none; margin: 0; padding: 0; position: relative; }
.stage-step {
  position: relative;
  display: flex; align-items: flex-start; gap: 10px;
  padding: 0 0 16px;
}
.stage-step:last-child { padding-bottom: 0; }
/* The thread between one circle and the next. Drawn as a border on the
   step rather than as its own element, so it can never fall out of step
   with the circle it hangs from. */
.stage-step::before {
  content: ""; position: absolute;
  left: 11px; top: 24px; bottom: 2px; width: 2px;
  background: var(--border-soft);
}
.stage-step:last-child::before { display: none; }
.stage-step.done::before { background: var(--good); opacity: 0.35; }

.stage-dot {
  flex: none; position: relative; z-index: 1;
  width: 24px; height: 24px; border-radius: 999px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700;
  background: var(--surface-3);
  border: 2px solid var(--border);
  color: var(--text-faint);
  transition: background 0.3s ease, border-color 0.3s ease, color 0.3s ease;
}
.stage-step.done .stage-dot {
  background: var(--good-soft); border-color: var(--good); color: var(--good);
}
.stage-step.active .stage-dot {
  background: var(--accent-soft); border-color: var(--accent); color: var(--accent);
  animation: stage-breathe 1.6s ease-in-out infinite;
}
.stage-step.waiting .stage-dot {
  background: var(--warn-soft); border-color: var(--warn); color: var(--warn);
  animation: stage-breathe 1.6s ease-in-out infinite;
}
.stage-step.failed .stage-dot {
  background: var(--bad-soft); border-color: var(--bad); color: var(--bad);
}
@keyframes stage-breathe {
  0%, 100% { box-shadow: 0 0 0 0 rgba(30,58,138,0.30); }
  50%      { box-shadow: 0 0 0 6px rgba(30,58,138,0.00); }
}

.stage-text { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.stage-label {
  font-size: 12.5px; font-weight: 600; color: var(--text-faint);
  transition: color 0.3s ease;
}
.stage-hint { font-size: 11px; line-height: 1.45; color: var(--text-faint); }
.stage-step.done .stage-label { color: var(--text); }
.stage-step.active .stage-label,
.stage-step.waiting .stage-label,
.stage-step.failed .stage-label { color: var(--text); }
.stage-step.active .stage-hint,
.stage-step.waiting .stage-hint { color: var(--text-dim); }

/* ── the scan ───────────────────────────────────────────────── */
.scan-wrap { width: 100%; }
.scan-svg { width: 100%; height: auto; display: block; }

.scan-core { fill: var(--accent-soft); stroke: var(--accent); stroke-width: 2; }
.scan-core.live { animation: scan-core 2.2s ease-in-out infinite; }
@keyframes scan-core {
  0%, 100% { stroke-opacity: 1; }
  50%      { stroke-opacity: 0.45; }
}
.scan-core-tx {
  fill: var(--accent); font-size: 12px; font-weight: 700;
  text-anchor: middle; dominant-baseline: middle;
}
.scan-empty { fill: var(--text-faint); font-size: 11px; text-anchor: middle; }

.scan-spoke {
  stroke: var(--border); stroke-width: 1.5; stroke-dasharray: 2 6;
  opacity: 0.7;
}
/* The dashes crawl toward the middle. Nothing about the speed means
   anything — it is there to say "still reading this one", which is the
   only honest thing a picture can say about a step whose real progress
   nobody is counting. */
.scan-spoke.on {
  stroke: var(--accent); stroke-width: 2; stroke-dasharray: 4 8;
  opacity: 1; animation: scan-flow 0.85s linear infinite;
}
@keyframes scan-flow { to { stroke-dashoffset: -12; } }

.scan-dot {
  fill: var(--surface); stroke: var(--border); stroke-width: 2;
  transition: fill 0.3s ease, stroke 0.3s ease;
}
.scan-node.on .scan-dot { fill: var(--accent-soft); stroke: var(--accent); }
/* Grows by thickening its own ring rather than by changing its radius.
   The radius of an SVG circle is only animatable from CSS in some
   browsers; stroke-width is animatable everywhere, and at this size the
   two look the same. */
.scan-pulse {
  fill: none; stroke: var(--accent);
  animation: scan-pulse 1.4s ease-in-out infinite;
}
@keyframes scan-pulse {
  0%, 100% { stroke-opacity: 0.85; stroke-width: 2.5; }
  50%      { stroke-opacity: 0.12; stroke-width: 9; }
}
.scan-tx {
  fill: var(--text-faint); font-size: 10px; text-anchor: middle;
  transition: fill 0.3s ease;
}
.scan-node.on .scan-tx { fill: var(--text); font-weight: 600; }

/* ── the pauses ─────────────────────────────────────────────── */
.gate {
  border: 1px solid var(--warn);
  border-left-width: 3px;
  border-radius: var(--radius);
  background: var(--surface);
  padding: 14px 16px;
}
.gate-hd {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; margin-bottom: 4px;
}
.gate-title { font-size: 13.5px; font-weight: 700; color: var(--text); }
.gate-sub { font-size: 11.5px; line-height: 1.55; color: var(--text-dim); }

.gate-list {
  max-height: 320px; overflow-y: auto;
  border: 1px solid var(--border-soft); border-radius: var(--radius);
  background: var(--surface-2);
}
.gate-item {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 9px 11px; cursor: pointer;
  border-bottom: 1px solid var(--border-soft);
}
.gate-item:last-child { border-bottom: none; }
.gate-item:hover { background: var(--surface-3); }
.gate-item.on { background: var(--good-soft); }
.gate-item input { margin-top: 2px; flex: none; }
.gate-item-body { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.gate-item-tx { font-size: 12.5px; line-height: 1.5; color: var(--text); }
.gate-item-meta { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

/* ── the log, now optional ──────────────────────────────────── */
.sse-logtoggle {
  width: 100%; display: flex; align-items: center; gap: 8px;
  padding: 7px 12px;
  background: transparent; border: none;
  border-top: 1px solid rgba(255,255,255,0.08);
  color: #94a3b8; font-size: 11px; font-weight: 600;
  cursor: pointer;
}
.sse-logtoggle:hover { color: #e2e8f0; background: rgba(255,255,255,0.04); }
.sse-logcount {
  margin-left: auto;
  padding: 1px 7px; border-radius: 999px;
  background: rgba(255,255,255,0.08); color: #cbd5e1;
  font-family: var(--mono); font-size: 10px;
}

/* ── pre-built use cases ────────────────────────────────────────
   Front doors to finished applications elsewhere. Deliberately card
   sized rather than list sized: there are three of them and each is a
   destination, not a row of data. */
.usecase-grid {
  display: grid; gap: 14px; margin-top: 14px;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
}
.usecase-card {
  display: flex; flex-direction: column; gap: 8px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.usecase-card:not(.off):hover {
  border-color: var(--accent);
  box-shadow: 0 2px 10px rgba(30,58,138,0.08);
}
/* Present but not available. Faded rather than hidden, so a missing
   address reads as something to fix rather than something that was
   never there. */
.usecase-card.off { background: var(--surface-2); border-style: dashed; }
.usecase-hd {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px;
}
.usecase-name { font-weight: 650; font-size: 14px; color: var(--text); }
.usecase-card.off .usecase-name { color: var(--text-dim); }
.usecase-blurb {
  font-size: 12.5px; line-height: 1.55; color: var(--text-dim);
  flex: 1;
}
.usecase-go {
  display: inline-flex; align-items: center; gap: 6px;
  align-self: flex-start; margin-top: 2px;
  padding: 7px 12px; border-radius: 8px;
  background: var(--accent); color: #fff;
  font-size: 12.5px; font-weight: 600; text-decoration: none;
}
.usecase-go:hover { background: var(--accent-strong); }
.usecase-off-note {
  font-size: 11.5px; line-height: 1.5; color: var(--text-faint);
}
/* The card is a flex column, so a plain button stretches the full width
   and stops reading as a secondary action. Both of these belong to an
   ADDED card only — a built-in has no attribution line and no Remove. */
.usecase-card > button { align-self: flex-start; }

/* vis-network hover tooltip (components/kg_viz.js). The vendored UMD leaves
   this div unstyled, which showed as a blank white square; empty titles are
   now omitted in kg_viz.js, and non-empty ones get a readable dark card. */
div.vis-tooltip {
  position: absolute; visibility: hidden; pointer-events: none;
  max-width: 280px; padding: 6px 9px;
  background: #0b1424; color: #e2e8f0;
  border: 1px solid rgba(148, 163, 184, 0.35); border-radius: 6px;
  font: 11px/1.45 Inter, ui-sans-serif, system-ui, sans-serif;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  box-shadow: 0 6px 18px rgba(2, 6, 23, 0.35); z-index: 1001;
}

/* ── Store advisor (components/assist_bot.js) ───────────────────────────
   Floating assistant, bottom-right of every project screen. z-index 900:
   above page content, below the KG fullscreen overlay (1000) and the
   vis tooltip (1001) — advice must never cover an expanded graph. */
.advisor-fab {
  position: fixed; right: 22px; bottom: 22px; z-index: 900;
  width: 46px; height: 46px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--accent); color: #fff; border: 1px solid var(--accent);
  box-shadow: 0 6px 20px rgba(15, 23, 42, 0.28);
  cursor: pointer;
}
.advisor-fab:hover { background: var(--accent-strong); border-color: var(--accent-strong); }

.advisor-panel {
  position: fixed; right: 22px; bottom: 22px; z-index: 900;
  width: 380px; max-width: calc(100vw - 44px);
  max-height: min(560px, calc(100vh - 90px));
  display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; overflow: hidden;
  box-shadow: 0 12px 40px rgba(15, 23, 42, 0.22);
}
.advisor-head {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px; border-bottom: 1px solid var(--border-soft);
  background: var(--surface-2);
}
.advisor-head-title {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 13px; font-weight: 650; color: var(--text);
}
.advisor-head-spacer { flex: 1; }
.advisor-iconbtn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 26px; height: 26px; padding: 0; border-radius: 6px;
  background: transparent; border: 1px solid transparent;
  color: var(--text-dim); cursor: pointer;
}
.advisor-iconbtn:hover { background: var(--surface-3); border-color: var(--border); }

.advisor-body { padding: 10px 12px; overflow-y: auto; flex: 1; }
.advisor-busy {
  display: flex; align-items: center; gap: 8px;
  color: var(--text-dim); font-size: 12.5px; padding: 8px 0;
}
.advisor-detail {
  font-size: 11.5px; line-height: 1.5; color: var(--text-dim);
  margin-bottom: 8px;
}

.advisor-item {
  border: 1px solid var(--border-soft); border-radius: 8px;
  padding: 8px 10px; margin-bottom: 8px; background: var(--surface);
}
.advisor-item-top { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.advisor-item-name { font-size: 12.5px; font-weight: 650; }
.advisor-conf { margin-left: auto; font-size: 11px; color: var(--text-faint); }
.advisor-item-reason {
  font-size: 12px; line-height: 1.5; color: var(--text-dim); margin: 4px 0 6px;
}
.advisor-item-actions { display: flex; align-items: center; gap: 6px; }
.advisor-panel button.xsmall {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 10px; font-size: 11.5px; border-radius: 6px;
}

.advisor-questions { margin-top: 4px; }
.advisor-q { margin-bottom: 8px; }
.advisor-q-text { font-size: 12px; color: var(--text); margin-bottom: 4px; }
.advisor-q input { width: 100%; font-size: 12.5px; }

.advisor-foot {
  display: flex; align-items: center; gap: 6px;
  padding: 8px 12px; border-top: 1px solid var(--border-soft);
  background: var(--surface-2);
}
.advisor-foot input { flex: 1; font-size: 12.5px; }
.advisor-note {
  padding: 5px 12px 8px; background: var(--surface-2);
  font-size: 10.5px; color: var(--text-faint);
}

/* ── Connector catalog cards — "What goes in" restyle (01nov) ──────
 * Additive block: upgrades the catalog tiles to card presentation
 * (status dot, kind label, description, hover lift) in the existing
 * light palette. Same markup targets, selection and handlers; the
 * old .conn-tile rules are kept above, unused, for easy revert. */
.conn-layout { grid-template-columns: 416px minmax(0, 1fr); }
@media (max-width: 1100px) { .conn-layout { grid-template-columns: 1fr; } }

.conn-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.conn-card2 {
  position: relative; display: flex; flex-direction: column; gap: 5px;
  padding: 11px 12px; text-align: left; min-width: 0;
  background: var(--surface); border: 1px solid var(--border-soft);
  border-radius: 10px; cursor: pointer; color: var(--text);
  font-family: inherit; box-shadow: var(--shadow);
  transition: transform .13s ease, border-color .13s ease, box-shadow .13s ease;
}
.conn-card2:hover {
  transform: translateY(-2px); border-color: var(--accent);
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.09);
}
.conn-card2-head { display: flex; align-items: center; gap: 9px; min-width: 0; }
.conn-card2-icon { font-size: 19px; line-height: 1; flex: none; }
.conn-card2-tt { display: flex; flex-direction: column; min-width: 0; }
.conn-card2-name {
  font-size: 12.5px; font-weight: 650; line-height: 1.3;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.conn-card2-kind {
  font-size: 9.5px; color: var(--text-faint);
  text-transform: uppercase; letter-spacing: .07em;
}
.conn-card2-desc {
  font-size: 11px; color: var(--text-dim); line-height: 1.45; min-height: 32px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}
.conn-card2-dot {
  position: absolute; top: 11px; right: 11px;
  width: 8px; height: 8px; border-radius: 50%; background: var(--border);
}
.conn-card2.connected { border-color: var(--good); }
.conn-card2.connected .conn-card2-dot {
  background: var(--good); box-shadow: 0 0 7px rgba(21, 128, 61, 0.5);
}
.conn-card2.selected { border-color: var(--accent); background: var(--accent-soft); }
.conn-card2.selected .conn-card2-name { color: var(--accent); }

/* ------------------------------------------------------------------ */
/* Connector marketplace — "What goes in" gallery (01nov).             */
/* Supersedes the conn-card2 block above (kept for easy revert).       */
/* Full-width card grid with brand logos, search + category chips,     */
/* per-type connection-count pills. Purely presentational.             */

.mkt { display: flex; flex-direction: column; gap: 14px; }

.mkt-toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.mkt-search { max-width: 300px; margin: 0; flex: none; }
.mkt-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.mkt-chip {
  border: 1px solid var(--border); background: var(--surface);
  color: var(--text-dim); border-radius: 999px; padding: 4px 12px;
  font: inherit; font-size: 12px; cursor: pointer;
  transition: border-color .12s ease, color .12s ease, background .12s ease;
}
.mkt-chip:hover { border-color: var(--accent); color: var(--accent); }
.mkt-chip.on { background: var(--accent); border-color: var(--accent); color: #fff; }

.mkt-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 10px;
}
.mkt-card {
  display: flex; flex-direction: column; gap: 8px; text-align: left;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; padding: 12px 13px; cursor: pointer;
  font: inherit; color: var(--text); box-shadow: var(--shadow);
  transition: border-color .12s ease, box-shadow .12s ease, transform .12s ease;
}
.mkt-card:hover {
  border-color: var(--accent); transform: translateY(-2px);
  box-shadow: 0 4px 14px rgba(30, 58, 138, 0.10);
}
.mkt-card.selected { border-color: var(--accent); background: var(--accent-soft); }
.mkt-card.selected .mkt-name { color: var(--accent); }

.mkt-head { display: flex; gap: 10px; align-items: center; min-width: 0; }
.mkt-logo {
  width: 36px; height: 36px; flex: none; display: inline-flex;
  align-items: center; justify-content: center;
  background: var(--surface-3); border: 1px solid var(--border-soft);
  border-radius: 8px;
}
.mkt-logo svg { width: 20px; height: 20px; display: block; }
.mkt-logo-emoji { font-size: 17px; }
.mkt-tt { display: flex; flex-direction: column; min-width: 0; }
.mkt-name {
  font-size: 13.5px; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.mkt-cat { font-size: 11px; color: var(--text-faint); }
.mkt-desc {
  font-size: 12px; color: var(--text-dim); line-height: 1.45;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden; min-height: 2.9em;
}
.mkt-foot {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px; margin-top: auto;
}
.mkt-pill {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px; font-weight: 600; color: var(--good);
  background: var(--good-soft); border: 1px solid rgba(21, 128, 61, 0.25);
  border-radius: 999px; padding: 2px 8px; white-space: nowrap;
}
.mkt-pill-dot {
  width: 6px; height: 6px; border-radius: 50%; background: var(--good);
  box-shadow: 0 0 5px rgba(21, 128, 61, 0.5);
}
.mkt-add { font-size: 11.5px; font-weight: 600; color: var(--accent); white-space: nowrap; }

.mkt-lower {
  display: grid; grid-template-columns: 320px minmax(0, 1fr);
  gap: 16px; align-items: start;
}
@media (max-width: 960px) { .mkt-lower { grid-template-columns: 1fr; } }

/* Marketplace follow-up (01nov): category sections restored inside the
 * gallery, and the config form moved into a Dialog. */
.mkt-section { display: flex; flex-direction: column; gap: 8px; }
.mkt-section .mini-label { margin: 2px 0 0; }

/* Inside the dialog the form's own panel chrome is redundant — the
 * dialog already draws the box. Flatten, don't restyle. */
.mkt-modal > .panel,
.mkt-modal .panel:first-child {
  border: none; box-shadow: none; padding: 0; background: transparent;
}

/* ── Crew console (context_crew.js) ─────────────────────────────────
 * Additive block for the "Build the context layer — Crew" screen. The
 * console reuses the dark-box language of .sse-console (and the global
 * .progress-track / .sse-log / .sse-stage classes render inside it
 * unchanged); everything crew-specific is new and prefixed .crew-. */
.crew-console {
  margin-top: 12px;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  background: var(--text);
  color: #e2e8f0;
  overflow: hidden;
}
.crew-console.sse-waiting { border-color: var(--warn); }
.crew-console.sse-waiting .progress-fill { background: var(--warn); }
.crew-top {
  display: flex; align-items: center; justify-content: space-between;
  padding: 9px 12px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.crew-title {
  display: inline-flex; align-items: center; gap: 8px;
  font-weight: 650; font-size: 12.5px; color: #e2e8f0;
}
.crew-now {
  padding: 2px 14px 8px;
  font-size: 11.5px; color: #94a3b8;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.crew-grid {
  display: grid; grid-template-columns: repeat(5, 1fr);
  gap: 8px; padding: 10px 12px 4px;
}
@media (max-width: 1100px) { .crew-grid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 760px)  { .crew-grid { grid-template-columns: 1fr 1fr; } }
.crew-card {
  display: flex; flex-direction: column; gap: 6px;
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: var(--radius);
  background: rgba(255,255,255,0.05);
  padding: 10px;
  min-height: 120px;
  /* Grid items default to min-width:auto, so one long nowrap log line
     makes the card GROW to fit instead of ellipsising — the first card
     swells to the whole row and pushes the other four out of the
     overflow-hidden console. min-width:0 is what lets text-overflow
     actually clip. */
  min-width: 0;
  transition: border-color 0.3s ease, background 0.3s ease;
}
.crew-card.active {
  border-color: #3b82f6; background: rgba(59,130,246,0.10);
  box-shadow: 0 0 0 1px rgba(59,130,246,0.35), 0 0 18px rgba(59,130,246,0.12);
}
.crew-card.gated  { border-color: var(--warn); background: rgba(245,158,11,0.08); }
.crew-card.done   { border-color: rgba(34,197,94,0.45); }
.crew-card.failed { border-color: var(--bad); background: rgba(239,68,68,0.08); }
.crew-head { display: flex; align-items: center; gap: 7px; }
.crew-emoji { font-size: 17px; line-height: 1; }
.crew-name { font-weight: 650; font-size: 12.5px; color: #e2e8f0; }
.crew-state {
  margin-left: auto;
  font-size: 9.5px; text-transform: uppercase; letter-spacing: 0.06em;
  border-radius: 99px; padding: 1px 7px;
  background: rgba(255,255,255,0.08); color: #94a3b8;
}
.crew-state.active { background: rgba(59,130,246,0.22); color: #93c5fd; }
.crew-state.gated  { background: rgba(245,158,11,0.22); color: #fcd34d; }
.crew-state.done   { background: rgba(34,197,94,0.20);  color: #86efac; }
.crew-state.failed { background: rgba(239,68,68,0.22);  color: #fca5a5; }
.crew-role { font-size: 10.5px; line-height: 1.45; color: #94a3b8; min-height: 30px; }
.crew-bar {
  height: 3px; border-radius: 99px; overflow: hidden;
  background: rgba(255,255,255,0.10);
}
.crew-fill { height: 100%; width: 0; background: var(--accent-strong); }
.crew-fill.done { width: 100%; background: var(--good); }
.crew-fill.failed { width: 100%; background: var(--bad); }
.crew-fill.gated { width: 60%; background: var(--warn); }
.crew-fill.active {
  width: 40%;
  animation: crew-sweep 1.6s ease-in-out infinite;
}
@keyframes crew-sweep {
  0%   { margin-left: 0;   width: 25%; }
  50%  { margin-left: 55%; width: 45%; }
  100% { margin-left: 0;   width: 25%; }
}
.crew-log {
  flex: 1;
  font-family: var(--mono); font-size: 10px; line-height: 1.6;
  color: #cbd5e1;
  overflow: hidden;
  min-width: 0; max-width: 100%;
}
.crew-log.empty { color: #64748b; font-family: var(--font); font-size: 10.5px; }
.crew-line {
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  min-width: 0; max-width: 100%;
}
.crew-artifact {
  font-size: 10.5px; color: #86efac;
  border-top: 1px dashed rgba(255,255,255,0.12);
  padding-top: 6px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.crew-foot {
  padding: 4px 14px 10px;
  font-size: 11px; color: #94a3b8;
}
.crew-gate { padding: 0 12px 12px; }
/* The gate forms are light boxes (.gate has a white surface). They sit
   inside this dark console, which sets `color: #e2e8f0` — and .data-table
   cells and .strong set no colour of their own, so without this reset the
   plan gate's source names render light-grey on white and read as
   disabled. Reset inheritance at the gate boundary. */
.crew-gate .gate { color: var(--text); }
/* The radar, demoted: the cards are the picture now, the scan is the
   garnish underneath — capped so it never pushes the crew off screen. */
.crew-scan {
  max-width: 540px; margin: 0 auto;
  padding: 0 12px 6px;
  opacity: 0.9;
}
