/* VIDAN — one stylesheet, no framework, no build step.
   Tokens first so Mode 4's cards and Mode 1's table share one vocabulary. */

:root {
  --bg: #0f1115;
  --surface: #171a21;
  --surface-2: #1e222b;
  --line: #2a2f3a;
  --text: #e7e9ee;
  --text-dim: #9aa3b2;
  --text-faint: #6b7483;
  --accent: #5b9dff;
  --accent-dim: #2f5aa8;
  --ok: #3fb950;
  --warn: #d29922;
  --bad: #f85149;
  --gap: #4a3a1a;
  --radius: 10px;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 var(--sans);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---- chrome ------------------------------------------------------------ */

header.top {
  display: flex; align-items: center; gap: 20px;
  padding: 12px 22px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  position: sticky; top: 0; z-index: 20;
}
header.top .brand { font-weight: 650; letter-spacing: .04em; font-size: 16px; }
header.top .brand span { color: var(--text-faint); font-weight: 400; margin-left: 10px;
                         font-size: 13px; letter-spacing: 0; }
header.top nav { display: flex; gap: 16px; margin-left: auto; align-items: center; }
header.top nav a { color: var(--text-dim); font-size: 14px; }
header.top nav a.on, header.top nav a:hover { color: var(--text); text-decoration: none; }

.lang { display: inline-flex; gap: 4px; border: 1px solid var(--line);
        border-radius: 6px; overflow: hidden; vertical-align: middle; }
.lang a { padding: 2px 8px; font-size: 12px; color: var(--text-faint); text-transform: uppercase; }
.lang a.on { background: var(--surface-2); color: var(--text); }

main { max-width: 1240px; margin: 0 auto; padding: 26px 22px 80px; }
h1 { font-size: 21px; font-weight: 620; margin: 0 0 4px; }
h2 { font-size: 16px; font-weight: 600; margin: 28px 0 10px; }
.sub { color: var(--text-dim); font-size: 13px; margin: 0 0 22px; }

/* ---- controls ---------------------------------------------------------- */

button, .btn {
  font: inherit; font-size: 14px;
  background: var(--accent-dim); color: var(--text);
  border: 1px solid transparent; border-radius: 7px;
  padding: 8px 15px; cursor: pointer;
}
button:hover, .btn:hover { background: var(--accent); text-decoration: none; }
button.ghost, .btn.ghost { background: transparent; border-color: var(--line);
                           color: var(--text-dim); }
button.ghost:hover, .btn.ghost:hover { color: var(--text); border-color: var(--text-faint);
                                       background: transparent; }
button:disabled { opacity: .45; cursor: not-allowed; }

input[type=password], input[type=text], input[type=search], select {
  font: inherit; background: var(--surface-2); color: var(--text);
  border: 1px solid var(--line); border-radius: 7px; padding: 9px 12px; width: 100%;
}
input:focus, select:focus { outline: 2px solid var(--accent-dim); outline-offset: -1px; }

/* ---- cards ------------------------------------------------------------- */

.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px 18px;
}
.cards { display: grid; gap: 12px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }

.modes { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); }
.mode {
  display: block; text-align: left; width: 100%;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; color: var(--text); cursor: pointer;
}
.mode:hover:not(:disabled) { border-color: var(--accent-dim); background: var(--surface-2); }
.mode[aria-pressed="true"] { border-color: var(--accent); background: var(--surface-2); }
.mode b { display: block; font-weight: 600; margin-bottom: 4px; }
.mode small { color: var(--text-dim); font-size: 12.5px; line-height: 1.45; }
.mode:disabled { opacity: .5; cursor: not-allowed; }
.mode .soon { float: right; font-size: 10.5px; color: var(--warn);
              border: 1px solid var(--warn); border-radius: 4px; padding: 0 5px;
              text-transform: uppercase; letter-spacing: .05em; }

/* ---- metric strip (Mode 4 reuses this) --------------------------------- */

.metrics { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
           margin: 14px 0 22px; }
.metric { background: var(--surface); border: 1px solid var(--line);
          border-radius: var(--radius); padding: 12px 14px; }
.metric .v { font-size: 22px; font-weight: 600; font-variant-numeric: tabular-nums; }
.metric .k { font-size: 11.5px; color: var(--text-dim); text-transform: uppercase;
             letter-spacing: .06em; margin-top: 3px; }
.metric.warn .v { color: var(--warn); }
.metric.bad .v { color: var(--bad); }

/* ---- tables ------------------------------------------------------------ */

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th {
  text-align: left; font-size: 11.5px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .06em; color: var(--text-dim);
  padding: 9px 12px; border-bottom: 1px solid var(--line);
  position: sticky; top: 53px; background: var(--bg); z-index: 5;
}
td { padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
tbody tr:hover { background: var(--surface); }
td.t { font-family: var(--mono); font-size: 12.5px; color: var(--text-dim);
       white-space: nowrap; width: 1%; }
td.who { white-space: nowrap; width: 1%; font-weight: 500; }
td.text { line-height: 1.5; }

/* A gap is a row, and it must look like a hole rather than like content. */
tr.gap td { background: var(--gap); color: #f0dfae; font-style: italic; }
tr.gap td.t { color: #f0dfae; }

.risk { display: inline-block; margin-left: 8px; font-size: 11px; color: var(--warn);
        border: 1px solid var(--warn); border-radius: 4px; padding: 0 5px;
        font-style: normal; vertical-align: 1px; }
.tier { font-size: 10.5px; color: var(--text-faint); font-family: var(--mono); }

/* ---- participants ------------------------------------------------------ */

.people { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 18px; }
.person { display: flex; align-items: center; gap: 8px;
          background: var(--surface); border: 1px solid var(--line);
          border-radius: 999px; padding: 5px 13px 5px 6px; font-size: 13px; }
.person .slot { display: inline-flex; align-items: center; justify-content: center;
                width: 22px; height: 22px; border-radius: 50%;
                background: var(--accent-dim); color: #fff;
                font-family: var(--mono); font-size: 12px; font-weight: 600; }
.person.off { opacity: .62; }
.person.noslot { padding-left: 13px; }
.person .note { color: var(--text-faint); font-size: 11.5px; }

/* ---- job progress ------------------------------------------------------ */

.bar { height: 6px; background: var(--surface-2); border-radius: 3px; overflow: hidden;
       margin: 10px 0 6px; }
.bar > i { display: block; height: 100%; background: var(--accent);
           transition: width .4s ease; }
.stages { display: flex; gap: 6px; flex-wrap: wrap; font-size: 11.5px;
          color: var(--text-faint); }
.stages span.on { color: var(--accent); font-weight: 600; }
.stages span.past { color: var(--text-dim); }

.state { font-size: 12px; padding: 2px 8px; border-radius: 999px; border: 1px solid; }
.state.queued { color: var(--text-dim); border-color: var(--line); }
.state.running { color: var(--accent); border-color: var(--accent-dim); }
.state.done { color: var(--ok); border-color: var(--ok); }
.state.failed { color: var(--bad); border-color: var(--bad); }

.error { background: #2a1416; border: 1px solid var(--bad); color: #ffb4ae;
         border-radius: 7px; padding: 10px 13px; font-size: 13.5px; margin: 10px 0; }
.notice { background: var(--surface-2); border: 1px solid var(--line);
          border-radius: 7px; padding: 10px 13px; font-size: 13.5px;
          color: var(--text-dim); margin: 10px 0; }

/* ---- login ------------------------------------------------------------- */

.login-wrap { min-height: 100vh; display: grid; place-items: center; }
.login { width: 340px; }
.login h1 { text-align: center; letter-spacing: .1em; }
.login .sub { text-align: center; }
.login form { display: grid; gap: 12px; margin-top: 18px; }

/* ---- upload ------------------------------------------------------------ */

.drop { border: 2px dashed var(--line); border-radius: var(--radius);
        padding: 44px 20px; text-align: center; color: var(--text-dim);
        background: var(--surface); cursor: pointer; }
.drop.over { border-color: var(--accent); color: var(--text); }
.drop input { display: none; }

.file-row { display: flex; align-items: center; gap: 14px; padding: 12px 0;
            border-bottom: 1px solid var(--line); }
.file-row .name { flex: 1; min-width: 0; }
.file-row .name b { display: block; font-weight: 500; overflow: hidden;
                    text-overflow: ellipsis; white-space: nowrap; }
.file-row .name small { color: var(--text-faint); font-size: 12px; }

@media (max-width: 760px) {
  main { padding: 18px 14px 60px; }
  th, td { padding: 8px 8px; }
  header.top { gap: 12px; padding: 10px 14px; }
}

/* ---- transcript review: player beside the table ------------------------- */

.split { display: grid; grid-template-columns: 380px 1fr; gap: 20px; align-items: start; }

.player { position: sticky; top: 66px; z-index: 10; background: var(--bg);
           padding-bottom: 8px; }
.player video { width: 100%; max-height: 46vh; border-radius: var(--radius);
                background: #000; border: 1px solid var(--line); display: block; }
.player-info { display: flex; align-items: center; gap: 10px; margin-top: 8px;
               font-size: 13px; color: var(--text-dim); }
.player-info .mono { font-family: var(--mono); color: var(--text); }
.player .hint { font-size: 11.5px; color: var(--text-faint); margin: 6px 0 0;
                line-height: 1.5; }

.toggle { display: inline-flex; align-items: center; gap: 6px; font-size: 13px;
          color: var(--text-dim); cursor: pointer; }
.toggle input { width: auto; }

.transcript table th { top: 53px; }
td.t a.seek { font-family: var(--mono); color: var(--text-dim); }
td.t a.seek:hover { color: var(--accent); }

tr.playing td { background: #1b2942; }
tr.playing td.t a.seek { color: var(--accent); font-weight: 600; }

/* Detected speech that never became an utterance. Distinct from a failed chunk: the run
   succeeded here, which is exactly why it needs to look different. */
tr.missing td { background: #2a2418; color: #d8c9a0; }

/* ---- inline editing ----------------------------------------------------- */

.edit-text, .edit-speaker { cursor: text; border-radius: 3px;
                            border-bottom: 1px dashed transparent; }
.edit-text:hover, .edit-speaker:hover,
.edit-text:focus, .edit-speaker:focus { border-bottom-color: var(--text-faint);
                                        outline: none; }
.edit-text.saving, .edit-speaker.saving { opacity: .5; }
.edit-text.save-failed, .edit-speaker.save-failed { background: #4a1d1d;
                                                    border-bottom-color: var(--bad); }

.inline-edit { font: inherit; width: 100%; background: var(--surface-2);
               color: var(--text); border: 1px solid var(--accent-dim);
               border-radius: 6px; padding: 6px 8px; resize: vertical; }

tr.edited td.t { border-left: 2px solid var(--ok); }
.edited-mark { display: inline-block; margin-left: 8px; font-size: 10.5px;
               color: var(--ok); border: 1px solid var(--ok); border-radius: 4px;
               padding: 0 5px; cursor: help; }
button.revert { background: transparent; border: 1px solid var(--line);
                color: var(--text-faint); font-size: 10.5px; padding: 1px 7px;
                margin-left: 5px; border-radius: 4px; }
button.revert:hover { color: var(--text); border-color: var(--text-faint);
                      background: transparent; }

#flash { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
         background: #4a1d1d; border: 1px solid var(--bad); color: #ffb4ae;
         padding: 10px 16px; border-radius: 8px; font-size: 13.5px; z-index: 50;
         opacity: 0; pointer-events: none; transition: opacity .2s; max-width: 80vw; }
#flash.on { opacity: 1; }

/* Narrow: one column, and the player stays stuck to the top rather than scrolling away.
   Reviewing means constant jumping between a row and its moment in the video, so losing the
   player off-screen is losing the feature. It shrinks instead of being dropped, and it
   carries an opaque background so rows never show through it. */
@media (max-width: 1000px) {
  .split { grid-template-columns: 1fr; }
  .player { top: 0; padding-top: 8px; border-bottom: 1px solid var(--line); }
  .player video { max-height: 32vh; }
  .player .hint { display: none; }
  .transcript table th { top: calc(32vh + 58px); }
}

/* Short windows: a 46vh video plus a sticky header leaves too little transcript to read. */
@media (max-height: 620px) {
  .player video { max-height: 38vh; }
}
