/* ============================================================
   Scribe — styles
   ============================================================ */

:root {
  color-scheme: light dark;

  --accent: #6c5ce7;
  --accent-strong: #5f4dd0;
  --accent-soft: color-mix(in srgb, var(--accent) 10%, transparent);
  --accent-border: color-mix(in srgb, var(--accent) 35%, transparent);

  --bg: #f5f5fa;
  --bg-sidebar: #fafafd;
  --surface: #ffffff;
  --surface-2: #f2f2f8;
  --text: #1b1b28;
  --text-2: #5b5b72;
  --text-3: #9494ab;
  --border: color-mix(in srgb, #1b1b28 10%, transparent);
  --border-strong: color-mix(in srgb, #1b1b28 16%, transparent);
  --danger: #d94550;
  --shadow: 0 1px 2px rgba(24, 18, 70, 0.05), 0 8px 24px rgba(24, 18, 70, 0.06);
  --shadow-pop: 0 4px 10px rgba(24, 18, 70, 0.08), 0 16px 40px rgba(24, 18, 70, 0.14);
  --radius: 14px;
  --radius-sm: 9px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --accent: #8578ec;
    --accent-strong: #7364e0;
    --bg: #101016;
    --bg-sidebar: #14141c;
    --surface: #1a1a24;
    --surface-2: #22222e;
    --text: #ececf4;
    --text-2: #a8a8bd;
    --text-3: #6d6d84;
    --border: color-mix(in srgb, #ececf4 11%, transparent);
    --border-strong: color-mix(in srgb, #ececf4 18%, transparent);
    --danger: #ee6a72;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.35), 0 8px 24px rgba(0, 0, 0, 0.35);
    --shadow-pop: 0 4px 10px rgba(0, 0, 0, 0.4), 0 16px 40px rgba(0, 0, 0, 0.5);
  }
}

* { box-sizing: border-box; margin: 0; padding: 0; }

/* Author display rules (e.g. .file-list { display: flex }, .tabs { display: inline-flex })
   would otherwise defeat the UA's non-important [hidden] { display: none }. */
[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; }
input, select, textarea { font: inherit; color: inherit; }

::selection { background: color-mix(in srgb, var(--accent) 25%, transparent); }

/* ---------- app shell ---------- */

#app {
  display: grid;
  grid-template-columns: 280px 1fr;
  height: 100vh;
  height: 100dvh;
  width: 100%;
  min-width: 0;
  overflow-x: hidden;
}

/* ---------- sidebar ---------- */

.sidebar {
  display: flex;
  flex-direction: column;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  overflow: hidden;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 18px 14px;
}

.logo { flex: none; display: block; }

.brand-name {
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.sidebar-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 0 14px 12px;
  border-bottom: 1px solid var(--border);
}

.search-wrap { position: relative; }

.search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-3);
  pointer-events: none;
}

#search {
  width: 100%;
  padding: 8px 10px 8px 32px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  outline: none;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

#search::placeholder { color: var(--text-3); }

#search:focus {
  border-color: var(--accent-border);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.library {
  flex: 1;
  overflow-y: auto;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.lib-empty {
  margin: auto;
  padding: 32px 16px;
  text-align: center;
  color: var(--text-3);
  font-size: 13.5px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.lib-item {
  position: relative;
  display: block;
  width: 100%;
  padding: 10px 30px 10px 12px;
  border-radius: 10px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 150ms ease, border-color 150ms ease;
  outline: none;
}

.lib-item:hover { background: color-mix(in srgb, var(--text) 5%, transparent); }

.lib-item:focus-visible { box-shadow: 0 0 0 3px var(--accent-soft); border-color: var(--accent-border); }

.lib-item.active {
  background: var(--accent-soft);
  border-color: var(--accent-border);
}

.lib-title {
  display: block;
  font-weight: 600;
  font-size: 13.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lib-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 3px;
  font-size: 12px;
  color: var(--text-3);
}

.dur-badge {
  font-variant-numeric: tabular-nums;
  background: color-mix(in srgb, var(--text) 7%, transparent);
  border-radius: 5px;
  padding: 0 5px;
  font-size: 11px;
  line-height: 18px;
}

.mode-chip {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
  border-radius: 5px;
  padding: 0 5px;
  line-height: 18px;
}

.mode-chip.diarize { background: var(--accent-soft); color: var(--accent); }
.mode-chip.fast { background: color-mix(in srgb, #0ea5e9 13%, transparent); color: color-mix(in srgb, #0ea5e9 75%, var(--text)); }

.lib-del {
  position: absolute;
  top: 50%;
  right: 6px;
  transform: translateY(-50%);
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  color: var(--text-3);
  opacity: 0;
  transition: opacity 150ms ease, background 150ms ease, color 150ms ease;
}

.lib-item:hover .lib-del,
.lib-item:focus-within .lib-del { opacity: 1; }

.lib-del:hover { background: color-mix(in srgb, var(--danger) 14%, transparent); color: var(--danger); }

/* ---------- main ---------- */

.main { overflow-y: auto; }

.view-inner {
  max-width: 860px;
  margin: 0 auto;
  padding: 40px 40px 80px;
}

.view-inner.narrow { max-width: 680px; }

.page-head { margin-bottom: 26px; }

.page-head h1 {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.page-head p { color: var(--text-2); margin-top: 4px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

/* ---------- buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  font-weight: 600;
  font-size: 13.5px;
  color: var(--text);
  transition: background 150ms ease, border-color 150ms ease, box-shadow 150ms ease, transform 150ms ease, filter 150ms ease;
  outline: none;
}

.btn:hover { background: var(--surface-2); }

.btn:focus-visible { box-shadow: 0 0 0 3px var(--accent-soft); border-color: var(--accent-border); }

.btn:active { transform: translateY(1px); }

.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }

.btn-primary {
  background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 88%, #ffffff), var(--accent-strong));
  border-color: transparent;
  color: #fff;
  box-shadow: 0 1px 2px rgba(60, 40, 180, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.18);
}

.btn-primary:hover { filter: brightness(1.07); background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 88%, #ffffff), var(--accent-strong)); }

.btn-primary:disabled:hover { filter: none; }

.btn-danger { color: var(--danger); }

.btn-danger:hover {
  background: color-mix(in srgb, var(--danger) 9%, transparent);
  border-color: color-mix(in srgb, var(--danger) 35%, transparent);
}

.btn-lg { padding: 12px 20px; font-size: 15px; border-radius: 11px; }

.btn-block { width: 100%; }

.icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 7px;
  color: var(--text-3);
  transition: background 150ms ease, color 150ms ease;
}

.icon-btn:hover { background: color-mix(in srgb, var(--text) 8%, transparent); color: var(--text); }

/* ---------- recording source ---------- */

.source-switch { display: flex; gap: 4px; padding: 4px; margin-bottom: 16px; width: fit-content; border-radius: 11px; background: var(--surface-2); border: 1px solid var(--border); }
.source-option { padding: 8px 18px; border-radius: 8px; color: var(--text-2); font-size: 14px; font-weight: 600; }
.source-option.active { background: var(--surface); color: var(--accent); box-shadow: 0 1px 4px rgba(24, 18, 70, 0.1); }
.source-option:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.link-card { display: flex; flex-direction: column; gap: 12px; padding: 26px; }
.link-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.link-input-wrap { position: relative; }
#source-url { width: 100%; min-width: 0; padding: 14px 42px 14px 14px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); outline: none; }
#source-clear { position: absolute; right: 9px; top: 50%; transform: translateY(-50%); font-size: 22px; color: var(--text-2); }
.platform-badge { font-size: 12px; font-weight: 650; color: var(--accent); background: var(--accent-soft); padding: 3px 9px; border-radius: 20px; }
.platform-list { display: flex; flex-wrap: wrap; gap: 6px; }
.platform-list span { font-size: 11.5px; color: var(--text-2); background: var(--surface-2); padding: 3px 9px; border-radius: 6px; }
.link-note { font-size: 12px; color: var(--text-2); }
#source-url:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
#source-url[aria-invalid="true"] { border-color: var(--danger); }
.link-hint { font-size: 13px; color: var(--text-2); }
.link-error { font-size: 13px; color: var(--danger); overflow-wrap: anywhere; }
.link-error-card { padding: 14px; border: 1px solid color-mix(in srgb, var(--danger) 30%, transparent); border-radius: var(--radius-sm); background: color-mix(in srgb, var(--danger) 5%, var(--surface)); font-size: 13px; overflow-wrap: anywhere; }
.link-error-card strong { display: block; color: var(--danger); margin-bottom: 5px; }
.link-error-card .btn { margin-top: 12px; }
.download-progress { display: block; width: 100%; height: 8px; accent-color: var(--accent); margin: 18px 0; border: 0; border-radius: 10px; overflow: hidden; }
.download-progress::-webkit-progress-bar { background: var(--surface-2); border-radius: 10px; }
.download-progress::-webkit-progress-value { background: var(--accent); border-radius: 10px; transition: width 180ms ease; }
.progress-phase { font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--accent); font-weight: 650; margin-bottom: 8px; }
#progress-source { margin: 6px 0 10px; }
#btn-cancel-download { margin-top: 16px; }
.source-link { color: var(--accent); text-decoration: none; }
.source-link:hover { text-decoration: underline; }

/* ---------- dropzone ---------- */

.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 52px 24px;
  border: 2px dashed var(--border-strong);
  border-radius: 16px;
  background: var(--surface);
  color: var(--text-2);
  cursor: pointer;
  text-align: center;
  transition: border-color 150ms ease, background 150ms ease, box-shadow 150ms ease;
  outline: none;
}

.dropzone:hover, .dropzone:focus-visible, .dropzone.dragover {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 4%, var(--surface));
}

.dropzone.dragover { box-shadow: 0 0 0 4px var(--accent-soft); }

.dz-icon { color: var(--accent); margin-bottom: 6px; transition: transform 150ms ease; }

.dropzone.dragover .dz-icon { transform: translateY(-3px); }

.dz-title { font-size: 16.5px; font-weight: 650; color: var(--text); }

.dz-sub { font-size: 13px; color: var(--text-3); }

.dz-browse { color: var(--accent); font-weight: 600; text-decoration: underline; text-underline-offset: 2px; }

/* ---------- selected files (merged in list order) ---------- */

.files-card {
  margin-top: 14px;
  padding: 12px 14px 13px;
  background: var(--surface);
  border: 1px solid var(--accent-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.files-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-bottom: 10px;
}

.files-summary {
  flex: 1;
  min-width: 0;
  font-size: 12.5px;
  font-weight: 650;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.btn-sm { padding: 5px 10px; font-size: 12.5px; border-radius: 8px; }

.file-list { list-style: none; display: flex; flex-direction: column; gap: 6px; }

.file-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 8px 7px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}

.file-idx {
  flex: none;
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 11.5px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.file-main {
  display: flex;
  align-items: baseline;
  gap: 10px;
  min-width: 0;
  flex: 1;
}

.file-name {
  font-weight: 600;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.file-size { font-size: 12.5px; color: var(--text-3); font-variant-numeric: tabular-nums; flex: none; }

.file-moves { display: flex; gap: 2px; }

.file-moves .icon-btn, .file-row > .icon-btn { width: 24px; height: 24px; }

.icon-btn:disabled { opacity: 0.3; cursor: not-allowed; }

.icon-btn:disabled:hover { background: none; color: var(--text-3); }

.files-hint { font-size: 12.5px; color: var(--text-3); line-height: 1.45; margin-top: 10px; }

/* ---------- options ---------- */

.options {
  margin-top: 18px;
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.opt-group { display: flex; flex-direction: column; gap: 7px; }

.opt-label {
  font-size: 12.5px;
  font-weight: 650;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.opt-optional {
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0;
  color: var(--text-3);
  font-size: 12px;
}

.mode-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.mode-cards.mode-cards-3 { grid-template-columns: repeat(auto-fit, minmax(195px, 1fr)); }

.mode-card {
  position: relative;
  display: flex;
  padding: 13px 14px;
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  cursor: pointer;
  transition: border-color 150ms ease, background 150ms ease, box-shadow 150ms ease;
}

.mode-card:hover { border-color: var(--accent-border); }

.mode-card:has(input:checked) {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 5%, transparent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.mode-card input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.mode-card:has(input:focus-visible) { box-shadow: 0 0 0 3px var(--accent-soft); }

.mode-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }

.mode-title {
  font-weight: 650;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
}

.mode-desc { font-size: 12.5px; color: var(--text-3); }

.chip {
  display: inline-block;
  font-size: 10.5px;
  font-weight: 650;
  letter-spacing: 0.03em;
  padding: 1px 7px;
  border-radius: 20px;
  line-height: 16px;
}

.chip-rec { background: var(--accent-soft); color: var(--accent); }

.opt-grid {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 16px;
  align-items: start;
}

select, textarea {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  outline: none;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

textarea { resize: vertical; min-height: 42px; }

textarea::placeholder { color: var(--text-3); }

select:focus, textarea:focus {
  border-color: var(--accent-border);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.check {
  display: flex;
  align-items: center;
  gap: 9px;
  cursor: pointer;
  font-size: 14px;
  user-select: none;
}

.check input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  cursor: pointer;
}

.footnote {
  font-size: 12.5px;
  color: var(--text-3);
  text-align: center;
  margin-top: -6px;
}

/* ---------- speaker guide ---------- */

.guide-row { display: flex; align-items: center; }

.guide-card {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 8px 7px 12px;
  max-width: 100%;
  background: var(--surface);
  border: 1px solid var(--accent-border);
  border-radius: var(--radius-sm);
}

.guide-icon { color: var(--accent); flex: none; }

.guide-name {
  font-size: 13.5px;
  font-weight: 600;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.guide-hint { font-size: 12.5px; color: var(--text-3); line-height: 1.45; }

.guide-hint em { font-style: normal; font-weight: 600; }

/* ---------- progress ---------- */

.progress-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 44px 32px 38px;
  text-align: center;
  margin-top: 24px;
}

.eq { display: flex; align-items: center; gap: 5px; height: 40px; margin-bottom: 6px; }

.eq span {
  width: 6px;
  height: 12px;
  border-radius: 4px;
  background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 80%, #ffffff), var(--accent));
  animation: eq-bounce 1.1s ease-in-out infinite;
}

.eq span:nth-child(1) { animation-delay: 0s; }
.eq span:nth-child(2) { animation-delay: 0.18s; }
.eq span:nth-child(3) { animation-delay: 0.36s; }
.eq span:nth-child(4) { animation-delay: 0.54s; }
.eq span:nth-child(5) { animation-delay: 0.72s; }

@keyframes eq-bounce {
  0%, 100% { height: 12px; opacity: 0.7; }
  50% { height: 38px; opacity: 1; }
}

.progress-file {
  font-size: 17px;
  font-weight: 650;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.progress-stage { color: var(--text-2); font-size: 14px; min-height: 22px; }

.live-wrap { margin-top: 16px; overflow: hidden; }

.live-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 18px;
  font-size: 12.5px;
  font-weight: 650;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border);
}

.live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #e5484d;
  animation: pulse 1.4s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.8); }
}

.live-text {
  padding: 18px;
  max-height: 46vh;
  overflow-y: auto;
  white-space: pre-wrap;
  font-size: 15px;
  color: var(--text);
}

/* ---------- transcript ---------- */

.t-head { margin-bottom: 16px; }

.t-title-row { min-height: 40px; display: flex; align-items: center; }

.t-title {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.02em;
  cursor: text;
  border-radius: 8px;
  padding: 2px 8px;
  margin-left: -8px;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: background 150ms ease;
}

.t-title:hover { background: color-mix(in srgb, var(--text) 6%, transparent); }

.t-title-input {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.02em;
  width: 100%;
  padding: 2px 8px;
  margin-left: -8px;
  border: 1px solid var(--accent-border);
  border-radius: 8px;
  background: var(--surface);
  outline: none;
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.t-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 14px;
  margin-top: 6px;
  color: var(--text-3);
  font-size: 13px;
}

.t-meta .meta-item { display: inline-flex; align-items: center; gap: 5px; }

.t-meta .meta-item + .meta-item::before {
  content: "·";
  margin-right: 14px;
  color: var(--text-3);
}

.model-chip {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11.5px;
  background: color-mix(in srgb, var(--text) 6%, transparent);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1px 7px;
}

.toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.toolbar .btn-danger { margin-left: auto; }

/* dropdown */

.dropdown { position: relative; }

.menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 30;
  min-width: 230px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-pop);
  padding: 6px;
  animation: menu-in 130ms ease;
}

@keyframes menu-in {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

.menu-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 13.5px;
  font-weight: 550;
  text-align: left;
  transition: background 130ms ease;
}

.menu-item:hover:not(.disabled) { background: var(--accent-soft); }

.menu-item .ext {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  color: var(--text-3);
}

.menu-item.disabled { opacity: 0.4; cursor: not-allowed; }

/* tabs */

.tabs {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  background: color-mix(in srgb, var(--text) 6%, transparent);
  border-radius: 10px;
  margin-bottom: 14px;
}

.tab {
  padding: 6px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
  transition: background 150ms ease, color 150ms ease, box-shadow 150ms ease;
}

.tab.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
}

/* player */

.player-wrap {
  position: sticky;
  top: 0;
  z-index: 20;
  padding: 12px 0;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.player-wrap audio {
  width: 100%;
  height: 44px;
  border-radius: 12px;
  box-shadow: var(--shadow);
}

/* segments */

.t-content { margin-top: 6px; }

.segments {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.seg {
  display: grid;
  grid-template-columns: 140px 56px 1fr;
  gap: 12px;
  align-items: start;
  padding: 12px 18px;
  border-left: 3px solid transparent;
  transition: background 150ms ease, border-color 150ms ease;
}

.seg + .seg { border-top: 1px solid var(--border); }

.seg.active {
  background: var(--accent-soft);
  border-left-color: var(--accent);
}

.spk-chip {
  --spk: #6c5ce7;
  justify-self: start;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  font-weight: 650;
  padding: 3px 10px;
  border-radius: 20px;
  background: color-mix(in srgb, var(--spk) 13%, transparent);
  border: 1px solid color-mix(in srgb, var(--spk) 30%, transparent);
  color: color-mix(in srgb, var(--spk) 72%, var(--text));
  cursor: pointer;
  transition: background 150ms ease, box-shadow 150ms ease;
}

.spk-chip:hover {
  background: color-mix(in srgb, var(--spk) 22%, transparent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--spk) 12%, transparent);
}

.spk-0 { --spk: #6c5ce7; }
.spk-1 { --spk: #0ea5e9; }
.spk-2 { --spk: #10b981; }
.spk-3 { --spk: #f59e0b; }
.spk-4 { --spk: #ef476f; }
.spk-5 { --spk: #14b8a6; }
.spk-6 { --spk: #d946ef; }
.spk-7 { --spk: #f97316; }

.seg-time {
  font-variant-numeric: tabular-nums;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-3);
  padding: 3px 0;
  border-radius: 6px;
  transition: color 150ms ease;
  text-align: left;
}

.seg-time:hover { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }

.seg-text { font-size: 15px; padding-top: 2px; overflow-wrap: anywhere; }

/* plain paragraphs (fast mode / translation) */

.prose {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 26px 30px;
}

.prose p + p { margin-top: 14px; }

.prose p { overflow-wrap: anywhere; }

.content-empty {
  text-align: center;
  color: var(--text-3);
  padding: 40px 0;
}

/* ---------- toasts ---------- */

.toasts {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 360px;
}

.toast {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 10px;
  box-shadow: var(--shadow-pop);
  padding: 11px 16px;
  font-size: 13.5px;
  font-weight: 550;
  opacity: 0;
  transform: translateX(12px);
  transition: opacity 200ms ease, transform 200ms ease;
}

.toast.show { opacity: 1; transform: translateX(0); }

.toast.error { border-left-color: var(--danger); }

.toast.success { border-left-color: #10b981; }

/* ---------- scrollbars (webkit) ---------- */

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb {
  background: color-mix(in srgb, var(--text) 16%, transparent);
  border-radius: 6px;
  border: 2px solid transparent;
  background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover { background: color-mix(in srgb, var(--text) 28%, transparent); background-clip: padding-box; border: 2px solid transparent; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- sidebar footer, voiceprints & account modals ---------- */

.sidebar-footer {
  padding: 12px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: color-mix(in srgb, var(--surface) 75%, transparent);
}

.sb-profile-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 11px;
  background: var(--surface);
  display: flex;
  flex-direction: column;
  gap: 8px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.sb-profile-top {
  display: flex;
  align-items: center;
  gap: 9px;
}

.sb-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 700;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border: 1px solid var(--accent-border);
}

.sb-profile-info {
  min-width: 0;
  flex: 1;
}

.sb-profile-name-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.sb-user-name {
  font-size: 13px;
  font-weight: 650;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sb-plan-badge {
  font-size: 10.5px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 99px;
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid var(--accent-border);
  white-space: nowrap;
  flex-shrink: 0;
}

.sb-user-email {
  font-size: 11.5px;
  color: var(--text-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 1px;
}

.sb-credits-box {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding-top: 2px;
}

.sb-credits-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
}

.sb-credits-total {
  color: var(--text-3);
  font-weight: 500;
}

.credits-track {
  width: 100%;
  height: 6px;
  border-radius: 99px;
  background: color-mix(in srgb, var(--text) 10%, transparent);
  overflow: hidden;
}

.credits-track-lg {
  height: 9px;
}

.credits-fill {
  height: 100%;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--accent), color-mix(in srgb, var(--accent) 75%, #22c55e));
  transition: width 250ms ease;
}

.sb-profile-actions {
  display: flex;
  gap: 6px;
  margin-top: 2px;
}

.btn-xs {
  padding: 5px 8px;
  font-size: 11.5px;
  font-weight: 600;
  border-radius: 7px;
  flex: 1;
  justify-content: center;
}

.sb-vp-btn {
  width: 100%;
  justify-content: center;
  font-size: 12px;
  padding: 6px 10px;
}

.voiceprint-banner {
  padding: 12px 16px;
  margin-bottom: 14px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  border-color: var(--accent-border);
  background: color-mix(in srgb, var(--accent) 4%, var(--surface));
}

.vp-banner-title {
  font-size: 12.5px;
  font-weight: 650;
  color: var(--accent);
}

.vp-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  padding: 4px 10px;
  border-radius: 20px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
}

.vp-chip button {
  font-size: 11.5px;
  font-weight: 650;
  color: var(--accent);
  cursor: pointer;
}

.vp-chip button:hover {
  text-decoration: underline;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: rgba(10, 12, 20, 0.58);
  backdrop-filter: blur(5px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-backdrop[hidden] {
  display: none !important;
}

.modal-card {
  width: 100%;
  max-width: 540px;
  max-height: 88vh;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-pop);
  padding: 24px 26px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.modal-card.modal-wide {
  max-width: 820px;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.modal-head h2 {
  font-size: 19px;
  font-weight: 700;
}

.modal-sub {
  font-size: 13px;
  color: var(--text-2);
  line-height: 1.45;
}

.vp-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.vp-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.vp-row-meta {
  font-size: 12px;
  color: var(--text-3);
}

/* ---------- Account Modal: Profile & Credits ---------- */

.acc-profile-section {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px;
  background: color-mix(in srgb, var(--accent) 3%, var(--surface));
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.acc-profile-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.acc-profile-identity {
  display: flex;
  align-items: center;
  gap: 12px;
}

.acc-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 700;
  font-size: 17px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--accent-border);
  flex-shrink: 0;
}

.acc-name-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.acc-user-name {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}

.acc-user-email {
  font-size: 13px;
  color: var(--text-2);
  margin-top: 2px;
}

.acc-credits-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  background: var(--surface);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.acc-credits-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.acc-credits-title {
  font-size: 13px;
  font-weight: 650;
  color: var(--text);
}

.acc-credits-summary {
  font-size: 13px;
  font-weight: 700;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

.acc-stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 2px;
}

.acc-stat-box {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  background: color-mix(in srgb, var(--text) 2%, var(--surface));
}

.acc-stat-label {
  font-size: 11px;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.acc-stat-val {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  margin-top: 2px;
  font-variant-numeric: tabular-nums;
}

.acc-tools-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.acc-auth-section {
  display: flex;
  flex-direction: column;
}

.acc-auth-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px 20px;
  background: color-mix(in srgb, var(--accent) 3%, var(--surface));
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.acc-auth-card h3 {
  font-size: 16px;
  font-weight: 700;
}

.acc-form-row {
  display: flex;
  gap: 8px;
}

.acc-form-row input {
  flex: 1;
  padding: 9px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
}

/* ---------- Plans Grid (2-column clean layout) ---------- */

.plans-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.plans-section-header {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.plans-section-header h3 {
  font-size: 16px;
  font-weight: 700;
}

.plans-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

@media (max-width: 640px) {
  .plans-grid {
    grid-template-columns: 1fr;
  }
  .acc-stats-grid {
    grid-template-columns: 1fr;
  }
}

.plan-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  background: var(--surface);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 12px;
  position: relative;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

.plan-card:hover {
  border-color: var(--accent-border);
}

.plan-card.popular-plan {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent-soft);
}

.plan-card.active-plan {
  background: color-mix(in srgb, var(--accent) 5%, var(--surface));
  border-color: var(--accent);
}

.plan-card-top {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.plan-card-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.plan-card-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
}

.plan-badge {
  font-size: 10.5px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 99px;
  background: var(--accent-soft);
  color: var(--accent);
  white-space: nowrap;
}

.plan-card-price {
  font-size: 22px;
  font-weight: 750;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.plan-card-price span {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-3);
}

.plan-card-features {
  list-style: none;
  padding: 0;
  margin: 4px 0 0;
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 12.5px;
  color: var(--text-2);
}

.plan-card-features li::before {
  content: "✓ ";
  color: var(--accent);
  font-weight: 700;
}

.plan-card-btn {
  width: 100%;
  justify-content: center;
  padding: 9px 14px;
  font-weight: 650;
  white-space: nowrap;
}

.plan-row-title {
  font-weight: 650;
  font-size: 13.5px;
}

.btn-google {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 11px 14px;
  font-size: 14px;
  font-weight: 650;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: background 140ms ease, border-color 140ms ease, transform 100ms ease;
}

.btn-google:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
}

.auth-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 11.5px;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin: 2px 0;
}

.auth-divider::before,
.auth-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}


/* ---------- Responsive & Mobile-Ready Layout ---------- */

.mobile-topbar {
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 16px;
  padding-top: max(10px, env(safe-area-inset-top));
  background: var(--bg-sidebar);
  border-bottom: 1px solid var(--border);
  z-index: 45;
  flex-shrink: 0;
}

.mobile-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.mobile-topbar-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.mobile-menu-btn {
  width: 38px;
  height: 38px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.sidebar-close-btn {
  display: none;
  margin-left: auto;
  width: 34px;
  height: 34px;
  font-size: 20px;
  border-radius: 8px;
}

.sidebar-backdrop {
  position: fixed;
  inset: 0;
  z-index: 75;
  background: rgba(10, 12, 20, 0.5);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}

/* Acc classes used in index.html */
.acc-name-line {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.acc-credits-panel {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  background: var(--surface);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.acc-credits-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.acc-stat-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  background: color-mix(in srgb, var(--text) 2%, var(--surface));
  display: flex;
  flex-direction: column;
}

.acc-actions-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.acc-info-callout {
  padding: 10px 12px;
  border-radius: 9px;
  border: 1px solid var(--accent-border);
  background: var(--accent-soft);
  font-size: 13px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.acc-auth-inner {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px 20px;
  background: color-mix(in srgb, var(--accent) 3%, var(--surface));
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.acc-plans-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.acc-plans-head {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

@media (hover: none) {
  .lib-del {
    opacity: 0.8;
  }
}

@media (max-width: 860px) {
  #app {
    display: flex;
    flex-direction: column;
    grid-template-columns: 1fr;
    height: 100dvh;
  }

  .mobile-topbar {
    display: flex;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(300px, 86vw);
    z-index: 80;
    transform: translateX(-105%);
    transition: transform 220ms cubic-bezier(0.22, 1, 0.36, 1);
    box-shadow: var(--shadow-pop);
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
  }

  body.sidebar-open .sidebar {
    transform: translateX(0);
  }

  body.sidebar-open {
    overflow: hidden;
  }

  .sidebar-close-btn {
    display: inline-flex;
  }

  .main {
    flex: 1;
    width: 100%;
    min-height: 0;
  }

  .view-inner {
    padding: 26px 22px 64px;
  }

  .opt-grid {
    grid-template-columns: 1fr;
    gap: 14px;
  }
}

@media (max-width: 640px) {
  .view-inner {
    padding: 18px 14px calc(56px + env(safe-area-inset-bottom));
  }

  .page-head {
    margin-bottom: 18px;
  }

  .page-head h1 {
    font-size: 22px;
  }

  .source-switch {
    width: 100%;
    display: flex;
  }

  .source-option {
    flex: 1;
    text-align: center;
    justify-content: center;
  }

  .dropzone {
    padding: 28px 16px;
  }

  .options {
    padding: 16px;
    gap: 15px;
  }

  .mode-cards,
  .mode-cards.mode-cards-3 {
    grid-template-columns: 1fr;
  }

  input,
  select,
  textarea {
    font-size: 16px;
  }

  .t-title,
  .t-title-input {
    font-size: 20px;
  }

  .toolbar {
    gap: 6px;
  }

  .toolbar .btn {
    padding: 8px 11px;
    font-size: 13px;
  }

  .seg {
    grid-template-columns: 1fr auto;
    gap: 6px 10px;
    padding: 12px 14px;
  }

  .seg-text {
    grid-column: 1 / -1;
    padding-top: 2px;
  }

  .prose {
    padding: 18px 16px;
  }

  .modal-backdrop {
    align-items: flex-end;
    padding: 0;
  }

  .modal-card,
  .modal-card.modal-wide {
    max-width: 100%;
    max-height: 92dvh;
    border-radius: 18px 18px 0 0;
    padding: 18px 16px calc(22px + env(safe-area-inset-bottom));
    gap: 14px;
  }

  .acc-profile-section,
  .acc-auth-inner,
  .acc-auth-card {
    padding: 14px;
  }

  .acc-form-row {
    flex-direction: column;
  }

  .acc-form-row .btn {
    width: 100%;
    min-height: 42px;
  }

  .acc-actions-row .btn,
  .acc-tools-bar .btn {
    flex: 1 1 100%;
    justify-content: center;
    min-height: 40px;
  }

  .toasts {
    top: 12px;
    left: 12px;
    right: 12px;
    max-width: none;
  }
}
