/* =========================================================================
   Ternavia — thème « Grimoire enluminé »
   Le site est un manuscrit : parchemin, filets dorés doubles, lettrines,
   rubriques en onglets de registre. Les polices sont embarquées (OFL) :
   la CSP n'autorise aucune ressource externe et le site fonctionne hors ligne.
   ========================================================================= */

@font-face {
  font-family: "Cinzel";
  src: url("../fonts/cinzel.woff2") format("woff2");
  font-weight: 400 900;
  font-display: swap;
}
@font-face {
  font-family: "Cinzel Decorative";
  src: url("../fonts/cinzel-decorative.woff2") format("woff2");
  font-weight: 700;
  font-display: swap;
}
@font-face {
  font-family: "EB Garamond";
  src: url("../fonts/eb-garamond.woff2") format("woff2");
  font-weight: 400 800;
  font-display: swap;
}
@font-face {
  font-family: "EB Garamond";
  src: url("../fonts/eb-garamond-italic.woff2") format("woff2");
  font-weight: 400 800;
  font-style: italic;
  font-display: swap;
}

:root {
  --ink: #2c2620;
  --paper: #f3ecdd;
  --parchment: #faf6ec;
  --accent: #7a5c3e;
  --accent-dark: #4a3826;
  --gold: #b08d4f;
  --border: #d9cdb4;
  --muted: #8a7d63;
  /* Le texte courant des cartes et des fiches : plus sombre que « muted », lisible sur parchemin. */
  --ink-soft: #5a4e3c;
  /* La teinte des onglets au repos et des bandeaux secondaires. */
  --vellum: #ebe2cd;
  --font-display: "Cinzel", Georgia, "Times New Roman", serif;
  --font-ornate: "Cinzel Decorative", "Cinzel", Georgia, serif;
  --font-body: "EB Garamond", Georgia, "Times New Roman", serif;
  /* Un filet double doré : le trait qui encadre tout le manuscrit. */
  --double-rule: 5px double var(--gold);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 1.08rem;
  background: var(--paper);
  color: var(--ink);
  line-height: 1.6;
  display: flex;
  min-height: 100vh;
  flex-direction: column;
}

/* ---------- En-tête : la page de titre du grimoire ---------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 1100; /* au-dessus des panneaux Leaflet (≤ 1000) */
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  column-gap: 1.2rem;
  row-gap: 0.45rem;
  padding: 0.6rem 2rem 0;
  background: var(--parchment);
  border-top: var(--double-rule);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 2px 10px rgba(44, 38, 32, 0.12);
}

.site-header .brand {
  order: 1;
  display: inline-flex;
  align-items: center;
  gap: 0.7rem;
  color: var(--accent-dark);
  text-decoration: none;
  white-space: nowrap;
}
.site-header .brand img { width: 44px; height: 44px; flex: none; border-radius: 50%; box-shadow: 0 0 0 1px var(--gold), 0 1px 4px rgba(44, 38, 32, 0.25); }
.brand-name {
  font-family: var(--font-ornate);
  font-size: 1.45rem;
  letter-spacing: 0.14em;
  line-height: 1;
}
.brand-tagline {
  display: block;
  margin-top: 0.2rem;
  font-family: var(--font-display);
  font-size: 0.62rem;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--muted);
}

/* ---------- Navigation : les onglets du registre ---------- */

.site-nav {
  order: 4;
  flex: 1 0 100%;
  display: flex;
  align-items: flex-end;
  gap: 0.25rem;
  margin-top: 0.25rem;
  /* Les onglets chevauchent le filet du bas d'un pixel : l'onglet ouvert s'y fond. */
  margin-bottom: -1px;
}

/* Entrée de premier niveau : lien direct ou bouton de rubrique, même allure d'onglet. */
.site-nav .nav-link,
.site-nav .nav-toggle {
  font-family: var(--font-display);
  font-size: 0.74rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent-dark);
  background: var(--vellum);
  border: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  border-radius: 7px 7px 0 0;
  padding: 0.55rem 0.9rem 0.5rem;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  white-space: nowrap;
}

.site-nav .nav-link:hover,
.site-nav .nav-toggle:hover { background: var(--parchment); color: var(--ink); }
.site-nav .nav-link.current,
.site-nav .nav-toggle.current,
.nav-group.open .nav-toggle {
  background: var(--parchment);
  color: var(--ink);
  border-bottom-color: var(--parchment);
  box-shadow: inset 0 3px 0 var(--gold);
}
.site-nav .nav-link:focus-visible,
.site-nav .nav-toggle:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

/* Les deux entrées hors lore, à droite : le livre de campagne et la plume du créateur. */
.site-nav .nav-link.nav-aside { margin-left: auto; }
.site-nav .nav-link.nav-aside + .nav-link.nav-aside { margin-left: 0; }
.site-nav .nav-link.nav-creator {
  background: var(--accent-dark);
  color: #f0e6cf;
  border-color: var(--accent-dark);
}
.site-nav .nav-link.nav-creator:hover,
.site-nav .nav-link.nav-creator.current { background: var(--accent); border-color: var(--accent); color: #fff; box-shadow: none; }

.caret {
  width: 0;
  height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid currentColor;
  transition: transform 0.15s ease;
}
.nav-group.open .caret { transform: rotate(180deg); }

.nav-group { position: relative; }

.nav-menu {
  display: none;
  position: absolute;
  top: calc(100% + 1px);
  left: 0;
  min-width: 13rem;
  background: var(--parchment);
  border: 1px solid var(--gold);
  border-top: var(--double-rule);
  box-shadow: 0 10px 24px rgba(44, 38, 32, 0.25);
  padding: 0.4rem;
  z-index: 1200;
}
/* L'ouverture tient à une classe, pas à aria-expanded : en panneau mobile, les rubriques
   sont annoncées dépliées, et cet attribut ne doit pas pouvoir déclencher deux menus
   ouverts d'un coup si la fenêtre revient au grand format. */
.nav-group.open .nav-menu { display: block; }

.nav-menu a {
  display: block;
  padding: 0.45rem 0.9rem;
  color: var(--accent-dark);
  text-decoration: none;
  font-size: 1.02rem;
  white-space: nowrap;
  border-bottom: 1px dotted var(--border);
}
.nav-menu a:last-child { border-bottom: none; }
.nav-menu a:hover { background: var(--vellum); color: var(--ink); }
.nav-menu a[aria-current="page"] {
  color: var(--accent-dark);
  font-weight: 600;
  box-shadow: inset 3px 0 0 var(--gold);
}

/* Bouton hamburger : caché tant que la barre tient sur une ligne. */
.nav-burger {
  order: 3;
  display: none;
  font: inherit;
  font-family: var(--font-display);
  align-items: center;
  gap: 0.5rem;
  color: var(--accent-dark);
  background: none;
  border: 1px solid var(--gold);
  border-radius: 6px;
  padding: 0.4rem 0.7rem;
  cursor: pointer;
}
.nav-burger:hover { background: var(--vellum); }
.nav-burger:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.burger-text { font-size: 0.72rem; letter-spacing: 0.1em; text-transform: uppercase; }
.nav-burger { justify-content: center; line-height: 0; }

/* Trois barres dessinées en CSS : pas d'image à charger pour trois traits. La barre du
   milieu est un pseudo-élément, les deux autres sont les bordures du cadre — celui-ci a
   donc une hauteur réelle, et rien ne déborde du bouton sur les petits écrans. */
.burger-bars {
  position: relative;
  display: block;
  flex: none;
  width: 18px;
  height: 14px;
  border-top: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
}
.burger-bars::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  height: 2px;
  margin-top: -1px;
  background: currentColor;
}

/* ---------- Recherche ---------- */

/* Texte réservé aux lecteurs d'écran : présent dans le document, absent de l'écran. */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* À droite du titre, sur la première ligne de l'en-tête ; les onglets prennent la seconde. */
.site-search {
  position: relative;
  order: 2;
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0;
  flex: 0 1 22rem;
  min-width: 13rem;
  background: var(--paper);
  border: 1px solid var(--gold);
  padding: 2px 2px 2px 0.6rem;
}

.search-input {
  font: inherit;
  font-size: 1rem;
  width: 100%;
  min-width: 0;
  padding: 0.3rem 0.4rem;
  color: var(--ink);
  background: transparent;
  border: none;
}
.search-input::placeholder { color: var(--muted); font-style: italic; }
.search-input:focus { outline: none; }
.site-search:focus-within { box-shadow: 0 0 0 2px rgba(176, 141, 79, 0.35); }

/* La croix que Chrome et Safari ajoutent d'office doublerait le bouton de recherche. */
.search-input::-webkit-search-cancel-button { -webkit-appearance: none; }

.search-go {
  font: inherit;
  flex: none;
  line-height: 0;
  width: 2.2rem;
  height: 2rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #f0e6cf;
  background: var(--accent-dark);
  border: none;
  cursor: pointer;
}
.search-go svg { width: 16px; height: 16px; }
.search-go:hover { background: var(--accent); }
.search-go:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

/* Le panneau s'accroche au bord droit de la barre et s'étend vers la gauche : il est plus large
   que le champ, et l'ancrer à droite l'empêche de sortir de l'écran. */
.search-panel {
  position: absolute;
  top: calc(100% + 0.4rem);
  right: -1px;
  left: auto;
  width: min(32rem, calc(100vw - 2rem));
  z-index: 1200;
  background: var(--parchment);
  border: 1px solid var(--gold);
  border-top: var(--double-rule);
  box-shadow: 0 10px 26px rgba(44, 38, 32, 0.25);
  overflow: hidden;
  text-align: left;
}
.search-panel[hidden] { display: none; }

.search-list {
  max-height: min(60vh, 26rem);
  overflow-y: auto;
  overscroll-behavior: contain;
}

.search-hit {
  display: block;
  padding: 0.5rem 0.8rem;
  color: var(--ink);
  text-decoration: none;
  border-bottom: 1px dotted var(--border);
}
.search-hit:last-child { border-bottom: none; }
/* Survol et désignation au clavier partagent le même fond : un seul repère à lire. */
.search-hit:hover,
.search-hit.is-active { background: var(--vellum); }

.search-hit-head { display: flex; align-items: baseline; gap: 0.5rem; }
.search-hit-name { font-family: var(--font-display); font-size: 0.92rem; color: var(--accent-dark); }

/* Deux lignes au plus : la liste doit rester une liste, pas un article. */
.search-hit-excerpt {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-top: 0.1rem;
  font-size: 0.92rem;
  color: var(--muted);
}

.search-empty { margin: 0; padding: 0.7rem 0.8rem; color: var(--muted); font-style: italic; }

.search-more {
  display: block;
  padding: 0.5rem 0.8rem;
  background: var(--vellum);
  border-top: 1px solid var(--border);
  color: var(--accent);
  font-family: var(--font-display);
  font-size: 0.74rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  text-align: center;
  text-decoration: none;
}
.search-more:hover { background: #e2d7bd; color: var(--accent-dark); }
.search-more[hidden] { display: none; }

/* Étiquette de genre, dans la liste comme dans la page de résultats. */
.search-hit-kind,
.search-kind {
  flex: none;
  font-family: var(--font-display);
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--accent);
  background: var(--paper);
  border: 1px solid var(--gold);
  padding: 0.1rem 0.4rem;
  white-space: nowrap;
}

/* --- Page de résultats --- */

.search-results { list-style: none; margin: 1.6rem 0 0; padding: 0; }
.search-results > li { padding: 0.9rem 0; border-bottom: 1px dotted var(--gold); }
.search-results > li:last-child { border-bottom: none; }

.search-result { display: flex; align-items: baseline; gap: 0.6rem; text-decoration: none; }
.search-name { font-family: var(--font-display); font-size: 1.05rem; color: var(--accent-dark); }
.search-result:hover .search-name { color: var(--gold); }
.search-summary { margin: 0.35rem 0 0; }
.search-excerpt { margin: 0.35rem 0 0; font-size: 0.98rem; color: var(--muted); }

.search-excerpt mark,
.search-hit-excerpt mark {
  background: #f4e2a6;
  color: var(--ink);
  padding: 0 0.12em;
}

@media (max-width: 900px) {
  /* Le menu est replié dans son bouton : la barre reprend le milieu de la ligne, entre le titre
     et ce bouton, et n'a plus de largeur minimale à défendre. */
  .site-search { order: 2; flex: 1 1 8rem; min-width: 0; margin-left: 0; }
  .nav-burger { order: 3; }
  .site-header { padding-bottom: 0.6rem; }
}

@media (max-width: 640px) {
  /* Trois éléments ne tiennent plus sur une ligne : la barre prend la sienne, toute la largeur. */
  .site-search { order: 3; flex: 1 0 100%; margin: 0; }
  .search-panel { right: 0; width: 100%; }

  /* Sur la carte en plein écran, chaque pixel de hauteur compte et le menu mène partout. */
  body.page-full .site-search { display: none; }
}

/* Contenu */
.container { max-width: 900px; margin: 0 auto; padding: 2rem 1.5rem; flex: 1; width: 100%; }
main.full { flex: 1; min-height: 0; display: flex; flex-direction: column; }

/* Pages plein écran (carte) : la page est verrouillée à la taille de l'écran,
   elle ne peut plus défiler — seule la carte bouge à l'intérieur. */
body.page-full { height: 100vh; height: 100dvh; overflow: hidden; overscroll-behavior: none; }
body.page-full .site-footer { display: none; }

/* Sur la page carte, l'en-tête reste compact sur une seule ligne :
   chaque pixel de hauteur va à la carte (important en fenêtre réduite ou zoomée). */
body.page-full .site-header { flex-direction: row; flex-wrap: wrap; padding: 0.4rem 1.2rem; }

@media (max-height: 560px) {
  body.page-full .map-note { display: none; }
  body.page-full .site-header { padding: 0.2rem 1rem; }
  body.page-full .site-header .brand { font-size: 1.05rem; }
}

h1 { font-size: 2rem; color: var(--accent-dark); margin: 0.2rem 0 1rem; }
h2 { color: var(--accent-dark); margin-top: 2rem; }

/* Sous-titres de catégorie des listes de lieux liés (« Villes », « Montagnes »…) */
.category-title {
  margin: 1.6rem 0 0.6rem;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--gold);
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.25rem;
}

a { color: var(--accent); }
a:hover { color: var(--accent-dark); }

.lead { font-size: 1.15rem; color: var(--muted); font-style: italic; }

/* Sections par plan d'existence (page Lieux) */
.plane-section { border-top: 3px double var(--gold); margin-top: 2.2rem; padding-top: 0.6rem; }
.plane-section:first-of-type { border-top: none; margin-top: 0; padding-top: 0; }

/* Fil d'Ariane */
.breadcrumb { font-size: 0.9rem; color: var(--muted); margin-bottom: 0.4rem; }
.breadcrumb a { color: var(--muted); }
.breadcrumb .sep { margin: 0 0.35rem; }

/* Cartes de lieux */
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 1.2rem; margin-top: 1.2rem; }

.place-card {
  background: var(--parchment);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  text-decoration: none;
  color: inherit;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
  display: flex;
  flex-direction: column;
}

.place-card:hover { transform: translateY(-3px); box-shadow: 0 6px 18px rgba(60, 45, 20, 0.15); }
.place-card img { width: 100%; height: 150px; object-fit: cover; display: block; }
.place-card .no-image { height: 90px; background: linear-gradient(135deg, #e8dcc0, #d9cdb4); display: flex; align-items: center; justify-content: center; font-size: 2rem; }
.place-card .body { padding: 0.9rem 1.1rem 1.1rem; }
.place-card h3 { margin: 0 0 0.3rem; color: var(--accent-dark); }
.place-card .type { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--gold); }
.place-card p { margin: 0.4rem 0 0; font-size: 0.92rem; color: var(--muted); }

/* Page de détail */
.place-cover { width: 100%; max-height: 380px; object-fit: cover; border-radius: 10px; border: 1px solid var(--border); }
.prose { max-width: 70ch; }
.prose img { max-width: 100%; border-radius: 8px; }
.prose blockquote { border-left: 3px solid var(--gold); margin-left: 0; padding-left: 1.2rem; color: var(--muted); font-style: italic; }

.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 0.9rem; margin-top: 1rem; }
.gallery figure { margin: 0; }
.gallery img { width: 100%; height: 140px; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); }
.gallery figcaption { font-size: 0.8rem; color: var(--muted); margin-top: 0.25rem; }
.gallery a { display: block; cursor: zoom-in; }
.gallery a:focus-visible img { outline: 2px solid var(--gold); outline-offset: 2px; }

/* Faits courts au bas d'une carte de liste (alphabet, diffusion, difficulté d'une langue). */
.place-card .card-facts {
  margin-top: 0.4rem;
  font-size: 0.8rem;
  color: var(--muted);
  font-variant: small-caps;
}

/* Rappel cultuel sous les champs de foi du créateur : une carte par divinité vénérée. */
#cc-faith-card { display: flex; flex-direction: column; gap: 0.6rem; margin: 0.6rem 0 0.9rem; }
#cc-faith-card[hidden] { display: none; }
.cc-faith {
  padding: 0.7rem 0.9rem;
  background: var(--parchment);
  border: 1px solid var(--border);
  border-left: 3px solid var(--gold);
  border-radius: 8px;
}

/* Les divinités retenues, en pastilles retirables. */
#cc-faith-chips { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-top: 0.4rem; }
#cc-faith-chips[hidden] { display: none; }
.cc-faith-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.2rem 0.55rem;
  font: inherit;
  font-size: 0.85rem;
  color: var(--accent-dark);
  background: var(--parchment);
  border: 1px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
}
.cc-faith-chip:hover, .cc-faith-chip:focus-visible { border-color: var(--gold); }
.cc-faith-chip span { color: var(--muted); font-size: 1rem; line-height: 1; }
.cc-faith-note { margin: 0; font-size: 0.85rem; color: var(--muted); font-style: italic; }
.cc-faith-title { margin: 0; font-weight: 600; color: var(--accent-dark); }
.cc-faith-religion {
  margin-left: 0.5rem;
  font-weight: 400;
  font-size: 0.8rem;
  color: var(--muted);
}
.cc-faith-summary { margin: 0.25rem 0 0.5rem; font-size: 0.9rem; color: var(--muted); }
.cc-faith-facts { display: grid; grid-template-columns: max-content 1fr; gap: 0.15rem 0.8rem; margin: 0; font-size: 0.88rem; }
.cc-faith-facts dt { color: var(--gold); font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.05em; }
.cc-faith-facts dd { margin: 0; }
.cc-faith-link { display: inline-block; margin-top: 0.5rem; font-size: 0.85rem; }

/* ---------- Année liturgique ---------- */

.year-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 1.5rem; align-items: start; }
.year-wheel { position: sticky; top: 5rem; }
.year-wheel svg { width: 100%; height: auto; }

.year-ring { fill: none; stroke: var(--border); stroke-width: 1; }
.year-period { stroke: var(--parchment); stroke-width: 2; transition: opacity 0.15s ease; }
/* Une saison, une teinte : le printemps clair, l''hiver froid. */
.year-season-verania { fill: #dfe6cf; }
.year-season-solea { fill: #f0e2c4; }
.year-season-aurelia { fill: #e8d6bd; }
.year-season-glacialis { fill: #dce3e8; }

.year-period-name {
  font-size: 11px;
  fill: var(--accent-dark);
  text-anchor: middle;
  dominant-baseline: middle;
  pointer-events: none;
}
.year-centre { font-size: 15px; fill: var(--accent-dark); text-anchor: middle; }
.year-centre-sub { font-size: 10px; fill: var(--muted); text-anchor: middle; }

.year-feast { stroke: #fff; stroke-width: 1.5; cursor: pointer; transition: r 0.12s ease, opacity 0.15s ease; }
.year-feast:hover, .year-feast.is-current { r: 10; }
.year-feast:focus-visible { outline: 2px solid var(--gold); }

/* Une couleur par religion, reprise par la liste : le point et la ligne se répondent. */
.religion-0 { fill: #7a5c3e; }
.religion-1 { fill: #b08d4f; }
.religion-2 { fill: #4a3826; }
.religion-3 { fill: #5d7a3e; }
li.religion-0 { border-left-color: #7a5c3e; }
li.religion-1 { border-left-color: #b08d4f; }
li.religion-2 { border-left-color: #4a3826; }
li.religion-3 { border-left-color: #5d7a3e; }

.is-dimmed { opacity: 0.15; }
li.is-dimmed { display: none; }

.feast-list { list-style: none; margin: 0 0 1.5rem; padding: 0; }
.feast-list .feast {
  border-left: 3px solid var(--border);
  padding: 0.45rem 0 0.45rem 0.7rem;
  margin-bottom: 0.5rem;
  background: transparent;
  transition: background 0.15s ease;
}
.feast-list .feast.is-current { background: var(--parchment); }
.feast-date {
  display: block;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--gold);
}
.feast-name { font-weight: 600; margin-right: 0.4rem; }
.feast-religion { font-size: 0.85rem; color: var(--muted); }
.feast-what { display: block; font-size: 0.9rem; color: var(--muted); margin-top: 0.15rem; }

.belief-filter button {
  font: inherit;
  padding: 0.3rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--parchment);
  font-size: 0.88rem;
  color: var(--ink);
  cursor: pointer;
}
.belief-filter button:hover { border-color: var(--gold); color: var(--accent-dark); }
.belief-filter button.current { background: var(--accent); border-color: var(--accent-dark); color: #fff; }

@media (max-width: 900px) {
  .year-layout { grid-template-columns: minmax(0, 1fr); }
  .year-wheel { position: static; max-width: 26rem; margin: 0 auto; }
}

/* ---------- Visionneuse ---------- */

/* La classe est posée par le script : sans lui, la couverture n'est qu'une image. */
.is-zoomable { cursor: zoom-in; }
.is-zoomable:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }

/* Le fond de page ne défile plus derrière la visionneuse. */
html.lb-open { overflow: hidden; }

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 2000; /* au-dessus de l'en-tête collant (1100) et de ses menus (1200) */
  display: grid;
  grid-template-columns: auto 1fr auto;
  grid-template-rows: auto 1fr auto;
  grid-template-areas:
    "bar bar bar"
    "prev stage next"
    "caption caption caption";
  gap: 0.4rem;
  padding: 0.6rem;
  background: rgba(20, 17, 13, 0.94);
  color: #f0e6cf;
}
.lightbox[hidden] { display: none; }

.lb-bar {
  grid-area: bar;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.lb-counter { font-size: 0.9rem; letter-spacing: 0.05em; color: #d8c9a8; }
.lb-tools { display: flex; gap: 0.4rem; }

.lb-btn {
  font: inherit;
  font-size: 1.1rem;
  line-height: 1;
  min-width: 2.4rem;
  padding: 0.45rem 0.6rem;
  color: #f0e6cf;
  background: rgba(240, 230, 207, 0.08);
  border: 1px solid rgba(240, 230, 207, 0.35);
  border-radius: 6px;
  cursor: pointer;
}
.lb-btn:hover { background: rgba(240, 230, 207, 0.18); border-color: var(--gold); }
.lb-btn:focus-visible, .lb-nav:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

.lb-stage {
  grid-area: stage;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  min-height: 0;
  touch-action: none; /* le doigt zoome et déplace : il ne fait pas défiler la page */
}

.lb-image {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 4px;
  cursor: zoom-in;
  transform-origin: center center;
  user-select: none;
  -webkit-user-drag: none;
}
.lightbox.is-zoomed .lb-image { cursor: grab; }

.lb-nav {
  font: inherit;
  font-size: 2.2rem;
  line-height: 1;
  padding: 0.4rem 0.7rem;
  color: #f0e6cf;
  background: rgba(20, 17, 13, 0.4);
  border: 1px solid rgba(240, 230, 207, 0.25);
  border-radius: 8px;
  cursor: pointer;
  align-self: center;
}
.lb-nav:hover { background: rgba(240, 230, 207, 0.15); border-color: var(--gold); }
.lb-prev { grid-area: prev; }
.lb-next { grid-area: next; }
.lb-nav[hidden] { display: none; }

.lb-caption {
  grid-area: caption;
  margin: 0;
  text-align: center;
  font-size: 0.92rem;
  color: #d8c9a8;
  max-width: 70ch;
  justify-self: center;
}
.lb-caption[hidden] { display: none; }

@media (max-width: 640px) {
  /* Les flèches mangeraient la largeur de l'image : au doigt, on balaie. */
  .lightbox {
    grid-template-columns: 1fr;
    grid-template-areas: "bar" "stage" "caption";
  }
  .lb-nav { display: none; }
  .lb-btn { min-width: 2.8rem; padding: 0.6rem 0.7rem; }
}

.event-list { list-style: none; padding: 0; }
.event-list li { padding: 0.5rem 0; border-bottom: 1px dashed var(--border); }
.event-list .date { color: var(--gold); font-weight: 600; margin-right: 0.6rem; white-space: nowrap; }

.map-link { display: inline-block; margin-top: 0.6rem; }

/* Carte plein écran */
#world-map { flex: 1; min-height: 0; background: #e8dcc0; }

/* Carte embarquée sur la page d'un lieu : hors layout plein écran, flex:1 donnerait
   une hauteur nulle — on lui fixe une hauteur et un cadre assorti aux vignettes. */
#world-map.place-map,
#place-outline.place-map {
  flex: none;
  height: min(70vh, 560px);
  border: 1px solid var(--border);
  border-radius: 8px;
}

/* La carte d'emprise est un repère, pas la pièce maîtresse de la page : plus basse. */
#place-outline.place-map { height: min(55vh, 420px); background: #e8dcc0; }

/* Sélecteur de plan au-dessus de la carte */
.map-switcher {
  display: flex;
  gap: 0.4rem;
  padding: 0.35rem 1rem;
  background: var(--parchment);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.map-switcher a, .map-switcher .current {
  padding: 0.2rem 0.9rem;
  border-radius: 999px;
  font-size: 0.9rem;
  text-decoration: none;
}
.map-switcher .current { background: var(--accent); color: #fff; }
.map-switcher a { color: var(--accent); border: 1px solid var(--border); }
.map-switcher a:hover { background: #efe9dc; }
.map-note { text-align: center; font-size: 0.85rem; color: var(--muted); padding: 0.4rem; }

.leaflet-popup-content .popup-cover {
  display: block;
  width: 100%;
  height: 110px;
  object-fit: cover;
  border-radius: 6px;
  margin: 0 0 0.45rem;
}
.leaflet-popup-content h3 { margin: 0 0 0.2rem; }
.leaflet-popup-content .type { font-size: 0.75rem; text-transform: uppercase; color: var(--gold); }

/* Popup retourné (ouvert sous le marqueur quand la place manque au-dessus) :
   la pointe passe au-dessus du contenu et pointe vers le haut. */
.leaflet-popup.popup-below .leaflet-popup-tip-container {
  top: -19px;
  bottom: auto;
  transform: rotate(180deg);
  margin-top: 0;
}

/* Chronologie */
.timeline-era {
  background: var(--parchment);
  border: 1px solid var(--border);
  outline: 1px solid var(--gold);
  outline-offset: -6px;
  padding: 1.4rem 1.8rem;
  margin-bottom: 1.6rem;
}
.timeline-era h2 { margin: 0; }
.timeline-era h2::after { display: none; }
.timeline-era .period { color: var(--muted); font-style: italic; }
.timeline-events { list-style: none; padding: 0; margin: 1rem 0 0; }
.timeline-events li { display: flex; gap: 1rem; padding: 0.55rem 0; border-top: 1px dotted var(--gold); }
.timeline-events .date { min-width: 100px; font-family: var(--font-display); font-size: 0.9rem; color: var(--accent); white-space: nowrap; }
.timeline-events .title { font-weight: 600; }
.timeline-events p { margin: 0.15rem 0 0; font-size: 0.98rem; color: var(--ink-soft); }

/* Pied de page : le colophon */
.site-footer {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  padding: 1.1rem 2rem;
  margin-top: 2rem;
  font-family: var(--font-display);
  font-size: 0.68rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--muted);
  background: var(--parchment);
  border-top: 1px solid var(--border);
  border-bottom: var(--double-rule);
}

/* Sous 900 px, la barre ne tient plus : le menu passe derrière un bouton et s'ouvre
   en panneau sous l'en-tête, chaque rubrique dépliée d'avance pour éviter un clic de plus. */
@media (max-width: 900px) {
  .nav-burger { display: inline-flex; }

  .site-nav {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    margin: 0;
    background: var(--parchment);
    border-top: 1px solid var(--border);
    border-bottom: var(--double-rule);
    box-shadow: 0 10px 24px rgba(44, 38, 32, 0.25);
    padding: 0.4rem 1.2rem 1rem;
    max-height: calc(100vh - 100%);
    max-height: calc(100dvh - 100%);
    overflow-y: auto;
    overscroll-behavior: contain;
    z-index: 1200;
  }
  .site-header.nav-open .site-nav { display: flex; }

  /* En panneau, l'intitulé de rubrique n'est plus un bouton mais un titre de chapitre. */
  .site-nav .nav-toggle {
    pointer-events: none;
    font-size: 0.68rem;
    letter-spacing: 0.25em;
    color: var(--gold);
    background: none;
    border: none;
    border-bottom: 1px solid var(--border);
    border-radius: 0;
    box-shadow: none;
    width: 100%;
    padding: 1rem 0 0.3rem;
    justify-content: flex-start;
  }
  .site-nav .nav-toggle.current { color: var(--accent-dark); }
  .site-nav .caret { display: none; }

  .nav-group { position: static; }

  .nav-menu {
    display: block;
    position: static;
    transform: none;
    min-width: 0;
    background: none;
    border: none;
    box-shadow: none;
    padding: 0;
  }

  .nav-menu a, .site-nav .nav-link {
    display: block;
    width: 100%;
    font-family: var(--font-body);
    font-size: 1.1rem;
    letter-spacing: 0;
    text-transform: none;
    color: var(--accent-dark);
    background: none;
    border: none;
    border-radius: 0;
    box-shadow: none;
    padding: 0.6rem 0.2rem;
    border-bottom: 1px dotted var(--border);
    margin: 0;
  }
  .nav-menu a:hover, .site-nav .nav-link:hover { background: var(--vellum); color: var(--ink); }
  .nav-menu a[aria-current="page"], .site-nav .nav-link.current {
    background: none;
    color: var(--accent-dark);
    font-weight: 700;
    box-shadow: inset 3px 0 0 var(--gold);
    padding-left: 0.6rem;
  }
  .site-nav .nav-link.nav-aside { margin-top: 0.9rem; font-family: var(--font-display); font-size: 0.8rem; letter-spacing: 0.1em; text-transform: uppercase; }
  .site-nav .nav-link.nav-aside + .nav-link.nav-aside { margin-top: 0; }
  .site-nav .nav-link.nav-creator { color: var(--accent-dark); }
}

@media (max-width: 640px) {
  .container { padding: 1.2rem 1rem; }
  .site-header { padding: 0.6rem 1rem; }
  .brand-name { font-size: 1.2rem; }
  .brand-tagline { display: none; }

  /* Sans son intitulé, le bouton se resserre autour des trois barres : on lui rend de la
     hauteur pour rester une cible confortable au doigt. */
  .burger-text { display: none; }
  .nav-burger { padding: 0.7rem 0.75rem; }
}

/* ---------- Races & bestiaire ---------- */

/* La même carte des deux côtés : une planche, un nom, deux lignes. Un peuple comme une bête se
   reconnaît d'abord à son image — c'est elle qui distingue deux lignes d'une liste. */
.race-card, .species-card {
  background: var(--parchment);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.race-card > a, .species-card > a { text-decoration: none; color: inherit; display: block; }
.race-card > a:hover h2, .species-card > a:hover h2 { color: var(--gold); }
.race-card img, .species-card img { width: 100%; height: 170px; object-fit: cover; display: block; }
.race-card .no-image, .species-card .no-image {
  height: 110px;
  background: linear-gradient(135deg, #e8dcc0, #d9cdb4);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.2rem;
}
.race-card .body, .species-card .body { padding: 0.9rem 1.1rem 1rem; }
.race-card h2, .species-card h2 { margin: 0.1rem 0 0.3rem; font-size: 1.25rem; color: var(--accent-dark); }
.race-card .type, .species-card .type { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--gold); }
.race-card p, .species-card p { margin: 0.4rem 0 0; font-size: 0.92rem; color: var(--muted); }
.sub-race-links {
  list-style: none;
  margin: 0;
  padding: 0.5rem 1.1rem 0.9rem;
  border-top: 1px dashed var(--border);
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem 0.9rem;
  font-size: 0.88rem;
}

/* Habitat et prix d'achat, sous la description : deux faits courts, pas une phrase. */
.species-card .card-facts {
  margin-top: 0.5rem;
  font-size: 0.8rem;
  color: var(--muted);
  font-variant: small-caps;
}

/* Ce que la bête fournit se lit sur sa carte, et chaque matière est une porte : ces liens
   restent donc hors du bloc cliquable qui mène à la fiche. */
.species-card .matter-links {
  padding: 0.5rem 1.1rem 0.9rem;
  border-top: 1px dashed var(--border);
}

.rank-badge {
  display: inline-block;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-style: normal;
  color: #fff;
  background: var(--accent);
  border-radius: 20px;
  padding: 0.12rem 0.6rem;
  vertical-align: 0.12em;
}
.race-summary { max-width: 70ch; }
.race-aliases { font-size: 0.9rem; color: var(--muted); margin-top: -0.4rem; }
.inherit-note {
  background: var(--parchment);
  border-left: 3px solid var(--gold);
  padding: 0.7rem 1rem;
  font-size: 0.92rem;
  max-width: 70ch;
}
.hint-inline { font-size: 0.9rem; color: var(--muted); margin: -0.5rem 0 0.6rem; }

/* Fiche de jeu */
.statblock {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.15rem 1.4rem;
  margin: 0.6rem 0 1.6rem;
  max-width: 46rem;
}
.statblock dt { font-weight: 600; color: var(--muted); }
.statblock dd { margin: 0; }
.statblock dt, .statblock dd { padding: 0.3rem 0; border-bottom: 1px dashed var(--border); }

.inherited {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 0.05rem 0.5rem;
  margin-left: 0.4rem;
  white-space: nowrap;
}

.bonus-list { list-style: none; padding: 0; margin: 0.4rem 0 1.6rem; max-width: 70ch; }
.bonus-list li { padding: 0.4rem 0; border-bottom: 1px dashed var(--border); }
.bonus-list .ability { font-weight: 700; color: var(--accent-dark); margin-right: 0.4rem; }
.bonus-list .value { color: var(--gold); font-weight: 700; margin-right: 0.6rem; }
.bonus-list .note { font-size: 0.88rem; color: var(--muted); }

/* Traits raciaux */
.trait-list { display: grid; gap: 0.9rem; margin: 0.6rem 0 1.8rem; }
.trait {
  background: var(--parchment);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.8rem 1.1rem;
}
.trait h3 { margin: 0 0 0.35rem; font-size: 1.05rem; color: var(--accent-dark); }
.trait p { margin: 0; }
.tag {
  display: inline-block;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 400;
  color: var(--muted);
  background: #efe7d5;
  border-radius: 4px;
  padding: 0.08rem 0.45rem;
  margin-left: 0.35rem;
  vertical-align: 0.1em;
}
.tag-level { background: #e6dcc0; color: var(--accent-dark); }
.tag-ability { background: var(--gold); color: #fff; }

/* Tableaux du lore */
.table-scroll { overflow-x: auto; margin: 0.6rem 0 1.8rem; }
.lore-table { border-collapse: collapse; min-width: 26rem; }
.lore-table th, .lore-table td {
  text-align: left;
  padding: 0.4rem 1rem 0.4rem 0;
  border-bottom: 1px dashed var(--border);
}
.lore-table th { color: var(--muted); font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.05em; }

.race-prose h3 { margin-top: 1.8rem; color: var(--accent-dark); }

/* Portrait de race : affiché en entier, jamais rogné — un visage coupé n'a aucun intérêt ici */
.race-portrait { margin: 1.2rem 0; text-align: center; }
.race-portrait img {
  max-height: 520px;
  max-width: 100%;
  width: auto;
  border-radius: 10px;
  border: 1px solid var(--border);
}

/* ---------- Classes ---------- */

.spell-list { max-width: 70ch; font-size: 0.95rem; }
.progression table { border-collapse: collapse; min-width: 34rem; font-size: 0.9rem; }
.progression th, .progression td {
  text-align: left;
  padding: 0.3rem 0.9rem 0.3rem 0;
  border-bottom: 1px dashed var(--border);
  vertical-align: top;
}
.progression th { color: var(--muted); font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.05em; }
.equipment-list { max-width: 70ch; padding-left: 1.2rem; }
.equipment-list li { padding: 0.25rem 0; }
.equipment-list .choice-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--gold);
  margin-right: 0.4rem;
}

/* ---------- Mémos joueur ---------- */

.memo-common-link { font-size: 0.95rem; }

.memo-picker {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 1rem;
  margin: 1.2rem 0 1.8rem;
  padding: 1.1rem 1.2rem;
  background: var(--parchment);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.memo-picker .field { display: flex; flex-direction: column; gap: 0.3rem; }
.memo-picker label {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--gold);
}
.memo-picker select {
  font: inherit;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.45rem 0.6rem;
  min-width: 14rem;
}
.memo-picker select:focus-visible { outline: 2px solid var(--gold); outline-offset: 1px; }
.btn-memo {
  font: inherit;
  cursor: pointer;
  color: #fff;
  background: var(--accent);
  border: 1px solid var(--accent-dark);
  border-radius: 6px;
  padding: 0.5rem 1.1rem;
}
.btn-memo:hover { background: var(--accent-dark); }

.memo-missing {
  margin: 1.4rem 0;
  padding: 1rem 1.3rem;
  background: var(--parchment);
  border: 1px solid var(--border);
  border-left: 4px solid var(--gold);
  border-radius: 8px;
}
.memo-missing h2 { margin: 0 0 0.4rem; font-size: 1.15rem; }
.memo-missing ul { margin: 0.4rem 0 0; padding-left: 1.2rem; }
.memo-missing li { padding: 0.2rem 0; }

.memo { margin-top: 1.6rem; }
.memo-title { color: var(--accent-dark); font-size: 1.6rem; margin: 0 0 0.4rem; }
.memo-intro { color: var(--muted); font-style: italic; max-width: 70ch; }
.memo-intro p { margin: 0.2rem 0; }

.memo-toc {
  margin: 1.2rem 0 2rem;
  padding: 0.9rem 1.2rem;
  background: var(--parchment);
  border: 1px solid var(--border);
  border-radius: 8px;
  max-width: 70ch;
}
.memo-toc ol { margin: 0; padding-left: 1.3rem; columns: 2; column-gap: 2rem; }
.memo-toc li { padding: 0.15rem 0; font-size: 0.92rem; break-inside: avoid; }

.memo-section { scroll-margin-top: 5rem; margin-bottom: 2rem; }
.memo-section h3 {
  color: var(--accent-dark);
  font-size: 1.2rem;
  margin: 0 0 0.5rem;
  padding-bottom: 0.3rem;
  border-bottom: 1px solid var(--border);
}
.memo-body table { border-collapse: collapse; width: 100%; font-size: 0.92rem; display: block; overflow-x: auto; }
.memo-body th, .memo-body td {
  text-align: left;
  padding: 0.35rem 0.9rem 0.35rem 0;
  border-bottom: 1px dashed var(--border);
  vertical-align: top;
}
.memo-body th { color: var(--muted); font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.05em; }
.memo-body h4 { color: var(--accent-dark); margin: 1.4rem 0 0.3rem; }
.memo-body blockquote {
  border-left: 3px solid var(--gold);
  margin-left: 0;
  padding: 0.2rem 0 0.2rem 1.2rem;
  color: var(--accent-dark);
  font-style: normal;
  font-weight: 600;
}

.memo-links { margin-top: 1.6rem; font-size: 0.92rem; color: var(--muted); }

@media (max-width: 640px) {
  .memo-picker select { min-width: 0; width: 100%; }
  .memo-picker .field { width: 100%; }
  .memo-toc ol { columns: 1; }
}

/* ---------- Objets ---------- */

.item-search { display: flex; align-items: baseline; gap: 0.6rem; flex-wrap: wrap; margin: 1rem 0; }
.item-search label { font-size: 0.85rem; color: var(--muted); }
.item-search input {
  flex: 1 1 16rem;
  max-width: 26rem;
  padding: 0.45rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--parchment);
  font: inherit;
  color: var(--ink);
}
.item-search input:focus-visible { outline: 2px solid var(--gold); outline-offset: 1px; }
.item-search-count { font-size: 0.85rem; color: var(--muted); }

.item-table td { vertical-align: top; }
.item-table .item-summary { display: block; font-size: 0.85rem; color: var(--muted); max-width: 46ch; }

/* Texte secondaire occupant une cellule entière — un habitat, une durée, une liste de sortants.
 * Il ne fallait surtout pas réemployer `.item-summary` pour cela : elle porte `display: block`,
 * ce qui sort la cellule de sa rangée. La cellule prend alors la hauteur de son seul contenu et
 * son filet de bas se dessine plus haut que celui de ses voisines — d'où des lignes en escalier
 * d'une colonne à l'autre. Ici, on ne touche qu'à la typographie.
 */
.item-table td.item-note { font-size: 0.85rem; color: var(--muted); }
.item-table .item-contents { display: block; font-size: 0.8rem; color: var(--gold); max-width: 46ch; }

/* Mots-clés d'une ligne : cliquables, ils pilotent le filtre. */
.item-keywords { display: flex; flex-wrap: wrap; gap: 0.25rem; margin-top: 0.3rem; }
.item-keyword {
  font: inherit;
  font-size: 0.72rem;
  line-height: 1.5;
  padding: 0.05rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--parchment);
  color: var(--muted);
  cursor: pointer;
}
.item-keyword:hover { border-color: var(--gold); color: var(--accent-dark); }
.item-keyword.current { background: var(--accent); border-color: var(--accent-dark); color: #fff; }
.item-keyword:focus-visible { outline: 2px solid var(--gold); outline-offset: 1px; }

.item-search select {
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--parchment);
  font: inherit;
  color: var(--ink);
  max-width: 18rem;
}
.item-search select:focus-visible { outline: 2px solid var(--gold); outline-offset: 1px; }
.item-table .item-category { white-space: nowrap; }
.item-table .item-number { white-space: nowrap; text-align: right; }
.item-table tr[hidden] { display: none; }

/* ---------- Sorts ---------- */

/* Concentration et rituel se lisent dans la colonne Durée : ce sont des contraintes de durée. */
.spell-flag {
  display: inline-block;
  margin-left: 0.25rem;
  padding: 0 0.35rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 0.7rem;
  color: var(--muted);
}

/* Les trois lettres du manuel : la glose se prend au survol, l'abréviation le signale. */
.spell-comps { white-space: nowrap; }
.spell-comp {
  text-decoration: none;
  border-bottom: 1px dotted var(--muted);
  cursor: help;
}
.spell-comp-sep { color: var(--muted); }

.spell-table td { white-space: normal; }
.spell-table .item-summary { max-width: 40ch; }

/* Qui peut lancer le sort, et les races qui l'accordent d'elles-mêmes. */
.spell-access {
  list-style: none;
  margin: 0.4rem 0 1.2rem;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}
.spell-access li {
  padding: 0.3rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--parchment);
  font-size: 0.88rem;
}
.spell-innate li { border-style: dashed; }
.spell-condition { display: block; font-size: 0.78rem; color: var(--muted); }

/* ---------- Croyances : religions et panthéon ---------- */

/* Les runes d'une religion sous son résumé : elles disent l'essentiel d'un coup d'œil. */
.belief-runes { display: flex; flex-wrap: wrap; gap: 0.3rem; margin-top: 0.6rem !important; }

.belief-counts {
  list-style: none;
  margin: 0;
  padding: 0.5rem 1.1rem 0.9rem;
  border-top: 1px dashed var(--border);
  display: flex;
  flex-wrap: wrap;
  gap: 0.2rem 1rem;
  font-size: 0.85rem;
  color: var(--muted);
}
.belief-counts strong { color: var(--accent-dark); }

/* Filtre du panthéon : des onglets discrets, pas un formulaire. */
.belief-filter {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 1rem 0 1.4rem;
}
.belief-filter a {
  padding: 0.3rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--parchment);
  font-size: 0.88rem;
  text-decoration: none;
  color: var(--ink);
}
.belief-filter a:hover { border-color: var(--gold); color: var(--accent-dark); }
.belief-filter a.current { background: var(--accent); border-color: var(--accent-dark); color: #fff; }

.belief-group-title { display: flex; align-items: baseline; gap: 0.6rem; }
.belief-group-title a { text-decoration: none; color: inherit; }
.belief-group-title a:hover { color: var(--gold); }
.belief-count {
  font-size: 0.78rem;
  font-weight: 400;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.05rem 0.5rem;
}

/* Rites groupés par type : un geste quotidien et une fête saisonnière ne se lisent pas pareil. */
.rite-list { display: grid; gap: 1rem; }
.rite-group {
  background: var(--parchment);
  border: 1px solid var(--border);
  border-left: 3px solid var(--gold);
  border-radius: 8px;
  padding: 0.8rem 1.1rem;
}
.rite-group h3 { margin: 0 0 0.5rem; font-size: 1rem; color: var(--accent-dark); }
.rite-icon { margin-right: 0.35rem; }
.rite-group ul { list-style: none; margin: 0; padding: 0; }
.rite-group li { padding: 0.35rem 0; border-top: 1px dashed var(--border); }
.rite-group li:first-child { border-top: none; }
.rite-name { font-weight: 600; margin-right: 0.4rem; }
.rite-group li p { margin: 0.2rem 0 0; font-size: 0.92rem; color: var(--muted); }

/* Attributs cultuels : un symbole, un interdit, une couleur — des lignes courtes. */
.attribute-list { list-style: none; margin: 0; padding: 0; }
.attribute-list li {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.5rem;
  padding: 0.45rem 0;
  border-bottom: 1px dashed var(--border);
}
.attribute-icon { width: 1.4rem; text-align: center; }
.attribute-kind {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--gold);
  min-width: 7rem;
}
.attribute-value { font-weight: 600; }
.attribute-note { color: var(--muted); font-size: 0.9rem; flex: 1 1 14rem; }

.belief-neighbours {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1.2rem;
  font-size: 0.92rem;
}
.belief-neighbours .neighbour-epithet { color: var(--muted); font-size: 0.82rem; margin-left: 0.3rem; }

@media (max-width: 640px) {
  .attribute-kind { min-width: 0; }
  .attribute-list li { gap: 0.3rem; }
}

/* ---------- Créateur de personnage ---------- */

/* La page a besoin de deux colonnes : le conteneur standard (900px) est trop étroit. */
.container-wide { max-width: 1560px; }

.cc-lead { margin-bottom: 1.2rem; }

.cc-layout {
  /* Hauteur à laquelle se collent les deux barres de tête — les boutons du formulaire et les
     onglets de la fiche. Une seule valeur pour les deux : elles doivent s'aligner, et l'en-tête
     du site mesure 66 px. */
  --cc-stick: 84px;

  display: grid;
  grid-template-columns: minmax(0, 440px) minmax(0, 1fr);
  gap: 1.6rem;
  align-items: start;
}

/* La fiche est dessinée à 830 px puis réduite par transform, qui ne change pas la place
   qu'elle occupe : sans min-width nul, la colonne prendrait ces 830 px et pousserait la
   page hors de l'écran. */
.cc-form, .cc-preview, .sheet-viewport { min-width: 0; }

/* --- Formulaire (colonne gauche) --- */

.cc-actions { display: flex; gap: 0.6rem; margin-bottom: 0.6rem; flex-wrap: wrap; }

/* Emporter son personnage : retour de l'action et lien de repli si la copie échoue */
.cc-share-note {
  font-size: 0.88rem;
  color: var(--muted);
  background: var(--parchment);
  border-left: 3px solid var(--gold);
  border-radius: 0 6px 6px 0;
  padding: 0.5rem 0.8rem;
  margin: 0 0 0.6rem;
}
.cc-share-note.error { border-left-color: #a5462f; color: #7d3323; }

.cc-link {
  font: inherit;
  font-size: 0.82rem;
  width: 100%;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.4rem 0.55rem;
  margin-bottom: 0.8rem;
}

.btn-ghost {
  font: inherit;
  cursor: pointer;
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.5rem 1rem;
}
.btn-ghost:hover { background: #efe9dc; }
.btn-small { font-size: 0.85rem; padding: 0.3rem 0.7rem; margin-top: 0.5rem; }

.cc-form details {
  background: var(--parchment);
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 0.9rem;
  padding: 0 1.1rem 0.2rem;
}
.cc-form details[open] { padding-bottom: 1rem; }
.cc-form summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--accent-dark);
  padding: 0.75rem 0;
}
.cc-form summary:hover { color: var(--gold); }

.cc-form .fields { display: grid; grid-template-columns: 1fr 1fr; gap: 0.7rem 0.9rem; }
.cc-form .field { display: flex; flex-direction: column; gap: 0.25rem; min-width: 0; }
.cc-form .field-wide { margin-top: 0.7rem; display: flex; flex-direction: column; gap: 0.25rem; }
.cc-form .fields .field-wide { grid-column: 1 / -1; margin-top: 0; }

.cc-form label {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--gold);
}

.cc-form input[type="text"],
.cc-form input[type="number"],
.cc-form input[type="file"],
.cc-form select,
.cc-form textarea {
  font: inherit;
  font-size: 0.95rem;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.4rem 0.55rem;
  width: 100%;
}
.cc-form textarea { resize: vertical; line-height: 1.45; }
.cc-form input:focus-visible,
.cc-form select:focus-visible,
.cc-form textarea:focus-visible { outline: 2px solid var(--gold); outline-offset: 1px; }
.cc-form input[type="checkbox"] { accent-color: var(--accent); width: 1.05rem; height: 1.05rem; }

.cc-form .field-check { justify-content: end; }
.cc-form .field-check label {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.95rem;
  text-transform: none;
  letter-spacing: normal;
  color: var(--ink);
}

.cc-abilities { grid-template-columns: repeat(3, 1fr); }
.field-ability { position: relative; }
.cc-mod {
  position: absolute;
  right: 0.4rem;
  top: 0;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--gold);
}
.cc-mod:empty::before { content: "—"; color: var(--border); font-weight: 400; }

/* Bonus racial affiché en indice à côté du nom de la caractéristique, dans le formulaire */
.cc-race-bonus {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--accent);
  vertical-align: super;
  letter-spacing: normal;
}

.cc-note { font-size: 0.9rem; color: var(--muted); margin: 0.7rem 0 0.2rem; }

/* ── Lanceur de dés ──────────────────────────────────────────────────────────
   La boîte vit hors du formulaire : elle ne peut donc pas hériter des styles de
   `.cc-form`, et redéclare ce dont elle a besoin. */
.cc-roll-open { margin: 0.6rem 0 0; }

.cc-roll {
  border: 1px solid var(--gold);
  border-radius: 8px;
  padding: 0;
  max-width: 34rem;
  width: calc(100% - 2rem);
  max-height: calc(100vh - 3rem);
  background: var(--parchment);
  color: var(--ink);
  box-shadow: 0 8px 28px rgba(44, 38, 32, 0.28);
}
.cc-roll::backdrop { background: rgba(44, 38, 32, 0.45); }
.cc-roll-box { padding: 1.1rem 1.3rem 1.2rem; }

.cc-roll-head { display: flex; align-items: start; justify-content: space-between; gap: 0.6rem; }
.cc-roll-head h2 { margin: 0 0 0.6rem; font-size: 1.15rem; }
.cc-roll-x {
  border: 0;
  background: none;
  cursor: pointer;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1;
  padding: 0.2rem 0.3rem;
}
.cc-roll-x:hover { color: var(--accent-dark); }

.cc-roll-modes { border: 1px solid var(--border); border-radius: 6px; padding: 0.4rem 0.8rem 0.7rem; margin: 0; }
.cc-roll-modes legend {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--gold);
  padding: 0 0.3rem;
}
.cc-roll-mode { display: flex; align-items: start; gap: 0.5rem; cursor: pointer; margin-top: 0.3rem; }
.cc-roll-mode input { accent-color: var(--accent); margin-top: 0.35rem; }
.cc-roll-mode strong { display: block; font-weight: 700; }
.cc-roll-mode small { color: var(--muted); font-size: 0.85rem; }

.cc-roll-count { display: flex; align-items: center; gap: 0.6rem; margin-top: 0.7rem; }
.cc-roll-count[hidden] { display: none; }
.cc-roll-count label { font-size: 0.85rem; color: var(--muted); }
.cc-roll input[type="number"], .cc-roll select {
  font-family: inherit;
  font-size: 0.95rem;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.3rem 0.4rem;
}
.cc-roll input[type="number"] { width: 5rem; }
.cc-roll input:focus-visible, .cc-roll select:focus-visible, .cc-roll button:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 1px;
}

.cc-roll-bar { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; margin: 0.9rem 0 0; }
.cc-roll-bar .btn-small { margin-top: 0; }

.cc-roll-result { margin-top: 0.9rem; }
.cc-roll-result[hidden], .cc-roll-assign[hidden], .cc-roll-note[hidden] { display: none; }
.cc-roll-line { display: flex; align-items: center; gap: 0.5rem; padding: 0.15rem 0; flex-wrap: wrap; }
.cc-roll-tag {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  min-width: 3.4rem;
}
.cc-roll-dice { display: flex; gap: 0.3rem; flex-wrap: wrap; }
.cc-die {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.75rem;
  height: 1.75rem;
  padding: 0 0.25rem;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: #fff;
  font-size: 0.9rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
/* Un dé retiré reste lisible mais barré : on doit pouvoir vérifier le lancer. */
.cc-die.out {
  text-decoration: line-through;
  text-decoration-thickness: 2px;
  text-decoration-color: var(--accent);
  color: var(--muted);
  background: transparent;
  font-weight: 400;
}
.cc-roll-sum { font-weight: 700; color: var(--gold); font-variant-numeric: tabular-nums; }
.cc-roll-kept { margin: 0.5rem 0 0; font-size: 0.9rem; color: var(--muted); }

.cc-roll-assign { margin-top: 1rem; border-top: 1px solid var(--border); padding-top: 0.6rem; }
.cc-roll-subtitle {
  margin: 0 0 0.4rem;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--gold);
}
.cc-roll-row { display: grid; grid-template-columns: 7.5rem 5rem 1fr; align-items: center; gap: 0.5rem; padding: 0.15rem 0; }
.cc-roll-ab { font-size: 0.92rem; }
.cc-roll-total { font-size: 0.9rem; font-weight: 700; color: var(--accent); font-variant-numeric: tabular-nums; }

.cc-roll-note { margin: 0.8rem 0 0; font-size: 0.85rem; color: var(--muted); }
.cc-roll-foot { display: flex; justify-content: end; gap: 0.6rem; margin-top: 1rem; flex-wrap: wrap; }

.cc-hint {
  font-size: 0.85rem;
  color: var(--muted);
  background: #efe9dc;
  border-radius: 6px;
  padding: 0.5rem 0.7rem;
  margin: 0.7rem 0 0.2rem;
}

.cc-checkgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.4rem 1rem; margin-top: 0.5rem; }
.cc-checkgrid h4 {
  margin: 0.4rem 0 0.25rem;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--gold);
  font-weight: 400;
}
.cc-checkgrid .check {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.92rem;
  text-transform: none;
  letter-spacing: normal;
  color: var(--ink);
  padding: 0.08rem 0;
}
.cc-checkgrid .check .ab { color: var(--muted); font-size: 0.8rem; }
.cc-inline-checks { display: inline-flex; gap: 0.5rem; padding: 0.2rem 0; }

/* Compétences : trois groupes qui se recomposent selon la race, la classe et l'historique */
.cc-skills { margin-top: 0.3rem; }
.cc-skill-group { margin-bottom: 0.8rem; }
.cc-group-title {
  margin: 0 0 0.25rem;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--gold);
}
.cc-group-note {
  text-transform: none;
  letter-spacing: normal;
  font-size: 0.82rem;
  color: var(--muted);
  font-style: italic;
}
.cc-group-note:not(:empty)::before { content: "— "; }
.cc-skill-list { display: grid; grid-template-columns: 1fr 1fr; gap: 0.05rem 1rem; }
.cc-skill-list .check {
  display: flex;
  align-items: baseline;
  gap: 0.35rem;
  font-size: 0.92rem;
  padding: 0.08rem 0;
  text-transform: none;
  letter-spacing: normal;
  color: var(--ink);
}
.cc-skill-list .check .ab { color: var(--muted); font-size: 0.8rem; }
.cc-skill-list .check .src {
  margin-left: auto;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--gold);
  white-space: nowrap;
}

/* Les compétences imposées tiennent sur une colonne : la source a la place de s'afficher. */
#skills-granted .cc-skill-list { grid-template-columns: 1fr; }

/* Dans « À choisir », la provenance est déjà donnée par la note du groupe. */
#skills-choice .check .src, #skills-other .check .src { display: none; }

/* Équipement de départ : un lot par bloc, options exclusives */
.cc-equip-group {
  border-left: 2px solid var(--border);
  padding: 0.15rem 0 0.15rem 0.7rem;
  margin-bottom: 0.5rem;
}
.cc-equip-group.fixed { border-left-style: dotted; }
.cc-equip-group .check {
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
  font-size: 0.92rem;
  padding: 0.1rem 0;
  text-transform: none;
  letter-spacing: normal;
  color: var(--ink);
  cursor: pointer;
}
.cc-equip-group input[type="radio"] { accent-color: var(--accent); }
.cc-equip-letter {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--gold);
  min-width: 0.8rem;
}
.cc-equip-fixed { margin: 0.1rem 0; font-size: 0.92rem; color: var(--muted); }

/* Choix ouverts : « deux armes de guerre », « un instrument de musique au choix ». */
.cc-picks { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-top: 0.35rem; }
.cc-picks[hidden] { display: none; }
.cc-picks select {
  max-width: 20rem;
  padding: 0.25rem 0.4rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  font: inherit;
  font-size: 0.85rem;
  color: var(--ink);
}
.cc-picks select:focus-visible { outline: 2px solid var(--gold); outline-offset: 1px; }

.cc-tool-choice { margin: 0.6rem 0; }
.cc-tool-choice .cc-tool-source { display: block; font-size: 0.85rem; color: var(--muted); }
#cc-tool-picks[hidden] { display: none; }

/* Objets reconnus dans un lot de départ : leur fiche en un clic, leurs chiffres sous les yeux. */
.cc-equip-items { display: flex; flex-wrap: wrap; gap: 0.3rem; margin-top: 0.25rem; }
.cc-item-chip {
  display: inline-flex;
  align-items: baseline;
  gap: 0.35rem;
  padding: 0.1rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--parchment);
  font-size: 0.78rem;
  line-height: 1.5;
  text-decoration: none;
  color: var(--ink);
}
.cc-item-chip:hover { border-color: var(--gold); background: #f3ecdd; }
.cc-item-chip strong { font-weight: 600; }
.cc-item-chip span { color: var(--muted); }
.cc-equip-fixed::before { content: "▪ "; color: var(--gold); }
.cc-skill-list .check.locked { cursor: not-allowed; }
.cc-skill-list .check.locked .name, .cc-skill-list .check.locked .ab { color: var(--muted); }
.cc-skill-list .check.is-granted .name { font-weight: 600; color: var(--ink); }
#skills-other .cc-skill-list .check .name { color: var(--muted); }

/* Une attaque par bloc. Sur téléphone les quatre champs se replient sur deux lignes : sans
   trait de séparation, on ne voit plus où finit une attaque et où commence la suivante. */
.cc-attack-row { display: grid; grid-template-columns: 1.8fr 1fr 1.4fr 1fr; gap: 0.4rem; }
.cc-attack-row + .cc-attack-row {
  margin-top: 0.5rem;
  padding-top: 0.5rem;
  border-top: 1px dashed var(--border);
}

.cc-coins { grid-template-columns: repeat(5, 1fr); margin-top: 0.7rem; }

.cc-spell-level { display: grid; grid-template-columns: 110px 1fr; gap: 0.6rem; align-items: end; margin-top: 0.6rem; }
.cc-spell-level .field-wide { margin-top: 0; }

/* Le choix des sorts : on coche dans le grimoire du monde, la ligne s'écrit dans le niveau. */
.cc-spell-picker { margin-top: 0.6rem; }
.cc-spell-tools { display: flex; align-items: flex-end; gap: 0.8rem; flex-wrap: wrap; }
.cc-spell-tools .field-wide { flex: 1 1 14rem; margin-top: 0; }
/* La case et sa glose. Les libellés du créateur sont en petites capitales dorées : la glose,
   elle, est une phrase — elle reprend la casse et la couleur du texte courant, et elle passe à
   la ligne plutôt que de sortir du cadre. */
.cc-check {
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
  flex-wrap: wrap;
  flex: 1 1 12rem;
  min-width: 0;
  padding-bottom: 0.5rem;
}
.cc-check input { flex: none; }
.cc-check-note {
  font-size: 0.85rem;
  color: var(--muted);
  text-transform: none;
  letter-spacing: normal;
}

.cc-spell-list {
  max-height: 22rem;
  overflow: auto;
  margin-top: 0.5rem;
  padding: 0.3rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--parchment);
}
.cc-spell-group h4 {
  margin: 0.7rem 0 0.25rem;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}
/* Chaque sort est un <label>, mais ce n'est pas un libellé de champ : c'est une entrée de
   catalogue. Elle reprend donc le texte courant, pas les petites capitales dorées du créateur. */
.cc-form .cc-spell {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0 0.45rem;
  align-items: baseline;
  padding: 0.15rem 0;
  cursor: pointer;
  text-transform: none;
  letter-spacing: normal;
  color: var(--ink);
}
.cc-spell:hover .cc-spell-name { color: var(--accent-dark); }
.cc-spell-name { font-size: 0.94rem; }
.cc-spell-meta { grid-column: 2; font-size: 0.78rem; color: var(--muted); }

/* Accordé par la race : coché, verrouillé, et sa source écrite — comme les compétences. */
.cc-spell.is-granted { cursor: default; }
.cc-spell.is-granted .cc-spell-name { font-weight: 600; }
.cc-spell-source { grid-column: 2; font-size: 0.78rem; color: var(--gold); }

.cc-subtitle {
  margin: 1rem 0 0.4rem;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--gold);
  font-weight: 400;
}

/* --- Aperçu (colonne droite) --- */

.cc-preview { position: sticky; top: var(--cc-stick, 84px); }

.sheet-tabs { display: flex; gap: 0.4rem; margin-bottom: 0.6rem; flex-wrap: wrap; }
.sheet-tab {
  font: inherit;
  font-size: 0.9rem;
  cursor: pointer;
  padding: 0.2rem 0.9rem;
  border-radius: 999px;
  color: var(--accent);
  background: transparent;
  border: 1px solid var(--border);
}
.sheet-tab:hover { background: #efe9dc; }
.sheet-tab.active { background: var(--accent); color: #fff; border-color: var(--accent-dark); }

.sheet-viewport { overflow: hidden; }
.sheet { width: 830px; }

/* Quand la fiche ne rentre plus même réduite (téléphone), son cadre se parcourt du doigt. */
.sheet-pannable .sheet-viewport {
  overflow-x: auto;
  overscroll-behavior-x: contain;
  -webkit-overflow-scrolling: touch;
}
.sheet-pannable .sheet-hint { display: block; }
.sheet-hint {
  display: none;
  font-size: 0.82rem;
  color: var(--muted);
  font-style: italic;
  margin: 0 0 0.4rem;
}

/* --- La fiche elle-même : parchemin crème, filets dorés, encadrés bruns --- */

.sheet-page {
  --sh-ink: #3a2f1f;
  --sh-border: #a98c58;
  --sh-line: #c8a24b;
  --sh-rule: #d9c491;
  --sh-fill: #eee1c4;
  --sh-card: #faf5e7;
  --sh-label: #8a734a;
  --sh-title: #5a4123;
  display: none;
  width: 830px;
  background: #f6efdc;
  border: 1px solid var(--sh-border);
  outline: 4px solid #f6efdc;
  box-shadow: 0 4px 18px rgba(60, 45, 20, 0.18);
  padding: 14px 18px 10px;
  color: var(--sh-ink);
  font-size: 12.5px;
  line-height: 1.35;
}
.sheet-page.active { display: block; }

/* Page écartée (le Grimoire d'un personnage sans sorts) : ni à l'écran, ni à l'impression. */
.sheet-page.page-off { display: none !important; }

.sh-label {
  font-size: 8.5px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--sh-label);
  display: block;
}

.sh-head { text-align: center; margin-bottom: 8px; }
.sh-title {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 22px;
  letter-spacing: 0.18em;
  color: var(--sh-title);
  font-weight: 700;
}
.sh-title::before, .sh-title::after { content: ""; flex: 1; border-top: 3px double var(--sh-line); }
.sh-sub { font-style: italic; font-size: 11px; color: var(--sh-label); }

.sh-identity {
  display: grid;
  grid-template-columns: 1.1fr 2.4fr;
  gap: 10px;
  border: 1px solid var(--sh-border);
  border-radius: 6px;
  background: var(--sh-card);
  padding: 8px 10px;
  margin-bottom: 10px;
}
.sh-namebox { display: flex; flex-direction: column; justify-content: center; }
.sh-name { font-size: 17px; min-height: 24px; border-bottom: 1px solid var(--sh-line); }
.sh-idgrid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.sh-idgrid-6 { grid-template-columns: repeat(6, 1fr); }
.sh-idgrid-2 { grid-template-columns: repeat(2, 1fr); }
.sh-field {
  background: var(--sh-fill);
  border: 1px solid var(--sh-border);
  border-radius: 4px;
  padding: 2px 6px 3px;
  min-height: 32px;
}
.sh-field > span:last-child { font-size: 11.5px; display: block; min-height: 14px; }

.sh-grid { display: grid; grid-template-columns: 300px 255px 1fr; gap: 10px; }
.sh-left-cols { display: grid; grid-template-columns: 92px 1fr; gap: 8px; }

.sh-abilities { display: flex; flex-direction: column; gap: 15px; }
.sh-ability {
  border: 1px solid var(--sh-border);
  border-radius: 6px;
  background: var(--sh-card);
  text-align: center;
  padding: 5px 3px 8px;
  position: relative;
}
.sh-ability .sh-label { font-size: 7.5px; }
.sh-score { display: block; font-size: 20px; min-height: 26px; }
.sh-oval {
  position: absolute;
  bottom: -10px;
  left: 50%;
  transform: translateX(-50%);
  min-width: 36px;
  min-height: 17px;
  border: 1px solid var(--sh-border);
  border-radius: 20px;
  background: var(--sh-fill);
  font-size: 12px;
  padding: 0 5px;
}

.sh-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--sh-border);
  border-radius: 14px;
  background: var(--sh-card);
  padding: 3px 8px;
  margin-bottom: 7px;
}
.sh-pillbox {
  min-width: 32px;
  min-height: 17px;
  border: 1px solid var(--sh-border);
  border-radius: 9px;
  background: var(--sh-fill);
  text-align: center;
  font-size: 11px;
}
.sh-pill .sh-label { display: inline; }

.sh-box {
  border: 1px solid var(--sh-border);
  border-radius: 6px;
  background: var(--sh-card);
  padding: 6px 8px;
  margin-bottom: 8px;
}
.sh-box h3 {
  margin: 0 0 5px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  text-align: center;
  color: var(--sh-title);
  border-bottom: 2px double var(--sh-line);
  padding-bottom: 3px;
}

.sh-checklist { list-style: none; margin: 0; padding: 0; font-size: 10.5px; }
.sh-checklist li {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 1.5px 0;
  border-bottom: 1px solid #e7dabb;
}
.sh-checklist li:last-child { border-bottom: none; }
.sh-dot { width: 9px; height: 9px; flex: none; border: 1px solid var(--sh-border); border-radius: 2px; background: #fff; }
.sh-dot.filled { background: var(--sh-ink); }
.sh-val { min-width: 24px; text-align: center; border-bottom: 1px solid var(--sh-line); font-size: 10.5px; }
.sh-ab { color: var(--sh-label); }

.sh-combat-top { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; margin-bottom: 8px; }
.sh-shield {
  border: 2px solid var(--sh-border);
  border-radius: 6px 6px 42% 42%;
  background: var(--sh-card);
  text-align: center;
  padding: 5px 3px 12px;
}
.sh-stat {
  border: 1px solid var(--sh-border);
  border-radius: 6px;
  background: var(--sh-card);
  text-align: center;
  padding: 5px 3px;
}
.sh-big { display: block; font-size: 19px; min-height: 25px; }

.sh-hp .sh-hp-line { display: flex; gap: 6px; align-items: baseline; border-bottom: 1px solid var(--sh-line); padding-bottom: 3px; }
.sh-hp .sh-hp-line .sh-label { display: inline; }
.sh-hp .sh-hp-line span:last-child { font-size: 12px; min-width: 30px; }
.sh-hp-current { text-align: center; padding-top: 3px; }
.sh-tempbox {
  display: block;
  border: 1px solid var(--sh-border);
  border-radius: 6px;
  background: #fffaec;
  min-height: 21px;
  padding: 1px 6px;
  font-size: 13px;
  text-align: center;
}
.sh-duo { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.sh-death { display: flex; align-items: center; justify-content: space-between; padding: 1.5px 0; }
.sh-death .sh-label { display: inline; }
[data-death] i {
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-left: 4px;
  border: 1px solid var(--sh-border);
  border-radius: 50%;
  background: #fff;
}
[data-death] i.filled { background: var(--sh-ink); }

.sh-attacks { width: 100%; border-collapse: collapse; font-size: 10.5px; margin-bottom: 5px; }
.sh-attacks th {
  font-size: 8px;
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--sh-label);
  text-align: left;
  border-bottom: 1px solid var(--sh-line);
  padding: 0 4px 1px 0;
}
.sh-attacks td { border-bottom: 1px solid #e7dabb; height: 16px; padding: 1px 4px 1px 0; }

/* Zones lignées : le texte coule sur des réglures dessinées en dégradé répété. */
.sh-ruled {
  --rh: 16px;
  background: repeating-linear-gradient(
    to bottom,
    transparent 0,
    transparent calc(var(--rh) - 1px),
    var(--sh-rule) calc(var(--rh) - 1px),
    var(--sh-rule) var(--rh)
  );
  line-height: var(--rh);
  font-size: 10.5px;
  white-space: pre-wrap;
  word-break: break-word;
  min-height: calc(var(--rh) * 4);
}
.sh-ruled-4 { min-height: calc(var(--rh) * 4); }
.sh-ruled-5 { min-height: calc(var(--rh) * 5); }
.sh-ruled-6 { min-height: calc(var(--rh) * 6); }
.sh-ruled-7 { min-height: calc(var(--rh) * 7); }
.sh-ruled-9 { min-height: calc(var(--rh) * 9); }
.sh-ruled-10 { min-height: calc(var(--rh) * 10); }
.sh-ruled-16 { min-height: calc(var(--rh) * 16); }

/* La colonne Capacités & traits s'étire sur toute la hauteur de la page. */
.sh-caps { display: flex; flex-direction: column; }
.sh-caps .sh-ruled-fill { flex: 1; min-height: calc(var(--rh) * 20); }

.sh-coins { display: flex; gap: 6px; justify-content: space-between; margin-top: 5px; }
.sh-coin {
  display: flex;
  align-items: center;
  gap: 4px;
  border: 1px solid var(--sh-border);
  border-radius: 10px;
  background: var(--sh-fill);
  padding: 1px 7px;
  font-size: 10px;
  min-width: 46px;
}
.sh-coin b { color: var(--sh-label); font-weight: 700; }
.sh-coin span { min-width: 18px; text-align: center; }

.sh-foot {
  display: flex;
  justify-content: space-between;
  margin-top: 10px;
  border-top: 2px solid var(--sh-line);
  padding-top: 4px;
  font-size: 8.5px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--sh-label);
}

/* Page II */
.sh-grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; align-items: start; }
.sh-appearance { display: grid; grid-template-columns: 125px 1fr; gap: 8px; }
.sh-appearance .sh-ruled-fill { min-height: 160px; }
.sh-portrait {
  position: relative;
  border: 1px solid var(--sh-border);
  border-radius: 4px;
  background: var(--sh-fill);
  min-height: 160px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.sh-portrait img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.sh-portrait-ph {
  font-size: 7.5px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--sh-label);
  text-align: center;
  padding: 6px;
}

/* Page III */
.sh-spellhead {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  border: 1px solid var(--sh-border);
  border-radius: 6px;
  background: var(--sh-card);
  padding: 8px 10px;
  margin-bottom: 10px;
}
.sh-spellhead .sh-field { background: transparent; border: none; border-bottom: 1px solid var(--sh-line); border-radius: 0; }
.sh-grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; align-items: start; }
.sh-spellbox {
  border: 1px solid var(--sh-border);
  border-radius: 8px;
  background: var(--sh-card);
  padding: 6px 8px;
  margin-bottom: 8px;
}
.sh-spellbox-head {
  display: flex;
  align-items: center;
  gap: 6px;
  border-bottom: 2px double var(--sh-line);
  padding-bottom: 3px;
  margin-bottom: 4px;
}
.sh-spellbox-head h3 {
  margin: 0;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--sh-title);
}
.sh-spellbox-head .sh-label { display: inline; }
.sh-lvl {
  width: 18px;
  height: 18px;
  flex: none;
  border: 1px solid var(--sh-border);
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  background: var(--sh-fill);
}
.sh-slot {
  margin-left: auto;
  min-width: 28px;
  min-height: 15px;
  border: 1px solid var(--sh-border);
  border-radius: 6px;
  background: var(--sh-fill);
  text-align: center;
  font-size: 11px;
}
.sh-spells {
  --rh: 16px;
  min-height: calc(var(--rh) * 7);
  background: repeating-linear-gradient(
    to bottom,
    transparent 0,
    transparent calc(var(--rh) - 1px),
    var(--sh-rule) calc(var(--rh) - 1px),
    var(--sh-rule) var(--rh)
  );
}
.sh-spell { display: flex; align-items: center; gap: 5px; line-height: 16px; font-size: 10.5px; }
.sh-square { width: 8px; height: 8px; flex: none; border: 1px solid var(--sh-border); background: #fff; }
.sh-square.filled { background: var(--sh-ink); }

/* --- Le grimoire : la page de détail des sorts choisis --- */

/* Elle porte à l'écran la géométrie exacte de la feuille imprimée. C'est ce qui permet au
   script de savoir, en mesurant, quand une fiche de sort déborde — et d'ouvrir une page. */
.sheet-page.sh-book {
  box-sizing: border-box;
  height: 1173px;
  padding: 28px;
  flex-direction: column;
}
.sheet-page.sh-book.active { display: flex; }

/* Mesure : la feuille est sortie du flux le temps du calcul, quel que soit l'onglet ouvert. */
.sheet.measuring .sheet-page.sh-book {
  display: flex !important;
  position: absolute;
  top: 0;
  left: 0;
  visibility: hidden;
  pointer-events: none;
}

/* Deux colonnes, comme un vrai grimoire. Une troisième colonne qui apparaît, c'est la page
   qui déborde : le script la détecte à la largeur, pas à la hauteur. */
.sh-book-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  column-count: 2;
  column-gap: 16px;
  column-rule: 1px solid var(--sh-rule);
}

.sh-spellcard {
  break-inside: avoid;
  margin-bottom: 9px;
  padding-bottom: 7px;
  border-bottom: 1px solid var(--sh-rule);
}
.sh-spellcard:last-child { border-bottom: none; }
.sh-spellcard header { display: flex; align-items: baseline; gap: 5px; }
.sh-spellcard h3 {
  margin: 0;
  font-size: 12px;
  font-weight: 700;
  color: var(--sh-title);
  flex: 1;
}
.sh-spellcard-level {
  font-size: 8px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--sh-label);
  white-space: nowrap;
}
.sh-spellcard-facts {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0 5px;
  margin: 2px 0 4px;
  font-size: 9px;
  line-height: 1.3;
}
.sh-spellcard-facts dt {
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--sh-label);
  font-size: 7.5px;
  align-self: center;
}
.sh-spellcard-facts dd { margin: 0; }
.sh-spellcard p { margin: 0 0 3px; font-size: 9.5px; line-height: 1.35; text-align: justify; }
.sh-spellcard ul { margin: 0 0 3px; padding-left: 12px; font-size: 9.5px; line-height: 1.35; }
.sh-spellcard-up { border-left: 2px solid var(--sh-line); padding-left: 5px; }
.sh-spellcard-up .sh-label { display: block; }

/* Page IV */
.sh-langhead, .sh-lang { display: grid; grid-template-columns: 1fr 34px 40px; align-items: center; }
.sh-langhead {
  font-size: 8px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--sh-label);
  border-bottom: 1px solid var(--sh-line);
  padding-bottom: 1px;
  margin-bottom: 2px;
}
.sh-langhead span { text-align: center; }
.sh-langhead span:first-child { text-align: left; }
.sh-langs {
  --rh: 17px;
  min-height: calc(var(--rh) * 8);
  background: repeating-linear-gradient(
    to bottom,
    transparent 0,
    transparent calc(var(--rh) - 1px),
    var(--sh-rule) calc(var(--rh) - 1px),
    var(--sh-rule) var(--rh)
  );
}
.sh-lang { line-height: 17px; font-size: 10.5px; }
.sh-lang .sh-square { margin: 0 auto; }

.sh-faith { display: flex; gap: 6px; align-items: baseline; border-bottom: 1px solid #e7dabb; padding: 2px 0; font-size: 10.5px; }
.sh-faith .sh-label { display: inline; min-width: 88px; }
.sh-faith span:last-child { flex: 1; min-height: 13px; }

.sh-tablehead, .sh-row3 { display: grid; grid-template-columns: 1.4fr 1fr 1fr; gap: 6px; }
.sh-tablehead {
  font-size: 8px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--sh-label);
  border-bottom: 1px solid var(--sh-line);
  padding-bottom: 1px;
  margin-bottom: 2px;
}
.sh-row3 span { border-bottom: 1px solid #e7dabb; min-height: 18px; font-size: 10.5px; line-height: 17px; }

/* Page V — encadré de l'équipement et de la richesse de départ */
.sh-start-box { margin-bottom: 10px; }
.sh-start-grid { display: grid; grid-template-columns: 3fr 1fr; gap: 10px; }
.sh-start-list { margin: 2px 0 0; padding-left: 14px; font-size: 9.5px; line-height: 1.5; }
.sh-start-list li { padding: 0; }
/* Détail des sources de pièces d'or, au-dessus du total */
.sh-purse-detail { list-style: none; margin: 2px 0 3px; padding: 0; font-size: 8.5px; line-height: 1.45; }
.sh-purse-detail li {
  display: flex;
  justify-content: space-between;
  gap: 6px;
  border-bottom: 1px dotted var(--sh-rule);
  padding: 1px 0;
}
.sh-purse-detail b { white-space: nowrap; }

.sh-start-purse {
  display: block;
  margin-top: 2px;
  border: 1px solid var(--sh-border);
  border-radius: 6px;
  background: var(--sh-fill);
  min-height: 19px;
  text-align: center;
  font-size: 12px;
  padding: 1px 6px;
}

/* Page V — annexe auto-générée */
.sh-annex { column-count: 2; column-gap: 16px; margin-bottom: 8px; }
.sh-annex-section { margin-bottom: 12px; }
.sh-annex-section h3 {
  margin: 0 0 5px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--sh-title);
  border-bottom: 2px double var(--sh-line);
  padding-bottom: 3px;
  column-span: none;
}
.sh-annex-entry { break-inside: avoid; margin-bottom: 7px; }
.sh-annex-entry h4 { margin: 0; font-size: 10.5px; color: var(--sh-title); }
.sh-annex-meta {
  font-weight: 400;
  font-size: 7.5px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--sh-label);
  margin-left: 5px;
}
.sh-annex-entry p { margin: 1px 0 0; font-size: 9.5px; line-height: 1.45; }
.sh-annex-empty { font-style: italic; color: var(--sh-label); font-size: 11px; column-span: all; }

/* --- Deux défilements indépendants : le formulaire à gauche, la fiche à droite ---
 *
 * Tous les blocs du formulaire ouverts en font une colonne de plusieurs milliers de pixels.
 * La page n'avait qu'un ascenseur, celui du formulaire, et la molette le servait où que soit le
 * pointeur : la fiche, collée sous l'en-tête, gardait son bas hors d'atteinte.
 *
 * La colonne de la fiche reçoit donc le sien. Le formulaire garde celui de la page — c'est lui
 * qui la fait défiler, et c'est très bien ainsi : le titre et le chapeau s'effacent au passage
 * et rendent leur hauteur à la fiche.
 */
@media (min-width: 1101px) {
  /* La colonne de la fiche défile chez elle. Elle reste collée sous l'en-tête et sa hauteur est
     bornée à celle de l'écran : au-delà, c'est son propre ascenseur qui sert, et non celui de
     la page. `overscroll-behavior` referme la porte — arrivé au bas de la fiche, la molette
     s'arrête là plutôt que d'emporter le formulaire avec elle. */
  .cc-preview {
    max-height: calc(100vh - 6rem);
    overflow-y: auto;
    overscroll-behavior-y: contain;
    /* L'ascenseur ne doit pas mordre sur le bord de la fiche. */
    padding-right: 0.5rem;
  }

  /* Les onglets restent atteignables pendant qu'on parcourt la fiche. */
  .cc-preview .sheet-tabs {
    position: sticky;
    top: 0;
    z-index: 1;
    background: var(--paper);
    padding-bottom: 0.4rem;
    margin-bottom: 0.2rem;
  }

  /* Symétriquement, les boutons restent en tête du formulaire : imprimer ou exporter ne doit pas
     demander de remonter deux mille pixels. Ils se collent à la même hauteur que les onglets,
     de sorte que les deux colonnes partagent une seule ligne de tête.
     Réservé au grand écran : sur un téléphone, ces six boutons se rangent sur trois rangées et
     mangeraient un bon quart de la hauteur utile — le formulaire y est déjà seul à l'écran, et
     on remonte d'un geste de pouce. */
  .cc-toolbar {
    position: sticky;
    top: var(--cc-stick);
    z-index: 2;
    background: var(--paper);
    padding-bottom: 0.6rem;
    /* Le contenu qui passe dessous s'estompe au lieu de se couper net sur le bord. */
    box-shadow: 0 6px 6px -6px rgba(44, 38, 32, 0.25);
  }
  .cc-toolbar .cc-actions { margin-bottom: 0; }
  .cc-toolbar .cc-share-note:not([hidden]),
  .cc-toolbar .cc-link:not([hidden]) { margin-top: 0.5rem; }
}

/* --- Responsive : sous 1100px, le formulaire passe au-dessus de l'aperçu --- */
@media (max-width: 1100px) {
  .cc-layout { grid-template-columns: minmax(0, 1fr); }
  .cc-preview { position: static; }
}

@media (max-width: 640px) {
  .cc-form .fields, .cc-abilities, .cc-checkgrid, .cc-skill-list { grid-template-columns: 1fr; }
  .cc-coins { grid-template-columns: repeat(4, 1fr); }
  .cc-attack-row { grid-template-columns: 1fr 1fr; }
  .cc-spell-level { grid-template-columns: 1fr; }
  .cc-actions .btn-memo, .cc-actions .btn-ghost { flex: 1; }
  .sheet-tabs { gap: 0.3rem; }
  .sheet-tab { font-size: 0.82rem; padding: 0.2rem 0.6rem; }
}

/* --- Impression : la fiche seule, les quatre pages à la suite --- */
/* --- Impression : chaque page de la fiche EST une page A4, sans marge --- */
@page { size: A4 portrait; margin: 0; }

@media print {
  .site-header, .site-footer, .cc-form, .cc-roll, .sheet-tabs, .cc-lead, h1 { display: none !important; }
  html, body { margin: 0; padding: 0; background: #fff; display: block; }
  .container, .container-wide { max-width: none; padding: 0; margin: 0; }

  /* L'ascenseur propre à la colonne de la fiche n'a pas de sens sur du papier : le laisser
     couperait la fiche à la hauteur de la fenêtre. */
  .cc-layout { display: block; }
  .cc-preview { position: static; max-height: none; overflow: visible; padding-right: 0; }
  .sheet-viewport { overflow: visible; height: auto !important; }
  .sheet { zoom: 1 !important; width: auto; }
  .sheet-hint { display: none !important; }

  /* La fiche est dessinée à 830 px de large ; le zoom la ramène à 210 mm (793,7 px) pour
     couvrir la feuille bord à bord. Le zoom agit sur la mise en page — contrairement à un
     transform — donc les sauts de page tombent juste. Hauteur : 297 mm au même facteur,
     à un pixel près pour qu'un arrondi n'ajoute pas de page blanche. */
  .sheet-page {
    display: flex !important;
    flex-direction: column;
    position: relative;
    box-sizing: border-box;
    zoom: 0.9562;
    width: 830px;
    height: 1173px;
    padding: 28px;
    margin: 0;
    background: #f6efdc;
    border: none;
    outline: none;
    box-shadow: none;
    overflow: hidden;
    page-break-after: always;
    break-after: page;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
  .sheet-page:last-child { page-break-after: auto; break-after: auto; }

  /* « Imprimer le grimoire » : les feuilles de sorts seules. Elles se ré-impriment souvent —
     un sort préparé change d'un jour à l'autre — quand le reste de la fiche ne bouge pas. */
  body.print-book .sheet-page:not(.sh-book) { display: none !important; }
  body.print-book .sh-book.book-last { page-break-after: auto; break-after: auto; }

  /* Le liseré du modèle, en retrait du bord pour survivre à la zone non imprimable. */
  .sheet-page::before {
    content: "";
    position: absolute;
    inset: 16px;
    border: 1px solid var(--sh-border);
    pointer-events: none;
  }

  /* Le corps de la fiche occupe toute la feuille et le pied de page reste en bas,
     comme sur le modèle : sans cela le bas de la page resterait blanc. */
  .sh-grid, .sh-grid2, .sh-grid3, .sh-annex, .sh-book-body { flex: 1 1 auto; }
  .sh-grid2, .sh-grid3 { align-items: stretch; }
  .sh-foot { margin-top: auto; }

  /* Dernier encadré de chaque colonne : ses réglures descendent jusqu'au bas de la feuille
     (Autres maîtrises, Équipement, Histoire du personnage, sorts…), ce qui remplit la page
     comme le modèle au lieu de laisser un blanc sous la dernière ligne. Les encadrés
     au-dessus gardent la hauteur calibrée du modèle. */
  .sh-left, .sh-mid, .sh-grid2 > div, .sh-grid3 > div { display: flex; flex-direction: column; }
  .sh-left > *:last-child,
  .sh-mid > *:last-child,
  .sh-grid2 > div > *:last-child,
  .sh-grid3 > div > *:last-child {
    flex: 1;
    display: flex;
    flex-direction: column;
    margin-bottom: 0;
  }
  .sh-left > *:last-child .sh-ruled,
  .sh-mid > *:last-child .sh-ruled,
  .sh-grid2 > div > *:last-child .sh-ruled { flex: 1; }

  /* Grimoire : la place restante se répartit entre tous les encadrés de sorts de la colonne,
     plutôt que de gonfler le dernier. */
  .sh-grid3 .sh-spellbox { flex: 1; display: flex; flex-direction: column; }
  .sh-grid3 .sh-spells { flex: 1; min-height: 0; }
}

/* ---------- La chaîne de la matière : ressources, matériaux, procédés, espèces ---------- */

/* Un bloc de reflets — « Utilisé dans », « Fournie par ». Des pastilles, pas un tableau : ce
   sont des portes vers d'autres pages, et elles se lisent d'un coup d'œil. */
.matter-lead { font-size: 0.9rem; color: var(--muted); margin: 0.2rem 0 0.6rem; }

.matter-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  list-style: none;
  padding: 0;
  margin: 0 0 1.2rem;
}
.matter-links li {
  display: inline-flex;
  align-items: baseline;
  gap: 0.35rem;
  padding: 0.2rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--parchment);
  font-size: 0.85rem;
}
.matter-links li:hover { border-color: var(--gold); }
.matter-links-inline { margin-bottom: 0; }

/* Les intrants d'un procédé, la composition d'un objet : une quantité, un nom, une nature. */
.matter-parts { list-style: none; padding: 0; margin: 0 0 1rem; }
.matter-parts li {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.35rem;
  padding: 0.25rem 0;
  border-bottom: 1px dashed var(--border);
}
.matter-parts li:last-child { border-bottom: 0; }

.matter-amount {
  min-width: 4.5rem;
  font-variant-numeric: tabular-nums;
  color: var(--accent-dark);
  font-weight: 600;
}
.matter-kind, .matter-detail { font-size: 0.78rem; color: var(--muted); }
.matter-detail::before { content: "· "; }

/* Une matière que le lore nomme sans qu'aucune page ne l'ait encore reçue. Elle reste lisible,
   elle n'est simplement pas cliquable — et le pointillé le dit sans l'écrire. */
.matter-orphan { border-bottom: 1px dotted var(--muted); color: var(--muted); }

.matter-tool { background: var(--parchment); color: var(--muted); border: 1px solid var(--border); }

/* La recette affichée sur la fiche d'un matériau : de quoi lire la composition sans partir. */
.matter-recipe {
  border: 1px solid var(--border);
  border-left: 3px solid var(--gold);
  border-radius: 8px;
  background: var(--parchment);
  padding: 0.8rem 1rem;
  margin-bottom: 1rem;
}
.matter-recipe h3 { margin: 0; font-size: 1.05rem; }
.matter-recipe h4 {
  margin: 0.8rem 0 0.3rem;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

/* Intrants et sortants côte à côte : c'est la forme même du procédé. */
.matter-flow { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; }
.matter-flow h2 { margin-top: 0; }

@media (max-width: 700px) {
  .matter-flow { grid-template-columns: 1fr; gap: 0.5rem; }
}

/* ---------- Créateur : la date de naissance sur la roue de l'année ---------- */

.cc-birth-field { display: flex; flex-direction: column; gap: 0.3rem; }

/* Le champ n'a pas de <label> à qui parler — la date se choisit au clic, pas au clavier — mais
   il doit se lire comme les autres intitulés de la colonne. */
.cc-birth-caption {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--gold);
}

/* Le repli montre la date choisie : c'est la seule chose qu'on veut voir une fois le choix fait.
   Les trois dernières déclarations défont ce que `.cc-form details` impose aux grands blocs du
   formulaire — cette boîte-ci est un champ, pas une section. */
.cc-birth {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--parchment);
}
.cc-form details.cc-birth,
.cc-form details.cc-birth[open] { margin-bottom: 0; padding: 0; }
.cc-birth > summary {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  flex-wrap: wrap;
  padding: 0.5rem 0.8rem;
  cursor: pointer;
  list-style: none;
}
.cc-birth > summary::-webkit-details-marker { display: none; }
.cc-birth > summary::before { content: "🗓"; }
.cc-birth[open] > summary { border-bottom: 1px solid var(--border); }
.cc-birth > summary:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

.cc-birth-value { color: var(--muted); font-style: italic; }
.cc-birth.is-set .cc-birth-value { color: var(--accent-dark); font-style: normal; font-weight: 600; }
.cc-birth-season { font-size: 0.8rem; color: var(--gold); }

/* La roue au-dessus, les cinquante jours en dessous. La colonne du formulaire fait quatre cent
   quarante pixels : côte à côte, la grille des jours n'aurait plus que quatre-vingts pixels et
   des cases de treize — illisibles et intouchables au doigt. */
.cc-birth-panel { padding: 0.9rem; }
.cc-birth-wheel { max-width: 15rem; margin: 0 auto 0.8rem; }
.cc-birth-wheel svg { width: 100%; height: auto; display: block; }

/* La période choisie s'enlève du reste de la roue : le contour, pas la couleur — les quatre
   teintes de saison portent déjà un sens et rien ne doit les brouiller. */
.cc-birth-sector { cursor: pointer; }
.cc-birth-sector:hover { opacity: 0.75; }
.cc-birth-sector.is-current { stroke: var(--accent-dark); stroke-width: 2.5; }
.cc-birth-sector:focus-visible { outline: 2px solid var(--gold); }

.cc-birth-marker { fill: var(--accent-dark); stroke: #fff; stroke-width: 2; }
.cc-birth-marker.is-hidden { display: none; }

.cc-birth-legend { margin: 0 0 0.4rem; font-size: 0.85rem; color: var(--muted); }
.cc-birth-of { color: var(--accent-dark); font-weight: 600; }

/* Cinquante jours, dix par rangée : la lecture d'une période entière tient en cinq lignes. */
.cc-birth-days { display: grid; grid-template-columns: repeat(10, 1fr); gap: 3px; }
.cc-birth-day {
  font: inherit;
  font-size: 0.78rem;
  padding: 0.3rem 0;
  border: 1px solid transparent;
  border-radius: 4px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.cc-birth-day:hover { border-color: var(--gold); color: var(--accent-dark); }
.cc-birth-day.is-current { background: var(--accent); border-color: var(--accent-dark); color: #fff; }
.cc-birth-day:focus-visible { outline: 2px solid var(--gold); outline-offset: 1px; }

/* Deux rangées jumelles — l'année, puis l'âge. Les intitulés partagent une largeur fixe pour
   que les deux champs s'alignent : ce sont les deux faces d'une même valeur, ils doivent se
   lire comme un couple et non comme deux réglages sans rapport. */
.cc-birth-year { display: flex; align-items: baseline; gap: 0.5rem; flex-wrap: wrap; margin-top: 0.6rem; }
.cc-birth-year > label { flex: 0 0 9.5rem; }
.cc-birth-year input {
  width: 6rem;
  padding: 0.35rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  font: inherit;
  color: var(--ink);
}
.cc-birth-year input:focus-visible { outline: 2px solid var(--gold); outline-offset: 1px; }
.cc-birth-age { font-size: 0.85rem; color: var(--gold); }

.cc-birth-feast {
  margin: 0.6rem 0 0;
  padding: 0.4rem 0.6rem;
  border-left: 3px solid var(--gold);
  background: #fff;
  font-size: 0.85rem;
}
.cc-birth-actions { margin-top: 0.6rem; }

/* La colonne de droite de la fiche porte deux rangées : mensurations, puis naissance. */
.sh-idstack { display: grid; gap: 6px; align-content: start; }

@media (max-width: 560px) {
  /* Au doigt, une case de jour doit rester atteignable : cinq rangées de dix deviennent dix de cinq. */
  .cc-birth-days { grid-template-columns: repeat(5, 1fr); }
}

/* ---------------------------------------------------------------------------
   Rattachements d'une page — ce que son bloc « Miroirs » vise.
   Une nature de lien par ligne, ses cibles à la suite : c'est ainsi que le
   corpus les écrit, et une fiche de personnage en porte jusqu'à neuf.
   --------------------------------------------------------------------------- */
.lore-links { list-style: none; margin: 0.6rem 0 1.8rem; padding: 0; display: grid; gap: 0.35rem; }

.lore-links li {
  display: grid;
  grid-template-columns: 10rem 1fr;
  gap: 0.6rem;
  align-items: baseline;
  padding: 0.3rem 0;
  border-bottom: 1px solid var(--border);
}

.lore-link-kind {
  color: var(--muted);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

@media (max-width: 560px) {
  /* Sur un écran étroit, la nature du lien passe au-dessus de ses cibles. */
  .lore-links li { grid-template-columns: 1fr; gap: 0.1rem; }
}

/* ---------- Feuille de statblock ---------- */

/* Une fiche de jeu se consulte en plein combat : ce qu'on y cherche — la CA, les PV, un DD —
   doit se trouver sans lire. Le corpus l'écrit en Markdown condensé, et l'import le conserve tel
   quel ; c'est donc ici que la feuille prend sa forme. Le rendu nomme ce qu'il reconnaît
   (data-sheet), et tout ce qui suit s'appuie sur ces noms. */
.statblock-sheet {
  max-width: none;
  background: var(--parchment);
  border: 1px solid var(--border);
  border-left: 4px solid var(--gold);
  border-radius: 8px;
  padding: 1rem 1.2rem 1.1rem;
  margin: 0.6rem 0 1.8rem;
  font-size: 0.95rem;
}

.statblock-sheet > *:first-child { margin-top: 0; }
.statblock-sheet > *:last-child { margin-bottom: 0; }

/* La ligne d'identité — « Bête de taille G, neutre mauvais · CA 14 · PV 37 » — ouvre la fiche
   et porte les trois chiffres qu'on regarde en premier. */
.statblock-sheet > p:first-child {
  margin: 0 0 0.9rem;
  padding-bottom: 0.7rem;
  border-bottom: 1px solid var(--border);
  color: var(--accent-dark);
  font-size: 1rem;
}

/* Les lignes de valeurs qui suivent (compétences, sens, immunités) ouvrent sur leur libellé :
   il devient une étiquette, et la valeur reste de la prose. */
.statblock-sheet p { margin: 0.45rem 0; }
.statblock-sheet p > strong:first-child {
  color: var(--accent);
  text-transform: uppercase;
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  margin-right: 0.15rem;
}
/* La ligne d'identité, elle, garde ses mises en gras telles quelles : ce sont des valeurs. */
.statblock-sheet > p:first-child > strong:first-child {
  text-transform: none;
  font-size: inherit;
  letter-spacing: normal;
  color: var(--accent-dark);
}

.statblock-sheet table { border-collapse: collapse; width: 100%; margin: 0.7rem 0; }
.statblock-sheet td, .statblock-sheet th { text-align: left; vertical-align: top; }

/* Les six caractéristiques : une seule ligne, six colonnes égales, lue d'un coup d'œil. */
.statblock-sheet table[data-sheet="abilities"] { margin: 0.9rem 0; }
.statblock-sheet table[data-sheet="abilities"] th {
  text-align: center;
  color: var(--gold);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 0.2rem 0.3rem;
  border-bottom: 1px solid var(--border);
}
.statblock-sheet table[data-sheet="abilities"] td {
  text-align: center;
  padding: 0.35rem 0.3rem;
  font-size: 1rem;
  color: var(--accent-dark);
  width: 16.66%;
}

/* Une table clé/valeur : le libellé devient une étiquette, la valeur garde le poids. */
.statblock-sheet table[data-sheet="fields"] td { padding: 0.3rem 0; border-bottom: 1px dashed var(--border); }
.statblock-sheet table[data-sheet="fields"] tr:last-child td { border-bottom: 0; }
.statblock-sheet table[data-sheet="fields"] td:first-child {
  width: 12rem;
  color: var(--accent);
  text-transform: uppercase;
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  padding-right: 1rem;
}

/* Aptitudes, attaques, traits : un tableau à colonnes, mais aéré. */
.statblock-sheet table[data-sheet="traits"] th {
  color: var(--muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 0.25rem 1rem 0.4rem 0;
  border-bottom: 1px solid var(--border);
}
.statblock-sheet table[data-sheet="traits"] td {
  padding: 0.45rem 1rem 0.45rem 0;
  border-bottom: 1px dashed var(--border);
}
.statblock-sheet table[data-sheet="traits"] tr:last-child td { border-bottom: 0; }
.statblock-sheet table[data-sheet="traits"] td:first-child { white-space: nowrap; }
.statblock-sheet table[data-sheet="traits"] td:first-child strong { color: var(--accent-dark); }

/* La pile : le recueil des espèces empile ses lignes dans un tableau sans colonnes. On lui rend
   sa nature — une suite de lignes, la rare seconde cellule (le FP) alignée à droite. */
.statblock-sheet table[data-sheet="lines"] td {
  padding: 0.4rem 0;
  border-bottom: 1px dashed var(--border);
}
.statblock-sheet table[data-sheet="lines"] tr:last-child td { border-bottom: 0; }
.statblock-sheet table[data-sheet="lines"] td:empty { display: none; }
.statblock-sheet table[data-sheet="lines"] td + td {
  text-align: right;
  white-space: nowrap;
  color: var(--accent-dark);
  padding-left: 1rem;
}
.statblock-sheet table[data-sheet="lines"] td:first-child > strong:first-child { color: var(--accent-dark); }

/* Les blocs d'une fiche répartie sur plusieurs tableaux (Statistiques, Attaques, Traits…). */
.statblock-sheet h4 {
  margin: 1.2rem 0 0.2rem;
  color: var(--gold);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
}
.statblock-sheet h4:first-child { margin-top: 0; }

@media (max-width: 560px) {
  /* Six colonnes tiennent encore sur un téléphone, à condition de serrer : « 15 (+2) » doit
     rester sur une ligne, sans quoi la ligne des caractéristiques perd ce qui la rend lisible. */
  .statblock-sheet { padding: 0.8rem 0.9rem; font-size: 0.92rem; }
  .statblock-sheet table[data-sheet="abilities"] th { font-size: 0.68rem; letter-spacing: 0.04em; }
  .statblock-sheet table[data-sheet="abilities"] td { font-size: 0.85rem; padding: 0.3rem 0.1rem; }
  .statblock-sheet table[data-sheet="fields"] td:first-child { width: 8rem; }
  .statblock-sheet table[data-sheet="traits"] td:first-child { white-space: normal; }
}

/* Les actions d'une fiche : une par ligne, la première mise en gras servant de nom de coup. */
.statblock-sheet ul {
  list-style: none;
  margin: 0.3rem 0 0.6rem;
  padding: 0;
}
.statblock-sheet li {
  position: relative;
  padding: 0.25rem 0 0.25rem 1.1rem;
  border-bottom: 1px dashed var(--border);
}
.statblock-sheet li:last-child { border-bottom: 0; }
.statblock-sheet li::before {
  content: "◆";
  position: absolute;
  left: 0;
  top: 0.25rem;
  color: var(--gold);
  font-size: 0.7rem;
}
.statblock-sheet li > strong:first-child { color: var(--accent-dark); }

/* ---------- Récits de campagne ---------- */

/* La page s'élargit (container-wide) pour dégager une marge de part et d'autre du texte : c'est
   là que les illustrations viennent se poser. La colonne de lecture, elle, ne bouge pas — un
   récit se lit à soixante-huit caractères par ligne, pas à cent quarante. */
.recit { max-width: 1080px; margin: 0 auto; container-type: inline-size; }
.recit-block, .recit-scene { max-width: 68ch; margin-left: auto; margin-right: auto; }

/* Hauteur sous laquelle se calent le sommaire et les ancres : celle de l'en-tête collant, qui
   change avec la largeur (recit-toc.js la mesure et la pose sur la page). */
.recit-page { --recit-stick: 118px; --recit-anchor: var(--recit-stick); }

.recit-cover { margin: 1.2rem 0 1.6rem; }
.recit-cover img {
  width: 100%;
  max-height: 420px;
  object-fit: cover;
  border-radius: 10px;
  border: 1px solid var(--border);
  display: block;
}

/* ---- Sommaire : toujours sous la main pendant la lecture ---- */

.recit-toc {
  background: var(--parchment);
  border: 1px solid var(--border);
  border-left: 4px solid var(--gold);
  border-radius: 8px;
  padding: 0.9rem 1.2rem;
  margin: 0 auto 1.6rem;
  max-width: 68ch;
}
.recit-toc h2 { margin: 0 0 0.4rem; font-size: 1rem; color: var(--accent-dark); }
.recit-toc h2::after { display: none; }
.recit-toc ol { margin: 0; padding-left: 1.3rem; }
.recit-toc li { padding: 0.2rem 0; }
.recit-toc ul { list-style: none; margin: 0.25rem 0 0.2rem; padding: 0 0 0 0.7rem; border-left: 1px solid var(--border); }
.recit-toc ul li { padding: 0.12rem 0; }
.recit-toc a { text-decoration: none; }
.recit-toc a:hover { text-decoration: underline; }
.recit-toc-scene { font-size: 0.9rem; color: var(--ink-soft); }
.recit-toc-date { color: var(--muted); font-size: 0.85rem; font-style: italic; margin-left: 0.4rem; }

/* Le passage en cours de lecture : le chapitre s'enlumine, la scène prend un filet d'or. */
.recit-toc .recit-toc-chapter.is-current {
  color: var(--accent-dark);
  font-weight: 600;
  background: linear-gradient(transparent 55%, rgba(176, 141, 79, 0.28) 55%);
}
.recit-toc li.is-current::marker { color: var(--gold); font-weight: 600; }
.recit-toc .recit-toc-scene.is-current { position: relative; color: var(--accent-dark); font-weight: 600; }
.recit-toc .recit-toc-scene.is-current::before {
  content: "";
  position: absolute;
  left: calc(-0.7rem - 2px);
  top: 0.1em;
  bottom: 0.1em;
  border-left: 3px solid var(--gold);
}

.recit-toc-toggle {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  width: 100%;
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  color: var(--accent-dark);
  cursor: pointer;
  text-align: left;
}
.recit-toc-toggle[hidden] { display: none; }
.recit-toc-label {
  font-family: var(--font-display);
  font-size: 0.85rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  flex: none;
}
.recit-toc-label::after { content: " ▾"; color: var(--gold); }
.recit-toc-toggle[aria-expanded="true"] .recit-toc-label::after { content: " ▴"; }
.recit-toc-now { font-style: italic; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }

/* Grand écran : le sommaire tient sa colonne et colle sous l'en-tête jusqu'à la dernière page.
   S'il est plus haut que l'écran, il défile pour son compte. */
@media (min-width: 1100px) {
  .recit-page.has-toc {
    display: grid;
    grid-template-columns: 15.5rem minmax(0, 1fr);
    gap: 2rem;
    align-items: start;
  }
  .recit-page.has-toc .recit { margin: 0; width: 100%; justify-self: center; }
  .recit-page.has-toc .recit-toc {
    position: sticky;
    top: calc(var(--recit-stick) + 1rem);
    max-height: calc(100vh - var(--recit-stick) - 2rem);
    overflow-y: auto;
    overscroll-behavior: contain;
    margin: 1rem 0 0;
    max-width: none;
    padding: 0.9rem 1rem;
    font-size: 0.95rem;
  }
  .recit-page.has-toc .recit-toc ol { padding-left: 1.1rem; }
  .recit-toc-toggle { display: none; }
  .recit-page.has-toc .recit-toc-date { display: block; margin: 0.05rem 0 0; font-size: 0.8rem; }
}

/* Petit écran (avec JavaScript) : le sommaire se replie en bandeau collé sous l'en-tête, qui
   nomme le chapitre en cours ; un toucher le déplie. Sans JavaScript, il reste une liste en
   tête de récit, comme avant. */
@media (max-width: 1099.98px) {
  .recit-toc.is-enhanced {
    position: sticky;
    top: var(--recit-stick);
    z-index: 900;
    margin: 0 0 1.2rem;
    max-width: none;
    padding: 0.55rem 1rem;
    border-radius: 0 0 8px 8px;
    box-shadow: 0 2px 8px rgba(44, 38, 32, 0.12);
  }
  .recit-toc.is-enhanced h2 { display: none; }
  .recit-toc.is-enhanced ol { display: none; }
  .recit-toc.is-enhanced.is-open ol {
    display: block;
    margin-top: 0.6rem;
    max-height: calc(100vh - var(--recit-stick) - 6rem);
    overflow-y: auto;
    overscroll-behavior: contain;
  }
  .recit-page { --recit-anchor: calc(var(--recit-stick) + 3rem); }
}

.recit-chapter { margin-top: 3rem; scroll-margin-top: calc(var(--recit-anchor) + 1rem); }
.recit-scene { scroll-margin-top: calc(var(--recit-anchor) + 1rem); }
.recit-chapter h2 {
  font-size: 1.6rem;
  color: var(--accent-dark);
  border-bottom: 2px solid var(--gold);
  padding-bottom: 0.3rem;
  margin-bottom: 0.3rem;
}
.recit-chapter-date { color: var(--muted); font-style: italic; margin: 0.2rem 0 0; }

/* « flow-root » plutôt qu'un vide-flotteur : une image posée en fin de scène ne doit pas
   déborder sur la scène suivante, et il n'y a rien à ajouter dans le HTML pour ça. */
.recit-scene { display: flow-root; margin-top: 2rem; }
.recit-scene h3 {
  font-size: 1.15rem;
  color: var(--accent);
  margin: 0 0 0.6rem;
  letter-spacing: 0.02em;
}

/* Chaque paragraphe est son propre bloc : c'est ce qui permet d'intercaler une image entre deux
   d'entre eux sans couper le fil du texte. Les marges du .prose feraient double emploi. */
.recit-para { max-width: none; }
.recit-para p { margin: 0 0 1rem; }

.recit-figure { margin: 0.4rem 0 1.2rem; }
.recit-figure a { display: block; cursor: zoom-in; }
.recit-figure img {
  width: 100%;
  display: block;
  border-radius: 8px;
  border: 1px solid var(--border);
  box-shadow: 0 2px 6px rgba(44, 38, 32, 0.12);
}
.recit-figure figcaption {
  font-size: 0.82rem;
  color: var(--muted);
  font-style: italic;
  margin-top: 0.35rem;
}
.recit-figure a:focus-visible img { outline: 2px solid var(--gold); outline-offset: 2px; }

/* Dans la marge : l'image sort de la colonne de texte de la largeur du dégagement, et le texte
   l'enveloppe sur le reste. Elle est dans la marge du récit, pas dans son fil. */
.recit-figure-left, .recit-figure-right { width: 300px; }
/* Le dégagement se mesure sur le récit (requête de conteneur) : à côté du sommaire, la marge
   est plus étroite, et l'image ne doit pas venir mordre sur lui. */
.recit-figure-right { float: right; margin-left: 1.6rem; margin-right: calc(-1 * clamp(0px, (100cqi - 68ch) / 2, 190px)); }
.recit-figure-left { float: left; margin-right: 1.6rem; margin-left: calc(-1 * clamp(0px, (100cqi - 68ch) / 2, 190px)); }
.recit-figure-wide { width: 100%; margin: 1.4rem 0 1.6rem; }

/* Plus de marge à prendre : l'image rentre dans la colonne, le texte l'enveloppe encore. */
@media (max-width: 1180px) {
  .recit-figure-left, .recit-figure-right { width: 42%; }
  .recit-figure-right { margin-right: 0; }
  .recit-figure-left { margin-left: 0; }
}

/* Sous 700 px, une image de marge prendrait la moitié d'une ligne de six mots : elle passe en
   pleine largeur, comme les autres. */
@media (max-width: 700px) {
  .recit-figure-left, .recit-figure-right {
    float: none;
    width: 100%;
    margin-left: 0;
    margin-right: 0;
  }
}

.recit-others { margin-top: 3rem; }

/* Le globe : la planisphère enroulée sur une sphère (page /globe, globe.js). Fond sombre pour
   que la carte ressorte ; les commandes et la lecture de case sont posées par-dessus. */
.map-switcher .map-switcher-globe { margin-left: auto; }
#world-globe { flex: 1; min-height: 0; }
.globe { position: relative; overflow: hidden; background: #101c22; color: #e9e1cc; user-select: none; -webkit-user-select: none; }
.globe .globe-canvas { display: block; width: 100%; height: 100%; touch-action: none; cursor: grab; }
.globe .globe-canvas:active { cursor: grabbing; }
.globe-help { position: absolute; right: 16px; top: 12px; margin: 0; text-align: right; font-style: italic; font-size: 0.85rem; color: rgba(233, 225, 204, 0.6); pointer-events: none; z-index: 2; }
.globe-controls { position: absolute; left: 16px; bottom: 14px; display: flex; flex-direction: column; gap: 8px; z-index: 2; }
.globe-row { display: flex; gap: 6px; flex-wrap: wrap; }
.globe-controls button {
  font: inherit; font-size: 0.9rem; color: #e9e1cc; background: rgba(16, 28, 34, 0.72);
  border: 1px solid rgba(233, 225, 204, 0.18); border-radius: 6px; padding: 5px 12px; cursor: pointer;
  backdrop-filter: blur(6px); transition: border-color 0.15s, background 0.15s;
}
.globe-controls button:hover { border-color: #d9a441; background: rgba(28, 48, 55, 0.85); }
.globe-controls button:focus-visible { outline: 2px solid #d9a441; outline-offset: 2px; }
.globe-controls button[aria-pressed="true"] { border-color: #d9a441; color: #d9a441; }
.globe-readout { position: absolute; right: 16px; bottom: 14px; text-align: right; pointer-events: none; z-index: 2; }
.globe-cell { font-size: 2.6rem; font-weight: 600; letter-spacing: 0.04em; color: #d9a441; line-height: 1; min-height: 2.6rem; }
.globe-sub { margin-top: 4px; font-style: italic; font-size: 0.85rem; color: rgba(233, 225, 204, 0.6); }

/* Les marqueurs : des épingles HTML projetées chaque image, les mêmes icônes que sur la planisphère. */
.globe-pins { position: absolute; inset: 0; pointer-events: none; overflow: hidden; z-index: 1; }
/* Pas de filtre ni de transition sur une épingle : déplacée à chaque image, un filtre CSS la
   fait re-rastériser et clignoter pendant une glissade ; une ombre de texte suffit. */
.globe-pin {
  position: absolute; left: 0; top: 0; margin: -22px 0 0 -12px; width: 24px; height: 24px; padding: 0;
  border: 0; background: none; font-size: 22px; line-height: 1; pointer-events: auto; cursor: pointer;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6); will-change: transform; backface-visibility: hidden;
}
.globe-pin:hover, .globe-pin:focus-visible { text-shadow: 0 0 6px #d9a441, 0 0 2px #d9a441; outline: none; }
.globe-pin-static, .globe.dragging .globe-pin { pointer-events: none; }

/* Le popup d'un lieu : même contenu que sur la planisphère, dans une bulle claire qui suit son épingle. */
.globe-popup {
  position: absolute; left: 0; top: 0; z-index: 3; width: min(300px, calc(100% - 16px));
  background: var(--parchment); color: var(--ink); border: 1px solid var(--border); border-radius: 10px;
  padding: 0.8rem 0.9rem; box-shadow: 0 6px 24px rgba(0, 0, 0, 0.45); font-size: 0.95rem; line-height: 1.45;
}
.globe-popup .popup-cover { display: block; width: 100%; height: 110px; object-fit: cover; border-radius: 6px; margin: 0 0 0.45rem; }
.globe-popup h3 { margin: 0 1.4rem 0.2rem 0; font-size: 1.1rem; }
.globe-popup .type { font-size: 0.75rem; text-transform: uppercase; color: var(--gold); }
.globe-popup p { margin: 0.4rem 0; }
.globe-popup a { color: var(--accent); font-weight: 600; }
.globe-popup-close {
  position: absolute; right: 6px; top: 4px; border: 0; background: none; font-size: 1.3rem; line-height: 1;
  color: var(--muted); cursor: pointer; padding: 2px 6px;
}
.globe-popup-close:hover { color: var(--ink); }

/* Superficies d'une emprise, sous sa carte : deux mesures, planisphère et globe. */
.place-areas { text-align: center; font-size: 0.9rem; color: var(--muted); margin: -0.2rem 0 0.8rem; }
.place-areas strong { color: var(--ink); }
.place-areas .sep { margin: 0 0.5rem; }

@media (max-width: 640px) {
  .globe-help { display: none; }
  .globe-cell { font-size: 1.8rem; min-height: 1.8rem; }
  .globe-controls button { font-size: 0.8rem; padding: 4px 9px; }
}

/* =========================================================================
   Thème « Grimoire enluminé » — ce que toutes les pages partagent
   Posé en fin de feuille : ces règles prennent le pas sur les mises en page
   de chaque rubrique sans les réécrire.
   ========================================================================= */

/* --- Titres : capitales gravées, filet doré à la suite --- */
h1, h2, h3, h4 { font-family: var(--font-display); font-weight: 700; color: var(--accent-dark); }
h1 { font-size: 2.3rem; line-height: 1.1; letter-spacing: 0.02em; margin: 0.2rem 0 1rem; }
h2 {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  font-size: 1.25rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin: 2.2rem 0 0.9rem;
}
h2::after { content: ""; flex: 1; border-top: 1px solid var(--gold); min-width: 1.5rem; }
h3 { font-size: 1.08rem; letter-spacing: 0.02em; }

/* Les titres d'une carte, d'un encart ou d'une colonne ne tirent pas de filet. */
.place-card h3::after, .panel h2::after, .sheet-page h2::after, .sh-box h2::after,
.cc-form h2::after, .cc-sheet h2::after, .recit-block h2::after, .memo h2::after { display: none; }

/* --- Prose : la lettrine ouvre le premier paragraphe --- */
.lead { font-size: 1.22rem; color: var(--ink-soft); font-style: italic; }

/* La lettrine ne se pose que là où on la demande : le corps importé ouvre souvent sur une
   épithète en italique, qu'une lettrine rendrait illisible. */
.lettrine::first-letter {
  float: left;
  font-family: var(--font-ornate);
  font-style: normal;
  font-size: 3.6em;
  line-height: 0.8;
  padding: 0.14em 0.18em 0.08em 0.14em;
  margin: 0.08em 0.22em 0 0;
  color: var(--accent);
  background: var(--parchment);
  border: 2px solid var(--gold);
  outline: 1px solid var(--gold);
  outline-offset: 3px;
}

.prose { max-width: 72ch; }
.prose h3 { margin-top: 1.8rem; }
.prose blockquote { border-left: 2px solid var(--gold); margin-left: 0; padding-left: 1.2rem; color: var(--ink-soft); font-style: italic; }

/* --- Fil d'Ariane et sous-titres de catégorie --- */
.breadcrumb {
  font-family: var(--font-display);
  font-size: 0.68rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.6rem;
}
.breadcrumb a { color: var(--muted); text-decoration: none; }
.breadcrumb a:hover { color: var(--accent-dark); }
.breadcrumb .sep { margin: 0 0.45rem; color: var(--gold); }

.category-title {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 0.72rem;
  letter-spacing: 0.25em;
  color: var(--accent);
  border-bottom: 1px solid var(--gold);
}

a { color: var(--accent); text-decoration-color: var(--gold); text-underline-offset: 0.15em; }
a:hover { color: var(--accent-dark); }

/* --- Cartes : des encarts enluminés, cadre et liseré doré --- */
.card-grid { gap: 1.3rem; }

.place-card {
  border-radius: 0;
  border: 1px solid var(--border);
  outline: 1px solid var(--gold);
  outline-offset: -6px;
  background: var(--parchment);
  transition: outline-color 0.12s ease, box-shadow 0.12s ease;
}
.place-card:hover { transform: none; outline-color: var(--accent); box-shadow: 0 6px 18px rgba(60, 45, 20, 0.14); }
.place-card img { height: 160px; }
.place-card .no-image {
  height: 96px;
  background: repeating-linear-gradient(135deg, #eee4cf 0 6px, var(--paper) 6px 12px);
  border-bottom: 1px solid var(--border);
  color: var(--accent);
  font-size: 1.9rem;
}
.place-card .body { padding: 1rem 1.2rem 1.2rem; }
.place-card h3 { margin: 0 0 0.3rem; font-size: 1.12rem; }
.place-card .type {
  font-family: var(--font-display);
  font-size: 0.64rem;
  letter-spacing: 0.25em;
  color: var(--gold);
}
.place-card p { font-size: 1rem; color: var(--ink-soft); }
.place-card .card-facts { font-family: var(--font-display); font-variant: normal; font-size: 0.66rem; letter-spacing: 0.12em; text-transform: uppercase; }

/* --- Accueil : le prologue et ses chapitres --- */
.home-prologue {
  display: flex;
  gap: 2.4rem;
  flex-wrap: wrap;
  align-items: stretch;
  padding: 2.4rem 2.5rem;
  background: var(--parchment);
  border: 1px solid var(--border);
  outline: 1px solid var(--gold);
  outline-offset: -6px;
}
.home-prologue .text { flex: 1 1 26rem; min-width: 0; }
.home-prologue .kicker {
  margin: 0 0 0.4rem;
  font-family: var(--font-display);
  font-size: 0.7rem;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--gold);
}
.home-prologue h1 { margin: 0 0 1.2rem; }
.home-prologue p { margin: 0; font-size: 1.18rem; }
.home-prologue .epigraph { margin-top: 1.3rem; font-style: italic; color: var(--muted); }
.home-prologue .actions { display: flex; gap: 0.8rem; flex-wrap: wrap; margin-top: 1.6rem; }
.home-prologue .figure {
  flex: 0 1 19rem;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.6rem;
  background: repeating-linear-gradient(135deg, #eee4cf 0 6px, var(--paper) 6px 12px);
  border: 1px solid var(--border);
}
.home-prologue .figure img {
  display: block;
  width: 100%;
  height: auto;
  max-height: 27rem;
  object-fit: cover;
  border: 1px solid var(--accent-dark);
  box-shadow: 0 6px 18px rgba(44, 38, 32, 0.3);
}

.chapter-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 1.3rem; margin-top: 1.6rem; }
.chapter {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  padding: 1.6rem 1.4rem 1.3rem;
  background: var(--parchment);
  border: 1px solid var(--border);
  outline: 1px solid var(--gold);
  outline-offset: -6px;
  color: var(--ink);
  text-decoration: none;
  transition: outline-color 0.12s ease;
}
.chapter:hover { outline-color: var(--accent); color: var(--ink); }
.chapter .num { font-family: var(--font-display); font-size: 0.72rem; letter-spacing: 0.3em; color: var(--gold); }
.chapter h3 { margin: 0; font-size: 1.2rem; }
.chapter p { margin: 0; color: var(--ink-soft); font-size: 1rem; }

.continent-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 1.3rem; }
.continent {
  display: flex;
  gap: 1rem;
  padding: 1.1rem;
  background: var(--parchment);
  border: 1px solid var(--border);
  color: var(--ink);
  text-decoration: none;
  transition: border-color 0.12s ease;
}
.continent:hover { border-color: var(--gold); color: var(--ink); }
.continent .initial {
  flex: none;
  width: 64px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-ornate);
  font-size: 2.4rem;
  line-height: 1;
  color: var(--accent);
  background: var(--paper);
  border: 1px solid var(--gold);
  overflow: hidden;
}
.continent .initial img { width: 100%; height: 100%; object-fit: cover; }
.continent h3 { margin: 0 0 0.25rem; font-size: 1.15rem; }
.continent p { margin: 0; font-size: 1rem; color: var(--ink-soft); }
.continent .type { display: block; font-family: var(--font-display); font-size: 0.62rem; letter-spacing: 0.25em; text-transform: uppercase; color: var(--gold); margin-bottom: 0.2rem; }

/* --- Boutons, pastilles, étiquettes --- */
.btn-scroll,
.map-link,
.btn-ghost {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-family: var(--font-display);
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 0.7rem 1.1rem;
  color: var(--accent-dark);
  background: var(--parchment);
  border: 1px solid var(--gold);
  text-decoration: none;
  cursor: pointer;
}
.btn-scroll:hover, .map-link:hover, .btn-ghost:hover { background: var(--accent-dark); color: #f0e6cf; }
.btn-scroll.primary { background: var(--accent-dark); color: #f0e6cf; border-color: var(--accent-dark); }
.btn-scroll.primary:hover { background: var(--accent); border-color: var(--accent); }
.map-link + .map-link { margin-left: 0.5rem; }

.rank-badge,
.tag,
.item-category,
.belief-count {
  font-family: var(--font-display);
  font-size: 0.64rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent);
  background: var(--paper);
  border: 1px solid var(--gold);
  border-radius: 0;
  padding: 0.2rem 0.6rem;
}

/* --- Tableaux du lore : en-têtes gravés, lignes pointillées --- */
.lore-table th, .item-table th {
  font-family: var(--font-display);
  font-size: 0.68rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent-dark);
  border-bottom: 2px solid var(--gold);
}
.lore-table td, .item-table td { border-bottom: 1px dotted var(--gold); }

/* --- Encarts de section (plans d'existence, chapitres de liste) --- */
.plane-section { border-top: var(--double-rule); }

/* --- Formulaires ordinaires : champs sur parchemin --- */
input[type="text"], input[type="search"]:not(.search-input), select, textarea {
  font-family: var(--font-body);
}

/* Le filet double sous l'en-tête collant mesure désormais deux lignes : les colonnes qui se
   calent sous lui (créateur de personnage) prennent la nouvelle hauteur. */
.cc-layout { --cc-stick: 118px; }

/* --- Fiche de lieu : en-tête, deux colonnes, fiche de runes dans la marge --- */
.fiche { max-width: 1180px; margin: 0 auto; }

.fiche-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1.5rem; flex-wrap: wrap; margin-top: 0.4rem; }
.fiche-head h1 { margin: 0.6rem 0 0.1rem; font-size: 2.8rem; }
.fiche-epithet { margin: 0; font-style: italic; font-size: 1.35rem; color: var(--accent); }
.fiche-actions { display: flex; gap: 0.6rem; flex-wrap: wrap; padding-bottom: 0.4rem; }
.fiche-actions .map-link { margin: 0; }

.fiche-rule { border: 0; border-top: 1px solid var(--gold); border-bottom: 1px solid var(--gold); height: 3px; margin: 1rem 0 1.8rem; }

.fiche-layout { display: flex; gap: 2.4rem; flex-wrap: wrap; align-items: flex-start; }
.fiche-main { flex: 999 1 32rem; min-width: 0; }
.fiche-main > h2:first-child { margin-top: 0; }
.fiche-aside { flex: 1 1 20rem; max-width: 24rem; display: flex; flex-direction: column; gap: 1.3rem; }

.fiche-main .lead { margin: 0 0 1.2rem; font-size: 1.22rem; }
.fiche-cover { margin: 0 0 1.4rem; }
.fiche-cover img { border-radius: 0; border: 1px solid var(--border); outline: 1px solid var(--gold); outline-offset: -6px; }
.fiche-main .prose { max-width: none; }
.fiche-main .prose h3 { display: flex; align-items: center; gap: 0.8rem; font-size: 0.98rem; letter-spacing: 0.1em; text-transform: uppercase; margin: 2rem 0 0.7rem; }
.fiche-main .prose h3::after { content: ""; flex: 1; border-top: 1px solid var(--gold); }

.fiche-panel {
  background: var(--parchment);
  border: 1px solid var(--border);
  outline: 1px solid var(--gold);
  outline-offset: -6px;
  padding: 1.4rem 1.4rem 1.2rem;
}
.fiche-panel h3 {
  margin: 0 0 0.8rem;
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  color: var(--gold);
}
.fiche-panel-map { padding: 0.9rem; }
.fiche-panel-map h3 { margin: 0.3rem 0.5rem 0.8rem; }
.fiche-panel-map #place-outline.place-map { height: 230px; margin: 0; border: 1px solid var(--border); }
.fiche-panel-map .map-note { padding: 0.5rem 0 0; font-size: 0.8rem; }

.fiche-facts { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 0.5rem 1rem; font-size: 1rem; }
.fiche-facts dt { color: var(--muted); font-style: italic; }
.fiche-facts dd { margin: 0; font-weight: 600; }
.fiche-facts dd p { margin: 0; }

.fiche-list { display: flex; flex-direction: column; }
.fiche-list a {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.8rem;
  padding: 0.5rem 0;
  border-bottom: 1px dotted var(--gold);
  color: var(--ink);
  text-decoration: none;
}
.fiche-list a:last-child { border-bottom: none; }
.fiche-list a:hover { color: var(--accent); }
.fiche-list .kind { font-family: var(--font-display); font-size: 0.6rem; letter-spacing: 0.2em; text-transform: uppercase; color: var(--muted); white-space: nowrap; }

.event-table { width: 100%; min-width: 0; }
.event-table td.date { font-family: var(--font-display); font-size: 0.9rem; color: var(--accent); white-space: nowrap; }
.event-table td span { color: var(--ink-soft); }

@media (max-width: 640px) {
  .fiche-head h1 { font-size: 2.1rem; }
  .fiche-aside { max-width: none; }
}

.fiche-note { margin: 0.9rem 0 0; padding-top: 0.8rem; border-top: 1px dotted var(--gold); font-size: 0.98rem; color: var(--ink-soft); }
.fiche-note em { color: var(--muted); }
.fiche-note p { display: inline; margin: 0; }

/* Les tableaux que le corps importé porte (mensurations) prennent la règle des tableaux du lore. */
.fiche-main .prose table { border-collapse: collapse; margin: 0.6rem 0 1.4rem; }
.fiche-main .prose th { font-family: var(--font-display); font-size: 0.68rem; letter-spacing: 0.18em; text-transform: uppercase; color: var(--accent-dark); text-align: left; padding: 0.4rem 1rem 0.4rem 0; border-bottom: 2px solid var(--gold); }
.fiche-main .prose td { padding: 0.4rem 1rem 0.4rem 0; border-bottom: 1px dotted var(--gold); vertical-align: top; }

/* --- Toutes les fiches : badges au-dessus du titre, marge à encarts --- */
.fiche-badges { display: flex; flex-wrap: wrap; gap: 0.4rem; margin: 0; }
.fiche-head .belief-runes { margin: 0.6rem 0 0 !important; }
.fiche-head h1 { margin: 0.6rem 0 0.1rem; }
.fiche-epithet a { color: var(--accent); }
.fiche-epithet-note { display: block; font-size: 1rem; color: var(--muted); margin-top: 0.1rem; }
.fiche-epithet > span + .fiche-epithet-note { margin-top: 0.2rem; }

/* Un encart vide — section conditionnelle non rendue — ne laisse pas de cadre. */
.fiche-panel:not(:has(*)) { display: none; }

.fiche-panel h2 {
  display: block;
  margin: 0 0 0.8rem;
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  color: var(--gold);
}
.fiche-panel h2::after { display: none; }
.fiche-panel > p.matter-lead, .fiche-panel > .matter-lead { margin: -0.4rem 0 0.8rem; font-size: 0.92rem; }
.fiche-panel .race-aliases { margin: 0.6rem 0 0; }

.fiche-panel .statblock { display: grid; grid-template-columns: auto 1fr; gap: 0.45rem 1rem; margin: 0; font-size: 1rem; }
.fiche-panel .statblock dt, .fiche-panel .statblock dd { padding: 0; border: none; }
.fiche-panel .statblock dt { font-weight: 400; font-style: italic; color: var(--muted); }
.fiche-panel .statblock dd { margin: 0; font-weight: 600; }
.fiche-panel .statblock .inherited { display: block; font-weight: 400; font-size: 0.85rem; color: var(--muted); }

.fiche-panel .lore-links, .fiche-panel .matter-links, .fiche-panel .belief-neighbours { margin: 0; padding: 0; list-style: none; }
.fiche-panel .lore-links { display: block; }
.fiche-panel .lore-links li { display: block; padding: 0.45rem 0; border-bottom: 1px dotted var(--gold); }
.fiche-panel .lore-links li:last-child, .fiche-panel .matter-links li:last-child, .fiche-panel .belief-neighbours li:last-child { border-bottom: none; }
.fiche-panel .lore-link-kind { display: block; font-family: var(--font-display); font-size: 0.6rem; letter-spacing: 0.2em; text-transform: uppercase; color: var(--muted); margin-bottom: 0.1rem; }
.fiche-panel .matter-links li, .fiche-panel .belief-neighbours li { padding: 0.45rem 0; border-bottom: 1px dotted var(--gold); }
.fiche-panel .matter-detail, .fiche-panel .neighbour-epithet { display: block; font-size: 0.9rem; color: var(--muted); margin: 0; }

.fiche-aside .race-portrait { margin: 0; text-align: center; }
.fiche-aside .race-portrait img { max-width: 100%; max-height: none; border-radius: 0; border: 1px solid var(--border); outline: 1px solid var(--gold); outline-offset: -6px; }

.fiche-main .race-prose { max-width: none; }
.fiche-main .race-aliases { margin: -0.6rem 0 1.2rem; font-style: italic; }
.fiche-main .inherit-note { margin-bottom: 1.4rem; }

/* La lettrine flotte : un résumé d'une ligne ne doit pas laisser le titre suivant s'y coller. */
.lettrine::after { content: ""; display: table; clear: both; }

/* --- Pages de liste : le registre --- */
.registre-head { margin: 0.4rem 0 1.8rem; padding-bottom: 1.2rem; border-bottom: 1px solid var(--gold); box-shadow: 0 3px 0 -2px var(--gold); }
.registre-head .kicker { margin: 0 0 0.3rem; font-family: var(--font-display); font-size: 0.68rem; letter-spacing: 0.3em; text-transform: uppercase; color: var(--gold); }
.registre-head h1 { margin: 0 0 0.6rem; font-size: 2.6rem; }
.registre-head .lead { margin: 0; max-width: 70ch; }
.registre-head .lead a { color: var(--accent); }

/* Filtres : les onglets du registre */
.belief-filter { gap: 0.4rem; margin: 0 0 1.2rem; }
.belief-filter a, .belief-filter button {
  font-family: var(--font-display);
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 0.5rem 0.9rem;
  border: 1px solid var(--gold);
  border-radius: 0;
  background: var(--parchment);
  color: var(--accent-dark);
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}
.belief-filter a:hover, .belief-filter button:hover { background: var(--vellum); color: var(--ink); }
.belief-filter a.current, .belief-filter button.current { background: var(--accent-dark); border-color: var(--accent-dark); color: #f0e6cf; }
.belief-filter a.current .belief-count { color: #f0e6cf; border-color: rgba(240, 230, 207, 0.5); }
.belief-count { font-family: var(--font-display); font-size: 0.62rem; letter-spacing: 0.08em; color: var(--gold); border: 1px solid var(--gold); border-radius: 0; padding: 0.05rem 0.4rem; }

.belief-group-title { gap: 0.8rem; }
.belief-group-title .belief-count { font-size: 0.6rem; letter-spacing: 0.1em; }

/* Champs de recherche et de tri d'une liste */
.item-search { align-items: center; gap: 0.5rem 0.8rem; margin: 0 0 1.2rem; padding: 0.9rem 1.1rem; background: var(--parchment); border: 1px solid var(--border); }
.item-search label { font-family: var(--font-display); font-size: 0.66rem; letter-spacing: 0.18em; text-transform: uppercase; color: var(--muted); }
.item-search input, .item-search select, .memo-picker select {
  border: 1px solid var(--gold);
  border-radius: 0;
  background: var(--paper);
  font-family: var(--font-body);
  font-size: 1rem;
  color: var(--ink);
  padding: 0.4rem 0.7rem;
}
.item-search-count { font-family: var(--font-display); font-size: 0.66rem; letter-spacing: 0.15em; text-transform: uppercase; color: var(--muted); margin-left: auto; }

/* Cartes des listes (peuples, classes, espèces) : même encart enluminé que les lieux */
.race-card, .species-card {
  border-radius: 0;
  border: 1px solid var(--border);
  outline: 1px solid var(--gold);
  outline-offset: -6px;
  background: var(--parchment);
  box-shadow: none;
  transition: outline-color 0.12s ease, box-shadow 0.12s ease;
}
.race-card:hover, .species-card:hover { transform: none; outline-color: var(--accent); box-shadow: 0 6px 18px rgba(60, 45, 20, 0.14); }
.race-card img, .species-card img { height: 170px; }
.race-card .no-image, .species-card .no-image {
  background: repeating-linear-gradient(135deg, #eee4cf 0 6px, var(--paper) 6px 12px);
  border-bottom: 1px solid var(--border);
}
.race-card .body, .species-card .body { padding: 1rem 1.2rem 1.1rem; }
.race-card h2, .species-card h2 { font-size: 1.12rem; margin: 0.2rem 0 0.3rem; }
.race-card h2::after, .species-card h2::after { display: none; }
.race-card .type, .species-card .type { font-family: var(--font-display); font-size: 0.64rem; letter-spacing: 0.25em; color: var(--gold); }
.race-card p, .species-card p { font-size: 1rem; color: var(--ink-soft); }
.race-card .sub-race-links { border-top: 1px dotted var(--gold); }
.place-card h3::after { display: none; }

/* Le choix de mémo, sur parchemin */
.memo-picker { background: var(--parchment); border: 1px solid var(--border); padding: 1rem 1.2rem; }
.memo-picker label { font-family: var(--font-display); font-size: 0.66rem; letter-spacing: 0.18em; text-transform: uppercase; color: var(--muted); }
.btn-memo { font-family: var(--font-display); font-size: 0.72rem; letter-spacing: 0.12em; text-transform: uppercase; border-radius: 0; background: var(--accent-dark); color: #f0e6cf; border: 1px solid var(--accent-dark); padding: 0.7rem 1.1rem; }

/* =========================================================================
   Enluminure : la matière du manuscrit
   Grain du papier et taches d'âge posés sur les couleurs du thème,
   bords de page assombris, coins dorés sur les cartes encadrées et lettrine
   d'or sur fond de rubrique. Les tuiles sont générées par
   tools/scripts/textures-grimoire.mjs (PNG d'une seule teinte, fond transparent) :
   les couleurs restent celles des variables, la texture ne fait que s'y ajouter.
   ========================================================================= */

:root {
  --tex-grain: url("../images/textures/grain.png");
  --tex-grain-fort: url("../images/textures/grain-fort.png");
  --tex-taches: url("../images/textures/taches.png");
  /* Le pourtour d'une page jaunie : plus sombre vers les bords. */
  --vignette: inset 0 0 38px rgba(122, 92, 62, 0.2), inset 0 0 6px rgba(122, 92, 62, 0.18);
  /* Le rouge des rubriques, fond des lettrines enluminées. */
  --rubric: #6b2419;
  --gold-leaf: #f0d68a;
}

body {
  background-image: var(--tex-grain), var(--tex-taches);
}

/* Les surfaces de parchemin : le même grain et les mêmes taches que la page. */
.site-header, .site-footer, .nav-menu, .search-panel,
.home-prologue, .chapter, .continent, .place-card, .race-card, .species-card,
.fiche-panel, .statblock-sheet, .timeline-era, .recit-toc, .memo-toc,
.rite-group, .item-search, .memo-picker, .matter-recipe {
  background-image: var(--tex-grain), var(--tex-taches);
}

/* Les pages et cartes : bords assombris comme un vélin vieilli. */
.home-prologue, .chapter, .continent, .place-card, .race-card, .species-card,
.fiche-panel, .statblock-sheet, .recit-toc, .memo-toc, .rite-group, .item-search, .memo-picker {
  box-shadow: var(--vignette);
}
.place-card:hover,
.race-card:hover, .species-card:hover { box-shadow: var(--vignette), 0 6px 18px rgba(60, 45, 20, 0.14); }
.home-prologue .figure { box-shadow: var(--vignette); }

/* Les cartes à filet doré intérieur reçoivent un fleuron à chaque coin, dans le cadre. */
.home-prologue, .chapter, .continent, .place-card, .fiche-panel {
  background-image:
    url("../images/textures/coin-hg.svg"), url("../images/textures/coin-hd.svg"),
    url("../images/textures/coin-bg.svg"), url("../images/textures/coin-bd.svg"),
    var(--tex-grain), var(--tex-taches);
  background-position: top 2px left 2px, top 2px right 2px, bottom 2px left 2px, bottom 2px right 2px, 0 0, 0 0;
  background-repeat: no-repeat, no-repeat, no-repeat, no-repeat, repeat, repeat;
  background-size: 38px 38px, 38px 38px, 38px 38px, 38px 38px, auto, auto;
}

/* La lettrine : lettre d'or sur fond de rubrique grainé. */
.lettrine::first-letter {
  color: var(--gold-leaf);
  background-color: var(--rubric);
  background-image: var(--tex-grain-fort);
  text-shadow: 0 1px 0 #3a120c, 0 0 6px rgba(240, 214, 138, 0.35);
}

/* L'encre a légèrement bu dans le papier. */
h1, h2 { text-shadow: 0 0 1px rgba(44, 38, 32, 0.35); }
main p { text-shadow: 0 0 0.6px rgba(44, 38, 32, 0.25); }

@media print {
  body, .site-header, .site-footer, .nav-menu, .search-panel,
  .home-prologue, .chapter, .continent, .place-card, .race-card, .species-card,
  .fiche-panel, .statblock-sheet, .timeline-era, .recit-toc, .memo-toc,
  .rite-group, .item-search, .memo-picker, .matter-recipe { background-image: none !important; box-shadow: none !important; }
  h1, h2, main p { text-shadow: none; }
}
