/* Polices système uniquement : aucune police téléchargée. */
:root {
  color-scheme: light dark;
  --bg: #f6f7f9;
  --fg: #1c2026;
  --muted: #5b6470;
  --accent: #2563eb;
  --accent-texte: #ffffff;
  --danger: #b91c1c;
  --danger-texte: #ffffff;
  --ok: #15803d;
  --card: #ffffff;
  --border: #d9dee5;
  font-family:
    system-ui,
    -apple-system,
    'Segoe UI',
    Roboto,
    'Helvetica Neue',
    Arial,
    sans-serif;
  line-height: 1.5;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14171c;
    --fg: #e8ebef;
    --muted: #9aa4b1;
    --accent: #60a5fa;
    /* Texte sombre sur bleu clair : contraste ≈ 8:1 (blanc sur #60a5fa : 2,5:1). */
    --accent-texte: #0b1220;
    --danger: #f87171;
    --danger-texte: #0b1220;
    --ok: #4ade80;
    --card: #1c2026;
    --border: #2d333c;
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
}

.app {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.25rem 1rem;
  border-bottom: 1px solid var(--border);
}

.brand {
  font-weight: 700;
  font-size: 1.25rem;
  text-decoration: none;
  color: inherit;
  padding: 0.5rem 0;
}

.nav {
  display: flex;
  gap: 0.25rem;
}

/* Cibles tactiles d'au moins 44 px. */
.nav a {
  color: var(--muted);
  text-decoration: none;
  padding: 0.75rem 0.5rem;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
}

.nav a[aria-current='page'] {
  color: var(--fg);
  font-weight: 600;
}

.main {
  flex: 1;
  width: 100%;
  max-width: 60rem;
  margin: 0 auto;
  padding: 1rem;
}

.page h1 {
  font-size: 1.5rem;
  line-height: 1.3;
  margin: 0.5rem 0 1rem;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

h2 {
  font-size: 1.25rem;
  line-height: 1.3;
  margin: 1rem 0 0.5rem;
}

h2:focus {
  outline: none;
}

.compteur {
  font-weight: 400;
  color: var(--muted);
  font-size: 1rem;
}

.hint {
  border-left: 4px solid var(--accent);
  background: var(--card);
  padding: 0.75rem 1rem;
  margin: 1rem 0;
}

.hint-offline {
  border-left-color: var(--ok);
}

.placeholder,
.muted {
  color: var(--muted);
  font-size: 0.9rem;
}

.footer {
  border-top: 1px solid var(--border);
  padding: 1rem;
  color: var(--muted);
}

.footer p {
  margin: 0.25rem 0;
}

.footer-liens {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1rem;
  margin: 0.5rem 0;
}

.footer-liens a {
  padding: 0.4rem 0;
  display: inline-block;
}

.footer-technique {
  font-size: 0.8rem;
}

a {
  color: var(--accent);
}

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.9em;
}

/* Boutons */
.bouton {
  font: inherit;
  padding: 0.6rem 1.2rem;
  min-height: 44px;
  border-radius: 0.4rem;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: var(--accent-texte);
  cursor: pointer;
}

.bouton.grand {
  width: 100%;
  font-size: 1.1rem;
  padding: 0.8rem 1.2rem;
}

.bouton.petit {
  min-height: 36px;
  padding: 0.3rem 0.8rem;
  font-size: 0.9rem;
}

.bouton:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.bouton.secondaire {
  background: transparent;
  color: var(--accent);
}

.bouton.danger {
  background: var(--danger);
  border-color: var(--danger);
  color: var(--danger-texte);
}

.lien {
  font: inherit;
  background: none;
  border: none;
  padding: 0.6rem 0.25rem;
  min-height: 44px;
  color: var(--accent);
  text-decoration: underline;
  cursor: pointer;
}

.alerte,
.erreur {
  border-left: 4px solid var(--danger);
  background: var(--card);
  padding: 0.75rem 1rem;
  margin: 1rem 0;
}

.alerte p:first-child,
.erreur p:first-child {
  margin-top: 0;
}

.alerte p:last-child,
.erreur p:last-child {
  margin-bottom: 0;
}

/* Largeur du texte seulement : cliquer dans le vide à droite ne replie rien. */
details summary {
  cursor: pointer;
  padding: 0.5rem 0;
  color: var(--accent);
  width: fit-content;
  max-width: 100%;
}

/* Listes déroulantes dans le style du site (le rendu natif est gris) : le
   chevron est dessiné en CSS (deux bordures tournées), car l'apparence
   native ne se règle pas et la CSP interdit une image en data:. */
.select-cadre {
  position: relative;
  display: inline-block;
  width: fit-content;
  max-width: 100%;
}

.select-cadre select {
  font: inherit;
  color: var(--fg);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 0.4rem;
  padding: 0.5rem 2.75rem 0.5rem 0.75rem;
  min-height: 44px;
  max-width: 100%;
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
}

.select-cadre::after {
  content: '';
  position: absolute;
  right: 1.1rem;
  top: 50%;
  width: 0.55rem;
  height: 0.55rem;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: translateY(-70%) rotate(45deg);
  pointer-events: none;
}

/* Tout ce qui se clique a le curseur main. */
label.ligne,
input[type='checkbox'],
input[type='radio'],
input[type='range'] {
  cursor: pointer;
}

/* Une case à cocher et son texte : cliquable sur le texte, pas sur toute la ligne. */
.reglages .ligne {
  width: fit-content;
  max-width: 100%;
}

/* Contrôles natifs assez grands pour le doigt. */
input[type='checkbox'],
input[type='radio'] {
  width: 1.5rem;
  height: 1.5rem;
  margin: 0;
  accent-color: var(--accent);
}

input[type='range'] {
  width: 100%;
  accent-color: var(--accent);
  height: 44px;
}

/* Import de vidéo */
.zone-depot {
  border: 2px dashed var(--border);
  border-radius: 0.5rem;
  padding: 1rem;
  text-align: center;
  background: var(--card);
}

.zone-depot.survol {
  border-color: var(--accent);
}

.zone-depot p {
  margin: 0.5rem 0 0;
}

/* Vidéo chargée */
.video-prete {
  display: grid;
  gap: 0.5rem;
}

.resume-video {
  margin: 0;
  word-break: break-word;
}

/* « Choisir une autre vidéo » : à droite du nom du fichier, visible sans dominer. */
.resume-video .retirer {
  float: right;
  margin-left: 0.75rem;
}

.lien.gauche {
  justify-self: start;
  padding-left: 0;
}

.apercu {
  max-width: 100%;
  max-height: 60svh;
  height: auto;
  background: #000;
  border-radius: 0.25rem;
}

.details-techniques dl {
  margin: 0.5rem 0 0;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.25rem 1rem;
  font-size: 0.9rem;
}

.details-techniques dt {
  font-weight: 600;
}

.details-techniques dd {
  margin: 0;
}

/* Analyse */
.analyse {
  margin-top: 1rem;
}

.reglages {
  border: 1px solid var(--border);
  border-radius: 0.4rem;
  display: grid;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  margin: 0.5rem 0;
}

.reglages label {
  display: grid;
  gap: 0.25rem;
}

.reglages .ligne {
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 0.75rem;
}

.progression {
  width: 100%;
  height: 1.25rem;
}

/* Traitement en cours : bloc centré, plus lisible sur un petit écran. */
.centre {
  text-align: center;
}

.centre .commandes {
  justify-content: center;
}

/* Relecture */
.relecture {
  margin-top: 0.5rem;
}

.consigne {
  margin: 0.5rem 0;
}

.cadre-lecteur {
  margin: 0.5rem 0;
}

.lecteur {
  position: relative;
  background: #000;
  border-radius: 0.25rem;
  display: flex;
  justify-content: center;
}

/* Le canvas garde ses proportions (pas de bandes noires internes, sinon les
   coordonnées du doigt seraient fausses) : largeur = toute la largeur, sauf si
   la hauteur dépasserait 70 % de l'écran. Unité svh et non vh : sur iPhone, vh
   change quand la barre d'adresse se replie au défilement, et l'image
   changeait de taille (effet de saut). */
.cadre-image {
  position: relative;
  width: min(100%, calc(70svh * var(--ratio, 1.333)));
}

.image-relecture {
  display: block;
  width: 100%;
  height: auto;
  cursor: pointer;
}

/* Le doigt ne fait défiler la page que hors mode dessin. */
.image-relecture.dessin {
  touch-action: none;
  cursor: crosshair;
}

.bandeau-dessin {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  margin: 0.5rem 0;
  background: var(--card);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: 0.4rem;
}

.bulle.colonne {
  display: block;
}

.bulle.colonne p {
  margin: 0 0 0.4rem;
}

.bulle.colonne .commandes {
  margin: 0.25rem 0 0;
}

.bulle {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-left: 4px solid #facc15;
  border-radius: 0 0 0.4rem 0.4rem;
  padding: 0.5rem 0.75rem;
}

/* Barre de la vidéo : le curseur est la bande elle-même. */
.timeline {
  position: relative;
  height: 48px;
  margin: 0.75rem 0 0.25rem;
}

.timeline-bande {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 48px;
  display: block;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 0.25rem;
  pointer-events: none;
}

.timeline-curseur {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 48px;
  margin: 0;
  background: transparent;
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
}

.timeline-curseur::-webkit-slider-runnable-track {
  height: 48px;
  background: transparent;
}

.timeline-curseur::-moz-range-track {
  height: 48px;
  background: transparent;
}

.timeline-curseur::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 22px;
  height: 48px;
  border-radius: 4px;
  background: rgba(37, 99, 235, 0.35);
  /* Bordure sombre et épaisse : lisible sur les barres grises comme sur les
     passages rouges (le remplissage seul était à 1,5:1). */
  border: 3px solid var(--fg);
  box-shadow: inset 0 0 0 2px var(--accent-texte);
}

.timeline-curseur::-moz-range-thumb {
  width: 22px;
  height: 48px;
  border-radius: 4px;
  background: rgba(37, 99, 235, 0.35);
  border: 3px solid var(--fg);
  box-shadow: inset 0 0 0 2px var(--accent-texte);
}

.timeline-curseur:focus {
  outline: none;
}

/* Anneau de focus au clavier seulement : un <input type="range"> n'étant pas
   une saisie de texte, le navigateur ne déclenche pas :focus-visible au clic. */
.timeline-curseur:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

.liste-caches {
  margin: 0.5rem 0;
}

.liste-caches ul {
  margin: 0.25rem 0;
  padding-left: 1.25rem;
}

.liste-caches li {
  margin: 0.25rem 0;
}

.liste-caches .ajout-clavier {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: end;
}

.liste-caches .ajout-clavier label {
  display: flex;
  flex-direction: column;
  font-size: 0.9rem;
}

.liste-caches .ajout-clavier input {
  width: 5rem;
}

@media (prefers-reduced-motion: reduce) {
  * {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}

.etat-relecture {
  margin: 0.25rem 0 0.5rem;
}

.commandes {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0.5rem 0;
  align-items: center;
}

.commandes.navigation .bouton {
  flex: 1 1 0;
}

.validation {
  margin-top: 1rem;
}

/* Export */
.export {
  margin-top: 0.5rem;
}

/* Boîte de dialogue (exemples de floutage). */
.dialogue {
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  background: var(--card);
  color: var(--fg);
  padding: 1rem;
  /* Largeur fixée (un <dialog> s'ajuste sinon à son contenu) : les trois
     exemples tiennent sur une ligne dès un écran de portable. */
  width: min(72rem, 94vw);
  max-width: 94vw;
}

.dialogue::backdrop {
  background: rgba(0, 0, 0, 0.5);
}

.dialogue h2 {
  margin-top: 0;
  font-size: 1.1rem;
}

.exemples {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
  gap: 1rem;
}

.exemples figure {
  margin: 0;
}

.exemples canvas {
  display: block;
  width: auto;
  max-width: 100%;
  height: auto;
  /* Jamais plus haut que 40 % de l'écran : une vidéo en portrait reste
     visible sans faire défiler la boîte. */
  max-height: 40vh;
  margin: 0 auto;
  background: #000;
  border-radius: 0.25rem;
}

.exemples figcaption {
  font-size: 0.9rem;
  margin-top: 0.25rem;
}

/* Grand écran : les boutons ne prennent plus toute la largeur, les commandes
   de la relecture se centrent. */
@media (min-width: 700px) {
  .bouton.grand {
    width: auto;
    min-width: 16rem;
  }

  .commandes.passages,
  .commandes.ajout {
    justify-content: center;
  }
}

a.bouton {
  display: inline-block;
  text-decoration: none;
  text-align: center;
}

/* Journal des changements */
.journal {
  list-style: none;
  padding: 0;
}

.journal li {
  margin: 0 0 0.75rem;
}

.journal time {
  font-weight: 600;
}

/* Pages de texte */
.prose h2 {
  font-size: 1.15rem;
  margin-top: 1.5rem;
}

.prose li {
  margin: 0.25rem 0;
}

.prose p.alerte {
  margin-top: 0;
}

.sommaire {
  list-style: none;
  padding: 0;
}

.sommaire li {
  margin: 0.75rem 0;
}

.sommaire a {
  display: inline-block;
  padding: 0.25rem 0;
  font-weight: 600;
}
