/* QuantaLearn design system.
   Same identity as the project documents: IBM Plex Sans Condensed for UI,
   Source Serif 4 for prose, IBM Plex Mono for data. Indigo carries structure,
   vermilion carries signal. Semantic colours are separate from the accent. */

:root {
  --ground:#ECEEF3; --surface:#FBFCFD; --surface-2:#F1F4F9; --surface-3:#E5E9F1;
  --ink:#101320; --ink-2:#3D4557; --ink-3:#5F687C;
  --rule:#D2D8E4; --rule-2:#B6BFD0;
  --accent:#2F3FBF; --accent-2:#4A5AD8; --accent-soft:#E2E5FA; --on-accent:#FFFFFF;
  --signal:#BE4128; --signal-soft:#F7E2DC;
  --good:#1B6F52; --good-soft:#DCEFE7;
  --warn:#8A5A08; --warn-soft:#F7EAD2;
  --wire:#A9B3C6; --sphere:#DEE3EC;
  --shadow:0 1px 2px rgba(16,19,32,.05), 0 10px 28px -20px rgba(16,19,32,.4);
  --cw:56px; --rh:54px;
}
@media (prefers-color-scheme:dark) {
  :root:not([data-theme="light"]) {
    --ground:#0B0D14; --surface:#131722; --surface-2:#1A1F2C; --surface-3:#222839;
    --ink:#EDF0F7; --ink-2:#B2BACB; --ink-3:#7B8497;
    --rule:#252C3C; --rule-2:#394257;
    --accent:#8E99FF; --accent-2:#A6AEFF; --accent-soft:#1B2142; --on-accent:#0B0D14;
    --signal:#FF8E71; --signal-soft:#3B2018;
    --good:#4ECFA0; --good-soft:#12312A;
    --warn:#E5B45C; --warn-soft:#33290F;
    --wire:#4A5468; --sphere:#242B3B;
    --shadow:0 1px 2px rgba(0,0,0,.5), 0 12px 32px -22px rgba(0,0,0,.9);
  }
}
:root[data-theme="dark"] {
  --ground:#0B0D14; --surface:#131722; --surface-2:#1A1F2C; --surface-3:#222839;
  --ink:#EDF0F7; --ink-2:#B2BACB; --ink-3:#7B8497;
  --rule:#252C3C; --rule-2:#394257;
  --accent:#8E99FF; --accent-2:#A6AEFF; --accent-soft:#1B2142; --on-accent:#0B0D14;
  --signal:#FF8E71; --signal-soft:#3B2018;
  --good:#4ECFA0; --good-soft:#12312A;
  --warn:#E5B45C; --warn-soft:#33290F;
  --wire:#4A5468; --sphere:#242B3B;
  --shadow:0 1px 2px rgba(0,0,0,.5), 0 12px 32px -22px rgba(0,0,0,.9);
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin:0; padding:0; }
body {
  background: var(--ground); color: var(--ink);
  font-family:"IBM Plex Sans Condensed","Helvetica Neue",Arial,sans-serif;
  font-size:15px; line-height:1.55; -webkit-font-smoothing:antialiased;
  overflow-x:hidden;
}
.mono { font-family:"IBM Plex Mono",ui-monospace,SFMono-Regular,monospace; }
.prose { font-family:"Source Serif 4","Iowan Old Style",Georgia,serif; }
button { font-family:inherit; font-size:inherit; color:inherit; }
:focus-visible { outline:2px solid var(--accent); outline-offset:2px; border-radius:2px; }
@media (prefers-reduced-motion:reduce) { *{ animation:none!important; transition:none!important; } }
.sr-only {
  position:absolute; width:1px; height:1px; padding:0; margin:-1px;
  overflow:hidden; clip:rect(0 0 0 0); white-space:nowrap; border:0;
}

/* ---------------------------------------------------------------- chrome */
.app { max-width:1400px; margin:0 auto; padding:0 20px 80px; }
header.bar {
  display:flex; align-items:center; gap:20px; flex-wrap:wrap;
  padding:16px 0 12px; border-bottom:1px solid var(--rule); margin-bottom:18px;
}
.brand { display:flex; align-items:baseline; gap:9px; margin-right:auto; }
.brand .mark { font-family:"IBM Plex Mono",monospace; font-weight:600; font-size:19px;
  color:var(--accent); letter-spacing:-.02em; }
.brand .name { font-weight:700; font-size:19px; letter-spacing:-.01em; }
.brand .tag { font-family:"IBM Plex Mono",monospace; font-size:10px; letter-spacing:.13em;
  text-transform:uppercase; color:var(--ink-3); }
nav { display:flex; gap:2px; flex-wrap:wrap; }
nav button {
  background:none; border:0; padding:7px 12px; cursor:pointer; border-radius:2px;
  font-family:"IBM Plex Mono",monospace; font-size:11px; letter-spacing:.1em;
  text-transform:uppercase; color:var(--ink-3); transition:color .15s, background .15s;
}
nav button:hover { color:var(--ink); background:var(--surface-2); }
nav button[aria-current="true"] { color:var(--accent); background:var(--accent-soft); font-weight:600; }
.view { display:none; }
.view.on { display:block; }

h2.vh { font-size:26px; font-weight:700; letter-spacing:-.01em; margin:0 0 4px; text-wrap:balance; }
p.vd { color:var(--ink-2); margin:0 0 18px; max-width:74ch; font-size:15px; }
.sec-h {
  font-family:"IBM Plex Mono",monospace; font-size:10.5px; letter-spacing:.13em;
  text-transform:uppercase; color:var(--ink-3); font-weight:600;
  margin:30px 0 12px; padding-bottom:7px; border-bottom:1px solid var(--rule);
}
.sec-h:first-child { margin-top:0; }

/* ----------------------------------------------------------------- panel */
.panel { background:var(--surface); border:1px solid var(--rule); border-radius:3px; box-shadow:var(--shadow); }
.panel > h3 {
  margin:0; padding:9px 12px; border-bottom:1px solid var(--rule);
  font-family:"IBM Plex Mono",monospace; font-size:10.5px; letter-spacing:.12em;
  text-transform:uppercase; color:var(--ink-3); font-weight:600;
  display:flex; align-items:center; justify-content:space-between; gap:8px;
}

/* --------------------------------------------------------------- buttons */
select { max-width:100%; min-width:0; text-overflow:ellipsis; }
.toolbar, .tb-group, .scrub, .inspector, .chal-actions { min-width:0; }
.tb-group { flex-wrap:wrap; }
select, .btn, input[type="text"] {
  font-family:"IBM Plex Mono",monospace; font-size:11.5px;
  background:var(--surface); color:var(--ink); border:1px solid var(--rule-2);
  border-radius:2px; padding:5px 9px; cursor:pointer; transition:border-color .12s, color .12s;
}
select:hover, .btn:hover { border-color:var(--accent); color:var(--accent); }
.btn.primary { background:var(--accent); border-color:var(--accent); color:var(--on-accent); font-weight:600; }
.btn.primary:hover { background:var(--accent-2); border-color:var(--accent-2); color:var(--on-accent); }
.btn[disabled] { opacity:.45; cursor:not-allowed; }
.btn.tiny { padding:3px 7px; font-size:10.5px; }
.btn.ghost { background:transparent; border-color:transparent; color:var(--ink-3); }
.btn.ghost:hover { background:var(--surface); border-color:var(--rule-2); color:var(--accent); }
.spacer { flex:1; }

.pill {
  display:inline-block; font-family:"IBM Plex Mono",monospace; font-size:10px;
  letter-spacing:.07em; text-transform:uppercase; padding:2px 7px; border-radius:2px;
  font-weight:600; white-space:nowrap;
}
.pill.ok   { background:var(--good-soft);   color:var(--good); }
.pill.bad  { background:var(--signal-soft); color:var(--signal); }
.pill.warn { background:var(--warn-soft);   color:var(--warn); }
.pill.info { background:var(--accent-soft); color:var(--accent); }

/* ------------------------------------------------------------- workbench */
.wb { display:grid; grid-template-columns:98px minmax(0,1fr) 310px; gap:14px; align-items:start; }
.wb > * { min-width:0; }
@media (max-width:1220px) {
  .wb { grid-template-columns:98px minmax(0,1fr); }
  .wb > .tutor-panel { grid-column:1 / -1; }
  .tutor { max-height:none; }
}
@media (max-width:840px) { .wb { grid-template-columns:minmax(0,1fr); } }

.palette { padding:10px; display:grid; grid-template-columns:repeat(2,1fr); gap:6px; }
@media (max-width:840px) { .palette { grid-template-columns:repeat(6,1fr); } }
.chip {
  border:1px solid var(--rule-2); background:var(--surface-2); border-radius:2px;
  height:34px; display:flex; align-items:center; justify-content:center; cursor:grab;
  font-family:"IBM Plex Mono",monospace; font-size:12.5px; font-weight:600; color:var(--ink);
  user-select:none; transition:border-color .12s, background .12s, transform .08s;
}
.chip:hover { border-color:var(--accent); color:var(--accent); }
.chip:active { cursor:grabbing; transform:scale(.95); }
.chip.armed { background:var(--accent); border-color:var(--accent); color:var(--on-accent); }
.chip.two { grid-column:span 2; }
.chip[aria-disabled="true"] { opacity:.35; cursor:not-allowed; }
.palette-note { padding:0 12px 12px; font-size:11.5px; color:var(--ink-3); line-height:1.45; }

.toolbar {
  display:flex; flex-wrap:wrap; gap:8px; align-items:center;
  padding:10px 12px; border-bottom:1px solid var(--rule); background:var(--surface-2);
}
.tb-group { display:flex; align-items:center; gap:6px; }
.tb-label { font-family:"IBM Plex Mono",monospace; font-size:10px; letter-spacing:.1em;
  text-transform:uppercase; color:var(--ink-3); }

.canvas-scroll { overflow-x:auto; padding:20px 16px 8px; background:var(--surface); }
.grid-host { position:relative; }
.qlabel { position:absolute; left:0; font-family:"IBM Plex Mono",monospace; font-size:11.5px;
  color:var(--ink-2); transform:translateY(-50%); white-space:nowrap; }
.wire { position:absolute; height:1.5px; background:var(--wire); }
.cell { position:absolute; border-radius:2px; transition:background .1s, box-shadow .1s; }
.cell:hover { background:var(--accent-soft); }
.cell.over { background:var(--accent-soft); box-shadow:inset 0 0 0 1px var(--accent); }
.cell.kb { box-shadow:inset 0 0 0 2px var(--accent); }
.gbox {
  position:absolute; display:flex; align-items:center; justify-content:center;
  background:var(--surface); border:1.6px solid var(--accent); border-radius:2px;
  font-family:"IBM Plex Mono",monospace; font-size:13px; font-weight:600; color:var(--accent);
  cursor:pointer; user-select:none;
}
.gbox.sel { box-shadow:0 0 0 2px var(--accent), 0 0 0 4px var(--accent-soft); }
.gbox small { font-size:8.5px; font-weight:400; opacity:.8; margin-left:1px; }
.link { position:absolute; width:1.6px; background:var(--accent); }
.dot { position:absolute; border-radius:50%; background:var(--accent); cursor:pointer; }
.dot.sel { box-shadow:0 0 0 3px var(--accent-soft); }
.xor { position:absolute; border:1.6px solid var(--accent); border-radius:50%;
  background:var(--surface); cursor:pointer; }
.xor::before, .xor::after { content:""; position:absolute; background:var(--accent); }
.xor::before { left:2px; right:2px; top:50%; height:1.6px; transform:translateY(-50%); }
.xor::after { top:2px; bottom:2px; left:50%; width:1.6px; transform:translateX(-50%); }
.swapx { position:absolute; color:var(--accent); font-family:"IBM Plex Mono",monospace;
  font-size:18px; line-height:1; cursor:pointer; display:flex; align-items:center; justify-content:center; }
.measure { position:absolute; border:1.5px solid var(--rule-2); background:var(--surface-2);
  border-radius:2px; display:flex; align-items:center; justify-content:center; }
.colhead { position:absolute; font-family:"IBM Plex Mono",monospace; font-size:9.5px;
  color:var(--ink-3); text-align:center; }
.colhead.now { color:var(--signal); font-weight:600; }

.scrub { display:flex; align-items:center; gap:12px; padding:10px 14px;
  border-top:1px solid var(--rule); background:var(--surface-2); flex-wrap:wrap; }
input[type=range] { accent-color:var(--accent); flex:1; min-width:140px; }
.step-read { font-family:"IBM Plex Mono",monospace; font-size:11px; color:var(--ink-2);
  white-space:nowrap; font-variant-numeric:tabular-nums; }

.inspector { padding:10px 14px; border-top:1px solid var(--rule); display:flex; gap:12px;
  align-items:center; flex-wrap:wrap; font-family:"IBM Plex Mono",monospace; font-size:11.5px;
  color:var(--ink-2); min-height:44px; }
.inspector .k { color:var(--ink); font-weight:600; }

/* ----------------------------------------------------------------- tabs */
.tabs { display:flex; gap:2px; padding:8px 10px 0; border-bottom:1px solid var(--rule);
  flex-wrap:wrap; background:var(--surface-2); }
.tabs button {
  background:none; border:0; border-bottom:2px solid transparent; padding:6px 11px 8px;
  cursor:pointer; font-family:"IBM Plex Mono",monospace; font-size:11px; letter-spacing:.09em;
  text-transform:uppercase; color:var(--ink-3);
}
.tabs button:hover { color:var(--ink); }
.tabs button[aria-selected="true"] { color:var(--accent); border-bottom-color:var(--accent); font-weight:600; }
.tabpane { display:none; padding:14px; }
.tabpane.on { display:block; }
.legend { font-family:"IBM Plex Mono",monospace; font-size:10.5px; color:var(--ink-3);
  margin-top:12px; line-height:1.6; }
.legend b { color:var(--signal); font-weight:600; }

/* ------------------------------------------------------------ histogram */
.hist { display:grid; gap:6px; }
.hrow { display:grid; grid-template-columns:auto minmax(0,1fr) auto; gap:10px; align-items:center; }
.hrow .lbl { font-family:"IBM Plex Mono",monospace; font-size:12px; color:var(--ink-2); white-space:nowrap; }
.hbar { height:16px; background:var(--surface-3); border-radius:1px; overflow:hidden; position:relative; }
.hbar i { display:block; height:100%; background:var(--accent); border-radius:0 3px 3px 0; transition:width .3s ease; }
.hbar u { position:absolute; top:0; bottom:0; width:1.5px; background:var(--signal); text-decoration:none; }
.hrow .val { font-family:"IBM Plex Mono",monospace; font-size:11.5px; color:var(--ink-2);
  font-variant-numeric:tabular-nums; white-space:nowrap; }
.hrow.pred .lbl::before { content:"▸ "; color:var(--signal); }

/* ---------------------------------------------------------- statevector */
.svwrap { overflow-x:auto; }
table.sv { border-collapse:collapse; width:100%; min-width:540px;
  font-family:"IBM Plex Mono",monospace; font-size:11.5px; }
table.sv th { text-align:left; padding:6px 10px; border-bottom:1px solid var(--rule-2);
  font-size:9.5px; letter-spacing:.1em; text-transform:uppercase; color:var(--ink-3); font-weight:600; }
table.sv td { padding:5px 10px; border-bottom:1px solid var(--rule); color:var(--ink-2);
  font-variant-numeric:tabular-nums; white-space:nowrap; }
table.sv tr:last-child td { border-bottom:0; }
.swatch { display:inline-block; width:11px; height:11px; border-radius:2px; vertical-align:-1px;
  border:1px solid rgba(128,138,160,.45); margin-right:7px; }
.magbar { display:inline-block; height:8px; background:var(--accent); border-radius:1px; min-width:1px; }

/* --------------------------------------------------------------- bloch */
.blochs { display:flex; gap:16px; flex-wrap:wrap; }
.bloch-card { text-align:center; }
.bloch-card canvas { display:block; border-radius:2px; }
.bloch-cap { font-family:"IBM Plex Mono",monospace; font-size:10.5px; color:var(--ink-3);
  margin-top:4px; line-height:1.5; }
.bloch-cap b { display:block; color:var(--ink-2); font-weight:600; font-size:11.5px; }
.bloch-cap .mix { color:var(--signal); }

/* ---------------------------------------------------------------- code */
.codewrap { background:var(--surface-2); border:1px solid var(--rule); border-radius:2px; overflow-x:auto; }
pre { margin:0; padding:14px; font-family:"IBM Plex Mono",monospace; font-size:11.8px;
  line-height:1.62; color:var(--ink-2); white-space:pre; }
pre .cm { color:var(--ink-3); font-style:italic; }
pre .kw { color:var(--accent); font-weight:500; }
pre .st { color:var(--signal); }

/* --------------------------------------------------------------- tutor */
.tutor { padding:12px; display:grid; gap:9px; max-height:600px; overflow-y:auto; }
.tnote { border:1px solid var(--rule); border-left:2.5px solid var(--accent);
  border-radius:0 2px 2px 0; padding:9px 11px; background:var(--surface-2); }
.tnote.warn { border-left-color:var(--warn); background:var(--warn-soft); }
.tnote.error { border-left-color:var(--signal); background:var(--signal-soft); }
.tnote.good { border-left-color:var(--good); background:var(--good-soft); }
.tnote.reference { border-left-color:var(--ink-3); }
.tnote.coach { border-left-color:var(--signal); }
.tnote h4 { margin:0 0 3px; font-size:12.5px; font-weight:700; letter-spacing:-.005em; }
.tnote p { margin:0; font-size:12.5px; color:var(--ink-2); line-height:1.5; }
.tnote code, .tnote k { font-family:"IBM Plex Mono",monospace; font-size:11px;
  background:var(--surface-3); padding:0 4px; border-radius:2px; font-style:normal; }
.tnote .cite { display:block; margin-top:6px; font-family:"IBM Plex Mono",monospace;
  font-size:10px; color:var(--ink-3); line-height:1.45; }
.tnote .cite a { color:var(--accent); }
.tnote ol { margin:4px 0 0; padding-left:18px; font-size:12.5px; color:var(--ink-2); }
.tnote ol li { margin-bottom:2px; }
.tutor-foot { padding:0 12px 12px; font-size:11px; color:var(--ink-3); line-height:1.5; }
.verify-badge { display:flex; align-items:center; gap:6px; }

/* --------------------------------------------------------------- learn */
.lessons { display:grid; grid-template-columns:repeat(auto-fill,minmax(300px,1fr)); gap:14px; }
.lesson { background:var(--surface); border:1px solid var(--rule); border-radius:3px;
  padding:16px 18px 18px; box-shadow:var(--shadow); display:flex; flex-direction:column; }
.lesson.done { border-color:var(--good); }
.lesson .no { font-family:"IBM Plex Mono",monospace; font-size:10.5px; letter-spacing:.12em;
  color:var(--accent); font-weight:600; margin-bottom:6px; display:flex; justify-content:space-between; }
.lesson h3 { margin:0 0 6px; font-size:19px; font-weight:700; letter-spacing:-.01em; }
.lesson .prose { font-size:15px; color:var(--ink-2); margin:0 0 10px; line-height:1.6; }
.lesson .key { font-family:"IBM Plex Mono",monospace; font-size:11px; color:var(--ink-3);
  border-top:1px dashed var(--rule); padding-top:9px; margin-top:auto; line-height:1.55; }
.lesson .key b { color:var(--signal); font-weight:600; display:block; letter-spacing:.09em;
  text-transform:uppercase; font-size:10px; margin-bottom:2px; }
.lesson .acts { display:flex; gap:6px; margin-top:11px; flex-wrap:wrap; }
k { font-family:"IBM Plex Mono",monospace; font-size:.9em; background:var(--surface-2);
  border:1px solid var(--rule); border-radius:3px; padding:0 4px; font-style:normal; }

/* predict-then-run */
.predict { border:1px solid var(--rule-2); border-left:3px solid var(--signal);
  background:var(--surface); border-radius:0 3px 3px 0; padding:14px 16px; margin:14px 0; }
.predict .pt { font-family:"IBM Plex Mono",monospace; font-size:10px; letter-spacing:.11em;
  text-transform:uppercase; color:var(--signal); font-weight:600; margin-bottom:5px; }
.predict .q { font-size:15.5px; font-weight:600; margin-bottom:10px; }
.opts { display:flex; gap:6px; flex-wrap:wrap; }
.opt {
  text-align:left; background:var(--surface-2); border:1px solid var(--rule); border-radius:2px;
  padding:7px 12px; cursor:pointer; font-family:"IBM Plex Mono",monospace; font-size:12.5px;
  transition:border-color .12s, background .12s;
}
.opt:hover { border-color:var(--accent); }
.opt[aria-pressed="true"] {
  background:var(--accent-soft); border:2px solid var(--accent); color:var(--accent); font-weight:600;
  padding:6px 12px 6px 30px; position:relative;
}
.opt[aria-pressed="true"]::before {
  content:"✓"; position:absolute; left:10px; top:50%; transform:translateY(-50%);
  font-weight:700; font-size:11px;
}
.opt.right { background:var(--good-soft); border-color:var(--good); color:var(--good); font-weight:600;
  animation:optPop .32s cubic-bezier(.22,.9,.28,1) both; }
.opt.wrong { background:var(--signal-soft); border-color:var(--signal); color:var(--signal);
  animation:optShake .32s ease both; }
.verdict { margin-top:10px; font-size:14px; color:var(--ink-2); line-height:1.55;
  border-top:1px dashed var(--rule); padding-top:9px; display:none; }
.verdict.on { display:block; }
.verdict b { color:var(--ink); }

/* ----------------------------------------------------------- challenges */
.chal-grid { display:grid; grid-template-columns:repeat(auto-fill,minmax(310px,1fr)); gap:14px; }
.chal { background:var(--surface); border:1px solid var(--rule); border-radius:3px;
  padding:15px 17px 17px; box-shadow:var(--shadow); }
.chal.passed { border-color:var(--good); }
.chal h3 { margin:0 0 4px; font-size:17px; font-weight:700; display:flex; justify-content:space-between; gap:8px; align-items:baseline; }
.chal .goal { font-size:14px; color:var(--ink-2); margin:0 0 10px; }
.chal .status { font-family:"IBM Plex Mono",monospace; font-size:11px; padding:7px 9px;
  border-radius:2px; background:var(--surface-2); color:var(--ink-3); margin-bottom:10px; line-height:1.5; }
.chal .status.pass { background:var(--good-soft); color:var(--good); font-weight:600; }
.chal .status.fail { background:var(--signal-soft); color:var(--signal); }
.chal-actions { display:flex; gap:6px; flex-wrap:wrap; }
.golf { font-family:"IBM Plex Mono",monospace; font-size:10.5px; color:var(--ink-3);
  margin-top:9px; border-top:1px dashed var(--rule); padding-top:8px; }
.golf b { color:var(--accent); font-weight:600; }
.golf .best { color:var(--good); }

/* ---------------------------------------------------------------- quiz */
.quiz { display:grid; gap:12px; max-width:780px; }
.q { background:var(--surface); border:1px solid var(--rule); border-radius:3px;
  padding:15px 17px; box-shadow:var(--shadow); }
.q .qt { font-weight:600; font-size:15.5px; margin-bottom:9px; }
.q .opts { display:grid; gap:5px; }
.q .opt { font-family:inherit; font-size:14px; }
.q .why { margin-top:9px; font-size:13.5px; color:var(--ink-2); display:none;
  border-top:1px dashed var(--rule); padding-top:9px; line-height:1.55; }
.q.done .why { display:block; }
.q .fix { display:block; margin-top:6px; color:var(--signal); font-size:13px; }

/* ------------------------------------------------------------- mastery */
.mastery { display:grid; gap:8px; max-width:600px; }
.mrow { display:grid; grid-template-columns:160px minmax(0,1fr) 42px; gap:10px;
  align-items:center; font-size:13.5px; }
.mrow.locked { opacity:.5; }
.mrow .mbar { height:9px; background:var(--surface-3); border-radius:5px; overflow:hidden; }
.mrow .mbar i { display:block; height:100%; background:var(--accent); border-radius:5px; transition:width .4s ease; }
.mrow .mv { font-family:"IBM Plex Mono",monospace; font-size:11px; color:var(--ink-3);
  text-align:right; font-variant-numeric:tabular-nums; }
.rec { border:1px solid var(--rule); border-left:3px solid var(--signal); background:var(--surface);
  padding:14px 16px; border-radius:0 3px 3px 0; margin:16px 0; max-width:780px; }
.rec .rt { font-family:"IBM Plex Mono",monospace; font-size:10px; letter-spacing:.11em;
  text-transform:uppercase; color:var(--signal); font-weight:600; margin-bottom:4px; }
.rec p { margin:0 0 10px; font-size:15px; color:var(--ink-2); }

/* --------------------------------------------------------- concept map */
.mapwrap { overflow-x:auto; background:var(--surface); border:1px solid var(--rule);
  border-radius:3px; box-shadow:var(--shadow); padding:16px; }
.mapwrap svg { display:block; }
.node rect { cursor:pointer; }
.node text { pointer-events:none; }

/* ---------------------------------------------------------------- class */
.stats { display:grid; grid-template-columns:repeat(auto-fit,minmax(160px,1fr)); gap:12px; margin-bottom:18px; }
.stat { background:var(--surface); border:1px solid var(--rule); border-radius:3px;
  padding:13px 15px; box-shadow:var(--shadow); }
.stat .sl { font-family:"IBM Plex Mono",monospace; font-size:10px; letter-spacing:.11em;
  text-transform:uppercase; color:var(--ink-3); }
.stat .sv { font-size:26px; font-weight:700; letter-spacing:-.02em;
  font-variant-numeric:tabular-nums; margin-top:2px; }
.stat .sn { font-size:12.5px; color:var(--ink-2); }
.stat.alert .sv { color:var(--signal); }
.heat-scroll { overflow-x:auto; background:var(--surface); border:1px solid var(--rule);
  border-radius:3px; box-shadow:var(--shadow); padding:16px; }
table.heat { border-collapse:collapse; font-size:12px; min-width:720px; }
table.heat th { padding:6px 8px; font-family:"IBM Plex Mono",monospace; font-size:9.5px;
  letter-spacing:.08em; text-transform:uppercase; color:var(--ink-3); font-weight:600;
  text-align:center; vertical-align:bottom; }
table.heat th.stu { text-align:left; min-width:150px; }
table.heat td { padding:2px; }
table.heat td.stu { font-size:13px; color:var(--ink-2); padding-right:12px; white-space:nowrap; cursor:pointer; }
table.heat tr.sel td.stu { color:var(--accent); font-weight:700; }
.hc { width:46px; height:24px; border-radius:2px; display:flex; align-items:center;
  justify-content:center; font-family:"IBM Plex Mono",monospace; font-size:10px;
  font-variant-numeric:tabular-nums; }
.flagrow td.stu { color:var(--signal); font-weight:600; }
.heat-key { display:flex; gap:14px; align-items:center; flex-wrap:wrap; margin-top:14px;
  font-family:"IBM Plex Mono",monospace; font-size:10.5px; color:var(--ink-3); }
.heat-key span { display:flex; align-items:center; gap:5px; }
.heat-key i { width:14px; height:14px; border-radius:2px; display:block; }
.drill { margin-top:16px; }

/* ---------------------------------------------------------------- about */
.stack-list { display:grid; gap:7px; max-width:940px; }
.layer { display:grid; grid-template-columns:128px minmax(0,1fr); gap:16px; align-items:center;
  border:1px solid var(--rule); background:var(--surface); border-radius:3px; padding:12px 15px; }
.layer .ln { font-family:"IBM Plex Mono",monospace; font-size:10.5px; letter-spacing:.1em;
  text-transform:uppercase; color:var(--accent); font-weight:600; }
.layer .ld { font-size:14.5px; color:var(--ink-2); }
.layer.key { border-color:var(--accent); background:var(--accent-soft); }
@media (max-width:620px) { .layer { grid-template-columns:1fr; gap:4px; } }
.tablewrap { overflow-x:auto; background:var(--surface); border:1px solid var(--rule);
  border-radius:3px; box-shadow:var(--shadow); margin:16px 0; }
table.dm { border-collapse:collapse; width:100%; min-width:640px; font-size:14px; }
table.dm th { text-align:left; padding:10px 13px; background:var(--surface-2);
  font-family:"IBM Plex Mono",monospace; font-size:9.5px; letter-spacing:.1em;
  text-transform:uppercase; color:var(--ink-3); font-weight:600; border-bottom:1px solid var(--rule-2); }
table.dm td { padding:10px 13px; border-bottom:1px solid var(--rule); vertical-align:top; color:var(--ink-2); }
table.dm tr:last-child td { border-bottom:0; }
table.dm td.d { color:var(--ink); font-weight:600; }
.note { border:1px solid var(--rule); border-left:3px solid var(--signal); background:var(--surface);
  padding:13px 16px; border-radius:0 3px 3px 0; margin:16px 0; max-width:940px; }
.note.blue { border-left-color:var(--accent); }
.note .nt { font-family:"IBM Plex Mono",monospace; font-size:10px; letter-spacing:.11em;
  text-transform:uppercase; color:var(--signal); font-weight:600; margin-bottom:4px; }
.note.blue .nt { color:var(--accent); }
.note p { margin:0; font-size:14.5px; color:var(--ink-2); line-height:1.6; }
.note p + p { margin-top:8px; }

/* --------------------------------------------------------------- toast */
.toast {
  position:fixed; left:50%; bottom:24px; transform:translateX(-50%);
  background:var(--ink); color:var(--ground); padding:10px 16px; border-radius:3px;
  font-family:"IBM Plex Mono",monospace; font-size:12px; box-shadow:var(--shadow);
  z-index:50; opacity:0; pointer-events:none; transition:opacity .18s;
}
.toast.on { opacity:1; }

/* ------------------------------------------- backend status and run notes */
.runbar { display:flex; align-items:center; gap:10px; margin-bottom:12px; flex-wrap:wrap; }
.runbar-note { font-size:11.5px; color:var(--ink-3); line-height:1.5; }
.pill.live { background:var(--good-soft); color:var(--good); }
.pill.localrun { background:var(--surface-3); color:var(--ink-2); }
.pill.pending { background:var(--warn-soft); color:var(--warn); }

.run-notes { display:grid; gap:7px; margin-top:12px; }
.run-note { font-size:11.5px; line-height:1.55; padding:8px 11px; border-radius:3px;
  border-left:2px solid var(--warn); background:var(--warn-soft); color:var(--ink-1); }
.run-note.error { border-left-color:var(--signal); background:var(--signal-soft); }
.run-note code { font-family:"IBM Plex Mono",monospace; font-size:11px; }

/* An outcome the state vector says is impossible. Shown, never hidden. */
.hrow.impossible .lbl { color:var(--signal); }
.hrow.impossible .lbl::after { content:" ✗"; }
.hrow.impossible .hbar i { background:var(--signal); }

/* ------------------------------------------------------------- auth control */
.auth-control { position:relative; display:flex; align-items:center; }

.auth-chip { display:flex; align-items:center; gap:8px; }
.auth-name { font-size:12px; font-weight:600; color:var(--ink-1); white-space:nowrap; }
.pill.role-student   { background:var(--surface-3); color:var(--ink-2); }
.pill.role-instructor{ background:var(--accent-soft); color:var(--accent); }
.pill.role-admin     { background:var(--warn-soft);  color:var(--warn); }

.auth-pop {
  position:absolute; top:calc(100% + 8px); right:0; z-index:40;
  width:260px; padding:14px; border-radius:6px;
  background:var(--surface-1); border:1px solid var(--rule-2);
  box-shadow:0 10px 28px rgba(0,0,0,.18);
}
.auth-tabs { display:flex; gap:4px; margin-bottom:12px; border-bottom:1px solid var(--rule-2); }
.auth-tab { flex:1; padding:6px 4px; background:none; border:0; border-bottom:2px solid transparent;
  font-family:"IBM Plex Sans Condensed",sans-serif; font-size:12px; font-weight:600;
  color:var(--ink-3); cursor:pointer; }
.auth-tab.on { color:var(--accent); border-bottom-color:var(--accent); }
.auth-tab:hover { color:var(--ink-1); }

.auth-form { display:grid; gap:10px; }
.auth-field { display:grid; gap:4px; font-size:11px; color:var(--ink-2); }
.auth-field input {
  padding:7px 9px; border:1px solid var(--rule-2); border-radius:4px;
  background:var(--surface-2); color:var(--ink-1); font-size:13px;
  font-family:"IBM Plex Sans Condensed",sans-serif;
}
.auth-field input:focus { outline:2px solid var(--accent); outline-offset:1px; }

.auth-hint { font-size:10.5px; color:var(--ink-3); line-height:1.5; }
.auth-error { font-size:11.5px; color:var(--signal); background:var(--signal-soft);
  padding:7px 9px; border-radius:4px; line-height:1.5; }
.auth-actions { display:flex; justify-content:flex-end; gap:8px; margin-top:2px; }

/* --------------------------------------------------------------- code IDE */
.ide-toolbar { display:flex; align-items:center; gap:8px; flex-wrap:wrap; margin-bottom:10px; position:relative; }
.ide-toolbar .spacer { flex:1; }

.ide-editor {
  height:320px; border:1px solid var(--rule); border-radius:2px; overflow:hidden;
  background:var(--surface-2);
}
/* Monaco paints its own background; this only shows before it mounts, or
   never at all if the fallback textarea below is what actually renders. */
.ide-fallback {
  width:100%; height:320px; resize:vertical; box-sizing:border-box;
  padding:10px 12px; border:0; outline:none;
  background:var(--surface-2); color:var(--ink-1);
  font-family:"IBM Plex Mono",monospace; font-size:12.5px; line-height:1.6;
  tab-size:4;
}

.ide-errors { display:grid; gap:6px; margin-top:10px; }
.ide-error-line {
  font-size:11.5px; line-height:1.55; padding:8px 11px; border-radius:3px;
  border-left:2px solid var(--signal); background:var(--signal-soft); color:var(--ink-1);
}
.ide-error-line .ln { font-family:"IBM Plex Mono",monospace; font-weight:600; margin-right:6px; }
.ide-error-line .hint { display:block; margin-top:3px; color:var(--ink-2); }

.ide-ai-row { display:flex; gap:8px; margin-top:10px; flex-wrap:wrap; }
.ide-ai-response {
  margin-top:10px; padding:10px 12px; border-radius:3px;
  background:var(--accent-soft); border-left:2px solid var(--accent);
  font-size:12.5px; line-height:1.6; white-space:pre-wrap;
}
.ide-ai-response .ide-ai-src { display:block; font-family:"IBM Plex Mono",monospace;
  font-size:10px; letter-spacing:.06em; text-transform:uppercase; color:var(--accent); margin-bottom:6px; }

.ide-output {
  margin-top:10px; max-height:260px; overflow:auto; padding:10px 12px;
  background:var(--ink-1); color:var(--surface-1); border-radius:3px;
  font-family:"IBM Plex Mono",monospace; font-size:12px; line-height:1.55;
  white-space:pre-wrap; word-break:break-word;
}
.ide-output.err { border-left:3px solid var(--signal); }

/* Save/Load popovers — same recipe as .auth-pop, kept separate so the two
   features stay independently editable. */
.ide-pop {
  position:absolute; top:calc(100% + 8px); left:0; z-index:40;
  width:300px; max-width:90vw; padding:14px; border-radius:6px;
  background:var(--surface-1); border:1px solid var(--rule-2);
  box-shadow:0 10px 28px rgba(0,0,0,.18);
}
.ide-pop h4 { margin:0 0 10px; font-size:12px; letter-spacing:.03em; }
.ide-pop .auth-field { display:grid; gap:4px; font-size:11px; color:var(--ink-2); margin-bottom:10px; }
.ide-pop .auth-field input {
  padding:7px 9px; border:1px solid var(--rule-2); border-radius:4px;
  background:var(--surface-2); color:var(--ink-1); font-size:13px;
  font-family:"IBM Plex Sans Condensed",sans-serif;
}
.ide-pop .auth-actions { display:flex; justify-content:flex-end; gap:8px; margin-top:2px; }
.ide-pop .auth-error { font-size:11.5px; color:var(--signal); background:var(--signal-soft);
  padding:7px 9px; border-radius:4px; line-height:1.5; margin-bottom:10px; }

.ide-saved-list { display:grid; gap:2px; max-height:240px; overflow-y:auto; margin:-2px; }
.ide-saved-row {
  display:flex; align-items:center; gap:8px; padding:7px 8px; border-radius:4px;
  cursor:pointer; border:1px solid transparent;
}
.ide-saved-row:hover { background:var(--surface-3); }
.ide-saved-row .name { flex:1; font-size:12.5px; font-weight:600; color:var(--ink-1);
  overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.ide-saved-row .meta { font-size:10.5px; color:var(--ink-3); font-family:"IBM Plex Mono",monospace; }
.ide-saved-empty { font-size:11.5px; color:var(--ink-3); padding:6px 2px; line-height:1.5; }
