/* ============================================================
   Speaker Lab — pastel, sharp, modern. No gradients, no glass,
   no big shadows, no emoji, no default blue/purple.
   ============================================================ */

@font-face {
  font-family: "Space Grotesk";
  src: url("/static/fonts/space-grotesk.ttf") format("truetype");
  font-weight: 300 700;
  font-style: normal;
}
@font-face {
  font-family: "IBM Plex Sans";
  src: url("/static/fonts/ibm-plex-sans.ttf") format("truetype");
  font-weight: 100 700;
  font-style: normal;
}
@font-face {
  font-family: "IBM Plex Mono";
  src: url("/static/fonts/ibm-plex-mono.ttf") format("truetype");
  font-weight: 100 700;
  font-style: normal;
}

:root {
  /* paper + ink */
  --paper: #f6f4ee;
  --card: #fffdf8;
  --ink: #26251f;
  --ink-soft: #6b6a60;
  --ink-faint: #9b9a8e;
  --line: #d9d5c8;
  --line-soft: #e6e2d6;

  /* accents (pastel, desaturated) */
  --accent: #d98e63;        /* terracotta — primary action */
  --accent-ink: #fffdf8;
  --ok: #7fae8b;            /* sage */
  --warn: #d9b45b;          /* ochre */
  --bad: #c97b6d;           /* clay */

  /* speaker pastels (assigned in order) */
  --spk-0: #cfe3d4;  /* sage */
  --spk-1: #f3d9b8;  /* apricot */
  --spk-2: #cfdcef;  /* powder blue */
  --spk-3: #e9cfd8;  /* blush */
  --spk-4: #ddd2ea;  /* lilac */
  --spk-5: #d7e3c9;  /* moss */
  --spk-6: #f0d5c4;  /* sand */
  --spk-7: #c9dde0;  /* mist */

  --r: 3px;
  --font-display: "Space Grotesk", sans-serif;
  --font-body: "IBM Plex Sans", sans-serif;
  --font-mono: "IBM Plex Mono", monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { font-family: var(--font-display); font-weight: 600; letter-spacing: -0.01em; margin: 0; }
h1 { font-size: 30px; }
h2 { font-size: 22px; }
h3 { font-size: 13px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-soft); font-weight: 600; }
.mono { font-family: var(--font-mono); font-size: 0.92em; }
.muted { color: var(--ink-faint); font-size: 13px; }
.lede { color: var(--ink-soft); max-width: 62ch; margin: 10px 0 26px; }

/* ---------- header ---------- */
.top {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 28px;
  border-bottom: 1px solid var(--line);
  background: var(--card);
  position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; align-items: baseline; gap: 10px; }
.brand-mark {
  width: 10px; height: 10px; background: var(--accent);
  display: inline-block; transform: translateY(1px);
}
.brand-name { font-family: var(--font-display); font-weight: 700; letter-spacing: 0.14em; font-size: 15px; }
.brand-sub { color: var(--ink-faint); font-size: 12px; }
.top-right { display: flex; gap: 8px; }
.pill {
  font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.04em;
  border: 1px solid var(--line); border-radius: var(--r);
  padding: 3px 8px; color: var(--ink-soft); background: var(--paper);
}
.pill-ok { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 40%, var(--line)); }

/* ---------- layout ---------- */
main { max-width: 1180px; margin: 0 auto; padding: 34px 28px 80px; }
.view { display: none; }
.view.active { display: block; }
.card, .upload-card, .panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r);
}
.card, .upload-card { padding: 30px; }
.panel { padding: 18px; }

/* ---------- buttons ---------- */
.btn {
  font-family: var(--font-display); font-weight: 600; font-size: 14px;
  letter-spacing: 0.02em;
  border: 1px solid var(--line); border-radius: var(--r);
  padding: 10px 18px; cursor: pointer;
  background: var(--card); color: var(--ink);
  transition: border-color .12s, background .12s, transform .05s;
}
.btn:hover:not(:disabled) { border-color: var(--ink-soft); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover:not(:disabled) { border-color: color-mix(in srgb, var(--accent) 70%, #000); }
.btn-ghost { background: transparent; }

/* ---------- upload ---------- */
.drop {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  border: 1px dashed var(--line); border-radius: var(--r);
  padding: 44px 20px; cursor: pointer;
  background: var(--paper);
  transition: border-color .12s, background .12s;
}
.drop:hover, .drop.drag { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 6%, var(--paper)); }
.drop input { display: none; }
.drop-icon {
  width: 34px; height: 34px; border: 1px solid var(--ink-soft); border-radius: var(--r);
  position: relative; margin-bottom: 6px;
}
.drop-icon::before, .drop-icon::after {
  content: ""; position: absolute; left: 50%; background: var(--ink-soft);
}
.drop-icon::before { width: 12px; height: 1.5px; top: 50%; transform: translate(-50%, -50%); }
.drop-icon::after { width: 1.5px; height: 12px; left: 50%; top: 50%; transform: translate(-50%, -50%); }
.drop-text { font-family: var(--font-display); font-weight: 600; font-size: 16px; }
.drop-hint { font-family: var(--font-mono); font-size: 11px; color: var(--ink-faint); }
.drop.has-file { border-style: solid; border-color: var(--ok); }

.form-row { margin-top: 26px; }
.field { display: flex; flex-direction: column; gap: 7px; }
.field-label { font-family: var(--font-display); font-weight: 600; font-size: 14px; }
.field-hint { font-size: 12px; color: var(--ink-faint); }

.count-ctl { display: inline-flex; align-items: stretch; width: fit-content; border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; background: var(--card); }
.count-ctl input {
  width: 74px; border: none; background: transparent; color: var(--ink);
  font-family: var(--font-mono); font-size: 18px; text-align: center; padding: 9px 0;
  -moz-appearance: textfield; appearance: textfield;
}
.count-ctl input::-webkit-outer-spin-button, .count-ctl input::-webkit-inner-spin-button { -webkit-appearance: none; }
.count-btn {
  border: none; background: var(--paper); color: var(--ink);
  font-size: 18px; width: 42px; cursor: pointer; font-family: var(--font-display);
  border-left: 1px solid var(--line);
}
.count-btn:first-child { border-left: none; }
.count-btn:hover { background: var(--line-soft); }

.run-row { display: flex; align-items: center; gap: 14px; margin-top: 26px; }

.steps { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--r); margin-top: 22px; overflow: hidden; }
.step { background: var(--card); padding: 12px 14px; font-size: 12.5px; color: var(--ink-soft); display: flex; gap: 9px; align-items: baseline; }
.step-n { font-family: var(--font-mono); font-size: 11px; color: var(--accent); }

/* ---------- progress ---------- */
.bar { height: 6px; background: var(--line-soft); border-radius: var(--r); margin: 18px 0 22px; overflow: hidden; }
.bar-fill { height: 100%; width: 0%; background: var(--accent); transition: width .4s ease; }
.prog-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px; margin-bottom: 18px; }
.prog-grid .k { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-faint); }
.prog-grid .v { font-size: 17px; font-family: var(--font-display); font-weight: 600; }
.log {
  font-family: var(--font-mono); font-size: 12px; line-height: 1.7;
  background: #26251f; color: #d8d5c8; border-radius: var(--r);
  padding: 14px 16px; max-height: 220px; overflow-y: auto; white-space: pre-wrap;
  margin: 0 0 18px;
}
.log .err { color: #e8a08f; }

/* ---------- review ---------- */
.review-head { display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: 20px; }
.review-actions { display: flex; gap: 10px; }
.review-body { display: grid; grid-template-columns: 320px 1fr; gap: 18px; align-items: start; }
.side { display: flex; flex-direction: column; gap: 18px; position: sticky; top: 76px; }
.badge {
  font-family: var(--font-mono); font-size: 11px; font-weight: 400;
  background: color-mix(in srgb, var(--warn) 22%, var(--card));
  color: #8a6d1f; border: 1px solid color-mix(in srgb, var(--warn) 45%, var(--line));
  border-radius: var(--r); padding: 1px 7px; margin-left: 6px;
}
.badge.zero { background: color-mix(in srgb, var(--ok) 16%, var(--card)); color: #4c7a58; border-color: color-mix(in srgb, var(--ok) 40%, var(--line)); }

.speaker-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line-soft); }
.speaker-row:last-child { border-bottom: none; }
.swatch { width: 14px; height: 14px; border-radius: 2px; flex: none; border: 1px solid rgba(0,0,0,.12); }
.speaker-row input {
  flex: 1; min-width: 0; border: 1px solid var(--line); border-radius: var(--r);
  background: var(--paper); padding: 5px 9px; font-family: var(--font-body); font-size: 14px; color: var(--ink);
  cursor: text;
}
.speaker-row input:hover { border-color: var(--ink-faint); }
.speaker-row input:focus { outline: none; border-color: var(--accent); background: var(--card); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 18%, transparent); }
.speaker-row input::placeholder { color: var(--ink-faint); }
.speaker-row .stat { font-family: var(--font-mono); font-size: 11px; color: var(--ink-faint); flex: none; }

.conflict-item {
  border: 1px solid var(--line); border-radius: var(--r);
  padding: 9px 11px; margin-bottom: 8px; background: var(--paper);
  font-size: 12.5px; cursor: pointer; transition: border-color .12s;
}
.conflict-item:hover { border-color: var(--warn); }
.conflict-item .ts { font-family: var(--font-mono); font-size: 11px; color: var(--ink-faint); display: block; margin-bottom: 3px; }
.conflict-item .txt { color: var(--ink-soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conflict-item .tag { font-family: var(--font-mono); font-size: 10px; color: #8a6d1f; }

/* transcript */
.transcript-panel { min-height: 480px; display: flex; flex-direction: column; }
.transcript-tools { display: flex; gap: 14px; align-items: center; padding-bottom: 12px; border-bottom: 1px solid var(--line-soft); margin-bottom: 6px; }
.transcript-tools input[type="search"] {
  flex: 1; border: 1px solid var(--line); border-radius: var(--r); background: var(--paper);
  padding: 8px 12px; font-family: var(--font-body); font-size: 14px; color: var(--ink);
}
.transcript-tools input[type="search"]:focus { outline: none; border-color: var(--accent); }
.check { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--ink-soft); cursor: pointer; white-space: nowrap; }
.check input { accent-color: var(--accent); }

.transcript { overflow-y: auto; max-height: calc(100vh - 320px); padding: 6px 4px; }
.turn { display: flex; gap: 14px; padding: 9px 10px; border-radius: var(--r); align-items: baseline; }
.turn:hover { background: var(--paper); }
.turn.selected { background: color-mix(in srgb, var(--accent) 9%, var(--card)); outline: 1px solid color-mix(in srgb, var(--accent) 45%, var(--line)); }
.turn-time { font-family: var(--font-mono); font-size: 11.5px; color: var(--ink-faint); flex: none; width: 92px; }
.turn-body { flex: 1; min-width: 0; }
.turn-speaker { font-family: var(--font-display); font-weight: 600; font-size: 13px; margin-right: 8px; }
.turn-text { font-size: 14.5px; }
.turn-flag {
  font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.03em;
  border: 1px solid color-mix(in srgb, var(--warn) 50%, var(--line));
  color: #8a6d1f; background: color-mix(in srgb, var(--warn) 14%, var(--card));
  border-radius: var(--r); padding: 1px 6px; margin-left: 8px; cursor: pointer;
}
.turn-flag:hover { background: color-mix(in srgb, var(--warn) 26%, var(--card)); }
.turn.unresolved { background: color-mix(in srgb, var(--warn) 7%, var(--card)); }
.turn.unresolved .turn-text { color: var(--ink-soft); }

/* assign popover */
.assign-pop {
  position: fixed; z-index: 50; background: var(--card);
  border: 1px solid var(--line); border-radius: var(--r);
  box-shadow: 0 2px 10px rgba(38,37,31,.12);
  padding: 6px; min-width: 180px;
}
.assign-pop .ap-title { font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-faint); padding: 5px 10px 7px; }
.assign-pop button {
  display: flex; align-items: center; gap: 9px; width: 100%;
  border: none; background: transparent; padding: 7px 10px;
  font-family: var(--font-body); font-size: 13.5px; color: var(--ink);
  border-radius: var(--r); cursor: pointer; text-align: left;
}
.assign-pop button:hover { background: var(--paper); }
.assign-pop button .swatch { width: 12px; height: 12px; }

/* ---------- export ---------- */
.export-grid { display: grid; grid-template-columns: 260px 1fr; gap: 26px; margin-top: 18px; }
.export-opts { display: flex; flex-direction: column; gap: 18px; }
.export-opts select {
  border: 1px solid var(--line); border-radius: var(--r); background: var(--paper);
  padding: 9px 12px; font-family: var(--font-body); font-size: 14px; color: var(--ink);
}
.export-opts .check { margin-bottom: 6px; }
.export-opts .btn { width: fit-content; }
.preview {
  font-family: var(--font-mono); font-size: 12px; line-height: 1.7;
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--r);
  padding: 16px; max-height: 560px; overflow: auto; white-space: pre-wrap; word-break: break-word;
  margin: 0;
}

.foot {
  border-top: 1px solid var(--line);
  padding: 16px 28px; text-align: center;
  font-family: var(--font-mono); font-size: 11px; color: var(--ink-faint);
}

/* ---------- responsive ---------- */
@media (max-width: 900px) {
  .review-body { grid-template-columns: 1fr; }
  .side { position: static; }
  .steps, .prog-grid { grid-template-columns: repeat(2, 1fr); }
  .export-grid { grid-template-columns: 1fr; }
}
