:root {
  --bg: #0b0e14;
  --bg2: #11161f;
  --panel: #151b26;
  --line: #243042;
  --ink: #e7edf5;
  --muted: #8a99ad;
  --accent: #7cc4ff;     /* lit / selected */
  --accent2: #b18cff;    /* concept */
  --gold: #ffd479;       /* answer / reference */
  --good: #5fe3a1;
  --bad: #ff8a8a;
  --fog: #3a4150;
  --radius: 12px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: radial-gradient(1200px 700px at 70% -10%, #16203054, transparent), var(--bg);
  color: var(--ink);
  font: 15px/1.55 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}
.mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; }
.gold { color: var(--gold); }
.dim { color: var(--muted); opacity: .8; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.big { font-size: 17px; font-weight: 600; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
b { color: #fff; font-weight: 600; }

/* topbar */
.topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; border-bottom: 1px solid var(--line);
  position: sticky; top: 0; background: #0b0e14e0; backdrop-filter: blur(8px); z-index: 20;
}
.brand { flex: 1; display: flex; align-items: baseline; gap: 10px; }
.brand h1 { font-size: 19px; margin: 0; letter-spacing: .2px; }
.brand .by { color: var(--muted); font-size: 12px; }
.icon-btn {
  width: 32px; height: 32px; border-radius: 50%; border: 1px solid var(--line);
  background: var(--panel); color: var(--ink); font-size: 15px; cursor: pointer;
}
.icon-btn:hover { border-color: var(--accent); }
.raw-toggle { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); cursor: pointer; user-select: none; }
.raw-toggle input { accent-color: var(--accent); }

main { max-width: 1180px; margin: 0 auto; padding: 16px; }

.prompt-bar {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px 16px; margin-bottom: 12px;
}
.prompt-line { font-size: 15px; }
.prompt-line .answer-token { color: var(--gold); font-weight: 700; background: #ffd4791a; padding: 1px 8px; border-radius: 6px; }
.level-title { color: var(--muted); font-size: 13px; margin-top: 4px; }
.tagline { color: #c4d0e0; margin: 4px 2px 14px; }

/* stage: graph + detail */
.stage { display: grid; grid-template-columns: 1fr 300px; gap: 14px; align-items: start; }
.graph-wrap { position: relative; }
#graph {
  width: 100%; height: auto; aspect-ratio: 1000 / 660;
  background: linear-gradient(180deg, #0e1420, #0b0e14);
  border: 1px solid var(--line); border-radius: var(--radius);
  touch-action: none; cursor: grab; display: block;
}
#graph.grabbing { cursor: grabbing; }
.zoom-ctl { position: absolute; top: 10px; right: 10px; display: flex; flex-direction: column; gap: 6px; }
.zoom-ctl button {
  width: 30px; height: 30px; border-radius: 8px; border: 1px solid var(--line);
  background: #141b27e8; color: var(--ink); font-size: 16px; cursor: pointer; line-height: 1;
}
.zoom-ctl button:hover { border-color: var(--accent); color: var(--accent); }
.graph-hint { position: absolute; bottom: 8px; left: 12px; font-size: 11px; color: var(--muted); pointer-events: none; opacity: .7; }

/* edges */
.edge { stroke: #283648; stroke-opacity: .5; vector-effect: non-scaling-stroke; }
.edge.lit { stroke: var(--accent); stroke-opacity: .95; }
.edge.ref { stroke: var(--gold); stroke-opacity: .85; }

/* nodes */
.node { user-select: none; }
.node-label { fill: var(--ink); font-size: 12px; text-anchor: middle; font-weight: 600; pointer-events: none; }
.lab-token { fill: #cdd9e8; }
.chip { fill: #1a2231; stroke: var(--line); }
.token-chip { fill: #16202e; stroke: #2f3e54; }
.target-chip { fill: #2a230f; stroke: var(--gold); stroke-width: 1.5; }
.competitor-chip { fill: #20242c; stroke: #3a3340; }
.lab-target { fill: var(--gold); font-weight: 700; font-size: 14px; }
.lab-comp { fill: #9aa4b4; font-weight: 600; font-size: 12px; }
.fog-node { fill: #161b24; stroke: var(--fog); stroke-dasharray: 2 3; }
.lab-fog { fill: #5a6577; font-size: 10px; font-weight: 500; }

/* feature nodes — all look identical until submit (honest: can't tell circuit from decoy by sight) */
.feat { fill: #223044; stroke: #3d557a; stroke-width: 1.5; transition: fill .12s, stroke .12s; }
.node.feature:hover .feat { stroke: var(--accent); }
.feat.selected { fill: #194067; stroke: var(--accent); stroke-width: 2.5; }
.expandable { fill: none; stroke: #4a648c; stroke-width: 1; stroke-dasharray: 2 3; opacity: .8; }
.feat.sel-ref { fill: #4a3a12; stroke: var(--gold); stroke-width: 2.5; }     /* your pick, on the circuit */
.feat.sel-decoy { fill: #3a1820; stroke: var(--bad); stroke-width: 2.5; }   /* your pick, a decoy */
.lab-feat { fill: #8fa1b8; font-size: 10.5px; font-weight: 500; }
.lab-feat.lab-ref { fill: var(--gold); font-weight: 700; }
.lab-feat.lab-decoy { fill: var(--bad); font-weight: 700; }

/* select badge */
.badge { cursor: pointer; }
.badge-bg { fill: #11161f; stroke: #4a648c; stroke-width: 1; }
.badge.on .badge-bg { fill: var(--accent); stroke: var(--accent); }
.badge-txt { fill: #9fb4cc; font-size: 11px; font-weight: 700; }
.badge.on .badge-txt { fill: #06223a; }

/* detail panel */
.detail {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px; min-height: 200px;
}
.detail h3 { margin: 0 0 8px; font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
.detail .big { margin: 2px 0 6px; }
.toggle-sel {
  margin: 10px 0; padding: 7px 12px; border-radius: 8px; cursor: pointer;
  background: #18222f; color: var(--ink); border: 1px solid var(--line); font-size: 13px;
}
.toggle-sel.on { background: #143047; border-color: var(--accent); color: var(--accent); }
.members { margin-top: 10px; border-top: 1px solid var(--line); padding-top: 10px; }
.members-head { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.member {
  display: flex; justify-content: space-between; gap: 8px; align-items: center;
  padding: 5px 8px; border-radius: 7px; margin-bottom: 4px; background: #121925;
  font-size: 12px; border: 1px solid transparent;
}
.member:hover { border-color: var(--accent); text-decoration: none; }
.member .mono { color: #c9d6e6; }
.member-meta { color: var(--muted); font-size: 11px; white-space: nowrap; }

/* controls */
.controls { display: flex; align-items: center; justify-content: space-between; margin: 14px 2px; flex-wrap: wrap; gap: 10px; }
.stat { color: var(--muted); }
.stat b { color: var(--ink); }
.t-gold { color: var(--gold); font-weight: 600; }
.t-decoy { color: var(--bad); font-weight: 600; }
.control-btns { display: flex; gap: 8px; }
button { font: inherit; }
.primary {
  background: linear-gradient(180deg, #2f7fd6, #2569b8); color: #fff; border: 0;
  padding: 9px 18px; border-radius: 9px; cursor: pointer; font-weight: 600;
}
.primary:disabled { opacity: .4; cursor: not-allowed; }
.primary:not(:disabled):hover { filter: brightness(1.08); }
.ghost {
  background: transparent; color: var(--ink); border: 1px solid var(--line);
  padding: 9px 16px; border-radius: 9px; cursor: pointer;
}
.ghost:hover { border-color: var(--accent); }

/* result card */
.result {
  display: none; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; margin: 6px 0 16px; position: relative;
}
.result.show { display: block; animation: rise .25s ease; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.result-close { position: absolute; top: 10px; right: 12px; background: none; border: 0; color: var(--muted); font-size: 22px; cursor: pointer; }
.result-head { display: flex; align-items: center; gap: 26px; flex-wrap: wrap; }
.metric { text-align: center; }
.metric-num { font-size: 30px; font-weight: 700; }
.metric-lab { font-size: 12px; color: var(--muted); }
.badge-r { margin-left: auto; padding: 6px 14px; border-radius: 999px; font-weight: 700; font-size: 13px; letter-spacing: .5px; }
.badge-r.pass { background: #13351f; color: var(--good); border: 1px solid #245c3a; }
.badge-r.fail { background: #36181c; color: var(--bad); border: 1px solid #5c2a30; }
.readout { margin: 14px 0 8px; color: #d7e2f0; }
.how { margin: 8px 0; }
.how summary { cursor: pointer; color: var(--accent); font-size: 14px; }
.how p { margin: 8px 0; }
.result-actions { display: flex; gap: 10px; align-items: center; margin-top: 12px; }

/* explainer */
.explainer { margin-top: 22px; border-top: 1px solid var(--line); padding-top: 16px; color: #c4d0e0; }
.explainer h2 { font-size: 16px; }

/* ad slot */
.ad-slot { min-height: 90px; display: flex; align-items: center; justify-content: center;
  border: 1px dashed var(--line); border-radius: var(--radius); color: var(--muted); margin: 16px 0; font-size: 12px; }
.ad-slot span { opacity: .5; }

/* loader */
.loader { position: fixed; inset: 0; background: var(--bg); display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 14px; z-index: 50; }
.spinner { width: 36px; height: 36px; border: 3px solid var(--line); border-top-color: var(--accent);
  border-radius: 50%; animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* modal */
.modal { position: fixed; inset: 0; background: #00000099; display: flex; align-items: center; justify-content: center; z-index: 60; padding: 16px; }
.modal.hidden { display: none; }
.modal-card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 22px; max-width: 480px; position: relative; max-height: 92vh; overflow-y: auto; }
.modal-card.wide { max-width: 820px; }
#solutionGraph { width: 100%; height: auto; aspect-ratio: 760 / 430; background: linear-gradient(180deg, #0e1420, #0b0e14);
  border: 1px solid var(--line); border-radius: 10px; margin: 6px 0 12px; }
.sol-edge { stroke: var(--gold); stroke-opacity: .5; vector-effect: non-scaling-stroke; }
.sol-concept { fill: #3a2f10; stroke: var(--gold); stroke-width: 1.5; }
.sol-concept.partial { stroke-dasharray: 4 3; }
.sol-sub.redundant { fill: #e0a85a; }
.sol-target { fill: #2a230f; stroke: var(--gold); stroke-width: 2; }
.sol-token { fill: #16202e; stroke: #2f3e54; }
.sol-lab { fill: var(--gold); font-size: 12.5px; font-weight: 700; text-anchor: middle; pointer-events: none; }
.sol-lab.dim { fill: #cdd9e8; font-weight: 600; }
.sol-sub { fill: #c9a94e; font-size: 9.5px; text-anchor: middle; pointer-events: none; }
.walkthrough { padding-left: 20px; } .walkthrough li { margin: 6px 0; color: #cdd9e8; }
.modal-card h2 { margin-top: 0; }
.modal-card ol { padding-left: 18px; } .modal-card li { margin: 7px 0; }
.modal-close { position: absolute; top: 10px; right: 14px; background: none; border: 0; color: var(--muted); font-size: 24px; cursor: pointer; }

/* footer */
.footer { color: var(--muted); font-size: 13px; text-align: center; padding: 22px 16px 40px; border-top: 1px solid var(--line); margin-top: 24px; }

@media (max-width: 820px) {
  .stage { grid-template-columns: 1fr; }
  #graph { aspect-ratio: 4 / 3; }
  .detail { min-height: auto; }
}
