/* Shadowdark — thème inspiré des livres : noir d'encre sur papier cassé, filets noirs, accents rouge sang et
   lueur de torche ; titres gothiques (Manufacturing Consent), texte en Montserrat (police des livres).
   Mode sombre : vraie obscurité, texte gris clair, la torche éclaire les accents. */

/* Couleurs : chaque jeton donne sa valeur claire puis sombre (light-dark), selon le color-scheme de :root.
   color-scheme vaut « light dark » (le site suit l'appareil), sauf choix du lecteur dans Mon compte : la balise
   <meta name="color-scheme"> passe alors à « light » ou « dark » (rendue par le serveur, voir App.razor). */
:root {
    color-scheme: light dark;
    --paper: light-dark(#f2eee5, #0a0908);
    --paper-2: light-dark(#e9e3d6, #11100e);
    --card: light-dark(#faf8f3, #141210);
    --card-2: light-dark(#f1ece2, #1b1815);
    --ink: light-dark(#14120f, #d6d1c8);
    --ink-soft: light-dark(#35312b, #bcb6ab);
    --muted: light-dark(#625c52, #8f887c);
    --rule: light-dark(#14120f, #4a433a);          /* filets noirs des livres */
    --line: light-dark(#d5cdbd, #2b2722);
    --blood: light-dark(#a3141a, #d23c30);
    --blood-soft: color-mix(in srgb, var(--blood) 12%, transparent);
    --torch: light-dark(#c25e0c, #ff9b3d);
    --torch-soft: color-mix(in srgb, var(--torch) 16%, transparent);
    --glow: light-dark(rgba(194, 94, 12, 0), rgba(255, 140, 40, .35));
    --heading: light-dark(#14120f, #ece6db);
    --link: light-dark(#8e1116, #ffa04a);
    --star: light-dark(#b8740a, #ffb347);
    --night: #070605;
    --night-2: #15120f;
    --night-ink: #ddd6ca;
    --night-muted: #91897c;
    --shadow: 0 1px 2px light-dark(rgba(20, 15, 5, .08), rgba(0, 0, 0, .5)), 0 6px 18px -10px light-dark(rgba(20, 15, 5, .25), rgba(0, 0, 0, .8));
    --shadow-lg: 0 2px 6px light-dark(rgba(0, 0, 0, .15), rgba(0, 0, 0, .5)), 0 18px 40px -16px light-dark(rgba(0, 0, 0, .5), rgba(0, 0, 0, .9));
    --radius: 4px;
    --radius-sm: 3px;
    --font-gothic: "Manufacturing Consent", "Old English Text MT", "Times New Roman", serif;
    --font-body: "Montserrat", "Segoe UI", system-ui, sans-serif;
    --sidebar-w: 264px;
}
:root:has(> head > meta[name="color-scheme"][content="light"]) { color-scheme: light; }
:root:has(> head > meta[name="color-scheme"][content="dark"]) { color-scheme: dark; }
/* « Système (actuellement clair / sombre) » dans Mon compte */
.si-sombre { display: none; }
@media (prefers-color-scheme: dark) { .si-clair { display: none; } .si-sombre { display: inline; } }

/* ---------- Base ---------- */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
html, body { margin: 0; }
body {
    font-family: var(--font-body);
    font-size: 1rem;              /* 16 px minimum, lisible sur téléphone */
    line-height: 1.6;
    background: var(--paper);
    color: var(--ink);
    -webkit-font-smoothing: antialiased;
    font-variant-numeric: lining-nums;
}
a { color: var(--link); text-decoration-color: color-mix(in srgb, var(--link) 40%, transparent); text-underline-offset: 3px; }
a:hover { text-decoration-color: currentColor; }
h1, h2, h3, h4 { line-height: 1.15; color: var(--heading); margin: 1.2em 0 .45em; }
h1 { font-family: var(--font-gothic); font-weight: 400; font-size: clamp(1.9rem, 4vw, 3rem); overflow-wrap: anywhere; margin: 0 0 .3em; letter-spacing: .01em; }
h2 { font-weight: 800; font-size: 1.3rem; text-transform: uppercase; letter-spacing: .06em; }
h3 { font-weight: 700; font-size: 1.1rem; }
h4 { font-weight: 700; font-size: 1rem; }
p { margin: 0 0 .8em; }
code { font-size: .9em; background: var(--card-2); padding: 1px 5px; border-radius: 3px; }
::selection { background: color-mix(in srgb, var(--blood) 30%, transparent); }
:focus-visible { outline: 2px solid var(--torch); outline-offset: 2px; }
h1:focus, h1:focus-visible { outline: none; }

.muted { color: var(--muted); }
.petit { font-size: .85rem; }
.source { color: var(--muted); font-size: .85rem; font-style: italic; margin-top: 14px; clear: both; }
.erreur { color: var(--blood); }

/* Traduction : « (VO) » et nom anglais rappelé sous le nom français */
.vo {
    display: inline-block; vertical-align: middle; margin-left: 6px;
    font-family: var(--font-body); font-size: .7rem; font-weight: 700; letter-spacing: .06em; line-height: 1.5;
    padding: 0 6px; border: 1px solid currentColor; border-radius: 2px; color: var(--muted);
}
h1 .vo { font-size: .8rem; position: relative; top: -4px; }
.vo.perimee { color: var(--torch); }
.nom-anglais { margin: -2px 0 8px; font-size: .95rem; font-style: italic; color: var(--muted); }
.nom-anglais::before { content: 'EN · '; font-style: normal; font-size: .75rem; letter-spacing: .1em; }
.nom-anglais-ligne { display: block; font-size: .85rem; font-style: italic; color: var(--muted); }
.note-vo { padding: 8px 12px; border-left: 3px solid var(--muted); background: var(--card-2); font-size: .95rem; }

/* ---------- Structure : menu latéral noir ---------- */
.shell { min-height: 100vh; }
.topbar { display: none; }
/* Grand écran : le tiroir et sa surface de glissement s'effacent, le menu latéral est un simple bloc fixe. */
.tiroir, .tiroir-defileur { display: contents; }
.nav-fermer { display: none; }

.sidebar {
    position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w); z-index: 30;
    display: flex; flex-direction: column; gap: 2px;
    padding: 20px 14px 16px; overflow-y: auto;
    color: var(--night-ink);
    background: radial-gradient(ellipse at 50% -10%, rgba(255, 130, 30, .12), transparent 55%), var(--night);
    border-right: 1px solid #2a241e;
    scrollbar-width: thin; scrollbar-color: rgba(255, 255, 255, .15) transparent;
}
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; color: inherit; padding: 4px 6px 12px; }
.brand-mark {
    flex: none; width: 30px; height: 40px; position: relative;
    background: radial-gradient(ellipse at 50% 70%, #ffd27a 0 18%, #ff8a1e 38%, #b3261e 62%, transparent 64%);
    filter: drop-shadow(0 0 8px rgba(255, 140, 40, .6));
}
.brand-mark::after { content: ''; position: absolute; left: 13px; top: 24px; width: 4px; height: 16px; background: #6b4a2b; border-radius: 1px; }
.brand-text { display: flex; flex-direction: column; line-height: 1; }
.brand-text b { font-family: var(--font-gothic); font-weight: 400; font-size: 1.75rem; color: #f2ece2; letter-spacing: .01em; }
.brand-text small { font-size: .7rem; text-transform: uppercase; letter-spacing: .3em; color: #ff9b3d; margin-top: 4px; }

.side-langue { padding: 0 6px 10px; }
.side-search { position: relative; margin: 0 4px 10px; }
.side-search .icon { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--night-muted); }
.side-search input {
    width: 100%; font: inherit; font-size: 1rem; color: var(--night-ink);
    padding: 9px 10px 9px 34px; border-radius: 3px;
    border: 1px solid rgba(255, 255, 255, .14); background: rgba(255, 255, 255, .05);
}
.side-search input::placeholder { color: var(--night-muted); }
.side-search input:focus { outline: none; border-color: #ff9b3d; background: rgba(255, 255, 255, .08); }

.nav-group { display: flex; flex-direction: column; gap: 1px; margin-bottom: 6px; }
.nav-title { margin: 10px 10px 4px; font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .22em; color: #c9443a; }
.sidebar .nav-group a {
    display: flex; align-items: center; gap: 11px; min-height: 40px;
    padding: 6px 10px; border-radius: 3px;
    color: var(--night-ink); text-decoration: none; font-size: .98rem;
    border-left: 2px solid transparent;
    transition: background .15s, color .15s;
}
.sidebar .nav-group a .icon { color: var(--night-muted); transition: color .15s; }
.sidebar .nav-group a:hover { background: rgba(255, 255, 255, .06); }
.sidebar .nav-group a:hover .icon { color: #ff9b3d; }
.sidebar .nav-group a.active {
    background: linear-gradient(90deg, rgba(255, 140, 40, .2), rgba(255, 140, 40, .02));
    border-left-color: #ff9b3d; color: #fff;
}
.sidebar .nav-group a.active .icon { color: #ffb05c; }
.side-foot { margin: 0 10px; padding-top: 12px; font-size: .72rem; color: var(--night-muted); opacity: .75; }
.side-user { display: flex; align-items: center; gap: 6px; padding: 6px 8px; margin-top: auto; font-size: .9rem; }
.side-user a { color: var(--night-ink); }
.side-user-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-logout { margin-left: auto; }
.sidebar .tag { background: rgba(255, 140, 40, .15); color: #ffb05c; border-color: rgba(255, 140, 40, .4); }

/* Bascule FR / EN */
.langue-bascule { display: inline-flex; border: 1px solid rgba(255, 255, 255, .25); border-radius: 3px; overflow: hidden; }
.langue-bascule button {
    min-width: 44px; min-height: 36px; padding: 4px 10px; border: 0; cursor: pointer;
    font: inherit; font-size: .8rem; font-weight: 700; letter-spacing: .12em;
    background: transparent; color: var(--night-muted);
}
.langue-bascule button + button { border-left: 1px solid rgba(255, 255, 255, .25); }
.langue-bascule button[aria-pressed="true"] { background: #b3261e; color: #fff; }
.langue-bascule button:hover:not([aria-pressed="true"]) { color: #ffb05c; background: rgba(255, 255, 255, .06); }

.content { margin-left: var(--sidebar-w); padding: 28px clamp(16px, 3.5vw, 48px) 64px; max-width: calc(1240px + var(--sidebar-w)); }

@media (max-width: 980px) {
    .topbar {
        display: flex; align-items: center; gap: 10px;
        position: sticky; top: 0; z-index: 25; padding: 6px 8px 6px 14px;
        color: var(--night-ink); background: var(--night);
        border-bottom: 2px solid #b3261e;
    }
    .topbar .brand { padding: 0; margin-right: auto; }
    .topbar .brand-mark { width: 22px; height: 30px; }
    .topbar .brand-mark::after { left: 9px; top: 18px; height: 12px; }
    .topbar .brand-text b { font-size: 1.45rem; }
    .topbar .brand-text small { display: none; }
    .side-langue { display: none; }
    .nav-burger, .nav-fermer {
        display: grid; place-items: center; width: 48px; height: 48px; padding: 0; border-radius: 3px; cursor: pointer;
        color: #ff9b3d; background: none; border: 0;
    }
    .nav-burger:hover, .nav-fermer:hover { background: rgba(255, 255, 255, .08); }
    .nav-fermer { align-self: flex-end; margin: -6px -4px 4px; }
    .content { margin-left: 0; padding: 18px 16px 48px; }

    /* Tiroir (guide navigation-drawer) : popover plein écran, défileur horizontal à deux crans (ouvert / fermé),
       le doigt fait glisser la feuille ; le fond s'assombrit au rythme du glissement. */
    .tiroir {
        --tiroir-largeur: min(20em, 86dvw, 100dvw - 24px);
        --tiroir-fond: 0;
        inset: 0; width: auto; height: auto; max-width: none; max-height: none;
        margin: 0; padding: 0; border: 0; background: transparent; overflow: visible; color: inherit;
    }
    .tiroir:not(:popover-open) { display: none; }
    .tiroir:popover-open { display: block; }
    .tiroir::backdrop { background: rgb(0 0 0); opacity: calc(var(--tiroir-fond) * .7); }
    .tiroir-defileur {
        position: relative; display: grid; grid-template-columns: var(--tiroir-largeur) 100%; height: 100%;
        overflow-x: scroll; overscroll-behavior: none; scrollbar-width: none; scroll-snap-type: x mandatory;
    }
    .tiroir-defileur::after { content: ''; scroll-snap-align: end; scroll-initial-target: nearest; }
    .sidebar.tiroir-feuille {
        position: relative; inset: auto; width: auto; z-index: auto; height: 100svh; padding-top: 10px;
        scroll-snap-align: start; box-shadow: var(--shadow-lg);
    }
    .sidebar > .brand { display: none; }
    .sidebar .nav-group a { min-height: 48px; }
}
@media (max-width: 980px) and (prefers-reduced-motion: no-preference) {
    .tiroir-defileur { scroll-behavior: smooth; }
}
@supports (animation-timeline: scroll()) {
    @property --tiroir-fond { syntax: '<number>'; inherits: true; initial-value: 0; }
    @keyframes tiroir-fondu { 0% { --tiroir-fond: 1; } 100% { --tiroir-fond: 0; } }
    @media (max-width: 980px) {
        .tiroir { timeline-scope: --tiroir-defilement; animation: tiroir-fondu linear both; animation-timeline: --tiroir-defilement; }
        .tiroir-defileur { scroll-timeline: --tiroir-defilement x; }
    }
}

/* ---------- Bandeaux ---------- */
.hero, .home-hero {
    position: relative; overflow: hidden; isolation: isolate;
    margin: 0 0 24px; color: #f2ece2; background: var(--night);
    border-top: 4px solid #0d0b09; border-bottom: 4px solid #b3261e;
    box-shadow: var(--shadow-lg);
}
.hero::before, .home-hero::before {
    content: ''; position: absolute; inset: 0; z-index: -2;
    background: var(--hero-img) var(--hero-pos, center 30%) / cover no-repeat;
    filter: grayscale(.35) contrast(1.1);
}
.hero::after, .home-hero::after {
    content: ''; position: absolute; inset: 0; z-index: -1;
    background:
        linear-gradient(90deg, rgba(5, 4, 3, .94) 0%, rgba(5, 4, 3, .72) 40%, rgba(5, 4, 3, .15) 78%),
        linear-gradient(0deg, rgba(5, 4, 3, .6), transparent 55%);
}
/* Sans illustration : obscurité et halo de torche. */
.hero.sans-image::before, .home-hero.sans-image::before {
    background: radial-gradient(ellipse at 88% 120%, rgba(255, 130, 30, .45), transparent 55%),
                radial-gradient(ellipse at 10% -40%, rgba(179, 38, 30, .35), transparent 50%), var(--night);
    filter: none;
}
.hero.sans-image::after, .home-hero.sans-image::after { background: none; }
.hero { min-height: 170px; display: flex; align-items: flex-end; }
.hero-text { padding: 28px clamp(18px, 3vw, 36px) 22px; max-width: 720px; min-width: 0; flex: 1; }
.hero h1, .home-hero h1 { color: #f7f1e6; margin: 0; text-shadow: 0 0 22px rgba(255, 120, 30, .35), 0 2px 10px rgba(0, 0, 0, .7); }
.eyebrow { margin: 0 0 6px; font-size: .74rem; font-weight: 700; text-transform: uppercase; letter-spacing: .24em; color: #ff9b3d; }
.eyebrow a { color: inherit; }
.hero-sub { margin: 8px 0 0; color: rgba(242, 236, 226, .86); font-size: 1rem; max-width: 60ch; }
.hero .tag { background: rgba(255, 140, 40, .18); color: #ffc483; border-color: rgba(255, 140, 40, .4); }

.home-hero { min-height: min(56vh, 480px); display: flex; align-items: center; margin-bottom: 8px; --hero-pos: center 25%; }
.home-hero-text { padding: clamp(26px, 5vw, 56px); max-width: 680px; min-width: 0; flex: 1; }
.home-hero h1 { font-size: clamp(2.2rem, 11vw, 5.2rem); line-height: .95; overflow-wrap: anywhere; }
.home-hero h1 span { display: block; font-family: var(--font-body); font-size: .22em; font-weight: 700; letter-spacing: .5em; text-transform: uppercase; color: #ff9b3d; margin-top: 12px; text-shadow: none; }
.home-hero .hero-sub { font-size: 1.08rem; margin-top: 16px; }
.hero-search {
    display: flex; align-items: center; gap: 8px; margin: 24px 0 16px;
    background: #f7f3ea; border-radius: 3px; padding: 5px 5px 5px 14px; color: #5a534a;
    box-shadow: 0 0 0 1px #000, 0 10px 30px -10px rgba(0, 0, 0, .8);
}
.hero-search input { flex: 1; min-width: 0; border: 0; background: transparent; font: inherit; font-size: 1rem; color: #14120f; padding: 8px 4px; }
.hero-search input:focus { outline: none; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.etat-traduction { margin-top: 24px; font-size: .9rem; }

/* ---------- Titres de section : filet noir épais ---------- */
.section-title { display: flex; align-items: center; gap: 12px; margin: 34px 0 14px; scroll-margin-top: 80px; }
.section-title::after { content: ''; flex: 1; height: 3px; background: var(--rule); }
.section-title span { display: inline-flex; align-items: center; gap: 10px; }
.section-title span::before { content: ''; width: 9px; height: 9px; background: var(--blood); transform: rotate(45deg); flex: none; }

/* ---------- Tuiles de l'accueil ---------- */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.tiles-wide { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.tile {
    position: relative; isolation: isolate; overflow: hidden;
    display: flex; flex-direction: column; justify-content: flex-end;
    min-height: 200px; padding: 14px; border-radius: var(--radius);
    color: #f2ece2; text-decoration: none; background: var(--night);
    border: 1px solid #000; box-shadow: var(--shadow);
    transition: transform .2s ease, box-shadow .2s ease;
}
.tiles-wide .tile { min-height: 140px; }
.tile::before {
    content: ''; position: absolute; inset: 0; z-index: -2;
    background: var(--tile-img) center 25% / cover no-repeat; filter: grayscale(.4) contrast(1.1);
    transition: transform .5s ease, filter .3s;
}
.tile.sans-image::before { background: radial-gradient(ellipse at 50% 120%, rgba(255, 130, 30, .4), transparent 60%), var(--night-2); }
.tile::after { content: ''; position: absolute; inset: 0; z-index: -1; background: linear-gradient(0deg, rgba(5, 4, 3, .97) 0%, rgba(5, 4, 3, .9) 40%, rgba(5, 4, 3, .45) 72%, rgba(5, 4, 3, .1)); }
.tile:hover { transform: translateY(-3px); box-shadow: 0 0 0 1px #ff9b3d, 0 10px 30px -10px rgba(255, 120, 30, .5); }
.tile:hover::before { transform: scale(1.06); filter: grayscale(0) contrast(1.1); }
.tile.vide { opacity: .7; }
.tile-count {
    position: absolute; top: 10px; right: 10px;
    font-weight: 800; font-size: .95rem; padding: 1px 9px; border-radius: 2px;
    background: #b3261e; color: #fff;
}
.tile.vide .tile-count { background: rgba(255, 255, 255, .15); font-weight: 600; font-size: .8rem; }
.tile-body { display: flex; flex-direction: column; gap: 2px; text-shadow: 0 1px 3px rgba(0, 0, 0, .9); }
.tile-label { display: flex; align-items: center; gap: 8px; font-family: var(--font-gothic); font-size: 1.55rem; line-height: 1.1; }
.tile-label .icon { color: #ff9b3d; flex: none; }
.tile-sub { font-size: .85rem; color: rgba(242, 236, 226, .92); }

/* ---------- Fil d'Ariane, en-tête de fiche ---------- */
.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: .9rem; color: var(--muted); margin: 0 0 10px; }
.crumbs a { display: inline-flex; align-items: center; gap: 5px; min-height: 32px; text-decoration: none; color: var(--muted); }
.crumbs a:hover { color: var(--link); }
.fiche-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 10px; margin-bottom: 12px; padding-bottom: 10px; border-bottom: 3px solid var(--rule); }
.fiche-head .eyebrow { color: var(--blood); }
.fiche-head h1 { margin: 0; }
.fiche-titre { min-width: 0; }
.sommaire-fiche { display: flex; flex-wrap: wrap; gap: 4px 14px; margin: 0 0 14px; font-size: .92rem; font-weight: 600; }
.sommaire-fiche a { display: inline-flex; align-items: center; min-height: 36px; }
.autres-versions { margin: -4px 0 14px; padding: 6px 10px; font-size: .92rem; border-left: 3px solid var(--torch); background: var(--torch-soft); }

/* ---------- Boutons, champs ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 44px;
    font: inherit; font-weight: 700; font-size: .95rem; line-height: 1.2; letter-spacing: .02em;
    padding: 9px 18px; border-radius: 3px; cursor: pointer; text-decoration: none;
    color: #fff; border: 1px solid #000; background: #a3141a;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .15), 0 2px 6px -2px rgba(0, 0, 0, .6);
    transition: background .15s, box-shadow .15s, transform .05s;
}
.btn:hover { background: #c01b20; box-shadow: 0 0 0 1px #000, 0 0 18px -2px var(--glow); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.ghost { background: rgba(255, 255, 255, .06); color: #f2ece2; border-color: rgba(255, 255, 255, .4); box-shadow: none; }
.btn.ghost:hover { background: rgba(255, 255, 255, .14); }
.btn.danger { background: var(--blood); }

:where(button:not(.btn, .fav, .choix-btn, .de-btn, .langue-bascule button, .chip-btn, .nav-burger, .nav-fermer, .lightbox-close)) {
    font: inherit; font-size: .95rem; min-height: 40px; padding: 7px 14px; border-radius: 3px; cursor: pointer;
    border: 1px solid var(--rule); background: var(--card); color: var(--ink);
    transition: border-color .15s, background .15s;
}
:where(button:not(.btn, .fav, .choix-btn, .de-btn, .langue-bascule button, .chip-btn, .nav-burger, .nav-fermer, .lightbox-close)):hover { background: var(--card-2); border-color: var(--torch); }

:where(input:not([type=checkbox]):not([type=radio]):not([type=color]), select, textarea) {
    font: inherit; font-size: max(1rem, 1em); color: var(--ink); min-height: 42px;
    padding: 8px 11px; border-radius: 3px;
    border: 1px solid color-mix(in srgb, var(--rule) 55%, var(--line)); background: var(--card);
    transition: border-color .15s, box-shadow .15s;
}
:where(input:not([type=checkbox]):not([type=radio]), select, textarea):focus { outline: none; border-color: var(--torch); box-shadow: 0 0 0 3px var(--torch-soft); }
select { cursor: pointer; }
input[type=checkbox], input[type=radio] { accent-color: var(--blood); width: 18px; height: 18px; }
textarea { width: 100%; }
input.court { width: 76px; }

.filters {
    display: flex; gap: 10px; flex-wrap: wrap; align-items: center;
    margin: 0 0 14px; padding: 12px; border-radius: var(--radius);
    background: var(--card); border: 1px solid var(--line); border-top: 3px solid var(--rule);
}
.filters > input:first-child:not([type=checkbox]) { flex: 1 1 240px; }
.filters label { display: flex; gap: 6px; align-items: center; color: var(--muted); font-size: .95rem; }
.card .filters, .hero .filters { background: none; border: 0; padding: 0; }
.count { color: var(--muted); font-size: .92rem; margin: -4px 0 10px; }
label.case { display: inline-flex; align-items: center; gap: 8px; min-height: 40px; cursor: pointer; }

/* ---------- Cartes ---------- */
.card {
    position: relative; background: var(--card);
    border: 1px solid var(--line); border-top: 3px solid var(--rule);
    border-radius: var(--radius); padding: 18px 22px; margin: 14px 0;
    box-shadow: var(--shadow);
}
.card::after { content: ''; display: block; clear: both; }
.card > h2:first-child, .card > h3:first-child { margin-top: 0; }
.cartes-liste { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; }
.cartes-liste.larges { grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); }
.cartes-liste .card { margin: 0; scroll-margin-top: 80px; }
.carte-lien { display: block; color: inherit; text-decoration: none; transition: box-shadow .15s, border-color .15s; }
.carte-lien:hover { border-top-color: var(--blood); box-shadow: 0 0 0 1px var(--torch), 0 8px 24px -12px var(--glow); }
.carte-lien h3 { margin: 0 0 4px; color: var(--link); }
.carte-lien p { margin: 0; }
.bientot { display: flex; gap: 14px; align-items: flex-start; }
.bientot .icon { color: var(--torch); flex: none; filter: drop-shadow(0 0 6px var(--glow)); }

.tag {
    display: inline-flex; align-items: center; vertical-align: middle;
    font-family: var(--font-body); font-size: .7rem; font-weight: 700; line-height: 1.6;
    text-transform: uppercase; letter-spacing: .08em;
    padding: 0 7px; margin-left: 6px; border-radius: 2px;
    background: var(--blood-soft); color: var(--blood);
    border: 1px solid color-mix(in srgb, var(--blood) 35%, transparent);
}
.tag a { color: inherit; text-decoration: none; }
h1 .tag, h2 .tag, h3 .tag { position: relative; top: -2px; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 10px 0; }
.chips a {
    display: inline-flex; align-items: center; min-height: 34px;
    background: var(--card); border: 1px solid var(--line); border-radius: 2px;
    padding: 2px 11px; font-size: .9rem; text-decoration: none;
    transition: border-color .15s, background .15s;
}
.chips a:hover { border-color: var(--torch); background: var(--torch-soft); }

dl.meta { display: grid; grid-template-columns: max-content 1fr; gap: 6px 18px; margin: 12px 0 16px; padding: 12px 16px; background: var(--card-2); border-left: 3px solid var(--rule); }
dl.meta dt { color: var(--muted); font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .1em; align-self: center; }
dl.meta dd { margin: 0; }
@media (max-width: 520px) { dl.meta { grid-template-columns: 1fr; gap: 2px; } dl.meta dd { margin-bottom: 8px; } }

.trait { margin: 0 0 6px; }
.trait p { margin: 0 0 .5em; }
.md > :last-child { margin-bottom: 0; }
.md ul, .md ol { padding-left: 1.3em; margin: 0 0 .8em; }
.md table { border-collapse: collapse; margin: .5em 0 1em; font-size: .93rem; display: block; overflow-x: auto; }
.md th, .md td { padding: 5px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.md th { background: var(--card-2); border-bottom: 2px solid var(--rule); }
.note-table { font-style: italic; color: var(--ink-soft); }

/* Illustrations des fiches : encre sur papier */
.illus { float: right; width: min(38%, 380px); margin: 0 0 14px 22px; text-align: center; }
.illus img { max-width: 100%; max-height: 440px; object-fit: contain; filter: drop-shadow(0 8px 14px rgba(0, 0, 0, .3)); }
@media (max-width: 720px) { .illus { float: none; width: auto; margin: 0 0 12px; } .illus img { max-height: 320px; } }

/* ---------- Stat-block de monstre, façon livre ---------- */
.statblock {
    display: flow-root;   /* reste à côté de l'illustration flottante */
    margin: 4px 0 16px; padding: 12px 0 10px; max-width: 72ch;
    border-top: 4px solid var(--rule); border-bottom: 4px solid var(--rule);
}
.sb-nom { margin: 0 0 4px; font-size: 1.3rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.sb-desc { font-style: italic; color: var(--ink-soft); margin-bottom: 8px; }
.sb-stats { margin: 10px 0; padding: 8px 0; border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule); line-height: 1.75; }
.sb-stats span { white-space: nowrap; }
.sb-stats b { font-weight: 800; color: var(--blood); letter-spacing: .03em; margin-right: 2px; }
.sb-trait { margin: 6px 0; }
.sb-trait p { margin: 0 0 .3em; }
.sb-trait strong { font-weight: 800; }
.sb-sort { font-size: .88rem; color: var(--muted); margin: 0 0 .4em; }
.sb-sort .tag { margin-left: 0; margin-right: 4px; }

/* ---------- Tableaux ---------- */
.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--line); border-top: 3px solid var(--rule); background: var(--card); box-shadow: var(--shadow); margin: 0 0 20px; }
table.grid { border-collapse: collapse; width: 100%; font-size: .95rem; font-variant-numeric: tabular-nums; }
table.grid th, table.grid td { padding: 8px 12px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line); }
table.grid thead th {
    position: sticky; top: 0; z-index: 1;
    font-size: .72rem; font-weight: 800; text-transform: uppercase; letter-spacing: .12em; color: var(--ink);
    background: var(--card-2); white-space: nowrap; border-bottom: 2px solid var(--rule);
}
table.grid tbody tr:last-child td { border-bottom: 0; }
table.grid tbody tr { transition: background .12s; }
table.grid tbody tr:hover { background: var(--torch-soft); }
table.grid td:first-child a { font-weight: 700; text-decoration: none; }
table.grid td:first-child a:hover { text-decoration: underline; }
table.grid td.num, table.grid th.num { text-align: center; }
table.grid.compact td, table.grid.compact th { padding: 5px 8px; }
table.grid .col-de { width: 1%; white-space: nowrap; text-align: center; font-weight: 800; color: var(--blood); }
table.grid tr[id], table.grid tr td[id] { scroll-margin-top: 80px; }
@media (max-width: 720px) { table.grid .col-source, table.grid .col-mvt { display: none; } table.grid th, table.grid td { padding: 7px 8px; } }

/* Tables à lancer : la ligne tirée s'allume comme à la lueur d'une torche */
.table-lancable { margin: 0 0 22px; scroll-margin-top: 80px; }
.tl-titre { margin: 18px 0 8px; }
.tl-barre { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; margin: 0 0 10px; }
.tl-resultat { font-size: 1rem; }
.tl-valeur { font-size: 1.4rem; font-weight: 800; color: var(--blood); padding: 0 4px; }
table.grid.tirage tbody tr.tiree, table.grid.tirage tbody tr.tiree:hover {
    background: color-mix(in srgb, var(--torch) 22%, var(--card));
    box-shadow: inset 4px 0 0 var(--blood);
    animation: lueur 1.2s ease-out;
}
table.grid.tirage tr.tiree td { font-weight: 600; }
table.grid.tirage td.cellule-tiree { outline: 2px solid var(--blood); outline-offset: -2px; background: color-mix(in srgb, var(--torch) 30%, var(--card)); }
@keyframes lueur { from { background: color-mix(in srgb, var(--torch) 55%, var(--card)); } }
@media (prefers-reduced-motion: reduce) { table.grid.tirage tbody tr.tiree { animation: none; } }

/* ---------- Listes ---------- */
.link-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 8px; list-style: none; padding: 0; margin: 0 0 12px; }
.sommaire-regles { list-style: none; padding: 0; margin: 0 0 14px; columns: 2 320px; column-gap: 28px; }
.sommaire-regles li { break-inside: avoid; padding: 3px 0; display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 8px; }
.sommaire-regles a { display: inline-flex; align-items: center; min-height: 32px; text-decoration: none; }
.sommaire-regles a:hover { text-decoration: underline; }
.sommaire-regles .niveau-1 { font-weight: 800; margin-top: 8px; }
.sommaire-regles .niveau-2 { padding-left: 16px; }
.sommaire-regles .niveau-3 { padding-left: 32px; font-size: .95rem; }
.sommaire-regles .niveau-4 { padding-left: 48px; font-size: .92rem; }
.pager { display: flex; justify-content: space-between; gap: 12px; margin: 28px 0 0; padding-top: 12px; border-top: 3px solid var(--rule); }
.pager a { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; font-weight: 600; text-decoration: none; }
dl.proprietes dt { font-weight: 800; margin-top: 12px; scroll-margin-top: 80px; }
dl.proprietes dd { margin: 2px 0 0; }
.ancre { display: block; position: relative; top: -80px; visibility: hidden; }

/* ---------- Règles (Markdown) ---------- */
.markdown { max-width: 78ch; }
.markdown h1 { margin-bottom: .5em; }
.markdown h2 { padding-bottom: 6px; border-bottom: 3px solid var(--rule); }
.markdown h3 { color: var(--blood); }
.markdown img { max-width: 100%; }
.markdown blockquote { margin: 1em 0; padding: 10px 18px; border-left: 4px solid var(--rule); background: var(--card-2); color: var(--ink-soft); }
.page-livre { display: block; height: 0; scroll-margin-top: 80px; }

/* ---------- Favoris ---------- */
.fav {
    display: inline-grid; place-items: center; width: 38px; height: 38px; vertical-align: middle;
    font: inherit; font-size: 1.15rem; line-height: 1; padding: 0; margin-left: 8px;
    border-radius: 50%; cursor: pointer;
    color: var(--muted); background: var(--card); border: 1px solid var(--line);
    transition: color .15s, border-color .15s, box-shadow .15s;
}
.fav:hover { color: var(--star); border-color: var(--star); box-shadow: 0 0 12px -2px var(--glow); }
.fav.on { color: var(--star); border-color: var(--star); background: color-mix(in srgb, var(--star) 14%, var(--card)); }
.fav:disabled { opacity: .5; cursor: default; }
h1 .fav { position: relative; top: -6px; }

details { margin: 10px 0; padding: 4px 18px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); }
details summary { cursor: pointer; }

/* ---------- Erreur Blazor ---------- */
#blazor-error-ui { display: none; position: fixed; bottom: 0; left: 0; right: 0; z-index: 1000; background: #fff4e0; color: #14120f; padding: 10px 16px; border-top: 3px solid #b3261e; }
#blazor-error-ui .dismiss { cursor: pointer; float: right; }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { transition: none !important; }
}

@media (max-width: 600px) {
    .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
    .tile { min-height: 140px; padding: 12px; }
    .tile-label { font-size: 1.4rem; }
    .tile-sub { font-size: .8rem; }
    .home-hero { min-height: 0; }
    .home-hero-text { padding: 26px 18px; }
    .hero { min-height: 130px; }
    .hero-text { padding: 20px 16px 16px; }
    .card { padding: 14px; }
    .filters > select { flex: 1 1 45%; }
}

/* Lightbox (images) */
dialog.lightbox {
    border: 1px solid #000; border-radius: var(--radius); padding: 18px 18px 12px; max-width: min(92vw, 760px); min-width: min(92vw, 380px);
    background: var(--card); color: var(--ink); box-shadow: var(--shadow-lg);
}
dialog.lightbox::backdrop { background: rgba(0, 0, 0, .8); }
dialog:modal { overscroll-behavior: contain; }
dialog::backdrop { overflow: hidden; overscroll-behavior: contain; }
dialog.lightbox figure { margin: 0; text-align: center; }
dialog.lightbox img { max-width: 100%; max-height: 76vh; object-fit: contain; }
/* Encre noire sur fond transparent : fond papier en mode sombre, sinon le dessin disparaît. */
img.encre, dialog.lightbox.encre img { background: light-dark(transparent, #ece6db); padding: 6px; border-radius: var(--radius-sm, 4px); }
.illus img.encre { filter: none; }
dialog.lightbox figcaption { margin-top: 8px; font-family: var(--font-gothic); font-size: 1.4rem; }
.lightbox-close { position: absolute; top: 8px; right: 8px; width: 44px; height: 44px; border-radius: 50%; cursor: pointer; border: 1px solid var(--line); background: var(--card); color: var(--ink); font-size: 1rem; }

/* Comptes (connexion, inscription, Mon compte, administration) */
.compte { max-width: 460px; margin: 24px auto; }
.compte-form { display: flex; flex-direction: column; gap: 12px; }
.compte-form label { display: flex; flex-direction: column; gap: 4px; }
.compte-form label.inline { flex-direction: row; align-items: center; gap: 8px; }
.compte .erreur, ul.erreur { color: var(--blood); }
.compte .validation-message { color: var(--blood); font-size: .85rem; }
.compte-carte h3 { margin-top: 0; }
.comptes td div { line-height: 1.5; }
tr.compte-bloque td { opacity: .6; }
.notes-mj { margin-top: 8px; padding: 8px 10px; border-left: 3px solid var(--torch); background: var(--torch-soft); font-size: .92rem; }

/* Page des dés : sélecteur, plateau 3D (dice-box) et résultat affiché au centre du plateau. */
.des-titre { margin-bottom: 6px; }
.des-barre { display: flex; flex-direction: column; gap: 10px; margin-bottom: 12px; }
.des-picker { display: flex; flex-wrap: wrap; gap: 8px; }
.de-btn {
    position: relative; display: flex; flex-direction: column; align-items: center; gap: 2px;
    padding: 6px 8px 4px; min-width: 58px; min-height: 58px; border: 1px solid var(--line); border-radius: 3px;
    background: var(--card); color: var(--ink); cursor: pointer; font: inherit; font-size: .8rem; font-weight: 700;
    transition: transform .12s, border-color .12s, box-shadow .12s;
}
.de-btn:hover { border-color: var(--torch); transform: translateY(-2px); box-shadow: 0 0 14px -4px var(--glow); }
.de-btn:active { transform: translateY(0) scale(.96); }
.de-icone polygon, .de-icone rect, .de-icone path { fill: var(--blood-soft); stroke: var(--rule); stroke-width: 2; stroke-linejoin: round; }
.de-icone .interieur { fill: none; stroke-width: 1.2; opacity: .7; }
.de-icone text { fill: var(--ink); font-size: 11px; font-weight: 800; stroke: none; }
.de-compte {
    position: absolute; top: -7px; right: -7px; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 10px;
    background: var(--blood); color: #fff; font-size: .75rem; line-height: 20px; text-align: center;
}
.des-jet { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.des-notation { font-size: 1.1rem; font-weight: 800; min-width: 220px; }
.des-modif { display: inline-flex; align-items: center; gap: 4px; }
.des-modif b { min-width: 2.2em; text-align: center; }
fieldset.des-mode { display: inline-flex; flex-wrap: wrap; gap: 6px; border: 0; padding: 0; margin: 0; }
.des-plateau {
    position: relative; height: max(340px, 56vh); margin-bottom: 18px; overflow: hidden; border-radius: var(--radius);
    border: 1px solid #000;
    background: radial-gradient(ellipse at 50% 35%, #3a2a1c 0%, #1a130d 55%, #070504 100%);
    box-shadow: inset 0 0 80px rgba(0, 0, 0, .7), var(--shadow);
}
.des-plateau.plat { height: auto; min-height: 160px; }
.des-canvas, .des-canvas canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.des-resultat-3d {
    position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 2; pointer-events: none;
    display: flex; flex-wrap: wrap; align-items: baseline; justify-content: center; gap: 10px; max-width: 90%;
    padding: 12px 22px; border-radius: 4px; background: rgba(5, 4, 3, .8); color: #f2ece2;
    box-shadow: 0 0 40px rgba(255, 120, 30, .25); animation: des-apparait .25s ease-out;
}
.des-resultat-3d .des-valeurs { display: flex; flex-wrap: wrap; gap: 8px; font-size: 1.3rem; }
.des-resultat-3d .des-valeurs .max { color: #ffb05c; font-weight: 800; }
.des-resultat-3d .des-valeurs .min { color: #ff6b5e; font-weight: 800; }
.des-resultat-3d .des-valeurs .ecarte { opacity: .45; text-decoration: line-through; }
.des-resultat-3d .des-valeurs .bonus { color: #e8c99a; }
.des-resultat-3d .des-egal { font-size: 1.3rem; opacity: .7; }
.des-total { font-size: 2.6rem; font-weight: 800; line-height: 1; }
.des-resultat-3d .des-total { color: #fff; }
.des-resultat-3d .des-mention { flex-basis: 100%; text-align: center; font-weight: 800; letter-spacing: .05em; }
.des-resultat-3d.crit { box-shadow: 0 0 0 2px #ff9b3d, 0 0 50px rgba(255, 140, 40, .55); }
.des-resultat-3d.crit .des-mention { color: #ffb05c; }
.des-resultat-3d.fumble { box-shadow: 0 0 0 2px #d23c30, 0 8px 30px rgba(0, 0, 0, .45); }
.des-resultat-3d.fumble .des-mention { color: #ff6b5e; }
.des-sans-3d { position: absolute; bottom: 8px; left: 12px; right: 12px; color: #d8cbb8; }
.des-panneau { max-width: 680px; }
.des-panneau p.erreur { color: var(--blood); }
.des-panneau input[type=color] { width: 48px; height: 40px; padding: 2px; border-radius: 3px; cursor: pointer; vertical-align: middle; }
.des-historique { list-style: none; padding: 0; margin: 0; }
.des-historique li { padding: 4px 0; border-bottom: 1px dotted var(--line); }
.chip-btn { font: inherit; font-size: .88rem; min-height: 38px; padding: 4px 12px; border: 1px solid var(--line); border-radius: 2px; background: var(--card); color: var(--ink); cursor: pointer; }
.chip-btn:hover { border-color: var(--torch); }
@keyframes des-apparait { from { opacity: 0; transform: translate(-50%, -40%); } to { opacity: 1; transform: translate(-50%, -50%); } }
@media (prefers-reduced-motion: reduce) { .des-resultat-3d { animation: none; } .de-btn { transition: none; } }

/* Consultation hors ligne */
.bandeau-hors-ligne { display: none; margin: 0 0 12px; padding: 8px 12px; border-radius: 3px; background: var(--torch-soft); border: 1px solid var(--torch); }
html.hors-ligne .bandeau-hors-ligne { display: block; }
html.hors-ligne #components-reconnect-modal, html.hors-ligne #blazor-error-ui { display: none !important; }
ul.hl-groupes { list-style: none; padding: 0; }
ul.hl-groupes li { margin: 4px 0; }
progress[data-hl-progression] { width: 100%; height: 10px; accent-color: var(--blood); }

/* ---------- Accessibilité des formulaires ---------- */
.visually-hidden {
    position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; border: 0;
    overflow: hidden; clip-path: inset(50%); white-space: nowrap;
}
fieldset.choix-theme { min-width: 0; border: 0; padding: 0; margin: 0 0 6px; }
fieldset.choix-theme > legend { padding: 0; }
fieldset legend h3 { margin: 0 0 8px; }
.choix-btn {
    display: inline-flex; flex-wrap: wrap; align-items: center; gap: 6px; min-height: 44px;
    font: inherit; text-align: left; padding: 6px 14px; margin: 0 8px 8px 0; cursor: pointer;
    border: 1px solid var(--line); border-radius: 3px; background: var(--card-2); color: var(--ink);
    transition: border-color .15s, background .15s;
}
.choix-btn:hover { border-color: var(--torch); }
.choix-btn:has(input:checked), .choix-btn.on { border-color: var(--blood); background: var(--blood-soft); box-shadow: inset 0 0 0 1px var(--blood); }
.choix-btn:has(input:focus-visible) { outline: 2px solid var(--torch); outline-offset: 2px; }
.choix-theme .icon { color: var(--torch); }
/* Zones tactiles d'au moins 48 px sur écran tactile */
@media (pointer: coarse) {
    .fav { width: 48px; height: 48px; }
    .choix-btn, .btn, .chip-btn, .chips a, .langue-bascule button, label.case { min-height: 48px; }
    :where(input:not([type=checkbox]):not([type=radio]), select) { min-height: 48px; }
    .crumbs a, .sommaire-fiche a, .sommaire-regles a { min-height: 48px; }
    table.grid td:first-child a { display: inline-block; padding: 6px 0; }
}

@media print {
    :root { color-scheme: light !important; }
    html, body { background: #fff !important; color: #111 !important; }
    .tiroir, .sidebar, .topbar, .hero, .tl-barre, .fav, #blazor-error-ui { display: none !important; }
    .content { margin: 0 !important; padding: 0 !important; max-width: none !important; }
    a { color: inherit; text-decoration: none; }
}
