:root {
  --ink: #1a1814; --paper: #f2f5fa; --paper-dark: #e6ecf6; --card: #ffffff;
  --brand: #1d3a5f; --gold: #b89a5a; --gold-light: #d4b87a; --muted: #6d6a63;
  --line: #d7deea; --nav-h: 72px;
  --serif: "Cormorant Garamond", Georgia, "Times New Roman", serif;
  --sans: "Montserrat", system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
html { background: var(--paper); }
body { font-family: var(--sans); font-weight: 300; background: var(--paper); color: var(--ink); min-height: 100vh; }

.entete { text-align: center; padding: calc(var(--nav-h) + 1rem) 1.2rem 0.4rem; }
.entete .eyebrow { font-size: 0.68rem; letter-spacing: 0.26em; text-transform: uppercase; color: var(--gold); margin: 0 0 0.5rem; }
.entete h1 { font-family: var(--serif); font-weight: 600; font-size: clamp(1.9rem, 4.6vw, 3rem); line-height: 1.03; color: var(--brand); }
.entete .accroche { max-width: 820px; margin: 0.7rem auto 0; font-size: 0.95rem; line-height: 1.55; color: var(--muted); }

/* ── Barre d'outils ── */
.toolbar { display: flex; align-items: center; gap: 0.45rem; flex-wrap: wrap; justify-content: center;
  max-width: 1500px; margin: 0.9rem auto 0.4rem; padding: 0 1rem; }
.toolbar button { font-family: var(--sans); font-size: 12.5px; font-weight: 500; color: var(--ink);
  background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 7px 12px; cursor: pointer; transition: all 0.14s; }
.toolbar button:hover { border-color: var(--gold); color: var(--brand); }
.toolbar .zoomgrp { display: inline-flex; }
.toolbar .zoomgrp button { border-radius: 0; border-right: none; font-size: 15px; padding: 5px 12px; }
.toolbar .zoomgrp button:first-child { border-radius: 8px 0 0 8px; }
.toolbar .zoomgrp button:last-child { border-radius: 0 8px 8px 0; border-right: 1px solid var(--line); }
.tb-sep { width: 1px; height: 22px; background: var(--line); margin: 0 3px; }
.tb-search { position: relative; }
.tb-search input { width: 260px; font-family: var(--sans); font-size: 12.5px; font-weight: 400; color: var(--ink);
  background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 7px 12px; outline: none; }
.tb-search input:focus { border-color: var(--gold); }
.tb-search input::placeholder { color: var(--muted); }
#clear-focus { display: none; }
.search-results { position: absolute; top: calc(100% + 4px); left: 0; z-index: 60; width: 320px; max-width: 80vw; max-height: 340px; overflow-y: auto;
  background: var(--card); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 10px 30px rgba(29,58,95,0.16); display: none; text-align: left; }
.search-results.open { display: block; }
.sr-item { display: flex; align-items: center; gap: 8px; padding: 7px 12px; cursor: pointer; font-size: 12.5px; border-top: 1px solid rgba(29,58,95,0.05); }
.sr-item:hover { background: var(--paper-dark); }
.sr-dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.sr-name { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sr-meta { color: var(--muted); font-size: 11px; white-space: nowrap; }
.sr-empty { padding: 12px; color: var(--muted); font-style: italic; font-size: 12px; }
.tb-opts { display: inline-flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.tb-opts label { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: var(--ink); cursor: pointer; }
.tb-opts input[type="checkbox"] { accent-color: var(--brand); cursor: pointer; }
.tb-opts .rng { gap: 7px; }
.tb-opts .rng span { color: var(--muted); font-size: 11px; }
.tb-opts input[type="range"] { width: 84px; accent-color: var(--gold); cursor: pointer; }
#restore-hidden { color: var(--brand); border-color: #c9b98f; background: #fbf6ea; }
#restore-hidden:hover { border-color: var(--gold); }

/* ── Puces de secteur ── */
.legend { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; max-width: 1500px; margin: 0.2rem auto 0.5rem; padding: 0 1rem; align-items: center; }
.legend .leg-lbl { font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); margin-right: 4px; }
.chip { font-family: var(--sans); font-size: 11.5px; font-weight: 500; display: inline-flex; align-items: center; gap: 6px;
  background: var(--card); border: 1px solid var(--line); border-radius: 20px; padding: 4px 11px; cursor: pointer; color: var(--muted); transition: all .12s; }
.chip .chip-dot { width: 9px; height: 9px; border-radius: 50%; flex: none; opacity: .35; }
.chip.on { color: var(--ink); border-color: #c5d0e2; }
.chip.on .chip-dot { opacity: 1; }
.chip:hover { border-color: var(--gold); }
.legend .leg-mini { font-size: 11px; color: var(--muted); background: none; border: none; text-decoration: underline; cursor: pointer; padding: 2px 4px; }

/* ── Scène ── */
.scene-wrap { position: relative; max-width: 1500px; margin: 0 auto; padding: 0 1rem; }
.scene { position: relative; width: 100%; height: min(76vh, 940px); min-height: 420px;
  border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--paper);
  box-shadow: 0 8px 26px rgba(29,58,95,0.07); cursor: grab; touch-action: none; }
.scene.grabbing { cursor: grabbing; }
.scene.reordering { cursor: ns-resize; }
.scene-wrap.is-fs .scene { height: 100vh; border-radius: 0; }
.scene-wrap.fs-fallback { position: fixed; inset: 0; z-index: 3000; background: var(--paper); max-width: none; margin: 0; padding: 0; }
.scene-wrap.fs-fallback .scene { height: 100vh; height: 100dvh; border-radius: 0; }
.fs-exit { position: absolute; top: 12px; left: 12px; z-index: 60; display: none; font-family: var(--sans); font-size: 12.5px; font-weight: 500;
  color: var(--brand); background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 7px 12px; cursor: pointer; box-shadow: 0 4px 14px rgba(29,58,95,.15); }
.scene-wrap.is-fs .fs-exit, .scene-wrap.fs-fallback .fs-exit { display: block; }
.fs-exit:hover { border-color: var(--gold); }
#svg { width: 100%; height: 100%; display: block; font-family: var(--sans); }

/* Axe + colonnes */
.axis-bg { fill: var(--paper); }
.corner-bg { fill: var(--paper); }
.gutter-bg { fill: var(--paper); }
.axis-year { fill: var(--muted); font-size: 11px; text-anchor: middle; }
.axis-tick { stroke: #c3cdde; stroke-width: 1; }
.axis-now { stroke: var(--gold); stroke-width: 2; }
.grid-line { stroke: #e2e8f2; stroke-width: 1; }
.grid-century { stroke: #cdd7e6; stroke-width: 1.4; }
.fam-sep { stroke: #d0d9e8; stroke-width: 1; stroke-dasharray: 2 4; }
.fam-name { font-family: var(--serif); font-size: 15px; font-weight: 600; fill: var(--brand); }
.fam-dot { }
.fam-label.dim { opacity: .32; }

/* Lifelines */
.bar-rect { stroke: rgba(255,255,255,.55); stroke-width: .6; }
.bar { cursor: pointer; }
.bar.bar-live .bar-rect { }
.bar.hot .bar-rect { stroke: var(--brand); stroke-width: 1.6; }
.bar.dim { opacity: .16; }
.bar-label { font-size: 11px; fill: #33475f; paint-order: stroke; stroke: var(--paper); stroke-width: 3px; stroke-linejoin: round; pointer-events: none; }
.bar-label.hot { fill: var(--brand); font-weight: 600; }
.bar-label.dim { opacity: .18; }

/* Événements */
.ev-path { fill: none; stroke: #7c8ba0; stroke-width: 1.4; opacity: .8; }
.ev-mark { fill: #55617a; stroke: var(--paper); stroke-width: 1.2; cursor: pointer; }
.ev-split .ev-mark, .ev-spinoff .ev-mark { fill: #fff; stroke: #55617a; stroke-width: 1.6; }
.ev-rename .ev-mark { fill: #9aa6bb; }
.ev-divest .ev-path, .ev-stake .ev-path { stroke-dasharray: 3 3; opacity: .6; }
.ev-divest .ev-mark, .ev-stake .ev-mark { fill: #b0562a; }
.ev { cursor: pointer; }
.ev.hot .ev-path { stroke: var(--brand); stroke-width: 2.4; opacity: 1; }
.ev.hot .ev-mark { fill: var(--gold); stroke: var(--brand); }
.ev.dim { opacity: .12; }

/* Tooltip */
#tip { position: absolute; z-index: 40; pointer-events: none; max-width: 300px; background: #fff; border: 1px solid var(--line);
  border-radius: 10px; box-shadow: 0 12px 30px rgba(29,58,95,0.18); padding: 9px 11px; font-size: 12px; color: var(--ink); opacity: 0; transition: opacity .1s; }
#tip.show { opacity: 1; }
.tt-h { font-family: var(--serif); font-size: 15px; font-weight: 600; color: var(--brand); display: flex; align-items: center; gap: 7px; }
.tt-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.tt-year { color: var(--gold); font-family: var(--sans); font-size: 13px; }
.tt-meta { color: var(--muted); font-size: 11.5px; margin-top: 2px; }
.tt-flow { margin-top: 5px; font-size: 12px; }
.tt-from { color: #33475f; } .tt-to { color: var(--brand); font-weight: 600; } .tt-arrow { color: var(--gold); }
.tt-note { margin-top: 5px; font-size: 11.5px; line-height: 1.4; color: #4a4a44; }
.tt-hint { margin-top: 5px; font-size: 10.5px; font-style: italic; color: var(--muted); }

/* Fiche détaillée */
#detail { position: absolute; top: 12px; right: 12px; z-index: 50; width: 330px; max-width: calc(100% - 24px); max-height: calc(100% - 24px); overflow-y: auto;
  background: #fff; border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 16px 40px rgba(29,58,95,0.22); padding: 16px 16px 14px;
  transform: translateX(12px); opacity: 0; pointer-events: none; transition: all .16s; }
#detail.show { transform: none; opacity: 1; pointer-events: auto; }
.detail-close { position: absolute; top: 8px; right: 8px; background: none; border: none; font-size: 16px; color: var(--muted); cursor: pointer; line-height: 1; }
.detail-close:hover { color: var(--brand); }
.detail-head { display: flex; align-items: flex-start; gap: 9px; padding-right: 18px; }
.detail-dot { width: 13px; height: 13px; border-radius: 50%; margin-top: 4px; flex: none; }
.detail-head h3 { font-family: var(--serif); font-size: 1.35rem; font-weight: 600; color: var(--brand); line-height: 1.1; }
.detail-sub { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.detail-tags { display: flex; flex-wrap: wrap; gap: 5px; margin: 9px 0 0; }
.dtag { font-size: 10.5px; background: var(--paper-dark); color: #445; border-radius: 12px; padding: 2px 9px; }
.detail-note { font-size: 12.5px; line-height: 1.5; color: #3c3c36; margin-top: 9px; }
.detail-rel { margin-top: 11px; }
.detail-rel h4 { font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--gold); margin-bottom: 5px; }
.detail-rel ul { list-style: none; }
.detail-rel li { font-size: 11.5px; line-height: 1.4; color: #444; padding: 4px 0; border-top: 1px solid #eef1f7; }
.detail-rel li b { color: var(--brand); }
.rel-d { display: block; color: var(--muted); font-size: 11px; margin-top: 1px; }
.detail-wiki { margin-top: 11px; }
.wiki-img { width: 100%; max-height: 180px; object-fit: cover; border-radius: 8px; margin-bottom: 8px; }
.wiki-ex { font-size: 12px; line-height: 1.5; color: #3c3c36; }
.wiki-loading { font-size: 11.5px; color: var(--muted); font-style: italic; }
.detail-link { display: inline-block; margin-top: 10px; font-size: 12px; color: var(--brand); text-decoration: none; border-bottom: 1px solid var(--gold-light); }
.detail-link:hover { border-color: var(--brand); }
.detail-hide { display: block; width: 100%; margin-top: 12px; font-family: var(--sans); font-size: 12px; color: #9a4a3a;
  background: #fbeeea; border: 1px solid #ecccc2; border-radius: 8px; padding: 7px 10px; cursor: pointer; transition: all .13s; }
.detail-hide:hover { background: #f6e0d9; border-color: #d98f7c; }

/* Aide / événements légende */
.ev-legend { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; max-width: 1200px; margin: 0.55rem auto 0; padding: 0 1rem; font-size: 11.5px; color: var(--muted); }
.ev-legend span { display: inline-flex; align-items: center; gap: 5px; }
.ev-legend .lg-mark { width: 12px; height: 12px; display: inline-block; }
.hint-line { text-align: center; color: var(--muted); font-size: 11.5px; font-style: italic; font-family: var(--serif); margin: 0.4rem auto 0; }

/* Sources */
.sources { max-width: 900px; margin: 2.2rem auto 1rem; padding: 0 1.2rem; }
.src-box { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 1.3rem 1.5rem; }
.src-box h2 { font-family: var(--serif); font-size: 1.5rem; font-weight: 600; color: var(--brand); margin-bottom: 0.5rem; }
.src-box p { font-size: 0.9rem; line-height: 1.6; color: #4a4a44; margin-bottom: 0.6rem; }
.src-box a { color: var(--brand); }
.src-box ul { margin: 0.3rem 0 0.3rem 1.1rem; font-size: 0.86rem; color: #4a4a44; line-height: 1.55; }

.seo-note { max-width: 900px; margin: 1.4rem auto; padding: 0 1.2rem; font-size: 0.86rem; line-height: 1.6; color: var(--muted); }
.seo-note h2 { font-family: var(--serif); color: var(--brand); font-size: 1.25rem; font-weight: 600; margin-bottom: 0.4rem; }

.noscript-fallback { max-width: 760px; margin: 1.5rem auto; padding: 1rem 1.4rem; background: #fff; border: 1px solid var(--line); border-radius: 12px; font-size: 0.9rem; line-height: 1.55; }

@media (max-width: 640px) {
  .tb-search input { width: 180px; }
  #detail { width: calc(100% - 24px); }
  .fam-name { font-size: 12px; }
}
