:root {
  --fond: #f6f1e7;
  --papier: #fffdf8;
  --encre: #2a2420;
  --encre-douce: #6b6058;
  --accent: #8a3b2e;
  --accent-doux: #f0dcd4;
  --trait: #e2d8c8;
  --ombre: 0 1px 2px rgba(60, 40, 20, .08), 0 8px 24px rgba(60, 40, 20, .08);
  --serif: "Cormorant Garamond", Georgia, serif;
  --sans: "Inter", system-ui, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --fond: #1b1816;
    --papier: #25211e;
    --encre: #eee6da;
    --encre-douce: #a89c90;
    --accent: #e0907e;
    --accent-doux: #3d2a25;
    --trait: #3a332e;
    --ombre: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .3);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --fond: #1b1816;
  --papier: #25211e;
  --encre: #eee6da;
  --encre-douce: #a89c90;
  --accent: #e0907e;
  --accent-doux: #3d2a25;
  --trait: #3a332e;
  --ombre: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .3);
  color-scheme: dark;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--fond);
  color: var(--encre);
  font: 16px/1.55 var(--sans);
}
a { color: var(--accent); }
h1, h2, h3 { font-family: var(--serif); font-weight: 600; line-height: 1.15; margin: 0; }

.bouton {
  display: inline-flex; align-items: center; gap: .4em;
  padding: .55em 1.1em; border-radius: 999px;
  border: 1px solid var(--trait); background: var(--papier); color: var(--encre);
  font: 500 .9rem var(--sans); text-decoration: none; cursor: pointer;
}
.bouton:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.bouton:disabled { opacity: .4; cursor: default; }
.bouton.plein { background: var(--accent); border-color: var(--accent); color: var(--papier); }
.bouton.plein:hover { filter: brightness(1.08); color: var(--papier); }

/* ---------- Bibliothèque ---------- */
.entete { max-width: 1100px; margin: 0 auto; padding: 56px 16px 24px; text-align: center; }
.entete .auteur { font: 500 .8rem var(--sans); letter-spacing: .18em; text-transform: uppercase; color: var(--encre-douce); }
.entete h1 { font-size: clamp(2.2rem, 6vw, 3.6rem); margin: .2em 0 .3em; }
.entete p { max-width: 560px; margin: 0 auto; color: var(--encre-douce); }
.recherche {
  display: block; width: min(420px, 100%); margin: 28px auto 0;
  padding: .7em 1.1em; border-radius: 999px; border: 1px solid var(--trait);
  background: var(--papier); color: var(--encre); font: inherit;
}
.recherche:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

.grille {
  max-width: 1100px; margin: 0 auto; padding: 24px 16px 64px;
  display: grid; gap: 28px; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
}
.carte {
  display: flex; flex-direction: column; background: var(--papier);
  border: 1px solid var(--trait); border-radius: 10px; overflow: hidden;
  box-shadow: var(--ombre); text-decoration: none; color: inherit;
  transition: transform .15s ease;
}
.carte:hover { transform: translateY(-3px); }
.couverture { aspect-ratio: 3 / 4; background: var(--accent-doux); display: grid; place-items: center; overflow: hidden; }
.couverture img { width: 100%; height: 100%; object-fit: cover; display: block; }
.couverture.typo {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  padding: 24px 20px; text-align: center; color: #fbf6ec;
  background:
    radial-gradient(120% 80% at 50% 0%, hsl(var(--teinte) 30% 38%), transparent 70%),
    hsl(var(--teinte) 32% 22%);
  box-shadow: inset 0 0 0 10px hsl(var(--teinte) 32% 22%), inset 0 0 0 11px rgba(251, 246, 236, .35);
}
.couverture.typo .c-auteur { font: 500 .68rem var(--sans); letter-spacing: .22em; text-transform: uppercase; opacity: .8; }
.couverture.typo .c-titre { font: 600 1.75rem/1.1 var(--serif); text-wrap: balance; }
.couverture.typo .c-filet { width: 36px; height: 1px; background: currentColor; opacity: .6; }
.carte .corps { padding: 16px 18px 18px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.carte .genre { font-size: .72rem; letter-spacing: .12em; text-transform: uppercase; color: var(--accent); }
.carte h2 { font-size: 1.45rem; }
.carte .resume { font-size: .9rem; color: var(--encre-douce); margin: 0; flex: 1;
  display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.carte .limites { font-size: .8rem; color: var(--encre-douce); border-top: 1px solid var(--trait); padding-top: 10px; margin-top: 6px; }
.vide { grid-column: 1 / -1; text-align: center; color: var(--encre-douce); padding: 48px 0; }

.pied { text-align: center; padding: 0 16px 40px; color: var(--encre-douce); font-size: .85rem; }

/* ---------- Liseuse ---------- */
.liseuse { min-height: 100vh; display: flex; flex-direction: column; }
.barre {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 10px 16px; background: var(--papier); border-bottom: 1px solid var(--trait);
}
.barre .titre { flex: 1; min-width: 0; font: 600 1.25rem var(--serif); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.minuteur { font: 600 .9rem var(--sans); font-variant-numeric: tabular-nums; padding: .35em .8em; border-radius: 999px; background: var(--accent-doux); color: var(--accent); }
.minuteur.urgent { background: var(--accent); color: var(--papier); }

.scene { flex: 1; display: flex; justify-content: center; padding: 24px 16px 96px; }
.page { position: relative; width: min(820px, 100%); }
.page canvas { width: 100%; height: auto; display: block; background: #fff; box-shadow: var(--ombre); border-radius: 2px;
  user-select: none; -webkit-user-select: none; }
.chargement { text-align: center; color: var(--encre-douce); padding: 80px 0; }

.navigation {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 5;
  display: flex; align-items: center; gap: 10px; padding: 6px; border-radius: 999px;
  background: var(--papier); border: 1px solid var(--trait); box-shadow: var(--ombre);
}
.navigation .compteur { font-size: .85rem; font-variant-numeric: tabular-nums; color: var(--encre-douce); min-width: 7.5em; text-align: center; }

.voile {
  position: fixed; inset: 0; z-index: 10; display: none; place-items: center; padding: 16px;
  background: color-mix(in srgb, var(--fond) 82%, transparent); backdrop-filter: blur(6px);
}
.voile.visible { display: grid; }
.voile .boite { max-width: 460px; text-align: center; background: var(--papier); border: 1px solid var(--trait);
  border-radius: 14px; padding: 32px 28px; box-shadow: var(--ombre); }
.voile h2 { font-size: 2rem; margin-bottom: .3em; }
.voile p { color: var(--encre-douce); margin: 0 0 1.4em; }
.voile .actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

@media print { body { display: none; } }
