:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --border: #e3e6eb;
  --text: #1b1f24;
  --muted: #5f6b7a;
  --accent: #3657d6;
  --accent-soft: #e8edff;
  --good: #1f7a4d;
  --good-soft: #e3f4eb;
  --bad: #b3261e;
  --bad-soft: #fbe7e5;
  --busy: #8a5a00;
  --busy-soft: #fdf1d8;
  --radius: 10px;
  --mono: ui-monospace, "SF Mono", Menlo, monospace;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111418;
    --surface: #181c21;
    --border: #2a3038;
    --text: #e6e9ee;
    --muted: #97a1ae;
    --accent: #8ea6ff;
    --accent-soft: #232c4d;
    --good: #6fd3a0;
    --good-soft: #17322a;
    --bad: #ff8f86;
    --bad-soft: #3a1d1b;
    --busy: #f0c060;
    --busy-soft: #372c14;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.6rem; margin: 0; line-height: 1.25; }
h2 { font-size: 1.05rem; margin: 0 0 .6rem; }
h3 { margin: 1rem 0 .3rem; }

.topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: 2rem;
  padding: .7rem 1.5rem; background: var(--surface); border-bottom: 1px solid var(--border);
}
.brand { font-weight: 700; color: var(--text); letter-spacing: -.01em; }
.topbar nav a { color: var(--muted); }
.topbar nav a[aria-current] { color: var(--text); font-weight: 600; }
.topbar nav a.urgent { color: var(--bad); font-weight: 600; }
.topbar nav a.urgent .count { display: inline-block; min-width: 1.3em; padding: 0 0.35em; border-radius: 999px;
  background: var(--bad); color: var(--bg, #fff); font-size: 0.75em; line-height: 1.5; text-align: center; }
.review-queue.urgent { border-color: var(--bad); background: var(--bad-soft); }
main { max-width: 1120px; margin: 0 auto; padding: 1.5rem; }

.page-head { display: flex; align-items: baseline; gap: 1rem; margin: .25rem 0 1.25rem; flex-wrap: wrap; }
.page-head > a, .page-links a { white-space: nowrap; }
.page-links { display: inline-flex; gap: 1rem; margin-left: auto; }
.section-head { display: flex; align-items: baseline; gap: 1rem; margin: 1.75rem 0 .75rem; }
.section-head h2 { margin: 0; }
.crumbs { display: flex; gap: .5rem; color: var(--muted); font-size: .9rem; margin-bottom: .5rem; }

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1rem 1.15rem; margin-bottom: 1rem;
}
.card.flush { padding: 0; overflow-x: auto; }
.cards.two { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 1rem; }
.cards.two .card { margin: 0; }
.cards.two { margin-bottom: 1rem; }

.row { display: flex; gap: .5rem; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.mono { font-family: var(--mono); font-size: .9em; }
.break { word-break: break-all; }
.nowrap { white-space: nowrap; }
.empty { color: var(--muted); padding: 2rem; text-align: center; border: 1px dashed var(--border); border-radius: var(--radius); }
.error { color: var(--bad); }
.accent { color: var(--accent); }

input, select, button {
  font: inherit; color: inherit; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface); padding: .45rem .7rem;
}
input[type=url] { flex: 1; min-width: 0; }
input[type=file] { flex: 1; min-width: 0; padding: .35rem; }
button { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; cursor: pointer; }
@media (prefers-color-scheme: dark) { button { color: #0d1020; } }
button.secondary { background: var(--surface); color: var(--text); border-color: var(--border); font-weight: 500; }
button.small { padding: .2rem .6rem; font-size: .85rem; }
button:disabled { opacity: .5; cursor: default; }
button:hover:not(:disabled) { filter: brightness(1.08); }
label { display: block; margin-bottom: .3rem; }
.row label { margin: 0; }

table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-weight: 600; font-size: .8rem; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
th, td { padding: .55rem .75rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
table.list tbody tr:hover { background: color-mix(in srgb, var(--accent-soft) 40%, transparent); }
.num { text-align: right; }
.title-cell { display: flex; align-items: center; gap: .6rem; }
.art { width: 28px; height: 28px; border-radius: 6px; object-fit: cover; background: var(--border); flex: none; display: inline-block; }

.badge {
  display: inline-block; padding: .05rem .5rem; border-radius: 999px; font-size: .75rem; font-weight: 600;
  background: var(--bg); color: var(--muted); border: 1px solid var(--border); white-space: nowrap;
}
.badge.good { background: var(--good-soft); color: var(--good); border-color: transparent; }
.badge.bad { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
.badge.busy { background: var(--busy-soft); color: var(--busy); border-color: transparent; }
.badge.accent { background: var(--accent-soft); color: var(--accent); border-color: transparent; }

.show-head { display: flex; gap: 1.25rem; align-items: flex-start; margin: .25rem 0 1.25rem; flex-wrap: wrap; }
.show-head h1 { margin-bottom: .2rem; }
.show-head p { margin: 0 0 .5rem; }
.cover { width: 96px; height: 96px; border-radius: 12px; object-fit: cover; }
.actions { display: flex; gap: .75rem; align-items: center; }

.facts { display: grid; grid-template-columns: max-content 1fr; gap: .35rem 1rem; margin: 0; }
.facts dt { color: var(--muted); font-size: .85rem; }
.facts dd { margin: 0; min-width: 0; }

.download header { margin-bottom: .6rem; }
.stats { display: flex; flex-wrap: wrap; gap: .5rem 2rem; margin: 0 0 .75rem; }
.stats dt { color: var(--muted); font-size: .75rem; text-transform: uppercase; letter-spacing: .03em; }
.stats dd { margin: 0; font-size: 1.05rem; }
.player { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: .6rem; margin: .4rem 0 .2rem; }
.player-play { width: 2.2rem; height: 2.2rem; border-radius: 50%; padding: 0; font-size: .8rem; }
.player-wave { display: block; width: 100%; height: 48px; cursor: pointer; touch-action: none; }
.player-time { color: var(--muted); font-size: .8rem; white-space: nowrap; }

/* ---------- the episode page: downloads, and a sidebar with the feed and Download ---------- */
.ep-main { min-width: 0; }
.ep-side { padding: .6rem .9rem .9rem; }
.ep-side-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: .4rem; }
.ep-side-part { padding: .6rem 0; border-top: 1px solid var(--border); }
.ep-side-part h2 { font-size: 1rem; margin: 0 0 .5rem; }
.ep-side .facts { grid-template-columns: 1fr; gap: .1rem; }
.ep-side .facts dd { margin-bottom: .35rem; }
audio { width: 100%; }
.progress { height: 6px; background: var(--border); border-radius: 999px; overflow: hidden; margin: .25rem 0; }
.progress div { height: 100%; background: var(--accent); transition: width .4s ease; }
details { margin-top: .75rem; }
summary { cursor: pointer; color: var(--muted); }
.chain { padding-left: 1.25rem; margin: 0; }
.chain li { margin: .2rem 0; }
table.headers th { text-transform: none; letter-spacing: 0; width: 30%; font-weight: 500; }
table.headers th, table.headers td { padding: .2rem .5rem; }

@media (max-width: 640px) {
  main { padding: 1rem; }
  th, td { padding: .5rem; }
  .actions { width: 100%; }
}

/* ---------- shared bits ---------- */
.spacer { flex: 1; }
a.button {
  display: inline-block; background: var(--accent); color: #fff; font-weight: 600;
  border-radius: 8px; padding: .45rem .8rem; text-decoration: none;
}
@media (prefers-color-scheme: dark) { a.button { color: #0d1020; } }
a.button.small { padding: .2rem .6rem; font-size: .85rem; }
a.button:hover { filter: brightness(1.08); text-decoration: none; }
button.icon { background: transparent; border-color: var(--border); color: var(--text); font-weight: 500; padding: .2rem .55rem; }
button.danger:hover { color: var(--bad); border-color: var(--bad); }
kbd {
  font-family: var(--mono); font-size: .8em; padding: .05rem .35rem; border-radius: 4px;
  border: 1px solid var(--border); border-bottom-width: 2px; background: var(--bg);
}

/* ---------- labels and transcript (the Analysis page) ---------- */
label.inline { display: inline-flex; align-items: center; gap: .35rem; margin: 0; font-size: .85rem; color: var(--muted); }
label.inline select { padding: .2rem .4rem; font-size: .85rem; }
.check { display: flex; flex-wrap: wrap; gap: .25rem 1.25rem; padding: .5rem .75rem; border-radius: 8px; background: var(--bg); margin-bottom: .75rem; }
.check .good { color: var(--good); }
.check .warn { color: var(--busy); font-weight: 600; }
.seg-time { background: none; border: 0; color: var(--text); font-weight: 500; padding: 0; text-align: left; cursor: pointer; }
.seg-time:hover { color: var(--accent); filter: none; }
.status-actions { margin-top: .5rem; }
.card-actions { margin-left: auto; }
.card-actions form { margin: 0; }

/* ---------- transcript ---------- */
.transcript-text {
  max-height: 62vh; overflow-y: auto; padding-right: .5rem; line-height: 1.75; font-size: .95rem;
  scroll-behavior: smooth;
}
.transcript-text p { margin: 0 0 .9rem; }
.transcript-text span { cursor: pointer; border-radius: 3px; padding: 0 1px; }
.transcript-text span:hover { background: var(--accent-soft); }
.transcript-text span.in-seg { background: rgba(var(--kind), .2); box-shadow: inset 0 -2px rgba(var(--kind), .6); }
.transcript-text span.now { background: var(--accent); color: var(--surface); }
.para-time { background: none; border: 0; padding: 0 .4rem 0 0; color: var(--muted); font-size: .75rem; cursor: pointer; }
.para-time:hover { color: var(--accent); filter: none; }
.para-speaker { display: inline-block; min-width: 1.4em; margin-right: .35rem; padding: 0 .3rem; border-radius: 4px;
  font-size: .72rem; font-weight: 700; text-align: center; color: #fff; background: var(--who, var(--muted)); }
a.para-speaker { text-decoration: none; }
a.para-speaker:hover { color: #fff; text-decoration: underline; }
.selection-action { display: flex; align-items: center; gap: .5rem; margin-top: .5rem; }
.selection-action[hidden] { display: none; }
.notice {
  display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1rem;
  padding: .5rem .75rem; margin-bottom: .75rem; border-radius: 8px;
  background: var(--busy-soft); color: var(--text);
}
.notice form { margin: 0; }
.label-prompt .button, #needs-labels .button { white-space: nowrap; }
#shows-list .warn { color: var(--busy); font-weight: 600; }

/* ---------- fetch lab ---------- */
.profiles { width: auto; min-width: 24rem; margin: 0; }
.lab-grid.profiles tr.platform th { padding-top: .55rem; }
.lab-grid.profiles td, .lab-grid.profiles th { padding-top: .2rem; padding-bottom: .2rem; }
.profiles .tick { width: 1.6rem; padding-right: 0; }
.profiles input { margin: 0; accent-color: var(--accent); }
.profiles label { cursor: pointer; }
.profiles tr.platform th { font-size: .8rem; color: var(--muted); font-weight: 600; }
.versions { margin: .4rem 0 .9rem; display: flex; flex-wrap: wrap; gap: 1rem 2.5rem; align-items: flex-start; }
.versions-found .lab-grid { margin-top: .4rem; }
.table-scroll { overflow-x: auto; }
.lab-grid th, .lab-grid td { padding: .35rem .6rem; white-space: nowrap; }
.lab-grid tbody th { text-transform: none; letter-spacing: 0; font-size: .85rem; color: var(--text); font-weight: 500; }
.version {
  display: inline-block; min-width: 1.4em; text-align: center; font-weight: 700; font-size: .75rem;
  border-radius: 4px; padding: 0 .3rem; margin-right: .25rem; color: #fff;
}
.version.v0 { background: #3657d6; } .version.v1 { background: #d6573a; } .version.v2 { background: #2b9a66; }
.version.v3 { background: #9a5bd6; } .version.v4 { background: #c08a12; } .version.v5 { background: #2a8fb0; }

/* ---------- scores ---------- */
.score-controls { gap: .5rem 1rem; margin-bottom: 1rem; }
.segmented { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.segmented a { padding: .3rem .75rem; color: var(--text); font-size: .85rem; text-decoration: none; }
.segmented a + a { border-left: 1px solid var(--border); }
.segmented a[aria-current] { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.page-tabs { margin-bottom: .75rem; }
.filter-bar { margin: .75rem 0; gap: .5rem .75rem; }
.card .filter-bar { margin: .75rem; }
.filter-bar .segmented { flex-wrap: wrap; }
.filter-group { display: inline-flex; align-items: center; gap: .5rem; }
.filter-bar .segmented a { white-space: nowrap; }
details.dropdown { position: relative; margin: 0; }
details.dropdown > summary { list-style: none; cursor: pointer; padding: .3rem .75rem; font-size: .85rem;
  border: 1px solid var(--border); border-radius: 8px; white-space: nowrap; }
details.dropdown > summary::-webkit-details-marker { display: none; }
details.dropdown > summary::after { content: " ▾"; color: var(--muted); }
details.dropdown[open] > summary { border-color: var(--accent); }
.dropdown-menu { position: absolute; z-index: 10; top: calc(100% + .25rem); left: 0; min-width: 12rem;
  display: flex; flex-direction: column; gap: .35rem; padding: .6rem .75rem;
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 6px 20px rgb(0 0 0 / .25); }
.dropdown-menu label { white-space: nowrap; font-size: .85rem; }
.dropdown-menu { max-height: 24rem; overflow-y: auto; }
.dropdown-search { font-size: .85rem; padding: .25rem .5rem; position: sticky; top: 0; }
.run-bar { gap: .75rem; padding: .6rem 1rem; }
.run-bar form { margin: 0; }
table.scores td, table.scores th { vertical-align: top; }
.topbar nav { display: flex; gap: 1.25rem; }
table.scores td[data-detector] { min-width: 17rem; }

/* ---------- report timeline ---------- */
/* Outcome colors: the reference palette's first three categorical slots, validated
   all-pairs for color-vision deficiency in both modes. */
:root { --out-caught: #1baf7a; --out-missed: #2a78d6; --out-cut: #eb6834; }
@media (prefers-color-scheme: dark) { :root { --out-caught: #199e70; --out-missed: #3987e5; --out-cut: #d95926; } }
#report-player { gap: .75rem; align-items: center; }
#report-player audio { width: min(420px, 100%); }
.report-facts { margin-bottom: 1rem; }
.timeline { display: grid; grid-template-columns: max-content 1fr; padding: .75rem 0 .75rem .75rem; gap: 0 .75rem; }
.tl-names > div, .tl-track { height: 30px; }
.tl-names { font-size: .85rem; }
.tl-axis-name, .tl-axis { height: 22px !important; }
.tl-name { display: flex; align-items: center; font-weight: 500; white-space: nowrap; }
.tl-scroll { overflow-x: auto; overflow-y: hidden; padding-right: .75rem; }
.tl-inner { position: relative; width: 100%; min-width: 100%; }
.tl-axis { position: relative; border-bottom: 1px solid var(--border); }
.tl-tick { position: absolute; bottom: 0; height: 6px; border-left: 1px solid var(--border); }
.tl-tick span { position: absolute; bottom: 7px; left: 2px; font-size: .7rem; color: var(--muted); white-space: nowrap; font-family: var(--mono); }
.tl-track { position: relative; border-bottom: 1px solid color-mix(in srgb, var(--border) 60%, transparent); cursor: crosshair; }
.tl-seg {
  position: absolute; top: 6px; bottom: 6px; min-width: 2px; padding: 0; border: 0; border-radius: 3px;
  cursor: pointer; box-shadow: 0 0 0 1px var(--surface);
}
.tl-seg:hover { filter: brightness(1.15); outline: 2px solid var(--text); outline-offset: 1px; z-index: 2; }
.tl-seg.label { background: var(--muted); }
.tl-seg.label.other { background: transparent; box-shadow: inset 0 0 0 2px var(--muted); }
.tl-seg.caught { background: var(--out-caught); }
.tl-seg.missed { background: var(--out-missed); }
.tl-seg.cut { background: var(--out-cut); }
.tl-seg.dont-care, .sw.dont-care {
  background: repeating-linear-gradient(45deg, var(--border) 0 2px, transparent 2px 6px);
  box-shadow: none; cursor: default; top: 3px; bottom: 3px;
}
.tl-seg.dont-care:hover { filter: none; outline: none; }
.tl-note { position: absolute; left: .25rem; right: .25rem; top: 6px; font-size: .8rem;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tl-playhead { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--text); pointer-events: none; left: 0; opacity: .8; }
.legend { display: flex; flex-wrap: wrap; gap: .4rem 1.25rem; margin: .5rem 0 0; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: .4rem; }
.sw { display: inline-block; width: 14px; height: 10px; border-radius: 2px; }
.sw.caught { background: var(--out-caught); } .sw.missed { background: var(--out-missed); } .sw.cut { background: var(--out-cut); }
.sw.label-sw { background: var(--muted); }
.sw.label-sw.other { background: transparent; box-shadow: inset 0 0 0 2px var(--muted); }

/* ---------- charts ---------- */
/* Categorical series colors: the reference palette, fixed order, light and dark steps. */
:root {
  --series-1: #2a78d6; --series-2: #eb6834; --series-3: #1baf7a; --series-4: #eda100;
  --series-5: #e87ba4; --series-6: #008300; --series-7: #6250d6; --series-8: #e34948;
  --series-9: #9c6b30;
}
@media (prefers-color-scheme: dark) {
  :root {
    --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70; --series-4: #c98500;
    --series-5: #d55181; --series-6: #0ca30c; --series-7: #9085e9; --series-8: #e66767;
    --series-9: #b98446;
  }
}
svg.chart { width: 100%; max-width: 760px; height: auto; display: block; font-family: inherit; }
svg.chart .grid { stroke: var(--border); stroke-width: 1; }
svg.chart .axis { stroke: var(--muted); stroke-width: 1; }
svg.chart .tick { fill: var(--muted); font-size: 11px; font-family: var(--mono); }
svg.chart .axis-title { fill: var(--muted); font-size: 12px; }
svg.chart .hint { fill: var(--muted); font-size: 11px; font-style: italic; }
svg.chart .direct-label { fill: var(--text); font-size: 12px; font-weight: 600; }
svg.chart .hit { fill: transparent; }
svg.chart .pt:hover .series-dot { r: 7; }
/* One colour per series (s1–s8), the same in the chart and its legend. */
.s1 { --c: var(--series-1); } .s2 { --c: var(--series-2); } .s3 { --c: var(--series-3); } .s4 { --c: var(--series-4); }
.s5 { --c: var(--series-5); } .s6 { --c: var(--series-6); } .s7 { --c: var(--series-7); } .s8 { --c: var(--series-8); }
svg.chart .series-dot { fill: var(--c); stroke: var(--surface); stroke-width: 2; }
svg.chart .hull { fill: var(--c); fill-opacity: .1; stroke: var(--c); stroke-opacity: .55; stroke-width: 1.5; stroke-linejoin: round; }
svg.chart .hull-line { stroke: var(--c); stroke-opacity: .55; stroke-width: 6; stroke-linecap: round; }
svg.chart .series { transition: opacity .12s; }
svg.chart .direct-label { display: none; paint-order: stroke; stroke: var(--surface); stroke-width: 3px; }
svg.chart[data-focus] .series { opacity: .12; }
svg.chart[data-focus] .series.focus { opacity: 1; }
svg.chart .series.focus .direct-label { display: block; }
svg.chart .series.focus .hull { fill-opacity: .2; }
svg.chart .series.off { display: none; }
.legend .sw.s1, .legend .sw.s2, .legend .sw.s3, .legend .sw.s4,
.legend .sw.s5, .legend .sw.s6, .legend .sw.s7, .legend .sw.s8 { background: var(--c); }
.tradeoff { display: grid; grid-template-columns: minmax(0, 1fr) minmax(12rem, 16rem); gap: 1rem; align-items: start; }
@media (max-width: 900px) { .tradeoff { grid-template-columns: minmax(0, 1fr); } }
.chart-legend p { margin: 0 0 .4rem; }
.chart-legend ul { list-style: none; margin: 0; padding: 0; display: grid; gap: .15rem; max-height: 22rem; overflow-y: auto; }
.legend-item { display: flex; align-items: center; gap: .45rem; width: 100%; text-align: left; background: none; border: 0;
  padding: .2rem .35rem; border-radius: 6px; color: var(--text); font-size: .85rem; }
.legend-item:hover, .legend-item.focus { background: var(--accent-soft); filter: none; }
.legend-item .swatch { width: .8rem; height: .8rem; border-radius: 3px; background: var(--c); flex: none; }
.legend-item[aria-pressed=false] { color: var(--muted); text-decoration: line-through; }
.legend-item[aria-pressed=false] .swatch { background: none; border: 1.5px solid var(--c); }
/* Recall heat cells: one hue, more saturated for higher recall, with the number printed. */
td.heat { background: color-mix(in srgb, var(--out-missed) calc(var(--v) * 45%), transparent); }
.section-head { flex-wrap: wrap; }
.section-head h2 { white-space: nowrap; }

/* Sortable tables (frontend/tables.ts marks the headers). */
th[data-sort-header] { cursor: pointer; user-select: none; white-space: nowrap; }
th[data-sort-header]:hover, th[data-sort-header]:focus-visible { color: var(--text); }
th[data-sort-header]::after { content: "↕"; margin-left: .3em; opacity: .3; font-size: .9em; }
th[aria-sort]::after { opacity: .9; }
th[aria-sort=ascending]::after { content: "↑"; }
th[aria-sort=descending]::after { content: "↓"; }
th[data-sort-then]::after { opacity: .6; }  /* breaks ties in the column sorted first */
th[data-sort-then=asc]::after { content: "↑"; }
th[data-sort-then=desc]::after { content: "↓"; }

/* Show / hide detectors on the scores page: a checkbox, and "only" on hover. */
table.scores .pick { width: 1%; white-space: nowrap; padding-right: 0; }
.pick-row { display: flex; align-items: center; gap: .35rem; }
.pick-row form { display: contents; }
.pick-row input[type=checkbox] { width: 1rem; height: 1rem; margin: 0; accent-color: var(--accent); cursor: pointer; }
button.only {
  background: none; border: 0; padding: 0 .2rem; font-size: .75rem; font-weight: 500;
  color: var(--accent); text-decoration: underline; opacity: 0;
}
tr:hover button.only, button.only:focus-visible { opacity: 1; }
@media (hover: none) { button.only { opacity: 1; } }
table.scores tr.off td:not(.pick) { opacity: .4; }

/* Jobs page */
.job-counts { margin-bottom: 1rem; }
table.jobs td.job-progress { min-width: 8rem; }
table.jobs td.job-actions form { margin: 0; }
table.jobs .job-error pre { white-space: pre-wrap; max-width: 40rem; margin: .5rem 0 0; }

/* Login page */
main.login { max-width: 22rem; margin: 15vh auto 0; padding: 0 1rem; }
main.login form { display: flex; flex-direction: column; gap: .5rem; }
main.login .bad { color: var(--bad); margin: 0; }
.topbar nav { flex: 1; }
.topbar form.logout { margin: 0; }
.topbar form.logout button { background: none; border: 0; color: var(--muted); padding: 0; font: inherit; cursor: pointer; }
table.jobs td.job-actions button { white-space: nowrap; }

/* Users page */
table.users form { margin: 0; }
table.users input[type=password] { width: 10rem; }
.topbar form.logout { display: flex; gap: .75rem; align-items: center; }

/* Cut versions of a proxy download */
.cuts { margin-top: .75rem; }
.cuts h3 { margin: 0 0 .25rem; }
table.cut-versions tr:not(.listen) td { border-bottom: 0; padding-bottom: 0; }
table.cut-versions audio { display: block; width: 100%; height: 2rem; }
.lanes-head, details.lane > summary { display: grid; grid-template-columns: 9rem minmax(0, 1fr) 5rem minmax(8rem, 12rem) 7rem;
  gap: .75rem; align-items: center; padding: .55rem .9rem; }
.lanes-head { font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); border-bottom: 1px solid var(--border); }
details.lane { border-bottom: 1px solid var(--border); }
details.lane:last-child { border-bottom: 0; }
details.lane > summary { cursor: pointer; list-style: none; }
details.lane > summary::-webkit-details-marker { display: none; }
details.lane > summary:hover { background: var(--accent-soft); }
details.lane[open] > summary { background: var(--accent-soft); }
.lane-name { font-weight: 600; display: flex; align-items: center; gap: .45rem; }
.lane-name::before { content: "›"; color: var(--muted); transition: transform .15s; }
details.lane[open] .lane-name::before { transform: rotate(90deg); }
.dot { width: .55rem; height: .55rem; border-radius: 50%; background: var(--border); }
.dot.busy { background: var(--accent); }
.lane-progress { display: inline-flex; align-items: center; gap: .4rem; vertical-align: middle; }
.lane-progress .progress { width: 6rem; margin: 0; }
.lanes .num { text-align: right; }
.lanes .num.bad { color: var(--bad); font-weight: 600; }
.lane-body { padding: 0 .9rem .6rem 2.2rem; }
.lane-body td.small { white-space: nowrap; }
.failed-jobs { border-color: var(--bad); margin-bottom: 1rem; }
.failed-jobs .failed-head { padding: .6rem .8rem; gap: .5rem; align-items: center; }
.failed-table td { vertical-align: top; }
.failed-table .job-error pre { max-width: 48rem; white-space: pre-wrap; }
.failed-table .actions form + form { margin-left: .3rem; }
@media (max-width: 760px) {
  .lanes-head { display: none; }
  details.lane > summary { grid-template-columns: 1fr auto; }
  details.lane > summary > :nth-child(4) { display: none; }
}
table.jobs tr.finished td { color: var(--muted); }
details.episodes-in-progress { margin-bottom: 1rem; }
details.episodes-in-progress > summary { cursor: pointer; padding: .55rem .9rem; display: flex; gap: .75rem; align-items: baseline; }
details.episodes-in-progress[open] > summary { border-bottom: 1px solid var(--border); }
details.episodes-in-progress .pad { padding: .55rem .9rem; margin: 0; }
table.episodes-work { margin: 0; }
table.episodes-work th, table.episodes-work td { padding-left: .9rem; }
table.episodes-work .num { text-align: right; }
table.episodes-work form { margin: 0; }
table.episodes-work button { white-space: nowrap; }



/* ---------- Analysis: layers over the waveform ---------- */
.l2-msg { color: var(--muted); }
.l2-msg.error { color: var(--bad); }
.l2-main { margin: 0; min-width: 0; }
.l2-bar { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1rem; margin-bottom: .6rem; }
.l2-play { width: 2.4rem; height: 2.4rem; border-radius: 50%; padding: 0; font-size: .95rem; }
.l2-time { font-size: 1rem; min-width: 15ch; }
.l2-zoom { display: inline-flex; gap: .25rem; }
.l2-zoom button { min-width: 2rem; }
.l2-overview { display: block; width: 100%; height: 40px; border: 1px solid var(--border); border-radius: 6px;
  background: var(--bg); cursor: pointer; touch-action: none; margin-bottom: .5rem; }
.l2-timeline { display: grid; grid-template-columns: 9.5rem minmax(0, 1fr); }
.l2-gutter { display: flex; flex-direction: column; font-size: .8rem; border-right: 1px solid var(--border); }
.l2-wave-name { display: flex; align-items: center; color: var(--muted); padding-left: .25rem; }
.l2-lane-row { display: flex; align-items: stretch; border-top: 1px solid var(--border); box-sizing: border-box; }
.l2-lane-row:hover { background: var(--bg); }
.l2-lane-row.focused { background: var(--accent-soft); }
.l2-lane-name {
  display: flex; align-items: center; gap: .4rem; flex: 1; min-width: 0; padding: 0 .2rem 0 .25rem; margin: 0;
  background: transparent; border: 0; border-radius: 0;
  color: var(--text); font-weight: 500; font-size: .8rem; text-align: left; cursor: pointer;
}
.l2-lane-name:hover { filter: none; }
.l2-lane-row.focused .l2-lane-name { color: var(--accent); }
.l2-lane-hide {
  flex: none; width: 1.4rem; padding: 0; margin: 0; background: transparent; border: 0; border-radius: 0;
  color: var(--muted); font-weight: 400; cursor: pointer; opacity: 0;
}
.l2-lane-row:hover .l2-lane-hide, .l2-lane-hide:focus-visible { opacity: 1; }
@media (hover: none) { .l2-lane-hide { opacity: .7; } }
.l2-lane-hide:hover { color: var(--text); filter: none; }
.l2-lane-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.l2-stage { position: relative; min-width: 0; }
.l2-canvas { display: block; width: 100%; touch-action: none; cursor: crosshair; }
.l2-tip {
  position: absolute; z-index: 5; max-width: 300px; pointer-events: none; padding: .45rem .6rem; font-size: .85rem;
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 6px 20px rgb(0 0 0 / .18);
}
.l2-tip-layer { font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin-bottom: .15rem; }
.l2-hint { margin: .5rem 0 0; }
.l2-hint summary { cursor: pointer; width: max-content; }
.l2-keys-help { display: grid; grid-template-columns: max-content 1fr; gap: .4rem .9rem; margin: .5rem 0 0; }
.l2-keys-help dt { font-weight: 600; }
.l2-keys-help dd { margin: 0; color: var(--muted); }

/* Below the player: the transcript beside the labels (status, then every label). */
.l2-work { border-top: 1px solid var(--border); margin-top: .9rem; padding-top: .75rem; }
.l2-work h2 { font-size: 1rem; margin: 0 0 .4rem; }
.l2-transcript .transcript-text { max-height: 50vh; }
.l2-from-audio-motifs { display: flex; flex-wrap: wrap; align-items: center; gap: .35rem .6rem; margin: .6rem 0 .2rem; }
.l2-proposals h2 { font-size: .95rem; margin: .8rem 0 .2rem; }
.l2-proposals ul { list-style: none; margin: .4rem 0; padding: 0; display: grid; gap: .5rem; }
.l2-proposals li { border: 1px solid var(--border); border-radius: 8px; padding: .5rem .65rem; }
.l2-proposals li p { margin: .25rem 0 .4rem; }
.l2-proposals form { margin: 0; }
.l2-label-list { list-style: none; margin: .25rem 0 0; padding: 0; max-height: 50vh; overflow-y: auto; }
.l2-label {
  display: grid; grid-template-columns: 1fr auto auto auto; align-items: center; gap: .5rem;
  padding: .3rem .5rem; border-left: 4px solid var(--sw); border-radius: 6px; margin-bottom: .3rem; background: var(--bg);
}
.l2-label.selected { outline: 2px solid var(--text); outline-offset: -1px; }
.l2-label select { padding: .15rem .3rem; font-size: .8rem; }
.l2-label-time { background: none; border: 0; color: var(--text); font-weight: 500; padding: 0; text-align: left; cursor: pointer; }
.l2-label-time:hover { color: var(--accent); filter: none; }
.l2-sel {
  position: absolute; z-index: 6; display: flex; align-items: center; gap: .35rem; padding: .3rem .4rem;
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 6px 20px rgb(0 0 0 / .18);
  white-space: nowrap;
}
.l2-sel[hidden] { display: none; }
.l2-sel select { padding: .15rem .4rem; font-size: .85rem; }
.l2 .sw { flex: none; width: 10px; height: 10px; border-radius: 3px; }

.l2-chip {
  display: inline-flex; align-items: center; gap: .45rem; padding: .25rem .55rem; border-radius: 999px;
  border: 1px solid var(--border); background: var(--bg); font-size: .82rem; max-width: 100%;
}
.l2-chip-layer { color: var(--muted); }
.l2-chip-what { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 28ch; }
.l2-chip-when { color: var(--muted); font-size: .75rem; }

.l2-panel { padding: 0 .9rem .75rem; }
.l2-side-tabs { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; gap: .25rem;
  margin: 0 -.9rem .5rem; padding: .55rem .9rem .4rem; background: var(--surface); border-bottom: 1px solid var(--border); }
.l2-side-tabs [role=tab] { background: none; border: 0; padding: .3rem .6rem; border-radius: 6px; color: var(--muted); font-weight: 600; }
.l2-side-tabs [role=tab][aria-selected=true] { background: var(--accent-soft); color: var(--accent); }
.l2-labels h2 { font-size: 1rem; margin: 0 0 .4rem; }
.l2-panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: .25rem; }
.l2-panel-head h2 { margin: 0; font-size: 1.05rem; }
.l2-panel-head { flex-wrap: wrap; gap: .4rem; }
.l2-panel-head .row { gap: .3rem; flex-wrap: wrap; justify-content: flex-end; }
.l2-panel-head button { white-space: nowrap; }
.l2-group { border-top: 1px solid var(--border); padding: .5rem 0; }
.l2-group > summary { display: flex; align-items: baseline; justify-content: space-between; cursor: pointer; list-style: none; }
.l2-group > summary::-webkit-details-marker { display: none; }
.l2-group > summary::before { content: "▸"; color: var(--muted); margin-right: .35rem; font-size: .8rem; }
.l2-group[open] > summary::before { content: "▾"; }
.l2-group-name { font-weight: 600; flex: 1; }
.l2-group-explain { margin: .2rem 0 .35rem; color: var(--muted); font-size: .8rem; }
.l2-group ul { list-style: none; padding: 0; margin: 0; }
.l2-layer { padding: .3rem .35rem; border-radius: 6px; border: 1px solid transparent; }
.l2-layer.on { background: var(--bg); }
.l2-layer.proxy { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent-soft), var(--accent) 30%);
  margin-bottom: .25rem; }
.l2-layer.proxy .l2-layer-name { font-weight: 600; }
.l2-layer.unavailable .l2-layer-name { color: var(--muted); }
.l2-toggle { display: flex; align-items: center; gap: .45rem; margin: 0; cursor: pointer; font-size: .9rem; }
.l2-toggle input { margin: 0; accent-color: var(--accent); }
.l2-layer-name { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.l2-note { color: var(--muted); font-size: .78rem; margin: .1rem 0 0 1.55rem; }
.l2-explain { margin: .1rem 0 0 1.55rem; font-size: .8rem; }
.l2-explain summary { color: var(--accent); cursor: pointer; width: max-content; }
.l2-explain p { margin: .25rem 0; color: var(--text); }
.l2-keys { display: flex; flex-wrap: wrap; gap: .2rem .7rem; }
.l2-key { display: inline-flex; align-items: center; gap: .3rem; color: var(--muted); }
.l2-tune-open { margin: .2rem 0 0 1.55rem; }
/* The Tune tab: one layer's settings, a draft of it, and where the draft differs. */
.l2-tune { display: flex; flex-direction: column; gap: .6rem; }
.l2-tune > p { margin: 0; }
.l2-tune-pick { display: flex; align-items: center; gap: .5rem; font-weight: 600; }
.l2-tune-pick select { flex: 1; min-width: 0; }
.l2-tune-status p { margin: 0 0 .3rem; }
.l2-tune-changes { list-style: none; padding: 0; margin: 0; max-height: 14rem; overflow-y: auto; font-size: .82rem;
  border: 1px solid var(--border); border-radius: 6px; }
.l2-tune-changes li { display: flex; gap: .5rem; align-items: baseline; padding: .2rem .45rem; border-top: 1px solid var(--border); }
.l2-tune-changes li:first-child { border-top: 0; }
.l2-tune-changes li span:first-of-type { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.l2-tune-group { font-size: .85rem; margin: .4rem 0 .1rem; color: var(--muted); font-weight: 600; }
.l2-knob { padding: .4rem .45rem; border-radius: 6px; border-left: 3px solid transparent; }
.l2-knob.changed { background: var(--accent-soft); border-left-color: var(--accent); }
.l2-knob-head { display: flex; align-items: center; gap: .4rem; }
.l2-knob-head label { flex: 1; min-width: 0; font-size: .88rem; margin: 0; }
.l2-knob-value { white-space: nowrap; }
.l2-knob-num { width: 5.2rem; padding: .1rem .3rem; font-size: .85rem; }
.l2-knob input[type=range] { width: 100%; margin: .25rem 0 0; accent-color: var(--accent); }
.l2-knob p { margin: .15rem 0 0; font-size: .76rem; }
.l2-tune-save { border-top: 1px solid var(--border); padding-top: .6rem; display: flex; flex-direction: column; gap: .4rem; }
.l2-tune-save p { margin: 0; }
.l2-tune-save .row { gap: .4rem; }
@media (max-width: 1000px) { .l2-timeline { grid-template-columns: 6.5rem minmax(0, 1fr); } }
/* Narrow screens: the top bar's links scroll sideways instead of widening every page. */
@media (max-width: 700px) {
  .topbar nav { min-width: 0; overflow-x: auto; white-space: nowrap; scrollbar-width: none; }
  .page-head { flex-wrap: wrap; }
}

/* ---------- the shows page: Add show, pages ---------- */
.add-show-dialog { border: 1px solid var(--border); border-radius: 12px; padding: 1rem 1.2rem 1.2rem; width: min(34rem, 92vw);
  background: var(--surface); color: var(--text); box-shadow: 0 20px 50px rgb(0 0 0 / .25); }
.add-show-dialog::backdrop { background: rgb(0 0 0 / .35); }
.add-show-dialog h2 { margin: 0; font-size: 1.1rem; }
.add-show .segmented { margin: .6rem 0 .8rem; }
.add-show .segmented [role=tab] { background: none; border: 0; padding: .3rem .7rem; color: var(--muted); }
.add-show .segmented [role=tab][aria-selected=true] { background: var(--accent-soft); color: var(--accent); border-radius: 6px; }
.add-show input[type=url] { flex: 1; }
.drop-hint { position: fixed; inset: 1rem; z-index: 50; display: grid; place-items: center; border: 3px dashed var(--accent);
  border-radius: 16px; background: rgb(255 255 255 / .85); color: var(--accent); font-size: 1.3rem; font-weight: 600; pointer-events: none; }
.drop-hint[hidden] { display: none; }
.pager { justify-content: space-between; align-items: center; margin: .6rem .2rem 1rem; }

/* ---------- fetch analytics ---------- */
.measurement { gap: .35rem; margin: .2rem 0 .7rem; }
td.chain { line-height: 1.8; }
.hop { white-space: nowrap; }
.hop.measured { color: var(--muted); }

/* ---------- scores tables: every column its own, the first ones kept in view ---------- */
table.scores td.pick, table.scores th.pick { position: sticky; left: 0; z-index: 1; background: var(--surface); }
table.scores .detector-col { position: sticky; left: 4.6rem; z-index: 1; background: var(--surface); white-space: nowrap; }
#recall-by-host .detector-col, #labeled-downloads .detector-col { left: 0; }
#recall-by-host .detector-col, #labeled-downloads .detector-col { position: sticky; z-index: 1; background: var(--surface); }
table.scores th, #recall-by-host th, #labeled-downloads th { white-space: nowrap; }
.det-head { font-size: .8rem; }
td.nowrap, .nowrap { white-space: nowrap; }

/* ---------- episode page: description, the live download first, the Download tool ---------- */
.ep-description { max-width: 72ch; margin: -.3rem 0 1rem; }
.ep-description .description-text { white-space: pre-line; margin: 0 0 .25rem; color: var(--text); }
.ep-description.clamped .description-text { display: -webkit-box; -webkit-line-clamp: 4; line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
button.link { background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; text-decoration: underline; }
.live-download { border: 2px solid var(--accent); border-radius: 10px; padding: .7rem .9rem .2rem; margin-bottom: 1rem; }
.live-download .live-head h3 { margin: 0 0 .3rem; font-size: 1rem; display: flex; gap: .5rem; align-items: center; }
.live-download .live-head p { margin: 0 0 .4rem; }
.live-download .card.download { margin-left: 0; margin-right: 0; }
h3.other-downloads { margin: 1.2rem 0 .5rem; }
.download-tool { margin: 0 0 1rem; }
.download-tool > summary { cursor: pointer; display: flex; align-items: baseline; gap: .6rem; }
.download-tool > summary h2 { font-size: 1rem; margin: 0; display: inline; }
.download-tool[open] > summary { margin-bottom: .5rem; }
.live-download.none { border: 1px dashed var(--border); }

/* ---------- tuning ---------- */
.profile-list { gap: .6rem; margin-bottom: .6rem; }
.profile { display: flex; gap: .5rem; align-items: center; border: 1px solid var(--border); border-radius: 8px; padding: .35rem .6rem; }
.profile.active { border-color: var(--accent); background: var(--accent-soft); }
.profile form { margin: 0; }
.new-profile input { min-width: 14rem; }
.tuning-group h2 { font-size: 1.05rem; margin: 0 0 .3rem; }
table.tunables input[type=number] { width: 6.5rem; text-align: right; }
table.tunables td { vertical-align: top; }
table.tunables tr[data-changed=true] td:first-child { border-left: 3px solid var(--accent); }
.download-tool > summary { list-style: none; }
.download-tool > summary::-webkit-details-marker { display: none; }
.download-tool > summary::before { content: "▸"; color: var(--muted); transition: transform .15s; }
.download-tool[open] > summary::before { transform: rotate(90deg); }

/* ---------- a show's Speakers page ---------- */
.people { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(30rem, 100%), 1fr)); gap: 1rem; }
.person { border: 1px solid var(--border); border-radius: 8px; padding: .6rem .8rem; }
.person header { display: flex; flex-wrap: wrap; align-items: baseline; gap: .3rem .7rem; margin-bottom: .4rem; }
.person h3 { margin: 0; font-size: 1.05rem; }
.speakers-page .warn, #people .warn, #alike .warn { color: var(--busy); font-weight: 600; }
table.compact { width: 100%; border-collapse: collapse; font-size: .85rem; }
table.compact th, table.compact td { padding: .2rem .4rem; text-align: left; border-top: 1px solid var(--border); }
table.compact thead th { border-top: 0; color: var(--muted); font-weight: 500; }
td.ellipsis { max-width: 14rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.likeness { display: inline-flex; align-items: center; gap: .35rem; }
.likeness-bar { display: inline-block; height: .5rem; max-width: 3rem; background: var(--accent); border-radius: 2px; }
.likeness.weak .likeness-bar { background: var(--busy); }
table.alike td { text-align: center; background: color-mix(in srgb, var(--accent) calc(var(--v, 0) * 45%), transparent); }
table.alike th { white-space: nowrap; }
.episode-speakers { border-top: 1px solid var(--border); padding: .5rem 0; }
.episode-speakers > summary { cursor: pointer; }
.diarized { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(26rem, 100%), 1fr)); gap: 1rem; margin-top: .4rem; }
.diarized h3 { margin: .2rem 0; font-size: .95rem; }
a.button.secondary { background: var(--surface); color: var(--text); border: 1px solid var(--border); font-weight: 500; }

/* ---------- a person's page under Speakers: clips to hear, label and correct ---------- */
.person-tools { display: flex; flex-direction: column; gap: .5rem; }
.person-tools form { gap: .5rem; align-items: center; }
.person-tools p { margin: 0; }
.person-tools .warn { color: var(--busy); font-weight: 600; }
.clip-bar { position: sticky; top: 0; z-index: 5; display: flex; flex-wrap: wrap; gap: .4rem 1rem; align-items: center;
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: .45rem .7rem; margin: 1rem 0; }
.selection-tools { gap: .5rem; align-items: center; margin-bottom: .5rem; }
.clips { display: flex; flex-direction: column; gap: .6rem; }
.clip { border: 1px solid var(--border); border-radius: 8px; padding: .35rem .5rem .45rem; }
.clip-head { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; margin-bottom: .25rem; }
.clip-title { font-weight: 500; max-width: 26rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.clip-canvas { display: block; width: 100%; cursor: crosshair; }
.clip-foot { display: flex; gap: .5rem; align-items: center; margin-top: .3rem; }
/* A motif's page (audio or text) and a show's Motifs page */
.motif-ref-head { display: flex; flex-wrap: wrap; gap: .5rem 2rem; justify-content: space-between; align-items: flex-start; }
.motif-ref-head h2 { margin: 0 0 .2rem; }
.motif-ref-head p { margin: 0; }
.motif-kind { max-width: 24rem; }
.motif-kind p { margin: .25rem 0 0; }
.edge-editor { margin-top: .75rem; display: flex; flex-direction: column; gap: .4rem; }
.edge-tools, .edge-actions { display: flex; flex-wrap: wrap; gap: .4rem .6rem; align-items: center; }
.edge-readout b { font-weight: 600; }
.edge-canvas { display: block; width: 100%; user-select: none; border-radius: 6px; }
.edge-words { line-height: 1.7; max-height: 9rem; overflow-y: auto; }
.edge-words .w { color: var(--muted); opacity: .6; cursor: pointer; padding: 0 .1rem; border-radius: 3px; }
.edge-words .w::after { content: ' '; }
.edge-words .w.in { color: var(--text); opacity: 1; }
.edge-words .w:hover { background: var(--accent-soft); }
.edge-words .w.now { background: var(--accent); color: var(--surface); opacity: 1; }
.motif-more > summary { cursor: pointer; display: flex; gap: .75rem; align-items: baseline; list-style: none; }
.motif-more > summary::before { content: '▸'; color: var(--muted); }
.motif-more[open] > summary::before { content: '▾'; }
.motif-more > summary h2 { margin: 0; font-size: 1rem; }
.motif-more[open] > summary { margin-bottom: .5rem; }
.motif-more .row { margin-bottom: .4rem; gap: .5rem; align-items: center; }
#occurrences .clip-bar h2 { margin: 0; font-size: 1rem; }
.flash { margin: -.75rem 0 1rem; padding: .35rem .7rem; border-radius: 6px; background: var(--accent-soft); width: fit-content; }
.clip.unlike { border-color: var(--series-4); }
.clip.slipped .clip-info { color: var(--busy); }
.slipped-note { color: var(--busy); }
.clip.now-playing { box-shadow: 0 0 0 2px var(--accent); }
.edge-switch { display: flex; flex-wrap: wrap; gap: .4rem .6rem; align-items: center; margin-top: .6rem;
  padding: .4rem .6rem; border-radius: 6px; background: var(--accent-soft); }
.motif-ref-head .warn { color: var(--busy); }
.edge-switch .break { flex-basis: 100%; height: 0; }
.edge-switch .segmented { display: inline-flex; border: 1px solid var(--border); border-radius: 6px; overflow: hidden; }
.edge-switch .segmented button { border: none; border-radius: 0; background: var(--surface); color: var(--text); font-weight: 500; }
.edge-switch .segmented button + button { border-left: 1px solid var(--border); }
.edge-switch .segmented button[aria-pressed="true"] { background: var(--accent); color: var(--surface); }
.clip.editing { border-color: var(--accent); box-shadow: inset 3px 0 0 var(--accent); }
.clip.ticked { border-color: var(--bad); background: color-mix(in srgb, var(--bad) 6%, transparent); }
.clip-words { margin: .35rem 0 0; line-height: 1.55; }
.clip-words mark, #occurrences p mark { background: color-mix(in srgb, var(--series-4) 30%, transparent); color: inherit; border-radius: 2px; }
.num-input { width: 5.5rem; }
select.suggested { font-style: italic; color: var(--muted); }
.inline-form { display: inline; margin: 0; }
#audio-motif-list tr.muted td { color: var(--muted); }

/* ---------- sidebars (the episode page, the Analysis page) ----------
   From the top bar's bottom edge to the window's, sliding in from the right. On a wide
   screen the page makes room for it; on a narrow one it lies over the page. The page
   says whether it's open: data-side=open (episode) or data-panel=open (Analysis) on the
   sidebar's parent. */
:root { --side-w: 340px; --topbar-h: 3.2rem; }
.side-panel {
  position: fixed; top: var(--topbar-h); right: 0; bottom: 0; z-index: 30; width: min(var(--side-w), 90vw);
  margin: 0; overflow-y: auto; overscroll-behavior: contain;
  background: var(--surface); border-left: 1px solid var(--border);
  transform: translateX(100%); visibility: hidden;
  transition: transform .25s ease, visibility 0s linear .25s;
}
[data-side=open] > .side-panel, [data-panel=open] > .side-panel {
  transform: none; visibility: visible; transition: transform .25s ease, visibility 0s;
}
main { transition: padding-right .25s ease, max-width .25s ease; }
@media (min-width: 1001px) {
  body:has([data-side=open] > .side-panel, [data-panel=open] > .side-panel) main {
    max-width: calc(1120px + var(--side-w)); padding-right: calc(1.5rem + var(--side-w));
  }
}
.side-backdrop { display: none; }
@media (max-width: 1000px) {
  .side-panel { box-shadow: -8px 0 30px rgb(0 0 0 / .25); }
  [data-side=open] > .side-backdrop, [data-panel=open] > .side-backdrop {
    display: block; position: fixed; inset: var(--topbar-h) 0 0 0; z-index: 29; background: rgb(0 0 0 / .3);
  }
}
button.side-toggle {
  display: inline-flex; align-items: center; gap: .3rem; padding: .25rem .4rem; line-height: 1;
  background: transparent; border: 1px solid var(--border); color: var(--muted); font-weight: 600; font-size: .8rem;
}
button.side-toggle:hover { color: var(--text); filter: none; }
button.side-toggle[aria-expanded=true] { color: var(--accent); }
.side-icon { display: block; }
.side-count:empty { display: none; }
@media (prefers-reduced-motion: reduce) { .side-panel, main { transition: none; } }

/* ---------- ticking rows to act on together (shows, episodes) ---------- */
.list th.tick, .list td.tick { width: 2rem; padding-right: 0; }
.selection-bar { gap: .75rem; align-items: center; padding: .5rem .9rem; margin: 0 0 .6rem;
  background: var(--accent-soft); border-radius: var(--radius); }
#episodes .selection-bar { margin: .5rem .75rem; }
.narrow-num { width: 4.5rem; padding: .2rem .4rem; }
.lane-slots { gap: .75rem; align-items: center; padding: .5rem .9rem; }
.lane-slots label.inline { white-space: nowrap; flex: none; }

.proposal-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.proposal-list li { display: flex; flex-wrap: wrap; gap: .4rem 1rem; justify-content: space-between; align-items: center;
  padding: .45rem .6rem; border: 1px solid var(--border); border-radius: 8px; }
.proposal-list li > div:first-child { display: grid; gap: 2px; flex: 1 1 20rem; }
.proposal-list li .row { gap: .4rem; }
.proposal-list li.previewing { border-color: var(--series-2); background: color-mix(in srgb, var(--series-2) 7%, transparent); }

/* ---------- score history (scores page, Over time) ---------- */
table.history td { vertical-align: top; }
table.history td.history-cell { min-width: 8.5rem; }
table.history th { white-space: nowrap; }
table.history .then-now { font-variant-numeric: tabular-nums; }
table.history td[data-change="worse"] .now { color: var(--bad); font-weight: 600; }
table.history td[data-change="better"] .now { color: var(--good); font-weight: 600; }
table.history td[data-change="worse"] { background: var(--bad-soft); }
table.history td[data-change="better"] { background: var(--good-soft); }
svg.spark { display: block; margin-left: auto; overflow: visible; }
svg.spark polyline { fill: none; stroke: var(--accent); stroke-width: 1.5; }
svg.spark circle { fill: var(--accent); }
svg.spark line.since { stroke: var(--muted); stroke-dasharray: 2 2; }
#history-since { max-width: 22rem; }

/* The Review page's bar (routes/review.py): on an item's page while a queue is being worked through. */
.review-bar {
  position: fixed; left: 50%; bottom: 1rem; transform: translateX(-50%); z-index: 60;
  display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; max-width: calc(100vw - 2rem);
  padding: .5rem .75rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: 0 4px 16px rgb(0 0 0 / .15);
}
main:has(~ .review-bar) { padding-bottom: 5rem; }
.review-queue h2 { margin: 0; }

/* What accepting a proposal would do (motif.ts, proposal-effect-core.ts). */
.proposal-effect { flex-basis: 100%; margin-top: 0.4rem; }
.proposal-effect p { margin: 0.15rem 0; }
.clip-change { color: var(--muted); }
.clip[data-change="grows"] .clip-change, .clip[data-change="both"] .clip-change,
.clip[data-change="joined"] .clip-change, .clip[data-change="added"] .clip-change { color: var(--accent); }
.clip[data-change="gone"] .clip-change, .clip[data-change="neither"] .clip-change { color: var(--bad); }
.clip[data-change="first"] .clip-change, .clip[data-change="second"] .clip-change { color: var(--busy); }
.clip[data-change="gone"], .clip[data-change="neither"] { border-color: var(--bad); }

/* ---------- the Learning page ---------- */
svg.chart .series-line { fill: none; stroke: var(--c); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
svg.chart .series.overall { --c: var(--text); }
svg.chart .series.overall .series-line { stroke-width: 3; }
svg.chart .series.overall .direct-label { display: block; }
.learning-curves { display: grid; grid-template-columns: repeat(auto-fit, minmax(34rem, 1fr)); gap: 1rem; align-items: start; }
.legend .sw.overall { background: var(--text); }
.push-bar { display: inline-block; height: .55rem; border-radius: 0 4px 4px 0; background: var(--accent); vertical-align: middle; }
.push-bar.toward-show { background: var(--muted); }
td.sep { font-family: var(--mono); font-size: .85rem; text-align: right; }
td.sep.strong { font-weight: 600; }
.learning-words { display: grid; grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr)); gap: 1rem; }
.learning-words ol { margin: 0; padding-left: 1.4rem; columns: 2; font-size: .9rem; }
.kind-table td, .kind-table th { text-align: center; }
.kind-table td.same { background: var(--good-soft); font-weight: 600; }
.motif-pattern { font-size: .8rem; padding: .05rem .4rem; border-radius: 999px; background: var(--bg); border: 1px solid var(--border); }
.motif-pattern.edge, .motif-pattern.split { background: var(--busy-soft); border-color: transparent; }
#learning-signals td:first-child { min-width: 15rem; }
#learning-signals th.num { white-space: nowrap; }
#learning-signals td:nth-child(2) { white-space: nowrap; }
.find-all { justify-content: flex-end; gap: .4rem; margin: 0 0 .5rem; }

/* Where a motif sits among the show's others, and the one an edit made (_motif_neighbours.html). */
.motif-neighbours { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; margin: 0 0 .8rem; }
.motif-chip { display: inline-flex; align-items: baseline; gap: .35rem; padding: .2rem .55rem; border: 1px solid var(--border);
  border-radius: 999px; background: var(--surface); text-decoration: none; }
.motif-chip.current { background: var(--accent-soft); border-color: var(--accent); }
.motif-chip.made { border-color: var(--series-2); background: color-mix(in srgb, var(--series-2) 10%, var(--surface)); }
.motif-made { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; }

/* ---------- a motif in context (prototype: motif_context.html, context.ts) ---------- */
.context-tools { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; margin-bottom: .5rem; }
.context-sep { width: 1px; height: 1.2rem; background: var(--border, rgba(127,127,127,.3)); }
#context-play { min-width: 2.4rem; }
#context .l2-lane-row.current .l2-lane-label { font-weight: 700; }
#context .l2-lane-name .sw { width: .7rem; height: .7rem; border-radius: 2px; flex: none; }
#context .l2-lane-name .sw.unset { background-image: repeating-linear-gradient(-45deg, transparent 0 2px, var(--surface) 2px 3.5px) !important; opacity: .8; }
#context .context-fixed { color: var(--muted); cursor: default; }
.context-pending { display: flex; flex-wrap: wrap; align-items: baseline; gap: .5rem; margin-top: .5rem; padding: .4rem .6rem; border-radius: 6px; background: color-mix(in srgb, var(--series-4) 12%, transparent); }
.context-pending[hidden] { display: none; }
.context-pending ul { margin: 0; padding-left: 1.2rem; flex: 1 1 100%; }
.context-words { margin-top: .75rem; line-height: 1.7; max-height: 8rem; overflow-y: auto; }
.context-words span { cursor: pointer; border-radius: 2px; }
.context-words span.in-motif { background: color-mix(in srgb, var(--chosen, var(--accent)) 28%, transparent); }
.context-words span.now { background: var(--accent); color: var(--surface); }

/* A small rounded label beside a name (the Automatic tab's trained and proxy). */
.chip { display: inline-block; padding: 0 .5em; margin-left: .3em; border-radius: 999px; font-size: .75rem; line-height: 1.5;
  vertical-align: middle; background: color-mix(in srgb, var(--series-7) 14%, transparent); color: var(--series-7); }
.chip.proxy { background: color-mix(in srgb, var(--series-3) 14%, transparent); color: var(--series-3); }
.scores-shown { align-items: center; gap: .5rem; margin-bottom: .5rem; }

/* ---------- the Shows table's two looks, tried side by side (_shows_table.html) ---------- */
.shows-bar { align-items: center; gap: .5rem; }
#shows-list td { font-variant-numeric: tabular-nums; }
#shows-list .good { color: var(--good); }
#shows-list .title-text { display: flex; flex-direction: column; min-width: 0; }
#shows-list .title-text > a { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#shows-list td[data-side] { white-space: nowrap; }
#shows-list .title-cell { max-width: 20rem; }
#shows-list .title-text .sub { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kinds-bar { display: inline-flex; width: 64px; height: 6px; margin: 0 .4rem; border-radius: 3px; overflow: hidden; vertical-align: middle;
  background: var(--border); }
.motif-counts { white-space: nowrap; }
#shows-list .chip.proposals { display: inline-block; margin: .2rem 0 0; text-decoration: none; background: var(--accent-soft); color: var(--accent); }
.kinds-bar .kb-ads { background: var(--series-8); }
.kinds-bar .kb-edge { background: var(--series-7); }
.kinds-bar .kb-show { background: var(--series-3); }
.kinds-bar .kb-unset { background: color-mix(in srgb, var(--muted) 45%, transparent); }

/* A motif in context: its occurrences beside the reference (frontend/compare.ts) */
.compare-tools { display: flex; gap: .6rem; align-items: center; margin: .5rem 0; }
.compare-canvas { width: 100%; height: 150px; display: block; }
.compare-words { font-size: 1rem; line-height: 1.9; margin: .5rem 0 .75rem; }
.compare-words .w, #compare .del, #compare .ins, #compare .rold, #compare .rnew { border-radius: 3px; padding: 0 1px; }
.compare-words .w { cursor: pointer; }
.compare-words .w:hover { background: color-mix(in srgb, var(--accent-soft) 70%, transparent); }
.compare-words .w.now { box-shadow: inset 0 -2px 0 var(--accent); }
#compare .del { color: var(--bad); text-decoration: line-through; text-decoration-thickness: 1.5px; }
#compare .ins { color: var(--busy); background: var(--busy-soft); text-decoration: underline; text-underline-offset: 3px; }
#compare .rold { color: #534ab7; text-decoration: line-through; opacity: .75; }
#compare .rnew { color: #534ab7; background: color-mix(in srgb, #7f77dd 18%, transparent); text-decoration: underline; text-underline-offset: 3px; }
@media (prefers-color-scheme: dark) { #compare .rold, #compare .rnew { color: #afa9ec; } }
#compare .faded { opacity: .35; }
.compare-table { max-height: 22rem; overflow-y: auto; }
.compare-rows { table-layout: fixed; }
.compare-rows th:nth-child(1) { width: 28%; } .compare-rows th:nth-child(3) { width: 4rem; }
.compare-rows th:nth-child(4) { width: 8rem; } .compare-rows th:nth-child(5) { width: 5rem; }
.compare-rows tbody tr { cursor: pointer; }
.compare-rows tr.chosen td { background: var(--accent-soft); }
.compare-rows th:nth-child(6) { width: 17rem; }
.compare-rows th { white-space: normal; vertical-align: bottom; }
.compare-rows .cmp-acts { text-align: right; }
.compare-rows .cmp-acts button { margin: .1rem 0 .1rem .25rem; white-space: nowrap; }
.compare-rows .cmp-acts button { visibility: hidden; }
.compare-rows tr.chosen .cmp-acts button, .compare-rows tr:hover .cmp-acts button { visibility: visible; }
.compare-rows tr:not(.chosen):hover .cmp-acts button { opacity: .6; }
.context-proposal { margin: .4rem 0; padding: calc(.35rem + 2px) .6rem; border-radius: 6px; background: color-mix(in srgb, rgb(239, 159, 39) 9%, transparent); border: 1px solid color-mix(in srgb, rgb(186, 117, 23) 35%, transparent); }
.context-proposal[hidden] { display: none; }
.context-proposal-top { display: flex; align-items: center; gap: .8rem; }
.context-proposal-head { flex: 1; min-width: 0; font-weight: 600; }
.context-proposal-acts { display: flex; align-items: center; gap: .35rem; flex: none; }
.context-proposal-acts [hidden] { display: none; }
.context-proposal-nav { display: flex; align-items: center; gap: .3rem; margin-left: .3rem; padding-left: .6rem; border-left: 1px solid color-mix(in srgb, rgb(186, 117, 23) 35%, transparent); }
.context-proposal-why { margin-top: .2rem; }
.compare-rows .cmp-ep { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.cmp-strip { position: relative; display: block; height: 14px; background: color-mix(in srgb, var(--border) 45%, transparent); border-radius: 3px; }
.cmp-ref { position: absolute; top: 0; bottom: 0; border: 1px dashed var(--muted); border-radius: 2px; }
.cmp-copy { position: absolute; top: 3px; height: 8px; background: var(--accent); border-radius: 2px; opacity: .85; }
.compare-canvas { cursor: text; touch-action: none; }
.compare-only { display: block; margin: .25rem 0; }
.compare-tools { flex-wrap: wrap; } .compare-tools button, #compare-clock { white-space: nowrap; }
