/* Balance System viewer. Visual language from viewer/prototype/index.html (mode "Hybrid"). */
:root {
  --bg: #f3f5f4; --panel: #ffffff; --fg: #17201d; --muted: #5d6b66; --line: #d6dedb;
  --stage: #e7ecea; --accent: #0b7a6b; --warn: #9a5b00;
  --display: "Source Serif 4", Georgia, serif;
  --body: "IBM Plex Sans", system-ui, -apple-system, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, Menlo, monospace;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {
  --bg: #101614; --panel: #161e1b; --fg: #e4ebe8; --muted: #93a39d; --line: #2a3632; --stage: #0c1110; --accent: #4fc2ae; --warn: #e3a74a; color-scheme: dark } }
:root[data-theme="dark"] {
  --bg: #101614; --panel: #161e1b; --fg: #e4ebe8; --muted: #93a39d; --line: #2a3632; --stage: #0c1110; --accent: #4fc2ae; --warn: #e3a74a; color-scheme: dark }

[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; overflow: hidden; }
body { background: var(--stage); color: var(--fg); font-family: var(--body); font-size: 14px; line-height: 1.45; }
h1 { font-family: var(--display); font-weight: 650; margin: 0; letter-spacing: -0.01em; }
.sub { color: var(--muted); margin: 2px 0 0; max-width: 70ch; }
.about { font-size: 12px; color: var(--muted); max-width: 64ch; margin: 0; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
button:focus-visible, input:focus-visible, select:focus-visible, summary:focus-visible, [role=button]:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------------------------------------------------------------- full-viewport stage + overlay UI (2026-11-10)
   z-order: canvas 0 · 3D labels 1 · overlays 10 · drawer/popover 12 · hover card 15 · toast 20 */
:root { --ov-bg: color-mix(in srgb, var(--panel) 82%, transparent); --ov-blur: 10px; --ov-line: color-mix(in srgb, var(--line) 85%, transparent);
  --ov-shadow: 0 6px 24px rgb(0 0 0 / .14); --ov-radius: 10px; --gap: 12px; --dock-w: 380px; --top-h: 52px;
  --inset-t: 0px; --inset-r: 0px; --inset-b: 0px; --inset-l: 0px; }
.stage { position: fixed; inset: 0; overflow: hidden; background: var(--stage); }
#c { position: absolute; inset: 0; display: block; width: 100%; height: 100%; touch-action: none; z-index: 0; }
.labels { position: absolute; inset: 0; pointer-events: none; overflow: hidden; z-index: 1; }
.ui { position: absolute; inset: 0; pointer-events: none; z-index: 10; }
.ui > * { pointer-events: auto; }
.ov { background: var(--ov-bg); -webkit-backdrop-filter: blur(var(--ov-blur)) saturate(1.2); backdrop-filter: blur(var(--ov-blur)) saturate(1.2);
  border: 1px solid var(--ov-line); border-radius: var(--ov-radius); box-shadow: var(--ov-shadow); }
.ibtn { font: 600 14px var(--body); min-width: 34px; min-height: 34px; padding: 0 8px; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border-radius: 8px; border: 1px solid transparent; background: transparent; color: var(--fg); cursor: pointer; }
.ibtn:hover { background: color-mix(in srgb, var(--fg) 8%, transparent); }
.ibtn[aria-expanded="true"], .ibtn[aria-pressed="true"] { background: var(--accent); color: var(--panel); }
.ibtn .ilbl { font: 600 12.5px var(--body); }
.ibtn.x { font-size: 18px; }

/* top bar */
.topbar { position: absolute; top: var(--gap); left: var(--gap); right: var(--gap); display: flex; align-items: center; gap: 8px; padding: 5px 6px; min-height: 42px; box-sizing: border-box; flex-wrap: wrap; }
.brand { font-size: 15.5px; white-space: nowrap; margin: 0 6px 0 2px; }
.topbar .ctl { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; flex: 1; min-width: 0; }
.topbar .icons { display: flex; gap: 2px; margin-left: auto; align-items: center; }
.hctl { display: inline-flex; align-items: center; gap: 6px; padding: 0 6px 0 2px; font: 600 12px var(--mono); color: var(--fg); }
.hctl[hidden] { display: none; }
.hctl input { width: 104px; accent-color: var(--accent); }
.hctl output { min-width: 3.2ch; text-align: right; }
.seg { display: inline-flex; background: color-mix(in srgb, var(--bg) 70%, transparent); border: 1px solid var(--ov-line); border-radius: 8px; padding: 2px; gap: 2px; }
.seg button { font: 600 12.5px var(--body); color: var(--fg); background: transparent; border: 0; border-radius: 6px; padding: 5px 11px; cursor: pointer; min-height: 30px; }
.seg button:hover { background: color-mix(in srgb, var(--fg) 8%, transparent); }
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--panel); }
.seg.views button { font-weight: 500; padding: 5px 9px; }
.chips { position: absolute; top: calc(var(--gap) + var(--top-h) + 6px); left: calc(var(--gap) + var(--inset-l)); right: calc(var(--gap) + var(--inset-r)); display: flex; flex-wrap: wrap; gap: 6px; pointer-events: none; }
.chip { font: 500 11px var(--mono); letter-spacing: .02em; background: var(--ov-bg); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); border: 1px solid var(--ov-line); border-radius: 999px; padding: 2px 9px; color: var(--muted); }
.chip.warn { color: var(--warn); border-color: currentColor; }
.chip.lvlnote { font-family: var(--body); max-width: 52ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* left drawer (model controls), closed by default */
.drawer { position: absolute; top: calc(var(--gap) + var(--top-h) + 6px); left: var(--gap); bottom: var(--gap); width: 360px; max-width: calc(100vw - 2 * var(--gap));
  overflow-y: auto; display: flex; flex-direction: column; gap: 10px; padding: 10px 12px 14px; box-sizing: border-box; z-index: 12; }
.drawer section.box { background: transparent; border: 0; border-top: 1px solid var(--ov-line); border-radius: 0; padding: 10px 2px 2px; }
.drawerhd { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.drawerhd h2 { font: 600 11.5px var(--body); text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 0; }
.mobilectl:empty { display: none; }
.mobilectl { display: flex; flex-direction: column; gap: 8px; }
.mobilectl .seg { width: 100%; box-sizing: border-box; flex-wrap: wrap; }
.mobilectl .seg button { flex: 1; }

/* right dock (guided tour) */
.tourdock { position: absolute; top: calc(var(--gap) + var(--top-h) + 6px); right: var(--gap); width: var(--dock-w); max-width: calc(100vw - 2 * var(--gap));
  max-height: calc(100% - var(--top-h) - 3 * var(--gap) - 6px); overflow-y: auto; box-sizing: border-box; }
.tourdock:empty { display: none; }
.tourdock .tourbox { background: transparent; border: 0; border-radius: 0; padding: 10px 14px 14px; }
.tourdock.collapsed { width: auto; overflow: visible; }

/* bottom: circuit diagram */
.fcbox { position: absolute; left: calc(var(--gap) + var(--inset-l)); right: calc(var(--gap) + var(--dock-space, 0px)); bottom: var(--gap); padding: 6px 10px 6px; box-sizing: border-box; }
.fchd { display: flex; align-items: center; gap: 4px; }
.fchd h2 { flex: 1; display: flex; gap: 10px; align-items: baseline; font: 600 11px var(--body); text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 0; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fcbox .ibtn { min-width: 28px; min-height: 26px; font-size: 13px; }
.fcbox.mini .fc { height: 128px; }
.fcbox:not(.mini) .fc { height: min(330px, 42vh); }
.fcbox.closed .fc { display: none; }
.fcbox.closed { right: auto; }

/* captions: small, above the diagram, clear of the tour dock */
.stepcap { position: absolute; z-index: 9; left: calc(var(--gap) + var(--inset-l) + 8px); right: calc(var(--gap) + var(--inset-r) + 8px); bottom: calc(var(--inset-b) + var(--gap) + 8px);
  margin-inline: auto; width: max-content; max-width: min(760px, calc(100% - var(--inset-l) - var(--inset-r) - 2 * var(--gap) - 16px)); box-sizing: border-box;
  text-align: center; pointer-events: none; font: 600 13.5px/1.3 var(--display); color: var(--fg);
  background: var(--ov-bg); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); border: 1px solid var(--ov-line); border-radius: 8px; padding: 5px 12px; }
.stepcap .n { font: 600 11.5px var(--mono); color: var(--accent); margin-right: 6px; }
.stepcap .sub { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; font: 400 12.5px/1.35 var(--body); color: var(--fg); margin-top: 2px; }

/* info popover */
.popover { position: absolute; top: calc(var(--gap) + var(--top-h) + 6px); right: var(--gap); width: 460px; max-width: calc(100vw - 2 * var(--gap)); max-height: calc(100% - var(--top-h) - 3 * var(--gap));
  overflow-y: auto; padding: 12px 16px 16px; box-sizing: border-box; z-index: 12; display: flex; flex-direction: column; gap: 8px; }
.popover section.box { background: transparent; border: 0; border-top: 1px solid var(--ov-line); border-radius: 0; padding: 10px 0 0; }

/* hide UI (presentation) */
.ui-hidden .ui, .ui-hidden .stepcap, .ui-hidden #tip { display: none !important; }
.showui { position: absolute; right: 8px; bottom: 8px; z-index: 20; opacity: 0; transition: opacity .2s; background: var(--ov-bg); }
.ui-hidden .showui { display: inline-flex; }
.showui:hover, .showui:focus-visible { opacity: 1; }
html:not(.ui-hidden) .showui { display: none; }
.toast { position: absolute; left: 50%; top: 70px; transform: translateX(-50%); z-index: 20; font-size: 12.5px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 6px 12px; box-shadow: var(--ov-shadow); }
.tabs { display: none; }

#status { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); font: 500 13px var(--mono); pointer-events: none; }
#tip { position: absolute; pointer-events: none; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; width: 330px; max-width: calc(100% - 20px); font-size: 12.5px; box-shadow: 0 4px 16px rgb(0 0 0 / .14); z-index: 15; }
.lbl { position: absolute; left: 0; top: 0; font: 600 12px var(--mono); line-height: 16px; color: var(--fg); background: color-mix(in srgb, var(--panel) 85%, transparent);
  border: 1px solid var(--fg); border-radius: 4px; padding: 0 4px; white-space: nowrap; }
.lbl.blk { font: 600 12.5px var(--body); padding: 1px 6px; }
.ldot { position: absolute; left: -3px; top: -3px; width: 6px; height: 6px; border-radius: 50%; background: var(--fg); box-shadow: 0 0 0 1.5px var(--panel); }
#tip b.nm, .card .nm { display: block; font-family: var(--display); font-size: 15px; font-weight: 650; line-height: 1.25; }
.meta { font-family: var(--mono); font-size: 11px; color: var(--muted); }
#tip ul, .card ul { margin: 4px 0 0; padding-left: 16px; }
#tip li, .card li { margin: 3px 0; }
.rel { font-style: italic; }
.cite { font: 500 11px var(--mono); color: var(--accent); white-space: nowrap; }

section.box { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; display: flex; flex-direction: column; gap: 8px; }
.box h2 { font: 600 11.5px var(--body); text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 0; display: flex; justify-content: space-between; gap: 8px; }
.box h3 { font: 600 12px var(--body); margin: 6px 0 0; }
.note { font-size: 12px; color: var(--muted); margin: 0; }
.row { display: flex; align-items: center; gap: 8px; }
.row label { display: flex; align-items: center; gap: 6px; cursor: pointer; }
input[type=range] { accent-color: var(--accent); }
.row input[type=range] { flex: 1; min-width: 60px; }
select, input[type=search] { font: 13px var(--body); color: var(--fg); background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 5px 7px; min-width: 0; }
input[type=search] { width: 100%; box-sizing: border-box; }
.groups { display: grid; grid-template-columns: auto 1fr 90px; gap: 4px 8px; align-items: center; }
.groups label { display: flex; gap: 6px; align-items: center; cursor: pointer; }
.groups .n { color: var(--muted); font: 11px var(--mono); }
.btns { display: flex; gap: 6px; flex-wrap: wrap; }
.btns button, .card button.lnk { font: 500 12.5px var(--body); padding: 6px 10px; border-radius: 6px; border: 1px solid var(--line); background: var(--bg); color: var(--fg); cursor: pointer; }
.btns button.primary { background: var(--accent); color: var(--panel); border-color: var(--accent); }
.btns button:disabled { opacity: .45; cursor: default; }
.slist { max-height: 260px; overflow-y: auto; border-top: 1px solid var(--line); }
.slist div { display: grid; grid-template-columns: auto 1fr auto; gap: 6px; align-items: center; padding: 3px 0; border-bottom: 1px solid var(--line); font-size: 12.5px; }
.slist button { all: unset; cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.slist button:hover { color: var(--accent); }
.slist button:focus-visible { outline: 2px solid var(--accent); }
ol.edges { margin: 0; padding-left: 0; list-style: none; font-size: 12.5px; max-height: 220px; overflow-y: auto; }
ol.edges li { margin: 2px 0; cursor: pointer; }
ol.edges li.cur { font-weight: 600; }
ol.edges li.dim { color: var(--muted); }
#stepText { font-size: 12.5px; }

/* placement-status badge (honesty layer in the UI): word + icon shape, never colour alone.
   sourced = filled circle, partial = half-filled circle, pending = empty dashed circle */
.st { display: inline-flex; align-items: center; gap: 5px; font: 600 10.5px var(--mono); letter-spacing: .04em; text-transform: uppercase; padding: 1px 6px 1px 4px; border-radius: 4px; border: 1px solid var(--line); color: var(--fg); background: var(--panel); white-space: nowrap; }
.st::before { content: ""; width: 9px; height: 9px; border-radius: 50%; flex: none; box-sizing: border-box; border: 1.5px solid var(--fg); }
.st.sourced::before { background: var(--fg); }
.st.partial::before { background: linear-gradient(90deg, var(--fg) 50%, transparent 50%); }
.st.pending::before { border-style: dashed; background: transparent; }
.lvl { font-size: 12px; color: var(--fg); border-left: 2px solid var(--accent); padding-left: 6px; }
.tag { font: 500 10.5px var(--mono); color: var(--muted); border: 1px solid var(--line); border-radius: 4px; padding: 0 5px; white-space: nowrap; }

.legend { display: grid; gap: 5px; font-size: 12.5px; }
.legend div { display: flex; align-items: center; gap: 8px; }
.sw { width: 14px; height: 6px; border-radius: 1px; flex: none; }
.mk { width: 22px; height: 12px; flex: none; }
.legend .st { min-width: 92px; }

.card { display: flex; flex-direction: column; gap: 6px; font-size: 12.5px; }
.card .hd { display: flex; justify-content: space-between; align-items: start; gap: 8px; }
.card .x { all: unset; cursor: pointer; font: 600 16px var(--body); color: var(--muted); padding: 0 4px; }
.card details { margin-top: 2px; }
.card summary { cursor: pointer; color: var(--muted); font-size: 11.5px; }
.card blockquote { margin: 3px 0 0 0; padding-left: 8px; border-left: 2px solid var(--line); color: var(--muted); }
.card .lnk { all: unset; cursor: pointer; color: var(--accent); }
.card .lnk:hover { text-decoration: underline; }
ol.refs { margin: 0; padding-left: 22px; font-size: 12.5px; }
ol.refs li { margin: 4px 0; overflow-wrap: anywhere; }
ol.refs li:target { background: color-mix(in srgb, var(--accent) 14%, transparent); }

/* labels: tokens a style variant may override (viewer/themes.json) */
.lbl { font: var(--label-font, 600 12px var(--mono)); color: var(--label-fg, var(--fg)); background: var(--label-bg, color-mix(in srgb, var(--panel) 85%, transparent));
  border: var(--label-border, 1px solid var(--fg)); border-radius: var(--label-radius, 4px); padding: var(--label-pad, 0 4px); box-shadow: var(--label-shadow, none); line-height: 1.25; }
.ldot { background: var(--ink, var(--fg)); }
.lead { position: absolute; left: 0; top: 0; height: 0; border-top: 1.2px solid var(--ink, var(--fg)); transform-origin: 0 0; }
.lbl.mid { font: 600 11px var(--mono); font-style: normal; text-transform: uppercase; letter-spacing: .08em; background: var(--panel); border: 1px dashed var(--ink, var(--fg)); border-radius: 3px; padding: 0 4px; color: var(--fg); }
.lbl.cue { color: var(--cue, var(--fg)); border-color: var(--cue, var(--fg)); font-weight: 700; }
.ldot.mid, .ldot.cue { display: none; }

/* guided tour panel (viewer/tour.js) */
.tourbox { border-color: var(--accent); }
.tourbox .steptitle { font: 650 17px/1.25 var(--display); margin: 2px 0 0; text-wrap: balance; }
.tourtext { font-size: var(--text-size, 14px); line-height: var(--text-leading, 1.55); }
.tourtext p { margin: 0 0 8px; }
.tourtext .placeholder { font-size: 12px; color: var(--warn); border-left: 2px solid var(--warn); padding-left: 6px; }
.tourtext .cuenote { font-size: 12px; color: var(--muted); }
.tcite { font: 600 .72em var(--mono); color: var(--accent); margin-left: 1px; cursor: help; }
.tcite.unverified { color: var(--warn); }
ul.tourflow { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; font-size: 12.5px; border-top: 1px solid var(--line); padding-top: 8px; }
ul.tourflow li { display: grid; gap: 3px; }
ul.tourflow .lnk { all: unset; cursor: pointer; display: flex; gap: 6px; align-items: center; font-weight: 600; }
ul.tourflow .lnk:hover { text-decoration: underline; }
ul.tourflow .g { display: inline-flex; }
ul.tourflow .tags { display: flex; flex-wrap: wrap; gap: 4px; padding-left: 28px; }
.tag .sw { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 4px; vertical-align: -1px; }
.tag.strong { color: var(--fg); border-color: var(--fg); font-weight: 600; }
.tourbtns button { flex: 1; }
ol.tsteps, ol.recap { margin: 0; padding-left: 20px; font-size: 12.5px; }
ol.tsteps li.cur { font-weight: 700; }
ol.tsteps li.cur::marker { color: var(--accent); }
ol.tsteps .lnk, ol.recap .lnk { all: unset; cursor: pointer; vertical-align: top; }
ol.tsteps .lnk:hover, ol.recap .lnk:hover { color: var(--accent); }
.trefs summary { cursor: pointer; font-size: 12px; color: var(--muted); }
.touring #hCirc + select, .touring .box[aria-labelledby="hCirc"] { opacity: .75; }

/* style variants: small structural differences beyond the tokens */
[data-style="scientific"] .stage { border-color: #1b2632; }
[data-style="scientific"] .box h2 { font-family: var(--mono); letter-spacing: .12em; }
[data-style="scientific"] .tourbox .steptitle { font-family: var(--mono); font-weight: 500; font-size: 14.5px; letter-spacing: .01em; }
[data-style="scientific"] .stepcap { font: 500 13px var(--mono); border-radius: 2px; }
[data-style="clinical"] .tourbox { border-width: 2px; }
[data-style="clinical"] .seg button[aria-pressed="true"], [data-style="clinical"] .btns button.primary { background: var(--accent); }
[data-style="textbook"] .tourbox .steptitle { font-size: 20px; font-weight: 600; }
[data-style="textbook"] .stepcap { font: italic 600 15.5px var(--display); border: 0; border-top: 1.5px solid var(--ink); border-bottom: 1.5px solid var(--ink); border-radius: 0; }
[data-style="textbook"] section.box { box-shadow: 0 1px 0 var(--line); }
[data-style="textbook"] .lbl.mid { font: italic 600 13px var(--display); text-transform: none; letter-spacing: 0; background: var(--stage); }

/* ---------------------------------------------------------------- tour v2 */
/* label fades (step transitions); none with reduced motion */
.labels .fadein { animation: lblin .45s ease both; }
.labels .out { opacity: 0; transition: opacity .35s ease; }
@keyframes lblin { from { opacity: 0; } }
.reduce-motion .labels .fadein { animation: none; }
.reduce-motion .labels .out { display: none; }
.reduce-motion .labels .fadein { animation: none; } .reduce-motion .labels .out { display: none; }

/* audio guide */
.player { display: grid; grid-template-columns: auto auto auto 1fr; gap: 6px 8px; align-items: center; padding: 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); }
.player button { font: 600 13px var(--body); min-width: 36px; min-height: 32px; border-radius: 6px; border: 1px solid var(--line); background: var(--panel); color: var(--fg); cursor: pointer; }
.player button.primary { background: var(--accent); color: var(--panel); border-color: var(--accent); }
.player button:disabled { opacity: .45; cursor: default; }
.player .ppos { font: 500 11.5px var(--mono); color: var(--muted); justify-self: end; }
.player .prow { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 4px 14px; align-items: center; font-size: 12px; color: var(--muted); }
.player .prow label { display: inline-flex; gap: 6px; align-items: center; cursor: pointer; }
.player input[type=range] { width: 90px; }
.player .pnote { grid-column: 1 / -1; font-size: 11.5px; color: var(--muted); margin: 0; }
.tourtext .sent { border-radius: 3px; transition: background-color .25s ease, color .25s ease; cursor: pointer; }
.tourtext .sent:hover { text-decoration: underline dotted; text-underline-offset: 3px; }
.tourtext .sent.now { background: color-mix(in srgb, var(--accent) 18%, transparent); color: var(--fg); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 18%, transparent); }
.tourtext.narrating .sent:not(.now) { color: var(--muted); }
[data-style="textbook"] .stepcap .sub { font: italic 400 15px/1.35 var(--display); }
[data-style="scientific"] .stepcap .sub { font: 400 12.5px/1.4 var(--body); }

/* tour dock: header, collapse pill, step list */
.tourbox h2 { align-items: center; }
.tpill { display: flex; align-items: center; gap: 2px; padding: 3px; }
.tpill #pillOpen { font: 600 12.5px var(--mono); }
.tstepsbox summary { cursor: pointer; font-size: 12px; color: var(--muted); }
.tstepsbox[open] summary { margin-bottom: 4px; }

/* circuit diagram (flow chart) */
.fc { overflow: hidden; }
.fc svg { display: block; width: 100%; height: 100%; font-family: var(--body); }
.fc .mid line { stroke: var(--muted); stroke-dasharray: 5 4; stroke-width: 1; }
.fc .mid text, .fc .side { font: 600 9.5px var(--mono); fill: var(--muted); letter-spacing: .06em; text-transform: uppercase; }
.fc .node rect { fill: var(--panel); stroke: var(--line); stroke-width: 1.2; rx: 6; transition: stroke .2s, fill .2s, opacity .2s; }
.fc .node text.ab { font: 700 11.5px var(--body); fill: var(--fg); }
.fc .node text.nm { font: 400 9px var(--body); fill: var(--muted); }
.fc .node { cursor: pointer; opacity: .55; transition: opacity .25s; }
.fc .node.step { opacity: 1; }
.fc .node.step rect { stroke: var(--fg); stroke-width: 1.6; }
.fc .node.now rect { stroke: var(--accent); stroke-width: 2.6; fill: color-mix(in srgb, var(--accent) 14%, var(--panel)); }
.fc .partof { stroke: var(--muted); stroke-dasharray: 2 2; stroke-width: 1; fill: none; }
.fc .edge { cursor: pointer; opacity: .35; transition: opacity .25s; }
.fc .edge path.ln { fill: none; stroke-width: 2; }
.fc .edge path.hit { fill: none; stroke: transparent; stroke-width: 12; }
.fc .edge.step { opacity: 1; }
.fc .edge.now path.ln { stroke-width: 3.6; }
.fc .edge text { font: 500 9px var(--mono); fill: var(--muted); }
.fc .glyph { fill: var(--ink, var(--fg)); stroke: none; }
.fc path.glyph { fill: none; stroke: var(--ink, var(--fg)); }
.fc .xmid { fill: var(--panel); stroke: var(--ink, var(--fg)); stroke-width: 1.4; }
.fc .node:focus-visible rect, .fc .edge:focus-visible path.ln { outline: none; stroke: var(--accent); stroke-width: 3; }
.fc .legend text { font: 500 9.5px var(--body); fill: var(--muted); }
[data-style="textbook"] .fc .node text.ab { font: italic 600 13px var(--display); }
[data-style="scientific"] .fc .node text.ab { font: 600 11px var(--mono); }

/* screenshot mode (?shot=1): canvas only */
.shot .ui, .shot #tip, .shot .stepcap, .shot .showui, .shot .toast { display: none !important; }

/* phones: canvas full screen; overlays become one bottom sheet with tabs, full-bleed (no cards with side margins) */
@media (max-width: 767px) {
  :root { --gap: 0px; --top-h: 44px; --sheet-h: 52vh; }
  .topbar { top: 0; left: 0; right: 0; border-radius: 0; border-inline: 0; border-top: 0; padding: 4px 8px; padding-top: max(4px, env(safe-area-inset-top, 0px)); flex-wrap: nowrap; }
  .topbar .ctl { display: none; }
  .ibtn .ilbl { display: none; }
  .brand { font-size: 14px; flex: 1; }
  .hctl input { width: 70px; }
  .hctl output { display: none; }
  .chips { top: calc(var(--top-h) + 6px); left: 8px; right: 8px; }
  .chip.lvlnote, #orientChip { display: none; }
  .tabs { display: flex; position: absolute; left: 0; right: 0; bottom: 0; z-index: 13; background: var(--ov-bg); -webkit-backdrop-filter: blur(var(--ov-blur)); backdrop-filter: blur(var(--ov-blur));
    border-top: 1px solid var(--ov-line); padding-bottom: env(safe-area-inset-bottom, 0px); }
  .tabs button { flex: 1; min-height: 46px; font: 600 13.5px var(--body); color: var(--fg); background: transparent; border: 0; border-top: 3px solid transparent; cursor: pointer; }
  .tabs button[aria-pressed="true"] { border-top-color: var(--accent); color: var(--accent); }
  /* the three panels share the sheet; only the active tab's panel shows */
  .drawer, .tourdock, .fcbox { position: absolute; top: auto; left: 0; right: 0; bottom: calc(46px + env(safe-area-inset-bottom, 0px)); width: auto; max-width: none;
    height: var(--sheet-h); max-height: none; border-radius: 0; border-inline: 0; border-bottom: 0; box-shadow: 0 -6px 20px rgb(0 0 0 / .12); z-index: 12; }
  .ui:not([data-tab="settings"]) .drawer, .ui:not([data-tab="tour"]) .tourdock, .ui:not([data-tab="diagram"]) .fcbox { display: none !important; }
  .ui[data-tab="settings"] .drawer[hidden] { display: flex !important; }
  .ui[data-tab="diagram"] .fcbox[hidden] { display: block !important; }
  .drawer { padding: 8px 16px 16px; }
  .drawer section.box { padding: 12px 0 4px; }
  .tourdock .tourbox { padding: 10px 16px 16px; }
  .fcbox { padding: 8px 16px; }
  .fcbox .fc, .fcbox.mini .fc, .fcbox:not(.mini) .fc { height: auto; max-height: calc(var(--sheet-h) - 48px); overflow: auto; }
  .fcbox .fc svg { width: auto; height: 250px; max-width: none; }
  .stepcap { font-size: 12.5px; padding: 4px 10px; }
  .stepcap .sub { -webkit-line-clamp: 1; }
  #fcSize, #fcHide, #drawerBtn, #drawerClose { display: none; }
  .popover { top: var(--top-h); left: 0; right: 0; width: auto; border-radius: 0; border-inline: 0; max-height: calc(100% - var(--top-h) - 46px); }
  .stepcap { bottom: calc(46px + var(--inset-b) + 8px); left: 8px; right: 8px; max-width: calc(100% - 16px); }
  .showui { bottom: 8px; }
  .slist { max-height: none; }
}
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto; } }
.ibtn.plain[aria-expanded] { background: transparent; color: var(--fg); }
.ibtn.plain:hover { background: color-mix(in srgb, var(--fg) 8%, transparent); }
