/* Segura Quantum application shell and workspaces (D03–D09). */

html, body.app { height: 100%; overflow: hidden; }
body.app { font-size: var(--text-md); }
.spacer { flex: 1; }
.small { font-size: var(--text-sm); }

.shell {
  height: 100vh; height: 100dvh;
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr) auto;
  grid-template-rows: 44px minmax(0, 1fr) 26px;
  grid-template-areas: "top top top" "rail view ai" "status status status";
}

/* Top bar */
.topbar { grid-area: top; display: flex; align-items: center; gap: var(--space-2); padding: 0 var(--space-2) 0 0; border-bottom: 1px solid var(--line); background: var(--bg-2); min-width: 0; }
.app-brand { width: 52px; height: 44px; display: grid; place-items: center; border-right: 1px solid var(--line); color: var(--text); }
.app-brand .logo-mark { width: 24px; height: 24px; }
.crumbs { display: flex; align-items: center; gap: var(--space-2); min-width: 0; padding-left: var(--space-2); }
.crumb-sep { color: var(--text-3); }
.crumb-view { font-weight: 600; white-space: nowrap; }
.crumb-file { color: var(--text-3); font-size: var(--text-sm); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.select-ghost { border-color: transparent; background: transparent; min-height: 28px; padding: 2px 6px; width: auto; color: var(--text-2); font-size: var(--text-sm); }
.select-ghost:hover { border-color: var(--line-strong); }
.select-ghost option { background: var(--surface); color: var(--text); }
.mode-switch { display: flex; align-items: center; gap: 4px; font-size: var(--text-xs); margin-left: var(--space-3); padding-left: var(--space-3); border-left: 1px solid var(--line); }
.palette-trigger { display: flex; align-items: center; gap: var(--space-2); min-width: 280px; max-width: 420px; flex: 0 1 420px; height: 30px; padding: 0 8px 0 10px; border-radius: var(--radius-2); border: 1px solid var(--line-strong); background: var(--bg); color: var(--text-3); cursor: pointer; font-size: var(--text-sm); }
.palette-trigger span:nth-child(2) { flex: 1; text-align: left; }
.palette-trigger:hover { border-color: var(--accent); color: var(--text-2); }
.badge-count { position: absolute; top: 2px; right: 0; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px; background: var(--interactive-fill); color: #fff; font: 600 10px/16px var(--font-mono); }
#notif-btn { position: relative; }
#ai-btn[aria-pressed="true"] { color: var(--quantum); background: var(--surface-2); }

/* Rail */
.rail { grid-area: rail; display: flex; flex-direction: column; gap: 2px; padding: 6px 0; border-right: 1px solid var(--line); background: var(--bg-2); align-items: center; }
.rail a { position: relative; width: 40px; height: 40px; display: grid; place-items: center; border-radius: var(--radius-2); color: var(--text-3); text-decoration: none; }
.rail a svg { width: 20px; height: 20px; }
.rail a:hover { color: var(--text); background: var(--surface-2); }
.rail a[aria-current="page"] { color: var(--accent); background: var(--surface-2); }
.rail a[aria-current="page"]::before { content: ""; position: absolute; left: -6px; top: 8px; bottom: 8px; width: 2px; background: var(--accent); border-radius: 2px; }
.rail .rail-sep { flex: 1; }
.rail a .rail-tip { position: absolute; left: 48px; top: 50%; transform: translateY(-50%); white-space: nowrap; background: var(--surface-3); border: 1px solid var(--line-strong); padding: 4px 8px; border-radius: var(--radius-2); font-size: var(--text-sm); color: var(--text); opacity: 0; pointer-events: none; transition: opacity var(--dur-1); z-index: 30; }
.rail a:hover .rail-tip, .rail a:focus-visible .rail-tip { opacity: 1; }

.view { grid-area: view; min-width: 0; min-height: 0; overflow: hidden; outline: none; position: relative; background: var(--bg); }

/* AI panel */
.ai-panel { grid-area: ai; width: 320px; border-left: 1px solid var(--line); background: var(--surface); display: flex; flex-direction: column; min-height: 0; }
.ai-body p { margin: 0 0 var(--space-3); }
.ai-h { font: 600 var(--text-sm) var(--font-ui); margin: var(--space-5) 0 var(--space-2); letter-spacing: 0; }
.ai-guide { display: grid; gap: var(--space-2); margin-bottom: var(--space-3); }

/* Status bar */
.statusbar { grid-area: status; display: flex; align-items: center; gap: var(--space-4); padding: 0 var(--space-3); border-top: 1px solid var(--line); background: var(--bg-2); font-size: var(--text-xs); color: var(--text-2); white-space: nowrap; overflow: hidden; }
.statusbar kbd { font-size: 10px; padding: 0 4px; }
.sb-item { display: inline-flex; align-items: center; gap: 6px; }
.dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }
.dot-ok { background: var(--success); }
.dot-warn { background: var(--warning); border-radius: 1px; transform: rotate(45deg); }
.dot-err { background: var(--critical); border-radius: 0; }
#sb-msg.is-error { color: var(--critical); }
#sb-msg.is-success { color: var(--success); }

/* Notifications */
.notif { position: fixed; top: 46px; right: 50px; z-index: 60; width: 360px; max-height: 60vh; overflow: auto; background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--radius-3); box-shadow: var(--shadow-3); }
.notif ul { list-style: none; margin: 0; padding: 6px; }
.notif li { padding: 8px 10px; border-radius: var(--radius-2); font-size: var(--text-sm); display: grid; gap: 2px; }
.notif li + li { border-top: 1px solid var(--line); }
.notif li small { color: var(--text-3); font-family: var(--font-mono); font-size: 11px; }

/* Palette */
.palette { padding: 0; }
.palette li .pal-icon { width: 18px; text-align: center; color: var(--text-3); }
.palette li kbd { margin-left: var(--space-2); }
.palette li.pal-empty { cursor: default; }
.shortcuts { width: 760px; }
.shortcut-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-5); }
.shortcut-grid dl { margin: 0; display: grid; gap: 8px; }
.shortcut-grid dl > div { display: flex; justify-content: space-between; gap: var(--space-3); font-size: var(--text-sm); }
.shortcut-grid dd { margin: 0; color: var(--text-2); }

/* ============ Studio ============ */
.studio {
  --left: 248px; --right: 320px; --bottom: 260px; --split: 62%;
  height: 100%; display: grid;
  grid-template-columns: var(--left) 5px minmax(0, 1fr) 5px var(--right);
  grid-template-rows: minmax(0, 1fr) 5px var(--bottom);
  grid-template-areas: "left lh center rh right" "left lh bh rh right" "left lh bottom rh right";
}
.studio.hide-left { grid-template-columns: 0 0 minmax(0, 1fr) 5px var(--right); }
.studio.hide-right { grid-template-columns: var(--left) 5px minmax(0, 1fr) 0 0; }
.studio.hide-left.hide-right { grid-template-columns: 0 0 minmax(0, 1fr) 0 0; }
.studio.hide-bottom { grid-template-rows: minmax(0, 1fr) 0 0; }
.studio.hide-left .explorer, .studio.hide-left [data-resize="left"], .studio.hide-right .inspector, .studio.hide-right [data-resize="right"], .studio.hide-bottom .bottom, .studio.hide-bottom [data-resize="bottom"] { display: none; }
.explorer { grid-area: left; }
.inspector { grid-area: right; }
.center { grid-area: center; }
.bottom { grid-area: bottom; }
.pane { background: var(--surface); min-width: 0; min-height: 0; display: flex; flex-direction: column; overflow: hidden; }
.handle { background: var(--line); position: relative; z-index: 2; }
.handle:hover, .handle:focus-visible, .handle.dragging { background: var(--accent); box-shadow: none; border-radius: 0; }
.handle[aria-orientation="vertical"] { cursor: col-resize; }
.handle[aria-orientation="horizontal"] { cursor: row-resize; grid-area: bh; }
[data-resize="left"] { grid-area: lh; }
[data-resize="right"] { grid-area: rh; }

.pane-tabs { display: flex; align-items: stretch; border-bottom: 1px solid var(--line); min-height: 34px; padding: 0 4px; gap: 2px; }
.pane-tabs .tab { font-size: var(--text-sm); padding: 0 10px; }
.pane-tabs .spacer { flex: 1; }
.pane-scroll { overflow: auto; min-height: 0; flex: 1; }
.sec { padding: var(--space-3); border-bottom: 1px solid var(--line); }
.sec:last-child { border-bottom: 0; }
.sec-h { font: 600 10.5px/1 var(--font-mono); letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-3); margin: 0 0 var(--space-3); display: flex; align-items: center; gap: var(--space-2); }
.sec-h .spacer { flex: 1; }

/* Explorer */
.tree { list-style: none; margin: 0; padding: 4px; }
.tree li { display: flex; align-items: center; gap: 6px; }
.tree button.item { flex: 1; min-width: 0; text-align: left; background: none; border: 0; padding: 6px 8px; border-radius: var(--radius-1); color: var(--text-2); cursor: pointer; font-size: var(--text-sm); display: flex; gap: 8px; align-items: center; }
.tree button.item:hover { background: var(--surface-2); color: var(--text); }
.tree button.item[aria-current="true"] { background: var(--surface-3); color: var(--text); box-shadow: inset 2px 0 0 var(--accent); }
.tree .ico { color: var(--accent); font-family: var(--font-mono); font-size: 11px; width: 14px; }
.tree .meta { margin-left: auto; color: var(--text-3); font: 500 10.5px var(--font-mono); }
.tree .item-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tree .del { opacity: 0; }
.tree li:hover .del, .tree .del:focus-visible { opacity: 1; }
.tree li.lib-item { display: block; }
.insp-row .field-wide { grid-column: 1 / -1; }
.lib-note { display: block; color: var(--text-3); font-size: 11px; padding: 0 8px 6px 30px; margin-top: -4px; }

/* Center */
.center { display: flex; flex-direction: column; background: var(--bg); }
.gate-bar { display: flex; align-items: center; gap: 6px; padding: 6px 10px; border-bottom: 1px solid var(--line); background: var(--surface); flex-wrap: wrap; }
.gate-bar .gate { width: 32px; height: 32px; font-size: 12px; touch-action: none; }
.gate-bar .gate[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--gate-color); }
.gate-bar .gate.wide { width: auto; padding: 0 7px; }
.gate-bar .group-sep { width: 1px; height: 22px; background: var(--line-strong); margin: 0 4px; }
.gate-bar .tools { display: flex; gap: 4px; margin-left: auto; align-items: center; }
.drag-ghost { position: fixed; z-index: 100; pointer-events: none; transform: translate(-50%, -50%); opacity: 0.9; }
.split { flex: 1; min-height: 0; display: grid; grid-template-columns: var(--split) 5px minmax(0, 1fr); }
.studio[data-mode="programming"] .split { grid-template-columns: minmax(0, 1fr) 5px var(--split); }
.studio[data-mode="programming"] .canvas-pane { order: 3; }
.studio[data-mode="programming"] .split > .handle { order: 2; }
.studio[data-mode="programming"] .source-pane { order: 1; }
.canvas-pane, .source-pane { min-width: 0; min-height: 0; display: flex; flex-direction: column; }
.split > .handle { cursor: col-resize; }
.pane-bar { display: flex; align-items: center; gap: var(--space-2); min-height: 30px; padding: 0 10px; border-bottom: 1px solid var(--line); font: 500 var(--text-xs)/1 var(--font-mono); color: var(--text-3); letter-spacing: 0.06em; text-transform: uppercase; background: var(--bg-2); }
.pane-bar .sync { text-transform: none; letter-spacing: 0; font-family: var(--font-ui); display: inline-flex; align-items: center; gap: 6px; }
.pane-bar .sync.ok { color: var(--success); }
.pane-bar .sync.err { color: var(--critical); }

/* Circuit canvas */
.cc-host { flex: 1; overflow: auto; min-height: 0; outline: none; background-color: var(--bg); background-image: linear-gradient(var(--grid) 1px, transparent 1px), linear-gradient(90deg, var(--grid) 1px, transparent 1px); background-size: 29px 29px; }
.cc-host:focus-visible { box-shadow: inset 0 0 0 2px var(--accent); border-radius: 0; }
.cc-host.armed { cursor: copy; }
.cc-svg { display: block; overflow: visible; }
.cc-col { stroke: var(--grid); stroke-width: 1; }
.cc-wire { stroke: var(--viz-wire); stroke-width: 1.5; }
.cc-creg { stroke: var(--viz-wire); stroke-width: 1; }
.cc-wire-label { font: 500 12px var(--font-mono); fill: var(--text-2); }
.cc-ket { font: 500 11px var(--font-mono); fill: var(--text-3); }
.cc-note { font: 500 10px var(--font-mono); fill: var(--text-3); }
.cc-meas rect { fill: var(--surface-2); stroke: var(--gate-measure); stroke-dasharray: 3 2; }
.cc-meas path { fill: none; stroke: var(--gate-measure); stroke-width: 1.2; }
.cc-cursor { fill: none; stroke: var(--accent); stroke-width: 1.5; stroke-dasharray: 4 3; }
.cc-op { cursor: grab; }
.cc-op .cc-box { fill: color-mix(in srgb, var(--fam) 18%, var(--surface)); stroke: var(--fam); stroke-width: 1.5; }
.cc-op .cc-sym { font: 600 13px var(--font-mono); fill: var(--text); text-anchor: middle; pointer-events: none; }
.cc-op .cc-param { font: 500 9.5px var(--font-mono); fill: var(--text-2); text-anchor: middle; pointer-events: none; }
.cc-op .cc-phase-mark { stroke: var(--fam); stroke-width: 2; }
.cc-op .cc-comp { fill: var(--fam); }
.cc-op .cc-link { stroke: var(--fam); stroke-width: 2; }
.cc-op .cc-dot { fill: var(--fam); }
.cc-op .cc-target { fill: var(--bg); stroke: var(--fam); stroke-width: 2; }
.cc-op .cc-plus { stroke: var(--fam); stroke-width: 2; }
.cc-op .cc-swap { stroke: var(--fam); stroke-width: 2.4; stroke-linecap: round; }
.cc-op .cc-group { fill: color-mix(in srgb, var(--fam) 7%, transparent); stroke: var(--fam); stroke-dasharray: 4 3; }
.cc-op .cc-hit { fill: transparent; }
.cc-op:hover .cc-box, .cc-op:hover .cc-group { filter: drop-shadow(0 0 6px color-mix(in srgb, var(--fam) 60%, transparent)); }
.cc-op.is-selected .cc-box, .cc-op.is-selected .cc-hit { stroke: var(--text); stroke-width: 2; }
.cc-op.is-selected .cc-hit { fill: color-mix(in srgb, var(--accent) 8%, transparent); stroke-dasharray: 3 2; }
.fam-h { --fam: var(--gate-h); } .fam-pauli { --fam: var(--gate-pauli); } .fam-phase { --fam: var(--gate-phase); }
.fam-rotation { --fam: var(--gate-rotation); } .fam-control { --fam: var(--gate-control); } .fam-swap { --fam: var(--gate-swap); }
.cc-drop { fill: color-mix(in srgb, var(--accent) 14%, transparent); stroke: var(--accent); stroke-dasharray: 4 3; pointer-events: none; }
.cc-drop.invalid { stroke: var(--critical); }

/* Source editor */
.editor { flex: 1; min-height: 0; position: relative; display: grid; grid-template-columns: 44px minmax(0, 1fr); overflow: auto; background: var(--bg-2); font: 400 13px/1.7 var(--font-mono); }
.editor .gutter { padding: 10px 8px 10px 0; text-align: right; color: var(--text-3); user-select: none; border-right: 1px solid var(--line); white-space: pre; }
.editor .code-wrap { position: relative; min-width: 0; }
.editor pre, .editor textarea { margin: 0; padding: 10px 12px; font: inherit; white-space: pre; overflow: hidden; border: 0; tab-size: 2; }
.editor pre { pointer-events: none; color: var(--text); min-height: 100%; }
.editor textarea { position: absolute; inset: 0; width: 100%; height: 100%; resize: none; background: transparent; color: transparent; caret-color: var(--accent); outline: none; }
.editor textarea::selection { background: rgb(0 217 255 / 0.25); color: transparent; }
.tok-kw { color: var(--quantum); } .tok-gate { color: var(--accent); } .tok-num { color: var(--warning); } .tok-com { color: var(--text-3); font-style: italic; } .tok-str { color: var(--success); } .tok-reg { color: var(--interactive); }
.editor-status { padding: 6px 10px; border-top: 1px solid var(--line); font-size: var(--text-xs); color: var(--text-2); background: var(--surface); }
.editor-status.err { color: var(--critical); }

/* Inspector */
.insp-title { display: flex; align-items: center; gap: var(--space-3); }
.insp-title .gate { cursor: default; }
.insp-title b { display: block; font-size: var(--text-md); }
.insp-title small { color: var(--text-3); font-size: var(--text-xs); }
.kv { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 6px 12px; margin: 0; font-size: var(--text-sm); }
.kv dt { color: var(--text-3); font-family: var(--font-mono); font-size: 11px; padding-top: 2px; }
.kv dd { margin: 0; font-family: var(--font-mono); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.insp-row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-2); margin-top: var(--space-3); }
.insp-row .field { font-size: var(--text-xs); }
.insp-row .input, .insp-row .select { min-height: 28px; padding: 3px 8px; font-size: var(--text-sm); }
.math-block { font: 400 13px/1.5 var(--font-math); background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius-2); padding: 8px 10px; margin: var(--space-2) 0 0; overflow-x: auto; }
.decomp { list-style: none; margin: var(--space-2) 0; padding: 0; display: flex; flex-wrap: wrap; gap: 4px; }
.decomp li { font: 500 11px var(--font-mono); padding: 2px 6px; border: 1px solid var(--line-strong); border-radius: var(--radius-1); color: var(--text-2); }
.mini-sphere { width: 100%; aspect-ratio: 1.25; display: block; }
.reduced-note { font-size: var(--text-xs); color: var(--warning); margin: 6px 0 0; }
.limits li { display: flex; justify-content: space-between; font-size: var(--text-sm); padding: 3px 0; }
.limits { list-style: none; margin: 0; padding: 0; }
.limits span:last-child { font-family: var(--font-mono); color: var(--text-2); }

/* Bottom instrumentation */
.bottom .pane-scroll { padding: var(--space-3) var(--space-4); }
.hist { display: grid; gap: 6px; }
.hist-head { display: flex; align-items: center; gap: var(--space-3); font-size: var(--text-xs); color: var(--text-2); margin-bottom: var(--space-2); flex-wrap: wrap; }
.legend-sw { display: inline-block; width: 10px; height: 10px; border-radius: 2px; vertical-align: -1px; margin-right: 4px; }
.legend-exact { background: linear-gradient(90deg, var(--interactive-fill), var(--accent)); }
.legend-sample { background: var(--state); border-radius: 50%; }
.h-row { display: grid; grid-template-columns: 90px minmax(0, 1fr) 76px 64px 84px; gap: var(--space-3); align-items: center; font-size: var(--text-sm); }
.h-row code { font-size: var(--text-sm); }
.h-track { position: relative; height: 16px; background: var(--surface-2); border-radius: 2px; }
.h-bar { position: absolute; left: 0; top: 3px; bottom: 3px; border-radius: 2px; background: linear-gradient(90deg, var(--interactive-fill), var(--accent)); }
.h-err { position: absolute; top: 2px; bottom: 2px; border-left: 1.5px solid var(--state); border-right: 1.5px solid var(--state); }
.h-err::after { content: ""; position: absolute; left: 0; right: 0; top: 50%; border-top: 1.5px solid var(--state); }
.h-pt { position: absolute; top: 50%; width: 9px; height: 9px; margin: -4.5px 0 0 -4.5px; border-radius: 50%; background: var(--state); border: 1.5px solid var(--bg); }
.h-row .num { text-align: right; font-family: var(--font-mono); font-variant-numeric: tabular-nums; color: var(--text-2); }
.h-head { font: 600 10px var(--font-mono); color: var(--text-3); letter-spacing: 0.08em; text-transform: uppercase; }
.amp-row { display: grid; grid-template-columns: 90px 140px minmax(0, 1fr) 90px 90px; gap: var(--space-3); align-items: center; font-size: var(--text-sm); padding: 3px 0; border-bottom: 1px solid var(--line); }
.amp-bar { height: 10px; border-radius: 2px; }
.phase-sw { width: 14px; height: 14px; border-radius: 50%; border: 1px solid var(--line-strong); display: inline-block; vertical-align: -3px; margin-right: 6px; }
.log { list-style: none; margin: 0; padding: 0; font: 400 12px/1.6 var(--font-mono); }
.log li { display: grid; grid-template-columns: 76px 70px minmax(0, 1fr); gap: var(--space-3); padding: 1px 0; }
.log .lv-info { color: var(--text-3); } .log .lv-success { color: var(--success); } .log .lv-warn { color: var(--warning); } .log .lv-error { color: var(--critical); }
.problems { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--space-2); font-size: var(--text-sm); }
.problems li { display: flex; gap: var(--space-2); align-items: baseline; }

/* ============ State Lab ============ */
.lab { height: 100%; display: grid; grid-template-columns: 280px minmax(0, 1fr) 340px; min-height: 0; }
.lab > aside { background: var(--surface); overflow: auto; min-height: 0; }
.lab > aside:first-child { border-right: 1px solid var(--line); }
.lab > aside:last-child { border-left: 1px solid var(--line); }
.lab-stage { position: relative; min-width: 0; min-height: 0; display: flex; flex-direction: column; background: radial-gradient(60% 60% at 50% 45%, color-mix(in srgb, var(--interactive-fill) 10%, transparent), transparent 70%), var(--bg); }
.lab-stage canvas { flex: 1; min-height: 0; width: 100%; outline: none; cursor: grab; }
.lab-stage canvas:active { cursor: grabbing; }
.lab-stage canvas:focus-visible { box-shadow: inset 0 0 0 2px var(--accent); border-radius: 0; }
.lab-banner { position: absolute; top: 12px; left: 12px; right: 12px; display: flex; gap: var(--space-2); flex-wrap: wrap; align-items: center; pointer-events: none; }
.lab-banner > * { pointer-events: auto; }
.lab-tools { position: absolute; top: 12px; right: 12px; display: flex; gap: 4px; }
.timeline-bar { border-top: 1px solid var(--line); background: var(--surface); padding: var(--space-3) var(--space-4); display: grid; gap: var(--space-2); }
.tl-controls { display: flex; align-items: center; gap: var(--space-2); }
.tl-controls input[type=range] { flex: 1; accent-color: var(--sq-cyan); }
.tl-steps { display: flex; gap: 3px; overflow-x: auto; padding-bottom: 2px; }
.tl-step { flex: 0 0 auto; min-width: 36px; height: 30px; padding: 0 6px; border: 1px solid var(--line-strong); background: var(--surface-2); border-radius: var(--radius-1); color: var(--text-2); font: 600 11px var(--font-mono); cursor: pointer; }
.tl-step[aria-current="step"] { border-color: var(--accent); color: var(--text); box-shadow: inset 0 -2px 0 var(--accent); }
.tl-step.k-identity { opacity: 0.55; }
.tl-step.k-nonlocal { border-style: dashed; }
.lab-full .lab { grid-template-columns: 0 minmax(0, 1fr) 0; }
.lab-full .lab > aside { display: none; }
.toggles { display: grid; gap: 6px; }
.toggles label { display: flex; align-items: center; gap: var(--space-2); font-size: var(--text-sm); }
.toggles input { accent-color: var(--sq-cyan); }
.ket { font: 400 15px/1.6 var(--font-math); background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius-2); padding: 10px 12px; overflow-x: auto; }
.step-table { font-size: 12px; }
.step-table td, .step-table th { padding: 4px 6px; }

/* ============ Runs and roadmap ============ */
.page { height: 100%; overflow: auto; padding: var(--space-6) clamp(16px, 3vw, 40px); }
.page h1 { font-size: var(--text-2xl); margin-bottom: var(--space-2); }
.page-lede { color: var(--text-2); max-width: 70ch; margin: 0 0 var(--space-5); }
.runs-layout { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: var(--space-5); align-items: start; }
.runs-table tbody tr { cursor: pointer; }
.runs-table tbody tr:hover { background: var(--surface-2); }
.runs-table tbody tr[aria-selected="true"] { background: var(--surface-3); box-shadow: inset 2px 0 0 var(--accent); }
.run-detail { border: 1px solid var(--line); border-radius: var(--radius-3); background: var(--surface); padding: var(--space-4); position: sticky; top: 0; }
.run-detail pre { font-size: 12px; background: var(--bg-2); padding: var(--space-3); border-radius: var(--radius-2); overflow: auto; max-height: 160px; }
.roadmap { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 420px), 1fr)); gap: 0; border-top: 1px solid var(--line); }
.roadmap > div { display: grid; grid-template-columns: 56px minmax(0, 1fr); gap: var(--space-3); padding: var(--space-4) var(--space-3) var(--space-4) 0; border-bottom: 1px solid var(--line); }
.roadmap .rm-id { font: 600 var(--text-sm) var(--font-mono); color: var(--accent); }
.roadmap b { display: block; }
.roadmap p { margin: 4px 0 6px; color: var(--text-2); font-size: var(--text-sm); }

/* Responsive: tablets get stacked panels; phones get monitoring views, not the full IDE */
@media (max-width: 1100px) {
  .studio { --left: 200px; --right: 280px; }
  .lab { grid-template-columns: 0 minmax(0, 1fr) 300px; }
  .lab > aside:first-child { display: none; }
  .palette-trigger { min-width: 0; flex-basis: 220px; }
  .palette-trigger span:nth-child(2) { display: none; }
}
@media (max-width: 820px) {
  .mode-switch, .crumb-file { display: none; }
  .studio { grid-template-columns: 0 0 minmax(0, 1fr) 0 0 !important; grid-template-rows: minmax(0, 1fr) 0 45%; }
  .studio .explorer, .studio .inspector, .studio [data-resize] { display: none; }
  .studio .bottom { display: flex !important; }
  .split { grid-template-columns: 1fr !important; }
  .split > .handle, .source-pane { display: none; }
  .lab { grid-template-columns: 1fr; grid-template-rows: minmax(300px, 55vh) auto; overflow: auto; }
  .lab > aside:last-child { border-left: 0; border-top: 1px solid var(--line); }
  .runs-layout { grid-template-columns: 1fr; }
  .ai-panel { position: fixed; inset: 44px 0 26px auto; width: min(100vw, 360px); z-index: 40; }
  .shell { grid-template-columns: 0 minmax(0, 1fr) 0; }
  .rail { position: fixed; bottom: 26px; left: 0; right: 0; height: 52px; flex-direction: row; justify-content: space-around; border-right: 0; border-top: 1px solid var(--line); z-index: 30; padding: 0 6px; }
  .rail .rail-sep, .rail .rail-tip { display: none; }
  .rail a[aria-current="page"]::before { left: 8px; right: 8px; top: auto; bottom: -5px; width: auto; height: 2px; }
  .view { padding-bottom: 52px; }
  .statusbar #sb-circuit, .statusbar .faint { display: none; }
}
@media (max-width: 820px) {
  .crumb-view, .crumb-sep, .app-brand { display: none; }
  .palette-trigger { min-width: 0; flex: 0 0 auto; width: 36px; padding: 0; justify-content: center; }
  .palette-trigger kbd, .palette-trigger span:nth-child(2) { display: none; }
  .topbar .theme-toggle, #ai-btn { display: none; }
  .gate-bar .tools { margin-left: 0; width: 100%; }
  .h-row { grid-template-columns: 64px minmax(60px, 1fr) 64px 48px; }
  .h-row > :last-child { display: none; }
  .bottom .pane-tabs { overflow-x: auto; }
  .bottom .pane-tabs .tab { white-space: nowrap; }
}
