:root {
  --bg: #f7f3ec;
  --bg-deep: #efe8dc;
  --surface: #fffdf9;
  --text: #2b2622;
  --muted: #776d63;
  --border: #e4dacb;
  --line: #b9a98f;
  --accent: #2f5d50;
  --accent-soft: #dfe9e4;
  --gold: #b08d57;
  --hero-from: #23453c;
  --hero-to: #2f5d50;
  --hero-text: #f7f3ec;
  --male: #4a6c8c;
  --male-soft: #e3ebf3;
  --female: #a8566e;
  --female-soft: #f5e4e9;
  --unknown: #8a8178;
  --unknown-soft: #ece7e0;
  --shadow-sm: 0 1px 2px rgba(60, 40, 20, .06), 0 2px 8px rgba(60, 40, 20, .06);
  --shadow-md: 0 4px 12px rgba(60, 40, 20, .08), 0 12px 32px rgba(60, 40, 20, .08);
  --radius: 14px;
  --serif: "Cormorant Garamond", Georgia, "Times New Roman", serif;
  --sans: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15130f;
    --bg-deep: #1b1814;
    --surface: #221e19;
    --text: #ece5da;
    --muted: #a39887;
    --border: #3a332a;
    --line: #6e6250;
    --accent: #7fb3a2;
    --accent-soft: #23362f;
    --gold: #d2ad73;
    --hero-from: #10211c;
    --hero-to: #1d3a32;
    --hero-text: #f1ebe0;
    --male: #7ea3c8;
    --male-soft: #1f2a36;
    --female: #d38aa0;
    --female-soft: #36222a;
    --unknown: #a39887;
    --unknown-soft: #2b2620;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, .35);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 var(--sans);
  -webkit-font-smoothing: antialiased;
}

button, input, select { font: inherit; color: inherit; }

h1, h2, h3 { font-family: var(--serif); font-weight: 600; line-height: 1.1; }

[hidden] { display: none !important; }

/* ---------- Přihlášení ---------- */

.login {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 32px 16px;
  background:
    radial-gradient(900px 400px at 80% -10%, rgba(255, 255, 255, .10), transparent 60%),
    linear-gradient(160deg, var(--hero-from), var(--hero-to));
}

.login-card {
  width: min(100%, 420px);
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 36px 32px 32px;
  background: var(--surface);
  border-radius: 22px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .3);
  animation: pop .5s cubic-bezier(.2, .8, .2, 1) both;
}
.login-card h1 { margin: 0; font-size: 2.4rem; }
.login-card .eyebrow { margin: 0; }
.login-intro { margin: 0 0 12px; color: var(--muted); }
.login-questions { display: flex; flex-direction: column; gap: 16px; }
.login-question { display: flex; flex-direction: column; gap: 6px; }
.login-card label[for] { font-weight: 600; }
.login-card input[type="text"] {
  height: 46px;
  padding: 0 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  outline: none;
  font-size: 1.05rem;
  transition: border-color .2s, box-shadow .2s;
}
.login-card input[type="text"]:focus { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.login-hint { color: var(--muted); font-size: .82rem; }
.login-remember { display: flex; align-items: center; gap: 8px; margin-top: 6px; font-size: .9rem; color: var(--muted); cursor: pointer; }
.login-card button[type="submit"] {
  margin-top: 10px;
  height: 46px;
  border: 0;
  border-radius: 999px;
  background: var(--gold);
  color: #1f1a14;
  font-weight: 600;
  cursor: pointer;
  transition: transform .2s, opacity .2s;
}
.login-card button[type="submit"]:hover { transform: translateY(-1px); }
.login-card button[type="submit"]:disabled { opacity: .7; cursor: wait; transform: none; }

.login-error {
  margin: 0;
  max-width: 420px;
  padding: 10px 16px;
  border-radius: 12px;
  background: #fbe9e7;
  color: #8c2a1c;
  text-align: center;
  font-weight: 500;
}

/* ---------- Úvod ---------- */

.hero {
  position: relative;
  overflow: hidden;
  color: var(--hero-text);
  background:
    radial-gradient(1200px 500px at 85% -10%, rgba(255, 255, 255, .10), transparent 60%),
    linear-gradient(160deg, var(--hero-from), var(--hero-to));
  padding: clamp(56px, 10vw, 120px) 16px clamp(48px, 8vw, 96px);
}

.hero-art {
  position: absolute;
  right: -60px;
  bottom: -40px;
  width: min(560px, 80vw);
  color: var(--gold);
  opacity: .18;
  pointer-events: none;
}

.hero-inner { position: relative; max-width: 1100px; margin: 0 auto; }

.eyebrow {
  margin: 0 0 12px;
  font-size: .8rem;
  font-weight: 600;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: var(--gold);
}

.hero h1 {
  margin: 0;
  font-size: clamp(2.6rem, 7vw, 5rem);
  font-weight: 600;
  letter-spacing: -.01em;
}

.lead {
  margin: 14px 0 0;
  max-width: 560px;
  font-family: var(--serif);
  font-style: italic;
  font-size: clamp(1.2rem, 2.4vw, 1.5rem);
  opacity: .85;
}

.stats {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 40px;
  margin: 40px 0 0;
}
.stats div { min-width: 90px; }
.stats dt { font-size: .8rem; letter-spacing: .08em; text-transform: uppercase; opacity: .7; }
.stats dd { margin: 2px 0 0; font-family: var(--serif); font-size: 2.4rem; font-weight: 600; line-height: 1; }

.cta {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 40px;
  padding: 12px 22px;
  border-radius: 999px;
  background: var(--gold);
  color: #1f1a14;
  font-weight: 600;
  text-decoration: none;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .25);
  transition: transform .2s ease, box-shadow .2s ease;
}
.cta:hover { transform: translateY(-2px); box-shadow: 0 10px 28px rgba(0, 0, 0, .3); }

/* ---------- Sekce ---------- */

.section { max-width: 1280px; margin: 0 auto; padding: 64px 16px 0; }
.section-head h2 { margin: 0; font-size: clamp(1.9rem, 4vw, 2.6rem); }
.section-head p { margin: 6px 0 24px; color: var(--muted); }

.split {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr));
  gap: 48px;
}

/* ---------- Ovládání stromu ---------- */

/* Strom zabírá celou šířku i výšku okna, ovládání a detail plavou nad ním. */
.tree-section { max-width: none; padding-left: 0; padding-right: 0; }
.tree-section .section-head { max-width: 1280px; margin: 0 auto; padding: 0 16px; }

.toolbar {
  position: absolute;
  z-index: 5;
  top: 14px;
  left: 14px;
  right: 14px;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  pointer-events: none;
}
.toolbar > * { pointer-events: auto; }

.controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 6px;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow-sm);
}
.controls label { padding-left: 6px; }
.controls label { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: .9rem; }

select, .zoom button, .ghost {
  height: 36px;
  padding: 0 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
}
.ghost:hover, .zoom button:hover { border-color: var(--line); }

.zoom { display: flex; }
.zoom button { border-radius: 0; min-width: 38px; }
.zoom button:first-child { border-radius: 10px 0 0 10px; }
.zoom button:last-child { border-radius: 0 10px 10px 0; }
.zoom button + button { border-left: 0; }

.search { position: relative; flex: 0 1 320px; }
.search svg {
  position: absolute;
  left: 12px;
  top: 50%;
  width: 18px;
  height: 18px;
  transform: translateY(-50%);
  fill: none;
  stroke: var(--muted);
  stroke-width: 2;
  stroke-linecap: round;
}
.search input {
  width: 100%;
  height: 40px;
  padding: 0 14px 0 38px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  outline: none;
  box-shadow: var(--shadow-sm);
  transition: border-color .2s, box-shadow .2s;
}
.search input:focus { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }

.search-results {
  position: absolute;
  z-index: 20;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  max-height: 340px;
  overflow: auto;
  margin: 0;
  padding: 6px;
  list-style: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow-md);
}
.search-results .chip { width: 100%; }
.search-results .empty { padding: 8px 10px; color: var(--muted); }

/* ---------- Strom ---------- */

.tree-layout {
  position: relative;
  height: 100vh;
  height: 100dvh;
  min-height: 480px;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  overflow: hidden;
}
.tree-layout:fullscreen { height: 100%; border: 0; }

.viewport {
  position: absolute;
  inset: 0;
  overflow: auto;
  cursor: grab;
  background:
    radial-gradient(circle at 1px 1px, var(--border) 1px, transparent 0) 0 0 / 22px 22px,
    var(--bg);
  overscroll-behavior: contain;
}
.viewport.dragging { cursor: grabbing; user-select: none; }

.canvas { position: relative; margin: 0 auto; }
.canvas svg { position: absolute; inset: 0; overflow: visible; }
.canvas path {
  fill: none;
  stroke: var(--line);
  stroke-width: 2;
  stroke-linecap: round;
  animation: fade .5s ease both;
}
.canvas path.marriage { stroke: var(--gold); stroke-dasharray: 2 5; stroke-width: 2.5; }

.node {
  position: absolute;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px 8px 8px;
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: box-shadow .2s, border-color .2s, transform .2s;
}
.node.enter { animation: pop .45s cubic-bezier(.2, .8, .2, 1) both; }
.node:hover { border-color: var(--line); box-shadow: var(--shadow-md); }
.node:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.node::before {
  content: "";
  position: absolute;
  left: 0;
  top: 12px;
  bottom: 12px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--tone);
}

.node.focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--gold) 25%, transparent), var(--shadow-md);
}

.node .info { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.node .given { font-weight: 600; font-size: .95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.node .surname { font-size: .85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.node .meta { margin-top: 2px; font-size: .75rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.node .more {
  position: absolute;
  top: -8px;
  right: -8px;
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--surface);
  font-size: .8rem;
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}

.m { --tone: var(--male); --tone-soft: var(--male-soft); }
.z { --tone: var(--female); --tone-soft: var(--female-soft); }
.u { --tone: var(--unknown); --tone-soft: var(--unknown-soft); }

.avatar {
  flex-shrink: 0;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--tone-soft);
  color: var(--tone);
  font-family: var(--serif);
  font-weight: 700;
  font-size: 1.1rem;
  overflow: hidden;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; animation: fade .4s ease both; }
.avatar.deceased img { filter: grayscale(.7); }
.avatar.deceased { box-shadow: inset 0 0 0 2px var(--line); }

/* ---------- Detail ---------- */

.detail {
  position: absolute;
  z-index: 4;
  top: 74px;
  right: 14px;
  bottom: 14px;
  width: 340px;
  overflow: auto;
  padding: 28px 24px;
  background: color-mix(in srgb, var(--surface) 95%, transparent);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow-md);
  transition: transform .35s cubic-bezier(.2, .8, .2, 1), opacity .35s;
}
.tree-layout.detail-hidden .detail { transform: translateX(calc(100% + 28px)); opacity: 0; pointer-events: none; }
#detail-body > * { animation: fade .35s ease both; }

.detail-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 50%;
  background: none;
  color: var(--muted);
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
}
.detail-close:hover { background: var(--bg); color: var(--text); }
#detail-toggle[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }

.detail-head { text-align: center; }
.detail-head .avatar { width: 120px; height: 120px; margin: 0 auto 14px; font-size: 2.6rem; box-shadow: 0 0 0 4px var(--surface), 0 0 0 6px var(--tone-soft); }
.detail-head h3 { margin: 0; font-size: 1.9rem; }
.detail-head .maiden { margin: 2px 0 0; color: var(--muted); font-style: italic; font-family: var(--serif); font-size: 1.1rem; }
.detail-head .badge {
  display: inline-block;
  margin-top: 10px;
  padding: 3px 12px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: .8rem;
  font-weight: 600;
}

.facts { margin: 22px 0 0; padding: 0; list-style: none; border-left: 2px solid var(--border); }
.facts li { position: relative; padding: 0 0 14px 18px; }
.facts li::before {
  content: "";
  position: absolute;
  left: -6px;
  top: 6px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--surface);
  border: 2px solid var(--gold);
}
.facts .label { display: block; font-size: .72rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.facts .value { font-weight: 500; }

.detail h4 {
  margin: 20px 0 8px;
  font-size: .72rem;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
}
.detail .note {
  margin: 0;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--bg);
  font-family: var(--serif);
  font-size: 1.1rem;
  white-space: pre-line;
}
.detail .photo { width: 100%; max-height: 260px; object-fit: cover; border-radius: 14px; margin-bottom: 16px; }
.chips { display: flex; flex-direction: column; gap: 4px; margin: 0; padding: 0; list-style: none; }

.chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px;
  background: none;
  border: 0;
  border-radius: 10px;
  text-align: left;
  cursor: pointer;
  transition: background .15s;
}
.chip:hover, .chip:focus-visible { background: var(--bg); outline: none; }
.chip .avatar { width: 32px; height: 32px; font-size: .85rem; }
.chip .chip-text { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.chip .chip-name { font-weight: 500; }
.chip small { color: var(--muted); font-size: .78rem; }

/* ---------- Generace ---------- */

.generation { margin-bottom: 36px; }
.generation-head {
  display: flex;
  align-items: baseline;
  gap: 14px;
  margin-bottom: 14px;
}
.generation-head h3 { margin: 0; font-size: 1.6rem; }
.generation-head span { color: var(--muted); font-size: .9rem; }
.generation-head::after { content: ""; flex: 1; height: 1px; background: var(--border); }

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 230px), 1fr));
  gap: 14px;
}

.card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px;
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: transform .2s, box-shadow .2s, border-color .2s;
}
.card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); border-color: var(--line); }
.card .avatar { width: 52px; height: 52px; font-size: 1.25rem; }
.card .card-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.card .card-name { font-family: var(--serif); font-size: 1.25rem; font-weight: 600; }
.card small { color: var(--muted); }

/* ---------- Narozeniny a místa ---------- */

.birthdays { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 10px; }
.birthday {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 12px 16px;
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  cursor: pointer;
  transition: border-color .2s, box-shadow .2s;
}
.birthday:hover { border-color: var(--line); box-shadow: var(--shadow-sm); }
.birthday .date {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 54px;
  height: 54px;
  border-radius: 12px;
  background: var(--accent-soft);
  color: var(--accent);
  line-height: 1;
}
.birthday .date b { font-family: var(--serif); font-size: 1.5rem; }
.birthday .date small { font-size: .7rem; text-transform: uppercase; letter-spacing: .06em; margin-top: 2px; }
.birthday .bd-text { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.birthday .bd-name { font-weight: 600; }
.birthday .bd-sub { color: var(--muted); font-size: .85rem; }
.birthday .when { flex-shrink: 0; font-size: .85rem; color: var(--muted); }
.birthday.today { border-color: var(--gold); background: color-mix(in srgb, var(--gold) 10%, var(--surface)); }
.birthday.today .when { color: var(--gold); font-weight: 600; }

.places { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 12px; }
.place { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; align-items: baseline; }
.place .name { font-weight: 500; }
.place .count { color: var(--muted); font-size: .85rem; }
.place .bar { grid-column: 1 / -1; height: 8px; border-radius: 999px; background: var(--bg-deep); overflow: hidden; }
.place .bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--gold));
  transform-origin: left;
  animation: grow .9s cubic-bezier(.2, .8, .2, 1) both;
}

.muted { color: var(--muted); }

/* ---------- Patička ---------- */

.footer {
  margin-top: 80px;
  padding: 32px 16px;
  text-align: center;
  color: var(--muted);
  border-top: 1px solid var(--border);
  font-family: var(--serif);
  font-size: 1.1rem;
}
.footer p { margin: 0 0 12px; }
.footer .ghost { font-family: var(--sans); font-size: .85rem; color: var(--muted); }

/* ---------- Animace ---------- */

@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.96); } }
@keyframes grow { from { transform: scaleX(0); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  html { scroll-behavior: auto; }
}

/* ---------- Mobil ---------- */

/* Na úzkém displeji: ovládání nad stromem, detail pod ním. */
@media (max-width: 860px) {
  .tree-layout { display: flex; flex-direction: column; height: auto; min-height: 0; overflow: visible; }
  .toolbar { position: static; order: -1; padding: 12px 16px; }
  .viewport { position: relative; inset: auto; height: 75dvh; }
  .detail, .tree-layout.detail-hidden .detail {
    position: static;
    width: auto;
    transform: none;
    opacity: 1;
    pointer-events: auto;
    border-radius: 0;
    border-width: 1px 0 0;
    box-shadow: none;
    backdrop-filter: none;
  }
  .wide-only { display: none; }
  .search { flex: 1 1 100%; }
  .section { padding-top: 48px; }
}

@media print {
  .hero-art, .cta, .toolbar, .detail { display: none; }
  .tree-layout { height: auto; }
  .viewport { position: static; overflow: visible; }
}
