:root {
  --bg: #f3f0e8;
  --surface: #fbfaf6;
  --surface-2: #ebe7dc;
  --ink: #16140f;
  --ink-2: #5d584c;
  --ink-3: #8f897a;
  --line: #d9d3c4;
  --line-2: #c6bfad;
  --accent: #e5412d;
  --accent-ink: #ffffff;
  --accent-soft: #f6d3cb;
  --track-a: #2a2721;
  --track-b: #4a463c;
  --track-off: #d3cdbd;
  --radius: 6px;
  --sans: "Schibsted Grotesk", ui-sans-serif, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #12110e;
    --surface: #1a1915;
    --surface-2: #24221d;
    --ink: #eeeae0;
    --ink-2: #aaa496;
    --ink-3: #777162;
    --line: #2f2c25;
    --line-2: #403c33;
    --accent: #f0533e;
    --accent-ink: #12110e;
    --accent-soft: #4a221b;
    --track-a: #d8d2c4;
    --track-b: #a49e8f;
    --track-off: #2f2c25;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #12110e; --surface: #1a1915; --surface-2: #24221d; --ink: #eeeae0; --ink-2: #aaa496; --ink-3: #777162;
  --line: #2f2c25; --line-2: #403c33; --accent: #f0533e; --accent-ink: #12110e; --accent-soft: #4a221b;
  --track-a: #d8d2c4; --track-b: #a49e8f; --track-off: #2f2c25; color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.45 var(--sans);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
body::before {
  content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background: radial-gradient(circle at 50% 45%,
    color-mix(in srgb, var(--accent) 38%, var(--bg)) 0%,
    color-mix(in srgb, var(--accent) 14%, var(--bg)) 35%,
    var(--bg) 75%);
}
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--ink-3); font-weight: 400; }
[hidden] { display: none !important; }
a { color: inherit; }
button, input, select { font: inherit; color: inherit; }

/* ---------- top bar ---------- */
.bar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 24px; border-bottom: 1px solid var(--line);
}
.top { position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--bg) 82%, transparent); backdrop-filter: blur(10px); }
.brand { display: inline-flex; align-items: center; gap: 8px; font-weight: 800; letter-spacing: -0.02em; text-decoration: none; font-size: 17px; margin-bottom: 2px; }
.mark { display: block; flex: none; width: 20px; height: 20px; }
.bar-actions { display: flex; gap: 6px; }
.bar-end { display: flex; align-items: center; gap: 6px; margin-left: auto; }
.btn.icon { display: inline-grid; place-items: center; width: 36px; height: 36px; padding: 0; }
.btn.icon svg { display: block; }
.btn .ico { flex: none; }
.bar-actions .btn { display: inline-flex; align-items: center; gap: 7px; }
.btn.accent { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn.accent:hover { background: color-mix(in srgb, var(--accent) 86%, var(--ink)); border-color: transparent; }
.btn.soft { background: var(--surface-2); border-color: var(--surface-2); color: var(--ink-2); }
.btn.soft:hover { color: var(--ink); border-color: var(--line-2); }
.btn.plain { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn.plain:hover, .btn.plain[aria-expanded=true] { color: var(--ink); border-color: var(--line-2); }
/* Drawer-only parts; shown on phones (see responsive section). */
.btn.icon.menu-btn, .drawer-head, .drawer-sep, .drawer-scrim, .theme-label { display: none; }

/* ---------- buttons & inputs ---------- */
.btn {
  border: 1px solid var(--line-2); background: var(--surface); border-radius: var(--radius);
  padding: 8px 14px; cursor: pointer; font-weight: 500; white-space: nowrap;
  transition: background .12s, border-color .12s;
}
.btn:hover { border-color: var(--ink-3); }
.btn.primary { background: var(--ink); color: var(--bg); border-color: var(--ink); font-weight: 600; }
.btn.primary:hover { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.ghost { background: transparent; }
.btn.link { border: 0; background: none; padding: 8px 4px; color: var(--ink-2); text-decoration: underline; text-underline-offset: 3px; }
.btn.link:disabled { color: var(--ink-3); text-decoration: none; cursor: default; }
.btn:focus-visible, input:focus-visible, select:focus-visible, summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn[disabled] { opacity: .5; cursor: progress; }
.badge { display: inline-block; min-width: 18px; padding: 0 5px; border-radius: 9px; background: var(--accent); color: var(--accent-ink); font: 600 11px/18px var(--mono); margin-left: 4px; }

input[type=url], input[type=search], input[type=number], input[type=date], input[type=text], select {
  border: 1px solid var(--line-2); background: var(--surface); border-radius: var(--radius);
  padding: 8px 10px; min-width: 0;
}
input::placeholder { color: var(--ink-3); }

.seg { display: inline-flex; justify-self: start; border: 1px solid var(--line-2); border-radius: var(--radius); padding: 2px; background: var(--surface-2); }
.seg button { border: 0; background: none; padding: 6px 14px; border-radius: 4px; cursor: pointer; color: var(--ink-2); font-weight: 500; }
.seg button.on { background: var(--surface); color: var(--ink); box-shadow: 0 1px 0 var(--line-2); }
.seg.small button { padding: 4px 10px; font-size: 13px; }

input[type=range] { accent-color: var(--accent); width: 100%; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; }

/* ---------- source ---------- */
main { max-width: 1280px; margin: 0 auto; padding: 0 24px 80px; }
.source { min-height: calc(100vh - 140px); display: flex; flex-direction: column; justify-content: center; align-items: center; text-align: center; }
.source-title {
  font-size: clamp(40px, 9vw, 120px); line-height: .9; letter-spacing: -0.05em; font-weight: 800; margin: 0;
  display: flex; align-items: center; justify-content: center; gap: .18em; flex-wrap: wrap;
}
.source-title .mark { width: .82em; height: .82em; }
.source-sub { color: var(--ink-2); margin: 14px 0 28px; }
.source-card { width: min(620px, 100%); padding: 16px; text-align: left; display: grid; gap: 14px; }
.src-pane { display: flex; gap: 8px; }
.src-pane input { flex: 1; padding: 11px 12px; font-size: 15px; }
.drop {
  flex: 1; display: grid; gap: 4px; place-items: center; padding: 26px 16px; cursor: pointer;
  border: 1px dashed var(--line-2); border-radius: var(--radius); background: var(--bg);
}
.drop.over { border-color: var(--accent); background: var(--accent-soft); }
.drop-sub { font-size: 12px; color: var(--ink-3); }
.err { margin: 0; color: var(--accent); font-size: 14px; }
.note { font-size: 12px; color: var(--ink-3); margin-top: 18px; }

/* ---------- results head ---------- */
.head { display: flex; justify-content: space-between; align-items: flex-end; gap: 24px; padding: 32px 0 16px; flex-wrap: wrap; }
.head h2 { margin: 0; font-size: clamp(24px, 3.4vw, 36px); letter-spacing: -0.03em; line-height: 1.05; font-weight: 800; }
.meta { margin: 8px 0 0; color: var(--ink-2); display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.meta .sep { color: var(--line-2); }
.pill { font: 500 11px/1 var(--mono); padding: 4px 6px; border: 1px solid var(--line-2); border-radius: 4px; color: var(--ink-2); text-transform: none; }
.tc-block { text-align: right; }
.tc { font-size: clamp(44px, 7vw, 84px); font-weight: 700; letter-spacing: -0.04em; line-height: .9; }
.tc-label { color: var(--ink-2); font-size: 13px; margin-top: 6px; }

/* ---------- track ---------- */
.track { display: flex; height: 28px; gap: 1px; margin: 8px 0 20px; border-radius: 4px; overflow: hidden; background: var(--line); }
.track i { display: block; height: 100%; background: var(--track-a); min-width: 1px; cursor: pointer; }
.track i:nth-child(even) { background: var(--track-b); }
.track i.off { background: var(--track-off); }
.track i:hover { background: var(--accent) !important; }

/* ---------- filters ---------- */
.filters { padding: 12px; margin-bottom: 16px; position: sticky; top: var(--top-h, 55px); z-index: 10; }
.f-basic { display: flex; gap: 10px 20px; align-items: flex-end; flex-wrap: wrap; }
.f-basic .fld { display: grid; gap: 4px; }
.fld-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; min-height: 18px; }
.search-fld { flex: 1 1 220px; }
.f-count { font-size: 12px; color: var(--accent); white-space: nowrap; }
.help-wrap { position: relative; display: inline-flex; align-items: center; gap: 6px; }
.help {
  width: 16px; height: 16px; padding: 0; border-radius: 50%; border: 1px solid var(--line-2); background: var(--surface-2);
  color: var(--ink-2); font: 600 10px/14px var(--mono); cursor: pointer;
}
.help:hover, .help[aria-expanded=true] { border-color: var(--accent); color: var(--accent); }
.help-pop {
  display: none; position: absolute; left: 0; top: calc(100% + 6px); z-index: 30; width: min(300px, 80vw);
  background: var(--ink); color: var(--bg); padding: 8px 10px; border-radius: 4px; font-size: 12px; font-weight: 400; line-height: 1.4;
}
.help-wrap:hover .help-pop, .help-wrap.open .help-pop { display: block; }
.f-end { font-size: 12px; color: var(--ink); white-space: nowrap; min-width: 48px; }
.f-end:last-child { text-align: right; }
.f-basic select { max-width: 220px; }
.f-label { font-size: 12px; color: var(--ink-2); font-weight: 500; }
mark { background: var(--accent-soft); color: inherit; border-radius: 2px; }
.range-field { flex: 1 1 320px; }
.range-row { display: flex; align-items: center; gap: 10px; height: 36px; }
.dual { position: relative; flex: 1; height: 22px; min-width: 120px; }
.dual input { position: absolute; inset: 0; pointer-events: none; background: none; -webkit-appearance: none; appearance: none; height: 22px; margin: 0; }
.dual::before { content: ""; position: absolute; left: 0; right: 0; top: 10px; height: 3px; border-radius: 2px; background: var(--line-2); }
.dual .fill { position: absolute; top: 10px; height: 3px; background: var(--accent); border-radius: 2px; }
.dual input::-webkit-slider-thumb { pointer-events: auto; -webkit-appearance: none; width: 16px; height: 16px; border-radius: 50%; background: var(--surface); border: 2px solid var(--accent); cursor: pointer; position: relative; z-index: 2; }
.dual input::-moz-range-thumb { pointer-events: auto; width: 12px; height: 12px; border-radius: 50%; background: var(--surface); border: 2px solid var(--accent); cursor: pointer; }
.dual input::-webkit-slider-runnable-track { background: none; }
.dual input::-moz-range-track { background: none; }

.f-adv { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px 16px; padding-top: 12px; margin-top: 12px; border-top: 1px solid var(--line); }
.f-adv .fld { display: grid; gap: 4px; }
.f-adv .pair { display: flex; gap: 6px; align-items: center; }
.f-adv .pair input { width: 100%; }
.f-adv .pair span { color: var(--ink-3); }

/* ---------- tiles ---------- */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); background: var(--surface); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; margin-bottom: 20px; }
.tile { padding: 14px 14px 12px; box-shadow: 1px 0 0 var(--line), 0 1px 0 var(--line); min-width: 0; }
.tile .k { font-size: 12px; color: var(--ink-2); }
.tile .v { font: 600 22px/1.2 var(--mono); letter-spacing: -0.02em; margin-top: 4px; font-variant-numeric: tabular-nums; }
.tile .s { font-size: 12px; color: var(--ink-3); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- sections ---------- */
.sec { border-top: 1px solid var(--line-2); }
.sec > summary { list-style: none; cursor: pointer; display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 16px 0; font-size: 20px; font-weight: 700; letter-spacing: -0.02em; }
.sec > summary::-webkit-details-marker { display: none; }
.sec > summary span:first-child::before { content: "+"; display: inline-block; width: 22px; font-family: var(--mono); color: var(--accent); }
.sec[open] > summary span:first-child::before { content: "–"; }
.sum-hint { font-size: 12px; color: var(--ink-2); font-weight: 400; letter-spacing: 0; }
.sec-body { padding: 0 0 28px; }

/* ---------- planner ---------- */
.plan { display: grid; grid-template-columns: minmax(280px, 380px) 1fr; gap: 24px; }
.plan-controls { display: grid; gap: 18px; align-content: start; }
.ctl { display: grid; gap: 8px; }
.ctl.row2 { grid-template-columns: auto 1fr; align-items: center; gap: 8px 12px; }
.ctl.row2 .check { grid-column: 1 / -1; }
.slider-row { display: flex; gap: 12px; align-items: center; }
.num { width: 76px; text-align: right; }
.num-out { min-width: 44px; text-align: right; font-weight: 600; }
.small { font-size: 12px; }
.btn.link.reset { justify-self: start; padding: 0; font-size: 12px; }
.chips { display: flex; flex-wrap: wrap; gap: 4px; }
.chips button { border: 1px solid var(--line-2); background: transparent; border-radius: 4px; padding: 4px 0; width: 38px; cursor: pointer; font: 500 12px var(--mono); color: var(--ink-3); }
.chips button.on { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.check { display: inline-flex; gap: 8px; align-items: center; font-size: 14px; cursor: pointer; }
.check input { accent-color: var(--accent); }

.plan-out { min-width: 0; display: grid; gap: 16px; align-content: start; }
.plan-end { display: grid; gap: 2px; }
.plan-end strong { font-size: clamp(28px, 4vw, 44px); letter-spacing: -0.03em; line-height: 1.05; }
.plan-stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 12px; margin: 0; }
.plan-stats div { border-left: 2px solid var(--line-2); padding-left: 10px; }
.plan-stats dt { font-size: 12px; color: var(--ink-2); }
.plan-stats dd { margin: 2px 0 0; font: 600 18px var(--mono); font-variant-numeric: tabular-nums; }
.cal-wrap { overflow-x: auto; padding-bottom: 4px; }
.calendar { display: block; font: 10px var(--mono); }
.calendar text { fill: var(--ink-3); }
.sub > summary { cursor: pointer; font-weight: 600; font-size: 14px; color: var(--ink-2); padding: 4px 0; }
.schedule { margin: 8px 0 0; padding: 0; list-style: none; max-height: 420px; overflow: auto; border: 1px solid var(--line); border-radius: 6px; }
.schedule li { display: grid; grid-template-columns: 54px 92px 1fr 70px; gap: 10px; padding: 7px 10px; border-bottom: 1px solid var(--line); font-size: 13px; align-items: baseline; }
.schedule li:last-child { border-bottom: 0; }
.schedule .d { font-family: var(--mono); color: var(--ink-3); }
.schedule .t { font-family: var(--mono); text-align: right; }
.schedule .vids { min-width: 0; }
.schedule .vids span { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- charts ---------- */
.charts { display: grid; grid-template-columns: repeat(auto-fill, minmax(420px, 1fr)); gap: 16px; }
.chart { padding: 14px; }
.chart h3 { margin: 0 0 10px; font-size: 14px; font-weight: 600; display: flex; justify-content: space-between; gap: 8px; }
.chart h3 small { color: var(--ink-3); font: 400 12px var(--mono); }
.chart svg { width: 100%; height: auto; display: block; overflow: visible; }
.chart text { fill: var(--ink-2); font: 11px var(--mono); }
.chart .axis { stroke: var(--line-2); }
.chart .grid { stroke: var(--line); }
.chart .bar { fill: var(--ink); }
.chart .bar:hover, .chart .dot:hover { fill: var(--accent); }
.chart .dot { fill: var(--ink); fill-opacity: .55; }
.chart .line { fill: none; stroke: var(--accent); stroke-width: 2; }

/* ---------- selection banner (sticks below the top bar and the filters) ---------- */
.sel-bar {
  position: sticky; top: calc(var(--top-h, 55px) + var(--filters-h, 0px)); z-index: 9;
  display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 10px 24px;
  padding: 10px 12px; margin-bottom: 10px; border-color: var(--line-2);
}
.sel-stats { display: flex; flex-wrap: wrap; gap: 8px 24px; margin: 0; }
.sel-stats div { border-left: 2px solid var(--accent); padding-left: 10px; }
.sel-stats dt { font-size: 12px; color: var(--ink-2); }
.sel-stats dd { margin: 2px 0 0; font: 600 16px var(--mono); font-variant-numeric: tabular-nums; }
.sel-stats small { display: block; font: 400 11px var(--mono); color: var(--ink-3); }
.sel-actions { display: flex; gap: 6px; }

/* ---------- table ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
/* A sideways-scrolling box cannot have a page-sticky head, so a copy of the head floats above the table:
   it lies exactly over the real head (which stays invisible and sets the column widths), sticks below the
   top bar, filters and selection banner, and follows the table's sideways scroll (table-view.js). */
.thead-float {
  position: sticky; top: calc(var(--top-h, 55px) + var(--filters-h, 0px) + var(--sel-h, 0px)); z-index: 8;
  overflow: hidden; margin: 1px 1px calc(-1px - var(--thead-h, 0px)); height: var(--thead-h, auto);
  border-radius: 8px 8px 0 0; background: var(--surface);
}
.thead-float table { table-layout: fixed; }
#videoTable thead { visibility: hidden; }
.vt { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.vt th { text-align: left; font-weight: 600; font-size: 12px; color: var(--ink-2); padding: 10px; border-bottom: 1px solid var(--line-2); white-space: nowrap; cursor: pointer; user-select: none; background: var(--surface); }
.vt th.num, .vt td.num { text-align: right; }
.vt th.sorted { color: var(--ink); }
.vt th.sorted::after { content: " ↓"; color: var(--accent); }
.vt th.sorted.asc::after { content: " ↑"; }
.vt td { padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.vt td.empty { padding: 20px; }
.plan-stats dd.err { font: inherit; color: var(--accent); }
.vt td.num { font-family: var(--mono); font-variant-numeric: tabular-nums; white-space: nowrap; }
.vt tr.row { cursor: pointer; }
.vt tr.row:hover td { background: var(--surface-2); }
.vt tr.row.open td { background: var(--surface-2); }
.vt td.title { min-width: 280px; max-width: 520px; }
.vt td.title a { text-decoration: none; }
.vt td.title a:hover { text-decoration: underline; }
.vt .tag { font: 500 11px var(--mono); color: var(--ink-3); }
/* Select, # and Watched stay at the left edge while the table scrolls sideways (offsets set by table-view.js). */
.vt .stick { position: sticky; z-index: 1; background: var(--surface); }
.vt .stick-0 { left: var(--stick-0, 0px); }
.vt .stick-1 { left: var(--stick-1, 0px); }
.vt .stick-2 { left: var(--stick-2, 0px); }
.vt th.stick { z-index: 3; }
.vt .stick-last { box-shadow: inset -1px 0 0 var(--line-2); }
.vt td.watched, .vt td.select, .vt th.select { white-space: nowrap; width: 1%; }
.vt td.select input, .vt th.select input { accent-color: var(--accent); cursor: pointer; vertical-align: middle; }
.vt td.select input:disabled { cursor: not-allowed; opacity: .4; }
.vt th.select { cursor: default; }
.vt tr.row.sel td { background: var(--accent-soft); }
.vt td.link a { color: var(--ink-2); text-decoration: underline; text-underline-offset: 3px; }
.vt td.link a:hover { color: var(--accent); }
.vt td.watched input { accent-color: var(--accent); cursor: pointer; vertical-align: middle; }
.vt td.watched input:disabled { cursor: not-allowed; }
.vt td.watched .muted { font: 11px var(--mono); margin-left: 6px; }
.vt td.num .of { display: block; font-size: 11px; color: var(--ink-3); }
.vt tr.row.done td.title a { color: var(--ink-3); }
.more { margin: 12px auto 0; display: block; }

.detail td { background: var(--bg); padding: 16px 18px 20px; }
.detail-grid { display: grid; grid-template-columns: minmax(200px, 300px) 1fr; gap: 24px; }
.detail h4 { margin: 0 0 8px; font-size: 13px; font-weight: 600; color: var(--ink-2); }
.chapters { list-style: none; margin: 0; padding: 0; font-size: 13px; display: grid; gap: 3px; }
.chapters a { text-decoration: none; display: grid; grid-template-columns: 56px 1fr; }
.chapters a:hover { color: var(--accent); }
.chapters .mono { color: var(--ink-3); }
.tr-bar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; }
.tr-bar select, .tr-bar .btn { padding: 5px 10px; font-size: 13px; }
.tr-text { max-height: 420px; overflow: auto; font-size: 14px; line-height: 1.6; padding-right: 8px; }
.tr-text p { margin: 0 0 10px; }
.tr-text a { font: 500 12px var(--mono); color: var(--accent); text-decoration: none; margin-right: 6px; }
.tr-info { font: 12px var(--mono); color: var(--ink-3); }

/* ---------- popover ---------- */
.pop { position: relative; }
.pop-panel {
  position: absolute; right: 0; top: calc(100% + 6px); width: 300px; max-height: 70vh; overflow: auto;
  background: var(--surface); border: 1px solid var(--line-2); border-radius: 8px; padding: 12px;
  box-shadow: 0 12px 32px -12px rgba(0,0,0,.25); z-index: 30;
}
.pop-panel h5 { margin: 4px 0 6px; font-size: 11px; color: var(--ink-3); font-weight: 600; letter-spacing: .04em; }
.pop-panel h5:not(:first-child) { margin-top: 14px; }
.pop-panel .check { display: flex; padding: 3px 0; }

/* ---------- tooltip & loading ---------- */
.tip { position: fixed; z-index: 50; pointer-events: none; background: var(--ink); color: var(--bg); padding: 6px 8px; border-radius: 4px; font-size: 12px; max-width: 320px; line-height: 1.35; }
.tip b { font-family: var(--mono); font-weight: 600; }
.loading { position: fixed; inset: 0; z-index: 60; background: color-mix(in srgb, var(--bg) 85%, transparent); display: grid; place-content: center; gap: 14px; justify-items: center; font-size: 13px; color: var(--ink-2); }
.scan { width: 240px; height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; position: relative; }
.scan::after { content: ""; position: absolute; top: 0; bottom: 0; width: 60px; background: var(--accent); animation: scan 1.1s ease-in-out infinite alternate; }
@keyframes scan { from { left: 0; } to { left: 180px; } }

.reveal { animation: rise .35s ease-out both; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .reveal, .scan::after { animation: none; } .bar-end { transition: none !important; } }

/* ---------- responsive ---------- */
/* Tablet: one column for planner, charts and details; filters scroll away instead of sticking. */
@media (max-width: 860px) {
  main { padding: 0 20px 64px; }
  .bar { padding: 12px 20px; }
  .plan { grid-template-columns: 1fr; }
  .charts { grid-template-columns: 1fr; }
  .detail-grid { grid-template-columns: 1fr; }
  .filters { position: static; }
  .range-field, .search-fld { flex-basis: 100%; }
  .head { padding-top: 24px; }
  .vt td.title { min-width: 240px; }
}
/* Phone */
@media (max-width: 560px) {
  main { padding: 0 12px 56px; }
  .bar { padding: 8px 12px; }
  .brand { font-size: 15px; }
  .brand .mark { width: 18px; height: 18px; }

  /* Header drawer (shadcn "Sheet", side right): 80 % wide, slides from right to left. */
  .top { backdrop-filter: none; background: var(--bg); } /* a backdrop-filter would trap the fixed drawer */
  .btn.icon.menu-btn { display: inline-grid; margin-left: auto; }
  .drawer-scrim { display: block; position: fixed; inset: 0; z-index: 40; background: rgb(0 0 0 / .6); }
  .bar-end {
    position: fixed; top: 0; right: 0; bottom: 0; z-index: 41; width: 80%; overflow-y: auto;
    flex-direction: column; align-items: stretch; gap: 8px; margin: 0; padding: 16px 20px 24px;
    background: var(--surface); border-left: 1px solid var(--line-2); box-shadow: -16px 0 40px -20px rgb(0 0 0 / .5);
    transform: translateX(100%); visibility: hidden; transition: transform .25s ease, visibility 0s .25s;
  }
  .bar-end.open { transform: none; visibility: visible; transition: transform .25s ease; }
  .drawer-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
  .bar-actions { flex-direction: column; gap: 8px; }
  .bar-actions .btn, .bar-end > #themeBtn { width: 100%; justify-content: flex-start; padding: 12px 14px; font-size: 15px; }
  .bar-actions .btn.accent { justify-content: center; }
  .bar-actions .pop { order: 0; }
  .bar-actions #newBtn { order: 1; }
  .bar-actions #exportBtn { order: 2; margin-top: 8px; }
  .pop { position: static; }
  .pop-panel { position: static; width: auto; max-height: none; margin-top: 6px; box-shadow: none; }
  .drawer-sep { display: block; width: 100%; border: 0; border-top: 1px solid var(--line-2); margin: 16px 0 8px; }
  .bar-end > #themeBtn { display: flex; align-items: center; gap: 10px; height: auto; color: var(--ink-2); }
  .theme-label { display: inline; }
  .source-card { padding: 12px; }
  .src-pane { flex-direction: column; }
  .head { gap: 12px; }
  .tc-block { text-align: left; }
  .f-basic { gap: 10px; }
  .f-basic > .btn { flex: 1; }
  .f-adv { grid-template-columns: 1fr; }
  .tiles { grid-template-columns: repeat(2, 1fr); }
  .tile .v { font-size: 18px; }
  .sec > summary { font-size: 18px; padding: 14px 0; }
  .plan-stats { grid-template-columns: repeat(2, 1fr); }
  .plan-stats dd { font-size: 16px; }
  .ctl.row2 { grid-template-columns: 1fr; }
  .schedule li { grid-template-columns: 34px 1fr 60px; }
  .schedule .dt { display: none; }
  .chart { padding: 10px; }
  .sel-bar { padding: 8px 10px; }
  .sel-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px 10px; width: 100%; }
  .sel-stats dd { font-size: 14px; }
  .sel-actions { width: 100%; }
  .sel-actions .btn { flex: 1; }
  .vt { font-size: 13px; }
  .vt th, .vt td { padding: 7px 8px; }
  .vt td.title { min-width: 200px; }
  .detail td { padding: 12px; }
}
/* Touch screens: bigger checkboxes */
@media (pointer: coarse) {
  .vt input[type=checkbox], .check input { width: 20px; height: 20px; }
  .chips button { padding: 7px 0; width: 42px; }
}
