:root {
  /* Shared type, spacing and control sizes are defined in css/ui.css, loaded after page styles. */
  --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;
}

/* Suggestion list of every person / place field (js/fields.js): the same look as the tree's search results, placed under its field. */
.gt-suggest {
  position: fixed;
  z-index: 3000;
  margin: 0;
  padding: 0.25rem 0;
  list-style: none;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--bg-white);
  border: 1.5px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow-lg);
  text-align: left;
}

.gt-suggest[hidden] {
  display: none !important;
}

.gt-suggest li {
  padding: 0.6rem 0.9rem;
  font-size: 14px;
  line-height: 1.3;
  cursor: pointer;
  color: var(--text);
  border-bottom: 1px solid #f0ede8;
}

.gt-suggest li:last-child {
  border-bottom: none;
}

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

/* 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;
}

/* Zoomed far out the texts are under ~2.5 px: not drawn (js/graph-cull.js). */
#graph.gt-far text,
#graph.gt-far clipPath {
  display: none;
}

.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: var(--btn-h);
  padding: 0.4rem 0.9rem;
  font-family: inherit;
  font-size: var(--btn-font);
  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; }
.nav-invite { display: inline-flex; align-items: center; justify-content: center; min-height: 2.25rem; padding: 0.35rem 0.6rem; font-size: 1rem; line-height: 1.2; text-decoration: none; border: 1.5px solid var(--border); border-radius: 8px; background: var(--bg-white); }
.nav-invite:hover { border-color: var(--primary); background: var(--bg-light); }
.nav-invite:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(139, 111, 71, 0.3); }
.nav-invite[hidden] { display: none; }
.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; }
}
/* Grouped navigation: a short desktop row; direct links under headings in the compact menu. */
.site-nav [hidden] { display: none !important; }
.site-nav .nav-link, .nav-group-toggle { min-height: 44px; font-size: 1rem; }
.nav-group { position: relative; flex: 0 0 auto; }
.nav-group-toggle { display: inline-flex; align-items: center; gap: .5rem; padding: .35rem .7rem; font: inherit; font-size: 1rem; line-height: 1.2; color: var(--text); border: 1.5px solid transparent; border-radius: 8px; background: transparent; cursor: pointer; white-space: nowrap; }
.nav-group-toggle:hover, .nav-group.open > .nav-group-toggle { border-color: var(--border); background: var(--bg-light); }
.nav-group-current > .nav-group-toggle { color: var(--primary-dark); border-color: var(--border); background: var(--bg-light); font-weight: 600; }
.nav-group-toggle:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }
.nav-group-items { display: none; position: absolute; top: calc(100% + .4rem); left: 0; z-index: 1000; min-width: 15rem; max-width: calc(100vw - 2rem); max-height: calc(100dvh - var(--gt-bars-h, 0px) - 7rem); overflow-y: auto; padding: .5rem; border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow-lg); background: var(--bg-white); }
.nav-group.open > .nav-group-items { display: grid; gap: .25rem; }
.nav-group-items .nav-link { display: flex; white-space: normal; line-height: 1.4; }
.nav-group-heading, .nav-account-heading, .nav-invite-label { display: none; }
.nav-account { display: flex; align-items: center; gap: .4rem; }
.site-nav .nav-burger, .site-nav .nav-lang, .site-nav .nav-invite, .site-nav #logout-btn { min-height: var(--btn-h); min-width: var(--btn-h); }
.site-nav .nav-burger, .site-nav #logout-btn { font-size: var(--btn-font); }
.nav-compact .nav-panel { width: min(32rem, calc(100vw - 2rem)); max-height: calc(100vh - var(--gt-bars-h, 0px) - 6rem); max-height: calc(100dvh - var(--gt-bars-h, 0px) - 6rem - env(safe-area-inset-bottom, 0px)); }
.nav-compact .nav-group { border-top: 1px solid var(--border); padding-top: .5rem; }
.nav-compact .nav-group-toggle { display: none; }
.nav-compact .nav-group-heading, .nav-compact .nav-account-heading { display: block; margin: 0; padding: .25rem .7rem .4rem; font-size: 1rem; line-height: 1.4; font-weight: 600; color: var(--primary-dark); }
.nav-compact .nav-group-items, .nav-compact .nav-group.open > .nav-group-items { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .25rem; position: static; min-width: 0; max-width: none; max-height: none; overflow: visible; border: 0; border-radius: 0; box-shadow: none; padding: 0; }
.nav-compact .nav-link { white-space: normal; line-height: 1.4; }
.nav-compact .nav-account { flex-wrap: wrap; align-items: stretch; border-top: 1px solid var(--border); padding-top: .5rem; }
.nav-compact .nav-account-heading, .nav-compact .nav-account > .nav-link, .nav-compact .nav-account > .nav-invite { flex: 1 1 100%; }
.nav-compact .nav-account .nav-name { max-width: 100%; white-space: normal; overflow-wrap: anywhere; }
.nav-compact .nav-invite { justify-content: flex-start; gap: .5rem; font-size: 1rem; }
.nav-compact .nav-invite-label { display: inline; }
.nav-compact #logout-btn { flex: 1 1 auto; }
@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: .3rem; right: .4rem; z-index: 2; width: 2.25rem; height: 2.25rem; display: flex; align-items: center; justify-content: center; border: 0; border-radius: 8px; background: transparent; cursor: pointer; color: var(--text-light); }
.detail-close:hover { background: var(--bg-light); color: var(--primary-dark); }
/* One chevron for both states (as in Topola Viewer): → folds the open panel, ← unfolds the strip; ↓ / ↑ at the bottom of a phone. */
.detail-chevron { display: inline-block; font-size: 1.6rem; line-height: 1; transition: transform .15s ease; }
.detail-panel.collapsed .detail-chevron { transform: rotate(180deg); }
.detail-strip { display: none; }
.detail-panel.collapsed { flex: 0 0 44px; max-width: none; padding: 0; overflow: hidden; }
.detail-panel.collapsed #detail-body { display: none; }
.detail-panel.collapsed .detail-close { left: 0; right: 0; margin: 0 auto; top: .3rem; }
.detail-panel.collapsed .detail-strip { display: flex; position: absolute; inset: 0; padding: 3rem 0 .75rem; border: 0; background: transparent; cursor: pointer; align-items: center; justify-content: center; }
.detail-panel.collapsed .detail-strip:hover { background: var(--bg-light); }
.detail-strip-name { writing-mode: vertical-rl; transform: rotate(180deg); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-height: 100%; font-weight: 700; font-size: 1rem; color: var(--primary-dark); }
.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: 2.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: .92rem; padding: .3rem 0; border: 0; border-radius: 0; background: transparent; color: var(--primary); cursor: pointer; box-shadow: none; min-height: 0; }
.detail-link:hover { background: transparent; text-decoration: underline; text-underline-offset: 3px; }
.detail-years { color: var(--text-light); font-size: .8rem; }
.detail-spouse .detail-meta { display: block; padding-left: .4rem; }
.detail-birthday { display: block; width: 100%; margin-top: 1rem; padding: .55rem .7rem; border: 0; border-radius: 8px; background: var(--primary); color: #fff; font: inherit; font-size: .85rem; font-weight: 600; text-align: left; cursor: pointer; }
.detail-birthday:hover { filter: brightness(1.08); }
.detail-links { display: flex; flex-wrap: wrap; gap: 0 .8rem; }
.detail-textlink { display: inline-flex; align-items: center; min-height: 2.25rem; font-size: .88rem; color: var(--primary); text-decoration: none; }
.detail-textlink:hover { text-decoration: underline; text-underline-offset: 3px; }
@media (pointer: coarse), (max-width: 600px) { .detail-textlink { min-height: 2.75rem; } }
@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); }
  /* Folded at the bottom: a 44 px bar with the name across and the arrow on the right (↑ unfolds, ↓ folds). */
  .detail-panel.collapsed { flex: 0 0 44px; height: 44px; }
  .detail-panel.collapsed .detail-close { left: auto; right: .4rem; top: 4px; margin: 0; }
  .detail-panel.collapsed .detail-strip { padding: 0 3rem 0 1rem; justify-content: flex-start; }
  .detail-strip-name { writing-mode: horizontal-tb; transform: none; max-width: 100%; }
  .detail-chevron { transform: rotate(90deg); }
  .detail-panel.collapsed .detail-chevron { transform: rotate(-90deg); }
}
@media print { .detail-panel { 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 */

/* 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; flex-wrap: wrap; gap: .6rem; margin-top: .75rem; }
.about-actions .auth-submit { min-width: 12rem; }
.about-actions a.auth-submit { text-decoration: none; display: inline-flex; align-items: center; justify-content: center; box-sizing: border-box; }
@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; align-items: center; }
/* Sharing buttons (js/share-bar.js): all the same, icon only (the name is the tooltip): e-mail, WhatsApp, share. */
.gt-sbtn {
  display: inline-flex; align-items: center; justify-content: center; box-sizing: border-box; width: 2.75rem; min-height: var(--btn-h); padding: .3rem; font: inherit; font-size: 1.2rem; line-height: 1;
  border: 1.5px solid var(--border); border-radius: 8px; background: var(--bg-white); color: var(--text); text-decoration: none; cursor: pointer;
  -webkit-appearance: none; appearance: none; -webkit-tap-highlight-color: transparent;
}
.gt-sbtn:hover { border-color: var(--primary); background: var(--bg-light); }
.gt-sbtn:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(139, 111, 71, 0.3); }
.gt-sbtn:disabled { opacity: .6; cursor: default; }
.gt-i-share::before, .gt-i-mail::before { content: ''; width: 1.3rem; height: 1.3rem; background: currentColor; -webkit-mask: center / contain no-repeat; mask: center / contain no-repeat; }
.gt-i-share::before { -webkit-mask-image: url('/icons/share.svg'); mask-image: url('/icons/share.svg'); }
.gt-i-mail::before { -webkit-mask-image: url('/icons/mail.svg'); mask-image: url('/icons/mail.svg'); }
.gt-i-mail.is-sent::before { display: none; }
.logout-btn.gt-i-share:not(.adm-icon)::before { width: 1rem; height: 1rem; margin-right: .4rem; } /* icon + word (member invitations) */
.gt-i-share, .gt-i-mail { display: inline-flex; align-items: center; justify-content: center; } /* also on icon buttons that are not .gt-sbtn (admin invitation actions) */

/* 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-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); }
.auth-card .auth-brandline { margin: -.2rem 0 .7rem; font-size: 1.15rem; font-weight: 650; color: var(--primary); }
/* The tree's name is written the same way everywhere (sign-in heading, brand line of the public pages, request headline). */
/* Always the same: a capital first letter, the rest in small capitals. */
.treename, .auth-brandline, h1.auth-treename { text-transform: capitalize; font-variant: small-caps; letter-spacing: .06em; }

/* 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-hint { display: block; min-height: 0; margin-top: 3px; font-size: .78rem; color: var(--text-light); }
.gt-date-hint:empty { display: none; }
.gt-date-hint.bad { color: var(--error); }
.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; justify-content: center; text-decoration: none; padding: .3rem .9rem; min-height: var(--btn-h, 2.25rem); font-size: var(--btn-font, 13px); }
#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; }
.chart-toolbar .site-nav.nav-compact { flex: 1 1 100%; min-width: 0; max-width: 100%; } /* the tree page: the menu row takes the toolbar's width, never more */
.nav-search-tree .chart-search-wrap { flex: 1 1 auto; width: auto; min-width: 0; max-width: none; margin: 0; } /* (not the 100% width the phone toolbar gives it: here it shares the row with the 🌳 button) */
.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)); } }
.gt-question-fold { position: absolute; top: 0.35rem; right: 2.2rem; border: 0; background: none; font-size: 1.1rem; line-height: 1; color: var(--text-light); cursor: pointer; padding: 0.3rem 0.4rem; }
.gt-question-bubble .gt-question-title { padding-right: 3.5rem; }
/* Folded (the default on the tree page): only a pill, so the tree stays free to use. */
.gt-question-bubble.gt-question-folded { width: auto; padding: 0; border: 0; background: none; box-shadow: none; }
.gt-question-pill { min-height: var(--btn-h); padding: 0 .9rem; border: 1px solid var(--border); border-left: 4px solid var(--accent); border-radius: 999px; background: var(--bg-white); color: var(--primary-dark); font: inherit; font-size: var(--btn-font); font-weight: 600; box-shadow: var(--shadow-lg); cursor: pointer; }
.gt-question-pill:hover { border-color: var(--primary); }
/* Phones: above the folded details bar at the bottom; while the details are open (lower half of the screen) it waits. */
@media (max-width: 768px) {
  .gt-question-bubble { bottom: calc(44px + 4.2rem + env(safe-area-inset-bottom, 0px)); }
  .gt-question-bubble.gt-question-folded { bottom: calc(44px + 3.2rem + env(safe-area-inset-bottom, 0px)); }
  body.gt-details-open .gt-question-bubble { display: none; }
}



/* 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; }

/* Memories (stories and recipes) */
.mem-form { margin-top: 12px; }
.mem-filters { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; }
.mem-filters input[type=search] { flex: 1 1 14rem; min-width: 0; }
.mem-filters select { flex: 0 0 auto; width: auto; }
.mem-items { display: flex; flex-direction: column; gap: 12px; }
.mem-card { border: 1.5px solid var(--border); border-radius: 12px; padding: 12px 14px; background: var(--bg-white); }
.mem-head { display: flex; align-items: center; gap: 8px; }
.mem-head h3 { margin: 0; font-size: 1.05rem; }
.mem-kind { font-size: 1.3rem; }
.mem-meta { margin: 4px 0 6px; font-size: .85rem; color: var(--text-light); }
.mem-occasion { margin: 4px 0; font-style: italic; color: var(--primary-dark); }
.mem-card h4 { margin: 10px 0 4px; font-size: .9rem; color: var(--primary-dark); }
.mem-ingredients { margin: 0; padding-left: 1.2rem; }
.mem-body { margin: 6px 0; white-space: pre-wrap; overflow-wrap: anywhere; }

/* Sign-in page: minimal, with a clearly visible way to ask for an invitation. */
.auth-join { margin: 1.15rem 0 .4rem; padding: .95rem 1rem 1rem; border-radius: 16px; background: linear-gradient(180deg, #f8f1e5 0%, #f4eadb 100%); border: 1px solid #eadcc4; text-align: center; }
.auth-card .auth-join-lead { margin: 0 0 .55rem; font-family: Georgia, "Times New Roman", serif; font-size: 1.05rem; color: #5a4630; }
.auth-join-btn { display: flex; align-items: center; justify-content: center; gap: .5rem; min-height: 3rem; padding: 0 1.2rem; border-radius: 12px; background: #fff; border: 2px solid var(--primary); color: var(--primary-dark); font-weight: 650; font-size: 1rem; text-decoration: none; box-shadow: 0 4px 12px rgba(139, 111, 71, .15); transition: background .15s, color .15s, transform .15s; }
.auth-join-btn:hover, .auth-join-btn:focus-visible { background: var(--primary); color: #fff; transform: translateY(-1px); }
.auth-card .login-links { margin: .9rem 0 0; font-size: .85rem; }
.auth-card .login-links .login-link { color: var(--text-light); text-decoration: none; }
.auth-card .login-links .login-link:hover { color: var(--primary-dark); text-decoration: underline; }
.auth-card .about-open-wrap { display: none; }
/* Sign-in card: tighter, so everything fits in one screen */
.auth-card:has(.auth-join) { padding: 2rem 2.2rem 1.6rem; }
.auth-card:has(.auth-join) .auth-form { gap: .7rem; }
.auth-card:has(.auth-join) .auth-logo { margin-bottom: .4rem; }
.auth-card:has(.auth-join) p { margin-bottom: 1rem; }
.auth-card:has(.auth-join) .login-hint { margin: 0; }
.auth-card:has(.auth-join) .auth-status:empty { display: none; }
.auth-card:has(.auth-join) .auth-join-lead { margin-bottom: .5rem; }

/* Birthday card dialog (js/birthday-dialog.js, profile and calendar) */
.prof-bday-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.prof-bday-dlg { max-width: min(560px, 94vw); width: 100%; border: 0; border-radius: 16px; padding: 1.1rem 1.2rem 1rem; box-shadow: var(--shadow-lg); }
.prof-bday-dlg::backdrop { background: rgba(60, 44, 24, .45); }
.prof-bday-dlg h2 { margin: 0 0 .6rem; font-size: 1.15rem; color: var(--primary-dark); }
.prof-bday-dlg > * { margin-bottom: .6rem; }
.prof-bday-tabs { display: flex; gap: 6px; }
.prof-bday-tabs .logout-btn { flex: 1; }
.prof-bday-tabs .logout-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.prof-bday-img { display: block; width: 100%; max-width: 420px; aspect-ratio: 1; margin: 0 auto; border-radius: 12px; border: 1px solid var(--border); background: #fdfbf8; }
.prof-bday-msg { width: 100%; box-sizing: border-box; resize: none; font-size: .9rem; }
.prof-bday-row { display: flex; gap: 6px; flex-wrap: wrap; }
.prof-bday-row a.logout-btn { text-decoration: none; display: inline-flex; align-items: center; }
.prof-bday-check { display: flex; gap: 6px; align-items: flex-start; font-size: .85rem; color: var(--text-light); }

/* WhatsApp buttons show the logo only (the name is the tooltip / accessible name). */
.gt-wa::before { content: ''; width: 1.4rem; height: 1.4rem; background: url('/icons/whatsapp.svg') center / contain no-repeat; } /* official WhatsApp glyph, unmodified (icons/whatsapp.svg) */
.rel-coparent { display: flex; align-items: center; gap: .4rem; margin: .5rem 0; font-size: .9rem; }
/* Tree page: pinching anywhere zooms the chart (handled in js/graph.js), never the whole page. */
body[data-boot="loadFromUrl"] { touch-action: pan-x pan-y; }

/* Photos: the profile picture in the person's panel, the crop dialog, the administrator's review cards. */
.detail-photo { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; margin: 0 0 .5rem; }
.detail-photo-img { width: 72px; height: 72px; border-radius: 50%; object-fit: cover; border: 2px solid var(--border, #d8d2c4); background: #f3efe6; }
.detail-photo .gt-photo-btn { font-size: 12px; min-height: 2rem; padding: .2rem .7rem; }
.detail-photo-note { flex-basis: 100%; margin: 0; font-size: .78rem; color: var(--text-light); }
.gt-photo-overlay { position: fixed; inset: 0; z-index: 1000; background: rgba(20, 20, 20, .55); display: flex; align-items: center; justify-content: center; padding: 16px; }
.gt-photo-dialog { background: #fff; border-radius: 12px; padding: 1rem; max-width: 380px; width: 100%; display: grid; gap: .6rem; justify-items: center; }
.gt-photo-dialog canvas { width: 100%; max-width: 320px; aspect-ratio: 1; border-radius: 8px; touch-action: none; cursor: grab; background: #eee; }
.gt-photo-dialog input[type=range] { width: 100%; max-width: 320px; }
.gt-photo-dialog p { margin: 0; font-size: .85rem; color: var(--text-light); text-align: center; }
.gt-photo-actions { display: flex; gap: .5rem; flex-wrap: wrap; justify-content: center; }
.pho-items { display: grid; gap: .8rem; }
.pho-card { display: flex; gap: .8rem; align-items: flex-start; padding: .6rem; border: 1px solid var(--border, #d8d2c4); border-radius: 10px; }
.pho-thumb { width: 128px; height: 128px; border-radius: 8px; object-fit: cover; flex: none; background: #f3efe6; }
.pho-side { min-width: 0; flex: 1; }

/* Family photos page */
.pho-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: .8rem; }
.pho-tile { margin: 0; display: grid; gap: .3rem; }
.pho-open { display: block; width: 100%; padding: 0; border: 0; background: none; cursor: pointer; border-radius: 8px; overflow: hidden; line-height: 0; }
.pho-open img { display: block; width: 100%; height: auto; aspect-ratio: 4 / 3; object-fit: cover; background: #f3efe6; }
.pho-tile figcaption { display: grid; gap: .15rem; font-size: .8rem; color: var(--text-light); }
.pho-tile figcaption strong { color: var(--text); }
.pho-stage { position: relative; line-height: 0; max-width: 100%; }
.pho-stage img, .pho-stage canvas { width: 100%; height: auto; border-radius: 8px; display: block; }
.pho-edit canvas { cursor: crosshair; touch-action: manipulation; }
.pho-ring { position: absolute; aspect-ratio: 1; transform: translate(-50%, -50%); border: 2px solid rgba(255, 255, 255, .9); border-radius: 50%; box-shadow: 0 0 0 1.5px rgba(0, 0, 0, .55); background: transparent; padding: 0; pointer-events: auto; }
.pho-ring.on { border-color: #ffd34d; box-shadow: 0 0 0 2px #7a5b00, 0 0 8px 2px rgba(255, 211, 77, .8); }
.pho-view img + .pho-ring, .pho-view .pho-ring { pointer-events: none; }
.pho-form { display: grid; gap: .6rem; margin-top: .8rem; max-width: 720px; }
.pho-step { margin: 0; font-weight: 600; }
.pho-panel { display: grid; gap: .5rem; padding: .6rem; border: 1px solid var(--border, #d8d2c4); border-radius: 10px; }
.pho-panel[hidden] { display: none; }
.pho-count, .pho-cap { margin: 0; font-size: .85rem; color: var(--text-light); }
.pho-details { display: grid; grid-template-columns: 1fr 9.5rem; gap: .5rem; }
.pho-people { list-style: none; margin: 0; padding: 0; display: grid; gap: .3rem; width: 100%; }
.pho-people li { display: flex; align-items: center; gap: .5rem; justify-content: space-between; }
.pho-who { background: none; border: 0; padding: 0; font: inherit; cursor: pointer; text-align: left; color: var(--primary-dark); text-decoration: underline dotted; }
.gt-photo-dialog.pho-view { max-width: 720px; max-height: 92vh; overflow: auto; justify-items: stretch; }
.pho-thumb-wrap { position: relative; }
.pho-admin-stage { flex: none; width: 320px; max-width: 45%; }
@media (max-width: 600px) { .pho-card { flex-direction: column; } .pho-admin-stage { max-width: 100%; width: 100%; } }

/* Photos attached to a memory */
.mem-photo-row { display: flex; flex-wrap: wrap; gap: .5rem; margin: .5rem 0; }
.mem-photo { position: relative; margin: 0; width: 96px; }
.mem-photo img { width: 96px; height: 72px; object-fit: cover; border-radius: 6px; display: block; background: #f3efe6; }
.mem-photo .pho-open { width: 96px; }
.mem-photo-x { position: absolute; top: 2px; right: 2px; width: 22px; height: 22px; border: 0; border-radius: 50%; background: rgba(0, 0, 0, .6); color: #fff; font-size: 12px; line-height: 1; cursor: pointer; padding: 0; }
.mem-photos { display: grid; gap: .4rem; justify-items: start; }
.mem-photos[hidden] { display: none; }
.gt-photo-dialog.pho-tagger { max-width: 720px; max-height: 94vh; overflow: auto; justify-items: stretch; }
.pho-tagger .pho-count { text-align: center; }
.mem-card .pho-admin-stage { width: 360px; max-width: 100%; margin: .5rem 0; }

/* "Today" page (today.html, js/today.js) */
.today-main { max-width: 920px; }
.today-hello { margin: 0; font-size: 1.6rem; color: var(--primary-dark); }
.today-tree { display: grid; gap: .8rem; justify-items: center; }
.today-row { display: flex; flex-wrap: wrap; gap: .5rem; justify-content: center; }
.today-person { display: grid; gap: .1rem; min-width: 8.5rem; max-width: 12rem; padding: .55rem .8rem; text-align: center; text-decoration: none; color: var(--text); background: #fff; border: 1.5px solid var(--border); border-left-width: 4px; border-radius: 10px; }
.today-person:hover { border-color: var(--primary); box-shadow: var(--shadow-sm, 0 1px 4px rgba(0,0,0,.12)); }
.today-person.today-m { border-left-color: #4a7fb5; }
.today-person.today-f { border-left-color: #c8607a; }
.today-person.today-me { background: var(--bg-light, #f6f1e7); border-color: var(--primary); }
.today-person small { color: var(--text-light); font-size: .75rem; }
.today-pref { text-align: center; margin: 1rem 0 2rem; }
.today-event { display: flex; flex-wrap: wrap; align-items: center; gap: .3rem .5rem; padding: .25rem 0; }
.today-card-btn { margin-left: auto; }
/* Person details: relatives are plain text rows, not boxed buttons (beats the shared button rule in css/ui.css). */
body[class] .detail-panel .detail-link { justify-content: flex-start; min-height: 0; padding: .3rem 0; border: 0; border-radius: 0; background: transparent; box-shadow: none; font-weight: 500; color: var(--primary); }
body[class] .detail-panel .detail-link:hover:not(:disabled) { background: transparent; border: 0; text-decoration: underline; text-underline-offset: 3px; }
.login-notice { margin: 4px 0 8px; padding: 10px 12px; border-radius: 10px; background: var(--accent-soft, #f3ece2); color: var(--text, #2b2620); text-align: left; }
