
/* paper palette (results/figures/palette/palette.css): one hue per role */
:root {
  --judgment:#1f77b4; --judgment-text:#165682; --judgment-tint:#e4eff6; --judgment-tint2:#c0d9ea;
  --adjustment:#2ca02c; --adjustment-text:#207320; --adjustment-tint:#e6f4e6; --adjustment-tint2:#c4e4c4;
  --memory:#9467bd; --memory-text:#6b4a88; --memory-tint:#f2edf7; --memory-tint2:#e1d4ed;
  --feedback:#ff7f0e; --feedback-text:#b85b0a; --feedback-tint:#fff0e2; --feedback-tint2:#ffdbbc;
  --base:#7f7f7f; --base-text:#5b5b5b; --base-tint:#f0f0f0; --base-tint2:#dbdbdb;
  --wrong:#d62728; --wrong-text:#9a1c1d;
  --cov1:#76b7b2; --cov1-text:#558480; --cov2:#ff9da7; --cov2-text:#b87178;

  --ink:#16181d; --ink2:#4a4f59; --ink3:#8a909b; --line:#e6e8ec; --line2:#f1f2f5;
  --bg:#f6f7f9; --card:#ffffff;
  --mono: "JetBrains Mono", "SFMono-Regular", ui-monospace, Menlo, Consolas, monospace;
  --sans: "Pretendard", -apple-system, "Segoe UI", system-ui, sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 14px/1.5 var(--sans); overflow: hidden; }

/* header */
.top { height: 68px; display: flex; align-items: center; justify-content: space-between; padding: 0 24px;
  background: var(--card); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 12px; }
.brand .mark { width: 34px; height: 34px; }
.brand .name { font-weight: 700; font-size: 20px; letter-spacing: -0.01em; }
.brand .tag { font-size: 12.5px; color: var(--ink3); margin-top: -2px; }
.top-right { display: flex; align-items: center; gap: 10px; }
.clock { display: flex; flex-direction: column; align-items: flex-end; margin-right: 8px; min-width: 190px; }
.clock-label { font-size: 11px; color: var(--ink3); text-transform: uppercase; letter-spacing: .06em; }
.clock-time { font: 600 15px var(--mono); transition: color .4s; }
.clock.fb .clock-time { color: var(--feedback-text); }
.badge { display: flex; flex-direction: column; padding: 5px 12px; border: 1px solid var(--line); border-radius: 10px; background: #fbfbfc; }
.b-k { font-size: 10.5px; color: var(--ink3); text-transform: uppercase; letter-spacing: .06em; }
.b-v { font-weight: 600; font-size: 13.5px; }
.status { display: flex; align-items: center; gap: 8px; padding: 8px 14px; border-radius: 999px; background: var(--base-tint);
  font-weight: 600; font-size: 13px; color: var(--ink2); min-width: 118px; justify-content: center; }
.s-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--base); }
.status.run { background: var(--judgment-tint); color: var(--judgment-text); }
.status.run .s-dot { background: var(--judgment); animation: pulse 1.2s infinite; }
.status.done { background: var(--adjustment-tint); color: var(--adjustment-text); }
.status.done .s-dot { background: var(--adjustment); }
@keyframes pulse { 0%{ box-shadow: 0 0 0 0 rgba(31,119,180,.45);} 70%{ box-shadow: 0 0 0 8px rgba(31,119,180,0);} 100%{ box-shadow: 0 0 0 0 rgba(31,119,180,0);} }

/* layout */
.grid { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: 16px; padding: 16px 24px;
  height: calc(100% - 68px); }
.left { display: flex; flex-direction: column; gap: 12px; min-height: 0; overflow-y: auto; }
.left > * { flex-shrink: 0; }
.left > .bank-card { flex-shrink: 1; min-height: 132px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; }
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; padding: 14px 18px 4px; flex-wrap: wrap; min-height: 62px; }
.card-head.slim { padding: 10px 18px 2px; align-items: baseline; justify-content: flex-start; min-height: 0; }
.card-title { font-weight: 700; font-size: 16px; }
.card-title.small { font-size: 13.5px; display: flex; align-items: center; gap: 8px; }
.card-sub { font-size: 12.5px; color: var(--ink3); }
.sq { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.sq.mem { background: var(--memory); }

/* stage rail */
.rail { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
.rail li { display: flex; align-items: center; gap: 8px; padding: 9px 10px; border-radius: 10px; background: var(--card);
  border: 1px solid var(--line); font-size: 12.5px; font-weight: 600; color: var(--ink3); transition: all .35s; line-height: 1.2; min-height: 40px; }
.rail .n { width: 20px; height: 20px; flex: none; border-radius: 50%; display: grid; place-items: center; font-size: 11px;
  background: var(--line2); color: var(--ink3); transition: all .35s; }
.rail li.on { color: var(--ink); border-color: var(--c, var(--judgment)); box-shadow: 0 0 0 3px var(--ct, var(--judgment-tint)); }
.rail li.on .n { background: var(--c, var(--judgment)); color: #fff; }
.rail li.done { color: var(--ink2); }
.rail li.done .n { background: var(--c, var(--judgment)); color: #fff; opacity: .55; }
.rail li.skip { opacity: .45; text-decoration: line-through; }
.rail [data-stage=base] { --c: var(--base); --ct: var(--base-tint); }
.rail [data-stage=store] { --c: var(--memory); --ct: var(--memory-tint); }
.rail [data-stage=judge] { --c: var(--judgment); --ct: var(--judgment-tint); }
.rail [data-stage=adjust] { --c: var(--adjustment); --ct: var(--adjustment-tint); }
.rail [data-stage=observe], .rail [data-stage=construct] { --c: var(--feedback); --ct: var(--feedback-tint); }

/* main chart */
.chart-card { position: relative; }
.legend { display: flex; gap: 4px 14px; flex-wrap: wrap; font-size: 12px; color: var(--ink2); padding: 4px 18px 0; }
.lg { display: inline-flex; align-items: center; gap: 6px; transition: opacity .4s; }
.lg.off { opacity: .25; }
.sw { width: 18px; height: 0; border-top: 2px solid; display: inline-block; }
.sw-obs { border-color: #111; }
.sw-base { border-color: var(--base); border-top-style: dashed; }
.sw-bl { border-color: var(--wrong); }
.sw-jc { border-color: var(--judgment); border-top-width: 3px; }
.sw-res { border-color: var(--feedback); border-top-width: 6px; opacity: .6; }
.sw-cand { border-color: var(--memory); }
.chart-wrap { position: relative; padding: 0 8px 4px; }
.chart { width: 100%; height: auto; display: block; }
.chart text { font-family: var(--sans); }
.tip { position: absolute; pointer-events: none; background: rgba(22,24,29,.92); color: #fff; font-size: 12px; padding: 7px 10px;
  border-radius: 8px; white-space: nowrap; line-height: 1.55; }
.tip .t { color: #b9c0cc; font-family: var(--mono); font-size: 11px; }
.tip i { width: 8px; height: 8px; border-radius: 2px; display: inline-block; margin-right: 6px; }
.scoreboard { display: flex; align-items: center; gap: 12px; padding: 6px 14px; margin-top: -2px;
  background: #fff; border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 6px 20px rgba(20,30,50,.08);
  animation: rise .5s ease; }
.score { display: flex; flex-direction: column; }
.sc-k { font-size: 10.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--ink3); }
.sc-v { font: 700 18px var(--mono); }
.score.jc .sc-v { color: var(--judgment-text); }
.score.bl { padding-left: 12px; border-left: 1px solid var(--line); }
.score.bl .sc-v { color: var(--wrong-text); }
.score.delta .sc-v { font-size: 14px; color: var(--adjustment-text); background: var(--adjustment-tint); padding: 3px 8px; border-radius: 8px; }
.arrow { color: var(--ink3); }
@keyframes rise { from { opacity: 0; transform: translateY(6px);} to { opacity: 1; transform: none; } }

/* covariates */
.cov-card { padding-bottom: 6px; }
.cov { padding: 0 8px; }
.cov-name { font-size: 12.5px; font-weight: 600; line-height: 1.3; }
.cov-name code { display: block; font: 500 11px var(--mono); color: var(--ink3); margin-top: 2px; }
.cov svg { width: 100%; height: auto; display: block; }

/* memory bank */
.bank-card { flex: 1; min-height: 84px; display: flex; flex-direction: column; }
.bank-card .card-head { flex: none; }
.bank { display: flex; flex-wrap: wrap; gap: var(--gap, 4px); padding: 10px 18px 14px; align-content: flex-start; overflow-y: auto; scrollbar-gutter: stable; flex: 1; min-height: 0; }
.cell { width: var(--cell, 15px); height: var(--cell, 15px); border-radius: 3px; background: var(--memory-tint2); transition: all .4s; position: relative; }
/* a cell takes the colour of the role reading it: judgment (relevant experience) blue, adjustment (matched case) green */
.cell.hit { background: var(--judgment); transform: scale(1.35); box-shadow: 0 0 0 2px #fff, 0 0 0 3.5px var(--judgment); z-index: 1; }
.cell.case { background: var(--adjustment); box-shadow: 0 0 0 2px #fff, 0 0 0 3.5px var(--adjustment); transform: scale(1.35); z-index: 1; }
.cell.new { background: var(--memory); animation: born 1.2s ease; box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--memory); }
@keyframes born { 0% { transform: scale(0); } 55% { transform: scale(2.2); } 100% { transform: scale(1.35); } }

/* trace */
.right { display: flex; flex-direction: column; min-height: 0; }
.trace-head { padding: 14px 18px 10px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: baseline; }
.trace { flex: 1; overflow-y: auto; scrollbar-gutter: stable; padding: 14px 16px 120px; scroll-behavior: smooth; }
.trace::-webkit-scrollbar { width: 8px; } .trace::-webkit-scrollbar-thumb { background: var(--line); border-radius: 4px; }

.step { border-left: 2px solid var(--line); margin: 0 0 14px 9px; padding: 0 0 2px 18px; position: relative; animation: rise .35s ease; }
.step::before { content: ""; position: absolute; left: -7px; top: 3px; width: 12px; height: 12px; border-radius: 50%;
  background: #fff; border: 2px solid var(--c); }
.step.running::before { background: var(--c); animation: pulse2 1.1s infinite; }
.step.done::before { background: var(--c); }
@keyframes pulse2 { 0%{ box-shadow: 0 0 0 0 var(--ct2);} 100%{ box-shadow: 0 0 0 8px transparent;} }
.step.memory { --c: var(--memory); --ct: var(--memory-tint); --ct2: var(--memory-tint2); --tx: var(--memory-text); }
.step.judgment { --c: var(--judgment); --ct: var(--judgment-tint); --ct2: var(--judgment-tint2); --tx: var(--judgment-text); }
.step.adjustment { --c: var(--adjustment); --ct: var(--adjustment-tint); --ct2: var(--adjustment-tint2); --tx: var(--adjustment-text); }
.step.feedback { --c: var(--feedback); --ct: var(--feedback-tint); --ct2: var(--feedback-tint2); --tx: var(--feedback-text); }
.step.base { --c: var(--base); --ct: var(--base-tint); --ct2: var(--base-tint2); --tx: var(--base-text); }
.sh { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.sh .st { font-weight: 700; font-size: 14px; }
.sh .who { font: 500 11px var(--mono); color: var(--tx); background: var(--ct); padding: 1px 7px; border-radius: 6px; }
.sh .tm { margin-left: auto; font: 12px var(--mono); color: var(--ink3); }
.sd { color: var(--ink2); font-size: 12.5px; margin: 2px 0 8px; }
.sb { display: flex; flex-direction: column; gap: 8px; }

.think { display: inline-flex; align-items: center; gap: 8px; font-size: 12.5px; font-weight: 600;
  background: linear-gradient(90deg, var(--ink3) 0%, var(--ink3) 35%, #d3d7de 50%, var(--ink3) 65%, var(--ink3) 100%);
  background-size: 250% 100%; -webkit-background-clip: text; background-clip: text; color: transparent; animation: shimmer 1.6s linear infinite; }
.think.fin { animation: none; background: none; color: var(--ink3); font-weight: 500; }
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: -150% 0; } }

.block { background: #fafbfc; border: 1px solid var(--line2); border-radius: 10px; padding: 9px 12px; }
.block .bh { display: flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 600; margin-bottom: 4px; }
.block .bh code { font: 600 11.5px var(--mono); }
.rz { font-size: 13px; line-height: 1.55; color: var(--ink); }
.caret { display: inline-block; width: 7px; height: 14px; background: var(--c, var(--ink)); vertical-align: -2px; margin-left: 1px; animation: blink .9s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }

.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { display: inline-flex; align-items: center; gap: 6px; font: 500 11.5px var(--mono); padding: 3px 8px; border-radius: 7px;
  background: var(--judgment-tint); color: var(--judgment-text); border: 1px solid var(--judgment-tint2); animation: pop .3s ease; white-space: nowrap; }
.chip b { font-weight: 700; }
.chip.mem { background: var(--memory-tint); color: var(--memory-text); border-color: var(--memory-tint2); }
.chip.adj { background: var(--adjustment-tint); color: var(--adjustment-text); border-color: var(--adjustment-tint2); }
.chip.fb { background: var(--feedback-tint); color: var(--feedback-text); border-color: var(--feedback-tint2); }
.chip.gray { background: var(--base-tint); color: var(--base-text); border-color: var(--base-tint2); }
@keyframes pop { from { opacity: 0; transform: scale(.85);} to { opacity: 1; transform: none; } }

.exp { display: grid; grid-template-columns: 92px 1fr auto; gap: 10px; align-items: center; padding: 6px 10px; border-radius: 9px;
  background: var(--memory-tint); border: 1px solid transparent; animation: rise .3s ease; }
.exp .d { font: 600 11.5px var(--mono); color: var(--memory-text); line-height: 1.3; }
.exp .d span { display: block; font-weight: 400; color: var(--ink3); font-size: 10.5px; }
.exp .dist { font: 11px var(--mono); color: var(--ink3); text-align: right; line-height: 1.3; }
.exp .chips .chip { font-size: 10.5px; padding: 1px 6px; }

.cases { display: flex; flex-direction: column; gap: 3px; }
.case { display: grid; grid-template-columns: 86px 1fr 70px 78px; gap: 8px; font: 11px var(--mono); color: var(--ink2);
  padding: 3px 8px; border-radius: 6px; background: var(--adjustment-tint); animation: rise .25s ease; }
.case .k { color: var(--adjustment-text); font-weight: 600; }
.subh { font-size: 11.5px; font-weight: 600; letter-spacing: .02em; margin: 2px 0 -2px; }
.subh.mem { color: var(--memory-text); }
.subh.jud { color: var(--judgment-text); margin-top: 6px; }
.result { display: flex; align-items: center; gap: 10px; font-size: 13px; font-weight: 600; }
.delta-v { font: 700 14px var(--mono); padding: 3px 10px; border-radius: 8px; background: var(--adjustment-tint); color: var(--adjustment-text);
  border: 1px solid var(--adjustment-tint2); animation: pop .35s ease; }

.kv { display: grid; grid-template-columns: auto 1fr; gap: 3px 14px; font-size: 12.5px; }
.kv .k { color: var(--ink3); }
.kv .v { font-family: var(--mono); font-size: 12px; }

.cand { display: grid; grid-template-columns: 30px 1fr; gap: 10px; padding: 8px 10px; border-radius: 10px; background: #fafbfc;
  border: 1px solid var(--line2); animation: rise .3s ease; transition: all .4s; }
.cand .id { font: 700 12px var(--mono); color: var(--ink3); padding-top: 1px; }
.cand .rz { font-size: 12.5px; color: var(--ink2); margin-top: 4px; }
.cand.sel { border-color: var(--memory); background: var(--memory-tint); box-shadow: 0 0 0 3px var(--memory-tint2); }
.cand.sel .id { color: var(--memory-text); }

.losses { display: flex; flex-direction: column; gap: 5px; margin-top: 2px; }
.loss { display: grid; grid-template-columns: 64px 1fr 62px; gap: 10px; align-items: center; font: 12px var(--mono); transition: all .4s; }
.loss .lab { color: var(--ink2); }
.loss .bar { height: 14px; background: var(--line2); border-radius: 4px; position: relative; overflow: hidden; }
.loss .bar i { position: absolute; left: 0; top: 0; bottom: 0; width: 0; border-radius: 4px; background: var(--base-tint2); transition: width .7s cubic-bezier(.2,.8,.2,1); }
.loss.fwd .bar i { background: var(--judgment-tint2); }
.loss.basel .bar i { background: repeating-linear-gradient(135deg, var(--base-tint2) 0 4px, #fff 4px 7px); }
.loss.win .bar i { background: var(--memory); }
.loss.win .lab, .loss.win .val { color: var(--memory-text); font-weight: 700; }
.loss .val { text-align: right; }

.stored { border: 1px solid var(--memory-tint2); background: var(--memory-tint); border-radius: 12px; padding: 10px 12px; animation: rise .4s ease; }
.stored .bh { color: var(--memory-text); font-weight: 700; font-size: 13px; margin-bottom: 6px; display: flex; gap: 8px; align-items: center; }
.muted { color: var(--ink3); font-size: 12px; }
.endline { text-align: center; color: var(--ink3); font-size: 12.5px; margin-top: 18px; animation: rise .4s ease; }

/* controls: hidden with H for recording */
.controls { position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%); display: flex; align-items: center; gap: 4px;
  background: rgba(22,24,29,.92); color: #fff; border-radius: 12px; padding: 6px 8px; box-shadow: 0 10px 30px rgba(0,0,0,.2); z-index: 10; transition: opacity .3s; }
.controls.hide { opacity: 0; pointer-events: none; }
.controls button { background: transparent; color: #dfe3ea; border: 0; font: 600 13px var(--sans); padding: 6px 10px; border-radius: 8px; cursor: pointer; }
.controls button:hover { background: rgba(255,255,255,.1); }
.controls button.on { background: #fff; color: var(--ink); }
.controls #btn-play { font-size: 14px; width: 38px; }
.controls .sep { width: 1px; height: 20px; background: rgba(255,255,255,.2); margin: 0 4px; }
.controls .hint { font-size: 11.5px; color: #9aa3b2; padding: 0 6px; }

.views { display: none; }

/* video mode (?video): a red ring on what to look at; the step outlines give way to it; reasoning is background */
#spot { position: fixed; z-index: 60; pointer-events: none; box-sizing: border-box; border: 4px solid #d62728; border-radius: 14px;
  box-shadow: 0 0 0 6px rgba(214,39,40,.15), 0 10px 28px rgba(214,39,40,.14); opacity: 0; transition: opacity .25s; }
#spot.on { opacity: 1; }
#spot.pop { animation: spotpop .5s cubic-bezier(.2,.8,.2,1); }
#spot.glide { transition: opacity .25s, left .4s ease, top .4s ease, width .4s ease, height .4s ease; }
#spot.thick { border-width: 5px; box-shadow: 0 0 0 4px rgba(214,39,40,.18), 0 8px 22px rgba(214,39,40,.16); }
@keyframes spotpop { 0% { transform: scale(1.06); opacity: 0; } 100% { transform: none; opacity: 1; } }
/* the tag sits inside the ring on the empty end of the bar track, clear of the numbers */
#spot .tag { position: absolute; top: 50%; right: 84px; transform: translateY(-50%); background: #d62728; color: #fff;
  font: 700 15px/1 var(--sans); padding: 6px 12px; border-radius: 8px; letter-spacing: .02em; }
html.video .losses { gap: 14px; }
#climax { position: fixed; z-index: 61; display: grid; grid-template-columns: auto auto auto; align-items: baseline; gap: 4px 18px;
  background: #fff; border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 18px 44px rgba(20,30,50,.20);
  padding: 16px 22px 14px; opacity: 0; transform: translateY(10px); transition: opacity .3s, transform .3s; }
#climax.on { opacity: 1; transform: none; }
#climax .k { font-size: 19px; font-weight: 600; color: var(--ink2); }
#climax .v { font: 700 36px var(--mono); text-align: right; color: var(--ink2); }
#climax .k.win { color: var(--ink); }
#climax .v.win { color: var(--memory-text); }
#climax .d b { font: 700 17px var(--mono); color: var(--adjustment-text); background: var(--adjustment-tint);
  border: 1px solid var(--adjustment-tint2); padding: 4px 9px; border-radius: 8px; }
#climax .f { grid-column: 1 / -1; font-size: 12.5px; color: var(--ink3); margin-top: 4px; }
html.video .card.focus, html.video .scoreboard.focus { border-color: var(--line); box-shadow: none; }
html.video .trace .rz { color: var(--ink2); }
html.video .trace .sd { opacity: .75; }
/* results appear whole: each card fades in complete instead of being typed */
html.video .trace .block, html.video .trace .cand, html.video .trace .stored { animation: cardin .45s ease; }
@keyframes cardin { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.keyline { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 7px; }
.kl { font-size: 11px; font-weight: 700; color: var(--ink2); text-transform: uppercase; letter-spacing: .05em; margin-right: 2px; }

/* header switch between the recorded samples */
.samples { display: flex; align-items: stretch; align-self: center; gap: 3px; background: #eef0f3; border-radius: 12px; padding: 3px; margin: 0 16px; }
.samples button { display: flex; flex-direction: column; justify-content: center; height: auto; line-height: 1.3;
  border: 0; background: transparent; text-align: left; padding: 5px 14px; border-radius: 9px; cursor: pointer;
  font-family: var(--sans); color: var(--ink2); transition: background .2s, box-shadow .2s; }
.samples button:hover { background: rgba(255,255,255,.55); }
.samples .smp-t { display: block; font-weight: 600; font-size: 13px; line-height: 1.3; white-space: nowrap; }
.samples .smp-d { display: block; font-size: 11px; color: var(--ink3); line-height: 1.3; white-space: nowrap; }
.samples button.on { background: #fff; color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.08); }
@media (max-width: 1599px) { .brand .tag { display: none; } }
/* where the scoreboard would wrap under the title, don't hold its space before it appears */
@media (max-width: 1279px) { .scoreboard[style*="hidden"] { display: none; } }
@media (max-width: 1439px) { .samples .smp-d { display: none; } }
@media (min-width: 1000px) and (max-width: 1279px) { .badge { display: none; } }
/* PC: the card the current step is acting on */
.card, .scoreboard { transition: border-color .35s, box-shadow .35s; }
.card.focus, .scoreboard.focus { border-color: var(--fc); box-shadow: 0 0 0 3px var(--fct); }
.sc-k { white-space: nowrap; }

@media (min-width: 1000px) and (max-height: 920px) {
  .cov-card .card-sub { display: none; }
  .card-head { min-height: 0; }
}
/* small laptops and tablets in landscape: keep the two columns, compact the chrome */
@media (min-width: 1000px) and (max-width: 1279px) {
  .brand .tag { display: none; }
  .b-v { white-space: nowrap; }
  .clock { min-width: 0; }
  .rail { display: flex; gap: 5px; }
  .rail li { flex: none; min-height: 0; }
  .rail li .t { display: none; }
  .rail li.on { flex: 1; }
  .rail li.on .t { display: inline; }
  .rail li:not(.on) { padding: 9px 8px; }
  .legend { gap: 2px 12px; }
}

/* tablet portrait and phones: one column, one visualization at a time above the trace */
@media (max-width: 999px) {
  body { display: flex; flex-direction: column; height: 100vh; height: 100dvh; }
  .top { height: auto; flex: none; padding: 10px 14px; gap: 8px; flex-wrap: wrap; }
  .samples { order: 3; width: 100%; margin: 0; }
  .samples button { flex: 1; padding: 5px 8px; text-align: center; align-items: center; }
  .samples .smp-t { font-size: 12px; white-space: normal; }
  .brand { gap: 9px; }
  .brand .mark { width: 28px; height: 28px; }
  .brand .name { font-size: 17px; }
  .brand .tag, .badge { display: none; }
  .top-right { gap: 8px; }
  .clock { min-width: 0; margin-right: 0; }
  .clock-label { font-size: 9.5px; }
  .clock-time { font-size: 12px; }
  .status { min-width: 0; padding: 6px 10px; font-size: 12px; }
  .grid { display: flex; flex-direction: column; gap: 10px; padding: 10px 12px; height: auto; flex: 1; min-height: 0; }
  .left { flex: none; gap: 8px; }
  .right { flex: 1; min-height: 140px; }
  .rail { display: flex; gap: 4px; }
  .rail li { flex: none; padding: 6px 8px; min-height: 0; font-size: 12px; }
  .rail li .t { display: none; }
  .rail li.on { flex: 1; }
  .rail li.on .t { display: inline; }
  .views { display: flex; gap: 4px; background: #eceef2; border-radius: 10px; padding: 3px; }
  .views button { flex: 1; border: 0; background: transparent; font: 600 12.5px var(--sans); color: var(--ink2); padding: 6px 0; border-radius: 8px; cursor: pointer; }
  .views button.on { background: #fff; color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.08); }
  .card.focus, .scoreboard.focus { border-color: var(--line); box-shadow: none; }
  .left[data-view=forecast] .cov-card, .left[data-view=forecast] .bank-card,
  .left[data-view=covariates] .chart-card, .left[data-view=covariates] .bank-card,
  .left[data-view=memory] .chart-card, .left[data-view=memory] .cov-card { display: none; }
  .card-head { min-height: 0; padding: 10px 14px 2px; gap: 8px; }
  .chart-card .card-head .card-sub, .cov-card .card-sub { display: none; }
  .sc-k { font-size: 9.5px; }
  .card-title { font-size: 14.5px; }
  .legend { font-size: 11px; gap: 3px 10px; padding: 2px 14px 0; }
  .scoreboard { gap: 4px 8px; padding: 4px 10px; box-shadow: none; flex-wrap: wrap; max-width: 100%; }
  .scoreboard .arrow { display: none; }
  .sc-v { font-size: 15px; }
  .score.delta .sc-v { font-size: 12.5px; }
  .left > .bank-card { flex: none; min-height: 0; }
  .bank { height: var(--bankh, 200px); flex: none; }
  .trace-head { padding: 10px 14px 8px; }
  .trace { padding: 10px 12px 90px; }
  .step { margin-left: 7px; padding-left: 14px; }
  .case { grid-template-columns: 76px 1fr 56px 70px; gap: 4px; font-size: 10.5px; }
  .exp { grid-template-columns: 80px 1fr; }
  .exp .dist { grid-column: 2; text-align: left; }
  .controls { bottom: calc(10px + env(safe-area-inset-bottom, 0px)); }
  .controls .hint, .controls .spd[data-s="0.5"] { display: none; }
}
@media (max-width: 999px) and (min-height: 1000px) {
  .card-title { font-size: 16px; }
  .legend { font-size: 12px; }
}
