:root {
  --bg: #f7f3ea;
  --paper: #fffdf8;
  --ink: #172033;
  --muted: #6f756f;
  --navy: #0e2744;
  --gold: #b99a57;
  --line: #d8c8a4;
  --family-line: #9f8550;
  --soft: #eef3f0;
  --spouse: #f4f4f1;
  --deceased: #eef1f6;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic", "Yu Gothic UI", sans-serif;
  background: radial-gradient(circle at top left, #fff 0, var(--bg) 36%, #efe6d2 100%);
  color: var(--ink);
}
.hero {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: flex-end;
  padding: 48px clamp(20px, 5vw, 72px) 28px;
  border-bottom: 1px solid rgba(185,154,87,.35);
}
.eyebrow { letter-spacing: .18em; font-size: 12px; color: var(--gold); font-weight: 700; }
h1 { margin: 6px 0 10px; font-size: clamp(34px, 5vw, 64px); color: var(--navy); line-height: 1.05; }
.lead { margin: 0; color: var(--muted); font-size: 16px; }
.hero-card {
  background: rgba(255,255,255,.7);
  border: 1px solid rgba(185,154,87,.4);
  border-radius: 20px;
  padding: 16px 20px;
  min-width: 160px;
  box-shadow: 0 18px 40px rgba(14,39,68,.08);
}
.hero-card span { display:block; color:var(--muted); font-size:12px; }
.hero-card strong { color:var(--navy); font-size:20px; }
main { padding: 24px clamp(16px, 4vw, 56px) 56px; }
.toolbar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 16px;
  position: sticky;
  top: 0;
  z-index: 2;
  padding: 12px;
  border-radius: 18px;
  background: rgba(247,243,234,.88);
  backdrop-filter: blur(10px);
}
input, button {
  border: 1px solid rgba(14,39,68,.16);
  border-radius: 999px;
  padding: 12px 16px;
  font-size: 15px;
  background: white;
}
input { min-width: min(100%, 340px); flex: 1; }
button { cursor: pointer; color: var(--navy); font-weight: 700; }
.notice {
  max-width: 1000px;
  background: rgba(255,255,255,.62);
  border: 1px solid rgba(185,154,87,.3);
  padding: 14px 18px;
  border-radius: 16px;
  color: var(--muted);
  margin-bottom: 28px;
}
.tree {
  overflow-x: auto;
  padding: 20px 0 40px;
}
.union {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  margin: 8px 14px;
  vertical-align: top;
}
.partners {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border: 2px solid color-mix(in srgb, var(--family-line) 42%, transparent);
  border-radius: 16px;
  background: color-mix(in srgb, var(--family-bg) 72%, white);
}
.partner-line { color: var(--family-line); font-weight: 900; font-size: 20px; }
.person {
  width: 180px;
  min-height: 102px;
  padding: 14px 14px 12px;
  border-radius: 8px;
  background:
    linear-gradient(90deg, var(--family-line) 0 8px, transparent 8px),
    color-mix(in srgb, var(--family-bg) 38%, var(--paper));
  border: 2px solid color-mix(in srgb, var(--family-line) 34%, rgba(14,39,68,.12));
  box-shadow: 0 14px 32px rgba(14,39,68,.07);
}
.person.spouse {
  background:
    linear-gradient(90deg, var(--family-line) 0 8px, transparent 8px),
    color-mix(in srgb, var(--family-bg) 24%, var(--spouse));
}
.person.deceased {
  background:
    linear-gradient(90deg, var(--family-line) 0 8px, transparent 8px),
    color-mix(in srgb, var(--family-bg) 18%, var(--deceased));
}
.person.hit { outline: 4px solid rgba(185,154,87,.45); transform: translateY(-2px); }
.person-relation {
  margin: 0 0 4px;
  color: #8a8f92;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.2;
}
.person-name { font-weight: 800; color: var(--navy); font-size: 18px; letter-spacing: .02em; }
.person-meta { margin-top: 8px; color: var(--muted); font-size: 12px; }
.person-age { margin-top: 6px; font-weight: 700; color: var(--gold); font-size: 13px; }
.children {
  display: flex;
  gap: 18px;
  align-items: flex-start;
  list-style: none;
  padding: 36px 0 0;
  margin: 0;
  position: relative;
}
.children::before {
  content: '';
  position: absolute;
  top: 17px;
  left: 8%;
  right: 8%;
  height: 4px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--family-line) 72%, var(--line));
}
.children > li {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.children > li::before {
  content: '';
  position: absolute;
  top: -19px;
  width: 4px;
  height: 18px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--family-line) 72%, var(--line));
}
.continuation {
  margin-top: 0;
}
.continuation > .partners {
  margin-top: 10px;
}
.family-root { --family-line: #8b6f2f; --family-bg: #fff8e4; }
.family-0 { --family-line: #af5f3d; --family-bg: #fff0e8; }
.family-1 { --family-line: #527d48; --family-bg: #eef8e9; }
.family-2 { --family-line: #7b6bb4; --family-bg: #f0edff; }
.family-3 { --family-line: #2d7c89; --family-bg: #e8f7fa; }
.family-4 { --family-line: #bf8a22; --family-bg: #fff5d9; }
.family-5 { --family-line: #a84f78; --family-bg: #fdebf3; }
.family-6 { --family-line: #4f6f9f; --family-bg: #edf3ff; }
.collapsed .children { display: none; }
.depth-2 .person { width: 164px; }
.depth-3 .person { width: 150px; }
footer { padding: 24px 56px; color: var(--muted); }
@media (max-width: 760px) {
  .hero { display: block; padding-top: 32px; }
  .hero-card { margin-top: 18px; }
  .person { width: 156px; }
  .children { gap: 10px; }
}
@media print {
  body { background: #fff; }
  .toolbar, .notice, footer { display: none; }
  .tree { overflow: visible; zoom: .62; }
}
