:root {
  --paper: #F1F3F0;
  --surface: #FFFFFF;
  --ink: #1C2226;
  --muted: #5A666C;
  --line: #D3D9D5;
  --accent: #2E6A57;
  --accent-ink: #FFFFFF;
  --accent-soft: #E1ECE6;
  --danger: #A63D2F;
  --ui: "Manrope", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --read: "Source Serif 4", Georgia, "Times New Roman", serif;
  --r-sm: 8px;
  --r-lg: 16px;
  color-scheme: light dark;
  box-sizing: border-box;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #121718;
    --surface: #1A2124;
    --ink: #E4E9E6;
    --muted: #98A5A0;
    --line: #2C3538;
    --accent: #86C8B1;
    --accent-ink: #0F1A16;
    --accent-soft: #1F3029;
    --danger: #E08A7C;
  }
}

*, *::before, *::after { box-sizing: inherit; }
[hidden] { display: none !important; }

html { background: var(--paper); }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 16px/1.5 var(--ui);
  -webkit-font-smoothing: antialiased;
}

.shell { max-width: 680px; margin: 0 auto; padding: 28px 20px 72px; }

.masthead { margin-bottom: 28px; }
.brand { margin: 0 0 22px; font-weight: 700; font-size: 15px; letter-spacing: 0.04em; color: var(--accent); }
h1 { margin: 0; font-size: clamp(28px, 7vw, 38px); line-height: 1.08; font-weight: 700; letter-spacing: -0.025em; }
.lede { margin: 12px 0 0; color: var(--muted); max-width: 52ch; }
h2 { margin: 0 0 14px; font-size: 18px; line-height: 1.3; font-weight: 700; }

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 20px;
  margin-bottom: 20px;
}

.field { margin-bottom: 18px; }
label, .label { display: block; margin-bottom: 6px; font-size: 14px; font-weight: 600; }
.hint { margin: 6px 0 0; font-size: 13px; color: var(--muted); min-height: 1.2em; }
.hint strong { color: var(--ink); font-weight: 600; overflow-wrap: anywhere; }

input[type="text"], input[type="date"] {
  width: 100%;
  min-height: 48px;
  padding: 11px 12px;
  font: inherit;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  -webkit-appearance: none;
  appearance: none;
}

:is(input, button):focus-visible, .drop:focus-within, .recent-list button:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent) 45%, transparent);
  outline-offset: 2px;
}

.drop {
  position: relative;
  display: grid;
  gap: 4px;
  padding: 22px 18px;
  margin: 0;
  background: var(--paper);
  border: 1.5px dashed var(--line);
  border-radius: var(--r-sm);
  cursor: pointer;
  font-weight: 400;
}
.drop input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.drop.dragging { border-color: var(--accent); }
.drop.has-file { border-style: solid; border-color: var(--accent); background: var(--accent-soft); }
.drop-title { font-size: 16px; font-weight: 600; overflow-wrap: anywhere; }
.drop-sub { font-size: 13px; color: var(--muted); }

button {
  min-height: 44px;
  padding: 10px 16px;
  font: inherit;
  font-weight: 600;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  cursor: pointer;
}
.primary {
  width: 100%;
  min-height: 52px;
  font-size: 16px;
  color: var(--accent-ink);
  background: var(--accent);
  border-color: var(--accent);
}
button:disabled { opacity: 0.55; cursor: progress; }

.form-error { margin: 12px 0 0; font-size: 14px; color: var(--danger); }

.steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; counter-reset: step; }
.steps li { position: relative; min-height: 24px; padding-left: 36px; color: var(--muted); counter-increment: step; }
.steps li::before {
  content: counter(step);
  position: absolute;
  left: 0;
  top: 0;
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 700;
  border: 1.5px solid var(--line);
  border-radius: 50%;
}
.steps li.done { color: var(--ink); }
.steps li.done::before { content: "✓"; color: var(--accent-ink); background: var(--accent); border-color: var(--accent); }
.steps li.active { color: var(--ink); font-weight: 600; }
.steps li.active::before { color: var(--accent); border-color: var(--accent); animation: pulse 1.6s ease-in-out infinite; }
.steps li.failed { color: var(--danger); font-weight: 600; }
.steps li.failed::before { content: "!"; color: var(--danger); border-color: var(--danger); animation: none; }
.pct { font-weight: 400; color: var(--muted); font-variant-numeric: tabular-nums; }
@keyframes pulse { 50% { box-shadow: 0 0 0 6px color-mix(in srgb, var(--accent) 20%, transparent); } }

.result-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.result-head h2 { margin: 0; }
.actions { display: flex; gap: 8px; }
.meta { margin: 6px 0 18px; font-size: 13px; color: var(--muted); }

.transcript { font-family: var(--read); font-size: 18px; line-height: 1.65; }
.turn { display: grid; grid-template-columns: 92px 1fr; gap: 2px 16px; padding: 12px 0; border-top: 1px solid var(--line); }
.turn:first-child { border-top: 0; padding-top: 0; }
.speaker { padding-top: 5px; font-family: var(--ui); font-size: 13px; font-weight: 700; color: var(--muted); overflow-wrap: anywhere; }
.turn.clinician .speaker { color: var(--accent); }
.turn p { margin: 0; max-width: 65ch; white-space: pre-wrap; }

.recent { margin-top: 36px; }
.recent-list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.recent-list button {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 2px 12px;
  width: 100%;
  min-height: 0;
  padding: 14px 4px;
  text-align: left;
  font-weight: 400;
  background: none;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
}
.r-name { font-weight: 600; overflow-wrap: anywhere; }
.r-sub { grid-column: 1; font-size: 13px; color: var(--muted); }
.r-status { grid-column: 2; grid-row: 1 / span 2; align-self: center; font-size: 13px; font-weight: 600; color: var(--muted); }
.r-status.completed { color: var(--accent); }
.r-status.failed { color: var(--danger); }
.empty { color: var(--muted); }

@media (max-width: 480px) {
  .shell { padding: 20px 16px 64px; }
  .panel { padding: 16px; }
  .turn { grid-template-columns: 1fr; }
  .speaker { padding-top: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .steps li.active::before { animation: none; }
}
