/* SSTPN — console de transcription locale.
   Palette OKLCH, police système, clair/sombre automatique. */

:root {
  color-scheme: light dark;

  --bg: oklch(98.2% 0.003 80);
  --surface: oklch(100% 0 0);
  --surface-2: oklch(96.5% 0.004 80);
  --ink: oklch(21% 0.01 80);
  --ink-2: oklch(43% 0.012 80);
  --ink-3: oklch(51% 0.012 80);
  --hairline: oklch(88% 0.006 80);
  --accent: oklch(55% 0.16 250);
  --accent-ink: oklch(98% 0.01 250);
  --ok: oklch(56% 0.14 150);
  --warn: oklch(62% 0.13 70);
  --danger: oklch(54% 0.17 25);
  --danger-bg: oklch(96% 0.02 25);

  --radius: 10px;
  --radius-lg: 14px;
  --shadow-1: 0 1px 2px oklch(20% 0.01 80 / 0.06), 0 4px 16px oklch(20% 0.01 80 / 0.05);
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: oklch(19% 0.008 80);
    --surface: oklch(23.5% 0.008 80);
    --surface-2: oklch(27% 0.008 80);
    --ink: oklch(93% 0.005 80);
    --ink-2: oklch(74% 0.008 80);
    --ink-3: oklch(66% 0.008 80);
    --hairline: oklch(32% 0.008 80);
    --accent: oklch(68% 0.14 250);
    --accent-ink: oklch(18% 0.02 250);
    --danger-bg: oklch(26% 0.03 25);
    --shadow-1: 0 1px 2px oklch(0% 0 0 / 0.3), 0 6px 20px oklch(0% 0 0 / 0.25);
  }
}

* { box-sizing: border-box; }

html { height: 100%; }

body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: clamp(20px, 5vh, 56px) 20px 48px;
}

.app {
  width: 100%;
  max-width: 560px;
}

/* ---------- En-tête ---------- */

header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 28px;
}

header h1 {
  font-size: 1.25rem;
  font-weight: 650;
  letter-spacing: -0.015em;
  margin: 0;
}

header .tagline {
  color: var(--ink-3);
  font-size: 0.8rem;
}

/* ---------- Écrans ---------- */

.screen { display: none; }
.screen.active {
  display: block;
  animation: screen-in 240ms var(--ease-out);
}

@keyframes screen-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: none; }
}

/* ---------- Zone de dépôt ---------- */

.dropzone {
  border: 1.5px dashed var(--hairline);
  border-radius: var(--radius-lg);
  background: var(--surface);
  padding: 40px 24px;
  text-align: center;
  cursor: pointer;
  transition: border-color 140ms var(--ease-out),
              background-color 140ms var(--ease-out),
              transform 140ms var(--ease-out);
}

.dropzone:hover { border-color: var(--ink-3); }
.dropzone:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.dropzone.dragover {
  border-color: var(--accent);
  background: color-mix(in oklch, var(--accent) 6%, var(--surface));
  transform: scale(1.01);
}
.dropzone:active { transform: scale(0.995); }

.dropzone .dz-icon {
  width: 34px; height: 34px;
  margin: 0 auto 10px;
  color: var(--ink-3);
}
.dropzone.dragover .dz-icon,
.dropzone.has-file .dz-icon { color: var(--accent); }

.dropzone .dz-title { font-weight: 550; }
.dropzone .dz-hint {
  color: var(--ink-3);
  font-size: 0.8rem;
  margin-top: 4px;
}

.dropzone.has-file { border-style: solid; border-color: var(--accent); }
.dropzone .dz-file {
  font-weight: 550;
  overflow-wrap: anywhere;
}
.dropzone .dz-filesize { color: var(--ink-2); font-size: 0.8rem; }

/* ---------- Réglages (rows façon Préférences) ---------- */

.settings {
  margin-top: 16px;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 11px 16px;
  min-height: 44px;
}
.setting-row + .setting-row { border-top: 1px solid var(--hairline); }

.setting-row .label { font-weight: 500; }
.setting-row .sublabel {
  display: block;
  color: var(--ink-3);
  font-size: 0.78rem;
  font-weight: 400;
}

select {
  appearance: none;
  font: inherit;
  color: var(--ink);
  background: var(--surface-2)
    url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="10" height="6" viewBox="0 0 10 6"><path d="M1 1l4 4 4-4" fill="none" stroke="%23888" stroke-width="1.5" stroke-linecap="round"/></svg>')
    no-repeat right 10px center;
  border: 1px solid var(--hairline);
  border-radius: 8px;
  padding: 6px 28px 6px 10px;
  max-width: 230px;
}
[hidden] {
  display: none !important;
}

/* Interrupteur iOS / Apple HIG */
.switch {
  position: relative;
  width: 48px;
  height: 28px;
  display: inline-block;
  flex: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}
.switch input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  margin: 0;
  cursor: pointer;
  z-index: 2;
}
.switch .track {
  position: absolute;
  inset: 0;
  border-radius: 14px;
  background: color-mix(in oklch, var(--ink) 25%, var(--surface-2));
  border: 1px solid var(--hairline);
  transition: background-color 200ms cubic-bezier(0.16, 1, 0.3, 1),
              border-color 200ms cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: inset 0 1px 2px oklch(0% 0 0 / 0.12);
}
.switch .thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 2px 5px oklch(0% 0 0 / 0.28), 0 0.5px 1px oklch(0% 0 0 / 0.15);
  transition: transform 200ms cubic-bezier(0.16, 1, 0.3, 1);
  pointer-events: none;
}
.switch input:checked ~ .track {
  background: #34c759; /* Apple Green */
  border-color: #34c759;
  box-shadow: none;
}
.switch input:checked ~ .thumb {
  transform: translateX(20px);
}
.switch input:focus-visible ~ .track {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---------- Boutons ---------- */

a.btn { text-decoration: none; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font: inherit;
  font-weight: 550;
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  padding: 10px 18px;
  min-height: 44px;
  cursor: pointer;
  transition: transform 100ms var(--ease-out), background-color 140ms var(--ease-out),
              opacity 140ms var(--ease-out);
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: scale(0.97); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn[disabled] { opacity: 0.45; cursor: default; pointer-events: none; }

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}
.btn-primary:hover { background: color-mix(in oklch, var(--accent) 88%, black); }

.btn-block { width: 100%; margin-top: 16px; }

/* ---------- Bannière de reprise ---------- */

.resume-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 16px;
  padding: 10px 14px;
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  background: var(--surface);
  font-size: 0.85rem;
  color: var(--ink-2);
}
.resume-banner .btn { min-height: 34px; padding: 5px 12px; font-size: 0.85rem; }

/* ---------- Écran traitement ---------- */

.file-line {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 14px;
}
.file-line .name { font-weight: 600; overflow-wrap: anywhere; }
.file-line .pct {
  font-variant-numeric: tabular-nums;
  color: var(--ink-2);
  font-size: 0.9rem;
}

.progressbar {
  height: 4px;
  border-radius: 2px;
  background: var(--surface-2);
  overflow: hidden;
  margin-bottom: 22px;
}
.progressbar .fill {
  height: 100%;
  width: 100%;
  border-radius: 2px;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 400ms var(--ease-out);
}

.steps {
  list-style: none;
  margin: 0; padding: 0;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.step {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  color: var(--ink-3);
  transition: color 200ms var(--ease-out);
}
.step + .step { border-top: 1px solid var(--hairline); }
.step .marker {
  width: 18px; height: 18px;
  flex: none;
  display: grid;
  place-items: center;
}
.step .dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--hairline);
  transition: background-color 200ms var(--ease-out);
}
.step.running { color: var(--ink); }
.step.done { color: var(--ink-2); }
.step .check { display: none; color: var(--ok); }
.step.done .check { display: block; }
.step.done .dot, .step.running .dot { display: none; }

.spinner {
  display: none;
  width: 14px; height: 14px;
  border: 2px solid var(--hairline);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 800ms linear infinite;
}
.step.running .spinner { display: block; }
@keyframes spin { to { transform: rotate(360deg); } }

.run-message {
  margin: 14px 2px 0;
  min-height: 1.5em;
  color: var(--ink-2);
  font-size: 0.85rem;
}

details.log { margin-top: 10px; }
details.log summary {
  cursor: pointer;
  color: var(--ink-3);
  font-size: 0.8rem;
  user-select: none;
}
details.log summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.log-body {
  margin-top: 8px;
  max-height: 200px;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  padding: 10px 12px;
  font: 12px/1.6 ui-monospace, "SF Mono", Menlo, monospace;
  color: var(--ink-2);
  overscroll-behavior: contain;
}

/* ---------- Écran résultat ---------- */

.done-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
}
.done-header .badge {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: color-mix(in oklch, var(--ok) 15%, var(--surface));
  color: var(--ok);
  display: grid;
  place-items: center;
  flex: none;
}
.done-header h2 {
  font-size: 1.05rem;
  font-weight: 650;
  letter-spacing: -0.01em;
  margin: 0;
}
.done-header .meta { color: var(--ink-3); font-size: 0.8rem; }

.speakers {
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: 16px;
}
.speaker-row {
  display: grid;
  grid-template-columns: 10px 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 11px 16px;
}
.speaker-row + .speaker-row { border-top: 1px solid var(--hairline); }
.speaker-row .swatch {
  width: 10px; height: 10px;
  border-radius: 50%;
}
.speaker-row .who { font-weight: 550; }
.speaker-row .bar {
  grid-column: 2 / 4;
  height: 4px;
  border-radius: 2px;
  background: var(--surface-2);
  overflow: hidden;
}
.speaker-row .bar > div { height: 100%; border-radius: 2px; }
.speaker-row .time {
  color: var(--ink-2);
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
}

.who-input {
  font: inherit;
  font-weight: 550;
  color: var(--ink);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 2px 6px;
  margin-left: -7px;
  width: 100%;
  max-width: 220px;
  transition: border-color 140ms var(--ease-out), background-color 140ms var(--ease-out);
}
.who-input:hover { border-color: var(--hairline); }
.who-input:focus-visible {
  outline: none;
  border-color: var(--accent);
  background: var(--surface-2);
}

.rename-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: -6px 2px 16px;
}
.rename-bar .rename-hint {
  color: var(--ink-3);
  font-size: 0.78rem;
}
.rename-bar .btn { min-height: 36px; padding: 6px 14px; font-size: 0.88rem; flex: none; }

.actions { display: flex; gap: 10px; flex-wrap: wrap; }
.actions .btn { flex: 1; }
.actions .btn.ghost { flex: none; }

/* ---------- Erreur ---------- */

.error-box {
  background: var(--danger-bg);
  border: 1px solid color-mix(in oklch, var(--danger) 30%, transparent);
  border-radius: var(--radius-lg);
  padding: 16px;
  margin-bottom: 16px;
}
.error-box h2 {
  margin: 0 0 6px;
  font-size: 0.95rem;
  color: var(--danger);
}
.error-box p { margin: 0; font-size: 0.88rem; color: var(--ink-2); overflow-wrap: anywhere; }
.error-box .suggestion { margin-top: 8px; font-style: italic; }

/* ---------- Divers ---------- */

.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  clip-path: inset(50%);
  overflow: hidden;
  white-space: nowrap;
}

@media (prefers-reduced-motion: reduce) {
  .screen.active { animation: none; }
  .dropzone, .btn, .switch .thumb, .progressbar .fill { transition: none; }
  .spinner { animation-duration: 1600ms; }
}

/* ---------- Éditeur : app élargie sur l'écran résultat ---------- */

.app:has(#screen-done.active) { max-width: 840px; }

.text-input {
  width: 100%;
  max-width: 260px;
  padding: 7px 10px;
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
}
.text-input:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* ---------- Lecteur audio ---------- */

.player {
  position: sticky;
  top: 8px;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  margin: 18px 0 6px;
  border: 1px solid var(--hairline);
  border-radius: var(--radius-lg);
  background: color-mix(in oklab, var(--surface) 75%, transparent);
  backdrop-filter: blur(16px) saturate(160%);
  box-shadow: var(--shadow-1);
}
@media (prefers-reduced-transparency: reduce) {
  .player { background: var(--surface); backdrop-filter: none; }
}

.p-play {
  flex: none;
  width: 34px;
  height: 34px;
  border: none;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-ink);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: transform 100ms ease-out;
}
.p-play:active { transform: scale(0.94); }
.p-play .ic-pause { display: none; }
.player.playing .ic-play { display: none; }
.player.playing .ic-pause { display: block; }

.p-time {
  flex: none;
  font-variant-numeric: tabular-nums;
  font-size: 12.5px;
  color: var(--ink-2);
  min-width: 40px;
  text-align: center;
}

#p-seek {
  flex: 1;
  accent-color: var(--accent);
  min-width: 60px;
}

#p-rate {
  flex: none;
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink-2);
  font-size: 12.5px;
  padding: 4px 6px;
}

.editor-hint {
  margin: 4px 2px 10px;
  font-size: 12px;
  color: var(--ink-3);
}

/* ---------- Transcript ---------- */

.transcript { margin-bottom: 20px; }

.block {
  padding: 10px 12px;
  border-radius: var(--radius);
  margin-bottom: 2px;
}
.block:hover { background: var(--surface-2); }

.block-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 3px;
}

.spk-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: none;
  background: none;
  padding: 2px 8px 2px 2px;
  border-radius: 999px;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  cursor: pointer;
}
.spk-badge:hover { background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--hairline); }
.spk-badge .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex: none;
}

.block-time {
  font-size: 12px;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}

.block-text { margin: 0; line-height: 1.65; }

.w { border-radius: 3px; cursor: pointer; }
.w:hover { background: color-mix(in oklab, var(--accent) 18%, transparent); }
.w.active { background: color-mix(in oklab, var(--accent) 30%, transparent); }

.gap {
  text-align: center;
  color: var(--ink-3);
  font-size: 12px;
  padding: 6px 0;
}

/* ---------- Menu de correction du locuteur ---------- */

.spk-menu {
  position: absolute;
  z-index: 50;
  min-width: 230px;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-1);
  padding: 6px;
}
.spk-menu h4 {
  margin: 6px 8px 4px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-3);
}
.spk-menu button {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  border: none;
  background: none;
  padding: 7px 8px;
  border-radius: var(--radius);
  font: inherit;
  font-size: 13.5px;
  color: var(--ink);
  cursor: pointer;
  text-align: left;
}
.spk-menu button:hover { background: var(--surface-2); }
.spk-menu .dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }

@media (prefers-reduced-motion: reduce) {
  .p-play, .w { transition: none; }
}

/* ---------- Correction avancée : plage de mots, glisser-déposer, annulation ---------- */

.who-cell { display: flex; align-items: center; gap: 6px; min-width: 0; }

.spk-preview {
  flex: none;
  width: 22px; height: 22px;
  border: 1px solid var(--hairline);
  border-radius: 50%;
  background: var(--surface);
  color: var(--ink-2);
  font-size: 9px;
  line-height: 1;
  display: grid;
  place-items: center;
  cursor: pointer;
  padding: 0;
}
.spk-preview:hover { background: var(--surface-2); color: var(--ink); }
.spk-preview:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.p-undo {
  flex: none;
  width: 30px; height: 30px;
  border: 1px solid var(--hairline);
  border-radius: 50%;
  background: var(--surface);
  color: var(--ink-2);
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
}
.p-undo:hover:not([disabled]) { background: var(--surface-2); color: var(--ink); }
.p-undo[disabled] { opacity: 0.35; cursor: default; }
.p-undo:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Mots : sélection de plage et surlignage */
.w.sel {
  background: color-mix(in oklab, var(--accent) 26%, transparent);
  border-radius: 3px;
  box-shadow: 0 0 0 1px color-mix(in oklab, var(--accent) 35%, transparent);
}
.w.sel.active {
  background: color-mix(in oklab, var(--accent) 42%, transparent);
  box-shadow: 0 0 0 1.5px var(--accent);
}

/* Poignée de phrase */
.sent-handle {
  display: inline-block;
  width: 12px;
  margin-right: 1px;
  color: var(--ink-3);
  font-size: 11px;
  line-height: 1;
  letter-spacing: -2px;
  cursor: grab;
  opacity: 0;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  transition: opacity 120ms var(--ease-out);
}
.block:hover .sent-handle { opacity: 0.55; }
.sent-handle:hover { opacity: 1; color: var(--accent); }
.sent-handle.grabbed { opacity: 1; color: var(--accent); cursor: grabbing; }

/* Cibles de dépôt : la cible doit être évidente, pas subtile */
body.dragging { cursor: grabbing; }
body.dragging .w, body.dragging .sent-handle { cursor: grabbing; }
.block.drop-target {
  box-shadow: inset 0 0 0 1px var(--hairline);
  background: var(--surface-2);
}
.block.drop-hover {
  box-shadow: inset 0 0 0 2px var(--accent);
  background: color-mix(in oklch, var(--accent) 12%, var(--surface));
}
.block.drop-hover .spk-badge { background: color-mix(in oklch, var(--accent) 22%, transparent); }

.drag-ghost {
  position: fixed;
  top: 0; left: 0;
  z-index: 60;
  max-width: 320px;
  padding: 6px 10px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--accent);
  box-shadow: var(--shadow-1);
  font-size: 12.5px;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
  opacity: 0.95;
}

/* Barre flottante d'actions sur la sélection */
.sel-bar {
  position: absolute;
  z-index: 55;
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
  max-width: min(92vw, 680px);
  padding: 5px;
  border: 1px solid var(--hairline);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-1);
  animation: bar-pop 140ms var(--ease-out);
}
.sel-bar[hidden] {
  display: none !important;
}
@keyframes bar-pop {
  from { opacity: 0; transform: scale(0.96) translateY(4px); }
  to   { opacity: 1; transform: none; }
}
.sel-bar .sel-info {
  padding: 0 6px 0 4px;
  font-size: 11.5px;
  font-weight: 500;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}
.sel-bar button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid transparent;
  background: var(--surface-2);
  border-radius: var(--radius);
  padding: 5px 9px;
  font: inherit;
  font-size: 12.5px;
  color: var(--ink);
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 100ms var(--ease-out), border-color 100ms var(--ease-out);
}
.sel-bar button:hover { border-color: var(--accent); background: var(--surface); }
.sel-bar button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.sel-bar .dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.sel-bar kbd {
  font: inherit;
  font-size: 10.5px;
  color: var(--ink-3);
  border: 1px solid var(--hairline);
  border-radius: 4px;
  padding: 0 4px;
}
.sel-bar .sel-new {
  border-color: color-mix(in oklch, var(--accent) 30%, transparent);
  background: color-mix(in oklch, var(--accent) 8%, var(--surface));
  font-weight: 500;
}
.sel-bar .sel-new:hover {
  background: color-mix(in oklch, var(--accent) 16%, var(--surface));
  border-color: var(--accent);
}
.sel-bar .sel-new .plus-icon {
  font-size: 13px;
  font-weight: 700;
  color: var(--accent);
}
.sel-bar .sel-split {
  color: var(--ink-2);
}
.sel-bar .sel-split:hover {
  color: var(--ink);
  border-color: var(--hairline);
}
.sel-bar .sel-cancel {
  background: transparent;
  color: var(--ink-3);
  padding: 5px 8px;
  min-width: 28px;
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
  cursor: pointer;
  user-select: none;
  touch-action: manipulation;
}
.sel-bar .sel-cancel:hover {
  color: var(--ink);
  background: var(--surface-2);
}
.sel-bar .sel-cancel:active {
  transform: scale(0.92);
}

/* ---------- Apple HIG : Segmented Control & Sélecteur de Mode ---------- */

.mode-selector-container {
  margin-top: 18px;
}

.apple-segmented {
  display: flex;
  background: var(--surface-2);
  padding: 3px;
  border-radius: 12px;
  border: 1px solid var(--hairline);
  position: relative;
  gap: 2px;
  user-select: none;
}

.segment-btn {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 12px;
  font: inherit;
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--ink-2);
  background: transparent;
  border: none;
  border-radius: 9px;
  cursor: pointer;
  transition: all 160ms var(--ease-out);
  white-space: nowrap;
}

.segment-btn:hover:not(.active) {
  color: var(--ink);
}

.segment-btn.active {
  background: var(--surface);
  color: var(--ink);
  font-weight: 600;
  box-shadow: 0 1px 4px oklch(0% 0 0 / 0.12), 0 0.5px 1px oklch(0% 0 0 / 0.08);
}

.segment-btn .seg-icon {
  font-size: 0.95rem;
}

.mode-description {
  margin-top: 6px;
  margin-left: 2px;
  font-size: 0.78rem;
  color: var(--ink-3);
  line-height: 1.4;
  min-height: 2.2em;
}

/* Barre d'action avec bouton Paramètres */
.setup-actions-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 12px;
}

.btn-settings-trigger {
  font-size: 0.85rem;
  padding: 8px 14px;
  min-height: 38px;
  color: var(--ink-2);
}
.btn-settings-trigger:hover {
  color: var(--ink);
}

/* ---------- Apple HIG : Feuille Modale (Settings Sheet) ---------- */

.apple-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: color-mix(in oklab, var(--bg) 60%, transparent);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms var(--ease-out);
}

.apple-modal-backdrop:not([hidden]) {
  opacity: 1;
  pointer-events: auto;
}

.apple-modal-sheet {
  width: 100%;
  max-width: 580px;
  max-height: 88vh;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: 20px;
  box-shadow: 0 20px 48px -12px oklch(0% 0 0 / 0.35), 0 0 0 1px oklch(100% 0 0 / 0.05);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: scale(0.96) translateY(8px);
  transition: transform 220ms cubic-bezier(0.16, 1, 0.3, 1);
}

.apple-modal-backdrop:not([hidden]) .apple-modal-sheet {
  transform: scale(1) translateY(0);
}

.apple-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--hairline);
}

.apple-modal-title-group h3 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 650;
  letter-spacing: -0.01em;
}

.apple-modal-subtitle {
  font-size: 0.78rem;
  color: var(--ink-3);
  margin-top: 2px;
  display: block;
}

.apple-modal-close {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: none;
  background: var(--surface-2);
  color: var(--ink-2);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background-color 120ms, color 120ms;
}
.apple-modal-close:hover {
  background: color-mix(in oklch, var(--ink) 12%, var(--surface-2));
  color: var(--ink);
}

.apple-modal-body {
  padding: 16px 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
  overscroll-behavior: contain;
}

/* Groupes façon iOS / macOS Settings */
.apple-group {
  display: flex;
  flex-direction: column;
}

.apple-group-header {
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-bottom: 6px;
  padding-left: 8px;
}

.apple-group .apple-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 16px;
  background: var(--surface-2);
  user-select: none;
  min-height: 48px;
}
.apple-group .apple-row.apple-row-toggle {
  cursor: pointer;
  transition: background-color 140ms var(--ease-out);
}
.apple-group .apple-row.apple-row-toggle:hover {
  background: color-mix(in oklch, var(--ink) 4%, var(--surface-2));
}
.apple-group .apple-row.apple-row-toggle:active {
  background: color-mix(in oklch, var(--ink) 7%, var(--surface-2));
}

.apple-group .apple-row:first-of-type {
  border-top-left-radius: 14px;
  border-top-right-radius: 14px;
}
.apple-group .apple-row:last-of-type {
  border-bottom-left-radius: 14px;
  border-bottom-right-radius: 14px;
}
.apple-group .apple-row + .apple-row {
  border-top: 1px solid color-mix(in oklch, var(--hairline) 60%, transparent);
}

.apple-row .row-label {
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex: 1;
  min-width: 0;
}
.apple-row .row-title {
  font-size: 0.90rem;
  font-weight: 550;
  color: var(--ink);
}
.apple-row .row-sub {
  font-size: 0.76rem;
  color: var(--ink-3);
  font-weight: 400;
  line-height: 1.35;
}
.apple-row .row-control {
  flex: none;
  display: flex;
  align-items: center;
}

.apple-select {
  appearance: none;
  font: inherit;
  font-size: 0.85rem;
  color: var(--ink);
  background: var(--surface)
    url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="10" height="6" viewBox="0 0 10 6"><path d="M1 1l4 4 4-4" fill="none" stroke="%23888" stroke-width="1.5" stroke-linecap="round"/></svg>')
    no-repeat right 10px center;
  border: 1px solid var(--hairline);
  border-radius: 8px;
  padding: 6px 28px 6px 10px;
  max-width: 230px;
}

.apple-row-input {
  flex-direction: column;
  align-items: stretch !important;
  gap: 8px !important;
}

.apple-input {
  width: 100%;
  padding: 8px 12px;
  font: inherit;
  font-size: 0.85rem;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: 8px;
  color: var(--ink);
}
.apple-input:focus-visible {
  outline: 2px solid var(--accent);
}

.apple-modal-footer {
  padding: 12px 20px 16px;
  border-top: 1px solid var(--hairline);
  display: flex;
  justify-content: flex-end;
  background: var(--surface);
}

/* Toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translate(-50%, 12px);
  z-index: 70;
  padding: 9px 16px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--bg);
  font-size: 13px;
  box-shadow: var(--shadow-1);
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms var(--ease-out), transform 160ms var(--ease-out);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (prefers-reduced-motion: reduce) {
  .sent-handle, .toast, .apple-modal-backdrop, .apple-modal-sheet { transition: none; }
  .block:hover .sent-handle { opacity: 0.55; }
}

/* ==========================================================================
   Mobile Design & Responsiveness (max-width: 640px)
   ========================================================================== */

@media (max-width: 640px) {
  body {
    padding: max(14px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(28px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
  }

  .app {
    width: 100%;
    max-width: 100%;
  }

  header {
    margin-bottom: 20px;
  }

  header h1 {
    font-size: 1.15rem;
  }

  /* Zone de dépôt mobile */
  .dropzone {
    padding: 28px 16px;
    border-radius: var(--radius);
  }
  .dropzone .dz-icon {
    width: 30px;
    height: 30px;
    margin-bottom: 8px;
  }
  .dropzone .dz-title {
    font-size: 0.95rem;
  }

  /* Segmented Control mobile */
  .apple-segmented {
    padding: 3px;
    gap: 2px;
  }
  .segment-btn {
    padding: 8px 4px;
    font-size: 0.80rem;
    gap: 4px;
  }
  .segment-btn .seg-icon {
    font-size: 0.85rem;
  }

  /* Boutons tactiles (Fitts' Law: min-height 44px) */
  .btn {
    min-height: 46px;
    padding: 10px 16px;
    font-size: 0.95rem;
    touch-action: manipulation;
  }

  /* Feuille Modale Apple HIG (Bottom Sheet mobile) */
  .apple-modal-backdrop {
    align-items: flex-end;
    padding: 0;
  }
  .apple-modal-sheet {
    width: 100%;
    max-width: 100%;
    max-height: 88dvh;
    max-height: 88vh;
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
    border-top-left-radius: 20px;
    border-top-right-radius: 20px;
    transform: translateY(100%);
  }
  .apple-modal-backdrop:not([hidden]) .apple-modal-sheet {
    transform: translateY(0);
  }
  .apple-modal-sheet::before {
    content: "";
    display: block;
    width: 36px;
    height: 5px;
    background: color-mix(in oklch, var(--ink) 20%, var(--surface-2));
    border-radius: 3px;
    margin: 8px auto 0;
  }
  .apple-modal-header {
    padding: 12px 16px;
  }
  .apple-modal-body {
    padding: 12px 14px;
    gap: 16px;
  }
  .apple-modal-footer {
    padding: 12px 16px max(16px, env(safe-area-inset-bottom));
  }
  .apple-modal-footer .btn {
    width: 100%;
  }

  /* Rangées réglages & contrôles */
  .apple-group .apple-row {
    padding: 12px 14px;
    gap: 12px;
    min-height: 48px;
  }
  .apple-row .row-title {
    font-size: 0.88rem;
  }
  .apple-row .row-sub {
    font-size: 0.74rem;
  }
  .apple-select {
    max-width: 150px;
    font-size: 0.82rem;
  }

  /* Lecteur Audio mobile */
  .player {
    position: sticky;
    top: max(6px, env(safe-area-inset-top));
    padding: 8px 10px;
    gap: 8px;
  }
  .p-play {
    width: 38px;
    height: 38px;
  }
  .p-time {
    font-size: 11.5px;
    min-width: 34px;
  }
  #p-rate {
    font-size: 11.5px;
    padding: 4px;
  }

  /* Barre flottante d'actions sur mobile : ancrée en bas façon Bottom Toolbar */
  .sel-bar {
    position: fixed !important;
    left: 10px !important;
    right: 10px !important;
    bottom: max(12px, env(safe-area-inset-bottom)) !important;
    top: auto !important;
    width: auto !important;
    max-width: none !important;
    overflow-x: auto;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
    border-radius: 16px;
    box-shadow: 0 8px 30px oklch(0% 0 0 / 0.35);
    padding: 6px 8px;
    gap: 6px;
  }
  .sel-bar .sel-info {
    flex: none;
    font-size: 11px;
  }
  .sel-bar button {
    flex: none;
    min-height: 40px;
    padding: 6px 10px;
    font-size: 12.5px;
    touch-action: manipulation;
  }
  .sel-bar .sel-cancel {
    min-width: 36px;
    min-height: 36px;
  }

  /* Actions & export écran de fin */
  .actions {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
  }
  .actions .btn {
    width: 100%;
    min-height: 46px;
  }
  .speaker-row {
    padding: 10px 12px;
    gap: 8px;
  }
  .who-input {
    max-width: 140px;
  }
  .rename-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }
  .rename-bar .btn {
    width: 100%;
  }
}

