/* ───────── Dar Jeddi — styles ───────── */
:root {
  --bg: #f6f1e9;
  --surface: #fffdf9;
  --surface-2: #f0e9de;
  --ink: #2b2520;
  --muted: #7b7065;
  --line: #e6ddcf;
  --line-strong: #cdbda6;
  --primary: #2e6150;
  --primary-hover: #244e40;
  --primary-soft: #e2ede8;
  --on-primary: #ffffff;
  --accent: #c26d3c;
  --danger: #b3412d;
  --danger-soft: #f7e3de;
  --m: #4a7aa5; --m-soft: #e3edf6;
  --f: #b3587a; --f-soft: #f7e5ec;
  --u: #8b8175; --u-soft: #ece7e0;
  --shadow: 0 1px 2px rgba(60, 40, 20, .06), 0 4px 16px rgba(60, 40, 20, .07);
  --shadow-lg: 0 12px 44px rgba(40, 25, 10, .2);
  --r: 18px;
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --serif: 'Fraunces', Georgia, 'Times New Roman', serif;
  --top: 60px;
  --tab: 66px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1b1916; --surface: #25221e; --surface-2: #2f2b26; --ink: #f1ebe2; --muted: #a99e91;
    --line: #3a352f; --line-strong: #5a5248; --primary: #74b59d; --primary-hover: #8cc6b0;
    --primary-soft: #22362f; --on-primary: #0f1f19; --accent: #e0915f; --danger: #e27a64; --danger-soft: #3a2420;
    --m: #82abd2; --m-soft: #223040; --f: #da8ca9; --f-soft: #3b2530; --u: #a99e91; --u-soft: #33302b;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .25);
    --shadow-lg: 0 12px 44px rgba(0, 0, 0, .5);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--ink);
  font: 16px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
h1 { font: 600 28px/1.15 var(--serif); letter-spacing: -.01em; }
h2 { font: 600 19px/1.2 var(--serif); }
h3 { font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
svg.i { width: 20px; height: 20px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.muted { color: var(--muted); }
.center { text-align: center; }
.boot, .fatal { display: grid; place-items: center; min-height: 100dvh; color: var(--muted); }

/* ───────── Shell ───────── */
.topbar {
  position: sticky; top: 0; z-index: 30; height: var(--top);
  display: flex; align-items: center; gap: 24px; padding: 0 16px;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; white-space: nowrap; flex: none; text-decoration: none; font: 600 22px var(--serif); color: var(--primary); }
.brand svg { width: 34px; height: 34px; }
.nav { display: none; margin-left: auto; gap: 4px; }
.nav a { display: flex; align-items: center; gap: 8px; padding: 8px 14px; border-radius: 999px; text-decoration: none; color: var(--muted); font-weight: 500; font-size: 15px; }
.nav a:hover { background: var(--surface-2); color: var(--ink); }
.nav a.on { background: var(--primary-soft); color: var(--primary); }
.nav a.add { background: var(--primary); color: var(--on-primary); }
.nav a.add:hover { background: var(--primary-hover); }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: grid; grid-template-columns: repeat(5, 1fr);
  height: calc(var(--tab) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  background: var(--surface); border-top: 1px solid var(--line);
}
.tabbar a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; text-decoration: none; color: var(--muted); font-size: 11.5px; font-weight: 500; }
.tabbar a svg.i { width: 24px; height: 24px; }
.tabbar a.on { color: var(--primary); }
.tabbar a.add .plus {
  width: 50px; height: 50px; border-radius: 18px; display: grid; place-items: center; margin-top: -10px;
  background: var(--primary); color: var(--on-primary); box-shadow: 0 6px 18px color-mix(in srgb, var(--primary) 40%, transparent);
}
.tabbar a.add .plus svg.i { width: 26px; height: 26px; stroke-width: 2.2; }
.tabbar a.add span:last-child { display: none; }

#view { padding-bottom: calc(var(--tab) + env(safe-area-inset-bottom) + 28px); }
#view.full { padding: 0; position: relative; overflow: hidden; height: calc(100dvh - var(--top) - var(--tab) - env(safe-area-inset-bottom)); }

@media (min-width: 900px) {
  .topbar { padding: 0 28px; }
  .nav { display: flex; }
  .tabbar { display: none; }
}
@media (min-width: 900px) and (max-width: 1180px) {
  .nav { gap: 2px; }
  .nav a { padding: 8px 11px; }
  .nav a.desk > span { display: none; }
  #view { padding-bottom: 48px; }
  #view.full { height: calc(100dvh - var(--top)); }
}

/* ───────── Pages, cartes, boutons ───────── */
.page { max-width: 1120px; margin: 0 auto; padding: 20px 16px; }
.page.narrow { max-width: 680px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 4px 0 18px; }
.page-head p { margin: 4px 0 0; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 18px; box-shadow: var(--shadow); }
.card + .card, .card + section, section + .card { margin-top: 14px; }
.card > h2 { margin-bottom: 14px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.card-head h2 { display: flex; align-items: center; gap: 8px; }
.card-head h2 svg.i { color: var(--accent); }
.card-head h2 small { font: 500 13px var(--font); color: var(--muted); background: var(--surface-2); padding: 1px 8px; border-radius: 999px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 18px; border-radius: 12px;
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink);
  font-weight: 600; font-size: 15px; text-decoration: none; white-space: nowrap;
  transition: background .15s, border-color .15s, transform .1s;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.btn.primary:hover { background: var(--primary-hover); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.sm { min-height: 36px; padding: 0 12px; font-size: 14px; border-radius: 10px; }
.btn.block { width: 100%; }
.btn.icon-only { padding: 0; width: 44px; }
.btn[disabled] { opacity: .6; pointer-events: none; }
.icon-btn { display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 12px; border: 0; background: transparent; color: var(--muted); text-decoration: none; }
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }
.link { color: var(--primary); font-weight: 600; font-size: 14px; text-decoration: none; background: none; border: 0; padding: 0; }

/* ───────── Formulaires ───────── */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field > span { font-size: 14px; font-weight: 600; }
.field > span em { font-style: normal; font-weight: 400; color: var(--muted); }
input:not([type=checkbox]):not([type=radio]):not([type=file]), select, textarea {
  width: 100%; min-height: 48px; padding: 11px 14px; border-radius: 12px;
  border: 1px solid var(--line-strong); background: var(--bg); font-size: 16px; outline: none;
  transition: border-color .15s, box-shadow .15s;
}
textarea { min-height: 160px; resize: vertical; line-height: 1.6; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 20%, transparent); }
.row2 { display: grid; gap: 0 12px; }
@media (min-width: 560px) { .row2 { grid-template-columns: 1fr 1fr; } }
.form-error { color: var(--danger); background: var(--danger-soft); padding: 10px 14px; border-radius: 12px; font-size: 14px; margin: 0 0 14px; }
.hint { font-size: 13px; color: var(--muted); margin: -6px 0 14px; }

.seg { display: grid; grid-template-columns: repeat(3, 1fr); background: var(--surface-2); border-radius: 12px; padding: 4px; gap: 4px; }
.seg label { position: relative; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { display: flex; align-items: center; justify-content: center; min-height: 40px; border-radius: 9px; font-weight: 500; font-size: 15px; color: var(--muted); cursor: pointer; }
.seg input:checked + span { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); font-weight: 600; }
.seg input:focus-visible + span { outline: 2px solid var(--primary); }

.switch { display: flex; align-items: center; gap: 12px; cursor: pointer; font-weight: 500; min-height: 44px; }
.switch input { position: absolute; opacity: 0; }
.switch .track { width: 48px; height: 28px; border-radius: 99px; background: var(--line-strong); position: relative; flex: none; transition: background .2s; }
.switch .track::after { content: ''; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; transition: transform .2s; box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.switch input:checked + .track { background: var(--primary); }
.switch input:checked + .track::after { transform: translateX(20px); }
.switch input:focus-visible + .track { outline: 2px solid var(--primary); outline-offset: 2px; }

.form-head { display: flex; align-items: center; gap: 8px; margin: 0 0 16px -8px; }
.form-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; }
.form-actions.sticky {
  position: sticky; bottom: calc(var(--tab) + env(safe-area-inset-bottom) + 8px);
  background: color-mix(in srgb, var(--bg) 90%, transparent); backdrop-filter: blur(8px);
  padding: 10px; margin: 18px -10px 0; border-radius: 16px;
}
.form-actions.sticky .btn { flex: 1; }
@media (min-width: 900px) { .form-actions.sticky { bottom: 12px; } .form-actions.sticky .btn { flex: 0 0 auto; min-width: 140px; } }
.ctx-banner { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 14px; background: var(--primary-soft); color: var(--primary); font-weight: 500; margin-bottom: 14px; }

/* ───────── Avatars ───────── */
.av { display: grid; place-items: center; flex: none; border-radius: 50%; overflow: hidden; font-weight: 600; width: 44px; height: 44px; font-size: 15px; background: var(--u-soft); color: var(--u); box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--u-soft); }
.av img { width: 100%; height: 100%; object-fit: cover; }
.av.sm { width: 38px; height: 38px; font-size: 13px; }
.av.lg { width: 56px; height: 56px; font-size: 18px; }
.sex-M .av, .av.sex-M { background: var(--m-soft); color: var(--m); box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--m-soft); }
.sex-F .av, .av.sex-F { background: var(--f-soft); color: var(--f); box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--f-soft); }

/* ───────── Connexion ───────── */
.auth { min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px;
  background: radial-gradient(circle at 20% 10%, var(--primary-soft), transparent 50%), radial-gradient(circle at 90% 90%, color-mix(in srgb, var(--accent) 14%, transparent), transparent 45%), var(--bg); }
.auth-card { width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--line); border-radius: 24px; padding: 32px 24px; box-shadow: var(--shadow-lg); }
.auth-logo { width: 64px; height: 64px; margin: 0 auto 12px; }
.auth-card h1 { text-align: center; font-size: 34px; color: var(--primary); }
.auth-card > p { text-align: center; margin: 4px 0 24px; }
.auth-card > p.auth-ar { margin: 2px 0 6px; font-size: 22px; color: var(--accent); font-family: 'Amiri', 'Traditional Arabic', 'Segoe UI', serif; }

/* ───────── Arbre ───────── */
.tree-vp {
  position: absolute; inset: 0; overflow: hidden; touch-action: none; cursor: grab; user-select: none; -webkit-user-select: none;
  background-color: var(--bg);
  background-image: radial-gradient(color-mix(in srgb, var(--line-strong) 55%, transparent) 1px, transparent 1.4px);
  background-size: 22px 22px;
}
.tree-vp:active { cursor: grabbing; }
.tree-stage { position: absolute; left: 0; top: 0; transform-origin: 0 0; will-change: transform; animation: fadein .35s ease; }
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }
.tree-links { position: absolute; left: 0; top: 0; overflow: visible; }
.tree-links path { fill: none; stroke: var(--line-strong); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.tree-links path.couple { stroke: var(--accent); stroke-width: 2.4; stroke-dasharray: 1 5; opacity: .9; }

.tcard {
  position: absolute; width: 176px; height: 76px; display: flex; align-items: center; gap: 12px; padding: 0 12px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow);
  cursor: pointer; transition: box-shadow .15s, transform .15s;
}
.tcard:hover { box-shadow: var(--shadow-lg); }
.tcard::before { content: ''; position: absolute; left: -1px; top: 14px; bottom: 14px; width: 4px; border-radius: 0 4px 4px 0; background: var(--u); opacity: .7; }
.tcard.sex-M::before { background: var(--m); }
.tcard.sex-F::before { background: var(--f); }
.tcard.focus { border: 2px solid var(--primary); box-shadow: 0 0 0 6px color-mix(in srgb, var(--primary) 16%, transparent), var(--shadow-lg); }
.tcard.dead .tc-first, .tcard.dead .tc-last { opacity: .85; }
.tc-txt { display: flex; flex-direction: column; min-width: 0; line-height: 1.2; }
.tc-first { font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tc-last { font-weight: 700; font-size: 14px; text-transform: uppercase; letter-spacing: .02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tc-yr { font-size: 12px; color: var(--muted); margin-top: 2px; }
.tc-half { position: absolute; top: -10px; right: 10px; font-size: 11px; font-weight: 600; line-height: 18px; padding: 0 8px; border-radius: 99px; background: var(--surface-2); border: 1px solid var(--line-strong); color: var(--muted); }
.radio-list { display: grid; gap: 8px; }
.radio-list label { display: flex; align-items: flex-start; gap: 12px; padding: 14px; border: 1px solid var(--line); border-radius: 14px; background: var(--bg); cursor: pointer; }
.radio-list label:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); }
.radio-list input { accent-color: var(--primary); width: 20px; height: 20px; margin: 2px 0 0; flex: none; }
.radio-list b { display: block; }
.radio-list span { font-size: 14px; color: var(--muted); }
.tcard.ghost { justify-content: center; gap: 8px; background: transparent; border: 2px dashed var(--line-strong); box-shadow: none; color: var(--muted); font-weight: 600; font-size: 14px; }
.tcard.ghost::before { display: none; }
.tcard.ghost:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-soft); }

.tree-tools { position: absolute; top: 12px; left: 12px; right: 12px; display: flex; justify-content: space-between; gap: 8px; pointer-events: none; z-index: 5; }
.tree-tools > * { pointer-events: auto; }
.tool-group { display: flex; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); overflow: hidden; }
.tool-btn { display: inline-flex; align-items: center; gap: 8px; height: 44px; min-width: 44px; justify-content: center; padding: 0 12px; border: 0; background: var(--surface); color: var(--ink); font-weight: 600; font-size: 14px; }
.tool-btn:hover { background: var(--surface-2); }
.tool-btn.wide { border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); padding: 0 16px; }
.tree-focus {
  position: absolute; left: 12px; right: 12px; bottom: 12px; z-index: 5; margin: 0 auto; max-width: 460px;
  display: flex; align-items: center; gap: 12px; padding: 10px 10px 10px 14px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow-lg);
}
.tf-txt { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.tf-txt b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tf-txt span { font-size: 13px; color: var(--muted); }
.tree-hint { position: absolute; left: 0; right: 0; bottom: 92px; text-align: center; font-size: 13px; color: var(--muted); margin: 0; pointer-events: none; animation: hint 6s ease forwards; }
@keyframes hint { 0%, 70% { opacity: 1; } 100% { opacity: 0; } }

.welcome { text-align: center; max-width: 520px; margin: 6vh auto 0; padding: 36px 24px; }
.welcome .art { width: 140px; height: 140px; margin: 0 auto 18px; }
.welcome h1 { font-size: 30px; margin-bottom: 10px; }
.welcome p { color: var(--muted); margin: 0 0 24px; }

/* ───────── Fiche personne ───────── */
.pp-grid { display: grid; gap: 14px; }
.pp-grid > * > .card + .card { margin-top: 14px; }
@media (min-width: 900px) {
  .pp-grid { grid-template-columns: 340px 1fr; align-items: start; gap: 20px; }
  .pp-side { position: sticky; top: calc(var(--top) + 20px); }
}
.hero { text-align: center; padding-top: 26px; }
.hero-photo {
  position: relative; width: 128px; height: 128px; border-radius: 50%; margin: 0 auto 16px; padding: 0; border: 0;
  display: grid; place-items: center; background: var(--u-soft); color: var(--u); font: 600 40px var(--serif);
  box-shadow: 0 0 0 4px var(--surface), 0 0 0 7px var(--u-soft), var(--shadow);
}
.hero-photo.sex-M { background: var(--m-soft); color: var(--m); box-shadow: 0 0 0 4px var(--surface), 0 0 0 7px var(--m-soft), var(--shadow); }
.hero-photo.sex-F { background: var(--f-soft); color: var(--f); box-shadow: 0 0 0 4px var(--surface), 0 0 0 7px var(--f-soft), var(--shadow); }
.hero-photo img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
.hero-photo i { position: absolute; right: 2px; bottom: 2px; width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; background: var(--primary); color: var(--on-primary); box-shadow: 0 0 0 3px var(--surface); }
.hero-photo i svg.i { width: 18px; height: 18px; }
.hero h1 { font-size: 27px; }
.hero h1 b { font-weight: 600; text-transform: uppercase; letter-spacing: .02em; }
.hero p { margin: 6px 0 0; }
.hero .life { color: var(--muted); font-weight: 500; }
.chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin-top: 12px; }
.chip { background: color-mix(in srgb, var(--accent) 13%, transparent); color: var(--accent); padding: 4px 12px; border-radius: 999px; font-size: 13px; font-weight: 600; }
.hero-actions { display: flex; gap: 8px; margin-top: 20px; }
.hero-actions .btn:not(.icon-only) { flex: 1; }

.facts { margin: 0; display: grid; gap: 12px; }
.facts div { display: grid; gap: 1px; }
.facts dt { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; }
.facts dd { margin: 0; font-weight: 500; }

.story-text { font-size: 16.5px; line-height: 1.75; }
.story-text p { margin: 0 0 12px; }
.story-text p:first-child::first-letter { font: 600 2.6em/1 var(--serif); float: left; margin: 4px 8px 0 0; color: var(--primary); }
.empty-cta { display: flex; align-items: center; justify-content: center; text-align: center; min-height: 100px; padding: 18px; border: 2px dashed var(--line-strong); border-radius: 14px; color: var(--muted); text-decoration: none; font-weight: 500; }
.empty-cta:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-soft); }

.fam-group + .fam-group { margin-top: 18px; }
.fam-group h3 { margin-bottom: 8px; }
.fam-list { display: grid; gap: 8px; }
@media (min-width: 640px) { .fam-list { grid-template-columns: 1fr 1fr; } }
.fam-chip { display: flex; align-items: center; border: 1px solid var(--line); border-radius: 14px; background: var(--bg); }
.fam-chip > a { flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px; padding: 10px 12px; text-decoration: none; }
.fam-chip > a > div { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.fam-chip b { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fam-chip span { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fam-chip:hover { border-color: var(--line-strong); }
.fam-manage { display: none; padding-right: 6px; }
.family.managing .fam-manage { display: flex; }
.fam-manage .icon-btn.rm { color: var(--danger); }
.kin-group + .kin-group { margin-top: 18px; }
.kin-group h3 { margin-bottom: 8px; display: flex; align-items: center; gap: 8px; }
.kin-group h3 small { font-size: 12px; letter-spacing: 0; text-transform: none; background: var(--surface-2); padding: 0 8px; border-radius: 99px; }
.kin-group.folded .extra { display: none; }
.kin-more { margin-top: 10px; }
.kin-label { font-style: normal; font-weight: 600; color: var(--accent); }
.fam-add { display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 60px; border: 2px dashed var(--line-strong); border-radius: 14px; background: transparent; color: var(--muted); font-weight: 600; font-size: 14px; }
.fam-add:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-soft); }

.photo-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
@media (min-width: 640px) { .photo-grid { grid-template-columns: repeat(4, 1fr); } }
.photo-grid .photo, .photo-add { position: relative; aspect-ratio: 1; border-radius: 12px; overflow: hidden; border: 0; padding: 0; background: var(--surface-2); }
.photo-grid .photo img { width: 100%; height: 100%; object-fit: cover; transition: transform .25s; }
.photo-grid .photo:hover img { transform: scale(1.04); }
.photo-grid .badge { position: absolute; left: 6px; bottom: 6px; background: rgba(0,0,0,.6); color: #fff; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 99px; }
.photo-add { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; border: 2px dashed var(--line-strong); background: transparent; color: var(--muted); font-weight: 600; font-size: 13px; cursor: pointer; }
.photo-add:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-soft); }

.doc-list { display: grid; gap: 8px; }
.doc-row { display: flex; align-items: center; gap: 4px; border: 1px solid var(--line); border-radius: 14px; background: var(--bg); }
.doc-main { flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px; padding: 10px 12px; text-decoration: none; }
.doc-main > div { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.doc-main b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.doc-main span { font-size: 13px; color: var(--muted); }
.doc-ico { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; flex: none; background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--accent); }
.doc-ico.img { background: var(--primary-soft); color: var(--primary); }
.empty-small { color: var(--muted); font-size: 14px; margin: 0; }
.meta { text-align: center; font-size: 13px; color: var(--muted); margin: 20px 0 0; }
.meta a { color: var(--primary); }

/* ───────── Listes ───────── */
.search-wrap { position: relative; margin-bottom: 16px; }
.search-wrap svg.i { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.search-wrap input { padding-left: 44px !important; background: var(--surface) !important; }
.letter { font: 600 15px var(--serif); color: var(--accent); margin: 18px 4px 8px; }
.person-list { display: grid; gap: 8px; }
@media (min-width: 720px) { .person-list { grid-template-columns: 1fr 1fr; } }
.person-row { display: flex; align-items: center; gap: 12px; width: 100%; padding: 12px 14px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); text-decoration: none; text-align: left; }
.person-row:hover { border-color: var(--line-strong); box-shadow: var(--shadow); }
.person-row > div { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.person-row b { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.person-row span { font-size: 13px; color: var(--muted); }
.empty { text-align: center; padding: 40px 16px; color: var(--muted); }
.empty h2 { color: var(--ink); margin-bottom: 8px; }
.empty .btn { margin-top: 16px; }

/* ───────── Historique ───────── */
.day { font: 600 15px var(--serif); color: var(--accent); margin: 20px 4px 8px; text-transform: capitalize; }
.hist { display: grid; gap: 8px; }
.hist-row { display: flex; align-items: flex-start; gap: 12px; padding: 12px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; }
.hist-row .dot { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; flex: none; background: var(--primary-soft); color: var(--primary); font-weight: 700; font-size: 13px; }
.hist-row .txt { flex: 1; min-width: 0; }
.hist-row .txt p { margin: 0; }
.hist-row .txt small { color: var(--muted); }
.hist-row.undone .txt p { text-decoration: line-through; color: var(--muted); }
.hist-row a { color: var(--primary); text-decoration: none; font-weight: 500; }

/* ───────── Compte ───────── */
.user-row { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); }
.user-row:first-of-type { border-top: 0; }
.user-row > div { flex: 1; min-width: 0; }
.user-row b { display: block; }
.user-row span { font-size: 13px; color: var(--muted); }
.user-row > div > span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.role { font-size: 12px; font-weight: 600; padding: 2px 10px; border-radius: 99px; background: var(--surface-2); color: var(--muted); }
.role.admin { background: color-mix(in srgb, var(--accent) 15%, transparent); color: var(--accent); }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; text-align: center; }
.stats div { background: var(--bg); border-radius: 14px; padding: 12px 6px; }
.stats b { display: block; font: 600 26px var(--serif); color: var(--primary); }
.stats span { font-size: 13px; color: var(--muted); }
.account-grid { display: grid; gap: 14px; }
.account-grid > .card + .card { margin-top: 0; }
@media (min-width: 900px) { .account-grid { grid-template-columns: 1fr 1fr; align-items: start; } }

/* ───────── Accueil ───────── */
.home-hero {
  position: relative; overflow: hidden; display: flex; align-items: center; gap: 16px;
  padding: 26px 22px; border-radius: 24px; color: #fff; margin-bottom: 14px;
  background:
    radial-gradient(circle at 92% 8%, rgba(255,255,255,.16), transparent 40%),
    radial-gradient(circle at 0% 100%, color-mix(in srgb, var(--accent) 55%, transparent), transparent 55%),
    linear-gradient(135deg, #2e6150, #1f4a3c);
  box-shadow: var(--shadow-lg);
}
.home-hero::after {
  content: ''; position: absolute; right: -30px; bottom: -40px; width: 180px; height: 180px; opacity: .1;
  background: radial-gradient(circle, #fff 0 30%, transparent 31%) 50% 20% / 70% 60% no-repeat,
              linear-gradient(#fff, #fff) 50% 100% / 10% 50% no-repeat;
}
.hh-text { flex: 1; min-width: 0; position: relative; z-index: 1; }
.hh-kicker { margin: 0 0 4px; font-size: 13px; text-transform: capitalize; opacity: .8; font-weight: 500; }
.home-hero h1 { font-size: 30px; color: #fff; }
.hh-msg { margin: 10px 0 18px; font-size: 16.5px; line-height: 1.5; opacity: .95; max-width: 560px; }
.hh-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.btn.light { background: #fff; color: #1f4a3c; border-color: #fff; }
.btn.light:hover { background: #f1ebe2; }
.btn.ghost-light { background: rgba(255,255,255,.12); color: #fff; border-color: rgba(255,255,255,.35); }
.btn.ghost-light:hover { background: rgba(255,255,255,.2); }
.hh-streak { position: relative; z-index: 1; flex: none; display: flex; flex-direction: column; align-items: center; justify-content: center; width: 92px; height: 92px; border-radius: 22px; background: rgba(255,255,255,.14); border: 1px solid rgba(255,255,255,.25); }
.hh-streak svg.i { width: 24px; height: 24px; color: #ffc48a; }
.hh-streak b { font: 600 26px/1 var(--serif); margin-top: 2px; }
.hh-streak span { font-size: 11.5px; opacity: .85; }
@media (max-width: 520px) { .hh-streak { position: absolute; top: 16px; right: 16px; width: 64px; height: 64px; border-radius: 16px; } .hh-streak b { font-size: 20px; } .hh-streak span { display: none; } .home-hero h1 { font-size: 26px; padding-right: 64px; } }

.home-grid { display: grid; gap: 14px; }
.home-grid > .card + .card { margin-top: 0; }
@media (min-width: 900px) { .home-grid { grid-template-columns: 1fr 1fr; align-items: start; } .home-grid .wide { grid-column: 1 / -1; } }
.tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
@media (min-width: 560px) { .tiles { grid-template-columns: repeat(4, 1fr); } }
.tile { background: var(--bg); border-radius: 14px; padding: 14px 10px; text-align: center; }
.tile b { display: block; font: 600 28px/1.1 var(--serif); color: var(--primary); }
.tile span { font-size: 13px; color: var(--muted); }
.home-note { font-size: 14px; color: var(--muted); margin: 12px 0 0; }
.home-note b { color: var(--ink); }
.goal { margin: 0 0 10px; color: var(--muted); }
.goal b { font: 600 34px var(--serif); color: var(--primary); }
.bar { height: 10px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.bar span { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--primary), color-mix(in srgb, var(--primary) 60%, var(--accent))); transition: width .6s ease; min-width: 0; }
.lineage { display: grid; gap: 12px; margin-top: 14px; }
.lin-head { display: flex; justify-content: space-between; gap: 8px; font-size: 14px; margin-bottom: 5px; }
.lin-head span { color: var(--muted); }
.rel-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-top: 18px; }
@media (min-width: 560px) { .rel-grid { grid-template-columns: repeat(4, 1fr); } }
@media (min-width: 900px) { .rel-grid { grid-template-columns: repeat(7, 1fr); } }
.rel { background: var(--primary-soft); border-radius: 14px; padding: 12px 8px; text-align: center; }
.rel b { display: block; font: 600 24px/1.1 var(--serif); color: var(--primary); }
.rel span { font-size: 12.5px; color: var(--ink); }
.rel.zero { background: var(--bg); }
.rel.zero b { color: var(--muted); }
.pick-me { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; border: 2px dashed var(--line-strong); box-shadow: none; }
.pick-me > div:first-child { width: 52px; height: 52px; border-radius: 16px; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary); }
.pick-me > div:nth-child(2) { flex: 1; min-width: 200px; }
.steps { display: grid; gap: 8px; }
.step { display: flex; align-items: center; gap: 12px; width: 100%; padding: 12px; border: 1px solid var(--line); border-radius: 14px; background: var(--bg); text-decoration: none; text-align: left; }
.step:hover { border-color: var(--primary); background: var(--primary-soft); }
.step > div { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.3; }
.step b { font-weight: 600; }
.step span { font-size: 13px; color: var(--muted); }
.step > svg.i:first-child { width: 38px; height: 38px; padding: 9px; border-radius: 50%; background: var(--primary-soft); color: var(--primary); }
.step > svg.i:last-child { color: var(--muted); }
.oldest { display: flex; align-items: center; gap: 12px; margin-top: 12px; padding: 12px; border-radius: 14px; background: color-mix(in srgb, var(--accent) 10%, transparent); text-decoration: none; }
.oldest div { display: flex; flex-direction: column; line-height: 1.3; }
.oldest span { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--accent); font-weight: 600; }
.recent { display: grid; gap: 10px; }
.rec { display: flex; gap: 10px; align-items: flex-start; }
.rec .dot { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; flex: none; background: var(--primary-soft); color: var(--primary); font-weight: 700; font-size: 12px; }
.rec p { margin: 0; font-size: 14.5px; line-height: 1.4; }
.rec small { display: block; color: var(--muted); font-size: 12.5px; }
.contrib { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.contrib-chip { font-size: 13px; padding: 3px 10px; border-radius: 99px; background: var(--surface-2); color: var(--muted); font-weight: 500; }
.contrib-chip.me { background: var(--primary-soft); color: var(--primary); }
.quote { text-align: center; font: italic 500 17px/1.5 var(--serif); color: var(--muted); margin: 26px auto 0; max-width: 560px; }

/* ───────── Pastille non lus & compte (mobile) ───────── */
.nav a, .tabbar .ti { position: relative; }
.badge-dot { position: absolute; top: -4px; right: -8px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 99px; background: var(--danger); color: #fff; font: 700 11px/18px var(--font); font-style: normal; text-align: center; box-shadow: 0 0 0 2px var(--surface); }
.nav a .badge-dot { top: 2px; right: 2px; }
.tabbar .ti { display: inline-flex; }
.top-account { margin-left: auto; text-decoration: none; }
@media (min-width: 900px) { .top-account { display: none; } }

/* ───────── Messagerie ───────── */
.chat { display: grid; height: 100%; min-height: 0; }
.chat-list, .chat-conv { min-height: 0; }
.chat-list { overflow-y: auto; padding: 18px 12px 24px; background: var(--bg); }
.chat-conv { display: none; flex-direction: column; background: var(--surface); }
.chat.has-conv .chat-list { display: none; }
.chat.has-conv .chat-conv { display: flex; }
@media (min-width: 900px) {
  .chat { grid-template-columns: 360px 1fr; }
  .chat .chat-list, .chat.has-conv .chat-list { display: block; border-right: 1px solid var(--line); }
  .chat .chat-conv { display: flex; }
  .cc-back { display: none !important; }
}
.cl-head { padding: 0 6px 12px; }
.cl-head p { margin: 4px 0 0; font-size: 14px; }
.ol-row { display: flex; gap: 14px; overflow-x: auto; padding: 4px 6px 14px; }
.ol { display: flex; flex-direction: column; align-items: center; gap: 6px; text-decoration: none; font-size: 12.5px; font-weight: 500; width: 64px; flex: none; text-align: center; }
.ol span:last-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.cl-items { display: grid; grid-template-columns: minmax(0, 1fr); gap: 4px; }
.chat-list { overflow-x: hidden; }
.cl-item { display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: 16px; text-decoration: none; }
.cl-item:hover { background: var(--surface-2); }
.cl-item.on { background: var(--primary-soft); }
.cl-item > div { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.3; }
.cl-item b { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cl-item span { font-size: 13.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cl-item.unread span { color: var(--ink); font-weight: 600; }
.cl-item small { font-size: 12px; color: var(--muted); flex: none; }
.cl-item .cnt { flex: none; min-width: 22px; height: 22px; padding: 0 7px; border-radius: 99px; background: var(--primary); color: var(--on-primary); font: 700 12px/22px var(--font); font-style: normal; text-align: center; }
.av-wrap { position: relative; display: inline-flex; flex: none; }
.av-wrap .online { position: absolute; right: -1px; bottom: -1px; width: 13px; height: 13px; border-radius: 50%; background: #3fb36b; box-shadow: 0 0 0 2.5px var(--bg); }
.chat-conv .av-wrap .online { box-shadow: 0 0 0 2.5px var(--surface); }
.room-ico { width: 44px; height: 44px; border-radius: 14px; flex: none; display: grid; place-items: center; background: color-mix(in srgb, var(--accent) 16%, transparent); color: var(--accent); }

.chat-empty { margin: auto; text-align: center; color: var(--muted); padding: 24px; max-width: 360px; }
.chat-empty svg.i, .cc-emptymsg svg.i { width: 44px; height: 44px; color: var(--line-strong); }
.chat-empty h2 { color: var(--ink); margin: 10px 0 6px; }
.cc-head { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-bottom: 1px solid var(--line); background: var(--surface); }
.cc-head > div { min-width: 0; display: flex; flex-direction: column; line-height: 1.3; }
.cc-head b { font-weight: 600; }
.cc-head span { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cc-back { margin-left: -6px; }
.cc-msgs { flex: 1; min-height: 0; overflow-y: auto; padding: 14px 14px 8px; display: flex; flex-direction: column; gap: 3px; background: var(--bg); }
.cc-emptymsg { margin: auto; text-align: center; color: var(--muted); max-width: 300px; }
.cc-day { text-align: center; margin: 14px 0 8px; }
.cc-day span { font-size: 12px; font-weight: 600; color: var(--muted); background: var(--surface-2); padding: 3px 12px; border-radius: 99px; text-transform: capitalize; }
.bubble-row { display: flex; }
.bubble-row:not(.cont) { margin-top: 6px; }
.bubble-row.mine { justify-content: flex-end; }
.bubble { max-width: min(78%, 560px); padding: 8px 12px 6px; border-radius: 18px 18px 18px 6px; background: var(--surface); border: 1px solid var(--line); box-shadow: 0 1px 1px rgba(0,0,0,.03); }
.bubble-row.mine .bubble { background: var(--primary); color: var(--on-primary); border-color: var(--primary); border-radius: 18px 18px 6px 18px; }
.bubble[data-del-msg] { cursor: pointer; }
.bubble .who { display: block; font-size: 12.5px; color: var(--accent); margin-bottom: 2px; }
.bubble p { margin: 0; white-space: pre-wrap; word-wrap: break-word; overflow-wrap: anywhere; }
.bubble time { display: block; text-align: right; font-size: 11px; opacity: .65; margin-top: 2px; }
.cc-input { display: flex; align-items: flex-end; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--line); background: var(--surface); }
.cc-input textarea { min-height: 46px !important; max-height: 140px; resize: none; border-radius: 22px !important; padding: 11px 16px !important; line-height: 1.4 !important; }
.cc-input .btn { border-radius: 50%; width: 46px; min-height: 46px; flex: none; }

/* ───────── Feuilles (bottom sheet) ───────── */
.sheet-wrap { position: fixed; inset: 0; z-index: 100; display: flex; align-items: flex-end; justify-content: center; }
.sheet-bg { position: absolute; inset: 0; background: rgba(20, 14, 8, .45); opacity: 0; transition: opacity .2s; }
.sheet {
  position: relative; width: 100%; max-width: 560px; max-height: 88dvh; display: flex; flex-direction: column;
  background: var(--surface); border-radius: 24px 24px 0 0; box-shadow: var(--shadow-lg);
  transform: translateY(100%); transition: transform .25s cubic-bezier(.2, .8, .2, 1);
  padding-bottom: env(safe-area-inset-bottom);
}
.sheet-wrap.open .sheet-bg { opacity: 1; }
.sheet-wrap.open .sheet { transform: none; }
@media (min-width: 640px) {
  .sheet-wrap { align-items: center; padding: 24px; }
  .sheet { border-radius: 24px; transform: translateY(20px) scale(.98); opacity: 0; transition: transform .2s, opacity .2s; }
  .sheet-wrap.open .sheet { opacity: 1; }
}
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 18px 18px 8px 22px; }
.sheet-body { padding: 8px 22px 22px; overflow-y: auto; }
.sheet-body .pick-list { display: grid; gap: 8px; margin-top: 12px; }
.choice-list { display: grid; gap: 10px; }
.choice { display: flex; align-items: center; gap: 14px; padding: 16px; border: 1px solid var(--line); border-radius: 16px; background: var(--bg); text-decoration: none; text-align: left; width: 100%; }
.choice:hover { border-color: var(--primary); background: var(--primary-soft); }
.choice > svg.i { width: 26px; height: 26px; color: var(--primary); }
.choice div { display: flex; flex-direction: column; }
.choice span { font-size: 14px; color: var(--muted); }
.choice.danger > svg.i, .choice.danger b { color: var(--danger); }
.sheet-actions { display: flex; gap: 10px; margin-top: 18px; }
.sheet-actions .btn { flex: 1; }

/* ───────── Visionneuse photo ───────── */
.lightbox { position: fixed; inset: 0; z-index: 110; background: rgba(10, 8, 6, .94); display: flex; flex-direction: column; color: #fff; animation: fadein .2s; }
.lb-top { display: flex; justify-content: space-between; align-items: center; padding: 12px; padding-top: max(12px, env(safe-area-inset-top)); }
.lb-top .icon-btn { color: #fff; }
.lb-top .icon-btn:hover { background: rgba(255,255,255,.12); }
.lb-img { flex: 1; min-height: 0; display: grid; place-items: center; padding: 0 12px; position: relative; }
.lb-img img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 8px; }
.lb-nav { position: absolute; top: 50%; transform: translateY(-50%); width: 48px; height: 48px; border-radius: 50%; border: 0; background: rgba(255,255,255,.14); color: #fff; display: grid; place-items: center; }
.lb-nav.prev { left: 12px; } .lb-nav.next { right: 12px; }
.lb-bottom { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; padding: 14px; padding-bottom: max(14px, env(safe-area-inset-bottom)); }
.lb-bottom .btn { background: rgba(255,255,255,.12); border-color: transparent; color: #fff; }
.lb-bottom .btn:hover { background: rgba(255,255,255,.22); }

/* ───────── Notifications ───────── */
#toasts { position: fixed; z-index: 200; left: 0; right: 0; top: calc(var(--top) + 10px); display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; padding: 0 16px; }
.toast { background: var(--ink); color: var(--bg); padding: 12px 18px; border-radius: 14px; font-weight: 500; font-size: 15px; box-shadow: var(--shadow-lg); animation: toastin .25s ease; transition: opacity .3s, transform .3s; max-width: 100%; }
.toast.ok { background: var(--primary); color: var(--on-primary); }
.toast.err { background: var(--danger); color: #fff; }
.toast.out { opacity: 0; transform: translateY(-8px); }
@keyframes toastin { from { opacity: 0; transform: translateY(-8px); } }
