:root {
  --fond: #faf8f4;
  --surface: #ffffff;
  --texte: #1f1d1a;
  --discret: #6b665e;
  --trait: #e4dfd6;
  --accent: #8a3b2e;
  --accent-texte: #ffffff;
  --positif: #2f6b3a;
  --negatif: #9a3324;
  --lettre-A: #2f6b3a;
  --lettre-B: #5f8a3a;
  --lettre-C: #b08a22;
  --lettre-D: #c0632b;
  --lettre-E: #9a3324;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  /* Toujours clair, quel que soit le thème de l'appareil. */
  color-scheme: light;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--fond); color: var(--texte); font: 17px/1.6 var(--sans); }
h1, h2, h3 { font-family: var(--serif); line-height: 1.2; font-weight: 600; }
h1 { font-size: 2.1rem; margin: .2em 0; }
h2 { font-size: 1.4rem; margin: 2.2em 0 .6em; padding-bottom: .3em; border-bottom: 1px solid var(--trait); }
h3 { font-size: 1.1rem; margin: 1.4em 0 .5em; }
a { color: var(--accent); }
img { max-width: 100%; }

.conteneur { max-width: 980px; margin: 0 auto; padding: 0 16px; }
.discret { color: var(--discret); font-size: .9rem; }

/* En-tête */
.entete { background: var(--surface); border-bottom: 1px solid var(--trait); }
.entete__ligne { display: flex; align-items: center; gap: 16px; min-height: 60px; flex-wrap: wrap; padding-block: 8px; }
.logo { font-family: var(--serif); font-size: 1.5rem; font-weight: 700; color: var(--texte); text-decoration: none; }
.logo span { color: var(--accent); }
.recherche { flex: 1; min-width: 160px; }
.recherche input, .filtres input, .filtres select, textarea, .formulaire input {
  width: 100%; padding: 8px 12px; font: inherit; color: var(--texte);
  background: var(--fond); border: 1px solid var(--trait); border-radius: 6px;
}
.compte { display: flex; align-items: center; gap: 12px; font-size: .95rem; }
.compte form { margin: 0; }

/* Boutons */
.bouton {
  display: inline-block; padding: 8px 16px; border: 1px solid var(--accent); border-radius: 6px;
  background: var(--accent); color: var(--accent-texte); font: inherit; text-decoration: none; cursor: pointer;
}
.bouton--petit { padding: 4px 12px; font-size: .9rem; }
.bouton--secondaire, .bouton--actif { background: transparent; color: var(--accent); }
.lien { background: none; border: 0; padding: 0; color: var(--accent); font: inherit; cursor: pointer; text-decoration: underline; }

.message { padding: 10px 14px; border-radius: 6px; background: var(--surface); border: 1px solid var(--trait); }
.message--error { border-color: var(--negatif); }

/* Accueil */
.intro { padding: 40px 0 8px; }
.intro p { font-size: 1.15rem; max-width: 40em; }
.niveaux { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.niveaux a { display: flex; flex-direction: column; padding: 14px; background: var(--surface); border: 1px solid var(--trait); border-radius: 8px; color: var(--texte); text-decoration: none; }
.niveaux span { color: var(--discret); font-size: .9rem; }

/* Cartes */
.grille { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.carte { display: flex; gap: 14px; align-items: center; padding: 12px; background: var(--surface); border: 1px solid var(--trait); border-radius: 8px; color: var(--texte); text-decoration: none; }
.carte:hover { border-color: var(--accent); }
.carte__texte { display: flex; flex-direction: column; min-width: 0; }
.carte__texte strong { font-family: var(--serif); overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.carte__texte span, .carte__texte small { color: var(--discret); font-size: .9rem; }

.lettre { flex: none; display: inline-grid; place-items: center; width: 42px; height: 42px; border-radius: 8px; color: #fff; font: 700 1.4rem var(--serif); }
.lettre--grande { width: 88px; height: 88px; font-size: 3.2rem; border-radius: 14px; }
.lettre--A { background: var(--lettre-A); }
.lettre--B { background: var(--lettre-B); }
.lettre--C { background: var(--lettre-C); }
.lettre--D { background: var(--lettre-D); }
.lettre--E { background: var(--lettre-E); }

/* Liste */
.filtres { display: grid; grid-template-columns: 2fr 1.5fr 1fr auto; gap: 8px; margin: 16px 0; }
.pagination { display: flex; justify-content: center; gap: 20px; margin: 28px 0; }

/* Page livre */
.fil { margin: 20px 0 0; font-size: .9rem; color: var(--discret); }
.fil a { color: var(--discret); }
.livre { display: flex; flex-wrap: wrap; gap: 36px; align-items: flex-start; margin-top: 20px; }
/* Bases assez petites pour ne jamais passer à la ligne au-dessus de 640 px,
   où la grille mobile prend le relais. */
.livre__cote { flex: 1 1 200px; max-width: 240px; display: flex; flex-direction: column; gap: 20px; }
.livre__corps { flex: 999 1 360px; min-width: 0; }
.livre__corps section[id] { scroll-margin-top: 16px; }

.couverture { display: block; width: 100%; border-radius: 4px; box-shadow: 0 8px 24px rgb(0 0 0 / .2); }
.couverture--vide { box-sizing: border-box; aspect-ratio: 2 / 3; display: flex; flex-direction: column; justify-content: space-between; padding: 20px 18px; background: #1d3a4f; color: #e9e2d0; }
.couverture--vide span { font-size: .75rem; letter-spacing: .1em; text-transform: uppercase; }
.couverture--vide strong { font: 600 1.5rem/1.15 var(--serif); }

.lecture { display: grid; gap: 6px; text-align: center; }
.lecture form { margin: 0; }
.lecture .bouton { width: 100%; min-height: 44px; font-weight: 600; }
.lecture p { margin: 0; }

.etiquette { margin: 0 0 8px; padding: 0; border: 0; font: 600 .78rem/1.3 var(--sans); letter-spacing: .08em; text-transform: uppercase; color: var(--discret); }

.achats ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.achats a { display: flex; justify-content: space-between; align-items: center; min-height: 44px; padding: 0 14px; background: var(--surface); border: 1px solid var(--trait); border-radius: 8px; color: var(--texte); text-decoration: none; }
.achats a:hover { border-color: var(--accent); }
.achats a span { color: var(--accent); }

/* Titre à gauche, score à droite ; le score passe dessous quand la place manque. */
.livre__entete { display: flex; flex-wrap: wrap; gap: 24px; align-items: flex-start; }
.livre__titre { flex: 1 1 280px; min-width: 0; }
.livre__titre p { margin: 0; }
.livre__titre h1 { margin: .15em 0 .2em; font-size: 2.4rem; line-height: 1.1; }
.surtitre { font-size: .9rem; font-weight: 600; color: var(--accent); }
.auteur { font-size: 1.15rem; }

.score { flex: 0 1 260px; display: grid; gap: 12px; padding: 18px; background: var(--surface); border: 1px solid var(--trait); border-radius: 12px; }
.score p { margin: 0; }
.score .etiquette { margin: 0; }
.score .lettre--grande { width: 72px; height: 72px; font-size: 2.6rem; }
.score__tete { display: flex; align-items: center; gap: 14px; }
.score__tete strong { display: block; font: 600 1.35rem/1.2 var(--serif); }
.score__tete .discret { display: block; }
.score__mesure { padding: 8px 10px; background: var(--fond); border-radius: 8px; font-size: .85rem; color: var(--discret); }
.score__alertes { margin: 0; padding: 8px 10px 8px 26px; border: 1px solid var(--lettre-D); border-radius: 8px; font-size: .85rem; }

.echelle { display: flex; gap: 4px; }
.echelle span { flex: 1; padding: 2px 0; border-radius: 4px; text-align: center; font-size: .85rem; font-weight: 600; background: color-mix(in srgb, var(--c) 22%, var(--surface)); }
.echelle .echelle--active { background: var(--c); color: #fff; outline: 2px solid var(--texte); outline-offset: 1px; }
.echelle--A { --c: var(--lettre-A); }
.echelle--B { --c: var(--lettre-B); }
.echelle--C { --c: var(--lettre-C); }
.echelle--D { --c: var(--lettre-D); }
.echelle--E { --c: var(--lettre-E); }

.sommaire { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 24px; padding: 5px; background: var(--surface); border: 1px solid var(--trait); border-radius: 10px; }
.sommaire a { padding: 6px 12px; border-radius: 6px; color: var(--texte); text-decoration: none; font-size: .95rem; }
.sommaire a:hover { background: var(--fond); }

.resume { max-width: 42em; }

.dimensions { list-style: none; padding: 0; margin: 12px 0 0; display: grid; gap: 10px; }
.dimensions li { display: grid; grid-template-columns: 110px 1fr 36px; gap: 14px; align-items: center; }
.dimensions__valeur { text-align: right; font-variant-numeric: tabular-nums; }
.barre { position: relative; height: 12px; background: var(--trait); border-radius: 6px; }
.barre__valeur { display: block; height: 100%; background: var(--accent); border-radius: 6px; }
.barre__mediane { position: absolute; left: 50%; top: -4px; bottom: -4px; width: 2px; margin-left: -1px; background: var(--texte); }

.pli { margin-bottom: 10px; padding: 0 16px; background: var(--surface); border: 1px solid var(--trait); border-radius: 10px; }
.pli[open] { padding-bottom: 12px; }
.pli summary { padding: 10px 0; font-weight: 600; cursor: pointer; }
.pli summary .discret { font-weight: 400; }
.defilement { overflow-x: auto; }

.criteres { width: 100%; border-collapse: collapse; font-size: .92rem; font-variant-numeric: tabular-nums; }
.criteres th, .criteres td { padding: 6px 8px; border-bottom: 1px solid var(--trait); text-align: right; }
.criteres th:first-child, .criteres td:first-child { text-align: left; }
.criteres th { color: var(--discret); font-weight: 500; }
.criteres small { white-space: nowrap; }
.sens { color: var(--discret); text-decoration: none; cursor: help; }
.positif { color: var(--positif); }
.negatif { color: var(--negatif); }

.reserve { padding: 20px; background: var(--surface); border: 1px dashed var(--trait); border-radius: 8px; text-align: center; }

.extraits { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; }
.extrait { margin: 0; display: flex; flex-direction: column; gap: 10px; padding: 20px; background: var(--surface); border: 1px solid var(--trait); border-radius: 12px; }
.extrait blockquote { margin: 0; font: 1.1rem/1.5 var(--serif); }
.extrait figcaption { color: var(--discret); font-size: .85rem; }
.pastille { align-self: flex-start; padding: 1px 10px; border: 1px solid var(--trait); border-radius: 999px; background: var(--fond); font-size: .82rem; color: var(--discret); }

.liees { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: 10px; }
.liees li { display: flex; gap: 10px; align-items: center; width: 220px; padding: 8px; background: var(--surface); border: 1px solid var(--trait); border-radius: 8px; }
.liees img, .liees .liees__vide { flex: none; width: 40px; height: 60px; object-fit: cover; border-radius: 3px; background: var(--trait); }
.liees span { display: flex; flex-direction: column; min-width: 0; }
.liees small { color: var(--discret); }
.liees .liees__pourquoi { margin-top: 4px; font-size: .85em; line-height: 1.35; }

.commenter { display: grid; gap: 8px; justify-items: start; margin-bottom: 20px; }
.commenter .bouton { min-height: 44px; }
.commentaire { display: flex; gap: 14px; padding: 14px 0; border-top: 1px solid var(--trait); }
.commentaire p { margin: 0 0 4px; }
.avatar { flex: none; display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; background: var(--trait); font-weight: 600; }

.formulaire { max-width: 420px; margin: 40px auto; }
.formulaire .helptext, .formulaire ul { color: var(--discret); font-size: .85rem; }

.pied { margin-top: 60px; padding-block: 24px; border-top: 1px solid var(--trait); color: var(--discret); font-size: .9rem; }

@media (max-width: 640px) {
  .filtres { grid-template-columns: 1fr 1fr; }
  .filtres input { grid-column: 1 / -1; }
  /* Une seule grille : la couverture et le score côte à côte en tête,
     puis le titre, « J'ai lu », les achats et le reste de l'article. */
  .livre { display: grid; grid-template-columns: 96px minmax(0, 1fr); gap: 16px; }
  .livre__cote, .livre__corps, .livre__entete { display: contents; }
  .livre > * > *, .livre__entete > * { grid-column: 1 / -1; }
  .livre .couverture { grid-column: 1; grid-row: 1; }
  .livre .score { grid-column: 2; grid-row: 1; padding: 12px; gap: 8px; align-self: start; }
  .livre__titre { order: -1; }
  .score .lettre--grande { width: 52px; height: 52px; font-size: 2rem; }
  .score__tete { gap: 10px; }
  .score__tete strong { font-size: 1.15rem; }
  .score__tete .discret { font-size: .8rem; }
  .score__mesure { font-size: .78rem; }
  .achats ul { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
  .couverture--vide { padding: 8px; }
  .couverture--vide span { font-size: .55rem; }
  .couverture--vide strong { font-size: .8rem; }
  .livre__titre h1 { font-size: 1.8rem; }
  h1 { font-size: 1.7rem; }
  .criteres { font-size: .82rem; }
  .criteres th:nth-child(3), .criteres td:nth-child(3),
  .criteres th:nth-child(6), .criteres td:nth-child(6) { display: none; }
  .score__alertes { font-size: .78rem; }
}
