:root {
  --fond: #faf7f2; --papier: #fff; --encre: #2b2620; --doux: #6f665b; --trait: #d9d0c3;
  --accent: #7a4b2a; --homme: #e4edf5; --femme: #f6e7ea; --inconnu: #eeebe6;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root { --fond: #1c1a17; --papier: #26231f; --encre: #ece6dc; --doux: #a89f92; --trait: #48423a;
          --accent: #e0a878; --homme: #26323d; --femme: #3d2a30; --inconnu: #33302b; }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--fond); color: var(--encre); font: 16px/1.5 Georgia, "Times New Roman", serif; }
a { color: var(--accent); }
.entete { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .8rem 1.5rem;
          border-bottom: 1px solid var(--trait); background: var(--papier); }
.marque { font-size: 1.25rem; font-weight: bold; text-decoration: none; color: var(--encre); }
.entete nav a { margin-left: 1.2rem; }
main { max-width: 1100px; margin: 0 auto; padding: 1.5rem; }
h1 { margin: .2rem 0 .6rem; font-weight: normal; font-size: 2rem; }
h2 { font-weight: normal; border-bottom: 1px solid var(--trait); padding-bottom: .2rem; margin-top: 2rem; }
.intro, .vide, small { color: var(--doux); }

.recherche { display: block; margin: 1rem 0; color: var(--doux); }
.recherche input { display: block; width: 100%; max-width: 30rem; margin-top: .3rem; padding: .6rem .8rem; font: inherit;
                   border: 1px solid var(--trait); border-radius: 6px; background: var(--papier); color: var(--encre); }
.grille { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: .6rem; }

.carte { display: flex; align-items: center; gap: .7rem; padding: .5rem .7rem; border-radius: 8px; text-decoration: none;
         color: var(--encre); background: var(--inconnu); border: 1px solid var(--trait); min-height: 64px; }
.carte:hover, .carte:focus-visible { border-color: var(--accent); }
.carte img, .sans-photo { width: 46px; height: 46px; border-radius: 50%; object-fit: cover; flex: none; }
.sans-photo { display: grid; place-items: center; background: var(--trait); color: var(--doux); font-size: 1.2rem; }
.carte strong { display: block; font-weight: normal; }
.carte small { display: block; }
.sexe-M { background: var(--homme); } .sexe-F { background: var(--femme); }
.carte.inconnu { color: var(--doux); font-style: italic; }
.cartes { display: flex; flex-wrap: wrap; gap: .6rem; }
.cartes .carte { min-width: 230px; }

.identite { display: flex; gap: 1.5rem; align-items: flex-start; flex-wrap: wrap; }
.portrait { width: 200px; max-height: 260px; object-fit: cover; border-radius: 8px; border: 1px solid var(--trait); }
dl { display: grid; grid-template-columns: max-content 1fr; gap: .2rem 1rem; margin: .5rem 0 1rem; }
dt { color: var(--doux); }
dd { margin: 0; }
.bouton { display: inline-block; padding: .4rem .9rem; border: 1px solid var(--accent); border-radius: 6px; text-decoration: none; }
.notes { white-space: normal; }
.galerie { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 1rem; }
.galerie figure { margin: 0; }
.galerie img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 6px; border: 1px solid var(--trait); }
.galerie figcaption span, .galerie figcaption small { display: block; }
.sources li { margin-bottom: .5rem; }

/* Arbre */
.page-arbre main { max-width: none; padding: 0; }
.outils { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem 1rem; padding: .6rem 1.5rem; border-bottom: 1px solid var(--trait); }
.outils select, .outils button { font: inherit; padding: .2rem .6rem; border-radius: 5px; border: 1px solid var(--trait);
                                 background: var(--papier); color: var(--encre); cursor: pointer; }
.aide { color: var(--doux); font-size: .85rem; }
.vue { position: relative; height: calc(100vh - 115px); overflow: hidden; cursor: grab; touch-action: none; outline: none; }
.vue:active { cursor: grabbing; }
.plan { position: absolute; left: 0; top: 0; transform-origin: 0 0; }
.liens { position: absolute; left: 0; top: 0; overflow: visible; }
.liens path { fill: none; stroke: var(--doux); stroke-width: 1.5; }
.case { position: absolute; display: flex; gap: .5rem; align-items: center; padding: .3rem .5rem; border-radius: 8px;
        border: 1px solid var(--trait); background: var(--inconnu); cursor: pointer; overflow: hidden; font-size: .85rem; line-height: 1.2; }
.case.sexe-M { background: var(--homme); } .case.sexe-F { background: var(--femme); }
.case:hover, .case:focus-visible { border-color: var(--accent); }
.case.centre { border: 2px solid var(--accent); }
.case img { width: 44px; height: 44px; border-radius: 50%; object-fit: cover; flex: none; }
.case .txt { min-width: 0; }
.case strong { display: block; font-weight: normal; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.case small { display: inline; color: var(--doux); margin-right: .4rem; }
.case small.conjoint { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.case .fiche { font-size: .75rem; }

/* Formulaires (connexion, propositions) */
.formulaire { max-width: 36rem; }
.formulaire form > div { margin-bottom: 1rem; }
.formulaire label { display: block; color: var(--doux); margin-bottom: .2rem; }
.formulaire input:not([type=checkbox]):not([type=file]), .formulaire select, .formulaire textarea {
  width: 100%; padding: .5rem .7rem; font: inherit; border: 1px solid var(--trait); border-radius: 6px;
  background: var(--papier); color: var(--encre); }
.formulaire .helptext { display: block; font-size: .85rem; color: var(--doux); }
.formulaire .errorlist { color: #c0392b; padding-left: 1rem; }
.formulaire button.bouton { font: inherit; background: var(--papier); color: var(--accent); cursor: pointer; }
.identite .bouton { margin: 0 .3rem .4rem 0; }

/* Éditeur */
.entete nav a.discret { color: var(--doux); }
.formulaire fieldset { border: 1px solid var(--trait); border-radius: 8px; margin: 0 0 1rem; padding: .6rem 1rem 1rem; }
.formulaire legend { color: var(--doux); padding: 0 .3rem; }
.formulaire label { margin-bottom: .8rem; }
.formulaire .deux { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1rem; }
@media (max-width: 600px) { .formulaire .deux { grid-template-columns: 1fr; } }
.ligne-source { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; margin-bottom: .5rem; }
.case-a-cocher { display: flex !important; align-items: center; gap: .5rem; color: var(--encre) !important; }
.case-a-cocher input[type=checkbox] { width: auto; }
.portrait-choix { margin-left: auto; color: var(--doux); font-size: .85rem; }
.formulaire button, .bouton { font: inherit; background: var(--papier); color: var(--accent); cursor: pointer; }
.bouton.principal { background: var(--accent); color: var(--papier); }
.bouton.danger { border-color: #b03a2e; color: #b03a2e; float: right; }
.bouton:disabled { opacity: .6; cursor: wait; }
.erreur { color: #c0392b; font-weight: bold; min-height: 1em; }
.succes { padding: .8rem 1rem; border: 1px solid var(--accent); border-radius: 8px; }
.aide { color: var(--doux); font-size: .9rem; }
.progression { color: var(--doux); }
.photo-page .grande { max-width: 100%; max-height: 70vh; border-radius: 8px; display: block; margin-bottom: 1rem; }
.formulaire.source { border-bottom: 1px solid var(--trait); padding-bottom: 1rem; margin-bottom: 1rem; }
.fiche section > p .bouton, .fiche > p .bouton { margin: 0 .3rem .4rem 0; }
.vue { position: relative; height: calc(100vh - 115px); overflow: hidden; cursor: grab; touch-action: none; outline: none; }
