/* Layout : barre fixe avec navigation, contenu centré 1100px ; fiche en sections ; codex en cartes ; détail en panneau. */
:root {
  --bg: #f3f4f1; --surface: #ffffff; --surface-2: #e9ebe6; --fg: #1b2230; --muted: #5d6675; --line: #d6dae0;
  --accent: #d2342b; --accent-ink: #ffffff; --hi: #ffd43b; --hi-ink: #2b2200; --ok: #1f7a4d; --warn: #b35c00;
  --c-attaque: #c62f27; --c-controle: #6f3bd6; --c-defense: #1f7a4d; --c-general: #a86200; --c-mouvement: #0f6fb5; --c-sensoriel: #0b8585;
  --c-combat: #c62f27; --c-fortune: #a86200; --c-competence: #0f6fb5; --c-extra: #1f7a4d; --c-defaut: #c62f27;
  --shadow: 0 10px 30px rgba(20, 30, 50, .18);
  --display: "Bebas Neue", "Oswald", "Arial Narrow", sans-serif;
  --body: "Source Sans 3", "Segoe UI", Helvetica, Arial, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {
  --bg: #131820; --surface: #1c232e; --surface-2: #242d3a; --fg: #e8ecf1; --muted: #9aa5b5; --line: #2f3946;
  --accent: #ff5a4f; --accent-ink: #1a0604; --hi: #ffd43b; --hi-ink: #2b2200; --ok: #52c48a; --warn: #f0a938;
  --c-attaque: #ff6b61; --c-controle: #b48cff; --c-defense: #52c48a; --c-general: #f0a938; --c-mouvement: #5db0f0; --c-sensoriel: #3fc9c9;
  --c-combat: #ff6b61; --c-fortune: #f0a938; --c-competence: #5db0f0; --c-extra: #52c48a; --c-defaut: #ff6b61;
  --shadow: 0 10px 30px rgba(0, 0, 0, .5); color-scheme: dark;
} }
:root[data-theme="dark"] {
  --bg: #131820; --surface: #1c232e; --surface-2: #242d3a; --fg: #e8ecf1; --muted: #9aa5b5; --line: #2f3946;
  --accent: #ff5a4f; --accent-ink: #1a0604; --hi: #ffd43b; --hi-ink: #2b2200; --ok: #52c48a; --warn: #f0a938;
  --c-attaque: #ff6b61; --c-controle: #b48cff; --c-defense: #52c48a; --c-general: #f0a938; --c-mouvement: #5db0f0; --c-sensoriel: #3fc9c9;
  --c-combat: #ff6b61; --c-fortune: #f0a938; --c-competence: #5db0f0; --c-extra: #52c48a; --c-defaut: #ff6b61;
  --shadow: 0 10px 30px rgba(0, 0, 0, .5); color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--fg); font-family: var(--body); font-size: 16px; line-height: 1.45; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }
a { color: inherit; }

.top { position: sticky; top: 0; z-index: 5; background: var(--bg); border-bottom: 1px solid var(--line); }
.top-inner { max-width: 1100px; margin: 0 auto; padding: 10px 16px 0; display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.brand { font-family: var(--display); font-size: 30px; letter-spacing: .02em; line-height: 1; text-decoration: none; margin-right: auto; }
.brand span { color: var(--accent); }
.nav { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; width: 100%; order: 3; }
.nav a { flex: 0 0 auto; padding: 8px 12px; border-bottom: 3px solid transparent; color: var(--muted); font-weight: 600; text-decoration: none; }
.nav a[aria-current="page"] { color: var(--fg); border-bottom-color: var(--accent); }
.who { color: var(--muted); font-size: 14px; display: flex; gap: 8px; align-items: center; }
.who b { color: var(--fg); }
.demo-badge { background: var(--hi); color: var(--hi-ink); font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 999px; text-transform: uppercase; letter-spacing: .06em; }

main { max-width: 1100px; margin: 0 auto; padding: 16px 16px 90px; }
h1, h2 { font-family: var(--display); font-weight: 400; letter-spacing: .02em; line-height: 1; margin: 0; text-wrap: balance; }
h1 { font-size: 40px; } h2 { font-size: 28px; margin: 22px 0 10px; }
h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); margin: 18px 0 6px; }
p { margin: 0 0 10px; }
.muted { color: var(--muted); }
.hint { font-size: 13px; color: var(--muted); }
.btn { border: 1px solid var(--line); background: var(--surface); border-radius: 10px; padding: 8px 14px; font-weight: 600; display: inline-flex; align-items: center; gap: 6px; text-decoration: none; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.danger { color: var(--accent); }
.btn.small { padding: 4px 10px; font-size: 14px; }
.btn:disabled { opacity: .5; cursor: default; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spread { justify-content: space-between; }
.stack { display: grid; gap: 10px; }
.error { background: color-mix(in srgb, var(--accent) 12%, var(--surface)); border: 1px solid var(--accent); border-radius: 10px; padding: 10px 12px; }
.notice { background: var(--surface-2); border-radius: 10px; padding: 10px 12px; }

/* Formulaires */
.field label { display: block; font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin-bottom: 3px; }
.field input, .field textarea, .field select { width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; background: var(--surface); }
.field textarea { min-height: 80px; resize: vertical; }
.auth { max-width: 420px; margin: 30px auto; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 22px; display: grid; gap: 12px; }
.auth .switch { text-align: center; font-size: 14px; }
.auth .switch button { border: 0; background: none; color: var(--accent); font-weight: 600; text-decoration: underline; padding: 0; }

/* Listes de persos */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; }
.pcard { border: 1px solid var(--line); background: var(--surface); border-radius: 14px; padding: 14px; display: grid; gap: 6px; text-decoration: none; min-width: 0; }
.pcard:hover { border-color: var(--fg); }
.pcard .n { font-family: var(--display); font-size: 28px; line-height: 1; }
.pcard .o { color: var(--muted); font-size: 14px; }
.pcard .pw { font-size: 14px; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.pill { display: inline-block; font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); color: var(--muted); font-variant-numeric: tabular-nums; }
.pill.ok { background: color-mix(in srgb, var(--ok) 18%, var(--surface)); color: var(--ok); }
.pill.warn { background: color-mix(in srgb, var(--warn) 18%, var(--surface)); color: var(--warn); }
.pill.bad { background: color-mix(in srgb, var(--accent) 18%, var(--surface)); color: var(--accent); }

/* Fiche */
.sheet-head { display: grid; gap: 10px; margin-bottom: 6px; }
.sheet-head input.name { width: 100%; border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px; background: var(--surface); font-family: var(--display); font-size: 32px; letter-spacing: .02em; }
.budget { position: sticky; top: 92px; z-index: 4; display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 6px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 8px 10px; margin: 10px 0; box-shadow: 0 4px 14px rgba(0,0,0,.06); }
.budget div { font-size: 13px; color: var(--muted); }
.budget div b { display: block; font-size: 20px; color: var(--fg); font-variant-numeric: tabular-nums; }
.budget div.total b { color: var(--accent); }
.budget div.over b { color: var(--accent); }
.subnav { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; border-bottom: 1px solid var(--line); margin-bottom: 12px; }
.subnav button { flex: 0 0 auto; border: 0; background: none; padding: 8px 12px; border-bottom: 3px solid transparent; color: var(--muted); font-weight: 600; }
.subnav button[aria-selected="true"] { color: var(--fg); border-bottom-color: var(--accent); }
.sec { display: grid; gap: 10px; }
table.t { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
table.t th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); padding: 8px 10px; background: var(--surface-2); font-weight: 600; }
table.t td { padding: 6px 10px; border-top: 1px solid var(--line); vertical-align: middle; }
table.t td.num, table.t th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.t input[type="number"] { width: 68px; border: 1px solid var(--line); border-radius: 8px; padding: 5px 8px; background: var(--bg); text-align: right; }
table.t input[type="text"] { width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 5px 8px; background: var(--bg); }
.wrap { overflow-x: auto; }
.cap { font-size: 12px; color: var(--muted); }
.cap.bad { color: var(--accent); font-weight: 700; }

.item { border: 1px solid var(--line); background: var(--surface); border-radius: 12px; padding: 10px 14px; display: grid; gap: 8px; }
.item .head { display: flex; gap: 10px; align-items: flex-start; justify-content: space-between; }
.item .title { font-weight: 700; font-size: 17px; }
.item .title button { border: 0; background: none; padding: 0; font: inherit; color: inherit; text-decoration: underline dotted; text-underline-offset: 3px; }
.item .sub { color: var(--muted); font-size: 13px; }
.item .fields { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.item .fields .full { grid-column: 1 / -1; }
.item input.pname { font-weight: 700; }
.cost { flex: 0 0 auto; background: var(--hi); color: var(--hi-ink); font-weight: 700; font-size: 13px; padding: 3px 8px; border-radius: 6px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.x { border: 0; background: var(--surface-2); color: var(--muted); border-radius: 8px; width: 30px; height: 30px; font-size: 16px; }

/* Picker (choisir un pouvoir/avantage) + codex */
.search { position: relative; }
.search input { width: 100%; padding: 10px 40px 10px 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); font-size: 17px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin: 10px 0; }
.chip { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 4px 12px; font-size: 14px; font-weight: 600; color: var(--muted); }
.chip[aria-pressed="true"] { background: var(--fg); color: var(--bg); border-color: var(--fg); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 10px; }
.card { text-align: left; border: 1px solid var(--line); background: var(--surface); border-radius: 12px; padding: 12px 14px; display: grid; gap: 6px; min-width: 0; }
.card:hover { border-color: var(--fg); }
.card .row2 { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.card .name { font-family: var(--display); font-size: 23px; line-height: 1; letter-spacing: .02em; }
.card .en { color: var(--muted); font-size: 13px; }
.cat { display: inline-block; font-size: 11px; text-transform: uppercase; letter-spacing: .1em; font-weight: 700; padding: 2px 7px; border-radius: 4px; border: 1px solid currentColor; }
.meta { color: var(--muted); font-size: 13px; display: flex; gap: 10px; flex-wrap: wrap; }
.meta b { color: var(--fg); font-weight: 600; }
.card .desc { font-size: 14px; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.empty { color: var(--muted); padding: 30px 0; text-align: center; grid-column: 1 / -1; }

/* Panneau de détail */
.backdrop { position: fixed; inset: 0; background: rgba(10, 14, 20, .45); z-index: 9; }
.panel { position: fixed; z-index: 10; background: var(--surface); box-shadow: var(--shadow); overflow-y: auto; overscroll-behavior: contain;
  left: 0; right: 0; bottom: 0; max-height: 88vh; border-radius: 16px 16px 0 0; padding: 14px 16px 28px; }
@media (min-width: 900px) { .panel { top: 0; bottom: 0; left: auto; right: 0; width: 540px; max-height: none; border-radius: 0; padding: 20px 24px; } }
.panel .head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.panel h2 { font-size: 34px; margin: 0; }
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px 14px; margin: 14px 0; padding: 12px; background: var(--surface-2); border-radius: 10px; font-size: 14px; }
.stats div span { display: block; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .08em; }
.panel p { max-width: 62ch; }
.opts { width: 100%; border-collapse: collapse; font-size: 14px; }
.opts td { padding: 5px 6px; border-top: 1px solid var(--line); vertical-align: top; }
.opts td:first-child { font-weight: 600; }
.opts td:nth-child(2) { white-space: nowrap; font-variant-numeric: tabular-nums; }
.note { font-size: 13px; color: var(--muted); border-left: 3px solid var(--hi); padding-left: 10px; margin: 10px 0; }
.degrees li { margin-bottom: 4px; }
.panel .actions { margin-top: 16px; display: flex; gap: 8px; flex-wrap: wrap; }

/* Vue lecture */
.ro { display: grid; gap: 14px; }
.ro .block { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
.ro .kv { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px; }
.ro .kv div { font-size: 13px; color: var(--muted); }
.ro .kv div b { display: block; font-size: 20px; color: var(--fg); font-variant-numeric: tabular-nums; }
.ro .line { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; padding: 8px 0; border-top: 1px solid var(--line); }
.ro .line:first-of-type { border-top: 0; }
.ro .line .com { grid-column: 1 / -1; white-space: pre-wrap; font-size: 14px; color: var(--muted); }

.toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); background: var(--fg); color: var(--bg); padding: 8px 14px; border-radius: 999px; font-weight: 600; z-index: 20; }
.saving { font-size: 13px; color: var(--muted); }
@media (prefers-reduced-motion: no-preference) { .panel { animation: up .18s ease-out; } @keyframes up { from { transform: translateY(16px); opacity: 0; } } }
@media (max-width: 600px) { .item .fields { grid-template-columns: 1fr; } .budget { top: 118px; grid-template-columns: repeat(4, 1fr); gap: 4px; padding: 6px 8px; } .budget div { font-size: 11px; } .budget div b { font-size: 16px; } }
.pill.secret { background: color-mix(in srgb, var(--c-controle) 18%, var(--surface)); color: var(--c-controle); }
.secret-block { border: 1px dashed var(--c-controle); border-radius: 12px; padding: 12px 14px; background: color-mix(in srgb, var(--c-controle) 6%, var(--surface)); display: grid; gap: 6px; }
.secret-block h3, .secret-block label { color: var(--c-controle) !important; }

/* ---------- Portraits et emblèmes ---------- */
.avatar { display: block; flex: 0 0 auto; object-fit: cover; border-radius: 12px; background: var(--surface-2); border: 2px solid var(--fg); }
.avatar-sm { width: 48px; height: 48px; border-radius: 10px; border-width: 1.5px; }
.avatar-md { width: 72px; height: 72px; }
.avatar-lg { width: 100%; height: auto; aspect-ratio: 16 / 10; object-position: 50% 22%; border-radius: 12px 12px 0 0; border: 0; border-bottom: 2px solid var(--fg); }
.avatar-xl { width: 168px; height: 168px; border-radius: 16px; border-width: 3px; box-shadow: 6px 6px 0 var(--fg); }
.pcard-head { display: flex; gap: 12px; align-items: center; min-width: 0; }
.sheet-title { display: flex; gap: 12px; align-items: center; }
.sheet-title input.name { flex: 1 1 auto; min-width: 0; }
.portrait-edit { display: grid; gap: 6px; justify-items: center; }

/* ---------- Barre de répartition des points ---------- */
.seg-car { background: var(--c-mouvement); } .seg-def { background: var(--c-defense); } .seg-comp { background: var(--c-general); }
.seg-av { background: var(--c-controle); } .seg-pow { background: var(--accent); }
.pbar { display: flex; height: 12px; border-radius: 999px; overflow: hidden; background: var(--surface-2); gap: 2px; }
.pbar span { display: block; height: 100%; }
.plegend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 10px; font-size: 14px; color: var(--muted); align-items: center; }
.plegend i, .steps i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.plegend b { color: var(--fg); font-variant-numeric: tabular-nums; }
.plegend .ptotal { margin-left: auto; color: var(--fg); font-weight: 700; font-variant-numeric: tabular-nums; }

/* ---------- Page Inspiration ---------- */
.insp-head { display: grid; gap: 6px; margin-bottom: 8px; }
.lead { font-size: 18px; color: var(--muted); max-width: 62ch; margin: 0; }
.explain { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 14px 18px; margin: 16px 0; }
.explain h2 { margin-top: 4px; }
.steps { list-style: none; padding: 0; margin: 12px 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; }
.steps li { display: flex; gap: 8px; align-items: flex-start; font-size: 15px; min-width: 0; }
.steps li i { flex: 0 0 auto; margin-top: 5px; width: 14px; height: 14px; }
.steps .muted { font-size: 13px; }
.hgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
.hcard { display: grid; grid-template-rows: auto 1fr; text-decoration: none; background: var(--surface); border: 2px solid var(--fg); border-radius: 14px; overflow: hidden; box-shadow: 4px 4px 0 var(--fg); transition: transform .12s ease, box-shadow .12s ease; min-width: 0; }
.hcard:hover { transform: translate(-2px, -2px); box-shadow: 6px 6px 0 var(--fg); }
.hcard-body { padding: 10px 12px 12px; display: grid; gap: 6px; align-content: start; }
.hcard-top { display: flex; justify-content: space-between; align-items: center; gap: 4px 8px; flex-wrap: wrap; min-width: 0; }
.hcard-top .tag { max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.hcard .n { font-family: var(--display); font-size: 28px; line-height: 1; letter-spacing: .02em; }
.hcard .o { color: var(--muted); font-size: 13px; }
.hcard .pitch { font-size: 14px; margin: 0; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.hcard .pw { font-size: 13px; color: var(--muted); }
.tag { display: inline-block; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; padding: 2px 8px; border-radius: 999px; background: var(--fg); color: var(--bg); white-space: nowrap; }

/* ---------- Page d'un héros ---------- */
.back { color: var(--muted); text-decoration: none; font-weight: 600; }
.hero-banner { display: flex; gap: 22px; align-items: center; flex-wrap: wrap; padding: 20px; border-radius: 18px; border: 2px solid var(--fg); margin-bottom: 14px;
  background: linear-gradient(135deg, color-mix(in srgb, var(--hero) 22%, var(--surface)) 0%, var(--surface) 70%); }
.hero-id { flex: 1 1 280px; display: grid; gap: 8px; min-width: 0; }
.hero-id p { margin: 0; max-width: 60ch; }
.hero-id .tags { display: flex; gap: 6px; flex-wrap: wrap; }
.hero-name { font-size: clamp(44px, 9vw, 72px); line-height: .9; }
.hero-concept { color: var(--muted); font-size: 17px; }
.lesson { border-left: 4px solid var(--hi); background: var(--surface); border-radius: 0 12px 12px 0; padding: 10px 14px; margin-bottom: 14px; }
.lesson h3 { margin-top: 0; }
.lesson p { margin: 0; max-width: 70ch; }
.hero-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 14px; }
main > .block, .hero-grid > .block, main > section.block { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; margin-bottom: 14px; min-width: 0; }
.hero-grid > .block { margin-bottom: 0; }
.hero-grid { margin-bottom: 14px; }
.block h3 .muted { text-transform: none; letter-spacing: 0; font-weight: 400; }
.kv { display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 8px; }
.kv div { font-size: 13px; color: var(--muted); }
.kv div b { display: block; font-size: 20px; color: var(--fg); font-variant-numeric: tabular-nums; }
.pline { padding: 8px 0; border-top: 1px solid var(--line); display: grid; gap: 4px; }
.pline:first-of-type { border-top: 0; }
.pline-head { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; flex-wrap: wrap; }
.pline .com { white-space: pre-wrap; font-size: 14px; color: var(--muted); }
.linkish { border: 0; background: none; padding: 0; font: inherit; color: var(--c-mouvement); text-decoration: underline dotted; text-underline-offset: 3px; }
.showcase-box { border: 2px solid var(--fg); border-radius: 12px; padding: 12px 14px; display: grid; gap: 8px; background: var(--surface); }
.showcase-box h3 { margin: 0; }
.showcase-box .fields { display: grid; grid-template-columns: 1fr; gap: 8px; }
@media (max-width: 600px) { .avatar-xl { width: 120px; height: 120px; } .hero-banner { padding: 14px; } .avatar-md { width: 56px; height: 56px; } }
