:root {
  --bg: #fbfaf8;
  --panel: #ffffff;
  --ink: #1c1b19;
  --muted: #6b6862;
  --line: #e4e1db;
  --accent: #b4532a;
  --accent-soft: #fdf3ee;
  --ok: #2f6f4e;
  --bad: #a3302a;
  --warn: #9a6400;
  --radius: 12px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #171614;
    --panel: #201f1c;
    --ink: #f0ede8;
    --muted: #9b968d;
    --line: #322f2a;
    --accent: #e0794b;
    --accent-soft: #2a201b;
    --ok: #6fbf90;
    --bad: #e8837c;
    --warn: #e3b35c;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.55 ui-sans-serif, -apple-system, "Segoe UI", Roboto, sans-serif;
  display: flex;
  justify-content: center;
  padding: 3rem 1.25rem;
}

main { width: 100%; max-width: 560px; }
/* Inside the sidebar shell, main is a flex child: it keeps its reading
   width but is no longer the thing being centred by body. */
.shell main { max-width: 720px; padding: 1.75rem 1.5rem; }

h1 { font-size: 1.6rem; margin: 0 0 .35rem; letter-spacing: -.01em; }
.lede { color: var(--muted); margin: 0 0 2rem; }

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.5rem;
}

/* The old drop-box rules lived here. The box is gone: the list itself is
   the drop target now, and <main> must not inherit a dashed border or
   centred text. */
input[type=file] { display: none; }

/* The bare `button` and `progress` rules that lived here styled the single
   Transcribe submit button and its upload bar. Both are gone — the list is
   the drop target now — and as global element rules they were silently
   sizing every later button: the menu's collapse toggle inherited
   width:100%, squeezing the brand beside it to zero. Nothing on
   processing.html uses either element, so they are removed rather than
   scoped. */

.note { font-size: .85rem; color: var(--muted); margin-top: 1rem; }
.error { color: var(--bad); font-size: .9rem; margin-top: 1rem; min-height: 1.2em; }

/* --- processing page --- */
.stage { display: flex; align-items: center; gap: .7rem; padding: .45rem 0; color: var(--muted); }
.stage .dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--line); flex: 0 0 auto;
}
.stage.done { color: var(--ink); }
.stage.done .dot { background: var(--ok); }
.stage.active { color: var(--ink); font-weight: 600; }
.stage.active .dot { background: var(--accent); animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .25; } }

.downloads { display: grid; gap: .6rem; margin-top: 1.25rem; }
.downloads a {
  display: block; padding: .8rem 1rem;
  border: 1px solid var(--line); border-radius: 8px;
  color: var(--ink); text-decoration: none;
}
.downloads a:hover { border-color: var(--accent); background: var(--accent-soft); }
.downloads a span { display: block; font-size: .8rem; color: var(--muted); }

.banner { padding: .9rem 1rem; border-radius: 8px; margin-bottom: 1.25rem; font-size: .92rem; }
.banner.ok { background: var(--accent-soft); border: 1px solid var(--line); }
.banner.bad { background: var(--accent-soft); border: 1px solid var(--bad); color: var(--bad); }

/* ── three columns: menu | transcriptions | queue ──────────────────────── */
/* body centres a single narrow column, which is right for processing.html but
   fights a full-width layout. Scoped with :has() so that page is untouched. */
body:has(.shell) { display: block; padding: 0; }

.shell {
  display: grid;
  grid-template-columns: 15% 70% 15%;
  min-height: 100vh;
}
.shell.collapsed { grid-template-columns: 56px 1fr 18%; }

/* ── left: menu ────────────────────────────────────────────────────────── */
.rail {
  padding: 1.25rem .9rem; display: flex; flex-direction: column; gap: .6rem;
  border-right: 1px solid var(--line); background: var(--panel); min-width: 0;
}
.rail-top { display: flex; align-items: center; justify-content: space-between; gap: .4rem; }
.brand { font-weight: 700; font-size: .9rem; white-space: nowrap; overflow: hidden; }
.collapse {
  font: inherit; font-size: .9rem; line-height: 1; cursor: pointer; flex: 0 0 auto;
  background: none; border: 1px solid var(--line); border-radius: 6px;
  padding: .15rem .35rem; color: var(--muted);
}
.collapse:hover { border-color: var(--accent); color: var(--accent); }
.shell.collapsed .wide { display: none; }
.shell.collapsed .brand { display: none; }
.shell.collapsed .rail { padding: 1.25rem .5rem; align-items: center; }
.shell.collapsed .rail-top { justify-content: center; }
.narrow { display: none; }
.shell.collapsed .narrow { display: inline; }

.rail-label {
  display: block; font-size: .66rem; text-transform: uppercase; letter-spacing: .05em;
  color: var(--muted); font-weight: 600; margin: .7rem 0 .25rem;
}
.rail input[type="search"] {
  font: inherit; font-size: .8rem; width: 100%; padding: .35rem .5rem;
  border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--ink);
}
.primary {
  font: inherit; font-size: .82rem; font-weight: 600; cursor: pointer;
  background: var(--accent); color: #fff; border: 0; border-radius: 9px; padding: .5rem .65rem;
}
.primary:hover { filter: brightness(1.06); }
.record {
  font: inherit; font-size: .82rem; font-weight: 600; cursor: pointer; margin-top: .45rem;
  background: none; color: var(--bad); border: 1px solid var(--bad); border-radius: 9px; padding: .45rem .65rem;
}
.record:hover { background: var(--accent-soft); }
.record.on { background: var(--bad); color: #fff; }
.record:disabled { cursor: not-allowed; }
.record:disabled:not(.on) { opacity: .5; }
.record:disabled:not(.on):hover { background: none; }
/* Record Audio while the live console saves its copy: on, but stopped from the live window. */
.record.on:disabled { cursor: default; }
/* Recording on its own: Stop stays in reach above the sign-in overlay (z-index 40) that an
   expired session raises. The recording needs no session, and a reload would lose it. */
#record-audio.on:not(:disabled) { position: relative; z-index: 41; }
.record-link { display: block; margin-top: .35rem; font-size: .8rem; color: var(--bad); }
.record-audio { margin-top: .35rem; font-size: .8rem; }
.record-audio-level { display: block; width: 100%; height: .5rem; }
.record-audio-level[hidden] { display: none; }
.record-audio-message { margin: .25rem 0 0; color: var(--muted); overflow-wrap: anywhere; }
.record-audio-message:empty { display: none; }
.record-audio-again { color: var(--bad); }
.filters { display: flex; flex-direction: column; gap: .15rem; }
.filter {
  font: inherit; font-size: .8rem; text-align: left; cursor: pointer;
  background: none; border: 0; border-radius: 7px; padding: .3rem .45rem; color: var(--muted);
}
.filter:hover { background: var(--accent-soft); }
.filter.on { background: var(--accent-soft); color: var(--ink); font-weight: 600; }
/* The rail's selection block (.rail-actions/.count/.rail-btn) lived here.
   Deletion is per row now, so there is no selection and no bulk action.
   Removed rather than left behind: orphaned rules from removed UI have
   silently restyled their replacements three times in this project. */
.rail .note { font-size: .7rem; color: var(--muted); margin: .7rem 0 0; }

/* ── centre: the table, which is also the drop target ──────────────────── */
.shell main {
  min-width: 0; max-width: none; position: relative; overflow: auto;
  padding: 1.35rem 1.35rem 3rem;
}
.shell main h1 { font-size: 1.25rem; margin-bottom: .9rem; }
.dropveil { display: none; }
.shell main.over .dropveil {
  display: flex; align-items: center; justify-content: center;
  position: fixed; inset: 0 15% 0 15%; z-index: 2;
  border: 2px dashed var(--accent); border-radius: var(--radius);
  background: var(--accent-soft); pointer-events: none;
}
.dropveil span { font-weight: 700; color: var(--accent); }

.library-table { width: 100%; border-collapse: collapse; font-size: .82rem; table-layout: fixed; }
.library-table th {
  text-align: left; font-size: .66rem; text-transform: uppercase; letter-spacing: .04em;
  color: var(--muted); font-weight: 600; padding: .5rem .45rem;
  border-bottom: 1px solid var(--line);
}
.library-table td {
  padding: .55rem .45rem; border-bottom: 1px solid var(--line); vertical-align: top;
  overflow-wrap: anywhere;
}
.trashcol { width: 2.2rem; text-align: right; }
.trash {
  display: inline-flex; align-items: center; justify-content: center;
  width: 26px; height: 26px; padding: 0; cursor: pointer;
  background: none; border: 1px solid transparent; border-radius: 6px;
  color: var(--muted);
}
/* Kept quiet until the row is hovered: a destructive control should not be
   the loudest thing in a table you are reading. */
.library-table tr:hover .trash { color: var(--ink); border-color: var(--line); }
.trash:hover { color: var(--bad); border-color: var(--bad); background: var(--bg); }
.trash:focus-visible { color: var(--bad); border-color: var(--bad); outline: none; }
.whencell { width: 8.5rem; color: var(--muted); font-size: .76rem; white-space: nowrap; }
.desccell { color: var(--muted); }
.library-table strong { display: block; font-weight: 600; }
.library-table small { display: block; margin-top: .15rem; color: var(--muted); font-size: .7rem; }
.files { width: 14.5rem; }
.files a {
  display: inline-block; margin: 0 .3rem .25rem 0; padding: .1rem .35rem;
  font-size: .7rem; font-weight: 600; text-decoration: none;
  color: var(--accent); border: 1px solid var(--line); border-radius: 5px;
}
.files a:hover { border-color: var(--accent); background: var(--accent-soft); }
.empty { color: var(--muted); padding: 2.5rem 0; text-align: center; }

/* A batch and the recordings in it. The batch row is tinted and its members
   are indented behind a rule, so the nesting reads without a disclosure
   control — the centre column stays free of buttons. */
.library-table tr.batch td { background: var(--accent-soft); border-bottom-color: transparent; }
.library-table tr.batch .whencell { white-space: normal; }
.library-table tr.batch .whencell div { white-space: nowrap; }
.library-table tr.member td:nth-child(2) {
  padding-left: 1.1rem; box-shadow: inset 3px 0 0 var(--accent-soft);
}
.library-table tr.member strong { font-weight: 500; }

/* ── right: the queue console ──────────────────────────────────────────── */
.console {
  border-left: 1px solid var(--line); background: var(--panel);
  padding: 1.25rem .8rem; min-width: 0;
  display: flex; flex-direction: column; max-height: 100vh;
}
.console h2 {
  font-size: .66rem; text-transform: uppercase; letter-spacing: .05em;
  color: var(--muted); margin: 0 0 .6rem;
}
/* The list grows downward and scrolls; the job at the top is the one the
   worker is on, since the queue drains in order. */
.console-list { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1;
                display: flex; flex-direction: column; gap: .45rem; }
.console-item {
  border: 1px solid var(--line); border-radius: 8px; padding: .45rem .55rem;
  background: var(--bg);
}
.console-item.bad { border-color: var(--bad); }
.c-name {
  display: block; font-size: .73rem; font-weight: 600;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.c-stage { display: block; font-size: .68rem; color: var(--muted); margin: .15rem 0 .25rem; }
.console-item.bad .c-stage { color: var(--bad); }
.console-item progress { width: 100%; height: 4px; display: block; }
.console-idle { font-size: .72rem; color: var(--muted); }

/* A drop of several files: its files inside one frame, and a last line for the
   one step the batch has of its own. */
.console-group {
  border: 1px solid var(--line); border-radius: 8px; padding: .45rem .45rem .5rem;
  display: flex; flex-direction: column; gap: .4rem;
}
.console-group.bad { border-color: var(--bad); }
.console-group .console-list { overflow: visible; flex: none; }
.c-group {
  font-size: .66rem; text-transform: uppercase; letter-spacing: .05em;
  color: var(--muted); font-weight: 600;
}
.c-tail { margin: 0; }
.console-group.bad .c-tail { color: var(--bad); }

@media (max-width: 900px) {
  .shell, .shell.collapsed { grid-template-columns: 1fr; }
  .rail { border-right: 0; border-bottom: 1px solid var(--line); }
  .console { border-left: 0; border-top: 1px solid var(--line); max-height: 40vh; }
  .shell main.over .dropveil { inset: 0; }
}

/* ── sign-in ─────────────────────────────────────────────────────────── */
.signin {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  background: var(--bg);
}
.signin[hidden] { display: none; }
.signin-card {
  display: flex;
  flex-direction: column;
  gap: .5rem;
  min-width: min(22rem, 90vw);
  padding: 1.5rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
}
.signin-card h2 { margin: 0; }
.signin-note { margin: 0 0 .5rem; opacity: .7; font-size: .9rem; }
.signin-card label { font-size: .75rem; letter-spacing: .05em; text-transform: uppercase; opacity: .7; }
.signin-card input { padding: .5rem; border: 1px solid var(--line); border-radius: .25rem;
                     background: var(--bg); color: inherit; }
.signin-error { min-height: 1.2em; margin: .25rem 0 0; color: var(--bad); font-size: .9rem; }
.signin-card button { margin-top: .5rem; }
.signed-in { margin-top: auto; }
.who { display: block; font-size: .9rem; margin-bottom: .25rem; }
.linkish { background: none; border: 0; padding: 0; color: inherit; opacity: .7;
           text-decoration: underline; cursor: pointer; font: inherit; }

/* ── Live console window (live.html) ─────────────────────────────────────
   Its own window: full width, large type, a bar that stays on top. The
   `.console` class already names the main page's Queue sidebar, hence .live-*. */
body:has(.live) { display: block; padding: 0; }
.live { max-width: none; min-height: 100vh; display: flex; flex-direction: column; }
.live-bar {
  position: sticky; top: 0; z-index: 1; display: flex; align-items: center; flex-wrap: wrap;
  gap: .6rem .9rem; padding: .7rem 1rem; background: var(--panel); border-bottom: 1px solid var(--line);
}
.rec-dot { width: .8rem; height: .8rem; border-radius: 50%; background: var(--line); flex: 0 0 auto; }
.rec-dot.on { background: var(--bad); animation: pulse 1.2s infinite; }
.rec-dot.warn { background: var(--warn); animation: pulse 1.2s infinite; }
.live-clock { font-variant-numeric: tabular-nums; font-weight: 600; }
.live-level { width: 5.5rem; }
.live-state { flex: 1 1 10rem; min-width: 0; color: var(--muted); font-size: .9rem; }
.live-state.warn { color: var(--warn); }
.live-stop { margin-left: auto; font-size: .95rem; padding: .45rem 1.1rem; }
.live-notice { flex: 1 1 100%; margin: 0; color: var(--warn); font-size: .9rem; }
.live-text {
  flex: 1 1 auto; width: 100%; max-width: 60rem; margin: 0 auto; padding: 1.25rem 1rem 4rem;
  font-size: clamp(1.2rem, 2.4vw, 2.1rem); line-height: 1.45; overflow-wrap: anywhere;
}
.live-text p { margin: 0 0 .55em; }
.live-text .partial { color: var(--muted); }
.live-text .gap { color: var(--muted); letter-spacing: .3em; }
.live-hint { color: var(--muted); font-size: 1rem; }
.live-start, .live-done {
  position: fixed; inset: 0; display: grid; place-items: center; padding: 1rem;
  background: color-mix(in srgb, var(--bg) 90%, transparent); text-align: center;
}
.live-start[hidden], .live-done[hidden] { display: none; }
.live-start-button { font-size: 1.2rem; padding: .9rem 1.6rem; }
.live-done p { font-size: 1.1rem; max-width: 36rem; margin: 0 auto 1rem; }
.live-done .live-local { font-size: .95rem; color: var(--muted); overflow-wrap: anywhere; }
.live-done-actions { display: flex; gap: .75rem; justify-content: center; align-items: center; }
