:root {
  --fond-haut: #3b3050;
  --fond: #2a2238;
  --fond-bas: #1d1828;
  --texte: #f5f1f9;
  --doux: #bfb5cf;
  --accent: #f2c14e;
  --bouton: rgba(255, 255, 255, 0.1);
  --bouton-survol: rgba(255, 255, 255, 0.2);
  --ratio: 0.756;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }

body {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  background: radial-gradient(ellipse at top, var(--fond-haut) 0%, var(--fond) 45%, var(--fond-bas) 100%) fixed;
  color: var(--texte);
  font: 15px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

/* en-tête */
.entete {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  padding-top: max(10px, env(safe-area-inset-top));
}
.entete-titre { display: flex; flex-direction: column; min-width: 0; }
.entete-titre strong, .entete-titre span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.entete-titre strong { font-size: 16px; }
.entete-titre span { font-size: 13px; color: var(--doux); }
.entete-actions { display: flex; gap: 8px; flex-shrink: 0; }

.bouton {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 40px;
  padding: 8px 14px;
  border: 0;
  border-radius: 999px;
  background: var(--bouton);
  color: var(--texte);
  font: inherit;
  font-size: 14px;
  text-decoration: none;
  cursor: pointer;
}
.bouton:hover { background: var(--bouton-survol); }
.bouton:disabled { opacity: 0.3; cursor: default; }
.bouton.rond { width: 40px; padding: 0; }
.bouton svg, .fleche svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* livre */
.scene {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 64px;
}
.cadre { width: 100%; transform-origin: 0 0; transition: transform 0.12s ease-out; }
.scene.zoome { cursor: grab; overflow: hidden; }
.scene.glisse { cursor: grabbing; }
.scene.glisse .cadre { transition: none; }
.taille-normale {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 6;
  background: rgba(16, 12, 24, 0.85);
}
.taille-normale[hidden] { display: none; }
.page { background: #fff; }
.page img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
  user-select: none;
  -webkit-user-select: none;
}

.fleche {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 46px;
  height: 46px;
  border: 0;
  border-radius: 50%;
  background: var(--bouton);
  color: var(--texte);
  cursor: pointer;
  z-index: 5;
}
.fleche:hover { background: var(--bouton-survol); }
.fleche:disabled { opacity: 0.2; cursor: default; }
.fleche.prec { left: 10px; }
.fleche.suiv { right: 10px; }

.barre {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 6px 16px;
}
.compteur {
  min-width: 84px;
  text-align: center;
  color: var(--doux);
  font-variant-numeric: tabular-nums;
}
.mobile { display: none; }

.pied {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 2px 14px;
  padding: 2px 16px 10px;
  padding-bottom: max(10px, env(safe-area-inset-bottom));
  color: var(--doux);
  font-size: 12px;
  text-align: center;
}
.pied a { color: var(--texte); }

.sans-js { max-width: 420px; text-align: center; }
.sans-js a { color: var(--accent); }

/* calques : page agrandie et grille */
.calque {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  background: rgba(16, 12, 24, 0.97);
}
.calque[hidden] { display: none; }
.calque-haut {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 16px;
  padding-top: max(10px, env(safe-area-inset-top));
}
.calque-haut div { display: flex; gap: 8px; }

.zoom-zone {
  flex: 1;
  overflow: auto;
  padding: 0 8px 24px;
  -webkit-overflow-scrolling: touch;
}
.zoom-zone img {
  display: block;
  width: min(100%, 980px);
  height: auto;
  margin: 0 auto;
  background: #fff;
  cursor: zoom-in;
}
.zoom.grand .zoom-zone img { width: min(220%, 2200px); max-width: none; cursor: zoom-out; }
.zoom .fleche { top: 55%; }

.grille-pages {
  flex: 1;
  overflow: auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(112px, 1fr));
  align-content: start;
  gap: 16px;
  padding: 8px 16px 32px;
}
.grille-pages button {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--doux);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}
.grille-pages img {
  width: 100%;
  aspect-ratio: var(--ratio);
  object-fit: cover;
  background: #fff;
  border-radius: 3px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.45);
}
.grille-pages button.actif img { outline: 3px solid var(--accent); outline-offset: 2px; }
.grille-pages button.actif span { color: var(--accent); }

.avis {
  position: fixed;
  left: 50%;
  bottom: 96px;
  transform: translateX(-50%);
  z-index: 60;
  padding: 10px 18px;
  border-radius: 999px;
  background: #fff;
  color: #222;
  font-size: 14px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
}

/* pages simples : liste des catalogues, catalogue introuvable */
body.simple { display: block; height: auto; min-height: 100vh; overflow: auto; }
.simple-contenu { max-width: 720px; margin: 0 auto; padding: 48px 16px; text-align: center; }
.simple-contenu h1 { font-size: 26px; margin: 0 0 24px; }
.simple-pied { margin-top: 40px; color: var(--doux); font-size: 13px; }
.simple-pied a { color: var(--texte); }
.liste {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 24px;
}
.liste a { display: flex; flex-direction: column; gap: 10px; color: var(--texte); text-decoration: none; }
.liste img { width: 100%; border-radius: 4px; background: #fff; box-shadow: 0 6px 20px rgba(0, 0, 0, 0.45); }

@media (max-width: 700px) {
  .scene { padding: 4px 8px; }
  .scene > .fleche { display: none; }
  .mobile { display: inline-flex; }
  .entete-actions .bouton span { display: none; }
  .entete-actions .bouton { width: 40px; padding: 0; }
  .barre .bouton span { display: none; }
  .barre .bouton { width: 40px; padding: 0; }
  .zoom .fleche { top: auto; bottom: 18px; transform: none; }
}

/* styles de la bibliothèque StPageFlip (non injectés par sa version navigateur) */
.stf__parent { position: relative; display: block; box-sizing: border-box; transform: translateZ(0); touch-action: pan-y; }
.stf__wrapper { position: relative; width: 100%; box-sizing: border-box; }
.stf__parent canvas { position: absolute; width: 100%; height: 100%; left: 0; top: 0; }
.stf__block { position: absolute; width: 100%; height: 100%; box-sizing: border-box; perspective: 2000px; }
.stf__item { display: none; position: absolute; transform-style: preserve-3d; }
.stf__outerShadow, .stf__innerShadow, .stf__hardShadow, .stf__hardInnerShadow { position: absolute; left: 0; top: 0; }
