/* Histoire — feuille de style. Papier, encre et bordeaux ; Fraunces pour les titres. */
@font-face { font-family: 'Fraunces'; font-style: normal; font-weight: 100 900; font-display: swap; src: url(../fonts/fraunces-latin-opsz-normal.woff2) format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215; }
@font-face { font-family: 'Fraunces'; font-style: normal; font-weight: 100 900; font-display: swap; src: url(../fonts/fraunces-latin-ext-opsz-normal.woff2) format('woff2'); unicode-range: U+0100-02AF, U+0304, U+0308, U+0329, U+1E00-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: 'Fraunces'; font-style: italic; font-weight: 100 900; font-display: swap; src: url(../fonts/fraunces-latin-opsz-italic.woff2) format('woff2'); }

:root {
  --paper: #f5f0e6; --card: #fffcf6; --sunk: #ede5d6; --ink: #221d18; --muted: #6f655a; --line: #e2d8c6; --line-2: #d2c5ad;
  --accent: #7a2a22; --accent-2: #9a3a2f; --accent-soft: #f1ddd6; --gold: #b0883f; --ok: #2e6b3a; --ok-soft: #dcebdc; --ko-soft: #f6dcd7;
  --shadow: 0 1px 2px rgba(60, 40, 20, .06), 0 4px 16px rgba(60, 40, 20, .06);
  --radius: 12px; --serif: 'Fraunces', Georgia, 'Times New Roman', serif; --sans: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --top: 56px; --tab: 62px; --side: 232px;
  --sat: env(safe-area-inset-top, 0px); --sab: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root { --paper: #17140f; --card: #211d17; --sunk: #2a251e; --ink: #efe7d9; --muted: #a79c8c; --line: #362f25; --line-2: #4a4134;
    --accent: #d27a6c; --accent-2: #e08f81; --accent-soft: #3c2420; --gold: #d2ad69; --ok: #8cc79a; --ok-soft: #1f3324; --ko-soft: #3c2420;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 20px rgba(0, 0, 0, .25); color-scheme: dark; }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 16px/1.55 var(--sans); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
h1, h2, h3 { font-family: var(--serif); font-weight: 520; line-height: 1.15; margin: 0; font-optical-sizing: auto; }
code { font-size: .88em; background: var(--sunk); padding: 1px 5px; border-radius: 4px; }
img { max-width: 100%; }
.muted { color: var(--muted); }
.small { font-size: .86rem; }
.ico { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.hide-sm { display: inline; }
button { font: inherit; color: inherit; }
[hidden] { display: none !important; }

/* ---------- Mise en page ---------- */
.app { min-height: 100vh; }
body.logged-out .app { display: none; }
.sidebar { position: fixed; inset: 0 auto 0 0; width: var(--side); background: var(--card); border-right: 1px solid var(--line); padding: 18px 12px; overflow-y: auto; z-index: 20; }
.brand { display: flex; align-items: center; gap: 10px; font: 600 1.35rem var(--serif); color: var(--ink); padding: 4px 10px 18px; }
.brand:hover { text-decoration: none; }
.brand img { width: 34px; height: 34px; border-radius: 8px; }
.sidebar nav a { display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: 9px; color: var(--muted); font-size: .95rem; }
.sidebar nav a:hover { background: var(--sunk); color: var(--ink); text-decoration: none; }
.sidebar nav a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.content { margin-left: var(--side); min-height: 100vh; }
.topbar { position: sticky; top: 0; z-index: 15; display: flex; align-items: center; gap: 8px; height: calc(var(--top) + var(--sat)); padding: var(--sat) 20px 0;
  background: color-mix(in srgb, var(--paper) 86%, transparent); backdrop-filter: saturate(1.4) blur(14px); -webkit-backdrop-filter: saturate(1.4) blur(14px); border-bottom: 1px solid var(--line); }
.page-title { font: 560 1.15rem var(--serif); flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-actions { display: flex; gap: 6px; align-items: center; }
.main { max-width: 1000px; margin: 0 auto; padding: 24px 24px 64px; }
.main.wide { max-width: 1280px; }
.main.full { max-width: none; padding: 0; }
.tabbar { display: none; }

@media (max-width: 899px) {
  .sidebar { display: none; }
  .content { margin-left: 0; padding-bottom: calc(var(--tab) + var(--sab)); }
  .topbar { padding-left: 12px; padding-right: 12px; }
  .main { padding: 16px 16px 40px; }
  .tabbar { display: flex; position: fixed; inset: auto 0 0 0; z-index: 20; height: calc(var(--tab) + var(--sab)); padding-bottom: var(--sab);
    background: color-mix(in srgb, var(--card) 90%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border-top: 1px solid var(--line); }
  .tabbar a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; color: var(--muted); font-size: .68rem; }
  .tabbar a:hover { text-decoration: none; }
  .tabbar a.active { color: var(--accent); }
  .tabbar .ico { width: 23px; height: 23px; }
  .hide-sm { display: none; }
}

/* ---------- Boutons & champs ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; border: 1px solid var(--accent); background: var(--accent); color: #fff; border-radius: 9px;
  padding: 9px 15px; font-weight: 560; font-size: .94rem; cursor: pointer; text-decoration: none; white-space: nowrap; transition: background .15s, border-color .15s; }
@media (prefers-color-scheme: dark) { .btn { color: #1a1410; } }
.btn:hover { background: var(--accent-2); text-decoration: none; }
.btn:disabled { opacity: .55; cursor: default; }
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--line-2); }
.btn.ghost:hover { background: var(--sunk); }
.btn.danger { background: #a02c25; border-color: #a02c25; color: #fff; }
.btn.danger.ghost { background: transparent; color: #b4382f; border-color: transparent; }
.btn.danger.ghost:hover { background: var(--ko-soft); }
.btn.small { padding: 6px 11px; font-size: .86rem; }
.btn.small .ico { width: 17px; height: 17px; }
.btn.block { width: 100%; }
.icon-btn { display: inline-grid; place-items: center; width: 38px; height: 38px; border-radius: 9px; border: 0; background: transparent; color: var(--ink); cursor: pointer; flex: none; }
.icon-btn:hover { background: var(--sunk); }
.icon-btn.small { width: 32px; height: 32px; color: var(--muted); }
.icon-btn.small .ico { width: 17px; height: 17px; }
.icon-btn.on { color: var(--gold); }
.icon-btn.on .ico { fill: currentColor; }

input, select, textarea { font: inherit; font-size: 16px; color: var(--ink); background: var(--card); border: 1px solid var(--line-2); border-radius: 9px; padding: 9px 11px; min-width: 0; }
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--accent) 45%, transparent); outline-offset: 0; border-color: var(--accent); }
textarea { resize: vertical; line-height: 1.5; }
select { padding-right: 28px; appearance: none; -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' fill='none' stroke='%23887a68' stroke-width='1.6'%3E%3Cpath d='m1 1.5 5 5 5-5'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; }
input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--accent); padding: 0; }
.toggle { display: inline-flex; align-items: center; gap: 7px; font-size: .92rem; color: var(--muted); white-space: nowrap; cursor: pointer; }

.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 16px; }
.toolbar .grow { flex: 1 1 200px; }
.toolbar .zoom { display: inline-flex; gap: 2px; align-items: center; margin-left: auto; }
.segmented { display: inline-flex; flex-wrap: wrap; gap: 4px; background: var(--sunk); border-radius: 10px; padding: 3px; margin-bottom: 14px; }
.segmented button { border: 0; background: transparent; padding: 6px 12px; border-radius: 8px; cursor: pointer; color: var(--muted); font-size: .9rem; }
.segmented button span { opacity: .6; margin-left: 3px; font-size: .82em; }
.segmented button.on { background: var(--card); color: var(--ink); box-shadow: var(--shadow); font-weight: 560; }
.segmented.small { margin: 12px 0 0; }
.segmented.small button { padding: 4px 10px; font-size: .84rem; }

/* ---------- Titres & textes ---------- */
.display { font-size: clamp(1.9rem, 4.5vw, 2.8rem); font-weight: 480; letter-spacing: -.01em; }
.eyebrow { text-transform: uppercase; letter-spacing: .12em; font-size: .74rem; color: var(--gold); font-weight: 650; margin: 0 0 6px; }
.lead { font-size: 1.08rem; color: var(--ink); }
.prose { max-width: 70ch; }
.prose p { margin: 0 0 .9em; }
.prose p:last-child { margin-bottom: 0; }
.wikilink { border-bottom: 1px solid color-mix(in srgb, var(--accent) 40%, transparent); }
.wikilink:hover { text-decoration: none; border-bottom-color: var(--accent); }
.wikilink.missing { color: var(--muted); border-bottom-style: dashed; border-bottom-color: var(--line-2); }
.empty { color: var(--muted); font-style: italic; margin: 6px 0; }
.sub { font: 600 .76rem var(--sans); text-transform: uppercase; letter-spacing: .1em; color: var(--muted); margin: 18px 0 8px; }

/* ---------- Sections, cartes, lignes ---------- */
.section { margin-top: 30px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; padding-bottom: 8px; border-bottom: 1px solid var(--line); }
.section-head h2 { font-size: 1.3rem; }
.count { font: 500 .78rem var(--sans); color: var(--muted); background: var(--sunk); border-radius: 20px; padding: 2px 8px; vertical-align: middle; }
.more-link { display: inline-block; margin-top: 8px; font-size: .9rem; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 10px; }
.card { display: flex; gap: 12px; align-items: flex-start; padding: 12px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); color: var(--ink); transition: border-color .15s, box-shadow .15s; }
.card:hover { text-decoration: none; border-color: var(--line-2); box-shadow: var(--shadow); }
.card-body { display: flex; flex-direction: column; min-width: 0; }
.card-title { font: 560 1.05rem var(--serif); }
.card-sub { font-size: .84rem; color: var(--muted); }
.card-extra { font-size: .88rem; margin-top: 3px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.fav-dot { color: var(--gold); font-size: .85em; }
.avatar { width: 46px; height: 46px; border-radius: 50%; overflow: hidden; flex: none; display: grid; place-items: center; background: var(--sunk); }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar.initials { background: hsl(var(--h) 30% 82%); color: hsl(var(--h) 35% 28%); font: 600 .95rem var(--serif); }
@media (prefers-color-scheme: dark) { .avatar.initials { background: hsl(var(--h) 22% 26%); color: hsl(var(--h) 40% 82%); } }
.avatar.sm { width: 32px; height: 32px; font-size: .78rem; }
.avatar.xs { width: 22px; height: 22px; font-size: .6rem; }
.avatar.xl { width: 128px; height: 128px; font-size: 2.4rem; border: 3px solid var(--card); box-shadow: var(--shadow); }

.rows { display: flex; flex-direction: column; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.rows > .row, .rows > .row-wrap { border-top: 1px solid var(--line); }
.rows > :first-child { border-top: 0; }
.row { display: flex; gap: 12px; align-items: center; padding: 10px 14px; color: var(--ink); flex: 1; min-width: 0; }
.row:hover { background: var(--sunk); text-decoration: none; }
.row-wrap { display: flex; align-items: center; padding-right: 6px; }
.row-wrap:hover { background: var(--sunk); }
.row-wrap .row:hover { background: transparent; }
.row-ico { width: 32px; height: 32px; border-radius: 8px; background: var(--sunk); color: var(--muted); display: grid; place-items: center; flex: none; }
.row-ico .ico { width: 17px; height: 17px; }
.row-main { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.row-title { font-weight: 560; }
.row-sub { font-size: .85rem; color: var(--muted); }
.rows.compact .row { padding: 8px 12px; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; vertical-align: 1px; }
.status { font-size: .74rem; padding: 2px 8px; border-radius: 20px; background: var(--sunk); color: var(--muted); white-space: nowrap; flex: none; }
.status.s-àdécouvrir { background: color-mix(in srgb, var(--gold) 20%, transparent); color: color-mix(in srgb, var(--gold) 70%, var(--ink)); }
.status.s-encours { background: #dde7f3; color: #2c4c78; }
.status.s-luvu, .status.s-vérifiée, .status.s-visit { background: var(--ok-soft); color: var(--ok); }
.status.s-attribuée { background: color-mix(in srgb, var(--gold) 20%, transparent); color: color-mix(in srgb, var(--gold) 70%, var(--ink)); }
.status.s-apocryphe { background: var(--ko-soft); color: #a02c25; }
@media (prefers-color-scheme: dark) { .status.s-encours { background: #1e2a3a; color: #9db8dd; } }
.chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 20px; background: var(--card); border: 1px solid var(--line-2); font-size: .85rem; color: var(--ink); }
.chip:hover { text-decoration: none; border-color: var(--accent); }
.chip.plain { background: var(--sunk); border-color: transparent; }
.chip.person { padding-left: 3px; }
.chip-x { border: 0; background: none; color: var(--muted); cursor: pointer; font-size: 1.1rem; line-height: 1; padding: 0 0 0 2px; }
.tag { font: 500 .72rem var(--sans); text-transform: uppercase; letter-spacing: .06em; color: var(--c, var(--muted)); vertical-align: middle; margin-left: 6px; }
.callout { margin: 14px 0; padding: 10px 14px; border-radius: 10px; background: var(--ok-soft); color: var(--ink); border-left: 3px solid var(--ok); font-size: .94rem; }

/* ---------- Accueil ---------- */
.hero { padding: 26px 28px; border-radius: 18px; background: var(--card); border: 1px solid var(--line);
  background-image: radial-gradient(circle at 100% 0, color-mix(in srgb, var(--gold) 16%, transparent), transparent 55%); }
.ephemeris { list-style: none; padding: 0; margin: 16px 0 0; display: flex; flex-direction: column; gap: 8px; }
.ephemeris li { display: flex; gap: 14px; align-items: baseline; }
.eph-year { font: 560 1.1rem var(--serif); color: var(--accent); min-width: 4.2em; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-top: 14px; }
.stat { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 14px; border-radius: var(--radius); background: var(--card); border: 1px solid var(--line); color: var(--ink); }
.stat:hover { text-decoration: none; border-color: var(--line-2); }
.stat .ico { color: var(--gold); }
.stat strong { font: 500 1.7rem var(--serif); line-height: 1.1; margin-top: 4px; }
.stat span { font-size: .82rem; color: var(--muted); }
.welcome { padding: 20px; background: var(--card); border: 1px dashed var(--line-2); border-radius: var(--radius); }
@media (max-width: 560px) { .stats { grid-template-columns: repeat(2, 1fr); } .hero { padding: 20px; } }

/* ---------- Fiche personnage ---------- */
.profile { display: flex; gap: 26px; align-items: flex-start; }
.profile-portrait { border: 0; padding: 0; background: none; cursor: pointer; border-radius: 50%; }
.profile-text { min-width: 0; flex: 1; }
.profile-text .chips { margin: 10px 0 0; }
.profile-text .lead { margin: 12px 0 0; }
.life { display: flex; flex-wrap: wrap; gap: 4px 18px; margin: 10px 0 0; font-size: .95rem; }
.life b { font-weight: 600; font-size: .78rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin-right: 4px; }
.jump { position: sticky; top: calc(var(--top) + var(--sat)); z-index: 5; display: flex; gap: 4px; overflow-x: auto; margin: 22px -4px 0; padding: 8px 4px; background: var(--paper); scrollbar-width: none; }
.jump::-webkit-scrollbar { display: none; }
.jump a { padding: 5px 12px; border-radius: 20px; font-size: .86rem; color: var(--muted); white-space: nowrap; background: var(--sunk); }
.jump a:hover { color: var(--ink); text-decoration: none; }
.detail-grid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 32px; align-items: start; }
.col-side .section:first-child, .col-main > :first-child .section, .col-main > .section:first-child { margin-top: 18px; }
[id^="s-"] { scroll-margin-top: calc(var(--top) + var(--sat) + 56px); }
@media (max-width: 1000px) { .detail-grid { grid-template-columns: 1fr; gap: 0; } }
@media (max-width: 600px) { .profile { flex-direction: column; align-items: center; text-align: center; gap: 14px; } .profile .chips, .life { justify-content: center; } .avatar.xl { width: 112px; height: 112px; } }

.chrono { list-style: none; margin: 0; padding: 0 0 0 4px; position: relative; }
.chrono::before { content: ''; position: absolute; left: 88px; top: 8px; bottom: 8px; width: 2px; background: var(--line); }
.chrono li { display: grid; grid-template-columns: 76px 1fr auto; gap: 24px; align-items: start; padding: 7px 0; position: relative; }
.chrono li::before { content: ''; position: absolute; left: 79px; top: 14px; width: 10px; height: 10px; border-radius: 50%; background: var(--card); border: 2px solid var(--accent); }
.chrono li.birth::before, .chrono li.death::before { background: var(--accent); }
.chrono-date { font: 560 .95rem var(--serif); text-align: right; line-height: 1.3; }
.chrono-date small { display: block; font: .75rem var(--sans); color: var(--muted); }
.chrono-body { display: flex; flex-direction: column; }
.chrono-body .muted { font-size: .9rem; }

.quotes { display: flex; flex-direction: column; gap: 10px; }
.quote { position: relative; margin: 0; padding: 14px 44px 14px 18px; background: var(--card); border: 1px solid var(--line); border-left: 3px solid var(--gold); border-radius: 0 var(--radius) var(--radius) 0; }
.quote blockquote { margin: 0; font: italic 400 1.15rem/1.45 var(--serif); }
.quote figcaption { margin-top: 6px; font-size: .84rem; color: var(--muted); }
.quote .icon-btn { position: absolute; top: 8px; right: 6px; }
.notes .prose { background: color-mix(in srgb, var(--gold) 9%, var(--card)); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; max-width: none; }

/* ---------- Œuvres ---------- */
.work-head { display: flex; gap: 22px; align-items: flex-start; margin-bottom: 18px; }
.work-cover { border: 0; padding: 0; background: none; cursor: zoom-in; flex: none; }
.work-cover img { width: 150px; max-height: 210px; object-fit: cover; border-radius: 8px; box-shadow: var(--shadow); display: block; }
@media (max-width: 560px) { .work-head { flex-direction: column; } .work-cover img { width: 100%; max-height: 260px; } }

/* ---------- Images ---------- */
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px; }
.media-tile { aspect-ratio: 1; border: 0; padding: 0; border-radius: 10px; overflow: hidden; cursor: zoom-in; background: var(--sunk); }
.media-tile img, .gal-item img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .25s; }
.media-tile:hover img, .gal-item:hover img { transform: scale(1.04); }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.gal-item { position: relative; border: 0; padding: 0; border-radius: 12px; overflow: hidden; background: var(--sunk); aspect-ratio: 4 / 5; cursor: zoom-in; text-align: left; }
.gal-cap { position: absolute; inset: auto 0 0 0; padding: 26px 10px 9px; background: linear-gradient(transparent, rgba(20, 14, 8, .78)); color: #fff; display: flex; flex-direction: column; font-size: .86rem; }
.gal-cap small { opacity: .85; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gal-cap .warn { color: #ffd98a; }
@media (max-width: 560px) { .gallery { grid-template-columns: repeat(2, 1fr); gap: 8px; } }
.viewer { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 20px; }
.viewer-img { display: grid; place-items: center; background: var(--sunk); border-radius: 10px; overflow: hidden; }
.viewer-img img { max-height: 70vh; width: auto; display: block; }
.viewer-info .chips { margin: 12px 0; }
.meta { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; font-size: .9rem; margin: 10px 0; }
.meta dt { color: var(--muted); }
.meta dd { margin: 0; overflow-wrap: anywhere; }
@media (max-width: 700px) { .viewer { grid-template-columns: 1fr; } }

/* ---------- Cartes géographiques ---------- */
.mini-map { height: 220px; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); margin-bottom: 10px; z-index: 0; }
.mini-map.tall { height: 300px; margin-top: 16px; }
.picker-map { height: 220px; border-radius: 10px; overflow: hidden; border: 1px solid var(--line-2); margin: 8px 0 4px; z-index: 0; }
.map-wrap { position: relative; height: calc(100vh - var(--top) - var(--sat)); height: calc(100dvh - var(--top) - var(--sat)); }
@media (max-width: 899px) { .map-wrap { height: calc(100dvh - var(--top) - var(--sat) - var(--tab) - var(--sab)); } }
#bigmap, #graph { position: absolute; inset: 0; z-index: 0; }
.map-filters { position: absolute; z-index: 500; top: 12px; left: 12px; right: 12px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; pointer-events: none; }
.map-filters > * { pointer-events: auto; box-shadow: var(--shadow); }
.map-filters .toggle { background: var(--card); padding: 8px 11px; border-radius: 9px; border: 1px solid var(--line-2); color: var(--ink); }
.map-filters .icon-btn { background: var(--card); border: 1px solid var(--line-2); }
.map-filters select { max-width: 46vw; }
.map-count { position: absolute; z-index: 500; bottom: 8px; left: 12px; margin: 0; font-size: .8rem; background: var(--card); padding: 3px 9px; border-radius: 20px; color: var(--muted); }
.leaflet-container { font: inherit; background: var(--sunk); }
.leaflet-popup-content-wrapper, .leaflet-popup-tip { background: var(--card); color: var(--ink); }
.pop strong { font: 560 1.05rem var(--serif); display: block; }
.pop small { color: var(--muted); }
.pop p, .pop ul { margin: 6px 0 0; padding-left: 0; list-style: none; }
.pop .visit { color: var(--ok); }
.graph-legend { position: absolute; z-index: 5; bottom: 10px; left: 12px; right: 12px; display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: .78rem; color: var(--muted); pointer-events: none; }
.graph-legend i { display: inline-block; width: 14px; height: 3px; border-radius: 2px; margin-right: 5px; vertical-align: middle; }
.graph-legend i.dash { background: repeating-linear-gradient(90deg, #b0a590 0 4px, transparent 4px 7px); }

/* ---------- Frise ---------- */
.scroller { overflow-x: auto; overflow-y: hidden; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); -webkit-overflow-scrolling: touch; touch-action: pan-x pan-y; }
.lanes { display: block; font-family: var(--sans); user-select: none; -webkit-user-select: none; }
.lanes .grid line { stroke: var(--line); stroke-width: 1; }
.lanes .axis text { font-size: 11px; fill: var(--muted); text-anchor: middle; font-variant-numeric: tabular-nums; }
.lanes .sep { stroke: var(--line-2); stroke-dasharray: 2 4; }
.lanes .band text { font-size: 11px; font-weight: 600; }
.lanes .band:hover rect { fill-opacity: .3; }
.lanes .life { fill: var(--accent); transition: fill .15s; }
.lanes .life.fade-end, .lanes .life.fade-start { fill-opacity: .55; stroke: var(--accent); stroke-dasharray: 3 3; }
.lanes .life.alive { fill: var(--ok); }
.lanes .lane:hover .life { fill: var(--accent-2); }
.lanes .lane.dim { opacity: .35; }
.lanes .mk { fill: var(--card); stroke: var(--accent); stroke-width: 1.5; }
.lanes .mk-work { fill: var(--gold); stroke: var(--card); stroke-width: 1; }
.lanes .lbl { font-size: 12.5px; font-weight: 600; fill: var(--ink); pointer-events: none; }
.lanes .hit { fill: transparent; }
.lanes .lane:hover .lbl { fill: var(--accent); }
.lanes .cursor line { stroke: var(--gold); stroke-width: 1; stroke-dasharray: 3 3; pointer-events: none; }
.lanes .cursor rect { fill: var(--gold); pointer-events: none; }
.lanes .cursor text { fill: #fff; font-size: 11px; font-weight: 700; text-anchor: middle; pointer-events: none; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: .8rem; color: var(--muted); margin: -6px 0 10px; align-items: center; }
.legend i { display: inline-block; margin-right: 6px; vertical-align: -1px; }
.lg-life { width: 22px; height: 10px; border-radius: 5px; background: var(--accent); }
.lg-ms { width: 9px; height: 9px; border-radius: 50%; border: 1.5px solid var(--accent); background: var(--card); }
.lg-work { width: 8px; height: 8px; background: var(--gold); transform: rotate(45deg); }

.cmp-table { display: grid; grid-template-columns: 84px repeat(var(--cols), minmax(0, 1fr)); background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); font-size: .92rem; }
.cmp-table > .cmp-h:first-child { border-top-left-radius: var(--radius); }
.cmp-table > div { padding: 7px 12px; border-top: 1px solid var(--line); }
.cmp-h { position: sticky; top: calc(var(--top) + var(--sat)); background: var(--sunk); font: 600 1rem var(--serif); border-top: 0 !important; z-index: 2; }
.cmp-key { font: 560 .95rem var(--serif); color: var(--accent); text-align: right; }
.cmp-cell { display: flex; flex-direction: column; gap: 2px; }
.cmp-cell a { color: var(--ink); text-decoration: underline; text-decoration-color: var(--line-2); text-underline-offset: 3px; }

/* ---------- Contexte ---------- */
.events { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.event { display: grid; grid-template-columns: 110px 1fr auto; gap: 16px; padding: 12px 10px 12px 16px; background: var(--card); border: 1px solid var(--line); border-left: 4px solid var(--c); border-radius: 0 var(--radius) var(--radius) 0; }
.event.focus { box-shadow: 0 0 0 2px var(--gold); }
.event-date { font: 560 .98rem var(--serif); }
.event-date small { display: block; font: .8rem var(--sans); color: var(--muted); }
.event h3 { font-size: 1.12rem; margin-bottom: 4px; }
.event p { margin: 4px 0 0; }
.event .ico { width: 15px; height: 15px; vertical-align: -2px; }
@media (max-width: 560px) { .event { grid-template-columns: 1fr auto; } .event-date { grid-column: 1 / -1; } }

/* ---------- Quiz ---------- */
.quiz { max-width: 620px; margin: 10px auto; }
.quiz.done { text-align: center; padding-top: 40px; }
.quiz.done .display { font-size: 4rem; margin: 6px 0; }
.quiz-progress { height: 4px; background: var(--sunk); border-radius: 2px; overflow: hidden; margin-bottom: 18px; }
.quiz-progress span { display: block; height: 100%; background: var(--gold); transition: width .3s; }
.quiz-q { font-size: 1.55rem; font-weight: 450; margin: 4px 0 20px; }
.quiz-choices { display: grid; gap: 10px; }
.choice { text-align: left; padding: 14px 16px; border-radius: var(--radius); border: 1px solid var(--line-2); background: var(--card); cursor: pointer; font-size: 1.02rem; }
.choice:hover:not(:disabled) { border-color: var(--accent); }
.choice.ok { border-color: var(--ok); background: var(--ok-soft); }
.choice.ko { border-color: #a02c25; background: var(--ko-soft); }
.choice:disabled { cursor: default; }
.quiz-feedback { margin: 16px 0; padding: 12px 14px; border-radius: 10px; background: var(--sunk); }
.quiz-feedback.ok strong { color: var(--ok); }
.quiz-feedback.ko strong { color: #b4382f; }

/* ---------- Recherche, menu, réglages ---------- */
.big-search { width: 100%; font-size: 1.15rem; padding: 13px 16px; border-radius: 12px; margin-bottom: 6px; }
.menu-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; }
.menu-item { display: flex; gap: 14px; align-items: center; padding: 16px; border-radius: var(--radius); background: var(--card); border: 1px solid var(--line); color: var(--ink); }
.menu-item:hover { text-decoration: none; border-color: var(--line-2); }
.menu-item .ico { width: 24px; height: 24px; color: var(--accent); }
.menu-item span { display: flex; flex-direction: column; }
.menu-item small { color: var(--muted); }
.steps { padding-left: 20px; }
.steps li { margin: 6px 0; }

/* ---------- Modales & formulaires ---------- */
body.modal-open { overflow: hidden; }
.modal-wrap { position: fixed; inset: 0; z-index: 1000; background: rgba(25, 18, 10, .45); display: flex; align-items: flex-start; justify-content: center; padding: 6vh 16px 16px; overflow-y: auto; animation: fade .15s; }
.modal { width: 100%; max-width: 560px; background: var(--card); border-radius: 16px; box-shadow: 0 20px 60px rgba(0, 0, 0, .25); animation: rise .18s ease-out; }
.modal.wide { max-width: 860px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 14px 10px 22px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--card); border-radius: 16px 16px 0 0; z-index: 2; }
.modal-head h2 { font-size: 1.25rem; }
.modal-body { padding: 18px 22px 22px; }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { transform: translateY(12px); opacity: .5; } }
@media (max-width: 640px) {
  .modal-wrap { padding: calc(var(--sat) + 12px) 0 0; align-items: stretch; }
  .modal, .modal.wide { max-width: none; border-radius: 16px 16px 0 0; min-height: 100%; padding-bottom: var(--sab); }
}
.form .grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 14px; }
.field { display: flex; flex-direction: column; gap: 5px; grid-column: 1 / -1; min-width: 0; }
.field.half { grid-column: span 1; }
.field > span { font-size: .84rem; font-weight: 600; color: var(--muted); }
.field small { font-size: .78rem; color: var(--muted); }
.field small.bad { color: #b4382f; }
.field.check { flex-direction: row; align-items: center; gap: 9px; align-self: end; padding: 8px 0; }
.field.check span { color: var(--ink); font-weight: 500; font-size: .95rem; }
.coords-row { display: flex; gap: 8px; }
.coords-row input { flex: 1; width: 0; }
@media (max-width: 560px) { .form .grid { grid-template-columns: 1fr; } .field.half { grid-column: 1 / -1; } }
.form-actions { display: flex; gap: 8px; align-items: center; margin-top: 18px; }
.form-actions.wrap { flex-wrap: wrap; }
.section .form-actions { margin-top: 10px; flex-wrap: wrap; }
.spacer { flex: 1; }
.form-error { color: #b4382f; background: var(--ko-soft); padding: 8px 12px; border-radius: 8px; margin: 12px 0 0; font-size: .92rem; }

#toasts { position: fixed; z-index: 2000; left: 50%; transform: translateX(-50%); bottom: calc(var(--sab) + 84px); display: flex; flex-direction: column; gap: 6px; align-items: center; pointer-events: none; }
@media (min-width: 900px) { #toasts { bottom: 24px; } }
.toast { background: var(--ink); color: var(--paper); padding: 9px 16px; border-radius: 20px; font-size: .92rem; box-shadow: var(--shadow); animation: rise .2s; transition: opacity .4s; max-width: 90vw; }
.toast.error { background: #a02c25; color: #fff; }
.toast.out { opacity: 0; }

/* ---------- Connexion ---------- */
.login { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 20px; }
.login-card { width: 100%; max-width: 360px; text-align: center; background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 30px 26px; box-shadow: var(--shadow); }
.login-card h1 { font-size: 2rem; }
.login-card .field { text-align: left; margin: 20px 0 14px; }
.login-logo { width: 72px; height: 72px; border-radius: 16px; margin-bottom: 10px; }
