/* TympanIQ pilot: tokens and components on top of Bootstrap 5.3.
   Look agreed in the design mockup (project overview §9). */

@font-face { font-family: "IBM Plex Sans"; font-weight: 400; font-display: swap; src: url("../vendor/fonts/ibm-plex-sans-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Sans"; font-weight: 500; font-display: swap; src: url("../vendor/fonts/ibm-plex-sans-latin-500-normal.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Sans"; font-weight: 600; font-display: swap; src: url("../vendor/fonts/ibm-plex-sans-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Mono"; font-weight: 400; font-display: swap; src: url("../vendor/fonts/ibm-plex-mono-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Mono"; font-weight: 500; font-display: swap; src: url("../vendor/fonts/ibm-plex-mono-latin-500-normal.woff2") format("woff2"); }

:root,
[data-bs-theme="light"] {
  --tq-bg: #eef1f4;
  --tq-surface: #ffffff;
  --tq-fg: #1d2630;
  --tq-muted: #5d6b78;
  --tq-line: #d5dce3;
  --tq-accent: #3f6b8a;          /* soft blue-gray, from the device's visual character */
  --tq-accent-hover: #345a75;
  --tq-accent-soft: #e3ecf3;
  --tq-rec: #1f6fd1;             /* device light: blue = recording */
  --tq-rec-soft: #e2eefc;
  --tq-amber: #b7791f;           /* device light: amber = paused or finishing */
  --tq-amber-soft: #fbf0dc;
  --tq-fault: #c0392b;           /* device light: red = fault */
  --tq-fault-soft: #fbe5e2;
  --tq-ok: #2f7d4f;
  --tq-ok-soft: #e1f2e8;
  --tq-interim: #8a97a3;
  --tq-highlight: #fff4c2;
  --font-body: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
}

[data-bs-theme="dark"] {
  --tq-bg: #12171c;
  --tq-surface: #1a2128;
  --tq-fg: #e4e9ee;
  --tq-muted: #9aa7b3;
  --tq-line: #2d3741;
  --tq-accent: #7ea6c4;
  --tq-accent-hover: #93b7d2;
  --tq-accent-soft: #233340;
  --tq-rec: #5aa2f5;
  --tq-rec-soft: #18304d;
  --tq-amber: #e0a84e;
  --tq-amber-soft: #3a2d16;
  --tq-fault: #ef7b6e;
  --tq-fault-soft: #402020;
  --tq-ok: #6cc391;
  --tq-ok-soft: #173326;
  --tq-interim: #6f7c88;
  --tq-highlight: #4a4120;
}

body {
  --bs-body-font-family: var(--font-body);
  --bs-body-bg: var(--tq-bg);
  --bs-body-color: var(--tq-fg);
  --bs-border-color: var(--tq-line);
  --bs-secondary-color: var(--tq-muted);
  background: var(--tq-bg);
  color: var(--tq-fg);
  font-family: var(--font-body);
  font-size: .92rem;
  min-height: 100vh;
}

.min-w-0 { min-width: 0; }
[hidden] { display: none !important; }  /* Bootstrap's d-* classes would otherwise show hidden elements */
.mono, .ts { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

.btn-primary {
  --bs-btn-bg: var(--tq-accent); --bs-btn-border-color: var(--tq-accent);
  --bs-btn-hover-bg: var(--tq-accent-hover); --bs-btn-hover-border-color: var(--tq-accent-hover);
  --bs-btn-active-bg: var(--tq-accent-hover); --bs-btn-active-border-color: var(--tq-accent-hover);
  --bs-btn-color: var(--tq-surface); --bs-btn-hover-color: var(--tq-surface); --bs-btn-active-color: var(--tq-surface);
  --bs-btn-disabled-bg: var(--tq-accent); --bs-btn-disabled-border-color: var(--tq-accent);
}
.btn-outline-secondary {
  --bs-btn-color: var(--tq-fg); --bs-btn-border-color: var(--tq-line);
  --bs-btn-hover-bg: var(--tq-accent-soft); --bs-btn-hover-color: var(--tq-fg); --bs-btn-hover-border-color: var(--tq-accent);
}
.form-control, .form-select { background-color: var(--tq-surface); color: var(--tq-fg); border-color: var(--tq-line); }
.table { --bs-table-bg: var(--tq-surface); --bs-table-color: var(--tq-fg); --bs-table-border-color: var(--tq-line); }

/* Top bar */
.app-bar { display: flex; align-items: center; gap: 14px; padding: 10px 16px; background: var(--tq-surface); border-bottom: 1px solid var(--tq-line); }
.brand { font-weight: 600; letter-spacing: .01em; display: flex; align-items: center; gap: 8px; color: var(--tq-fg); text-decoration: none; }
.brand-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--tq-accent); box-shadow: 0 0 0 3px var(--tq-accent-soft); }
.app-bar nav { display: flex; gap: 4px; margin-left: 12px; }
.app-bar nav a { color: var(--tq-muted); text-decoration: none; padding: 4px 10px; border-radius: 6px; font-weight: 500; }
.app-bar nav a.active { color: var(--tq-fg); background: var(--tq-accent-soft); }
.app-bar .signout { margin-left: auto; }
.app-bar .signout button { border: none; background: none; color: var(--tq-muted); font-size: .85rem; padding: 4px 6px; }
.app-bar .signout button:hover { color: var(--tq-fg); }
@media (max-width: 575.98px) {
  .app-bar { flex-wrap: wrap; }
  .app-bar nav { order: 3; width: 100%; margin-left: 0; }
}

.app-body { max-width: 1600px; margin: 0 auto; padding: 14px 16px 24px; display: grid; gap: 12px; }
/* Forms and long text read better in a narrower column (P04, P05). */
.app-body.narrow { max-width: 1240px; }

.panel { background: var(--tq-surface); border: 1px solid var(--tq-line); border-radius: 10px; min-width: 0; }
.panel-head { display: flex; align-items: baseline; justify-content: space-between; padding: 10px 12px 6px; }
.panel-head h3 { font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--tq-muted); margin: 0; font-weight: 600; }
.empty { padding: 18px 12px 22px; color: var(--tq-muted); font-size: .85rem; text-align: center; }
.field-hint { font-size: .74rem; color: var(--tq-muted); }

.alert-tq { border-radius: 8px; padding: 8px 12px; font-size: .85rem; color: var(--tq-fg); }
.alert-tq.warn { background: var(--tq-amber-soft); border: 1px solid var(--tq-amber); }
.alert-tq.err { background: var(--tq-fault-soft); border: 1px solid var(--tq-fault); }
.alert-tq.ok { background: var(--tq-ok-soft); border: 1px solid var(--tq-ok); }

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

.tag { border-radius: 4px; padding: 0 6px; font-weight: 600; font-size: .72rem; }
.tag.built { background: var(--tq-accent-soft); color: var(--tq-accent); }
.tag.edited { background: var(--tq-amber-soft); color: var(--tq-amber); }

/* Environments (P03): a row opens to show its event types (F09) */
.env-row { cursor: pointer; }
.env-row:hover > td, .env-row.open > td { background: var(--tq-accent-soft); }
.env-toggle { display: inline-flex; align-items: center; gap: 6px; border: 0; padding: 0; background: none; color: var(--tq-fg); font-weight: 600; text-align: left; }
.env-toggle .chev { width: 7px; height: 7px; border-right: 2px solid var(--tq-muted); border-bottom: 2px solid var(--tq-muted); transform: rotate(-45deg); transition: transform .15s; flex: none; }
.env-toggle[aria-expanded="true"] .chev { transform: rotate(45deg); }
.env-detail > td { background: var(--tq-bg); padding: 8px; }
.env-types { font-size: .82rem; }
.env-types td { vertical-align: top; }
/* On a phone the row's buttons wrap, so the list and its detail row fit the screen. */
@media (max-width: 575.98px) {
  .env-btns { flex-wrap: wrap; justify-content: flex-end; max-width: 176px; }
  .env-btns > .btn { flex: 1 0 50%; white-space: nowrap; }
}

/* System prompt (P05) */
.prompt-grid { display: grid; grid-template-columns: minmax(0, 1fr) 240px; gap: 12px; align-items: start; }
@media (max-width: 767.98px) { .prompt-grid { grid-template-columns: minmax(0, 1fr); } }
textarea.prompt-editor { font-family: var(--font-mono); font-size: .8rem; line-height: 1.5; min-height: 60vh; resize: vertical; }
textarea.prompt-editor[readonly] { background: var(--tq-bg); }
.rev { display: flex; justify-content: space-between; align-items: center; gap: 8px; width: 100%; padding: 8px 10px; border: 0; border-radius: 8px; background: none; color: var(--tq-fg); font-size: .85rem; text-align: left; }
.rev:hover { background: var(--tq-accent-soft); }
.rev.shown { outline: 1px solid var(--tq-accent); }
.rev.current { background: var(--tq-accent-soft); }
.rev small { color: var(--tq-muted); text-align: right; }

/* Session (P02) */
.controls { display: grid; gap: 10px; }
.controls-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.btn-record {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  border: none; border-radius: 999px; padding: 12px 22px; font-weight: 600; font-size: 1rem;
  background: var(--tq-rec); color: #fff;
}
.btn-record .dot { width: 12px; height: 12px; border-radius: 50%; background: #fff; }
.btn-record.stop { background: var(--tq-fault); }
.btn-record.stop .dot { border-radius: 2px; }
.btn-record:disabled { opacity: .55; }
.env-select { width: 240px; }
.llm-select { width: auto; max-width: 100%; }
@media (max-width: 575.98px) {
  .btn-record { width: 100%; padding: 16px; font-size: 1.05rem; }
  .env-select, .llm-select { width: 100%; }
}
.status { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: .85rem; }
.status .meta { color: var(--tq-muted); }
.pill { display: inline-flex; align-items: center; gap: 6px; border-radius: 999px; padding: 3px 10px; font-weight: 600; font-size: .8rem; }
.pill .led { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.pill.idle { background: var(--tq-accent-soft); color: var(--tq-muted); }
.pill.rec { background: var(--tq-rec-soft); color: var(--tq-rec); }
.pill.rec .led { animation: pulse 1.4s ease-in-out infinite; }
.pill.finishing { background: var(--tq-amber-soft); color: var(--tq-amber); }
.pill.done { background: var(--tq-ok-soft); color: var(--tq-ok); }
.pill.error { background: var(--tq-fault-soft); color: var(--tq-fault); }
@keyframes pulse { 50% { opacity: .25; } }
@media (prefers-reduced-motion: reduce) { .pill.rec .led { animation: none; } }

.split { display: grid; gap: 12px; }
@media (min-width: 768px) { .split { grid-template-columns: 5fr 7fr; align-items: start; } }
.panel-head small { color: var(--tq-muted); }
.ev-list, .tr-list { list-style: none; margin: 0; padding: 0 6px 8px; }
.tr-list { max-height: 60vh; overflow-y: auto; }
.ev { display: grid; grid-template-columns: 64px 1fr; gap: 2px 10px; padding: 8px 6px; border-radius: 8px; cursor: pointer; border-left: 3px solid transparent; }
.ev:hover { background: var(--tq-accent-soft); }
.ev .ts { font-size: .8rem; color: var(--tq-muted); padding-top: 2px; }
.ev .name { font-weight: 600; }
.ev .sub { grid-column: 2; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: .76rem; color: var(--tq-muted); }
.kind { border-radius: 4px; padding: 0 6px; font-weight: 600; font-size: .72rem; }
.kind.heard { background: var(--tq-accent-soft); color: var(--tq-accent); }
.kind.inferred { border: 1px dashed var(--tq-amber); color: var(--tq-amber); }
.kind.corrected { background: var(--tq-amber-soft); color: var(--tq-amber); }
.ev.inferred { border-left-color: var(--tq-amber); }
.ev.withdrawn .name, .ev.withdrawn .ts { text-decoration: line-through; color: var(--tq-muted); font-weight: 400; }
.ev.new { animation: arrive 1.2s ease-out; }
@keyframes arrive { from { background: var(--tq-highlight); } }
@media (prefers-reduced-motion: reduce) { .ev.new { animation: none; } }
.seg { display: grid; grid-template-columns: 22px 1fr; gap: 0 8px; padding: 6px 6px; border-radius: 6px; }
.seg .who { font-family: var(--font-mono); font-weight: 500; font-size: .8rem; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; background: var(--tq-accent-soft); color: var(--tq-accent); }
.seg .line { min-width: 0; }
.seg .meta { font-size: .72rem; color: var(--tq-muted); }
.seg.hl { background: var(--tq-highlight); }
.seg.interim .text { color: var(--tq-interim); font-style: italic; }

/* LLM call log (F10) */
.calls-toggle { display: inline-flex; align-items: center; gap: 8px; border: 0; padding: 0; background: none; color: var(--tq-muted); }
.calls-toggle .chev { width: 7px; height: 7px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(-45deg); transition: transform .15s; }
.calls-toggle[aria-expanded="true"] .chev { transform: rotate(45deg); }
.call-list { list-style: none; margin: 0; padding: 0 6px 8px; max-height: 50vh; overflow-y: auto; }
.call { border-radius: 8px; border-left: 3px solid transparent; }
.call.skipped { background: var(--tq-amber-soft); border-left-color: var(--tq-amber); }
.call-head { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; width: 100%; padding: 7px 6px; border: 0; border-radius: 8px; background: none; color: var(--tq-fg); font-size: .8rem; text-align: left; }
.call-head:hover, .call.open > .call-head { background: var(--tq-accent-soft); }
.call-head .num { font-family: var(--font-mono); font-weight: 600; min-width: 2.2em; }
.call-head .meta { color: var(--tq-muted); }
.reason { border-radius: 4px; padding: 0 6px; font-weight: 600; font-size: .72rem; background: var(--tq-accent-soft); color: var(--tq-accent); white-space: nowrap; }
.reason.after-previous-call, .reason.word-limit { background: var(--tq-amber-soft); color: var(--tq-amber); }
.result.running { color: var(--tq-rec); }
.result.skipped { color: var(--tq-fault); font-weight: 600; }
.call-detail { padding: 4px 10px 12px 2.8em; display: grid; gap: 8px; font-size: .8rem; }
.call-detail h4 { font-size: .7rem; text-transform: uppercase; letter-spacing: .06em; color: var(--tq-muted); margin: 0 0 2px; font-weight: 600; }
.call-detail ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.call-detail .ignored { color: var(--tq-muted); text-decoration: line-through; }
.call-detail .note { color: var(--tq-amber); }
.call-detail pre { margin: 0; padding: 8px; max-height: 40vh; overflow: auto; background: var(--tq-bg); border-radius: 6px; font-size: .74rem; white-space: pre-wrap; word-break: break-word; }
@media (max-width: 575.98px) { .call-detail { padding-left: 8px; } }

/* Detection report (F11) */
.rp-body { padding: 0 12px 12px; display: grid; gap: 10px; font-size: .85rem; }
.rp-lines { display: grid; gap: 2px; }
.rp-lines .meta { color: var(--tq-muted); font-size: .78rem; }
.rp-stats { font-size: .8rem; margin: 0; width: auto; }
.rp-stats th { font-weight: 400; color: var(--tq-muted); padding-right: 16px; }
.rp-stats thead th { font-size: .7rem; text-transform: uppercase; letter-spacing: .06em; font-weight: 600; }
.rp-stats td { text-align: right; padding-left: 16px; }
.rp-summary { display: flex; flex-wrap: wrap; gap: 4px 32px; align-items: flex-start; }
.rp-stats tr.rp-part th { padding-top: 10px; color: var(--tq-fg); font-weight: 600; font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; }
.rp-how { margin: 0; color: var(--tq-muted); font-size: .78rem; max-width: 110ch; }
.rp-value { display: inline-flex; align-items: center; gap: 6px; }
.rp-value .input-num { width: 80px; }
.rp-rebuild { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.rp-table { font-size: .8rem; margin: 0; }
.rp-table td { vertical-align: top; }
.rp-table .flags { color: var(--tq-muted); font-size: .72rem; }
.rp-table .warn { color: var(--tq-amber); }
.res { border-radius: 4px; padding: 0 6px; font-weight: 600; font-size: .72rem; white-space: nowrap; background: var(--tq-accent-soft); color: var(--tq-muted); }
.res.good { background: var(--tq-ok-soft); color: var(--tq-ok); }
.res.part { background: var(--tq-amber-soft); color: var(--tq-amber); }
.res.bad { background: var(--tq-fault-soft); color: var(--tq-fault); }

.badge-transcript { background: var(--tq-amber-soft); color: var(--tq-amber); border-radius: 4px; padding: 1px 6px; font-size: .72rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.upload-panel { border: 1px dashed var(--tq-line); border-radius: 10px; padding: 10px 12px; display: grid; gap: 8px; background: var(--tq-surface); }

/* Settings (P04) */
.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 767.98px) { .settings-grid { grid-template-columns: minmax(0, 1fr); } }
.label-row { display: flex; align-items: center; gap: 6px; margin-bottom: 4px; }
.label-row .form-label { margin: 0; }
.help {
  width: 18px; height: 18px; flex: none; border-radius: 50%; border: 1px solid var(--tq-accent); color: var(--tq-accent);
  background: transparent; font: 600 .7rem/1 var(--font-body); display: inline-grid; place-items: center; padding: 0; cursor: help;
}
.help:hover, .help:focus-visible { background: var(--tq-accent); color: var(--tq-surface); outline: none; }
.tooltip.tq-tip { --bs-tooltip-max-width: 340px; --bs-tooltip-font-size: .8rem; --bs-tooltip-padding-x: .75rem; --bs-tooltip-padding-y: .55rem; --bs-tooltip-opacity: 1; }
.tooltip.tq-tip .tooltip-inner { text-align: left; line-height: 1.45; }
.input-num { max-width: 140px; }
.field-error { font-size: .78rem; color: var(--tq-fault); }
.changed-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--tq-amber); }

/* Sign in (P01) */
.signin { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.signin form { width: 100%; max-width: 300px; display: grid; gap: 14px; }
.signin .brand { justify-content: center; font-size: 1.25rem; }

/* Session history (P06, F12) */
.hist-filters { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 12px 10px; }
.hist-filters .form-select { width: auto; max-width: 100%; }
.hist-filters input[type="search"] { width: 220px; max-width: 100%; }
.hist-list { list-style: none; margin: 0; padding: 0 6px 8px; }
.hist-row { display: grid; gap: 2px; padding: 8px 8px; border-radius: 8px; color: inherit; text-decoration: none; font-size: .85rem; }
.hist-row:hover, .hist-row:focus-visible { background: var(--tq-accent-soft); color: inherit; }
.hist-list > li + li { border-top: 1px solid var(--tq-line); }
/* Re-run groups (F12 §5 step 16) */
.hist-group-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; padding: 0 8px 6px 34px; }
.hist-toggle { padding: 4px 6px; min-height: 32px; font-size: .8rem; text-decoration: none; color: var(--tq-accent); }
.hist-toggle:hover { text-decoration: underline; }
.hist-caret { display: inline-block; width: 1em; font-size: 1.1rem; line-height: 1; vertical-align: -1px; }
.hist-sub { list-style: none; margin: 0 0 8px 34px; padding: 0 0 0 8px; border-left: 2px solid var(--tq-line); }
.hist-sub > li + li { border-top: 1px dashed var(--tq-line); }
.hist-row-wrap.dim .hist-row { opacity: .55; }
.hist-row-wrap.dim .hist-row:hover, .hist-row-wrap.dim .hist-row:focus-visible { opacity: 1; }
@media (max-width: 575.98px) { .hist-group-bar { padding-left: 26px; } .hist-sub { margin-left: 18px; } }
.hist-line { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; }
.hist-row .meta { color: var(--tq-muted); font-size: .78rem; overflow-wrap: anywhere; }
.hist-row .pill { font-size: .72rem; padding: 1px 8px; }
.hist-note { margin-left: 8px; color: var(--tq-fg); font-style: italic; }
.hist-note::before { content: "\201C"; }
.hist-note::after { content: "\201D"; }
.hist-note-text { font-size: .78rem; color: var(--tq-fg); white-space: pre-line; overflow-wrap: anywhere; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden; }

/* Session record (P07, F12) */
.rec-head { padding: 12px 14px; display: grid; gap: 10px; }
.rec-title { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; }
.rec-title h1 { font-size: 1.05rem; margin: 0; font-weight: 600; }
.rec-facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px 24px; margin: 0; font-size: .82rem; }
.rec-facts > div { display: grid; grid-template-columns: 120px minmax(0, 1fr); gap: 8px; }
.rec-facts dt { font-weight: 400; color: var(--tq-muted); }
.rec-facts dd { margin: 0; overflow-wrap: anywhere; }
.rec-facts .meta { color: var(--tq-muted); }
@media (max-width: 767.98px) { .rec-facts { grid-template-columns: minmax(0, 1fr); } }
.rec-note-view { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; font-size: .85rem;
  border-top: 1px solid var(--tq-line); padding-top: 10px; }
.rec-note-text { white-space: pre-wrap; color: var(--tq-muted); }
.rec-note-form { display: grid; border-top: 1px solid var(--tq-line); padding-top: 10px; }
/* Review player (P07, F16 §5 step 10; design mockup tab "P07 Review player") */
.rp { position: sticky; top: 0; z-index: 5; background: var(--tq-surface); border: 1px solid var(--tq-line); border-radius: 10px;
  padding: 12px; display: grid; gap: 12px; grid-template-columns: minmax(0, 384px) minmax(0, 1fr); align-items: center;
  box-shadow: 0 4px 14px rgba(20, 30, 40, .08); }
.rp.audio { grid-template-columns: minmax(0, 1fr); }
.rp[hidden], .rp-video[hidden], .rp-note[hidden], .rp-band[hidden], .rp [hidden] { display: none; }
.rp-video { position: relative; aspect-ratio: 16 / 9; border-radius: 8px; overflow: hidden; background: #0e1418; }
.rp-video video { width: 100%; height: 100%; display: block; object-fit: contain; cursor: pointer; }
.rp-video:fullscreen { border-radius: 0; }
.rp-video .big-play { position: absolute; inset: 0; margin: auto; width: 52px; height: 52px; border-radius: 50%; border: none;
  background: rgba(255, 255, 255, .88); color: #1d2a33; display: grid; place-items: center; }
.rp-video .big-play:focus-visible { outline: 3px solid var(--tq-accent); outline-offset: 2px; }
.rp-main { display: grid; gap: 6px; min-width: 0; }
.rp-pins { position: relative; height: 30px; }
.rp-pin { position: absolute; bottom: 0; transform: translateX(-50%); width: 24px; height: 30px; padding: 0; border: none;
  background: transparent; display: flex; flex-direction: column; align-items: center; cursor: pointer; }
.rp-pin .head { width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--tq-accent); background: var(--tq-accent); transition: transform .12s; }
.rp-pin.inferred .head { background: var(--tq-surface); border-color: var(--tq-amber); border-style: dashed; }
.rp-pin .stem { width: 2px; flex: 1; background: var(--tq-accent); opacity: .5; }
.rp-pin.inferred .stem { background: var(--tq-amber); }
.rp-pin.low { height: 18px; }
.rp-pin:hover .head, .rp-pin:focus-visible .head, .rp-pin.on .head { transform: scale(1.3); }
.rp-pin:focus-visible { outline: 2px solid var(--tq-accent); outline-offset: 1px; border-radius: 4px; }
.rp-tip { position: absolute; bottom: 100%; left: 50%; transform: translate(-50%, -4px); white-space: nowrap; background: var(--tq-fg);
  color: var(--tq-surface); font-size: .72rem; padding: 3px 7px; border-radius: 5px; pointer-events: none; opacity: 0; transition: opacity .12s; z-index: 3; }
.rp-pin:hover .rp-tip, .rp-pin:focus-visible .rp-tip { opacity: 1; }
.rp-wave { position: relative; height: 64px; border-radius: 6px; cursor: pointer; touch-action: none; }
.rp-wave:focus-visible { outline: 2px solid var(--tq-accent); outline-offset: 2px; }
.rp-wave svg { position: relative; width: 100%; height: 100%; display: block; }     /* above the band */
.rp-wave rect.b { fill: var(--tq-muted); opacity: .45; }
.rp-wave rect.b.p { fill: var(--tq-accent); opacity: 1; }
.rp-band { position: absolute; top: 0; bottom: 0; background: var(--tq-highlight); border-radius: 4px; pointer-events: none; }
.rp-head { position: absolute; top: -4px; bottom: -4px; width: 2px; margin-left: -1px; background: var(--tq-accent); pointer-events: none; }
.rp-head::before { content: ""; position: absolute; top: -4px; left: -4px; width: 10px; height: 10px; border-radius: 50%; background: var(--tq-accent); }
.rp-time { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; font-size: .78rem; color: var(--tq-muted); }
.rp-time .now { font-family: var(--font-mono); font-variant-numeric: tabular-nums; color: var(--tq-fg); font-weight: 600; }
.rp-time .now span { color: var(--tq-muted); font-weight: 400; }
.rp-seg { font-family: var(--font-mono); min-width: 3ch; text-align: right; }
.rp-legend { display: inline-flex; gap: 10px; align-items: center; }
.rp-legend i { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 4px; vertical-align: -1px;
  background: var(--tq-accent); border: 2px solid var(--tq-accent); }
.rp-legend i.inf { background: transparent; border: 2px dashed var(--tq-amber); }
.rp-ctrl { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; }
.rp-ctrl .left, .rp-ctrl .right { display: flex; align-items: center; gap: 6px; }
.rp-ctrl .right { justify-content: flex-end; }
.rp-ctrl .mid { display: flex; align-items: center; gap: 10px; }
.rp-btn { width: 44px; height: 44px; border-radius: 50%; border: 1px solid transparent; background: transparent; color: var(--tq-fg);
  display: inline-grid; place-items: center; padding: 0; position: relative; }
.rp-btn:hover { background: var(--tq-accent-soft); }
.rp-btn:focus-visible { outline: 2px solid var(--tq-accent); outline-offset: 1px; }
.rp-btn .n { position: absolute; font: 600 .55rem/1 var(--font-mono); top: 50%; left: 50%; transform: translate(-50%, -38%); }
.rp-play { width: 48px; height: 48px; background: var(--tq-accent); color: var(--tq-surface); }
.rp-play:hover { background: var(--tq-accent-hover); }
.rp-speed { min-width: 48px; height: 34px; border-radius: 6px; border: 1px solid var(--tq-line); background: var(--tq-surface); color: var(--tq-fg);
  font: 600 .78rem var(--font-mono); }
.rp-speed:focus-visible { outline: 2px solid var(--tq-accent); outline-offset: 1px; }
.rp-vol { width: 90px; accent-color: var(--tq-accent); }
.rp-keys { font-size: .72rem; color: var(--tq-muted); }
.rp-keys kbd { font: .7rem var(--font-mono); background: var(--tq-bg); color: var(--tq-fg); border: 1px solid var(--tq-line); border-radius: 4px;
  padding: 0 4px; box-shadow: none; }
.rp.audio .rp-frame-keys { display: none; }
.rp-note { grid-column: 1 / -1; display: flex; align-items: center; gap: 10px; font-size: .82rem; }
.rp-note .bar { flex: 0 0 140px; height: 6px; border-radius: 3px; background: var(--tq-line); overflow: hidden; }
.rp-note .bar i { display: block; height: 100%; background: var(--tq-amber); }
.rp-note.alert-tq { display: block; }
.rp-note pre { margin: 4px 0 0; font: .74rem var(--font-mono); white-space: pre-wrap; overflow-wrap: anywhere; }
@media (max-width: 767.98px) {
  /* Not sticky on a phone: the video would cover half the screen (F16 §5 step 10). */
  .rp { position: static; grid-template-columns: minmax(0, 1fr); padding: 10px; gap: 10px; }
  .rp-vol, .rp-volicon, .rp-keys, .rp-legend .txt { display: none; }
}
@media (prefers-reduced-motion: reduce) { .rp-pin .head, .rp-tip { transition: none; } }
/* Lanes of marks under the waveform (P09, F17 §5 step 3) */
.rp.has-lanes .rp-pins, .rp.has-lanes .rp-wave { margin-left: 22px; }
.rp-lane { position: relative; height: 18px; margin-left: 22px; }
.rp-lane-l { position: absolute; left: -22px; top: 1px; font: 600 .66rem var(--font-mono); color: var(--tq-muted); }
.rp-lane-in { position: absolute; inset: 0; }
.gt-mark { position: absolute; top: 0; height: 18px; padding: 0; border: none; background: transparent; cursor: pointer; }
.gt-mark.m { width: 18px; margin-left: -9px; }
.gt-mark.m::before { content: ""; position: absolute; left: 4px; top: 4px; width: 10px; height: 10px; transform: rotate(45deg); background: var(--tq-ok); border-radius: 2px; }
.gt-mark.r { min-width: 6px; }
.gt-mark.r::before { content: ""; position: absolute; left: 0; right: 0; top: 6px; height: 6px; border-radius: 3px; background: var(--tq-ok); }
.rp-lane[data-lane="video"] .gt-mark.m::before { background: var(--tq-rec); border-radius: 50%; transform: none; }
.rp-lane[data-lane="video"] .gt-mark.r::before { background: var(--tq-rec); }
.rp-legend i.gt-k { border: none; width: 9px; height: 9px; }
.rp-legend i.gt-k.a { background: var(--tq-ok); transform: rotate(45deg); border-radius: 2px; }
.rp-legend i.gt-k.v { background: var(--tq-rec); }
.gt-mark.miss::before { background: var(--tq-surface); border: 2px solid var(--tq-ok); }
.rp-lane[data-lane="video"] .gt-mark.miss::before { background: var(--tq-surface); border-color: var(--tq-rec); }
.rp-legend i.gt-k.miss { background: var(--tq-surface); border: 2px solid var(--tq-muted); transform: rotate(45deg); border-radius: 2px; }
.gt-mark.on::before { outline: 2px solid var(--tq-fg); outline-offset: 1px; }
.gt-mark:focus-visible { outline: 2px solid var(--tq-accent); outline-offset: 1px; border-radius: 3px; }

/* Ground truth editor (P09, F17) */
.gt-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; font-size: .85rem; }
.gt-head h1 { font-size: 1.05rem; font-weight: 600; margin: 0; }
.gt-acts { margin-left: auto; display: flex; gap: 6px; align-items: flex-start; }
.gt-export { position: relative; }
.gt-export summary { list-style: none; }
.gt-export summary::-webkit-details-marker { display: none; }
.gt-export summary::after { content: " ▾"; }
.gt-export-menu { position: absolute; right: 0; top: calc(100% + 4px); z-index: 20; background: var(--tq-surface); border: 1px solid var(--tq-line);
  border-radius: 8px; padding: 4px; display: grid; min-width: 170px; box-shadow: 0 8px 20px rgba(20, 30, 40, .14); }
.gt-export-menu .btn { text-align: left; text-decoration: none; color: var(--tq-fg); }
.gt-export-menu .btn:hover { background: var(--tq-accent-soft); }
.gt-llm-toggle { display: flex; gap: 6px; align-items: center; justify-self: end; font-size: .8rem; color: var(--tq-muted); margin-top: -6px; }
.gt-work { display: grid; gap: 12px; grid-template-columns: minmax(0, 1fr) 260px; align-items: start; }
.gt-work[hidden] { display: none; }
.gt-table { width: 100%; border-collapse: collapse; font-size: .82rem; }
.gt-table th { font-size: .7rem; text-transform: uppercase; letter-spacing: .05em; color: var(--tq-muted); font-weight: 600; text-align: left;
  padding: 4px 6px; border-bottom: 1px solid var(--tq-line); white-space: nowrap; }
.gt-table td { padding: 6px 4px; border-bottom: 1px solid var(--tq-line); vertical-align: top; }
.gt-table tr.on td { background: var(--tq-accent-soft); }
.gt-table tr.on td:first-child { box-shadow: inset 3px 0 0 var(--tq-accent); }
.gt-table .n { color: var(--tq-muted); width: 28px; padding-top: 10px; }
.gt-type { min-width: 210px; font-size: .8rem; }
.gt-type.no-type { border-color: var(--tq-fault); }
.gt-cell { display: grid; gap: 4px; min-width: 190px; }
.gt-btns { display: flex; gap: 4px; flex-wrap: nowrap; align-items: center; }
.gt-btns .btn { padding: 1px 8px; font-size: .74rem; line-height: 1.6; white-space: nowrap; }
.gt-time { display: flex; flex-wrap: wrap; align-items: center; gap: 2px; font-family: var(--font-mono); font-size: .78rem; max-width: 190px; }
.gt-t { display: inline-flex; gap: 2px; white-space: nowrap; }
#rows { overflow-x: auto; }
.gt-time button { border: 1px solid var(--tq-line); background: var(--tq-surface); color: var(--tq-fg); border-radius: 5px; padding: 0 6px; line-height: 1.6; font: inherit; min-width: 24px; }
.gt-time button.t { border-color: transparent; background: var(--tq-ok-soft); color: var(--tq-ok); font-weight: 500; }
.gt-video .gt-time button.t { background: var(--tq-rec-soft); color: var(--tq-rec); }
.gt-time .dash { color: var(--tq-muted); padding: 0 2px; }
.gt-wait { color: var(--tq-amber); font-size: .76rem; font-weight: 600; }
.gt-same { font-size: .74rem; color: var(--tq-muted); display: flex; gap: 4px; align-items: center; white-space: nowrap; }
.gt-note { font-size: .8rem; min-width: 140px; }
.gt-table td:nth-last-child(2) { width: 100%; }
.gt-del { border: none; background: transparent; color: var(--tq-muted); width: 32px; height: 32px; border-radius: 6px; font-size: 1.1rem; }
.gt-del:hover, .gt-del:focus-visible { background: var(--tq-fault-soft); color: var(--tq-fault); }
.gt-add { display: flex; gap: 8px; align-items: center; padding: 8px 12px 10px; flex-wrap: wrap; }
.gt-keys { font-size: .72rem; color: var(--tq-muted); padding: 0 12px 10px; }
.gt-keys kbd { font: .7rem var(--font-mono); background: var(--tq-bg); color: var(--tq-fg); border: 1px solid var(--tq-line); border-radius: 4px; padding: 0 4px; box-shadow: none; }
.gt-side-tabs { display: flex; gap: 4px; padding: 8px 10px 4px; }
.gt-side-tabs button { border: 1px solid var(--tq-line); background: var(--tq-surface); color: var(--tq-fg); border-radius: 999px; padding: 2px 12px; font-size: .78rem; min-height: 28px; }
.gt-side-tabs button[aria-selected="true"] { background: var(--tq-accent); border-color: var(--tq-accent); color: var(--tq-surface); }
.gt-types { list-style: none; margin: 0; padding: 4px 6px 8px; max-height: 480px; overflow: auto; }
.gt-types li { display: grid; grid-template-columns: 34px 1fr auto auto; gap: 6px; align-items: center; padding: 4px 6px; border-radius: 6px; font-size: .8rem; }
.gt-types li:hover { background: var(--tq-bg); }
.gt-types .id { color: var(--tq-muted); font-size: .74rem; }
.gt-types .cnt { font-family: var(--font-mono); font-size: .72rem; border-radius: 999px; padding: 0 7px; background: var(--tq-ok-soft); color: var(--tq-ok); }
.gt-types .cnt.zero { background: transparent; color: var(--tq-muted); }
.gt-types .flag { font-size: .68rem; font-weight: 600; color: var(--tq-amber); display: block; }
.gt-types .flag.bad { color: var(--tq-fault); }
.gt-types .plus { border: 1px solid var(--tq-line); background: var(--tq-surface); color: var(--tq-fg); border-radius: 6px; width: 28px; height: 28px; line-height: 1; }
.gt-words { padding: 4px 10px 10px; max-height: 480px; overflow: auto; font-size: .82rem; display: grid; gap: 8px; }
.gt-words .meta { font-size: .72rem; color: var(--tq-muted); }
.gt-words button { border: none; background: transparent; color: var(--tq-fg); padding: 1px 2px; border-radius: 3px; font: inherit; }
.gt-words button:hover:not(:disabled), .gt-words button:focus-visible { background: var(--tq-ok-soft); color: var(--tq-ok); }
.gt-words button:disabled { color: var(--tq-muted); }
.gt-dialog { border: 1px solid var(--tq-line); border-radius: 12px; padding: 16px 18px; width: min(580px, calc(100% - 24px)); background: var(--tq-surface); color: var(--tq-fg);
  box-shadow: 0 14px 40px rgba(0, 0, 0, .25); }
.gt-dialog::backdrop { background: rgba(15, 22, 28, .45); }
.gt-dialog form, .gt-dialog { display: grid; gap: 10px; }
.gt-dialog:not([open]) { display: none; }
.gt-dialog h2 { font-size: 1rem; font-weight: 600; margin: 0; }
.gt-dialog p { margin: 0; }
.gt-opt { display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; border: 1px solid var(--tq-line); border-radius: 8px; padding: 8px 10px; font-size: .85rem; cursor: pointer; }
.gt-opt:has(input:checked) { border-color: var(--tq-accent); background: var(--tq-accent-soft); }
.gt-opt.off { opacity: .55; cursor: not-allowed; }
.gt-opt small { grid-column: 2; color: var(--tq-muted); }
.gt-check { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; font-size: .85rem; max-height: 50vh; overflow: auto; }
.gt-check li { display: grid; grid-template-columns: 22px 1fr; gap: 6px; }
.gt-check .i { font-weight: 700; text-align: center; }
.gt-check .ok .i { color: var(--tq-ok); }
.gt-check .warn .i { color: var(--tq-amber); }
.gt-check .err .i { color: var(--tq-fault); }
.gt-check .info .i { color: var(--tq-muted); }
.gt-dialog-btns { display: flex; gap: 8px; justify-content: flex-end; align-items: center; flex-wrap: wrap; }
.gt-dialog-btns small { margin-right: auto; }
@media (max-width: 991.98px) { .gt-work { grid-template-columns: minmax(0, 1fr); } }
/* On a wide screen a time range fits on one line, and event type names in the side panel. */
@media (min-width: 1500px) { .gt-time { max-width: none; flex-wrap: nowrap; } .gt-work { grid-template-columns: minmax(0, 1fr) 300px; } }
@media (max-width: 767.98px) {
  /* On a phone each row is a card (P09 §3). */
  .gt-table thead { display: none; }
  .gt-table, .gt-table tbody, .gt-table tr, .gt-table td { display: block; width: 100%; }
  .gt-table tr { position: relative; border: 1px solid var(--tq-line); border-radius: 8px; margin: 0 0 8px; padding: 6px 8px; }
  .gt-table tr.on { border-color: var(--tq-accent); background: var(--tq-accent-soft); }
  .gt-table tr.on td { background: transparent; box-shadow: none !important; }
  .gt-table td { border: none; padding: 3px 0; }
  .gt-table td[data-label]:not(.n)::before { content: attr(data-label); display: block; font-size: .68rem; text-transform: uppercase; letter-spacing: .05em; color: var(--tq-muted); font-weight: 600; }
  .gt-table td:last-child { position: absolute; top: 4px; right: 4px; width: auto; }
  .gt-type { min-width: 0; }
  #rows { padding: 0 8px; }
}
@media (prefers-reduced-motion: no-preference) { .gt-wait { animation: gtblink 1.2s ease-in-out infinite; } }
@keyframes gtblink { 50% { opacity: .45; } }
.rec-table { font-size: .8rem; margin-bottom: 8px; }
.rec-table td:first-child { color: var(--tq-muted); }
.rec-sub { font-size: .7rem; text-transform: uppercase; letter-spacing: .06em; color: var(--tq-muted); font-weight: 600; margin: 8px 0 4px; }
.rec-pre { margin: 0 12px 12px; padding: 10px; max-height: 60vh; overflow: auto; background: var(--tq-bg); border-radius: 6px;
  font-family: var(--font-mono); font-size: .74rem; white-space: pre-wrap; overflow-wrap: anywhere; }
.rec-files { list-style: none; margin: 0; padding: 0 6px 8px; font-size: .82rem; }
.rec-files li + li { border-top: 1px solid var(--tq-line); }
.rec-file-row { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; padding: 6px 6px; }
.rec-file-row > :first-child { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; text-align: left; }
.rec-file-toggle { border: 0; background: none; padding: 0; color: var(--tq-accent); }
.rec-file-toggle:hover { text-decoration: underline; }
.rec-files .rec-pre { margin: 0 6px 8px; }
#transcript .seg { cursor: pointer; }

/* Session comparison (P08, F15) */
.cmp-controls { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; padding: 0 12px 10px; font-size: .85rem; }
.cmp-controls .input-num { width: 80px; }
.cmp-controls .form-select { width: auto; max-width: 100%; }
.cmp-wrap { overflow-x: auto; padding: 0 12px 12px; }
.cmp-table { font-size: .8rem; margin: 0; border-collapse: separate; border-spacing: 0; min-width: 100%; }
.cmp-table th, .cmp-table td { padding: 4px 10px; border-bottom: 1px solid var(--tq-line); vertical-align: top; }
.cmp-table thead th { position: sticky; top: 0; background: var(--tq-surface); white-space: nowrap; }
.cmp-table .cmp-lead { position: sticky; left: 0; background: var(--tq-surface); color: var(--tq-muted); font-weight: 400; min-width: 180px; max-width: 260px; }
.cmp-table .group th { color: var(--tq-muted); font-size: .7rem; text-transform: uppercase; letter-spacing: .06em; font-weight: 600; padding-top: 12px; }
.cmp-table td.num { font-family: var(--font-mono); }
.cmp-table td.best { background: var(--tq-ok-soft); color: var(--tq-ok); font-weight: 600; }
.cmp-table tr.differs .cmp-lead { box-shadow: inset 3px 0 0 var(--tq-amber); }
.cmp-table .flags { color: var(--tq-muted); font-size: .72rem; }
.hist-row-wrap { display: flex; align-items: flex-start; gap: 4px; }
.hist-row-wrap .hist-row { flex: 1; min-width: 0; }
.hist-check { padding: 12px 0 0 8px; }
.hist-tabs { margin: 0 12px 10px; }
.hist-row.plain:hover { background: none; }
.delete-area { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.delete-question { font-size: .8rem; }
.hist-delete { flex: none; max-width: 45%; justify-content: flex-end; padding: 6px 4px 0 0; }
.hist-delete .btn-link { font-size: .78rem; text-decoration: none; }
.hist-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 0 12px 10px; font-size: .8rem; color: var(--tq-muted); }
