/* ═══════════════════════════════════════════════════════════
   STAMMBAUM – PCB / Circuit Board Design System
   ═══════════════════════════════════════════════════════════ */

:root {
  --bg: #ffffff;
  --bg-secondary: #f8f9fa;
  --trace: #1a1a1a;
  --trace-light: #d0d0d0;
  --trace-faint: #e8e8e8;
  --red: #e63946;
  --red-light: #fce4e6;
  --red-glow: rgba(230, 57, 70, 0.3);
  --blue: #457b9d;
  --blue-light: #e8f0f5;
  --text: #1a1a1a;
  --text-secondary: #6b7280;
  --text-muted: #9ca3af;
  --radius: 4px;
  --radius-lg: 8px;
  --font: 'IBM Plex Mono', 'SF Mono', 'Fira Code', monospace;
  --transition: 300ms cubic-bezier(0.4, 0, 0.2, 1);
  --shadow: 0 2px 8px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.12);
}

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

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
}

input, button, select, textarea {
  font-family: inherit;
  font-size: inherit;
}

a {
  color: var(--red);
  text-decoration: none;
}

/* ─── Views ─── */
.view {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  display: none;
  opacity: 0;
  transition: opacity var(--transition);
}

.view.active {
  display: flex;
  flex-direction: column;
  opacity: 1;
}

.hidden {
  display: none !important;
}

/* ═══════════════════════════════════════════════════════════
   LOADING SCREEN
   ═══════════════════════════════════════════════════════════ */

#loading-screen {
  align-items: center;
  justify-content: center;
  background: var(--bg);
}

.loading-circuit {
  text-align: center;
}

.loading-text {
  margin-top: 24px;
  color: var(--text-secondary);
  font-size: 12px;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.pulse-dot {
  animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; r: 6; }
  50% { opacity: 0.4; r: 8; }
}

/* ═══════════════════════════════════════════════════════════
   AUTH VIEW
   ═══════════════════════════════════════════════════════════ */

#view-auth {
  /* Spaltenlayout: vertikal über margin:auto der Karte zentrieren — mit
     justify-content:center würde auf kleinen Screens oben abgeschnitten */
  align-items: center;
  justify-content: flex-start;
  padding: 24px;
  overflow-y: auto;
}

.auth-container {
  width: 100%;
  max-width: 360px;
  margin: auto;
  text-align: center;
}

.auth-logo {
  margin-bottom: 16px;
}

/* Familienwappen (Pommern links, Mark rechts) nebeneinander über dem Titel */
.auth-arms {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  gap: 28px;
  margin-bottom: 20px;
}
.auth-arms img {
  height: 120px;
  width: auto;
  image-rendering: auto;
}

.auth-title {
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -0.5px;
  margin-bottom: 6px;
}

.auth-subtitle {
  color: var(--text-secondary);
  font-size: 13px;
  letter-spacing: 0.2px;
  line-height: 1.6;
  margin-bottom: 36px;
}

.auth-footer {
  margin-top: 36px;
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 0.3px;
}
.auth-footer a { color: var(--text-secondary); text-decoration: underline; }

.auth-form {
  text-align: left;
}

.auth-switch {
  text-align: center;
  margin-top: 20px;
  color: var(--text-secondary);
  font-size: 13px;
}

.auth-forgot {
  text-align: center;
  margin-top: 12px;
  font-size: 12px;
}

.auth-forgot a {
  color: var(--text-muted);
  text-decoration: none;
}

.auth-forgot a:hover {
  color: var(--red);
}

.auth-hint {
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.6;
  margin-bottom: 16px;
  text-align: center;
}

/* ═══════════════════════════════════════════════════════════
   FORM ELEMENTS
   ═══════════════════════════════════════════════════════════ */

.input-group {
  margin-bottom: 16px;
}

.input-group label {
  display: block;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.input-group input,
.input-group select,
.input-group textarea {
  width: 100%;
  padding: 10px 12px;
  border: 2px solid var(--trace-light);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  transition: border-color var(--transition);
  outline: none;
}

.input-group input:focus,
.input-group select:focus,
.input-group textarea:focus {
  border-color: var(--trace);
}

.input-group input::placeholder,
.input-group textarea::placeholder {
  color: var(--text-muted);
}

/* ─── Buttons ─── */
.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 12px 20px;
  border: 2px solid transparent;
  border-radius: var(--radius);
  font-weight: 500;
  font-size: 14px;
  cursor: pointer;
  transition: all var(--transition);
  margin-bottom: 10px;
}

.btn-primary {
  background: var(--trace);
  color: var(--bg);
  border-color: var(--trace);
}

.btn-primary:hover, .btn-primary:active {
  background: var(--red);
  border-color: var(--red);
}

.btn-secondary {
  background: transparent;
  color: var(--trace);
  border-color: var(--trace-light);
}

.btn-secondary:hover, .btn-secondary:active {
  border-color: var(--trace);
}

.btn-small {
  width: auto;
  padding: 6px 16px;
  font-size: 12px;
  margin-bottom: 0;
}

.btn-icon {
  font-weight: 700;
  font-size: 16px;
}

.btn-danger {
  background: var(--red);
  color: white;
  border-color: var(--red);
}

.btn.loading {
  position: relative;
  color: transparent !important;
  pointer-events: none;
}

.btn.loading::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 18px;
  height: 18px;
  margin: -9px 0 0 -9px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: btnSpin 600ms linear infinite;
}

.btn-primary.loading::after {
  border-color: var(--bg);
  border-right-color: transparent;
}

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

/* ─── Icon Buttons ─── */
.icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: none;
  border-radius: var(--radius);
  background: transparent;
  color: var(--trace);
  cursor: pointer;
  transition: background var(--transition);
  flex-shrink: 0;
}

.icon-btn:hover, .icon-btn:active {
  background: var(--bg-secondary);
}

/* ═══════════════════════════════════════════════════════════
   PENDING APPROVAL VIEW
   ═══════════════════════════════════════════════════════════ */

#view-pending {
  align-items: center;
  justify-content: center;
  padding: 24px;
  text-align: center;
}

.pending-container {
  max-width: 360px;
  width: 100%;
}

.pending-icon {
  margin-bottom: 24px;
}

.pending-container h2 {
  font-size: 22px;
  font-weight: 600;
  margin-bottom: 12px;
}

.pending-text {
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.7;
}

/* ═══════════════════════════════════════════════════════════
   ADMIN APPROVE VIEW
   ═══════════════════════════════════════════════════════════ */

#view-admin-approve {
  overflow-y: auto;
  padding: 24px;
}

.admin-container {
  max-width: 560px;
  margin: 0 auto;
  width: 100%;
}

.admin-section-title {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.admin-count {
  font-weight: 500;
  color: var(--text-muted);
  text-transform: none;
  letter-spacing: 0;
}

.admin-hint {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.5;
}

.admin-user-card .user-meta {
  font-size: 11px;
  color: var(--text-muted);
  margin: 4px 0 8px;
  line-height: 1.5;
}

.admin-user-card .user-link {
  color: var(--blue);
  cursor: pointer;
  text-decoration: underline;
}

.admin-user-card .user-link:hover { color: var(--red); }

.admin-user-card.is-admin { border-color: var(--trace); }

.status-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: 10px;
  margin-left: 8px;
  vertical-align: middle;
  background: var(--bg-secondary);
  color: var(--text-secondary);
}

.status-badge.approved { background: #e4f4e8; color: #2b7a3c; }
.status-badge.pending { background: #fff4d6; color: #8a6100; }
.status-badge.rejected, .status-badge.revoked { background: var(--red-light); color: var(--red); }
.status-badge.admin { background: var(--trace); color: var(--bg); }

.admin-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.admin-actions .btn { margin-bottom: 0; }

/* Profil verknüpfen: Suchfeld klappt unter dem Button auf, nimmt volle Breite */
.admin-link { flex: 1 0 100%; }
.admin-link-box { margin-top: 8px; }
.admin-link-box input {
  width: 100%;
  padding: 8px 10px;
  border: 2px solid var(--trace-light);
  border-radius: var(--radius);
  font-size: 13px;
  outline: none;
}
.admin-link-box input:focus { border-color: var(--trace); }
.mini-result-item.is-taken { color: var(--text-muted); cursor: default; }

.admin-container h2 {
  font-size: 22px;
  font-weight: 600;
  margin-bottom: 4px;
}

.admin-subtitle {
  color: var(--text-secondary);
  font-size: 13px;
  margin-bottom: 24px;
}

.admin-head { margin-bottom: 14px; }

/* Konten-Suche: filtert die drei Listen clientseitig (Name, Profil, E-Mail) */
.admin-search { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.admin-search input {
  flex: 1 1 220px;
  font-family: var(--font);
  font-size: 13px;
  padding: 8px 10px;
  border: 2px solid var(--trace-faint);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  outline: none;
}
.admin-search input:focus { border-color: var(--trace); }
.admin-user-card.is-filtered { display: none; }

.admin-user-card {
  border: 2px solid var(--trace-faint);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
}

.admin-user-card .user-name {
  font-weight: 600;
  font-size: 15px;
  margin-bottom: 4px;
}

.admin-user-card .user-email {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

.admin-user-card .admin-actions {
  display: flex;
  gap: 8px;
}

.admin-user-card .admin-actions .btn {
  width: auto;
  flex: 0 0 auto;
  margin-bottom: 0;
}

/* ═══════════════════════════════════════════════════════════
   CLAIM VIEW
   ═══════════════════════════════════════════════════════════ */

#view-claim {
  align-items: center;
  justify-content: flex-start;
  padding: 24px;
  padding-top: 60px;
  overflow-y: auto;
}

.claim-container {
  width: 100%;
  max-width: 400px;
}

.view-header {
  margin-bottom: 32px;
}

.view-header h2 {
  font-size: 22px;
  font-weight: 600;
  margin-bottom: 8px;
}

.view-header p {
  color: var(--text-secondary);
  font-size: 13px;
}

.claim-results {
  max-height: 240px;
  overflow-y: auto;
  margin-bottom: 16px;
}

.claim-result-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border: 2px solid var(--trace-faint);
  border-radius: var(--radius);
  margin-bottom: 8px;
  cursor: pointer;
  transition: all var(--transition);
}

.claim-result-item:hover {
  border-color: var(--red);
  background: var(--red-light);
}

.claim-result-item .name {
  font-weight: 500;
}

.claim-result-item .info {
  font-size: 12px;
  color: var(--text-secondary);
}

.claim-divider {
  display: flex;
  align-items: center;
  gap: 16px;
  margin: 24px 0;
  color: var(--text-muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.claim-divider::before,
.claim-divider::after {
  content: '';
  flex: 1;
  height: 2px;
  background: var(--trace-faint);
}

/* ═══════════════════════════════════════════════════════════
   MAIN VIEW – TOP BAR
   ═══════════════════════════════════════════════════════════ */

#top-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--bg);
  border-bottom: 2px solid var(--trace-faint);
  z-index: 100;
  flex-shrink: 0;
}

.search-bar {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border: 2px solid var(--trace-faint);
  border-radius: var(--radius);
  transition: border-color var(--transition);
}

.search-bar:focus-within {
  border-color: var(--trace);
}

.search-bar svg {
  flex-shrink: 0;
  color: var(--text-muted);
}

.search-bar input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  font-size: 13px;
}

/* ═══════════════════════════════════════════════════════════
   TREE CONTAINER
   ═══════════════════════════════════════════════════════════ */

#tree-area {
  flex: 1;
  position: relative;
  overflow: hidden;
}

#tree-container {
  position: absolute;
  inset: 0;
  z-index: 10;   /* eigener Stacking-Kontext: Minimap/Generationslabels bleiben unter Fächer (20) und Gotha (25) */
  overflow: hidden;
  background: var(--bg);
  /* Subtle grid pattern like PCB */
  background-image:
    radial-gradient(circle, var(--trace-faint) 1px, transparent 1px);
  background-size: 24px 24px;
}

/* ═══════════════════════════════════════════════════════════
   SEARCH RESULTS
   ═══════════════════════════════════════════════════════════ */

.search-results {
  position: absolute;
  top: 58px;
  left: 12px;
  right: 12px;
  max-height: 300px;
  overflow-y: auto;
  background: var(--bg);
  border: 2px solid var(--trace-faint);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  z-index: 200;
}

.search-result-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  cursor: pointer;
  transition: background var(--transition);
  border-bottom: 1px solid var(--trace-faint);
}

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

.search-result-item:hover, .search-result-item:active {
  background: var(--bg-secondary);
}

.search-result-item .result-name {
  font-weight: 500;
  font-size: 14px;
}

.search-result-item .result-info {
  font-size: 11px;
  color: var(--text-secondary);
}

.search-result-item .result-avatar {
  width: 36px;
  height: 36px;
  border-radius: var(--radius);
  border: 2px solid var(--trace-faint);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 14px;
  color: var(--text-secondary);
  background: var(--bg-secondary);
  flex-shrink: 0;
}

/* ═══════════════════════════════════════════════════════════
   FLOATING ACTION BUTTONS
   ═══════════════════════════════════════════════════════════ */

/* Kleine Knöpfe oben rechts (ⓘ, „zu mir") — Stil und Höhe wie der
   Ansichts-Umschalter unten (42 px, 2 px heller Rand) */
#fab-container {
  position: absolute;
  top: 70px;                 /* unter der Kopfleiste, auf Höhe des Zweig-Umschalters */
  right: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  z-index: 50;
}

.fab {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 2px solid var(--trace-faint);
  background: var(--bg);
  color: var(--text-secondary);
  box-shadow: 0 2px 12px rgba(0,0,0,0.06);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: all var(--transition);
}

.fab:hover, .fab:active {
  background: var(--trace);
  color: var(--bg);
}

.fab:hover { color: var(--text); border-color: var(--trace-light); }
/* Desktop mit offener Seitenleiste: aus dem Panel heraus nach links rücken */
@media (min-width: 600px) {
  body.side-panel-open #fab-container { right: calc(min(400px, 50vw) + 12px); }
  body.side-panel-open .legend-panel { right: calc(min(400px, 50vw) + 62px); }
}
/* Handy: unter den Zweig-Umschalter (der geht fast über die ganze Breite) */
@media (max-width: 480px) {
  #fab-container { top: 112px; }
}
@supports (padding: env(safe-area-inset-top)) {
  #fab-container { top: max(70px, calc(env(safe-area-inset-top) + 62px)); }
  @media (max-width: 480px) { #fab-container { top: max(112px, calc(env(safe-area-inset-top) + 104px)); } }
}

/* ═══════════════════════════════════════════════════════════
   LEGEND PANEL — meaning of node border styles
   ═══════════════════════════════════════════════════════════ */

.legend-panel {
  position: absolute;
  /* Links neben dem ⓘ-Knopf oben rechts */
  top: 70px;
  right: 62px;
  width: 250px;
  max-width: calc(100vw - 100px);
  max-height: calc(100% - 90px);
  overflow-y: auto;
  background: var(--bg);
  border: 2px solid var(--trace);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 12px 14px;
  z-index: 60;
  font-size: 12px;
}

.legend-panel.hidden {
  display: none;
}

.legend-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 600;
  margin-bottom: 8px;
}

.legend-close {
  border: none;
  background: none;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  color: var(--text-secondary);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
  color: var(--text-secondary);
}

.legend-swatch {
  flex: none;
  width: 22px;
  height: 14px;
  border-radius: 3px;
  background: var(--bg);
}

/* Fächer-Legende */
.legend-swatch-male { background: hsl(207 72% 80%); }
.legend-swatch-female { background: hsl(340 72% 80%); }
.legend-swatch-fan-deceased { background: hsl(207 32% 84%); }
.legend-swatch-registered { background: hsl(207 72% 80%); border: 2px solid var(--trace); }
.legend-swatch-fan-current { background: hsl(207 72% 80%); border: 3px solid var(--red); }
.legend-swatch-dimmed { background: hsl(207 72% 80%); opacity: 0.22; }
.legend-swatch-text {
  flex: none;
  font-size: 11px;
  font-weight: 600;
  color: var(--text);
  opacity: 0.75;
}
.legend-hint {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid var(--trace-faint);
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.4;
}

/* ═══════════════════════════════════════════════════════════
   CONNECTION SIDE PANEL
   Slides in from the right, doesn't cover the tree
   ═══════════════════════════════════════════════════════════ */

.connection-panel {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 320px;
  max-width: 85vw;
  background: var(--bg);
  border-left: 2px solid var(--trace-faint);
  box-shadow: -4px 0 24px rgba(0,0,0,0.08);
  z-index: 200;
  display: flex;
  flex-direction: column;
  transform: translateX(0);
  animation: slideInRight 300ms cubic-bezier(0.4, 0, 0.2, 1);
  overflow-y: auto;
}

.connection-panel.hidden {
  display: none !important;
}

@keyframes slideInRight {
  from { transform: translateX(100%); }
  to { transform: translateX(0); }
}

.overlay-content {
  width: 100%;
  padding: 20px;
  padding-bottom: max(20px, env(safe-area-inset-bottom));
  position: relative;
}

.overlay-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 32px;
  height: 32px;
  border: none;
  background: var(--bg-secondary);
  border-radius: 50%;
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  z-index: 1;
}

.overlay-close:hover {
  background: var(--trace-faint);
}

#connection-header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 20px;
  padding-top: 40px;
}

.connection-person {
  text-align: center;
  flex: 1;
  min-width: 0;
}

.connection-person .conn-avatar {
  width: 48px;
  height: 48px;
  border-radius: var(--radius);
  border: 2px solid var(--trace);
  margin: 0 auto 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 16px;
  background: var(--bg-secondary);
  overflow: hidden;
}

.connection-person .conn-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.connection-person .conn-name {
  font-weight: 500;
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.connection-line {
  flex-shrink: 0;
}

#connection-details {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.conn-detail {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  border: 2px solid var(--trace-faint);
  border-radius: var(--radius);
}

.conn-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
}

.conn-value {
  font-weight: 600;
  font-size: 13px;
  color: var(--red);
}

/* Mobile: panel at bottom instead of side */
@media (max-width: 600px) {
  .connection-panel {
    top: auto;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    max-width: 100%;
    max-height: 45vh;
    border-left: none;
    border-top: 2px solid var(--trace-faint);
    border-radius: 16px 16px 0 0;
    box-shadow: 0 -4px 24px rgba(0,0,0,0.08);
    animation: slideUp 300ms cubic-bezier(0.4, 0, 0.2, 1);
  }

  @keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
  }
}

/* ═══════════════════════════════════════════════════════════
   PROFILE VIEW
   On desktop (≥600px): side panel over tree, doesn't hide tree
   On mobile (<600px): profile as bottom sheet (lower half), the person
   stays visible in the diagram above; edit form fullscreen
   ═══════════════════════════════════════════════════════════ */

#view-profile {
  overflow-y: auto;
}

.profile-container {
  max-width: 480px;
  margin: 0 auto;
  padding: 0 20px 40px;
  width: 100%;
}

/* Desktop: profile and edit form as side panel */
@media (min-width: 600px) {
  .view.side-panel {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: auto;
    width: 400px;
    max-width: 50vw;
    background: var(--bg);
    border-left: 2px solid var(--trace-faint);
    box-shadow: -4px 0 24px rgba(0,0,0,0.08);
    z-index: 150;
    display: flex;
    flex-direction: column;
    opacity: 1;
    animation: slideInRight 300ms cubic-bezier(0.4, 0, 0.2, 1);
  }
}

/* Handy: Profil als Bottom-Sheet in der unteren Hälfte — das Diagramm
   darüber bleibt bedienbar, die Person ist dort zentriert und hervorgehoben.
   Wegwischen nach unten oder Tipp ins Diagramm schließt es. */
@media (max-width: 599px) {
  #view-profile.side-panel {
    position: absolute;
    top: auto;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 50%;
    background: var(--bg);
    border-top: 2px solid var(--trace-faint);
    border-radius: 16px 16px 0 0;
    box-shadow: 0 -4px 24px rgba(0,0,0,0.12);
    z-index: 150;
    display: flex;
    flex-direction: column;
    opacity: 1;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding-bottom: env(safe-area-inset-bottom);
    animation: slideUp 300ms cubic-bezier(0.4, 0, 0.2, 1);
  }
  /* Griff oben in der Mitte (im klebenden Kopf, bleibt beim Scrollen) */
  #view-profile.side-panel .profile-header { padding-top: 18px; }
  #view-profile.side-panel .profile-header::before {
    content: '';
    position: absolute;
    top: 6px;
    left: 50%;
    width: 36px;
    height: 4px;
    margin-left: -18px;
    border-radius: 2px;
    background: var(--trace-faint);
  }
  /* Ansichts-Umschalter läge unter dem Sheet; Drehrad in die freie obere Hälfte */
  body.side-panel-open .view-switch { display: none; }
  body.side-panel-open .fan-wheel { top: 27%; right: 54px; height: min(150px, 22vh); }
  #view-profile.side-panel .profile-photo { width: 56px; height: 56px; }
  #view-profile.side-panel .profile-photo-wrap { margin: 0 0 8px; }
  #view-profile.side-panel .profile-name { font-size: 18px; overflow-wrap: anywhere; }
  #view-profile.side-panel .profile-badges { margin-bottom: 12px; }
}

.profile-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 10;
}

/* Vollbild: Zurück-Pfeil links. Seitenpanel: Schließen-X rechts,
   Bearbeiten-Stift rückt nach links. */
#btn-profile-back .icon-close { display: none; }
#view-profile.side-panel #btn-profile-back .icon-back { display: none; }
#view-profile.side-panel #btn-profile-back .icon-close { display: block; }
#view-profile.side-panel .profile-header { flex-direction: row-reverse; }
/* im Seitenpanel: X ganz rechts, Stift links (row-reverse) */
#btn-edit-cancel .icon-close { display: none; }
#view-edit.side-panel #btn-edit-cancel .icon-back { display: none; }
#view-edit.side-panel #btn-edit-cancel .icon-close { display: block; }
#view-edit.side-panel #btn-edit-cancel { order: 3; }
#view-edit.side-panel .edit-header h2 { order: 1; flex: 1; }
#view-edit.side-panel #btn-edit-save { order: 2; }
#view-edit.side-panel .edit-container { max-width: none; }

.profile-photo-wrap {
  display: flex;
  justify-content: center;
  margin: 16px 0;
}

.profile-photo {
  width: 120px;
  height: 120px;
  border-radius: var(--radius-lg);
  border: 3px solid var(--trace);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-secondary);
  overflow: hidden;
}

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

.profile-name {
  text-align: center;
  font-size: 24px;
  font-weight: 600;
  margin-bottom: 4px;
}

.profile-birthname {
  text-align: center;
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 16px;
}

.profile-badges {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border: 1.5px solid var(--trace-light);
  border-radius: 20px;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-secondary);
}

.badge-deceased {
  border-color: var(--text-muted);
  color: var(--text-muted);
}

.badge-placeholder {
  border-color: var(--blue);
  color: var(--blue);
}

.profile-section {
  margin-bottom: 24px;
}

.profile-section h3 {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--trace-faint);
}

.profile-field {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--trace-faint);
}

.field-label {
  font-size: 13px;
  color: var(--text-secondary);
}

.field-value {
  font-weight: 500;
  text-align: right;
}

.profile-notes {
  font-size: 13px;
  color: var(--text-secondary);
  white-space: pre-wrap;
  line-height: 1.7;
}

.profile-actions {
  margin-top: 32px;
}

/* ═══════════════════════════════════════════════════════════
   EDIT VIEW
   ═══════════════════════════════════════════════════════════ */

#view-edit {
  overflow-y: auto;
}

.edit-container {
  max-width: 480px;
  margin: 0 auto;
  padding: 0 20px 40px;
  width: 100%;
}

.edit-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 10;
}

.edit-header h2 {
  flex: 1;
  font-size: 18px;
}

.edit-section {
  margin-top: 32px;
  padding-top: 24px;
  border-top: 2px solid var(--trace-faint);
}

.edit-section h3 {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 4px;
}

.hint {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 16px;
}

.mini-results {
  max-height: 160px;
  overflow-y: auto;
  margin-top: 4px;
}

.mini-result-item {
  padding: 8px 12px;
  border: 1px solid var(--trace-faint);
  border-radius: var(--radius);
  margin-bottom: 4px;
  cursor: pointer;
  font-size: 13px;
  transition: all var(--transition);
}

.mini-result-item:hover {
  border-color: var(--red);
  background: var(--red-light);
}

/* ═══════════════════════════════════════════════════════════
   RELATIONSHIP LIST ITEMS (profile + edit views)
   ═══════════════════════════════════════════════════════════ */

.rel-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 2px solid var(--trace-faint);
  border-radius: var(--radius);
  margin-bottom: 6px;
  transition: all var(--transition);
  cursor: pointer;
}

.rel-item:hover {
  border-color: var(--trace-light);
  background: var(--bg-secondary);
}

.rel-item .rel-type-badge {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 2px 8px;
  border-radius: 12px;
  white-space: nowrap;
  flex-shrink: 0;
}

.rel-item .rel-type-badge.parent { background: #e8f0f5; color: var(--blue); }
.rel-item .rel-type-badge.child  { background: #e8f5e8; color: #2d7a4f; }
.rel-item .rel-type-badge.spouse { background: var(--red-light); color: var(--red); }
.rel-item .rel-type-badge.sibling { background: #f0e8f5; color: #7b4d9d; }
.rel-item .rel-type-badge.ex_spouse { background: #f3f4f6; color: var(--text-secondary); }

.rel-item .rel-name {
  flex: 1;
  font-size: 13px;
  font-weight: 500;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rel-item .rel-delete {
  width: 28px;
  height: 28px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all var(--transition);
  font-size: 16px;
}

.rel-item .rel-delete:hover {
  background: var(--red-light);
  color: var(--red);
}

.rel-empty {
  padding: 12px;
  text-align: center;
  color: var(--text-muted);
  font-size: 12px;
}

/* ═══════════════════════════════════════════════════════════
   QR VIEW
   ═══════════════════════════════════════════════════════════ */

#view-scanner {
  background: var(--bg);
}

.scanner-container {
  max-width: 720px;            /* Kamera und eigener Code nebeneinander */
  margin: 0 auto;
  padding: 0 20px;
  width: 100%;
}

.scanner-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
}

.scanner-header h2 {
  font-size: 18px;
}

.scanner-hint {
  text-align: center;
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.7;
}

#qr-reader {
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin: 20px 0;
}
.scanner-grid { display: grid; grid-template-columns: 1fr; gap: 12px; }
@media (min-width: 700px) { .scanner-grid { grid-template-columns: 3fr 2fr; align-items: start; } }
.scanner-me { display: flex; flex-direction: column; align-items: center; padding: 8px 0 24px; }
.scanner-qr { padding: 14px; background: #fff; border: 2px solid var(--trace); border-radius: var(--radius-lg); margin-bottom: 10px; }
.scanner-qr:empty { display: none; }
.scanner-qr canvas, .scanner-qr img { display: block; width: 160px; height: 160px; }

#qr-reader video {
  border-radius: var(--radius-lg);
}

/* ═══════════════════════════════════════════════════════════
   SIDE MENU
   ═══════════════════════════════════════════════════════════ */

.side-menu {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  z-index: 1000;
}

.menu-backdrop {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  animation: fadeIn 200ms ease-out;
}

.menu-content {
  position: absolute;
  top: 0;
  left: 0;
  width: 280px;
  height: 100%;
  background: var(--bg);
  box-shadow: var(--shadow-lg);
  animation: slideRight 250ms cubic-bezier(0.4, 0, 0.2, 1);
  overflow-y: auto;
}

@keyframes slideRight {
  from { transform: translateX(-100%); }
  to { transform: translateX(0); }
}

.menu-header {
  padding: 32px 20px 20px;
  border-bottom: 2px solid var(--trace-faint);
}

.menu-user-photo {
  width: 56px;
  height: 56px;
  border-radius: var(--radius);
  border: 2px solid var(--trace);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 20px;
  background: var(--bg-secondary);
  overflow: hidden;
}

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

.menu-user-name {
  font-weight: 600;
  font-size: 16px;
  margin-bottom: 2px;
}

.menu-user-email {
  font-size: 12px;
  color: var(--text-secondary);
}

.menu-list {
  list-style: none;
  padding: 8px 0;
}

.menu-list li a {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 20px;
  color: var(--text);
  transition: background var(--transition);
}

.menu-list li a:hover, .menu-list li a:active {
  background: var(--bg-secondary);
}

.menu-list li a svg {
  flex-shrink: 0;
}

.menu-divider {
  height: 0;
  border-top: 2px solid var(--trace-faint);
  margin: 8px 20px;
}

/* ═══════════════════════════════════════════════════════════
   TOAST NOTIFICATIONS
   ═══════════════════════════════════════════════════════════ */

#toast-container {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  padding: 10px 20px;
  background: var(--trace);
  color: var(--bg);
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  animation: toastIn 300ms ease-out;
  pointer-events: auto;
  white-space: nowrap;
}

.toast.error {
  background: var(--red);
}

.toast.success {
  background: #2d7a4f;
}

.toast.out {
  animation: toastOut 200ms ease-in forwards;
}

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

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

/* ═══════════════════════════════════════════════════════════
   CYTOSCAPE OVERRIDES
   ═══════════════════════════════════════════════════════════ */

/* Cytoscape tooltip on hover */
.cy-tooltip {
  position: absolute;
  padding: 8px 12px;
  background: var(--trace);
  color: var(--bg);
  border-radius: var(--radius);
  font-size: 12px;
  font-family: var(--font);
  pointer-events: none;
  white-space: nowrap;
  box-shadow: var(--shadow);
  z-index: 300;
}

/* ═══════════════════════════════════════════════════════════
   UTILITY CLASSES
   ═══════════════════════════════════════════════════════════ */

.text-center { text-align: center; }
.text-red { color: var(--red); }
.text-muted { color: var(--text-muted); }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-16 { margin-bottom: 16px; }

/* ═══════════════════════════════════════════════════════════
   RESPONSIVE / MOBILE TWEAKS
   ═══════════════════════════════════════════════════════════ */

@media (max-width: 480px) {
  .auth-title { font-size: 24px; }
  .profile-name { font-size: 20px; }
  .profile-photo { width: 96px; height: 96px; }
}

/* Safe area for iPhones with notch */
@supports (padding: env(safe-area-inset-top)) {
  #top-bar {
    padding-top: max(8px, env(safe-area-inset-top));
  }
  .menu-header {
    padding-top: max(32px, calc(env(safe-area-inset-top) + 12px));
  }
}

/* ═══════════════════════════════════════════════════════════
   CONNECTION PATH ANIMATION (for tree highlighting)
   ═══════════════════════════════════════════════════════════ */

@keyframes tracePulse {
  0% { stroke-opacity: 0.4; }
  50% { stroke-opacity: 1; }
  100% { stroke-opacity: 0.4; }
}

/* ═══════════════════════════════════════════════════════════
   VIEW MODE TOGGLE BUTTON
   ═══════════════════════════════════════════════════════════ */

/* Legende: Geburtsjahr-Skala */
.legend-year { padding: 4px 0 6px; }
.legend-year-bar {
  height: 12px;
  border-radius: 6px;
  border: 1px solid var(--trace-faint);
}
.legend-year-labels {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* Dark mode support (future) */
@media (prefers-color-scheme: dark) {
  /* Could add dark mode variables here later */
}

/* ═══════════════════════════════════════════════════════════
   WAISEN-ABLAGE (unverbundene Profile)
   ═══════════════════════════════════════════════════════════ */

.orphan-tray {
  position: absolute;
  bottom: 66px;
  left: 12px;
  z-index: 90;
  max-width: min(280px, calc(100vw - 24px));
}

.orphan-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border: 2px solid var(--trace-faint);
  border-radius: 20px;
  background: var(--bg);
  color: var(--text-secondary);
  font-size: 11px;
  cursor: pointer;
  box-shadow: 0 2px 12px rgba(0,0,0,0.06);
}

.orphan-toggle:hover { border-color: var(--trace); color: var(--text); }

.orphan-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #e0a100;
  flex-shrink: 0;
}

.orphan-list {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 0;
  min-width: 220px;
  background: var(--bg);
  border: 2px solid var(--trace);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  max-height: 40vh;
  overflow-y: auto;
  padding: 6px 0;
}

.orphan-hint {
  padding: 6px 12px 8px;
  font-size: 11px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--trace-faint);
  margin-bottom: 4px;
}

.orphan-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 7px 12px;
  border: none;
  background: transparent;
  font-size: 12px;
  color: var(--text);
  cursor: pointer;
}

.orphan-item:hover { background: var(--bg-secondary); color: var(--red); }
.orphan-item small { color: var(--text-muted); margin-left: 6px; }

@supports (padding: env(safe-area-inset-bottom)) {
  .orphan-tray { bottom: max(66px, calc(env(safe-area-inset-bottom) + 58px)); }
}

/* ─── Familienzweig-Umschalter ─── */
.family-switch {
  position: absolute;
  top: 70px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 90;
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  background: var(--bg);
  border: 2px solid var(--trace-faint);
  border-radius: 20px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.06);
  max-width: calc(100vw - 24px);
  /* drei Zweige: auf dem Handy zweizeilig. width: max-content, weil ein
     absolut positioniertes Element mit left: 50% sonst nur die halbe
     Breite als Platz sieht und jeden Knopf in eine eigene Zeile bricht. */
  width: max-content;
  flex-wrap: wrap;
  justify-content: center;
}

.family-btn {
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-family: var(--font);
  font-size: 11px;
  padding: 5px 12px;
  border-radius: 16px;
  cursor: pointer;
  white-space: nowrap;
}

.family-btn:hover { color: var(--text); }

.family-btn.active {
  background: var(--trace);
  color: var(--bg);
}

@supports (padding: env(safe-area-inset-top)) {
  .family-switch { top: max(70px, calc(env(safe-area-inset-top) + 62px)); }
}
/* Schmale Handys: „(Pomm)" weglassen, dann bleiben drei Zweige einzeilig */
.family-btn-tiny { display: none; }
@media (max-width: 480px) {
  .family-btn { padding: 5px 9px; }
  .family-btn-suffix { display: none; }
  .family-btn-full { display: none; }
  .family-btn-tiny { display: inline; }
}

/* ═══════════════════════════════════════════════════════════
   ANSICHTS-UMSCHALTER (unten mittig, 4 Icons)
   ═══════════════════════════════════════════════════════════ */

.view-switch {
  position: absolute;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  z-index: 90;
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  background: var(--bg);
  border: 2px solid var(--trace-faint);
  border-radius: 22px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.06);
}
.view-btn {
  width: 40px;
  height: 44px;
  border: none;
  border-radius: 16px;
  background: transparent;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
}
.view-btn:hover { color: var(--text); }
.view-btn.active { background: var(--trace); color: var(--bg); }
/* Seitenpanel (Desktop) offen: in die freie linke Hälfte rücken */
@media (min-width: 600px) {
  body.side-panel-open .view-switch,
  body.side-panel-open .family-switch,
  body.side-panel-open .temp-root-bar,
  body.side-panel-open .offline-banner { left: calc((100% - min(400px, 50vw)) / 2); }
}
@supports (padding: env(safe-area-inset-bottom)) {
  .view-switch { bottom: max(16px, calc(env(safe-area-inset-bottom) + 8px)); }
}
/* Handy: sechs Ansichten à 36 px, mittig (rechts unten ist seit dem Umzug
   der Knöpfe nach oben nichts mehr im Weg) */
@media (max-width: 480px) {
  .view-btn { width: 44px; }
}

/* Readable forms without iOS auto-zoom; pinch zoom remains available outside canvases. */
@media (max-width: 599px) {
  .input-group input:not([type="checkbox"]), .input-group select, .input-group textarea,
  #search-input, #article-textarea { font-size: 16px; }
}
:focus-visible { outline: 3px solid var(--accent, #e63946); outline-offset: 3px; }
button.search-result-item { width: 100%; border: 0; background: var(--bg); text-align: left; font: inherit; }
.checkbox-label { display: flex; align-items: center; gap: 8px; }
.checkbox-label input[type="checkbox"] { width: 20px; height: 20px; flex: none; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

.admin-code-box { border: 1.5px solid var(--trace-faint); border-radius: var(--radius-lg); padding: 12px 14px; }
.admin-code-row { display: flex; gap: 12px; flex-wrap: wrap; }
.admin-code-row .input-group { flex: 1 1 200px; margin-bottom: 8px; }
.admin-code-box .btn { width: auto; display: inline-block; margin-right: 10px; }

/* Änderungsprotokoll (Nutzerverwaltung) */
.changes-list { display: flex; flex-direction: column; gap: 6px; }
.change-item { display: grid; grid-template-columns: 74px 1fr; column-gap: 10px; padding: 8px 10px;
  border: 1.5px solid var(--trace-faint); border-radius: var(--radius); font-size: 12px; line-height: 1.45; }
.change-when { color: var(--text-muted); font-size: 11px; white-space: nowrap; }
.change-who { font-weight: 600; }
.change-what { color: var(--text-secondary); }
.change-subject { color: var(--text); cursor: pointer; text-decoration: underline; text-decoration-color: var(--trace-light); }
.change-subject:hover { color: var(--red); }
.change-fields { color: var(--text-muted); }
.change-op { display: inline-block; padding: 0 5px; border-radius: 3px; font-size: 10px; font-weight: 600; margin-right: 4px; vertical-align: 1px; }
.change-op.INSERT { background: #e6f4ea; color: #1e7b3a; }
.change-op.UPDATE { background: var(--blue-light); color: var(--blue); }
.change-op.DELETE { background: var(--red-light); color: var(--red); }
.changes-more { margin-top: 8px; }

/* Nutzungsstatistik (Nutzerverwaltung) */
.usage-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; margin-bottom: 14px; }
.usage-tile { border: 1.5px solid var(--trace-faint); border-radius: var(--radius-lg); padding: 10px 12px; }
.usage-val { font-size: 22px; font-weight: 700; line-height: 1.1; }
.usage-label { font-size: 11px; font-weight: 600; letter-spacing: 0.5px; text-transform: uppercase; color: var(--text-secondary); margin-top: 4px; }
.usage-sub { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.usage-table-wrap { overflow-x: auto; border: 1.5px solid var(--trace-faint); border-radius: var(--radius-lg); }
.usage-table { border-collapse: collapse; width: 100%; font-size: 12px; }
.usage-table th { text-align: right; font-size: 10px; letter-spacing: 0.4px; text-transform: uppercase; color: var(--text-muted); padding: 8px 8px; border-bottom: 1.5px solid var(--trace-faint); white-space: nowrap; }
.usage-table th:first-child, .usage-table td.usage-day { text-align: left; }
.usage-table td { text-align: right; padding: 5px 8px; border-bottom: 1px solid var(--trace-faint); font-variant-numeric: tabular-nums; }
.usage-table td.usage-zero { color: var(--trace-light); }
.usage-table tr.usage-total td { font-weight: 700; border-top: 1.5px solid var(--trace); border-bottom: none; }

/* Datenschutz-Seite */
#view-privacy { overflow-y: auto; padding: 24px; align-items: flex-start; justify-content: flex-start; }
.privacy-container { max-width: 640px; width: 100%; margin: 0 auto; }
.privacy-header { display: flex; align-items: center; gap: 12px; }
.privacy-header h2 { margin: 0; }
.privacy-body { font-size: 13px; line-height: 1.7; color: var(--text); }
.privacy-body h3 { font-size: 11px; font-weight: 600; letter-spacing: 1px; text-transform: uppercase; color: var(--text-muted); margin: 22px 0 8px; }
.privacy-body ul { padding-left: 18px; margin: 0 0 12px; }
.privacy-body li { margin-bottom: 6px; }
.privacy-body a { color: var(--blue); }
.privacy-date { color: var(--text-muted); font-size: 11px; }

/* Hinweis: eigenes Profil noch unverbunden — unter dem Familien-Umschalter */
.connect-hint {
  position: absolute;
  top: 116px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 90;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: var(--red-light);
  border: 1.5px solid var(--red);
  border-radius: var(--radius-lg);
  font-size: 12px;
  color: var(--text);
  max-width: calc(100vw - 24px);
  box-shadow: var(--shadow);
}
.connect-hint .btn { margin: 0; white-space: nowrap; }
@media (max-width: 480px) { .connect-hint { flex-direction: column; gap: 6px; text-align: center; } }

.claim-branch-box { margin-top: 14px; padding: 12px 14px; border: 1.5px solid var(--trace-faint); border-radius: var(--radius-lg); text-align: left; }
.claim-branch-label { display: block; font-size: 11px; font-weight: 600; letter-spacing: 1px; text-transform: uppercase; color: var(--text-muted); margin-bottom: 8px; }
.claim-branch-options { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.claim-branch-option { display: flex; align-items: center; gap: 10px; font-size: 13px; cursor: pointer; }
.claim-branch-option input { width: 16px; height: 16px; margin: 0; accent-color: var(--red); }

/* Code-Feld unter dem Familientag-Knopf */
.guest-code-box { margin-top: 12px; text-align: left; }

/* ═══════════════════════════════════════════════════════════
   OFFLINE / FAMILIENTAG BANNER (über dem Ansichts-Umschalter)
   ═══════════════════════════════════════════════════════════ */

.offline-banner {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  bottom: 66px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  background: var(--bg);
  border: 2px solid var(--trace-faint);
  border-radius: 20px;
  font-size: 11px;
  color: var(--text-secondary);
  z-index: 90;
  box-shadow: 0 2px 12px rgba(0,0,0,0.06);
  white-space: nowrap;
  pointer-events: none;
}

.offline-banner .offline-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--red);
  flex-shrink: 0;
  animation: pulse-dot 2s ease-in-out infinite;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

/* ═══════════════════════════════════════════════════════════
   WHO AM I (identity picker)
   ═══════════════════════════════════════════════════════════ */

.whoami-hint {
  padding: 12px;
  color: var(--text-muted);
  text-align: center;
  font-size: 13px;
}

/* ═══════════════════════════════════════════════════════════
   CONNECTION STEPS (plain-language path)
   ═══════════════════════════════════════════════════════════ */

.conn-detail-main .conn-value {
  font-size: 15px;
}
.conn-detail-main { flex-wrap: wrap; }
.conn-explanation {
  flex-basis: 100%;
  margin-top: 6px;
  font-size: 11.5px;
  line-height: 1.45;
  color: var(--text-secondary);
}

.conn-steps-wrap {
  padding: 10px 12px;
  border: 2px solid var(--trace-faint);
  border-radius: var(--radius);
}

.conn-steps {
  margin-top: 8px;
  display: flex;
  flex-direction: column;
}

.conn-step {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  cursor: pointer;
  position: relative;
  padding: 0 0 14px 0;
}

.conn-step:last-child {
  padding-bottom: 0;
}

/* vertical connector line between step dots */
.conn-step:not(:last-child)::before {
  content: '';
  position: absolute;
  left: 4px;
  top: 12px;
  bottom: 0;
  width: 2px;
  background: var(--trace-faint);
}

/* Schritt-Icons: Endpunkte als Punkt, dazwischen Richtungspfeile,
   gemeinsamer Vorfahre als blauer Stern */
.conn-step-icon {
  width: 14px;
  height: 14px;
  margin: 1px 0 0 -2px;      /* zentriert auf der Verbindungslinie (left 4px + 1px) */
  flex-shrink: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--bg);
  color: var(--red);
}

.conn-step-icon svg {
  width: 13px;
  height: 13px;
}

.conn-step-icon.endpoint {
  width: 10px;
  height: 10px;
  margin: 3px 2px 0 0;
  border: 2px solid var(--red);
  background: var(--red);
}

.conn-step-icon.ancestor {
  width: 20px;
  height: 20px;
  margin: -2px 0 0 -5px;
  color: var(--blue);
  background: var(--blue-light);
  border: 2px solid var(--blue);
}

.conn-step-icon.ancestor svg {
  width: 11px;
  height: 11px;
}

.conn-step-ancestor .conn-step-body {
  background: var(--blue-light);
  border-left: 3px solid var(--blue);
  border-radius: var(--radius);
  padding: 4px 8px;
  margin-top: -3px;
  flex: 1;
}

.conn-step-ancestor .conn-step-name {
  color: var(--blue);
}

.conn-step-body {
  min-width: 0;
}

.conn-step-name {
  font-size: 12px;
  font-weight: 600;
  line-height: 1.3;
}

.conn-step-name:hover {
  color: var(--red);
}

.conn-step-sub {
  font-size: 11px;
  color: var(--text-secondary);
  line-height: 1.3;
}

.conn-branch-btn { margin-top: 10px; }
.conn-step-hint {
  font-size: 12px;
  color: var(--text-muted);
  padding: 6px 0;
}

/* ═══════════════════════════════════════════════════════════
   FAN CHART (radiale Ansicht) — Overlay über dem Cytoscape-Baum
   ═══════════════════════════════════════════════════════════ */

#fan-container {
  position: absolute;
  inset: 0;
  z-index: 20;
  background: var(--bg);
  background-image: radial-gradient(circle, var(--trace-faint) 1px, transparent 1px);
  background-size: 24px 24px;
}

#fan-container.hidden { display: none; }

.fan-svg {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: grab;
  font-family: var(--font);
}

.fan-svg:active { cursor: grabbing; }

.fan-seg { cursor: pointer; }
/* Hover-Halo: dicker Rand in Segmentfarbe (per JS als Kopie über den Nachbarn gelegt) */
.fan-hover { pointer-events: none; }
.fan-hover .fan-hover-rim { vector-effect: non-scaling-stroke; stroke-linejoin: round; fill: none; }

.fan-hl, .fan-hl * {
  pointer-events: none;
}

/* Verwandtschaftspfad: Unbeteiligte ausgrauen, Beteiligte behalten Farbe + roten Rahmen */
.fan-seg.fan-dim { opacity: 0.22; }
.fan-label.fan-dim { opacity: 0.3; }

.fan-label {
  pointer-events: none;
  user-select: none;
  -webkit-user-select: none;
}

/* Rändelrad: rechts, bildschirmfix; vertikal ziehen dreht den Fächer.
   .fan-wheel ist nur der (unsichtbare, großzügige) Griffbereich; die
   sichtbare Leiste mit Rillen zeichnet ::before. Die Maske liegt auf
   ::before, weil Chrome maskierte Bereiche beim Hit-Test ausblendet. */
.fan-wheel {
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 34px;                 /* Griffbereich: Leiste + 10 px Rand rechts + 4 px Spiel links */
  height: min(300px, 48vh);
  cursor: grab;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  z-index: 60;
}
.fan-wheel::before {
  content: '';
  position: absolute;
  top: 0; bottom: 0;
  right: 10px;
  width: 20px;                 /* sichtbare Leiste */
  border-radius: 10px;
  background-image: repeating-linear-gradient(to bottom, var(--trace-light) 0 1px, transparent 1px 7px);
  background-position-y: var(--wheel-y, 0px);   /* läuft mit dem Fingerweg */
  /* Rillen laufen oben/unten weich aus */
  -webkit-mask-image: linear-gradient(to bottom, transparent, #000 12%, #000 88%, transparent);
  mask-image: linear-gradient(to bottom, transparent, #000 12%, #000 88%, transparent);
  opacity: 0.85;
  transition: opacity var(--transition);
}
.fan-wheel.is-active::before {
  opacity: 1;
  background-image: repeating-linear-gradient(to bottom, var(--trace) 0 1px, transparent 1px 7px);
}
/* Hover nur mit echter Maus — auf Touch bleibt :hover nach dem Tipp kleben */
@media (hover: hover) {
  .fan-wheel:hover::before {
    opacity: 1;
    background-image: repeating-linear-gradient(to bottom, var(--trace) 0 1px, transparent 1px 7px);
  }
}
.fan-wheel.is-active { cursor: grabbing; }

/* Touch: breitere Leiste. Der Griffbereich ragt bewusst nur wenig über
   die Leiste hinaus — alles darunter wäre für Segmente/Partner-Links
   unerreichbar (Leiste 28 + 8 rechts + 6 Spiel links = 42 px). */
@media (pointer: coarse) {
  .fan-wheel { width: 42px; }
  .fan-wheel::before { width: 28px; right: 8px; border-radius: 14px; opacity: 0.95; }
}
/* Schmale Screens: Rad vertikal mittig (halbe Seitenhöhe), etwas kürzer —
   die kleinen Knöpfe oben rechts und der Umschalter unten bleiben frei */
@media (max-width: 768px) {
  .fan-wheel { top: 50%; transform: translateY(-50%); height: min(260px, 34vh); }
}

/* Zeitstrahl (Geburtsjahr-Modus): horizontales Rändelrad unten mittig.
   Streifen mit Jahresstrichen läuft unter einer festen roten Marke durch;
   Personen mit Geburtsjahr nach der Marke sind ausgeblendet (.fan-future). */
.fan-timeline {
  position: absolute;
  left: 50%;
  bottom: 62px;
  transform: translateX(-50%);
  width: min(460px, calc(100% - 180px));
  height: 34px;
  cursor: grab;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  z-index: 60;
}
.fan-timeline[hidden] { display: none; }
.fan-timeline.is-active { cursor: grabbing; }
.fan-timeline-window {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  -webkit-mask-image: linear-gradient(to right, transparent, #000 14%, #000 86%, transparent);
  mask-image: linear-gradient(to right, transparent, #000 14%, #000 86%, transparent);
}
.fan-timeline-strip {
  position: absolute;
  left: 50%;
  top: 0;
  height: 100%;
  will-change: transform;
}
.tl-tick {
  position: absolute;
  bottom: 0;
  width: 1px;
  height: 7px;
  background: var(--trace-light);
}
.tl-half { height: 10px; }
.tl-decade { height: 15px; background: var(--trace); opacity: 0.55; }
.tl-label {
  position: absolute;
  top: 1px;
  transform: translateX(-50%);
  font-size: 9px;
  color: var(--text-muted);
  letter-spacing: 0.3px;
  white-space: nowrap;
}
.fan-timeline.is-active .tl-tick { background: var(--trace); }
.fan-timeline-marker {
  position: absolute;
  left: 50%;
  top: -3px;
  bottom: -2px;
  width: 2px;
  margin-left: -1px;
  background: var(--red);
  pointer-events: none;
}
.fan-timeline-year {
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  margin-bottom: 5px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
  background: var(--bg);
  border: 1.5px solid var(--red);
  border-radius: 999px;
  padding: 2px 9px;
  white-space: nowrap;
  box-shadow: var(--shadow);
}
/* Abspielen-Taste links neben dem Streifen */
.fan-timeline-play {
  position: absolute;
  right: 100%;
  top: 50%;
  margin-right: 10px;
  transform: translateY(-50%);
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1.5px solid var(--trace);
  background: var(--bg);
  color: var(--trace);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  box-shadow: var(--shadow);
}
.fan-timeline-play svg { width: 18px; height: 18px; fill: currentColor; }
.fan-timeline-play .ico-pause { display: none; }
.fan-timeline.is-playing .fan-timeline-play { background: var(--red); border-color: var(--red); color: #fff; }
.fan-timeline.is-playing .fan-timeline-play .ico-play { display: none; }
.fan-timeline.is-playing .fan-timeline-play .ico-pause { display: block; }
.fan-timeline.is-playing .fan-timeline-year { animation: tl-pulse 1s ease-in-out infinite; }
@keyframes tl-pulse { 50% { transform: translateX(-50%) scale(1.08); } }
@media (pointer: coarse) {
  .fan-timeline { height: 40px; }
  .fan-timeline-play { width: 40px; height: 40px; }
}
/* Gast-/Offline-Pille sichtbar: Zeitstrahl darüber */
body.has-status .fan-timeline { bottom: 112px; }
@media (max-width: 600px) {
  /* über Ansichts-Umschalter, Waisen-Ablage (links unten) und Gast-Hinweis, neben dem FAB-Stapel */
  .fan-timeline, body.has-status .fan-timeline { bottom: 110px; width: calc(100% - 176px); }
}

.legend-swatch-timeline {
  background: repeating-linear-gradient(to right, var(--trace-light) 0 1px, transparent 1px 4px);
  position: relative;
}
.legend-swatch-timeline::after {
  content: ''; position: absolute; left: 50%; top: -2px; bottom: -2px; width: 2px; margin-left: -1px; background: var(--red);
}

/* Vom Zeitstrahl ausgeblendete Personen: Platz bleibt, Fläche verschwindet */
.fan-seg, .fan-label { transition: opacity 0.25s ease; }
.fan-seg.fan-future, .fan-label.fan-future { opacity: 0; pointer-events: none; }
.fan-label.fan-future .fan-spouse-link { pointer-events: none; }
.fan-label tspan.fan-future { visibility: hidden; }

/* ═══════════════════════════════════════════════════════════
   STAMMTAFEL (Tree v2, reines SVG)
   ═══════════════════════════════════════════════════════════ */
.tree-svg {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: grab;
  font-family: var(--font);
}
.tree-svg:active { cursor: grabbing; }
.tree-band { fill: transparent; }
.tree-band.odd { fill: rgba(0, 0, 0, 0.03); }
.tree-edge {
  fill: none;
  stroke: var(--trace);
  stroke-width: 1.4;
  stroke-opacity: 0.55;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.tree-edge.hl { stroke: var(--red); stroke-width: 3; stroke-opacity: 1; }
.tree-unit { transition: opacity 0.25s ease; }
.tree-person, .tree-spouse { cursor: pointer; }
.tree-person text, .tree-spouse text { pointer-events: none; }
.tree-unit.tree-dim { opacity: 0.22; }
.tree-unit.tree-hl .tree-person > rect { stroke: var(--red); stroke-width: 3; }
.tree-toggle { cursor: pointer; }
.tree-toggle text { pointer-events: none; }
@media (hover: hover) {
  .tree-person:hover > rect, .tree-spouse:hover > rect { filter: brightness(0.94); }
  .tree-toggle:hover rect { fill: var(--red); stroke: var(--red); }
  .tree-toggle:hover text { fill: #fff; }
}

/* Generationsbeschriftung: bildschirmfix am linken Rand */
.tree-genlabels { position: absolute; inset: 0; pointer-events: none; z-index: 30; }
.tree-genlabel {
  position: absolute;
  left: 10px;
  display: flex;
  align-items: baseline;
  gap: 6px;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.85);
  border: 1px solid var(--trace-faint);
  font-size: 11px;
  color: var(--text-secondary);
  white-space: nowrap;
}
.tree-genlabel b { font-size: 13px; color: var(--text); letter-spacing: 1px; }
.tree-genlabel.compact { padding: 0 6px; font-size: 10px; }
.tree-genlabel.compact b { font-size: 10px; letter-spacing: 0.5px; }

/* Minimap: rechts oben, Klick/Ziehen springt */
.tree-minimap {
  position: absolute;
  top: 12px;
  right: 68px; /* leave space for legend/centre controls */
  z-index: 40;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid var(--trace-light);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  cursor: crosshair;
  touch-action: none;
  overflow: hidden;
}
.tree-minimap[hidden] { display: none; }
.tree-minimap-svg { width: 100%; height: 100%; display: block; }
.tree-minimap-view { fill: rgba(230, 57, 70, 0.08); stroke: var(--red); stroke-width: 2; vector-effect: non-scaling-stroke; }
.tree-zoom-controls { position: absolute; right: 12px; bottom: max(80px, calc(env(safe-area-inset-bottom) + 80px)); z-index: 40; display: flex; flex-direction: column; border: 1px solid var(--trace-light); border-radius: 12px; overflow: hidden; box-shadow: var(--shadow); }
.tree-zoom-controls button { width: 44px; height: 44px; border: 0; background: rgba(255,255,255,.96); color: var(--text); font: 24px var(--font); cursor: pointer; }
.tree-zoom-controls button + button { border-top: 1px solid var(--trace-light); }
.tree-zoom-controls button:hover { background: var(--bg-secondary); }
.profile-link-section .hint { line-height: 1.5; margin-bottom: 12px; }
.profile-link-section .mini-result-item { display: block; width: 100%; text-align: left; color: var(--text); background: var(--bg); font: inherit; border: 0; border-bottom: 1px solid var(--trace-faint); min-height: 44px; cursor: pointer; }
.profile-link-section .btn { width: 100%; }
.profile-link-section .btn:disabled { opacity: .45; cursor: not-allowed; }
@media (min-width: 601px) { body.side-panel-open .tree-zoom-controls { right: calc(min(400px, 50vw) + 12px); } }
@media (max-width: 599px) {
  body.side-panel-open .tree-zoom-controls { top: auto; bottom: calc(50dvh + 12px); flex-direction: row; }
  body.side-panel-open .tree-zoom-controls button + button { border-top: 0; border-left: 1px solid var(--trace-light); }
}
@media (max-width: 900px) {
  /* unter dem Familien-Umschalter (der reicht auf schmalen Screens bis rechts) */
  .tree-minimap { top: 62px; }
}
@media (max-width: 600px) {
  .tree-minimap { top: 58px; right: 64px; transform: scale(0.8); transform-origin: top right; }
}

/* Legende Stammtafel */
.legend-swatch-tree-spouse { background: hsl(340 60% 93%); border: 1px solid var(--trace); }
.legend-swatch-tree-toggle {
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--trace); border-radius: 999px; background: #fff; font-size: 11px; font-weight: 700; line-height: 1;
}
.legend-swatch-tree-stack {
  background:
    linear-gradient(to right, var(--trace) 0 1px, transparent 1px) 3px 0 / 100% 100% no-repeat,
    repeating-linear-gradient(to bottom, var(--trace-light) 0 3px, transparent 3px 5px) 6px 0 / 16px 100% no-repeat;
}

/* Plus-Chips (Kind/Geschwister anlegen) */
.fan-ghost { cursor: pointer; }
.fan-ghost:hover circle { fill: var(--red); stroke: var(--red); }
.fan-ghost:hover text { fill: #fff; }
.fan-ghost text { pointer-events: none; }

/* Partner-Namen im Segment: Hyperlink zum eigenen Profil; beim Hovern
   rot, damit klar ist, welcher Link gerade gewählt ist */
.fan-spouse-link {
  pointer-events: none;   /* Treffer werden per Geometrie ermittelt (spouseLinkAt), nicht per DOM-Hit-Test */
  fill: var(--blue);
  fill-opacity: 1;
  text-decoration: underline;
}
.fan-spouse-link.is-hover { fill: var(--red); }

/* Namens-Modus: wer den Zweig-Namen nicht (mehr) trägt, wird gedämpft */
.fan-label.fan-muted { opacity: 0.35; }
.fan-label tspan.fan-muted { fill-opacity: 0.3; }


/* ═══════════════════════════════════════════════════════════
   GOTHA-ANSICHT (Textverzeichnis mit Einrückung je Generation)
   ═══════════════════════════════════════════════════════════ */

#gotha-container {
  position: absolute;
  inset: 0;
  z-index: 25;
  overflow: auto;
  background: var(--bg);
  -webkit-overflow-scrolling: touch;
}

#gotha-container.hidden { display: none; }

.gotha-doc {
  max-width: 900px;
  margin: 0 auto;
  padding: 52px 16px 120px;   /* Platz für den Familien-Umschalter oben */
  font-size: 13px;
  line-height: 1.5;
}

.gotha-tools {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}
.gotha-tools .btn { margin-bottom: 0; }

.gotha-family { margin-top: 20px; }

.gotha-title {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.2px;
  margin: 0;
}

.gotha-subtitle {
  font-size: 11px;
  color: var(--text-muted);
  margin: 2px 0 10px;
}

.gotha-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

/* Einrückung je Generation mit feiner Führungslinie */
.gotha-children {
  margin-left: 12px;
  padding-left: 12px;
  border-left: 1px solid var(--trace-faint);
}

.gotha-row {
  display: flex;
  align-items: baseline;
  gap: 6px;
  padding: 3px 6px 3px 2px;
  border-radius: var(--radius);
  border-left: 3px solid transparent;
}

.gotha-row:hover { background: var(--bg-secondary); }

.gotha-toggle {
  flex: none;
  width: 18px;
  height: 18px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 12px;
  line-height: 18px;
  cursor: pointer;
  padding: 0;
  align-self: center;
}
.gotha-toggle.is-leaf { cursor: default; }

.gotha-gen {
  flex: none;
  min-width: 26px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.5px;
  color: var(--blue);
  text-align: right;
  padding-right: 4px;
}

.gotha-body { min-width: 0; }

.gotha-name {
  color: var(--text);
  text-decoration: none;
  border-bottom: 1px dotted var(--trace-light);
}
.gotha-name:hover { color: var(--red); border-bottom-color: var(--red); }

.is-registered > .gotha-body > .gotha-name { font-weight: 600; }
.is-deceased > .gotha-body { color: var(--text-secondary); }
.gotha-surname { color: var(--text-secondary); }
.gotha-muted, .gotha-dates { color: var(--text-muted); }
.gotha-spouse { color: var(--text-secondary); }
.gotha-spouse-name { color: var(--blue); }

.gotha-row.is-me {
  border-left-color: var(--red);
  background: var(--red-light);
}

.gotha-row.is-flash { animation: gothaFlash 1.6s ease-out; }
@keyframes gothaFlash {
  0% { background: var(--red-light); }
  100% { background: transparent; }
}

/* Verwandtschaftspfad: Beteiligte markieren, Rest abschwächen */
.gotha-row.is-path { border-left-color: var(--red); background: #fff5f5; }
.gotha-row.is-off-path { opacity: 0.45; }

@media (max-width: 480px) {
  .gotha-doc { padding: 52px 8px 120px; font-size: 12px; }
  .gotha-children { margin-left: 6px; padding-left: 8px; }
  .gotha-gen { min-width: 22px; }
}

/* ═══════════════════════════════════════════════════════════
   ARTIKEL-ANSICHT (Vollseite mit Properties + Markdown-Vita)
   ═══════════════════════════════════════════════════════════ */

#view-article { overflow-y: auto; background: var(--bg); }

.article-container {
  max-width: 760px;
  margin: 0 auto;
  padding: 0 20px 80px;
  width: 100%;
}

.article-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 0;
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 10;
}

.article-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.article-actions .btn { margin-bottom: 0; }

.article-hero {
  display: flex;
  align-items: center;
  gap: 16px;
  margin: 8px 0 16px;
}

.article-photo {
  flex: none;
  width: 72px;
  height: 72px;
  border-radius: var(--radius-lg);
  border: 2px solid var(--trace);
  background: var(--bg-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  font-weight: 600;
  color: var(--text-muted);
  overflow: hidden;
}
.article-photo img { width: 100%; height: 100%; object-fit: cover; }

.article-name { font-size: 26px; font-weight: 600; letter-spacing: -0.5px; line-height: 1.2; margin: 0; }
.article-birthname { color: var(--text-secondary); font-size: 13px; margin: 2px 0 0; }

/* Properties wie in Notion: Schlüssel links schmal, Wert rechts */
.article-props {
  display: grid;
  grid-template-columns: 130px 1fr;
  gap: 6px 12px;
  padding: 12px 0;
  border-top: 2px solid var(--trace-faint);
  border-bottom: 2px solid var(--trace-faint);
  font-size: 13px;
}
.article-prop-key { color: var(--text-muted); font-size: 11px; letter-spacing: 0.5px; text-transform: uppercase; padding-top: 3px; }
.article-prop-val { color: var(--text); min-width: 0; overflow-wrap: anywhere; }
/* Beziehungen: identische .rel-item/.rel-type-badge-Styles wie im Profil, nur kompakter */
.article-rels .rel-item { padding: 6px 10px; margin-bottom: 4px; }
.article-badges { display: flex; flex-wrap: wrap; gap: 6px; padding: 0; margin: 0; }

.article-section-title {
  font-size: 11px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin: 22px 0 8px;
}

/* Der Artikel: lesefreundlich, proportionale Schrift für Fließtext */
.article-body {
  font-size: 15px;
  line-height: 1.65;
  color: var(--text);
}
.article-body.is-empty { color: var(--text-muted); font-size: 13px; }
.article-body h2 { font-size: 19px; font-weight: 600; margin: 22px 0 8px; letter-spacing: -0.2px; }
.article-body h3 { font-size: 15px; font-weight: 600; margin: 18px 0 6px; }
.article-body h4 { font-size: 13px; font-weight: 600; margin: 14px 0 4px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-secondary); }
.article-body p { margin: 0 0 12px; }
.article-body ul, .article-body ol { margin: 0 0 12px 22px; padding: 0; }
.article-body li { margin: 3px 0; }
.article-body blockquote { margin: 0 0 12px; padding: 6px 14px; border-left: 3px solid var(--trace-light); color: var(--text-secondary); }
.article-body hr { border: none; border-top: 2px solid var(--trace-faint); margin: 18px 0; }
.article-body a { color: var(--blue); text-decoration: underline; }
.article-body strong { font-weight: 600; }

/* Editor */
.article-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 6px;
  border: 2px solid var(--trace-light);
  border-bottom: none;
  border-radius: var(--radius) var(--radius) 0 0;
  background: var(--bg-secondary);
}
.article-toolbar button {
  border: 1px solid transparent;
  background: transparent;
  font-family: var(--font);
  font-size: 12px;
  padding: 4px 8px;
  border-radius: var(--radius);
  cursor: pointer;
  color: var(--text);
}
.article-toolbar button:hover { border-color: var(--trace); background: var(--bg); }

.article-textarea {
  width: 100%;
  min-height: 60vh;
  padding: 12px;
  border: 2px solid var(--trace-light);
  border-radius: 0 0 var(--radius) var(--radius);
  font-family: var(--font);
  font-size: 13px;
  line-height: 1.6;
  resize: vertical;
  outline: none;
}
.article-textarea:focus { border-color: var(--trace); }
.article-preview {
  padding: 12px;
  border: 2px solid var(--trace-light);
  border-radius: 0 0 var(--radius) var(--radius);
  min-height: 60vh;
}
.article-hint { font-size: 11px; color: var(--text-muted); margin-top: 8px; line-height: 1.6; }
.article-hint code { background: var(--bg-secondary); padding: 1px 4px; border-radius: 3px; }

/* „Ganze Seite öffnen" / „Weiterlesen" unter dem Vita-Auszug */
.profile-article-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
}

@media (max-width: 480px) {
  .article-props { grid-template-columns: 96px 1fr; }
  .article-name { font-size: 22px; }
  .article-container { padding: 0 14px 80px; }
}

/* ═══════════════════════════════════════════════════════════
   KARTENANSICHT (map.js) — Wohnorte aller Zweige
   ═══════════════════════════════════════════════════════════ */

#map-container {
  position: absolute;
  inset: 0;
  z-index: 26;               /* über Fächer (20) und Gotha (25) */
  background: var(--bg-secondary);
}
#map-container.hidden { display: none; }
.map-canvas { position: absolute; inset: 0; font-family: var(--font); }
.map-canvas .leaflet-control-attribution { font-family: var(--font); font-size: 9px; color: var(--text-muted); background: rgba(255,255,255,0.8); }
.map-canvas .leaflet-control-attribution a { color: var(--text-secondary); }
.map-canvas .leaflet-bar { border: 1px solid var(--trace-faint); box-shadow: var(--shadow); }
.map-canvas .leaflet-bar a { font-family: var(--font); color: var(--text); }
.map-canvas .leaflet-bottom.leaflet-right { bottom: 8px; right: 6px; }
.map-canvas .leaflet-div-icon { background: none; border: none; }

/* Pin für einen Ort: Kreis mit Zahl + Ortsname darunter */
.map-marker { pointer-events: none; }
.map-pin, .map-cluster { pointer-events: auto; cursor: pointer; }
.map-pin {
  position: absolute; left: -16px; top: -16px;
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--pin, var(--blue)); color: #fff;
  border: 2px solid #fff; box-shadow: 0 2px 8px rgba(0,0,0,0.25);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font); font-size: 12px; font-weight: 700;
  transition: transform 150ms ease;
}
.map-pin:hover { transform: scale(1.12); }
.map-pin.is-deceased { opacity: 0.55; }
.map-pin-label {
  position: absolute; left: 50%; top: 18px; transform: translateX(-50%);
  white-space: nowrap; font-family: var(--font); font-size: 11px; color: var(--text);
  background: rgba(255,255,255,0.85); padding: 1px 5px; border-radius: 3px;
  text-shadow: 0 0 2px #fff;
}
/* Bündel mehrerer Orte */
.map-cluster {
  border-radius: 50%;
  background: color-mix(in srgb, var(--pin, var(--blue)) 82%, #fff);
  color: #fff; border: 3px solid rgba(255,255,255,0.9);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--pin, var(--blue)) 30%, transparent), 0 2px 10px rgba(0,0,0,0.2);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font); font-size: 13px; font-weight: 700;
  transition: transform 150ms ease;
}
.map-cluster:hover { transform: scale(1.08); }

/* Werkzeuge oben links (unter dem Zweig-Umschalter auf dem Handy) */
/* Koordinaten relativ zum Kartencontainer (beginnt unter der Kopfleiste): 12px = Höhe des Zweig-Umschalters */
.map-tools { position: absolute; top: 12px; left: 12px; z-index: 400; display: flex; gap: 6px; }
.map-toggle {
  border: 2px solid var(--trace-faint); background: var(--bg); color: var(--text-secondary);
  font-family: var(--font); font-size: 11px; padding: 6px 12px; border-radius: 16px;
  cursor: pointer; box-shadow: 0 2px 12px rgba(0,0,0,0.06);
}
.map-toggle.active { background: var(--trace); border-color: var(--trace); color: var(--bg); }

/* Personenliste eines Orts */
.map-list {
  position: absolute; top: 54px; left: 12px; z-index: 400;
  width: min(300px, calc(100vw - 24px)); max-height: calc(100% - 160px);
  display: flex; flex-direction: column;
  background: var(--bg); border: 1px solid var(--trace-light); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg); overflow: hidden;
}
.map-list.hidden { display: none; }
.map-list-head { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--trace-faint); }
.map-list-title { font-weight: 600; font-size: 13px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.map-list-count { font-size: 11px; color: var(--text-muted); white-space: nowrap; }
.map-list-close { border: none; background: none; font-size: 18px; line-height: 1; color: var(--text-secondary); cursor: pointer; padding: 0 2px; }
.map-list-items { overflow-y: auto; padding: 6px; }
.map-list-item {
  display: grid; grid-template-columns: 10px 1fr; grid-template-rows: auto auto; column-gap: 8px; align-items: center; width: 100%; text-align: left;
  border: none; background: none; font-family: var(--font); font-size: 12px; color: var(--text);
  padding: 7px 6px; border-radius: var(--radius); cursor: pointer;
}
.map-list-item:hover { background: var(--red-light); }
.map-list-item.is-deceased .map-list-name { color: var(--text-secondary); }
.map-list-dot { grid-row: 1 / span 2; width: 10px; height: 10px; border-radius: 50%; }
.map-list-name { min-width: 0; line-height: 1.35; }
.map-list-branch { grid-column: 2; font-size: 10px; color: var(--text-muted); }

.map-empty {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 400;
  max-width: min(360px, calc(100vw - 48px)); padding: 12px 16px; text-align: center;
  background: var(--bg); border: 1px solid var(--trace-light); border-radius: var(--radius-lg);
  box-shadow: var(--shadow); font-size: 12px; color: var(--text-secondary);
}
.map-empty.hidden { display: none; }

/* Zweig-Umschalter als Filter (Karte): mehrere „aktiv" möglich, Häkchen davor */
.family-switch.is-filter .family-btn.active::before { content: '✓ '; }

/* Legende */
.legend-swatch-map { border-radius: 50%; width: 14px; height: 14px; border: 2px solid #fff; box-shadow: 0 0 0 1px var(--trace-light); }
.legend-swatch-map-cluster, .legend-swatch-map-pin {
  display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px; border-radius: 50%;
  color: #fff; font-size: 10px; font-weight: 700; background: var(--blue); border: 2px solid #fff; box-shadow: 0 0 0 1px var(--trace-light);
}
.legend-swatch-map-cluster { box-shadow: 0 0 0 3px rgba(69,123,157,0.3); }

/* „Wie ist X mit … verwandt?" im Profil-Panel */
.connect-other-btn { margin-top: 8px; }
.connect-other-box { margin-top: 8px; }
.connect-other-box .mini-results { max-height: 220px; }

/* Temporäre Stammperson: Leiste oben mittig, unter dem Zweig-Umschalter (beide bleiben) */
.temp-root-bar {
  position: absolute; top: 112px; left: 50%; transform: translateX(-50%); z-index: 90;
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 3px 3px 12px;
  background: var(--trace); color: var(--bg); border: 2px solid var(--trace); border-radius: 20px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.12); max-width: calc(100vw - 24px); font-size: 11px;
}
.temp-root-bar.hidden { display: none; }
.temp-root-label { color: rgba(255,255,255,0.7); white-space: nowrap; }
.temp-root-name { border: none; background: none; color: var(--bg); font-family: var(--font); font-size: 11px; font-weight: 600;
  cursor: pointer; padding: 5px 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 60vw; }
.temp-root-close { width: 28px; height: 28px; border-radius: 50%; border: none; background: var(--bg); color: var(--trace);
  font-size: 18px; line-height: 1; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.temp-root-close:hover { background: var(--red); color: #fff; }
@supports (padding: env(safe-area-inset-top)) {
  .temp-root-bar { top: max(112px, calc(env(safe-area-inset-top) + 104px)); }
}
/* Handy: die Leiste braucht die Breite — ⓘ/„zu mir", Legende und Kartenwerkzeuge eine Zeile tiefer */
@media (max-width: 480px) {
  body.temp-root #fab-container { top: 154px; }
  body.temp-root .legend-panel { top: 154px; }
  body.temp-root .map-tools { top: 96px; }
  body.temp-root .map-list { top: 138px; }
}

/* Gewählte Person (Profil offen): wie der Hover-Halo, bleibt bis das Panel zugeht */
.fan-selected { pointer-events: none; }

/* Anlegen-Zeile im Profil: nur auf dem Handy (Desktop hat die Hover-Chips) */
.profile-add-row { display: none; align-items: center; flex-wrap: wrap; gap: 6px; margin: 10px 0 6px; }
.profile-add-row.hidden { display: none; }
.profile-add-label { font-size: 11px; color: var(--text-secondary); margin-right: 2px; }
.profile-add-row .btn { width: auto; }
@media (max-width: 599px) {
  .profile-add-row:not(.hidden) { display: flex; }
}

/* Orts-Picker im Editor */
.input-hint { margin-top: 4px; font-size: 11px; color: var(--text-muted); min-height: 14px; }
.input-hint.ok { color: #2a7f62; }
.input-hint.warn { color: var(--red); }
.mini-result-item .place-sub { display: block; font-size: 11px; color: var(--text-muted); }

@media (max-width: 480px) {
  .family-switch.is-filter .family-btn.active::before { content: none; }   /* Häkchen kostet die eine Zeile */
  .map-tools { top: 54px; }
  .map-list { top: 96px; max-height: calc(100% - 210px); }
  .map-canvas .leaflet-bottom.leaflet-right { bottom: 8px; }
}

/* Legende auf dem Handy: unter dem Zweig-Umschalter, neben dem ⓘ-Knopf, volle Restbreite
   (steht nach der Basisregel, sonst gewinnt deren top/right) */
@media (max-width: 480px) {
  .legend-panel { top: 112px; right: 62px; left: 12px; width: auto; max-width: none; max-height: calc(100% - 200px); }
}
