﻿:root {
  --bg: #f7f6fb;
  --card-bg: #ffffff;
  --text: #1e1b2e;
  --muted: #6b6a78;
  --border: #eceaf4;
  --border-strong: #ddd9ec;
  --primary: #7c3aed;
  --primary-dark: #6524d9;
  --primary-light: #f2ecfe;
  --danger: #dc2626;
  --danger-light: #fee2e2;
  --success: #15803d;
  --success-light: #dcfce7;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow-sm: 0 1px 2px rgba(30, 20, 60, 0.05);
  --shadow: 0 1px 3px rgba(30, 20, 60, 0.08), 0 6px 20px -8px rgba(30, 20, 60, 0.12);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  background-image: radial-gradient(circle at 12% 0%, rgba(124, 58, 237, 0.06), transparent 45%);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

/* ---------- Topbar ---------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 28px;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: saturate(180%) blur(10px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

/* Nom de la communauté, centré dans l'en-tête (tronqué s'il ne tient pas entre le logo et l'avatar). */
.topbar-title {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  max-width: calc(100% - 2 * 190px);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.015em;
  color: var(--text);
  text-decoration: none;
}
.topbar-title:hover { color: var(--primary); }
@media (max-width: 640px) {
  /* Peu de place : le nom se range entre le logo et l'avatar (centré dans l'espace restant). */
  .topbar-title { position: static; transform: none; flex: 1; min-width: 0; max-width: none; margin: 0 10px; text-align: center; font-size: 1rem; }
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-weight: 700;
  font-size: 1.15rem;
  letter-spacing: -0.01em;
  color: var(--text);
  text-decoration: none;
}
.brand-mark {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #7c3aed, #ec4899);
  color: #fff;
  font-size: 1rem;
  box-shadow: var(--shadow-sm);
}

/* Menu du profil : icône en haut à droite, liste déroulante dessous. */
.user-menu { position: relative; }
.user-menu-btn {
  display: inline-flex;
  padding: 2px;
  border: 1.5px solid transparent;
  border-radius: 50%;
  background: none;
  box-shadow: none;
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.user-menu-btn:hover,
.user-menu-btn[aria-expanded="true"] { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); background: none; }
.avatar-nav { width: 36px; height: 36px; }
.user-menu-panel {
  position: absolute;
  z-index: 20;
  top: calc(100% + 8px);
  right: 0;
  min-width: 220px;
  padding: 6px;
  background: #fff;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  box-shadow: 0 10px 30px rgba(30, 27, 46, 0.14);
}
.user-menu-head { padding: 8px 10px 10px; border-bottom: 1px solid var(--border); margin-bottom: 4px; font-size: 0.92rem; }
.user-menu-panel a {
  display: block;
  padding: 9px 10px;
  border-radius: 7px;
  color: var(--text);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
}
.user-menu-panel a:hover { background: var(--primary-light); color: var(--primary); }
.user-menu-sep { height: 1px; background: var(--border); margin: 6px 4px; }
.user-menu-panel a.user-menu-logout { color: var(--danger); }
.user-menu-panel a.user-menu-logout:hover { background: var(--danger-light); color: var(--danger); }

/* ---------- Layout ---------- */

.page {
  /* Largeur unique de tous les panneaux : 1010 px + 24 px de marge de chaque côté. */
  max-width: 1058px;
  margin: 0 auto;
  padding: 32px 24px 70px;
}

.auth-wrap {
  min-height: calc(100vh - 190px);
  display: flex;
  align-items: center;
  justify-content: center;
}

.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 26px 26px 28px;
  margin-bottom: 22px;
}

/* Panneau à formulaire : même largeur que les autres, contenu centré en colonne étroite. */
.card-narrow { width: 100%; }
.card-narrow > * { max-width: 420px; margin-left: auto; margin-right: auto; }

/* Sort du carcan de `.page` (800px) pour donner à la toile tout l'espace
   horizontal disponible. Élargir le PARENT plutôt que de bricoler des marges
   en `vw` (piège classique : 100vw compte la largeur de la scrollbar, ce qui
   décentre le résultat dès que la page a un ascenseur vertical). */
.card-wide { width: 100%; }

h1 { margin: 0 0 6px; font-size: 1.5rem; font-weight: 700; letter-spacing: -0.015em; }
h2 { margin-top: 0; font-size: 1.1rem; font-weight: 600; letter-spacing: -0.01em; }
h3 { font-weight: 600; }

.subtitle { color: var(--muted); font-size: 0.92rem; margin: 0 0 20px; }

/* ---------- Forms ---------- */

label {
  display: block;
  margin-bottom: 15px;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text);
}

input[type="text"],
input[type="search"],
input[type="email"],
input[type="password"],
input[type="file"],
select {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 10px 12px;
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-family: inherit;
  color: var(--text);
  background: #fff;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input[type="text"]:focus,
input[type="search"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

input[type="file"] { padding: 7px; font-size: 0.85rem; }

/* ---------- Buttons ---------- */

button, .btn-primary, .btn-secondary, .btn-link {
  cursor: pointer;
  font-size: 0.88rem;
  font-weight: 600;
  font-family: inherit;
  border-radius: var(--radius-sm);
  border: 1.5px solid transparent;
  padding: 9px 16px;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.05s ease;
}
button:active, .btn-primary:active, .btn-secondary:active { transform: translateY(1px); }

button[type="submit"], .btn-primary {
  background: var(--primary);
  color: #fff;
  box-shadow: var(--shadow-sm);
}
button[type="submit"]:hover, .btn-primary:hover { background: var(--primary-dark); }

.btn-secondary {
  background: #fff;
  border-color: var(--border-strong);
  color: var(--text);
}
.btn-secondary:hover { border-color: var(--primary); color: var(--primary); }

.btn-link, button.btn-link, button[type="submit"].btn-link {
  background: none;
  border: none;
  box-shadow: none;
  color: var(--muted);
  text-decoration: none;
  padding: 4px 2px;
  font-weight: 600;
}
.btn-link:hover, button.btn-link:hover { text-decoration: underline; color: var(--danger); background: none; }

/* ---------- Alerts ---------- */

.alert {
  padding: 11px 15px;
  border-radius: var(--radius-sm);
  margin-bottom: 18px;
  font-size: 0.88rem;
  border: 1px solid transparent;
}
.alert-error { background: var(--danger-light); color: #991b1b; border-color: #fecaca; }
.alert-success { background: var(--success-light); color: #166534; border-color: #bbf7d0; }
.alert ul { margin: 0; padding-left: 18px; }

.muted { color: var(--muted); font-size: 0.85rem; }

/* ---------- Community list ---------- */

.community-list { list-style: none; padding: 0; margin: 0; }
.community-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 13px 4px;
  border-bottom: 1px solid var(--border);
}
.community-list li:last-child { border-bottom: none; }
.community-list a {
  text-decoration: none;
  color: var(--text);
  display: flex;
  gap: 10px;
  align-items: baseline;
  font-weight: 600;
}
.community-list a strong { transition: color 0.15s ease; }
.community-list a:hover strong { color: var(--primary); }

.share-btn { flex-shrink: 0; white-space: nowrap; padding: 7px 13px; font-size: 0.85rem; }

.badge {
  background: var(--primary);
  color: #fff;
  border-radius: 999px;
  padding: 3px 11px;
  font-size: 0.72rem;
  font-weight: 600;
}

.empty-state {
  text-align: center;
  padding: 28px 10px;
  color: var(--muted);
}
.empty-state .empty-icon { font-size: 2rem; display: block; margin-bottom: 8px; }

/* ---------- Avatars ---------- */

.avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--primary-light);
  border: 1.5px solid var(--border);
  flex-shrink: 0;
}
.avatar-lg { width: 88px; height: 88px; border-width: 3px; box-shadow: var(--shadow); }
.avatar-initials {
  display: inline-flex;
  background-color: var(--primary-light);
  background-image: url("data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAxMjAgMTIwIj48ZGVmcz48Y2xpcFBhdGggaWQ9ImMiPjxjaXJjbGUgY3g9IjYwIiBjeT0iNjAiIHI9IjYwIi8+PC9jbGlwUGF0aD48L2RlZnM+PGNpcmNsZSBjeD0iNjAiIGN5PSI2MCIgcj0iNjAiIGZpbGw9IiNmMmVjZmUiLz48ZyBjbGlwLXBhdGg9InVybCgjYykiIGZpbGw9IiNhODliZDEiPjxjaXJjbGUgY3g9IjYwIiBjeT0iNDYiIHI9IjIyIi8+PGNpcmNsZSBjeD0iNjAiIGN5PSIxMjgiIHI9IjQ0Ii8+PC9nPjwvc3ZnPg==");
  background-size: cover;
  background-position: center;
  color: transparent;
}

.person-name {
  display: flex;
  flex-direction: column;
  line-height: 1.25;
}
.person-name .first { font-weight: 700; color: var(--text); }
.person-name .last { font-weight: 300; color: var(--muted); }
.person-name-centered { align-items: center; text-align: center; }

.profile-photo {
  display: flex;
  justify-content: center;
  margin-bottom: 22px;
}
.profile-badge {
  width: 250px;
  height: 250px;
  border-radius: 50%;
  border: 2px solid var(--border-strong);
  background: var(--bg);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.profile-badge .avatar-lg { width: 108px; height: 108px; border-width: 2px; box-shadow: none; }
.profile-badge .person-name .first { font-size: 1.4rem; }
.profile-badge .person-name .last { font-size: 1.1rem; }

/* ---------- Invite box ---------- */

.invite-box { margin-top: 6px; }
.invite-box summary {
  cursor: pointer;
  color: var(--primary);
  font-size: 0.88rem;
  font-weight: 600;
  list-style: none;
}
.invite-box summary::-webkit-details-marker { display: none; }
.invite-box[open] summary { margin-bottom: 10px; }
.invite-link-row input {
  font-size: 0.82rem;
  margin-bottom: 10px;
  background: var(--bg);
  color: var(--muted);
}

/* ---------- Graph ---------- */

.graph-mode-tabs {
  display: flex;
  gap: 4px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px;
  margin-bottom: 14px;
  width: fit-content;
}
.mode-tab {
  border: none;
  background: none;
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
  box-shadow: none;
}
.mode-tab:hover { color: var(--text); background: rgba(124, 58, 237, 0.08); }
.mode-tab.is-active { background: var(--primary); color: #fff; }

.graph-search-row { position: relative; margin-bottom: 12px; max-width: 360px; }
.graph-search-row input { margin-top: 0; }
.graph-search-results {
  position: absolute;
  z-index: 5;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: #fff;
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-sm);
  box-shadow: 0 8px 24px rgba(30, 27, 46, 0.12);
  max-height: 260px;
  overflow-y: auto;
}
.graph-search-result {
  display: block;
  width: 100%;
  text-align: left;
  padding: 9px 12px;
  font-size: 0.9rem;
  color: var(--text);
  background: none;
  border: none;
  border-radius: 0;
  box-shadow: none;
}
.graph-search-result:hover,
.graph-search-result.is-active {
  background: var(--primary-light);
}
.graph-search-empty {
  padding: 9px 12px;
  font-size: 0.85rem;
  color: var(--muted);
}

.type-filter-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.type-filter-label { font-size: 0.82rem; font-weight: 600; color: var(--muted); }
.type-filter-btn {
  border: 1.5px solid var(--border-strong);
  background: #fff;
  border-radius: 999px;
  padding: 6px 13px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
  box-shadow: none;
}
.type-filter-btn:hover { border-color: var(--type-color); color: var(--text); }
.type-filter-btn.is-active {
  background: var(--type-color);
  border-color: var(--type-color);
  color: #fff;
}
.degree-filter-btn.is-active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.graph-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}
.graph-filter-label {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin: 0;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
}
.graph-filter-label input { width: auto; margin: 0; accent-color: var(--primary); }

/* La carte est posée sur le fond de la page, sans cadre, sur toute la largeur de la fenêtre
   (hauteur ajustée par graph.js). */
#graph {
  width: 100vw;
  margin-left: calc(50% - 50vw);
  height: 480px;
  margin-bottom: 22px;
  background: transparent;
}
/* Les cartes passent AU-DESSUS de la carte (qui se prolonge derrière elles). */
.page .card { position: relative; z-index: 1; }
.page .head-card { z-index: 3; } /* le menu de changement de communauté déborde sur les cartes suivantes */
/* Cercle / Arbre + bouton « Filtres » (ce dernier seulement sur mobile). */
.graph-toolbar { display: flex; align-items: center; gap: 8px; }
.filters-toggle { display: none; }
.filters-count {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px;
  background: var(--primary); color: #fff; font-size: 0.7rem; font-weight: 700;
}
@media (max-width: 760px) {
  .graph-toolbar { justify-content: space-between; margin-bottom: 0; }
  .graph-toolbar .graph-mode-tabs { margin-bottom: 0; }
  .filters-toggle {
    display: inline-flex; align-items: center; gap: 6px;
    margin: 0; padding: 7px 12px; border-radius: 999px;
    background: var(--bg); border: 1px solid var(--border); box-shadow: none;
    color: var(--text); font-size: 0.8rem;
  }
  .filters-toggle[aria-expanded="true"] { border-color: var(--primary); color: var(--primary); }
  .filters-toggle[aria-expanded="true"] .caret { display: inline-block; transform: rotate(180deg); }
  /* Filtres repliés par défaut ; la phrase d'aide (survol à la souris) est inutile au doigt. */
  .head-card .graph-controls { display: none; margin-top: 10px; }
  .head-card .graph-controls.is-open { display: block; }
  .graph-hint { display: none; }
  .head-card .type-filter-row:last-of-type { margin-bottom: 0; }
}

/* Bloc du haut de la carte : moins d'espace vide sous la dernière ligne. */
.page .head-card { padding-bottom: 16px; }
.head-card .graph-controls { margin-bottom: 0; }
@media (max-width: 640px) { .page .head-card { padding-bottom: 12px; } }
#graph { position: relative; z-index: 0; --under: 0px; }

/* Près des bords de l'écran et des blocs de texte, la carte s'estompe en douceur : ça montre qu'on
   arrive à la limite du champ (au-delà, on ne verrait plus rien). Simple fondu (masque), sans bord net. */
#graph {
  --fade-top-start: calc(var(--under) - 120px);  /* invisible au-dessus */
  --fade-top-end: calc(var(--under) + 100px);    /* pleinement visible en dessous */
  --fade-bottom-end: calc(100% - var(--under) - 34px - 100px);  /* pleinement visible au-dessus */
  --fade-bottom-start: calc(100% - var(--under) - 34px + 120px);/* invisible en dessous */
  -webkit-mask-image:
    linear-gradient(to bottom, transparent var(--fade-top-start), #000 var(--fade-top-end), #000 var(--fade-bottom-end), transparent var(--fade-bottom-start)),
    linear-gradient(to right, transparent 0, #000 110px, #000 calc(100% - 110px), transparent 100%);
  -webkit-mask-composite: source-in;
  mask-image:
    linear-gradient(to bottom, transparent var(--fade-top-start), #000 var(--fade-top-end), #000 var(--fade-bottom-end), transparent var(--fade-bottom-start)),
    linear-gradient(to right, transparent 0, #000 110px, #000 calc(100% - 110px), transparent 100%);
  mask-composite: intersect;
}
body { overflow-x: clip; } /* 100vw inclut la barre de défilement : on évite un défilement horizontal parasite */
/* Bloc du bas : une carte à part, visible seulement quand une personne est sélectionnée. */
.graph-details:empty { display: none; }
.graph-details h3 { margin: 0 0 6px; font-size: 1rem; }
.graph-details ul { margin: 4px 0 0; padding-left: 18px; }
.details-propose { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border); }
.details-propose-title { margin: 0 0 8px; font-size: 0.85rem; font-weight: 600; color: var(--muted); }
.details-propose .inline-form { max-width: 440px; }
.details-propose .inline-form select { flex: 1; min-width: 0; }
.graph-details li { padding: 1px 0; }

/* ---------- Request list ---------- */

.request-list { list-style: none; padding: 0; margin: 0; }
.request-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 4px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.request-list li:last-child { border-bottom: none; }
.request-actions { display: flex; gap: 8px; }
.request-actions form, .request-list form { margin: 0; }

/* ---------- Inscription ---------- */

/* Profils déjà sur la toile qui ressemblent au nom tapé : « C'est toi ? ». */
.claim-suggest {
  background: var(--primary-light);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin: -4px 0 15px;
  font-size: 0.86rem;
}
.claim-suggest p { margin: 0 0 8px; }
.claim-suggest-list { display: flex; flex-wrap: wrap; gap: 6px; }
.claim-suggest-item {
  margin: 0;
  padding: 6px 12px;
  border-radius: 999px;
  background: #fff;
  border: 1.5px solid var(--border-strong);
  box-shadow: none;
  color: var(--text);
  font-size: 0.85rem;
}
.claim-suggest-item:hover { border-color: var(--primary); color: var(--primary); background: #fff; }

.claim-selected {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: var(--primary-light);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin-bottom: 14px;
  font-size: 0.9rem;
}
.claim-selected .btn-link { color: var(--primary); }

.pw-rules {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin: 4px 0 10px;
  font-size: 0.82rem;
  color: var(--muted);
}
.pw-rules ul { list-style: none; margin: 6px 0 0; padding: 0; }
.pw-rules li { padding-left: 20px; position: relative; margin-top: 3px; }
.pw-rules li::before { content: "○"; position: absolute; left: 0; }
.pw-rules li.is-ok { color: var(--success); }
.pw-rules li.is-ok::before { content: "✓"; font-weight: 700; }

.photo-preview { display: flex; align-items: center; gap: 12px; margin: -6px 0 14px; flex-wrap: wrap; }
.photo-preview .avatar-lg { width: 64px; height: 64px; }
.photo-remove { display: inline-flex; align-items: center; gap: 6px; margin: 0; font-size: 0.82rem; font-weight: 500; color: var(--muted); }
.photo-remove input { width: auto; margin: 0; accent-color: var(--primary); }

/* ---------- Members ---------- */

.member-list { list-style: none; padding: 0; margin: 0; }
/* Une ligne = personne (nom tronqué si besoin) | étiquette du lien | menu ⋮ (actions). */
.member-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 4px;
  border-bottom: 1px solid var(--border);
}
.member-row:last-child { border-bottom: none; }
.member-info { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1; font-weight: 600; }
/* Nom complet toujours visible : il passe à la ligne plutôt que d'être tronqué. */
.member-row .person-name { flex-direction: row; flex-wrap: wrap; column-gap: 5px; min-width: 0; line-height: 1.25; }
.member-row .person-name .last { overflow-wrap: anywhere; }
/* Le lien est aligné à droite, juste à côté du menu ⋮ : tous les liens forment une colonne.
   S'il manque de place, il passe sous le nom (toujours à droite) plutôt que de le couper. */
.member-text { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; min-width: 0; flex: 1; }
.member-text .existing-types { margin-left: auto; justify-content: flex-end; }
/* Étiquettes de même largeur, contenu calé à gauche : les émojis s'alignent verticalement.
   Bordure transparente sur toutes pour que le texte soit au même endroit que « Aucun lien ». */
.member-text .type-chip {
  box-sizing: border-box;
  min-width: 7.5rem;
  justify-content: flex-start;
  border: 1.5px solid transparent;
}
.member-text .type-chip-empty { border-style: dashed; border-color: var(--border); }
.member-text .type-chip-empty:hover { border-color: var(--primary); }
.member-side { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

.inline-form { display: flex; gap: 6px; align-items: center; margin: 0; }
.inline-form select { width: auto; margin: 0; padding: 8px 10px; font-size: 0.85rem; }

.existing-types { display: flex; gap: 6px; flex-wrap: wrap; font-weight: 500; }
.type-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text);
  background: var(--primary-light);
  border-radius: 999px;
  padding: 4px 10px;
  white-space: nowrap;
}
/* « Aucun lien » : étiquette en pointillés qui ouvre le menu ⋮ sur « Proposer un lien ». */
.type-chip-empty {
  border: 1.5px dashed var(--border);
  background: none;
  box-shadow: none;
  color: var(--muted);
  cursor: pointer;
  margin: 0;
  width: auto;
}
.type-chip-empty:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-light); }

/* ---------- Menu ⋮ d'une personne (proposer/changer le lien, supprimer, bloquer) ---------- */
.member-menu { position: relative; }
.member-menu-btn {
  width: 28px;
  height: 28px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  border: 1.5px solid transparent;
  background: none;
  box-shadow: none;
  color: var(--muted);
  font-size: 1.15rem;
  line-height: 1;
  letter-spacing: 1px;
}
.member-menu-btn:hover, .member-menu-btn[aria-expanded="true"] { background: var(--primary-light); color: var(--primary); }
.member-menu-panel {
  position: absolute;
  z-index: 8;
  top: calc(100% + 6px);
  right: 0;
  width: 220px;
  padding: 10px;
  background: #fff;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  box-shadow: 0 10px 30px rgba(30, 27, 46, 0.14);
}
/* Select et bouton l'un sous l'autre (plutôt que côte à côte) : le menu reste étroit,
   même quand la ligne elle-même a peu de place (colonne de gauche, grand écran). */
.member-menu-panel .propose-form { display: flex; flex-direction: column; gap: 6px; }
.member-menu-panel .propose-form select { width: 100%; margin: 0; }
.member-menu-panel .propose-form button { width: 100%; }
.member-menu-panel .remove-links { display: flex; flex-direction: column; gap: 2px; }
.member-menu-panel > * + * { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--border); }
/* Les boutons repris (Supprimer / Bloquer) deviennent des lignes de menu pleine largeur. */
.member-menu-panel .btn-link {
  display: flex;
  width: 100%;
  padding: 7px 8px;
  border-radius: 7px;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text);
  text-decoration: none;
}
.member-menu-panel .btn-link:hover { background: var(--danger-light); color: var(--danger); text-decoration: none; }
.member-menu-panel .block-form .btn-link { color: var(--danger); }

/* ---------- Admin ---------- */

.avatar-sm { width: 28px; height: 28px; font-size: 0.68rem; border-width: 1px; }

.admin-stats { display: flex; gap: 28px; flex-wrap: wrap; margin-top: 16px; }
.admin-stats .stat { display: flex; flex-direction: column; }
.admin-stats .stat strong { font-size: 1.7rem; font-weight: 700; color: var(--primary); letter-spacing: -0.02em; }
.admin-stats .stat span { font-size: 0.78rem; color: var(--muted); font-weight: 500; }

.admin-menu { list-style: none; padding: 0; margin: 0; display: flex; gap: 10px; flex-wrap: wrap; }
.admin-menu a {
  color: var(--text);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.88rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  display: inline-block;
  transition: border-color 0.15s ease, color 0.15s ease;
}
.admin-menu a:hover { border-color: var(--primary); color: var(--primary); }

.admin-table { width: 100%; border-collapse: collapse; font-size: 0.87rem; }
.admin-table th {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1.5px solid var(--border-strong);
  color: var(--muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 600;
}
.admin-table td {
  text-align: left;
  padding: 7px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.admin-table th, .admin-table td { white-space: nowrap; }
.admin-table tr:last-child td { border-bottom: none; }
.admin-add, .admin-edit { display: inline-block; text-decoration: none; }
.admin-add { padding: 7px 14px; font-size: 0.85rem; }
.admin-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.admin-head h1 { margin: 0; }
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 14px;
  padding: 5px 12px 5px 10px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
  text-decoration: none;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  transition: color 0.15s ease, border-color 0.15s ease;
}
.back-link:hover { color: var(--primary); border-color: var(--primary); }
.admin-stats .stat .admin-edit { margin-top: 10px; align-self: flex-start; padding: 6px 12px; font-size: 0.8rem; }
.admin-create-link { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.admin-create-link select, .admin-create-link input[type="text"] { width: 260px; max-width: 100%; margin: 0; }
.admin-communities { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px; margin: 0 0 14px; }
.admin-communities legend { font-size: 0.82rem; font-weight: 600; color: var(--muted); padding: 0 6px; }
.person-cell { display: inline-flex; align-items: center; gap: 8px; }
/* Boutons d'une ligne : tous sur la même ligne, alignés à droite. */
td.admin-actions { white-space: nowrap; text-align: right; }
td.admin-actions > * { display: inline-flex; vertical-align: middle; margin-left: 6px; }
.admin-table .btn-secondary, .admin-table button.btn-secondary {
  background: #fff;
  border: 1.5px solid var(--border-strong);
  color: var(--text);
  box-shadow: none;
  padding: 5px 11px;
  font-size: 0.8rem;
}
.admin-table .btn-secondary:hover, .admin-table button.btn-secondary:hover { background: #fff; border-color: var(--primary); color: var(--primary); }
.admin-table .btn-link { font-size: 0.8rem; }


/* ---------- Responsive ---------- */

/* Mobile : textes plus petits, blocs compacts et sans chevauchement. */
@media (max-width: 760px) {
  body { font-size: 15px; }
  h1 { font-size: 1.25rem; }
  h2 { font-size: 1rem; }
  .subtitle { font-size: 0.85rem; }
  .muted { font-size: 0.78rem; }
  .card { padding: 16px 14px 18px; margin-bottom: 14px; border-radius: 12px; }
  .page { padding: 14px 10px 50px; }

  .community-head { margin-bottom: 12px; gap: 10px; }
  .community-switcher-btn { font-size: 1.25rem; }
  .community-switcher-panel { min-width: min(300px, calc(100vw - 48px)); }
  .share-btn { padding: 6px 11px; font-size: 0.8rem; }

  input[type="text"], input[type="search"], input[type="email"], input[type="password"], select { font-size: 16px; padding: 8px 11px; } /* 16px : évite le zoom automatique d'iOS */
  button, .btn-primary, .btn-secondary { font-size: 0.82rem; padding: 8px 13px; }

  /* Filtres : une seule ligne défilante au lieu d'un mur de pastilles. */
  .graph-search-row { max-width: none; margin-bottom: 10px; }
  .graph-mode-tabs { margin-bottom: 10px; }
  .mode-tab { padding: 6px 12px; font-size: 0.8rem; }
  .graph-controls { margin-bottom: 4px; }
  .type-filter-row {
    flex-wrap: nowrap;
    gap: 6px;
    overflow-x: auto;
    margin: 0 -14px 8px;
    padding: 0 14px 2px;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }
  .type-filter-row::-webkit-scrollbar { display: none; }
  .type-filter-row > * { flex: 0 0 auto; white-space: nowrap; }
  .type-filter-label { font-size: 0.74rem; }
  .type-filter-btn { padding: 5px 10px; font-size: 0.76rem; }

  /* La carte n'est plus glissée sous les cartes : pas de fondu, et un doigt sur la carte
     fait défiler la page (le zoom se fait avec les boutons + / −). */
  #graph { -webkit-mask-image: none; mask-image: none; margin-bottom: 14px; }
  #graph canvas { touch-action: pan-y !important; }
  .graph-stage { touch-action: pan-y; } /* pas de zoom natif de la page sur la carte : le pincement est géré dans graph.js */
  .graph-zoom { margin: 0 0 10px; }

  /* Liste des membres : avatar plus petit, le reste (chip + menu ⋮) est déjà compact. */
  .member-row { padding: 10px 2px; }
  .avatar { width: 32px; height: 32px; }
  .person-name { font-size: 0.9rem; }
  .type-chip { font-size: 0.74rem; padding: 3px 8px; }
  .member-menu-panel { min-width: 210px; }
}

/* ---------- Membres en colonne, dans la marge gauche (grand écran) ---------- */
/* Sur grand écran, la liste des membres est une colonne fixe collée à gauche. Le
   panneau central n'est plus forcément centré : il se décale vers la droite (et se
   rétrécit si besoin) pour laisser à la colonne une largeur confortable. Il reste
   centré quand la fenêtre est assez large pour tout accueillir. En dessous du seuil,
   la liste reprend sa place normale sous la carte. */
@media (min-width: 1280px) {
  .page:has(.members-card) {
    /* 450 px minimum : le plus long « prénom nom + lien » tient sur une ligne. */
    --members-w: clamp(450px, calc(100vw - 1058px - 96px), 480px);
    margin-left: max(calc(var(--members-w) + 48px), calc((100vw - 1058px) / 2));
    margin-right: auto;
  }
  .page .members-card {
    position: fixed;
    top: 96px;
    left: 24px;
    width: var(--members-w);
    box-sizing: border-box;
    max-height: calc(100vh - 116px);
    overflow-y: auto;
    margin: 0;
  }
}

@media (max-width: 640px) {
  .topbar { padding: 10px 14px; }
  .brand { font-size: 1rem; }
  .page { padding: 14px 10px 50px; }
  .card { padding: 16px 14px 18px; }
  .admin-table { display: block; overflow-x: auto; white-space: nowrap; }
  .auth-wrap { min-height: calc(100vh - 220px); }
}

/* Recherche au-dessus des tableaux admin. */
.admin-search { max-width: 420px; margin: 0 0 12px; }
.admin-search-empty { margin: 0 0 12px; }

.admin-member-list { max-height: 260px; overflow-y: auto; padding-right: 6px; }
.admin-member-list label { display: flex; align-items: center; margin-bottom: 6px; }
/* Dans les tableaux admin, prénom et nom sur une seule ligne (lignes plus fines). */
.admin-table .person-name { flex-direction: row; gap: 5px; align-items: baseline; }

/* Toutes les pages admin : même largeur de panneau (~1010 px), centrée, avec de l'air sur les côtés. */
.admin-card { width: 100%; }
/* Les formulaires de modification restent lisibles : colonne centrée dans le panneau. */
.admin-form { max-width: 560px; margin-left: auto; margin-right: auto; }

/* Réserve toujours la place de la barre de défilement : sans ça, les pages longues
   (avec barre) sont décalées de quelques pixels par rapport aux pages courtes. */
html { overflow-y: scroll; }

/* Page profil : photo à gauche, formulaire de modification à droite. */
.profile-layout { display: flex; align-items: center; justify-content: center; gap: 56px; margin-top: 12px; }
.profile-layout .profile-photo { margin: 0; flex: 0 0 250px; }
.profile-layout form { flex: 1; max-width: 480px; }
@media (max-width: 720px) {
  .profile-layout { flex-direction: column; gap: 24px; }
  .profile-layout form { width: 100%; max-width: none; }
}

/* Compte : déconnexion puis suppression, l'un sous l'autre. */
.account-actions { display: flex; flex-direction: column; align-items: flex-start; gap: 12px; }
.account-btn { display: inline-block; text-decoration: none; }
.btn-danger {
  background: #fff;
  border: 1.5px solid #fecaca;
  border-radius: var(--radius-sm);
  color: var(--danger);
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  padding: 9px 16px;
  cursor: pointer;
  box-shadow: none;
}
.btn-danger:hover, button.btn-danger:hover { background: var(--danger-light); border-color: var(--danger); color: var(--danger); }
button[type="submit"].btn-danger { background: #fff; color: var(--danger); }

.form-column { max-width: 560px; margin-left: auto; margin-right: auto; }
.reason-list label { display: flex; align-items: center; margin-bottom: 8px; }
.delete-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 6px; }

textarea {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 10px 12px;
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-family: inherit;
  color: var(--text);
  background: #fff;
  resize: vertical;
}
textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }
button[type="submit"].btn-danger:hover { background: var(--danger-light); border-color: var(--danger); color: var(--danger); }

/* ---------- Recadrage de photo ---------- */
.crop-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(20, 15, 40, 0.55);
}
.crop-open { overflow: hidden; }
.crop-dialog {
  width: min(100%, 400px);
  max-height: 100%;
  overflow-y: auto;
  padding: 20px 20px 18px;
  background: #fff;
  border-radius: var(--radius);
  box-shadow: 0 20px 50px rgba(20, 15, 40, 0.3);
}
.crop-dialog h3 { margin: 0 0 14px; text-align: center; }
.crop-stage {
  position: relative;
  margin: 0 auto 14px;
  overflow: hidden;
  border-radius: var(--radius-sm);
  background: #fff;
  cursor: grab;
  touch-action: none;
  user-select: none;
}
.crop-stage.is-dragging { cursor: grabbing; }
.crop-canvas { display: block; }
/* Cercle de recadrage : tout ce qui est hors du cercle est estompé. */
.crop-mask {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  box-shadow: 0 0 0 999px rgba(255, 255, 255, 0.72);
  border: 2px solid var(--primary);
  pointer-events: none;
}
.crop-zoom { display: flex; align-items: center; gap: 12px; margin: 0 0 6px; font-weight: 600; }
.crop-zoom input { flex: 1; accent-color: var(--primary); }
.crop-hint { text-align: center; margin: 0 0 14px; }
.crop-actions { display: flex; gap: 10px; justify-content: flex-end; }
.crop-note { margin: -8px 0 14px; }

/* ---------- Choix d'un avatar ---------- */
.avatar-picker { margin: -4px 0 16px; }
.avatar-picker-label { display: block; margin-bottom: 8px; font-size: 0.85rem; font-weight: 500; color: var(--text); }
.avatar-picker-list { display: flex; gap: 10px; flex-wrap: wrap; }
.avatar-choice {
  width: 46px;
  height: 46px;
  padding: 0;
  border: 2px solid transparent;
  border-radius: 50%;
  background: none;
  box-shadow: none;
  overflow: hidden;
  cursor: pointer;
  transition: border-color 0.15s ease, transform 0.1s ease, box-shadow 0.15s ease;
}
.avatar-choice img { display: block; width: 100%; height: 100%; border-radius: 50%; }
.avatar-choice:hover { transform: scale(1.08); border-color: var(--border-strong); background: none; }
.avatar-choice.is-selected { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }

/* ---------- Logo ---------- */
.brand-full { display: block; height: 40px; width: auto; }
@media (max-width: 640px) { .brand-full { height: 32px; } }
.brand-icon { display: block; height: 34px; width: 34px; }
.brand-logo { display: block; height: 26px; width: auto; }
.brand-baseline { display: block; height: 11px; width: auto; margin-left: 4px; opacity: 0.85; }
.auth-logo { display: block; width: 190px; max-width: 70%; height: auto; margin: 0 auto 22px; }
/* `.subtitle` a sa propre marge et écrasait le centrage de la colonne étroite. */
.card-narrow > .subtitle { margin: 0 auto 20px; }

/* ---------- Ajouter quelqu'un ---------- */
.add-person { margin: 0 0 16px; }
.add-person-form { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)) auto; gap: 12px; align-items: end; margin: 10px 0 6px; }
.add-person-form label { margin: 0; }
.add-person-form button { height: 42px; white-space: nowrap; }
@media (max-width: 760px) { .add-person-form { grid-template-columns: 1fr; } }

/* Titre de la communauté avec son bouton Partager à côté. */
.community-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; margin-bottom: 18px; }
.community-head h1 { margin: 0; }

/* « Créer une communauté » : un cadre fin, tout sur une ligne (titre, champ, bouton). */
.create-community { padding: 16px 26px; }
.create-row { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.create-row h2 { margin: 0; white-space: nowrap; }
.create-row form { display: flex; flex: 1; gap: 10px; min-width: 260px; margin: 0; }
.create-row input[type="text"] { flex: 1; margin: 0; }
.create-note { margin: 10px 0 0; }

/* ---------- Accueil : rechercher ou créer une communauté ---------- */
.home-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 22px; align-items: start; }
.home-grid .card { margin-bottom: 0; }
.home-grid input[type="search"], .home-grid input[type="text"] { margin-top: 0; }
.create-form { display: flex; gap: 10px; margin-bottom: 10px; }
.create-form input { flex: 1; }
.community-results { margin-top: 10px; }
.community-result {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 2px; border-bottom: 1px solid var(--border); font-size: 0.92rem;
}
.community-result:last-child { border-bottom: none; }
.result-action { padding: 6px 12px; font-size: 0.82rem; white-space: nowrap; text-decoration: none; }
.result-state { white-space: nowrap; }
.sent-requests { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 14px; }
@media (max-width: 760px) { .home-grid { grid-template-columns: 1fr; } }

/* ---------- Profil : utilisateurs bloqués ---------- */
.blocked-list { list-style: none; margin: 0; padding: 0; }
.blocked-row { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.blocked-row:last-child { border-bottom: none; }
.blocked-row .person-name { flex-direction: row; flex-wrap: wrap; column-gap: 5px; flex: 1; min-width: 0; }
.blocked-date { font-size: 0.8rem; white-space: nowrap; }
@media (max-width: 480px) { .blocked-date { display: none; } }

/* ---------- Page « Communautés » : mes communautés ---------- */
.my-communities h1 { font-size: 1.25rem; margin-bottom: 10px; }
.my-community-list { list-style: none; margin: 0; padding: 0; }
.my-community {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 0; border-bottom: 1px solid var(--border);
}
.my-community:last-child { border-bottom: none; }
.my-community-link {
  flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px;
  padding: 8px 12px; margin-left: -12px; border-radius: 10px;
  color: var(--text); text-decoration: none;
}
.my-community-link:hover { background: var(--primary-light); }
.my-community.is-current .my-community-link { background: var(--primary-light); }
.my-community-name { font-weight: 700; }
.my-community.is-current .my-community-name { color: var(--primary); }
.my-community-meta { font-size: 0.82rem; }

/* ---------- Menu de changement de communauté ---------- */
.community-switcher { position: relative; }
.community-title { margin: 0; }
.community-switcher-btn {
  display: inline-flex; align-items: center; gap: 8px;
  margin-left: -10px; padding: 2px 10px;
  font: inherit; font-size: 1.5rem; font-weight: 700; letter-spacing: -0.015em; color: var(--text);
  background: none; border: 1.5px solid transparent; border-radius: var(--radius-sm); box-shadow: none; cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.community-switcher-btn:hover, .community-switcher-btn[aria-expanded="true"] { background: var(--primary-light); }
.community-switcher-btn .caret { font-size: 0.9rem; color: var(--primary); }
.community-switcher-panel {
  position: absolute; z-index: 20; top: calc(100% + 6px); left: 0; min-width: 300px; padding: 6px;
  background: #fff; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  box-shadow: 0 10px 30px rgba(30, 27, 46, 0.14);
}
.community-switcher-panel a {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 9px 10px; border-radius: 7px; color: var(--text); text-decoration: none; font-size: 0.9rem; font-weight: 500;
}
.community-switcher-panel a:hover { background: var(--primary-light); color: var(--primary); }
.community-switcher-panel a.is-current { font-weight: 700; background: var(--primary-light); }

/* ---------- Commandes de zoom de la carte (mobile) ---------- */
.graph-stage { display: flow-root; } /* limite la portée de la barre de zoom collante à la carte */
.graph-zoom { display: none; }
@media (max-width: 760px) {
  .graph-zoom {
    position: sticky;
    top: 74px; /* reste visible sous l'en-tête tant qu'on parcourt la carte */
    z-index: 6; /* au-dessus de la carte, qui passe derrière */
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0 0 10px;
    padding: 5px 6px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 999px;
    box-shadow: var(--shadow-sm);
  }
  .zoom-btn, .members-toggle {
    flex: 0 0 auto;
    width: 32px;
    height: 32px;
    margin: 0;
    padding: 0;
    border-radius: 50%;
    font-size: 1.15rem;
    line-height: 1;
    background: var(--primary);
    color: #fff;
    box-shadow: none;
    touch-action: manipulation;
  }
  /* Burger à droite de la barre, en contour : il ouvre la liste des membres. */
  .members-toggle {
    margin-left: auto;
    background: var(--primary-light);
    color: var(--primary);
    font-size: 1.05rem;
  }
  .members-toggle[aria-expanded="true"] { background: var(--primary); color: #fff; }

  /* Liste des membres : cachée, elle s'ouvre en panneau par-dessus la carte (burger ☰). */
  .page .members-card { display: none; }
  body.members-open .page .members-card {
    display: block;
    position: fixed;
    z-index: 40;
    left: 8px;
    right: 8px;
    top: 70px;
    bottom: 8px;
    margin: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    box-shadow: 0 12px 40px rgba(30, 27, 46, 0.25);
  }
  .members-backdrop {
    position: fixed;
    inset: 0;
    z-index: 39;
    background: rgba(30, 27, 46, 0.35);
  }
  body.members-open { overflow: hidden; } /* la page derrière ne défile pas */
}
.members-card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.members-card-head h2 { margin-bottom: 0; }
.members-card > .members-card-head { margin-bottom: 12px; }
.members-close { display: none; }
@media (max-width: 760px) {
  .members-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    margin: 0;
    padding: 0;
    border-radius: 50%;
    background: var(--primary-light);
    color: var(--primary);
    box-shadow: none;
    font-size: 1rem;
  }
}
