/* ===========================================================
   Platypus Economics — Justin's Voice
   Brand: Abyss / Surf / Paper / Ink
   =========================================================== */

@font-face {
  font-family: "Inter";
  src: url("/brand/fonts/Inter.ttf") format("truetype-variations");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Sublime";
  src: url("/brand/fonts/Sublime.ttf") format("truetype");
  font-display: swap;
}

:root {
  /* Brand palette — Platypus Economics canonical values */
  --abyss: #0E4A53;
  --abyss-2: #13585F;
  --abyss-3: #1A6770;
  --abyss-deep: #062227;
  --surf: #2F9E97;
  --surf-2: #5DBAB4;
  --surf-deep: #1F7570;
  --sun: #D9A315;
  --coral: #D93A43;
  --algae: #006B2E;
  --orchid: #8E4AA0;
  --ink: #0B1626;
  --paper: #F6F4EE;
  --paper-2: #FFFFFF;

  /* Semantic */
  --rule: rgba(123, 209, 222, 0.14);
  --rule-strong: rgba(123, 209, 222, 0.28);
  --text: #EEF2F8;
  --text-strong: var(--paper);
  --muted: #C7D2E2;
  --dimmer: #97A8C2;
  --accent: var(--surf);
  --accent-hover: var(--surf-2);
  --accent-ink: #062029;
  --danger: #E6556A;
  --good: #6FE1B0;

  /* Type */
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --display: "Sublime", "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 12px 40px rgba(8, 14, 26, 0.55);
  --surf-glow: 0 0 0 3px rgba(63, 182, 201, 0.22);
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }
body {
  font: 14px/1.5 var(--sans);
  color: var(--text);
  min-height: 100vh;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;

  /* Deep navy gradient — unmistakably Abyss, not generic dark mode */
  background: var(--abyss-deep);
  background-image:
    radial-gradient(ellipse 70% 45% at 100% 0%, rgba(63, 182, 201, 0.14), transparent 60%),
    radial-gradient(ellipse 60% 50% at 0% 100%, rgba(63, 182, 201, 0.08), transparent 60%),
    linear-gradient(180deg, var(--abyss) 0%, var(--abyss-deep) 60%, var(--ink) 100%);
  background-attachment: fixed;
}

a { color: var(--surf-2); text-decoration: none; }
a:hover { color: var(--surf); }

/* ---------- Header ---------- */
header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.15rem max(2rem, env(safe-area-inset-right)) 1.15rem max(2rem, env(safe-area-inset-left));
  background: linear-gradient(180deg, rgba(15, 39, 71, 0.92) 0%, rgba(8, 27, 54, 0.88) 100%);
  backdrop-filter: blur(12px) saturate(140%);
  -webkit-backdrop-filter: blur(12px) saturate(140%);
  border-bottom: 1px solid var(--rule);
  box-shadow:
    0 1px 0 rgba(63, 182, 201, 0.20),
    0 8px 24px rgba(0, 0, 0, 0.25);
}
.brand {
  display: flex;
  align-items: center;
  gap: 1rem;
  min-width: 0;
  text-decoration: none;
}
.brand .mark {
  width: 60px; height: 60px;
  border-radius: 12px;
  background: var(--paper);
  display: grid; place-items: center;
  overflow: hidden;
  flex-shrink: 0;
  box-shadow:
    0 0 0 1px rgba(63, 182, 201, 0.35),
    0 4px 14px rgba(0, 0, 0, 0.35);
}
.brand .mark img { width: 100%; height: 100%; object-fit: contain; padding: 6px; }
.brand .titles { display: flex; flex-direction: column; min-width: 0; gap: 1px; }
.brand .product {
  font-family: var(--sans);
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: -0.015em;
  color: var(--paper);
  line-height: 1.1;
}
.brand .tagline {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--surf-2);
  line-height: 1.3;
  margin-top: 1px;
}
.brand .label {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  margin-top: 3px;
}
nav { display: flex; gap: 0.35rem; align-items: center; }
nav a {
  color: var(--muted);
  text-decoration: none;
  padding: 0.45rem 0.95rem;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  border: 1px solid transparent;
  transition: all .12s ease;
}
nav a:hover {
  color: var(--paper);
  background: rgba(63, 182, 201, 0.08);
}
nav a.active {
  color: var(--paper);
  background: rgba(63, 182, 201, 0.18);
  border-color: rgba(63, 182, 201, 0.35);
  box-shadow: inset 0 0 0 1px rgba(63, 182, 201, 0.10);
}

/* ---------- Main layout ---------- */
main {
  max-width: 920px;
  margin: 0 auto;
  padding: 2.25rem max(2rem, env(safe-area-inset-right)) 4rem max(2rem, env(safe-area-inset-left));
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

/* ---------- Build info footer ---------- */
.build-info {
  max-width: 920px;
  margin: -1rem auto 1.5rem;
  padding: 0 max(2rem, env(safe-area-inset-right)) 0 max(2rem, env(safe-area-inset-left));
  font: 11px var(--mono);
  color: var(--muted);
  opacity: 0.55;
  text-align: right;
  letter-spacing: 0.02em;
}
.build-info:empty { display: none; }
@media (max-width: 720px) {
  .build-info {
    padding: 0 max(1rem, env(safe-area-inset-right)) 0 max(1rem, env(safe-area-inset-left));
    margin: -0.5rem auto 1rem;
  }
}

/* ---------- Lede paragraph (with Surf rule) ---------- */
.lede {
  margin: 0 0 0.5rem;
  font-size: 15px;
  line-height: 1.6;
  color: var(--paper);
  max-width: 64ch;
  padding: 0.15rem 0 0.15rem 1rem;
  border-left: 3px solid var(--surf);
}
.lede strong { color: var(--paper); font-weight: 700; }

/* ---------- Composer / Editor ---------- */
/* Rich-text contenteditable so pasted Substack/Word/Docs content keeps its
   block structure visually. Looks like a textarea, but renders headings,
   paragraphs, blockquotes, and lists at native sizes. */
.composer-editor {
  position: relative;
  width: 100%;
  min-height: 280px;
  max-height: 70vh;
  overflow-y: auto;
  padding: 1.1rem 1.2rem;
  font: 16px/1.55 var(--sans);
  color: var(--paper);
  background: var(--abyss);
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius);
  resize: vertical;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.04),
    0 6px 20px rgba(0, 0, 0, 0.25);
  white-space: pre-wrap;
  word-wrap: break-word;
}
.composer-editor:focus {
  border-color: var(--surf);
  outline: none;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.04),
    var(--surf-glow);
}
.composer-editor.is-empty::before {
  content: attr(data-placeholder);
  position: absolute;
  top: 1.1rem;
  left: 1.2rem;
  right: 1.2rem;
  color: var(--dimmer);
  pointer-events: none;
  white-space: normal;
}
.composer-editor > :first-child { margin-top: 0; }
.composer-editor > :last-child { margin-bottom: 0; }
.composer-editor p,
.composer-editor div { margin: 0 0 0.85em; }
.composer-editor h1,
.composer-editor h2,
.composer-editor h3,
.composer-editor h4,
.composer-editor h5,
.composer-editor h6 {
  font-family: var(--display), var(--sans);
  color: var(--paper);
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.2;
  margin: 1.4em 0 0.5em;
}
.composer-editor h1 { font-size: 1.55em; }
.composer-editor h2 { font-size: 1.35em; }
.composer-editor h3 { font-size: 1.18em; }
.composer-editor h4 { font-size: 1.05em; }
.composer-editor h5,
.composer-editor h6 { font-size: 1em; color: var(--surf-2); text-transform: uppercase; letter-spacing: 0.06em; }
.composer-editor blockquote {
  margin: 0.6em 0;
  padding: 0.15em 0 0.15em 0.95em;
  border-left: 3px solid var(--surf-2);
  color: var(--muted);
  font-style: italic;
}
.composer-editor ul,
.composer-editor ol { margin: 0 0 0.85em; padding-left: 1.5em; }
.composer-editor li { margin: 0.15em 0; }
.composer-editor strong, .composer-editor b { color: var(--paper); font-weight: 700; }
.composer-editor em, .composer-editor i { font-style: italic; }

.composer-foot {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  font: 12.5px var(--mono);
  color: var(--surf-2);
  margin-top: 0.5rem;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}
.composer-foot #chunkhint { flex: 1; }
.composer-clear {
  padding: 0.2rem 0.55rem;
  font: 12px var(--mono);
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--surf-2);
  background: transparent;
  border: 1px solid var(--rule);
  border-radius: 4px;
  cursor: pointer;
}
.composer-clear:hover:not([disabled]) {
  color: var(--paper);
  border-color: var(--surf);
  background: rgba(63, 182, 201, 0.08);
}

/* Pause sliders with an on/off checkbox in the title. */
.sliders label.with-toggle > span:first-child { display: inline-flex; align-items: center; gap: 0.45rem; }
.sliders label.with-toggle .pause-toggle {
  width: 14px; height: 14px; margin: 0; accent-color: var(--surf);
}
.sliders label.pause-off > .slider-track,
.sliders label.pause-off > .val { opacity: 0.4; pointer-events: none; }
.sliders label.pause-off > .control-hint { opacity: 0.7; }
.settings-voice-grid label.pause-default > span { display: inline-flex; align-items: center; gap: 0.4rem; }
.settings-voice-grid label.pause-default > span > input[type=checkbox] {
  width: 14px; height: 14px; margin: 0; accent-color: var(--surf);
}
.settings-voice-grid label.pause-off > input[type=number] { opacity: 0.4; pointer-events: none; }

.preview { margin-top: 0.7rem; }
.preview > summary { font-size: 13px; font-weight: 600; color: var(--surf-2); cursor: pointer; padding: 0.2rem 0; }
.preview > summary:hover { color: var(--surf); }
.preview[open] > summary { color: var(--surf); }
.preview-chunk { margin-top: 0.6rem; border: 1px solid var(--rule); border-radius: 6px; overflow: hidden; }
.preview-chunk-head {
  background: var(--abyss-2);
  color: var(--surf-2);
  font: 11.5px var(--mono);
  font-weight: 600;
  padding: 0.35rem 0.7rem;
  border-bottom: 1px solid var(--rule);
}
.preview-chunk pre {
  margin: 0;
  padding: 0.7rem;
  font: 12.5px var(--mono);
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--paper);
  background: transparent;
  max-height: 320px;
  overflow: auto;
}

/* ---------- Cards (controls / step / voice-info) ---------- */
.controls,
.step,
.voice-info {
  background: linear-gradient(180deg, var(--abyss-2) 0%, var(--abyss) 100%);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 1.4rem 1.4rem 1.5rem;
  box-shadow: var(--shadow);
  position: relative;
}
.controls::before,
.step::before {
  content: "";
  position: absolute;
  top: 0; left: 1.4rem; right: 1.4rem;
  height: 2px;
  background: linear-gradient(90deg, transparent 0%, var(--surf) 30%, var(--surf) 70%, transparent 100%);
  opacity: 0.55;
  border-radius: 0 0 2px 2px;
}
.controls {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* Lock state — applied while audio is playing back, since these settings
   only affect the next generation, not what's already being read. */
.controls.locked .row,
.controls.locked .sliders {
  opacity: 0.5;
  transition: opacity .15s ease;
}
.controls.locked input:disabled,
.controls.locked select:disabled {
  cursor: not-allowed;
}

/* ---------- Form controls ---------- */
.row {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}
.row label {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  font-size: 13px;
  font-weight: 600;
  color: var(--surf-2);
  min-width: 240px;
}
select,
input[type=text] {
  background: var(--abyss-deep);
  color: var(--paper);
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.75rem;
  font: 16px/1.4 var(--sans);
  text-transform: none;
  letter-spacing: 0;
  font-weight: 500;
}
select:focus,
input[type=text]:focus {
  border-color: var(--surf);
  outline: none;
  box-shadow: var(--surf-glow);
}

/* ---------- Details / collapsible ---------- */
details summary {
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: var(--surf-2);
  user-select: none;
  padding: 0.4rem 0;
}
details summary:hover { color: var(--surf); }

/* ---------- Sliders ---------- */
.sliders {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-top: 0.85rem;
}
.sliders label {
  display: grid;
  grid-template-columns: 9rem 1fr auto;
  grid-template-areas:
    "name slider value"
    "hint hint   hint";
  align-items: center;
  gap: 0.4rem 0.75rem;
  font-size: 13px;
  color: var(--muted);
  padding: 0.75rem 0.95rem;
  background: var(--abyss-deep);
  border: 1px solid var(--rule);
  border-left: 3px solid rgba(63, 182, 201, 0.35);
  border-radius: var(--radius-sm);
}
.sliders label:hover { border-left-color: var(--surf); }
.sliders label > span:first-child {
  grid-area: name;
  color: var(--paper);
  font-weight: 600;
  font-size: 13px;
  letter-spacing: 0;
  text-transform: none;
}
.sliders label > input[type=range] { grid-area: slider; accent-color: var(--surf); }
.sliders label > .slider-track { grid-area: slider; position: relative; display: flex; flex-direction: column; gap: 0.3rem; }
.sliders label > .slider-track > input[type=range] { width: 100%; margin: 0; }
.sliders label > input[type=checkbox] { grid-area: name; }
.sliders label > .val { grid-area: value; }
.sliders label > .control-hint { grid-area: hint; margin: 0; }
.slider-default {
  position: absolute;
  top: -3px;
  width: 2px;
  height: 14px;
  background: var(--paper);
  opacity: 0.45;
  border-radius: 1px;
  transform: translateX(-50%);
  pointer-events: none;
}
.slider-scale {
  display: flex;
  justify-content: space-between;
  font-size: 10.5px;
  color: var(--muted);
  letter-spacing: 0.02em;
  opacity: 0.75;
}
.sliders .val {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: 12px;
  color: var(--surf);
  min-width: 3.2em;
  text-align: right;
  font-weight: 700;
  background: rgba(63, 182, 201, 0.10);
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  border: 1px solid rgba(63, 182, 201, 0.20);
}
.sliders .check { grid-template-columns: auto 1fr; grid-template-areas: "check name" "hint hint"; gap: 0.4rem 0.6rem; }
.sliders .check > input[type=checkbox] { grid-area: check; width: 16px; height: 16px; accent-color: var(--surf); margin: 0; justify-self: start; }
.sliders .check > span:nth-of-type(1) { grid-area: name; padding-left: 0; }
.sliders .check > .val { display: none; }

/* ---------- Range track styling ---------- */
input[type=range] {
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  background: rgba(63, 182, 201, 0.18);
  border-radius: 999px;
  outline: none;
}
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--surf);
  cursor: pointer;
  border: 2px solid var(--abyss);
  box-shadow: 0 0 0 1px var(--surf), 0 2px 6px rgba(0, 0, 0, 0.4);
}
input[type=range]::-moz-range-thumb {
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--surf);
  cursor: pointer;
  border: 2px solid var(--abyss);
  box-shadow: 0 0 0 1px var(--surf), 0 2px 6px rgba(0, 0, 0, 0.4);
}

/* ---------- Hints ---------- */
.hint, .control-hint {
  font-size: 13px;
  color: var(--muted);
  margin: 0.45rem 0 0;
  line-height: 1.6;
}
.hint code, .control-hint code {
  background: rgba(63, 182, 201, 0.10);
  border: 1px solid rgba(63, 182, 201, 0.22);
  padding: 0.05rem 0.4rem;
  border-radius: 4px;
  font: 12px var(--mono);
  color: var(--surf-2);
}
.hint strong, .control-hint strong { color: var(--paper); font-weight: 600; }

/* ---------- Tag bar ---------- */
#tagbar {
  background: var(--abyss-deep);
  border: 1px solid var(--rule);
  border-radius: var(--radius-sm);
  padding: 0.8rem 0.95rem;
}
.tagbar-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
}
.tagbar-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--surf-2);
  margin-right: 0.4rem;
}
#tagbar button {
  background: rgba(63, 182, 201, 0.06);
  border: 1px solid rgba(63, 182, 201, 0.22);
  color: var(--surf-2);
  padding: 0.3rem 0.75rem;
  border-radius: 999px;
  font: 12px var(--sans);
  font-weight: 600;
  cursor: pointer;
  transition: all .12s ease;
}
#tagbar button:hover {
  border-color: var(--surf);
  color: var(--abyss);
  background: var(--surf);
}

/* ---------- Buttons ---------- */
.actions {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
  align-items: center;
}
button {
  background: rgba(63, 182, 201, 0.06);
  color: var(--text);
  border: 1px solid var(--rule-strong);
  padding: 0.6rem 1.1rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font: 13px var(--sans);
  font-weight: 600;
  letter-spacing: 0.01em;
  transition: all .12s ease;
}
button:hover:not([disabled]) {
  border-color: var(--surf);
  background: rgba(63, 182, 201, 0.12);
  color: var(--paper);
}
button.primary {
  background: linear-gradient(180deg, var(--surf-2) 0%, var(--surf) 100%);
  border-color: var(--surf);
  color: var(--accent-ink);
  font-weight: 700;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.30) inset,
    0 6px 18px rgba(63, 182, 201, 0.30);
}
button.primary:hover:not([disabled]) {
  background: linear-gradient(180deg, #95DEE9 0%, var(--surf-2) 100%);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.35) inset,
    0 8px 22px rgba(63, 182, 201, 0.45);
  transform: translateY(-1px);
}
button.primary:active:not([disabled]) { transform: translateY(0); }
button:disabled { opacity: 0.4; cursor: not-allowed; box-shadow: none; }

/* ---------- Status messages ---------- */
#status, #proc-status, #upload-status, #train-status {
  font-size: 13px;
  color: var(--text);
  font-weight: 500;
}
#status.error, #proc-status.error, #upload-status.error, #train-status.error {
  color: var(--danger);
}
#status.ok, #proc-status.ok, #upload-status.ok, #train-status.ok {
  color: var(--good);
}

/* ---------- Audio player ---------- */
audio {
  width: 100%;
  margin-top: 0.6rem;
  border-radius: var(--radius-sm);
  filter: hue-rotate(165deg) saturate(0.9);
}

/* ---------- Update page ---------- */
.voice-info {
  font-size: 13px;
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1rem;
  line-height: 1.6;
}
.voice-info strong { color: var(--paper); font-weight: 600; }
.voice-info .pill {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.65rem;
  border-radius: 999px;
  background: var(--surf);
  color: var(--abyss);
  font: 12px var(--sans);
  font-weight: 700;
  margin-left: 0.4rem;
}
.voice-info-foot {
  width: 100%;
  margin-top: 0.4rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.voice-sources summary {
  cursor: pointer;
  color: var(--surf-2);
  font-size: 13px;
  font-weight: 600;
  padding: 0.2rem 0;
  user-select: none;
}
.voice-sources summary:hover { color: var(--surf); }
.voice-sources .source-list {
  list-style: none;
  margin: 0.4rem 0 0;
  padding: 0.5rem 0.7rem;
  background: var(--abyss-deep);
  border: 1px solid var(--rule);
  border-radius: var(--radius-sm);
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  max-height: 18rem;
  overflow-y: auto;
}
.voice-sources .source-list li {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  font-size: 12.5px;
  color: var(--muted);
}
.voice-sources .source-list code {
  font: 12px var(--mono);
  color: var(--paper);
  background: rgba(63, 182, 201, 0.10);
  border: 1px solid rgba(63, 182, 201, 0.18);
  padding: 0.1rem 0.45rem;
  border-radius: 4px;
}
.voice-sources .source-list .legacy {
  font-size: 11.5px;
  color: var(--dimmer);
  font-style: italic;
}
.voice-sources .source-list .src-stats {
  font: 11.5px var(--mono);
  color: var(--surf);
  font-variant-numeric: tabular-nums;
  margin-left: auto;
  font-weight: 600;
}
.voice-sources .source-list li.justin code {
  background: rgba(63, 182, 201, 0.22);
  border-color: rgba(63, 182, 201, 0.45);
}
.speaker-panel .source-list li label.check {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  cursor: pointer;
  margin: 0;
}
.speaker-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 0.4rem;
  flex-wrap: wrap;
}
.speaker-actions .recompute-btn {
  background: var(--accent);
  color: var(--abyss-deep);
  border: 0;
  padding: 0.35rem 0.8rem;
  border-radius: var(--radius-sm);
  font: 600 12.5px var(--sans);
  cursor: pointer;
}
.speaker-actions .recompute-btn:disabled { opacity: 0.6; cursor: default; }
.speaker-actions .recompute-status { font-size: 12px; color: var(--surf); }
.speaker-actions .recompute-status.error { color: var(--err, #e0726b); }
.speaker-actions a { font-size: 12px; color: var(--muted); margin-left: auto; }

.ver {
  font: 600 11px var(--sans);
  padding: 0.1rem 0.45rem;
  border-radius: 4px;
  border: 1px solid transparent;
  letter-spacing: 0.01em;
}
.ver.ver-ok {
  color: var(--good);
  background: rgba(111, 225, 176, 0.10);
  border-color: rgba(111, 225, 176, 0.35);
}
.ver.ver-low {
  color: var(--surf-2);
  background: rgba(123, 209, 222, 0.10);
  border-color: rgba(123, 209, 222, 0.30);
}
.ver.ver-no {
  color: var(--dimmer);
  background: rgba(151, 168, 194, 0.08);
  border-color: rgba(151, 168, 194, 0.22);
}
.ver.ver-err {
  color: var(--danger);
  background: rgba(230, 85, 106, 0.10);
  border-color: rgba(230, 85, 106, 0.30);
}

.noise-hint {
  font: 600 11.5px var(--mono);
  color: var(--surf-2);
  font-variant-numeric: tabular-nums;
}

.step h2 {
  font-family: var(--sans);
  font-size: 1.05rem;
  margin: 0 0 0.85rem;
  font-weight: 700;
  color: var(--paper);
  letter-spacing: -0.005em;
  display: flex;
  align-items: center;
  gap: 0.7rem;
}
.step h2::before {
  content: "";
  display: inline-block;
  width: 10px; height: 10px;
  background: var(--surf);
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 0 0 3px rgba(63, 182, 201, 0.22);
}

/* ---------- Dropzone ---------- */
.dropzone {
  border: 1.5px dashed rgba(63, 182, 201, 0.35);
  border-radius: var(--radius);
  padding: 1.75rem;
  text-align: center;
  margin: 0.85rem 0;
  background: var(--abyss-deep);
  transition: all .15s ease;
  position: relative;
}
.dropzone:hover,
.dropzone.over {
  border-color: var(--surf);
  background: rgba(63, 182, 201, 0.08);
  box-shadow: var(--surf-glow);
}
.dropzone input[type=file] { display: none; }
.dropzone p { margin: 0.4rem 0; color: var(--text); font-size: 13.5px; }
.dropzone #filename { color: var(--paper); font-weight: 600; font-size: 14px; }
.dropzone button {
  background: var(--surf);
  color: var(--abyss);
  border-color: var(--surf);
  padding: 0.4rem 0.85rem;
  font-size: 12.5px;
  font-weight: 700;
}
.dropzone button:hover {
  background: var(--surf-2);
  color: var(--abyss);
  border-color: var(--surf-2);
}

/* ---------- File list (selected uploads) ---------- */
.filelist {
  list-style: none;
  margin: 0.6rem 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  text-align: left;
  max-width: 480px;
  margin-left: auto;
  margin-right: auto;
}
.filelist:empty { display: none; }
.filelist li {
  font-size: 13px;
  color: var(--paper);
  font-weight: 600;
  background: rgba(63, 182, 201, 0.06);
  border: 1px solid rgba(63, 182, 201, 0.18);
  padding: 0.35rem 0.7rem;
  border-radius: var(--radius-sm);
  font-variant-numeric: tabular-nums;
}
.filelist li.dupe {
  background: rgba(230, 85, 106, 0.08);
  border-color: rgba(230, 85, 106, 0.40);
}
.filelist li.dupe .dupe-warn {
  display: block;
  margin-top: 0.2rem;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--danger);
  font-variant-numeric: normal;
}

/* ---------- Per-file processing rows ---------- */
.proc-list {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-top: 0.85rem;
}
.proc-list:empty { display: none; }
.proc-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 2fr);
  gap: 0.85rem;
  align-items: center;
  padding: 0.5rem 0.85rem;
  background: var(--abyss-deep);
  border: 1px solid var(--rule);
  border-left: 3px solid rgba(63, 182, 201, 0.35);
  border-radius: var(--radius-sm);
  font-size: 13px;
}
.proc-row.ok { border-left-color: var(--good); }
.proc-row.error { border-left-color: var(--danger); }
.proc-name {
  color: var(--paper);
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.proc-stage {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  font-size: 12.5px;
}
.proc-row.ok .proc-stage { color: var(--good); }
.proc-row.error .proc-stage { color: var(--danger); }

/* ---------- Results / clip rows ---------- */
.results {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin: 0.85rem 0;
  max-height: 65vh;
  overflow-y: auto;
  padding-right: 4px;
}

/* ---------- Per-source clip group ---------- */
.job-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0.85rem;
  background: rgba(8, 27, 54, 0.55);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
}
.job-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.85rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--rule);
}
.job-source {
  color: var(--paper);
  font-weight: 700;
  font-size: 13.5px;
  flex-shrink: 0;
  max-width: 60%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.job-stats {
  font: 12px var(--mono);
  color: var(--surf-2);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}
.job-header label.check {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 12.5px;
  color: var(--muted);
  font-weight: 600;
}
.job-header label.check input[type=checkbox] {
  width: 16px; height: 16px; accent-color: var(--surf);
}
.group-source-label {
  flex: 1;
  min-width: 200px;
  max-width: 320px;
  font-size: 12.5px;
  padding: 0.4rem 0.6rem;
}
.job-group .clips {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.job-group > details.clip-list > summary {
  cursor: pointer;
  color: var(--surf-2);
  font-size: 13px;
  font-weight: 600;
  padding: 0.2rem 0;
  user-select: none;
}
.job-group > details.clip-list > summary:hover { color: var(--surf); }
.job-group > details.clip-list[open] > .clips { margin-top: 0.4rem; }

.clip {
  display: grid;
  grid-template-columns: auto auto 1fr;
  gap: 0.55rem 0.85rem;
  align-items: center;
  padding: 0.7rem 0.95rem;
  background: var(--abyss-deep);
  border: 1px solid var(--rule);
  border-left: 3px solid rgba(63, 182, 201, 0.4);
  border-radius: var(--radius-sm);
  transition: all .12s ease;
}
.clip:hover {
  border-color: var(--rule-strong);
  border-left-color: var(--surf);
  background: var(--abyss);
}
.clip input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--surf); }
.clip .meta {
  font: 11.5px var(--mono);
  color: var(--surf);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.03em;
  font-weight: 700;
}
.clip .text {
  font-size: 13px;
  color: var(--text);
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.clip audio {
  grid-column: 1 / -1;
  width: 100%;
  max-width: 100%;
  height: 44px;
  min-width: 0;
}

/* ---------- Stitched preview rows ---------- */
.stitched {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin: 0.85rem 0;
}
.stitched-row {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  padding: 0.7rem 0.95rem;
  background: var(--abyss-deep);
  border: 1px solid var(--rule);
  border-left: 3px solid rgba(63, 182, 201, 0.4);
  border-radius: var(--radius-sm);
  transition: border-color .12s ease;
}
.stitched-row.ok { border-left-color: var(--good); }
.stitched-row.error { border-left-color: var(--danger); }
.stitched-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.85rem;
}
.stitched-source {
  color: var(--paper);
  font-weight: 700;
  font-size: 13.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 60%;
}
.stitched-stats {
  font: 12px var(--mono);
  color: var(--surf-2);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}
.stitched-stats.error { color: var(--danger); }
.stitched-row audio { width: 100%; height: 36px; }

#stitch-status {
  font-size: 13px;
  color: var(--text);
  font-weight: 500;
}
#stitch-status.error { color: var(--danger); }
#stitch-status.ok { color: var(--good); }

/* ---------- Scrollbar ---------- */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb {
  background: rgba(63, 182, 201, 0.20);
  border-radius: 5px;
}
::-webkit-scrollbar-thumb:hover { background: rgba(63, 182, 201, 0.40); }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- Selection ---------- */
::selection { background: var(--surf); color: var(--abyss); }

/* ---------- Settings cog & modal ---------- */
#settings-cog {
  background: rgba(63, 182, 201, 0.06);
  color: var(--surf);
  border: 1px solid rgba(63, 182, 201, 0.22);
  width: 34px;
  height: 34px;
  padding: 0;
  border-radius: 8px;
  font-size: 16px;
  line-height: 1;
  display: inline-grid;
  place-items: center;
  margin-left: 0.4rem;
}
#settings-cog:hover {
  background: var(--surf);
  color: var(--abyss);
  border-color: var(--surf);
}

#settings-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(8, 14, 26, 0.78);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: grid;
  place-items: center;
  z-index: 100;
  padding: 24px;
}
#settings-backdrop[hidden] { display: none; }
.settings-modal {
  background: linear-gradient(180deg, var(--abyss-2) 0%, var(--abyss) 100%);
  border: 1px solid var(--rule-strong);
  border-radius: 14px;
  max-width: 480px;
  width: 100%;
  max-height: 90dvh;
  padding: 1.6rem;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 1rem;
  position: relative;
  overflow-y: auto;
}
.settings-modal::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--surf-2) 0%, var(--surf) 50%, var(--surf-deep) 100%);
}
.settings-modal h2 {
  margin: 0;
  font-family: var(--display);
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--paper);
  letter-spacing: -0.01em;
}
.settings-modal label {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.settings-modal label > span {
  font-size: 13px;
  font-weight: 600;
  color: var(--surf-2);
}
.settings-optional {
  font-style: normal;
  font-weight: 500;
  color: var(--dimmer);
  margin-left: 0.3rem;
  font-size: 12px;
}
.settings-modal input[type=text] {
  font: 16px var(--mono);
}
.settings-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin-top: 0.25rem;
}

/* Voice setting defaults inside the cog modal */
.settings-voice-defaults {
  border: 1px solid var(--rule);
  border-radius: var(--radius-sm);
  padding: 0.85rem 1rem 0.95rem;
  margin: 0;
  background: var(--abyss-deep);
}
.settings-voice-defaults legend {
  font-size: 13px;
  font-weight: 600;
  color: var(--surf-2);
  padding: 0 0.4rem;
}
.settings-voice-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.6rem 0.85rem;
}
.settings-voice-grid label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted);
}
.settings-voice-grid input[type=number] {
  background: var(--abyss);
  color: var(--paper);
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius-sm);
  padding: 0.4rem 0.55rem;
  font: 14px var(--mono);
  font-variant-numeric: tabular-nums;
}
.settings-voice-grid input[type=number]:focus {
  border-color: var(--surf);
  outline: none;
  box-shadow: var(--surf-glow);
}
.settings-voice-grid label.check {
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
  grid-column: 1 / -1;
}
.settings-voice-grid label.check input[type=checkbox] {
  width: 16px;
  height: 16px;
  accent-color: var(--surf);
  margin: 0;
}
.settings-voice-defaults .control-hint {
  margin-top: 0.65rem;
}

/* Six compact stacked H1–H6 cells in a single row */
.heading-breaks-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 0.45rem;
}
.heading-breaks-grid label {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
  font: 700 11px var(--mono);
  letter-spacing: 0.06em;
  color: var(--surf-2);
}
.heading-breaks-grid input[type=number] {
  width: 100%;
  background: var(--abyss);
  color: var(--paper);
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius-sm);
  padding: 0.4rem 0.35rem;
  font: 13px var(--mono);
  font-variant-numeric: tabular-nums;
  text-align: center;
}
.heading-breaks-grid input[type=number]:focus {
  border-color: var(--surf);
  outline: none;
  box-shadow: var(--surf-glow);
}

/* "Save as new default" row under the voice settings sliders */
.voice-default-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 0.85rem;
}
#voice-default-status {
  font-size: 12.5px;
  color: var(--muted);
  font-weight: 500;
}
#voice-default-status.ok { color: var(--good); }

/* ---------- Tablet & smaller (≤ 720px) ---------- */
@media (max-width: 720px) {
  header {
    padding: 0.85rem max(1rem, env(safe-area-inset-right)) 0.85rem max(1rem, env(safe-area-inset-left));
  }
  main {
    padding: 1.25rem max(1rem, env(safe-area-inset-right)) 3rem max(1rem, env(safe-area-inset-left));
  }
  .brand { gap: 0.75rem; }
  .brand .mark { width: 44px; height: 44px; border-radius: 10px; }
  .brand .mark img { padding: 4px; }
  .brand .product { font-size: 1.1rem; }
  .brand .tagline { font-size: 11px; }
  .brand .label { font-size: 9px; letter-spacing: 0.16em; }
  nav a { padding: 0.35rem 0.65rem; font-size: 12.5px; }
  .controls, .step, .voice-info { padding: 1.1rem; }
  .controls::before, .step::before { left: 1.1rem; right: 1.1rem; }
}

/* ---------- Phones (≤ 520px): reflow grids that don't fit ---------- */
@media (max-width: 520px) {
  .row label { min-width: 0; }

  /* Slider rows: stack name+value above the track */
  .sliders label {
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "name  value"
      "slider slider"
      "hint  hint";
  }

  /* Clip rows: tighten gaps on narrow viewports */
  .clip { gap: 0.45rem 0.7rem; }

  /* Per-file processing rows: stack name above stage */
  .proc-row {
    grid-template-columns: 1fr;
    gap: 0.3rem;
  }

  /* Job/stitched headers: don't truncate aggressively in single column */
  .job-source, .stitched-source { max-width: 100%; }
  .group-source-label { max-width: 100%; }
}

/* ---------- Narrow phones / Fold cover (≤ 420px) ---------- */
@media (max-width: 420px) {
  header {
    gap: 0.5rem;
    padding-top: 0.7rem;
    padding-bottom: 0.7rem;
  }
  .brand .tagline { display: none; }
  .brand .mark { width: 40px; height: 40px; }
  .brand .product { font-size: 1.05rem; }
  .brand .label { font-size: 9px; }
  nav a { padding: 0.3rem 0.55rem; font-size: 12px; }
  .controls, .step, .voice-info { padding: 1rem 0.85rem; }
  .controls::before, .step::before { left: 0.85rem; right: 0.85rem; }
  .composer-editor { padding: 0.9rem 1rem; min-height: 220px; }
  .composer-editor.is-empty::before { top: 0.9rem; left: 1rem; right: 1rem; }
  .lede { padding-left: 0.75rem; font-size: 14px; }
}

/* ---------- Touch devices (any size): bump tap targets ---------- */
@media (pointer: coarse) {
  button { min-height: 44px; }
  button.primary { min-height: 44px; }
  nav a {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
  }
  #tagbar button {
    min-height: 36px;
    padding: 0.45rem 0.95rem;
  }
  #settings-cog { width: 44px; height: 44px; }
  input[type=range] { height: 6px; }
  input[type=range]::-webkit-slider-thumb { width: 22px; height: 22px; }
  input[type=range]::-moz-range-thumb { width: 22px; height: 22px; }
  .clip input[type=checkbox] { width: 22px; height: 22px; }
  .sliders .check > input[type=checkbox] { width: 20px; height: 20px; }
  .job-header label.check input[type=checkbox] { width: 20px; height: 20px; }
  details summary { padding: 0.6rem 0; }
  .voice-sources summary { padding: 0.5rem 0; }
  select { min-height: 44px; }
}
