/* ------------------------------------------------------------------ Farben & Grundlagen */
:root {
  --bg: #f3eee4;
  --bg-dot: rgba(120, 100, 70, 0.10);
  --surface: #ffffff;
  --surface-2: #f8f5ef;
  --surface-3: #efe9de;
  --border: #e3dacb;
  --border-strong: #cbbfa9;
  --text: #2b2721;
  --muted: #7c7267;
  --accent: #2f6b4f;
  --accent-hover: #245a41;
  --accent-soft: #e2efe7;
  --on-accent: #ffffff;
  --gold: #c39b2c;
  --rose: #c8577a;
  --danger: #c0392b;
  --danger-soft: #fbe9e7;
  --warn-soft: #fdf3dc;
  --line: #b3a58e;
  --male: #4f7fb0;
  --female: #c0627e;
  --diverse: #8b6bb5;
  --unknown: #9a9a93;
  --male-soft: #e4edf6;
  --female-soft: #f8e6ec;
  --diverse-soft: #eee8f6;
  --unknown-soft: #eeede9;
  --shadow-sm: 0 1px 2px rgba(60, 40, 10, 0.07);
  --shadow: 0 1px 2px rgba(60, 40, 10, 0.06), 0 6px 18px rgba(60, 40, 10, 0.09);
  --shadow-lg: 0 10px 40px rgba(40, 25, 5, 0.22);
  --radius: 14px;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --header-h: 58px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1a1c19; --bg-dot: rgba(255, 255, 255, 0.05); --surface: #252824; --surface-2: #2c302b; --surface-3: #343933;
    --border: #3a3f38; --border-strong: #525a50; --text: #ece7dd; --muted: #a39b8e; --accent: #6cbf8e; --accent-hover: #82cfa1;
    --accent-soft: #263a2e; --on-accent: #10251a; --gold: #d8b54e; --rose: #e07896; --danger: #e5675a; --danger-soft: #3b2522;
    --warn-soft: #3a3322; --line: #6f6857; --male: #6f9fd0; --female: #de7f9b; --diverse: #a88bd3; --unknown: #8f8f88;
    --male-soft: #243242; --female-soft: #3d2730; --diverse-soft: #312a3d; --unknown-soft: #30312d;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3); --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 6px 18px rgba(0, 0, 0, 0.35);
    --shadow-lg: 0 10px 40px rgba(0, 0, 0, 0.5);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #1a1c19; --bg-dot: rgba(255, 255, 255, 0.05); --surface: #252824; --surface-2: #2c302b; --surface-3: #343933;
  --border: #3a3f38; --border-strong: #525a50; --text: #ece7dd; --muted: #a39b8e; --accent: #6cbf8e; --accent-hover: #82cfa1;
  --accent-soft: #263a2e; --on-accent: #10251a; --gold: #d8b54e; --rose: #e07896; --danger: #e5675a; --danger-soft: #3b2522;
  --warn-soft: #3a3322; --line: #6f6857; --male: #6f9fd0; --female: #de7f9b; --diverse: #a88bd3; --unknown: #8f8f88;
  --male-soft: #243242; --female-soft: #3d2730; --diverse-soft: #312a3d; --unknown-soft: #30312d;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3); --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 6px 18px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 10px 40px rgba(0, 0, 0, 0.5);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.45;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); }
[hidden] { display: none !important; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.block { display: block; }
.center { text-align: center; justify-content: center; }
.pad { padding: 12px; }
.pre { white-space: pre-wrap; }
.error { color: var(--danger); }
.spacer { flex: 1; }
.print-only { display: none; }
.ico { width: 20px; height: 20px; flex: none; }
code { background: var(--surface-3); padding: 1px 5px; border-radius: 5px; font-size: 0.9em; }

/* ------------------------------------------------------------------ Knöpfe & Formulare */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 38px; padding: 7px 14px; border-radius: 10px;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  font-weight: 550; text-decoration: none; white-space: nowrap; transition: background .15s, border-color .15s, box-shadow .15s;
}
.btn:hover { background: var(--surface-2); border-color: var(--muted); }
.btn:focus-visible, .icon-btn:focus-visible, .ctrl:focus-visible, .tab:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn:disabled { opacity: .55; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.danger-text, .danger-text { color: var(--danger); }
.btn.small { min-height: 32px; padding: 4px 10px; font-size: 13.5px; border-radius: 9px; }
.btn.big { min-height: 46px; padding: 10px 22px; font-size: 16px; }
.btn.dashed { border-style: dashed; color: var(--accent); background: transparent; }
.btn.dashed:hover { background: var(--accent-soft); border-color: var(--accent); }
.btn.full { width: 100%; }
.btn .ico, .btn-link .ico { width: 18px; height: 18px; }
.btn-link { background: none; border: none; padding: 0; color: var(--accent); font-weight: 550; display: inline-flex; align-items: center; gap: 5px; }
.btn-link:hover { text-decoration: underline; }
.icon-btn {
  display: inline-grid; place-items: center; width: 38px; height: 38px; border-radius: 10px;
  border: none; background: transparent; color: var(--muted); flex: none;
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.icon-btn.small { width: 30px; height: 30px; }
.icon-btn.small .ico { width: 17px; height: 17px; }

.form { display: flex; flex-direction: column; gap: 12px; }
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field-label { font-size: 12.5px; font-weight: 600; color: var(--muted); letter-spacing: .01em; }
.field-hint { font-size: 12px; color: var(--muted); min-height: 0; }
.field-hint.ok { color: var(--accent); }
.field-hint.error { color: var(--danger); }
input[type="text"], input[type="search"], input[type="number"], select, textarea {
  width: 100%; min-height: 40px; padding: 8px 11px; border-radius: 10px;
  border: 1px solid var(--border-strong); background: var(--surface); outline: none;
  transition: border-color .15s, box-shadow .15s;
}
textarea { resize: vertical; line-height: 1.5; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input.invalid { border-color: var(--danger); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid-title { display: grid; grid-template-columns: 90px 1fr; gap: 12px; }
.row { display: flex; align-items: center; gap: 8px; }
.row.wrap { flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }
fieldset.box { border: 1px solid var(--border); border-radius: 12px; padding: 10px 14px 14px; margin: 0; display: flex; flex-direction: column; gap: 12px; }
fieldset.box legend { padding: 0 6px; font-weight: 600; display: inline-flex; align-items: center; gap: 6px; }
.small-select { width: auto; min-height: 30px; padding: 3px 8px; font-size: 13px; border-radius: 8px; }

.segmented { display: inline-flex; align-self: flex-start; flex-wrap: wrap; background: var(--surface-3); border-radius: 10px; padding: 3px; gap: 2px; }
.segmented button { border: none; background: transparent; padding: 6px 12px; border-radius: 8px; font-size: 13.5px; color: var(--muted); font-weight: 550; }
.segmented button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }

.chip {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 999px;
  background: var(--surface-3); border: 1px solid transparent; font-size: 13px; white-space: nowrap;
}
button.chip:hover { border-color: var(--border-strong); }
.chip.accent { background: var(--accent-soft); color: var(--accent); font-weight: 600; margin-top: 6px; }
.chip.accent .ico { width: 16px; height: 16px; }
.chip.warn { background: var(--warn-soft); color: #9a6a00; }
.chip.small { font-size: 12px; padding: 2px 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }

/* ------------------------------------------------------------------ Kopfzeile */
.topbar {
  position: fixed; top: 0; left: 0; right: 0; height: var(--header-h); z-index: 30;
  display: flex; align-items: center; gap: 14px; padding: 0 14px;
  background: var(--surface); border-bottom: 1px solid var(--border); box-shadow: var(--shadow-sm);
}
.brand { display: flex; align-items: center; gap: 9px; border: none; background: none; padding: 4px 6px; border-radius: 10px; min-width: 0; }
.brand:hover { background: var(--surface-2); }
.brand-logo { width: 30px; height: 30px; color: var(--accent); flex: none; }
#tree-title { font-family: var(--serif); font-size: 19px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 260px; }
.views { display: flex; background: var(--surface-3); padding: 3px; border-radius: 11px; gap: 2px; }
.views button { border: none; background: transparent; padding: 6px 14px; border-radius: 9px; font-weight: 600; color: var(--muted); font-size: 14px; }
.views button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.search-wrap { position: relative; flex: 1; max-width: 380px; margin-left: auto; }
.search-box { display: flex; align-items: center; gap: 8px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 11px; padding: 0 10px; }
.search-box:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); background: var(--surface); }
.search-box .ico { color: var(--muted); width: 18px; height: 18px; }
.search-box input { border: none; box-shadow: none !important; background: transparent; min-height: 38px; padding: 6px 0; }
.search-box.grow { flex: 1; }
.search-results {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0; z-index: 40; max-height: 60vh; overflow: auto;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-lg); padding: 4px;
}
.sr-row { display: flex; align-items: center; gap: 10px; width: 100%; border: none; background: none; padding: 7px 8px; border-radius: 9px; text-align: left; }
.sr-row:hover, .sr-row.active { background: var(--accent-soft); }
.topbar-right { display: flex; align-items: center; gap: 8px; }
.only-mobile { display: none; }

.switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; padding: 4px 8px; border-radius: 10px; }
.switch:hover { background: var(--surface-2); }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch-track { width: 40px; height: 23px; border-radius: 999px; background: var(--border-strong); position: relative; transition: background .2s; flex: none; }
.switch-thumb { position: absolute; top: 3px; left: 3px; width: 17px; height: 17px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .2s; }
.switch input:checked + .switch-track { background: var(--accent); }
.switch input:checked + .switch-track .switch-thumb { transform: translateX(17px); }
.switch input:focus-visible + .switch-track { outline: 2px solid var(--accent); outline-offset: 2px; }
.switch-label { font-weight: 600; font-size: 14px; }

/* ------------------------------------------------------------------ Hauptbereich */
main { position: fixed; top: var(--header-h); left: 0; right: 0; bottom: 0; }
.view { position: absolute; inset: 0; }
#view-list { overflow: auto; }
.loading { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); }

/* ------------------------------------------------------------------ Baum */
.tree-host { position: absolute; inset: 0; }
.viewport {
  position: absolute; inset: 0; overflow: hidden; cursor: grab; touch-action: none; outline: none;
  background-color: var(--bg);
  background-image: radial-gradient(var(--bg-dot) 1.2px, transparent 1.3px);
  background-size: 22px 22px;
  user-select: none; -webkit-user-select: none;
}
.viewport.dragging { cursor: grabbing; }
.canvas { position: absolute; left: 0; top: 0; transform-origin: 0 0; will-change: transform; }
.canvas.smooth { transition: transform .55s cubic-bezier(.2, .8, .2, 1); }
svg.links { position: absolute; left: 0; top: 0; overflow: visible; pointer-events: none; transition: opacity .3s; }
svg.links.fading { opacity: 0; transition: opacity .12s; }
svg.links path { fill: none; stroke: var(--line); stroke-width: 2.2; stroke-linejoin: round; stroke-linecap: round; }
svg.links path.dashed { stroke-dasharray: 6 6; stroke-width: 1.8; opacity: .85; }
.cards { position: absolute; left: 0; top: 0; }
.cards > * { position: absolute; left: 0; top: 0; transition: opacity .35s ease; }
.cards.animate > * { transition: transform .55s cubic-bezier(.2, .8, .2, 1), opacity .35s ease; }
.cards > .enter { opacity: 0; }
.cards > .leave { opacity: 0; pointer-events: none; }

.card {
  --g: var(--unknown); --g-soft: var(--unknown-soft);
  display: flex; flex-direction: column; align-items: center; text-align: center;
  padding: 16px 10px 12px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); cursor: pointer;
}
.card.g-m { --g: var(--male); --g-soft: var(--male-soft); }
.card.g-f { --g: var(--female); --g-soft: var(--female-soft); }
.card.g-d { --g: var(--diverse); --g-soft: var(--diverse-soft); }
.card:hover { border-color: var(--g); box-shadow: 0 0 0 1px var(--g), var(--shadow); }
.card.focus { box-shadow: 0 0 0 3px var(--accent), 0 10px 28px rgba(40, 60, 40, .22); border-color: var(--accent); }
.card.selected { outline: 2px dashed var(--g); outline-offset: 5px; }
.card-stripe { position: absolute; top: 0; left: 0; right: 0; height: 6px; background: var(--g); border-radius: var(--radius) var(--radius) 0 0; }
.card-photo {
  width: 86px; height: 86px; border-radius: 50%; overflow: hidden; flex: none;
  border: 3px solid var(--g); background: var(--g-soft); box-shadow: 0 0 0 3px var(--surface);
}
.card-photo img { width: 100%; height: 100%; object-fit: cover; display: block; pointer-events: none; }
.card.deceased .card-photo img { filter: saturate(.8); }
.avatar { position: relative; width: 100%; height: 100%; display: grid; place-items: center; }
.avatar svg { position: absolute; inset: 14% 14% 0; width: 72%; height: 86%; fill: var(--g); opacity: .22; }
.avatar span { position: relative; font-size: 24px; font-weight: 700; color: var(--g); letter-spacing: .02em; }
.card-name { margin-top: 9px; line-height: 1.22; width: 100%; min-width: 0; }
.card-name .given { font-size: 13.5px; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.card-name .surname { font-size: 15.5px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-name .birthname { font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-name .nick { font-size: 12.5px; font-style: italic; color: var(--accent); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 1px; }
.card-dates { margin-top: auto; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; line-height: 1.35; white-space: nowrap; }
.card-dates .age { opacity: .8; }
.more {
  position: absolute; left: 50%; transform: translateX(-50%);
  display: inline-flex; align-items: center; gap: 2px; height: 24px; min-width: 30px; padding: 0 7px;
  border-radius: 999px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--accent);
  font-size: 12px; font-weight: 700; box-shadow: var(--shadow-sm);
}
.more .ico { width: 15px; height: 15px; }
.more.up { top: -13px; }
.more.down { bottom: -13px; }
.more:hover { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }

.ghost {
  --g: var(--accent);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px;
  border: 2px dashed var(--border-strong); border-radius: 12px; background: color-mix(in srgb, var(--surface) 70%, transparent);
  color: var(--muted); font-size: 13px; font-weight: 600; padding: 6px;
}
.ghost.g-m { --g: var(--male); }
.ghost.g-f { --g: var(--female); }
.ghost:hover { border-color: var(--g); color: var(--g); background: var(--surface); box-shadow: var(--shadow); }
.ghost-plus { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: var(--g); color: #fff; }
.ghost-plus .ico { width: 18px; height: 18px; stroke-width: 2.6; }
.ghost-x {
  position: absolute; top: 3px; right: 3px; width: 22px; height: 22px; border-radius: 50%;
  display: grid; place-items: center; color: var(--muted); opacity: 0; transition: opacity .15s, background .15s;
}
.ghost-x .ico { width: 14px; height: 14px; }
.ghost:hover .ghost-x, .ghost:focus-visible .ghost-x { opacity: 1; }
.ghost-x:hover { background: var(--danger-soft); color: var(--danger); }
@media (hover: none) { .ghost-x { opacity: .7; } }

.union {
  width: 36px; height: 36px; padding: 0; border: none; border-radius: 50%;
  display: grid; place-items: center; background: var(--bg); cursor: pointer;
}
.union:hover { box-shadow: 0 0 0 2px var(--gold); background: var(--surface); }
.union.kind-partner:hover { box-shadow: 0 0 0 2px var(--rose); }
.union .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--line); }

.tree-controls {
  position: absolute; right: 16px; bottom: 16px; z-index: 5;
  display: flex; flex-direction: column; gap: 2px; padding: 5px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow);
}
.ctrl { width: 40px; height: 40px; border: none; background: none; border-radius: 10px; display: grid; place-items: center; color: var(--text); }
.ctrl:hover { background: var(--surface-3); }
.ctrl-sep { height: 1px; background: var(--border); margin: 3px 6px; }
.gen-pop {
  position: absolute; right: calc(100% + 10px); bottom: 0; width: 270px; padding: 14px 16px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column; gap: 14px; font-size: 14px;
}
.gen-pop label:not(.check) { display: flex; flex-direction: column; gap: 6px; }
.gen-pop input[type="range"] { width: 100%; accent-color: var(--accent); }
.focus-bar {
  position: absolute; left: 16px; bottom: 16px; z-index: 5; max-width: calc(100% - 110px);
  padding: 7px 14px; background: var(--surface); border: 1px solid var(--border); border-radius: 999px; box-shadow: var(--shadow);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.edit-hint {
  position: absolute; top: 12px; left: 50%; transform: translate(-50%, -8px); z-index: 5; opacity: 0; pointer-events: none;
  padding: 7px 16px; border-radius: 999px; background: var(--accent); color: var(--on-accent); font-size: 13px; box-shadow: var(--shadow);
  transition: opacity .25s, transform .25s; white-space: nowrap; max-width: calc(100% - 24px); overflow: hidden; text-overflow: ellipsis;
}
body.editing .edit-hint { opacity: 1; transform: translate(-50%, 0); }
.hint-plus { font-weight: 800; }
body.is-empty .tree-controls, body.is-empty .focus-bar, body.is-empty .edit-hint { display: none; }

.empty { position: absolute; inset: 0; display: grid; place-items: center; padding: 20px; z-index: 6; background: var(--bg); overflow: auto; }
.empty-card { max-width: 560px; text-align: center; background: var(--surface); border: 1px solid var(--border); border-radius: 20px; padding: 34px 30px; box-shadow: var(--shadow); }
.empty-art { width: 120px; height: 100px; color: var(--accent); }
.empty-card h1 { font-family: var(--serif); font-size: 28px; margin: 10px 0 8px; font-weight: 600; }
.empty-card p { color: var(--muted); margin: 0 0 22px; }

/* ------------------------------------------------------------------ Seitenleiste Person */
.panel {
  position: fixed; top: var(--header-h); right: 0; bottom: 0; width: min(470px, 100vw); z-index: 25;
  background: var(--surface); border-left: 1px solid var(--border); box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column; transform: translateX(105%); transition: transform .28s cubic-bezier(.2, .8, .2, 1);
}
.panel.open { transform: none; }
.panel-head { padding: 10px 16px 12px; border-bottom: 1px solid var(--border); background: var(--surface-2); }
.panel-actions { display: flex; align-items: center; gap: 4px; margin-bottom: 8px; }
.panel-id { display: flex; gap: 16px; align-items: flex-start; }
.panel-photo {
  --g: var(--unknown); --g-soft: var(--unknown-soft);
  position: relative; width: 104px; height: 104px; border-radius: 50%; overflow: hidden; flex: none; padding: 0;
  border: 3px solid var(--g); background: var(--g-soft); display: grid; place-items: center;
}
.panel-photo.g-m { --g: var(--male); --g-soft: var(--male-soft); }
.panel-photo.g-f { --g: var(--female); --g-soft: var(--female-soft); }
.panel-photo.g-d { --g: var(--diverse); --g-soft: var(--diverse-soft); }
.panel-photo img { width: 100%; height: 100%; object-fit: cover; }
.panel-photo .initials { font-size: 34px; font-weight: 700; color: var(--g); }
.photo-edit { position: absolute; inset: auto 0 0 0; height: 34px; display: grid; place-items: center; background: rgba(0,0,0,.45); color: #fff; opacity: 0; transition: opacity .15s; }
.panel-photo:hover .photo-edit, .panel-photo:focus-visible .photo-edit { opacity: 1; }
.panel-names { min-width: 0; flex: 1; }
.panel-names h2 { font-family: var(--serif); font-size: 22px; line-height: 1.2; margin: 2px 0 2px; font-weight: 600; overflow-wrap: anywhere; }
.panel-names .nick { font-style: italic; color: var(--accent); }
.panel-names .life { font-size: 14px; }
.tabs { display: flex; gap: 2px; padding: 0 10px; border-bottom: 1px solid var(--border); overflow-x: auto; scrollbar-width: none; flex: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  border: none; background: none; padding: 11px 10px 10px; font-weight: 600; font-size: 13.5px; color: var(--muted);
  border-bottom: 2.5px solid transparent; white-space: nowrap; display: inline-flex; align-items: center; gap: 5px;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.badge { font-size: 11px; background: var(--surface-3); color: var(--muted); padding: 0 6px; border-radius: 999px; line-height: 17px; min-width: 17px; text-align: center; }
.tab.active .badge { background: var(--accent-soft); color: var(--accent); }
.panel-body { flex: 1; overflow: auto; padding: 14px 18px 40px; overscroll-behavior: contain; }
.section-title { font-size: 12.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 20px 0 8px; font-weight: 700; }
.panel-body > .section-title:first-child, .panel-body > .form > .section-title:first-child { margin-top: 4px; }

.facts { display: grid; grid-template-columns: 110px 1fr; gap: 8px 12px; padding: 12px 14px; background: var(--surface-2); border-radius: 12px; border: 1px solid var(--border); }
.fact { display: contents; }
.fact-label { color: var(--muted); font-size: 13.5px; }
.fact-value { font-weight: 550; overflow-wrap: anywhere; }

.family-mini { display: flex; flex-direction: column; gap: 10px; }
.mini-label { font-size: 12.5px; color: var(--muted); margin-bottom: 4px; font-weight: 600; }
.person-chip {
  display: inline-flex; align-items: center; gap: 8px; padding: 4px 10px 4px 4px; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--border); cursor: pointer; max-width: 100%; min-width: 0;
}
.person-chip:hover { border-color: var(--accent); background: var(--accent-soft); }
.pc-text { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.pc-name { font-weight: 600; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pc-life { font-size: 11.5px; color: var(--muted); }
.chip-rings { border: none; background: none; padding: 0 0 0 2px; display: grid; place-items: center; }
.mini-avatar {
  --g: var(--unknown); --g-soft: var(--unknown-soft);
  display: inline-grid; place-items: center; border-radius: 50%; overflow: hidden; flex: none;
  background: var(--g-soft); color: var(--g); font-weight: 700; font-size: 12px; border: 2px solid var(--g);
}
.mini-avatar.g-m { --g: var(--male); --g-soft: var(--male-soft); }
.mini-avatar.g-f { --g: var(--female); --g-soft: var(--female-soft); }
.mini-avatar.g-d { --g: var(--diverse); --g-soft: var(--diverse-soft); }
.mini-avatar img { width: 100%; height: 100%; object-fit: cover; }

.timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.tl-item { display: grid; grid-template-columns: 92px 18px 1fr; align-items: start; gap: 0 8px; padding: 5px 0; position: relative; }
.tl-item::before { content: ""; position: absolute; left: 108px; top: 0; bottom: 0; width: 2px; background: var(--border); }
.tl-item:first-child::before { top: 14px; }
.tl-item:last-child::before { bottom: calc(100% - 14px); }
.tl-date { font-size: 13px; font-variant-numeric: tabular-nums; text-align: right; color: var(--muted); padding-top: 1px; }
.tl-age { display: block; font-size: 11px; opacity: .8; }
.tl-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--surface); border: 2.5px solid var(--line); margin: 4px 0 0 3px; position: relative; z-index: 1; }
.tl-birth .tl-dot, .tl-child .tl-dot { border-color: var(--accent); }
.tl-marriage .tl-dot { border-color: var(--gold); background: var(--gold); }
.tl-death .tl-dot, .tl-burial .tl-dot { border-color: var(--text); background: var(--text); }
.tl-loss .tl-dot { border-color: var(--muted); }
.tl-text { font-size: 14px; min-width: 0; overflow-wrap: anywhere; }
.note-preview { background: var(--surface-2); border-radius: 12px; padding: 12px 14px; border: 1px solid var(--border); font-size: 14px; margin-bottom: 6px; }
.photo-strip { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; }
.thumb { width: 84px; height: 84px; flex: none; border-radius: 10px; overflow: hidden; border: 1px solid var(--border); padding: 0; background: var(--surface-3); }
.thumb img { width: 100%; height: 100%; object-fit: cover; }

.fam-box { border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; margin-bottom: 10px; display: flex; flex-direction: column; gap: 10px; background: var(--surface-2); }
.fam-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.fam-partner { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.union-btn { display: inline-flex; align-items: center; gap: 6px; border: 1px dashed var(--border-strong); background: var(--surface); border-radius: 999px; padding: 2px 10px 2px 4px; }
.union-btn:hover { border-color: var(--gold); }
.kid-list { display: flex; flex-direction: column; gap: 6px; padding-left: 14px; border-left: 2px solid var(--border); }
.kid-row { display: flex; align-items: center; gap: 6px; }
.kid-row .person-chip { flex: 0 1 auto; }

.event-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.event-row { display: grid; grid-template-columns: 86px 1fr auto; gap: 10px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2); }
.event-date { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.event-main { min-width: 0; overflow-wrap: anywhere; }
.event-actions { display: flex; gap: 2px; }
.event-form { border: 1px solid var(--accent); border-radius: 12px; padding: 12px; background: var(--surface-2); margin-bottom: 12px; }

.dropzone {
  display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center; padding: 18px 14px; margin-bottom: 14px;
  border: 2px dashed var(--border-strong); border-radius: 14px; color: var(--muted);
}
.dropzone.over { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.dropzone .ico { width: 28px; height: 28px; }
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 10px; }
.media-tile { position: relative; aspect-ratio: 1; padding: 0; border-radius: 12px; overflow: hidden; border: 1px solid var(--border); background: var(--surface-3); display: block; }
.media-tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.media-tile:hover { border-color: var(--accent); }
.media-cap { position: absolute; left: 0; right: 0; bottom: 0; padding: 14px 7px 5px; font-size: 11.5px; color: #fff; text-align: left; background: linear-gradient(transparent, rgba(0,0,0,.65)); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.media-cap .muted { color: rgba(255,255,255,.8); }
.media-people { position: absolute; top: 5px; right: 5px; display: inline-flex; align-items: center; gap: 2px; font-size: 11px; background: rgba(0,0,0,.55); color: #fff; padding: 1px 6px 1px 4px; border-radius: 999px; }
.media-people .ico { width: 13px; height: 13px; }
.file-tile { width: 100%; height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; color: var(--muted); font-weight: 700; }
.file-tile .ico { width: 36px; height: 36px; }
.media-view { display: grid; grid-template-columns: 1.3fr 1fr; gap: 18px; }
.media-preview { display: grid; place-items: center; background: var(--surface-3); border-radius: 12px; min-height: 240px; overflow: hidden; }
.media-preview img { max-width: 100%; max-height: 62vh; display: block; }
.media-preview.file { flex-direction: column; gap: 8px; color: var(--muted); padding: 20px; text-align: center; }
.media-preview.file .ico { width: 48px; height: 48px; }
.media-pdf { width: 100%; height: 62vh; border: 1px solid var(--border); border-radius: 12px; background: #fff; }
.tag { display: inline-flex; align-items: center; gap: 6px; padding: 2px 4px 2px 2px; border-radius: 999px; background: var(--surface-3); font-size: 13px; }
.tag-x { border: none; background: none; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; color: var(--muted); padding: 0; }
.tag-x:hover { background: var(--danger-soft); color: var(--danger); }
.tag-x .ico { width: 14px; height: 14px; }

.notes-area { min-height: 260px; font-size: 15px; }
.save-status { white-space: nowrap; }
.save-bar {
  position: sticky; bottom: -40px; margin: 16px -18px -40px; padding: 10px 18px; display: flex; align-items: center; gap: 8px; justify-content: flex-end;
  background: var(--surface); border-top: 1px solid var(--border); box-shadow: 0 -6px 16px rgba(0,0,0,.06);
  transform: translateY(110%); transition: transform .2s; visibility: hidden;
}
.save-bar .muted { margin-right: auto; }
.save-bar.show { transform: none; visibility: visible; }

/* ------------------------------------------------------------------ Dialoge */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 16px;
  background: rgba(25, 18, 8, .45); opacity: 0; transition: opacity .18s;
}
.modal-backdrop.show { opacity: 1; }
.modal {
  width: min(580px, 100%); max-height: calc(100vh - 32px); max-height: calc(100dvh - 32px); display: flex; flex-direction: column;
  background: var(--surface); border-radius: 18px; box-shadow: var(--shadow-lg); transform: translateY(10px) scale(.98); transition: transform .2s;
}
.modal-backdrop.show .modal { transform: none; }
.modal.wide { width: min(860px, 100%); }
.modal-head { display: flex; align-items: center; gap: 10px; padding: 14px 14px 6px 22px; }
.modal-head h2 { margin: 0; font-size: 19px; flex: 1; font-family: var(--serif); font-weight: 600; }
.modal-body { padding: 8px 22px 16px; overflow: auto; }
.modal-foot { display: flex; align-items: center; gap: 8px; justify-content: flex-end; padding: 12px 18px 16px; border-top: 1px solid var(--border); flex-wrap: wrap; }
.modal-foot:empty { display: none; }
.confirm-text p { margin: 0 0 8px; }
.form-top { display: flex; gap: 14px; align-items: flex-end; }
.form-top-fields { flex: 1; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.photo-pick {
  width: 92px; height: 92px; border-radius: 50%; border: 2px dashed var(--border-strong); flex: none; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; color: var(--muted); font-size: 12px; overflow: hidden;
}
.photo-pick:hover { border-color: var(--accent); color: var(--accent); }
.photo-pick.has-photo { border-style: solid; border-color: var(--accent); }
.photo-pick img { width: 100%; height: 100%; object-fit: cover; }
.new-person, .existing-person { display: flex; flex-direction: column; gap: 12px; }
.extra { display: flex; flex-direction: column; gap: 12px; }
.extra:empty { display: none; }
.person-search { display: flex; flex-direction: column; gap: 8px; }
.pick-list { max-height: 320px; overflow: auto; display: flex; flex-direction: column; gap: 2px; border: 1px solid var(--border); border-radius: 12px; padding: 4px; }
.pick-row { display: flex; align-items: center; gap: 10px; border: none; background: none; padding: 6px 8px; border-radius: 9px; text-align: left; width: 100%; }
.pick-row:hover { background: var(--surface-3); }
.pick-row.active { background: var(--accent-soft); box-shadow: inset 0 0 0 2px var(--accent); }
.pick-text { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.union-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 10px 12px; background: var(--surface-2); border-radius: 14px; }
.union-rings { display: grid; place-items: center; }
.union-names { display: flex; flex-direction: column; margin-left: 8px; line-height: 1.3; }
.union-names span { color: var(--muted); font-size: 12px; }

.crop-modal { width: min(420px, 100%); }
.crop-wrap { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.crop-stage { position: relative; overflow: hidden; border-radius: 16px; background: #111; cursor: move; touch-action: none; max-width: 100%; }
.crop-stage img { position: absolute; left: 0; top: 0; max-width: none; user-select: none; pointer-events: none; transform-origin: 0 0; }
.crop-ring { position: absolute; inset: 0; border-radius: 50%; box-shadow: 0 0 0 999px rgba(0,0,0,.45); pointer-events: none; outline: 2px solid rgba(255,255,255,.8); outline-offset: -2px; }
.crop-controls { display: flex; align-items: center; gap: 10px; width: 100%; color: var(--muted); }
.crop-zoom { flex: 1; accent-color: var(--accent); }

.settings { display: flex; flex-direction: column; gap: 6px; }
.settings section { padding: 12px 0 16px; border-bottom: 1px solid var(--border); display: flex; flex-direction: column; gap: 12px; }
.settings section:last-of-type { border-bottom: none; }
.settings h3 { margin: 0; font-size: 15px; }
.settings p { margin: 0; }
.home-label { font-weight: 600; }
.backup-list { display: flex; flex-direction: column; gap: 4px; max-height: 240px; overflow: auto; }
.backup-row { display: flex; align-items: center; gap: 6px; padding: 5px 8px; border-radius: 9px; background: var(--surface-2); }
.backup-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.popup-menu {
  position: fixed; z-index: 200; min-width: 230px; padding: 5px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-lg);
}
.menu-item { display: flex; align-items: center; gap: 10px; width: 100%; border: none; background: none; padding: 9px 10px; border-radius: 8px; text-align: left; font-size: 14px; }
.menu-item:hover:not(:disabled) { background: var(--surface-3); }
.menu-item:disabled { opacity: .45; cursor: default; }
.menu-item.danger { color: var(--danger); }
.menu-item .ico { width: 18px; height: 18px; color: var(--muted); }
.menu-item.danger .ico { color: var(--danger); }
.menu-sep { height: 1px; background: var(--border); margin: 4px 6px; }
.menu-header { font-size: 12px; color: var(--muted); padding: 6px 10px 2px; }

.toast {
  position: fixed; left: 50%; bottom: 22px; z-index: 300; transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  display: flex; align-items: center; gap: 14px; max-width: min(620px, calc(100vw - 24px));
  padding: 11px 18px; border-radius: 12px; background: #2b2721; color: #fff; box-shadow: var(--shadow-lg); transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
.toast.success { background: #25583f; }
.toast.error { background: #9e2f24; }
.toast .btn-link { color: #fff; text-decoration: underline; white-space: nowrap; }

/* ------------------------------------------------------------------ Personenliste */
.list-wrap { max-width: 1040px; margin: 0 auto; padding: 22px 18px 60px; display: flex; flex-direction: column; gap: 22px; }
.list-section { background: var(--surface); border: 1px solid var(--border); border-radius: 18px; padding: 16px 18px; box-shadow: var(--shadow-sm); display: flex; flex-direction: column; gap: 12px; }
.section-head { margin: 0; font-size: 16px; display: flex; align-items: center; gap: 8px; }
.section-head .ico { color: var(--accent); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; }
.stat { background: var(--surface-2); border-radius: 12px; padding: 12px 14px; border: 1px solid var(--border); }
.stat-value { font-size: 26px; font-weight: 700; font-family: var(--serif); color: var(--accent); line-height: 1.1; }
.stat-label { font-size: 13px; color: var(--muted); }
.surnames { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.anniv { display: flex; flex-direction: column; gap: 4px; }
.anniv-row { display: flex; align-items: center; gap: 12px; width: 100%; border: none; background: none; padding: 8px 10px; border-radius: 10px; text-align: left; }
.anniv-row:hover { background: var(--surface-2); }
.anniv-row.today { background: var(--accent-soft); }
.anniv-sym { width: 28px; text-align: center; font-size: 17px; flex: none; display: grid; place-items: center; }
.anniv-sym.death { font-weight: 700; }
.anniv-text { flex: 1; min-width: 0; }
.anniv-when { color: var(--muted); font-size: 13px; white-space: nowrap; }
.list-toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.list-toolbar select { width: auto; }
.person-list { display: flex; flex-direction: column; }
.person-row { display: flex; align-items: center; gap: 12px; padding: 9px 8px; border-radius: 12px; cursor: pointer; border-bottom: 1px solid var(--border); }
.person-row:last-child { border-bottom: none; }
.person-row:hover { background: var(--surface-2); }
.pr-main { flex: 1; min-width: 0; }
.pr-name { font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pr-name .nick { font-style: italic; color: var(--accent); font-weight: 500; }
.pr-sub { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.count { margin-top: 4px; }

/* ------------------------------------------------------------------ Handy & Tablet */
@media (max-width: 1100px) {
  #tree-title { max-width: 170px; }
}
@media (max-width: 960px) {
  #tree-title { display: none; }
  .search-wrap { max-width: 240px; }
  .switch-label { display: none; }
}
@media (max-width: 760px) {
  :root { --header-h: 54px; }
  .topbar { gap: 6px; padding: 0 8px; }
  #tree-title { display: none; }
  .views button { padding: 6px 10px; font-size: 13.5px; }
  .search-wrap { display: none; }
  body.search-open .search-wrap { display: block; position: fixed; top: 6px; left: 8px; right: 8px; max-width: none; z-index: 50; }
  body.search-open .search-box { background: var(--surface); box-shadow: var(--shadow-lg); }
  .only-mobile { display: inline-grid; }
  .topbar-right { margin-left: auto; gap: 2px; }
  .switch-label { display: none; }
  .panel { width: 100vw; }
  .grid2 { grid-template-columns: 1fr; }
  .focus-bar { display: none; }
  .tree-controls { right: 10px; bottom: 10px; }
  .ctrl { width: 38px; height: 38px; }
  .edit-hint { font-size: 12px; }
  .media-view { grid-template-columns: 1fr; }
  .modal-backdrop { padding: 0; place-items: end center; }
  .modal { border-radius: 18px 18px 0 0; max-height: 94vh; max-height: 94dvh; }
  .modal-foot .btn { flex: 1 1 auto; }
  .list-wrap { padding: 12px 10px 60px; }
  .event-row { grid-template-columns: 70px 1fr auto; }
  .facts { grid-template-columns: 92px 1fr; }
}

/* ------------------------------------------------------------------ Drucken */
@media print {
  @page { size: A4 landscape; margin: 10mm; }
  body { overflow: visible; background: #fff; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .topbar, .panel, .tree-controls, .focus-bar, .edit-hint, #toast, #modal-root, .more, .ghost, #view-list { display: none !important; }
  main { position: static; }
  #view-tree { position: relative; width: 1050px; height: 720px; }
  .tree-host { position: absolute; inset: 0; }
  .viewport { background: #fff !important; }
  .print-only { display: block; }
  .print-title { position: absolute; top: 0; left: 0; right: 0; text-align: center; font-family: var(--serif); font-size: 22px; font-weight: 600; z-index: 3; }
  .card { box-shadow: none; }
}
body.printing .ghost, body.printing .more { display: none; }
