/* ============================================================
   Système de design — d'après Genealogie.dc.html (Claude Design)
   Thèmes Sépia / Lin / Encre · polices Newsreader + Mulish
   ============================================================ */

/* --- Thèmes (variables) --- */
[data-theme="sepia"] {
  --paper:#F1E7D6; --card:#FBF5E9; --ink:#2C2113; --soft:#7A6A52;
  --line:#E4D7BF; --accent:#B0572F; --gold:#9C7C2E; --backdrop:#C9BBA4;
  --theme-name:"Sépia";
}
[data-theme="lin"] {
  --paper:#F6F2EA; --card:#FFFFFF; --ink:#33302A; --soft:#88826F;
  --line:#E9E2D4; --accent:#7C8A5E; --gold:#B08C3A; --backdrop:#D9D3C5;
  --theme-name:"Lin";
}
[data-theme="encre"] {
  --paper:#241C12; --card:#2F2618; --ink:#F1E7D2; --soft:#B0A083;
  --line:#41351F; --accent:#D78B4C; --gold:#CBA24B; --backdrop:#16110A;
  --theme-name:"Encre";
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
  min-height: 100vh;
  font-family: 'Mulish', system-ui, sans-serif;
  color: var(--ink, #2C2113);
  background: radial-gradient(120% 100% at 50% 0%,
              var(--backdrop, #C9BBA4) 0%,
              color-mix(in oklab, var(--backdrop, #C9BBA4) 78%, #000 22%) 100%);
  -webkit-font-smoothing: antialiased;
}

.serif { font-family: 'Newsreader', Georgia, serif; }

::-webkit-scrollbar { width: 0; height: 0; }
* { scrollbar-width: none; }

@keyframes fadeUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 12px); } to { opacity: 1; transform: translate(-50%, 0); } }

a { color: var(--accent); text-decoration: none; }

/* ============================================================
   Coquille « app » (colonne type mobile, cadrée sur desktop)
   ============================================================ */
.app {
  position: relative;
  width: 100%;
  max-width: 430px;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  background: var(--paper, #F1E7D6);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.app-main { flex: 1; display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.sidebar { display: none; }

/* Tablette : cadre arrondi façon « carte » */
@media (min-width: 480px) and (max-width: 1023px) {
  body { padding: 24px 16px; }
  .app {
    min-height: min(900px, calc(100vh - 48px));
    border-radius: 34px;
    box-shadow: 0 40px 80px -20px rgba(40,28,12,.55), 0 0 0 1px rgba(255,255,255,.05) inset;
  }
}

/* --- Sidebar (desktop) --- */
.sidebar {
  width: 256px; flex: none; height: 100%; overflow-y: auto;
  background: color-mix(in oklab, var(--card) 70%, var(--paper) 30%);
  border-right: 1px solid var(--line);
  flex-direction: column; padding: 22px 16px;
}
.side-brand { display: flex; align-items: center; gap: 11px; padding: 6px 8px 20px; text-decoration: none; }
.side-logo { font-size: 24px; }
.side-title { display: block; font-size: 18px; color: var(--ink); line-height: 1.05; }
.side-sub { display: block; font-size: 11px; font-weight: 700; letter-spacing: .6px; text-transform: uppercase; color: var(--soft); margin-top: 3px; }
.side-nav { display: flex; flex-direction: column; gap: 4px; }
.side-nav a { display: flex; align-items: center; gap: 11px; padding: 11px 14px; border-radius: 12px; color: var(--soft); font-size: 14px; font-weight: 700; text-decoration: none; }
.side-nav a .ico { width: 22px; text-align: center; font-size: 17px; }
.side-nav a.active { background: var(--accent); color: #FBF5E9; box-shadow: 0 6px 14px -6px color-mix(in oklab, var(--accent) 60%, transparent); }
.side-nav a:not(.active):hover { background: color-mix(in oklab, var(--accent) 9%, transparent); color: var(--ink); }
.side-nav-sm a { padding: 8px 14px; font-size: 13px; font-weight: 600; }
.side-section { margin-top: 22px; }
.side-label { font-size: 10px; font-weight: 800; letter-spacing: 1px; text-transform: uppercase; color: var(--soft); margin: 0 8px 10px; }
.side-stats { display: flex; gap: 20px; padding: 0 8px; }
.side-stats .num { display: block; font-family: 'Newsreader', serif; font-size: 24px; color: var(--ink); line-height: 1; }
.side-stats .cap { display: block; font-size: 10px; font-weight: 700; letter-spacing: .4px; text-transform: uppercase; color: var(--soft); margin-top: 3px; }
.side-foot { margin-top: auto; padding-top: 18px; }
.theme-swatches { display: flex; gap: 8px; padding: 0 8px; }
.theme-swatches .sw { width: 28px; height: 28px; border-radius: 50%; cursor: pointer; border: 2px solid transparent; box-shadow: inset 0 0 0 1px rgba(0,0,0,.12); }
.theme-swatches .sw.active { border-color: var(--ink); }

/* --- En-tête --- */
.app-header {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; padding: 18px 20px 12px;
  background: linear-gradient(var(--paper), color-mix(in oklab, var(--paper) 92%, transparent));
  position: sticky; top: 0; z-index: 20;
}
.app-header .left { display: flex; align-items: center; gap: 9px; min-width: 0; }
.app-title { font-family:'Newsreader',serif; font-size: 21px; font-weight: 500; color: var(--ink); letter-spacing: .2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn {
  width: 34px; height: 34px; flex: none; border: none; border-radius: 50%;
  background: var(--card); color: var(--ink); font-size: 18px; cursor: pointer;
  box-shadow: 0 1px 2px rgba(0,0,0,.1); display: flex; align-items: center; justify-content: center;
}
.theme-btn {
  height: 30px; padding: 0 12px; border: 1px solid var(--line); border-radius: 40px;
  background: transparent; color: var(--soft); font-size: 11px; font-weight: 700;
  letter-spacing: .6px; text-transform: uppercase; cursor: pointer;
  display: flex; align-items: center; gap: 6px; flex: none;
}
.theme-btn .dot { width: 11px; height: 11px; border-radius: 50%; background: var(--accent); }

/* --- Zone de contenu défilante --- */
.app-scroll { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.app-body { padding: 4px 20px 110px; animation: fadeUp .4s ease both; }

/* --- Bottom nav --- */
.app-nav {
  position: sticky; bottom: 0; z-index: 25;
  display: flex; align-items: stretch; justify-content: space-around;
  padding: 8px 12px 14px;
  background: linear-gradient(color-mix(in oklab, var(--paper) 0%, transparent), var(--paper) 38%);
}
.app-nav a {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 6px 10px; border-radius: 14px; color: var(--soft);
  font-size: 10px; font-weight: 700; letter-spacing: .3px; text-decoration: none;
}
.app-nav a .ico { font-size: 19px; }
.app-nav a.active { color: var(--accent); background: color-mix(in oklab, var(--accent) 10%, transparent); }

/* ============================================================
   Composants
   ============================================================ */
.eyebrow { margin: 6px 0 2px; font-size: 12px; font-weight: 700; letter-spacing: 1.4px; text-transform: uppercase; color: var(--accent); }
.h-display { margin: 0 0 18px; font-family:'Newsreader',serif; font-size: 32px; font-weight: 500; line-height: 1.1; color: var(--ink); }
.h-display em { font-style: italic; color: var(--soft); }
.h-section { margin: 24px 0 12px; font-family:'Newsreader',serif; font-size: 20px; font-weight: 500; color: var(--ink); }
.label-up { font-size: 11px; font-weight: 700; letter-spacing: 1px; text-transform: uppercase; color: var(--soft); }

/* Section pliable (ex. Sources) */
.fold { margin: 24px 0 0; }
.fold > .fold-sum { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 8px; padding: 6px 2px; }
.fold > .fold-sum::-webkit-details-marker { display: none; }
.fold > .fold-sum .label-up { margin: 0; }
.fold > .fold-sum::after { content: '›'; margin-left: auto; font-size: 22px; line-height: 1; color: var(--soft); transition: transform .2s ease; }
.fold[open] > .fold-sum::after { transform: rotate(90deg); }
.fold-body { padding-top: 8px; }

/* Lignes chiffrées (page d'analyse) */
.an-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 14px; line-height: 1.35; }
.an-row:last-of-type { border-bottom: none; }
.an-num { flex: none; font-family:'Newsreader',serif; font-size: 20px; font-weight: 600; color: var(--ink); }
.an-num.accent { color: var(--accent); }
/* Lignes d'événements en double */
.dup-ev { display: flex; align-items: center; gap: 10px; padding: 7px 2px; border-bottom: 1px dashed var(--line); }
.dup-ev:last-child { border-bottom: none; }
.dup-ev .grow { display: flex; flex-direction: column; min-width: 0; }
.dup-ev.keep { background: color-mix(in srgb, var(--accent) 6%, transparent); border-radius: 8px; padding-left: 8px; padding-right: 8px; }
.dup-place { font-size: 13px; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dup-desc { font-size: 12px; color: var(--soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dup-acts { flex: none; display: flex; align-items: center; gap: 6px; }
.dup-acts form { margin: 0; }
.muted { color: var(--soft); }

/* Stat cards */
.stats { display: flex; gap: 10px; margin-bottom: 22px; }
.stat { flex: 1; background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 14px 12px; }
.stat .num { font-family:'Newsreader',serif; font-size: 30px; font-weight: 500; color: var(--ink); line-height: 1; }
.stat .cap { font-size: 11px; font-weight: 700; letter-spacing: .5px; text-transform: uppercase; color: var(--soft); margin-top: 5px; }

/* Avatars (initiales) */
.av { border-radius: 50%; color: #FBF5E9; display: inline-flex; align-items: center; justify-content: center;
      font-family:'Newsreader',serif; font-weight: 500; flex: none; box-shadow: inset 0 0 0 1px rgba(0,0,0,.08); }
.av-xl { width: 96px; height: 96px; font-size: 38px; box-shadow: inset 0 0 0 2px rgba(255,255,255,.25), 0 10px 24px -12px rgba(0,0,0,.4); }
.av-lg { width: 72px; height: 72px; font-size: 28px; }
.av-md { width: 48px; height: 48px; font-size: 18px; }
.av-sm { width: 40px; height: 40px; font-size: 15px; }
.av-photo { overflow: hidden; background: var(--card, #fff); }
.av-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* Bouton accent plein */
.btn {
  display: inline-block; border: none; cursor: pointer;
  background: var(--accent); color: #FBF5E9; border-radius: 14px;
  padding: 14px 18px; font-family:'Mulish',sans-serif; font-size: 15px; font-weight: 800;
  letter-spacing: .3px; text-align: center;
  box-shadow: 0 10px 22px -10px color-mix(in oklab, var(--accent) 60%, transparent);
}
.btn-block { width: 100%; display: block; }
.btn-ghost { background: var(--card); color: var(--ink); border: 1px solid var(--line); box-shadow: none; font-weight: 700; }
.btn-danger { background: #b3261e; color: #fff; box-shadow: 0 10px 22px -10px rgba(179,38,30,.6); }
/* Bouton recherche FamilySearch (couleur de la marque) */
.fs-btn { display: flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none;
    background: #1c6ea4; color: #fff; box-shadow: 0 10px 22px -10px rgba(28,110,164,.55); }
.fs-btn:hover { background: #185f8e; }
.fs-ico { font-size: 15px; line-height: 1; }
.btn-link { background: none; border: none; color: var(--accent); font-weight: 700; cursor: pointer; padding: 8px; font-size: 13px; }

/* Carte CTA dégradé */
.cta-card {
  width: 100%; text-align: left; border: none; cursor: pointer; display: flex;
  align-items: center; justify-content: space-between; gap: 12px;
  background: linear-gradient(135deg, var(--accent), color-mix(in oklab, var(--accent) 70%, #000 30%));
  border-radius: 20px; padding: 18px 20px; margin-bottom: 24px;
  box-shadow: 0 10px 24px -10px color-mix(in oklab, var(--accent) 60%, transparent);
}
.cta-card .k { display: block; font-size: 11px; font-weight: 700; letter-spacing: 1px; text-transform: uppercase; color: rgba(255,255,255,.7); }
.cta-card .v { display: block; font-family:'Newsreader',serif; font-size: 21px; font-weight: 500; color: #FBF5E9; margin-top: 3px; }
.cta-card .arrow { width: 42px; height: 42px; border-radius: 50%; background: rgba(255,255,255,.16); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 20px; flex: none; }

/* Liste de personnes (lignes) */
.person-row {
  width: 100%; text-align: left; border: none; cursor: pointer; background: transparent;
  padding: 10px 4px; display: flex; align-items: center; gap: 13px;
  border-bottom: 1px solid var(--line); text-decoration: none;
}
.person-row .nm { font-family:'Newsreader',serif; font-size: 17px; font-weight: 500; color: var(--ink); }
.person-row .sb { font-size: 12px; font-weight: 600; color: var(--soft); margin-top: 1px; }
.person-row .chev { color: var(--soft); font-size: 18px; margin-left: auto; }
.person-row .grow { flex: 1; min-width: 0; }

/* Carte (entourée) */
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 16px;
}
.card + .card { margin-top: 12px; }

/* Champs de formulaire */
.field { margin-bottom: 14px; }
.field > label { display: block; font-size: 11px; font-weight: 700; letter-spacing: .8px; text-transform: uppercase; color: var(--soft); margin: 0 0 6px 2px; }
.input, input[type=text], input[type=email], input[type=password], input[type=number], textarea, select {
  width: 100%; border: 1px solid var(--line); background: var(--card); border-radius: 13px;
  padding: 13px 15px; font-family:'Newsreader',serif; font-size: 17px; color: var(--ink); outline: none;
}
textarea { font-family:'Mulish',sans-serif; font-size: 15px; line-height: 1.5; resize: vertical; }
.input:focus, input:focus, textarea:focus, select:focus { border-color: var(--accent); }
.input-error, .input-error:focus { border-color: #b3261e; background: color-mix(in srgb, #b3261e 5%, var(--card)); }
.form-error { margin: 10px 2px 0; font-size: 12.5px; font-weight: 700; color: #b3261e; line-height: 1.45; white-space: pre-line; }

/* Champ lieu avec autocomplétion + recherche en ligne */
.place-input { position: relative; }
.place-input input { width: 100%; padding-right: 46px; }
.place-online { position: absolute; right: 6px; top: 6px; width: 34px; height: 34px; border: none; cursor: pointer;
    border-radius: 10px; background: color-mix(in srgb, var(--ink) 6%, transparent); font-size: 16px; line-height: 1; }
.place-online:hover { background: color-mix(in srgb, var(--accent) 16%, transparent); }
.place-online.loading { opacity: .5; pointer-events: none; }
.place-suggest { position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 6; overflow: hidden;
    background: var(--card); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 14px 30px -12px rgba(20,12,4,.45); max-height: 260px; overflow-y: auto; }
.place-suggest .ps-head { font-size: 10px; font-weight: 800; letter-spacing: .6px; text-transform: uppercase; color: var(--soft); padding: 8px 12px 4px; }
.place-suggest button { display: block; width: 100%; text-align: left; border: none; background: none; cursor: pointer;
    padding: 9px 12px; font-family:'Mulish',sans-serif; font-size: 13px; color: var(--ink); }
.place-suggest button:hover, .place-suggest button.active { background: color-mix(in srgb, var(--accent) 12%, transparent); }
.place-suggest .ps-empty { padding: 10px 12px; font-size: 12px; color: var(--soft); }
.row-2 { display: flex; gap: 12px; }
.row-2 > * { flex: 1; }

/* Barre de recherche */
.searchbar { display: flex; align-items: center; gap: 9px; background: var(--card); border: 1px solid var(--line); border-radius: 40px; padding: 11px 16px; margin: 4px 0 8px; }
.searchbar input { border: none; background: transparent; padding: 0; font-family:'Mulish',sans-serif; font-size: 15px; font-weight: 600; }
.searchbar input:focus { border: none; }
.searchbar .ico { color: var(--soft); font-size: 16px; }

/* Contrôle segmenté + puces */
.segmented { display: flex; gap: 4px; background: var(--card); border: 1px solid var(--line); border-radius: 40px; padding: 4px; margin: 4px 0 20px; }
.segmented a { flex: 1; text-align: center; padding: 9px 0; border-radius: 30px; font-size: 13px; font-weight: 700; color: var(--soft); text-decoration: none; }
.segmented a.active { background: var(--accent); color: #FBF5E9; }
.chip { display: inline-flex; align-items: center; padding: 9px 14px; border-radius: 30px; border: 1px solid var(--line); background: var(--card); color: var(--soft); font-size: 13px; font-weight: 700; cursor: pointer; white-space: nowrap; }
.chip.active { background: var(--accent); color: #FBF5E9; border-color: var(--accent); }
.chip-row { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; }

/* Badges de rôle */
.badge { font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; padding: .15rem .5rem; border-radius: 999px; background: var(--line); color: var(--soft); }
.badge-owner { background: color-mix(in oklab, var(--accent) 18%, var(--card)); color: var(--accent); }
.badge-editor { background: color-mix(in oklab, var(--gold) 20%, var(--card)); color: var(--gold); }
.badge-viewerplus { background: color-mix(in oklab, var(--gold) 14%, var(--card)); color: var(--gold); }
.badge-create { background: #e6f4ea; color: #2e7d32; }
.badge-update { background: #fff4e5; color: #9a6700; }
.badge-delete { background: #fdecea; color: #b3261e; }
.badge-merge  { background: #eef1f5; color: #506176; }
.badge-import { background: color-mix(in oklab, var(--accent) 16%, var(--card)); color: var(--accent); }
.badge-export { background: #eee; color: #555; }

/* Flash */
.flash { padding: 11px 14px; border-radius: 12px; margin: 0 0 14px; font-weight: 600; font-size: 14px; }
.flash-ok { background: color-mix(in oklab, var(--accent) 14%, var(--card)); color: var(--accent); }
.flash-err { background: #fdecea; color: #b3261e; }

/* Chronologie */
.timeline { position: relative; padding-left: 4px; }
.tl-row { display: flex; gap: 16px; }
.tl-year { flex: none; width: 64px; text-align: right; display: flex; flex-direction: column; align-items: flex-end; gap: 1px; padding-top: 1px; }
.tl-y { font-family:'Newsreader',serif; font-size: 17px; font-weight: 600; color: var(--accent); line-height: 1.05; }
.tl-dm { font-family:'Newsreader',serif; font-size: 9px; font-weight: 500; color: var(--soft); line-height: 1.15; }
.tl-rail { flex: none; display: flex; flex-direction: column; align-items: center; }
.tl-dot { width: 13px; height: 13px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 4px color-mix(in oklab, var(--accent) 22%, transparent); margin-top: 4px; }
.tl-line { flex: 1; width: 2px; background: var(--line); }
.tl-body { flex: 1; padding-bottom: 22px; }
.tl-title { font-family:'Newsreader',serif; font-size: 17px; font-weight: 500; color: var(--ink); line-height: 1.25; }
.tl-place { font-size: 12px; font-weight: 400; color: var(--soft); margin-top: 2px; }
.tl-desc { font-size: 13px; color: var(--ink); line-height: 1.5; margin-top: 3px; white-space: pre-line; }
/* Notes sur la frise : pastille dorée + corps en retrait */
.tl-dot-note { background: var(--gold); box-shadow: 0 0 0 4px color-mix(in oklab, var(--gold) 22%, transparent); }
.tl-note { font-size: 14px; line-height: 1.55; color: var(--ink); margin-top: 4px;
    border-left: 2px solid color-mix(in oklab, var(--gold) 55%, transparent); padding-left: 10px; }
/* Événements de proches : pastille neutre, titre légèrement estompé */
.tl-dot-rel { width: 10px; height: 10px; background: var(--soft);
    box-shadow: 0 0 0 4px color-mix(in oklab, var(--soft) 16%, transparent); margin-top: 5px; }
.tl-row-rel .tl-title { color: var(--soft); font-style: italic; }
/* Âge de la personne à l'événement (sous le mois/jour) */
.tl-age { font-family:'Mulish',sans-serif; font-size: 9px; font-weight: 800; font-style: normal; color: var(--soft); white-space: nowrap; margin-top: 1px; }
/* Section « Sans date » : cartes simples sous la frise */
.tl-undated { display: flex; flex-direction: column; gap: 10px; }
.tl-card { border: 1px solid var(--line); border-radius: 12px; padding: 11px 13px; background: var(--card); }
.tl-card .tl-note { margin-top: 6px; }
/* Date affichée en tête d'une note + champs de saisie de dates */
.note-date { font-size: 12px; font-weight: 700; color: var(--accent); margin-bottom: 6px; }
.note-dates-row { display: flex; gap: 8px; margin-top: 6px; }
.note-dates-row input { flex: 1; min-width: 0; }

/* Galerie médias */
.media-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.media-tile { position: relative; }
.media-tile img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 12px; border: 1px solid var(--line); display: block; }
.media-doc { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; aspect-ratio: 1; border: 1px solid var(--line); border-radius: 12px; background: var(--card); text-align: center; padding: 8px; }
.media-doc .ic { font-size: 30px; }
.media-doc .nm { font-size: 10px; color: var(--soft); word-break: break-word; line-height: 1.2; }
.media-actions { display: flex; justify-content: space-between; align-items: center; gap: 6px; margin-top: 4px; }
.media-actions form { margin: 0; }

/* Boutons d'action en icône (notes, documents, lightbox) */
.icon-act { display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; border-radius: 50%;
    border: 1px solid var(--line); background: var(--card); color: var(--ink); font-size: 14px; line-height: 1; cursor: pointer; padding: 0;
    transition: background .15s, border-color .15s, color .15s; }
.icon-act:hover { background: var(--accent); border-color: var(--accent); color: #FBF5E9; }
.icon-act.icon-danger:hover { background: #b3261e; border-color: #b3261e; color: #fff; }
.note-acts { display: flex; align-items: center; gap: 8px; }
.note-acts form { margin: 0; }
.note-edit { margin-top: 12px; border-top: 1px solid var(--line); padding-top: 12px; }
.icon-act.icon-sm { width: 28px; height: 28px; font-size: 12px; }
/* Actions d'édition sur un événement de la timeline (fiche) */
.tl-title:has(.tl-acts) { display: flex; align-items: flex-start; gap: 8px; }
.tl-title-txt { flex: 1; min-width: 0; }
.tl-acts { flex: none; display: flex; align-items: center; gap: 6px; }
.tl-acts form { margin: 0; }

/* Tuile image cliquable (ouvre la lightbox) */
.media-open { display: block; width: 100%; padding: 0; border: none; background: none; cursor: pointer; position: relative; border-radius: 12px; }
.media-open img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 12px; border: 1px solid var(--line); display: block; transition: filter .15s; }
.media-open:hover img { filter: brightness(.93); }
.media-badge { position: absolute; top: 6px; left: 6px; width: 22px; height: 22px; border-radius: 50%; background: var(--accent); color: #FBF5E9;
    font-size: 12px; display: flex; align-items: center; justify-content: center; box-shadow: 0 2px 6px -1px rgba(0,0,0,.4); }
.media-del { position: absolute; top: 5px; right: 5px; margin: 0; }
.media-del .icon-act { width: 28px; height: 28px; font-size: 12px; background: color-mix(in srgb, var(--paper) 82%, transparent); }

/* Lightbox média */
.lightbox { position: fixed; inset: 0; z-index: 95; visibility: hidden; }
.lightbox.open { visibility: visible; }
.lb-backdrop { position: absolute; inset: 0; background: rgba(20,12,4,.55); opacity: 0; transition: opacity .25s ease; }
.lightbox.open .lb-backdrop { opacity: 1; }
/* Panneau type bottom sheet (comme les modales d'ajout) */
.lb-sheet { position: absolute; left: 50%; bottom: 0; width: min(680px, 100%); max-height: 92vh; box-sizing: border-box;
    display: flex; flex-direction: column; align-items: center; gap: 14px;
    background: var(--paper); border-radius: 22px 22px 0 0; padding: 8px 18px max(18px, env(safe-area-inset-bottom)); overflow-y: auto;
    box-shadow: 0 -18px 50px -20px rgba(20,12,4,.6);
    transform: translate(-50%, 100%); transition: transform .34s cubic-bezier(.32,.72,0,1); }
.lightbox.open .lb-sheet { transform: translate(-50%, 0); }
.lb-stage { position: relative; display: inline-block; line-height: 0; max-width: 100%; touch-action: none; user-select: none; }
.lb-img { max-width: 100%; max-height: 62vh; border-radius: 12px; display: block; }
.lb-stage .crop-box[hidden] { display: none; }
.lb-toolbar { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; justify-content: center; }
@media (prefers-reduced-motion: reduce) { .lb-sheet { transition: none; } }

/* Modale de confirmation (suppression) — au-dessus de tout */
.confirm-modal { position: fixed; inset: 0; z-index: 120; visibility: hidden; }
.confirm-modal.open { visibility: visible; }
.confirm-backdrop { position: absolute; inset: 0; background: rgba(20,12,4,.55); opacity: 0; transition: opacity .25s ease; }
.confirm-modal.open .confirm-backdrop { opacity: 1; }
.confirm-box { position: absolute; left: 50%; bottom: 0; width: min(460px, 100%); box-sizing: border-box; text-align: center;
    background: var(--paper); border-radius: 22px 22px 0 0; padding: 8px 22px max(22px, env(safe-area-inset-bottom));
    box-shadow: 0 -18px 50px -20px rgba(20,12,4,.6);
    transform: translate(-50%, 100%); transition: transform .34s cubic-bezier(.32,.72,0,1); }
.confirm-modal.open .confirm-box { transform: translate(-50%, 0); }
.confirm-ic { width: 52px; height: 52px; margin: 8px auto 12px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
    font-size: 24px; background: color-mix(in srgb, #b3261e 14%, var(--card)); }
.confirm-msg { margin: 0 0 20px; font-size: 18px; font-weight: 500; color: var(--ink); line-height: 1.35; }
.confirm-actions { display: flex; gap: 10px; }
.confirm-actions .btn { flex: 1; }
@media (prefers-reduced-motion: reduce) { .confirm-box { transition: none; } }
.lb-btn { display: inline-flex; align-items: center; gap: 6px; height: 38px; padding: 0 14px; border-radius: 22px; border: none; cursor: pointer;
    background: transparent; color: var(--ink); font-family:'Mulish',sans-serif; font-size: 13px; font-weight: 700; text-decoration: none; }
.lb-btn:hover { background: color-mix(in srgb, var(--ink) 8%, transparent); }
.lb-btn.accent { background: var(--accent); color: #FBF5E9; }
.lb-btn.accent:hover { background: color-mix(in srgb, var(--accent) 88%, #000); }
.lb-btn.danger { color: #b3261e; }
.lb-btn.danger:hover { background: color-mix(in srgb, #b3261e 12%, transparent); }
.lb-icon { width: 38px; padding: 0; justify-content: center; font-size: 17px; }
.lb-x { position: absolute; top: 12px; right: 14px; width: 38px; height: 38px; border-radius: 50%; border: 2px solid rgba(255,255,255,.85); cursor: pointer;
    background: rgba(20,12,4,.62); color: #fff; font-size: 21px; line-height: 1; z-index: 5; padding: 0;
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 3px 12px -2px rgba(0,0,0,.6); }
.lb-x:hover { background: rgba(20,12,4,.85); }

/* Éditeur d'image (recadrage) */
.crop-stage { position: relative; display: inline-block; max-width: 100%; touch-action: none; user-select: none; }
.crop-stage img { max-width: 100%; display: block; border-radius: 8px; }
.crop-box { position: absolute; border: 2px solid #fff; box-shadow: 0 0 0 9999px rgba(0,0,0,.45); cursor: move; }
.crop-handle { position: absolute; width: 16px; height: 16px; background: #fff; border: 1px solid var(--accent); border-radius: 50%; }
.crop-handle.tl { left: -8px; top: -8px; cursor: nwse-resize; }
.crop-handle.tr { right: -8px; top: -8px; cursor: nesw-resize; }
.crop-handle.bl { left: -8px; bottom: -8px; cursor: nesw-resize; }
.crop-handle.br { right: -8px; bottom: -8px; cursor: nwse-resize; }

/* État vide */
.empty { text-align: center; padding: 40px 16px; color: var(--soft); }
.empty .big { font-size: 40px; opacity: .5; }
.empty p { font-family:'Newsreader',serif; font-size: 17px; color: var(--ink); margin: 12px 0 4px; }

/* Toast */
.toast { position: fixed; bottom: 96px; left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--paper); font-size: 13px; font-weight: 700; padding: 11px 18px; border-radius: 30px; box-shadow: 0 12px 30px -8px rgba(0,0,0,.5); z-index: 40; animation: toastIn .3s ease both; }

/* ===== Bottom sheets (modales montant du bas) ===== */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(20,12,4,.45); opacity: 0; visibility: hidden;
    transition: opacity .25s ease, visibility .25s ease; z-index: 90; }
.sheet-backdrop.open { opacity: 1; visibility: visible; }
.sheet { position: fixed; left: 50%; bottom: 0; width: min(560px, 100%); z-index: 91; visibility: hidden;
    background: var(--paper); border-radius: 22px 22px 0 0;
    padding: 8px 22px max(24px, env(safe-area-inset-bottom)); max-height: 90vh; overflow-y: auto;
    box-shadow: 0 -18px 50px -20px rgba(20,12,4,.6);
    transform: translate(-50%, 100%); transition: transform .34s cubic-bezier(.32,.72,0,1), visibility 0s linear .34s; }
.sheet.open { transform: translate(-50%, 0); visibility: visible; transition: transform .34s cubic-bezier(.32,.72,0,1), visibility 0s; }
.sheet-grip { width: 42px; height: 4px; border-radius: 2px; background: var(--line); margin: 6px auto 2px; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 10px 0 16px; }
.sheet-title { font-size: 20px; font-weight: 600; color: var(--ink); }
.sheet-close { flex: none; width: 34px; height: 34px; border: none; border-radius: 50%; cursor: pointer;
    background: color-mix(in srgb, var(--ink) 6%, transparent); color: var(--soft); font-size: 22px; line-height: 1; }
.sheet-close:hover { background: color-mix(in srgb, var(--ink) 12%, transparent); color: var(--ink); }
.sheet-file { width: 100%; font-size: 14px; }
/* Zone de dépôt de fichier (avec aperçu) */
.filedrop { display: block; position: relative; border: 1.5px dashed var(--line); border-radius: 14px; padding: 22px 16px;
    text-align: center; cursor: pointer; background: color-mix(in srgb, var(--ink) 2%, var(--card)); transition: border-color .2s, background .2s; }
.filedrop:hover, .filedrop.drag { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, var(--card)); }
.filedrop-input { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); border: 0; }
.filedrop [hidden] { display: none !important; }   /* prime sur les display des classes ci-dessous */
.filedrop-empty { display: block; }
.filedrop-ic { display: block; font-size: 26px; color: var(--accent); margin-bottom: 6px; }
.filedrop-main { display: block; font-weight: 700; font-size: 14px; color: var(--ink); }
.filedrop-sub { display: block; font-size: 11px; color: var(--soft); margin-top: 3px; }
.filedrop-preview { display: flex; align-items: center; gap: 12px; text-align: left; }
.filedrop-thumb { width: 60px; height: 60px; border-radius: 10px; object-fit: cover; flex: none; background: var(--line); }
.filedrop-doc { width: 60px; height: 60px; border-radius: 10px; display: flex; align-items: center; justify-content: center;
    font-size: 26px; flex: none; background: color-mix(in srgb, var(--gold) 22%, var(--card)); }
.filedrop-info { min-width: 0; flex: 1; }
.filedrop-name { display: block; font-weight: 700; font-size: 14px; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.filedrop-meta { display: block; font-size: 11px; color: var(--soft); margin-top: 2px; }
.filedrop-clear { flex: none; font-size: 12px; }
html.sheet-lock, html.sheet-lock body { overflow: hidden; }
html.sheet-lock .app-scroll { overflow: hidden; }
@media (prefers-reduced-motion: reduce) { .sheet { transition: none; } }

/* Centres / détail arbre */
.center-stack { text-align: center; }
.center-focus {
  display: inline-flex; flex-direction: column; align-items: center; gap: 9px;
  background: linear-gradient(150deg, var(--card), color-mix(in oklab, var(--card) 86%, var(--gold) 14%));
  border: 1.5px solid var(--accent); border-radius: 20px; padding: 18px 22px; cursor: pointer;
  box-shadow: 0 12px 26px -14px color-mix(in oklab, var(--accent) 55%, transparent);
}
.mini-card { display: inline-flex; flex-direction: column; align-items: center; gap: 6px; width: 142px; border: 1px solid var(--line); background: var(--card); border-radius: 14px; padding: 11px 9px; cursor: pointer; text-decoration: none; }
.mini-card .nm { font-family:'Newsreader',serif; font-size: 14px; font-weight: 500; color: var(--ink); text-align: center; line-height: 1.1; }
.mini-card .yr { font-size: 10px; font-weight: 700; color: var(--soft); }
.connector { width: 1px; height: 22px; background: var(--line); margin: 6px auto; }

/* Centrage des pages auth / landing */
.center-page { min-height: 100vh; min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 28px 18px; }
.auth-card { background: var(--card); border: 1px solid var(--line); border-radius: 22px; padding: 28px 24px; width: 100%; max-width: 400px; box-shadow: 0 30px 70px -30px rgba(40,28,12,.5); }
.auth-card .brand { display: block; font-family:'Newsreader',serif; font-size: 24px; color: var(--ink); margin-bottom: 4px; }
.auth-card h1 { font-family:'Newsreader',serif; font-weight: 500; font-size: 26px; margin: 6px 0 18px; }
.stack > * + * { margin-top: 14px; }

/* ============================================================
   Arbre — barre d'outils + conteneur family-chart
   ============================================================ */
.tree-toolbar { display: flex; align-items: center; gap: 10px; margin: 4px 0 10px; flex-wrap: wrap; }
.seg-mini { display: flex; gap: 3px; background: var(--card); border: 1px solid var(--line); border-radius: 30px; padding: 3px; }
.seg-mini a { padding: 5px 12px; border-radius: 24px; font-size: 12px; font-weight: 700; color: var(--soft); text-decoration: none; }
.seg-mini a.active { background: var(--accent); color: #FBF5E9; }
.focus-chip { display: flex; align-items: center; gap: 8px; background: var(--card); border: 1px solid var(--line); border-radius: 40px; padding: 5px 14px 5px 6px; text-decoration: none; }
.focus-chip .serif { font-size: 15px; color: var(--ink); }

.tree-marks { display: inline-flex; align-items: center; gap: 5px; }
.tag-ico { display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 24px;
    border-radius: 50%; box-shadow: inset 0 0 0 1px rgba(255,255,255,.22), 0 1px 3px -1px rgba(0,0,0,.3); }
.tag-ico svg { width: 14px; height: 14px; display: block; }
.tag-photo { background: var(--accent); }
.tag-note { background: var(--gold); }
.mini-card .tree-marks { margin-top: 3px; }
.person-row .tree-marks { margin-right: 4px; }

/* Conteneur family-chart (vue Arbre) */
.fc-tree { position: relative; width: 100%; height: 72vh; min-height: 480px; border: 1px solid var(--line); border-radius: 18px;
    overflow: hidden; background: radial-gradient(70% 60% at 50% 34%, color-mix(in oklab, var(--card) 55%, transparent) 0%, transparent 72%); }
@media (min-width: 1024px) { .fc-tree { height: calc(100vh - 210px); } }

/* Contrôles de zoom (bas droite) */
.fc-zoom { position: absolute; bottom: 16px; right: 16px; display: flex; align-items: center; gap: 3px;
    background: var(--card); border: 1px solid var(--line); border-radius: 40px; padding: 5px;
    box-shadow: 0 10px 26px -10px rgba(20,12,4,.42); z-index: 6; }
.fc-zoom button { min-width: 38px; height: 38px; border: none; border-radius: 50%; background: transparent;
    color: var(--ink); font-size: 19px; font-weight: 700; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.fc-zoom button[data-z="reset"] { min-width: 58px; font-size: 12px; font-weight: 800; color: var(--soft); border-radius: 24px; }
.fc-zoom button.accent { background: var(--accent); color: #FBF5E9; font-size: 16px; }
.fc-zoom .fc-zoom-sep { width: 1px; height: 22px; background: var(--line); margin: 0 4px; }
/* Liens (family-chart est thémé sombre → on force une couleur visible sur fond clair) */
.fc-tree .link { stroke: color-mix(in oklab, var(--ink) 42%, transparent); stroke-width: 1.5px; }
.fc-tree .link.f3-path-to-main { stroke: var(--accent); }

/* Cartes HTML personnalisées */
.fc-card { position: relative; box-sizing: border-box; width: 308px; display: flex; align-items: center; gap: 14px;
    padding: 11px 13px; border-radius: 15px; border: 1px solid var(--line); color: var(--ink); cursor: pointer;
    pointer-events: auto;   /* family-chart met .card_cont en pointer-events:none ; on réactive l'interaction */
    box-shadow: 0 7px 18px -11px rgba(20,12,4,.45); }
.fc-card.card-male       { background: color-mix(in srgb, #6f8088 30%, var(--card)); }   /* bleu-gris pâle */
.fc-card.card-female     { background: color-mix(in srgb, #b27f73 32%, var(--card)); }   /* rose-terre pâle */
.fc-card.card-genderless { background: color-mix(in srgb, #a59079 28%, var(--card)); }   /* sable pâle */
.fc-card.fc-main { box-shadow: 0 0 0 2.5px var(--accent), 0 10px 22px -10px rgba(20,12,4,.5); }
.fc-av { flex: none; width: 58px; height: 58px; border-radius: 50%; overflow: hidden;
    background: color-mix(in srgb, var(--card) 70%, #fff); display: flex; align-items: center; justify-content: center; }
.fc-av img { width: 100%; height: 100%; object-fit: cover; display: block; }
.fc-av-default { width: 100%; height: 100%; opacity: .28;
    background: center 62% / 78% no-repeat url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%232C2113'%3E%3Cpath d='M12 12a5 5 0 1 0 0-10 5 5 0 0 0 0 10zm0 2c-5 0-9 2.7-9 6v2h18v-2c0-3.3-4-6-9-6z'/%3E%3C/svg%3E"); }
.fc-info { flex: 1; min-width: 0; line-height: 1.2; padding-right: 6px; }
.fc-given   { font-family:'Newsreader',serif; font-size: 19px; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fc-surname { font-family:'Newsreader',serif; font-size: 19px; font-weight: 600; letter-spacing: .2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 3px; }
.fc-dates   { font-family:'Newsreader',serif; font-size: 19px; font-weight: 500; color: var(--soft); margin-top: 5px; }
.fc-marks { position: absolute; bottom: 7px; right: 9px; display: flex; gap: 4px; }
.fc-mark { width: 21px; height: 21px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
    box-shadow: inset 0 0 0 1px rgba(255,255,255,.25); }
.fc-mark svg { width: 13px; height: 13px; display: block; }
.fc-mark-photo { background: var(--accent); }
.fc-mark-note  { background: var(--gold); }
.fc-fiche { position: absolute; top: 6px; right: 7px; width: 22px; height: 22px; border-radius: 50%; border: none; padding: 0; cursor: pointer;
    background: color-mix(in srgb, var(--card) 60%, #fff); color: var(--ink); font: italic 800 14px/22px 'Newsreader', serif;
    text-align: center; text-decoration: none; box-shadow: inset 0 0 0 1px var(--line); }
.fc-fiche:hover { background: var(--accent); color: #FBF5E9; }

/* Panneau latéral d'une carte (bouton « i ») */
.fc-side { position: absolute; top: 0; right: 0; bottom: 0; width: min(360px, 90%); z-index: 30;
    background: var(--card); border-left: 1px solid var(--line); box-shadow: -14px 0 36px -18px rgba(20,12,4,.5);
    transform: translateX(102%); transition: transform .28s ease; overflow-y: auto; }
.fc-side.open { transform: none; }
.fc-side-close { position: absolute; top: 10px; right: 12px; width: 30px; height: 30px; border: none; cursor: pointer;
    border-radius: 50%; background: transparent; color: var(--soft); font-size: 22px; line-height: 1; }
.fc-side-close:hover { background: color-mix(in srgb, var(--ink) 8%, transparent); color: var(--ink); }
.fc-side-body { padding: 30px 22px 22px; text-align: center; }
.fc-side-body.is-tl { padding-left: 11px; padding-right: 11px; }   /* frise : marges latérales réduites */
.fc-side-av { width: 96px; height: 96px; margin: 6px auto 14px; border-radius: 50%; overflow: hidden;
    background: color-mix(in srgb, var(--ink) 8%, var(--card)); box-shadow: 0 0 0 3px var(--paper), 0 0 0 4px var(--line); }
.fc-side-av img { width: 100%; height: 100%; object-fit: cover; display: block; }
.fc-side-av .fc-av-default { display: block; width: 100%; height: 100%; opacity: .3;
    background: center/58% no-repeat url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path fill="%23000" d="M12 12a5 5 0 1 0 0-10 5 5 0 0 0 0 10zm0 2c-5 0-9 2.5-9 6v2h18v-2c0-3.5-4-6-9-6z"/></svg>'); }
.fc-side-name { font-family:'Newsreader',serif; font-size: 21px; color: var(--ink); line-height: 1.2; }
.fc-side-surname { font-family:'Newsreader',serif; font-size: 21px; font-weight: 600; color: var(--ink); line-height: 1.2; }
.fc-side-dates { font-family:'Newsreader',serif; font-size: 15px; color: var(--soft); margin-top: 6px; }
.fc-side-badges { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin: 16px 0 4px; }
.fc-side-badge { display: inline-flex; align-items: center; gap: 6px; padding: 5px 11px 5px 9px; border-radius: 999px;
    font-size: 12px; font-weight: 700; color: #FBF5E9; }
.fc-side-badge svg { width: 14px; height: 14px; display: block; }
.fc-side-badge.badge-photo { background: var(--accent); }
.fc-side-badge.badge-note  { background: var(--gold); }
.fc-side-actions { display: flex; flex-direction: column; gap: 9px; margin-top: 22px; }
/* Chronologie affichée dans le panneau */
.fc-side-tlhead { display: flex; align-items: center; gap: 8px; text-align: left; margin-bottom: 10px; }
.fc-side-back { flex: none; width: 30px; height: 30px; border: 1px solid var(--line); border-radius: 50%; cursor: pointer;
    background: var(--card); color: var(--ink); font-size: 20px; line-height: 1; }
.fc-side-back:hover { background: var(--accent); color: #FBF5E9; border-color: var(--accent); }
.fc-side-tlname { font-family:'Newsreader',serif; font-size: 16px; font-weight: 600; color: var(--ink);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fc-side-tl { text-align: left; }
.fc-side-tl .timeline { padding-left: 0; }
.fc-side-tl .tl-year { width: 56px; }
.fc-side-tl .tl-body { padding-bottom: 16px; }

/* ============================================================
   DESKTOP : sidebar + zone principale large
   (placé en fin de fichier pour primer sur les règles mobiles)
   ============================================================ */
@media (min-width: 1024px) {
  body { padding: 0; background: var(--paper); }
  .app { max-width: none; width: 100%; height: 100vh; min-height: 0; margin: 0; border-radius: 0; box-shadow: none; flex-direction: row; }
  .sidebar { display: flex; }                  /* sidebar visible */
  .app-nav { display: none !important; }       /* bottom-nav masquée */
  .has-sidebar .app-header .theme-btn { display: none; }
  .app-header { height: 54px; padding: 0 32px; }
  .app-title { font-size: 24px; }
  .app-body { max-width: 1120px; padding: 2px 40px 64px; }
  .app-body-wide { max-width: none; }   /* l'onglet Arbre occupe toute la largeur */
}

/* ============================================================
   IMPRESSION : on masque la navigation et les actions,
   on déplie le contenu sur fond blanc.
   ============================================================ */
@media print {
  .sidebar, .app-header, .app-nav, .theme-btn, .no-print,
  .fc-zoom, .sheet, .sheet-backdrop, .lightbox, .confirm-modal { display: none !important; }
  html, body { background: #fff !important; }
  .app, .app-main, .app-scroll { display: block !important; overflow: visible !important; height: auto !important; min-height: 0 !important; }
  .app { max-width: none !important; width: auto !important; margin: 0 !important; border-radius: 0 !important; box-shadow: none !important; }
  .app-body { max-width: none !important; padding: 0 !important; margin: 0 !important; animation: none !important; }
  .card { break-inside: avoid; box-shadow: none !important; border: 1px solid #bbb !important; }
  .person-row { break-inside: avoid; }
  a { color: inherit !important; text-decoration: none !important; }
}
