/* KneeGrade: clinical, quiet interface. The X-ray viewer and the KL severity scale carry the colour. */
:root {
  --paper: #EEF2F4;
  --surface: #FFFFFF;
  --ink: #142231;
  --muted: #586777;
  --line: #DAE1E7;
  --line-strong: #BFCAD3;
  --nav: #0F2F47;
  --nav-ink: #B9CDDC;
  --nav-hover: #173F5D;
  --accent: #0B6E66;
  --accent-hover: #095C55;
  --accent-soft: #E1F0EE;
  --lightbox: #17222D;
  --danger: #B42318;
  --danger-soft: #FCEDEB;
  --warn-soft: #FFF6E5;
  /* Kellgren–Lawrence grades 0–4: one escalating scale */
  --g0: #3E9478;
  --g1: #8FA33A;
  --g2: #D39A22;
  --g3: #D2672A;
  --g4: #A8352A;
  --sidebar-w: 252px;
  --r-panel: 14px;
  --r-ctl: 9px;
  --font: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font: 400 15px/1.6 var(--font); font-feature-settings: "tnum" 1;
}
body.modal-open { overflow: hidden; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; font-weight: 600; letter-spacing: -0.01em; }
a { color: var(--accent); }
img { display: block; max-width: 100%; }
svg { flex: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.fine { font-size: 12.5px; color: var(--muted); margin: 10px 0 0; line-height: 1.5; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ============ App shell ============ */
.app {
  display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  min-height: 100vh; transition: grid-template-columns .22s ease;
}
.app.nav-collapsed { grid-template-columns: 0 minmax(0, 1fr); }
.app.nav-collapsed .sidebar { visibility: hidden; }

.sidebar {
  position: sticky; top: 0; height: 100vh; overflow: hidden auto;
  background: var(--nav); color: var(--nav-ink);
  display: flex; flex-direction: column; padding: 20px 14px 18px; width: var(--sidebar-w);
}
.brand { display: flex; align-items: center; gap: 12px; padding: 4px 8px 22px; color: #fff; text-decoration: none; }
.brand-mark { width: 34px; height: 34px; color: #7FD3C7; }
.brand-text { display: flex; flex-direction: column; line-height: 1.25; }
.brand-text strong { font-size: 17px; font-weight: 700; letter-spacing: -0.01em; }
.brand-text span { font-size: 12.5px; color: var(--nav-ink); }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px;
  color: var(--nav-ink); text-decoration: none; font-weight: 500; font-size: 14.5px;
  transition: background .15s ease, color .15s ease;
}
.nav-item svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.nav-item:hover { background: var(--nav-hover); color: #fff; }
.nav-item.active { background: #fff; color: var(--nav); }
.nav-item.active svg { color: var(--accent); }
.nav-item:focus-visible { outline-color: #7FD3C7; }

.sidebar-foot { margin-top: auto; padding: 16px 10px 0; border-top: 1px solid #234B69; font-size: 12.5px; }
.sidebar-foot p { margin: 0 0 8px; }
.model-state { display: flex; align-items: center; gap: 8px; color: #fff; }
.model-state .dot { width: 8px; height: 8px; border-radius: 50%; background: #E3B341; }
.model-state.ok .dot { background: #4FD1A5; }
.model-state.down .dot { background: #F07167; }
.shortcut kbd {
  font: 500 11.5px var(--font); padding: 1px 6px; border-radius: 5px;
  border: 1px solid #36607F; background: #163C58; color: #fff;
}
.disclaimer-mini { color: #8FAAC0; }

.backdrop { display: none; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 14px;
  padding: 14px 32px; background: rgba(238, 242, 244, .92); backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--line);
}
.topbar h1 { font-size: 21px; flex: 1; }
.content { flex: 1; padding: 28px 32px 40px; max-width: 1480px; width: 100%; outline: none; }
.page-foot { padding: 18px 32px 26px; font-size: 12.5px; color: var(--muted); border-top: 1px solid var(--line); }

/* ============ Controls ============ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 16px; border-radius: var(--r-ctl);
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink);
  font: 500 14px var(--font); text-decoration: none; cursor: pointer;
  transition: background .15s ease, border-color .15s ease;
}
.btn:hover { background: #F5F8F9; border-color: #A9B6C1; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-hover); }
.btn.primary:disabled { background: #9DBDB9; border-color: #9DBDB9; cursor: not-allowed; }
.btn.danger { color: var(--danger); }
.btn.danger:hover { background: var(--danger-soft); border-color: #E7B4AE; }
.btn.wide { width: 100%; height: 46px; font-size: 15px; }
.icon-btn {
  display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: var(--r-ctl);
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); cursor: pointer;
}
.icon-btn:hover { background: #F5F8F9; }
.icon-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; }
.text-btn { border: 0; background: none; color: var(--accent); font: 500 14px var(--font); cursor: pointer; padding: 4px; }
.text-link { font-size: 14px; font-weight: 500; text-decoration: none; }
.text-link:hover { text-decoration: underline; }

.field { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: var(--muted); font-weight: 500; }
.field.grow { flex: 1 1 220px; }
.field input, .field select {
  height: 40px; padding: 0 12px; border-radius: var(--r-ctl); border: 1px solid var(--line-strong);
  background: var(--surface); color: var(--ink); font: 400 14px var(--font);
}
.check { display: flex; align-items: center; gap: 10px; margin: 16px 0 12px; font-size: 14px; cursor: pointer; }
.check input { width: 17px; height: 17px; accent-color: var(--accent); }

/* ============ Panels ============ */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-panel); padding: 22px; }
.panel > h3, .panel-head h3 { font-size: 16px; }
.panel > h3 { margin-bottom: 14px; }
.panel-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.view > * + * { margin-top: 20px; }
.two-col { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.lead { margin: 0; color: var(--muted); max-width: 72ch; }

/* ============ Dashboard ============ */
.hero {
  display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); gap: 28px; align-items: center;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-panel); padding: 30px;
}
.hero h2 { font-size: 28px; font-weight: 600; letter-spacing: -0.02em; max-width: 18ch; }
.hero p { margin: 12px 0 0; color: var(--muted); max-width: 52ch; }
.hero .hero-fine { font-size: 13px; }

.dropzone {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  min-height: 190px; padding: 24px; text-align: center; cursor: pointer;
  border: 1.5px dashed var(--line-strong); border-radius: 12px; background: #F7FAFB;
  transition: border-color .15s ease, background .15s ease;
}
.dropzone svg { width: 30px; height: 30px; fill: none; stroke: var(--accent); stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; margin-bottom: 4px; }
.dropzone strong { font-size: 15.5px; font-weight: 600; }
.dropzone span { font-size: 13px; color: var(--muted); max-width: 34ch; }
.dropzone:hover, .dropzone.drag { border-color: var(--accent); background: var(--accent-soft); }
.dropzone.tall { min-height: 260px; }

.stats {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr));
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-panel);
}
.stat { padding: 18px 22px; display: flex; flex-direction: column; gap: 2px; }
.stat + .stat { border-left: 1px solid var(--line); }
.stat-label { font-size: 13px; color: var(--muted); font-weight: 500; }
.stat-value { font-size: 28px; font-weight: 600; letter-spacing: -0.02em; line-height: 1.2; }
.stat-sub { font-size: 12.5px; color: var(--muted); }

.dash-grid { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: 20px; }
.model-strip { display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.model-strip p { margin: 6px 0 0; color: var(--muted); max-width: 80ch; }
.model-strip b { color: var(--ink); }

.rec-list { display: flex; flex-direction: column; }
.rec {
  display: flex; align-items: center; gap: 14px; width: 100%; padding: 10px 8px; margin: 0;
  border: 0; border-bottom: 1px solid var(--line); background: none; text-align: left; cursor: pointer;
  font: inherit; color: inherit; border-radius: 0;
}
.rec:last-child { border-bottom: 0; }
.rec:hover { background: #F6F9FA; }
.rec img { width: 46px; height: 46px; border-radius: 8px; object-fit: cover; background: var(--lightbox); }
.rec-main { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.rec-name { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rec-date { font-size: 12.5px; color: var(--muted); }

.empty { padding: 26px 8px; text-align: center; color: var(--muted); }
.empty strong { display: block; color: var(--ink); font-size: 15px; margin-bottom: 4px; }
.empty .btn { margin-top: 14px; }

.dist { display: flex; flex-direction: column; gap: 10px; }
.dist-row { display: grid; grid-template-columns: 112px minmax(0, 1fr) 42px; align-items: center; gap: 12px; font-size: 14px; }
.dist-label b { display: inline-block; width: 16px; }
.dist-track { height: 12px; border-radius: 6px; background: #EDF1F4; overflow: hidden; }
.dist-fill { display: block; height: 100%; border-radius: 6px; background: var(--gc); }
.dist-val { text-align: right; font-weight: 600; }

/* ============ Grade badge ============ */
.badge {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; white-space: nowrap;
  font-size: 12.5px; font-weight: 600;
  background: color-mix(in srgb, var(--gc) 15%, white);
  color: color-mix(in srgb, var(--gc) 72%, black);
}
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--gc); }
.badge-name { font-weight: 500; }

/* ============ New analysis ============ */
.analyze-grid { display: grid; grid-template-columns: minmax(0, 0.85fr) minmax(0, 1.25fr); gap: 20px; align-items: start; }
.preview-frame { background: var(--lightbox); border-radius: 12px; padding: 14px; display: grid; place-items: center; }
.preview-frame img { max-height: 280px; border-radius: 4px; }
.preview-meta { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 10px; font-size: 14px; }

.error { margin: 12px 0 0; padding: 10px 12px; border-radius: var(--r-ctl); background: var(--danger-soft); color: var(--danger); font-size: 14px; }

.stepper { list-style: none; margin: 18px 0 0; padding: 0; display: flex; flex-direction: column; gap: 9px; font-size: 14px; color: var(--muted); }
.stepper li { display: flex; align-items: center; gap: 10px; }
.step-dot { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--line-strong); display: grid; place-items: center; }
.stepper li[data-state="active"] { color: var(--ink); font-weight: 500; }
.stepper li[data-state="active"] .step-dot { border-color: var(--accent); border-top-color: transparent; animation: spin .8s linear infinite; }
.stepper li[data-state="done"] { color: var(--ink); }
.stepper li[data-state="done"] .step-dot { background: var(--accent); border-color: var(--accent); }
.stepper li[data-state="done"] .step-dot::after { content: ""; width: 7px; height: 4px; border: 2px solid #fff; border-top: 0; border-right: 0; transform: translateY(-1px) rotate(-45deg); }
.stepper li[data-state="skipped"] { text-decoration: line-through; }
.stepper li[data-state="error"] { color: var(--danger); }
.stepper li[data-state="error"] .step-dot { border-color: var(--danger); background: var(--danger); }
@keyframes spin { to { transform: rotate(360deg); } }

.examples { margin-top: 24px; padding-top: 18px; border-top: 1px solid var(--line); }
.examples h4 { font-size: 14px; font-weight: 600; margin-bottom: 12px; }
.example-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.example {
  border: 1px solid var(--line); border-radius: 10px; padding: 6px; background: var(--surface); cursor: pointer;
  font: 500 12.5px var(--font); color: var(--ink); display: flex; flex-direction: column; gap: 6px; text-align: left;
}
.example:hover { border-color: var(--accent); }
.example img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 6px; background: var(--lightbox); }

/* ============ Result ============ */
.result-panel { min-height: 420px; }
.result-empty { height: 100%; min-height: 380px; display: grid; place-items: center; text-align: center; color: var(--muted); }
.result-empty .scale-ghost { display: flex; gap: 6px; justify-content: center; margin-bottom: 18px; }
.result-empty .scale-ghost span { width: 34px; height: 8px; border-radius: 4px; background: var(--gc); opacity: .5; }
.result-empty strong { display: block; color: var(--ink); font-size: 16px; margin-bottom: 4px; }

.result-head { display: flex; gap: 18px; align-items: center; }
.result-grade {
  flex: none; width: 92px; height: 92px; border-radius: 18px; display: flex; flex-direction: column;
  align-items: center; justify-content: center; background: var(--gc); color: #fff;
}
.result-num { font-size: 44px; font-weight: 700; line-height: 1; }
.result-kl { font-size: 12px; font-weight: 500; opacity: .9; margin-top: 4px; }
.result-head h3 { font-size: 24px; letter-spacing: -0.02em; }
.result-head p { margin: 4px 0 0; color: var(--muted); }

.sub { font-size: 13.5px; font-weight: 600; margin: 24px 0 12px; }
.scale { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; }
.scale-col { display: flex; flex-direction: column; gap: 6px; padding: 8px; border-radius: 12px; border: 1.5px solid transparent; }
.scale-col.is-pred { border-color: var(--gc); background: color-mix(in srgb, var(--gc) 7%, white); }
.scale-track { height: 104px; border-radius: 7px; background: #EDF1F4; display: flex; align-items: flex-end; overflow: hidden; }
.scale-fill { width: 100%; background: var(--gc); border-radius: 7px 7px 0 0; transition: height .5s ease; }
.scale-pct { font-size: 17px; font-weight: 600; }
.scale-label { font-size: 12.5px; color: var(--muted); line-height: 1.3; }
.scale-label b { color: var(--ink); }

.note { margin: 16px 0 0; padding: 11px 14px; border-radius: var(--r-ctl); background: var(--warn-soft); font-size: 13.5px; line-height: 1.5; border: 1px solid #F1DDB2; }
.note.quiet { background: #F4F7F9; border-color: var(--line); }

.viewer { margin-top: 22px; background: var(--lightbox); border-radius: 14px; padding: 14px; color: #D7E2EA; }
.viewer-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.seg { display: inline-flex; padding: 3px; border-radius: 9px; background: #0E1720; }
.seg button { border: 0; background: none; color: #A9BBC9; font: 500 13px var(--font); padding: 6px 12px; border-radius: 7px; cursor: pointer; }
.seg button[aria-selected="true"] { background: #2A3A49; color: #fff; }
.opacity { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.opacity input { width: 140px; accent-color: #7FD3C7; }
.viewer-hint { font-size: 13px; color: #8FA3B4; }
.viewer-stage { position: relative; width: min(100%, 400px); aspect-ratio: 1; margin: 0 auto; }
.viewer-stage img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; border-radius: 4px; }
.viewer-legend { display: flex; align-items: center; gap: 10px; margin: 12px 0 0; font-size: 12.5px; color: #A9BBC9; justify-content: center; text-align: center; flex-wrap: wrap; }
.ramp { width: 90px; height: 8px; border-radius: 4px; background: linear-gradient(90deg, #00008F, #0060FF, #00FFFF, #FFFF00, #FF3000, #800000); }

.meta { display: flex; gap: 28px; margin: 18px 0 0; flex-wrap: wrap; font-size: 13.5px; }
.meta div { min-width: 0; }
.meta dt { color: var(--muted); font-size: 12.5px; }
.meta dd { margin: 0; font-weight: 500; overflow-wrap: anywhere; }

/* ============ History ============ */
.filters { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.history-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 18px 0 8px; flex-wrap: wrap; }
.history-actions { display: flex; gap: 8px; }
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-size: 12.5px; font-weight: 600; color: var(--muted); padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; }
.table.compact td, .table.compact th { padding: 8px 10px; }
.table tbody tr.clickable { cursor: pointer; }
.table tbody tr.clickable:hover { background: #F6F9FA; }
.thumb { width: 44px; height: 44px; border-radius: 8px; object-fit: cover; background: var(--lightbox); }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; }
.row-actions .icon-btn { width: 34px; height: 34px; }
.row-actions .icon-btn svg { width: 17px; height: 17px; }
.row-actions .icon-btn.del:hover { color: var(--danger); background: var(--danger-soft); }

/* ============ Insights ============ */
.metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.metric { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-panel); padding: 18px 20px; }
.metric-label { font-size: 13px; color: var(--muted); font-weight: 500; }
.metric-value { font-size: 32px; font-weight: 600; letter-spacing: -0.02em; line-height: 1.2; margin-top: 4px; }
.metric-ci { font-size: 13px; color: var(--ink); margin-top: 2px; }
.metric-note { font-size: 12.5px; color: var(--muted); margin-top: 8px; line-height: 1.45; }
.metric.primary-metric { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }

.recall-bar { display: inline-block; width: 64px; height: 6px; border-radius: 3px; background: #EDF1F4; vertical-align: middle; margin-left: 8px; overflow: hidden; }
.recall-bar span { display: block; height: 100%; background: var(--gc); }

.cm { display: grid; grid-template-columns: 74px repeat(5, minmax(0, 1fr)); gap: 4px; font-size: 13px; }
.cm-h { display: grid; place-items: center; font-weight: 600; color: var(--muted); padding: 4px 0; text-align: center; }
.cm-rh { display: flex; align-items: center; font-weight: 600; color: var(--muted); }
.cm-cell { aspect-ratio: 1.25; border-radius: 7px; display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.2; }
.cm-cell b { font-size: 14.5px; }
.cm-cell span { font-size: 11.5px; opacity: .85; }
.cm-cell.diag { box-shadow: inset 0 0 0 2px rgba(20, 34, 49, .35); }

.charts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.charts figure { margin: 0; }
.charts figcaption { font-size: 13.5px; font-weight: 600; margin-bottom: 8px; }
.chart-box { position: relative; height: 230px; }

.exp-final td { font-weight: 600; background: var(--accent-soft); }

.checks { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.checks div { display: flex; flex-direction: column; gap: 4px; padding: 14px 16px; border-radius: 12px; background: #F4F7F9; }
.checks b { font-size: 22px; font-weight: 600; }
.checks span { font-size: 13.5px; color: var(--muted); line-height: 1.45; }
.figure-row { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 18px; margin-top: 18px; }
.figure-row figure { margin: 0; }
.figure-row img { width: 100%; border-radius: 10px; border: 1px solid var(--line); }
.figure-row figcaption { font-size: 12.5px; color: var(--muted); margin-top: 6px; }

/* ============ About ============ */
.prose-view .panel { max-width: 860px; }
.prose h3 { font-size: 18px; margin: 30px 0 10px; }
.prose h3:first-child { margin-top: 0; }
.prose p, .prose li { max-width: 74ch; }
.prose p { margin: 0 0 12px; }
.prose ul, .prose ol { padding-left: 22px; margin: 0 0 12px; }
.prose li { margin-bottom: 8px; }
.callout { padding: 14px 16px; border-radius: 12px; background: var(--warn-soft); border: 1px solid #F1DDB2; margin: 6px 0 4px; max-width: 74ch; }
.kl-list { display: flex; flex-direction: column; gap: 8px; }
.kl-row { display: grid; grid-template-columns: 130px minmax(0, 1fr); gap: 14px; align-items: center; }

/* ============ Modal and toast ============ */
.modal { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; padding: 24px; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(15, 30, 44, .55); }
.modal-panel {
  position: relative; width: min(760px, 100%); max-height: calc(100vh - 48px); overflow: auto;
  background: var(--surface); border-radius: 16px; padding: 22px 24px 26px;
}
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.modal-head h2 { font-size: 18px; }
.modal-actions { display: flex; gap: 8px; }

.toast {
  position: fixed; right: 24px; bottom: 24px; z-index: 50; padding: 12px 16px; border-radius: 10px;
  background: var(--ink); color: #fff; font-size: 14px; max-width: 360px;
}

/* ============ Responsive ============ */
@media (max-width: 1100px) {
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .charts { grid-template-columns: 1fr; }
  .two-col, .dash-grid { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .app, .app.nav-collapsed { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: fixed; left: 0; top: 0; z-index: 30; transform: translateX(-100%); transition: transform .22s ease; visibility: hidden; }
  .app.nav-open .sidebar { transform: none; visibility: visible; }
  .app.nav-open .backdrop { display: block; position: fixed; inset: 0; z-index: 20; background: rgba(15, 30, 44, .45); }
  .hero, .analyze-grid { grid-template-columns: 1fr; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat:nth-child(3) { border-left: 0; }
  .stat:nth-child(n + 3) { border-top: 1px solid var(--line); }
  .checks, .figure-row { grid-template-columns: 1fr; }
  .topbar, .content, .page-foot { padding-left: 18px; padding-right: 18px; }
  .model-strip { flex-direction: column; align-items: flex-start; }
}
@media (max-width: 560px) {
  .topbar-cta { display: none; }
  .scale { gap: 4px; }
  .scale-col { padding: 4px; }
  .scale-label { font-size: 11px; }
  .metrics { grid-template-columns: 1fr; }
  .kl-row { grid-template-columns: 1fr; gap: 4px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
