* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--fond);
  color: var(--texte);
  font: 17px/1.35 -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior-y: none;
}

body { min-height: 100dvh; }
button, input, select { font: inherit; color: inherit; }
button { background: none; border: 0; padding: 0; cursor: pointer; }
a { color: inherit; text-decoration: none; -webkit-tap-highlight-color: transparent; }
img { display: block; }
[hidden] { display: none !important; }

/* ---------- Scène et en-têtes ---------- */

#scene {
  padding: calc(var(--haut) + 12px) max(var(--marge), env(safe-area-inset-right, 0px)) calc(max(10px, var(--bas) - 10px) + 66px) max(var(--marge), env(safe-area-inset-left, 0px));
  max-width: 760px;
  margin: 0 auto;
}

.titre { font-size: 34px; font-weight: 700; letter-spacing: -.02em; margin: 8px 0 16px; }
/* Un nom de rangée qui ouvre sa liste complète. */
.sous-titre .chevron { display: inline-flex; align-items: center; gap: 8px; padding: 8px 0; margin: -8px 0; }
.sous-titre .chevron::after { width: 6px; height: 6px; }
.sous-titre { font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--texte-2); margin: 26px 4px 8px; }
.discret { color: var(--texte-2); font-size: 15px; }
.centre { text-align: center; padding: 48px 12px; }
.entete { display: flex; align-items: center; justify-content: space-between; gap: 12px; }

/* ---------- Barre d'onglets flottante ---------- */

/* Comme les apps d'iOS 26 : une capsule fine pour les onglets, la recherche à part dans un rond.
   Elle descend dans la zone de l'indicateur d'accueil (34 px → 24 px du bord) et garde 10 px
   sur les iPhone à bouton, où cette zone vaut 0. */
#barre {
  --barre: 46px;
  --assise: max(10px, calc(var(--bas) - 10px));
  position: fixed;
  left: max(20px, env(safe-area-inset-left, 0px));
  right: max(20px, env(safe-area-inset-right, 0px));
  bottom: var(--assise);
  max-width: 520px;
  margin-inline: auto;
  z-index: 30;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  pointer-events: none;
}
#barre > * { pointer-events: auto; }
/* Web app installée : calée depuis le haut sur la hauteur réelle de l'écran (voir app.js). */
.installee #barre { bottom: auto; top: calc(var(--ecran) - var(--barre) - var(--assise)); }
#onglets { display: flex; gap: 2px; padding: 3px; height: var(--barre); }
#onglets a {
  display: grid;
  place-items: center;
  width: 64px;
  height: 100%;
  border-radius: 999px;
  color: var(--texte-2);
  transition: background .25s, color .25s;
}
#barre svg { width: 21px; height: 21px; fill: currentColor; }
#onglets a.actif { color: var(--accent); background: var(--verre-teinte); box-shadow: inset 0 0 0 .5px var(--verre-bord); }
#loupe { display: grid; place-items: center; width: var(--barre); height: var(--barre); flex: none; color: var(--texte-2); }
#loupe.actif { color: var(--accent); }

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

.bouton {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 18px;
  font-weight: 600;
  font-size: 16px;
  white-space: nowrap;
}
.bouton svg { width: 19px; height: 19px; flex: none; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.bouton.suivie { color: var(--accent); }
.bouton.plein { background: var(--accent); color: #fff; border-radius: 999px; }
.bouton.large { width: 100%; }
.bouton[disabled] { opacity: .45; pointer-events: none; }
.rond { width: 44px; height: 44px; display: grid; place-items: center; flex: none; }
.rond svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- Champs ---------- */

.champ {
  width: 100%;
  min-height: 46px;
  padding: 0 16px;
  border: 0;
  outline: 0;
  border-radius: 14px;
  background: var(--fond-2);
  box-shadow: inset 0 0 0 .5px var(--trait);
}
.champ::placeholder { color: var(--texte-2); }
.formulaire { display: grid; gap: 12px; }

/* ---------- Grille de couvertures ---------- */

.grille { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 16px 12px; }
.carte { display: block; position: relative; }
.carte .couverture {
  aspect-ratio: 2 / 3;
  width: 100%;
  object-fit: cover;
  border-radius: 12px;
  background: var(--fond-2);
  box-shadow: inset 0 0 0 .5px var(--trait), 0 4px 14px rgba(0, 0, 0, .25);
}
.carte .nom {
  margin-top: 7px;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.25;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.pastille {
  position: absolute;
  top: 6px;
  right: 6px;
  min-width: 24px;
  padding: 2px 7px;
  font-size: 12px;
  font-weight: 700;
  text-align: center;
  color: #fff;
}
.carte .marque { position: absolute; top: 6px; left: 6px; padding: 2px 8px; font-size: 11px; font-weight: 700; color: #fff; }

.defile { display: flex; gap: 12px; overflow-x: auto; padding: 4px var(--marge) 10px; margin: 0 calc(-1 * var(--marge)); scrollbar-width: none; }
.defile::-webkit-scrollbar { display: none; }
.defile .carte { flex: 0 0 104px; }

/* ---------- Listes ---------- */

/* Listes groupées, à la manière des réglages d'iOS 26 : grands arrondis, lignes hautes, filets en retrait. */
.liste { background: var(--fond-2); border-radius: 24px; overflow: hidden; box-shadow: inset 0 0 0 .5px var(--trait); }
.ligne { display: flex; align-items: center; gap: 12px; padding: 11px 16px; min-height: 52px; position: relative; }
button.ligne { width: 100%; text-align: left; }
.ligne + .ligne::before { content: ""; position: absolute; top: 0; left: 16px; right: 16px; height: .5px; background: var(--trait); }
/* Sous une ligne à symbole, le filet commence au texte. */
.ligne + .ligne:has(> .tuile)::before { left: 58px; }
.tuile { flex: none; width: 30px; height: 30px; display: grid; place-items: center; border-radius: 8px; background: rgba(120, 120, 128, .2); box-shadow: inset 0 0 0 .5px var(--trait); }
.tuile svg { width: 19px; height: 19px; fill: none; stroke: var(--teinte); stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.vignette { flex: none; width: 40px; aspect-ratio: 2 / 3; object-fit: cover; border-radius: 7px; background: var(--fond); }
.ligne .corps { flex: 1; min-width: 0; }
.ligne .nom { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ligne .detail { font-size: 13px; color: var(--texte-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ligne.lu .nom { color: var(--texte-2); }
.ligne img.icone { width: 34px; height: 34px; border-radius: 8px; background: var(--fond); }
.coche { padding: 12px 6px 12px 2px; margin: -12px 0; flex: none; }
.point { display: block; width: 9px; height: 9px; border-radius: 50%; background: var(--accent); flex: none; }
.ligne.lu .point { background: transparent; box-shadow: inset 0 0 0 1.5px var(--trait); }
.action { color: var(--accent); font-weight: 600; font-size: 15px; padding: 8px 4px; flex: none; white-space: nowrap; }
/* Une ligne entière qui sert de bouton garde la largeur, le retrait et le corps de texte des autres lignes. */
.ligne.action { width: 100%; padding: 11px 16px; font-size: inherit; font-weight: 500; text-align: left; white-space: normal; }
.ligne.action.centree { justify-content: center; text-align: center; }
.action.danger { color: var(--alerte); }
.jauge { height: 3px; border-radius: 2px; background: var(--trait); margin-top: 5px; overflow: hidden; }
.jauge i { display: block; height: 100%; background: var(--accent); }

/* Téléchargement d'un chapitre sur l'appareil : flèche, anneau d'avancement, puis pastille pleine. */
.telechargement { flex: none; width: 40px; height: 40px; margin: -8px -8px -8px 0; display: grid; place-items: center; color: var(--texte-2); }
.telechargement svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.telechargement.pret { color: var(--accent); }
.telechargement.actif i {
  width: 20px; height: 20px; border-radius: 50%;
  background: conic-gradient(var(--accent) var(--part, 0%), var(--trait) 0);
  -webkit-mask: radial-gradient(circle, transparent 6.5px, #000 7px);
  mask: radial-gradient(circle, transparent 6.5px, #000 7px);
}

/* ---------- Fiche série ---------- */

.fiche-fond { position: fixed; inset: 0 0 auto 0; height: 46vh; z-index: -1; background-size: cover; background-position: center 20%; filter: blur(30px) saturate(140%); opacity: .5; transform: scale(1.2); -webkit-mask-image: linear-gradient(#000 30%, transparent); mask-image: linear-gradient(#000 30%, transparent); }
.fiche-tete { display: flex; gap: 16px; margin-top: 54px; }
.fiche-tete img { width: 118px; aspect-ratio: 2 / 3; object-fit: cover; border-radius: 14px; box-shadow: 0 10px 30px rgba(0, 0, 0, .45); flex: none; background: var(--fond-2); }
.fiche-tete h1 { font-size: 24px; line-height: 1.15; margin: 0 0 6px; letter-spacing: -.01em; }
.etiquette { padding: 4px 10px; font-size: 12.5px; font-weight: 600; border-radius: 999px; background: var(--fond-2); box-shadow: inset 0 0 0 .5px var(--trait); color: var(--texte-2); }
.resume { margin: 16px 0 0; color: var(--texte-2); font-size: 15px; white-space: pre-line; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.resume.ouvert { display: block; }
.actions { display: flex; gap: 10px; margin: 16px 0 4px; }
.actions .bouton { flex: 1; }

.flottant { position: fixed; top: calc(var(--haut) + 10px); z-index: 25; }
.flottant.gauche { left: 14px; }
.flottant.droite { right: 14px; display: flex; align-items: center; gap: 8px; }

/* ---------- Annonce ---------- */

#annonce {
  position: fixed;
  left: 50%;
  top: calc(var(--haut) + 12px);
  transform: translateX(-50%);
  z-index: 60;
  padding: 10px 18px;
  font-size: 14.5px;
  font-weight: 600;
  max-width: calc(100vw - 32px);
  text-align: center;
}

/* ---------- Attente ---------- */

.attente { width: 26px; height: 26px; margin: 40px auto; border-radius: 50%; border: 2.5px solid var(--trait); border-top-color: var(--texte-2); animation: tourne .8s linear infinite; }
@keyframes tourne { to { transform: rotate(360deg); } }

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

body.lecture { background: #000; }
body.lecture #scene { padding: 0; max-width: none; }
#bande {
  position: fixed;
  inset: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  /* Le lecteur compense lui-même les changements de hauteur : l'ancrage automatique du
     navigateur (absent de Safari, présent ailleurs) ferait double emploi. */
  overflow-anchor: none;
  background: #000;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}
#bande .colonne { margin: 0 auto; max-width: 820px; padding: 0 var(--bord, 0px); }
.planche { width: 100%; background: #0c0c0e; overflow: hidden; }
.planche img { width: 100%; height: 100%; -webkit-user-drag: none; pointer-events: none; }
.planche.erreur { display: grid; place-items: center; color: #8e8e93; font-size: 14px; pointer-events: auto; }
.jonction { padding: 44px 20px; text-align: center; color: #8e8e93; font-size: 14px; }
.jonction b { display: block; color: #f5f5f7; font-size: 17px; margin-top: 4px; }
.fin { padding: 60px 20px calc(var(--bas) + 120px); text-align: center; color: #8e8e93; }

.lecteur-barre { position: fixed; left: 14px; right: 14px; z-index: 40; display: flex; align-items: center; gap: 10px; transition: opacity .25s, transform .3s cubic-bezier(.2, .9, .3, 1); color: #f5f5f7; }
.lecteur-barre.haut { top: calc(var(--haut) + 10px); }
.lecteur-barre.bas { bottom: calc(var(--bas) + 14px); padding: 12px 18px; }
.lecteur-barre .legende { flex: 1; min-width: 0; padding: 9px 16px; }
.lecteur-barre .legende b, .lecteur-barre .legende span { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lecteur-barre .legende b { font-size: 15px; }
.lecteur-barre .legende span { font-size: 12.5px; opacity: .7; }
.lecteur-barre input[type=range] { flex: 1; accent-color: #fff; min-width: 0; }
.lecteur-barre .compte { font-size: 13px; font-variant-numeric: tabular-nums; opacity: .8; white-space: nowrap; }
body.immersion .lecteur-barre { opacity: 0; pointer-events: none; }
body.immersion .lecteur-barre.haut { transform: translateY(-16px); }
body.immersion .lecteur-barre.bas { transform: translateY(16px); }
/* Dans le lecteur, le verre est toujours sombre : il repose sur des planches, pas sur l'interface. */
body.lecture .verre { --verre-teinte: rgba(40, 40, 46, .45); --verre-bord: rgba(255, 255, 255, .2); --verre-reflet: rgba(255, 255, 255, .34); --verre-reflet-bas: rgba(255, 255, 255, .06); }

/* ---------- Réglages ---------- */

.reglage { justify-content: space-between; }
.reglage > span:not(.tuile):not(.discret) { flex: 1; min-width: 0; }
/* Ligne qui ouvre une sous-page. */
.chevron::after { content: ""; flex: none; width: 8px; height: 8px; margin: 0 4px 0 -2px; border: solid var(--texte-2); border-width: 2px 2px 0 0; transform: rotate(45deg); opacity: .6; }
.reglage > .discret { flex: none; max-width: 60%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.reglage input[type=range] { max-width: 45%; accent-color: var(--accent); }
.reglage select { -webkit-appearance: none; appearance: none; max-width: 58%; padding: 6px 0; border: 0; outline: 0; background: none; color: var(--accent); text-align: right; text-align-last: right; text-overflow: ellipsis; }
/* Interrupteur d'iOS 26 : piste basse et large, bouton en pilule. */
.bascule { appearance: none; -webkit-appearance: none; width: 64px; height: 28px; margin: 0; border-radius: 999px; background: rgba(120, 120, 128, .32); position: relative; transition: background .25s; flex: none; }
.bascule::after { content: ""; position: absolute; top: 2px; left: 2px; width: 38px; height: 24px; border-radius: 999px; background: #fff; box-shadow: 0 2px 6px rgba(0, 0, 0, .28); transition: transform .28s cubic-bezier(.3, 1.3, .5, 1); }
.bascule:checked { background: #30d158; }
.bascule:checked::after { transform: translateX(22px); }
.bascule:disabled { opacity: .45; }

/* ---------- Catalogue ---------- */

.carte .legende { font-size: 12px; color: var(--texte-2); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.defile.large .carte { flex-basis: 118px; }
.etiquette.bon { color: #30d158; }
.etiquette.moyen { color: #ff9f0a; }
.ligne .etiquette { flex: none; }
.ligne.source { width: 100%; text-align: left; }
.ligne.choisie .nom { color: var(--accent); }
.recherche-source { display: flex; align-items: center; gap: 12px; padding: 14px 4px; color: var(--texte-2); font-size: 15px; }
.recherche-source .attente { margin: 0; width: 18px; height: 18px; flex: none; }
