:root {
  --bg: #f6f7f6; --card: #ffffff; --ink: #14201b; --mute: #55635d; --line: #d3dbd7;
  --accent: #006b52; --accent-ink: #ffffff; --warn: #8a4100; --bad: #a11a2b; --chip: #e8f1ed; --focus: #0b5fff;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1513; --card: #18201d; --ink: #e8efec; --mute: #9aaaa3; --line: #2f3b36;
    --accent: #35c79d; --accent-ink: #06231a; --warn: #f0a35a; --bad: #ff8a98; --chip: #20302a; --focus: #7ab0ff;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  overflow-x: hidden;
}
[hidden] { display: none !important; }
h1 { font-size: 18px; margin: 0; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

input, select, button, textarea { font: inherit; color: var(--ink); }
input[type=text], input[type=search], input[type=password], select, textarea {
  width: 100%; min-height: 44px; padding: 8px 12px; font-size: 16px;
  border: 1px solid var(--line); border-radius: 8px; background: var(--card);
}
button {
  min-height: 44px; padding: 8px 14px; font-size: 16px; cursor: pointer;
  border: 1px solid var(--line); border-radius: 8px; background: var(--card);
}
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
button.quiet { background: transparent; }
button.danger { background: var(--bad); border-color: var(--bad); color: var(--card); font-weight: 600; }
textarea { min-height: 88px; resize: vertical; }
button:disabled { opacity: 0.6; cursor: default; }

.gate { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.gate-card { width: 100%; max-width: 420px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 20px 16px; }
.gate-card h1 { margin-bottom: 8px; }
.gate-card label { display: block; font-size: 14px; color: var(--mute); margin: 12px 0 4px; }
.gate-card button { width: 100%; margin-top: 12px; }

/* Not sticky on a phone: with the filters it is taller than the screen (review finding 2). */
.top { position: static; background: var(--bg); border-bottom: 1px solid var(--line); padding: 12px 16px; }
.filters-box { margin-top: 8px; }
.filters-box > summary {
  display: list-item; list-style-position: inside; min-height: 44px; line-height: 44px;
  padding: 0 4px; cursor: pointer; font-size: 16px; color: var(--ink);
}
.top-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.row { display: flex; flex-direction: column; gap: 8px; }
.filters { display: grid; grid-template-columns: 1fr; gap: 8px; margin-top: 4px; }
.filters label { display: block; font-size: 14px; color: var(--mute); }
.filters label input, .filters label select { margin-top: 2px; color: var(--ink); }
.filters label.check { display: flex; align-items: center; gap: 8px; min-height: 44px; color: var(--ink); }
.filters input[type=checkbox] { width: 22px; height: 22px; }
/* Recording detail filters (22.6): part of the same grid; shown only for a full key. */
.detail-filters { display: contents; }
.filters .hint, .details-form .hint { display: block; font-size: 13px; color: var(--mute); margin: 2px 0 0; }
.screens { grid-column: 1 / -1; margin: 0; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; min-width: 0; }
.screens legend { font-size: 14px; color: var(--mute); padding: 0 4px; }
.screens .hint { margin: 0 0 4px; }
.screens-list { display: grid; grid-template-columns: 1fr; gap: 0 12px; }
.screens-list label.check { display: flex; align-items: center; gap: 8px; min-height: 44px; color: var(--ink); font-size: 16px; }
.screens-list input[type=checkbox] { width: 22px; height: 22px; flex: 0 0 auto; margin: 0; }
.status { margin: 8px 0 0; font-size: 14px; color: var(--mute); min-height: 21px; }

/* Categories panel (32.2.2): under the search row, outside the Filters box, on every width.
   Each group is a wrapping row of toggle buttons; a long group scrolls inside itself. */
.categories { margin-top: 10px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; min-width: 0; }
.categories-title { font-size: 16px; margin: 0; }
.cat-group { display: grid; gap: 4px; min-width: 0; }
.cat-label { font-size: 14px; color: var(--mute); }
.cat-buttons { display: flex; flex-wrap: wrap; gap: 6px; max-height: 184px; overflow-y: auto; padding: 6px; margin: -6px; min-width: 0; }
.cat-buttons .hint { font-size: 14px; color: var(--mute); }
.cat-buttons button.chip-toggle { flex: 0 1 auto; max-width: 100%; border-radius: 999px; font-size: 14px; padding: 6px 12px; background: var(--chip); border-color: var(--line); overflow-wrap: anywhere; text-align: left; }
.cat-buttons button[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.cat-client { display: block; font-size: 14px; color: var(--mute); }
.cat-client select { margin-top: 2px; color: var(--ink); }
.cat-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 4px 12px; }
.cat-foot label.check { display: flex; align-items: center; gap: 8px; min-height: 44px; color: var(--ink); }
.cat-foot input[type=checkbox] { width: 22px; height: 22px; margin: 0; }
.browse-more { display: block; width: calc(100% - 32px); max-width: 1068px; margin: -48px auto 64px; }

main { padding: 12px 16px 64px; max-width: 1100px; margin: 0 auto; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; margin: 0 0 12px; overflow-wrap: anywhere; }
.meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 13px; color: var(--mute); margin-bottom: 6px; }
.chip { background: var(--chip); border-radius: 999px; padding: 2px 10px; color: var(--ink); }
.chip.ok { color: var(--accent); }
.chip.warn { color: var(--warn); }
.summary { font-weight: 600; margin: 0 0 4px; }
.quote { margin: 0; white-space: pre-wrap; }
.source { font-size: 14px; color: var(--mute); margin: 8px 0 0; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.actions button { flex: 1 1 140px; }

/* Recording details on a card (22.6): small labels and the Edit details form. */
.details-labels { margin: 8px 0 0; }
.chip.detail { font-size: 13px; }
.details-edit { margin-top: 10px; }
.details-edit > button { width: 100%; }
.details-form { display: grid; grid-template-columns: 1fr; gap: 4px; margin-top: 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; }
.details-form label { font-size: 14px; color: var(--mute); margin-top: 6px; }
.details-buttons { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.details-buttons button { flex: 1 1 140px; }
.details-state { margin: 8px 0 0; font-size: 14px; color: var(--mute); }
.details-state.ok { color: var(--accent); }
.details-state.warn { color: var(--warn); }
.details-state.bad { color: var(--bad); }

/* Clip control (20.5): mode choice and button share a row that wraps on a phone. */
.clip { margin-top: 10px; }
.clip-row { display: flex; flex-wrap: wrap; gap: 8px; }
.clip-row select { flex: 1 1 120px; width: auto; min-width: 0; }
.clip-row button { flex: 1 1 140px; }
.clip-state { margin: 8px 0 0; font-size: 14px; color: var(--mute); }
.clip-state.ok { color: var(--accent); }
.clip-state.warn { color: var(--warn); }
.clip-state.bad { color: var(--bad); }
.clip-link {
  display: inline-flex; align-items: center; justify-content: center; min-height: 44px; margin-top: 8px;
  padding: 8px 14px; border-radius: 8px; background: var(--accent); color: var(--accent-ink);
  font-weight: 600; text-decoration: none; max-width: 100%;
}

.player { margin-top: 10px; }
.player video { display: block; width: 100%; max-height: 60vh; border-radius: 8px; background: #000; }
.player-bar { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
/* Seek bar with previews (50.4): a thin track that thickens on hover; the tip above it shows the
   frame (one cell of a 10 by 10 scrub sheet, position set from script) and the time. */
.scrub { position: relative; padding: 10px 0; cursor: pointer; touch-action: none; user-select: none; -webkit-user-select: none; }
.scrub-track { position: relative; height: 4px; border-radius: 2px; background: var(--line); }
.scrub.hovering .scrub-track { height: 6px; margin-top: -1px; }
.scrub-fill { display: block; height: 100%; width: 0; border-radius: 2px; background: var(--accent); }
.scrub-head { position: absolute; top: 50%; width: 12px; height: 12px; margin: -6px 0 0 -6px; border-radius: 50%; background: var(--accent); }
.scrub-tip {
  position: absolute; bottom: 24px; left: 0; width: 160px; display: none; flex-direction: column; align-items: center;
  pointer-events: none; z-index: 2;
}
.scrub.hovering .scrub-tip { display: flex; }
.scrub-frame {
  display: none; width: 160px; border-radius: 6px; border: 2px solid #fff; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
  background-color: #000; background-repeat: no-repeat;
}
.scrub.has-frame .scrub-frame { display: block; }
.scrub-time {
  margin-top: 4px; padding: 1px 6px; border-radius: 4px; background: rgba(0, 0, 0, 0.8); color: #fff;
  font-size: 12px; line-height: 1.4; font-variant-numeric: tabular-nums;
}
.player-bar button { flex: 1 1 auto; }
/* Quality switch (33.2.4): two toggle buttons; 480p is disabled with a note when there is no watch copy. */
.quality { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; flex: 1 1 260px; min-width: 0; }
.quality button { flex: 1 1 90px; }
.quality button[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.quality-note { flex: 1 1 100%; font-size: 14px; color: var(--mute); }

/* Thumbnails (33.2.1, 33.2.2): one 16:9 box; the frame inside keeps the video's shape and shows one
   cell of the 6 by 5 contact sheet (background-size 600% 500%, position set from script). While a
   pointer, finger or the keyboard moves through the minutes, a time label and a thin bar show. */
.thumb {
  position: relative; aspect-ratio: 16 / 9; min-width: 0; border-radius: 8px; overflow: hidden;
  background: var(--chip); color: var(--mute); display: flex; align-items: center; justify-content: center;
  font-size: 14px; text-align: center; padding: 4px;
}
.thumb.has-image {
  padding: 0; background: #000; cursor: pointer; touch-action: pan-y;
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}
.thumb-frame { position: absolute; inset: 0; margin: auto; background-repeat: no-repeat; background-size: 600% 500%; background-position: 0% 0%; pointer-events: none; }
.thumb-time {
  position: absolute; right: 6px; bottom: 10px; padding: 1px 6px; border-radius: 4px; pointer-events: none;
  background: rgba(0, 0, 0, 0.75); color: #fff; font-size: 12px; line-height: 1.4; font-variant-numeric: tabular-nums; opacity: 0;
}
.thumb-bar { position: absolute; left: 0; right: 0; bottom: 0; height: 4px; background: rgba(255, 255, 255, 0.25); opacity: 0; pointer-events: none; }
.thumb-fill { display: block; height: 100%; width: 0; background: var(--accent); }
.thumb.scrubbing .thumb-time, .thumb.scrubbing .thumb-bar { opacity: 1; }
/* No blank flash (37.2.3): the previous preview stays, dimmed, until the next image has loaded. */
.thumb.stale { padding: 0; background: #000; }
.thumb.stale .thumb-frame { opacity: 0.45; }
@media (prefers-reduced-motion: no-preference) { .thumb .thumb-frame { transition: opacity 120ms ease-out; } }
.card.has-thumb { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; }
.card.has-thumb > :not(.thumb):not(.card-body) { grid-column: 1 / -1; }
.card.has-thumb .player { margin-top: 0; }
.card-body { min-width: 0; }

/* Regions (25.3.4): the overlay covers the video element exactly; outlines are placed in pixels
   inside the displayed picture. Clicks pass through to the video except while drawing. */
.player-stage { position: relative; }
.region-overlay { position: absolute; inset: 0; pointer-events: none; overflow: hidden; border-radius: 8px; }
.region-overlay.drawing { pointer-events: auto; cursor: crosshair; touch-action: none; outline: 2px dashed var(--focus); outline-offset: -2px; }
.region-box { position: absolute; border: 2px solid #ffd23f; box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.6); pointer-events: none; }
.region-box.draft { border-style: dashed; background: rgba(255, 210, 63, 0.15); }
.region-label {
  position: absolute; left: -2px; top: -2px; max-width: calc(100% + 4px); padding: 1px 6px; font-size: 12px; line-height: 1.4;
  background: #ffd23f; color: #14201b; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* Segments panel under the player (25.3). */
.chip.note { color: var(--accent); font-weight: 600; }
.segments { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--line); }
.segments-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; }
.segments-head h2 { font-size: 16px; margin: 0; }
.segments-state { margin: 8px 0 0; font-size: 14px; color: var(--mute); }
.segments-state.ok { color: var(--accent); }
.segments-state.warn { color: var(--warn); }
.segments-state.bad { color: var(--bad); }
.segments-list { list-style: none; margin: 8px 0 0; padding: 0; }
.segment { padding: 10px 0; border-bottom: 1px solid var(--line); }
.segment.playing { border-left: 3px solid var(--accent); padding-left: 8px; }
.segment-comment { margin: 0; white-space: pre-wrap; }
.segment-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.segment-actions button { flex: 1 1 100px; }
.segment-actions button.on { background: var(--chip); border-color: var(--accent); color: var(--accent); font-weight: 600; }
.segment-confirm { margin-top: 8px; padding: 8px 10px; border: 1px solid var(--bad); border-radius: 8px; }
.segment-confirm p { margin: 0; color: var(--bad); }
.segments-empty { color: var(--mute); padding: 12px 0; }
.segment-form { display: grid; gap: 6px; margin-top: 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; }
.segment-form h3 { font-size: 15px; margin: 0; }
.segment-form label { font-size: 14px; color: var(--mute); }
.segment-form .hint { display: block; font-size: 13px; color: var(--mute); margin: 0; }
.segment-times { display: grid; grid-template-columns: 1fr; gap: 8px; }
.segment-clock-row { display: flex; gap: 8px; margin-top: 2px; }
.segment-clock-row input { flex: 1 1 auto; min-width: 0; }
.segment-clock-row button { flex: 0 0 auto; }
.segment-regions { margin: 4px 0 0; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; min-width: 0; display: grid; gap: 6px; }
.segment-regions legend { font-size: 14px; color: var(--mute); padding: 0 4px; }
.segment-region-list { margin: 0; padding: 0; list-style: none; display: grid; gap: 8px; }
.segment-region { display: grid; grid-template-columns: 1fr; gap: 4px; }

/* Quick tagging view (27.2): replaces the search area; the header stays. */
.top-buttons { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }
#app.tagging #search-form, #app.tagging #status, #app.tagging #results { display: none !important; }
#app.tagging #browse-more { display: none !important; }
.tag-view { padding: 12px 16px 64px; max-width: 1100px; margin: 0 auto; }
.tag-view h2 { font-size: 18px; margin: 0; }
.tag-view > .hint { font-size: 14px; color: var(--mute); margin: 4px 0 0; }
.tag-view > label.check { display: flex; align-items: center; gap: 8px; min-height: 44px; margin-top: 4px; }
.tag-view > label.check input { width: 22px; height: 22px; margin: 0; }
.tag-list { list-style: none; margin: 8px 0 0; padding: 0; }
.tag-row { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; margin: 0 0 12px; overflow-wrap: anywhere; display: grid; grid-template-columns: 1fr; gap: 10px; }
.tag-main { display: grid; gap: 10px; min-width: 0; }
.tag-title { font-size: 16px; margin: 0; }
.tag-facts { display: flex; flex-wrap: wrap; gap: 6px 12px; font-size: 14px; color: var(--mute); margin: 2px 0 0; }
.tag-group { margin: 0; padding: 0; border: 0; min-width: 0; }
.tag-group legend { font-size: 14px; color: var(--mute); padding: 0; margin-bottom: 4px; }
.tag-buttons { display: flex; flex-wrap: wrap; gap: 6px; }
.tag-buttons button { flex: 1 1 70px; }
.tag-buttons button.chip-toggle { flex: 0 1 auto; border-radius: 999px; font-size: 14px; padding: 6px 12px; }
.tag-buttons button[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.tag-status { margin: 0; font-size: 14px; color: var(--mute); min-height: 21px; }
.tag-status.saved { color: var(--accent); }
.tag-status.bad { color: var(--bad); }
.tag-row .actions { margin-top: 0; }
.tag-row .player { grid-column: 1 / -1; }
.tag-more { width: 100%; margin-top: 4px; }

/* Status panel (37.2.6): replaces the search area like the tagging view; the header stays. */
#app.status-shown #search-form, #app.status-shown #status, #app.status-shown #results,
#app.status-shown #browse-more, #app.status-shown #columns, #app.status-shown .view-switch { display: none !important; }
.status-panel { padding: 12px 16px 64px; max-width: 1100px; margin: 0 auto; overflow-wrap: anywhere; }
.status-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; }
.status-panel h2 { font-size: 18px; margin: 0; }
.status-panel > .hint, .status-body .hint { font-size: 14px; color: var(--mute); margin: 4px 0 0; }
.status-panel > .notice { margin-top: 12px; }
.status-section { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; margin: 12px 0 0; min-width: 0; }
.status-section h3 { font-size: 16px; margin: 0 0 6px; }
.status-counts { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 8px 16px; margin: 0; }
.status-counts dt { font-size: 14px; color: var(--mute); }
.status-counts dd { margin: 0; font-size: 20px; font-weight: 600; font-variant-numeric: tabular-nums; }
.status-list { margin: 0; padding: 0 0 0 18px; display: grid; gap: 4px; }
.status-failures { list-style: none; padding: 0; gap: 10px; }
.status-failures li { border-top: 1px solid var(--line); padding-top: 8px; }
.status-failures li:first-child { border-top: 0; padding-top: 0; }
.status-failures p { margin: 0; }
.status-failure-title { font-weight: 600; }
.status-failure-facts { font-size: 14px; color: var(--mute); }
.status-failure-error { font-size: 14px; color: var(--bad); white-space: pre-wrap; }
.status-read { margin: 12px 0 0; font-size: 14px; color: var(--mute); }

/* View switch (35.1): two toggle buttons in the header. */
.view-switch { display: flex; gap: 0; }
.view-switch button { border-radius: 0; }
.view-switch button:first-child { border-radius: 8px 0 0 8px; }
.view-switch button:last-child { border-radius: 0 8px 8px 0; border-left-width: 0; }
.view-switch button[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
#app.tagging .view-switch, #app.tagging #columns { display: none !important; }
/* In Columns view the columns replace the category buttons and the Client select (35.3). */
#app.view-columns .cat-group, #app.view-columns .cat-client, #app.view-columns #cat-clear, #app.view-columns .categories-title { display: none !important; }
.columns-note { margin: 0 0 12px; font-size: 14px; color: var(--mute); }

/* Columns view (35.4): fixed-width columns with thin lines between them, scrolling sideways inside
   their own strip, and a wider preview on the right. Each column scrolls up and down on its own. */
.columns { padding: 12px 16px 24px; min-width: 0; }
.columns-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; margin-bottom: 10px; min-width: 0; }
.columns-arrange { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--mute); }
.columns-arrange select { width: auto; min-width: 0; max-width: 100%; color: var(--ink); }
.columns-path { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 4px; min-width: 0; flex: 1 1 240px; font-size: 14px; }
.columns-path button { min-height: 36px; padding: 4px 8px; font-size: 14px; background: transparent; border-color: transparent; max-width: 100%; overflow-wrap: anywhere; text-align: left; }
.columns-path button[aria-current="location"] { font-weight: 600; }
.columns-path-sep { color: var(--mute); }
.columns-body {
  display: flex; min-width: 0; height: clamp(360px, calc(100vh - 220px), 1000px);
  border: 1px solid var(--line); border-radius: 10px; background: var(--card); overflow: hidden;
}
.columns-strip { position: relative; display: flex; flex: 0 1 auto; min-width: 0; overflow-x: auto; overflow-y: hidden; overscroll-behavior-x: contain; }
.columns-strip > .loading, .columns-strip > .empty, .columns-strip > .notice { flex: 1 1 auto; margin: 12px; }
.columns-col {
  position: relative; flex: 0 0 240px; width: 240px; height: 100%; overflow-y: auto; overscroll-behavior-y: contain;
  border-right: 1px solid var(--line); padding: 4px 0;
}
.col-row {
  display: flex; align-items: center; gap: 8px; min-height: 32px; margin: 1px 6px; padding: 4px 8px;
  border-radius: 6px; font-size: 14px; line-height: 1.3; cursor: pointer; user-select: none; -webkit-user-select: none;
}
.col-row:hover { background: var(--chip); }
.col-row:focus-visible { outline-offset: -3px; }
.col-row[aria-selected="true"] { background: var(--line); }
.columns-col:focus-within .col-row[aria-selected="true"] { background: var(--accent); color: var(--accent-ink); }
.col-label { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.col-count { flex: 0 0 auto; font-size: 12px; color: var(--mute); font-variant-numeric: tabular-nums; }
.columns-col:focus-within .col-row[aria-selected="true"] .col-count { color: inherit; }
/* A folder drawn in CSS: a body with a small tab on its top left. */
.col-icon { position: relative; flex: 0 0 auto; width: 16px; height: 11px; margin-top: 3px; border-radius: 2px; background: currentColor; opacity: 0.55; }
.col-icon::before { content: ""; position: absolute; left: 0; top: -3px; width: 7px; height: 4px; border-radius: 2px 2px 0 0; background: currentColor; }
/* The chevron of a folder row: two borders of a small square, turned. */
.col-chevron { flex: 0 0 auto; width: 7px; height: 7px; margin: 0 3px 0 1px; border-top: 2px solid currentColor; border-right: 2px solid currentColor; transform: rotate(45deg); opacity: 0.6; }
.columns-preview { position: relative; flex: 1 1 320px; min-width: 320px; overflow-y: auto; padding: 14px; }
.columns-preview:focus { outline: none; }
.columns-hint { margin: 24px 8px; text-align: center; color: var(--mute); font-size: 14px; }
/* The preview is one Browse card at a large size: the thumbnail spans the pane above the text. */
.columns-preview .card { margin: 0; border: 0; padding: 0; background: transparent; }
.columns-preview .card.has-thumb { grid-template-columns: minmax(0, 1fr); }
.columns-preview .summary { font-size: 18px; }
#app.columns-shown #results { display: none; }

@media (max-width: 719px) {
  /* Phone (35.7): one column at a time, full width; the path line is the way back, and a selected
     recording's preview takes the whole width. */
  .columns { padding: 12px 16px 24px; }
  .columns-body { display: block; height: auto; }
  .columns-strip { display: block; overflow: visible; }
  .columns-col { width: 100%; height: clamp(320px, calc(100vh - 260px), 900px); border-right: 0; }
  .columns-col:not(.current) { display: none; }
  .col-row { min-height: 44px; }
  .columns-preview { min-width: 0; }
  .columns.has-preview .columns-strip { display: none; }
  .columns:not(.has-preview) .columns-preview { display: none; }
  .columns-path button { min-height: 44px; }
}

.notice { margin: 0 0 12px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); }
.notice.bad { color: var(--bad); border-color: var(--bad); }
.notice.warn { color: var(--warn); border-color: var(--warn); }
.empty { text-align: center; color: var(--mute); padding: 32px 8px; }
.loading { display: flex; align-items: center; gap: 10px; color: var(--mute); padding: 24px 4px; }
.spinner { width: 18px; height: 18px; border: 3px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation: none; } }

@media (min-width: 720px) {
  /* The header is not sticky here either: with the Categories panel it is taller than the screen. */
  .row { flex-direction: row; }
  .row input[type=search] { flex: 1 1 auto; }
  .row button { flex: 0 0 auto; }
  .filters { grid-template-columns: repeat(4, 1fr); align-items: end; }
  .actions button { flex: 0 0 auto; }
  .clip-row select { flex: 0 1 auto; }
  .clip-row button { flex: 0 0 auto; }
  .filters label.wide { grid-column: span 2; }
  .screens-list { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .details-edit > button { width: auto; }
  .details-form { grid-template-columns: max-content minmax(0, 1fr); column-gap: 12px; align-items: center; max-width: 640px; }
  .details-form label { margin-top: 0; }
  .details-form .hint { grid-column: 2; margin-top: -2px; }
  .details-form .details-buttons { grid-column: 1 / -1; }
  .details-buttons button { flex: 0 0 auto; }
  .segment-times { grid-template-columns: 1fr 1fr; }
  .segment-actions button { flex: 0 0 auto; }
  .segment-form { max-width: 720px; }
  .segment-region { grid-template-columns: minmax(0, 1fr) auto; gap: 2px 8px; align-items: end; }
  .segment-region label { grid-column: 1 / -1; }
  .tag-row { grid-template-columns: 260px minmax(0, 1fr); align-items: start; }
  .card.has-thumb { grid-template-columns: 240px minmax(0, 1fr); column-gap: 14px; align-items: start; }
  .tag-buttons button { flex: 0 0 auto; }
  .tag-more { width: auto; }
  .cat-client { max-width: 360px; }
  .browse-more { width: auto; margin: -48px 16px 64px; }
}

/* Wide screens: filters in a left sidebar, search and results in the main area. */
@media (min-width: 960px) {
  #app { display: grid; grid-template-columns: 300px minmax(0, 1fr); grid-template-rows: auto auto auto auto auto 1fr; align-items: start; min-height: 100vh; }
  .top, #search-form { display: contents; }
  .top-row { grid-column: 1 / -1; grid-row: 1; margin: 0; padding: 12px 16px; border-bottom: 1px solid var(--line); }
  #search-form > .row { grid-column: 2; grid-row: 2; padding: 16px 20px 0; max-width: 1000px; }
  .filters-box {
    grid-column: 1; grid-row: 2 / span 5; align-self: stretch; margin: 0; padding: 8px 16px 24px;
    border-right: 1px solid var(--line); background: var(--bg);
  }
  .filters-box > .filters { position: sticky; top: 8px; max-height: calc(100vh - 16px); overflow-y: auto; padding-right: 4px; }
  .filters-box > summary { list-style: none; pointer-events: none; font-weight: 600; padding: 0; }
  .filters-box > summary::-webkit-details-marker { display: none; }
  .filters { grid-template-columns: 1fr; align-items: stretch; }
  .filters label.wide { grid-column: auto; }
  .screens-list { grid-template-columns: 1fr; }
  .screens-list label.check { min-height: 32px; }
  .categories { grid-column: 2; grid-row: 3; margin: 0; padding: 12px 20px 0; max-width: 1000px; }
  .status { grid-column: 2; grid-row: 4; margin: 0; padding: 8px 20px 0; }
  main { grid-column: 2; grid-row: 5; margin: 0; padding: 12px 20px 64px; max-width: 1000px; width: 100%; box-sizing: border-box; }
  .browse-more { grid-column: 2; grid-row: 6; align-self: start; justify-self: start; margin: -48px 20px 64px; }
  .columns { grid-column: 2; grid-row: 5; padding: 12px 20px 24px; width: 100%; box-sizing: border-box; }
  .tag-view { grid-column: 1 / -1; grid-row: 2 / span 5; margin: 0; padding: 16px 20px 64px; max-width: 1200px; width: 100%; box-sizing: border-box; }
  .status-panel { grid-column: 1 / -1; grid-row: 2 / span 5; margin: 0; padding: 16px 20px 64px; max-width: 1200px; width: 100%; box-sizing: border-box; }
}
