/* DictaPulse — page de comparaison. Palette « salle de lecture » : gris bleuté, encre, accent
   cyan-sarcelle (repères des visionneuses) ; couleurs d'état séparées de l'accent. */
:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-2: #eef2f5;
  --ink: #15202b;
  --ink-2: #4a5866;
  --ink-3: #7b8896;
  --line: #d6dde4;
  --accent: #0b7285;
  --accent-ink: #ffffff;
  --accent-soft: #e3f2f4;
  --ok: #2b7a4b;
  --warn: #9a6700;
  --warn-soft: #fff4d6;
  --danger: #b42318;
  --danger-soft: #fdecea;
  --rec: #c92a2a;
  --radius: 8px;
  --font: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", "SF Mono", Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f151b;
    --surface: #161f28;
    --surface-2: #1c2733;
    --ink: #e6edf3;
    --ink-2: #aab6c2;
    --ink-3: #7d8a97;
    --line: #2b3844;
    --accent: #3bb0c4;
    --accent-ink: #0b1a1f;
    --accent-soft: #14323a;
    --ok: #5cc98a;
    --warn: #e3b341;
    --warn-soft: #2f2610;
    --danger: #f47067;
    --danger-soft: #3a1a18;
    --rec: #ff6b6b;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f151b;
  --surface: #161f28;
  --surface-2: #1c2733;
  --ink: #e6edf3;
  --ink-2: #aab6c2;
  --ink-3: #7d8a97;
  --line: #2b3844;
  --accent: #3bb0c4;
  --accent-ink: #0b1a1f;
  --accent-soft: #14323a;
  --ok: #5cc98a;
  --warn: #e3b341;
  --warn-soft: #2f2610;
  --danger: #f47067;
  --danger-soft: #3a1a18;
  --rec: #ff6b6b;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 var(--font);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
h2, h3 { margin: 0; text-wrap: balance; }
h2 { font-size: 1.05rem; font-weight: 650; }
h3 { font-size: 1rem; font-weight: 650; }
p { margin: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(12px + env(safe-area-inset-top, 0px)) 20px 12px;
  background: var(--surface); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.brand-mark { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); align-self: center; }
.brand-name { font-weight: 700; letter-spacing: 0.01em; }
.brand-sub { color: var(--ink-2); font-size: 0.9rem; }
.version { color: var(--ink-3); font: 0.8rem var(--mono); }

.page { display: grid; gap: 16px; max-width: 1400px; margin: 0 auto; padding: 20px 20px 48px; }

.warning {
  display: grid; gap: 8px; padding: 14px 16px;
  background: var(--warn-soft); border: 1px solid var(--warn); border-radius: var(--radius);
}
.warning h2 { color: var(--warn); font-size: 0.95rem; text-transform: uppercase; letter-spacing: 0.05em; }
.warning p { max-width: 90ch; color: var(--ink); }

.panel { display: grid; gap: 12px; padding: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.panel-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px 16px; flex-wrap: wrap; }
.hint { color: var(--ink-2); font-size: 0.9rem; }

.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-weight: 600; }
.check.small { font-weight: 500; font-size: 0.85rem; color: var(--ink-2); }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }

.access { display: flex; gap: 8px; flex-wrap: wrap; }
.access input { flex: 1 1 220px; }
input[type="password"], input[type="text"] {
  font: inherit; color: var(--ink); background: var(--surface-2);
  border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px;
}
.error { color: var(--danger); font-size: 0.9rem; }

.btn {
  font: inherit; font-weight: 600; cursor: pointer; border-radius: 6px; padding: 8px 14px;
  background: var(--accent); color: var(--accent-ink); border: 1px solid var(--accent);
}
.btn-quiet { background: transparent; color: var(--accent); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.option { font-size: 1rem; }
.choices { border: 0; margin: 0; padding: 0; display: grid; gap: 8px; min-width: 0; }
.choices legend { padding: 0; font-weight: 650; }
.choice-list { display: flex; flex-wrap: wrap; gap: 8px; }
.choice {
  display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-weight: 650;
  padding: 10px 16px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface);
}
.choice:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.choice input { width: 18px; height: 18px; accent-color: var(--accent); }
.configs { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; }
.config {
  display: grid; grid-template-columns: auto 1fr; gap: 4px 10px; align-content: start;
  padding: 12px; border: 1px solid var(--line); border-radius: 6px; cursor: pointer; background: var(--surface);
}
.config:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.config input { grid-row: span 3; margin-top: 3px; width: 18px; height: 18px; accent-color: var(--accent); }
.config-label { font-weight: 650; }
.config-desc { color: var(--ink-2); font-size: 0.88rem; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { font: 0.72rem var(--mono); color: var(--ink-2); background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px; padding: 1px 8px; }
.chip.live { color: var(--accent); border-color: var(--accent); }

/* Texte à lire (gauche) + bouton de dictée (droite) ; empilés sur écran étroit. */
.dictation-row { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(260px, 1fr); gap: 16px; align-items: stretch; }
@media (max-width: 860px) { .dictation-row { grid-template-columns: 1fr; } }
.sample-exam { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-3); }
.sample-text { font-size: 1.02rem; max-width: 75ch; line-height: 1.65; }

/* ---------- Le bouton de dictée : scène d'espace, orbe rouge, micro de verre ----------
   Élément volontairement « un seul look » (nuit profonde) dans les deux thèmes : couleurs
   posées explicitement. --level (0 à 1) vient du niveau du micro pendant la dictée. */
.recorder {
  --level: 0;
  --orb: clamp(92px, 12vw, 116px);
  position: relative; isolation: isolate; overflow: hidden;
  display: grid; justify-items: center; align-content: center; gap: 10px;
  padding: 16px 16px 18px; border-radius: 14px;
  background: radial-gradient(120% 90% at 50% 45%, #1a0b12 0%, #0b0d17 55%, #05060b 100%);
  color: #f3f4f8; border: 1px solid #1f2230;
}
.space { position: absolute; inset: 0; z-index: -1; pointer-events: none; }
.stars { position: absolute; inset: -50%; background-repeat: repeat; }
.stars-far {
  background-image:
    radial-gradient(1px 1px at 20px 30px, #ffffffcc 50%, transparent 51%),
    radial-gradient(1px 1px at 90px 120px, #ffffff99 50%, transparent 51%),
    radial-gradient(1px 1px at 160px 60px, #ffffffaa 50%, transparent 51%),
    radial-gradient(1px 1px at 210px 170px, #ffd9d980 50%, transparent 51%),
    radial-gradient(1px 1px at 60px 200px, #ffffff88 50%, transparent 51%);
  background-size: 240px 240px;
  animation: drift 90s linear infinite, twinkle 4s ease-in-out infinite;
}
.stars-near {
  background-image:
    radial-gradient(1.5px 1.5px at 40px 80px, #ffffff 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 190px 30px, #ffe3e3 50%, transparent 51%),
    radial-gradient(2px 2px at 130px 210px, #ffffffdd 50%, transparent 51%);
  background-size: 320px 320px;
  animation: drift 50s linear infinite reverse, twinkle 2.6s ease-in-out infinite 1s;
}
.nebula {
  position: absolute; inset: 0;
  background:
    radial-gradient(40% 55% at 50% 50%, rgb(224 49 49 / 0.28), transparent 70%),
    radial-gradient(30% 40% at 30% 70%, rgb(120 40 160 / 0.18), transparent 70%),
    radial-gradient(25% 35% at 72% 28%, rgb(40 90 200 / 0.14), transparent 70%);
  filter: blur(8px);
  animation: nebula 12s ease-in-out infinite alternate;
}

.orb-stage { position: relative; width: calc(var(--orb) * 1.6); height: calc(var(--orb) * 1.6); max-width: 100%; display: grid; place-items: center; }
.orb {
  position: relative; width: var(--orb); height: var(--orb); border-radius: 50%;
  border: 0; padding: 0; cursor: pointer; background: transparent; color: #fff;
  display: grid; place-items: center;
  transform: scale(calc(1 + var(--level) * 0.07));
  transition: transform 90ms linear;
}
.orb-body {
  position: absolute; inset: 0; border-radius: 50%;
  background: radial-gradient(circle at 34% 28%, #ffb3b3 0%, #ff5252 22%, #e03131 45%, #8f0f14 78%, #3d0306 100%);
  box-shadow:
    0 0 calc(34px + var(--level) * 60px) calc(6px + var(--level) * 18px) rgb(255 45 45 / 0.55),
    0 0 90px 30px rgb(224 49 49 / 0.18),
    inset 0 -14px 34px rgb(0 0 0 / 0.5),
    inset 0 10px 22px rgb(255 255 255 / 0.28);
  animation: breathe 3.4s ease-in-out infinite;
}
/* Reflet de verre sur l'orbe */
.orb-body::after {
  content: ""; position: absolute; left: 18%; top: 9%; width: 46%; height: 30%; border-radius: 50%;
  background: linear-gradient(180deg, rgb(255 255 255 / 0.55), rgb(255 255 255 / 0));
  filter: blur(1px);
}
.orb-mic {
  position: relative; z-index: 1; width: 46%; height: 46%;
  filter: drop-shadow(0 2px 6px rgb(60 0 0 / 0.6)) drop-shadow(0 0 calc(4px + var(--level) * 16px) rgb(255 255 255 / 0.6));
}
/* Lumière en orbite */
.orb-orbit {
  position: absolute; inset: -18%; border-radius: 50%;
  border: 1px solid rgb(255 120 120 / 0.22);
  animation: spin 7s linear infinite;
}
.orb-orbit::before {
  content: ""; position: absolute; top: -4px; left: calc(50% - 4px); width: 8px; height: 8px; border-radius: 50%;
  background: #ffe0e0; box-shadow: 0 0 12px 4px rgb(255 90 90 / 0.9), 0 0 30px 8px rgb(255 60 60 / 0.4);
}
/* Ondes : invisibles au repos, portées par la voix pendant la dictée */
.orb-wave {
  position: absolute; inset: 0; border-radius: 50%;
  border: 2px solid rgb(255 80 80 / 0.55);
  opacity: 0; pointer-events: none;
}
.orb:hover .orb-body, .orb:focus-visible .orb-body {
  box-shadow:
    0 0 70px 18px rgb(255 45 45 / 0.7),
    0 0 120px 40px rgb(224 49 49 / 0.25),
    inset 0 -14px 34px rgb(0 0 0 / 0.5),
    inset 0 10px 22px rgb(255 255 255 / 0.32);
}
.orb:hover { transform: scale(1.05); }
.orb:active { transform: scale(0.96); }
.orb:focus-visible { outline: 2px solid #ffc9c9; outline-offset: 10px; }

/* Arrivée depuis le fond de l'espace */
.recorder.arrive .orb { animation: arrive 1.4s cubic-bezier(0.16, 1, 0.3, 1) both; }
.recorder.arrive .orb-stage::before {
  content: ""; position: absolute; left: 50%; top: -60%; width: 2px; height: 160%;
  background: linear-gradient(180deg, transparent, rgb(255 140 140 / 0.9), transparent);
  transform: translateX(-50%); filter: blur(1px);
  animation: streak 1.1s ease-out both;
}

/* Pendant la dictée */
.orb.recording .orb-wave { animation: wave 1.8s ease-out infinite; }
.orb.recording .w2 { animation-delay: 0.6s; }
.orb.recording .w3 { animation-delay: 1.2s; }
.orb.recording .orb-orbit { animation-duration: 2.4s; border-color: rgb(255 140 140 / 0.4); }
.orb.recording .orb-body { animation: none; }
.orb.recording .orb-mic rect { fill: rgb(255 255 255 / 0.75); }

/* Pendant la rédaction du compte rendu */
.orb.working { cursor: progress; }
.orb.working .orb-orbit {
  inset: -10%; border: 3px solid transparent; border-top-color: #ffd8a8; border-right-color: rgb(255 160 120 / 0.5);
  animation-duration: 0.9s;
}
.orb.working .orb-orbit::before { display: none; }
.orb.working .orb-body { filter: saturate(0.85) brightness(0.9); }

.orb-caption { margin: -6px 0 0; font-size: 1.05rem; font-weight: 700; letter-spacing: 0.02em; color: #ffe3e3; text-shadow: 0 0 18px rgb(255 60 60 / 0.5); text-align: center; }
.rec-info { display: grid; justify-items: center; gap: 6px; text-align: center; }
.timer { font: 600 1.35rem var(--mono); font-variant-numeric: tabular-nums; color: #ffffff; letter-spacing: 0.06em; }
.rec-status { color: #c5c9d6; font-size: 0.92rem; max-width: 60ch; }

/* Rappel quand il clique avant d'avoir coché l'engagement ou un choix */
.nudge { animation: nudge 0.5s ease-in-out 2; }

@keyframes breathe { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.035); } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes wave {
  0% { transform: scale(1); opacity: calc(0.35 + var(--level) * 0.65); }
  100% { transform: scale(calc(1.7 + var(--level) * 0.9)); opacity: 0; }
}
@keyframes drift { to { transform: translate(120px, 60px); } }
@keyframes twinkle { 0%, 100% { opacity: 0.55; } 50% { opacity: 1; } }
@keyframes nebula { from { transform: scale(1) rotate(0deg); } to { transform: scale(1.12) rotate(6deg); } }
@keyframes arrive {
  0% { transform: translateY(-140px) scale(0.12); opacity: 0; filter: blur(8px) brightness(2.2); }
  60% { opacity: 1; filter: blur(0) brightness(1.4); }
  100% { transform: translateY(0) scale(1); filter: none; }
}
@keyframes streak { 0% { opacity: 0; transform: translateX(-50%) scaleY(0.2); } 30% { opacity: 1; } 100% { opacity: 0; transform: translateX(-50%) scaleY(1); } }
@keyframes nudge { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }

.results { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 12px; align-items: start; }
.column { display: grid; gap: 12px; padding: 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.column.best { border-color: var(--accent); }
.col-head { display: grid; gap: 2px; }
.col-models { font: 0.75rem var(--mono); color: var(--ink-3); overflow-wrap: anywhere; }

.live { display: grid; gap: 4px; padding: 10px; background: var(--surface-2); border-radius: 6px; }
.live-label { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-3); }
.live-text { max-height: 11em; overflow-y: auto; font-size: 0.92rem; }
.live-interim { color: var(--ink-3); font-style: italic; }

.state { font-size: 0.9rem; color: var(--ink-2); }
.state.working { color: var(--accent); }
.state.failed { color: var(--danger); background: var(--danger-soft); padding: 8px 10px; border-radius: 6px; }

.report { display: grid; gap: 10px; }
.section-title { font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.07em; color: var(--accent); }
.section-body { white-space: pre-line; font-size: 0.95rem; }
.section-body.empty { color: var(--ink-3); font-style: italic; }

.col-foot { display: grid; gap: 10px; padding-top: 10px; border-top: 1px solid var(--line); }
.metrics { display: grid; grid-template-columns: 1fr; gap: 8px; margin: 0; }
.metrics div { display: grid; gap: 2px; }
.metrics dt { font-size: 0.72rem; color: var(--ink-3); text-transform: uppercase; letter-spacing: 0.05em; }
.metrics dd { margin: 0; font: 600 1rem var(--mono); font-variant-numeric: tabular-nums; }
.badge { display: inline-block; margin-left: 6px; font: 600 0.7rem var(--font); color: var(--warn); border: 1px solid var(--warn); border-radius: 999px; padding: 0 6px; vertical-align: middle; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.rating { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.rating-label { font-size: 0.85rem; color: var(--ink-2); }
.stars { display: inline-flex; gap: 2px; }
.star { font-size: 1.5rem; line-height: 1; background: none; border: 0; padding: 2px; cursor: pointer; color: var(--ink-3); }
.star:hover { color: var(--warn); }
.star.on { color: var(--warn); }

@media (max-width: 480px) {
  .page { padding: 12px 16px 40px; }
  .topbar { padding-inline: 16px; }
  .brand-sub { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .stars, .nebula, .orb-body, .orb-orbit, .orb-wave, .recorder.arrive .orb, .recorder.arrive .orb-stage::before, .nudge { animation: none !important; }
  .orb { transition: none; }
}
