:root {
  --bg: #f4efe4; --ink: #2b2620; --muted: #7a7062; --line: #b8ab94;
  --m: #dce8f2; --f: #f4e0e6; --u: #e9e6de;
  --acte: #3f7d4e; --table: #c98a1b; --temoin: #9a9a9a;
}
* { box-sizing: border-box; }
body { margin: 0; height: 100vh; display: flex; flex-direction: column; background: var(--bg); color: var(--ink); font: 14px/1.4 "Segoe UI", system-ui, sans-serif; }
header { display: flex; flex-wrap: wrap; gap: 12px 18px; align-items: center; padding: 10px 18px; background: #fbf8f1; border-bottom: 1px solid var(--line); }
h1 { margin: 0; font: 600 20px Georgia, serif; }
h1 small { font: 13px "Segoe UI", sans-serif; color: var(--muted); margin-left: 6px; }
select, input, button { font: inherit; padding: 5px 8px; border: 1px solid var(--line); border-radius: 6px; background: #fff; color: var(--ink); }
button { cursor: pointer; } button:hover { background: #efe8d8; }
.zoom { display: flex; gap: 4px; }
.legend { margin-left: auto; display: flex; gap: 14px; color: var(--muted); font-size: 12px; }
.k { display: inline-block; width: 22px; height: 12px; border-radius: 3px; margin-right: 5px; vertical-align: -2px; background: #fff; }
.k.acte { border: 2px solid var(--acte); } .k.table { border: 2px solid var(--table); } .k.temoin { border: 2px dashed var(--temoin); }
main { flex: 1; display: flex; min-height: 0; }
#viewport { flex: 1; overflow: hidden; position: relative; cursor: grab;
  background: radial-gradient(circle at 1px 1px, #d9cfba 1px, transparent 0) 0 0 / 22px 22px; }
#viewport.drag { cursor: grabbing; }
#stage { position: absolute; left: 0; top: 0; transform-origin: 0 0; }
#lines { position: absolute; left: 0; top: 0; overflow: visible; pointer-events: none; }
#lines path { fill: none; stroke: var(--line); stroke-width: 2; }
#lines text { fill: var(--muted); font: 11px "Segoe UI", sans-serif; text-anchor: middle; }
.card { position: absolute; width: 196px; height: 84px; padding: 8px 10px 6px 12px; border-radius: 10px; background: var(--u); border: 2px solid var(--acte); cursor: pointer; overflow: hidden; box-shadow: 0 1px 3px #0002; transition: box-shadow .15s, transform .15s; }
.card:hover { box-shadow: 0 4px 12px #0003; transform: translateY(-2px); }
.card.M { background: var(--m); } .card.F { background: var(--f); }
.card.acte { border-color: var(--acte); } .card.table { border-color: var(--table); } .card.temoin { border: 2px dashed var(--temoin); }
.card.sel { outline: 3px solid #2b6cb0; outline-offset: 2px; }
.card .nm { font: 600 14px Georgia, serif; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card .nm span { font-weight: 400; letter-spacing: .03em; }
.card .dt { font-size: 12.5px; margin-top: 3px; } .card .pl { font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card .ic { position: absolute; right: 6px; top: 4px; font-size: 13px; }
aside { width: 380px; overflow-y: auto; background: #fbf8f1; border-left: 1px solid var(--line); padding: 16px 18px; }
aside h2 { margin: 0 0 2px; font: 600 22px Georgia, serif; }
aside .sub { color: var(--muted); margin-bottom: 12px; }
aside dl { margin: 0 0 12px; display: grid; grid-template-columns: 70px 1fr; gap: 4px 8px; } aside dt { color: var(--muted); }
aside dd { margin: 0; }
.anec { background: #fff6d8; border-left: 4px solid #e0b430; padding: 8px 10px; border-radius: 4px; margin: 10px 0; }
.k.epoq { background: linear-gradient(90deg, hsl(46 55% 80%), hsl(0 55% 85%), hsl(200 55% 82%)); }

/* Époques : bandes de fond, filigrane, frise */
.band { position: absolute; left: -4000px; display: flex; align-items: center; overflow: hidden; pointer-events: none;
  background: hsla(var(--h), 60%, 55%, .13); border-top: 1px solid hsla(var(--h), 45%, 40%, .22); }
.band span { flex: none; width: 1400px; text-align: center; white-space: nowrap; font: italic 600 58px Georgia, serif;
  color: hsla(var(--h), 45%, 28%, .10); letter-spacing: .02em; }
#eras { position: absolute; left: 0; top: 0; bottom: 0; width: 215px; pointer-events: none; z-index: 4; overflow: hidden; }
body.no-eras #eras { display: none; }
.era-lab { position: absolute; left: 0; right: 0; padding: 10px 14px 6px 12px; display: flex; flex-direction: column; overflow: hidden;
  background: linear-gradient(90deg, hsla(var(--h), 50%, 93%, .97) 82%, hsla(var(--h), 50%, 93%, 0));
  border-left: 5px solid hsla(var(--h), 55%, 42%, .85); border-top: 1px solid hsla(var(--h), 45%, 40%, .25); }
.era-lab { pointer-events: auto; cursor: pointer; }
.era-lab:hover { border-left-width: 9px; }
.era-lab.xs { padding: 3px 12px 2px; justify-content: center; }
.era-lab.xs .era-sc { font-size: 9px; } .era-lab.xs .era-nm { font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.era-lab.xs .era-y, .era-lab.xs ul { display: none; }
.era-lab.xxs { padding: 0 10px; justify-content: center; }
.era-lab.xxs .era-nm { font-size: 10.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.era-lab.xxs .era-sc, .era-lab.xxs .era-y, .era-lab.xxs ul { display: none; }
.band.new-sc, .era-lab.new-sc { border-top: 3px solid hsla(var(--h), 55%, 30%, .55); }
.per { border-left: 6px solid hsla(var(--h), 55%, 42%, .85); background: hsla(var(--h), 55%, 55%, .12); padding: 10px 12px; border-radius: 4px; }
.per h2 { margin: 2px 0 6px; } .per p { margin: 0; }
.per-txt { margin: 4px 0 2px; font-size: 13px; }
.who { margin: 4px 0; } .who a, .vecu a { color: #2b6cb0; cursor: pointer; text-decoration: underline; }
.era-sc { font: 600 10.5px "Segoe UI", sans-serif; letter-spacing: .14em; text-transform: uppercase; color: hsla(var(--h), 50%, 28%, .95); }
.era-nm { font: 600 14px/1.2 Georgia, serif; margin: 2px 0 1px; }
.era-y { font-size: 11px; font-style: italic; color: var(--muted); }
.era-lab ul { list-style: none; margin: 6px 0 0; padding: 0; font-size: 11.5px; line-height: 16px; }
.era-lab li { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.era-lab li b, .vecu li b { color: hsl(var(--h) 50% 28%); font-weight: 700; margin-right: 2px; }
.vecu { border-left: 4px solid hsla(var(--h), 55%, 42%, .85); background: hsla(var(--h), 55%, 55%, .10); padding: 8px 10px; border-radius: 4px; margin: 12px 0; }
.vecu-t { font: 600 14px Georgia, serif; }
.vecu-s { font-size: 12px; color: var(--muted); margin-top: 6px; }
.vecu ul { list-style: none; margin: 4px 0 0; padding: 0; font-size: 12.5px; }
.vecu li { padding: 2px 0; } .vecu li i { color: var(--muted); font-size: 11.5px; }
.fait { white-space: pre-wrap; margin: 8px 0; }
.src { margin: 14px 0; padding-top: 10px; border-top: 1px solid var(--line); font-size: 12.5px; }
.src img { width: 100%; max-height: 200px; object-fit: cover; object-position: top; border: 1px solid var(--line); border-radius: 4px; margin-top: 6px; cursor: zoom-in; }
.hint { color: var(--muted); }
.rel a { color: #2b6cb0; cursor: pointer; text-decoration: underline; }
#modal { position: fixed; inset: 0; background: #000c; overflow: auto; z-index: 10; padding: 20px; }
#modal img { display: block; margin: 0 auto; max-width: 100%; cursor: zoom-in; } #modal img.big { max-width: none; width: 220%; cursor: zoom-out; }
#modalClose { position: fixed; top: 14px; right: 24px; }

.tog { position: absolute; width: 22px; height: 22px; border-radius: 11px; border: 1.5px solid var(--line); background: #fff; color: var(--muted); font-size: 12px; line-height: 19px; text-align: center; cursor: pointer; z-index: 3; user-select: none; }
.tog:hover { background: #efe8d8; color: var(--ink); }
.tog.off { width: auto; padding: 0 7px; background: #efe3c2; color: var(--ink); font-weight: 600; }

/* Tablette */
@media (max-width: 900px) {
  header { padding: 8px 12px; gap: 8px 12px; }
  h1 { font: 600 17px Georgia, serif; }
  .legend { margin-left: 0; width: 100%; order: 5; font-size: 11px; gap: 10px; }
  main { flex-direction: column; }
  aside { width: 100%; max-height: 38vh; border-left: none; border-top: 1px solid var(--line); }
  #viewport { flex: 1 1 auto; min-height: 40vh; }
}

/* Mobile */
@media (max-width: 560px) {
  header { padding: 6px 10px; }
  h1 small { display: block; margin-left: 0; }
  label { display: none; }
  #search { flex: 1 1 100%; order: 4; }
  .zoom button { padding: 6px 10px; font-size: 15px; }
  #collapseAll, #expandAll { display: none; }
  aside { max-height: 45vh; padding: 12px 14px; }
  aside h2 { font-size: 19px; }
  .src img { max-height: 160px; }
  #eras { width: 140px; }
  .era-nm { font-size: 12px; } .era-lab ul { font-size: 10.5px; }
}
