/* ---------- Couleurs et polices ---------- */
:root {
  --bg: #eef1f6;
  --surface: #ffffff;
  --ink: #1d2340;
  --muted: #5d6482;
  --line: #d8ddea;
  --primary: #1d2340;
  --on-primary: #ffffff;
  --gold: #f5b02e;
  --lagoon: #1c8b83;
  --male: #2b6cb0;
  --female: #c0397a;
  --vodi: #b7791f;
  --hibiscus: #d6336c;
  --danger: #b3261e;
  --soft: #e4e8f2;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --radius: 14px;
  --tab-h: 62px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #11142a;
    --surface: #1b2040;
    --ink: #eceffa;
    --muted: #a5accb;
    --line: #2e3560;
    --primary: #f5b02e;
    --on-primary: #2a1d00;
    --soft: #262c52;
    --lagoon: #4fc9bf;
    --male: #5aa0e6;
    --female: #f07bb0;
    --vodi: #f5b02e;
    --danger: #ff8a80;
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: var(--sans); font-size: 16px; line-height: 1.45;
  -webkit-text-size-adjust: 100%; overscroll-behavior: none;
}
body.noscroll { overflow: hidden; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; border-radius: 8px; }
[hidden] { display: none !important; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
.small { font-size: 0.875rem; }
.center { text-align: center; }
.pad { padding: 20px 4px; }

#app { height: 100dvh; display: flex; flex-direction: column; }

/* ---------- En-tête et onglets ---------- */
.demo-bar { background: var(--gold); color: #2a1d00; text-align: center; font-size: 0.85rem; padding: 6px 12px; font-weight: 600; }
.top {
  background: #1d2340; color: #fff; display: flex; align-items: center; justify-content: space-between;
  padding: calc(12px + env(safe-area-inset-top)) 18px 12px;
}
.top h1 { margin: 0; font: 600 1.35rem/1.2 var(--serif); letter-spacing: 0.01em; }
.top p { margin: 0; font-size: 0.82rem; opacity: 0.75; min-height: 1.1em; }
.main { flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.main.is-tree { overflow: hidden; position: relative; }
.tabbar {
  display: flex; background: var(--surface); border-bottom: 1px solid var(--line); min-height: var(--tab-h);
}
.tab {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  background: none; border: 0; color: var(--muted); font-size: 0.75rem; font-weight: 600; padding: 8px 4px;
}
.tab[aria-current="page"] { color: var(--ink); box-shadow: inset 0 -3px 0 var(--gold); }
@media (prefers-color-scheme: dark) { .tab[aria-current="page"] { color: var(--gold); } }

.icon-btn {
  display: inline-grid; place-items: center; width: 44px; height: 44px; border-radius: 50%;
  background: transparent; border: 0; color: var(--ink);
}
.icon-btn.light { color: #fff; }
.icon-btn.small { width: 36px; height: 36px; }
.icon-btn:hover { background: var(--soft); }
.icon-btn.light:hover { background: rgba(255, 255, 255, 0.14); }

/* ---------- Boutons et champs ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 0 18px; border-radius: 12px; border: 1.5px solid transparent;
  font-weight: 650; background: var(--soft); color: var(--ink);
}
.btn.primary { background: var(--primary); color: var(--on-primary); }
.btn.ghost { background: transparent; border-color: var(--line); }
.btn.ghost:hover { background: var(--soft); }
.btn.text { background: transparent; color: var(--muted); text-decoration: underline; text-underline-offset: 3px; min-height: 40px; padding: 0 8px; }
.btn.danger { background: transparent; border-color: var(--danger); color: var(--danger); }
.btn.wide { width: 100%; }
.btn:disabled { opacity: 0.55; cursor: progress; }

.input {
  width: 100%; min-height: 46px; padding: 0 14px; border-radius: 12px;
  border: 1.5px solid var(--line); background: var(--surface); color: var(--ink);
}
.input.big { min-height: 54px; font-size: 1.05rem; }
.input::placeholder { color: var(--muted); }
select.input { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 30px; }
.form-error { color: var(--danger); margin: 6px 0; font-weight: 600; }
.form-error:empty { display: none; }

/* ---------- Pages ---------- */
.page { max-width: 720px; margin: 0 auto; padding: 16px 16px 96px; }
.empty { text-align: center; padding: 56px 20px; }
.empty h2 { font: 600 1.4rem var(--serif); margin: 0 0 8px; }
.empty p { color: var(--muted); max-width: 32ch; margin: 0 auto 20px; }

/* Avatars */
.avatar {
  --h: 200; display: inline-grid; place-items: center; flex: none; overflow: hidden; border-radius: 50%;
  background: hsl(var(--h) 55% 86%); color: hsl(var(--h) 50% 24%); font-weight: 700; letter-spacing: 0.02em;
}
@media (prefers-color-scheme: dark) { .avatar { background: hsl(var(--h) 30% 30%); color: hsl(var(--h) 70% 90%); } }
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.avatar.ring { box-shadow: 0 0 0 4px var(--surface), 0 0 0 7px var(--gold); }

/* Prochain anniversaire : l'élément mis en avant */
.hero {
  display: flex; align-items: center; gap: 18px; width: 100%; text-align: left;
  background: #1d2340; color: #fff; border: 0; border-radius: 20px; padding: 20px 22px; margin-bottom: 16px;
}
@media (prefers-color-scheme: dark) { .hero { background: #262c52; } }
.hero.today { background: var(--hibiscus); }
.hero-count { display: flex; flex-direction: column; align-items: center; min-width: 76px; }
.hero-num { font: 700 3.6rem/0.95 var(--serif); color: var(--gold); }
.hero.today .hero-num { color: #fff; font-size: 3.2rem; }
.hero-unit { font-size: 0.85rem; opacity: 0.8; margin-top: 2px; }
.hero-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.hero-names { font: 600 1.45rem/1.2 var(--serif); overflow-wrap: anywhere; }
.hero-line { opacity: 0.85; }

.who { background: var(--surface); border: 1.5px dashed var(--gold); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 16px; }
.who-title { margin: 0; font: 600 1.1rem var(--serif); }
.who p.muted { margin: 2px 0 10px; }
.who-actions { display: flex; flex-wrap: wrap; gap: 8px; }

.controls { display: flex; flex-direction: column; gap: 10px; margin-bottom: 6px; }
.seg { display: flex; background: var(--soft); border-radius: 12px; padding: 3px; }
.seg button { flex: 1; min-height: 40px; border: 0; background: transparent; border-radius: 9px; font-weight: 650; color: var(--muted); }
.seg button[aria-pressed="true"], .seg button[aria-checked="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(20, 25, 60, 0.15); }

.month { font: 600 1.05rem var(--serif); margin: 22px 4px 6px; color: var(--muted); }
.row {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; margin-bottom: 8px;
}
.row:hover { border-color: var(--gold); }
.row.gone { opacity: 0.6; }
.row.today { border-color: var(--hibiscus); border-width: 2px; }
.row-main { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.row-name { font: 600 1.05rem/1.25 var(--serif); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-sub { color: var(--muted); font-size: 0.88rem; }
.when { font-size: 0.82rem; font-weight: 700; color: var(--muted); white-space: nowrap; }
.when.soon { color: var(--hibiscus); }
.plist { margin-top: 10px; }
.menu-list { margin-top: 14px; }
.menu-ic { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; background: var(--soft); flex: none; }
.row.menu .row-name { font-family: var(--sans); font-size: 1rem; font-weight: 650; }
.me-row { padding: 14px; }

/* ---------- Fenêtres ---------- */
.overlay { position: fixed; inset: 0; background: rgba(12, 15, 36, 0.55); display: flex; align-items: flex-end; justify-content: center; z-index: 50; }
.sheet {
  width: 100%; max-width: 560px; max-height: 92dvh; display: flex; flex-direction: column;
  background: var(--bg); border-radius: 22px 22px 0 0; animation: rise 0.22s ease-out;
}
@keyframes rise { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 10px 4px 20px; }
.sheet-head h2 { margin: 0; font: 600 1.25rem var(--serif); }
.sheet-body { padding: 8px 18px calc(88px + env(safe-area-inset-bottom)); overflow-y: auto; }
@media (min-width: 700px) {
  .overlay { align-items: center; }
  .sheet { border-radius: 22px; max-height: 88dvh; }
}

.profile-top { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 14px 0 8px; }
.profile-name { font: 600 1.7rem/1.15 var(--serif); margin: 18px 0 4px; }
.profile-date { margin: 0; color: var(--muted); }
.profile-next { margin: 8px 0 0; font-weight: 650; }
.profile-next.today { color: var(--hibiscus); }
.rel-block { margin-top: 14px; }
.group-title { margin: 0 0 8px; font: 600 1rem var(--serif); color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; align-items: center; gap: 8px; padding: 4px 14px 4px 4px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); font-weight: 600; }
.chip:hover { border-color: var(--gold); }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 22px; }
.actions .btn { flex: 1 1 auto; }

.form { display: flex; flex-direction: column; gap: 14px; margin-top: 6px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label, .lbl { font-weight: 650; font-size: 0.92rem; }
.field.check { flex-direction: row; align-items: center; gap: 10px; }
.field.check input { width: 22px; height: 22px; accent-color: var(--lagoon); }
.field.check label { font-weight: 500; }
.hint { margin: 0; color: var(--muted); font-size: 0.85rem; }
.date-row { display: grid; grid-template-columns: 0.8fr 1.3fr 1.5fr; gap: 8px; }
.photo-box { display: flex; align-items: center; gap: 16px; }
.photo-actions { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; }
.group { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; display: flex; flex-direction: column; gap: 12px; }
.rel { display: flex; align-items: center; gap: 6px; }
.rel-btn { flex: 1; min-height: 46px; padding: 6px 12px; text-align: left; border: 1.5px solid var(--line); border-radius: 12px; background: var(--bg); }
.rel-chip { display: inline-flex; align-items: center; gap: 10px; font-weight: 600; }
.login-form .field.check { margin: 4px 0 8px; }

/* ---------- Connexion ---------- */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 20px; background: #1d2340; color: #fff; }
.login .muted { color: rgba(255, 255, 255, 0.75); }
.login-card { width: 100%; max-width: 380px; }
.login-card h1 { font: 600 2.1rem/1.15 var(--serif); margin: 0 0 6px; }
.login-sub { margin: 0 0 22px; opacity: 0.8; }
.login .input { background: #fff; color: #1d2340; border-color: transparent; }
.login .icon-btn { color: #fff; }
.login .btn.primary { background: var(--gold); color: #2a1d00; }
.login .form-error { color: #ffb4a8; }
.pw { display: flex; align-items: center; gap: 4px; margin-bottom: 8px; }

/* ---------- Arbre ---------- */
.tree-wrap { position: absolute; inset: 0; background:
  radial-gradient(circle at 1px 1px, var(--line) 1px, transparent 0) 0 0 / 28px 28px, var(--bg); }
.tree-vp { position: absolute; inset: 0; overflow: hidden; touch-action: none; cursor: grab; outline-offset: -3px; }
.tree-vp:active { cursor: grabbing; }
.tree-stage { position: absolute; left: 0; top: 0; transform-origin: 0 0; will-change: transform; }
.tree-stage.anim { transition: transform 0.4s ease; }
.tree-lines { position: absolute; left: 0; top: 0; pointer-events: none; overflow: visible; }
.ln { fill: none; stroke: var(--lagoon); stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; opacity: 0.75; }
.ln-spouse { stroke: var(--gold); stroke-width: 4; stroke-linecap: round; }

.pcard {
  position: absolute; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 6px 6px;
  background: var(--surface); border: 1.5px solid var(--line); border-radius: 16px; text-align: center; overflow: hidden;
}
.pcard:hover { border-color: var(--gold); }
.pcard .pname { font: 600 0.82rem/1.15 var(--serif); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; margin-top: 2px; }
.pcard .pdate { font-size: 0.72rem; color: var(--muted); line-height: 1.2; }
.pcard .pnote { font-size: 0.76rem; font-weight: 700; color: var(--lagoon); line-height: 1.2; min-height: 1em; }
.pcard.me { border-color: var(--lagoon); border-width: 2.5px; }
.pcard.bd { border-color: var(--hibiscus); border-width: 2.5px; }
.pcard.gone { background: var(--soft); border-style: dashed; }
.pcard.gone .avatar { filter: grayscale(0.7); }
.pcard.gone .pnote { color: var(--muted); }
.pcard.flash { animation: flash 0.6s ease 3; }
@keyframes flash { 50% { box-shadow: 0 0 0 8px rgba(245, 176, 46, 0.55); } }
.pghost {
  position: absolute; height: 34px; border: 1.5px dashed var(--muted); background: transparent; border-radius: 999px;
  color: var(--muted); font-size: 0.8rem; font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 0 8px;
}
.pghost:hover { color: var(--ink); border-color: var(--gold); }
.tog {
  position: absolute; transform: translate(-50%, -50%); min-width: 26px; height: 26px; padding: 0 7px; border-radius: 999px;
  border: 1.5px solid var(--lagoon); background: var(--surface); color: var(--lagoon); font-size: 0.8rem; font-weight: 800; line-height: 1;
}
.tog.closed { background: var(--lagoon); color: #fff; }

.tree-ctl { position: absolute; left: 12px; bottom: 14px; display: flex; flex-direction: column; gap: 8px; }
.ctl {
  width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center;
  background: var(--surface); border: 1px solid var(--line); box-shadow: 0 2px 8px rgba(20, 25, 60, 0.18);
}
.ctl:hover { border-color: var(--gold); }

/* ---------- Message temporaire ---------- */
.toast {
  position: fixed; left: 50%; top: calc(env(safe-area-inset-top) + 150px); transform: translateX(-50%);
  background: #1d2340; color: #fff; padding: 11px 18px; border-radius: 999px; font-weight: 600; z-index: 80;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3); max-width: 90vw; text-align: center;
}
@media (prefers-color-scheme: dark) { .toast { background: var(--gold); color: #2a1d00; } }

@media (prefers-reduced-motion: reduce) {
  .sheet, .pcard.flash { animation: none; }
  .tree-stage.anim { transition: none; }
}

/* ---------- En souvenir ---------- */
.souvenir { font-size: 0.8rem; font-weight: 650; color: var(--muted); white-space: nowrap; font-style: italic; }
.profile-next.souvenir { font-size: 1rem; font-style: normal; }

/* ---------- Mariage ---------- */
.wd-av { position: relative; display: inline-block; flex: none; }
.avatar.wd { background: color-mix(in srgb, var(--hibiscus) 16%, var(--surface)); color: var(--hibiscus); }
.wd-badge {
  position: absolute; right: -5px; bottom: -5px; display: grid; place-items: center; width: 22px; height: 22px;
  border-radius: 50%; background: var(--hibiscus); color: #fff; border: 2px solid var(--surface);
}
.wd-badge svg { width: 11px; height: 11px; }
.row.wedding { border-color: color-mix(in srgb, var(--hibiscus) 40%, var(--line)); background: color-mix(in srgb, var(--hibiscus) 5%, var(--surface)); }
.row.wedding .row-name { white-space: normal; }
.row.wedding.today { border-color: var(--hibiscus); }
.wd-card { display: flex; align-items: center; gap: 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; }
.wd-text { display: flex; flex-direction: column; min-width: 0; }
.wd-text strong { font: 600 1.02rem/1.25 var(--serif); }
.wd-text span { color: var(--muted); font-size: 0.9rem; }

/* ---------- Monsieur / Madame sur les cartes de l'arbre ---------- */
.gbadge {
  position: absolute; top: 6px; left: 6px; width: 20px; height: 20px; border-radius: 50%;
  display: grid; place-items: center; color: #fff;
}
.gbadge.male { background: var(--male); }
.gbadge.female { background: var(--female); }
.gbadge svg { stroke-width: 2.4; }
@media (prefers-color-scheme: dark) { .gbadge { color: #11142a; } }

/* ---------- Type de date de mariage ---------- */
.wd-tag {
  display: inline-block; padding: 1px 9px; border-radius: 999px; font-size: 0.76rem; font-weight: 700;
  color: #fff; background: var(--hibiscus); line-height: 1.5; vertical-align: 1px;
}
.wd-tag.wd-vodi { background: var(--vodi); color: #2a1d00; }
.wd-tag.wd-civil { background: var(--hibiscus); }
.wd-tag.wd-relig { background: var(--lagoon); }
@media (prefers-color-scheme: dark) { .wd-tag.wd-civil, .wd-tag.wd-relig { color: #11142a; } }
.wd-text { gap: 3px; }

/* Dans la liste : le type de date sur sa propre ligne, la date dessous */
.row-sub .wd-tag { display: table; margin: 3px 0 2px; }
