:root {
  color-scheme: light dark;
  --bg: #f4f6f9;
  --panel: #ffffff;
  --ink: #1b2230;
  --muted: #5f6b7d;
  --line: #d8dee8;
  --brand: #3156d3;
  --brand-ink: #ffffff;
  --soft: #eef2fb;
  --good: #19803f;
  --ok: #9a6a00;
  --warn: #c2570c;
  --bad: #c62d45;
  --grid: #e7ebf2;
  --edge: #566277;
  --radius: 10px;
  --c-users: #7a5af8;
  --c-edge: #0b9aa6;
  --c-compute: #2f6fe4;
  --c-data: #d9831a;
  --c-messaging: #cc3d85;
  --c-ops: #667489;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f141b;
    --panel: #172029;
    --ink: #e7ebf2;
    --muted: #9aa6b8;
    --line: #2a3544;
    --brand: #7b97ff;
    --brand-ink: #0b1020;
    --soft: #1c2837;
    --good: #4cc27d;
    --ok: #e0b341;
    --warn: #f0914d;
    --bad: #ff6b82;
    --grid: #1f2936;
    --edge: #9aa6b8;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
h1 { font-size: 1.6rem; margin: 0 0 .5rem; line-height: 1.25; }
h2 { font-size: 1.1rem; margin: 1.4rem 0 .5rem; }
h3 { font-size: .95rem; margin: 1rem 0 .4rem; }
p { margin: .4rem 0 .7rem; }
a { color: var(--brand); }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.hidden { display: none !important; }
.spacer { flex: 1; }
.lead { font-size: 1.05rem; color: var(--muted); }

/* ------------------------------------------------------------------ chrome */
.top {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 1.5rem;
  padding: .6rem 1.2rem; background: var(--panel); border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; text-decoration: none; color: var(--ink); white-space: nowrap; }
nav { display: flex; gap: .25rem; flex-wrap: wrap; }
nav a {
  padding: .4rem .8rem; border-radius: 8px; text-decoration: none; color: var(--muted); font-weight: 500;
}
nav a:hover { background: var(--soft); color: var(--ink); }
nav a.active { background: var(--soft); color: var(--brand); }

main { max-width: 860px; margin: 0 auto; padding: 1.2rem; }
body[data-view="workspace"] main { max-width: none; padding: .8rem; }

.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1.1rem 1.2rem; margin-bottom: 1rem;
}

/* ----------------------------------------------------------------- controls */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  font: inherit; font-weight: 600; padding: .5rem .95rem; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--line); background: var(--panel); color: var(--ink); text-decoration: none;
}
.btn:hover { background: var(--soft); }
.btn:focus-visible, .chip:focus-visible, .pal-item:focus-visible, .node:focus-visible, nav a:focus-visible,
textarea:focus-visible, input:focus-visible, select:focus-visible, summary:focus-visible {
  outline: 2px solid var(--brand); outline-offset: 2px;
}
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--bad); border-color: var(--bad); background: transparent; }
.btn.small { padding: .25rem .6rem; font-size: .85rem; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.actions { display: flex; gap: .6rem; flex-wrap: wrap; margin-top: 1rem; }

.chips { display: flex; flex-wrap: wrap; gap: .5rem; }
.chip {
  font: inherit; font-size: .9rem; padding: .35rem .8rem; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--line); background: var(--panel); color: var(--muted);
}
.chip.on { background: var(--soft); border-color: var(--brand); color: var(--brand); font-weight: 600; }

textarea, input[type=text], select {
  font: inherit; width: 100%; padding: .55rem .7rem; border-radius: 8px;
  border: 1px solid var(--line); background: var(--panel); color: var(--ink);
}
textarea { resize: vertical; }
.field { display: flex; flex-direction: column; gap: .25rem; margin-bottom: .8rem; }
.toolbar { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; margin-bottom: .7rem; }
.toolbar select { width: auto; }

.bar { flex: 1; height: 8px; background: var(--soft); border-radius: 999px; overflow: hidden; min-width: 60px; }
.bar-fill { height: 100%; background: var(--brand); border-radius: 999px; transition: width .3s; }
.bar-fill.tone-good { background: var(--good); }
.bar-fill.tone-ok { background: var(--ok); }
.bar-fill.tone-warn { background: var(--warn); }
.bar-fill.tone-bad { background: var(--bad); }

.tone-good { color: var(--good); }
.tone-ok { color: var(--ok); }
.tone-warn { color: var(--warn); }
.tone-bad { color: var(--bad); }

.score {
  font-weight: 800; font-size: 1.6rem; min-width: 4.2rem; text-align: center;
  border: 3px solid currentColor; border-radius: 12px; padding: .15rem .4rem;
}
.score.big { font-size: 2.4rem; padding: .3rem .8rem; }
.pill {
  display: inline-block; font-size: .78rem; font-weight: 700; padding: .05rem .5rem; border-radius: 999px;
  border: 1.5px solid currentColor;
}
.tag {
  display: inline-block; font-size: .72rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
  color: var(--brand); margin-right: .5rem;
}

ul.plain { list-style: none; padding: 0; margin: .3rem 0; }
ul.plain li { margin: .3rem 0; }
ul.cov { padding-left: 0; list-style: none; margin: .3rem 0; }
ul.cov li { padding: .3rem 0 .3rem 1.5rem; position: relative; }
ul.cov li::before { position: absolute; left: 0; font-weight: 700; }
ul.cov li.ok::before { content: "✓"; color: var(--good); }
ul.cov li.later::before { content: "◐"; color: var(--ok); }
ul.cov li.miss::before { content: "✕"; color: var(--bad); }
ul.cov li:not(.ok):not(.later):not(.miss)::before { content: "•"; color: var(--brand); }
.ok-note { color: var(--good); font-weight: 600; }
.model { background: var(--soft); border-radius: 8px; padding: .7rem .9rem; }
.tip { color: var(--muted); }

details > summary { cursor: pointer; font-weight: 600; }

/* ---------------------------------------------------------------- interview */
.iv-top { display: flex; align-items: center; gap: .8rem; margin-bottom: .8rem; flex-wrap: wrap; }
.voice-controls { display: inline-flex; align-items: center; gap: .4rem; }
.replay { margin-top: .3rem; }
.chat { display: flex; flex-direction: column; gap: .8rem; padding-bottom: 1rem; }
.bubble {
  max-width: 92%; padding: .7rem 1rem; border-radius: 14px; border: 1px solid var(--line); background: var(--panel);
}
.bubble.bot { align-self: flex-start; border-top-left-radius: 4px; }
.bubble.me { align-self: flex-end; background: var(--soft); border-top-right-radius: 4px; white-space: pre-wrap; }
.bubble .who { font-size: .72rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.bubble p { margin: .25rem 0; }
.bubble .q { font-size: 1.05rem; font-weight: 600; }
.hintline { color: var(--ok); font-style: italic; }
.debrief { min-width: min(560px, 80vw); }
.debrief-head { display: flex; gap: 1rem; align-items: center; margin: .5rem 0; }
.composer {
  position: sticky; bottom: 0; background: var(--bg); padding: .6rem 0 .8rem;
  border-top: 1px solid var(--line);
}
.composer-actions { display: flex; gap: .5rem; align-items: center; margin-top: .5rem; flex-wrap: wrap; }

.topic-row { display: flex; align-items: center; gap: .8rem; margin: .45rem 0; }
.topic-name { width: 10.5rem; flex: none; font-size: .92rem; }
.topic-pct { width: 5.5rem; text-align: right; font-size: .85rem; color: var(--muted); }

/* -------------------------------------------------------------- question bank */
.qlist { display: flex; flex-direction: column; gap: .5rem; }
.qcard { border: 1px solid var(--line); border-radius: 8px; padding: .5rem .8rem; background: var(--panel); }
.qcard summary { display: flex; gap: .5rem; align-items: baseline; flex-wrap: wrap; }
.qtext { flex: 1; font-weight: 600; }
.qbody { padding-top: .5rem; }

/* ---------------------------------------------------------------- workspace */
.ws { display: grid; grid-template-columns: 250px minmax(0, 1fr) 320px; gap: .8rem; align-items: start; }
.ws-left, .ws-right { display: flex; flex-direction: column; min-width: 0; }
.ws .card { padding: .8rem .9rem; margin-bottom: .7rem; }
.ws .brief h3 { margin-top: 0; }
.ws .brief p { font-size: .9rem; }

.palette { display: flex; flex-direction: column; gap: .3rem; }
.pal-cat { font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin-top: .5rem; }
.pal-item {
  padding: .35rem .6rem; border: 1px solid var(--line); border-left: 4px solid var(--cat, var(--line));
  border-radius: 6px; background: var(--panel); cursor: grab; user-select: none; font-size: .9rem;
}
.pal-item:hover { background: var(--soft); }
.pal-desc { margin-top: .6rem; min-height: 3.6em; }

.board-wrap {
  overflow: auto; border: 1px solid var(--line); border-radius: var(--radius);
  height: calc(100vh - 150px); min-height: 460px; background: var(--panel);
}
.board {
  position: relative; touch-action: none;
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 40px 40px;
}
svg.edges { position: absolute; left: 0; top: 0; z-index: 1; pointer-events: none; overflow: visible; }
.edge-line { fill: none; stroke: var(--edge); stroke-width: 2; }
.edge-hit { fill: none; stroke: transparent; stroke-width: 16; pointer-events: stroke; cursor: pointer; }
.edge.selected .edge-line { stroke: var(--brand); stroke-width: 3; }
.arrow-head { fill: var(--edge); }
.arrow-head.sel { fill: var(--brand); }
line.ghost { stroke: var(--brand); stroke-width: 2; stroke-dasharray: 5 4; }

.node {
  position: absolute; z-index: 2; display: flex; align-items: center; gap: .45rem; padding: 0 .55rem;
  background: var(--panel); border: 1.5px solid var(--line); border-left: 5px solid var(--cat, var(--line));
  border-radius: 8px; cursor: grab; user-select: none; touch-action: none;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .12);
}
.node.selected { border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 30%, transparent); }
.node.drop-target { border-color: var(--good); box-shadow: 0 0 0 3px color-mix(in srgb, var(--good) 35%, transparent); }
.n-icon { font-size: 1.3rem; }
.n-text { min-width: 0; line-height: 1.2; }
.n-name {
  font-weight: 600; font-size: .84rem; line-height: 1.15; overflow: hidden;
  display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical;
}
.n-sub { font-size: .72rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-height: .9em; }
.port {
  position: absolute; right: -9px; top: 50%; width: 16px; height: 16px; margin-top: -8px; border-radius: 50%;
  background: var(--brand); border: 2px solid var(--panel); cursor: crosshair; touch-action: none;
}
.port:hover { transform: scale(1.25); }

.cat-users { --cat: var(--c-users); }
.cat-edge { --cat: var(--c-edge); }
.cat-compute { --cat: var(--c-compute); }
.cat-data { --cat: var(--c-data); }
.cat-messaging { --cat: var(--c-messaging); }
.cat-ops { --cat: var(--c-ops); }

.props h3 { margin-top: 0; }
.stepper { display: flex; align-items: center; gap: .6rem; }
.stepper .btn { padding: .25rem .7rem; }
.stepper .count { min-width: 1.5rem; text-align: center; font-weight: 700; }
.notes { font-size: .9rem; }
.note-card { border-color: var(--brand); }

.review .rule { border: 1px solid var(--line); border-radius: 8px; margin: .4rem 0; padding: .3rem .6rem; }
.rule summary { display: flex; gap: .5rem; align-items: baseline; font-weight: 500; font-size: .92rem; }
.rule .ri { font-weight: 800; width: 1.1rem; flex: none; }
.rule.pass .ri { color: var(--good); }
.rule.partial .ri { color: var(--ok); }
.rule.fail .ri { color: var(--bad); }
.rule .rt { flex: 1; }
.rule .lvl { font-size: .68rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.rule .lvl.must { color: var(--bad); font-weight: 700; }
.rbody { padding: .2rem 0 .4rem 1.6rem; font-size: .9rem; }
.rbody p { margin: .3rem 0; }
.fix { color: var(--brand); }
.probes { padding-left: 1.2rem; }
.probes li { margin: .35rem 0; }

@media (max-width: 1180px) {
  .ws { grid-template-columns: 230px minmax(0, 1fr); }
  .ws-right { grid-column: 1 / -1; }
}
@media (max-width: 760px) {
  .composer { position: static; }
  .composer-input { min-height: 7rem; }
  .ws { grid-template-columns: 1fr; }
  .board-wrap { height: 70vh; }
  .hide-sm { display: none; }
  .top { gap: .6rem; padding: .5rem .7rem; flex-wrap: wrap; }
  .topic-name { width: 7rem; }
  .bubble { max-width: 100%; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; scroll-behavior: auto !important; }
}
