/* Colors are tokens: light by default, dark when Windows (or the browser) asks for it. */
:root {
  --font-ui: "Segoe UI", system-ui, -apple-system, Arial, sans-serif;
  --font-doc: Georgia, "Times New Roman", serif;
  --sidebar-width: 288px;

  --bg: #f4f1e8;
  --sidebar: #ece8dc;
  --surface: #faf8f2;
  --raised: #ffffff;
  --ink: #17201d;
  --ink-2: #3b4642;
  --muted: #68716d;
  --faint: #8f9792;
  --line: rgba(23, 32, 29, 0.11);
  --line-strong: rgba(23, 32, 29, 0.2);
  --hover: rgba(23, 32, 29, 0.05);
  --coral: #e7674a;
  --coral-strong: #c94c31;
  --coral-soft: rgba(231, 103, 74, 0.11);
  --on-coral: #ffffff;
  --green: #376b56;
  --green-soft: rgba(55, 107, 86, 0.12);
  --ok: #4b966f;
  --pending: #d5a633;
  --warn-bg: #fcefe8;
  --warn-ink: #8a3f30;
  --playing: rgba(231, 103, 74, 0.17);
  --toast-bg: #17201d;
  --toast-ink: #f4f1e8;
  --shadow-pop: 0 16px 40px rgba(23, 32, 29, 0.16), 0 2px 6px rgba(23, 32, 29, 0.06);
  --speaker-1: #c9573a;
  --speaker-2: #3d7a5f;
  --speaker-3: #3f6aa3;
  --speaker-4: #95660f;
  --speaker-5: #8a4f8f;
  --speaker-6: #2b7f7e;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111614;
    --sidebar: #0e1311;
    --surface: #161c19;
    --raised: #1e2521;
    --ink: #e8e5da;
    --ink-2: #cbc9bf;
    --muted: #9aa39e;
    --faint: #737c77;
    --line: rgba(232, 229, 218, 0.09);
    --line-strong: rgba(232, 229, 218, 0.18);
    --hover: rgba(232, 229, 218, 0.055);
    --coral: #ef7a5d;
    --coral-strong: #ff9479;
    --coral-soft: rgba(239, 122, 93, 0.15);
    --on-coral: #1b1210;
    --green: #8cc3a8;
    --green-soft: rgba(140, 195, 168, 0.13);
    --ok: #6cc196;
    --warn-bg: rgba(239, 122, 93, 0.12);
    --warn-ink: #f3b4a2;
    --playing: rgba(239, 122, 93, 0.24);
    --toast-bg: #e8e5da;
    --toast-ink: #161c19;
    --shadow-pop: 0 18px 44px rgba(0, 0, 0, 0.45), 0 2px 6px rgba(0, 0, 0, 0.3);
    --speaker-1: #f08b6f;
    --speaker-2: #8cc3a8;
    --speaker-3: #8fb3e6;
    --speaker-4: #e0b25a;
    --speaker-5: #d49bd8;
    --speaker-6: #7fcfcd;
  }
}

* { box-sizing: border-box; scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
[hidden] { display: none !important; }
html, body { height: 100%; }

body {
  margin: 0;
  overflow: hidden;
  color: var(--ink);
  background: var(--bg);
  font-family: var(--font-ui);
  font-size: 15px;
}

button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; }
:focus-visible { outline: 2px solid var(--coral); outline-offset: 2px; }

.icon {
  width: 18px;
  height: 18px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.icon.small { width: 14px; height: 14px; }

/* ---------- Frame ---------- */
.app { height: 100vh; display: grid; grid-template-columns: var(--sidebar-width) minmax(0, 1fr); }

/* ---------- Sidebar ---------- */
.sidebar {
  min-height: 0;
  display: flex;
  flex-direction: column;
  border-inline-end: 1px solid var(--line);
  background: var(--sidebar);
}
.sidebar-top { display: flex; flex-direction: column; gap: 12px; padding: 18px 14px 8px; }

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 2px 6px 4px;
  color: var(--ink);
  font-size: 1.14rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  text-decoration: none;
}
.brand-mark { direction: ltr; height: 22px; display: flex; align-items: center; gap: 3px; }
.brand-mark i { display: block; width: 3px; border-radius: 3px; background: var(--coral); }
.brand-mark i:nth-child(1), .brand-mark i:nth-child(5) { height: 7px; }
.brand-mark i:nth-child(2), .brand-mark i:nth-child(4) { height: 14px; }
.brand-mark i:nth-child(3) { height: 21px; }

.kbd {
  padding: 1px 5px;
  border: 1px solid currentColor;
  border-radius: 5px;
  font-size: 0.66rem;
  font-weight: 600;
  line-height: 1.4;
  white-space: nowrap;
  opacity: 0.55;
}

.new-button {
  display: flex;
  align-items: center;
  gap: 9px;
  height: 40px;
  padding: 0 12px;
  border: 0;
  border-radius: 10px;
  color: var(--on-coral);
  background: var(--coral);
  font-weight: 700;
  transition: background 0.15s;
}
.new-button:hover { background: var(--coral-strong); }
.new-button .kbd { margin-inline-start: auto; }
.new-button.current { box-shadow: 0 0 0 3px var(--coral-soft); }

.search { position: relative; display: block; }
.search input {
  width: 100%;
  height: 36px;
  padding-inline: 34px 64px;
  border: 1px solid var(--line);
  border-radius: 9px;
  outline: none;
  background: var(--surface);
  font-size: 0.86rem;
}
.search input:focus { border-color: var(--coral); box-shadow: 0 0 0 3px var(--coral-soft); }
/* Physical sides on purpose: logical insets would follow each element's own direction. */
.search > .icon { position: absolute; top: 10px; right: 11px; width: 16px; height: 16px; color: var(--faint); }
.search .kbd { position: absolute; top: 9px; left: 9px; color: var(--muted); }

.history { flex: 1; min-height: 0; overflow: auto; padding: 2px 8px 14px; }
.history-group { margin: 16px 10px 6px; color: var(--faint); font-size: 0.72rem; font-weight: 700; letter-spacing: 0.04em; }
.history-row { position: relative; }
.history-open {
  position: relative;
  display: block;
  width: 100%;
  padding: 9px 12px;
  border: 0;
  border-radius: 10px;
  background: none;
  text-align: start;
}
.history-open:hover { background: var(--hover); }
.history-open.active { background: var(--surface); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05); }
.history-open.active::before {
  content: "";
  position: absolute;
  top: 10px;
  bottom: 10px;
  inset-inline-start: 0;
  width: 3px;
  border-radius: 3px;
  background: var(--coral);
}
.history-title { display: flex; align-items: center; gap: 6px; padding-inline-end: 24px; font-size: 0.89rem; font-weight: 600; }
.history-title span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge { flex: none; padding: 0 6px; border-radius: 999px; color: var(--on-coral); background: var(--coral); font-size: 0.64rem; font-style: normal; font-weight: 800; line-height: 1.5; }
.history-meta { display: block; margin-top: 2px; color: var(--muted); font-size: 0.74rem; }
.history-preview { display: block; margin-top: 3px; overflow: hidden; color: var(--faint); font-size: 0.79rem; text-overflow: ellipsis; white-space: nowrap; }
.history-delete { position: absolute; top: 6px; inset-inline-end: 6px; width: 28px; height: 28px; opacity: 0; }
.history-row:hover .history-delete, .history-delete:focus-visible { opacity: 1; }
.history-delete:hover { color: var(--coral-strong); }
.history-empty { margin: 24px 12px; color: var(--muted); font-size: 0.86rem; line-height: 1.6; }

.run-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  margin: 6px 0 2px;
  padding: 10px 12px;
  border: 1px solid color-mix(in srgb, var(--coral) 35%, transparent);
  border-radius: 10px;
  background: var(--coral-soft);
  text-align: start;
}
.run-item > div { flex: 1; min-width: 0; }
.run-item strong { display: block; overflow: hidden; font-size: 0.86rem; text-overflow: ellipsis; white-space: nowrap; }
.run-item small { display: block; margin: 2px 0 6px; color: var(--muted); font-size: 0.74rem; }

.spinner {
  width: 16px;
  height: 16px;
  flex: none;
  border: 2px solid var(--coral-soft);
  border-top-color: var(--coral);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

progress.bar {
  display: block;
  width: 100%;
  height: 8px;
  border: 0;
  border-radius: 8px;
  overflow: hidden;
  appearance: none;
  background: var(--hover);
}
progress.bar::-webkit-progress-bar { background: var(--hover); }
progress.bar::-webkit-progress-value { background: var(--coral); transition: width 0.4s ease; }
progress.bar::-moz-progress-bar { background: var(--coral); }
progress.bar.mini { height: 4px; }

.update-pill {
  margin: 0 12px 10px;
  padding: 9px 12px;
  border: 0;
  border-radius: 10px;
  color: var(--on-coral);
  background: var(--coral);
  font-size: 0.84rem;
  font-weight: 700;
}
.update-pill:hover { background: var(--coral-strong); }

.sidebar-foot { display: flex; align-items: center; gap: 6px; padding: 10px 10px 10px 8px; border-top: 1px solid var(--line); }
.server-status {
  display: flex;
  flex: 1;
  min-width: 0;
  align-items: center;
  gap: 9px;
  padding: 6px 8px;
  border: 0;
  border-radius: 8px;
  background: none;
  color: var(--muted);
  font-size: 0.78rem;
  text-align: start;
}
.server-status:hover { background: var(--hover); }
.status-dot {
  width: 8px;
  height: 8px;
  flex: none;
  border-radius: 50%;
  background: var(--pending);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--pending) 18%, transparent);
}
.server-status.ready .status-dot { background: var(--ok); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 18%, transparent); }
.server-status.warning { color: var(--warn-ink); }
.server-status.warning .status-dot { background: var(--coral); box-shadow: 0 0 0 3px var(--coral-soft); }

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  flex: none;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 9px;
  background: none;
  color: var(--muted);
}
.icon-button:hover:not(:disabled) { background: var(--hover); color: var(--ink); }
.icon-button.bordered { border-color: var(--line-strong); background: var(--raised); }
.icon-button.bordered:hover { border-color: var(--coral); color: var(--coral-strong); }

/* ---------- Main ---------- */
.main { position: relative; min-width: 0; min-height: 0; display: flex; flex-direction: column; background: var(--surface); }
.view { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.scroll { flex: 1; min-height: 0; overflow: auto; }
.drawer-button { position: absolute; z-index: 5; top: 16px; inset-inline-start: 14px; display: none; }

.button {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 34px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  background: var(--raised);
  font-size: 0.86rem;
  font-weight: 600;
  white-space: nowrap;
}
.button:hover:not(:disabled) { border-color: var(--coral); color: var(--coral-strong); }
.button:disabled { opacity: 0.5; }
.button.small { height: 30px; padding: 0 10px; font-size: 0.8rem; }
.button.solid { border-color: var(--coral); color: var(--on-coral); background: var(--coral); }
.button.solid:hover:not(:disabled) { color: var(--on-coral); background: var(--coral-strong); }

.form-error { margin-top: 18px; padding: 12px 14px; border-radius: 10px; color: var(--warn-ink); background: var(--warn-bg); font-size: 0.88rem; line-height: 1.55; }
.note { margin: 14px 0 0; color: var(--faint); font-size: 0.8rem; line-height: 1.6; text-align: center; }

/* ---------- New transcription ---------- */
.new-inner { max-width: 760px; margin: 0 auto; padding: 56px 40px 48px; }
.new-inner h1 { margin: 0; font-family: var(--font-doc); font-size: 2.35rem; font-weight: 500; letter-spacing: -0.02em; }
.new-inner h1 em { color: var(--coral); font-style: normal; }
.lede { margin: 10px 0 28px; color: var(--muted); font-size: 1rem; line-height: 1.7; }

.banner {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
  padding: 12px 14px;
  border: 1px solid color-mix(in srgb, var(--coral) 30%, transparent);
  border-radius: 12px;
  color: var(--warn-ink);
  background: var(--warn-bg);
  font-size: 0.88rem;
  line-height: 1.55;
}
.banner > span { flex: 1; }
.banner .icon-button { width: 28px; height: 28px; color: inherit; }

.drop-zone {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 250px;
  padding: 28px;
  border: 1.5px dashed var(--line-strong);
  border-radius: 18px;
  background: color-mix(in srgb, var(--bg) 55%, transparent);
  text-align: center;
  cursor: pointer;
  transition: 0.18s ease;
}
.drop-zone:hover, .drop-zone:focus-within { border-color: var(--coral); background: var(--coral-soft); }
.drop-zone input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.drop-icon { display: grid; place-items: center; width: 54px; height: 54px; margin-bottom: 6px; border-radius: 50%; color: var(--coral); background: var(--coral-soft); }
.drop-icon .icon { width: 26px; height: 26px; }
.drop-zone strong { font-size: 1.02rem; }
.drop-zone small { color: var(--muted); font-size: 0.8rem; line-height: 1.6; }

.file-card { display: flex; align-items: center; gap: 14px; padding: 16px 18px; border: 1px solid var(--line); border-radius: 14px; background: var(--raised); }
.file-icon { display: grid; place-items: center; width: 46px; height: 46px; flex: none; border-radius: 11px; color: var(--green); background: var(--green-soft); }
.file-info { flex: 1; min-width: 0; }
.file-info strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-info small { display: block; margin-top: 3px; color: var(--muted); font-size: 0.8rem; }

.options { display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: 16px; margin-top: 22px; }
.field > span { display: block; margin-bottom: 7px; color: var(--ink-2); font-size: 0.82rem; font-weight: 700; }
.field small { color: var(--muted); font-weight: 400; }
.field input, .field select {
  width: 100%;
  height: 44px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  outline: none;
  background: var(--raised);
}
.field input:focus, .field select:focus { border-color: var(--coral); box-shadow: 0 0 0 3px var(--coral-soft); }

.primary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  width: 100%;
  height: 52px;
  margin-top: 22px;
  border: 0;
  border-radius: 12px;
  color: var(--on-coral);
  background: var(--coral);
  font-size: 1rem;
  font-weight: 800;
  transition: 0.15s;
}
.primary-button:hover:not(:disabled) { background: var(--coral-strong); }
.primary-button:disabled { opacity: 0.42; cursor: not-allowed; }

/* ---------- Progress ---------- */
.progress-inner { max-width: 620px; margin: 0 auto; padding: 64px 40px 48px; }
.eyebrow { margin: 0 0 6px; color: var(--coral-strong); font-size: 0.8rem; font-weight: 700; }
.progress-title { margin: 0 0 22px; overflow: hidden; font-size: 1.5rem; text-overflow: ellipsis; white-space: nowrap; }
.progress-card { padding: 22px 24px; border: 1px solid var(--line); border-radius: 18px; background: var(--raised); }
.stepper { display: flex; flex-direction: column; gap: 2px; margin: 0 0 20px; padding: 0; list-style: none; }
.step { position: relative; display: flex; align-items: flex-start; gap: 14px; padding: 10px 0; color: var(--faint); }
.step:not(:last-child)::after {
  content: "";
  position: absolute;
  top: 40px;
  bottom: -8px;
  inset-inline-start: 12px;
  width: 1.5px;
  background: var(--line);
}
.step-icon { display: grid; place-items: center; width: 26px; height: 26px; flex: none; border: 1.5px solid var(--line-strong); border-radius: 50%; background: var(--raised); }
.step-icon .icon { width: 14px; height: 14px; stroke-width: 2.4; }
.step-icon .spinner { width: 14px; height: 14px; }
.step strong { display: block; font-size: 0.95rem; }
.step small { display: block; margin-top: 2px; color: var(--muted); font-size: 0.8rem; }
.step.done { color: var(--ink-2); }
.step.done .step-icon { border-color: var(--green); color: var(--surface); background: var(--green); }
.step.active { color: var(--ink); }
.step.active .step-icon { border-color: var(--coral); }
.progress-foot { display: flex; align-items: center; gap: 16px; margin-top: 12px; color: var(--muted); font-size: 0.82rem; }
.progress-foot strong { color: var(--ink); font-variant-numeric: tabular-nums; }
.progress-foot .button { margin-inline-start: auto; }

/* ---------- Transcript ---------- */
.doc-head { padding: 18px 32px 0; border-bottom: 1px solid var(--line); background: var(--surface); }
.doc-head-row { display: flex; align-items: flex-start; gap: 16px; }
.doc-title { flex: 1; min-width: 0; }
.doc-title h1 { margin: 0; overflow: hidden; font-size: 1.32rem; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.doc-meta { margin-top: 4px; color: var(--muted); font-size: 0.82rem; }
/* File names show without their extension (no bidi mix-ups like "mp3.12"); the type is a tag. */
.ext {
  display: inline-block;
  margin-inline-start: 10px;
  padding: 1px 7px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  color: var(--muted);
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  vertical-align: 3px;
}
.actions { display: flex; align-items: center; gap: 6px; }

.menu-wrap { position: relative; }
.menu {
  position: absolute;
  z-index: 30;
  top: calc(100% + 6px);
  inset-inline-end: 0;
  min-width: 200px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--raised);
  box-shadow: var(--shadow-pop);
}
.menu.wide { min-width: 300px; }
.menu > button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: 8px;
  background: none;
  font-size: 0.88rem;
  text-align: start;
}
.menu > button:hover { background: var(--hover); }
.menu > button small { margin-inline-start: auto; color: var(--faint); font-size: 0.74rem; }
.menu .danger { color: var(--coral-strong); }
.menu-title { margin: 6px 10px 8px; color: var(--faint); font-size: 0.72rem; font-weight: 700; letter-spacing: 0.04em; }
.menu-sep { height: 1px; margin: 6px 4px; background: var(--line); }
.tech { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 6px 14px; margin: 0 10px 8px; font-size: 0.8rem; }
.tech dt { color: var(--muted); white-space: nowrap; }
.tech dd { margin: 0; overflow-wrap: anywhere; color: var(--ink-2); text-align: end; }

.speaker-1 { --speaker: var(--speaker-1); }
.speaker-2 { --speaker: var(--speaker-2); }
.speaker-3 { --speaker: var(--speaker-3); }
.speaker-4 { --speaker: var(--speaker-4); }
.speaker-5 { --speaker: var(--speaker-5); }
.speaker-6 { --speaker: var(--speaker-6); }
.speaker-none { --speaker: var(--faint); }

.speaker-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 14px; }
.speaker-bar-label { margin-inline-end: 2px; color: var(--muted); font-size: 0.78rem; }
.speaker-bar-hint { color: var(--faint); font-size: 0.74rem; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 28px;
  padding: 0 11px;
  border: 1px solid transparent;
  border-radius: 999px;
  color: var(--speaker);
  background: color-mix(in srgb, var(--speaker) 13%, transparent);
  font-size: 0.84rem;
  font-weight: 700;
  white-space: nowrap;
}
.chip-dot { width: 8px; height: 8px; flex: none; border-radius: 50%; background: var(--speaker); }
button.chip:hover { border-color: color-mix(in srgb, var(--speaker) 50%, transparent); }
.chip .icon { width: 13px; height: 13px; opacity: 0; transition: opacity 0.15s; }
button.chip:hover .icon, button.chip:focus-visible .icon { opacity: 0.85; }
.chip.editing { border-color: var(--speaker); background: var(--raised); box-shadow: 0 0 0 3px color-mix(in srgb, var(--speaker) 18%, transparent); }
.chip input { width: 120px; padding: 0; border: 0; outline: none; background: transparent; color: var(--ink); font-weight: 700; }
.chip.small { height: 24px; padding: 0 9px; font-size: 0.76rem; }

.tabs { display: flex; align-items: center; gap: 2px; margin-top: 12px; }
.tab { position: relative; padding: 10px 12px 12px; border: 0; background: none; color: var(--muted); font-size: 0.88rem; font-weight: 600; }
.tab:hover, .tab[aria-selected="true"] { color: var(--ink); }
.tab[aria-selected="true"]::after {
  content: "";
  position: absolute;
  bottom: -1px;
  inset-inline: 10px;
  height: 2px;
  border-radius: 2px;
  background: var(--coral);
}
.tab-count { margin-inline-start: 5px; padding: 1px 7px; border-radius: 999px; background: var(--hover); font-size: 0.72rem; }
.tabs-hint { margin-inline-start: auto; padding-bottom: 2px; color: var(--faint); font-size: 0.75rem; }

.doc-scroll { flex: 1; min-height: 0; overflow: auto; outline: none; }
.doc-wrap { max-width: 800px; margin: 0 auto; padding: 28px 40px 140px; }

.turn { margin-bottom: 24px; }
.turn-head { display: flex; align-items: center; gap: 6px; margin-bottom: 4px; }
.who {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 2px 6px 2px 8px;
  border: 0;
  border-radius: 7px;
  background: none;
  color: var(--speaker);
  font-size: 0.86rem;
  font-weight: 700;
}
.who:hover { background: color-mix(in srgb, var(--speaker) 11%, transparent); }
.time-button {
  padding: 2px 6px;
  border: 0;
  border-radius: 6px;
  background: none;
  color: var(--faint);
  font-size: 0.76rem;
  font-variant-numeric: tabular-nums;
}
.time-button:hover:not(:disabled) { color: var(--coral-strong); background: var(--coral-soft); }
.turn-text {
  margin: 0;
  margin-inline-start: 11px;
  padding-inline-start: 16px;
  border-inline-start: 2px solid color-mix(in srgb, var(--speaker) 32%, transparent);
  font-family: var(--font-doc);
  font-size: 1.17rem;
  line-height: 1.95;
}
.seg {
  padding: 2px 1px;
  border-radius: 4px;
  outline: none;
  transition: background 0.18s;
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
}
.seg[contenteditable] { cursor: text; }
.seg[contenteditable]:hover { background: var(--hover); }
.seg.playing { background: var(--playing); }
.seg:focus { background: var(--raised); box-shadow: 0 0 0 1px var(--coral), 0 0 0 4px var(--coral-soft); }
.flash { animation: flash 1.4s ease; }
@keyframes flash {
  0%, 30% { background: color-mix(in srgb, var(--ok) 28%, transparent); }
  100% { background: transparent; }
}

.notice {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 22px;
  padding: 12px 14px;
  border-radius: 12px;
  color: var(--ink-2);
  background: var(--hover);
  font-size: 0.86rem;
  line-height: 1.6;
}
.plain-transcript p { margin: 0 0 18px; font-family: var(--font-doc); font-size: 1.17rem; line-height: 1.95; white-space: pre-wrap; }
.panel-intro { margin: 0 0 16px; color: var(--muted); font-size: 0.86rem; line-height: 1.6; }
.diarized { margin-bottom: 18px; color: var(--muted); font-size: 0.86rem; }
.diarized summary { width: fit-content; color: var(--green); font-weight: 700; cursor: pointer; }
.diarized p { margin: 12px 0 0; color: var(--ink-2); font-family: var(--font-doc); font-size: 1rem; line-height: 1.9; white-space: pre-wrap; }
.change {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
  padding: 11px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--raised);
  font-size: 0.95rem;
}
.change del { color: var(--muted); }
.change ins { color: var(--green); font-weight: 700; text-decoration: none; }
.change-arrow { color: var(--coral); }
.change .time-button { margin-inline-start: auto; }
.original { margin: 0; color: var(--muted); font-family: var(--font-doc); font-size: 1.08rem; line-height: 1.95; white-space: pre-wrap; }
.segment-row {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr);
  gap: 12px;
  padding: 12px 8px;
  border-top: 1px solid var(--line);
  border-radius: 8px;
  transition: background 0.18s;
}
.segment-row.playing { background: var(--playing); }
.segment-row .time-button { align-self: start; justify-self: start; }
.segment-row p { margin: 6px 0 0; line-height: 1.7; }

.follow-button {
  position: absolute;
  z-index: 6;
  bottom: 84px;
  inset-inline-end: 28px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--raised);
  box-shadow: var(--shadow-pop);
  font-size: 0.84rem;
  font-weight: 700;
}
.follow-button:hover { color: var(--coral-strong); }

.player {
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: 64px;
  padding: 10px 24px;
  border-top: 1px solid var(--line);
  background: var(--surface);
}
.player-controls { display: flex; align-items: center; gap: 4px; }
.play-button { display: grid; place-items: center; width: 42px; height: 42px; border: 0; border-radius: 50%; color: var(--on-coral); background: var(--coral); }
.play-button:hover { background: var(--coral-strong); }
.skip { position: relative; }
.skip .icon { width: 22px; height: 22px; stroke-width: 1.5; }
.skip span { position: absolute; inset: 0; display: grid; place-items: center; padding-top: 2px; font-size: 0.56rem; font-weight: 800; }
.timeline { flex: 1; display: flex; align-items: center; gap: 12px; }
.timeline input { flex: 1; min-width: 80px; accent-color: var(--coral); cursor: pointer; }
.time { min-width: 42px; color: var(--muted); font-size: 0.8rem; font-variant-numeric: tabular-nums; }
.speed-button {
  min-width: 56px;
  height: 30px;
  padding: 0 10px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: none;
  font-size: 0.8rem;
  font-weight: 700;
}
.speed-button:hover { border-color: var(--coral); color: var(--coral-strong); }

/* ---------- Overlays ---------- */
.toast {
  position: absolute;
  z-index: 50;
  bottom: 24px;
  left: 50%;
  display: flex;
  align-items: center;
  gap: 14px;
  max-width: calc(100% - 40px);
  padding: 10px 16px;
  border-radius: 10px;
  color: var(--toast-ink);
  background: var(--toast-bg);
  box-shadow: var(--shadow-pop);
  font-size: 0.88rem;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 10px);
  transition: 0.2s ease;
}
.main.has-player .toast { bottom: 86px; }
.toast.show { opacity: 1; pointer-events: auto; transform: translate(-50%, 0); }
.toast button { padding: 0; border: 0; background: none; color: var(--coral); font-weight: 800; }

.drop-overlay {
  position: fixed;
  z-index: 80;
  inset: 0;
  display: grid;
  place-items: center;
  background: color-mix(in srgb, var(--bg) 80%, transparent);
  backdrop-filter: blur(3px);
}
.drop-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 40px 64px;
  border: 2px dashed var(--coral);
  border-radius: 22px;
  background: var(--raised);
  font-size: 1.15rem;
  font-weight: 700;
  pointer-events: none;
}
.drop-box .icon { width: 28px; height: 28px; color: var(--coral); }
.drop-box small { color: var(--muted); font-size: 0.84rem; font-weight: 400; }

.scrim { display: none; }

.settings-dialog {
  width: min(540px, calc(100vw - 32px));
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 18px;
  color: var(--ink);
  background: var(--raised);
  box-shadow: var(--shadow-pop);
}
.settings-dialog::backdrop { background: rgba(10, 14, 12, 0.45); backdrop-filter: blur(3px); }
.dialog-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px 8px; }
.dialog-head h2 { margin: 0; font-size: 1.15rem; }
.dialog-section { padding: 14px 22px; border-top: 1px solid var(--line); }
.dialog-section:last-child { padding-bottom: 20px; }
.dialog-section h3 { margin: 0 0 6px; font-size: 0.92rem; }
.dialog-section p { margin: 0 0 12px; color: var(--muted); font-size: 0.84rem; line-height: 1.6; }
.dialog-section .form-error { margin-top: 12px; }
.key-row { display: flex; gap: 8px; }
.key-row input {
  flex: 1;
  min-width: 0;
  height: 36px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  outline: none;
  background: var(--surface);
  direction: ltr;
  text-align: left;
}
.key-row input:focus { border-color: var(--coral); }
.key-row .button { height: 36px; }
.dialog-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; color: var(--ink-2); font-size: 0.86rem; font-variant-numeric: tabular-nums; }
.shortcuts { display: grid; grid-template-columns: 1fr auto; gap: 8px 16px; margin: 4px 0 0; font-size: 0.84rem; }
.shortcuts dt { color: var(--ink-2); }
.shortcuts dd { margin: 0; color: var(--muted); }
.shortcuts .kbd { opacity: 0.85; }

/* ---------- Server version: signed-in devices and the sign-in page ---------- */
.device-list { display: flex; flex-direction: column; gap: 6px; margin: 0 0 12px; padding: 0; list-style: none; }
.device-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 44px;
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink-2);
  font-size: 0.86rem;
}
.device-current { color: var(--green); font-size: 0.78rem; font-weight: 700; }
.account-row { margin: 0; }

.auth-page { height: 100%; overflow: auto; display: grid; place-items: center; padding: 24px 16px; }
.auth-card { width: min(420px, 100%); padding: 26px 24px 24px; border: 1px solid var(--line); border-radius: 18px; background: var(--raised); }
.auth-card .brand { padding: 0; }
.auth-card h1 { margin: 22px 0 8px; font-family: var(--font-doc); font-size: 1.7rem; font-weight: 500; }
.auth-card p { margin: 0 0 22px; color: var(--muted); line-height: 1.7; }
.auth-card .form-error { margin-top: 14px; }

/* ---------- Recording ---------- */
.record-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  width: 100%;
  height: 48px;
  margin-top: 12px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  color: var(--ink-2);
  background: var(--raised);
  font-weight: 700;
}
.record-button:hover { border-color: var(--coral); color: var(--coral-strong); }
.record-button .icon { color: var(--coral); }
/* Only while the drop zone shows: not with a file chosen, nor while recording. */
.drop-zone[hidden] ~ .record-button { display: none; }
.recorder {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px;
  padding: 16px 18px;
  border: 1px solid color-mix(in srgb, var(--coral) 35%, transparent);
  border-radius: 14px;
  background: var(--raised);
}
.record-dot { width: 14px; height: 14px; flex: none; border-radius: 50%; background: var(--coral); animation: recording 1.2s ease-in-out infinite; }
.record-dot.paused { background: var(--faint); animation: none; }
@keyframes recording { 50% { opacity: 0.3; } }
.recorder-info { flex: 1; min-width: 170px; display: flex; flex-direction: column; gap: 6px; }
.recorder-info strong { font-size: 1.5rem; font-variant-numeric: tabular-nums; }
.recorder-info small { color: var(--muted); font-size: 0.78rem; line-height: 1.5; }
.recorder meter { width: 100%; height: 8px; }
.recorder meter::-webkit-meter-bar { border: 0; border-radius: 4px; background: var(--hover); }
.recorder meter::-webkit-meter-optimum-value { border-radius: 4px; background: var(--green); }
.recorder meter::-moz-meter-bar { background: var(--green); }
.recorder-actions { display: flex; align-items: center; gap: 6px; }

/* Touch screens choose a file (there is nothing to drag) and have no keyboard shortcuts. */
.touch-hint { display: none; }
@media (pointer: coarse) {
  .drop-hint, .sidebar .kbd, .keyboard-only { display: none; }
  .touch-hint { display: inline; }
  .drop-zone { min-height: 180px; }
}

/* ---------- Narrow window: the sidebar becomes a drawer ---------- */
@media (max-width: 900px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: fixed;
    z-index: 40;
    top: 0;
    bottom: 0;
    inset-inline-start: 0;
    width: min(300px, 86vw);
    box-shadow: var(--shadow-pop);
    transform: translateX(105%);
    transition: transform 0.22s ease;
  }
  .app.drawer-open .sidebar { transform: none; }
  .app.drawer-open .scrim { position: fixed; z-index: 35; inset: 0; display: block; background: rgba(10, 14, 12, 0.35); }
  .drawer-button { display: inline-grid; }
  .doc-head { padding-inline-start: 60px; }
  .new-inner, .progress-inner { padding-top: 64px; }
}
@media (max-width: 1080px) {
  .tabs-hint { display: none; }
}
@media (max-width: 640px) {
  .options { grid-template-columns: 1fr; }
  .new-inner, .progress-inner { padding-inline: 20px; }
  .doc-wrap { padding-inline: 20px; }
  .actions .button span { display: none; }
  .speaker-bar-hint { display: none; }
}
