:root {
  --radius: 10px;
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  font-size: 14px;
  color: var(--ink);
}

/* ---------- Themes: light (default), gray, dark ---------- */
:root, :root[data-theme="light"] {
  color-scheme: light;
  --bg: #f4f5f8; --surface: #ffffff; --surface-2: #f3f4f7; --field: #ffffff;
  --ink: #17202c; --ink-2: #3b4757; --muted: #67727f; --line: #e2e5ea; --line-2: #cbd0d8;
  --accent: #3b3fb8; --accent-soft: #eaebfb; --on-accent: #ffffff; --danger: #c92f25; --danger-soft: #fdeeed;
  --warn: #975b08; --warn-soft: #fdf4e3; --good: #1f9d55; --good-soft: #e7f7ee; --good-ink: #126b3a;
  --canvas: #fafbfc; --wire: #98a2ae; --code-bg: rgba(0,0,0,.05);
  --s1: #2a78d6; --s2: #eb6834; --grid: #e8ebef;
  --g-h: #c8324b; --g-pauli: #2467c0; --g-phase: #6250d6; --g-rot: #a8660b; --g-meas: #4d5b6a; --g-multi: #3b4757;
  --code-surface: #fbfbfd; --tk-k: #3b3fb8; --tk-n: #a8520b; --tk-c: #6f7a87; --line-cur: #fff1d6; --line-sel: #eaebfb;
}
:root[data-theme="gray"] {
  color-scheme: light;
  --bg: #b9bec5; --surface: #d3d7dc; --surface-2: #c6cbd1; --field: #e4e7ea;
  --ink: #171d25; --ink-2: #2d3640; --muted: #4f5966; --line: #a8afb8; --line-2: #929aa5;
  --accent: #2f33a3; --accent-soft: #c6c8ee; --on-accent: #ffffff; --danger: #b52a21; --danger-soft: #edd3d0;
  --warn: #8a5300; --warn-soft: #e9dcc0; --good: #17804a; --good-soft: #c5e0d0; --good-ink: #0e5a30;
  --canvas: #cdd1d6; --wire: #5f6975; --code-bg: rgba(0,0,0,.08);
  --s1: #1f64b8; --s2: #c8501f; --grid: #b5bbc3;
  --g-h: #b02a42; --g-pauli: #1f5aaa; --g-phase: #5645c0; --g-rot: #8a5300; --g-meas: #3f4b58; --g-multi: #2d3640;
  --code-surface: #dcdfe3; --tk-k: #2f33a3; --tk-n: #8a4300; --tk-c: #4f5966; --line-cur: #efdfb8; --line-sel: #c6c8ee;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #12161b; --surface: #1c2128; --surface-2: #262c35; --field: #14181d;
  --ink: #dde3ea; --ink-2: #b4bdc8; --muted: #8b96a4; --line: #333b46; --line-2: #45505d;
  --accent: #8d90ff; --accent-soft: #272a55; --on-accent: #10121f; --danger: #ff6b61; --danger-soft: #3a1f1d;
  --warn: #e3a64c; --warn-soft: #33290f; --good: #3ccf7f; --good-soft: #17301f; --good-ink: #74e0a2;
  --canvas: #161a1f; --wire: #5e6a78; --code-bg: rgba(255,255,255,.08);
  --s1: #3987e5; --s2: #d95926; --grid: #2a313a;
  --g-h: #d9536b; --g-pauli: #4d8fe6; --g-phase: #8d7ff0; --g-rot: #d6922a; --g-meas: #8c9aa9; --g-multi: #b4bdc8;
  --code-surface: #161a1f; --tk-k: #a9acff; --tk-n: #e3a64c; --tk-c: #8b96a4; --line-cur: #3c3216; --line-sel: #272a55;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { display: flex; flex-direction: column; background: var(--bg); overflow: hidden; }
button, select, input, textarea { font: inherit; color: inherit; }
kbd { font: 12px Consolas, monospace; background: var(--code-bg); padding: 0 4px; border-radius: 3px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }

/* ---------- Top bar ---------- */
.topbar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap; row-gap: 6px;
  padding: 8px 14px; background: var(--surface); border-bottom: 1px solid var(--line); flex: none;
}
.topbar .brand { display: flex; align-items: center; gap: 9px; background: none; border: none; padding: 0 8px 0 0; font-size: 16px; height: auto; }
.topbar .brand:hover { background: none; }
.logo { width: 28px; height: 28px; display: block; }
.tb-group { display: flex; align-items: center; gap: 4px; padding-left: 8px; border-left: 1px solid var(--line); }
.tb-spacer { flex: 1; }
#sel-examples { max-width: 130px; }
#sel-export { max-width: 175px; }
.topbar button, .topbar select, #toolbar button, #stepbar button {
  height: 30px; padding: 0 10px; border: 1px solid var(--line); border-radius: 7px;
  background: var(--surface); cursor: pointer; white-space: nowrap;
}
.topbar select { padding: 0 4px; }
.topbar button:hover:not(:disabled), .topbar select:hover, #toolbar button:hover:not(:disabled), #stepbar button:hover:not(:disabled) { background: var(--surface-2); border-color: var(--line-2); }
#toolbar button:disabled, #stepbar button:disabled { opacity: .4; cursor: default; }
button.icon { padding: 0 !important; display: inline-grid; place-items: center; }
button.icon svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
#toolbar button.icon.sm, #stepbar button.icon.sm { width: 30px; height: 28px; font-size: 12px; }
#toolbar button.sm { height: 28px; }
#btn-class.on { background: var(--accent-soft); border-color: var(--accent); }
#nav { display: flex; gap: 2px; }
.topbar #nav button { border: none; background: none; color: var(--muted); font-weight: 500; }
.topbar #nav button:hover { color: var(--ink); background: var(--surface-2); }
.topbar #nav button.on { color: var(--accent); background: var(--accent-soft); font-weight: 600; }
body.on-home .work-only { display: none !important; }

/* ---------- Home ---------- */
#home { display: none; flex: 1; min-height: 0; overflow-y: auto; }
body.on-home #home { display: block; }
body.on-home #work { display: none; }
.home-in { max-width: 1000px; margin: 0 auto; padding: 44px 24px 40px; }
.hero h1 { font-size: 38px; line-height: 1.15; margin: 0 0 14px; letter-spacing: -.5px; }
.hero p { font-size: 17px; line-height: 1.5; color: var(--ink-2); max-width: 680px; margin: 0 0 22px; }
.hero-btns { display: flex; gap: 10px; flex-wrap: wrap; }
.big { height: 44px; padding: 0 20px; border-radius: 9px; border: 1px solid var(--line-2); background: var(--surface); cursor: pointer; font-weight: 600; font-size: 15px; }
.big:hover { background: var(--surface-2); }
.big.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.big.primary:hover { filter: brightness(1.1); background: var(--accent); }
.feats { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 14px; margin: 34px 0; }
.feat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; }
.feat h3 { margin: 0 0 6px; font-size: 15px; }
.feat p { margin: 0; color: var(--ink-2); line-height: 1.45; }
.how { margin-bottom: 34px; }
.how h2 { margin: 0; font-size: 22px; }
.how h3 { margin: 20px 0 6px; font-size: 15px; }
.how p { line-height: 1.5; color: var(--ink-2); margin: 6px 0; max-width: 820px; }
.how-steps { list-style: none; counter-reset: how; padding: 0; margin: 12px 0 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 12px; }
.how-steps li { counter-increment: how; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px 14px 52px; position: relative; line-height: 1.45; }
.how-steps li::before { content: counter(how); position: absolute; left: 14px; top: 14px; width: 26px; height: 26px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font-weight: 700; font-size: 13px; }
.how-steps b { display: block; margin-bottom: 3px; }
.how-steps span { color: var(--ink-2); font-size: 13.5px; }
.path-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.path-head h2 { margin: 0; font-size: 22px; }
.path-head span { color: var(--muted); }
.progress { height: 6px; border-radius: 3px; background: var(--line); margin: 10px 0 18px; overflow: hidden; }
.progress i { display: block; height: 100%; background: var(--accent); }
.path { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 18px; }
.path-level h3 { margin: 0 0 8px; font-size: 13px; color: var(--muted); font-weight: 600; }
.path-item {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; padding: 10px 12px; margin-bottom: 6px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 8px; cursor: pointer;
}
.path-item:hover { border-color: var(--accent); }
.path-item .num { width: 24px; height: 24px; flex: none; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); font-size: 12px; font-weight: 600; }
.path-item.finished .num { background: var(--good-soft); color: var(--good-ink); }

/* ---------- Work layout: guide | circuit and results | code ---------- */
#work { flex: 1; display: flex; min-height: 0; gap: 10px; padding: 10px; }
#side { width: 290px; flex: none; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); display: flex; flex-direction: column; overflow: hidden; }
#center { flex: 1; min-width: 0; display: flex; flex-direction: column; }
#build-card { flex: 0 1 auto; min-height: 150px; max-height: 62%; display: flex; flex-direction: column; overflow: hidden; }
#code-panel { width: 370px; flex: none; display: flex; flex-direction: column; overflow: hidden; }
#stage { flex: 1 1 auto; min-height: 60px; overflow: auto; background: var(--canvas); border-top: 1px solid var(--line); }
#canvas { display: block; touch-action: none; user-select: none; }
#splitter { height: 10px; flex: none; cursor: ns-resize; position: relative; }
#splitter::after { content: ""; position: absolute; left: 50%; top: 4px; width: 36px; height: 3px; margin-left: -18px; border-radius: 2px; background: var(--line-2); }
#splitter:hover::after { background: var(--accent); }
#dock { flex: 1 1 0; min-height: 130px; display: flex; flex-direction: column; overflow: hidden; }
#side-body { flex: 1; min-height: 0; overflow-y: auto; padding: 14px; line-height: 1.5; }
.statusbar {
  display: flex; justify-content: space-between; gap: 16px; padding: 4px 14px; flex: none;
  background: var(--surface); border-top: 1px solid var(--line); font-size: 12.5px; color: var(--muted);
}
body.on-home .statusbar { display: none; }
#status-msg.warn { color: var(--warn); }
#status-msg.error { color: var(--danger); font-weight: 600; }
#status-info { white-space: nowrap; font-variant-numeric: tabular-nums; }

/* ---------- Gate palette: tinted tiles in labelled groups ---------- */
#palette { display: flex; flex-wrap: wrap; gap: 6px 16px; padding: 10px 12px 6px; }
.pal-group { display: flex; flex-direction: column; gap: 3px; }
.pal-cat { font-size: 11.5px; color: var(--muted); }
.pal-grid { display: flex; gap: 4px; }
.fam-h { --fam: var(--g-h); } .fam-pauli { --fam: var(--g-pauli); } .fam-phase { --fam: var(--g-phase); }
.fam-rot { --fam: var(--g-rot); } .fam-meas { --fam: var(--g-meas); } .fam-multi { --fam: var(--g-multi); }
.pal-item {
  display: grid; place-items: center; min-width: 36px; height: 36px; padding: 0 7px; border-radius: 8px; font-weight: 700; font-size: 13.5px;
  cursor: grab; touch-action: none; user-select: none; color: var(--fam);
  background: color-mix(in srgb, var(--fam) 11%, var(--surface)); border: 1.5px solid color-mix(in srgb, var(--fam) 42%, var(--surface));
}
.pal-item:hover { background: var(--fam); color: var(--surface); }
.pal-item.wide { font-size: 12px; }
#gate-hint { margin: 2px 12px 8px; padding: 5px 10px; border-radius: 7px; background: var(--surface-2); font-size: 12.5px; color: var(--ink-2); min-height: 28px; line-height: 1.4; }
#toolbar { display: flex; align-items: center; gap: 4px; padding: 0 12px 8px; flex-wrap: wrap; }
#toolbar .lbl, #stepbar .lbl { color: var(--muted); margin-right: 3px; }
#toolbar .sep { width: 1px; height: 20px; background: var(--line); margin: 0 6px; }
#q-count { min-width: 20px; text-align: center; }
#stats { color: var(--muted); font-size: 12.5px; font-variant-numeric: tabular-nums; }
#drag-ghost {
  position: fixed; z-index: 50; pointer-events: none; min-width: 42px; height: 42px; padding: 0 8px; border-radius: 7px; display: grid; place-items: center;
  background: var(--fam); color: var(--surface); font-weight: 700; opacity: .92; transform: translate(-50%, -50%);
}
#drag-ghost[hidden] { display: none; }

/* ---------- Circuit ---------- */
.wire { stroke: var(--wire); stroke-width: 1.6; }
.qlabel { font: 600 13px "Segoe UI", system-ui, sans-serif; fill: var(--ink); }
.qket { font: 13px "Cambria Math", Cambria, serif; fill: var(--muted); }
.ruler { font: 11px "Segoe UI", system-ui, sans-serif; fill: var(--muted); text-anchor: middle; cursor: pointer; }
.ruler-hit { fill: transparent; cursor: pointer; }
.ruler-hit:hover { fill: var(--accent-soft); }
.playhead { stroke: var(--s2); stroke-width: 2; stroke-dasharray: 5 4; pointer-events: none; }
.drop-cell { fill: var(--accent-soft); stroke: var(--accent); stroke-width: 1.5; stroke-dasharray: 4 3; pointer-events: none; }
.op { cursor: move; }
.op.later { opacity: .28; }
.op .box { stroke: none; }
.op .box.fam-h { fill: var(--g-h); } .op .box.fam-pauli { fill: var(--g-pauli); } .op .box.fam-phase { fill: var(--g-phase); }
.op .box.fam-rot { fill: var(--g-rot); } .op .box.fam-meas { fill: var(--g-meas); }
.op .lab { font: 700 15px "Segoe UI", system-ui, sans-serif; fill: #fff; text-anchor: middle; pointer-events: none; }
:root[data-theme="dark"] .op .lab { fill: #10141a; }
:root[data-theme="dark"] .op .meter { stroke: #10141a; }
.op .lab.small { font-size: 10px; font-weight: 500; }
.op .link { stroke: var(--ink-2); stroke-width: 2; }
.op .dot { fill: var(--ink-2); cursor: ns-resize; }
.op .ring { fill: var(--canvas); stroke: var(--ink-2); stroke-width: 2; cursor: ns-resize; }
.op .plus { stroke: var(--ink-2); stroke-width: 2; pointer-events: none; }
.op .cross { stroke: var(--ink-2); stroke-width: 3; stroke-linecap: round; pointer-events: none; }
.op .hit { fill: transparent; }
.op .barrier { stroke: var(--ink-2); stroke-width: 2.5; stroke-dasharray: 6 5; pointer-events: none; }
.op.sel .barrier { stroke: var(--accent); }
.op .meter { fill: none; stroke: #fff; stroke-width: 1.8; stroke-linecap: round; pointer-events: none; }
.op.sel .box { stroke: var(--accent); stroke-width: 3; paint-order: stroke; }
.op.sel .link, .op.sel .ring, .op.sel .plus, .op.sel .cross { stroke: var(--accent); }
.op.sel .dot { fill: var(--accent); }

/* ---------- Code panel ---------- */
.code-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 10px; border-bottom: 1px solid var(--line); flex: none; }
.seg { display: inline-flex; background: var(--surface-2); border-radius: 8px; padding: 2px; }
.seg button { border: none; background: none; padding: 4px 10px; border-radius: 6px; cursor: pointer; color: var(--muted); font-size: 13px; }
.seg button.on { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: 0 1px 2px rgba(0,0,0,.12); }
.check { display: flex; align-items: center; gap: 5px; font-size: 12.5px; color: var(--ink-2); cursor: pointer; white-space: nowrap; }
.check input { accent-color: var(--accent); margin: 0; }
.code-wrap { position: relative; flex: 1; min-height: 160px; background: var(--code-surface); overflow: hidden; }
#code-paint, #code-text {
  position: absolute; inset: 0; margin: 0; padding: 8px 0; font: 12.5px/20px Consolas, "Courier New", monospace; white-space: pre; overflow: auto; tab-size: 2;
}
#code-paint { pointer-events: none; overflow: hidden; }
#code-text { width: 100%; height: 100%; border: none; background: transparent; resize: none; outline: none; color: transparent; caret-color: var(--ink); padding-left: 42px; }
#code-text::selection { background: color-mix(in srgb, var(--accent) 30%, transparent); }
.cl { display: block; height: 20px; padding-left: 42px; padding-right: 14px; position: relative; width: max-content; min-width: 100%; color: var(--ink); }
.cl .ln { position: absolute; left: 0; width: 32px; text-align: right; color: var(--muted); opacity: .6; user-select: none; }
.cl-pad { height: 20px; }
.cl.sel { background: var(--line-sel); }
.cl.cur { background: var(--line-cur); box-shadow: inset 3px 0 0 var(--s2); }
.cl.later { opacity: .38; }
.cl.bad { background: var(--danger-soft); box-shadow: inset 3px 0 0 var(--danger); }
.cl.fresh { animation: lineflash 1.6s ease-out; }
@keyframes lineflash { 0% { background: color-mix(in srgb, var(--good) 38%, transparent); } 100% { background: transparent; } }
.tk-k { color: var(--tk-k); } .tk-n { color: var(--tk-n); } .tk-c { color: var(--tk-c); }
#code-status { padding: 6px 12px; font-size: 12px; color: var(--muted); border-top: 1px solid var(--line); line-height: 1.35; flex: none; }
#code-status.bad { color: var(--danger); background: var(--danger-soft); font-weight: 600; }
.code-foot { display: flex; gap: 4px; padding: 8px 10px; border-top: 1px solid var(--line); flex: none; }
.code-foot button { height: 28px; padding: 0 10px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); cursor: pointer; font-size: 12.5px; }
.code-foot button:hover { background: var(--surface-2); border-color: var(--line-2); }

/* ---------- Results ---------- */
#stepbar { display: flex; align-items: center; gap: 3px; padding: 6px 12px; flex-wrap: wrap; flex: none; border-bottom: 1px solid var(--line); }
#st-range { flex: 1; min-width: 70px; margin: 0 8px; accent-color: var(--accent); }
#st-text { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; font-size: 12.5px; }
#dirac-line { display: block; font: 15px "Cambria Math", Cambria, Consolas, serif; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 6px 14px 0; flex: none; min-height: 25px; }
#tabs { display: flex; flex-wrap: wrap; gap: 2px; padding: 4px 8px 0; border-bottom: 1px solid var(--line); flex: none; }
#tabs button {
  border: 1px solid transparent; border-bottom: none; background: none; padding: 6px 11px; cursor: pointer;
  border-radius: 6px 6px 0 0; color: var(--muted); margin-bottom: -1px;
}
#tabs button:hover { color: var(--ink); background: var(--surface-2); }
#tabs button.on { color: var(--ink); font-weight: 600; background: var(--surface); border-color: var(--line); border-bottom: 1px solid var(--surface); }
#view { flex: 1; min-height: 0; overflow: auto; padding: 12px 14px; }
.v-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; }
.run-facts { display: flex; gap: 2px 12px; align-items: baseline; flex-wrap: wrap; margin-bottom: 8px; padding: 4px 10px; border-radius: 7px; background: var(--surface-2); font-size: 12.5px; color: var(--ink-2); }
.run-fact b { font-size: 14px; color: var(--ink); }
.run-state { margin-left: auto; }
.run-state.ok::before { content: "✓ "; color: var(--accent); font-weight: 700; }
.shot-pick { display: inline-flex; gap: 4px; align-items: center; flex-wrap: wrap; }
.shot-pick #shot-n { width: 92px; }
#btn-circuits .count { margin-left: 2px; padding: 0 6px; border-radius: 9px; background: var(--accent-soft); font-size: 11.5px; }
.v-row button, .v-row select, .side-btn {
  height: 30px; padding: 0 12px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); cursor: pointer;
}
.v-row button:hover, .side-btn:hover { background: var(--surface-2); border-color: var(--line-2); }
.v-row button:disabled { opacity: .45; cursor: default; }
.v-row button.primary, .side-btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.v-row button.primary:hover, .side-btn.primary:hover { background: var(--accent); filter: brightness(1.1); }
.side-btn:disabled { opacity: .4; cursor: default; }
.v-title { font-weight: 600; margin: 14px 0 6px; }
.v-title:first-child { margin-top: 0; }
.plain { background: var(--accent-soft); border-radius: 7px; padding: 8px 12px; margin-bottom: 12px; line-height: 1.45; }
body.level-full .plain { display: none; }
.note { color: var(--muted); font-size: 12.5px; margin: 8px 0; line-height: 1.45; }
.warnbox { background: var(--warn-soft); border-radius: 7px; padding: 10px 12px; margin-bottom: 12px; line-height: 1.45; }
.legend { display: flex; gap: 14px; font-size: 12.5px; color: var(--ink-2); align-items: center; flex-wrap: wrap; }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.bigresult { font: 700 26px "Cambria Math", Cambria, serif; }

/* Column chart: thin bars on one axis, recessive grid */
.chart { position: relative; height: 190px; margin: 4px 0 2px 38px; border-bottom: 1px solid var(--line-2); }
.chart .gl { position: absolute; left: 0; right: 0; border-top: 1px solid var(--grid); }
.chart .gl span { position: absolute; left: -38px; top: -8px; width: 32px; text-align: right; font-size: 11px; color: var(--muted); }
.bars { position: absolute; inset: 0; display: flex; align-items: flex-end; gap: 2px; padding: 0 2px; }
.bcol { flex: 1 1 0; max-width: 72px; min-width: 0; height: 100%; display: flex; align-items: flex-end; justify-content: center; gap: 2px; position: relative; }
.bcol:hover { background: var(--code-bg); }
.bar { flex: 1 1 0; max-width: 28px; min-width: 2px; border-radius: 4px 4px 0 0; background: var(--s1); }
.bar.b2 { background: var(--s2); }
.bval { position: absolute; left: 0; right: 0; text-align: center; font-size: 11px; color: var(--ink-2); pointer-events: none; }
.xlabs { display: flex; gap: 2px; padding: 3px 2px 0; margin-left: 38px; }
.xlabs span { flex: 1 1 0; max-width: 72px; min-width: 0; text-align: center; font: 12px Consolas, monospace; color: var(--ink-2); overflow: hidden; }
.xlabs.vert span { writing-mode: vertical-rl; height: 58px; font-size: 10.5px; line-height: 1; }

table.nums { border-collapse: collapse; font-variant-numeric: tabular-nums; }
table.nums th { text-align: right; font-weight: 600; color: var(--muted); font-size: 12px; padding: 3px 12px; border-bottom: 1px solid var(--line); }
table.nums td { text-align: right; padding: 3px 12px; border-bottom: 1px solid var(--grid); }
table.nums td.ket, table.nums th.ket { text-align: left; font-family: "Cambria Math", Cambria, serif; }
table.nums .mbar { display: inline-block; height: 9px; background: var(--s1); border-radius: 0 4px 4px 0; vertical-align: middle; }
td.barcell { text-align: left !important; min-width: 110px; }
.wheel { vertical-align: middle; margin-right: 6px; }
.dirac { font: 18px "Cambria Math", Cambria, serif; margin-bottom: 10px; overflow-wrap: anywhere; }

.heat { display: inline-grid; gap: 1px; background: var(--grid); padding: 1px; }
.heat div { background: var(--surface); display: grid; place-items: center; font-size: 11.5px; font-variant-numeric: tabular-nums; min-width: 0; overflow: hidden; }
.heat .hd { background: var(--surface); color: var(--muted); font: 11px Consolas, monospace; }
.ent-grid { display: flex; flex-wrap: wrap; gap: 28px; align-items: flex-start; }
.hbar { display: grid; grid-template-columns: 34px 170px 48px; align-items: center; gap: 8px; margin: 3px 0; font-size: 12.5px; font-variant-numeric: tabular-nums; }
.hbar .track { background: var(--grid); border-radius: 0 4px 4px 0; height: 12px; }
.hbar .fill { background: var(--s1); height: 100%; border-radius: 0 4px 4px 0; }
.stats { display: flex; gap: 22px; flex-wrap: wrap; margin-bottom: 12px; }
.stat b { display: block; font-size: 21px; font-variant-numeric: tabular-nums; }
.stat span { font-size: 12px; color: var(--muted); }

.bloch-grid { display: flex; flex-wrap: wrap; gap: 14px; }
.bloch-card { text-align: center; border: 1px solid var(--line); border-radius: var(--radius); padding: 8px; background: var(--surface); }
.bloch-card canvas { display: block; cursor: grab; touch-action: none; }
.bloch-name { display: block; margin: 0 auto 2px; border: none; background: none; font-weight: 700; cursor: zoom-in; padding: 1px 8px; border-radius: 5px; }
.bloch-name:hover { background: var(--surface-2); }
.bloch-card.big .bloch-name { cursor: zoom-out; font-size: 16px; }
.bloch-card .ket { font: 13.5px "Cambria Math", Cambria, serif; color: var(--ink); min-height: 18px; overflow-wrap: anywhere; max-width: 176px; margin: 0 auto; }
.bloch-card.big .ket { font-size: 18px; max-width: 340px; }
.bloch-card.big small { font-size: 13px; }
.bloch-card small { display: block; color: var(--muted); font-variant-numeric: tabular-nums; font-size: 11.5px; }
.bloch-card .says { color: var(--ink-2); max-width: 190px; margin: 3px auto 0; line-height: 1.3; }
body.level-full .bloch-card .says { display: none; }

.noise-layout { display: flex; gap: 26px; flex-wrap: wrap; align-items: flex-start; }
.noise-controls { width: 280px; flex: none; }
.noise-results { flex: 1; min-width: 260px; }
.slider { display: grid; grid-template-columns: 1fr 52px; gap: 0 8px; margin-bottom: 8px; font-size: 12.5px; }
.slider input { grid-column: 1 / 3; width: 100%; accent-color: var(--accent); margin: 2px 0 0; }
.slider output { text-align: right; font-variant-numeric: tabular-nums; }
.switch { display: flex; gap: 8px; align-items: center; font-weight: 600; margin-bottom: 10px; cursor: pointer; }
.switch input { width: 16px; height: 16px; accent-color: var(--accent); }

/* ---------- Side panel: guide, lessons, exercises, gate details ---------- */
#side-body h3 { margin: 0 0 6px; font-size: 16px; }
#side-body h4 { margin: 14px 0 4px; font-size: 13px; color: var(--muted); font-weight: 600; }
#side-body p { margin: 6px 0; }
#side-gate:not(:empty) { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); }
.mat { display: inline-grid; gap: 2px 12px; padding: 4px 10px; border-left: 2px solid var(--ink-2); border-right: 2px solid var(--ink-2); border-radius: 5px; font: 13px "Cambria Math", Cambria, serif; text-align: center; }
.chips { display: flex; gap: 4px; flex-wrap: wrap; }
.chip { border: 1px solid var(--line); border-radius: 13px; padding: 2px 10px; background: var(--surface); cursor: pointer; font-size: 12.5px; }
.chip.on { background: var(--accent-soft); border-color: var(--accent); font-weight: 600; }
.chip:disabled { opacity: .4; cursor: default; }
.list-search { margin-bottom: 6px; }
.my-progress section { margin-top: 28px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.stat { padding: 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.stat b { display: block; font-size: 22px; }
.stat span { font-size: 13px; color: var(--muted); }
.cert-name { display: flex; gap: 8px; align-items: center; max-width: 480px; white-space: nowrap; }
.track-row { margin-top: 12px; }
.track-top { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; margin-bottom: 4px; }
.track-top small { color: var(--muted); }
.track-top button { margin-left: auto; }
.my-progress button.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.badges { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; margin-top: 10px; }
.badge { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 12px 8px; text-align: center; border: 1px dashed var(--line-2); border-radius: 10px; color: var(--muted); }
.badge i { font-style: normal; font-size: 22px; }
.badge small { font-size: 11.5px; }
.badge.got { border: 1px solid var(--accent); background: var(--accent-soft); color: var(--ink); }
.badge.got i { color: var(--accent); }
.cert-issue { flex-wrap: wrap; }
.cert-issue select { width: auto; }
.cert-row { display: flex; gap: 10px; align-items: center; justify-content: space-between; margin-top: 8px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; }
.exam-item { font-weight: 600; }
.exam-option { display: block; width: 100%; margin-top: 6px; }
.library h1 { margin: 8px 0; }
.lib-search { max-width: 460px; margin: 8px 0; }
.lib-chips { margin-bottom: 6px; }
.lib-shelf { margin-top: 26px; }
.lib-shelf h2 { margin: 0 0 2px; }
.lib-shelf h2 span { font-size: 13px; font-weight: 500; color: var(--muted); }
.prog-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; margin-top: 8px; }
.prog-card { display: flex; flex-direction: column; gap: 6px; height: auto; padding: 12px; text-align: left; align-items: flex-start; white-space: normal; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.prog-card:hover { border-color: var(--accent); }
.prog-about { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; overflow: hidden; font-size: 12.5px; color: var(--ink-2); }
.prog-card small { margin-top: auto; color: var(--muted); }
.classes section { margin-top: 28px; }
.classes button.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.classes button.danger { color: var(--danger); }
.classes h1 { margin: 8px 0; }
.class-top { display: flex; gap: 10px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.class-card { margin-top: 12px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; }
.class-card h3 { margin: 0; }
.class-card small, .hw-head small, .class-code small { color: var(--muted); }
.class-link { display: flex; width: 100%; justify-content: space-between; gap: 12px; margin-top: 6px; padding: 10px 12px; text-align: left; }
.class-code { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin: 10px 0; padding: 10px 12px; border-radius: 10px; background: var(--surface-2); }
.class-code code { font-size: 20px; font-weight: 700; letter-spacing: .12em; }
.code-in { text-transform: uppercase; letter-spacing: .12em; }
.hw { margin-top: 10px; padding-top: 8px; border-top: 1px solid var(--line); }
.hw-head { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; }
.hw-head small.late { color: var(--danger); font-weight: 600; }
.hw-head button { margin-left: auto; }
.hw-item { display: flex; width: 100%; gap: 6px; margin-top: 4px; padding: 6px 8px; text-align: left; }
.hw-item .tick { width: 16px; color: var(--good); font-weight: 700; flex: none; }
.hw-new { margin-top: 16px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; }
.hw-new h3 { margin: 0 0 8px; }
.hw-due { display: flex; gap: 6px; align-items: center; white-space: nowrap; }
.hw-due input { width: 150px; }
.hw-pick { margin: 8px 0; }
.hw-pick summary { cursor: pointer; font-weight: 600; }
.hw-pick label { display: block; padding: 3px 0; }
.table-wrap { overflow-x: auto; }
.roster td, .roster th { text-align: left; white-space: nowrap; }
.list-levels { margin-bottom: 4px; }
.list-done { margin: 4px 0; }
.field { width: 100%; height: 30px; padding: 0 8px; border: 1px solid var(--line); border-radius: 7px; background: var(--field); }
.field.bad { border-color: var(--danger); }
.side-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.tiplist { padding-left: 18px; margin: 6px 0; }
.tiplist li { margin: 4px 0; }
.lesson-item, .ex-item {
  display: flex; align-items: center; gap: 8px; width: 100%; text-align: left; padding: 8px 10px; margin-bottom: 4px;
  border: 1px solid var(--line); border-radius: 7px; background: var(--surface); cursor: pointer;
}
.lesson-item:hover, .ex-item:hover { background: var(--surface-2); border-color: var(--line-2); }
.lesson-item .tick, .ex-item .tick { width: 16px; color: var(--good); font-weight: 700; flex: none; }
.lvl-head { font-size: 12px; color: var(--muted); font-weight: 600; margin: 12px 0 4px; }
.lvl-head:first-child { margin-top: 0; }
.stepnum { color: var(--muted); font-size: 12px; }
.stepdots { display: flex; gap: 3px; margin: 6px 0 10px; }
.stepdots i { flex: 1; height: 4px; border-radius: 2px; background: var(--line); }
.stepdots i.on { background: var(--accent); }
.todo { background: var(--warn-soft); border-radius: 7px; padding: 7px 10px; margin: 8px 0; font-size: 13px; }
#side-body code { font: 12.5px Consolas, monospace; background: var(--code-bg); padding: 1px 4px; border-radius: 3px; }
.done { background: var(--good-soft); color: var(--good-ink); border-radius: 7px; padding: 7px 10px; margin: 8px 0; font-weight: 600; }
.ring-hl { outline: 3px solid var(--s2); outline-offset: 2px; border-radius: 6px; }

#tip {
  position: fixed; z-index: 60; pointer-events: none; background: var(--ink); color: var(--surface); font-size: 12.5px;
  padding: 5px 9px; border-radius: 6px; max-width: 300px; line-height: 1.35; white-space: pre-line;
}

/* ---------- AI assistant ---------- */
body.ai-on #side { width: 360px; }
.ai-row { display: grid; grid-template-columns: 96px minmax(0, 1fr) auto; gap: 4px; margin: 8px 0; }
.ai-row .side-btn { padding: 0 8px; white-space: nowrap; font-size: 12.5px; }
.ai-keys { border: 1px solid var(--line); border-radius: 7px; padding: 6px 10px; margin-bottom: 8px; }
.ai-keys summary { cursor: pointer; font-weight: 600; font-size: 13px; }
.ai-key { display: block; margin: 8px 0; font-size: 12.5px; }
.ai-key span { display: flex; justify-content: space-between; margin-bottom: 2px; }
.ai-key a { color: var(--accent); }
.ai-modes { margin-bottom: 8px; }
.ai-chat { display: flex; flex-direction: column; gap: 8px; margin-bottom: 8px; }
.ai-bubble { border-radius: 8px; padding: 8px 10px; font-size: 13.5px; line-height: 1.45; overflow-wrap: anywhere; }
.ai-bubble.user { background: var(--accent-soft); }
.ai-bubble.ai { background: var(--surface-2); }
.ai-who { font-size: 11.5px; font-weight: 600; color: var(--muted); margin-bottom: 2px; }
.ai-body { white-space: normal; }
.ai-bubble.user .ai-body, .ai-text { white-space: pre-wrap; }
.ai-code { font: 12.5px/1.5 Consolas, "Courier New", monospace; background: var(--code-surface); border: 1px solid var(--line); border-radius: 6px; padding: 8px; overflow: auto; margin: 6px 0; white-space: pre; }
.ai-load { margin-bottom: 6px; }
.ai-input { height: auto; padding: 6px 8px; resize: vertical; }

/* ---------- Account menu and My circuits (hosted site only) ---------- */
html.auth-wait body { visibility: hidden; }
#btn-account { width: 30px; padding: 0; border-radius: 50%; overflow: hidden; display: grid; place-items: center; font-weight: 700; }
#btn-account img { width: 100%; height: 100%; object-fit: cover; }
.acct-menu { position: fixed; z-index: 70; min-width: 230px; background: var(--surface); border: 1px solid var(--line-2); border-radius: 10px; box-shadow: 0 14px 40px -12px rgba(0,0,0,.35); padding: 6px; display: flex; flex-direction: column; }
.acct-menu[hidden] { display: none; }
.acct-who { padding: 8px 10px 10px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.acct-who small { display: block; color: var(--muted); }
.acct-menu button, .acct-menu a { text-align: left; border: 0; background: none; padding: 8px 10px; border-radius: 6px; cursor: pointer; color: var(--ink); text-decoration: none; font-size: 13.5px; }
.acct-menu button:hover, .acct-menu a:hover { background: var(--surface-2); }
.panel-cloud { position: fixed; z-index: 65; top: 64px; left: 50%; transform: translateX(-50%); width: min(440px, calc(100vw - 16px)); max-height: calc(100vh - 90px); overflow: auto; background: var(--surface); border: 1px solid var(--line-2); border-radius: 12px; box-shadow: 0 18px 50px -16px rgba(0,0,0,.4); padding: 14px; display: grid; gap: 8px; }
.pc-head { display: flex; justify-content: space-between; align-items: center; font-size: 15px; }
.pc-x { width: 28px; height: 28px; border: none; background: none; font-size: 18px; cursor: pointer; color: var(--muted); }
.cl-save { display: flex; gap: 6px; }
.cl-name { flex: 1; min-width: 0; height: 30px; border: 1px solid var(--line-2); border-radius: 7px; background: var(--field); padding: 0 8px; }
.panel-cloud button:not(.pc-x) { height: 30px; padding: 0 10px; border: 1px solid var(--line-2); border-radius: 7px; background: var(--surface); cursor: pointer; white-space: nowrap; }
.panel-cloud button.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: 600; }
.panel-cloud button.danger { color: var(--danger); }
.cl-msg { margin: 0; font-size: 12.5px; min-height: 16px; color: var(--muted); }
.cl-msg.bad { color: var(--danger); }
.cl-empty { color: var(--muted); margin: 6px 0; }
.cl-list { display: grid; gap: 4px; }
.cl-row { display: flex; gap: 6px; align-items: center; padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; }
.cl-row > div { flex: 1; min-width: 0; }
.cl-row b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cl-row small { color: var(--muted); font-size: 11.5px; }
.cl-row.cur { border-color: var(--accent); background: var(--accent-soft); }

/* ---------- Simple level hides what only experts need ---------- */
body.level-simple .adv { display: none !important; }

/* ---------- Class view: large, for a projector ---------- */
body.present:not(.lesson-on) #side { display: none; }
body.present:not(.lesson-on) #gate-hint, body.present:not(.lesson-on) #palette { display: none; }
body.present #view { font-size: 18px; }
body.present .plain { font-size: 19px; }
body.present .dirac, body.present #dirac-line { font-size: 24px; }
body.present .chart { height: 260px; }
body.present .xlabs span { font-size: 16px; }
body.present .bval { font-size: 14px; }
body.present #side-body { font-size: 17px; }
body.present #code-panel { width: 440px; }
body.present #code-paint, body.present #code-text { font-size: 16px; line-height: 26px; }
body.present .cl, body.present .cl-pad { height: 26px; }

/* ---------- Narrower screens: one column, and the page scrolls ---------- */
@media (max-width: 1180px) {
  html, body { height: auto; overflow: auto; }
  #work { flex-wrap: wrap; height: auto; }
  #side { width: 100%; order: 1; }
  #center { order: 2; flex: 1 1 100%; }
  #code-panel, body.present #code-panel { order: 3; width: 100%; height: 340px; }
  #build-card { max-height: none; }
  #dock { flex: none; min-height: 0; }
  #view { overflow: visible; }
  #splitter { display: none; }
  #stage { max-height: 60vh; }
}
@media (max-width: 640px) {
  .topbar { padding: 6px 8px; }
  .tb-spacer { display: none; }
  .topbar #nav button { padding: 0 8px; }
  .tb-group { border-left: none; padding-left: 0; flex-wrap: wrap; }
  #work { padding: 6px; gap: 6px; }
  .hero h1 { font-size: 28px; }
  .home-in { padding: 24px 14px; }
  .noise-controls { width: 100%; }
  .statusbar { flex-direction: column; gap: 0; }
  #status-info { white-space: normal; }
}

/* Long addresses in AI messages must wrap, not push the panel sideways. */
.ai-msg { overflow-wrap: anywhere; }
#side-body { overflow-x: hidden; }
.ai-keys-ready { font-weight: 500; color: var(--good-ink); margin-left: 4px; }

/* ---------- The Lab ---------- */
body.on-lab #home { display: flex; overflow: hidden; }
.lx { --lx-bg: var(--bg); position: relative; flex: 1; min-width: 0; min-height: 0; display: grid; grid-template: "top top top top" auto "rail side main run" minmax(0, 1fr) "status status status status" auto / 46px 230px minmax(0, 1fr) 270px; background: var(--surface); color: var(--ink); font-size: 13px; }
.lx.noside { grid-template-columns: 46px 0 minmax(0, 1fr) 270px; }
.lx.wideside { grid-template-columns: 46px 340px minmax(0, 1fr) 270px; }
.lx-railbtn { position: relative; }
.lx-badge { position: absolute; top: 0; right: 0; min-width: 14px; padding: 0 3px; border-radius: 8px; background: var(--warn); color: #fff; font-size: 10px; font-weight: 700; line-height: 14px; }
.lx-runcount { padding: 0 10px 6px; color: var(--muted); border-bottom: 1px solid var(--line); }
.lx-resrow.on { background: var(--accent-soft); }
.lx-chip { padding: 1px 8px; border: 1px solid var(--line); border-radius: 10px; font-size: 11.5px; white-space: nowrap; }
.lx-tags .lx-chip.done, .lx-chip.done { color: var(--good-ink); border-color: var(--good); }
.lx-tags .lx-chip.running, .lx-chip.running { color: var(--accent); border-color: var(--accent); }
.lx-tags .lx-chip.failed, .lx-chip.failed { color: var(--danger); border-color: var(--danger); }
.lx-tags .lx-chip.stopped, .lx-chip.stopped { color: var(--warn); border-color: var(--warn); }
#lx-out { height: 100%; }
.lx-outempty { margin: 0; padding: 12px; color: var(--muted); }
.lo-card { display: flex; flex-direction: column; margin: 8px 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface-2); }
.lo-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; }
.lo-head small { color: var(--muted); }
.lo-head > button { display: inline-flex; gap: 5px; align-items: center; padding: 3px 9px; border: 1px solid var(--line-2); border-radius: 6px; background: var(--surface); font-size: 12.5px; }
.lo-head > button:hover { border-color: var(--accent); }
.lo-steps { display: flex; flex-wrap: wrap; gap: 3px 8px; margin-top: 7px; font-size: 12.5px; }
.lo-steps span::first-letter { color: var(--good); }
.lo-steps i { font-style: normal; color: var(--muted); }
.lo-sub { display: flex; justify-content: space-between; gap: 10px; margin-top: 10px; color: var(--muted); font-size: 12.5px; }
.lo-table { width: 100%; margin-top: 4px; border-collapse: collapse; }
.lo-table th { padding: 3px 8px 3px 0; font-weight: 500; color: var(--muted); text-align: left; }
.lo-table th button { padding: 0; border: none; background: none; color: inherit; }
.lo-table td { padding: 3px 8px 3px 0; }
.lo-table .num { text-align: right; width: 70px; }
.lo-barcell { width: 55%; padding-left: 8px !important; }
.lo-barcell i { display: block; height: 9px; border-radius: 3px; background: var(--accent); }
.lo-note { margin: 8px 0 0; color: var(--muted); font-size: 12px; }
.lo-log { margin: 0 10px 10px; }
.lo-log .lo-sub { margin-top: 0; }
.lo-log pre { margin: 3px 0 0; font-size: 12.5px; white-space: pre-wrap; overflow-wrap: anywhere; }
.lo-card .lx-output { margin: 8px 0 0; padding: 8px 10px; max-height: 240px; overflow: auto; border-radius: 6px; background: var(--field); }
.lxc { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.lx-side:has(> .lxc) { overflow: hidden; }
.lxc-head { display: flex; align-items: center; justify-content: space-between; min-height: 34px; padding: 4px 10px; color: var(--muted); font-size: 12.5px; }
.lxc-head button, .lxc-row button { padding: 1px 8px; border: 1px solid var(--line); border-radius: 5px; background: none; }
.lxc-row { display: flex; gap: 5px; padding: 0 10px 6px; }
.lxc-agent { display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: center; padding: 0 10px 8px; border-bottom: 1px solid var(--line); }
.lxc-agent small { color: var(--muted); }
.lxc-switch { padding: 3px 9px; border: 1px solid var(--line-2); border-radius: 12px; background: none; }
.lxc-switch b { color: var(--muted); font-size: 11px; }
.lxc-switch.on { border-color: var(--accent); background: var(--accent-soft); }
.lxc-switch.on b { color: var(--accent); }
.lxc-chat { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; padding: 10px; }
.lxc-hello { display: flex; flex-direction: column; gap: 6px; color: var(--ink-2); }
.lxc-hello .lx-i { color: var(--accent); }
.lxc-hello p { margin: 4px 0 6px; }
.lxc-hello button { padding: 8px 10px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface-2); text-align: left; }
.lxc-hello button:hover { border-color: var(--accent); }
.lxc-me { align-self: flex-end; max-width: 92%; padding: 7px 10px; border-radius: 9px; background: var(--accent-soft); white-space: pre-wrap; overflow-wrap: anywhere; }
.lxc-ai { line-height: 1.5; overflow-wrap: anywhere; }
.lxc-ai .ai-code { margin: 6px 0; padding: 7px 9px; overflow-x: auto; border-radius: 6px; background: var(--surface-2); font: 12.5px Consolas, monospace; }
.lxc-think { color: var(--muted); }
.lxc-steps { margin: 0 0 8px; padding: 0; list-style: none; color: var(--ink-2); font: 12.5px Consolas, monospace; }
.lxc-steps li { position: relative; padding: 2px 0 2px 15px; overflow-wrap: anywhere; }
.lxc-steps li::before { content: ''; position: absolute; left: 2px; top: 8px; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
.lxc-steps.live li:last-child { color: var(--ink); }
.lxc-steps.live li:last-child::before { animation: lxc-pulse 1s ease-in-out infinite; }
@keyframes lxc-pulse { 50% { opacity: .25; } }
@media (prefers-reduced-motion: reduce) { .lxc-steps.live li:last-child::before { animation: none; } }
.lxc-target { display: flex; align-items: center; gap: 6px; margin-top: 6px; font-size: 12.5px; color: var(--muted); }
.lxc-target select { flex: 1; min-width: 0; }
.lxc-warn { display: block; margin-top: 3px; color: var(--muted); font-size: 11.5px; }
.lxc-edit { margin-top: 8px; padding: 8px 10px; border: 1px solid var(--accent); border-radius: 8px; }
.lxc-etop { display: flex; justify-content: space-between; gap: 8px; overflow-wrap: anywhere; }
.lxc-etop em { font-style: normal; font-weight: 600; }
.lxc-etop em.a { color: var(--good-ink); }
.lxc-etop em.r { color: var(--danger); }
.lxc-edit summary { margin-top: 5px; cursor: pointer; color: var(--muted); font-size: 12.5px; }
.lxc-edit pre { margin: 5px 0 0; padding: 6px 8px; max-height: 300px; overflow: auto; border-radius: 6px; background: var(--field); font-size: 12px; line-height: 1.45; white-space: pre-wrap; overflow-wrap: anywhere; }
.lxc-edit pre i { display: block; min-height: 1.45em; font-style: normal; }
.lxc-edit pre i.lxc-skip { padding: 2px 0; font-style: italic; }
.lxc-why { margin-top: 5px; color: var(--ink-2); font-size: 13px; line-height: 1.45; }
.lxc-edit pre i.da { color: var(--good-ink); background: var(--good-soft); }
.lxc-edit pre i.dr { color: var(--danger); background: var(--danger-soft); }
.lxc-edit pre i.dk { color: var(--muted); }
.lxc-eacts { display: flex; justify-content: flex-end; gap: 6px; margin-top: 7px; }
.lxc-eacts button { padding: 4px 11px; border: 1px solid var(--line-2); border-radius: 6px; background: none; }
.lxc-eacts .primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent) !important; font-weight: 600; }
.lxc-eacts .ok { color: var(--good-ink); font-weight: 600; }
.lxc-foot { padding: 8px 10px; border-top: 1px solid var(--line); }
.lxc-who { margin: 0 0 6px; color: var(--muted); font-size: 12px; }
.lxc-who button { padding: 0; border: none; background: none; color: var(--accent); text-decoration: underline; }
.lxc-send { display: flex; gap: 6px; align-items: flex-end; }
.lxc-send textarea { flex: 1; resize: none; }
.lxc-send button { padding: 6px 12px; border: 1px solid var(--line-2); border-radius: 6px; background: none; }
.lxc-settings .ai-panel > :not(.ai-row):not(.ai-keys):not(.ai-msg):not(.ai-cost) { display: none; }
.lxc-cost { margin: 0 10px 6px; color: var(--ink-2); font-size: 11.5px; line-height: 1.4; }
.lxc-settings .ai-row { display: grid; grid-template-columns: 110px minmax(0, 1fr) auto; gap: 5px; margin-bottom: 8px; }
.lx.noside .lx-side { display: none; }
.lx button { font: inherit; color: inherit; cursor: pointer; }
.lx button:disabled { opacity: .45; cursor: default; }
.lx .mono, .lx code, .lx kbd { font-family: Consolas, "Cascadia Mono", monospace; }
.lx-i { fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex: none; vertical-align: -3px; }
.lx-grow { flex: 1; }
.lx-top { grid-area: top; display: flex; align-items: center; gap: 8px; min-height: 42px; padding: 0 8px 0 12px; border-bottom: 1px solid var(--line); background: var(--surface-2); flex-wrap: wrap; }
.lx-start h1 b { color: var(--accent); }
.lx-crumb { border: none; background: none; padding: 4px 6px; border-radius: 6px; }
.lx-crumb:hover, .lx-sidebtns button:hover, .lx-railbtn:hover, .lx-status button:hover { background: var(--line); }
.lx-crumb span { color: var(--muted); font-size: 11px; }
.lx-path { color: var(--muted); }
.lx-saved { color: var(--muted); font-size: 12px; }
.lx-topbtn { display: inline-flex; gap: 6px; align-items: center; padding: 5px 10px; border: 1px solid var(--line-2); border-radius: 7px; background: var(--surface); }
.lx-topbtn:hover { border-color: var(--accent); }
.lx kbd { font-size: 11px; color: var(--muted); }
.lx-rail { grid-area: rail; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 6px 0; border-right: 1px solid var(--line); background: var(--surface-2); }
.lx-rail hr { width: 22px; margin: 4px 0; border: none; border-top: 1px solid var(--line-2); }
.lx-railbtn { width: 34px; height: 34px; display: grid; place-items: center; border: none; border-radius: 8px; background: none; color: var(--muted) !important; }
.lx-railbtn.on { background: var(--accent-soft); color: var(--accent) !important; }
.lx-side { grid-area: side; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; border-right: 1px solid var(--line); }
.lx-sidehead { display: flex; align-items: center; justify-content: space-between; min-height: 34px; padding: 4px 10px; color: var(--muted); font-size: 12.5px; }
.lx-sidebtns button { display: inline-grid; place-items: center; width: 24px; height: 24px; border: none; border-radius: 5px; background: none; }
.lx-sidepad { padding: 4px 10px; }
.lx-pname { display: flex; gap: 6px; align-items: center; width: 100%; padding: 6px 10px; border: none; border-bottom: 1px solid var(--line); background: none; text-align: left; }
.lx-pname:hover { background: var(--surface-2); }
.lx-row { display: flex; align-items: center; min-width: 0; padding-right: 4px; }
.lx-row:hover { background: var(--surface-2); }
.lx-row.on { background: var(--accent-soft); }
.lx-row.on .lx-node { font-weight: 600; }
.lx-row .lx-node { flex: 1; min-width: 0; padding-left: 0; padding-right: 2px; background: none !important; }
.lx-row .lx-node span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lx-rowacts { display: none; gap: 1px; flex: none; }
.lx-row:hover .lx-rowacts, .lx-row:focus-within .lx-rowacts { display: inline-flex; }
.lx-rowacts button { display: grid; place-items: center; width: 22px; height: 22px; border: none; border-radius: 5px; background: none; color: var(--muted); }
.lx-rowacts button:hover { background: var(--line); color: var(--ink); }
.lx-tree { flex: 1; min-height: 60px; }
.lx-tree.dropon { outline: 2px dashed var(--accent); outline-offset: -3px; }
.lx-row.dropon { background: var(--accent-soft); box-shadow: inset 0 0 0 1.5px var(--accent); }
.lx-row[draggable="true"] { cursor: grab; }
.lx-menu .lx-i { margin-right: 4px; }
.lx-veil.pop { background: rgba(0,0,0,.4); padding-top: 46px; }
.lx-approve { color: var(--warn); font-weight: 600; }
.lx-approve[hidden] { display: none; }
.lo-head .lx-tags { align-items: center; }
.lx-tags { align-items: center; }
.lx-mach { gap: 3px; }
.lx-machtop { display: flex; justify-content: space-between; gap: 6px; align-items: flex-start; }
.lx-machrow { display: flex; gap: 4px; align-items: center; flex-wrap: wrap; }
.lx-machrow code { padding: 1px 6px; border-radius: 4px; background: var(--accent-soft); }
.lx-machrow button { display: inline-flex; gap: 3px; align-items: center; padding: 2px 6px; border: 1px solid var(--line); border-radius: 5px; background: none; font-size: 11.5px; }
.lx-machrow button:hover { border-color: var(--accent); }
.lxc-row select { flex: 1; min-width: 0; }
.lxc-row .lxc-keybtn { flex: none; padding: 1px 10px; border-color: var(--accent); color: var(--accent); font-weight: 600; white-space: nowrap; }
.lxc-row .lxc-keybtn:hover { background: var(--accent-soft); }
.lxc-key { margin: 0 10px 8px; padding: 8px 10px; border: 1px solid var(--accent); border-radius: 8px; background: var(--accent-soft); }
.lxc-keytop { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 5px; }
.lxc-keytop a { color: var(--accent); }
.lxc-keyrow { display: flex; gap: 5px; }
.lxc-keyrow button { padding: 5px 10px; border: 1px solid var(--accent); border-radius: 6px; background: var(--accent); color: var(--on-accent) !important; font-weight: 600; }
.lxc-keyrem { display: flex; gap: 5px; align-items: center; margin: 5px 0 2px; font-size: 12px; }
.lxc-key small { color: var(--ink-2); font-size: 11.5px; }
.lx-pname b { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lx-tree { display: flex; flex-direction: column; padding: 4px 0; }
.lx-node { display: flex; gap: 6px; align-items: center; padding: 4px 10px; border: none; background: none; text-align: left; overflow-wrap: anywhere; }
.lx-node:hover { background: var(--surface-2); }
.lx-node.on { background: var(--accent-soft); font-weight: 600; }
.lx .danger { color: var(--danger) !important; }
.lx-found { display: flex; flex-direction: column; }
.lx-hit, .lx-problem { display: block; width: 100%; padding: 4px 10px; border: none; background: none; text-align: left; overflow-wrap: anywhere; }
.lx-hit:hover, .lx-problem:hover { background: var(--surface-2); }
.lx-problem b { color: var(--danger); }
.lx-resrow { display: flex; flex-direction: column; gap: 3px; padding: 7px 10px; border: none; border-bottom: 1px solid var(--line); background: none; text-align: left; }
.lx-resrow small { color: var(--muted); }
.lx-bars { display: flex; flex-direction: column; gap: 2px; }
.lx-bar { display: flex; gap: 6px; align-items: center; font-size: 11.5px; }
.lx-bar i { display: block; height: 7px; min-width: 2px; border-radius: 2px; background: var(--accent); }
.lx-bar em { font-style: normal; color: var(--muted); }
.lx-mach { display: flex; flex-direction: column; padding: 6px 0; border-bottom: 1px solid var(--line); }
.lx-mach code { color: var(--accent); font-size: 12px; }
.lx-mach small { color: var(--muted); }
.lx-main { grid-area: main; min-width: 0; min-height: 0; display: flex; flex-direction: column; }
.lx-tabs { display: flex; align-items: stretch; min-height: 34px; border-bottom: 1px solid var(--line); background: var(--surface-2); overflow-x: auto; }
.lx-tab { display: inline-flex; align-items: center; border-right: 1px solid var(--line); box-shadow: inset 0 0 0 transparent; }
.lx-tab.on { background: var(--surface); box-shadow: inset 0 2px 0 var(--accent); }
.lx-tab button { padding: 6px 4px 6px 12px; border: none; background: none; white-space: nowrap; }
.lx-tab button.x { padding: 6px 9px 6px 5px; color: var(--muted); }
.lx-seg { display: inline-flex; align-self: center; margin-right: 8px; border: 1px solid var(--line-2); border-radius: 6px; overflow: hidden; flex: none; }
.lx-seg button { padding: 2px 10px; border: none; background: none; color: var(--muted); font-size: 12px; }
.lx-seg button.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.lx-work { flex: 1; min-height: 0; display: flex; }
.lx-empty { margin: auto; padding: 20px; text-align: center; color: var(--muted); max-width: 520px; }
.lx-editor { flex: 1; min-width: 0; display: flex; background: var(--field); }
.lx-gutter { margin: 0; padding: 8px 10px 8px 12px; overflow: hidden; text-align: right; color: var(--muted); background: var(--surface-2); border-right: 1px solid var(--line); user-select: none; font: 13px/19.5px Consolas, "Cascadia Mono", monospace; min-width: 42px; box-sizing: border-box; }
.lx-gutter span { display: block; height: 19.5px; }
.lx-gutter span.on { color: var(--ink); font-weight: 700; }
.lx-codebox { position: relative; flex: 1; min-width: 0; overflow: hidden; }
.lx-curline { position: absolute; left: 0; right: 0; top: 0; height: 19.5px; background: var(--surface-2); pointer-events: none; }
.lx-hl, #lx-text { position: absolute; left: 0; top: 0; margin: 0; padding: 8px 12px; border: 0; font: 13px/19.5px Consolas, "Cascadia Mono", monospace !important; white-space: pre; tab-size: 4; box-sizing: border-box; }
.lx-hl { pointer-events: none; color: var(--ink); min-width: 100%; min-height: 100%; }
#lx-text { width: 100%; height: 100%; resize: none; outline: none; overflow: auto; background: transparent; color: transparent; caret-color: var(--ink); }
#lx-text::selection { background: var(--accent-soft); color: transparent; }
.lx-hl i, .lx-snaptext i { font-style: normal; }
.lx i.k { color: #7a3fc0; } .lx i.s { color: #1f7a4d; } .lx i.n { color: #b05a00; } .lx i.c { color: var(--muted); font-style: italic; } .lx i.f { color: #1565c0; }
:root[data-theme="dark"] .lx i.k { color: #c79bff; } :root[data-theme="dark"] .lx i.s { color: #7fdca4; } :root[data-theme="dark"] .lx i.n { color: #f0b86e; } :root[data-theme="dark"] .lx i.f { color: #7ec4ff; }
.lx-bottom { height: 32%; min-height: 110px; display: flex; flex-direction: column; border-top: 1px solid var(--line); }
.lx.nopanel .lx-bottom { display: none; }
.lx-ptabs { display: flex; align-items: stretch; min-height: 30px; border-bottom: 1px solid var(--line); }
.lx-ptabs button { padding: 4px 12px; border: none; background: none; color: var(--muted); }
.lx-ptabs button.on { color: var(--ink); font-weight: 600; box-shadow: inset 0 -2px 0 var(--accent); }
.lx-ptabs em { padding: 0 5px; border-radius: 8px; background: var(--danger-soft); color: var(--danger); font-style: normal; font-size: 11px; }
.lx-pbody { flex: 1; min-height: 0; overflow: auto; }
.lx-output { margin: 0; padding: 8px 12px; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 12.5px; line-height: 1.5; }
.lx-output.faint { color: var(--muted); font-family: inherit !important; }
.lx-runrail { grid-area: run; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 9px; padding: 10px; border-left: 1px solid var(--line); }
.lx-railtitle { color: var(--muted); overflow-wrap: anywhere; }
.lx-field { display: flex; flex-direction: column; gap: 3px; }
.lx-field > span { font-size: 12.5px; color: var(--muted); }
.lx-input { width: 100%; box-sizing: border-box; padding: 6px 8px; border: 1px solid var(--line-2); border-radius: 6px; background: var(--field); color: var(--ink); font: inherit; }
.lx-input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.lx-code { display: flex; gap: 5px; align-items: center; }
.lx-code code { padding: 2px 7px; border-radius: 5px; background: var(--accent-soft); color: var(--accent); }
.lx-code button { display: grid; place-items: center; padding: 3px; border: 1px solid var(--line); border-radius: 5px; background: none; }
.lx-tags { display: flex; flex-wrap: wrap; gap: 4px; }
.lx-tags span { padding: 1px 8px; border: 1px solid var(--line); border-radius: 10px; font-size: 11.5px; }
.lx-tags .ok { color: var(--good-ink); border-color: var(--good); }
.lx-cost { display: flex; align-items: center; justify-content: space-between; padding: 7px 10px; border: 1px solid var(--line); border-radius: 7px; }
.lx-fit { margin: 0; font-size: 12.5px; color: var(--muted); }
.lx-fit.bad { color: var(--danger); }
.lx-submit, .lx-pyrun { display: flex; gap: 6px; align-items: center; justify-content: center; padding: 8px; border: 1px solid var(--accent); border-radius: 7px; background: var(--accent); color: var(--on-accent) !important; font-weight: 600 !important; }
.lx-pyrun { background: none; color: var(--accent) !important; }
.lx-rundiv { border-top: 1px solid var(--line); }
.lx-wide { width: 100%; padding: 6px; border: 1px solid var(--line-2); border-radius: 7px; background: none; }
.lx-machines summary { cursor: pointer; color: var(--muted); }
.lx-hint { margin: 4px 0; color: var(--muted); font-size: 12.5px; }
.lx-err { margin: 6px 0 0; color: var(--danger); font-size: 12.5px; }
.lx-status { grid-area: status; display: flex; flex-wrap: wrap; align-items: center; gap: 2px 14px; min-height: 24px; padding: 1px 10px; border-top: 1px solid var(--line); background: var(--surface-2); color: var(--muted); font-size: 12px; }
.lx-status button { padding: 1px 5px; border: none; border-radius: 4px; background: none; }
.lx-circuit { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.lx-ctools { padding: 6px 10px; border-bottom: 1px solid var(--line); }
.lx-cgates { display: flex; flex-wrap: wrap; gap: 3px; margin-bottom: 5px; }
.lx-cgates .pal-item { width: auto; min-width: 30px; height: 28px; padding: 0 6px; border-radius: 6px; font-size: 12.5px; }
.lx-cacts { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 10px; }
.lx-cacts button { padding: 1px 3px; border: none; background: none; color: var(--muted); font-size: 12.5px; }
.lx-cacts button:hover { color: var(--ink); }
.lx-cacts i { width: 1px; height: 14px; background: var(--line-2); }
.lx-chint { margin: 0; padding: 4px 10px; border-bottom: 1px solid var(--line); color: var(--muted); font-size: 12px; }
.lx-cstage { flex: 1; min-height: 0; overflow: auto; background: var(--canvas); }
#lx-canvas { display: block; touch-action: none; user-select: none; }
.lx-cinfo { display: flex; align-items: center; gap: 8px; padding: 3px 10px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; }
.lx-cinfo button { padding: 0 6px; border: none; background: none; }
.lx-menu { position: fixed; z-index: 60; display: flex; flex-direction: column; min-width: 170px; padding: 4px; border: 1px solid var(--line-2); border-radius: 8px; background: var(--surface); box-shadow: 0 8px 24px rgba(0,0,0,.25); }
.lx-menu button { padding: 5px 9px; border: none; border-radius: 5px; background: none; text-align: left; }
.lx-menu button:hover { background: var(--accent-soft); }
.lx-veil { position: fixed; inset: 0; z-index: 50; display: flex; align-items: flex-start; justify-content: center; padding: 8vh 16px 16px; background: rgba(0,0,0,.5); overflow-y: auto; }
.lx-modal { width: 100%; max-width: 460px; padding: 16px 18px; border: 1px solid var(--line-2); border-radius: 12px; background: var(--surface); box-shadow: 0 16px 48px rgba(0,0,0,.35); }
.lx-modal.wide { max-width: 720px; }
.lx-modal h3 { margin: 0 0 10px; font-size: 15px; }
.lx-mbody p { margin: 6px 0; }
.lx-mfoot { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; margin-top: 14px; padding-top: 10px; border-top: 1px solid var(--line); }
.lx-mfoot:empty { display: none; }
.lx-mfoot button, .lx-rowform button, .lx-swbtns button, .lx-snap button { padding: 6px 12px; border: 1px solid var(--line-2); border-radius: 7px; background: var(--surface); white-space: nowrap; }
.lx-mfoot .primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent) !important; font-weight: 600; }
.lx-rowform { display: flex; gap: 6px; }
.lx-notes { margin: 10px 0 0; padding-left: 18px; color: var(--ink-2); }
.lx-notes li { margin: 3px 0; }
.lx-snaps { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; max-height: 42vh; overflow-y: auto; }
.lx-snap { display: flex; gap: 8px; align-items: center; padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px; }
.lx-snap > div { flex: 1; min-width: 0; }
.lx-snap b { display: block; overflow-wrap: anywhere; }
.lx-snap small { color: var(--muted); }
.lx-snapview { display: grid; grid-template-columns: 170px minmax(0, 1fr); gap: 8px; }
.lx-snapfiles { display: flex; flex-direction: column; gap: 2px; }
.lx-snapfiles button { padding: 3px 7px; border: none; border-radius: 5px; background: none; text-align: left; overflow-wrap: anywhere; font-size: 12.5px; }
.lx-snapfiles button.on { background: var(--accent-soft); font-weight: 600; }
.lx-snaptext { margin: 0; padding: 8px 10px; max-height: 52vh; overflow: auto; border: 1px solid var(--line); border-radius: 7px; background: var(--field); font-size: 12.5px; line-height: 1.5; }
.lx-swlist { display: flex; flex-direction: column; gap: 2px; margin: 6px 0; max-height: 44vh; overflow-y: auto; }
.lx-swrow { position: relative; display: flex; flex-wrap: wrap; align-items: center; border-radius: 7px; }
.lx-swrow[hidden], .lx-cmds [hidden], .prog-card[hidden] { display: none !important; }
.lx-swrow.on { background: var(--accent-soft); }
.lx-swopen { flex: 1; min-width: 0; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding: 7px 9px; border: none; background: none; text-align: left; }
.lx-swopen small { margin-left: auto; color: var(--muted); }
.lx-swopen em { padding: 0 6px; border-radius: 4px; background: var(--surface); color: var(--accent); font-style: normal; font-size: 11px; font-weight: 700; }
.lx-more { padding: 3px 9px; border: none; background: none; }
.lx-swbtns { display: flex; gap: 6px; margin-top: 6px; }
.lx-cmds { display: flex; flex-direction: column; margin-top: 6px; max-height: 48vh; overflow-y: auto; }
.lx-cmds button { padding: 5px 9px; border: none; border-radius: 5px; background: none; text-align: left; }
.lx-cmds button.on, .lx-cmds button:hover { background: var(--accent-soft); }
.lx-libgrid { max-height: 56vh; overflow-y: auto; padding: 2px; }
.lx-guide { margin: 0; padding-left: 20px; }
.lx-guide li { margin: 5px 0; }
.lx-toast { position: fixed; left: 50%; bottom: 40px; transform: translateX(-50%); z-index: 70; max-width: 80vw; padding: 7px 14px; border-radius: 8px; background: var(--ink); color: var(--surface); }
.lx-toast[hidden] { display: none; }
.lx-startpage { display: flex; flex-direction: column; overflow-y: auto; }
.lx-start { width: 100%; max-width: 880px; margin: 0 auto; padding: 28px 20px 40px; box-sizing: border-box; font-size: 14px; }
.lx-start h1 { margin: 0 0 12px; font-size: 26px; }
.lx-start h2 { margin: 18px 0 6px; font-size: 18px; }
.lx-start > p { max-width: 640px; color: var(--ink-2); }
.lx-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px; margin-top: 12px; }
.lx-card { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; padding: 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); text-align: left; }
.lx-card:hover, .lx-prow:hover { border-color: var(--accent); }
.lx-cardicon { display: grid; place-items: center; width: 30px; height: 30px; border: 1px solid var(--line); border-radius: 7px; color: var(--accent); }
.lx-chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: auto; }
.lx-chips code { padding: 1px 6px; border: 1px solid var(--line); border-radius: 4px; font-size: 11.5px; }
.lx-prow { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; width: 100%; margin-top: 6px; padding: 9px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-2); text-align: left; }
.lx-prow small { margin-left: auto; color: var(--muted); }
.lx-startbtns { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0 8px; }
.lx-startbtns button { display: inline-flex; gap: 7px; align-items: center; padding: 8px 12px; border: 1px solid var(--line-2); border-radius: 8px; background: var(--surface); }
@media (max-width: 1000px) {
  body.on-lab #home { overflow-y: auto; display: block; }
  .lx { grid-template: "top" auto "rail" auto "side" auto "main" auto "run" auto "status" auto / minmax(0, 1fr); }
  .lx.noside, .lx.wideside { grid-template-columns: minmax(0, 1fr); }
  .lx-rail { flex-direction: row; flex-wrap: wrap; justify-content: center; border-right: none; border-bottom: 1px solid var(--line); }
  .lx-rail hr { width: 1px; height: 18px; margin: 0 2px; border: none; border-left: 1px solid var(--line-2); }
  .lx-rail .lx-grow { display: none; }
  .lx-side { max-height: 240px; border-right: none; border-bottom: 1px solid var(--line); }
  .lx.wideside .lx-side { height: 85vh; max-height: none; }
  .lx-main { height: 78vh; }
  .lx-runrail { border-left: none; border-top: 1px solid var(--line); }
  .lx-snapview { grid-template-columns: 1fr; }
  .lx-topbtn kbd { display: none; }
}

/* The Docs page */
.gd { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 32px; max-width: 1180px; margin: 0 auto; padding: 0 24px; align-items: start; }
.gd-side { position: sticky; top: 0; max-height: 100vh; overflow-y: auto; padding: 24px 4px 24px 0; }
.gd-search { width: 100%; margin-bottom: 10px; }
.gd-group h4 { margin: 14px 0 4px; color: var(--muted); font-size: 11.5px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; }
.gd-group button { display: block; width: 100%; padding: 5px 9px; border: none; border-radius: 6px; background: none; color: var(--ink-2); font-size: 13.5px; text-align: left; cursor: pointer; }
.gd-group button:hover { background: var(--surface-2); }
.gd-group button.on { background: var(--accent); color: var(--on-accent); font-weight: 600; }
.gd-main { min-width: 0; padding: 32px 0 80px; }
.gd-main header h1 { margin: 0 0 6px; }
.gd-main header p { margin: 0; color: var(--ink-2); }
.gd-main section { padding: 26px 0 10px; border-top: 1px solid var(--line); margin-top: 22px; scroll-margin-top: 4px; }
.gd-main section:first-of-type { margin-top: 18px; }
.gd-main h2 { margin: 0 0 10px; font-size: 22px; }
.gd-main h3 { margin: 18px 0 6px; font-size: 15.5px; }
.gd-main p, .gd-main li { line-height: 1.6; }
.gd-main code { padding: 1px 4px; border-radius: 4px; background: var(--surface-2); font: 12.5px Consolas, monospace; overflow-wrap: anywhere; }
.gd-note { padding: 9px 12px; border-left: 3px solid var(--accent); border-radius: 0 6px 6px 0; background: var(--accent-soft); }
.gd-none { color: var(--muted); }
.gd-tablebox { overflow-x: auto; margin: 10px 0; }
.gd-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.gd-table th { padding: 6px 10px; border-bottom: 1px solid var(--line-2); color: var(--muted); font-weight: 600; text-align: left; }
.gd-table td { padding: 7px 10px; border-bottom: 1px solid var(--line); vertical-align: top; line-height: 1.45; }
.gd-code { position: relative; margin: 10px 0; }
.gd-code pre { margin: 0; padding: 12px 70px 12px 14px; overflow-x: auto; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-2); font-size: 12.5px; line-height: 1.5; }
.gd-copy { position: absolute; top: 7px; right: 7px; display: grid; place-items: center; width: 30px; height: 30px; padding: 0; border: 1px solid var(--line-2); border-radius: 8px; background: var(--ink); color: var(--surface); cursor: pointer; }
.gd-copy:hover { opacity: .85; }
.gd-codecell { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.gd-codecell .gd-copy { position: static; flex: none; width: 24px; height: 24px; border-radius: 6px; }
.gd-codecell .gd-copy svg { width: 13px; height: 13px; }
.gd-demo { margin: 12px 0; padding: 12px 14px; border: 1px solid var(--accent); border-radius: 10px; }
.gd-demotop { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 10px; margin-bottom: 8px; }
.gd-bars > div { display: grid; grid-template-columns: auto minmax(0, 1fr) 52px; align-items: center; gap: 8px; padding: 2px 0; }
.gd-bars span { height: 12px; border-radius: 3px; background: var(--surface-2); overflow: hidden; }
.gd-bars i { display: block; height: 100%; border-radius: 3px; background: var(--accent); }
.gd-bars b { font-size: 12.5px; font-weight: 600; text-align: right; }
.gd-out { margin: 8px 0 0; color: var(--ink-2); font-size: 13.5px; }
.gd-error { margin: 8px 0 0; color: var(--danger); font-size: 13.5px; }
.gd-editor { display: block; width: 100%; height: auto; min-height: 120px; padding: 10px 46px 10px 12px; font-size: 12.5px; line-height: 1.5; resize: vertical; overflow: hidden; white-space: pre; overflow-x: auto; }
.gd-slider { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; margin-bottom: 8px; font-size: 13.5px; }
.gd-slider span { min-width: 110px; font-weight: 600; }
.gd-slider input { flex: 1; min-width: 140px; }
.gd-formula { margin: 10px 0; padding: 16px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-2); overflow-x: auto; }
.gd-formula math { font-family: 'Cambria Math', 'STIX Two Math', 'Latin Modern Math', math; font-size: 1.3em; }
.gd-arch { margin: 12px 0; }
.gd-box { display: flex; flex-direction: column; gap: 3px; padding: 10px 12px; border: 1px solid var(--line-2); border-radius: 8px; }
.gd-box.main { border-color: var(--accent); background: var(--accent-soft); }
.gd-box span { color: var(--ink-2); font-size: 13px; }
.gd-arrows, .gd-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.gd-arrows { padding: 2px 0; color: var(--muted); text-align: center; }
.gd-arrows i { font-style: normal; }
.gd-flow { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 8px 0; font-size: 13px; }
.gd-flow span { padding: 5px 10px; border: 1px solid var(--line-2); border-radius: 14px; }
.gd-flow i { color: var(--muted); font-style: normal; }
/* Below this width the whole page scrolls, not this section, and the side list must stick to the page. */
@media (max-width: 1180px) { body:has(.gd), #home:has(.gd) { overflow: visible; } }
@media (max-width: 820px) {
  .gd { display: block; padding: 0 14px; }
  .gd-side { position: static; max-height: 240px; padding: 14px 0 4px; border-bottom: 1px solid var(--line); }
  .gd-main { padding-top: 18px; }
  .gd-pair { grid-template-columns: 1fr; }
  .gd-arrows { grid-template-columns: 1fr; }
  .gd-arrows i + i { display: none; }
}

/* AI and Run inside Build */
#btn-ai, #btn-run { color: #fff; font-weight: 600; border-color: transparent; }
#btn-ai { background: linear-gradient(135deg, #5b5fe0, #a24fd8); }
#btn-run { background: linear-gradient(135deg, #16945a, #0f9d8a); }
#btn-ai:hover:not(:disabled), #btn-run:hover:not(:disabled) { filter: brightness(1.1); border-color: transparent; }
#btn-ai:hover:not(:disabled) { background: linear-gradient(135deg, #5b5fe0, #a24fd8); }
#btn-run:hover:not(:disabled) { background: linear-gradient(135deg, #16945a, #0f9d8a); }
#btn-ai.on, #btn-run.on { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--accent); }
body.present:not(.lesson-on) #btn-ai, body.present:not(.lesson-on) #btn-run { display: none; }
/* Keeps the top bar on one line on an ordinary laptop screen. */
@media (max-width: 1500px) { #nav button { padding: 0 5px; } #sel-examples { max-width: 90px; } #btn-ai, #btn-run { padding: 0 8px; } }
.code-foot { flex-wrap: wrap; }
.code-foot #code-lab { margin-left: auto; font-weight: 600; }
/* Build's Run panel */
.br h3 { margin: 0 0 8px; }
.br-facts { display: grid; grid-template-columns: repeat(4, 1fr); gap: 5px; margin-bottom: 8px; }
.br-facts div { display: flex; flex-direction: column; align-items: center; padding: 7px 2px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-2); }
.br-facts b { font-size: 16px; }
.br-facts span { color: var(--muted); font-size: 11px; }
.br-check { margin: 0 0 10px; padding: 6px 9px; border-radius: 7px; background: var(--good-soft); color: var(--good-ink); font-size: 12.5px; }
.br-check.bad { background: var(--warn-soft); color: var(--warn); }
.br-label { display: block; margin: 10px 0 4px; font-weight: 600; font-size: 13px; }
.br-label small { color: var(--muted); font-weight: 400; }
.br .note { margin: 4px 0 0; }
.br-choices { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 5px; }
.br-error { margin: 8px 0 0; color: var(--danger); font-size: 12.5px; }
.br-go { width: 100%; height: 38px; margin-top: 12px; border: none; border-radius: 8px; background: linear-gradient(135deg, #16945a, #0f9d8a); color: #fff; font-weight: 600; cursor: pointer; }
.br-go:hover:not(:disabled) { filter: brightness(1.1); }
.br-go:disabled { opacity: .45; cursor: default; }
.br-done { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 10px; padding: 9px 10px; border: 1px solid var(--good); border-radius: 8px; background: var(--good-soft); }
.br-done div { display: flex; flex-direction: column; font-size: 12.5px; }
.br-done button { flex: none; height: 28px; padding: 0 9px; border: 1px solid var(--line-2); border-radius: 7px; background: var(--surface); font-size: 12.5px; cursor: pointer; }
.br-recent { margin-top: 14px; padding-top: 10px; border-top: 1px solid var(--line); }
.br-recenttop { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.br-recenttop h4 { margin: 0; }
.br-recenttop button { border: none; background: none; color: var(--accent); font-size: 12px; cursor: pointer; text-decoration: underline; }
.br-run { display: flex; flex-direction: column; width: 100%; padding: 6px 8px; border: none; border-radius: 6px; background: none; text-align: left; font-size: 12.5px; cursor: pointer; }
.br-run:hover { background: var(--surface-2); }
.br-run span { color: var(--muted); font-size: 11.5px; }
/* The run report */
.rr-back { padding: 0; border: none; background: none; color: var(--ink-2); cursor: pointer; }
.rr-head { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 10px; margin: 8px 0 14px; }
.rr-head h1 { margin: 0 0 4px; }
.rr-head h1 code { margin-left: 8px; color: var(--muted); font-size: .75em; font-weight: 400; }
.rr-head p { margin: 0; color: var(--ink-2); font-size: 13.5px; }
.rr-status { color: var(--good-ink); font-weight: 600; }
.rr-actions { display: flex; gap: 6px; }
.rr-actions button, .rr-explain button, .rr-circuithead button, .rr-downloads button { height: 34px; padding: 0 12px; border: 1px solid var(--line-2); border-radius: 8px; background: var(--surface); cursor: pointer; }
.rr-actions .primary { border-color: var(--accent); background: var(--accent); color: var(--on-accent); font-weight: 600; }
.rr-explain { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 16px; border: 1px solid var(--accent); border-radius: 10px; background: var(--accent-soft); }
.rr-explain p { margin: 3px 0 0; color: var(--ink-2); font-size: 13.5px; }
.rr-explain button { border: none; background: linear-gradient(135deg, #5b5fe0, #a24fd8); color: #fff; font-weight: 600; }
.rr-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 10px; margin: 14px 0 22px; }
.rr-tiles > div { display: flex; flex-direction: column; gap: 4px; padding: 14px 16px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.rr-tiles span, .rr-tiles small { color: var(--muted); font-size: 12.5px; }
.rr-tiles b { font-size: 24px; }
.rr h2 { margin: 18px 0 8px; font-size: 18px; }
.rr-table { width: 100%; border-collapse: collapse; font-size: 13.5px; background: var(--surface); }
.rr-table th { padding: 7px 10px; border-bottom: 1px solid var(--line-2); color: var(--muted); font-weight: 600; text-align: right; white-space: nowrap; }
.rr-table th:first-child { text-align: left; }
.rr-table td { padding: 7px 10px; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; }
.rr-table td:first-child { text-align: left; }
.rr-barcell { width: 50%; min-width: 80px; }
.rr-barcell span { display: block; height: 10px; border-radius: 5px; background: var(--surface-2); overflow: hidden; }
.rr-barcell i { display: block; height: 100%; border-radius: 5px; background: var(--accent); }
.rr-downloads { display: flex; align-items: center; gap: 6px; margin-top: 8px; color: var(--muted); font-size: 13.5px; }
.rr-downloads button { height: 28px; color: var(--ink); }
.rr-circuithead { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 18px; }
.rr-circuithead h2 { margin: 0; }
.rr-circuithead button { height: 28px; font-size: 12.5px; }
.rr-qasm { margin: 8px 0 0; padding: 12px 14px; overflow-x: auto; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-2); font-size: 12.5px; line-height: 1.5; }

/* The Runs page */
.rl-latest { font-size: 18px !important; line-height: 1.6; }
.rl-tools { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.rl-tools .field { max-width: 300px; height: 34px; }
.rl-table th, .rl-table td { text-align: left; }
.rl-table th:nth-child(4), .rl-table td:nth-child(4) { text-align: right; }
.rl-id { padding: 0; border: none; background: none; color: var(--accent); font-size: 13px; text-decoration: underline; cursor: pointer; }
.rl-status { padding: 2px 8px; border-radius: 10px; background: var(--good-soft); color: var(--good-ink); font-size: 12.5px; }
.rl-open { padding: 0; border: none; background: none; color: var(--ink); font-weight: 600; cursor: pointer; }
.rl-open:hover { text-decoration: underline; }
.rl-empty { padding: 24px; border: 1px dashed var(--line-2); border-radius: 10px; color: var(--ink-2); text-align: center; }
.br-all { margin-top: 6px; padding: 0; border: none; background: none; color: var(--accent); font-size: 12.5px; cursor: pointer; text-decoration: underline; }

/* Formatted AI answers */
.ai-md { line-height: 1.55; overflow-wrap: anywhere; }
.ai-md > :first-child { margin-top: 0; }
.ai-md > :last-child { margin-bottom: 0; }
.ai-md p { margin: .6em 0; }
.ai-md h3, .ai-md h4, .ai-md h5, .ai-md h6 { margin: 1em 0 .4em; line-height: 1.3; }
.ai-md h3 { font-size: 1.2em; } .ai-md h4 { font-size: 1.1em; } .ai-md h5, .ai-md h6 { font-size: 1em; }
.ai-md ul, .ai-md ol { margin: .5em 0; padding-left: 1.4em; }
.ai-md li { margin: .25em 0; }
.ai-md hr { margin: 1em 0; border: none; border-top: 1px solid var(--line); }
.ai-md blockquote { margin: .6em 0; padding: 2px 10px; border-left: 3px solid var(--accent); color: var(--ink-2); }
.ai-md code { padding: 1px 4px; border-radius: 4px; background: var(--code-surface); font: .92em Consolas, monospace; }
.ai-md a { color: var(--accent); }
.md-tablebox { margin: .6em 0; overflow-x: auto; }
.ai-md table { border-collapse: collapse; font-size: .95em; }
.ai-md th, .ai-md td { padding: 4px 9px; border: 1px solid var(--line); text-align: left; vertical-align: top; overflow-wrap: normal; }
.ai-md th { background: var(--surface-2); font-weight: 600; }
.md-math { overflow-wrap: normal; }
.md-display { display: block; margin: .7em 0; overflow-x: auto; overflow-y: hidden; text-align: center; }
.md-display .katex-display { margin: 0; }
/* The explanation beside a report */
.home-in.rr.with-ai { max-width: 1560px; }
.rr-cols { display: block; }
.with-ai .rr-cols { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 18px; align-items: start; }
.rr-ai { position: sticky; top: 10px; display: flex; flex-direction: column; max-height: calc(100vh - 80px); min-height: 320px; border: 1px solid var(--accent); border-radius: 10px; background: var(--surface); }
.rr-aihead { display: flex; align-items: center; gap: 8px; padding: 9px 12px; border-bottom: 1px solid var(--line); }
.rr-grow { flex: 1; }
.rr-live { padding: 2px 9px; border-radius: 10px; background: var(--accent-soft); color: var(--accent); font-size: 12px; animation: lxc-pulse 1.4s ease-in-out infinite; }
@media (prefers-reduced-motion: reduce) { .rr-live { animation: none; } }
.rr-aihead button, .rr-aipick button { height: 28px; padding: 0 9px; border: 1px solid var(--line-2); border-radius: 7px; background: var(--surface); font-size: 12.5px; cursor: pointer; white-space: nowrap; }
.rr-aipick { display: flex; gap: 5px; padding: 8px 12px 0; }
.rr-aipick select { flex: 1; min-width: 0; }
.rr-aipick button { flex: none; border-color: var(--accent); color: var(--accent); font-weight: 600; }
.rr-cost { margin: 6px 12px 0; color: var(--ink-2); font-size: 11.5px; line-height: 1.4; }
.rr-aierror { margin: 8px 12px 0; color: var(--danger); font-size: 12.5px; }
.rr-aibody { flex: 1; min-height: 0; overflow-y: auto; padding: 10px 14px 16px; font-size: 14px; }
@media (max-width: 1180px) { body:has(.rr-ai), #home:has(.rr-ai) { overflow: visible; } }
@media (max-width: 1000px) { .with-ai .rr-cols { display: flex; flex-direction: column-reverse; } .rr-ai { position: static; max-height: none; width: 100%; } }

.rr-aisaved { padding: 8px 12px 0; }
.rr-aisaved label { display: block; margin-bottom: 3px; color: var(--muted); font-size: 11.5px; }
.rr-aisaved > div { display: flex; gap: 5px; }
.rr-aisaved select { flex: 1; min-width: 0; }
.rr-aisaved button { flex: none; height: 30px; padding: 0 9px; border: 1px solid var(--line-2); border-radius: 7px; background: var(--surface); font-size: 12.5px; cursor: pointer; }
.rr-downloads { flex-wrap: wrap; }
.rr-all { display: inline-flex; align-items: center; gap: 5px; color: var(--ink-2); font-size: 12.5px; }
.rl-ai { padding: 1px 8px; border: 1px solid var(--accent); border-radius: 10px; background: var(--accent-soft); color: var(--accent); font-size: 12px; font-weight: 600; cursor: pointer; white-space: nowrap; }

.rr-translate { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px; margin: 8px 12px 0; padding: 6px 9px; border-radius: 7px; background: var(--accent-soft); font-size: 12.5px; }
.rr-translate button { height: 26px; padding: 0 9px; border: 1px solid var(--accent); border-radius: 6px; background: var(--surface); color: var(--accent); font-size: 12.5px; font-weight: 600; cursor: pointer; }
.rr-dlnote:empty { display: none; }
.rr-veil { position: fixed; inset: 0; z-index: 1000; display: flex; align-items: center; justify-content: center; padding: 16px; background: rgba(0, 0, 0, .5); }
.rr-modal { display: flex; flex-direction: column; width: min(760px, 100%); max-height: calc(100vh - 32px); padding: 16px 18px; overflow-y: auto; border: 1px solid var(--line-2); border-radius: 12px; background: var(--surface); color: var(--ink); }
.rr-modal h3 { margin: 0 0 10px; font-size: 17px; }
.rr-modalfoot { display: flex; justify-content: flex-end; margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--line); }
.rr-modalfoot button { height: 34px; padding: 0 16px; border: 1px solid var(--accent); border-radius: 8px; background: var(--accent); color: var(--on-accent); font-weight: 600; cursor: pointer; }

.rr-status.bad { color: var(--danger); }
.rl-status.failed { background: var(--danger-soft); color: var(--danger); }
.rl-status.stopped { background: var(--warn-soft); color: var(--warn); }
.rr-output { max-height: 420px; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; }

/* ---------- Phones ---------- */
#btn-menu { display: none; }
@media (max-width: 820px) {
  html, body { height: auto; overflow-x: hidden; }
  body { min-height: 100vh; min-height: 100dvh; overflow-y: auto; }
  /* A phone zooms in on any box whose text is smaller than this. */
  input, select, textarea { font-size: 16px; }
  .topbar { position: sticky; top: 0; z-index: 60; gap: 6px; padding: 6px 8px; }
  .topbar #btn-menu { display: grid; place-items: center; width: 38px; height: 38px; padding: 0; }
  .topbar .brand { flex: 1; min-width: 0; padding: 0; }
  .tb-spacer { display: none; }
  #nav, .tb-group.prefs { display: none; width: 100%; }
  body.menu-open #nav { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; }
  .topbar #nav button { height: 40px; padding: 0 10px; border-radius: 8px; text-align: left; }
  body.menu-open .tb-group.prefs { display: flex; flex-wrap: wrap; gap: 6px; padding: 6px 0 2px; border-left: none; border-top: 1px solid var(--line); }
  .tb-group.prefs select, .tb-group.prefs button { height: 36px; }
  .tb-group.work-only { order: 5; width: 100%; padding: 0 0 2px; border-left: none; flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .tb-group.work-only > * { flex: none; }
  .tb-group.work-only button, .tb-group.work-only select { height: 34px; }
  #sel-examples { max-width: 130px; }
  /* In Build the circuit comes first, with the notes after it. */
  #center { min-width: 0; }
  #side { width: 100% !important; min-width: 0; }
  body.circuit-first #side { order: 3; }
  body.circuit-first #center { order: 1; }
  #code-panel { min-width: 0; }
  #palette { flex-wrap: wrap; }
  .pal-item { min-width: 40px; height: 40px; }
  #stepbar { flex-wrap: wrap; }
  #toolbar { flex-wrap: wrap; }
  #tabs { overflow-x: auto; flex-wrap: nowrap; }
  #tabs button { flex: none; }
  .home-in { padding: 18px 14px 30px; }
  .rr-actions { flex-wrap: wrap; }
  .rr-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .rr-tiles > div { min-width: 0; overflow-wrap: anywhere; }
  .with-ai .rr-cols > * { width: 100%; min-width: 0; }
  .rr-tiles b { font-size: 19px; }
  .rl-tools .field { max-width: none; }
  .rr-modal { padding: 12px; }
}

@media (max-width: 820px) {
  #canvas, #lx-canvas { touch-action: pan-x pan-y; }
  #canvas .op, #lx-canvas .op { touch-action: none; }
  .gd-side { max-height: none; padding-bottom: 8px; }
  .gd-side nav { display: none; }
  .gd-side.open nav { display: block; max-height: 60vh; overflow-y: auto; }
  .gd-toc { display: block; width: 100%; height: 38px; border: 1px solid var(--line-2); border-radius: 8px; background: var(--surface); text-align: left; padding: 0 12px; }
  .lx-fab { position: fixed; right: 14px; bottom: 16px; z-index: 40; height: 46px; padding: 0 18px; border: none; border-radius: 23px; background: linear-gradient(135deg, #16945a, #0f9d8a); color: #fff; font-weight: 700; box-shadow: 0 4px 14px rgba(0, 0, 0, .35); }
  .lx-status { padding-bottom: 70px; }
  .lx-main { height: auto; min-height: 70vh; }
}
.gd-toc, .lx-fab { display: none; }
@media (max-width: 820px) { .gd-toc { display: block; } .lx-fab { display: block; } }

/* ---------- your sister's list ---------- */
.classes button:not(.link-btn), .my-progress button { min-height: 32px; padding: 3px 12px; border: 1px solid var(--line-2); border-radius: 7px; background: var(--surface); color: var(--ink); font-size: 13.5px; cursor: pointer; }
.classes button:not(.link-btn):hover, .my-progress button:hover { border-color: var(--accent); }
.classes button.primary, .my-progress button.primary { border-color: var(--accent); background: var(--accent); color: var(--on-accent); font-weight: 600; }
.classes button.danger { border-color: var(--danger); color: var(--danger); }
.cls-tabs { display: flex; gap: 4px; margin-top: 16px; overflow-x: auto; border-bottom: 1px solid var(--line); }
.classes .cls-tabs button { flex: none; min-height: 38px; border: none; border-bottom: 2px solid transparent; border-radius: 0; background: none; color: var(--muted); font-weight: 600; }
.classes .cls-tabs button.on { border-bottom-color: var(--accent); color: var(--accent); }
.classes section[hidden] { display: none; }
.classes .cls-tabs + section { margin-top: 14px; }
.topics { border-collapse: collapse; font-size: 13px; }
.topics th { max-width: 110px; padding: 6px 8px; border-bottom: 1px solid var(--line-2); color: var(--muted); font-weight: 600; text-align: center; vertical-align: bottom; }
.topics th:first-child, .topics td:first-child { position: sticky; left: 0; background: var(--bg); text-align: left; }
.topics td { padding: 6px 8px; border-bottom: 1px solid var(--line); text-align: center; white-space: nowrap; font-variant-numeric: tabular-nums; color: var(--muted); }
.topics td.some { background: var(--accent-soft); color: var(--ink); }
.topics td.full { background: var(--good-soft); color: var(--good-ink); font-weight: 700; }
.link-btn { padding: 0; border: none; background: none; color: var(--accent); font: inherit; font-weight: 600; text-decoration: underline; cursor: pointer; }
.topic-who { margin-top: 14px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; }
.topic-who h3 { margin: 0; }
.topic-unit { padding: 6px 0; border-top: 1px solid var(--line); }
.topic-unit summary { font-weight: 600; cursor: pointer; }
.topic-unit summary small { margin-left: 6px; color: var(--muted); font-weight: 400; }
.topic-unit ul { margin: 6px 0 2px; padding: 0; list-style: none; columns: 2 260px; font-size: 13.5px; }
.topic-unit li { padding: 2px 0; color: var(--muted); break-inside: avoid; }
.topic-unit li.yes { color: var(--ink); }
.topic-unit li i { display: inline-block; width: 18px; font-style: normal; font-weight: 700; }
.topic-unit li.yes i { color: var(--good-ink); }
#resume-bar { position: fixed; left: 50%; bottom: 18px; z-index: 45; max-width: calc(100vw - 110px); transform: translateX(-50%); padding: 9px 16px; overflow: hidden; border: none; border-radius: 20px; background: var(--accent); color: var(--on-accent); font-weight: 600; font-size: 13.5px; text-overflow: ellipsis; white-space: nowrap; box-shadow: 0 6px 20px rgba(0, 0, 0, .35); cursor: pointer; }
#resume-bar[hidden] { display: none; }
.lo-bloch { margin-top: 12px; padding-top: 8px; border-top: 1px solid var(--line); }
.lo-bloch summary { font-weight: 600; cursor: pointer; }
.lo-bloch summary small { margin-left: 6px; color: var(--muted); font-weight: 400; }
.lo-bcircuits, .lo-bsteps { display: flex; align-items: center; gap: 6px; margin-top: 8px; flex-wrap: wrap; font-size: 12.5px; color: var(--muted); }
.lo-bcircuits button, .lo-bsteps button { min-width: 28px; height: 26px; padding: 0 7px; border: 1px solid var(--line-2); border-radius: 6px; background: var(--surface); color: var(--ink); cursor: pointer; }
.lo-bcircuits button.on { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); font-weight: 700; }
.lo-bsteps input { flex: 1; min-width: 120px; }
.lo-bspheres { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.lo-bspheres div { display: flex; flex-direction: column; align-items: center; font-size: 12.5px; }
.lo-bnote { margin: 6px 0 0; color: var(--muted); font-size: 12px; }
@media (max-width: 1180px) { .lx-bottom { height: 320px; flex: none; } }

/* ---------- the Classes page ---------- */
.ch { max-width: 1040px; }
.ch-hero { display: flex; flex-wrap: wrap; gap: 18px; align-items: center; justify-content: space-between; padding: 22px 24px; border: 1px solid var(--line); border-radius: 16px; background: linear-gradient(120deg, var(--accent-soft), var(--surface) 70%); }
.ch-hero h1 { margin: 0; }
.ch-hero p { margin: 4px 0 0; color: var(--muted); }
.ch-stats { display: flex; gap: 8px; margin: 0; }
.ch-stats div { min-width: 86px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 11px; background: var(--surface); text-align: center; }
.ch-stats dd { margin: 0; font-size: 22px; font-weight: 700; line-height: 1.2; color: var(--accent); }
.ch-stats dt { color: var(--muted); font-size: 12px; }
.ch-actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 14px; margin-top: 14px; }
.classes section.ch-action { display: flex; flex-direction: column; margin: 0; padding: 18px 20px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
.ch-action h2 { margin: 0; font-size: 17px; }
.ch-action p:not(.cl-msg) { flex: 1; margin: 6px 0 12px; color: var(--muted); font-size: 13.5px; line-height: 1.5; }
.ch-form { display: flex; gap: 8px; }
.ch-form input { flex: 1; min-width: 0; height: 40px; border-radius: 9px; }
.classes .ch-form button.primary { flex: none; min-height: 40px; padding: 0 18px; border-radius: 9px; white-space: nowrap; }
.classes section.ch-part { margin-top: 26px; }
.ch-part > h2 { margin: 0 0 10px; font-size: 18px; }
.ch-class { margin-top: 12px; padding: 16px 18px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
.ch-class-top { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.ch-mark { display: grid; flex: none; place-items: center; width: 42px; height: 42px; border-radius: 11px; background: var(--accent); color: var(--on-accent); font-size: 18px; font-weight: 700; }
.ch-class-name { flex: 1; min-width: 150px; }
.ch-class-name h3 { margin: 0; font-size: 16px; }
.ch-class-name small, .ch-whole small { color: var(--muted); }
.ch-whole { text-align: right; }
.ch-whole b { display: block; font-size: 18px; color: var(--accent); line-height: 1.1; }
.ch-whole small { font-size: 12px; }
.classes button.ch-ghost { border-color: transparent; background: none; color: var(--muted); }
.classes button.ch-ghost:hover { border-color: var(--danger); color: var(--danger); }
.ch-empty { margin: 12px 0 0; color: var(--muted); font-size: 13.5px; }
.ch-hw { margin-top: 12px; border: 1px solid var(--line); border-radius: 11px; overflow: hidden; }
.ch-hw summary { display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; align-items: center; padding: 11px 14px; background: var(--surface-2); cursor: pointer; list-style: none; }
.ch-hw summary::-webkit-details-marker { display: none; }
.ch-hw-title { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.ch-hw-count { color: var(--muted); font-size: 12.5px; }
.ch-chip { padding: 1px 9px; border-radius: 20px; background: var(--accent-soft); color: var(--accent); font-size: 12px; font-style: normal; font-weight: 600; }
.ch-chip.good { background: var(--good-soft); color: var(--good-ink); }
.ch-chip.late { background: var(--danger); color: #fff; }
.ch-bar { grid-column: 1 / -1; height: 5px; overflow: hidden; border-radius: 3px; background: var(--line); }
.ch-bar i { display: block; height: 100%; border-radius: 3px; background: var(--accent); }
.ch-items { padding: 4px; }
.classes button.ch-item { display: flex; width: 100%; min-height: 40px; gap: 10px; align-items: center; padding: 6px 10px; border: none; border-radius: 8px; background: none; color: var(--ink); font-size: 14px; text-align: left; }
.classes button.ch-item:hover { background: var(--accent-soft); }
.ch-tick { display: grid; flex: none; place-items: center; width: 20px; height: 20px; border: 2px solid var(--line-2); border-radius: 50%; color: #fff; font-size: 12px; font-weight: 700; }
.ch-item.yes .ch-tick { border-color: var(--good); background: var(--good); }
.ch-item.yes .ch-name { color: var(--muted); }
.ch-name { flex: 1; min-width: 0; }
.ch-item small { flex: none; color: var(--muted); font-size: 12px; }
.ch-go { flex: none; color: var(--muted); font-size: 18px; line-height: 1; }
.ch-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.classes button.ch-taught { display: flex; gap: 12px; align-items: center; padding: 14px 16px; border-radius: 14px; background: var(--surface); text-align: left; }
.classes button.ch-taught:hover { border-color: var(--accent); }
.ch-taught-name { flex: 1; min-width: 0; }
.ch-taught-name b { display: block; overflow: hidden; font-size: 15px; text-overflow: ellipsis; white-space: nowrap; }
.ch-taught-name code { color: var(--muted); font-size: 12.5px; letter-spacing: .08em; }
@media (max-width: 640px) { .ch-hero { padding: 16px; } .ch-stats { width: 100%; } .ch-stats div { flex: 1; min-width: 0; } .ch-item small { display: none; } }

/* ---------- reading lessons ---------- */
.ac { max-width: 1120px; margin: 0 auto; padding: 18px 20px 60px; }
.ac-hero { padding: 22px 26px; border-radius: 16px; background: linear-gradient(120deg, var(--accent), #6a3fb8); color: #fff; }
.ac-hero h1 { margin: 10px 0 0; font-size: 30px; line-height: 1.2; color: #fff; }
.ac-up { padding: 3px 11px; border: 1px solid rgba(255,255,255,.45); border-radius: 7px; background: none; color: #fff; font-size: 13px; cursor: pointer; }
.ac-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.ac-tags span { padding: 1px 9px; border-radius: 20px; background: rgba(255,255,255,.18); font-size: 12px; }
.ac-goals { margin-top: 14px; font-size: 14px; }
.ac-goals ul { margin: 4px 0 0; padding-left: 20px; }
.ac-layout { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 26px; margin-top: 20px; align-items: start; }
.ac-toc { position: sticky; top: 12px; display: flex; flex-direction: column; gap: 2px; font-size: 13px; }
.ac-toc > b { margin-bottom: 4px; }
.ac-toc a { padding: 4px 8px; border-left: 2px solid var(--line); color: var(--muted); cursor: pointer; }
.ac-toc a:hover { border-left-color: var(--accent); color: var(--accent); }
.ac-meter { margin-top: 12px; color: var(--muted); font-size: 12px; }
.ac-meter i { display: block; height: 5px; margin-top: 4px; overflow: hidden; border-radius: 3px; background: var(--line); }
.ac-meter u { display: block; height: 100%; background: var(--good); }
.ac-body { display: flex; flex-direction: column; gap: 16px; min-width: 0; font-size: 15.5px; line-height: 1.65; }
.ac-body .ai-md h2 { margin: 18px 0 6px; font-size: 22px; }
.ac-body .ai-md h3 { font-size: 17px; }
.ac-body figure { margin: 0; }
.ac-note { padding: 12px 15px; border-left: 4px solid var(--accent); border-radius: 0 10px 10px 0; background: var(--accent-soft); font-size: 14.5px; }
.ac-note.warn { border-left-color: var(--danger); background: color-mix(in srgb, var(--danger) 12%, transparent); }
.ac-note.real { border-left-color: var(--good); background: var(--good-soft); }
.ac-py, .ac-lab, .ac-check, .ac-quiz { padding: 13px 15px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.ac-py figcaption, .ac-lab figcaption { margin-bottom: 8px; font-size: 14.5px; }
.ac-bar { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 6px; color: var(--muted); font-size: 12.5px; }
.ac-bar > span { margin-right: auto; font-weight: 600; }
.ac-bar.end { justify-content: flex-end; margin: 10px 0 0; }
.ac button { min-height: 30px; padding: 2px 11px; border: 1px solid var(--line-2); border-radius: 7px; background: var(--surface); color: var(--ink); font-size: 13px; cursor: pointer; }
.ac button.primary { border-color: var(--accent); background: var(--accent); color: var(--on-accent); font-weight: 600; }
.ac button:disabled { opacity: .6; cursor: default; }
.ac-hero .ac-up { background: none; color: #fff; border-color: rgba(255,255,255,.45); }
.ac-py textarea { display: block; width: 100%; box-sizing: border-box; padding: 10px 12px; overflow: hidden; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--ink); font: 13px/1.5 ui-monospace, Consolas, monospace; resize: none; white-space: pre; overflow-x: auto; }
.acp-out { max-height: 300px; margin: 8px 0 0; padding: 10px 12px; overflow: auto; border-radius: 8px; background: var(--surface-2); font: 13px/1.5 ui-monospace, Consolas, monospace; white-space: pre-wrap; }
.acl-pic { overflow-x: auto; }
.acc { display: block; width: 100%; height: auto; }
.acc-wire, .acc-link { stroke: var(--muted); stroke-width: 1.4; fill: none; }
.acc-q { fill: var(--muted); font: 11px ui-monospace, Consolas, monospace; }
.acc-box { fill: var(--accent); }
.acc-box.m { fill: var(--muted); }
.acc-t { fill: var(--on-accent); font: 700 12px system-ui, sans-serif; text-anchor: middle; }
.acc-dot { fill: var(--ink); }
.acc-plus { fill: var(--surface); stroke: var(--ink); stroke-width: 1.4; }
.acc-bar { stroke: var(--muted); stroke-dasharray: 4 3; }
.acl-param { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 8px; font-size: 13px; color: var(--muted); }
.acl-param span { min-width: 92px; }
.acl-param input { flex: 1; min-width: 120px; }
.acl-param output { width: 42px; text-align: right; font-variant-numeric: tabular-nums; }
.acl-result { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 10px; align-items: flex-start; }
.acl-out { flex: 1; min-width: 210px; }
.acl-bar { display: grid; grid-template-columns: auto 1fr 54px; gap: 8px; align-items: center; margin-bottom: 3px; font-size: 13px; }
.acl-bar span { height: 11px; overflow: hidden; border-radius: 3px; background: var(--line); }
.acl-bar i { display: block; height: 100%; background: var(--accent); }
.acl-bar b { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.acl-spheres { display: flex; flex-wrap: wrap; gap: 6px; }
.acl-spheres div { display: flex; flex-direction: column; align-items: center; font-size: 12px; }
.ac-check > b, .ac-qhead b { color: var(--accent); font-size: 13px; }
.ac-check details { margin-top: 8px; }
.ac-check summary { color: var(--accent); font-weight: 600; cursor: pointer; }
.ac-quiz.right { border-color: var(--good); }
.ac-quiz.wrong { border-color: var(--danger); }
.ac-opts { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.ac-opt { display: flex; gap: 10px; align-items: flex-start; padding: 8px 11px; border: 1px solid var(--line); border-radius: 9px; cursor: pointer; }
.ac-opt:hover { border-color: var(--accent); }
.ac-opt input { position: absolute; opacity: 0; }
.ac-opt:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.ac-opt.good { border-color: var(--good); background: var(--good-soft); }
.ac-opt.bad { border-color: var(--danger); }
.ac-opt:has(input:focus-visible) { outline: 2px solid var(--accent); }
.ac-letter { display: grid; flex: none; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: var(--line); font-size: 12px; font-weight: 700; }
.ac-qbtns { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 10px; }
.ac-qsays { font-size: 13px; font-weight: 600; }
.ac-qtext { margin-top: 10px; padding: 9px 12px; border-radius: 9px; background: var(--surface-2); font-size: 14px; }
.ac-end { display: flex; justify-content: space-between; gap: 10px; margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--line); }
.ac .ac-end button { min-height: 40px; padding: 0 18px; border-radius: 9px; font-size: 14px; }
@media (max-width: 900px) { .ac-layout { grid-template-columns: minmax(0, 1fr); } .ac-toc { position: static; } .ac-toc a { display: none; } .ac-hero h1 { font-size: 24px; } }

/* ---------- the optional shortcuts box ---------- */
#btn-shortcuts.on { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
#shortcuts-box { position: fixed; right: 14px; bottom: 14px; z-index: 55; width: 190px; padding: 8px; border: 1px solid var(--line-2); border-radius: 12px; background: var(--surface); box-shadow: 0 6px 22px rgba(0, 0, 0, .3); font-size: 13px; }
#shortcuts-box.folded { width: auto; }
.sc-head { display: flex; gap: 4px; align-items: center; }
.sc-head b { flex: 1; padding: 0 4px; }
#shortcuts-box .sc-head button { width: 26px; height: 26px; padding: 0; border: none; border-radius: 6px; background: none; color: var(--muted); font-size: 15px; line-height: 1; cursor: pointer; }
#shortcuts-box .sc-head button:hover { background: var(--accent-soft); color: var(--accent); }
.sc-list { display: flex; flex-direction: column; gap: 4px; margin-top: 6px; }
#shortcuts-box .sc-list button { min-height: 32px; padding: 4px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-2); color: var(--ink); font-size: 13px; text-align: left; cursor: pointer; }
#shortcuts-box .sc-list button:hover { border-color: var(--accent); color: var(--accent); }
@media (max-width: 640px) { #shortcuts-box { right: 8px; bottom: 66px; } }
@media print { #shortcuts-box { display: none; } }

/* ---------- a student's Learn page ---------- */
.ch-start { margin: 16px 0 0; padding: 18px 20px; border: 1px dashed var(--line-2); border-radius: 14px; color: var(--muted); font-size: 15px; text-align: center; }
.ch-taught-name small { display: block; color: var(--muted); font-size: 12px; }
#nav button[hidden] { display: none; }

/* ---------- predictions, tasks and labelled blocks in reading lessons ---------- */
.ac-predict { margin-bottom: 10px; padding: 11px 13px; border: 1px dashed var(--accent); border-radius: 10px; background: var(--accent-soft); }
.ac-predict > b { color: var(--accent); font-size: 13px; }
.ac-task { padding: 13px 15px; border: 1px solid var(--line); border-left: 4px solid var(--accent); border-radius: 12px; background: var(--surface); }
.ac-task.right { border-color: var(--good); }
.ac-task.wrong { border-left-color: var(--danger); }
.ac-task textarea { display: block; width: 100%; box-sizing: border-box; padding: 10px 12px; overflow: hidden; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--ink); font: 13px/1.5 ui-monospace, Consolas, monospace; resize: none; white-space: pre; overflow-x: auto; }
.act-goal, .act-result { margin: 10px 0; font-size: 13px; }
.act-goal > span, .act-result > span { display: block; margin-bottom: 4px; color: var(--muted); font-weight: 600; }
.act-result:empty { display: none; }
.act-says { min-height: 1em; margin: 8px 0 0; font-size: 13.5px; font-weight: 600; }
.ac-block { padding: 12px 15px; border: 1px solid var(--line-2); border-radius: 10px; }
.ac-block > b { color: var(--accent); font-size: 12.5px; letter-spacing: .03em; text-transform: uppercase; }
.ac-proof { padding: 9px 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); font-size: 14.5px; }
.ac-proof summary { color: var(--accent); font-weight: 600; cursor: pointer; }

.lx-homebtn { display: inline-flex; flex: none; gap: 5px; align-items: center; height: 28px; margin-right: 8px; padding: 0 9px; border: 1px solid var(--line-2); border-radius: 7px; background: var(--surface); color: var(--ink); font-size: 12.5px; white-space: nowrap; cursor: pointer; }
.lx-homebtn:hover { border-color: var(--accent); color: var(--accent); }

.lx-prowrap { display: flex; gap: 6px; align-items: stretch; margin-top: 6px; }
.lx-prowrap .lx-prow { flex: 1; min-width: 0; margin-top: 0; }
.lx-prowmore { flex: none; width: 38px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--muted); cursor: pointer; }
.lx-prowmore:hover { border-color: var(--accent); color: var(--accent); }

.acct-edit { padding: 8px 10px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.acct-edit small { display: block; color: var(--muted); font-size: 12px; }
.acct-edit input { width: 100%; box-sizing: border-box; margin: 5px 0; }
.acct-btns { display: flex; gap: 6px; }
.acct-menu .acct-btns button { flex: 1; padding: 5px 8px; border: 1px solid var(--line-2); text-align: center; }
.acct-menu .acct-btns .acct-save { border-color: var(--accent); background: var(--accent); color: var(--on-accent); font-weight: 600; }
.acct-note { margin-top: 5px; }

.classes button.copied { border-color: var(--good); color: var(--good-ink); }
.classes button.cls-pen { min-height: 0; padding: 0 6px; border: none; background: none; color: var(--muted); font-size: 16px; font-weight: 400; vertical-align: middle; }
.classes button.cls-pen:hover { color: var(--accent); }
.cls-rename { flex: 1; min-width: 240px; }
.cls-rename input { flex: 1; min-width: 0; height: 38px; font-size: 18px; }
.hw-head button.hw-edit { margin-left: auto; }
.hw-head button.hw-edit + button { margin-left: 0; }
.hw-pick summary small { margin-left: 6px; color: var(--accent); font-weight: 400; }
#hw-cancel { margin-left: 6px; }

/* ---------- Topics, with nothing to slide ---------- */
.tp-row { display: grid; grid-template-columns: minmax(150px, 210px) minmax(0, 1fr); gap: 14px; align-items: start; padding: 12px 0; border-bottom: 1px solid var(--line); }
.tp-who small { display: block; margin: 2px 0 5px; color: var(--muted); font-size: 12px; }
.tp-who .ch-bar { display: block; }
.tp-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.tp-chip { display: inline-flex; gap: 8px; align-items: center; padding: 4px 10px; border: 1px solid var(--line); border-radius: 8px; color: var(--muted); font-size: 12.5px; }
.tp-chip b { font-variant-numeric: tabular-nums; font-weight: 600; }
.tp-chip.some { border-color: transparent; background: var(--accent-soft); color: var(--ink); }
.tp-chip.full { border-color: transparent; background: var(--good-soft); color: var(--good-ink); }
@media (max-width: 640px) { .tp-row { grid-template-columns: minmax(0, 1fr); } }

/* ---------- minimize, default size and maximize, for output and results ---------- */
.win-btn { display: inline-grid; flex: none; place-items: center; width: 28px; height: 26px; padding: 0; border: none; border-radius: 6px; background: none; color: var(--muted); cursor: pointer; }
.win-btn:hover { background: var(--line); color: var(--ink); }
.win-btn.on { color: var(--accent); }
.lx-ptabs .win-btn { align-self: center; padding: 0; box-shadow: none; }
.lx-psplit { flex: none; height: 8px; margin-bottom: -1px; cursor: ns-resize; position: relative; border-top: 1px solid var(--line); }
.lx-psplit::after { content: ""; position: absolute; left: 50%; top: 2px; width: 36px; height: 3px; margin-left: -18px; border-radius: 2px; background: var(--line-2); }
.lx-psplit:hover::after { background: var(--accent); }
.lx.nopanel .lx-psplit, .lx.panelmin .lx-psplit, .lx.panelmax .lx-psplit { display: none; }
.lx.panelmin .lx-bottom { flex: none; height: auto; min-height: 0; }
.lx.panelmin .lx-pbody { display: none; }
.lx.panelmax .lx-main > :not(.lx-bottom) { display: none; }
.lx.panelmax .lx-bottom { flex: 1; height: auto; min-height: 0; }
#dock-size { display: inline-flex; flex: none; gap: 1px; margin-left: 8px; }
#stepbar button.win-btn { width: 28px; height: 26px; border: none; background: none; }
#stepbar button.win-btn:hover { background: var(--line); }
@media (min-width: 1181px) {
  body.dock-max #build-card, body.dock-max #splitter { display: none; }
  body.dock-min #dirac-line, body.dock-min #tabs, body.dock-min #view { display: none; }
  body.dock-min #dock { flex: none; min-height: 0; }
  body.dock-min #build-card { flex: 1 1 0; max-height: none; }
}
@media (max-width: 1180px) {
  #dock-size, .lx-psplit { display: none; }
}

/* ---------- certificates a teacher has given ---------- */
.my-progress button.ch-taught { display: flex; gap: 12px; align-items: center; padding: 14px 16px; border-radius: 14px; background: var(--surface); text-align: left; }
.my-progress button.ch-taught:hover { border-color: var(--accent); }
.cert-stale { color: var(--muted); }
.cert-row button[data-recert] { margin-left: 6px; padding: 2px 10px; font-size: 12.5px; }

/* ---------- touch: a long press on the gates or the circuit starts a drag, never a text selection ---------- */
#build-card, #drag-ghost { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
#build-card input, #build-card textarea { -webkit-user-select: text; user-select: text; }
