:root {
  --paper: #f3eee3;
  --surface: #fffdf8;
  --surface-2: #f8f3e9;
  --ink: #262923;
  --muted: #686b62;
  --line: #ddd5c6;
  --green: #285846;
  --green-dark: #193d30;
  --green-soft: #dbe8e0;
  --gold: #af7c2e;
  --red: #94483f;
  --shadow: 0 14px 38px rgba(52, 45, 35, .08);
  --radius: 18px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; color: var(--ink); background: radial-gradient(circle at 8% 5%, rgba(175,124,46,.10), transparent 24rem), var(--paper); font: 15px/1.55 Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
a { color: var(--green); }
button, input, textarea, select { font: inherit; }
button, .button { cursor: pointer; }
button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible, a:focus-visible { outline: 3px solid rgba(175,124,46,.42); outline-offset: 2px; }
h1, h2, h3, p { overflow-wrap: anywhere; }
h1, h2 { font-family: Georgia, "Times New Roman", serif; font-weight: 500; letter-spacing: -.025em; }

.topbar { min-height: 72px; padding: 0 max(20px, calc((100vw - 1180px)/2)); border-bottom: 1px solid rgba(93,80,62,.15); display: flex; gap: 28px; align-items: center; color: var(--ink); background: rgba(255,253,248,.92); backdrop-filter: blur(14px); position: sticky; z-index: 20; top: 0; }
.brand { display: flex; gap: 10px; align-items: center; color: var(--ink); text-decoration: none; font-family: Georgia, serif; font-size: 18px; white-space: nowrap; }
.brand-mark { width: 35px; height: 40px; border: 2px solid var(--green); border-radius: 48% 48% 42% 42% / 30% 30% 60% 60%; display: grid; place-items: center; color: var(--green); font-size: 21px; }
.topbar nav { display: flex; gap: 6px; flex: 1; }
.nav-link { padding: 9px 11px; border-radius: 10px; color: var(--muted); text-decoration: none; font-weight: 700; }
.nav-link:hover, .nav-link.active { color: var(--green-dark); background: var(--green-soft); }
.account { display: flex; gap: 10px; align-items: center; color: var(--muted); font-size: 12px; }
.account form { margin: 0; }
.text-button { padding: 0; border: 0; color: var(--green); background: transparent; text-decoration: underline; }
.text-button.danger { color: var(--red); }
.language-switcher { position: fixed; z-index: 40; right: 16px; bottom: 16px; padding: 4px; border: 1px solid var(--line); border-radius: 99px; display: flex; gap: 3px; background: rgba(255,253,248,.96); box-shadow: var(--shadow); }
.language-switcher a { min-width: 38px; padding: 7px 9px; border-radius: 99px; color: var(--muted); font-size: 11px; font-weight: 900; text-align: center; text-decoration: none; }
html[lang="ru"] .language-switcher [data-lang="ru"], html[lang="en"] .language-switcher [data-lang="en"] { color: #fff; background: var(--green); }
.original-language-note { max-width: 1180px; margin: -58px auto 22px; padding: 0 28px; color: var(--muted); font-size: 10px; text-align: center; }
.public-page .original-language-note { display: none; }

.page { max-width: 1180px; margin: 0 auto; padding: 42px 28px 90px; }
.public-page .page { max-width: none; min-height: 100vh; padding: 0; }
.eyebrow { margin: 0 0 7px; color: var(--green); font-size: 11px; font-weight: 900; letter-spacing: .14em; text-transform: uppercase; }
.lede { color: var(--muted); font-size: 17px; }
.muted { color: var(--muted); }
.fine-print { margin-top: 22px; color: var(--muted); font-size: 12px; }

.button { min-height: 42px; padding: 10px 15px; border: 1px solid var(--line); border-radius: 11px; display: inline-flex; justify-content: center; align-items: center; color: var(--ink); background: var(--surface); text-decoration: none; font-weight: 800; }
.button:hover { border-color: #aea390; background: #fff; }
.button.primary { border-color: var(--green); color: #fff; background: var(--green); }
.button.primary:hover { background: var(--green-dark); }
.button.small { min-height: 36px; padding: 7px 11px; font-size: 12px; }
.button.active { border-color: var(--green); color: var(--green-dark); background: var(--green-soft); }

.auth-card { width: min(500px, calc(100% - 32px)); margin: 9vh auto; padding: 38px; border: 1px solid var(--line); border-radius: 24px; background: rgba(255,253,248,.94); box-shadow: var(--shadow); }
.auth-card h1 { margin: 0 0 16px; font-size: clamp(38px, 7vw, 58px); line-height: 1.02; }
.stack { margin-top: 26px; display: grid; gap: 16px; }
label { display: grid; gap: 6px; color: var(--muted); font-size: 12px; font-weight: 800; }
input, textarea, select { width: 100%; padding: 11px 12px; border: 1px solid var(--line); border-radius: 10px; color: var(--ink); background: #fff; }
textarea { min-height: 120px; resize: vertical; line-height: 1.5; }
small { color: var(--muted); font-weight: 500; }
.notice { margin: 18px 0; padding: 12px; border-radius: 10px; }
.notice.error { color: #752f28; background: #f8ded8; }

.dashboard-hero { min-height: 360px; padding: 48px; border-radius: 26px; display: grid; grid-template-columns: minmax(0,1fr) 300px; gap: 50px; align-items: end; color: #eff5f1; background: linear-gradient(130deg, var(--green-dark), #316954); box-shadow: var(--shadow); }
.dashboard-hero h1 { max-width: 760px; margin: 0; font-size: clamp(42px, 6vw, 74px); line-height: .98; }
.dashboard-hero > div > p:last-child { max-width: 680px; color: #cbdcd4; font-size: 17px; }
.dashboard-hero .eyebrow { color: #d8bd7c; }
.role-card { padding: 22px; border: 1px solid rgba(255,255,255,.18); border-radius: 16px; background: rgba(255,255,255,.08); }
.role-card span { color: #b9d0c5; font-size: 11px; font-weight: 800; text-transform: uppercase; }
.role-card strong { display: block; margin: 4px 0; font-family: Georgia,serif; font-size: 30px; font-weight: 500; }
.role-card p { margin: 0; color: #cbdcd4; font-size: 13px; }

.stats { margin: 18px 0 38px; display: grid; grid-template-columns: repeat(3,1fr); gap: 12px; }
.stats div { padding: 22px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.stats b { display: block; color: var(--green-dark); font-family: Georgia,serif; font-size: 36px; font-weight: 500; }
.stats span { color: var(--muted); font-size: 13px; }
.content-section { margin-top: 34px; padding: 26px; border: 1px solid var(--line); border-radius: var(--radius); background: rgba(255,253,248,.76); }
.section-title { margin-bottom: 18px; display: flex; justify-content: space-between; gap: 20px; align-items: end; }
.section-title h2 { margin: 0; font-size: 32px; }
.branch-grid, .interview-grid { display: grid; grid-template-columns: repeat(auto-fit,minmax(260px,1fr)); gap: 14px; }
.branch-grid article, .interview-grid article { padding: 22px; border: 1px solid var(--line); border-radius: 15px; background: var(--surface); }
.branch-grid h3, .interview-grid h2 { margin: 10px 0 8px; font-family: Georgia,serif; font-size: 23px; font-weight: 500; }
.branch-grid p, .interview-grid p { color: var(--muted); }
.branch-grid a, .interview-grid a { font-weight: 800; text-decoration: none; }
.branch-initial { width: 38px; height: 44px; border: 1px solid var(--green); border-radius: 50% 50% 42% 42%; display: grid; place-items: center; color: var(--green); font-family: Georgia,serif; font-size: 20px; }

.page-heading { max-width: 820px; margin-bottom: 32px; }
.page-heading h1 { margin: 0; font-size: clamp(44px,7vw,72px); line-height: 1; }
.page-heading > p:last-child { color: var(--muted); font-size: 17px; }
.tree-heading { margin-bottom: 20px; }
.branch-switcher { margin: 0 0 24px; display: grid; grid-template-columns: repeat(auto-fit,minmax(260px,1fr)); gap: 10px; }
.branch-switcher a { padding: 15px 17px; border: 1px solid var(--line); border-radius: 13px; display: grid; color: var(--ink); background: var(--surface); text-decoration: none; }
.branch-switcher a[aria-current="page"] { border: 2px solid var(--green); background: var(--green-soft); }
.branch-switcher span, .branch-switcher small { color: var(--muted); font-size: 10px; font-weight: 800; }
.branch-switcher b { font-family: Georgia,serif; font-size: 18px; font-weight: 500; }
.genealogy-tree { width: 100%; min-width: 0; margin: 24px 0; padding: 28px; border: 1px solid var(--line); border-radius: 22px; display: grid; justify-items: center; background: rgba(255,253,248,.84); box-shadow: var(--shadow); overflow-x: auto; }
.tree-generation-label { margin: 4px 0 12px; color: var(--gold); font-size: 10px; font-weight: 900; letter-spacing: .09em; text-align: center; text-transform: uppercase; }
.tree-root { display: flex; justify-content: center; }
.tree-node { width: min(260px,72vw); min-height: 106px; padding: 15px; border: 1px solid #cfc5b5; border-radius: 14px; display: grid; align-content: center; gap: 4px; color: var(--ink); background: var(--surface); text-align: center; text-decoration: none; box-shadow: 0 8px 18px rgba(52,45,35,.05); }
.tree-node:hover { border-color: var(--green); transform: translateY(-1px); }
.tree-node.living { background: #f4f8f5; }
.tree-node span { color: var(--green); font-size: 9px; font-weight: 900; text-transform: uppercase; }
.tree-node b { font-family: Georgia,serif; font-size: 19px; font-weight: 500; }
.tree-node small { font-size: 10px; }
.tree-couple { display: flex; justify-content: center; align-items: center; gap: 10px; }
.tree-union { width: 34px; height: 34px; border: 1px solid var(--gold); border-radius: 50%; display: grid; flex: 0 0 auto; place-items: center; color: var(--gold); background: #fff8ec; font-size: 18px; }
.vertical-line { width: 2px; height: 32px; margin: 4px 0; background: var(--green); opacity: .55; }
.tree-sibling-groups { width: 100%; min-width: 0; padding-top: 22px; border-top: 2px solid rgba(40,88,70,.32); display: grid; grid-template-columns: minmax(190px,.8fr) minmax(510px,1.8fr) minmax(190px,.8fr); gap: 14px; align-items: start; }
.tree-family-unit { min-height: 150px; padding: 14px; border: 1px solid var(--line); border-radius: 16px; display: grid; justify-items: center; gap: 10px; background: var(--surface-2); }
.tree-family-unit > .tree-node { width: 100%; }
.tree-family-unit .tree-couple .tree-node { width: 205px; }
.tree-family-unit.featured { background: #f4f8f5; border-color: #b9cfc3; }
.tree-family-unit > .tree-node, .tree-family-unit > .tree-couple { position: relative; }
.tree-family-unit > .tree-node::before, .tree-family-unit > .tree-couple::before { content: ''; width: 2px; height: 24px; position: absolute; top: -39px; left: 50%; background: rgba(40,88,70,.45); }
.tree-descent { width: 100%; padding-top: 12px; border-top: 1px solid var(--line); text-align: center; }
.tree-descent > span { color: var(--muted); font-size: 9px; font-weight: 900; text-transform: uppercase; }
.tree-descendants { margin-top: 8px; display: grid; grid-template-columns: repeat(auto-fit,minmax(145px,1fr)); gap: 7px; }
.tree-descendants .tree-node { width: auto; min-height: 90px; padding: 10px; }
.tree-descendants .tree-node b { font-size: 16px; }
.tree-parent-pair { width: min(720px,100%); display: grid; grid-template-columns: repeat(2,minmax(240px,1fr)); gap: 26px; align-items: stretch; }
.tree-parent-pair .tree-node { width: 100%; }
.tree-unresolved-label { max-width: 620px; margin: 12px 0 4px; padding: 8px 14px; border: 1px dashed #a96f56; border-radius: 99px; color: #84513d; background: #faf1ec; font-size: 11px; font-weight: 800; text-align: center; }
.tree-research-gap { margin: 18px 0 32px; padding: 24px; border: 2px dashed #b78b74; border-radius: 18px; background: #faf1ec; }
.tree-research-gap h2 { margin: 0; font-size: 28px; }
.tree-research-gap > p:not(.eyebrow) { max-width: 820px; color: var(--muted); }
.tree-gap-people { display: grid; grid-template-columns: minmax(190px,260px) minmax(180px,1fr) minmax(190px,260px); gap: 12px; align-items: center; }
.tree-gap-people i { padding: 10px; border-top: 1px dashed #a96f56; border-bottom: 1px dashed #a96f56; color: #84513d; font-size: 11px; text-align: center; }
.unplaced-people { margin-top: 30px; padding: 22px; border: 1px dashed var(--line); border-radius: var(--radius); }
.unplaced-people h2 { margin: 0; }
.unplaced-people > p:not(.eyebrow) { color: var(--muted); }
.people-list { display: grid; grid-template-columns: repeat(auto-fit,minmax(340px,1fr)); gap: 12px; }
.person-card { min-height: 130px; padding: 20px; border: 1px solid var(--line); border-radius: var(--radius); display: grid; grid-template-columns: 48px 1fr; gap: 15px; background: var(--surface); }
.person-icon { width: 48px; height: 54px; border-radius: 50% 50% 44% 44%; display: grid; place-items: center; color: #fff; background: var(--green); font-family: Georgia,serif; font-size: 24px; }
.person-card h3 { margin: 0 0 5px; font-family: Georgia,serif; font-size: 22px; font-weight: 500; }
.person-card h3 a { color: var(--ink); text-decoration: none; }
.person-card p { margin: 0 0 5px; color: var(--muted); }

.admin-panel { margin: 18px 0; padding: 18px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface-2); }
.admin-panel summary { color: var(--green); font-weight: 900; cursor: pointer; }
.admin-panel h3 { margin-top: 0; font-family: Georgia,serif; font-size: 22px; }
.form-grid { margin-top: 18px; display: grid; grid-template-columns: repeat(3,1fr); gap: 13px; align-items: end; }
.form-grid .wide { grid-column: span 2; }

.person-hero { padding: 32px; border: 1px solid var(--line); border-radius: 22px; display: grid; grid-template-columns: 94px 1fr; gap: 24px; align-items: center; background: var(--surface); }
.person-monogram { width: 90px; height: 106px; border: 2px solid var(--green); border-radius: 50% 50% 42% 42%; display: grid; place-items: center; color: var(--green); font-family: Georgia,serif; font-size: 48px; }
.person-hero h1 { margin: 0 0 10px; font-size: clamp(40px,6vw,66px); line-height: 1; }
.person-hero p { margin: 5px 0; color: var(--muted); }
.two-column { margin-top: 26px; display: grid; grid-template-columns: minmax(0,2fr) minmax(260px,1fr); gap: 22px; align-items: start; }
.two-column > div, .two-column > aside { padding: 24px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.two-column h2 { margin-top: 0; font-size: 30px; }
.claim { margin-bottom: 10px; padding: 15px; border-left: 4px solid var(--gold); border-radius: 10px; display: grid; grid-template-columns: 1fr 260px; gap: 18px; background: var(--surface-2); }
.claim.documented { border-color: var(--green); }
.claim.disputed { border-color: var(--red); }
.claim span, .claim-meta span { display: block; color: var(--muted); font-size: 11px; }
.claim strong { font-size: 16px; }
.claim-meta b { display: block; color: var(--green); font-size: 12px; }
.relation { margin-bottom: 8px; padding: 12px; border: 1px solid var(--line); border-radius: 10px; display: block; color: var(--ink); background: var(--surface-2); text-decoration: none; }
.relation span { display: block; color: var(--muted); font-size: 11px; }

.status, .pill { padding: 4px 8px; border-radius: 99px; color: var(--green-dark); background: var(--green-soft); font-size: 11px; font-weight: 900; }
.response { margin-bottom: 12px; padding: 18px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-2); }
.response > span { color: var(--muted); font-size: 11px; font-weight: 800; }
.response h3 { margin: 5px 0; font-size: 15px; }
.response p { white-space: pre-wrap; }
.response b { color: var(--green); font-size: 11px; }
.provenance { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--line); display: grid; gap: 3px; }
.provenance span { color: var(--muted); font-size: 11px; }

.role-matrix { display: grid; grid-template-columns: repeat(4,1fr); gap: 10px; }
.role-matrix div { padding: 17px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.role-matrix b, .role-matrix span { display: block; }
.role-matrix span { margin-top: 5px; color: var(--muted); font-size: 12px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { color: var(--muted); font-size: 11px; text-transform: uppercase; }
td small { display: block; }
.invite-forms { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.invite-forms .admin-panel { display: grid; gap: 12px; }
.audit-list { margin: 0; padding: 0; list-style: none; }
.audit-list li { padding: 9px 0; border-bottom: 1px solid var(--line); }
.audit-list span { color: var(--muted); font-size: 11px; }

.empty-state { max-width: 680px; margin: 10vh auto; padding: 42px; border: 1px solid var(--line); border-radius: 22px; text-align: center; background: var(--surface); box-shadow: var(--shadow); }
.empty-state h1 { margin: 0; font-size: 46px; }
.empty-state p { color: var(--muted); }
.copy-field { margin: 24px 0; grid-template-columns: 1fr auto; align-items: end; text-align: left; }
.copy-field input { grid-column: 1; }
.copy-field button { grid-column: 2; grid-row: 1 / span 2; }

.contribute-page { background: var(--paper); }
.contribute-page .page { max-width: 940px; margin: 0 auto; padding: 28px 18px 80px; }
.contribute-hero { padding: 32px; border-radius: 24px; color: #edf5f1; background: var(--green-dark); }
.contribute-hero .eyebrow { color: #d8bd7c; }
.contribute-hero h1 { margin: 0; font-size: clamp(38px,7vw,62px); line-height: 1; }
.contribute-hero p { color: #c8d9d1; }
.privacy-note { margin: 18px 0; padding: 14px 16px; border: 1px solid rgba(255,255,255,.16); border-radius: 13px; display: grid; gap: 3px; color: #dce9e3; background: rgba(255,255,255,.07); }
.privacy-note span { color: #bed1c8; font-size: 12px; }
.progress { display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: center; }
.progress > div { height: 8px; border-radius: 99px; overflow: hidden; background: rgba(255,255,255,.18); }
.progress span { display: block; height: 100%; border-radius: inherit; background: #d8bd7c; }
.mode-switch { margin-top: 16px; display: flex; gap: 8px; }
.upload-panel { margin: 16px 0 28px; padding: 20px; border: 1px solid var(--line); border-radius: var(--radius); display: grid; grid-template-columns: 1fr 1fr; gap: 20px; background: var(--surface); }
.upload-panel h2 { margin: 0; font-size: 26px; }
.upload-panel p { color: var(--muted); font-size: 13px; }
.upload-panel form { display: grid; gap: 8px; align-content: center; }
.file-list { display: flex; gap: 7px; flex-wrap: wrap; }
.file-list a { padding: 6px 9px; border-radius: 8px; background: var(--green-soft); font-size: 12px; text-decoration: none; }
.question-section { margin: 32px 0; }
.question-section[hidden], .question-card[hidden] { display: none; }
.question-list { display: grid; gap: 12px; }
.question-card { padding: 20px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.question-card.answered { border-left: 5px solid var(--green); }
.question-heading { display: grid; grid-template-columns: 36px 1fr; gap: 10px; }
.question-number { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; color: var(--green-dark); background: var(--green-soft); font-size: 12px; font-weight: 900; }
.question-heading h3 { margin: 4px 0 0; font-size: 16px; }
.question-heading em { margin-left: 8px; padding: 3px 7px; border-radius: 99px; color: #7d501f; background: #f3e3cd; font-size: 9px; font-style: normal; text-transform: uppercase; }
.answer-form { margin: 14px 0 0 46px; display: grid; grid-template-columns: minmax(0,2fr) minmax(180px,1fr); gap: 10px; }
.answer-form .answer-field { grid-row: span 2; }
.answer-form .answer-field textarea { min-height: 168px; }
.consent-check { grid-column: 1 / -1; padding: 10px 12px; border: 1px solid #c9d7cf; border-radius: 10px; display: flex; gap: 9px; align-items: flex-start; color: var(--green-dark); background: #eef5f0; font-size: 11px; line-height: 1.4; }
.consent-check input { width: 18px; height: 18px; margin: 0; flex: 0 0 auto; accent-color: var(--green); }
.voice-answer { grid-column: 1 / -1; padding: 11px; border: 1px solid var(--line); border-radius: 11px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; color: var(--muted); background: var(--surface-2); font-size: 11px; }
.voice-button { color: var(--green-dark); }
.voice-button.recording { border-color: #a53d34; color: #fff; background: #a53d34; animation: recording-pulse 1.4s ease-in-out infinite; }
.voice-files { display: flex; gap: 7px; flex-wrap: wrap; flex: 1 0 100%; }
.voice-files:empty { display: none; }
.voice-files a { padding: 6px 9px; border-radius: 8px; color: var(--green-dark); background: var(--green-soft); text-decoration: none; font-weight: 800; }
@keyframes recording-pulse { 50% { opacity: .72; } }
.answer-form .save-line { grid-column: 1 / -1; display: flex; gap: 10px; align-items: center; }
.save-message { color: var(--green); font-size: 11px; }
.contribute-footer { margin-top: 40px; padding: 24px; border-radius: var(--radius); color: #d4e4dc; background: var(--green-dark); text-align: center; }

.research-hero { padding: 38px; border-radius: 24px; display: grid; grid-template-columns: minmax(0,1fr) 260px; gap: 36px; color: #edf5f1; background: linear-gradient(135deg,var(--green-dark),#315f4d); box-shadow: var(--shadow); }
.research-hero h1 { max-width: 760px; margin: 0; font-size: clamp(42px,6vw,68px); line-height: 1; }
.research-hero p:last-child { max-width: 760px; color: #cbdcd4; }
.research-hero .eyebrow { color: #d8bd7c; }
.research-totals { padding: 20px; border: 1px solid rgba(255,255,255,.18); border-radius: 16px; display: grid; grid-template-columns: auto 1fr; gap: 5px 12px; align-content: center; background: rgba(255,255,255,.07); }
.research-totals b { color: #fff; font-family: Georgia,serif; font-size: 30px; font-weight: 500; }
.research-totals span { align-self: center; color: #cbdcd4; font-size: 12px; }
.research-section { margin-top: 34px; }
.research-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 15px; align-items: start; }
.research-card { padding: 22px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: 0 8px 22px rgba(52,45,35,.04); }
.research-card > header { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; }
.research-card h2 { margin: 0; font-size: 27px; }
.research-card header p:last-child, .research-summary { color: var(--muted); }
.research-card header p:last-child { margin: 5px 0 0; font-size: 12px; }
.research-summary { min-height: 48px; }
.research-status, .task-state { padding: 5px 8px; border-radius: 99px; white-space: nowrap; color: #72501f; background: #f2e2c8; font-size: 10px; font-weight: 900; text-transform: uppercase; }
.research-status.waiting, .task-state.waiting { color: #655c50; background: #eee9df; }
.research-status.verified, .task-state.done { color: var(--green-dark); background: var(--green-soft); }
.fact-stack { margin: 17px 0; display: grid; gap: 8px; }
.research-fact { padding: 12px 13px; border-left: 4px solid var(--gold); border-radius: 9px; background: var(--surface-2); }
.research-fact.document { border-color: var(--green); }
.research-fact.unknown { border-color: #a7a095; }
.research-fact.lead { border-color: #a65c3e; }
.fact-label { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; }
.fact-label span { color: var(--muted); font-size: 9px; font-weight: 900; letter-spacing: .06em; text-transform: uppercase; }
.fact-label b { color: var(--green-dark); font-size: 11px; }
.research-fact > strong { margin-top: 4px; display: block; }
.research-fact p { margin: 5px 0; color: var(--muted); font-size: 11px; }
.research-fact small { display: block; margin-top: 6px; font-size: 10px; }
.unlinked-note { color: #8b513a; font-size: 11px; font-weight: 800; }
.task-list { display: grid; gap: 10px; }
.research-task { padding: 18px; border: 1px solid var(--line); border-radius: 14px; display: grid; grid-template-columns: minmax(0,1fr) minmax(320px,1fr); gap: 20px; background: var(--surface); }
.research-task h3 { margin: 7px 0 4px; font-family: Georgia,serif; font-size: 21px; font-weight: 500; }
.research-task p { margin: 0; color: var(--muted); }
.research-task dl { margin: 0; display: grid; grid-template-columns: repeat(3,1fr); gap: 10px; }
.research-task dl div { padding: 10px; border-radius: 9px; background: var(--surface-2); }
.research-task dt { color: var(--muted); font-size: 9px; font-weight: 900; text-transform: uppercase; }
.research-task dd { margin: 3px 0 0; font-size: 11px; }
.source-grid { display: grid; grid-template-columns: repeat(auto-fit,minmax(230px,1fr)); gap: 10px; }
.source-grid article { padding: 17px; border: 1px solid var(--line); border-radius: 13px; background: var(--surface); }
.source-grid span { color: var(--gold); font-size: 9px; font-weight: 900; text-transform: uppercase; }
.source-grid h3 { margin: 7px 0; font-size: 14px; }
.source-grid p { color: var(--muted); font-size: 11px; }
.lineage-map { padding: 26px; border: 1px solid var(--line); border-radius: var(--radius); display: grid; justify-items: center; background: var(--surface); }
.map-generation { width: min(620px,100%); display: grid; grid-template-columns: 1fr auto 1fr; gap: 12px; align-items: center; }
.map-person { min-width: 230px; padding: 15px; border: 1px solid var(--line); border-radius: 12px; text-align: center; background: var(--surface-2); }
.map-person.focus { border: 2px solid var(--green); background: var(--green-soft); }
.map-person b, .map-person span, .map-person small { display: block; }
.map-person b { font-family: Georgia,serif; font-size: 20px; }
.map-person span, .map-person small { color: var(--muted); font-size: 11px; }
.map-plus { color: var(--gold); font-size: 24px; }
.map-arrow { padding: 10px; color: var(--green); font-size: 11px; font-weight: 900; }
.map-arrow.uncertain { color: #8b513a; border-top: 1px dashed #b88774; border-bottom: 1px dashed #b88774; }
.map-gap-panel { width: min(820px,100%); margin-top: 24px; padding: 18px; border: 2px dashed #b88774; border-radius: 15px; display: grid; grid-template-columns: 1fr minmax(160px,auto) 1fr; gap: 12px; align-items: center; background: #fbf2ed; }

.book-hero { padding: 42px; border-bottom: 1px solid var(--line); background: var(--surface); }
.book-hero h1 { margin: 0; font-size: clamp(52px,8vw,88px); line-height: .95; }
.book-hero p:last-of-type { max-width: 740px; color: var(--muted); font-size: 17px; }
.book-legend { margin: 18px 0 34px; display: flex; gap: 8px; flex-wrap: wrap; }
.book-legend span { padding: 6px 10px; border-radius: 99px; background: var(--surface); font-size: 10px; font-weight: 900; }
.book-legend .document { color: var(--green); border: 1px solid #96b6a7; }
.book-legend .family { color: #815b21; border: 1px solid #d3b57c; }
.book-legend .unknown { color: #7a5648; border: 1px dashed #b98d7a; }
.book-chapter { margin: 0 0 34px; padding: 36px; border: 1px solid var(--line); border-radius: 4px 22px 22px 4px; background: var(--surface); box-shadow: inset 8px 0 0 #e5dccb,var(--shadow); }
.book-chapter > header { max-width: 820px; padding-bottom: 20px; border-bottom: 1px solid var(--line); }
.book-chapter > header span { color: var(--gold); font-size: 10px; font-weight: 900; text-transform: uppercase; }
.book-chapter h2 { margin: 6px 0; font-size: clamp(36px,5vw,56px); line-height: 1; }
.book-chapter > header p { color: var(--muted); font-size: 16px; }
.book-evidence, .book-next { margin-top: 20px; padding: 18px; border-radius: 13px; }
.book-evidence.documented { border-left: 4px solid var(--green); background: #f0f6f2; }
.book-evidence.memories { border-left: 4px solid var(--gold); background: #faf3e6; }
.book-evidence.open { border-left: 4px dashed #9f6b55; background: #f7efeb; }
.book-evidence h3, .book-next h3 { margin: 0 0 8px; font-family: Georgia,serif; font-size: 22px; font-weight: 500; }
.book-evidence ul, .book-next ul { margin: 8px 0; padding-left: 20px; }
.book-evidence li, .book-next li { margin: 6px 0; }
.book-rule, .book-empty { color: var(--muted); font-size: 11px; }
.book-next { border: 1px solid var(--line); background: var(--surface-2); }
.book-media { margin-top: 20px; display: grid; grid-template-columns: repeat(4,1fr); gap: 9px; }
.book-media div { min-height: 125px; padding: 14px; border: 1px dashed #bdb19f; border-radius: 11px; display: grid; align-content: start; gap: 4px; background: #fffefa; }
.book-media span { color: var(--green); font-size: 24px; }
.book-media small { font-size: 10px; }

@media (max-width: 1080px) {
  .tree-sibling-groups { grid-template-columns: 1fr; border-top: 0; padding-top: 0; }
  .tree-family-unit > .tree-node::before, .tree-family-unit > .tree-couple::before { display: none; }
  .tree-family-unit .tree-couple .tree-node { width: min(260px,40vw); }
}

@media (max-width: 880px) {
  .topbar { padding: 10px 16px; flex-wrap: wrap; gap: 10px; }
  .topbar nav { order: 3; flex: 1 0 100%; overflow-x: auto; }
  .account { margin-left: auto; }
  .account span { display: none; }
  .page { padding: 28px 18px 70px; }
  .dashboard-hero { grid-template-columns: 1fr; gap: 28px; padding: 32px; }
  .role-card { max-width: 420px; }
  .role-matrix { grid-template-columns: 1fr 1fr; }
  .two-column { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr 1fr; }
  .research-hero, .research-task { grid-template-columns: 1fr; }
  .research-grid { grid-template-columns: 1fr; }
  .book-media { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 580px) {
  .brand span:last-child { display: none; }
  .nav-link { padding: 8px 9px; }
  .auth-card { padding: 26px 20px; }
  .stats { grid-template-columns: 1fr; }
  .people-list { grid-template-columns: 1fr; }
  .person-card { grid-template-columns: 42px 1fr; }
  .person-hero { padding: 22px; grid-template-columns: 1fr; }
  .person-monogram { width: 65px; height: 76px; }
  .claim { grid-template-columns: 1fr; }
  .form-grid, .invite-forms, .role-matrix, .upload-panel, .answer-form { grid-template-columns: 1fr; }
  .form-grid .wide { grid-column: auto; }
  .answer-form { margin-left: 0; }
  .answer-form .answer-field { grid-row: auto; }
  .consent-check { grid-column: 1; }
  .answer-form .save-line { grid-column: 1; }
  .contribute-hero { padding: 24px 20px; }
  .question-card { padding: 16px 14px; }
  .copy-field { grid-template-columns: 1fr; }
  .copy-field button { grid-column: 1; grid-row: auto; }
  .map-generation { grid-template-columns: 1fr; }
  .map-person { min-width: 0; width: 100%; }
  .map-plus { text-align: center; }
  .tree-couple { width: 100%; flex-direction: column; }
  .tree-family-unit .tree-couple .tree-node { width: 100%; }
  .tree-union { transform: rotate(90deg); }
  .tree-node { width: 100%; }
  .tree-parent-pair { grid-template-columns: 1fr; gap: 10px; }
  .tree-unresolved-label { border-radius: 13px; }
  .tree-gap-people, .map-gap-panel { grid-template-columns: 1fr; }
  .research-task dl, .book-media { grid-template-columns: 1fr; }
  .research-card > header { display: grid; }
  .book-hero, .book-chapter { padding: 24px 20px; }
  .language-switcher { right: 10px; bottom: 10px; }
}

@media print {
  .topbar, .button, form, .admin-panel, .language-switcher, .original-language-note { display: none !important; }
  body { background: #fff; }
  .page { max-width: none; padding: 0; }
  .person-card, .claim, .response, .research-card, .book-chapter, .book-evidence { break-inside: avoid; box-shadow: none; }
  .book-page .book-chapter { border: 0; border-top: 1px solid #bbb; border-radius: 0; }
}
