/* ==========================================================
   ARBRE GÉNÉALOGIQUE — style.css
   ========================================================== */

:root {
  /* Palette principale — Parchemin */
  --bg-deep:        #faf3e8;
  --bg-primary:     #fdf6ed;
  --bg-secondary:   #f0e4cc;
  --bg-card:        #fff8ec;
  --bg-card-hover:  #fef3e0;
  --bg-panel:       #f7edd8;

  /* Brun & accents — Parchemin */
  --gold:           #8b4513;
  --gold-light:     #b5622a;
  --gold-dark:      #5c2d0a;
  --gold-muted:     #c4a882;
  --gold-glow:      rgba(139,69,19,0.12);

  /* Genres */
  --male:           #2e7fc4;
  --male-light:     #4fa3e8;
  --male-bg:        rgba(46,127,196,0.10);
  --female:         #b8427a;
  --female-light:   #e06698;
  --female-bg:      rgba(184,66,122,0.10);
  --unknown-color:  #8a7560;

  /* État */
  --accent-green:   #3a7d44;
  --accent-red:     #c0392b;
  --accent-blue:    #2980b9;
  --accent-orange:  #c87d1a;

  /* Bordures & texte */
  --border:         #d4c4a8;
  --border-hover:   #b8a080;
  --text-primary:   #2c1a0a;
  --text-secondary: #6b4c2a;
  --text-muted:     #a07850;
  --text-accent:    var(--gold);

  /* Effets */
  --shadow-sm:  0 2px 8px rgba(100,60,20,0.15);
  --shadow-md:  0 4px 20px rgba(100,60,20,0.20);
  --shadow-lg:  0 8px 40px rgba(100,60,20,0.30);
  --shadow-gold: 0 0 24px rgba(139,69,19,0.20);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 22px;

  --panel-width:   380px;
  --header-height: 62px;
  --transition:    all 0.2s ease;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  width: 100%;
  height: 100%;
  height: 100dvh; /* iOS Safari : hauteur réelle sans la barre du navigateur */
  overflow: hidden;
  font-family: 'Inter', sans-serif;
  background: var(--bg-deep);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
}

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

/* ============================================================
   HEADER
   ============================================================ */
#header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--header-height);
  padding: 0 1.4rem;
  background: linear-gradient(180deg, var(--bg-deep) 0%, var(--bg-secondary) 100%);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 2px 16px rgba(100,60,20,0.18);
  z-index: 100;
  flex-shrink: 0;
  gap: 1rem;
}

.header-left {
  display: flex; align-items: center; gap: 0.75rem; flex-shrink: 0;
}

.header-tree-icon {
  font-size: 1.7rem;
  filter: drop-shadow(0 0 8px rgba(139,69,19,0.45));
}

#family-title {
  font-family: 'Playfair Display', serif;
  font-size: 1.25rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--gold-light), var(--gold));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: 0.3px;
  white-space: nowrap;
}

.header-center { flex: 1; max-width: 380px; }

.search-box {
  position: relative;
  display: flex;
  align-items: center;
}

/* Dropdown résultats de recherche */
.search-dropdown {
  position: absolute;
  top: calc(100% + 5px);
  left: 0; right: 0;
  background: var(--bg-card);
  border: 1px solid var(--border-hover);
  border-radius: var(--radius-md);
  z-index: 9999;
  list-style: none;
  max-height: 280px;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: dropIn 0.14s ease;
}
.search-dropdown.hidden { display: none; }

.search-result-item {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.55rem 0.85rem;
  cursor: pointer;
  transition: var(--transition);
  border-bottom: 1px solid rgba(0,0,0,0.06);
}
.search-result-item:last-child { border-bottom: none; }
.search-result-item:hover,
.search-result-item.sr-active { background: rgba(139,69,19,0.08); }

.search-result-avatar {
  width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.72rem; font-weight: 700;
  font-family: 'Playfair Display', serif;
}
.search-result-avatar.sr-male   { background: var(--male-bg); color: var(--male-light); }
.search-result-avatar.sr-female { background: var(--female-bg); color: var(--female-light); }
.search-result-avatar.sr-unknown { background: rgba(0,0,0,0.06); color: var(--text-muted); }

.search-result-info { flex: 1; min-width: 0; }
.search-result-name {
  display: block;
  font-size: 0.82rem; color: var(--text-primary);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.search-result-name strong { color: var(--gold); font-weight: 700; }
.search-result-sub {
  display: block;
  font-size: 0.68rem; color: var(--text-muted);
  margin-top: 1px;
}

.search-icon {
  position: absolute; left: 11px;
  font-size: 0.8rem;
  color: var(--text-muted);
  pointer-events: none;
}

#search-input {
  width: 100%;
  padding: 0.45rem 2.4rem 0.45rem 2.1rem;
  background: rgba(0,0,0,0.04);
  border: 1px solid var(--border);
  border-radius: 20px;
  color: var(--text-primary);
  font-size: 0.82rem;
  transition: var(--transition);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}

#search-input:focus {
  outline: none;
  border-color: var(--gold-dark);
  background: rgba(0,0,0,0.06);
  box-shadow: 0 0 0 3px rgba(139,69,19,0.1);
}

.search-clear {
  position: absolute; right: 9px;
  background: none; border: none;
  color: var(--text-muted); cursor: pointer;
  font-size: 0.72rem; padding: 2px 4px;
  transition: var(--transition);
}
.search-clear:hover { color: var(--text-primary); }

.header-right {
  display: flex; align-items: center; gap: 0.9rem; flex-shrink: 0;
}

.zoom-controls {
  display: flex;
  background: rgba(0,0,0,0.04);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.zoom-controls button {
  background: none; border: none;
  color: var(--text-secondary);
  padding: 0.35rem 0.75rem;
  font-size: 1rem; cursor: pointer;
  transition: var(--transition); line-height: 1;
}

.zoom-controls button:hover {
  background: rgba(0,0,0,0.07);
  color: var(--gold);
}

.zoom-controls button + button { border-left: 1px solid var(--border); }

.btn-admin {
  background: linear-gradient(135deg, var(--gold-dark) 0%, var(--gold) 100%);
  color: #fff8ec;
  border: none;
  padding: 0.42rem 1.1rem;
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-size: 0.82rem;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
  letter-spacing: 0.3px;
  box-shadow: 0 2px 8px rgba(139,69,19,0.2);
}

.btn-admin:hover {
  filter: brightness(1.12);
  transform: translateY(-1px);
  box-shadow: var(--shadow-gold);
}

/* ============================================================
   TREE CONTAINER & BACKGROUND
   ============================================================ */
#tree-container {
  flex: 1;
  position: relative;
  overflow: hidden;
  background: #b8956a;
}

/* Grille de points discrets (subtile, par-dessus la texture) */
#tree-container::before {
  content: '';
  position: absolute; inset: 0;
  background-image: radial-gradient(circle, rgba(100,80,60,0.06) 1px, transparent 1px);
  background-size: 28px 28px;
  pointer-events: none;
  z-index: 0;
}

#tree-svg {
  width: 100%; height: 100%;
  display: block;
  position: relative; z-index: 1;
}

/* ============================================================
   TREE — NODE CARDS (foreignObject)
   ============================================================ */
.person-fo-card {
  background: #fff8ec;
  border: 1px solid #b8936a;
  border-radius: var(--radius-md);
  padding: 7px 9px 7px 0;
  display: flex;
  align-items: center;
  gap: 0;
  width: 152px;
  height: 80px;
  overflow: hidden;
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
  cursor: pointer;
  user-select: none;
  position: relative;
  /* iOS Safari foreignObject rendering fix */
  -webkit-transform: translateZ(0);
  transform: translateZ(0);
  will-change: transform;
  box-shadow: 0 4px 16px rgba(100,60,20,0.18), 0 1px 0 rgba(255,255,255,0.6) inset;
}

/* Left colored bar */
.person-fo-card::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3.5px;
  border-radius: var(--radius-md) 0 0 var(--radius-md);
}

.person-fo-card.male-card::before   { background: linear-gradient(180deg, var(--male-light), var(--male)); }
.person-fo-card.female-card::before { background: linear-gradient(180deg, var(--female-light), var(--female)); }
.person-fo-card.unknown-card::before { background: var(--unknown-color); }

.person-fo-card:hover {
  border-color: var(--gold-dark);
  transform: translateY(-2px) scale(1.015);
  box-shadow: 0 6px 20px rgba(100,60,20,0.25), 0 0 12px rgba(139,69,19,0.12);
}

.person-fo-card.deceased-card {
  opacity: 0.72;
  filter: grayscale(0.3);
}

.person-fo-card.highlighted {
  border-color: var(--gold) !important;
  box-shadow: 0 0 16px rgba(139,69,19,0.3) !important;
}

/* Photo circle */
.card-photo {
  width: 44px; height: 44px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  border: 2px solid rgba(0,0,0,0.10);
  margin-left: 10px; margin-right: 8px;
  background: var(--bg-secondary);
  position: relative;
  z-index: 1;
}

.card-photo img {
  width: 100%; height: 100%;
  object-fit: cover;
}

.card-photo-male   { background: linear-gradient(135deg, var(--male-bg), rgba(46,127,196,0.04)); }
.card-photo-female { background: linear-gradient(135deg, var(--female-bg), rgba(184,66,122,0.04)); }
.card-photo-unknown { background: var(--bg-secondary); }

.card-initials {
  font-family: 'Playfair Display', serif;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.card-initials-male   { color: var(--male-light); }
.card-initials-female { color: var(--female-light); }
.card-initials-unknown { color: var(--text-muted); }

.card-info {
  flex: 1; min-width: 0; overflow: hidden;
  padding-right: 6px;
}

.card-firstname {
  font-size: 0.79rem; font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  line-height: 1.25;
}

.card-lastname {
  font-family: 'Playfair Display', serif;
  font-size: 0.73rem;
  font-weight: 700;
  color: var(--gold);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  line-height: 1.3;
}

.card-dates {
  font-size: 0.62rem;
  color: var(--text-muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  line-height: 1.4;
  margin-top: 1px;
}

.card-location {
  font-size: 0.6rem;
  color: var(--text-muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* ============================================================
   TREE — LINKS (SVG paths)
   ============================================================ */
.link {
  fill: none;
  stroke: url(#linkGradient);
  stroke-width: 1.8;
  opacity: 0.55;
}

/* Collapse toggle */
.collapse-btn {
  cursor: pointer;
  fill: var(--bg-card);
  stroke: var(--gold-dark);
  stroke-width: 1.5;
  transition: fill 0.15s ease;
}

.collapse-btn:hover { fill: var(--gold-dark); }

.collapse-btn-text {
  fill: var(--gold);
  font-size: 9px; font-weight: 700;
  text-anchor: middle; dominant-baseline: central;
  pointer-events: none;
}

/* ============================================================
   WELCOME SCREEN
   ============================================================ */
#welcome-screen {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  z-index: 10;
}

#welcome-screen.hidden { display: none; }

.welcome-bg {
  position: absolute; inset: 0;
  background: radial-gradient(ellipse at center, rgba(139,69,19,0.07) 0%, transparent 65%);
  pointer-events: none;
}

.welcome-content {
  text-align: center;
  max-width: 460px;
  padding: 3rem 2.5rem;
  background: linear-gradient(145deg, var(--bg-card) 0%, var(--bg-primary) 100%);
  border: 1px solid var(--border-hover);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg), inset 0 1px 0 rgba(255,255,255,0.5);
  position: relative; z-index: 1;
}

.welcome-tree {
  font-size: 4.5rem;
  margin-bottom: 1.2rem;
  filter: drop-shadow(0 0 18px rgba(139,69,19,0.4));
  animation: floatTree 3s ease-in-out infinite;
}

@keyframes floatTree {
  0%, 100% { transform: translateY(0); }
  50%       { transform: translateY(-8px); }
}

.welcome-content h2 {
  font-family: 'Playfair Display', serif;
  font-size: 1.6rem;
  background: linear-gradient(135deg, var(--gold-light), var(--gold));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 0.9rem;
  line-height: 1.3;
}

.welcome-content p {
  color: var(--text-secondary);
  font-size: 0.92rem;
  line-height: 1.65;
  margin-bottom: 1.8rem;
}

/* ============================================================
   LEGEND & MINI CONTROLS
   ============================================================ */
#legend {
  position: absolute; bottom: 18px; left: 18px;
  background: rgba(255,248,236,0.92);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.55rem 1rem;
  display: flex; gap: 1.1rem;
  font-size: 0.72rem; color: var(--text-muted);
  box-shadow: var(--shadow-sm);
}

.legend-item { display: flex; align-items: center; gap: 0.4rem; }

.legend-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.legend-dot.male   { background: linear-gradient(135deg, var(--male-light), var(--male)); }
.legend-dot.female { background: linear-gradient(135deg, var(--female-light), var(--female)); }

.legend-line-sample {
  width: 22px; height: 1.5px;
  background: linear-gradient(90deg, var(--gold-dark), var(--gold));
  border-radius: 1px; flex-shrink: 0;
}

.legend-heart { color: var(--gold); font-size: 0.85rem; }

/* Bouton retour arbre complet (mode focus nucléaire) */
.btn-back-full-tree {
  position: absolute; top: 14px; left: 50%;
  transform: translateX(-50%);
  z-index: 50;
  background: rgba(255,248,236,0.96);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  border: 1.5px solid #b8936a;
  border-radius: 20px;
  color: var(--gold-dark);
  padding: 0.38rem 1.2rem;
  font-size: 0.83rem; font-weight: 600;
  cursor: pointer;
  box-shadow: 0 3px 14px rgba(100,60,20,0.22);
  transition: var(--transition);
  white-space: nowrap;
}
.btn-back-full-tree:hover {
  background: #fff8ec;
  border-color: var(--gold-dark);
  box-shadow: 0 4px 18px rgba(100,60,20,0.30);
}

/* ============================================================
   MODALS
   ============================================================ */
.modal {
  position: fixed; inset: 0;
  z-index: 200;
  display: flex; align-items: center; justify-content: center;
}

.modal.hidden { display: none; }

.modal-backdrop {
  position: absolute; inset: 0;
  background: rgba(0,0,0,0.65);
  -webkit-backdrop-filter: blur(5px);
  backdrop-filter: blur(5px);
}

.modal-card {
  position: relative;
  background: linear-gradient(145deg, var(--bg-card) 0%, var(--bg-primary) 100%);
  border: 1px solid var(--border-hover);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg), inset 0 1px 0 rgba(255,255,255,0.5);
  z-index: 1;
  max-height: 90vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  animation: modalIn 0.22s ease;
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.96) translateY(10px); }
  to   { opacity: 1; transform: scale(1)    translateY(0); }
}

.modal-close {
  position: sticky; top: 0.75rem;
  float: right; margin: 0.75rem 0.75rem 0 0;
  background: rgba(0,0,0,0.05);
  border: 1px solid var(--border);
  border-radius: 50%;
  color: var(--text-secondary);
  width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; font-size: 0.78rem;
  transition: var(--transition); z-index: 2;
}

.modal-close:hover { background: var(--accent-red); color: white; border-color: var(--accent-red); }

/* ---- Profile modal ---- */
.profile-card { width: min(540px, 95vw); padding: 0; }

#profile-content { padding: 1.6rem 1.8rem; }

.profile-header {
  display: flex; align-items: center; gap: 1.4rem;
  margin-bottom: 1.4rem;
  padding-bottom: 1.2rem;
  border-bottom: 1px solid var(--border);
}

.profile-photo-large {
  width: 96px; height: 96px;
  border-radius: 50%; overflow: hidden; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  border: 3px solid var(--border-hover);
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
  background: var(--bg-secondary);
}

.profile-photo-large img { width: 100%; height: 100%; object-fit: cover; }

.initials-large {
  font-family: 'Playfair Display', serif;
  font-size: 2.1rem; font-weight: 700; color: var(--text-muted);
}

.profile-main-info h2 {
  font-family: 'Playfair Display', serif;
  font-size: 1.45rem; color: var(--text-primary);
  line-height: 1.25;
}

.profile-main-info .maiden {
  font-size: 0.83rem; color: var(--text-muted);
  font-style: italic; margin-top: 3px;
}

.profile-gender-badge {
  display: inline-block;
  padding: 2px 11px; border-radius: 10px;
  font-size: 0.68rem; font-weight: 600;
  margin-top: 6px; text-transform: uppercase; letter-spacing: 0.6px;
}

.profile-gender-badge.male    { background: var(--male-bg); color: var(--male-light); }
.profile-gender-badge.female  { background: var(--female-bg); color: var(--female-light); }
.profile-gender-badge.unknown { background: rgba(74,85,104,0.3); color: var(--text-muted); }

.profile-details {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 0.7rem; margin-bottom: 1rem;
}

.profile-detail-item {
  background: rgba(0,0,0,0.025);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.85rem;
  transition: var(--transition);
}

.profile-detail-item:hover { border-color: var(--border-hover); }

.profile-detail-item label {
  display: block;
  font-size: 0.62rem; text-transform: uppercase;
  letter-spacing: 0.8px; color: var(--text-muted);
  margin-bottom: 3px;
}

.profile-detail-item span { font-size: 0.84rem; color: var(--text-primary); }
.profile-detail-item.full-width { grid-column: 1 / -1; }

/* Unions multiples */
.profile-unions {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-bottom: 1rem;
}

.profile-union-block {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.7rem 0.85rem;
  background: rgba(0,0,0,0.02);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.union-ordinal {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  color: var(--gold);
  background: rgba(139,69,19,0.1);
  border: 1px solid rgba(139,69,19,0.2);
  border-radius: 10px;
  padding: 1px 9px;
  align-self: flex-start;
}

.profile-union-block .profile-details {
  margin-bottom: 0;
}

.profile-union-block .profile-detail-item {
  background: transparent;
  border: none;
  padding: 0.2rem 0;
}

/* ---- Lien extra-union (pointillé) ---- */
.link-extra {
  stroke: #9b6fba;
  stroke-dasharray: 6 4;
  opacity: 0.6;
}

/* ---- Nœud extra-union ---- */
.extra-union-label {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(155,111,186,0.18);
  border: 1px solid rgba(155,111,186,0.35);
  border-radius: 6px 6px 0 0;
  padding: 2px 8px;
  font-size: 0.62rem;
  font-weight: 700;
  color: #c99ee8;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.extra-union-year {
  color: rgba(201,158,232,0.7);
  font-weight: 400;
}

.extra-union-person-card {
  border-style: dashed !important;
}

/* ---- Cartes plus larges (texte qui se coupe moins) ---- */
.person-fo-card {
  width: 172px !important;
}

.card-firstname,
.card-lastname {
  white-space: normal !important;
  overflow: visible !important;
  text-overflow: unset !important;
  word-break: break-word;
  line-height: 1.2;
}

/* ---- Double étiquette (les deux conjoints à leur Nème union) ---- */
.extra-union-label-dual {
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding: 3px 8px;
}

.dual-union-row {
  display: flex;
  align-items: center;
  gap: 5px;
  width: 100%;
}

.dual-union-row-spouse {
  opacity: 0.85;
}

.dual-union-num {
  font-weight: 700;
  font-size: 0.60rem;
  white-space: nowrap;
}

.dual-union-name {
  font-weight: 600;
  font-size: 0.60rem;
  color: #c99ee8;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---- Divorcé ---- */
.extra-union-label-divorced {
  background: rgba(176,96,96,0.18);
  border-color: rgba(176,96,96,0.35);
  color: #d09090;
}

.extra-union-divorced {
  margin-left: auto;
  font-size: 0.7rem;
  color: #d07070;
  font-weight: 700;
}

.relation-card-divorced {
  border-color: rgba(176,96,96,0.3);
}

.relation-card-divorced .relation-card-header {
  background: rgba(176,96,96,0.08);
}

.rel-divorced-badge {
  font-size: 0.62rem;
  background: rgba(176,96,96,0.2);
  border: 1px solid rgba(176,96,96,0.3);
  border-radius: 8px;
  padding: 1px 7px;
  color: #d07070;
  font-weight: 400;
}

/* Toggle switch pour divorcé */
.rel-divorced-toggle {
  position: relative;
  display: inline-block;
  width: 32px;
  height: 18px;
  flex-shrink: 0;
  cursor: pointer;
}

.rel-divorced-toggle input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}

.rel-divorced-slider {
  position: absolute;
  inset: 0;
  background: var(--border);
  border-radius: 18px;
  transition: 0.2s;
}

.rel-divorced-slider::before {
  content: '';
  position: absolute;
  width: 12px; height: 12px;
  left: 3px; top: 3px;
  background: white;
  border-radius: 50%;
  transition: 0.2s;
}

.rel-divorced-toggle input:checked + .rel-divorced-slider {
  background: #b06060;
}

.rel-divorced-toggle input:checked + .rel-divorced-slider::before {
  transform: translateX(14px);
}

/* ---- Boutons de réordonnancement unions ---- */
.rel-order-btns {
  display: flex;
  flex-direction: column;
  gap: 1px;
  margin-right: 4px;
}

.btn-rel-order {
  background: none;
  border: 1px solid var(--border);
  border-radius: 3px;
  color: var(--text-muted);
  width: 20px;
  height: 16px;
  font-size: 0.65rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  line-height: 1;
}

.btn-rel-order:hover {
  background: var(--bg-card-hover);
  color: var(--gold);
  border-color: var(--gold-dark);
}

/* Badge plusieurs unions sur la carte */
.card-multi-union {
  font-size: 0.62rem;
  font-weight: 700;
  background: rgba(155,111,186,0.18);
  border: 1px solid rgba(155,111,186,0.40);
  border-radius: 8px;
  padding: 1px 6px;
  color: #9b6fba;
  vertical-align: middle;
  letter-spacing: 0.2px;
}

.profile-bio {
  background: rgba(0,0,0,0.025);
  border: 1px solid var(--border);
  border-left: 3px solid var(--gold-dark);
  border-radius: var(--radius-sm);
  padding: 0.9rem;
  margin-bottom: 1rem;
  font-size: 0.85rem; color: var(--text-secondary);
  line-height: 1.55; font-style: italic;
}

.profile-actions-bar {
  display: flex; gap: 0.6rem; flex-wrap: wrap;
  padding-top: 0.8rem;
  border-top: 1px solid var(--border);
}

/* ---- Login modal ---- */
.login-card { width: min(380px, 95vw); padding: 2.2rem; text-align: center; }
.login-icon { font-size: 2.8rem; margin-bottom: 0.9rem; }
.login-card h2 { font-family: 'Playfair Display', serif; color: var(--gold); margin-bottom: 0.5rem; font-size: 1.4rem; }
.login-card p { color: var(--text-secondary); font-size: 0.85rem; margin-bottom: 1.1rem; line-height: 1.5; }
.login-card input { margin-bottom: 0.8rem; }
.login-hint { margin-top: 1rem; font-size: 0.75rem; color: var(--text-muted); }

/* ============================================================
   ADMIN SIDE PANEL
   ============================================================ */
.side-panel {
  position: fixed; top: 0; right: 0;
  width: var(--panel-width); height: 100%;
  background: var(--bg-panel);
  border-left: 1px solid var(--border);
  box-shadow: -6px 0 30px rgba(0,0,0,0.5);
  z-index: 150;
  display: flex; flex-direction: column; overflow: hidden;
  transform: translateX(0);
  transition: transform 0.3s cubic-bezier(.4,0,.2,1);
}

.side-panel.hidden {
  transform: translateX(calc(100% + 6px));
  pointer-events: none;
}

.panel-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1.1rem 1.3rem;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, var(--bg-deep) 0%, var(--bg-secondary) 100%);
  flex-shrink: 0;
}

.panel-header h2 {
  font-family: 'Playfair Display', serif;
  font-size: 1.05rem;
  background: linear-gradient(135deg, var(--gold-light), var(--gold));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.panel-close-btn {
  background: none; border: 1px solid var(--border); border-radius: 50%;
  color: var(--text-secondary); width: 28px; height: 28px;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  font-size: 0.78rem; transition: var(--transition);
}
.panel-close-btn:hover { background: var(--accent-red); color: white; border-color: var(--accent-red); }

.panel-tabs {
  display: flex; border-bottom: 1px solid var(--border);
  background: var(--bg-secondary); flex-shrink: 0;
}

.tab-btn {
  flex: 1; background: none; border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  padding: 0.65rem 0.3rem;
  font-size: 0.8rem; font-weight: 500;
  cursor: pointer; transition: var(--transition);
}
.tab-btn:hover { color: var(--text-secondary); background: rgba(0,0,0,0.03); }
.tab-btn.active { color: var(--gold); border-bottom-color: var(--gold); }

.tab-content { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 1rem 1.3rem; }
.tab-content.hidden { display: none; }

.tab-title {
  font-family: 'Playfair Display', serif;
  font-size: 0.95rem; color: var(--text-primary);
  margin-bottom: 0.45rem; margin-top: 0.2rem;
}

.tab-desc { font-size: 0.78rem; color: var(--text-muted); margin-bottom: 1rem; line-height: 1.45; }
.tab-actions { margin-bottom: 0.9rem; }

/* ============================================================
   FORMS
   ============================================================ */
.form-group { margin-bottom: 0.82rem; }

.form-group label {
  display: block; font-size: 0.73rem; font-weight: 600;
  color: var(--text-secondary); margin-bottom: 0.3rem;
  text-transform: uppercase; letter-spacing: 0.5px;
}

.required { color: var(--accent-red); }

input[type="text"],
input[type="password"],
input[type="url"],
input[type="email"],
select, textarea {
  width: 100%;
  background: rgba(0,0,0,0.04);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  padding: 0.5rem 0.75rem;
  font-size: 0.83rem;
  font-family: 'Inter', sans-serif;
  transition: var(--transition);
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--gold-dark);
  background: rgba(0,0,0,0.06);
  box-shadow: 0 0 0 3px rgba(139,69,19,0.1);
}

input::placeholder, textarea::placeholder { color: var(--text-muted); }
select option { background: var(--bg-primary); }
textarea { resize: vertical; min-height: 64px; }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.7rem; }

.form-actions {
  display: flex; gap: 0.6rem; margin-top: 1rem;
  padding-top: 0.9rem; border-top: 1px solid var(--border);
}

.form-header {
  display: flex; align-items: center; gap: 0.9rem;
  margin-bottom: 1.1rem; padding-bottom: 0.85rem;
  border-bottom: 1px solid var(--border);
}
.form-header h3 { font-family: 'Playfair Display', serif; font-size: 0.95rem; color: var(--gold); }

.photo-input-row { display: flex; gap: 0.4rem; }
.photo-input-row input { flex: 1; }

.btn-upload {
  background: rgba(0,0,0,0.04); border: 1px solid var(--border); border-radius: var(--radius-sm);
  color: var(--text-secondary); padding: 0.4rem 0.65rem;
  cursor: pointer; font-size: 0.9rem;
  display: flex; align-items: center; transition: var(--transition);
}
.btn-upload:hover { background: rgba(0,0,0,0.07); color: var(--text-primary); }

.photo-preview { margin-top: 0.5rem; }
.photo-preview img { width: 60px; height: 60px; border-radius: 50%; object-fit: cover; border: 2px solid var(--border); }

.fb-input-row { display: flex; gap: 0.4rem; }
.fb-input-row input { flex: 1; }

.btn-fb {
  background: #0077b5;
  border: none; border-radius: var(--radius-sm);
  color: white; padding: 0.4rem 0.75rem;
  font-size: 0.75rem; font-weight: 700;
  cursor: pointer; white-space: nowrap; transition: var(--transition);
}
.btn-fb:hover { filter: brightness(1.15); }

/* ============================================================
   PERSON LIST
   ============================================================ */
#admin-search { margin-bottom: 0.75rem; }

#persons-list { display: flex; flex-direction: column; gap: 0.4rem; }

.person-list-item {
  display: flex; align-items: center; gap: 0.65rem;
  background: rgba(0,0,0,0.025);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.55rem 0.75rem;
  transition: var(--transition);
}
.person-list-item:hover { border-color: var(--border-hover); background: rgba(0,0,0,0.04); }

.person-list-photo {
  width: 33px; height: 33px; border-radius: 50%;
  background: var(--bg-secondary);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.72rem; font-weight: 700; color: var(--text-muted);
  flex-shrink: 0; overflow: hidden; border: 1px solid var(--border);
}
.person-list-photo img { width: 100%; height: 100%; object-fit: cover; }

.person-list-info { flex: 1; min-width: 0; }
.person-list-name { font-size: 0.82rem; font-weight: 500; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.person-list-sub  { font-size: 0.7rem; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.person-list-actions { display: flex; gap: 0.3rem; flex-shrink: 0; }

.btn-icon {
  background: none; border: 1px solid var(--border); border-radius: var(--radius-sm);
  color: var(--text-muted); width: 26px; height: 26px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; font-size: 0.72rem; transition: var(--transition);
}
.btn-icon:hover { background: rgba(0,0,0,0.05); color: var(--text-primary); }
.btn-icon.btn-edit:hover   { border-color: var(--accent-blue); color: var(--accent-blue); }
.btn-icon.btn-delete:hover { border-color: var(--accent-red); color: var(--accent-red); }

/* Relations list */
#relations-list { display: flex; flex-direction: column; gap: 0.4rem; }

.relation-item {
  background: rgba(0,0,0,0.025);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 0.5rem 0.75rem;
  font-size: 0.8rem; color: var(--text-secondary);
  display: flex; align-items: center; justify-content: space-between; gap: 0.5rem;
}

.relation-badge {
  font-size: 0.63rem;
  background: rgba(0,0,0,0.04);
  border: 1px solid var(--border);
  border-radius: 10px; padding: 1px 8px;
  color: var(--text-muted); white-space: nowrap;
}

/* ============================================================
   CONTEXT MENU
   ============================================================ */
#context-menu {
  position: fixed; z-index: 300;
  background: linear-gradient(145deg, var(--bg-card), var(--bg-primary));
  border: 1px solid var(--border-hover);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  min-width: 210px; overflow: hidden;
  animation: ctxIn 0.15s ease;
}

@keyframes ctxIn {
  from { opacity: 0; transform: scale(0.95); }
  to   { opacity: 1; transform: scale(1); }
}

#context-menu.hidden { display: none; }

.ctx-header {
  padding: 0.65rem 1rem;
  background: rgba(139,69,19,0.08);
  font-family: 'Playfair Display', serif;
  font-size: 0.85rem; font-weight: 600;
  color: var(--gold);
  border-bottom: 1px solid var(--border);
}

#context-menu ul { list-style: none; padding: 0.35rem 0; }

#context-menu li {
  padding: 0.52rem 1rem;
  font-size: 0.83rem; color: var(--text-secondary);
  cursor: pointer; transition: var(--transition);
  display: flex; align-items: center; gap: 0.55rem;
}

#context-menu li:hover { background: rgba(0,0,0,0.05); color: var(--text-primary); }
#context-menu li.ctx-danger { color: var(--accent-red); }
#context-menu li.ctx-danger:hover { background: rgba(248,81,73,0.08); }

/* ============================================================
   BUTTONS
   ============================================================ */
.btn-primary {
  background: linear-gradient(135deg, var(--gold-dark) 0%, var(--gold) 100%);
  color: #fff8ec; border: none; border-radius: var(--radius-sm);
  padding: 0.5rem 1.15rem; font-size: 0.83rem; font-weight: 700;
  cursor: pointer; transition: var(--transition);
  letter-spacing: 0.2px;
  box-shadow: 0 2px 8px rgba(139,69,19,0.15);
}
.btn-primary:hover { filter: brightness(1.1); transform: translateY(-1px); box-shadow: var(--shadow-gold); }

.btn-secondary {
  background: rgba(0,0,0,0.04);
  color: var(--text-secondary);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 0.5rem 1.1rem; font-size: 0.83rem; font-weight: 500;
  cursor: pointer; transition: var(--transition);
  display: inline-flex; align-items: center; gap: 0.3rem;
}
.btn-secondary:hover { background: rgba(0,0,0,0.07); color: var(--text-primary); border-color: var(--border-hover); }

.btn-warning {
  background: rgba(210,153,34,0.1); color: var(--accent-orange);
  border: 1px solid rgba(210,153,34,0.25); border-radius: var(--radius-sm);
  padding: 0.5rem 1.1rem; font-size: 0.83rem; font-weight: 500;
  cursor: pointer; transition: var(--transition);
}
.btn-warning:hover { background: rgba(210,153,34,0.18); }

.btn-danger {
  background: rgba(248,81,73,0.08); color: var(--accent-red);
  border: 1px solid rgba(248,81,73,0.25); border-radius: var(--radius-sm);
  padding: 0.5rem 1.1rem; font-size: 0.83rem; font-weight: 500;
  cursor: pointer; transition: var(--transition);
}
.btn-danger:hover { background: rgba(248,81,73,0.16); }

.btn-full { width: 100%; }

.btn-large { padding: 0.75rem 1.9rem; font-size: 1rem; border-radius: var(--radius-md); }

.btn-back {
  background: none; border: none; color: var(--text-muted);
  font-size: 0.8rem; cursor: pointer; padding: 0.2rem; transition: var(--transition);
}
.btn-back:hover { color: var(--gold); }

.btn-row { display: flex; gap: 0.6rem; }
.btn-row > * { flex: 1; justify-content: center; }

/* ============================================================
   MISC
   ============================================================ */
.hidden { display: none !important; }

.error-msg {
  background: rgba(248,81,73,0.1); border: 1px solid rgba(248,81,73,0.25);
  border-radius: var(--radius-sm); color: var(--accent-red);
  padding: 0.5rem 0.75rem; font-size: 0.8rem; margin-bottom: 0.65rem;
}

.info-msg {
  background: rgba(63,185,80,0.1); border: 1px solid rgba(63,185,80,0.25);
  border-radius: var(--radius-sm); color: var(--accent-green);
  padding: 0.5rem 0.75rem; font-size: 0.8rem; margin-top: 0.65rem;
}

.divider { border: none; border-top: 1px solid var(--border); margin: 1.1rem 0; }

.danger-zone {
  padding: 0.9rem;
  background: rgba(248,81,73,0.04);
  border: 1px solid rgba(248,81,73,0.12);
  border-radius: var(--radius-sm);
}
.danger-zone h3 { font-size: 0.82rem; color: var(--accent-red); margin-bottom: 0.65rem; }

/* ============================================================
   TOAST NOTIFICATIONS
   ============================================================ */
#toast-container {
  position: fixed; bottom: 1.6rem; left: 50%;
  transform: translateX(-50%);
  z-index: 500; display: flex; flex-direction: column;
  gap: 0.5rem; pointer-events: none;
}

.toast {
  background: linear-gradient(145deg, var(--bg-card), var(--bg-primary));
  border: 1px solid var(--border-hover);
  border-radius: var(--radius-md);
  padding: 0.65rem 1.3rem;
  font-size: 0.83rem; color: var(--text-primary);
  box-shadow: var(--shadow-md);
  animation: toastIn 0.25s ease, toastOut 0.3s ease 2.7s forwards;
  white-space: nowrap;
}

.toast.success { border-left: 3px solid var(--accent-green); }
.toast.error   { border-left: 3px solid var(--accent-red); }
.toast.info    { border-left: 3px solid var(--gold); }

@keyframes toastIn  { from { opacity:0; transform: translateY(12px); } to { opacity:1; transform:translateY(0); } }
@keyframes toastOut { from { opacity:1; } to { opacity:0; } }

/* ============================================================
   RELATION CARDS (modifier les relations)
   ============================================================ */
.relation-card {
  background: rgba(0,0,0,0.025);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  margin-bottom: 0.6rem;
}

.relation-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.55rem 0.85rem;
  background: rgba(139,69,19,0.06);
  border-bottom: 1px solid var(--border);
}

.relation-card-title {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--gold);
  font-family: 'Playfair Display', serif;
}

.btn-rel-delete {
  background: none;
  border: 1px solid rgba(248,81,73,0.25);
  border-radius: var(--radius-sm);
  color: var(--accent-red);
  font-size: 0.7rem;
  padding: 2px 8px;
  cursor: pointer;
  transition: var(--transition);
}
.btn-rel-delete:hover { background: rgba(248,81,73,0.1); }

.relation-card-section {
  padding: 0.5rem 0.85rem;
  border-bottom: 1px solid rgba(0,0,0,0.06);
}
.relation-card-section:last-child { border-bottom: none; }

.relation-section-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
}

.rel-member-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.25rem 0;
}

.rel-member-icon { font-size: 0.85rem; flex-shrink: 0; }

.rel-member-name {
  flex: 1;
  font-size: 0.8rem;
  color: var(--text-primary);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.btn-rel-remove {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 0.65rem;
  width: 22px; height: 22px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: var(--transition);
  flex-shrink: 0;
}
.btn-rel-remove:hover {
  background: rgba(248,81,73,0.1);
  border-color: rgba(248,81,73,0.4);
  color: var(--accent-red);
}

.rel-empty {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-style: italic;
}

/* ============================================================
   CITY AUTOCOMPLETE
   ============================================================ */
.autocomplete-wrapper {
  position: relative;
  width: 100%;
}

.autocomplete-dropdown {
  position: absolute;
  top: calc(100% + 3px);
  left: 0; right: 0;
  background: linear-gradient(145deg, var(--bg-card), var(--bg-primary));
  border: 1px solid var(--border-hover);
  border-radius: var(--radius-sm);
  z-index: 9999;
  list-style: none;
  max-height: 220px;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: dropIn 0.14s ease;
}

@keyframes dropIn {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.autocomplete-dropdown.hidden { display: none; }

.autocomplete-item {
  padding: 0.52rem 0.85rem;
  font-size: 0.82rem;
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  border-bottom: 1px solid rgba(0,0,0,0.06);
}

.autocomplete-item:last-child { border-bottom: none; }

.autocomplete-item .ac-pin {
  font-size: 0.75rem;
  color: var(--gold-dark);
  flex-shrink: 0;
}

.autocomplete-item .ac-city {
  font-weight: 600;
  color: var(--text-primary);
}

.autocomplete-item .ac-country {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-left: auto;
}

.autocomplete-item:hover,
.autocomplete-item.ac-active {
  background: rgba(139,69,19,0.09);
  color: var(--text-primary);
}

.autocomplete-loading {
  padding: 0.6rem 0.85rem;
  font-size: 0.78rem;
  color: var(--text-muted);
  display: flex; align-items: center; gap: 0.5rem;
}

.ac-spinner {
  width: 12px; height: 12px;
  border: 2px solid var(--border);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================================
   SCROLLBAR
   ============================================================ */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: var(--bg-primary); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-hover); }

/* ============================================================
   TREE — ELBOW / SPINE LINKS
   ============================================================ */
.link-spine {
  fill: none;
  stroke: #3d1f0a;
  stroke-width: 1.8;
  opacity: 0.75;
}

/* ============================================================
   GUEST BUTTON (header)
   ============================================================ */
.btn-guest {
  background: linear-gradient(135deg, rgba(88,166,255,0.15), rgba(88,166,255,0.05));
  border: 1px solid rgba(88,166,255,0.3);
  color: var(--accent-blue);
  border-radius: var(--radius-sm);
  padding: 0.38rem 0.85rem;
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
}
.btn-guest:hover {
  background: rgba(88,166,255,0.22);
  border-color: var(--accent-blue);
}
.btn-guest.active {
  background: rgba(88,166,255,0.25);
  border-color: var(--accent-blue);
  color: #fff;
}

/* ============================================================
   REQUEST BADGE (admin tab)
   ============================================================ */
.req-badge {
  display: inline-block;
  background: var(--accent-red);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  border-radius: 10px;
  padding: 0 5px;
  min-width: 16px;
  text-align: center;
  vertical-align: middle;
  margin-left: 3px;
}

/* ============================================================
   REQUESTS FILTER BUTTONS
   ============================================================ */
.requests-filter {
  display: flex;
  gap: 4px;
  margin-bottom: 0.85rem;
  flex-wrap: wrap;
}
.req-filter-btn {
  flex: 1;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  padding: 0.3rem 0.4rem;
  font-size: 0.72rem;
  cursor: pointer;
  transition: var(--transition);
  text-align: center;
}
.req-filter-btn:hover { color: var(--text-secondary); border-color: var(--border-hover); }
.req-filter-btn.active { background: rgba(139,69,19,0.12); border-color: var(--gold); color: var(--gold); font-weight: 600; }

/* ============================================================
   REQUEST CARDS (admin + guest)
   ============================================================ */
.request-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.85rem;
  margin-bottom: 0.65rem;
  font-size: 0.8rem;
}
.request-card.req-pending  { border-left: 3px solid var(--accent-orange); }
.request-card.req-accepted { border-left: 3px solid var(--accent-green); opacity: 0.8; }
.request-card.req-rejected { border-left: 3px solid var(--accent-red);   opacity: 0.7; }

.request-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}
.req-person {
  font-weight: 600;
  color: var(--text-primary);
  font-size: 0.83rem;
}
.req-status {
  font-size: 0.72rem;
  color: var(--text-muted);
}
.req-date {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}
.req-note {
  margin-top: 6px;
  padding: 5px 8px;
  background: rgba(0,0,0,0.04);
  border-radius: 4px;
  color: var(--text-secondary);
  font-size: 0.75rem;
  font-style: italic;
}

/* ---- Diff rows (admin view) ---- */
.req-diff-row {
  padding: 4px 0;
  border-bottom: 1px solid rgba(0,0,0,0.06);
}
.req-diff-row:last-child { border-bottom: none; }
.req-diff-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  display: block;
  margin-bottom: 2px;
}
.req-diff-values {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.req-diff-old {
  color: var(--accent-red);
  text-decoration: line-through;
  font-size: 0.78rem;
  opacity: 0.8;
}
.req-diff-arrow { color: var(--text-muted); font-size: 0.7rem; }
.req-diff-new  { color: var(--accent-green); font-size: 0.78rem; font-weight: 500; }
.req-diff-new-only { color: var(--text-muted); font-size: 0.7rem; }

/* ---- Field rows (guest view) ---- */
.req-field-row {
  padding: 3px 0;
  font-size: 0.78rem;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  border-bottom: 1px solid rgba(0,0,0,0.06);
}
.req-field-row:last-child { border-bottom: none; }
.req-field-label { color: var(--text-muted); min-width: 110px; flex-shrink: 0; }
.req-field-value { color: var(--text-primary); }

/* ---- Accept/Reject buttons ---- */
.req-actions {
  display: flex;
  gap: 8px;
  margin-top: 0.6rem;
}
.btn-req-accept {
  flex: 1;
  padding: 0.35rem 0.6rem;
  background: rgba(63,185,80,0.15);
  border: 1px solid var(--accent-green);
  color: var(--accent-green);
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  cursor: pointer;
  transition: var(--transition);
}
.btn-req-accept:hover { background: rgba(63,185,80,0.28); }
.btn-req-reject {
  flex: 1;
  padding: 0.35rem 0.6rem;
  background: rgba(248,81,73,0.12);
  border: 1px solid var(--accent-red);
  color: var(--accent-red);
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  cursor: pointer;
  transition: var(--transition);
}
.btn-req-reject:hover { background: rgba(248,81,73,0.25); }

/* ============================================================
   GUEST SUGGESTION MODAL
   ============================================================ */
.suggest-card {
  width: min(560px, 95vw);
  max-height: 85vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 1.8rem 2rem;
}
.suggest-subtitle {
  color: var(--gold);
  font-weight: 600;
  margin: 0.3rem 0 1.2rem;
  font-size: 0.95rem;
  padding-top: 0.1rem;
}
.sug-field label { font-size: 0.8rem; }
.sug-current {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-style: italic;
  font-weight: 400;
}
.sug-empty {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-style: italic;
  font-weight: 400;
}
.sug-field select {
  width: 100%;
  padding: 0.45rem 0.7rem;
  background: var(--bg-input, var(--bg-card));
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 0.88rem;
  font-family: inherit;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23888' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.7rem center;
  padding-right: 2rem;
}

/* ============================================================
   PHOTO UPLOAD — bouton principal
   ============================================================ */
.btn-upload-main {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.42rem 0.9rem;
  background: rgba(139,69,19,0.08);
  border: 1px dashed rgba(139,69,19,0.4);
  border-radius: var(--radius-sm);
  color: var(--gold);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  width: 100%;
  justify-content: center;
}
.btn-upload-main:hover {
  background: rgba(139,69,19,0.15);
  border-color: var(--gold);
}

/* ============================================================
   ANIMATIONS MOBILE
   ============================================================ */
@keyframes slideUp {
  from { transform: translateY(40px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

/* ============================================================
   RESPONSIVE — MOBILE (≤ 768px)
   ============================================================ */
@media (max-width: 768px) {

  /* --- Header : 2 rangées --- */
  #header {
    flex-wrap: wrap;
    height: auto;
    padding: 0.55rem 0.9rem 0.5rem;
    gap: 0.45rem;
  }

  .header-left { flex: 1; }

  .header-tree-icon { font-size: 1.4rem; }

  #family-title {
    font-size: 1rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 160px;
  }

  /* Barre de recherche : pleine largeur sur la 2e rangée */
  .header-center {
    order: 3;
    flex: 0 0 100%;
    max-width: 100%;
  }

  #search-input { font-size: 16px; } /* évite le zoom iOS */

  .header-right { gap: 0.4rem; }

  /* Masquer les contrôles de zoom desktop (pinch sur mobile) */
  .zoom-controls { display: none; }

  .btn-admin,
  .btn-guest {
    padding: 0.42rem 0.65rem;
    font-size: 0.78rem;
  }

  /* --- Légende : compacte --- */
  #legend {
    bottom: 10px;
    left: 10px;
    padding: 0.35rem 0.65rem;
    gap: 0.6rem;
    font-size: 0.62rem;
  }

  /* --- Panneau admin : glisse depuis le bas --- */
  .side-panel {
    width: 100%;
    height: 92vh;
    top: auto;
    bottom: 0;
    right: 0;
    border-left: none;
    border-top: 1px solid var(--border);
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    transform: translateY(0);
    transition: transform 0.32s cubic-bezier(.4,0,.2,1);
  }

  .side-panel.hidden { transform: translateY(calc(100% + 8px)); }

  /* Poignée de swipe */
  .panel-header {
    position: relative;
    padding-top: 1.5rem;
  }
  .panel-header::before {
    content: '';
    position: absolute;
    top: 8px; left: 50%;
    transform: translateX(-50%);
    width: 36px; height: 4px;
    background: var(--border-hover);
    border-radius: 2px;
  }

  .tab-btn {
    padding: 0.75rem 0.3rem;
    font-size: 0.74rem;
  }

  /* --- Modales : remontent depuis le bas --- */
  .modal { align-items: flex-end; }

  .modal-card {
    width: 100% !important;
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    max-height: 92vh;
    animation: slideUp 0.26s ease;
  }

  /* Fiche profil */
  #profile-content { padding: 1.2rem; }

  .profile-header { gap: 1rem; }

  .profile-photo-large { width: 72px; height: 72px; }

  .initials-large { font-size: 1.6rem; }

  .profile-main-info h2 { font-size: 1.15rem; }

  .profile-details { grid-template-columns: 1fr; }

  /* Formulaires */
  .form-row { grid-template-columns: 1fr; }

  input[type="text"],
  input[type="password"],
  input[type="url"],
  input[type="email"],
  select, textarea {
    font-size: 16px; /* évite le zoom iOS au focus */
    padding: 0.65rem 0.85rem;
  }

  /* Boutons : cibles plus grandes */
  .btn-primary,
  .btn-secondary,
  .btn-warning,
  .btn-danger {
    padding: 0.65rem 1.2rem;
    font-size: 0.88rem;
  }

  .btn-icon { width: 38px; height: 38px; font-size: 0.9rem; }

  /* Menu contextuel */
  #context-menu { min-width: 230px; }
  #context-menu li { padding: 0.78rem 1rem; font-size: 0.92rem; }

  /* Écran de bienvenue */
  .welcome-content {
    margin: 1rem;
    padding: 2rem 1.5rem;
    max-width: calc(100vw - 2rem);
  }
  .welcome-tree  { font-size: 3.5rem; }
  .welcome-content h2 { font-size: 1.25rem; }

  /* Toast */
  #toast-container {
    left: 1rem; right: 1rem;
    transform: none; bottom: 1rem;
  }
  .toast { white-space: normal; text-align: center; }

  /* Modal suggestion */
  .suggest-card { padding: 1.4rem 1.2rem; }

  /* Carte de connexion */
  .login-card { padding: 1.8rem 1.4rem; }
}

/* --- Très petits écrans (≤ 380px) --- */
@media (max-width: 380px) {
  #family-title { font-size: 0.85rem; max-width: 120px; }
  .btn-admin, .btn-guest { padding: 0.35rem 0.45rem; font-size: 0.72rem; }
  #legend { display: none; }
}

/* Contact texte (non URL) dans la fiche profil */
.profile-contact-text {
  display: inline-block;
  padding: 0.3rem 0.7rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 0.82rem;
  user-select: all;
}

/* ============================================================
   GUEST PANEL INFO TAB
   ============================================================ */
.guest-info-content {
  color: var(--text-secondary);
  font-size: 0.82rem;
  line-height: 1.6;
}
.guest-info-content h4 {
  color: var(--text-primary);
  margin-bottom: 0.6rem;
  font-size: 0.9rem;
}
.guest-info-content ol {
  padding-left: 1.2rem;
  margin-bottom: 0.8rem;
}
.guest-info-content li { margin-bottom: 0.3rem; }
.guest-info-content p { color: var(--text-muted); font-size: 0.78rem; }

/* ============================================================
   FOND PARCHEMIN
   ============================================================ */
#bg-parchment {
  position: fixed;
  top: 0; right: 0; bottom: 0; left: 0; /* fallback iOS < 15 */
  inset: 0;
  z-index: 0;
  pointer-events: none;
  /* Grain : SVG feTurbulence en tuile répétée */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='g'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.80' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='220' height='220' filter='url(%23g)' opacity='0.10'/%3E%3C/svg%3E");
  background-size: 220px 220px;
}

/* Vignette + taches de vieillissement par-dessus le grain */
#bg-parchment::after {
  content: '';
  position: absolute;
  top: 0; right: 0; bottom: 0; left: 0; /* fallback iOS < 15 */
  inset: 0;
  background:
    /* Vignette principale — bords sombres, centre clair */
    radial-gradient(ellipse at 50% 50%, transparent 28%, rgba(90,52,18,0.28) 100%),
    /* Coins encore plus sombres */
    radial-gradient(ellipse 60% 55% at  0%   0%, rgba(70,38,10,0.22) 0%, transparent 60%),
    radial-gradient(ellipse 60% 55% at 100%  0%, rgba(70,38,10,0.18) 0%, transparent 60%),
    radial-gradient(ellipse 60% 55% at 100% 100%, rgba(70,38,10,0.20) 0%, transparent 60%),
    radial-gradient(ellipse 60% 55% at  0% 100%, rgba(70,38,10,0.18) 0%, transparent 60%),
    /* Taches de vieillissement aléatoires */
    radial-gradient(ellipse 30% 20% at 12% 22%, rgba(160,120,60,0.12) 0%, transparent 100%),
    radial-gradient(ellipse 25% 30% at 88% 75%, rgba(140,100,45,0.10) 0%, transparent 100%),
    radial-gradient(ellipse 35% 18% at 65% 10%, rgba(170,130,65,0.08) 0%, transparent 100%),
    radial-gradient(ellipse 20% 25% at 30% 88%, rgba(150,110,50,0.09) 0%, transparent 100%);
}

/* ============================================================
   BOUTON FLOTTANT CARTE
   ============================================================ */
#btn-map {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 900;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 10px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 4px 18px rgba(0,0,0,0.40);
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}
#btn-map:hover  { transform: translateY(-2px); box-shadow: 0 6px 24px rgba(0,0,0,0.50); }
#btn-map:active { transform: translateY(0);    box-shadow: 0 2px 10px rgba(0,0,0,0.35); }
.btn-map-icon  { font-size: 1.35rem; line-height: 1; }
.btn-map-label {
  font-family: 'Inter', sans-serif;
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--gold);
  letter-spacing: 0.4px;
  text-transform: uppercase;
}

/* ============================================================
   MAP MODAL
   ============================================================ */
.map-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 3000;
  background: rgba(0,0,0,0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  box-sizing: border-box;
  animation: fadeIn 0.2s ease;
}
.map-modal-overlay.hidden { display: none; }

.map-modal-content {
  width: 100%;
  max-width: 900px;
  height: min(82vh, 680px);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 8px 48px rgba(0,0,0,0.60);
}

.map-modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 1rem 1.2rem 0.8rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  gap: 1rem;
}
.map-modal-title h2 {
  font-family: 'Playfair Display', serif;
  font-size: 1rem;
  background: linear-gradient(135deg, var(--gold-light), var(--gold));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin: 0 0 0.5rem;
}

/* Légende */
.map-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
}
.map-leg-item {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.72rem;
  color: var(--text-secondary);
  font-family: 'Inter', sans-serif;
}
.map-leg-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 1.5px solid rgba(255,255,255,0.5);
  flex-shrink: 0;
}
.map-leg-dot.birth     { background: #2e7fc4; }
.map-leg-dot.residence { background: #38a169; }
.map-leg-dot.death     { background: #718096; }
.map-leg-dot.multi     { background: #c9a84c; }

/* Status bar (géocodage en cours) */
.map-status {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px;
  background: rgba(201,168,76,0.08);
  border-bottom: 1px solid var(--border);
  font-size: 0.78rem;
  color: var(--gold);
  flex-shrink: 0;
}
.map-status.hidden { display: none; }
.map-status-spinner {
  width: 14px; height: 14px;
  border: 2px solid rgba(201,168,76,0.3);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Conteneur Leaflet */
#map-container {
  flex: 1;
  min-height: 0;
}

/* Popups Leaflet customisés */
.map-popup { font-family: 'Inter', sans-serif; min-width: 150px; max-width: 230px; }
.map-popup-place {
  display: block;
  font-size: 0.82rem;
  font-weight: 700;
  color: #1a202c;
  margin-bottom: 6px;
  padding-bottom: 5px;
  border-bottom: 1px solid #e2e8f0;
}
.map-popup-count {
  display: block;
  font-size: 0.68rem;
  color: #718096;
  margin-bottom: 7px;
  margin-top: -2px;
}
.map-popup-names {
  margin: 0;
  padding: 0;
  list-style: none;
}
.map-popup-names li { padding: 2px 0; }
.map-person-btn {
  background: none;
  border: none;
  padding: 1px 0;
  font-family: 'Inter', sans-serif;
  font-size: 0.78rem;
  color: #1a202c;
  cursor: pointer;
  text-align: left;
  width: 100%;
  display: -webkit-flex;
  display: flex;
  -webkit-align-items: center;
  align-items: center;
  -webkit-tap-highlight-color: transparent;
}
.map-person-btn:hover { color: #2e7fc4; }
.map-avatar {
  display: -webkit-inline-flex;
  display: inline-flex;
  -webkit-align-items: center;
  align-items: center;
  -webkit-justify-content: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  min-width: 22px;   /* empêche la compression sur iOS */
  border-radius: 50%;
  font-size: 0.55rem;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
  -webkit-flex-shrink: 0;
  letter-spacing: 0.3px;
  margin-right: 7px; /* fallback gap pour iOS < 14.5 */
}

/* Fix Leaflet popup arrow */
.leaflet-popup-content-wrapper { border-radius: 8px; box-shadow: 0 3px 12px rgba(0,0,0,0.2); }
.leaflet-popup-content { margin: 10px 12px; }

/* ============================================================
   MAP MODAL — responsive iPhone / mobile
   ============================================================ */
@media (max-width: 768px) {
  #btn-map {
    /* Fallback pour iOS < 15.4 (pas de max() CSS) */
    bottom: 20px;
    bottom: env(safe-area-inset-bottom, 20px);
    right: 16px;
    padding: 8px 12px;
  }
  .btn-map-icon  { font-size: 1.2rem; }

  .map-modal-overlay { padding: 0; -webkit-align-items: flex-end; align-items: flex-end; }
  .map-modal-content {
    max-width: 100%;
    width: 100%;
    height: 92vh;
    height: 92dvh; /* iOS Safari : exclut la barre du navigateur */
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
    border-radius: 18px 18px 0 0;
    -webkit-overflow-scrolling: touch;
  }
  .map-modal-header { padding: 0.9rem 1rem 0.7rem; }
  .map-modal-title h2 { font-size: 0.9rem; }
  .map-leg-item { font-size: 0.67rem; }
}
