:root {
  --primary: #8b6f47;
  --primary-light: #a0825c;
  --primary-dark: #6b5637;
  --accent: #d4a574;
  --success: #6ba88a;
  --error: #c85a54;
  --text: #3a3a3a;
  --text-light: #666;
  --border: #d9ccc1;
  --bg-light: #faf8f5;
  --bg-white: #ffffff;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.12);
  /* One size for every text field, select and textarea of the site (16px also avoids the iOS zoom on focus). */
  --field-font: 16px;
  --field-pad: 0.55rem 0.75rem;
  --field-min-h: 2.5rem;
  --field-border: 1.5px solid var(--border);
  --field-radius: 8px;
  --field-ring: 0 0 0 3px rgba(139, 111, 71, 0.2);
}

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

html {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', sans-serif;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  height: 100%;
  overflow: hidden;
  color: var(--text);
}

body {
  display: flex;
  flex-direction: column;
  margin: 0;
  height: 100%;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg-white);
  flex-grow: 1;
  overflow: hidden;
  touch-action: manipulation;
}

svg {
  background: var(--bg-white);
}

.graph {
  border: solid #ccc 1px;
}

/* Auth */
.auth-shell {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: linear-gradient(180deg, var(--bg-light) 0%, #fdfbf8 100%);
}

.auth-card {
  background: var(--bg-white);
  padding: 2.5rem;
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  max-width: 420px;
  width: min(100%, 420px);
  text-align: center;
}

.auth-card h1 {
  margin: 0 0 0.75rem 0;
  font-size: 1.75rem;
  color: var(--primary);
  font-weight: 600;
}

.auth-card p {
  margin: 0 0 1.5rem 0;
  color: var(--text-light);
  font-size: 15px;
  line-height: 1.5;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.auth-input {
  padding: var(--field-pad);
  min-height: var(--field-min-h);
  font-size: var(--field-font);
  border: var(--field-border);
  border-radius: var(--field-radius);
  font-family: inherit;
  color: var(--text);
  background: var(--bg-white);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  width: 100%;
}

.auth-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: var(--field-ring);
}

.auth-submit {
  padding: 0.875rem 1.5rem;
  font-size: 16px;
  font-weight: 600;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.2s ease;
}

.auth-submit:hover {
  background: var(--primary-light);
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}

.auth-submit:active {
  background: var(--primary-dark);
  transform: translateY(0);
}

.auth-submit:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(139, 111, 71, 0.2);
}

.auth-status {
  min-height: 1.2rem;
  margin: 0.75rem 0 0;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-light);
}

.auth-status.error {
  color: var(--error);
}

.auth-status.success {
  color: var(--success);
}

.auth-preview-link {
  margin-top: 1rem;
  padding: 0.875rem 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-light);
  text-align: left;
}

.auth-preview-link[hidden] {
  display: none !important;
}

.auth-preview-link p {
  margin: 0 0 0.5rem;
  font-size: 13px;
}

.auth-preview-link a {
  color: var(--primary-dark);
  word-break: break-all;
}

.auth-note {
  margin-top: 1rem;
  font-size: 12px;
  color: #888;
}

/* Layout */
#loading,
#chart {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#loading {
  align-items: center;
  justify-content: center;
  padding: 1rem;
  font-size: 16px;
  color: var(--text-light);
}

/* Toolbar */
.chart-toolbar {
  flex-shrink: 0;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-start;
  align-items: center;
  /* Same bar as every other page (.stats-header in stats.css): white, 1px border, same side margins and control size,
     so choosing "Tree" in the menu does not change how the top of the page looks. */
  padding: 0.6rem 20px;
  padding-top: max(0.6rem, env(safe-area-inset-top, 0px));
  gap: 0.5rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg-white);
}
.chart-toolbar .graph-zoom-btn,
.chart-toolbar .zoom-toggle { min-height: 2.25rem; padding: 0 0.8rem; font-size: 13px; font-weight: 600; }
.chart-toolbar .graph-zoom-btn { min-width: 2.25rem; padding: 0; font-size: 1.15rem; }

.chart-toolbar-zoom {
  display: flex;
  flex-shrink: 0;
  gap: 0.4rem;
  align-items: center;
}

.graph-zoom-btn,
.zoom-toggle,
.print-btn {
  min-height: 2.5rem;
  padding: 0.5rem 1rem;
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  background: var(--bg-white);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: all 0.2s ease;
  color: var(--text);
}

.graph-zoom-btn {
  min-width: 2.5rem;
  padding: 0;
  font-size: 1.25rem;
  line-height: 1;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
}

.graph-zoom-btn:hover:not(:disabled),
.zoom-toggle:hover,
.print-btn:hover {
  border-color: var(--primary);
  background: var(--bg-light);
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}

.graph-zoom-btn:active:not(:disabled),
.zoom-toggle:active,
.print-btn:active {
  background: var(--primary-light);
  color: white;
  border-color: var(--primary);
  transform: translateY(0);
}

.graph-zoom-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.graph-zoom-btn:focus-visible,
.zoom-toggle:focus-visible,
.print-btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(139, 111, 71, 0.2);
}

.zoom-toggle[aria-pressed="true"] {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.zoom-toggle[aria-pressed="true"]:hover {
  background: var(--primary-light);
}

.print-btn {
  flex-shrink: 0;
}

/* Search */
.chart-search-wrap {
  position: relative;
  flex: 1 1 12rem;
  min-width: 10rem;
  max-width: 28rem;
  margin-left: auto;
}

.grandtree-search {
  width: 100%;
  min-height: var(--field-min-h);
  padding: var(--field-pad);
  font-family: inherit;
  font-size: var(--field-font);
  border: var(--field-border);
  border-radius: var(--field-radius);
  background: var(--bg-white);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  color: var(--text);
}

.grandtree-search::placeholder {
  color: #999;
}

.grandtree-search:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: var(--field-ring);
}

.grandtree-search-results {
  position: absolute;
  z-index: 20;
  left: 0;
  right: 0;
  top: calc(100% + 4px);
  margin: 0;
  padding: 0.5rem 0;
  list-style: none;
  max-height: min(40vh, 18rem);
  overflow-y: auto;
  background: var(--bg-white);
  border: 1.5px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow-lg);
}

.grandtree-search-results[hidden] {
  display: none !important;
}

.grandtree-search-results li {
  padding: 0.625rem 1rem;
  font-size: 14px;
  cursor: pointer;
  border-bottom: 1px solid #f0ede8;
  transition: background-color 0.15s ease;
  color: var(--text);
}

.grandtree-search-results li:last-child {
  border-bottom: none;
}

.grandtree-search-results li:hover,
.grandtree-search-results li:focus,
.grandtree-search-results li[aria-selected="true"] {
  background: var(--bg-light);
  color: var(--primary);
}

.grandtree-search-results .search-meta {
  display: block;
  font-size: 12px;
  color: #999;
  margin-top: 0.25rem;
}

/* Graph Container */
.container {
  width: 100%;
  flex: 1 1 auto;
  min-height: 0;
  display: block;
  overflow: auto;
  overflow-x: auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  background: var(--bg-white);
  border-top: 1px solid var(--border);
  touch-action: pan-x pan-y;
  -webkit-tap-highlight-color: transparent;
  cursor: grab; /* mouse: drag to move around, wheel to zoom (js/graph.js) */
}
.container.dragging { cursor: grabbing; user-select: none; -webkit-user-select: none; }

.graph-scroll-inner {
  display: inline-block;
  vertical-align: top;
  line-height: 0;
}

#graph {
  display: block;
  flex-shrink: 0;
  max-width: none;
  user-select: none;
  -webkit-user-select: none;
  touch-action: pan-x pan-y;
}

#graph .detailed {
  cursor: pointer;
}

.node {
  cursor: pointer;
}

/* Footer */
footer {
  flex-shrink: 0;
}

.chart-toolbar-account {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.logout-btn {
  min-height: 2.5rem;
  padding: 0.5rem 1rem;
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  background: var(--bg-white);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: all 0.2s ease;
  color: var(--text);
}

.logout-btn:hover {
  border-color: var(--primary);
  background: var(--bg-light);
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}

.logout-btn:active {
  background: var(--primary-light);
  color: white;
  border-color: var(--primary);
  transform: translateY(0);
}

.logout-btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(139, 111, 71, 0.2);
}

.site-footer {
  text-align: center;
  padding: 0.5rem 1rem calc(0.5rem + env(safe-area-inset-bottom, 0px));
  padding-left: max(1rem, env(safe-area-inset-left, 0px));
  padding-right: max(1rem, env(safe-area-inset-right, 0px));
  border-top: 1px solid var(--border);
  background: var(--bg-light);
  font-size: 12px;
}

.footer-content {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  align-items: center;
}

.footer-quicklink {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  justify-content: center;
  flex-wrap: wrap;
}

#quicklink {
  font-size: 11px;
  color: #999;
  word-break: break-all;
  overflow-wrap: anywhere;
  max-width: 100%;
  font-family: 'Monaco', 'Courier New', monospace;
  background: rgba(0, 0, 0, 0.02);
  padding: 0.35rem 0.5rem;
  border-radius: 4px;
}

.copy-link-btn {
  min-width: 1.75rem;
  min-height: 1.75rem;
  padding: 0.25rem;
  font-size: 13px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-white);
  cursor: pointer;
  transition: all 0.2s ease;
  -webkit-tap-highlight-color: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
}

.copy-link-btn:hover {
  border-color: var(--primary);
  background: var(--bg-light);
}

.copy-link-btn:active {
  background: var(--primary);
}

.copy-link-btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px rgba(139, 111, 71, 0.2);
}

.copy-link-btn.copied {
  color: var(--success);
  border-color: var(--success);
}

.footer-meta {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  justify-content: center;
  flex-wrap: wrap;
  font-size: 10px;
}

#released {
  color: #999;
}

.footer-sep {
  color: #ccc;
}

.footer-credit {
  color: #999;
  font-weight: 500;
}

#start {
  text-align: center;
}

/* Mobile Responsive */
@media (max-width: 768px) {
  .chart-toolbar {
    padding: 0.5rem 12px;
    padding-top: max(0.5rem, env(safe-area-inset-top, 0px));
    gap: 0.4rem;
  }

  .graph-zoom-btn,
  .zoom-toggle,
  .print-btn {
    min-height: 2.25rem;
    padding: 0.4rem 0.75rem;
    font-size: 13px;
  }

  .graph-zoom-btn {
    min-width: 2.25rem;
  }

  .chart-search-wrap {
    flex: 1 1 8rem;
    min-width: 8rem;
  }

  .auth-card {
    padding: 2rem;
    width: 95%;
  }

  .auth-card h1 {
    font-size: 1.5rem;
  }

  .site-footer {
    padding: 0.4rem 0.75rem calc(0.4rem + env(safe-area-inset-bottom, 0px));
  }

  #quicklink {
    font-size: 10px;
  }

  .footer-meta {
    font-size: 9px;
  }

  .copy-link-btn {
    min-width: 1.5rem;
    min-height: 1.5rem;
    font-size: 11px;
  }
}

@media (max-width: 480px) {
  /* Stay a wrapping row: a column flexbox with flex-wrap makes Safari (WebKit) resolve
     flex-basis percentages against the height and split the toolbar into columns. */
  .chart-toolbar {
    padding: 0.5rem 12px;
    padding-top: max(0.5rem, env(safe-area-inset-top, 0px));
    gap: 0.4rem;
  }

  .chart-search-wrap {
    flex: 1 1 100%;
    width: 100%;
    max-width: none;
    margin-left: 0;
  }

  .zoom-toggle,
  .print-btn {
    flex: 1 1 auto;
    min-width: 0;
  }

  .chart-toolbar-account {
    width: 100%;
    justify-content: space-between;
  }

  .graph-zoom-btn,
  .zoom-toggle,
  .print-btn,
  .logout-btn {
    min-height: 2.25rem;
    font-size: 13px;
    padding: 0.4rem 0.6rem;
  }

  .auth-card {
    padding: 1.75rem;
    width: 92%;
    border-radius: 12px;
  }

  .auth-card h1 {
    font-size: 1.4rem;
    margin-bottom: 0.5rem;
  }

  .auth-card p {
    font-size: 14px;
  }

  .auth-input,
  .auth-submit {
    font-size: 16px;
  }

  .site-footer {
    padding: 0.35rem 0.5rem calc(0.35rem + env(safe-area-inset-bottom, 0px));
  }

  .footer-content {
    gap: 0.25rem;
  }

  #quicklink {
    font-size: 9px;
  }

  .footer-meta {
    font-size: 8px;
  }

  .copy-link-btn {
    min-width: 1.5rem;
    min-height: 1.5rem;
    font-size: 11px;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Site menu (shared across pages) */
.site-nav { flex: 1 1 100%; min-width: 0; position: relative; }
.nav-burger { display: none; }
.nav-panel { display: flex; align-items: center; flex-wrap: wrap; gap: 0.4rem; }
.nav-link {
  display: inline-flex; align-items: center; gap: 0.35rem; min-height: 2.25rem; padding: 0.35rem 0.7rem;
  font-family: inherit; font-size: 14px; font-weight: 500; line-height: 1.2; text-decoration: none; color: var(--text);
  white-space: nowrap; border: 1.5px solid transparent; border-radius: 8px; background: transparent; cursor: pointer;
  -webkit-appearance: none; appearance: none; -webkit-tap-highlight-color: transparent;
}
.nav-link:hover { background: var(--bg-light); border-color: var(--border); }
.nav-link[aria-current="page"] { background: var(--primary); color: #fff; border-color: var(--primary); }
.nav-link:focus-visible, .nav-lang:focus-visible, .nav-burger:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(139, 111, 71, 0.3); }
.nav-spacer { flex: 1 1 auto; }
.nav-lang, .nav-burger {
  min-height: 2.25rem; padding: 0.35rem 0.8rem; font-family: inherit; font-size: 13px; font-weight: 700; line-height: 1.2;
  border: 1.5px solid var(--border); border-radius: 8px; background: var(--bg-white); color: var(--text); cursor: pointer;
  -webkit-appearance: none; appearance: none; -webkit-tap-highlight-color: transparent;
}
.nav-lang:hover, .nav-burger:hover { border-color: var(--primary); background: var(--bg-light); }
.nav-lang { font-size: 1rem; padding: 0.35rem 0.6rem; }
.edit-relation { margin: 12px 0; padding: 8px 12px 10px; border: 1px solid var(--border); border-radius: 8px; }
.edit-relation legend { padding: 0 6px; font-weight: 600; font-size: .9rem; }
.edit-relation .tr-grid { margin-bottom: 4px; }
.site-nav .logout-btn { min-height: 2.25rem; padding: 0.35rem 0.8rem; white-space: nowrap; }
.auth-lang { position: fixed; z-index: 10; top: max(0.75rem, env(safe-area-inset-top, 0px)); right: max(0.75rem, env(safe-area-inset-right, 0px)); }
.footer-shortcuts { opacity: 0.8; }
.stats-header .site-nav { flex: 1 1 100%; }
.stats-header h1 { flex: 1 1 100%; }

/* Compact menu ("☰ Menu" button + drop-down panel). js/nav.js sets .nav-compact at 1100px and below, and on wider
   screens whenever the full menu would not fit on one row (language, member's name, window width). */
.site-nav.nav-compact { flex: 0 0 auto; }
.stats-header .site-nav.nav-compact { flex: 1 1 100%; }
.nav-compact .nav-burger { display: inline-flex; align-items: center; gap: 0.4rem; }
.nav-compact .nav-panel {
  display: none; position: absolute; z-index: 1000; top: calc(100% + 0.3rem); left: 0; min-width: 14rem;
  max-width: calc(100vw - 1rem); max-height: calc(100vh - 5rem); max-height: calc(100dvh - 5rem);
  overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain;
  flex-direction: column; flex-wrap: nowrap; align-items: stretch; padding: 0.5rem; background: var(--bg-white);
  border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
}
.site-nav.nav-compact.open .nav-panel { display: flex; }
.nav-compact .nav-panel > * { flex-shrink: 0; }
.nav-compact .nav-link { min-height: 2.75rem; }
.nav-compact .nav-spacer { display: none; }
@media (max-width: 768px) {
  .footer-shortcuts, .footer-shortcuts + .footer-sep { display: none; }
}
@media print { .site-nav { display: none !important; } }

/* Person details panel */
.chart-body { flex: 1 1 auto; min-height: 0; display: flex; }
.chart-body .container { flex: 1 1 auto; min-width: 0; width: auto; }
.detail-panel { position: relative; flex: 0 0 320px; max-width: 40vw; overflow-y: auto; padding: 1rem; background: var(--bg-white); border-left: 1px solid var(--border); box-shadow: -2px 0 8px rgba(0,0,0,.05); }
.detail-panel[hidden] { display: none; }
.detail-close { position: absolute; top: .4rem; right: .5rem; border: 0; background: transparent; font-size: 1.5rem; line-height: 1; cursor: pointer; color: var(--text-light); }
.detail-head { border-left: 4px solid #999; padding-left: .6rem; margin-bottom: .6rem; }
.detail-head.detail-sex-M { border-color: #4a7fb5; }
.detail-head.detail-sex-F { border-color: #c8607a; }
.detail-head h2 { margin: 0; font-size: 1.15rem; color: var(--primary-dark); padding-right: 1.5rem; }
.detail-sub, .detail-meta, .detail-id, .detail-none { margin: .15rem 0; font-size: .8rem; color: var(--text-light); }
.detail-event { margin: .25rem 0; font-size: .9rem; }
.detail-section h3 { margin: .9rem 0 .3rem; font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--primary-dark); }
.detail-link { display: block; width: 100%; text-align: left; font: inherit; font-size: .9rem; padding: .3rem .4rem; border: 0; border-radius: 6px; background: transparent; color: var(--primary); cursor: pointer; }
.detail-link:hover { background: var(--bg-light); }
.detail-years { color: var(--text-light); font-size: .8rem; }
.detail-spouse .detail-meta { display: block; padding-left: .4rem; }
.detail-actions { display: flex; flex-direction: column; gap: .35rem; margin-top: 1rem; }
.detail-action { padding: .45rem .6rem; border: 1.5px solid var(--border); border-radius: 8px; text-decoration: none; color: var(--text); font-size: .85rem; }
.detail-action:hover { border-color: var(--primary); background: var(--bg-light); }
@media (max-width: 768px) {
  .chart-body { flex-direction: column; }
  .detail-panel { position: relative; max-width: none; max-height: 55%; flex: none; border-left: 0; border-top: 1px solid var(--border); box-shadow: 0 -4px 12px rgba(0,0,0,.12); }
}
@media print { .detail-panel, #detail-toggle { display: none !important; } }

/* Shown when the admin published a newer family tree while this tab was open. */
.tree-update-bar {
  position: fixed; z-index: 2000; left: 50%; transform: translateX(-50%);
  bottom: max(1rem, env(safe-area-inset-bottom, 0px)); max-width: calc(100vw - 2rem);
  display: flex; align-items: center; gap: .75rem; padding: .6rem .6rem .6rem 1rem;
  background: var(--primary-dark); color: #fff; border-radius: 10px; box-shadow: var(--shadow-lg); font-size: 14px;
}
.tree-update-bar button {
  font: inherit; font-weight: 600; padding: .35rem .8rem; border: 0; border-radius: 6px;
  background: #fff; color: var(--primary-dark); cursor: pointer;
}
@media print { .tree-update-bar { display: none !important; } }

/* "Send by e-mail" (mailto:) next to invitation links */
.gt-mail-btn { display: inline-flex; align-items: center; gap: .3rem; text-decoration: none; white-space: nowrap; }

/* Login page: public "about the project" dialog */
.about-open-wrap { margin: 1.25rem 0 0; }
.about-open {
  display: inline-flex; align-items: center; gap: .35rem; padding: .45rem .9rem; border-radius: 999px;
  border: 1.5px solid var(--border); color: var(--primary-dark); font-weight: 600; font-size: 14px; text-decoration: none;
  background: var(--bg-light);
}
.about-open:hover { border-color: var(--primary); background: var(--bg-white); }
.about-dialog {
  width: min(640px, calc(100vw - 2rem)); max-height: calc(100dvh - 2rem); overflow-y: auto; overscroll-behavior: contain;
  padding: 0 1.75rem 1.5rem; border: 0; border-radius: 16px; color: var(--text); background: var(--bg-white);
  box-shadow: 0 20px 60px rgba(0, 0, 0, .25); font-size: 15px; line-height: 1.55;
}
.about-dialog::backdrop { background: rgba(58, 45, 30, .45); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); }
.about-dialog[open] { animation: about-in .22s ease-out; }
@keyframes about-in { from { opacity: 0; transform: translateY(12px) scale(.98); } to { opacity: 1; transform: none; } }
.about-close {
  position: sticky; top: .75rem; float: right; margin-right: -.75rem; width: 2.25rem; height: 2.25rem; border-radius: 50%;
  border: 0; background: var(--bg-light); color: var(--text-light); font-size: 1.4rem; line-height: 1; cursor: pointer; z-index: 1;
}
.about-close:hover { background: var(--border); color: var(--text); }
.about-hero {
  text-align: center; margin: 0 -1.75rem 1rem; padding: 2rem 1.75rem 1.25rem;
  background: linear-gradient(180deg, #f3ece2 0%, var(--bg-white) 100%);
}
.about-emoji { font-size: 3rem; line-height: 1; }
.about-hero h2 { margin: .4rem 0 .2rem; font-size: 1.8rem; color: var(--primary); }
.about-tagline { margin: 0; color: var(--primary-dark); font-style: italic; }
.about-dialog h3 { margin: 1.4rem 0 .5rem; font-size: 1rem; color: var(--primary-dark); }
.about-dialog p { margin: .5rem 0; }
.about-features { list-style: none; margin: .5rem 0; padding: 0; display: grid; gap: .55rem; }
.about-features li { display: flex; gap: .7rem; align-items: flex-start; }
.about-features li > span:first-child { flex: 0 0 1.6rem; font-size: 1.2rem; text-align: center; }
.about-sign { margin-top: 1.4rem !important; text-align: center; color: var(--text-light); font-size: 14px; }
.about-actions { display: flex; justify-content: center; margin-top: .75rem; }
.about-actions .auth-submit { min-width: 12rem; }
@media (max-width: 480px) {
  .about-dialog { padding: 0 1.1rem 1.25rem; font-size: 14.5px; }
  .about-hero { margin: 0 -1.1rem 1rem; padding: 1.5rem 1.1rem 1rem; }
  .about-close { margin-right: -.35rem; }
}

.gt-share { display: inline-flex; flex-wrap: wrap; gap: 8px; }
.gt-wa-btn { display: inline-flex; align-items: center; text-decoration: none; white-space: nowrap; }
.gt-wa-btn::before { content: ''; width: .7rem; height: .7rem; border-radius: 50%; background: #25d366; margin-right: .4rem; }

/* Invitation actions (profile and admin tables) */
.gt-inv-actions { white-space: nowrap; }
.gt-inv-actions .gt-inv-btn { min-height: 2rem; padding: .25rem .7rem; font-size: 13px; margin: 2px 4px 2px 0; }
.gt-inv-actions .gt-inv-primary { border-color: var(--primary); color: var(--primary-dark); }
.gt-share .gt-inv-primary { border-color: var(--primary); color: var(--primary-dark); font-weight: 600; }
.gt-inv-share td { background: var(--bg-light); }
.gt-inv-share-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.gt-inv-share-row .auth-input { flex: 1 1 260px; min-width: 0; }
.gt-inv-share-row .gt-inv-btn { min-height: 2.3rem; }
.gt-inv-note { margin: 4px 0 6px; font-size: .8rem; color: var(--text-light); }

/* Compact, discreet footer: one wrapping row, muted colours. */
.site-footer { padding: 0.25rem 0.75rem calc(0.25rem + env(safe-area-inset-bottom, 0px)); background: transparent; border-top: 1px solid var(--border); }
.site-footer .footer-content { flex-direction: row; flex-wrap: wrap; justify-content: center; align-items: center; gap: 0.15rem 0.9rem; }
.site-footer #quicklink { padding: 0; background: none; font-size: 10px; color: #aaa; }
.site-footer .copy-link-btn { min-width: 1.35rem; min-height: 1.35rem; padding: 0; font-size: 10px; border-color: transparent; background: transparent; opacity: 0.6; }
.site-footer .copy-link-btn:hover { opacity: 1; }
.site-footer .footer-meta { font-size: 10px; gap: 0.3rem; }
.site-footer .footer-credit { font-weight: 400; }
.site-footer .footer-sep { color: #ccc; }
.footer-contact { color: #999; text-decoration: none; border-bottom: 1px dotted currentColor; transition: color 0.2s; }
.footer-contact:hover, .footer-contact:focus-visible { color: var(--primary); outline: none; }
.stats-footer .footer-contact { color: inherit; }
@media (max-width: 768px) {
  .site-footer .footer-content { gap: 0.1rem 0.6rem; }
  .site-footer #quicklink, .site-footer .footer-meta { font-size: 9px; }
  .footer-shortcuts-sep { display: none; }
}

/* Auth pages (login, join, admin login): the app shell is overflow:hidden, these pages must scroll (iPhone). */
html:has(body.auth-page), body.auth-page { height: auto; min-height: 100%; overflow: visible; overflow-y: auto; -webkit-overflow-scrolling: touch; }
body.auth-page { display: block; }
body.auth-page .auth-shell { padding-top: max(1.5rem, env(safe-area-inset-top, 0px)); padding-bottom: max(1.5rem, env(safe-area-inset-bottom, 0px)); }
.req-dialog { width: min(440px, calc(100vw - 2rem)); max-height: calc(100dvh - 2rem); overflow-y: auto; overscroll-behavior: contain; padding: 1.5rem 1.5rem 1.25rem; border: 0; border-radius: 16px; color: var(--text); background: var(--bg-white); box-shadow: 0 20px 60px rgba(0, 0, 0, .25); }
.req-dialog::backdrop { background: rgba(58, 45, 30, .45); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); }
.req-dialog h2 { margin: 0 0 .5rem; font-size: 1.3rem; color: var(--primary); text-align: center; }
.req-dialog textarea.auth-input { resize: vertical; }
.req-actions { display: flex; gap: .6rem; }
.req-actions > * { flex: 1; }
.auth-help { margin: 1.25rem 0 0; padding-top: 1rem; border-top: 1px solid var(--border); }
.auth-help p { margin: 0 0 .75rem !important; font-size: 14px; }
html.auth-html { height: auto; min-height: 100%; overflow: visible; overflow-y: auto; }

/* Delete my account (profile) */
.prof-delete { margin-top: 1.5rem; padding-top: 1rem; border-top: 1px solid var(--border); }
.prof-delete .prof-row { flex-wrap: wrap; }
.prof-delete .prof-row[hidden], .prof-row[hidden] { display: none; }
.prof-danger { color: #b3261e; border-color: #e5b8b4; }
.prof-danger:hover { background: #fdf3f2; border-color: #b3261e; }

.auth-card .auth-brand { margin: -.55rem 0 .9rem 0; font-size: .75rem; letter-spacing: .14em; text-transform: uppercase; color: var(--text-light); }
.auth-logo { display: block; margin: 0 auto .6rem; border-radius: 16px; box-shadow: 0 4px 14px rgba(122, 95, 59, .3); }

/* Login page: "Découvrir le projet" sits centred under the sign-in block, set apart by a divider. */
.auth-card .about-open-wrap { margin: 1.5rem 0 0; padding-top: 1.25rem; border-top: 1px solid var(--border); text-align: center; }
.auth-card .auth-help p:last-child { margin-bottom: 0; }
.auth-card .auth-help .logout-btn { display: block; margin: 0 auto; }

.maint-emoji { font-size: 2rem; margin: .25rem 0 .75rem; }
.maint-admin { display: inline-flex; align-items: center; text-decoration: none; }

/* The profile link carries the member's name (replaces the separate e-mail pill). */
.nav-link .nav-name { display: inline-block; max-width: 11rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: bottom; }

/* Date field with a calendar button, and the shared autocomplete look (js/fields.js) */
.gt-date { position: relative; display: flex; gap: 6px; align-items: stretch; }
.gt-date > input[type="text"] { flex: 1 1 auto; min-width: 0; }
.gt-date-btn { flex: 0 0 auto; min-width: var(--field-min-h); min-height: var(--field-min-h); border: var(--field-border); border-radius: var(--field-radius); background: var(--bg-white); font-size: 1.1rem; cursor: pointer; line-height: 1; }
.gt-date-btn:hover { border-color: var(--primary); background: var(--bg-light); }
.gt-date-btn:focus-visible { outline: none; box-shadow: var(--field-ring); border-color: var(--primary); }
.gt-date-pick { position: relative; flex: 0 0 auto; display: flex; }
.gt-date-native { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; padding: 0; border: 0; opacity: 0; font-size: 16px; cursor: pointer; z-index: 1; -webkit-appearance: none; appearance: none; }
.gt-date-pick:focus-within .gt-date-btn { border-color: var(--primary); }
.edit-note { display: flex; flex-direction: column; gap: 4px; margin: 10px 0; font-weight: 600; font-size: .8rem; color: var(--primary-dark); }
.edit-note textarea { resize: vertical; font-weight: 400; }
.edit-note-text { white-space: pre-wrap; background: var(--bg-light); border-radius: 8px; padding: .5rem .75rem; margin: 6px 0; }
textarea.auth-input { font-family: inherit; line-height: 1.4; }
select.auth-input, .st-f select, .cal-field select, .viz-field select { height: var(--field-min-h); }

/* Person form (member /edit page and admin): one grid, one label style, like the other forms of the site */
.tr-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 10px 20px; margin: 8px 0; }
.tr-grid > label[hidden] { display: none; }
.tr-grid > label { display: flex; flex-direction: column; gap: 4px; font-size: .8rem; font-weight: 600; color: var(--primary-dark); min-width: 0; }
.tr-grid > label:has(> input[type="checkbox"]) { flex-direction: row; align-items: center; gap: 8px; font-size: .9rem; font-weight: 400; color: var(--text); }
.tr-grid > label > input, .tr-grid > label > select, .tr-grid > label > .gt-date { font-weight: 400; }
.tr-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 8px 0; }
.tr-btn { display: inline-flex; align-items: center; text-decoration: none; padding: .5rem .9rem; font-size: 14px; }
#individual-panel label[for="individual-search"] { display: block; font-size: .8rem; font-weight: 600; color: var(--primary-dark); margin-bottom: 4px; }
#individual-proposals table { width: 100%; border-collapse: collapse; font-size: .9rem; margin: 6px 0; }
#individual-proposals td { padding: 3px 8px; border-top: 1px solid var(--border); vertical-align: top; }
#individual-proposals caption { text-align: left; font-size: .8rem; color: var(--text-light); padding-bottom: 4px; }

/* Person search in the menu bar (replaces the "Tree" link) */
.nav-search { flex: 1 1 200px; min-width: 9rem; max-width: 26rem; margin: 0; display: flex; align-items: center; gap: 6px; }
.nav-search .nav-search-input { flex: 1 1 auto; min-width: 0; width: auto; }
/* Small "Tree" button beside the search bar */
.nav-tree { flex: 0 0 auto; display: inline-flex; align-items: center; gap: 4px; min-height: 2.25rem; padding: 0 .6rem; border: var(--field-border); border-radius: var(--field-radius); background: var(--bg-white); color: var(--text); text-decoration: none; font-size: 13px; font-weight: 600; white-space: nowrap; }
.nav-tree:hover { border-color: var(--primary); background: var(--bg-light); }
.nav-tree:focus-visible { outline: none; box-shadow: var(--field-ring); border-color: var(--primary); }
@media (max-width: 480px) { .nav-tree-label { display: none; } }
.nav-search[hidden] { display: none; }
.nav-search-input { width: 100%; min-height: 2.25rem; padding: 0.3rem 0.75rem; font: inherit; font-size: var(--field-font); border: var(--field-border); border-radius: var(--field-radius); background: var(--bg-white); color: var(--text); }
.nav-search-input:focus { outline: none; border-color: var(--primary); box-shadow: var(--field-ring); }
.site-nav { display: flex; align-items: center; flex-wrap: wrap; gap: 0.4rem; }
/* Full menu on one row: the search bar gives up width first (down to 10rem) before the menu turns compact. */
/* Full menu: one row that never wraps (a wrapping row would move the links down before shrinking anything). The search
   bar gives up width first, down to 15rem; the links keep their natural width. If that still overflows, js/nav.js
   switches to the compact menu. */
.site-nav:not(.nav-compact) { flex-wrap: nowrap; }
.site-nav:not(.nav-compact) .nav-search { flex: 0 1 18rem; min-width: 15rem; } /* 🌳 button + a field still usable to type a name */
.site-nav:not(.nav-compact) .nav-panel { flex: 1 0 auto; flex-wrap: nowrap; }
.nav-search-tree .chart-search-wrap { flex: 1 1 auto; min-width: 0; max-width: none; margin: 0; }
.nav-tree[aria-current="page"] { background: var(--primary); border-color: var(--primary); color: #fff; }

/* Administrator "navigating as" a member */
.gt-impersonation { position: sticky; top: 0; z-index: 1000; display: flex; gap: 12px; align-items: center; justify-content: center; flex-wrap: wrap; padding: 8px 12px; background: #b3261e; color: #fff; font-size: .9rem; text-align: center; }
.gt-impersonation button { background: #fff; color: #b3261e; border: 0; border-radius: 6px; padding: 4px 12px; font: inherit; font-weight: 700; cursor: pointer; }

/* "Question of the day" (js/question.js): a card on /edit, a bubble on the tree page */
.gt-question-ask { font-weight: 600; margin: 0.4rem 0 0.2rem; }
.gt-question-kin { margin: 0 0 0.5rem; }
.gt-question-form { display: flex; flex-direction: column; gap: 0.5rem; }
.gt-question-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.gt-question-actions .prof-linkish { font-size: 0.9rem; }
.gt-question-bubble { position: fixed; z-index: 1400; left: max(16px, env(safe-area-inset-left, 0px)); bottom: calc(4.5rem + env(safe-area-inset-bottom, 0px));
  width: min(22rem, calc(100vw - 32px)); padding: 0.9rem 1rem; background: var(--bg-white); color: var(--text);
  border: 1px solid var(--border); border-left: 4px solid var(--accent); border-radius: 12px; box-shadow: var(--shadow-lg); }
.gt-question-bubble .gt-question-title { display: block; padding-right: 1.5rem; color: var(--primary-dark); }
.gt-question-close { position: absolute; top: 0.35rem; right: 0.5rem; border: 0; background: none; font-size: 1.4rem; line-height: 1; color: var(--text-light); cursor: pointer; padding: 0.2rem 0.4rem; }
.gt-question-bubble .auth-status { margin: 0.4rem 0; }
@media (max-width: 600px) { .gt-question-bubble { bottom: calc(5.5rem + env(safe-area-inset-bottom, 0px)); } }



/* Invitation by link: "I do not have their e-mail" */
.prof-nomail { display: inline-flex; align-items: center; gap: 6px; font-size: .9rem; }
.prof-nomail[hidden], .auth-input[hidden] { display: none; }

/* Member sign-in page: one passkey button, one code form, two quiet links */
.login-sep { display: flex; align-items: center; gap: .75rem; margin: 1rem 0 .6rem; color: var(--text-light); font-size: .85rem; }
.login-sep[hidden] { display: none; }
.login-sep::before, .login-sep::after { content: ""; flex: 1; border-top: 1px solid var(--border); }
.login-hint { margin: .1rem 0 .2rem; font-size: .85rem; color: var(--text-light); text-align: left; }
.login-links { margin: 1.2rem 0 .4rem; font-size: .9rem; color: var(--text-light); display: flex; flex-wrap: wrap; justify-content: center; gap: .2rem 1.6rem; }
.login-link { background: none; border: 0; padding: .35rem .15rem; font: inherit; color: var(--primary-dark); text-decoration: underline; cursor: pointer; }
.auth-form button[hidden], #passkey-btn[hidden] { display: none; }

/* Member not linked to a record yet */
.gt-limited { position: sticky; top: var(--gt-imp-h, 0px); z-index: 999; padding: 8px 12px; background: #fff7e6; border-bottom: 1px solid #f0d9a8; color: #5b4720; font-size: .9rem; text-align: center; }
.gt-limited a { color: #6b5637; font-weight: 700; }
.gt-limited span { margin-right: .4em; }
.prof-welcome { font-size: 1rem; color: var(--text); }

/* Batch review of proposals (administrator) */
.batch-bar { position: sticky; top: 0; z-index: 5; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 8px 10px; margin: 0 0 10px; background: var(--bg, #faf8f5); border: 1px solid var(--border); border-radius: 10px; }
.batch-bar[hidden] { display: none; }
.batch-count { flex: 1 1 auto; font-size: .9rem; color: var(--text-light); }
.batch-pick { display: inline-flex; align-items: center; gap: 6px; font-size: .9rem; margin: 0 0 6px; }
.batch-dialog { max-width: min(760px, 94vw); }
.batch-table { width: 100%; border-collapse: collapse; margin: .6rem 0; }
.batch-table td { padding: 8px 6px; border-top: 1px solid var(--border); vertical-align: top; text-align: left; }
.batch-conflict { background: #fff7e6; }

/* ---- Cross-page consistency (one place for what every page shares) ---- */
:root { --page-max: 1400px; --page-pad: 20px; }
/* Native checkboxes, radios and sliders follow the brand colour instead of the browser's blue. */
input[type="checkbox"], input[type="radio"], input[type="range"], progress { accent-color: var(--primary); }
/* Quiet text link / button used inside cards (also on the tree page, which does not load profile.css). */
.prof-linkish { display: inline-block; margin: 6px 0; padding: 0; border: 0; background: none; color: var(--primary); font: inherit; font-size: .88rem; text-decoration: underline; cursor: pointer; }

/* Same page gutter and width on every tool page (stats, map, network, history, calendar). */
.stats-main, .viz-main, .history-main, .cal-main { max-width: var(--page-max); margin-left: auto; margin-right: auto; padding: var(--page-pad); }
@media (max-width: 520px) { :root { --page-pad: 12px; } }
/* Card titles: same colour and size everywhere (member and admin). */
.stat-chart > h3:not(.prof-h3), .gt-question-title { color: var(--primary-dark); font-size: 1rem; }
.stat-chart h2, .cal-h { font-size: 1rem; color: var(--primary-dark); }
/* Selects outside the shared field classes (history speed...) get the same look. */
.history-controls select { font: inherit; font-size: var(--field-font); padding: var(--field-pad); min-height: var(--field-min-h); border: var(--field-border); border-radius: var(--field-radius); background: var(--bg-white); color: var(--text); }
.history-controls select:focus { outline: none; border-color: var(--primary); box-shadow: var(--field-ring); }
/* Sign-in pages (member and admin) share the same look: left-aligned labels above full-width fields. */
.auth-form > label { text-align: left; font-size: .85rem; font-weight: 600; color: var(--primary-dark); margin-bottom: -.4rem; }
.auth-note.login-sep, p.login-sep { text-align: center; }
.auth-card p.login-sep { margin: 1rem 0 .8rem; }

/* Events: the two views (Calendar / Announce) as tabs under the page title */
.ev-tabs { display: flex; gap: 6px; padding: 8px var(--page-pad, 20px) 0; background: var(--bg-light); }
.ev-tabs a { padding: .4rem .95rem; border: 1.5px solid var(--border); border-radius: 999px; background: var(--bg-white); color: var(--text); text-decoration: none; font-size: 14px; font-weight: 500; }
.ev-tabs a:hover { border-color: var(--primary); }
.ev-tabs a[aria-current="page"] { background: var(--primary); border-color: var(--primary); color: #fff; }
.ev-tabs-narrow { max-width: calc(960px + 2 * var(--page-pad, 20px)); margin: 0 auto; }

/* Small notification dot (family news) on "My profile" and on the compact menu button */
.nav-dot { display: inline-block; flex: none; width: .6rem; height: .6rem; margin-left: .35rem; border-radius: 50%; background: #d9534f; box-shadow: 0 0 0 2px var(--bg-white); }
.nav-link[aria-current="page"] .nav-dot { box-shadow: 0 0 0 2px var(--primary); }

/* Invitation, last step: the two ways to sign in presented as two clear options */
.join-opt { margin: 12px 0; padding: 14px 16px; border: 1.5px solid var(--border); border-radius: 12px; background: var(--bg-white); text-align: left; }
.join-opt-secure { border-color: var(--primary); }
.join-opt h2 { margin: 0 0 6px; font-size: 1rem; color: var(--primary-dark); }
.auth-card .join-opt p { margin: 0 0 10px; font-size: .88rem; color: var(--text-light); line-height: 1.45; }
.join-tag { display: inline-block; margin-left: 6px; padding: 1px 8px; border-radius: 999px; background: var(--bg-light); border: 1px solid var(--border); color: var(--primary-dark); font-size: .72rem; font-weight: 600; vertical-align: middle; }
.join-or { margin: 4px 0; text-align: center; font-size: .85rem; color: var(--text-light); }
.auth-card .join-or { margin: 0; }
