/* Chroniques Oubliées Fantasy — thème inspiré des livres de la 2e édition :
   pages parchemin, filets et titres or, pages de garde indigo, onglets de chapitre orangés. */

:root {
    --paper: #f3eadb;
    --paper-2: #ebdfc8;
    --card: #fbf7ef;
    --card-2: #f6efe1;
    --ink: #1d1d1b;
    --ink-soft: #4a4a49;
    --muted: #776c58;
    --line: #e0d0b0;
    --gold: #c09949;
    --gold-soft: color-mix(in srgb, var(--gold) 16%, transparent);
    --heading: #9a6420;
    --link: #7a541a;
    --ember: #d07a2a;
    --danger: #b03a2e;
    --night: #16142e;
    --night-2: #221f45;
    --night-ink: #efe6d2;
    --night-muted: #a9a2c2;
    --star: #d9a520;
    --shadow: 0 1px 2px rgba(60, 40, 10, .06), 0 6px 20px -8px rgba(60, 40, 10, .18);
    --shadow-lg: 0 2px 6px rgba(20, 15, 40, .12), 0 18px 40px -16px rgba(20, 15, 40, .45);
    --radius: 14px;
    --radius-sm: 8px;
    --font-title: "Fraunces", "Georgia", serif;
    --font-body: "Alegreya Sans", "Segoe UI", system-ui, sans-serif;
    --sidebar-w: 264px;
    --plate: radial-gradient(circle at 50% 40%, #fbf6ea, #efe3c9 75%);
    --sketch-filter: none;
    --sketch-blend: multiply;
    color-scheme: light;
}
:root[data-theme="light"] { color-scheme: light; }

/* Mode sombre : préférence du système, sauf si le lecteur a choisi « clair » ; ou choix explicite « sombre »
   (bouton du menu, attribut data-theme posé sur <html> par theme.js). */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --paper: #121025;
        --paper-2: #18162f;
        --card: #1c1a35;
        --card-2: #221f3e;
        --ink: #ece4d2;
        --ink-soft: #cfc6b2;
        --muted: #a39cb8;
        --line: #322e55;
        --gold: #d6b062;
        --gold-soft: color-mix(in srgb, var(--gold) 14%, transparent);
        --heading: #e2b866;
        --link: #e8c47a;
        --ember: #e8954a;
        --danger: #e0695b;
        --night: #0d0b1f;
        --night-2: #1a1838;
        --star: #f0c040;
        --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px -10px rgba(0, 0, 0, .6);
        --shadow-lg: 0 2px 6px rgba(0, 0, 0, .3), 0 18px 40px -16px rgba(0, 0, 0, .8);
        color-scheme: dark;
        --plate: radial-gradient(circle at 50% 40%, #2a2650, #1a1834 75%);
        --sketch-filter: invert(1) sepia(.5) saturate(1.4) brightness(.92);
        --sketch-blend: screen;
    }
}
:root[data-theme="dark"] {
    --paper: #121025;
    --paper-2: #18162f;
    --card: #1c1a35;
    --card-2: #221f3e;
    --ink: #ece4d2;
    --ink-soft: #cfc6b2;
    --muted: #a39cb8;
    --line: #322e55;
    --gold: #d6b062;
    --gold-soft: color-mix(in srgb, var(--gold) 14%, transparent);
    --heading: #e2b866;
    --link: #e8c47a;
    --ember: #e8954a;
    --danger: #e0695b;
    --night: #0d0b1f;
    --night-2: #1a1838;
    --star: #f0c040;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px -10px rgba(0, 0, 0, .6);
    --shadow-lg: 0 2px 6px rgba(0, 0, 0, .3), 0 18px 40px -16px rgba(0, 0, 0, .8);
    color-scheme: dark;
    --plate: radial-gradient(circle at 50% 40%, #2a2650, #1a1834 75%);
    --sketch-filter: invert(1) sepia(.5) saturate(1.4) brightness(.92);
    --sketch-blend: screen;
}

/* ---------- Base ---------- */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
html, body { margin: 0; }
body {
    font-family: var(--font-body);
    font-size: 1.0625rem;
    line-height: 1.55;
    background: var(--paper);
    color: var(--ink);
    -webkit-font-smoothing: antialiased;
}
a { color: var(--link); text-decoration-color: color-mix(in srgb, var(--link) 35%, transparent); text-underline-offset: 3px; }
a:hover { text-decoration-color: currentColor; }
h1, h2, h3, h4 { font-family: var(--font-title); font-variation-settings: "SOFT" 60; line-height: 1.15; color: var(--heading); font-weight: 650; }
h1 { font-size: clamp(1.9rem, 3.2vw, 2.6rem); margin: 0 0 .4em; letter-spacing: -.01em; }
h2 { font-size: 1.55rem; margin: 1.4em 0 .5em; }
h3 { font-size: 1.22rem; margin: 1.2em 0 .4em; }
h4 { font-size: 1.05rem; margin: 1em 0 .3em; }
p { margin: 0 0 .8em; }
code { font-size: .9em; background: var(--gold-soft); padding: 1px 5px; border-radius: 4px; }
::selection { background: color-mix(in srgb, var(--gold) 40%, transparent); }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
h1:focus, h1:focus-visible { outline: none; }

.muted { color: var(--muted); }
.source { color: var(--muted); font-size: .85rem; font-style: italic; margin-top: 10px; }
.small { font-size: .8rem; font-weight: normal; margin-left: 6px; font-family: var(--font-body); }

/* ---------- Structure : menu latéral indigo ---------- */
.shell { min-height: 100vh; }
.nav-toggle { position: absolute; opacity: 0; pointer-events: none; }
.topbar { 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:
        linear-gradient(180deg, rgba(22, 20, 46, .55), rgba(22, 20, 46, .92)),
        url('/img/theme/texture.jpg') center / cover,
        var(--night);
    border-right: 1px solid color-mix(in srgb, var(--gold) 35%, transparent);
    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 14px; }
.brand-mark {
    flex: none; width: 38px; height: 42px; position: relative;
    background: linear-gradient(160deg, #e6c47a, #a87a2e);
    clip-path: polygon(50% 0, 100% 25%, 100% 75%, 50% 100%, 0 75%, 0 25%);
}
.brand-mark::after {
    content: ''; position: absolute; inset: 9px 8px;
    background: var(--night);
    clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-text b { font-family: var(--font-title); font-variation-settings: "SOFT" 80; font-weight: 700; font-size: 1.12rem; color: #ecd08e; letter-spacing: .01em; }
.brand-text small { font-size: .72rem; text-transform: uppercase; letter-spacing: .16em; color: var(--night-muted); margin-top: 3px; }

.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: .95rem; color: var(--night-ink);
    padding: 8px 10px 8px 34px; border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, .12); background: rgba(255, 255, 255, .06);
}
.side-search input::placeholder { color: var(--night-muted); }
.side-search input:focus { outline: none; border-color: var(--gold); background: rgba(255, 255, 255, .1); }

.nav-group { display: flex; flex-direction: column; gap: 1px; margin-bottom: 8px; }
.nav-title { margin: 10px 10px 4px; font-size: .7rem; text-transform: uppercase; letter-spacing: .18em; color: color-mix(in srgb, var(--gold) 80%, white); opacity: .8; }
.sidebar .nav-group a {
    display: flex; align-items: center; gap: 11px;
    padding: 7px 10px; border-radius: 9px;
    color: var(--night-ink); text-decoration: none; font-size: 1rem;
    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, .07); }
.sidebar .nav-group a:hover .icon { color: #ecd08e; }
.sidebar .nav-group a.active {
    background: linear-gradient(90deg, rgba(214, 176, 98, .22), rgba(214, 176, 98, .04));
    border-left-color: #e2bd6d; color: #fff;
}
.sidebar .nav-group a.active .icon { color: #ecd08e; }
.side-foot { margin: 0 10px; padding-top: 12px; font-size: .75rem; color: var(--night-muted); opacity: .7; }
.nav-scrim { display: none; }

.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; justify-content: space-between;
        position: sticky; top: 0; z-index: 25; padding: 8px 12px 8px 16px;
        color: var(--night-ink);
        background: linear-gradient(rgba(22, 20, 46, .8), rgba(22, 20, 46, .95)), url('/img/theme/texture.jpg') center / cover, var(--night);
        border-bottom: 1px solid color-mix(in srgb, var(--gold) 35%, transparent);
    }
    .topbar .brand { padding: 0; }
    .topbar .brand-mark { width: 30px; height: 33px; }
    .topbar .brand-mark::after { inset: 7px 6px; }
    .nav-burger { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 10px; cursor: pointer; color: #ecd08e; }
    .nav-burger:hover { background: rgba(255, 255, 255, .08); }
    .sidebar { transform: translateX(-102%); transition: transform .25s ease; box-shadow: var(--shadow-lg); width: min(300px, 86vw); }
    .sidebar > .brand { display: none; }
    .sidebar { padding-top: 16px; }
    .nav-toggle:checked ~ .sidebar { transform: none; }
    .nav-toggle:checked ~ .nav-scrim { display: block; position: fixed; inset: 0; z-index: 20; background: rgba(10, 8, 25, .5); backdrop-filter: blur(2px); }
    .content { margin-left: 0; padding: 18px 16px 48px; }
}

/* ---------- Bandeaux illustrés ---------- */
.hero, .home-hero {
    position: relative; overflow: hidden; isolation: isolate;
    border-radius: var(--radius); margin: 0 0 24px;
    color: #fff; background: var(--night);
    box-shadow: var(--shadow-lg);
    border: 1px solid color-mix(in srgb, var(--gold) 45%, transparent);
}
.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;
    transform: scale(1.02);
}
.hero::after, .home-hero::after {
    content: ''; position: absolute; inset: 0; z-index: -1;
    background:
        linear-gradient(90deg, rgba(14, 12, 32, .92) 0%, rgba(14, 12, 32, .7) 38%, rgba(14, 12, 32, .1) 75%),
        linear-gradient(0deg, rgba(14, 12, 32, .55), transparent 55%);
}
.hero { min-height: 190px; display: flex; align-items: flex-end; }
.hero-text { padding: 30px clamp(20px, 3vw, 36px) 26px; max-width: 680px; }
.hero h1, .home-hero h1 { color: #fff; margin: 0; text-shadow: 0 2px 18px rgba(0, 0, 0, .5); }
.eyebrow { margin: 0 0 6px; font-size: .74rem; text-transform: uppercase; letter-spacing: .22em; color: #ecd08e; }
.eyebrow a { color: inherit; }
.hero-sub { margin: 8px 0 0; color: rgba(255, 255, 255, .85); font-size: 1.05rem; max-width: 56ch; }
.hero .filters { margin: 16px 0 0; }
.hero .chips a { background: rgba(255, 255, 255, .1); border-color: rgba(255, 255, 255, .25); color: #fff; }
.hero .tag { background: rgba(236, 208, 142, .2); color: #f3dca6; border-color: rgba(236, 208, 142, .35); }

.home-hero { min-height: min(62vh, 520px); display: flex; align-items: center; margin-bottom: 8px; }
.home-hero { --hero-pos: center 22%; }
.home-hero::after {
    background:
        linear-gradient(90deg, rgba(14, 12, 32, .94) 0%, rgba(14, 12, 32, .72) 42%, rgba(14, 12, 32, .05) 80%),
        linear-gradient(0deg, rgba(14, 12, 32, .6), transparent 50%);
}
.home-hero-text { padding: clamp(28px, 5vw, 56px); max-width: 640px; }
.home-hero h1 { font-size: clamp(2.3rem, 5vw, 3.7rem); font-weight: 750; line-height: 1.02; }
.home-hero h1 span { display: block; font-size: .5em; letter-spacing: .32em; text-transform: uppercase; color: #ecd08e; margin-top: 8px; font-weight: 600; }
.home-hero .hero-sub { font-size: 1.15rem; margin-top: 16px; }
.hero-search {
    display: flex; align-items: center; gap: 8px; margin: 24px 0 16px;
    background: rgba(255, 255, 255, .96); border-radius: 999px; padding: 5px 5px 5px 16px;
    box-shadow: 0 10px 30px -10px rgba(0, 0, 0, .6); color: #6b5f48;
}
.hero-search input { flex: 1; min-width: 0; border: 0; background: transparent; font: inherit; font-size: 1.05rem; color: #1d1d1b; padding: 8px 4px; }
.hero-search input:focus { outline: none; }
.hero-search .btn { border-radius: 999px; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 10px; }

/* ---------- Titres de section ---------- */
.section-title { display: flex; align-items: center; gap: 14px; font-size: 1.35rem; margin: 34px 0 14px; }
.section-title::before, .section-title::after { content: ''; height: 1px; flex: 1; background: linear-gradient(90deg, transparent, var(--gold)); }
.section-title::after { background: linear-gradient(90deg, var(--gold), transparent); }
.section-title span { display: inline-flex; align-items: center; gap: 12px; }
.section-title span::before, .section-title span::after { content: ''; width: 7px; height: 7px; background: var(--gold); transform: rotate(45deg); }

/* ---------- Tuiles de l'accueil ---------- */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(165px, 1fr)); gap: 14px; }
.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: 220px; padding: 16px; border-radius: var(--radius);
    color: #fff; text-decoration: none; background: var(--night);
    border: 1px solid color-mix(in srgb, var(--gold) 40%, transparent);
    box-shadow: var(--shadow);
    transition: transform .2s ease, box-shadow .2s ease, border-color .2s;
}
.tiles-wide .tile { min-height: 170px; }
.tile::before {
    content: ''; position: absolute; inset: 0; z-index: -2;
    background: var(--tile-img) center 25% / cover no-repeat;
    transition: transform .5s ease;
}
.tile::after { content: ''; position: absolute; inset: 0; z-index: -1; background: linear-gradient(0deg, rgba(14, 12, 32, .95) 8%, rgba(14, 12, 32, .35) 55%, rgba(14, 12, 32, .05)); }
.tile:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); border-color: var(--gold); }
.tile:hover::before { transform: scale(1.06); }
.tile-count {
    position: absolute; top: 12px; right: 12px;
    font-family: var(--font-title); font-weight: 700; font-size: 1.05rem;
    padding: 2px 11px; border-radius: 999px;
    background: rgba(14, 12, 32, .65); border: 1px solid rgba(236, 208, 142, .5); color: #ecd08e;
    backdrop-filter: blur(4px);
}
.tile-body { display: flex; flex-direction: column; gap: 2px; }
.tile-label { display: flex; align-items: center; gap: 8px; font-family: var(--font-title); font-variation-settings: "SOFT" 60; font-size: 1.3rem; font-weight: 650; }
.tile-label .icon { color: #ecd08e; }
.tile-sub { font-size: .9rem; color: rgba(255, 255, 255, .78); }

/* ---------- Fil d'Ariane ---------- */
.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: .88rem; color: var(--muted); margin: 0 0 12px; }
.crumbs a { display: inline-flex; align-items: center; gap: 5px; text-decoration: none; color: var(--muted); }
.crumbs a:hover { color: var(--link); }

/* ---------- Boutons, champs ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 7px;
    font: inherit; font-weight: 700; font-size: .98rem; line-height: 1.2;
    padding: 9px 18px; border-radius: 10px; cursor: pointer; text-decoration: none;
    color: #2a1c05; border: 1px solid #b48a3a;
    background: linear-gradient(180deg, #ecca7e, #cf9f4b);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .45), 0 2px 6px -2px rgba(120, 80, 10, .5);
    transition: filter .15s, transform .05s;
}
.btn:hover { filter: brightness(1.06); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: default; filter: grayscale(.4); }
.btn.ghost { background: rgba(255, 255, 255, .08); color: #fff; border-color: rgba(255, 255, 255, .35); box-shadow: none; }
.btn.ghost:hover { background: rgba(255, 255, 255, .16); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; box-shadow: none; }

:where(button:not(.btn, .fav, .rang, .choix-btn)) {
    font: inherit; font-size: .95rem; padding: 7px 14px; border-radius: 10px; cursor: pointer;
    border: 1px solid var(--line); background: var(--card); color: var(--ink);
    transition: border-color .15s, background .15s;
}
:where(button:not(.btn, .fav, .rang, .choix-btn)):hover { border-color: var(--gold); background: var(--card-2); }

:where(input:not([type=checkbox]):not([type=radio]), select, textarea) {
    font: inherit; font-size: .98rem; color: var(--ink);
    padding: 8px 11px; border-radius: 10px;
    border: 1px solid 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(--gold); box-shadow: 0 0 0 3px var(--gold-soft); }
select { cursor: pointer; }
input[type=checkbox] { accent-color: var(--gold); width: 16px; height: 16px; }
textarea { width: 100%; }

.filters {
    display: flex; gap: 10px; flex-wrap: wrap; align-items: center;
    margin: 0 0 16px; padding: 12px; border-radius: var(--radius);
    background: var(--card); border: 1px solid var(--line);
}
.filters > input:first-child:not([type=checkbox]) { flex: 1 1 220px; }
.filters label { display: flex; gap: 6px; align-items: center; color: var(--muted); font-size: .95rem; }
.filters.col { flex-direction: column; align-items: stretch; }
.filters label.full, label.full { display: flex; flex-direction: column; align-items: stretch; }
.card .filters, .wizard .filters, .fiche-head .filters, .hero .filters, .editor .filters { background: none; border: 0; padding: 0; }
.count { color: var(--muted); font-size: .92rem; margin: -4px 0 10px; }

/* ---------- Cartes ---------- */
.card {
    position: relative;
    background: var(--card); border: 1px solid color-mix(in srgb, var(--gold) 38%, var(--line));
    border-radius: var(--radius); padding: 20px 24px; margin: 14px 0;
    box-shadow: var(--shadow);
}
.card::after { content: ''; display: block; clear: both; }
.card > h2:first-child, .card > h3:first-child, .card > h1:first-child { margin-top: 0; }
.card.fam { border-left: 4px solid var(--gold); }
.card h2 { font-size: 1.6rem; }

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

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

/* Lignes de caractéristiques façon encadré du livre : | AGI +1 | CON +2 | */
.statline { display: flex; flex-wrap: wrap; margin: 8px 0; font-variant-numeric: tabular-nums; }
.statline > span {
    padding: 3px 12px; border-left: 1px solid color-mix(in srgb, var(--gold) 60%, transparent);
    background: var(--card-2);
}
.statline > span:first-child { border-radius: 6px 0 0 6px; }
.statline > span:last-child { border-right: 1px solid color-mix(in srgb, var(--gold) 60%, transparent); border-radius: 0 6px 6px 0; }
.statline b { color: var(--heading); }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(68px, 1fr)); gap: 6px; margin: 14px 0 10px; max-width: 560px; }
.stat {
    display: flex; flex-direction: column; align-items: center; padding: 6px 4px;
    border-radius: 10px; background: var(--card-2); border: 1px solid var(--line);
    font-variant-numeric: tabular-nums;
}
.stat .lbl { font-size: .7rem; font-weight: 700; letter-spacing: .1em; color: var(--muted); }
.stat b { font-family: var(--font-title); font-size: 1.25rem; color: var(--ink); }
.stat.sup { border-color: var(--gold); background: var(--gold-soft); }
.stat.key { background: linear-gradient(180deg, color-mix(in srgb, var(--gold) 22%, var(--card)), var(--card-2)); border-color: color-mix(in srgb, var(--gold) 55%, transparent); }
.stat.key b { color: var(--heading); }

.attacks { margin: 10px 0 14px; display: flex; flex-direction: column; gap: 4px; }
.attack { padding: 6px 12px; border-radius: 8px; background: var(--card-2); border-left: 3px solid var(--ember); }

.capacity { padding: 10px 0; border-top: 1px dashed color-mix(in srgb, var(--gold) 40%, transparent); }
.capacity h4 { margin: 0 0 3px; font-size: 1.08rem; color: var(--ink); }
.capacity h4 .rank {
    display: inline-grid; place-items: center; width: 24px; height: 24px; margin-right: 6px;
    border-radius: 50%; font-size: .8rem; color: #2a1c05; background: linear-gradient(180deg, #ecca7e, #cf9f4b);
    font-family: var(--font-body); font-weight: 700; vertical-align: 2px;
}
.capacity p { margin: 0; color: var(--ink-soft); }

/* Illustrations des fiches */
.illus {
    float: right; width: min(38%, 380px); margin: 0 0 14px 22px; padding: 12px;
    border-radius: var(--radius); text-align: center;
    background: radial-gradient(circle at 50% 45%, color-mix(in srgb, var(--gold) 22%, transparent), transparent 70%);
}
.illus img { max-width: 100%; max-height: 440px; object-fit: contain; filter: drop-shadow(0 10px 18px rgba(30, 20, 5, .3)); }
@media (max-width: 720px) { .illus { float: none; width: auto; margin: 0 0 12px; } .illus img { max-height: 320px; } }

/* ---------- Tableaux ---------- */
.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--line); background: var(--card); box-shadow: var(--shadow); margin: 0 0 20px; }
table.grid { border-collapse: collapse; width: 100%; font-size: .97rem; 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: .74rem; font-weight: 700; text-transform: uppercase; letter-spacing: .1em; color: var(--muted);
    background: var(--card-2); white-space: nowrap;
}
table.grid tbody tr:last-child td { border-bottom: 0; }
table.grid tbody tr { transition: background .12s; }
table.grid tbody tr:hover { background: var(--gold-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 .source { margin: 0; font-size: .82rem; white-space: nowrap; }
.card table.grid { font-size: .93rem; }
.card .table-wrap { box-shadow: none; }
table.grid.compact td, table.grid.compact th { padding: 5px 8px; }

/* ---------- 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; }
.link-list li a {
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
    padding: 11px 14px; border-radius: 10px; text-decoration: none; color: var(--ink);
    background: var(--card); border: 1px solid var(--line); transition: border-color .15s, transform .15s;
}
.link-list li a:hover { border-color: var(--gold); transform: translateX(2px); }
.link-list li a .icon { color: var(--gold); flex: none; }
.link-list .muted { font-size: .88rem; }

.profil-list { list-style: none; padding: 0; margin: 4px 0 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 6px 14px; }
.profil-list li { padding: 6px 0; border-bottom: 1px dotted var(--line); }
.profil-list li a { font-weight: 700; text-decoration: none; }

.etats { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; }
.etats .card { margin: 0; }
.etats .card h3 { margin-top: 0; display: flex; align-items: center; gap: 8px; }
.etats .card h3 .icon { color: var(--ember); }

dl.meta { display: grid; grid-template-columns: max-content 1fr; gap: 6px 18px; margin: 12px 0 16px; padding: 12px 16px; border-radius: 10px; background: var(--card-2); }
dl.meta dt { color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .08em; align-self: center; }
dl.meta dd { margin: 0; }

/* ---------- Règles (Markdown) ---------- */
.markdown { max-width: 78ch; }
.markdown h1 { margin-bottom: .6em; }
.markdown h2 { padding-bottom: 6px; border-bottom: 1px solid color-mix(in srgb, var(--gold) 50%, transparent); }
.markdown img { max-width: 100%; }
.markdown blockquote { margin: 1em 0; padding: 10px 18px; border-left: 3px solid var(--gold); background: var(--card-2); border-radius: 0 10px 10px 0; color: var(--ink-soft); }
.markdown table { border-collapse: collapse; margin: 1em 0; font-size: .95rem; display: block; overflow-x: auto; }
.markdown th, .markdown td { padding: 6px 10px; border-bottom: 1px solid var(--line); text-align: left; }
.markdown th { background: var(--card-2); }

/* ---------- Favoris ---------- */
.fav {
    display: inline-grid; place-items: center; width: 34px; height: 34px; vertical-align: middle;
    font: inherit; font-size: 1.15rem; line-height: 1; padding: 0; margin-left: 10px;
    border-radius: 50%; cursor: pointer;
    color: var(--muted); background: var(--card); border: 1px solid var(--line);
    transition: color .15s, border-color .15s, transform .15s;
}
.fav:hover { color: var(--star); border-color: var(--star); transform: scale(1.08); }
.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; transform: none; }

/* ---------- Personnages : wizard et fiche ---------- */
ol.etapes { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 18px; counter-reset: none; }
ol.etapes button {
    font: inherit; font-size: .95rem; padding: 7px 14px; cursor: pointer;
    border: 1px solid var(--line); border-radius: 999px; background: var(--card); color: var(--ink);
}
ol.etapes li.done button { border-color: var(--gold); color: var(--heading); }
ol.etapes li.on button { background: linear-gradient(180deg, #ecca7e, #cf9f4b); color: #2a1c05; border-color: #b48a3a; font-weight: 700; }
.wizard { display: grid; grid-template-columns: minmax(0, 3fr) minmax(300px, 2fr); gap: 24px; align-items: start; }
.wizard-side { position: sticky; top: 16px; }
.wizard-main > h2:first-child { margin-top: 0; }
@media (max-width: 1100px) { .wizard { grid-template-columns: 1fr; } .wizard-side { position: static; } }
.nav-etapes { display: flex; justify-content: space-between; margin-top: 20px; }
.choix { display: flex; flex-wrap: wrap; gap: 8px; }
.choix-btn {
    font: inherit; text-align: left; padding: 8px 14px; cursor: pointer;
    border: 1px solid var(--line); border-radius: 10px; background: var(--card-2); color: var(--ink);
    transition: border-color .15s, background .15s;
}
.choix-btn:hover { border-color: var(--gold); }
.choix-btn.on { border-color: var(--gold); background: var(--gold-soft); box-shadow: inset 0 0 0 1px var(--gold); }
.editor h4 { margin: 16px 0 8px; }
.caracs-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 8px; }
.carac-cell { display: flex; flex-direction: column; gap: 3px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); }
.carac-cell .lbl { font-weight: 700; color: var(--heading); letter-spacing: .05em; }
.carac-cell select, .carac-cell input { padding: 5px 6px; background: var(--paper); }
.voie-edit { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 7px 8px; border-bottom: 1px dotted var(--line); border-radius: 8px; }
.voie-edit.on { background: var(--gold-soft); }
.rangs { display: inline-flex; gap: 4px; }
.rang {
    font: inherit; font-size: .85rem; font-weight: 700; width: 28px; height: 28px; padding: 0; cursor: pointer;
    border: 1px solid var(--line); border-radius: 50%; background: var(--card); color: var(--muted);
}
.rang.on { background: linear-gradient(180deg, #ecca7e, #cf9f4b); color: #2a1c05; border-color: #b48a3a; }
.fiche .caracs .carac { padding: 3px 12px; }
.derives { display: grid; grid-template-columns: repeat(auto-fit, minmax(70px, 1fr)); gap: 6px; margin: 12px 0; }
.derives div { text-align: center; padding: 6px 4px; border: 1px solid var(--line); border-radius: 10px; background: var(--card-2); }
.derives .lbl { display: block; color: var(--muted); font-size: .72rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; }
.derives b { font-family: var(--font-title); font-size: 1.25rem; color: var(--heading); }
.voie-ligne { margin: 8px 0; }
ul.caps { margin: 2px 0 6px; padding-left: 18px; }
.cap-text { color: var(--muted); font-size: .92rem; }
ul.problemes { padding-left: 18px; margin: 12px 0 0; }
ul.problemes .err { color: var(--danger); }
ul.problemes .warn { color: var(--muted); }
details { margin: 10px 0; padding: 4px 18px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); }
details[open] { padding-bottom: 14px; }
details summary { cursor: pointer; list-style: none; display: flex; align-items: center; gap: 8px; }
details summary::-webkit-details-marker { display: none; }
details summary h3 { display: inline-block; margin: 10px 0; }
details summary::before { content: '▸'; color: var(--gold); transition: transform .15s; }
details[open] summary::before { transform: rotate(90deg); }
.fiche-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 10px; }
.fiche-head h1 { margin: 0; }

/* ---------- Erreur Blazor ---------- */
#blazor-error-ui { display: none; position: fixed; bottom: 0; left: 0; right: 0; z-index: 1000; background: #fff4d6; color: #1d1d1b; padding: 10px 16px; border-top: 2px solid var(--gold); }
#blazor-error-ui .dismiss { cursor: pointer; float: right; }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { transition: none !important; }
}
.card .card { background: var(--card-2); box-shadow: none; }

/* ---------- Ajustements ---------- */
body { font-variant-numeric: lining-nums; }
.home-hero-text, .hero-text { min-width: 0; flex: 1; }
@media (max-width: 600px) {
    .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
    .tile { min-height: 150px; padding: 12px; }
    .tile-label { font-size: 1.1rem; }
    .tile-sub { font-size: .8rem; }
    .tile-count { font-size: .9rem; padding: 1px 9px; top: 8px; right: 8px; }
    .home-hero { min-height: 0; }
    .home-hero-text { padding: 26px 20px; }
    .hero-search { padding-left: 12px; }
    .hero-search .btn { padding: 9px 14px; }
    .hero { min-height: 150px; }
    .hero-text { padding: 22px 18px 18px; }
    .card { padding: 16px; }
    .filters > select { flex: 1 1 40%; }
}
.choix-btn .muted, .choix-btn .tag { margin-left: 5px; }

/* ---------- Équipement : croquis du livre ----------
   Plaques aux couleurs du thème ; les croquis au crayon (fond blanc, classe .trait) sont fondus en « produit »
   sur le parchemin, et inversés en trait de craie (« écran ») en mode sombre. */
.planche { display: flex; gap: 12px; overflow-x: auto; padding: 4px 2px 14px; margin: 0 0 12px; scroll-snap-type: x proximity; scrollbar-width: thin; }
.croquis { flex: none; width: 150px; display: flex; flex-direction: column; gap: 6px; text-decoration: none; color: var(--ink); scroll-snap-align: start; }
.plate {
    display: flex; align-items: center; justify-content: center; height: 170px; padding: 10px; border-radius: 12px; overflow: hidden;
    background: var(--plate);
    border: 1px solid color-mix(in srgb, var(--gold) 40%, transparent);
    box-shadow: var(--shadow); transition: transform .2s, border-color .2s;
}
.plate img { max-width: 130px; max-height: 150px; object-fit: contain; }
.croquis.trait .plate img, .eq-thumb.trait img { filter: var(--sketch-filter); mix-blend-mode: var(--sketch-blend); }
.croquis:hover .plate { transform: translateY(-3px); border-color: var(--gold); }
.croquis-nom { font-size: .88rem; line-height: 1.25; text-align: center; color: var(--ink-soft); }
table.grid .thumb-col { width: 58px; padding: 4px 6px; }
.eq-thumb {
    display: flex; align-items: center; justify-content: center; width: 46px; height: 46px; border-radius: 8px; overflow: hidden;
    background: var(--plate); border: 1px solid color-mix(in srgb, var(--gold) 35%, transparent);
}
.eq-thumb img { max-width: 40px; max-height: 40px; object-fit: contain; }
.eq-thumb:hover { border-color: var(--gold); }

dialog.lightbox {
    border: 1px solid var(--gold); border-radius: var(--radius); padding: 18px 18px 12px; max-width: min(92vw, 720px); min-width: min(92vw, 380px);
    background: var(--plate); color: var(--ink); box-shadow: var(--shadow-lg);
}
dialog.lightbox::backdrop { background: rgba(10, 8, 25, .7); backdrop-filter: blur(3px); }
dialog.lightbox figure { margin: 0; text-align: center; }
dialog.lightbox img { max-width: 100%; max-height: 76vh; object-fit: contain; }
dialog.lightbox figcaption { margin-top: 8px; font-family: var(--font-title); font-size: 1.15rem; color: var(--heading); }
dialog.lightbox.trait img { filter: var(--sketch-filter); mix-blend-mode: var(--sketch-blend); }

.lightbox-close {
    position: absolute; top: 8px; right: 8px; width: 34px; height: 34px; border-radius: 50%; cursor: pointer;
    border: 1px solid var(--line); background: var(--card); color: var(--ink); font-size: 1rem;
}

/* ---------- Choix du thème (menu latéral) ---------- */
.sidebar .theme-toggle {
    display: flex; align-items: center; margin: auto 4px 0; padding: 7px 12px; border-radius: 999px; cursor: pointer;
    font: inherit; font-size: .88rem; color: var(--night-muted);
    background: rgba(255, 255, 255, .05); border: 1px solid rgba(255, 255, 255, .12);
}
.sidebar .theme-toggle:hover { color: #ecd08e; border-color: rgba(236, 208, 142, .45); background: rgba(255, 255, 255, .08); }
.theme-toggle span { display: none; align-items: center; gap: 9px; }
:root:not([data-theme]) .theme-toggle .t-auto,
:root[data-theme="light"] .theme-toggle .t-light,
:root[data-theme="dark"] .theme-toggle .t-dark { display: inline-flex; }

/* Effets chiffrés des capacités (fiche de personnage et fiche de voie) */
.chips.effets .tag { font-size: 0.78rem; }
.chips.effets .tag.perm { border: 1px solid var(--gold, #c09949); }
ul.situations { padding-left: 18px; font-size: 0.92rem; }
ul.situations li { margin: 4px 0; }
tr.muted td { opacity: 0.55; }

/* Comptes (connexion, inscription) et utilisateur du menu latéral */
.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-form input[type=text], .compte-form input[type=password] { font: inherit; padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--card); color: var(--ink); }
.compte .erreur, ul.erreur { color: #b33; }
.compte .validation-message { color: #b33; font-size: 0.85rem; }
.side-user { display: flex; align-items: center; gap: 6px; padding: 6px 8px; margin-top: auto; font-size: 0.9rem; }
.side-user-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-logout { margin-left: auto; }

/* Portrait de personnage envoyé par le joueur */
.portrait { margin: 0 0 12px; text-align: center; }
.portrait img { max-width: 100%; max-height: 320px; border-radius: 10px; border: 1px solid var(--line); object-fit: cover; }
.portrait-mini { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; vertical-align: middle; margin-right: 6px; border: 1px solid var(--line); }

/* Fiche de personnage imprimable (/personnages/{id}/imprimer) */
.print-actions { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 16px; }
.feuille { max-width: 860px; margin: 0 auto; background: var(--card); color: var(--ink); border: 1px solid var(--line); border-radius: 10px; padding: 24px 28px; }
.feuille-tete { display: flex; gap: 18px; align-items: center; border-bottom: 2px solid var(--gold, #c09949); padding-bottom: 12px; margin-bottom: 12px; }
.feuille-tete h1 { margin: 0 0 4px; }
.feuille-tete p { margin: 0; color: var(--muted); }
.feuille-portrait { width: 110px; height: 110px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); }
.feuille-bloc { margin: 12px 0; break-inside: avoid; }
.feuille-bloc h2 { font-size: 1.1rem; margin: 14px 0 6px; border-bottom: 1px solid var(--line); padding-bottom: 3px; }
.feuille-caracs, .feuille-derives { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.feuille-caracs div, .feuille-derives div { border: 1px solid var(--line); border-radius: 6px; padding: 4px; text-align: center; }
.feuille-caracs span, .feuille-derives span { display: block; font-size: .75rem; color: var(--muted); }
.feuille-caracs b, .feuille-derives b { font-size: 1.15rem; }
.feuille-derives small { display: block; font-size: .7rem; color: var(--muted); }
.feuille-table { border-collapse: collapse; width: 100%; font-size: .92rem; margin: 6px 0; }
.feuille-table th, .feuille-table td { border-bottom: 1px solid var(--line); padding: 3px 6px; text-align: left; }
.feuille-voie { break-inside: avoid; }
.feuille-voie h3 { font-size: 1rem; margin: 10px 0 2px; }
.feuille-voie p { margin: 2px 0 4px; font-size: .9rem; }
.feuille-pied { margin-top: 16px; font-size: .75rem; color: var(--muted); text-align: right; }
@media (max-width: 640px) { .feuille-caracs, .feuille-derives { grid-template-columns: repeat(4, 1fr); } .feuille { padding: 16px; } }

@media print {
    :root { --paper: #fff; --card: #fff; --ink: #111; --muted: #555; --line: #bbb; color-scheme: light; }
    html, body { background: #fff !important; color: #111 !important; }
    .sidebar, .topbar, .nav-scrim, .nav-toggle, .no-print, #blazor-error-ui, .theme-toggle { display: none !important; }
    .content { margin: 0 !important; padding: 0 !important; max-width: none !important; }
    .feuille { border: none; border-radius: 0; padding: 0; max-width: none; }
    .feuille-voie p { font-size: 9.5pt; }
    a { color: inherit; text-decoration: none; }
    @page { margin: 12mm; }
}

/* Table de jeu (MJ) et page Dés */
.table-jeu { display: grid; grid-template-columns: minmax(0, 3fr) minmax(260px, 1fr); gap: 18px; align-items: start; }
.table-jeu-side { position: sticky; top: 12px; }
@media (max-width: 1000px) { .table-jeu { grid-template-columns: 1fr; } .table-jeu-side { position: static; } }
.titre-edit { font: inherit; color: inherit; background: transparent; border: 1px dashed transparent; border-radius: 6px; padding: 0 4px; width: 100%; max-width: 640px; }
.titre-edit:hover, .titre-edit:focus { border-color: var(--line); outline: none; }
.tag.round { font-size: 0.95rem; padding: 4px 10px; }
.combattant { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; margin: 10px 0; border-left: 4px solid var(--line); }
.combattant.pj { border-left-color: var(--accent); }
.combattant.actif { box-shadow: 0 0 0 2px var(--gold, #c09949); border-left-color: var(--gold, #c09949); }
.combattant.hors { opacity: 0.55; }
.combattant-tete { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.combattant-nom { font-size: 1.05rem; }
.combattant-actions { margin-left: auto; display: inline-flex; gap: 4px; }
.combattant .init { width: 58px; font: inherit; font-weight: 700; text-align: center; padding: 3px; border: 1px solid var(--line); border-radius: 6px; background: var(--paper, var(--bg)); color: var(--ink); }
.combattant .pv { font-weight: 700; }
.combattant .pv.bas { color: #c0392b; }
.pv-barre { height: 5px; background: var(--line); border-radius: 3px; margin: 6px 0; overflow: hidden; }
.pv-barre span { display: block; height: 100%; background: linear-gradient(90deg, #b8453b, #c09949 50%, #4f8a4b); background-size: 300% 100%; background-position: right; }
.filters.compact { gap: 6px; margin: 4px 0; }
.filters.compact input, .filters.compact select { padding: 4px 6px; }
.tag.etat { background: color-mix(in srgb, #c0392b 18%, var(--line)); }
.tag-x { background: none; border: none; color: inherit; cursor: pointer; padding: 0 0 0 4px; font: inherit; }
.chip-btn { font: inherit; font-size: 0.85rem; padding: 3px 10px; border: 1px solid var(--line); border-radius: 14px; background: var(--card); color: var(--ink); cursor: pointer; }
.chip-btn:hover { border-color: var(--gold, #c09949); }
.journal ol { padding-left: 0; list-style: none; margin: 0; max-height: 60vh; overflow-y: auto; font-size: 0.86rem; }
.journal li { padding: 3px 0; border-bottom: 1px dotted var(--line); }
.des-panneau { max-width: 640px; }
.des-resultat { display: flex; align-items: baseline; gap: 14px; margin: 16px 0 8px; padding: 12px 16px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); }
.des-resultat.crit { border-color: var(--gold, #c09949); box-shadow: 0 0 0 2px var(--gold, #c09949); }
.des-resultat.fumble { border-color: #c0392b; }
.des-total { font-size: 2.6rem; font-weight: 800; line-height: 1; }
.des-historique { list-style: none; padding: 0; margin: 0; }
.des-historique li { padding: 3px 0; border-bottom: 1px dotted var(--line); }
.fiche-head h1:has(.titre-edit) { flex: 1 1 380px; min-width: 0; }
.titre-edit { min-width: 16ch; }
.opposition { margin: 4px 0 10px; }
ul.propositions { list-style: none; padding: 0; margin: 8px 0 0; }
ul.propositions li { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px dotted var(--line); }
ul.propositions li button { margin-left: auto; }
tr.ligne-active td { background: color-mix(in srgb, var(--gold, #c09949) 18%, transparent); font-weight: 600; }
.card.session h3, .card.pnj-campagne h3 { margin-top: 0; }
.notes-mj { margin-top: 8px; padding: 8px 10px; border-left: 3px solid var(--gold, #c09949); background: color-mix(in srgb, var(--gold, #c09949) 8%, transparent); font-size: 0.92rem; }

/* Consultation hors ligne */
.bandeau-hors-ligne { display: none; margin: 0 0 12px; padding: 8px 12px; border-radius: 8px; background: color-mix(in srgb, var(--gold, #c09949) 22%, transparent); border: 1px solid var(--gold, #c09949); }
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: 6px 0; }
progress[data-hl-progression] { width: 100%; height: 10px; }

/* Aides de jeu des campagnes */
.aides-grille { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; margin: 10px 0 18px; }
.aide { margin: 0; background: var(--card); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; display: flex; flex-direction: column; }
.aide.revelee { border-color: var(--gold, #c09949); box-shadow: 0 0 0 1px var(--gold, #c09949); }
.aide img { width: 100%; aspect-ratio: 3 / 4; object-fit: cover; display: block; background: var(--line); }
.aide figcaption { padding: 6px 8px; font-size: 0.85rem; display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.aide-titre { flex: 1 1 100%; font: inherit; padding: 3px 5px; border: 1px solid var(--line); border-radius: 4px; background: var(--paper, var(--bg)); color: var(--ink); }
.aide-revele { display: inline-flex; gap: 4px; align-items: center; }

/* Texte libre saisi sur plusieurs lignes (fiche en lecture seule). */
.pre-wrap { white-space: pre-wrap; }

/* Colonne du dé dans les tables de tirage. */
table.grid .col-de { width: 1%; white-space: nowrap; text-align: center; font-weight: 700; color: var(--gold, #c09949); }
