/* ===== Humane Gang — base commune (chargée par toutes les pages) ===== */

:root {
  /* Couleurs de marque (bande arc-en-ciel uniquement, en pleine saturation) */
  --brand-red: #B70127;
  --brand-black: #000000;
  --rb-1: #FE3104; --rb-2: #FCA301; --rb-3: #FBD32D; --rb-4: #159946; --rb-5: #2B5AE2; --rb-6: #4E2398;

  /* Interface désaturée */
  --bg: #0E0E10;
  --surface: #17171A;
  --surface-2: #1F1F23;
  --border: #2A2A2F;
  --border-strong: #3A3A40;
  --text: #F2EFEA;
  --muted: #ABA7A0;

  --accent: #9E3543;          /* rouge désaturé : action principale */
  --accent-text: #ffffff;
  --sand: #E2C77E;            /* jaune désaturé */
  --amber: #D8A75E;
  --rust: #CF7055;
  --sage: #6FA37F; --sage-soft: #18241C; --sage-text: #8FC39F;
  --slate: #7E93C9;
  --plum: #9A88C4;
  --rose: #E0909A;

  /* Couleurs de section */
  --ss-bg: #2A1A1D; --ss-border: #3A2529; --ss-fg: #E0909A;
  --irl-bg: #29251A; --irl-border: #3A3424; --irl-fg: #E2C77E;
  --hist-bg: #171C29; --hist-border: #252C3D; --hist-fg: #7E93C9;

  --side-w: 64px;             /* largeur de la colonne d'outils (ordinateur) */
  --radius: 20px;
  --radius-sm: 12px;
  --font-display: 'Archivo Black', system-ui, sans-serif;
  --font-body: 'Inter', system-ui, sans-serif;
  --maxw: 1200px;
}

/* Les thèmes (table hg_themes) surchargent --accent, --bg, --surface(-2), --border(-strong), --text, --muted, --sand
   directement sur :root via core.js (applyTheme) ; data-theme="<slug>" est posé sur <html>. */

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: var(--font-body); font-size: 16px; line-height: 1.5;
  min-height: 100vh; display: flex; flex-direction: column;
}
main { flex: 1; }
img { max-width: 100%; display: block; }
a { color: var(--sand); }
@media (hover: hover) { a:hover { color: var(--amber); } }
h1, h2, h3 { margin: 0; }
.display { font-family: var(--font-display); font-weight: 400; letter-spacing: 0.2px; }
:focus-visible { outline: 2px solid var(--sand); outline-offset: 2px; }

.rainbow { height: 6px; display: flex; }
.rainbow span { flex: 1; }
.rainbow span:nth-child(1){background:var(--rb-1)} .rainbow span:nth-child(2){background:var(--rb-2)}
.rainbow span:nth-child(3){background:var(--rb-3)} .rainbow span:nth-child(4){background:var(--rb-4)}
.rainbow span:nth-child(5){background:var(--rb-5)} .rainbow span:nth-child(6){background:var(--rb-6)}

.container { width: 100%; max-width: var(--maxw); margin: 0 auto; padding: 0 24px; }
@media (max-width: 600px) { .container { padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right)); } }
button, a, label, summary, input, select, textarea { -webkit-tap-highlight-color: transparent; }

/* ---------- En-tête ---------- */
.site-header { border-bottom: 1px solid var(--border); }
.site-header .container { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; padding-top: 14px; padding-bottom: 14px; }
.brand { display: flex; align-items: center; gap: 12px; color: var(--text); text-decoration: none; }
.brand img { width: 44px; height: 44px; object-fit: contain; image-rendering: pixelated; }
.brand span { font-family: var(--font-display); font-size: 20px; }
.nav { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; justify-content: flex-end; flex: 1 1 auto; }
.nav-tools { display: flex; gap: 6px; align-items: center; }
/* Colonne d'outils : fixe à droite sur ordinateur (le contenu lui laisse la place, voir plus bas) */
.side-tools { display: flex; flex-direction: column; align-items: center; gap: 8px; min-width: 0; }
.side-tools .nav-account { color: var(--accent-text); text-decoration: none; border-radius: 999px; min-height: 44px; display: inline-flex; align-items: center; gap: 8px; }
.nav a { color: var(--text); text-decoration: none; padding: 10px 14px; border-radius: 999px; border: 1px solid transparent;
  min-height: 44px; display: inline-flex; align-items: center; gap: 8px; }
@media (hover: hover) { .nav a:hover { background: var(--surface-2); color: var(--text); } }
.nav a[aria-current="page"] { background: var(--surface-2); border-color: var(--border-strong); font-weight: 700; }
.nav a.nav-admin { color: var(--muted); font-size: 14px; }
.nav-account { background: var(--accent); font-weight: 700; padding: 4px 16px 4px 4px; max-width: 220px; border: 1px solid transparent; }
@media (hover: hover) { .nav-account:hover { filter: brightness(1.1); color: var(--accent-text); } }
.nav-account[aria-current="page"] { border-color: var(--sand); }
.nav-account.is-guest { padding: 10px 16px; }
.nav-account .avatar { font-size: 12px; box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent-text) 35%, transparent); }
.nav-account-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav a.nav-msg { position: relative; }
.nav-badge { min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--sand); color: #121212;
  font-size: 12px; font-weight: 700; line-height: 20px; text-align: center; }
.nav-badge[hidden] { display: none; }
a.nav-icon { text-decoration: none; }
.nav-icon { font: inherit; width: 44px; height: 44px; display: inline-grid; place-items: center; border-radius: 999px; cursor: pointer;
  color: var(--muted); background: transparent; border: 1px solid var(--border); }
@media (hover: hover) { .nav-icon:hover { color: var(--text); background: var(--surface-2); border-color: var(--border-strong); } }
@media (min-width: 761px) {
  /* Ordinateur : la colonne d'outils est fixe à droite, de bord à bord en hauteur ; le contenu s'arrête avant elle */
  body { padding-right: var(--side-w); }
  .nav-tools { display: none; }
  .side-tools { position: fixed; top: var(--god-h, 0px); right: 0; bottom: 0; width: var(--side-w); z-index: 40;
    padding: 12px 0; overflow-y: auto; overscroll-behavior: contain; background: var(--surface); border-left: 1px solid var(--border); }
  .side-tools .nav-account { width: 44px; height: 44px; padding: 0; max-width: none; justify-content: center; }
  .side-tools .nav-account:not(.is-guest) .avatar { width: 36px !important; height: 36px !important; }
  .side-tools .nav-account .nav-account-name { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .side-tools .nav-account-ico { display: inline-flex; }
  .toasts { right: calc(var(--side-w) + 16px); }
  .cookie-notice { right: calc(var(--side-w) + 16px); }
}
.nav-account-ico { display: none; }
@media (max-width: 760px) {
  /* Une rangée « marque + Menu », une rangée d'outils, puis la navigation pleine largeur qui défile horizontalement */
  .site-header .container { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "brand tools" "side side" "nav nav";
    align-items: center; gap: 8px; padding-top: 10px; padding-bottom: 6px; }
  .brand { grid-area: brand; min-width: 0; }
  .nav-tools { grid-area: tools; flex: none; }
  /* Rangée d'outils : étalée de bord à bord, son premier bouton est aligné sur le logo, son dernier sur le bouton Menu */
  .side-tools { grid-area: side; justify-content: space-between; flex-direction: row; flex-wrap: nowrap; gap: 6px; width: 100%; min-width: 0; }
  .nav { grid-area: nav; min-width: 0; flex: none; justify-content: flex-start; flex-wrap: nowrap; overflow-x: auto; overscroll-behavior-x: contain;
    scroll-snap-type: x proximity; scroll-padding-inline: 16px; scrollbar-width: none; margin: 0 -16px; padding: 0 16px; }
  .nav:empty { display: none; }
  .nav::-webkit-scrollbar { display: none; }
  .nav a { padding: 10px 12px; flex: none; white-space: nowrap; scroll-snap-align: start; }
  .nav-msg-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .nav a.nav-msg .nav-badge { position: absolute; top: 2px; right: 0; min-width: 18px; height: 18px; line-height: 18px; font-size: 12px; padding: 0 5px; }
}
@media (max-width: 600px) {
  .brand img { width: 40px; height: 40px; }
  .brand span { font-size: 18px; white-space: nowrap; }
  .nav-tools { gap: 4px; }
  .nav-account:not(.is-guest) { padding: 3px; }
  .nav-account:not(.is-guest) .nav-account-name { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .nav-account .avatar { width: 36px !important; height: 36px !important; }
}
@media (max-width: 480px) {
  /* Très étroit : le logo seul ; le nom reste lu par les lecteurs d'écran */
  .brand span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
}

/* Aide & tutos : dans le menu, sur téléphone seulement (sur ordinateur, le bouton « ? » est dans la colonne d'outils) */
.nav a.nav-help-link { display: none; }
@media (max-width: 760px) { .nav a.nav-help-link { display: inline-flex; } }

/* Lien « Aller au contenu » : visible seulement au focus clavier */
.skip-link { position: absolute; left: 12px; top: -120px; z-index: 1000; min-height: 44px; display: inline-flex; align-items: center;
  padding: 10px 18px; border-radius: 999px; background: var(--accent); color: var(--accent-text); font-weight: 700; text-decoration: none; }
.skip-link:focus-visible { top: 8px; outline: 2px solid var(--sand); outline-offset: 2px; }
#app[tabindex="-1"]:focus { outline: none; }

/* Menu repliable (760 px et moins) : bouton rond de la même famille que les outils (.nav-icon), trois traits
   qui deviennent une croix quand le menu est ouvert. La navigation s'ouvre sous l'en-tête, en colonne pleine largeur. */
.nav-toggle { display: none; }
@media (max-width: 760px) {
  .nav-toggle { display: inline-grid; color: var(--text); border-color: var(--border-strong); }
  .nav-toggle[hidden] { display: none; }
  .nav-toggle-ico { display: block; overflow: visible; }
  .nav-toggle-ico .bar { transform-box: view-box; transform-origin: 12px 12px; transition: transform .2s ease, opacity .15s ease; }
  .site-header.nav-open .nav-toggle { background: var(--surface-2); }
  .site-header.nav-open .nav-toggle .bar-1 { transform: translateY(4px) rotate(45deg); }
  .site-header.nav-open .nav-toggle .bar-2 { opacity: 0; }
  .site-header.nav-open .nav-toggle .bar-3 { transform: translateY(-4px) rotate(-45deg); }
  @media (prefers-reduced-motion: reduce) { .nav-toggle-ico .bar { transition: none; } }
  .site-header .container { row-gap: 0; }
  .site-header .nav { display: none; }
  .site-header.nav-open .container { row-gap: 8px; }
  /* Liens pleine largeur, texte aligné sur le bord gauche du logo (marge de 16 px) ; le lien courant a un filet doré */
  .site-header.nav-open .nav { display: flex; flex-direction: column; align-items: stretch; flex-wrap: nowrap; overflow: visible; scroll-snap-type: none;
    gap: 2px; margin: 0 -16px; padding: 6px 0 14px; border-top: 1px solid var(--border); }
  .site-header.nav-open .nav a { width: 100%; box-sizing: border-box; min-height: 48px; padding: 12px 16px; border: 0; border-radius: 0; }
  .site-header.nav-open .nav a.nav-admin, .site-header.nav-open .nav a.nav-help-link { border-top: 1px solid var(--border); margin-top: 4px; }
  .site-header.nav-open .nav a[aria-current="page"] { background: var(--surface-2); box-shadow: inset 3px 0 0 var(--sand); font-weight: 700; }
  .site-header.nav-open .nav-msg-label { position: static; width: auto; height: auto; overflow: visible; clip: auto; }
  .site-header.nav-open .nav a.nav-msg .nav-badge { position: static; margin-left: auto; }
}

/* ---------- Pied de page ---------- */
.site-footer { border-top: 1px solid var(--border); margin-top: 64px; }
.site-footer .container { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 16px; padding-top: 24px; padding-bottom: 24px; font-size: 14px; color: var(--muted); }
.site-footer nav { display: flex; flex-wrap: wrap; align-items: center; gap: 18px; }
.footer-prefs { font: inherit; font-size: 13px; color: var(--muted); background: none; border: 1px solid var(--border); border-radius: 999px;
  min-height: 44px; padding: 6px 14px; cursor: pointer; display: inline-flex; align-items: center; gap: 8px; }
.footer-prefs svg { width: 16px; height: 16px; }
@media (hover: hover) { .footer-prefs:hover { color: var(--text); border-color: var(--border-strong); } }

/* ---------- Panneau des préférences ---------- */
.prefs-dialog { width: min(560px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); padding: 0; overflow: auto;
  background: var(--surface); color: var(--text); border: 1px solid var(--border-strong); border-radius: var(--radius);
  box-shadow: 0 24px 80px rgba(0, 0, 0, .5); }
.prefs-dialog::backdrop { background: rgba(4, 4, 8, .62); backdrop-filter: blur(3px); }
.prefs-form { padding: 24px; display: flex; flex-direction: column; gap: 18px; }
.prefs-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.prefs-head h2 { font-size: 26px; }
.prefs-note { margin: -12px 0 0; }
.prefs-close { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 999px; border: 1px solid var(--border);
  background: transparent; color: var(--text); cursor: pointer; flex: none; }
@media (hover: hover) { .prefs-close:hover { background: var(--surface-2); } }
.prefs-modes { border: 0; margin: 0; padding: 0; min-width: 0; }
.prefs-modes legend, .volume-row label { font-size: 14px; color: var(--muted); padding: 0; margin-bottom: 8px; }
.prefs-mode-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.mode-opt { position: relative; display: flex; flex-direction: column; gap: 10px; padding: 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--bg); cursor: pointer; min-height: 44px; }
.mode-opt input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.mode-opt:has(input:checked) { border-color: var(--sand); box-shadow: inset 0 0 0 1px var(--sand); }
.mode-opt:has(input:focus-visible) { outline: 2px solid var(--sand); outline-offset: 2px; }
.mode-txt { display: flex; flex-direction: column; gap: 2px; }
.mode-txt small { font-size: 13px; color: var(--muted); line-height: 1.3; }
.mode-swatch { display: flex; height: 34px; border-radius: 8px; overflow: hidden; border: 1px solid var(--border-strong); }
.mode-swatch i { flex: 1; }
.sw-sombre i:nth-child(1) { background: #0E0E10; } .sw-sombre i:nth-child(2) { background: #2A2A2F; } .sw-sombre i:nth-child(3) { background: #9E3543; }
.sw-clair i:nth-child(1) { background: #F5F2ED; } .sw-clair i:nth-child(2) { background: #FFFFFF; } .sw-clair i:nth-child(3) { background: #8E2F3C; }
.sw-daltonien i:nth-child(1) { background: #0E0E10; } .sw-daltonien i:nth-child(2) { background: #3A72C2; } .sw-daltonien i:nth-child(3) { background: #F2A65A; }
.prefs-switches { display: flex; flex-direction: column; border-top: 1px solid var(--border); }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 0; border-bottom: 1px solid var(--border); cursor: pointer; min-height: 44px; }
.switch-txt { display: flex; flex-direction: column; gap: 2px; }
.switch-txt small { font-size: 13px; color: var(--muted); }
.pref-switch { appearance: none; -webkit-appearance: none; flex: none; width: 52px; height: 30px; margin: 0; border-radius: 999px; position: relative; cursor: pointer;
  background: var(--surface-2); border: 1px solid var(--border-strong); transition: background .15s; }
.pref-switch::after { content: ''; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: var(--muted); transition: transform .15s, background .15s; }
.pref-switch:checked { background: var(--accent); border-color: var(--accent); }
.pref-switch:checked::after { transform: translateX(22px); background: var(--accent-text); }
.volume-row { display: grid; grid-template-columns: auto 1fr auto auto; align-items: center; gap: 12px; padding: 14px 0 0; }
.volume-row label { margin: 0; }
.volume-row input { width: 100%; min-width: 0; accent-color: var(--accent); height: 44px; }
.volume-out { font-variant-numeric: tabular-nums; min-width: 44px; text-align: right; font-size: 14px; }
.volume-row.is-off { opacity: .5; }
.prefs-actions { justify-content: space-between; }
@media (max-width: 600px) {
  .prefs-dialog { inset: 0; width: 100%; height: 100vh; height: 100dvh; max-width: none; max-height: none; margin: 0; border-radius: 0; border: 0; }
  .prefs-form { min-height: 100%; padding: 18px calc(16px + env(safe-area-inset-right)) calc(18px + env(safe-area-inset-bottom)) calc(16px + env(safe-area-inset-left)); }
  .prefs-mode-grid { grid-template-columns: 1fr; }
  .mode-opt { flex-direction: row; align-items: center; }
  .mode-swatch { width: 64px; flex: none; }
  .volume-row { grid-template-columns: auto 1fr auto; }
  .volume-row .prefs-test { grid-column: 1 / -1; }
}

/* ---------- Célébration de badge ---------- */
.badge-celebrate { width: 100vw; height: 100vh; height: 100dvh; max-width: none; max-height: none; margin: 0; padding: 16px; border: 0;
  background: radial-gradient(circle at 50% 45%, color-mix(in srgb, var(--surface) 92%, transparent), rgba(4, 4, 8, .92) 70%);
  color: var(--text); display: grid; place-items: center; overflow: hidden; }
.badge-celebrate:not([open]) { display: none; }
.badge-celebrate::backdrop { background: rgba(4, 4, 8, .55); }
.bc-confetti { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; image-rendering: pixelated; }
.bc-card { position: relative; z-index: 1; text-align: center; max-width: 440px; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.bc-card .eyebrow { margin: 0; }
.bc-badge { width: 152px; height: 152px; border-radius: 50%; padding: 6px; display: grid; place-items: center;
  background: conic-gradient(var(--rb-1), var(--rb-2), var(--rb-3), var(--rb-4), var(--rb-5), var(--rb-6), var(--rb-1));
  box-shadow: 0 0 60px color-mix(in srgb, var(--sand) 35%, transparent); }
.bc-badge img, .bc-initials { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; image-rendering: pixelated; background: var(--surface); }
.bc-initials { display: grid; place-items: center; font-family: var(--font-display); font-size: 54px; color: var(--sand); }
.bc-card h2 { font-size: clamp(30px, 7vw, 44px); line-height: 1.05; }
.bc-desc { margin: 0; color: var(--muted); font-size: 17px; }
.bc-count { margin: 0; }
.bc-actions { justify-content: center; margin-top: 8px; }
.badge-celebrate.bc-pop .bc-badge { animation: bc-pop .7s cubic-bezier(.2, 1.6, .4, 1) both; }
.badge-celebrate.bc-pop .bc-card h2, .badge-celebrate.bc-pop .bc-desc { animation: bc-rise .5s .15s ease-out both; }
@keyframes bc-pop { from { transform: scale(.3) rotate(-12deg); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes bc-rise { from { transform: translateY(12px); opacity: 0; } to { transform: none; opacity: 1; } }
html[data-fx="off"] .badge-celebrate .bc-badge, html[data-fx="off"] .badge-celebrate h2, html[data-fx="off"] .badge-celebrate .bc-desc { animation: none !important; }

/* ---------- Composants ---------- */
.page-head { padding: 48px 0 28px; display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 20px; }
.eyebrow { font-size: 13px; letter-spacing: 3px; text-transform: uppercase; color: var(--sand); }
.page-title { font-family: var(--font-display); font-weight: 400; font-size: clamp(36px, 6vw, 64px); line-height: 1; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 28px; }
.card h2 { font-size: 18px; font-weight: 700; margin-bottom: 12px; font-family: var(--font-body); }
.card-ss { background: var(--ss-bg); border-color: var(--ss-border); }
.card-irl { background: var(--irl-bg); border-color: var(--irl-border); }
.card-hist { background: var(--hist-bg); border-color: var(--hist-border); }
@media (max-width: 600px) { .card { padding: 20px; } }

.grid { display: grid; gap: 20px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); }
.row { display: flex; flex-wrap: wrap; gap: 20px; }
.row > * { flex: 1 1 380px; min-width: 0; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.list-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.list-row:last-child { border-bottom: 0; }

.btn { font: inherit; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 12px 18px; border-radius: var(--radius-sm); border: 1px solid transparent; cursor: pointer; text-decoration: none; }
.btn-primary { background: var(--accent); color: var(--accent-text); }
@media (hover: hover) { .btn-primary:hover { filter: brightness(1.1); color: var(--accent-text); } }
.btn-light { background: var(--text); color: #121212; }
.btn-sand { background: var(--sand); color: #121212; }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--border-strong); font-weight: 500; }
@media (hover: hover) { .btn-ghost:hover { background: var(--surface-2); color: var(--text); } }
.btn-danger { background: transparent; color: var(--rose); border-color: var(--accent); font-weight: 500; }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field label, .label { font-size: 14px; color: var(--muted); }
.input, .field input, .field select, .field textarea {
  font: inherit; font-size: 16px; padding: 12px 14px; min-height: 44px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--bg); color: var(--text); width: 100%;
}
.field textarea { resize: vertical; min-height: 100px; }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; }
.check input { width: 20px; height: 20px; margin: 2px 0 0; accent-color: var(--accent); flex: none; }

.pill { display: inline-flex; align-items: center; gap: 6px; padding: 8px 12px; border-radius: 999px; background: var(--surface-2); font-size: 13px; }
.pill-ok { background: var(--sage-soft); color: var(--sage-text); font-weight: 700; }
.pill-current { border: 1px solid var(--amber); color: var(--amber); background: transparent; font-weight: 700; }
.pill-todo { border: 1px solid var(--border-strong); color: var(--muted); background: transparent; }

.progress { height: 12px; border-radius: 999px; background: var(--progress-bg, #26262A); overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--sage); }

.avatar { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; background: var(--surface-2); flex: none;
  display: inline-flex; align-items: center; justify-content: center; font-weight: 700; color: var(--text); }

.empty { padding: 24px; text-align: center; color: var(--muted); border: 1px dashed var(--border-strong); border-radius: var(--radius-sm); }

/* ===== Connexion impossible (initPage, hors ligne ou serveur injoignable) ===== */
.conn-error { max-width: 520px; margin: 48px auto; padding: 28px; display: grid; gap: 14px; justify-items: start;
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius); }
.conn-error h1 { margin: 0; font-size: clamp(26px, 5vw, 34px); }
.conn-error p { margin: 0; color: var(--muted); }
.conn-error .conn-detail:empty { display: none; }
.conn-error .conn-retry { min-height: 44px; }

/* ---------- Toasts ---------- */
.toasts { position: fixed; right: max(16px, env(safe-area-inset-right)); bottom: calc(16px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 8px; z-index: 100; max-width: calc(100vw - 32px); }
.toast { background: var(--surface-2); border: 1px solid var(--border-strong); border-radius: var(--radius-sm); padding: 12px 16px; box-shadow: 0 8px 24px rgba(0,0,0,.4); }
.toast.error { border-color: var(--accent); }
.toast.ok { border-color: var(--sage); }

/* ---------- Bandeau cookies ---------- */
.cookie-notice { position: fixed; left: max(16px, env(safe-area-inset-left)); right: max(16px, env(safe-area-inset-right)); bottom: calc(16px + env(safe-area-inset-bottom)); max-width: 760px; margin: 0 auto; z-index: 90;
  background: var(--surface-2); border: 1px solid var(--border-strong); border-radius: 16px; padding: 18px 20px;
  display: flex; flex-wrap: wrap; align-items: center; gap: 14px; }
.cookie-notice p { margin: 0; flex: 1 1 320px; font-size: 14px; }

.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ===== Effets de thème (calque derrière le contenu, généré par core.js) ===== */
.fx-layer { position: fixed; inset: 0; z-index: -1; pointer-events: none; overflow: hidden; contain: strict; }
.fx-layer span { position: absolute; top: -40px; display: block; will-change: transform; }
.fx-pluie span { line-height: 1; opacity: .5; animation: fx-fall linear infinite; }
.fx-neige span { border-radius: 50%; background: #fff; animation: fx-fall linear infinite; }
.fx-etoiles span { border-radius: 50%; background: var(--sand); box-shadow: 0 0 6px var(--sand); opacity: 0; animation: fx-twinkle ease-in-out infinite; }
@keyframes fx-fall {
  from { transform: translate3d(0, 0, 0) rotate(0deg); }
  to { transform: translate3d(var(--dx, 0px), calc(100vh + 80px), 0) rotate(var(--r, 0deg)); }
}
@keyframes fx-twinkle { 0%, 100% { opacity: 0; transform: scale(.6); } 50% { opacity: .7; transform: scale(1); } }

@media (prefers-reduced-motion: reduce) { .fx-layer { display: none; } }
html[data-fx="off"] .fx-layer { display: none; }

/* ===== Mode clair (préférence « Mode : Clair ») =====
   bg/surface/text/muted/accent/sand sont calculés par core.js (themeVars) ; ici : couleurs fixes non issues du thème. */
html[data-mode="clair"] {
  --sage: #2E7A4B; --sage-soft: #E2F1E7; --sage-text: #1E653A;
  --slate: #3C5A9E; --plum: #5E4A94; --rose: #A52F40; --rust: #A3462C;
  --ss-bg: #FBEEF0; --ss-border: #EBCFD4; --ss-fg: #9A2C3C;
  --irl-bg: #FBF5E4; --irl-border: #E8DBB4; --irl-fg: #775B10;
  --hist-bg: #EDF2FB; --hist-border: #CBD6EE; --hist-fg: #34508F;
  --progress-bg: #E3DFD8;
}
html[data-mode="clair"] .btn-light { background: var(--text); color: #FFFFFF; }
html[data-mode="clair"] .btn-sand { color: #FFFFFF; }
html[data-mode="clair"] .nav-badge { color: #FFFFFF; }
html[data-mode="clair"] .toast { box-shadow: 0 8px 24px rgba(0, 0, 0, .12); }
html[data-mode="clair"] .fx-neige span { background: #9DB0D6; }
html[data-mode="clair"] .prefs-dialog { box-shadow: 0 24px 80px rgba(0, 0, 0, .18); }
html[data-mode="clair"] .prefs-dialog::backdrop { background: rgba(30, 28, 34, .38); }
html[data-mode="clair"] .badge-celebrate { background: radial-gradient(circle at 50% 45%, rgba(255, 255, 255, .97), rgba(236, 232, 226, .96) 70%); }

/* ===== Mode daltonien (deutéranopie / protanopie) =====
   Succès = bleu, erreur/danger = orange ; contrastes renforcés ; états doublés d'icônes et de motifs. */
html[data-mode="daltonien"] {
  --sage: #5B9BE0; --sage-soft: #13233B; --sage-text: #A3C8F2;
  --rose: #F2A65A; --rust: #F2A65A; --plum: #B7A6E6; --slate: #8FB1EC;
  --ss-fg: #F2B479; --irl-fg: #F0D88E; --hist-fg: #9DB9F0;
  --progress-bg: #2E2E34;
}
html[data-mode="daltonien"] .pill-ok::before { content: ''; width: 12px; height: 12px; flex: none; background: currentColor;
  -webkit-mask: var(--ico-check) center / contain no-repeat; mask: var(--ico-check) center / contain no-repeat; }
html[data-mode="daltonien"] .progress > span { background-image: repeating-linear-gradient(135deg, rgba(255,255,255,.28) 0 4px, transparent 4px 9px); }
html[data-mode="daltonien"] .btn-danger { border-style: dashed; border-width: 2px; border-color: var(--rose); }
html[data-mode="daltonien"] .toast { display: flex; gap: 10px; align-items: flex-start; border-width: 2px; }
html[data-mode="daltonien"] .toast.ok { border-color: var(--sage); }
html[data-mode="daltonien"] .toast.error { border-color: var(--rose); border-style: dashed; }
html[data-mode="daltonien"] .toast.ok::before, html[data-mode="daltonien"] .toast.error::before {
  content: ''; width: 18px; height: 18px; flex: none; margin-top: 2px; background: var(--sage);
  -webkit-mask: var(--ico-check) center / contain no-repeat; mask: var(--ico-check) center / contain no-repeat; }
html[data-mode="daltonien"] .toast.error::before { background: var(--rose); -webkit-mask-image: var(--ico-alert); mask-image: var(--ico-alert); }
html[data-mode="daltonien"] :focus-visible { outline-width: 3px; }
:root {
  --ico-check: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7'/%3E%3C/svg%3E");
  --ico-alert: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 3l10 18H2z'/%3E%3Cpath d='M12 10v5M12 18.5v.01'/%3E%3C/svg%3E");
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; scroll-behavior: auto !important; } }

/* ===== Événements dynamiques (dyn-events.js) : calque au-dessus du contenu, seule l'image capte les clics ===== */
.dyn-layer { position: fixed; inset: 0; z-index: 9000; pointer-events: none; overflow: hidden; }
.dyn-fly { position: absolute; left: 0; top: 0; padding: 0; margin: 0; border: 0; background: none; cursor: pointer; pointer-events: auto;
  display: grid; place-items: center; border-radius: 16px; will-change: transform; touch-action: manipulation; -webkit-tap-highlight-color: transparent;
  filter: drop-shadow(0 6px 14px rgba(0, 0, 0, .45)); }
.dyn-fly img { width: 100%; height: 100%; object-fit: contain; image-rendering: pixelated; pointer-events: none; user-select: none; }
.dyn-emoji { line-height: 1; font-family: 'Apple Color Emoji', 'Segoe UI Emoji', 'Noto Color Emoji', sans-serif; pointer-events: none; user-select: none; }
.dyn-fly:focus-visible { outline: 3px solid var(--sand); outline-offset: 4px; }
.dyn-fly.is-still { position: absolute; background: color-mix(in srgb, var(--surface) 80%, transparent); border: 1px solid var(--border-strong); padding: 6px; box-sizing: content-box; }
.dyn-plus { position: absolute; font-family: var(--font-display); font-size: 26px; color: var(--sand); text-shadow: 0 2px 0 #000, 0 0 12px rgba(0, 0, 0, .6); pointer-events: none; white-space: nowrap; }
.dyn-px { position: absolute; display: block; pointer-events: none; image-rendering: pixelated; }

/* ===== Badges à niveaux : pastilles I, II, III… (badge-levels.js) ===== */
.lvl-pips { display: inline-flex; flex-wrap: wrap; justify-content: center; gap: 3px; }
.lvl-pip { min-width: 22px; height: 18px; padding: 0 4px; border-radius: 5px; display: inline-grid; place-items: center;
  font: 700 10px/1 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; letter-spacing: .02em;
  color: var(--muted); border: 1px solid var(--border-strong); background: transparent; }
.lvl-pip.is-on { color: #121212; background: var(--sand); border-color: var(--sand); }
.lvl-pip.is-cur { box-shadow: 0 0 0 2px color-mix(in srgb, var(--sand) 35%, transparent); }
.lvl-more { border-style: dashed; }
.lvl-name { font-size: 13px; font-weight: 700; color: var(--sand); }
html[data-mode="clair"] .lvl-pip.is-on { color: #FFFFFF; }

/* ===== Recherche globale (dialogue ouvert par la loupe de l'en-tête ou Ctrl/Cmd+K) ===== */
.search-dialog { width: min(640px, calc(100vw - 24px)); max-height: calc(100dvh - 32px); padding: 0; overflow: hidden;
  background: var(--surface); color: var(--text); border: 1px solid var(--border-strong); border-radius: var(--radius);
  box-shadow: 0 24px 80px rgba(0, 0, 0, .5); }
.search-dialog[open] { display: flex; flex-direction: column; }
.search-dialog::backdrop { background: rgba(4, 4, 8, .62); backdrop-filter: blur(3px); }
.search-form { display: flex; flex-direction: column; gap: 14px; padding: 20px 24px 22px; flex: 1 1 auto; min-height: 0; box-sizing: border-box; }
.search-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.search-head h2 { font-size: 24px; }
.search-close { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 999px; border: 1px solid var(--border);
  background: transparent; color: var(--text); cursor: pointer; flex: none; }
@media (hover: hover) { .search-close:hover { background: var(--surface-2); } }
.search-box { display: flex; align-items: center; gap: 10px; min-height: 48px; padding: 0 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--bg); color: var(--muted); flex: none; }
.search-box:focus-within { border-color: var(--sand); box-shadow: 0 0 0 2px color-mix(in srgb, var(--sand) 35%, transparent); }
.search-box svg { flex: none; }
.search-input { flex: 1; min-width: 0; min-height: 46px; padding: 0; border: 0; background: transparent; color: var(--text);
  font: inherit; font-size: 16px; outline: none; }
.search-input::placeholder { color: var(--muted); opacity: 1; }
.search-results { display: flex; flex-direction: column; gap: 16px; overflow-y: auto; min-height: 0; flex: 1 1 auto; overscroll-behavior: contain; }
.search-results .sr-group { display: flex; flex-direction: column; gap: 6px; }
.sr-group-title { display: flex; align-items: center; gap: 8px; margin: 0; font-family: var(--font-body); font-size: 13px; font-weight: 700;
  letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.sr-count { font-variant-numeric: tabular-nums; font-size: 12px; line-height: 20px; padding: 0 8px; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text); letter-spacing: 0; }
.sr-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.sr-item { display: flex; align-items: center; flex-wrap: wrap; gap: 2px 12px; min-height: 44px; padding: 8px 12px; border-radius: var(--radius-sm);
  border: 1px solid transparent; color: var(--text); text-decoration: none; }
@media (hover: hover) { .sr-item:hover { background: var(--surface-2); border-color: var(--border); } }
.sr-item:focus-visible { outline: 2px solid var(--sand); outline-offset: 2px; }
.sr-ico { display: inline-flex; flex: none; }
.sr-title { flex: 0 1 auto; min-width: 0; font-weight: 700; overflow-wrap: anywhere; }
.sr-sub { flex: 1 1 100%; font-size: 13px; color: var(--muted); }
.sr-empty, .sr-more { margin: 0; }
.sr-status { margin: 0; min-height: 1.5em; font-size: 14px; color: var(--muted); }
html[data-mode="clair"] .search-dialog { box-shadow: 0 24px 80px rgba(0, 0, 0, .18); }
html[data-mode="clair"] .search-dialog::backdrop { background: rgba(30, 28, 34, .38); }
@media (max-width: 600px) {
  .search-dialog { inset: 0; width: 100%; max-width: none; max-height: none; height: 100vh; height: 100dvh; margin: 0; border-radius: 0; border: 0; }
  .search-form { padding: 16px calc(16px + env(safe-area-inset-right)) calc(16px + env(safe-area-inset-bottom)) calc(16px + env(safe-area-inset-left)); }
}

/* ===== Mode sans limite (admin) : html[data-godmode="on"] posé par core.js =====
   Bandeau fixe en haut (au-dessus de l'en-tête, le contenu est décalé de --god-h), cadre d'écran en bandes
   « danger » jaune/noir (animées lentement, figées si mouvement réduit ou effets coupés). */
:root { --god-yellow: #F5C400; --god-ink: #111111; --god-text: #F5C400; --god-red: #B3261E;
  --god-stripes: repeating-linear-gradient(-45deg, var(--god-yellow) 0 14px, var(--god-ink) 14px 28px); }
html[data-mode="clair"] { --god-text: #6B4F00; }
html[data-godmode="on"] body { padding-top: var(--god-h, 60px); }
html[data-godmode="on"] { scroll-padding-top: calc(var(--god-h, 60px) + 12px); }
html[data-godmode="on"] :is(.bt-list, .bt-main .bt-preview, .legal-toc) { top: calc(var(--god-h, 60px) + 16px); }

.god-banner { position: fixed; top: 0; left: 0; right: 0; z-index: 9600; background: var(--god-yellow); color: var(--god-ink);
  box-shadow: 0 6px 20px rgba(0, 0, 0, .45); }
.god-banner::after { content: ''; position: absolute; left: 0; right: 0; top: 100%; height: 8px; background: var(--god-stripes);
  animation: god-stripes 3s linear infinite; }
.god-banner-in { max-width: var(--maxw); margin: 0 auto; padding: 6px 24px; min-height: 56px;
  display: flex; flex-wrap: wrap; align-items: center; gap: 4px 14px; }
.god-ico { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 8px; background: var(--god-ink); color: var(--god-yellow); flex: none; }
.god-msg { margin: 0; flex: 1 1 260px; font-weight: 700; line-height: 1.25; }
.god-msg strong { font-family: var(--font-display); font-weight: 400; font-size: 18px; letter-spacing: .04em; }
.god-count { margin: 0; font-weight: 700; font-size: 15px; white-space: nowrap; }
.god-count[hidden] { display: none; }
.god-left { font: 700 17px/1 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-variant-numeric: tabular-nums;
  background: var(--god-ink); color: var(--god-yellow); padding: 4px 8px; border-radius: 6px; margin-left: 4px; display: inline-block; }
.god-off { font: inherit; font-weight: 700; min-height: 44px; padding: 8px 16px; border-radius: var(--radius-sm); cursor: pointer;
  background: var(--god-ink); color: var(--god-yellow); border: 2px solid var(--god-ink); }
.god-off:hover { background: #2a2a2a; }
.god-off:focus-visible, .god-banner :focus-visible { outline: 3px solid var(--god-ink); outline-offset: 2px; }
.god-off[disabled] { opacity: .6; cursor: progress; }
@media (max-width: 600px) {
  .god-banner-in { padding: 6px 16px; gap: 4px 10px; }
  .god-ico { width: 28px; height: 28px; }
  .god-msg { flex-basis: calc(100% - 40px); font-size: 14px; }
  .god-msg strong { font-size: 16px; }
  .god-count { flex: 1 1 auto; font-size: 14px; }
  .god-off { min-height: 44px; padding: 6px 14px; }
}

.god-frame { position: fixed; inset: 0; z-index: 9500; pointer-events: none; padding: 8px; background: var(--god-stripes);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0);
  animation: god-stripes 3s linear infinite; }
@media (max-width: 600px) { .god-frame { padding: 5px; } }
@keyframes god-stripes { to { background-position: 39.598px 0; } } /* une période des bandes à 45° (28px × √2) : boucle sans saut */
html[data-fx="off"] .god-frame, html[data-fx="off"] .god-banner::after { animation: none; }
@media (prefers-reduced-motion: reduce) { .god-frame, .god-banner::after { animation: none !important; } }

/* En-tête : léger filtre + bouton éclair */
html[data-godmode="on"] .site-header { box-shadow: inset 0 -2px 0 var(--god-yellow); }
/* Filtre sur chaque bloc de l'en-tête (et non sur l'en-tête entier : un filtre ferait de l'en-tête le bloc englobant de la colonne fixe) */
html[data-godmode="on"] .site-header .container > :not(.side-tools) { filter: sepia(.35) saturate(.85); }
html[data-godmode="on"] .site-header .side-tools { filter: sepia(.35) saturate(.85); }
.nav-god[aria-pressed="true"] { background: var(--god-yellow); color: var(--god-ink); border-color: var(--god-ink); }
.nav-god[aria-pressed="true"]:hover { background: #ffd51f; color: var(--god-ink); }

/* ---------- Libellé sur les actions débloquées ---------- */
.god-tag { font-size: 12px; font-weight: 700; color: var(--god-text); white-space: nowrap; letter-spacing: .01em; }
.btn .god-tag, .pill .god-tag { color: inherit; font-weight: 500; opacity: .9; }
.god-note { margin: 0; padding: 10px 12px; border-radius: var(--radius-sm); border: 1px dashed var(--god-text); color: var(--text); font-size: 13px; }
.god-note strong { color: var(--god-text); }

/* ---------- Dialog d'activation ---------- */
.god-dialog { width: min(600px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); padding: 0; overflow: auto;
  background: var(--surface); color: var(--text); border: 2px solid var(--god-yellow); border-radius: var(--radius);
  box-shadow: 0 24px 80px rgba(0, 0, 0, .55); }
.god-dialog::before { content: ''; display: block; height: 12px; background: var(--god-stripes); }
.god-dialog::backdrop { background: rgba(10, 8, 0, .72); backdrop-filter: blur(3px); }
.god-form { padding: 22px 24px 24px; display: flex; flex-direction: column; gap: 14px; }
.god-dlg-head { display: flex; gap: 14px; align-items: center; }
.god-dlg-ico { width: 48px; height: 48px; flex: none; display: grid; place-items: center; border-radius: 12px; background: var(--god-yellow); color: var(--god-ink); }
.god-dlg-ico svg { width: 28px; height: 28px; }
.god-dlg-eyebrow { margin: 0 0 2px; font-size: 12px; letter-spacing: 2px; text-transform: uppercase; color: var(--god-text); font-weight: 700; }
.god-dialog h2 { font-size: clamp(22px, 5vw, 28px); line-height: 1.1; }
.god-desc { margin: 0; }
.god-lifts { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; font-size: 14px; }
.god-lifts strong { color: var(--text); }
.god-kept { margin: 0; color: var(--muted); }
.god-dur { border: 0; margin: 0; padding: 0; min-width: 0; }
.god-dur legend { font-size: 14px; color: var(--muted); padding: 0; margin-bottom: 8px; }
.god-dur-opts { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.god-dur-opt { position: relative; min-height: 44px; display: grid; place-items: center; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--bg); cursor: pointer; font-weight: 700; }
.god-dur-opt input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.god-dur-opt:has(input:checked) { border-color: var(--god-yellow); box-shadow: inset 0 0 0 1px var(--god-yellow); color: var(--god-text); }
.god-dur-opt:has(input:focus-visible) { outline: 2px solid var(--sand); outline-offset: 2px; }
.god-phrase { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; color: var(--text); letter-spacing: .06em; }
#god-confirm { text-transform: uppercase; letter-spacing: .06em; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.god-err { margin: 0; color: var(--rose); min-height: 0; }
.god-err:empty { display: none; }
.god-actions { justify-content: flex-end; }
.god-go { background: var(--god-red); color: #fff; border-color: var(--god-red); }
.god-go:hover:not([disabled]) { filter: brightness(1.1); color: #fff; }
html[data-mode="clair"] .god-dialog { box-shadow: 0 24px 80px rgba(0, 0, 0, .2); }
@media (max-width: 600px) {
  .god-form { padding: 18px 16px; }
  .god-dur-opts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .god-actions .btn { flex: 1 1 auto; }
  .god-dialog { inset: 0; width: 100%; height: 100vh; height: 100dvh; max-width: none; max-height: none; margin: 0; border-radius: 0; border: 0; }
  .god-dialog::before { height: 8px; }
}

/* ===== Mobile (≤ 600px) : pied de page, tailles de texte, cibles tactiles ===== */
@media (max-width: 600px) {
  .site-footer { margin-top: 40px; }
  .site-footer .container { padding-bottom: calc(20px + env(safe-area-inset-bottom)); gap: 12px; }
  .site-footer nav { gap: 2px 16px; }
  .site-footer nav a { display: inline-flex; align-items: center; min-height: 44px; }
  .footer-prefs { font-size: 14px; }
  .page-head { padding: 28px 0 20px; }
  .small, .pill { font-size: 14px; }
  .switch-txt small, .mode-txt small { font-size: 14px; }
  .check { align-items: center; min-height: 44px; }
  .btn-row { gap: 8px; }
}
@media (hover: none) {
  /* Tactile : pas d'état « survolé » collé après un tap */
  .btn:active:not([disabled]) { filter: brightness(.92); }
  .nav a:active { background: var(--surface-2); }
}
