:root {
  --fond: #f3f2ee;
  --surface: #ffffff;
  --surface-2: #ebeae5;
  --texte: #1b1a17;
  --doux: #66645e;
  --ligne: #dcdad3;
  --accent: #157347;
  --accent-fort: #0d5131;
  --sur-accent: #ffffff;
  --lien: #126b41;
  --danger: #c2372c;
  --attention: #b8730d;
  --ok: #1f8a55;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --fond: #121311;
    --surface: #1c1d1a;
    --surface-2: #272824;
    --texte: #f0efea;
    --doux: #a3a19a;
    --ligne: #33342f;
    --accent: #1b8a55;
    --accent-fort: #12663e;
    --sur-accent: #ffffff;
    --lien: #5fd39a;
    --danger: #e5584b;
    --attention: #e0a03a;
    --ok: #4cc488;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  background: var(--fond);
  color: var(--texte);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}
button { font: inherit; color: inherit; cursor: pointer; }
button:disabled { cursor: default; opacity: .55; }
h1, h2 { margin: 0; line-height: 1.2; }
h1 { font-size: 26px; letter-spacing: -.01em; }
h2 { font-size: 15px; }
.petit { font-size: 13px; color: var(--doux); margin: 0; overflow-wrap: anywhere; }

.carte {
  background: var(--surface);
  border: 1px solid var(--ligne);
  border-radius: 16px;
  padding: 16px;
}

.bouton-principal, .bouton-secondaire {
  border-radius: 999px;
  font-weight: 650;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
}
.bouton-principal { background: var(--accent); color: var(--sur-accent); border: 0; padding: 12px 20px; }
.bouton-principal:active { background: var(--accent-fort); }
.bouton-secondaire { background: var(--surface-2); color: var(--texte); border: 1px solid var(--ligne); padding: 10px 16px; }
.petit-bouton { padding: 6px 12px; font-size: 14px; }
.lien-discret {
  background: none; border: 0; padding: 4px 2px;
  color: var(--lien); font-weight: 600; font-size: 14px;
  text-decoration: underline; text-underline-offset: 3px;
}

/* Pastille d'état */
.etat { display: flex; align-items: center; gap: 8px; font-weight: 600; min-width: 0; }
.etat span:last-of-type { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pastille { width: 10px; height: 10px; border-radius: 50%; background: var(--doux); flex: none; }
.etat[data-ton="ok"] .pastille { background: var(--ok); }
.etat[data-ton="attente"] .pastille { background: var(--attention); animation: pulsation 1.4s ease-in-out infinite; }
.etat[data-ton="erreur"] .pastille { background: var(--danger); }
.chrono { font-variant-numeric: tabular-nums; color: var(--doux); font-weight: 500; }
@keyframes pulsation { 50% { opacity: .3; } }

/* ---------- Téléphone ---------- */

.tel {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  max-width: 560px;
  margin: 0 auto;
}

.tel-haut {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 56px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
}
.tel-haut .etat { flex: 1; }
.raccrocher {
  background: var(--danger); color: #fff; border: 0;
  border-radius: 999px; padding: 8px 14px; font-weight: 650; font-size: 15px;
}

.tel-milieu {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 4px 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.direct { display: flex; flex-direction: column; gap: 10px; padding-top: 8px; }
.niveaux {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 10px 12px;
  font-size: 13px;
  font-weight: 600;
  color: var(--doux);
}
.niveau { height: 10px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.niveau-barre {
  height: 100%;
  background: var(--ok);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform .1s linear;
}
.alerte {
  margin: 0;
  padding: 10px 12px;
  border-radius: 12px;
  background: color-mix(in srgb, var(--attention) 16%, transparent);
  color: var(--texte);
  font-size: 14px;
  font-weight: 600;
}

.journal h2 { color: var(--doux); text-transform: uppercase; letter-spacing: .04em; font-size: 13px; margin-bottom: 6px; }
.liste { list-style: none; margin: 0; padding: 0; }
.liste li {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--ligne);
  font-variant-numeric: tabular-nums;
}
.liste .num { font-weight: 700; min-width: 36px; }
.liste .info { flex: 1; color: var(--doux); }
.liste .info.coupe { color: var(--attention); }
#ecran-noir { white-space: normal; text-align: center; }

/* Volume (appli Android) : au milieu de l'écran. */
.volume {
  margin: auto 0;
  padding: 16px;
  border: 1px solid var(--ligne);
  border-radius: 18px;
  background: var(--surface);
}
.volume-tete { display: flex; justify-content: space-between; font-weight: 650; margin-bottom: 12px; }
#volume-valeur { color: var(--doux); font-variant-numeric: tabular-nums; }
.volume-reglage { display: flex; align-items: center; gap: 12px; }
.volume-bouton {
  width: 52px; height: 52px; flex: none;
  display: grid; place-items: center;
  border-radius: 50%;
  border: 1px solid var(--ligne);
  background: var(--surface-2);
  font-size: 28px; font-weight: 600; line-height: 1;
}
#volume-curseur {
  --rempli: 50%;
  flex: 1; min-width: 0; height: 44px; margin: 0;
  -webkit-appearance: none; appearance: none;
  background: transparent;
}
#volume-curseur::-webkit-slider-runnable-track {
  height: 10px;
  border-radius: 999px;
  background: linear-gradient(to right, var(--accent) var(--rempli), var(--surface-2) var(--rempli));
}
#volume-curseur::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 32px; height: 32px;
  margin-top: -11px;
  border-radius: 50%;
  border: 3px solid var(--sur-accent);
  background: var(--accent);
}
.liste .statut { font-size: 14px; font-weight: 600; color: var(--doux); }
.liste li[data-ton="ok"] .statut { color: var(--ok); }
.liste li[data-ton="envoi"] .statut { color: var(--attention); }
.liste li[data-ton="erreur"] .statut { color: var(--danger); }

/* Le gros bouton : tout le tiers bas de l'écran. */
.gros-bouton {
  flex: none;
  width: 100%;
  height: 33.333vh;
  height: 33.333dvh;
  border: 0;
  border-radius: 28px 28px 0 0;
  background: var(--accent);
  color: var(--sur-accent);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 0 16px env(safe-area-inset-bottom);
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  transition: background .2s, transform .08s;
}
.gros-bouton:active { background: var(--accent-fort); transform: scale(.99); }
.gros-bouton:disabled { opacity: .7; }
.gros-bouton.envoye { background: var(--accent-fort); }
.gros-bouton.refus { animation: secousse .3s; }
.bouton-titre { font-size: clamp(30px, 10vw, 46px); font-weight: 750; letter-spacing: -.01em; }
.bouton-sous { font-size: 16px; opacity: .85; font-variant-numeric: tabular-nums; text-align: center; }
@keyframes secousse {
  25% { transform: translateX(-8px); }
  50% { transform: translateX(8px); }
  75% { transform: translateX(-4px); }
}

/* ---------- Ordinateur ---------- */

.pc {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  max-width: 820px;
  margin: 0 auto;
  padding: 0 16px;
}
.pc-haut { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; padding: 16px 0; }
.pc-haut .niveaux { flex: 1 1 240px; max-width: 340px; margin-left: auto; gap: 6px 10px; }
.pc-haut .niveau { height: 8px; }
.note-micro { flex-basis: 100%; }
.volume-tel { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; color: var(--doux); }
.volume-tel input { width: 140px; accent-color: var(--accent); }
#volume-tel-valeur { min-width: 44px; font-variant-numeric: tabular-nums; color: var(--texte); }
.micro-bouton[data-coupe="true"] { background: var(--danger); border-color: var(--danger); color: #fff; }

/* « Tu as reçu » : tout le tiers haut de l'écran. */
.zone-recu {
  flex: none;
  height: 33.333vh;
  height: 33.333dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 16px;
  border: 2px dashed var(--ligne);
  border-radius: 24px;
  background: var(--surface);
  color: var(--doux);
  text-align: center;
  text-decoration: none;
  user-select: none;
}
.zone-recu[data-etat="reception"] { border-style: solid; border-color: var(--accent); color: var(--texte); }
.zone-recu[data-etat="recu"] {
  border: 0;
  background: var(--accent);
  color: var(--sur-accent);
  cursor: grab;
}
.zone-recu[data-etat="recu"]:hover { background: var(--accent-fort); }
.zone-recu[data-etat="recu"]:active { cursor: grabbing; }
.zone-recu.flash { animation: flash 1.2s ease-out; }
@keyframes flash {
  0% { transform: scale(1.02); box-shadow: 0 0 0 10px color-mix(in srgb, var(--accent) 35%, transparent); }
  100% { transform: scale(1); box-shadow: 0 0 0 0 transparent; }
}
.recu-titre { font-size: clamp(26px, 4.5vw, 44px); font-weight: 750; letter-spacing: -.01em; color: inherit; }
.zone-recu[data-etat="vide"] .recu-titre { color: var(--texte); font-size: clamp(22px, 3vw, 30px); }
.recu-sous { font-size: 17px; font-variant-numeric: tabular-nums; }
.recu-indice { font-size: 14px; opacity: .85; }
.recu-sous:empty, .recu-indice:empty { display: none; }
.recu-progression { width: min(360px, 80%); height: 8px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
#recu-barre { display: block; height: 100%; background: var(--accent); transform: scaleX(0); transform-origin: left; }

.pc-liste { flex: 1; min-height: 0; display: flex; flex-direction: column; padding: 20px 0 16px; }
.liste-tete { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 10px; }
.liste-tete h2 { font-size: 15px; color: var(--doux); font-variant-numeric: tabular-nums; }
.fichiers {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.fichier { display: flex; align-items: center; gap: 8px; }
.fichier-lien {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--ligne);
  border-radius: 14px;
  color: var(--texte);
  text-decoration: none;
  cursor: grab;
}
.fichier-lien:hover { border-color: var(--accent); }
.fichier-lien:active { cursor: grabbing; }
.fichier.nouveau .fichier-lien { animation: arrivee 1.6s ease-out; }
@keyframes arrivee {
  0% { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 30%, transparent); }
  100% { border-color: var(--ligne); box-shadow: 0 0 0 0 transparent; }
}
.fichier-icone {
  width: 38px; height: 38px; flex: none; padding: 8px;
  border-radius: 10px;
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  fill: none; stroke: var(--lien); stroke-width: 2.2; stroke-linecap: round;
}
.fichier-texte { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.fichier-nom { font-weight: 700; }
.fichier-meta { font-size: 14px; color: var(--doux); font-variant-numeric: tabular-nums; }
.fichier-action { font-size: 14px; font-weight: 600; color: var(--lien); }
.ecouter {
  width: 46px; height: 46px; flex: none;
  display: grid; place-items: center;
  border-radius: 50%;
  border: 1px solid var(--ligne);
  background: var(--surface);
  color: var(--texte);
}
.ecouter svg { width: 18px; height: 18px; fill: currentColor; }
.fichier.en-lecture .ecouter { background: var(--accent); color: var(--sur-accent); border-color: transparent; }

.voile {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(0, 0, 0, .6);
  color: #fff;
  font-size: 24px;
  font-weight: 700;
  text-align: center;
  cursor: pointer;
}

/* ---------- Photo d'une feuille ---------- */

.bouton-photo { font-size: 17px; padding: 14px 16px; }

.fichier-miniature {
  width: 48px; height: 48px; flex: none;
  border-radius: 10px;
  object-fit: cover;
  background: var(--surface-2);
}

/* Appareil photo : plein écran, toujours sombre pour bien voir le viseur. */
.camera {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  background: #000;
  color: #fff;
}
.camera-video {
  flex: 1;
  min-height: 0;
  width: 100%;
  object-fit: contain;
  background: #000;
}
/* Cadre au format A4 (1 × 1,414) au centre du viseur ; le reste est assombri. */
.camera-cadre {
  position: absolute;
  left: 50%;
  top: calc(50% - 60px);
  width: min(78vw, 46vh);
  aspect-ratio: 1 / 1.414;
  transform: translate(-50%, -50%);
  border: 3px solid rgba(255, 255, 255, .9);
  border-radius: 10px;
  box-shadow: 0 0 0 100vmax rgba(0, 0, 0, .35);
  pointer-events: none;
}
.camera-aide {
  position: absolute;
  top: calc(16px + env(safe-area-inset-top));
  left: 16px;
  right: 16px;
  margin: 0;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(0, 0, 0, .55);
  text-align: center;
  font-size: 15px;
  font-weight: 600;
}
/* Trois colonnes : le bouton du milieu reste au centre même quand un bouton de côté est caché. */
.camera-barre {
  flex: none;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  padding: 18px 20px calc(22px + env(safe-area-inset-bottom));
  background: #000;
}
.camera-barre > :first-child { justify-self: start; }
.camera-barre > :last-child { justify-self: end; }
.camera-petit {
  min-width: 96px;
  padding: 12px 14px;
  border: 1px solid rgba(255, 255, 255, .35);
  border-radius: 999px;
  background: rgba(255, 255, 255, .08);
  color: #fff;
  font-weight: 650;
}
.camera-declencheur {
  width: 78px; height: 78px; flex: none;
  border-radius: 50%;
  border: 5px solid #fff;
  background: #fff;
  box-shadow: inset 0 0 0 4px #000;
}
.camera-declencheur:active { transform: scale(.94); }

/* ---------- Ordinateur : lecture de texte (colonne de droite) ---------- */

.ecran { display: flex; justify-content: center; }
.ecran .pc { flex: 1 1 820px; min-width: 0; margin: 0; }
.lecture {
  flex: 0 1 440px;
  min-width: 300px;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px 16px 16px 8px;
}
.lecture-tete { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 12px; }
.lecture-tete h2 { flex: 1 1 0; min-width: 0; }
.lecture-entrainement { flex: none; }
.lecture-tete .lecture-reglage { flex-basis: 100%; }
.lecture-entrainement[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--sur-accent); }
.lecture-reglage { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; color: var(--doux); }
.lecture-reglage input { width: 120px; accent-color: var(--accent); }
.lecture-reglage input[type="checkbox"] { width: 16px; height: 16px; margin: 0; }
.lecture-reglage input[type="number"] {
  width: 56px; padding: 3px 6px; font: inherit; color: var(--texte);
  background: var(--surface); border: 1px solid var(--ligne); border-radius: 8px;
}
#lecture-vitesse-valeur { min-width: 40px; font-variant-numeric: tabular-nums; color: var(--texte); }
.lecture-texte {
  flex: 1;
  min-height: 0;
  width: 100%;
  margin: 0;
  padding: 14px;
  overflow-y: auto;
  resize: none;
  background: var(--surface);
  color: var(--texte);
  border: 1px solid var(--ligne);
  border-radius: 16px;
  font: inherit;
  line-height: 1.6;
}
.lecture-texte:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.lecture-affichage { white-space: pre-wrap; overflow-wrap: anywhere; }
/* Ce qui a été lu change de couleur ; le mot en train d'être dit est surligné. */
.lecture-affichage .mot { cursor: pointer; border-radius: 4px; transition: color .15s; }
.lecture-affichage .mot.lu { color: var(--lien); }
.lecture-affichage .mot.courant { background: color-mix(in srgb, var(--attention) 35%, transparent); }
.lecture-etat { margin: 0; min-height: 1.45em; font-size: 14px; font-weight: 600; color: var(--doux); }
.lecture-etat[data-ton="ok"] { color: var(--ok); }
.lecture-etat[data-ton="erreur"] { color: var(--danger); }
.lecture-etat[data-ton="attente"] { color: var(--attention); }
.lecture-boutons { display: flex; gap: 10px; }
.lecture-boutons button { flex: 1; }

/* Commandes du téléphone, à gauche de la page ordinateur. */
.pc-commandes {
  flex: 0 0 220px;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px 8px 16px 16px;
}
.commande {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding: 16px;
  border: 0;
  border-radius: 14px;
  background: var(--accent);
  color: var(--sur-accent);
  text-align: left;
}
.commande:hover:not(:disabled) { background: var(--accent-fort); }
.commande:disabled { background: var(--surface-2); color: var(--doux); }
.commande-titre { font-size: 18px; font-weight: 750; }
.commande-sous { font-size: 14px; opacity: .9; font-variant-numeric: tabular-nums; }
.commande-info { margin: 0; font-size: 14px; font-weight: 600; color: var(--doux); }
.commande-info:empty { display: none; }

/* Écran étroit : les commandes passent en ligne au-dessus, la lecture sous les vocaux. */
@media (max-width: 900px) {
  .ecran { flex-direction: column; }
  .ecran .pc { flex: none; }
  .lecture { flex: none; min-width: 0; height: 80vh; padding: 0 16px 16px; }
  .pc-commandes { flex: none; height: auto; flex-direction: row; flex-wrap: wrap; padding: 16px 16px 0; }
  .commande { flex: 1 1 200px; }
  .commande-info { flex-basis: 100%; }
}
