:root {
  --bg: #f6f2ea; --card: #fffdf8; --ink: #2b2620; --muted: #7a6f60; --line: #e0d7c6;
  --accent: #7a4b2a; --accent-soft: #efe3d3; --m: #dfeaf2; --f: #f5e1e4; --sosa: #c98a1b;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 16px/1.5 Georgia, "Times New Roman", serif; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { font-weight: normal; line-height: 1.2; margin: 0 0 .5em; }
h1 { font-size: 1.9rem; } h2 { font-size: 1.25rem; margin-top: 1.6em; border-bottom: 1px solid var(--line); padding-bottom: .25em; }
.muted { color: var(--muted); } .small { font-size: .88rem; }
[hidden] { display: none !important; }

/* Connexion */
#login { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }
.login-card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 2rem; width: min(100%, 22rem); display: grid; gap: .6rem; }
.login-card input[type=password] { font: inherit; padding: .55rem .7rem; border: 1px solid var(--line); border-radius: 6px; width: 100%; }
.login-card button { font: inherit; padding: .6rem; border: 0; border-radius: 6px; background: var(--accent); color: #fff; cursor: pointer; }
.check { display: flex; gap: .5rem; align-items: center; font-size: .9rem; }
.error { color: #a12525; min-height: 1.2em; margin: 0; }

/* Structure */
.top { position: sticky; top: 0; z-index: 5; display: flex; flex-wrap: wrap; gap: .5rem 1.2rem; align-items: center; padding: .6rem 1rem; background: var(--card); border-bottom: 1px solid var(--line); }
.brand { font-size: 1.15rem; color: var(--ink); white-space: nowrap; }
#nav { display: flex; gap: 1rem; flex-wrap: wrap; font-family: system-ui, sans-serif; font-size: .92rem; }
#nav a.on { border-bottom: 2px solid var(--accent); }
.search { position: relative; margin-left: auto; flex: 1 1 12rem; max-width: 20rem; }
.search input { width: 100%; font: .92rem system-ui, sans-serif; padding: .45rem .7rem; border: 1px solid var(--line); border-radius: 999px; background: #fff; }
#q-results { position: absolute; top: 100%; left: 0; right: 0; margin: .25rem 0 0; padding: .25rem; list-style: none; background: #fff; border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.12); max-height: 60vh; overflow: auto; }
#q-results a { display: block; padding: .35rem .5rem; border-radius: 5px; color: var(--ink); }
#q-results a:hover, #q-results a.sel { background: var(--accent-soft); text-decoration: none; }
main { max-width: 68rem; margin: 0 auto; padding: 1.2rem 1rem 3rem; }
.foot { text-align: center; color: var(--muted); font: .82rem system-ui, sans-serif; padding: 1.5rem 1rem; }

/* Cartes et listes */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr)); gap: .7rem; margin: 1rem 0; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: .8rem 1rem; }
.stat b { display: block; font-size: 1.6rem; font-weight: normal; }
.stat span { color: var(--muted); font: .82rem system-ui, sans-serif; }
.plist { list-style: none; padding: 0; margin: .3rem 0; }
.plist li { padding: .15rem 0; }
.sosa { display: inline-block; font: .7rem system-ui, sans-serif; background: var(--sosa); color: #fff; border-radius: 999px; padding: 0 .45em; vertical-align: middle; margin-left: .3em; }
.sex-M::before { content: "♂ "; color: #4a78a0; } .sex-F::before { content: "♀ "; color: #b0607a; }
.dates { color: var(--muted); font-size: .9em; white-space: nowrap; }

/* Fiche */
.person-head { display: flex; gap: 1.2rem; align-items: flex-start; flex-wrap: wrap; }
.portrait { width: 9.5rem; aspect-ratio: 4/5; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); background: var(--accent-soft); cursor: zoom-in; }
.portrait.none { display: grid; place-items: center; color: var(--muted); font-size: 2.6rem; cursor: default; }
.facts { margin: .4rem 0 0; padding: 0; list-style: none; }
.facts li { padding: .1rem 0; }
.facts b { font-weight: normal; color: var(--muted); display: inline-block; min-width: 6.2rem; font: .85rem system-ui, sans-serif; }
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(17rem, 1fr)); gap: 0 2rem; }
.union { margin: .5rem 0 .9rem; }
.union .plist { margin-left: 1.1rem; }
.note { background: var(--card); border-left: 3px solid var(--line); padding: .5rem .8rem; white-space: pre-wrap; }
.actions { margin-top: .6rem; font: .9rem system-ui, sans-serif; display: flex; gap: 1rem; flex-wrap: wrap; }

/* Arbre */
.tree-tools { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; font: .9rem system-ui, sans-serif; margin-bottom: .8rem; }
.tree-tools select { font: inherit; padding: .2rem .4rem; }
.pedigree-wrap { overflow-x: auto; padding-bottom: .5rem; }
.pedigree { display: flex; gap: 1.4rem; min-width: max-content; }
.gen { display: flex; flex-direction: column; justify-content: space-around; gap: 6px; }
.box { width: 12.5rem; min-height: 3.1rem; padding: .3rem .55rem; border: 1px solid var(--line); border-radius: 7px; background: var(--card); font: .84rem/1.25 system-ui, sans-serif; color: var(--ink); display: block; position: relative; }
.box:hover { border-color: var(--accent); text-decoration: none; }
.box.M { background: var(--m); } .box.F { background: var(--f); }
.box.empty { background: transparent; border-style: dashed; color: var(--muted); }
.box small { display: block; color: var(--muted); }
.box .up { position: absolute; right: .3rem; top: .15rem; color: var(--accent); font-size: .8rem; }
.desc ul { list-style: none; margin: 0; padding-left: 1.3rem; border-left: 1px solid var(--line); }
.desc > ul { padding-left: 0; border: 0; }
.desc li { padding: .12rem 0; }
.desc .sp { color: var(--muted); }

/* Tableaux */
.filters { display: flex; gap: .7rem; flex-wrap: wrap; margin: .6rem 0 1rem; font: .9rem system-ui, sans-serif; }
.filters input, .filters select { font: inherit; padding: .35rem .5rem; border: 1px solid var(--line); border-radius: 6px; background: #fff; }
table { width: 100%; border-collapse: collapse; font-size: .93rem; }
th { text-align: left; font: 600 .78rem system-ui, sans-serif; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; border-bottom: 1px solid var(--line); padding: .35rem .5rem; cursor: pointer; white-space: nowrap; }
td { padding: .32rem .5rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.table-wrap { overflow-x: auto; }

/* Galeries */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(8.5rem, 1fr)); gap: .9rem; }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; font: .82rem/1.3 system-ui, sans-serif; color: var(--ink); display: block; }
.tile img { width: 100%; aspect-ratio: 4/5; object-fit: cover; display: block; background: var(--accent-soft); }
.tile span { display: block; padding: .4rem .5rem; }
.docs { display: grid; grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr)); gap: 1rem; }
.doc { background: var(--card); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.doc img { width: 100%; aspect-ratio: 4/3; object-fit: cover; display: block; cursor: zoom-in; background: var(--accent-soft); }
.doc div { padding: .5rem .7rem .7rem; font: .86rem/1.35 system-ui, sans-serif; }
.doc b { display: block; font: 1rem/1.3 Georgia, serif; font-weight: normal; margin-bottom: .2rem; }
.tag { display: inline-block; font: .72rem system-ui, sans-serif; background: var(--accent-soft); border-radius: 4px; padding: .05rem .4rem; margin-right: .3rem; }

/* Visionneuse */
#lightbox { position: fixed; inset: 0; z-index: 20; background: rgba(20,16,12,.96); display: flex; flex-direction: column; color: #fff; }
.lb-bar { display: flex; justify-content: space-between; gap: 1rem; align-items: center; padding: .5rem .8rem; font: .9rem system-ui, sans-serif; }
.lb-actions { display: flex; gap: .6rem; align-items: center; white-space: nowrap; }
.lb-bar button, .lb-bar a { background: rgba(255,255,255,.12); color: #fff; border: 0; border-radius: 6px; padding: .3rem .7rem; font: inherit; cursor: pointer; }
.lb-stage { flex: 1; overflow: auto; text-align: center; }
.lb-stage img { max-width: 100%; max-height: 100%; cursor: zoom-in; }
.lb-stage.zoom img { max-width: none; max-height: none; cursor: zoom-out; }

@media (max-width: 40rem) {
  h1 { font-size: 1.5rem; }
  .search { max-width: none; flex-basis: 100%; margin-left: 0; }
  .portrait { width: 7rem; }
  .box { width: 10.5rem; }
}
@media print { .top, .foot, .actions, .tree-tools { display: none; } body { background: #fff; } }

/* Recherches complémentaires : tout ce qui ne vient pas de l'arbre Geneanet */
:root { --r: #6b4fa0; --r-soft: #f3eefa; }
.rtag { display: inline-block; font: 600 .66rem system-ui, sans-serif; letter-spacing: .03em; text-transform: uppercase; background: var(--r); color: #fff; border-radius: 4px; padding: .05rem .38em; margin-left: .35em; vertical-align: middle; }
.rbox { border: 1px dashed var(--r); background: var(--r-soft); border-radius: 8px; padding: .7rem .9rem; margin: .7rem 0; }
.rbox .rtag { margin-left: 0; margin-right: .3em; }
.rbox table { margin-top: .4rem; font-size: .9rem; } .rbox td { border: 0; padding: .12rem .6rem .12rem 0; } .rbox td:first-child { white-space: nowrap; width: 1%; }
.rbox p { margin: .4rem 0 0; }
.box.r { border: 1px dashed var(--r); background: var(--r-soft); }
a.stat.rstat { border: 1px dashed var(--r); background: var(--r-soft); color: var(--ink); display: block; }
a.stat.rstat:hover { text-decoration: none; }
.cols3 { columns: 3 16rem; }
.doc details { margin-top: .4rem; } .doc summary { cursor: pointer; color: var(--accent); } .doc details p { margin: .3rem 0; } .doc details ul { margin: .3rem 0; padding-left: 1.1rem; }
.noimg { aspect-ratio: 4/3; display: grid; place-items: center; background: var(--accent-soft); color: var(--muted); font: .85rem system-ui, sans-serif; }
