/* Andromeda Atom — dark laboratory-instrument theme. */
:root {
  --bg: #07090f;
  --bg-2: #0b0f18;
  --panel: #0d1320;
  --panel-2: #111a2a;
  --line: #1c2a40;
  --line-2: #26385a;
  --text: #dbe7f5;
  --muted: #8396b1;
  --faint: #5b6c86;
  --accent: #41d9ff;
  --accent-2: #1fb2e0;
  --accent-soft: rgba(65, 217, 255, 0.12);
  --warn: #ffb547;
  --danger: #ff6b6b;
  --ok: #46e39a;
  --violet: #a78bfa;
  --radius: 8px;
  --font: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--text); font: 13px/1.45 var(--font); overflow: hidden; -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
.muted { color: var(--muted); }
.small { font-size: 11.5px; }
.mono { font-family: var(--mono); font-size: 12px; }
.noscript { padding: 24px; }
[hidden] { display: none !important; }

/* ------------------------------------------------------------------ top bar */
.topbar { height: 52px; display: flex; align-items: center; gap: 14px; padding: 0 14px; background: linear-gradient(180deg, #0c1220, #090d16); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; min-width: 182px; }
.brand-mark { width: 30px; height: 30px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-text strong { font-size: 14px; letter-spacing: .01em; }
.brand-text span { font-size: 10.5px; color: var(--muted); }
.search { flex: 0 1 230px; min-width: 140px; }
.search input { width: 100%; height: 32px; background: var(--bg-2); border: 1px solid var(--line-2); border-radius: 6px; padding: 0 10px; outline: none; }
.search input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.lens-tabs { display: flex; gap: 2px; flex: 1; overflow-x: auto; scrollbar-width: none; }
.lens-tab { position: relative; height: 32px; padding: 0 9px; border: 1px solid transparent; border-radius: 6px; background: none; color: var(--muted); cursor: pointer; white-space: nowrap; display: flex; align-items: center; gap: 6px; }
.lens-tab:hover { color: var(--text); background: var(--panel-2); }
.lens-tab.active { color: #04131b; background: var(--accent); font-weight: 600; }
.lens-tab .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .55; }
.lens-tab.speculative .dot { background: var(--warn); opacity: 1; }
.lens-tab.interpretation .dot { background: var(--violet); opacity: 1; }
.lens-tab .lock { font-size: 10px; opacity: .8; }
.top-actions { display: flex; align-items: center; gap: 8px; }
.chip { height: 28px; padding: 0 12px; border-radius: 14px; border: 1px solid var(--line-2); background: var(--panel); color: var(--text); cursor: pointer; font-weight: 600; font-size: 12px; }
.chip.pro { border-color: var(--accent-2); color: var(--accent); }
.chip.premium { border-color: #c9a2ff; color: #e2ccff; background: rgba(167, 139, 250, .1); }
.chip.trial { border-color: var(--warn); color: var(--warn); }
.icon-button { width: 32px; height: 32px; display: grid; place-items: center; border-radius: 6px; border: 1px solid var(--line-2); background: var(--panel); cursor: pointer; color: var(--muted); }
.icon-button:hover { color: var(--text); border-color: var(--accent-2); }
.icon-button svg { width: 18px; height: 18px; }

/* ------------------------------------------------------------------ layout */
.layout { display: grid; grid-template-columns: 196px 1fr 372px; height: calc(100% - 52px); }
.dock { border-right: 1px solid var(--line); background: var(--bg-2); overflow-y: auto; padding: 8px 6px 16px; }
.dock h3 { margin: 12px 8px 4px; font-size: 10.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: var(--faint); }
.dock-button { width: 100%; display: flex; align-items: center; gap: 9px; padding: 6px 8px; border: 1px solid transparent; border-radius: 6px; background: none; color: var(--text); cursor: pointer; text-align: left; }
.dock-button:hover { background: var(--panel-2); }
.dock-button.active { background: var(--accent-soft); border-color: rgba(65, 217, 255, .35); color: #eafaff; }
.dock-button .glyph { width: 22px; height: 22px; border-radius: 5px; display: grid; place-items: center; background: var(--panel-2); color: var(--accent); font-size: 12px; font-weight: 700; flex: none; }
.dock-button .tier { margin-left: auto; font-size: 9.5px; padding: 1px 5px; border-radius: 8px; border: 1px solid var(--line-2); color: var(--muted); }
.dock-button .tier.premium { color: #d9c2ff; border-color: #5b4a86; }
.dock-button .tier.locked::before { content: '🔒 '; }

.viewport { position: relative; overflow: hidden; background: #05070c; min-width: 0; }
#gl, #overlay { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
#gl { cursor: grab; touch-action: none; }
#gl.dragging { cursor: grabbing; }
#overlay { pointer-events: none; }
.hud { position: absolute; z-index: 2; }
.hud-subject { left: 14px; top: 12px; max-width: 46%; pointer-events: none; }
.hud-subject h1 { margin: 0; font-size: 20px; font-weight: 650; letter-spacing: .01em; }
.hud-subject .sub { color: var(--muted); font-size: 12px; margin-top: 2px; }
.badges { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 6px; }
.badge { display: inline-flex; align-items: center; height: 20px; padding: 0 8px; border-radius: 10px; font-size: 11px; border: 1px solid var(--line-2); color: var(--muted); background: rgba(7, 9, 15, .6); }
.badge.experimental { color: var(--ok); border-color: rgba(70, 227, 154, .4); }
.badge.model { color: var(--warn); border-color: rgba(255, 181, 71, .4); }
.badge.speculative { color: #1a1003; background: var(--warn); border-color: var(--warn); font-weight: 600; }
.badge.interpretation { color: #e3d7ff; border-color: #6a58a8; }
.badge.established { color: var(--accent); border-color: rgba(65, 217, 255, .4); }
.hud-controls { right: 12px; top: 52px; display: flex; flex-direction: column; gap: 6px; align-items: flex-end; }
.control-group { display: flex; gap: 2px; padding: 3px; background: rgba(11, 15, 24, .82); border: 1px solid var(--line); border-radius: 7px; backdrop-filter: blur(6px); }
.control-group button { height: 26px; padding: 0 9px; border: 0; border-radius: 5px; background: none; color: var(--muted); cursor: pointer; font-size: 12px; }
.control-group button:hover { color: var(--text); background: var(--panel-2); }
.control-group button.active { background: var(--accent-soft); color: var(--accent); }
.scale-ladder { position: absolute; right: 12px; bottom: 54px; z-index: 2; display: flex; flex-direction: column; gap: 3px; align-items: stretch; }
.scale-ladder button { display: flex; align-items: center; gap: 8px; height: 24px; padding: 0 8px; border-radius: 5px; border: 1px solid var(--line); background: rgba(11, 15, 24, .78); color: var(--muted); font-size: 11.5px; cursor: pointer; }
.scale-ladder button:hover { color: var(--text); border-color: var(--accent-2); }
.scale-ladder button.active { color: var(--accent); border-color: rgba(65, 217, 255, .5); }
.scale-ladder button span.m { font-family: var(--mono); font-size: 10.5px; color: var(--faint); margin-left: auto; padding-left: 10px; }
.lens-card { position: absolute; left: 14px; top: 96px; width: 320px; max-height: calc(100% - 160px); overflow-y: auto; z-index: 2; background: rgba(11, 15, 24, .88); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; backdrop-filter: blur(8px); }
.lens-card.collapsed .lens-details { display: none; }
.lens-card h2 { margin: 0; font-size: 13.5px; display: flex; align-items: center; gap: 8px; }
.lens-card p { margin: 6px 0; color: #c3d3e8; }
.lens-card ul { margin: 6px 0 4px; padding-left: 18px; color: var(--muted); }
.lens-card li { margin: 3px 0; }
.lens-card .toggle { margin-left: auto; background: none; border: 0; color: var(--muted); cursor: pointer; font-size: 12px; }
.lens-card .sources { font-size: 11px; color: var(--faint); }
.progress { position: absolute; left: 50%; top: 14px; transform: translateX(-50%); z-index: 3; width: 260px; padding: 7px 10px; border-radius: 7px; background: rgba(11, 15, 24, .9); border: 1px solid var(--line); font-size: 11.5px; color: var(--muted); }
.progress-bar { height: 3px; background: var(--accent); width: 0; border-radius: 2px; margin-bottom: 5px; transition: width .15s; }
.drawer { position: absolute; left: 0; right: 0; bottom: 0; z-index: 4; max-height: 78%; overflow: auto; background: rgba(9, 13, 21, .97); border-top: 1px solid var(--line-2); padding: 12px 14px 16px; backdrop-filter: blur(8px); }
.drawer-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.drawer-head h2 { margin: 0; font-size: 14px; }
.startup-error { position: absolute; inset: 0; display: grid; place-items: center; padding: 40px; text-align: center; color: var(--text); background: rgba(5, 7, 12, .92); z-index: 6; }

/* ------------------------------------------------------------------ inspector */
.inspector { border-left: 1px solid var(--line); background: var(--bg-2); overflow-y: auto; display: flex; flex-direction: column; }
.panel { padding: 12px 14px; border-bottom: 1px solid var(--line); }
.panel h2 { margin: 0 0 8px; font-size: 13.5px; display: flex; align-items: center; gap: 8px; }
.panel h3 { margin: 12px 0 6px; font-size: 11px; text-transform: uppercase; letter-spacing: .07em; color: var(--faint); font-weight: 600; }
.panel .model-note { font-size: 11.5px; color: var(--muted); border-left: 2px solid var(--accent-2); padding: 4px 8px; margin: 8px 0; background: rgba(65, 217, 255, .04); }
.panel .model-note.warn { border-color: var(--warn); background: rgba(255, 181, 71, .05); }
.instrument { flex: 1; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 3px 12px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }
.kv dd.left { text-align: left; }
table.data { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; font-size: 12px; }
table.data th { text-align: left; font-weight: 600; color: var(--muted); border-bottom: 1px solid var(--line-2); padding: 4px 6px; position: sticky; top: 0; background: var(--bg-2); }
table.data td { border-bottom: 1px solid var(--line); padding: 3px 6px; }
table.data td.num { text-align: right; }
table.data tr.selected td { background: var(--accent-soft); }
table.data tr.clickable { cursor: pointer; }
table.data tr.clickable:hover td { background: var(--panel-2); }
.field { display: flex; flex-direction: column; gap: 4px; margin: 6px 0; }
.field > span { color: var(--muted); font-size: 11.5px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row > .field { flex: 1; min-width: 90px; }
input[type="text"], input[type="number"], input[type="search"], select, textarea { background: var(--bg); border: 1px solid var(--line-2); border-radius: 6px; padding: 5px 8px; outline: none; min-width: 0; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
textarea { resize: vertical; font-family: var(--mono); font-size: 12px; }
input[type="range"] { accent-color: var(--accent); width: 100%; }
.button { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 30px; padding: 0 12px; border-radius: 6px; border: 1px solid var(--line-2); background: var(--panel-2); color: var(--text); cursor: pointer; text-decoration: none; font-size: 12.5px; }
.button:hover { border-color: var(--accent-2); }
.button.primary { background: var(--accent); color: #03131b; border-color: var(--accent); font-weight: 600; }
.button.primary:hover { background: #6be3ff; }
.button.ghost { background: none; }
.button.small { height: 24px; padding: 0 8px; font-size: 11.5px; }
.button:disabled { opacity: .45; cursor: default; }
.segmented { display: inline-flex; border: 1px solid var(--line-2); border-radius: 6px; overflow: hidden; }
.segmented button { border: 0; background: none; padding: 4px 9px; color: var(--muted); cursor: pointer; font-size: 12px; }
.segmented button.active { background: var(--accent-soft); color: var(--accent); }
.error { color: var(--danger); font-size: 12px; }
.ok { color: var(--ok); }
.warn { color: var(--warn); }
canvas.plot { width: 100%; height: 170px; display: block; background: var(--bg); border: 1px solid var(--line); border-radius: 6px; }
canvas.plot.tall { height: 240px; }
canvas.plot.strip { height: 74px; }
.lock-card { border: 1px dashed var(--line-2); border-radius: var(--radius); padding: 14px; text-align: center; background: rgba(167, 139, 250, .04); }
.lock-card h3 { margin: 0 0 6px; color: var(--text); text-transform: none; letter-spacing: 0; font-size: 13px; }
.lock-card p { margin: 0 0 10px; color: var(--muted); }

/* periodic table */
.ptable { display: grid; grid-template-columns: repeat(18, minmax(38px, 1fr)); gap: 3px; min-width: 760px; }
.ptable .cell { position: relative; aspect-ratio: 1 / 1.05; border-radius: 4px; border: 1px solid rgba(255, 255, 255, .06); padding: 2px 3px; cursor: pointer; display: flex; flex-direction: column; justify-content: space-between; background: var(--panel-2); color: #e7f1fb; }
.ptable .cell:hover { outline: 2px solid var(--accent); z-index: 1; }
.ptable .cell.current { outline: 2px solid #fff; }
.ptable .cell .z { font-size: 9px; color: rgba(255, 255, 255, .55); }
.ptable .cell .s { font-size: 14px; font-weight: 700; text-align: center; }
.ptable .cell .w { font-size: 8.5px; color: rgba(255, 255, 255, .55); text-align: center; }
.ptable .gap { grid-column: span 1; }
.cat-alkali { background: #3a1d2e; }
.cat-alkaline-earth { background: #3a2a1a; }
.cat-transition { background: #1b2a3f; }
.cat-post-transition { background: #1d3333; }
.cat-metalloid { background: #2d331a; }
.cat-nonmetal { background: #17352a; }
.cat-halogen { background: #1d3a1f; }
.cat-noble-gas { background: #2b2140; }
.cat-lanthanide { background: #33233a; }
.cat-actinide { background: #3b2026; }
.cat-unknown { background: #22262e; }
.legend { display: flex; flex-wrap: wrap; gap: 8px 14px; margin-top: 10px; font-size: 11px; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }

/* standard model chart */
.smgrid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; }
.smcell { border-radius: 6px; padding: 6px; border: 1px solid var(--line-2); background: var(--panel-2); cursor: pointer; min-height: 64px; }
.smcell:hover { border-color: var(--accent); }
.smcell.quark { background: #2a1a24; } .smcell.lepton { background: #16283a; } .smcell.gauge { background: #2c2716; } .smcell.scalar { background: #251a36; }
.smcell b { display: block; font-size: 16px; }
.smcell small { color: var(--muted); font-size: 10px; display: block; line-height: 1.25; }
.smcell.selected { outline: 2px solid var(--accent); }

/* composer */
.quark-picker { display: grid; grid-template-columns: repeat(6, 1fr); gap: 4px; }
.quark-picker button { height: 30px; border-radius: 6px; border: 1px solid var(--line-2); background: var(--panel-2); cursor: pointer; }
.quark-picker button:hover { border-color: var(--accent); }
.tokens { display: flex; flex-wrap: wrap; gap: 4px; min-height: 30px; padding: 4px; border: 1px dashed var(--line-2); border-radius: 6px; margin: 6px 0; }
.token { display: inline-flex; align-items: center; gap: 4px; padding: 2px 6px; border-radius: 12px; background: var(--panel-2); border: 1px solid var(--line-2); font-weight: 600; }
.token .c { width: 9px; height: 9px; border-radius: 50%; }
.token button { background: none; border: 0; color: var(--muted); cursor: pointer; padding: 0 2px; }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin: 4px 0 8px; }
.tabs button { background: none; border: 0; border-bottom: 2px solid transparent; padding: 6px 9px; color: var(--muted); cursor: pointer; }
.tabs button.active { color: var(--accent); border-bottom-color: var(--accent); }

/* assistant */
.chat { display: flex; flex-direction: column; gap: 8px; max-height: 300px; overflow-y: auto; margin: 6px 0; }
.msg { padding: 7px 9px; border-radius: 8px; background: var(--panel-2); white-space: pre-wrap; }
.msg.user { background: rgba(65, 217, 255, .1); align-self: flex-end; max-width: 90%; }
.msg.system { color: var(--muted); font-size: 12px; }

/* feynman */
svg.feynman { width: 100%; height: 150px; background: var(--bg); border: 1px solid var(--line); border-radius: 6px; }
svg.feynman text { fill: #cfe3f5; font: 11px var(--font); }

/* dialogs and toast */
.dialog { border: 1px solid var(--line-2); border-radius: 10px; background: var(--panel); color: var(--text); padding: 0; width: min(560px, 92vw); }
.dialog::backdrop { background: rgba(3, 5, 9, .72); }
.dialog-body { padding: 18px 20px; }
.dialog h2 { margin: 0 0 6px; font-size: 16px; }
.dialog-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; margin-top: 14px; }
.tiers { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 10px 0; }
.tier-card { border: 1px solid var(--line-2); border-radius: 8px; padding: 8px 10px; font-size: 12px; color: var(--muted); }
.tier-card b { display: block; color: var(--text); font-size: 13px; }
.tier-card.current { border-color: var(--accent); background: var(--accent-soft); }
.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 14px; }
.toast { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%) translateY(20px); opacity: 0; pointer-events: none; transition: all .2s; z-index: 50; background: #121b2c; border: 1px solid var(--line-2); padding: 8px 14px; border-radius: 8px; max-width: 560px; }
.toast.show { opacity: 1; transform: translateX(-50%); }

@media (max-width: 1180px) {
  .layout { grid-template-columns: 168px 1fr 320px; }
  .lens-card { width: 290px; }
  .brand { min-width: 0; }
  .brand-text span { display: none; }
}
@media (max-width: 860px) {
  body { overflow: auto; }
  .topbar { flex-wrap: wrap; height: auto; padding: 8px 12px; }
  .layout { display: flex; flex-direction: column; height: auto; }
  .dock { display: flex; flex-wrap: wrap; border-right: 0; border-bottom: 1px solid var(--line); }
  .dock h3 { width: 100%; }
  .dock-button { width: auto; }
  .viewport { height: 70vh; }
  .lens-card { display: none; }
  .inspector { border-left: 0; }
}

/* Account gate: Andromeda Atom runs only for a signed-in 14d.space account (no free tier). */
.chip.locked { border-color: var(--warn); color: var(--warn); }
.access-gate { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 24px 16px; overflow-y: auto;
  background: radial-gradient(ellipse at 50% 30%, rgba(20, 40, 80, .82), rgba(5, 7, 12, .96) 70%); backdrop-filter: blur(6px); }
.access-gate[hidden] { display: none; }
.gate-card { width: min(560px, 100%); background: linear-gradient(160deg, #0f1828, #0a101b); border: 1px solid var(--line-2); border-radius: 14px; padding: 30px 28px 24px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, .55); text-align: left; }
.gate-mark { width: 44px; height: 44px; display: block; margin-bottom: 14px; }
.gate-eyebrow { margin: 0 0 8px; color: var(--accent); font: 500 11px/1.4 var(--mono); letter-spacing: .14em; text-transform: uppercase; }
.gate-card h1 { margin: 0 0 10px; font-size: 24px; line-height: 1.2; letter-spacing: -.01em; font-weight: 650; }
.gate-text { margin: 0 0 18px; color: #b9c7da; font-size: 14px; line-height: 1.55; }
.gate-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.gate-actions .button { height: 36px; padding: 0 14px; font-size: 13px; }
.button.link { background: none; border-color: transparent; color: var(--accent); text-decoration: underline; text-underline-offset: 3px; padding: 0 4px; }
.gate-code { display: grid; gap: 4px; justify-items: start; margin: 0 0 18px; padding: 14px 16px; border: 1px dashed var(--line-2); border-radius: 10px; background: rgba(65, 217, 255, .05); }
.gate-code output { font: 600 30px/1.2 var(--mono); letter-spacing: .12em; color: #eafaff; }
.gate-key { display: grid; gap: 10px; margin-top: 16px; }
.gate-key textarea { width: 100%; background: var(--bg-2); border: 1px solid var(--line-2); border-radius: 6px; padding: 8px; font: 12px/1.4 var(--mono); resize: vertical; }
.gate-card .error { margin: 14px 0 0; }
.gate-fine { margin: 16px 0 0; }
body.gated .topbar, body.gated .layout { filter: blur(2px) saturate(.6); }
@media (max-width: 520px) { .gate-card { padding: 22px 18px; } .gate-card h1 { font-size: 20px; } .gate-actions .button { width: 100%; } }

/* ------------------------------------------------------------------ quantum lab (1.1): stage instruments cover the 3D view */
.lab { position: absolute; inset: 0; z-index: 6; display: flex; flex-direction: column; background: radial-gradient(ellipse at 50% 0%, #0b1426, #05070c 70%); overflow: auto; padding: 0 14px 14px; }
.lab-head { display: flex; align-items: baseline; gap: 10px; padding: 10px 0 8px; flex-wrap: wrap; }
.lab-head h1 { margin: 0; font-size: 17px; font-weight: 650; }
.lab-head .sub { color: var(--muted); font-size: 12px; }
.lab-head .button { margin-left: auto; align-self: center; }
.lab-eyebrow { font: 500 10.5px/1 var(--mono); letter-spacing: .14em; text-transform: uppercase; color: var(--violet); }
.lab .instrument-root { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 10px; }
.lab .view { position: relative; flex: 1; min-height: 260px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg); overflow: hidden; }
.lab .view canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.lab .view canvas.overlay { pointer-events: none; }
.lab .view .hud { position: absolute; left: 10px; top: 8px; font: 11.5px/1.5 var(--mono); color: var(--muted); background: rgba(5, 7, 12, .72); border: 1px solid var(--line); border-radius: 7px; padding: 4px 8px; pointer-events: none; }
.lab .view .hud b { color: var(--text); font-weight: 600; }
.lab .split-h { display: grid; grid-template-columns: minmax(0, 1fr) 230px; gap: 10px; flex: 1; min-height: 0; }
.lab .split-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; flex: 1; min-height: 0; }
.lab .split-h > *, .lab .split-2 > * { min-height: 0; }
.lab .state-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.lab canvas.plot, .lab-controls canvas.plot { width: 100%; height: 170px; display: block; background: var(--bg); border: 1px solid var(--line); border-radius: 7px; }
.lab canvas.plot.tall { height: 240px; }
.lab canvas.plot.fill { flex: 1; height: auto; min-height: 220px; }
.lab .palette { display: flex; flex-wrap: wrap; gap: 4px; }
.lab .palette button { min-width: 38px; height: 28px; padding: 0 6px; border-radius: 6px; border: 1px solid var(--line-2); background: var(--panel-2); cursor: pointer; font: 600 12px var(--mono); color: var(--text); }
.lab .palette button.active { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.lab .palette button.locked { opacity: .5; }
.lab .circuit-scroll { overflow: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg); flex: none; max-height: 46%; }
.lab .circuit-scroll canvas { display: block; }
.lab .row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.lab-controls .field input[type=range] { width: 100%; }
.lab-controls .field > span { display: flex; justify-content: space-between; gap: 8px; }
.lab-controls .field > span b { font: 600 11.5px var(--mono); color: var(--text); }
.lab-controls .kv { grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); }
.lab-controls .kv dt, .lab-controls .kv dd { overflow-wrap: anywhere; }
.lab-controls .kv dd { font-family: var(--mono); font-size: 12px; }
.lab-controls .kv dd.good { color: var(--ok); }
.lab-controls .kv dd.bad { color: var(--danger); }
.lab-controls .button.active { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.lab-controls .button.violet { background: var(--violet); color: #0c0620; border-color: var(--violet); font-weight: 600; }
.lab-controls .row { margin: 6px 0; }
.panel .model-note.violet { border-color: var(--violet); background: rgba(167, 139, 250, .1); }
.lab-explain { margin-top: 14px; padding-top: 6px; border-top: 1px solid var(--line); }
.lab-explain h2 { font-size: 13px; margin: 6px 0; }
.lab-explain p, .lab-explain li { color: #c3d0e2; font-size: 12px; line-height: 1.55; }
.lab-explain ul { padding-left: 18px; margin: 6px 0; }
.lab-explain .eq { font-family: var(--mono); font-size: 12px; color: #e9f2ff; background: rgba(167, 139, 250, .08); border-left: 2px solid var(--violet); padding: 6px 9px; margin: 6px 0; border-radius: 0 6px 6px 0; white-space: pre-wrap; }
.lab-controls .chat { display: grid; gap: 6px; }
@media (max-width: 900px) { .lab { padding: 0 8px 8px; } .lab .split-h, .lab .split-2, .lab .state-grid { grid-template-columns: 1fr; } }
body.lab-open #subject-panel { display: none; }
