:root {
  --bg: #f5f5f4;
  --surface: #ffffff;
  --ink: #1c1917;
  --muted: #78716c;
  --border: #e7e5e4;
  --accent: #1d4ed8;
  --error: #b91c1c;
  --radius: 10px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1c1917;
    --surface: #292524;
    --ink: #f5f5f4;
    --muted: #a8a29e;
    --border: #44403c;
    --accent: #93c5fd;
    --error: #fca5a5;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 1.5rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.brand { font-weight: 700; text-decoration: none; color: var(--ink); letter-spacing: 0.02em; }

main { max-width: 60rem; margin: 2rem auto; padding: 0 1rem; }

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

.card--narrow { max-width: 24rem; margin: 4rem auto; }

h1 { margin-top: 0; font-size: 1.25rem; }

label { display: block; margin-bottom: 0.25rem; font-size: 0.875rem; color: var(--muted); }

input[type="password"], input[type="text"] {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--ink);
  margin-bottom: 1rem;
}

button {
  padding: 0.5rem 1rem;
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: var(--surface);
  font: inherit;
  cursor: pointer;
}

button.link { background: none; color: var(--muted); padding: 0; text-decoration: underline; }

.alert { padding: 0.5rem 0.75rem; border-radius: 6px; }
.alert--error { background: color-mix(in srgb, var(--error) 12%, transparent); color: var(--error); }

.empty { color: var(--muted); }

table.recordings { width: 100%; border-collapse: collapse; }
table.recordings th, table.recordings td {
  text-align: left; padding: 0.5rem; border-bottom: 1px solid var(--border);
}
table.recordings th { font-size: 0.8125rem; color: var(--muted); font-weight: 600; }

/* --- navigation ---------------------------------------------------------- */
.topbar nav { display: flex; align-items: center; gap: 1rem; }
.topbar nav a { color: var(--muted); text-decoration: none; }
.topbar nav a:hover { color: var(--ink); }

main { max-width: 64rem; }
.card + .card { margin-top: 1.5rem; }
h2 { font-size: 1.05rem; margin-top: 0; }

/* --- states -------------------------------------------------------------- */
.badge {
  display: inline-block;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  font-size: 0.8125rem;
  background: var(--border);
  color: var(--ink);
}
.badge--running { background: color-mix(in srgb, var(--accent) 22%, transparent); }
.badge--done { background: color-mix(in srgb, #16a34a 22%, transparent); }
.badge--failed { background: color-mix(in srgb, var(--error) 20%, transparent); color: var(--error); }

.muted { color: var(--muted); }
.error { color: var(--error); }

progress { width: 12rem; height: 0.6rem; vertical-align: middle; }

/* --- steps --------------------------------------------------------------- */
.steps { list-style: none; padding: 0; margin: 1rem 0 0; display: grid; gap: 0.25rem; }
.step {
  display: flex; align-items: baseline; gap: 0.75rem;
  padding: 0.35rem 0.5rem; border-radius: 6px; background: var(--bg);
}
.step__label { min-width: 9rem; }
.step__state { color: var(--muted); font-size: 0.875rem; min-width: 5rem; }
.step--done .step__state { color: #16a34a; }
.step--failed .step__state { color: var(--error); }
.step--running { background: color-mix(in srgb, var(--accent) 12%, transparent); }
.step form { margin-left: auto; }
.progress-line { margin-top: 0.75rem; }

/* --- forms --------------------------------------------------------------- */
.inline-form { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; }
.inline-form label { margin: 0; }
.inline-form input, .inline-form select { margin-bottom: 0; width: auto; min-width: 10rem; }

.speaker-row { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 0.5rem; }
.speaker-row label { margin: 0; min-width: 8rem; font-family: ui-monospace, monospace; }
.speaker-row input { margin-bottom: 0; max-width: 18rem; }
.confidence { font-size: 0.8125rem; color: var(--muted); }

select {
  padding: 0.5rem 0.75rem; border: 1px solid var(--border); border-radius: 6px;
  background: var(--bg); color: var(--ink);
}
button.danger { background: var(--error); }

audio { width: 100%; margin: 0.5rem 0 1rem; }

/* --- transcript ---------------------------------------------------------- */
.note {
  white-space: pre-wrap; font: inherit; background: var(--bg);
  padding: 1rem; border-radius: 8px; overflow-x: auto;
}
.transcript { display: grid; gap: 0.5rem; max-height: 40rem; overflow-y: auto; }
.turn { margin: 0; padding: 0.5rem 0.75rem; border-radius: 8px; border-left: 3px solid var(--border); background: var(--bg); }
.turn__meta { display: block; font-size: 0.8125rem; color: var(--muted); }
.turn.speaker-SPEAKER_00 { border-left-color: #2563eb; }
.turn.speaker-SPEAKER_01 { border-left-color: #16a34a; }
.turn.speaker-SPEAKER_02 { border-left-color: #d97706; }
.turn.speaker-SPEAKER_03 { border-left-color: #9333ea; }
.turn.speaker-SPEAKER_04 { border-left-color: #db2777; }
