/* Portfolio tokens; algorithm colours remain meaningful (visited, path, result). */
@import url('../style.css?v=playground-10');
:root { --ink:var(--text); --ink-soft:var(--muted); --surface:var(--bg); --surface-2:var(--selection); --line-strong:var(--line); --accent-deep:var(--accent-strong); --accent-soft:color-mix(in srgb,var(--accent) 16%,var(--bg)); --cool:#587c93; --cool-soft:color-mix(in srgb,var(--cool) 14%,var(--bg)); --good:#81718e; --good-soft:var(--accent-soft); --warn:#a98a55; --shadow:none; }
html { padding:0; height:auto; }
body.algorithm-tool { padding:108px 0 0; height:100vh; overflow:hidden; font:14px/1.5 var(--sans); }
.tool-header { height:64px; position:fixed; inset:0 0 auto; z-index:110; display:flex; align-items:center; gap:28px; padding:0 32px; border-bottom:1px solid var(--line); background:var(--bg); font:12px var(--sans); }
.tool-header a { text-decoration:none; }
.tool-wordmark { font-size:16px; font-weight:600; margin-right:auto; }
.tool-header button { padding:8px 0; border:0; background:transparent; font:12px var(--sans); }
.topic-nav { top:64px; height:44px; box-shadow:none; padding:6px 24px; background:var(--bg); border-color:var(--line); }
.topic-pill { font:12px var(--sans); border-radius:0; padding:6px 10px; }
.app,.suite-page,.fenwick-page,.hull-page,.traversal-page,.segtree-page { height:calc(100vh - 108px); grid-template-columns:minmax(0,1fr) 360px; }
.sidebar { height:calc(100vh - 108px); background:var(--bg); border-color:var(--line); min-width:0; }
.sidebar header { padding:28px 24px 24px; }
.sidebar h1 { font:32px/1.1 var(--serif); letter-spacing:-.5px; }
.sidebar .subtitle,.suite-sub { color:var(--muted); font:12px/1.65 var(--sans); margin-top:12px; }
.sidebar-section { padding:20px 24px; border-color:var(--line); }
.sidebar-section h2 { font:12px/1.6 var(--sans); font-weight:600; letter-spacing:0; text-transform:none; margin-bottom:12px; }
button,input,select,textarea,.algo-chip,.canvas-hint,.flow-readout,.step-bar,.topic-pill { border-radius:0; font-family:var(--sans); }
button,input,select,textarea { font-size:12px; }
button { padding:8px 12px; }
button.accent,.step-bar button.play { background:var(--text); border-color:var(--text); color:var(--bg); }
button.primary:hover:not(:disabled),button.accent:hover:not(:disabled) { background:var(--accent-strong); color:var(--bg); }
.canvas-wrap,.hull-stage,.suite-stage,.traversal-stage,.segtree-stage,.fenwick-stage { background:radial-gradient(circle at 1px 1px,var(--line) .7px,transparent .7px) 0 0/28px 28px,var(--bg); min-width:0; }
.canvas-hint { box-shadow:none; font-size:12px; line-height:1.6; max-width:300px; }
.flow-readout { box-shadow:none; min-width:100px; }
.flow-readout .value { font:32px var(--serif); }
.suite-title { font:24px var(--serif); }
.pseudocode,.graph-text,.event-list { font-family:var(--sans); font-variant-numeric:tabular-nums; }
svg text { font-family:var(--sans); }
a:focus-visible,button:focus-visible,input:focus-visible,select:focus-visible { outline:2px solid var(--accent); outline-offset:2px; }
@media(max-width:800px) {
 body.algorithm-tool { height:auto; overflow:auto; }
 .tool-header { padding:0 18px; gap:16px; }
 .tool-header a[href*='mental-math'] { display:none; }
 .tool-wordmark { font-size:14px; }
 .app,.suite-page,.fenwick-page,.hull-page,.traversal-page,.segtree-page { height:auto; display:grid; grid-template-columns:minmax(0,1fr); }
 .canvas-wrap,.hull-stage,.suite-stage,.traversal-stage,.segtree-stage,.fenwick-stage { height: min(65vh,560px); min-height:340px; }
 .sidebar { height:auto; overflow:visible; border-top:1px solid var(--line); border-left:0; }
 .scroll-region { overflow:visible; }
 .canvas-hint { max-width:230px; padding:8px; font-size:11px; top:8px; left:8px; }
 .flow-readout { top:auto; bottom:12px; right:12px; padding:8px; }
 .sidebar-section .row { flex-wrap:wrap; }
}

.node.on-path text,.node.cut-s text,.node.cut-t text { fill:var(--ink); }
.node .node-badge { fill:var(--muted); }
input[type="range"],input[type="checkbox"] { accent-color:var(--text); }
.overview .term,.overview .term-cool,.pseudocode .pline.active,.log-list .line.active,.phase-pill.search,.phase-pill.augment,.phase-pill.done,.pseudocode .kw { color:var(--text); }
.step-explain,.step-explain.done,.step-explain.error { background:var(--surface-2); color:var(--text); border-color:var(--line); }
.algo-chip-row,.pseudocode,.complexity-note { border-radius:0; }
.node.current .node-badge { fill:var(--muted); }
.complexity-note { border-color:var(--line); color:var(--muted); }
.call-stack-chip { color:var(--text); }
.dp-table td.empty { background:var(--surface-2); color:var(--muted); }

/* Let the example lead; reference material is opened when needed. */
html { overflow:auto; }
body.algorithm-tool { padding-top:120px; }
.tool-header { font-size:14px; }
.tool-header button { font-size:14px; }
.topic-nav { top:64px; height:56px; justify-content:space-between; gap:24px; padding:8px 32px; overflow:visible; }
.topic-nav > a { font:14px var(--sans); text-decoration:none; }
.topic-nav label { display:flex; align-items:center; gap:12px; font:12px var(--sans); color:var(--muted); }
.topic-nav select { width:240px; padding:8px 12px; font:14px var(--sans); background:var(--bg); }
.app,.suite-page,.fenwick-page,.hull-page,.traversal-page,.segtree-page { height:calc(100dvh - 120px); grid-template-columns:minmax(0,1fr) 320px; }
.sidebar { height:calc(100dvh - 120px); }
.sidebar header { padding:24px; }
.sidebar h1 { font-size:28px; }
.sidebar-section { padding:16px 24px; }
.sidebar .overview { font:14px/1.7 var(--sans); color:var(--muted); }
.overview-details > summary { list-style:none; display:flex; align-items:center; justify-content:space-between; gap:16px; color:var(--text); font:14px/1.5 var(--sans); padding:4px 0; cursor:pointer; }
.overview-details > summary::-webkit-details-marker { display:none; }
.overview-details > summary::after { content:'+'; font-size:20px; font-weight:400; }
.overview-details[open] > summary::after { content:'−'; }
.overview-details[open] > summary { margin-bottom:16px; }
.canvas-wrap,.hull-stage,.suite-stage,.traversal-stage,.segtree-stage,.fenwick-stage { background:var(--bg); }
.suite-title { font:32px/1.2 var(--serif); }
.suite-sub { font-size:14px; }
.set-display,.jaccard-display,.convergence-chart,.controls-panel { border-radius:0; background:var(--bg); }
.minhash-stage .set-row { gap:20px; }
.minhash-stage .set-display { flex:1; min-width:200px; }
.minhash-stage .jaccard-display { flex:1; }
.minhash-stage .controls-panel { gap:16px; }
@media(max-width:800px) {
 .topic-nav { padding:8px 18px; gap:12px; }
 .topic-nav select { width:min(48vw,240px); }
 .topic-nav label { font-size:0; gap:0; }
 .app,.suite-page,.fenwick-page,.hull-page,.traversal-page,.segtree-page { height:auto; grid-template-columns:minmax(0,1fr); }
 .sidebar { height:auto; }
 .suite-stage { height:auto; min-height:360px; overflow:auto; padding:24px 18px; }
 .suite-title { font-size:28px; }
 .minhash-stage .set-display { min-width:0; flex-basis:100%; }
 .minhash-stage .jaccard-display { flex-basis:100%; }
}
@media(max-width:600px) { .tool-header .tool-project-link { display:none; } }

/* Simulation workspace: persistent playback, quiet reference material. */
body.algorithm-tool { font-size:14px; }
.app,.suite-page,.fenwick-page,.hull-page,.traversal-page,.segtree-page { grid-template-columns:minmax(0,1fr) 350px; }
.sidebar { min-height:0; }
.sidebar > header { flex-shrink:0; padding:20px 24px; }
.sidebar > header h1 { font-size:26px; }
.sidebar .scroll-region { min-height:0; }
.playback-dock { flex-shrink:0; padding:16px 20px; border-bottom:1px solid var(--line); background:var(--bg); z-index:90; }
.step-controls { display:flex; gap:8px; }
.step-controls button { min-width:0; height:44px; min-height:44px; padding:8px 4px; flex:1; white-space:nowrap; font-size:15px; display:flex; justify-content:center; align-items:center; }
.step-controls button.accent { flex:1.3; }
.speed-row { display:flex; gap:12px; align-items:center; font-size:12px; color:var(--muted); }
.speed-row input { min-width:0; flex:1; height:24px; }
.step-explain { height:auto; min-height:0; max-height:none; overflow:visible; border:0; border-left:2px solid var(--line); border-radius:0; background:transparent!important; padding:8px 0 8px 14px; font:14px/1.65 var(--sans); }
.phase-pill { border:0; border-radius:0; padding:0; margin-bottom:12px; background:transparent!important; font-size:11px; letter-spacing:.05em; }
.phase-pill .dot { width:6px; height:6px; }
.reference-panel { width:100%; }
.reference-panel > summary,.overview-details > summary { display:flex; justify-content:space-between; align-items:center; list-style:none; font:14px/1.5 var(--sans); padding:6px 0; cursor:pointer; }
.reference-panel > summary::before,.overview-details > summary::before { display:none!important; }
.reference-panel > summary::after { content:'+'; color:var(--muted); font-size:20px; }
.reference-panel[open] > summary::after { content:'−'; }
.reference-panel[open] > summary { margin-bottom:16px; }
.reference-panel > summary::-webkit-details-marker { display:none; }
.reference-panel .pseudocode { overflow-x:auto; font-size:12px; }
.algo-chip-row { display:flex; flex-wrap:wrap; background:transparent; padding:0; gap:6px; border:0; }
.algo-chip { flex:1 1 auto; min-height:40px; border:1px solid var(--line); padding:8px; }
.algo-chip.active { background:var(--text); color:var(--bg); }
.empty-msg { font-style:normal; font-size:13px; line-height:1.6; }
.legend { font-size:13px; }
.suite-stage,.segtree-stage,.fenwick-stage { padding:28px; }
.suite-stage input,.suite-stage select { min-height:40px; }
.suite-stage button { min-height:40px; }
.suite-stage table { font-size:13px; }
@media(max-width:800px) {
 body.algorithm-tool { padding-bottom:130px; height:auto; overflow:auto; }
 .app,.suite-page,.fenwick-page,.hull-page,.traversal-page,.segtree-page { display:flex; flex-direction:column; height:auto; }
 .sidebar { height:auto; overflow:visible; }
 .sidebar .scroll-region { overflow:visible; }
 .playback-dock { position:fixed; bottom:0; left:0; right:0; border-top:1px solid var(--line); border-bottom:0; padding:12px 16px max(12px,env(safe-area-inset-bottom)); box-shadow:0 -6px 24px #00000008; }
 .playback-dock .step-controls { max-width:520px; margin:auto; }
 .playback-dock .speed-row { max-width:520px; margin:8px auto 0!important; }
 .canvas-wrap,.hull-stage,.traversal-stage { height:50svh; min-height:300px; }
 .suite-stage,.segtree-stage,.fenwick-stage { height:auto; min-height:320px; max-width:100%; overflow:auto; padding:20px 16px; }
 .suite-stage > *,.segtree-stage > *,.fenwick-stage > * { min-width:0; max-width:100%; }
 .suite-stage svg { max-width:100%; }
 .suite-title { font-size:26px; }
 .sidebar-section { padding:18px 20px; }
 .canvas-hint { position:relative; top:auto; left:auto; max-width:none; border:0; border-bottom:1px solid var(--line); padding:8px 16px; }
 .canvas-wrap svg { height:calc(100% - 54px); }
 input[type='text'],input[type='number'],select,textarea { font-size:16px; }
 .controls-panel,.set-row { flex-wrap:wrap; }
}
.canvas-wrap svg,.suite-stage svg { touch-action:none; }
.mc-speed-row { display:flex; align-items:center; gap:12px; margin-top:10px; }
.mc-speed-row input { flex:1; min-width:0; }
@media(max-width:800px) { .mc-layout,.mc-controls { max-width:100%; } .mc-layout { flex-wrap:wrap; grid-template-columns:minmax(0,1fr); } }
.playback-dock .step-bar { min-width:0; width:100%; flex-wrap:wrap; padding:0; border:0; border-radius:0; gap:8px; }
.playback-dock .step-bar button { flex:1; min-width:0; min-height:44px; padding:8px 4px; font-size:15px; border-radius:0; }
.playback-dock .step-bar .speed { flex:1 0 100%; margin:0; display:flex; gap:12px; align-items:center; }
.playback-dock .step-bar .speed input { width:auto; min-width:0; flex:1; }
@media(max-width:800px) {
 .mc-canvas-wrap { width:100%; min-width:0; }
 .mc-canvas-stack { width:100%!important; height:auto!important; aspect-ratio:1; }
 .mc-dot-canvas { width:100%; height:100%; }
 .mitm-tables { grid-template-columns:minmax(0,1fr); }
 .playback-dock .step-bar { max-width:520px; margin:auto; }
}

/* Monte Carlo: one diagram, a quiet results sheet, settings in the sidebar. */
.mc-body { display:grid; grid-template-columns:minmax(240px,1.15fr) minmax(230px,1fr); gap:32px; align-items:start; }
.mc-canvas-wrap { width:100%; min-width:0; }
.mc-canvas-stack { width:100%!important; height:auto!important; aspect-ratio:1; border-radius:0; border:1px solid var(--line); }
.mc-dot-canvas { width:100%; height:100%; border-radius:0; }
.mc-stats { min-width:0; display:grid; grid-template-columns:1fr; gap:0; border-top:1px solid var(--line); }
.mc-area-card,.mc-area-card.exact,.mc-area-card.estimate,.mc-area-card.mc-pi-card { padding:22px 0; border:0; border-bottom:1px solid var(--line); border-radius:0; background:transparent; }
.mc-area-label { text-transform:none; letter-spacing:0; font:13px var(--sans); }
.mc-area-val,.mc-pi-val { font:clamp(26px,3vw,40px)/1.25 var(--serif); font-variant-numeric:tabular-nums; color:var(--text); }
.mc-area-error,.mc-area-error.good,.mc-area-error.warn,.mc-pi-true { color:var(--muted); font:12px/1.6 var(--sans); }
.mc-progress { border:0; padding:20px 0; border-radius:0; background:transparent; }
.mc-dot-badge { font-weight:400; padding:4px 8px; border-radius:0; }
.mc-dot-badge.hit { background:var(--cool-soft); color:var(--text); border-left:2px solid var(--cool); }
.mc-dot-badge.miss { background:var(--surface); color:var(--text); border-left:2px solid #ab9782; }
.mc-controls { padding:0; border:0; border-radius:0; background:transparent; }
.mc-controls .field input { width:100%; min-height:40px; border-radius:0; }
.mc-canvas-label { text-align:left; font:12px/1.7 var(--sans); padding-top:8px; }
.mc-vertex { fill:var(--text); stroke:var(--bg); }
/* DP: readable inputs and a table that looks like a table. */
.dp-stage { gap:28px; }
.dp-stage .problem-chooser,.dp-stage .dir-toggle { background:transparent; padding:0; border:0; border-radius:0; gap:4px; display:flex; flex-wrap:wrap; }
.dp-stage .problem-chooser button,.dp-stage .dir-toggle button { border:1px solid var(--line); border-radius:0; padding:10px 14px; font:13px var(--sans); }
.dp-stage .problem-chooser button.active,.dp-stage .dir-toggle button.active { background:var(--text); color:var(--bg); }
.dp-stage .items-row { gap:12px; align-items:stretch; }
.dp-stage .items-row .item-pill { min-width:110px; padding:14px; border-radius:0; border:1px solid var(--line); background:transparent!important; gap:8px; }
.dp-stage .items-row .item-pill .name { font:12px var(--sans); text-transform:none; letter-spacing:0; padding-right:20px; }
.dp-stage .items-row .item-pill input { width:60px; min-height:36px; border-radius:0; font-size:14px; }
.dp-stage .items-row .item-pill .del { min-height:28px; min-width:28px; top:4px; right:4px; }
.dp-table-wrap { border:0; border-top:1px solid var(--line); border-bottom:1px solid var(--line); border-radius:0; padding:20px 0; }
.dp-table { width:100%; border-collapse:collapse; font-variant-numeric:tabular-nums; }
.dp-table caption { text-align:left; font:12px/1.6 var(--sans); color:var(--muted); padding-bottom:20px; }
.dp-table th,.dp-table td { min-width:44px; height:44px; padding:6px; background:transparent; font-size:13px; border:1px solid var(--line); }
.dp-table th { text-transform:none; letter-spacing:0; font-weight:500; white-space:nowrap; }
.dp-table td.empty,.dp-table td.row0 { background:transparent; color:var(--muted); }
.dp-table td.filled-this-step { background:var(--text); color:var(--bg); transform:none; box-shadow:none; }
.dp-table td.dep-skip { background:var(--cool-soft); }
.dp-table td.dep-take,.dp-table td.in-path { background:var(--good-soft); }
.dp-run { width:100%; min-height:44px; margin-bottom:10px; }
.dp-row-cell .box { border-radius:0; }
@media(max-width:1050px) { .mc-body { grid-template-columns:minmax(0,1fr); } .mc-canvas-wrap { max-width:520px; } .mc-stats { grid-template-columns:repeat(2,minmax(0,1fr)); gap:0 20px; } .mc-progress,.mc-pi-card { grid-column:1/-1; } }
@media(max-width:600px) { .dp-stage .items-row .item-pill { flex:1 0 110px; } .dp-stage .suite-title,.mc-stage .suite-title { font-size:28px; } .mc-area-val,.mc-pi-val { font-size:28px; } .mc-formula { overflow-wrap:anywhere; } }
.playback-dock:has(.dp-run) .step-controls { display:none; }
.playback-dock .dp-run { margin-bottom:0; }

/* Subsets: a full-width worksheet with restrained, meaningful highlights. */
.subsets-stage { gap:28px; }
.subsets-stage .segtree-opbar { border:0; border-top:1px solid var(--line); border-bottom:1px solid var(--line); border-radius:0; padding:16px 0; background:transparent; }
.subsets-stage .problem-chooser { display:flex; gap:4px; padding:0; border:0; border-radius:0; background:transparent; }
.subsets-stage .problem-chooser button { border:1px solid var(--line); border-radius:0; padding:10px 16px; }
.subsets-stage .problem-chooser button.active { background:var(--text); color:var(--bg); }
.bitmask-table { width:100%; font-variant-numeric:tabular-nums; }
.bitmask-table caption { text-align:left; font:13px/1.6 var(--sans); padding:0 0 16px; color:var(--muted); }
.bitmask-table th,.bitmask-table td { height:40px; padding:8px 12px; border:0; border-bottom:1px solid var(--line); background:transparent; }
.bitmask-table th { text-transform:none; letter-spacing:0; font-size:12px; font-weight:500; }
.bitmask-table td.bit-1 { background:var(--cool-soft); color:var(--text); font-weight:600; }
.bitmask-table tr.current td { background:var(--surface-2); }
.bitmask-table tr.current td:first-child { box-shadow:inset 3px 0 var(--text); }
.bitmask-table tr.current td.bit-1 { background:var(--text); color:var(--bg); }
.rec-tree-wrap { border-radius:0; background:transparent; }
@media(max-width:600px) { .bitmask-table th,.bitmask-table td { padding:8px 6px; font-size:12px; } .bitmask-table { min-width:420px; } }

/* Keep diagrams intact: stage scrolling, rather than shrinking each child. */
.suite-stage > *,.segtree-stage > *,.fenwick-stage > * { flex-shrink:0; }
.dp-table-wrap { max-height:none; height:auto; flex-shrink:0; overflow-x:auto; }
.rec-tree-wrap { padding:12px; overflow:hidden; }
.subsets-stage .rec-tree-svg { width:100%; max-width:100%; height:auto; display:block; touch-action:pan-y; }
.subsets-stage .bitmask-table th,.subsets-stage .bitmask-table td { height:30px; padding:5px 8px; }
.subsets-stage { gap:18px; }
.subsets-stage .segtree-opbar { padding:12px 0; }
.greedy-stage .task-editor { border-top:1px solid var(--line); border-bottom:1px solid var(--line); padding:10px 0; }
.task-editor > div { display:grid!important; grid-template-columns:repeat(auto-fit,minmax(270px,1fr)); gap:12px!important; padding-top:12px; }
.task-edit-row { min-width:0; }
.task-timeline { min-width:0; width:100%; overflow:visible; border-radius:0; padding:16px 28px 24px 12px; }
.task-row { min-width:0; height:28px; }
.task-row .bar-area { min-width:0; }
.time-axis { position:relative; height:24px; }
.time-axis .tick { width:0; }
.time-axis .tick-label { display:block; transform:translateX(-50%); padding-left:0; }
.greedy-stage .problem-chooser,.mitm-stage .problem-chooser { border-radius:0; background:transparent; padding:0; gap:4px; }
.greedy-stage .problem-chooser button,.mitm-stage .problem-chooser button { border-radius:0; border:1px solid var(--line); }
.mitm-stage .array-split { padding:16px; border-radius:0; flex-wrap:wrap; gap:24px; }
.mitm-stage .elements-row { flex-wrap:wrap; }
.mitm-table-wrap,.brute-table-wrap { width:100%; max-width:none; margin:0; border-radius:0; }
.mitm-table-header { background:transparent; text-align:left; text-transform:none; letter-spacing:0; font-size:13px; }
.mitm-table-wrap > div[style],.brute-table-wrap > div[style] { max-height:none!important; overflow:visible!important; }
.mitm-table td,.mitm-table th,.brute-table td,.brute-table th { padding:7px 10px; font-size:13px; }
.mitm-stage .sum-badge,.mitm-stage .element-pill { background:transparent; border-radius:0; font-weight:500; color:var(--text); }
.topo-chip,.brute-table tr.match td { color:var(--text); }
.node.black circle { fill:var(--surface-2); stroke:var(--muted); }
.node.black text { fill:var(--text); }
@media(max-width:800px) { .mitm-tables { grid-template-columns:minmax(0,1fr); } .task-timeline { padding-right:20px; } .task-bar { font-size:11px; } }
.mitm-stage .comparison-panel { background:transparent; border-radius:0; padding:12px 0; }
.mitm-stage .segtree-opbar { border-radius:0; background:transparent; }
.task-row .id-label { flex-shrink:0; }

/* Data structure workspaces: one page scroll, diagrams sized by their viewBox. */
.segtree-svg-wrap,.trie-svg-wrap { height:auto; min-height:0; max-height:none; overflow:visible; border-radius:0; padding:16px; flex-shrink:0; }
.segtree-svg,.trie-svg { display:block; width:100%; min-width:0!important; max-width:100%; height:auto; margin:auto; }
.trie-svg { max-height:650px; }
.segtree-stage textarea,.fenwick-stage textarea,.sparse-stage textarea { min-height:44px; height:52px; max-width:100%; border-radius:0; }
.fenwick-header h1,.segtree-header h1 { font:32px/1.2 var(--serif); }
.segtree-opbar,.fenwick-opbar { border-radius:0; background:transparent; flex-wrap:wrap; gap:12px; }
.segtree-opbar .field,.fenwick-opbar .field { min-width:0; }
.problem-chooser,.dir-toggle { border-radius:0; background:transparent; }
.problem-chooser button,.dir-toggle button { border-radius:0; }
.playback-dock .step-bar .speed { padding-left:0; border-left:0; }
.playback-dock input[type=range] { appearance:none; background:transparent; border:0; padding:0; box-shadow:none; height:28px; }
.playback-dock input[type=range]::-webkit-slider-runnable-track { height:4px; background:var(--line); border-radius:2px; }
.playback-dock input[type=range]::-webkit-slider-thumb { appearance:none; width:16px; height:16px; margin-top:-6px; border-radius:50%; background:var(--text); }
.playback-dock input[type=range]::-moz-range-track { height:4px; background:var(--line); }
.playback-dock input[type=range]::-moz-range-thumb { width:16px; height:16px; border:0; border-radius:50%; background:var(--text); }
.playback-dock input[type=range]:focus:not(:focus-visible) { outline:none; }
.minhash-plot { display:block; width:100%; height:auto; max-height:300px; touch-action:pan-y!important; }
.hash-table-scroll { overflow-x:auto; }
.hash-rows { width:100%; min-width:560px; }
@media(max-width:800px) { .segtree-svg-wrap,.trie-svg-wrap { padding:8px; } .segtree-opbar .divider,.fenwick-opbar .divider { display:none; } .minhash-stage .set-row { gap:12px; } }


.fenwick-stage .range-bar,.fenwick-stage .range-bar.touched,.fenwick-stage .range-bar.used { color:var(--text); background:var(--cool-soft); border-color:var(--cool); }
/* Shared simulation contract: purpose, playback, current step, optional reference. */
.algorithm-tool .sidebar > header h2 { font:normal clamp(24px,2.2vw,36px) Georgia,serif; color:var(--ink); margin:0 0 12px; }
.simulation-guide { padding:14px 22px; border-bottom:1px solid var(--line); flex-shrink:0; font-size:13px; line-height:1.6; }
.simulation-guide p { margin:6px 0; }
.guide-kind { font-size:11px; color:var(--muted); text-transform:uppercase; letter-spacing:.08em; }
.simulation-guide details { margin-top:8px; color:var(--muted); }
.simulation-guide summary { cursor:pointer; font-size:12px; }
.playback-state { font-size:12px; margin:10px 0; color:var(--muted); font-variant-numeric:tabular-nums; }
.playback-speed { display:flex; align-items:center; gap:12px; margin:0; font-size:12px; color:var(--muted); }
.playback-speed input { width:100%; min-width:0; accent-color:var(--ink); }
.algorithm-tool .shared-playback { display:grid!important; grid-template-columns:40px 40px minmax(72px,1fr) 40px 40px!important; gap:6px!important; }
.algorithm-tool .shared-playback button { min-width:0!important; padding:8px 4px!important; font-size:14px; min-height:42px; }
.algorithm-tool .continuous-playback { display:flex; gap:8px; }
.algorithm-tool .continuous-playback button { flex:1; }
@media(max-width:900px){.simulation-guide {padding:10px 16px;} .simulation-guide details {display:block;} }
/* Shared language for controls and bounded default tree views. */
.fenwick-title { font:normal clamp(26px,2.8vw,36px)/1.2 var(--serif); }
.problem-chooser,.dir-toggle { display:flex; flex-wrap:wrap; gap:4px; padding:0; background:transparent; border:0; border-radius:0; }
.problem-chooser button,.dir-toggle button { border:1px solid var(--line); border-radius:0; }
.problem-chooser button.active,.dir-toggle button.active { background:var(--text); color:var(--bg); }
.segtree-svg,.trie-svg { height:min(44svh,440px); object-fit:contain; }
.trie-stage { gap:18px; }
.trie-stage .trie-result { min-height:0; }
.simulation-guide { min-height:0; }
@media(max-width:800px){
 .segtree-svg,.trie-svg { height:auto; max-height:480px; }
 .playback-dock .playback-speed,.playback-dock .playback-state { max-width:520px; margin:8px auto 0; }
}
.tree-node.empty rect,.tree-node.no-overlap rect { fill:var(--bg); stroke:var(--line); }
.tree-node.empty text,.tree-node.no-overlap text { fill:var(--muted); }
@media(max-width:800px){
 .canvas-hint { padding-right:16px; }
 .canvas-wrap .flow-readout,.hull-stage .flow-readout,.traversal-stage .flow-readout { top:10px; bottom:auto; }
 .sidebar .preset-buttons,.sidebar .presets { flex-wrap:wrap; }
}
/* A current vertex stays readable during colour transitions in either theme. */
.node.current circle { fill:var(--cool-soft); stroke:var(--cool); stroke-width:3; }
.node.current text { fill:var(--ink); }
.node.current .node-badge { fill:var(--muted); }
