/* ============================================================
   Stammbaum – Styles
   Primär: Bordeaux #8E244D | Sekundär: Rosé #F8BBD0
   Hintergrund: Beige #FFF8E1 | Text: Dunkelbraun #4E342E
   Akzent: Gold #C9A227
   ============================================================ */
:root {
  --focus: #8E244D;
  --focus-dark: #6f1c3c;
  --focus-light: #f5e2ea;
  --teal: #C9A227;
  --teal-dark: #a4841f;
  --pink: #F8BBD0;
  --red: #b3261e;
  --blue: #3b82f6;
  --ink: #4E342E;
  --muted: #8d7468;
  --line: #cabba9;
  --card-border: #ecdfc4;
  --app-bg: #FFF8E1;
  --panel-w: 400px;
  --radius: 16px;
  --radius-sm: 10px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  font-family: 'Nunito', system-ui, -apple-system, sans-serif;
  color: var(--ink);
  overflow: hidden;
}

.hidden { display: none !important; }
.hidden-input { display: none; }

/* ---------- Topbar ---------- */
.topbar {
  position: fixed; top: 0; left: 0; right: 0; height: 60px;
  background: #fff; border-bottom: 1px solid #f0e6c8;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 22px; z-index: 40;
}
.logo {
  display: flex; align-items: center; gap: 8px;
  background: var(--focus); border-radius: var(--radius-sm);
  padding: 6px 14px; color: #fff;
  font-weight: 800; letter-spacing: 1px;
}
.topnav a {
  margin-left: 22px; text-decoration: none; color: var(--ink);
  font-weight: 600; font-size: 14.5px;
}
.topnav a:hover { color: var(--focus); }
.topnav .signin { color: var(--focus); }
.view-mode-switch {
  display: inline-flex; background: #f7efd8; border-radius: 999px; padding: 3px;
}
.vm-btn {
  border: none; background: none; padding: 7px 16px; border-radius: 999px;
  font-family: inherit; font-weight: 700; font-size: 13.5px; color: var(--muted);
  cursor: pointer; transition: background .15s, color .15s;
}
.vm-btn.active { background: #fff; color: var(--focus); box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.user-box {
  display: inline-flex; align-items: center; gap: 12px;
  margin-left: 22px; font-weight: 600; font-size: 14px;
}
#userEmail { color: var(--muted); }
.btn-link {
  background: none; border: none; color: var(--focus);
  font-family: inherit; font-weight: 700; font-size: inherit;
  cursor: pointer; text-decoration: underline; padding: 0;
}

.guest-banner {
  position: absolute; left: 50%; top: 14px; transform: translateX(-50%);
  background: #fff4e5; border: 1px solid #f3c98a; color: #7a4a00;
  padding: 8px 16px; border-radius: 999px; font-size: 13.5px;
  font-weight: 600; z-index: 20; display: flex; gap: 10px; align-items: center;
  box-shadow: 0 2px 8px rgba(0,0,0,.06);
}

/* ---------- Canvas ---------- */
#canvasWrap {
  position: fixed; inset: 60px 0 0 0;
  background: var(--tree-bg, var(--app-bg));
  overflow: hidden;
  cursor: grab;
}
#canvasWrap.dragging { cursor: grabbing; }
#treeSvg { width: 100%; height: 100%; display: block; }

.footer-note {
  position: absolute; left: 16px; bottom: 8px;
  font-size: 12.5px; color: var(--muted); pointer-events: none;
}

/* ---------- Empty State ---------- */
.empty-state {
  position: absolute; top: 40%; left: 50%; transform: translate(-50%, -50%);
  text-align: center;
}
.empty-state h2 { margin-bottom: 8px; }
.empty-state p { color: var(--muted); margin-bottom: 16px; }

/* ---------- Buttons ---------- */
.btn {
  border: none; border-radius: var(--radius-sm); padding: 10px 20px;
  font-family: inherit; font-weight: 700; font-size: 15px;
  cursor: pointer; transition: filter .15s, transform .1s;
}
.btn:hover { filter: brightness(1.05); }
.btn:active { transform: scale(.97); }
.btn.teal { background: var(--teal); color: #fff; }
.btn.teal.dark { background: var(--teal-dark); }
.btn.blue { background: var(--focus); color: #fff; border-radius: 999px; padding: 10px 28px; }
.btn.outline {
  background: #fff; color: var(--ink); border: 1px solid #d8d8e6;
  border-radius: 999px; padding: 10px 24px;
}

.bottom-buttons {
  position: absolute; left: 16px; bottom: 40px;
  display: flex; gap: 12px; z-index: 20;
}
.bottom-buttons .btn { box-shadow: 0 4px 14px rgba(109,94,248,.18); }
.bottom-buttons .btn.teal.dark { box-shadow: 0 4px 14px rgba(15,148,136,.18); }

/* ---------- Tools-Menü ---------- */
.tools-menu {
  position: absolute; left: 240px; bottom: 100px;
  background: #fff; border: 1px solid #f0e6c8; border-radius: 14px;
  box-shadow: 0 10px 30px rgba(0,0,0,.12);
  padding: 16px; width: 260px; z-index: 30;
  display: flex; flex-direction: column; gap: 6px;
}
.toggle-row {
  display: flex; align-items: center; gap: 12px;
  font-weight: 600; padding: 8px 4px; cursor: pointer;
}
.switch { position: relative; display: inline-block; width: 40px; height: 22px; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch i {
  position: absolute; inset: 0; background: #e0d3ba; border-radius: 999px;
  transition: background .15s;
}
.switch i::after {
  content: ""; position: absolute; top: 2px; left: 2px;
  width: 18px; height: 18px; background: #fff; border-radius: 50%;
  transition: left .15s;
}
.switch input:checked + i { background: var(--teal); }
.switch input:checked + i::after { left: 20px; }
.tools-item {
  background: none; border: none; text-align: left;
  font-family: inherit; font-size: 15px; font-weight: 600;
  padding: 10px 4px; cursor: pointer; color: var(--ink); border-radius: 8px;
}
.tools-item:hover { background: #f6efd9; }

/* ---------- Suche ---------- */
.search-panel {
  position: absolute; left: 150px; bottom: 100px;
  background: #fff; border: 1px solid #f0e6c8; border-radius: 14px;
  box-shadow: 0 10px 30px rgba(0,0,0,.12);
  padding: 12px; width: 280px; z-index: 30;
}
.search-panel input {
  width: 100%; padding: 10px 12px; border: 1px solid #e0d3ba;
  border-radius: 8px; font-family: inherit; font-size: 15px;
}
#searchResults { max-height: 220px; overflow: auto; margin-top: 8px; }
.search-result {
  padding: 8px 10px; border-radius: 8px; cursor: pointer; font-weight: 600;
}
.search-result:hover { background: #fdf0ec; color: var(--focus-dark); }

/* ---------- Add-Menü (pink) ---------- */
.add-menu {
  position: absolute; z-index: 35;
  display: flex; flex-direction: column; gap: 8px;
}
.pink-btn {
  background: var(--pink); color: var(--focus-dark); border: none;
  border-radius: 6px; padding: 7px 16px; font-family: inherit;
  font-weight: 700; font-size: 13.5px; cursor: pointer;
  box-shadow: 0 2px 6px rgba(0,0,0,.15);
}
.pink-btn:hover { filter: brightness(1.05); }

/* ---------- SVG-Karten ---------- */
.person-card { cursor: pointer; }
.person-card .hover-zone { pointer-events: all; }
.person-card .card-rect {
  fill: #fff; stroke: var(--card-border); stroke-width: 1;
}
.person-card.selected .card-rect { fill: var(--focus); stroke: var(--focus); }
.person-card .card-name {
  font-family: 'Nunito', sans-serif; font-weight: 700; font-size: 15px;
  fill: var(--ink); text-anchor: middle;
}
.person-card.selected .card-name { fill: #fff; }
.person-card .avatar-circle { fill: #e8ddc7; stroke: #111; stroke-width: 1.5; }
.person-card .avatar-sil { fill: #c3c7cf; }

.badge-rect { rx: 2; }
.badge-text {
  font-family: 'Nunito', sans-serif; font-weight: 800; font-size: 10px;
  fill: #fff; text-anchor: middle; letter-spacing: .5px;
}

.hover-btn { cursor: pointer; }
.hover-btn rect { rx: 4; }
.hover-btn text {
  font-weight: 800; fill: var(--ink); text-anchor: middle; font-size: 14px;
}
.hover-btn.delete text { fill: #fff; }
.person-card .hover-btn { opacity: 0; transition: opacity .12s; pointer-events: none; }
.person-card:hover .hover-btn { opacity: 1; pointer-events: all; }

.tree-line { stroke: var(--line); stroke-width: 1.75; fill: none; stroke-linecap: round; }

/* ---------- Edit-Panel ---------- */
.edit-panel {
  position: fixed; top: 56px; right: 0; bottom: 0; width: var(--panel-w);
  background: #fff; box-shadow: -8px 0 24px rgba(0,0,0,.10);
  display: flex; flex-direction: column; z-index: 50;
}
.edit-header {
  background: var(--focus); color: #fff; padding: 18px;
  text-align: center; position: relative;
}
.edit-header h2 { font-size: 22px; margin-bottom: 14px; }
.close-btn {
  position: absolute; top: 14px; left: 14px;
  background: rgba(255,255,255,.9); border: none; border-radius: 50%;
  width: 32px; height: 32px; cursor: pointer; font-size: 15px;
}
.avatar-wrap { position: relative; width: 110px; height: 110px; margin: 0 auto; }
.avatar-img, .avatar-placeholder {
  width: 110px; height: 110px; border-radius: 50%;
  background: #e8ddc7; object-fit: cover; display: block;
}
.avatar-placeholder::after {
  content: "👤"; font-size: 52px; display: flex;
  align-items: center; justify-content: center; height: 100%;
  filter: grayscale(1); opacity: .5;
}
.photo-btn {
  position: absolute; right: -4px; bottom: 2px;
  width: 34px; height: 34px; border-radius: 50%;
  border: none; background: #fff; cursor: pointer; font-size: 15px;
  box-shadow: 0 2px 6px rgba(0,0,0,.2);
}

.edit-body { flex: 1; overflow-y: auto; padding: 18px; }
.edit-section-title {
  font-size: 20px; font-weight: 800; margin-bottom: 14px;
}
.edit-body label {
  display: block; font-weight: 700; font-size: 15px; margin-bottom: 14px;
}
.edit-body label input[type="text"] {
  display: block; width: 100%; margin-top: 6px;
  padding: 10px 12px; border: 1px solid #e0d3ba; border-radius: 8px;
  font-family: inherit; font-size: 15px;
}
.radio-group { margin-bottom: 14px; }
.radio-label { display: block; font-weight: 700; margin-bottom: 6px; }
.radio-group label {
  display: inline-flex; align-items: center; gap: 6px;
  margin-right: 18px; font-weight: 600; font-size: 15px; cursor: pointer;
}
.dob-group { margin-bottom: 14px; }
.dob-inputs { display: flex; gap: 10px; }
.dob-inputs input {
  width: 80px; padding: 10px; border: 1px solid #e0d3ba; border-radius: 8px;
  font-family: inherit; font-size: 15px;
}

.edit-footer {
  padding: 14px 18px; background: #fbe3d4;
  display: flex; gap: 12px;
}

/* ---------- Toast ---------- */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 10px 22px;
  border-radius: 999px; font-weight: 700; z-index: 100;
  animation: toastIn .2s ease;
}
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 8px); } }

/* ---------- Mobil ---------- */
@media (max-width: 640px) {
  :root { --panel-w: 100vw; }
  .topnav a:not(.signin) { display: none; }
  .bottom-buttons { bottom: 56px; }
}

/* ---------- Tree-Switcher ---------- */
.tree-switcher { margin-left: 18px; }
.tree-switcher select {
  font-family: inherit; font-weight: 700; font-size: 14px;
  padding: 6px 10px; border-radius: 8px; border: 1px solid #e0d3ba;
  color: var(--ink); background: #fff;
}

/* ---------- Modal-Overlays (Login/Signup, Teilen) ---------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(15,20,35,.45);
  display: flex; align-items: center; justify-content: center; z-index: 60;
}
.modal-card {
  background: #fff; border-radius: 16px; padding: 28px 26px;
  width: 380px; max-width: 92vw; max-height: 88vh; overflow-y: auto;
  position: relative; box-shadow: 0 20px 60px rgba(0,0,0,.25);
}
.modal-card h2 { margin-bottom: 18px; font-size: 22px; }
.modal-card h3 { font-size: 15px; margin-bottom: 10px; }
.modal-card .close-btn { position: absolute; top: 14px; right: 14px; left: auto; }
.modal-card label {
  display: block; font-weight: 700; font-size: 14px; margin-bottom: 12px;
}
.modal-card label input {
  display: block; width: 100%; margin-top: 6px;
  padding: 9px 11px; border: 1px solid #e0d3ba; border-radius: 8px;
  font-family: inherit; font-size: 15px;
}
.name-row { display: flex; gap: 10px; }
.name-row label { flex: 1; }
.full-width { width: 100%; margin-top: 4px; }
.auth-error {
  background: #fdecec; color: #b42318; border-radius: 8px;
  padding: 8px 10px; font-size: 13.5px; font-weight: 600; margin-bottom: 12px;
}
.auth-switch { margin-top: 16px; font-size: 14px; text-align: center; }

.ts-link-wrap { display: flex; gap: 8px; margin: 10px 0 6px; }
.ts-link-wrap input {
  flex: 1; padding: 9px 10px; border: 1px solid #e0d3ba; border-radius: 8px;
  font-family: inherit; font-size: 13.5px;
}
.ts-divider { border: none; border-top: 1px solid #f0e6c8; margin: 18px 0; }
.ts-invite-form { display: flex; gap: 8px; margin-bottom: 14px; }
.ts-invite-form input {
  flex: 1; padding: 9px 10px; border: 1px solid #e0d3ba; border-radius: 8px;
  font-family: inherit; font-size: 14px;
}
.ts-invite-form select {
  padding: 9px 8px; border: 1px solid #e0d3ba; border-radius: 8px; font-family: inherit;
}
.ts-share-list { display: flex; flex-direction: column; gap: 8px; }
.ts-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; padding: 8px 10px; background: #fbf3de; border-radius: 8px;
  font-size: 14px;
}
.ts-perm { color: var(--muted); font-weight: 700; font-size: 12px; text-transform: uppercase; }
.ts-empty { color: var(--muted); font-size: 14px; }

/* ---------- Read-only Edit-Panel ---------- */
.edit-panel.read-only .edit-body input { background: #f7f7f8; color: #444; }

/* ---------- Geschlechts-Farben (Eltern/Vorfahren sofort erkennbar) ---------- */
.person-card.gender-male .card-rect { fill: #eef2f7; stroke: #cbd8e6; }
.person-card.gender-female .card-rect { fill: #fceef3; stroke: var(--pink); }
.person-card.gender-other .card-rect { fill: #f3ece0; stroke: #ddccaa; }
.person-card.selected .card-rect { fill: var(--focus); stroke: var(--focus); }

/* ---------- Generationstiefe (Tools-Menü) ---------- */
.tools-divider { border-top: 1px solid #f0e6c8; margin: 8px 0; }
.gen-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; padding: 6px 4px; font-size: 14px; font-weight: 600;
}
.gen-row select {
  font-family: inherit; font-weight: 700; font-size: 13.5px;
  padding: 5px 8px; border-radius: 6px; border: 1px solid #e0d3ba; background: #fff;
}

/* ---------- Delete-Bereich im Edit-Panel ---------- */
.danger-zone {
  padding: 14px 18px 20px; text-align: center;
}
.btn-link.danger { color: #c0392b; text-decoration: none; font-size: 14px; }
.btn-link.danger:hover { text-decoration: underline; }
.delete-confirm {
  margin-top: 10px; background: #fdecec; border-radius: 10px;
  padding: 12px 14px; font-size: 13.5px; color: #7a1a1a;
}
.delete-confirm-btns { display: flex; gap: 10px; justify-content: center; margin-top: 10px; }
.btn.red-solid {
  background: #c0392b; color: #fff; border: none; border-radius: 999px;
  padding: 8px 20px; font-weight: 700; cursor: pointer; font-family: inherit;
}

.delete-blocked {
  font-size: 13px; color: var(--muted); text-align: center;
  max-width: 260px; margin: 0 auto; line-height: 1.4;
}

/* ---------- Fokusperson: Akzentfarbe statt Geschlechtsfarbe, kein Textbadge mehr ---------- */
.person-card.focus .card-rect { fill: var(--focus); stroke: var(--focus); }
.person-card.focus .card-name { fill: #fff; }

/* ---------- Sanftes Einblenden statt abruptem "Aufpoppen" ----------
   Karten gleiten in .55s zur neuen Position (siehe drawCard). Die Linien
   blenden über dieselbe Dauer/Kurve ein, leicht verzögert - so wirken
   Karten und Linien wie EINE gemeinsame Bewegung statt nacheinander. */
.card-inner {
  transform-box: fill-box;
  transform-origin: center;
}
.card-inner.card-grow {
  animation: cardIn 0.55s cubic-bezier(0.4, 0, 0.2, 1) both;
}
@keyframes cardIn {
  from { opacity: 0; transform: scale(0.25); }
  60%  { opacity: 1; }
  to   { opacity: 1; transform: none; }
}
.tree-line {
  animation: lineIn 0.55s cubic-bezier(0.4, 0, 0.2, 1) both;
  animation-delay: 0.25s;
}
@keyframes lineIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  .card-inner, .card-grow, .tree-line, .person-card { animation: none !important; transition: none !important; }
}

/* ---------- Verstorben: leicht gedämpft/entsättigt, kleines Kreuz ---------- */
.person-card.deceased .card-inner { filter: saturate(0.55) opacity(0.88); }
.card-years {
  font-family: 'Nunito', sans-serif; font-size: 11.5px; font-weight: 700;
  fill: var(--muted); text-anchor: middle;
}
.person-card.focus .card-years,
.person-card.selected .card-years { fill: rgba(255,255,255,.85); }
