/* timbral.ai's design: paper and ink, Neue Haas Grotesk Display, hairlines, small letter-spaced labels.
   The webfont files are the site's (Commercial Type licence 2606-MHTPQJ); without them the page falls back to
   Helvetica Neue. */
@font-face { font-family: 'Neue Haas Grotesk Display'; src: url('fonts/NeueHaasGroteskDisplay-55Roman-Web.woff2') format('woff2'); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: 'Neue Haas Grotesk Display'; src: url('fonts/NeueHaasGroteskDisplay-45Light-Web.woff2') format('woff2'); font-weight: 300; font-style: normal; font-display: swap; }
@font-face { font-family: 'Neue Haas Grotesk Display'; src: url('fonts/NeueHaasGroteskDisplay-65Medium-Web.woff2') format('woff2'); font-weight: 500; font-style: normal; font-display: swap; }
:root {
  --bg: #FFFFFF;        /* paper */
  --bg2: #FFFFFF;
  --panel: #FFFFFF;
  --panel2: #F6F6F6;    /* a quiet fill for notes */
  --line: #E8E8E8;      /* the site's hairline */
  --line2: #EFEFEF;
  --line3: #D2D2D2;     /* field borders */
  --text: #0A0A0A;      /* ink */
  --text2: #555555;
  --text3: #8A8A8A;     /* the site's quiet grey */
  --amber: #0A0A0A;     /* the accent is ink, as on the site (the name stays for the rules that use it) */
  --amber-ink: #FFFFFF;
  --red: #C0392B;
  --green: #2E7D4F;
  --warn: #8A6100;
  --hover: #F3F3F3;
  --pressed: #EDEDED;
  --head-w: 260px;
  --brand: 'Neue Haas Grotesk Display', 'Helvetica Neue', Helvetica, Arial, sans-serif;
  --mono: ui-monospace, 'SF Mono', 'Roboto Mono', Menlo, Consolas, monospace;
  color-scheme: light;
  --surface: #FFFFFF;   /* buttons, fields, panels */
  --kbd-bg: #FAFAFA;
  --accent-fg: #FFFFFF; /* text on ink */
  --accent-hover: #2B2B2B;
  --on-accent-dim: rgba(255,255,255,.75);
  --on-accent-line: rgba(255,255,255,.35);
  --ring: rgba(10,10,10,.3);
  --spec-bg: #FFFFFF;
  --lane-sel: rgba(10,10,10,.035);
  --marker-line: rgba(10,10,10,.45);
  --veil: rgba(255,255,255,.72);
  --shadow: rgba(0,0,0,.12);
  --shadow-strong: rgba(0,0,0,.14);
  --body: #333333;
  --mark-bg: #FFF1BF;
  --chip-busy-line: #E3CE96;
  --chip-ok-line: #B7DCC4;
  --chip-err-line: #EBBDB7;
}
/* Dark, the default: the site's black pages, white type and white hairlines. Light is for someone who picks it with
   the header's switch (then <html data-theme="light">). */
:root:not([data-theme="light"]) {
    --bg: #000000;
    --bg2: #000000;
    --panel: #0A0A0A;
    --panel2: #141414;
    --surface: #0A0A0A;
    --line: rgba(255,255,255,.14);
    --line2: rgba(255,255,255,.10);
    --line3: rgba(255,255,255,.24);
    --text: #FFFFFF;
    --text2: rgba(255,255,255,.72);
    --text3: rgba(255,255,255,.5);
    --amber: #FFFFFF;
    --amber-ink: #000000;
    --red: #FF7A6B;
    --green: #6CCB94;
    --warn: #E8C877;
    --hover: rgba(255,255,255,.06);
    --pressed: rgba(255,255,255,.12);
    --kbd-bg: #111111;
    --accent-fg: #000000;
    --accent-hover: #E6E6E6;
    --on-accent-dim: rgba(0,0,0,.65);
    --on-accent-line: rgba(0,0,0,.3);
    --ring: rgba(255,255,255,.32);
    --spec-bg: #000000;
    --lane-sel: rgba(255,255,255,.05);
    --marker-line: rgba(255,255,255,.45);
    --veil: rgba(0,0,0,.62);
    --shadow: rgba(0,0,0,.6);
    --shadow-strong: rgba(0,0,0,.7);
    --body: rgba(255,255,255,.82);
    --mark-bg: #5A4416;
    --chip-busy-line: #6B5320;
    --chip-ok-line: #2E5A40;
    --chip-err-line: #6B2E28;
    color-scheme: dark;
}
:root[data-theme="dark"] {
  --bg: #000000;
  --bg2: #000000;
  --panel: #0A0A0A;
  --panel2: #141414;
  --surface: #0A0A0A;
  --line: rgba(255,255,255,.14);
  --line2: rgba(255,255,255,.10);
  --line3: rgba(255,255,255,.24);
  --text: #FFFFFF;
  --text2: rgba(255,255,255,.72);
  --text3: rgba(255,255,255,.5);
  --amber: #FFFFFF;
  --amber-ink: #000000;
  --red: #FF7A6B;
  --green: #6CCB94;
  --warn: #E8C877;
  --hover: rgba(255,255,255,.06);
  --pressed: rgba(255,255,255,.12);
  --kbd-bg: #111111;
  --accent-fg: #000000;
  --accent-hover: #E6E6E6;
  --on-accent-dim: rgba(0,0,0,.65);
  --on-accent-line: rgba(0,0,0,.3);
  --ring: rgba(255,255,255,.32);
  --spec-bg: #000000;
  --lane-sel: rgba(255,255,255,.05);
  --marker-line: rgba(255,255,255,.45);
  --veil: rgba(0,0,0,.62);
  --shadow: rgba(0,0,0,.6);
  --shadow-strong: rgba(0,0,0,.7);
  --body: rgba(255,255,255,.82);
  --mark-bg: #5A4416;
  --chip-busy-line: #6B5320;
  --chip-ok-line: #2E5A40;
  --chip-err-line: #6B2E28;
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }  /* also over .btn's inline-flex */
html, body { margin: 0; }
/* An app-height page: the header, toolbar and key hints stay in view, and the lanes and the side column
   scroll on their own, so a long list of sources never pushes the spectrogram or the card away. */
body {
  background: var(--bg); color: var(--text);
  font: 14px/1.45 var(--brand); -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
  display: flex; flex-direction: column; height: 100vh; overflow: hidden;
}
#topbar, #toolbar, #hints { flex: none; }
button, input, select, textarea { font: inherit; color: inherit; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--text2); }
.small { font-size: 12px; }
.mono { font-family: var(--mono); }
.big { font-size: 15px; }
.spacer { flex: 1; }
kbd {
  font-family: var(--mono); font-size: 10.5px; color: var(--text3);
  border: 1px solid var(--line3); border-radius: 4px; padding: 0 4px; background: var(--kbd-bg);
}
.btn {
  height: 32px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line3);
  background: var(--surface); color: var(--text); display: inline-flex; align-items: center; gap: 7px;
  cursor: pointer; white-space: nowrap; font-size: 13px; transition: border-color .15s, background .15s;
}
.btn:hover { border-color: var(--text); }
.btn[aria-pressed="true"] { background: var(--pressed); border-color: var(--text); }
/* Toggles that are on (Flag, Loop, Background, Unsure, Off screen) turn to ink. Snap says on or off in words. */
.btn[aria-pressed="true"]:not(#snapBtn) { background: var(--text); border-color: var(--text); color: var(--accent-fg); }
.btn[aria-pressed="true"]:not(#snapBtn) kbd { background: transparent; color: var(--on-accent-dim); border-color: var(--on-accent-line); }
.btn.sm { height: 26px; min-width: 26px; padding: 0 10px; justify-content: center; font-size: 12px; }
.btn:disabled { opacity: 0.4; cursor: default; background: transparent; }
.del {
  flex: none; width: 24px; height: 24px; margin-left: 6px; border-radius: 6px; border: 1px solid var(--line3);
  background: transparent; color: var(--text3); font-size: 16px; line-height: 1; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
}
.del:hover { color: var(--red); border-color: var(--red); background: rgba(255,107,94,0.08); }
.zctl { display: inline-flex; align-items: center; gap: 6px; }
.zctl[hidden] { display: none; }
#draftZVal { min-width: 34px; text-align: center; color: var(--text); }
.btn.primary { background: var(--text); color: var(--accent-fg); border: 1px solid var(--text); font-weight: 500; height: 36px; padding: 0 18px; letter-spacing: .01em; }
.btn.primary:hover { background: var(--accent-hover); }
.btn.primary kbd { color: var(--on-accent-dim); background: transparent; border-color: var(--on-accent-line); }
.btn.icon { width: 32px; padding: 0; justify-content: center; }
.btn.dashed { border-style: dashed; color: var(--text2); }
.chip { font-size: 12px; color: var(--text2); border: 1px solid var(--line3); border-radius: 4px; padding: 1px 8px; white-space: nowrap; }
.chip.busy { color: var(--warn); border-color: var(--chip-busy-line); }
.chip.ok { color: var(--green); border-color: var(--chip-ok-line); }
.chip.err { color: var(--red); border-color: var(--chip-err-line); }

#topbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px;
  padding: 12px 24px; border-bottom: 1px solid var(--line); background: var(--bg);
}
/* The site's wordmark: TIMBRAL in medium caps, widely spaced; the tool's name in its small quiet caps. */
.brand { display: flex; align-items: baseline; gap: 12px; margin-right: 6px; }
.wordmark { font-size: 13px; font-weight: 500; letter-spacing: .34em; }
.brand-name { font-size: 10.5px; letter-spacing: .22em; text-transform: uppercase; color: var(--text3); }
@media (max-width: 1200px) { .brand-name { display: none; } }
/* Below 1440 px the buttons drop their key hints (the footer and the ? sheet still list them), so the
   header and the toolbar stay one row each down to 1280 px, also with Windows key names. */
@media (max-width: 1440px) { #toolbar .btn kbd, #flagBtn kbd, #skipBtn kbd { display: none; } }
/* The clip list: its own chevron, set in from the edge like the text. */
.clip-pick select {
  height: 32px; max-width: 260px; border: 1px solid var(--line3); border-radius: 8px;
  padding: 0 34px 0 12px; font-family: var(--mono); font-size: 12px; color: var(--text); cursor: pointer;
  -webkit-appearance: none; appearance: none;
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%238A8A8A' stroke-width='1.4' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat right 13px center;
}
.clip-pick select:hover { border-color: var(--text); }
.progress { display: flex; align-items: center; gap: 10px; flex: 1 1 140px; min-width: 120px; }
.save-state { font-size: 12px; color: var(--text3); white-space: nowrap; }
.save-state.saved::before { content: "✓ "; color: var(--green); }
.save-state.pending, .save-state.saving { color: var(--text2); }
.save-state.error { color: var(--amber); font-weight: 600; }
.save-state.off, .save-state.login { color: var(--red); font-weight: 600; }
.progress .bar { flex: 1; height: 2px; background: var(--line); overflow: hidden; }
#progressFill { height: 2px; width: 0; background: var(--text); }
#progressText, #timer { font-size: 12px; }

#toolbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px 12px;
  padding: 10px 16px; border-bottom: 1px solid var(--line);
}
/* The site's play control: a thin-ringed circle with a line icon. */
.round {
  width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--ring); background: var(--surface); color: var(--text);
  display: inline-flex; align-items: center; justify-content: center; cursor: pointer; transition: border-color .2s;
}
.round:hover { border-color: var(--text); }
.seg { display: inline-flex; border: 1px solid var(--line3); border-radius: 6px; overflow: hidden; }
.seg button { height: 30px; padding: 0 9px; border: none; background: transparent; color: var(--text2); cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--pressed); color: var(--text); font-weight: 500; }

#main { display: flex; flex: 1 1 auto; min-height: 0; }
#timelineWrap { flex: 1 1 auto; min-width: 0; border-right: 1px solid var(--line); overflow-y: auto; overscroll-behavior: contain; }
/* The video sits at the top of the side column, so on a laptop it doesn't push the lanes off screen. */
#videoPanel { position: sticky; top: -16px; z-index: 3; margin: -16px -16px 0; padding: 16px 16px 0; background: var(--panel2); }
#videoPanel video { width: 100%; max-height: min(260px, 26vh); border-radius: 8px; background: #000; display: block; }
#timeline { position: relative; user-select: none; }
/* The ruler and the spectrogram stay at the top while the lanes scroll under them. */
.ruler-row, .spec-row { position: sticky; z-index: 4; background: var(--bg); }
.ruler-row { top: 0; }
.spec-row { top: 30px; }
.row { display: grid; grid-template-columns: var(--head-w) minmax(0, 1fr); border-bottom: 1px solid var(--line2); }
.row .head { padding: 8px 14px; min-width: 0; position: relative; }
.row .track { position: relative; min-width: 0; }
.ruler-row { height: 30px; }
.ruler-row .head { display: flex; align-items: center; gap: 6px; padding-top: 0; padding-bottom: 0; font-size: 12px; }
#ruler { height: 30px; overflow: hidden; cursor: pointer; }
.tick { position: absolute; top: 0; bottom: 0; border-left: 1px solid var(--line); padding-left: 4px; font-family: var(--mono); font-size: 11px; color: var(--text3); line-height: 30px; white-space: nowrap; }
.marker-pill { position: absolute; top: 6px; margin-left: -9px; background: var(--amber); color: var(--amber-ink); font-size: 11px; font-weight: 700; border-radius: 4px; padding: 0 5px; line-height: 18px; cursor: pointer; }
.marker-pill.sel { outline: 2px solid var(--text); outline-offset: 1px; }
.spec-row .head { height: 168px; }
.freqs { position: absolute; right: 8px; top: 0; bottom: 0; width: 40px; font-family: var(--mono); font-size: 11px; color: var(--text3); text-align: right; }
.freqs div { position: absolute; right: 0; transform: translateY(-50%); }
#specTrack { height: 168px; background: var(--spec-bg); cursor: crosshair; }
#specCanvas { width: 100%; height: 168px; display: block; image-rendering: auto; }
#specOverlay { position: absolute; inset: 0; pointer-events: none; }
.spec-hl { position: absolute; top: 0; bottom: 0; }

.lane { display: grid; grid-template-columns: var(--head-w) minmax(0, 1fr); border-bottom: 1px solid var(--line2); scroll-margin-top: 204px; scroll-margin-bottom: 8px; }
.lane.sel { background: var(--lane-sel); }
.lane .head { display: flex; align-items: center; gap: 10px; padding: 8px 10px 8px 14px; min-width: 0; cursor: pointer; }
.num {
  flex: none; width: 24px; height: 24px; border-radius: 6px; border: 1.5px solid var(--c);
  color: var(--c); font-family: var(--mono); font-size: 12px; font-weight: 600;
  display: inline-flex; align-items: center; justify-content: center;
}
.num.hold { background: var(--red); border-color: var(--red); color: #fff; }
.lane .txt { min-width: 0; flex: 1; }
.lane .cap { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lane .cap i { color: var(--text3); font-weight: 400; }
/* A caption being edited in its lane name: same line height, text where the name was */
.lane .cap-edit {
  display: block; width: calc(100% + 7px); height: 22px; margin: -2px 0 -2px -7px; padding: 0 6px;
  font-weight: 500; background: var(--surface); border: 1px solid var(--text); border-radius: 5px; outline: none; cursor: text;
}
.lane .meta { display: flex; align-items: center; gap: 6px; margin-top: 3px; font-size: 11px; white-space: nowrap; overflow: hidden; }
.label-chip { border: 1px solid var(--line3); border-radius: 4px; padding: 0 5px; color: var(--text2); max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.label-chip.missing { border-color: var(--warn); color: var(--warn); }
.label-chip.own { border-style: dashed; }  /* at least one label in the annotator's own words, not from the list */
.origin { color: var(--text2); }
.origin.review { color: var(--amber); }
.origin.human { color: var(--green); }
.attr { color: var(--text3); border: 1px solid var(--line3); border-radius: 3px; padding: 0 3px; }
.lane .track { position: relative; min-width: 0; height: 60px; cursor: crosshair; overflow: hidden; }
@media (max-width: 900px) { :root { --head-w: 170px; } .lane .head { gap: 6px; padding-left: 8px; } }
.curve { position: absolute; left: 0; top: 6px; width: 100%; height: 48px; pointer-events: none; overflow: visible; }
.span {
  position: absolute; top: 20px; height: 26px; border-radius: 5px; cursor: pointer;
  background: rgba(var(--rgb), 0.30); border: 1.5px solid var(--c);
}
.span[data-span] { cursor: grab; }
body.moving, body.moving * { cursor: grabbing !important; }
.span.draft { background: rgba(var(--rgb), 0.10); border-style: dashed; }
.span.sel { outline: 2px solid var(--amber); outline-offset: 2px; }
.span.live { background: rgba(255,107,94,0.22); border-color: var(--red); border-style: solid; }
.span .edge { position: absolute; top: -6px; bottom: -6px; width: 9px; cursor: ew-resize; }
.span .edge.l { left: -5px; }
.span .edge.r { right: -5px; }
.span.sel .edge::after { content: ""; position: absolute; top: 0; bottom: 0; left: 2px; width: 5px; border-radius: 2px; background: var(--amber); }
.span.sel .edge.active::after { background: var(--red); }
.span-time { position: absolute; top: -19px; font-family: var(--mono); font-size: 11px; color: var(--amber); white-space: nowrap; pointer-events: none; }
.span-time.r { right: 0; }
.span-time.l { left: 0; }
.add-row .head { padding: 8px 14px; }
.add-row .hint { display: flex; align-items: center; padding: 0 12px; color: var(--text3); font-size: 12px; }
#playhead { position: absolute; top: 0; bottom: 0; width: 1.5px; margin-left: -1px; background: var(--text); pointer-events: none; z-index: 5; }
#markerLines { position: absolute; inset: 0; pointer-events: none; z-index: 4; }
.marker-line { position: absolute; top: 30px; bottom: 0; border-left: 1px dashed var(--marker-line); }

#side { flex: 0 0 320px; min-width: 0; padding: 16px; display: flex; flex-direction: column; gap: 14px; background: var(--panel2); overflow-y: auto; overscroll-behavior: contain; }
body.has-video #side { flex-basis: 384px; }
/* Narrow or very short windows: the page scrolls as a whole instead. */
@media (max-width: 900px), (max-height: 480px) {
  body { height: auto; min-height: 100vh; overflow: visible; }
  #main { flex-wrap: wrap; }
  #timelineWrap, #side { overflow: visible; }
  #timelineWrap { flex: 1 1 100%; }
  #side, body.has-video #side { flex: 1 1 100%; }
  #videoPanel { position: static; }
}
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 14px; }
.card h2 { margin: 0; font-size: 14px; font-weight: 600; }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.hint { margin-top: 10px; color: var(--text3); font-size: 12px; }
/* Short windows give the list less height, so the selected source's card (and its Keep) stays in view. */
#reviewList { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; max-height: min(330px, 32vh); overflow: auto; }
.rv {
  width: 100%; text-align: left; display: flex; gap: 10px; align-items: flex-start; padding: 8px 10px;
  border-radius: 8px; border: 1px solid var(--line); background: var(--surface); cursor: pointer;
}
.rv.now { border-color: var(--text); background: var(--panel2); }
.rv .t { display: block; font-weight: 500; }
.rv .w { display: block; color: var(--text2); font-size: 12px; margin-top: 1px; }
.rv .c { margin-left: auto; font-family: var(--mono); font-size: 12px; color: var(--text2); }
.rv .c.low { color: var(--amber); }
.empty { color: var(--text3); font-size: 12px; padding: 6px 2px; }

#detailCard label.f { display: block; margin-top: 12px; color: var(--text2); font-size: 12px; }
#detailCard input[type=text] {
  display: block; width: 100%; height: 40px; margin-top: 4px; background: var(--surface);
  border: 1px solid var(--line3); border-radius: 8px; padding: 0 12px; font-size: 15px;
}
#detailCard input[type=text]:focus { border-color: var(--text); outline: none; }
/* Labels box and its suggestions */
.ac-wrap { position: relative; }
.ac-list {
  position: absolute; left: 0; right: 0; top: 100%; z-index: 20; list-style: none; margin: 4px 0 0; padding: 4px;
  background: var(--surface); border: 1px solid var(--line3); border-radius: 8px; box-shadow: 0 12px 32px var(--shadow);
  max-height: 280px; overflow-y: auto;
}
/* Opens upward when there isn't room below it in the side column. */
.ac-list.up { top: auto; bottom: 100%; margin: 0 0 4px; }
.ac-list li { display: flex; align-items: baseline; gap: 8px; padding: 5px 8px; border-radius: 6px; cursor: pointer; min-width: 0; }
.ac-list li:hover { background: var(--hover); }
.ac-list li.hi { background: var(--pressed); }
.ac-list .nm { font-weight: 500; white-space: nowrap; }
.ac-list .pth { color: var(--text3); font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lbl-foot { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-top: 4px; }
.lbl-note { color: var(--text3); font-size: 11px; }
.ac-toggle { display: inline-flex; align-items: center; gap: 5px; flex: none; color: var(--text2); font-size: 12px; cursor: pointer; }
.ac-toggle input { margin: 0; accent-color: var(--text); }
.alts { margin-top: 8px; display: flex; flex-wrap: wrap; gap: 6px; }
.alt { font-size: 11px; color: var(--text2); border: 1px dashed var(--line3); border-radius: 4px; padding: 1px 6px; background: transparent; cursor: pointer; }
.attrs { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.attrs .btn { height: 30px; font-size: 12px; }
table.spans { width: 100%; margin-top: 12px; border-collapse: collapse; font-size: 12px; }
table.spans th { color: var(--text3); font-weight: 500; text-align: left; padding: 4px 0; }
table.spans td { font-family: var(--mono); padding: 5px 0; border-top: 1px solid var(--line); cursor: pointer; }
table.spans tr.sel td { color: var(--amber); }
.hist { margin: 10px 0 0; color: var(--text2); font-size: 12px; }
#detailCard .card-head h2 { white-space: nowrap; }
/* Under the card's title: where the source came from, and for a draft the Keep button, above the fold. */
.det-status { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.det-status .btn { height: 28px; font-size: 12px; }
#draftStatus { display: inline-block; margin-top: 8px; white-space: normal; }
#draftStatus[hidden] { display: none; }
.clip-note { margin-top: 10px; padding: 10px 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel2); font-size: 13px; color: var(--text2); display: flex; flex-direction: column; gap: 8px; }
.clip-note > div { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.clip-note .bad { color: var(--red); font-weight: 500; }
/* A video clip on a short window: a smaller video and a shorter review list leave the card's Keep in view. */
body.has-video #reviewList { max-height: min(330px, 18vh); }
.dialog-card.guide-card { width: min(580px, 94vw); }  /* wider than .dialog-card, which comes later */
.guide-steps { margin: 16px 0 0; padding-left: 22px; display: flex; flex-direction: column; gap: 12px; color: var(--text2); line-height: 1.5; }
.guide-steps b { color: var(--text); font-weight: 500; }
.guide-steps kbd, #guideFoot kbd { white-space: nowrap; }
#guideFoot { margin: 14px 0 0; }

#hints {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 18px; padding: 10px 20px;
  border-top: 1px solid var(--line); color: var(--text3); font-size: 12px; background: var(--bg);
}
#hints span { display: inline-flex; align-items: center; gap: 6px; }
#hints kbd { color: var(--text); }

/* Scrolls when a sheet is taller than the window (the keys sheet on a laptop). */
.modal-wrap { position: fixed; inset: 0; background: var(--veil); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); display: flex; align-items: flex-start; justify-content: center; padding: 8vh 16px 4vh; overflow-y: auto; z-index: 50; }
.modal-wrap[hidden] { display: none; }
mark { background: var(--mark-bg); color: var(--text); border-radius: 3px; padding: 0 1px; }

/* Login and skip dialogs */
.login-wrap { background: var(--bg); align-items: center; padding-top: 0; }
.dialog-card { width: min(420px, 92vw); background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 24px 26px; box-shadow: 0 24px 64px var(--shadow); }
.dialog-card h2 { margin: 0 0 6px; font-size: 22px; font-weight: 300; letter-spacing: -.005em; }
.dialog-card label.f { display: block; margin-top: 12px; color: var(--text2); font-size: 12px; }
.dialog-card input {
  display: block; width: 100%; height: 40px; margin-top: 4px; background: var(--surface);
  border: 1px solid var(--line3); border-radius: 8px; padding: 0 12px; color: var(--text); font-size: 15px;
}
.dialog-card input:focus { border-color: var(--text); outline: none; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.login-err { min-height: 1em; margin: 8px 0 0; color: var(--red); }
.login-msg { margin: 8px 0 0; color: var(--warn); }
.login-msg:empty { display: none; }

.keys-card { width: min(1120px, 94vw); background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 24px 28px; box-shadow: 0 24px 64px var(--shadow); }
.keys-card h2 { font-size: 22px; font-weight: 300; margin: 0; }
.keys-card .card-head { align-items: center; }
.keys-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 22px; margin-top: 20px; }
.keys-grid h3 { margin: 0 0 4px; font-size: 11px; font-weight: 500; letter-spacing: .2em; text-transform: uppercase; }
.keys-grid .when { color: var(--text3); font-size: 12px; margin-bottom: 10px; }
.keys-grid ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 7px; }
.keys-grid li { display: grid; grid-template-columns: 96px minmax(0,1fr); gap: 10px; align-items: baseline; }
.keys-grid li kbd { justify-self: start; color: var(--text); }
.keys-grid li span { color: var(--text2); }

#toast {
  position: fixed; left: 50%; bottom: 64px; transform: translateX(-50%); z-index: 60;
  background: var(--text); border: 1px solid var(--text); color: var(--accent-fg); border-radius: 999px;
  padding: 9px 18px; font-size: 13px; opacity: 0; transition: opacity 0.15s; pointer-events: none; max-width: 80vw;
}
#toast.show { opacity: 1; }
#toast.warn { background: var(--surface); color: var(--text); border-color: var(--text); font-weight: 500; }

/* Who is logged in */
.who-wrap { display: inline-flex; align-items: center; gap: 8px; min-width: 0; }
#who { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 260px; }
@media (max-width: 1500px) { #who { max-width: 180px; } }

#guideFoot .btn { margin: 6px 0 2px; }

/* ---------- Caption mode (a clip set with "spans": false): one sound per clip, described in words ----------
   One centred column: the player (controls, time ruler, spectrogram) above the form (caption, tags, second caption,
   submit), two panels of one width on one left edge. The header carries the clip, its progress and its actions, with
   the primary action at its right end; the walkthrough's card sits in the margin to the right of the column. */
body.caption-mode #toolbar, body.caption-mode #timelineWrap, body.caption-mode #reviewCard,
body.caption-mode #lanes, body.caption-mode .add-row, body.caption-mode #markerLines,
body.caption-mode #specOverlay, body.caption-mode #timeline .row .head { display: none !important; }
body.caption-mode:not(.has-video) #side { display: none; }
.describe { flex: 1 1 auto; min-width: 0; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
.describe-body { max-width: 768px; margin: 0 auto; padding: 22px 24px 40px; display: flex; flex-direction: column; gap: 14px; }
.describe .clip-note { margin: 0; }
.player { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.player-bar { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.player-bar .round { width: 40px; height: 40px; border-radius: 20px; flex: none; }
.player-bar #timeText { margin-right: auto; color: var(--text); font-size: 14px; }
body.caption-mode #timeline { --head-w: 0px; }
body.caption-mode #timeline .row { grid-template-columns: minmax(0, 1fr); }  /* the track alone, its label column gone */
body.caption-mode .ruler-row, body.caption-mode .spec-row { position: static; }
body.caption-mode .ruler-row, body.caption-mode #ruler { height: 26px; }
body.caption-mode .tick { line-height: 26px; }
body.caption-mode .spec-row { border-bottom: 0; }
body.caption-mode #specTrack, body.caption-mode #specCanvas { height: 156px; }
body.caption-mode #detailCard { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 22px 26px 24px; }
.d-field { margin-top: 22px; }
.d-field:first-child { margin-top: 0; }
/* Field labels in the site's small letter-spaced caps. */
.d-label { display: flex; align-items: center; gap: 10px; font-size: 11px; font-weight: 500; letter-spacing: .2em; text-transform: uppercase; color: var(--text); }
.d-label .muted { letter-spacing: .04em; text-transform: none; font-size: 12px; font-weight: 400; color: var(--text3); }
.d-label.d-sub { margin-top: 18px; }
.d-label kbd { margin-left: 2px; }
.d-step { color: var(--text3); font-weight: 400; letter-spacing: .12em; }
.d-hint { margin: 6px 0 10px; color: var(--text2); font-size: 13.5px; line-height: 1.45; }
.d-row .d-hint { margin: 0; }
.d-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
#detailCard textarea { display: block; width: 100%; box-sizing: border-box; min-height: 64px; padding: 10px 12px; resize: vertical;
  font: inherit; font-size: 16px; line-height: 1.45; color: var(--text); background: var(--surface); border: 1px solid var(--line3); border-radius: 8px; }
#detailCard textarea:focus { border-color: var(--text); outline: none; }
#detailCard textarea[readonly], #detailCard input[readonly] { color: var(--text); background: var(--panel2); border-color: var(--line); }
body.caption-mode #detLabels { font-size: 15px; padding-top: 9px; padding-bottom: 9px; }
.d-actions { margin-top: 24px; padding-top: 18px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; }
.clip-note .ex-note { flex-basis: 100%; padding: 2px 0 2px 12px; border-left: 2px solid var(--text); color: var(--text); }
.clip-note .ex-tag { font-size: 10.5px; font-weight: 500; letter-spacing: .2em; text-transform: uppercase; color: var(--text); }
/* Until the clip list says which kind of set this is, the main area stays blank rather than flash the other layout. */
body.booting #main { visibility: hidden; }
/* The header in caption mode: one row at any laptop width, the primary action always at its right end. */
body.caption-mode #topbar { flex-wrap: nowrap; gap: 12px; }
body.caption-mode #topbar .progress { flex: 1 1 auto; min-width: 60px; }
body.caption-mode #topbar .btn { flex: none; }
@media (max-width: 1440px) { body.caption-mode #guideBtn kbd, body.caption-mode #keysBtn kbd { display: none; } }
#progressText, #timer { white-space: nowrap; }
@media (max-width: 1500px) { body.caption-mode #who { display: none; } }
@media (max-width: 1440px) { body.caption-mode #timer { display: none; } }
@media (max-width: 1100px) { body.caption-mode #progressText { display: none; } }

/* The walkthrough: a lit part of the page and a card saying what it is for. */
/* The lit part keeps its colour; the rest of the page fades to paper behind a white veil. */
/* It glides from one part to the next on the site's easing curve. */
#coachRing { position: fixed; z-index: 45; border-radius: 12px; pointer-events: none;
  box-shadow: 0 0 0 1.5px var(--text), 0 0 0 9999px var(--veil);
  transition: left .28s cubic-bezier(.2,.7,.2,1), top .28s cubic-bezier(.2,.7,.2,1), width .28s cubic-bezier(.2,.7,.2,1), height .28s cubic-bezier(.2,.7,.2,1); }
.coach { position: fixed; z-index: 46; width: min(256px, 92vw); padding: 18px 18px 16px; background: var(--surface);
  border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 18px 48px var(--shadow-strong);
  transition: top .28s cubic-bezier(.2,.7,.2,1), left .28s cubic-bezier(.2,.7,.2,1); }
/* The veil fades in when the walkthrough starts, the card rises in, and each new step's words fade in. */
#coachRing:not([hidden]) { animation: coach-fade .3s ease-out; }
.coach:not([hidden]) { animation: coach-rise .26s cubic-bezier(.2,.7,.2,1); }
.coach.swap .coach-step, .coach.swap h3, .coach.swap p { animation: coach-fade .24s ease-out; }
@keyframes coach-fade { from { opacity: 0; } }
@keyframes coach-rise { from { opacity: 0; transform: translateY(6px); } }
.coach-step { color: var(--text3); font-size: 10.5px; letter-spacing: .2em; text-transform: uppercase; }
.coach h3 { margin: 8px 0 6px; font-size: 19px; font-weight: 300; letter-spacing: -.005em; }
.coach p { margin: 0; color: var(--body); font-size: 13.5px; line-height: 1.5; }
.coach .coach-note { margin-top: 10px; padding: 2px 0 2px 12px; border-left: 2px solid var(--text); color: var(--text); }
/* One row, all one height: Skip as quiet text on the left (Esc), Back and Next together on the right. The last
   step drops Skip and the Enter hint, which is what lets "Start annotating" fit on the same row. */
.coach-actions { display: flex; align-items: center; gap: 8px; margin-top: 16px; }
.coach-actions .btn { flex: none; height: 30px; padding: 0 13px; font-size: 13px; }
.coach-actions .spacer { flex: 1; }
.btn.ghost { border-color: transparent; background: transparent; color: var(--text3); }
.coach-actions .btn.ghost { padding: 0; }
.btn.ghost:hover { color: var(--text); border-color: transparent; }

/* In the walkthrough an example's caption stays hidden until its clip has played. */
.listen-first { display: none; align-items: center; gap: 14px; padding: 26px 22px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel2); color: var(--text2); font-size: 14px; }
.listen-first .lf-icon { display: grid; place-items: center; flex: none; width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--ring); background: var(--surface); color: var(--text); font-size: 12px; }
.listen-first b { color: var(--text); font-weight: 500; }
body.walk-veil .listen-first { display: flex; }
body.walk-veil #detailCard { display: none; }
body.walk-veil #lanes .cap, body.walk-veil #lanes .label-chip { visibility: hidden; }
/* ...and fades in when it has. */
body.caption-mode #detailCard { animation: coach-fade .3s ease-out; }
@media (prefers-reduced-motion: reduce) {
  #coachRing, .coach { transition: none; }
  #coachRing, .coach, .coach *, body.caption-mode #detailCard { animation: none !important; }
}
.coach .btn:disabled { opacity: .45; cursor: default; }

/* The login: the site's password gate, black, with the wordmark over the form. */
.login-wrap { background: #000; align-items: center; padding-top: 0; -webkit-backdrop-filter: none; backdrop-filter: none; }
.login-wrap .dialog-card { background: transparent; border: 0; box-shadow: none; color: #fff; width: min(380px, 92vw); text-align: center; }
.gate-wordmark { font-size: clamp(34px, 6vw, 56px); font-weight: 500; letter-spacing: .3em; padding-left: .3em; line-height: 1.05; }
.login-wrap h2 { margin: 18px 0 0; font-size: 12px; font-weight: 400; letter-spacing: .28em; text-transform: uppercase; color: rgba(255,255,255,.55); }
.login-wrap .muted { color: rgba(255,255,255,.5); }
.login-wrap label.f { text-align: left; color: rgba(255,255,255,.55); font-size: 11px; letter-spacing: .18em; text-transform: uppercase; margin-top: 18px; }
.login-wrap input { height: 52px; background: #0A0A0A; border: 1px solid rgba(255,255,255,.22); color: #fff; caret-color: #fff; font-size: 16px; }
.login-wrap input:focus { border-color: rgba(255,255,255,.55); }
.login-wrap .dialog-actions { justify-content: center; margin-top: 26px; }
.login-wrap .btn.primary { background: #fff; color: #000; border-color: #fff; height: 44px; padding: 0 28px; }
.login-wrap .btn.primary:hover { background: #E6E6E6; }
.login-wrap .login-err { color: #FF8A7E; }
.login-wrap .login-msg { color: #E8C877; }
.login-links { margin: 14px 0 0; min-height: 1em; }
.login-wrap .login-links a { color: rgba(255,255,255,.7); text-decoration: underline; text-underline-offset: 3px; }
.login-wrap .login-links a:hover { color: #fff; }
:focus-visible { outline: 1px solid var(--text); outline-offset: 3px; }

/* ---------- Touch screens ----------
   html.touch (index.html sets it when the main pointer is a finger): the page names controls rather than keys, so
   the key hints and the keys sheet go, the controls are 44 px (Apple's minimum for a finger), and text boxes use
   16 px type, below which iOS zooms the page in when one takes the focus. */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
html:not(.touch) .touch-only { display: none !important; }
html.touch .key-only, html.touch .btn kbd, html.touch label kbd, html.touch #hints, html.touch #keysBtn,
html.touch #reviewHint { display: none !important; }
html.touch { -webkit-tap-highlight-color: transparent; }
html.touch button, html.touch select, html.touch .btn { touch-action: manipulation; }
html.touch .btn { height: 44px; padding: 0 16px; font-size: 14px; }
html.touch .btn.sm { height: 36px; min-width: 36px; padding: 0 12px; font-size: 13px; }
html.touch .btn.icon { width: 44px; padding: 0; }
html.touch .btn.primary { height: 44px; padding: 0 20px; }
html.touch .round { width: 44px; height: 44px; }
html.touch .player-bar .round { width: 48px; height: 48px; border-radius: 24px; }
html.touch .seg button { height: 42px; padding: 0 11px; }
html.touch .clip-pick select { height: 44px; font-size: 16px; }
html.touch .del { width: 40px; height: 40px; font-size: 20px; }
html.touch .attrs .btn, html.touch .det-status .btn, html.touch .coach-actions .btn { height: 40px; font-size: 13px; }
html.touch .ac-list li { padding: 11px 10px; }
html.touch .ac-toggle { padding: 10px 0 10px 10px; font-size: 13px; }
html.touch .ac-toggle input { width: 20px; height: 20px; }
html.touch .rv { padding: 11px 12px; }
html.touch table.spans td { padding: 6px 0; }
html.touch table.spans td.span-del { text-align: right; }
html.touch #detailCard input[type=text], html.touch .dialog-card input { font-size: 16px; }
/* A tap leaves :hover on in iOS: the controls keep their resting look, and show the press instead. */
html.touch .btn:hover, html.touch .clip-pick select:hover { border-color: var(--line3); }
html.touch .round:hover { border-color: var(--ring); }
html.touch .btn.primary:hover, html.touch .btn[aria-pressed="true"]:hover { border-color: var(--text); }
html.touch .btn.primary:hover { background: var(--text); }
html.touch .btn.ghost:hover { border-color: transparent; color: var(--text3); }
html.touch .btn:active, html.touch .round:active { background: var(--pressed); }
html.touch .btn.primary:active { background: var(--accent-hover); }
html.touch .login-wrap .btn.primary:hover { background: #fff; }
/* On the timeline a finger drags sideways (scrub, draw, move) and swipes up or down to scroll the page; the browser
   doesn't zoom there, since two fingers zoom the time axis. Span edges get a finger-wide grip. */
html.touch #ruler, html.touch #specTrack, html.touch .lane .track { touch-action: pan-y; }
html.touch #timeline { -webkit-user-select: none; -webkit-touch-callout: none; }
html.touch .span .edge { width: 26px; top: -14px; bottom: -14px; }
html.touch .span .edge.l { left: -13px; }
html.touch .span .edge.r { right: -13px; }
html.touch .span.sel .edge::after { left: 10.5px; top: 8px; bottom: 8px; }

/* Where the page scrolls as a whole (the rule at #side above), the caption column does too: left a scroll box of its
   own, with overscroll contained, a swipe that starts in it can't scroll the page. */
@media (max-width: 900px), (max-height: 480px) {
  .describe { overflow: visible; }
}

/* ---------- Narrow windows: the caption-mode header in three rows ----------
   Below 940 px its one row doesn't fit. Row 1 the wordmark and the page's own buttons, row 2 the clip and what to do
   with it, row 3 the progress. The clip list takes row 2's free width; its max-width keeps room for the buttons
   beside it, which is also what moves it off row 1. */
.d-actions.ex-next { display: none; }
@media (max-width: 940px) {
  body.caption-mode #topbar { flex-wrap: wrap; gap: 10px 8px; padding: 12px 16px; }
  body.caption-mode .brand { order: 1; margin-right: auto; }
  body.caption-mode #saveState { order: 2; }
  body.caption-mode #guideBtn { order: 3; }
  body.caption-mode #keysBtn { order: 4; }
  body.caption-mode #themeBtn { order: 5; }
  body.caption-mode .who-wrap { order: 6; }
  body.caption-mode .clip-pick { order: 7; flex: 1 1 100%; max-width: calc(100% - 340px); }
  body.caption-mode .clip-pick select { width: 100%; max-width: none; }
  body.caption-mode #flagBtn { order: 8; margin-left: auto; }
  body.caption-mode #skipBtn { order: 9; }
  body.caption-mode #submitBtn { order: 10; }
  body.caption-mode #topbar .progress { order: 11; flex: 1 1 100%; }
  body.caption-mode #progressText { display: inline; }
}

/* ---------- Phones (up to 640 px) ---------- */
@media (max-width: 640px) {
  /* The header, either mode: row 1 the wordmark, saving and the page's buttons; row 2 the clip list; then the rest. */
  #topbar { flex-wrap: wrap; gap: 10px 8px; padding: 10px 12px; }
  .brand { order: 1; margin-right: auto; }
  #saveState { order: 2; }
  #themeBtn { order: 5; }
  .who-wrap { order: 6; }
  #who, #timer { display: none; }
  .clip-pick { order: 7; flex: 1 1 100%; max-width: calc(100% - 130px); }
  .clip-pick select { width: 100%; max-width: none; }
  #submitBtn { order: 8; }
  #topbar .progress { order: 9; flex: 1 1 120px; }
  #flagBtn { order: 10; }
  #skipBtn { order: 11; }
  /* Caption mode: Submit is at the end of the form, where the caption and tags end; Flag and Skip join the clip list. */
  body.caption-mode #topbar { padding: 10px 12px; }
  body.caption-mode #submitBtn { display: none; }
  body.caption-mode .clip-pick { max-width: calc(100% - 152px); }
  body.caption-mode #topbar .progress { flex: 1 1 100%; }
  .d-actions.ex-next { display: flex; }
  body.caption-mode .d-actions .btn.primary { flex: 1; justify-content: center; }
  .describe-body { padding: 12px 12px 32px; gap: 12px; }
  body.caption-mode #detailCard { padding: 18px 16px 20px; }
  .d-actions { margin-top: 20px; padding-top: 16px; }
  .player-bar { padding: 10px 12px; gap: 8px; }
  .player-bar #timeText { font-size: 13px; white-space: nowrap; }
  /* Timing mode: each source's name sits above its row, so the row has the screen's width to draw on; the
     spectrogram is shorter, since it stays pinned while the rows scroll under it. */
  .ruler-row .head, .spec-row .head { display: none; }
  .row, .lane { grid-template-columns: minmax(0, 1fr); }
  .lane .head { padding: 8px 12px 2px; }
  .lane .track { height: 56px; }
  .lane { scroll-margin-top: 156px; }
  #specTrack, #specCanvas { height: 120px; }
  .add-row .head { padding: 10px 12px 4px; }
  .add-row .hint { padding: 0 12px 12px; }
  #toolbar { padding: 8px 12px; gap: 8px; }
  #side { padding: 12px; }
  .modal-wrap { padding: 16px 10px; }
  .dialog-card, .keys-card { padding: 20px 18px; }
  /* The walkthrough's card goes across the bottom of the screen. */
  .coach { width: auto; right: 8px; }
  /* Timing mode: play and pause float at the bottom right, in reach while the rows and the review list are scrolled
     to; the toasts sit above it. */
  body:not(.caption-mode) #playBtn { position: fixed; right: 16px; bottom: 16px; z-index: 30; width: 56px; height: 56px; box-shadow: 0 8px 24px var(--shadow-strong); }
  body:not(.caption-mode) #toast { bottom: 88px; }
}
