:root {
  --bg: #f7f3ec;
  --paper: #fffdf9;
  --ink: #2b2622;
  --muted: #6f655b;
  --rule: #e2d9cc;
  --accent: #8a3b2e;
  --kargol: #a0452f;
  --savrnoch: #3f7a4f;
  --fridlik: #2f5f8f;
  --ban: #b07a1e;
  --borbely: #6f4a8a;
  --shadow: 0 1px 3px rgba(60, 40, 20, .12);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1d1a17; --paper: #262220; --ink: #efe7dc; --muted: #b3a797; --rule: #3d3631; --accent: #e08a74;
    --kargol: #e0876e; --savrnoch: #7fc08f; --fridlik: #7fb0e0; --ban: #e0b35e; --borbely: #b797d0;
    --shadow: 0 1px 3px rgba(0, 0, 0, .4);
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 17px/1.65 "Source Serif 4", Georgia, "Times New Roman", serif;
}
a { color: var(--accent); }
header.site {
  background: var(--paper); border-bottom: 1px solid var(--rule);
  padding: 14px 16px; display: flex; flex-wrap: wrap; gap: 8px 24px; align-items: baseline;
}
header.site .brand { font-weight: 700; font-size: 1.15rem; color: var(--ink); text-decoration: none; }
header.site nav { display: flex; gap: 18px; flex-wrap: wrap; font-family: system-ui, sans-serif; font-size: .95rem; }
header.site nav a { color: var(--muted); text-decoration: none; }
header.site nav a.active, header.site nav a:hover { color: var(--accent); }
main { max-width: 820px; margin: 0 auto; padding: 24px 16px 64px; }
main.wide { max-width: none; padding: 0; }
h1 { font-size: 2.1rem; line-height: 1.2; margin: 12px 0 8px; }
h2 { font-size: 1.45rem; margin: 40px 0 8px; }
h3 { font-size: 1.1rem; margin: 24px 0 4px; }
.lead { font-size: 1.15rem; color: var(--muted); }
.small { font-size: .88rem; color: var(--muted); }
.line-tag {
  display: inline-block; font: 600 .75rem/1 system-ui, sans-serif; letter-spacing: .04em; text-transform: uppercase;
  padding: 4px 8px; border-radius: 99px; color: #fff; margin-bottom: 6px;
}
.t-kargol { background: var(--kargol); } .t-savrnoch { background: var(--savrnoch); } .t-fridlik { background: var(--fridlik); }
.t-ban { background: var(--ban); } .t-borbely { background: var(--borbely); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .line-tag { color: #1d1a17; } }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 14px; margin: 20px 0; }
.card {
  background: var(--paper); border: 1px solid var(--rule); border-radius: 10px; padding: 14px 16px; box-shadow: var(--shadow);
  text-decoration: none; color: inherit; display: block;
}
.card h3 { margin: 0 0 4px; }
.card p { margin: 0; font-size: .95rem; color: var(--muted); }

figure.photo { float: right; width: 220px; margin: 4px 0 12px 20px; }
figure.photo.left { float: left; margin: 4px 20px 12px 0; }
figure.photo img { width: 100%; border-radius: 6px; display: block; }
figure.photo figcaption { font-size: .78rem; color: var(--muted); line-height: 1.35; margin-top: 4px; }
section.story { overflow: hidden; }
@media (max-width: 560px) { figure.photo, figure.photo.left { float: none; width: 100%; max-width: 320px; margin: 8px 0 14px; } }

.timeline { border-left: 3px solid var(--rule); margin: 16px 0; padding-left: 16px; }
.timeline div { margin: 6px 0; }
.timeline b { font-family: system-ui, sans-serif; font-size: .9rem; color: var(--accent); margin-right: 6px; }

.note {
  background: var(--paper); border-left: 4px solid var(--accent); padding: 10px 14px; border-radius: 4px; margin: 16px 0;
  font-size: .95rem;
}
ul.sources li { margin: 4px 0; }
footer { text-align: center; color: var(--muted); font-size: .8rem; padding: 24px 16px; border-top: 1px solid var(--rule); }

/* Tree page */
.tree-wrap { display: flex; height: calc(100vh - 58px); min-height: 480px; }
#tree { flex: 1; position: relative; overflow: hidden; background: var(--bg); }
#tree svg { width: 100%; height: 100%; display: block; cursor: grab; }
#panel {
  width: 380px; max-width: 100%; background: var(--paper); border-left: 1px solid var(--rule); overflow-y: auto; padding: 16px;
}
@media (max-width: 800px) {
  .tree-wrap { flex-direction: column; height: auto; }
  #tree { flex: none; height: 62vh; }
  #panel { width: 100%; border-left: 0; border-top: 1px solid var(--rule); }
}
.couple rect { fill: var(--paper); stroke: var(--rule); stroke-width: 1.2; }
.couple.selected rect { stroke: var(--accent); stroke-width: 2.5; }
.couple .bar { stroke: none; }
.couple text { fill: var(--ink); font: 13px system-ui, sans-serif; }
.couple text.years { fill: var(--muted); font-size: 11.5px; }
.couple text.amp { fill: var(--muted); font-size: 11px; }
.couple.unknown rect { stroke-dasharray: 4 3; fill: none; }
.couple.unknown text { fill: var(--muted); font-style: italic; }
.link { fill: none; stroke: var(--muted); stroke-opacity: .5; stroke-width: 1.4; }
.tree-help {
  position: absolute; left: 12px; bottom: 10px; font: 12px system-ui, sans-serif; color: var(--muted);
  background: var(--paper); padding: 4px 8px; border-radius: 6px; border: 1px solid var(--rule);
}
.zoom-btns { position: absolute; right: 12px; top: 12px; display: flex; flex-direction: column; gap: 6px; }
.zoom-btns button {
  width: 34px; height: 34px; border-radius: 8px; border: 1px solid var(--rule); background: var(--paper); color: var(--ink);
  font-size: 18px; cursor: pointer;
}
#panel h2 { margin: 0 0 4px; font-size: 1.25rem; }
#panel .person { border-top: 1px solid var(--rule); padding-top: 10px; margin-top: 12px; }
#panel .person h3 { margin: 0; }
#panel .dates { font: .88rem system-ui, sans-serif; color: var(--muted); }
#panel p { font-size: .95rem; margin: 6px 0; }
#panel ul { padding-left: 18px; margin: 6px 0; font-size: .93rem; }
#panel .src { font-size: .8rem; }
#panel .src a { margin-right: 8px; }

/* Map page */
#map { height: calc(100vh - 58px); min-height: 420px; }
.legend { background: var(--paper); color: var(--ink); padding: 8px 10px; border-radius: 8px; font: 13px system-ui, sans-serif; box-shadow: var(--shadow); }
.legend div { display: flex; align-items: center; gap: 6px; margin: 2px 0; }
.legend span.sw { width: 14px; height: 4px; border-radius: 2px; display: inline-block; }
