@font-face { font-family: 'Source Serif 4'; src: url('/fonts/source-serif-4.woff2') format('woff2'); font-weight: 200 900; font-display: swap; }
@font-face { font-family: 'Source Sans 3'; src: url('/fonts/source-sans-3.woff2') format('woff2'); font-weight: 200 900; font-display: swap; }
@font-face { font-family: 'Source Sans 3'; src: url('/fonts/source-sans-3-italic.woff2') format('woff2'); font-weight: 200 900; font-style: italic; font-display: swap; }

:root {
  --bg: #F3EFE6;
  --surface: #FFFDF8;
  --sunken: #EAE4D7;
  --ink: #1C1A17;
  --ink-2: #3B3730;
  --muted: #5F594E;
  --line: #D9D1C1;
  --line-strong: #B5AC9B;
  --accent: #2F5D46;
  --accent-ink: #FFFFFF;
  --accent-soft: #E1EADF;
  --accent-deep: #1F4231;
  --warn: #7A4E0B;
  --warn-soft: #F6E8CC;
  --warn-line: #E2C78F;
  --danger: #8E2A1C;
  --danger-soft: #F7E1DC;
  --deceased: #E7E2D7;
  --serif: 'Source Serif 4', Georgia, 'Times New Roman', serif;
  --sans: 'Source Sans 3', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --radius: 12px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 400 17px/1.55 var(--sans); }
img { max-width: 100%; display: block; }
a { color: var(--accent); text-underline-offset: 2px; }
a:hover { color: var(--accent-deep); }
h1, h2, h3 { font-family: var(--serif); font-weight: 600; line-height: 1.15; margin: 0; letter-spacing: -0.005em; }
h1 { font-size: clamp(30px, 4vw, 40px); }
h2 { font-size: 22px; }
h3 { font-size: 18px; }
p { margin: 0; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Shell */
.shell { min-height: 100vh; display: flex; flex-direction: column; }
.topbar { background: var(--surface); border-bottom: 1px solid var(--line); }
.topbar-inner { max-width: 1200px; margin: 0 auto; padding: 10px 20px; display: flex; flex-wrap: wrap; align-items: center; gap: 10px 24px; }
.brand { display: flex; align-items: center; gap: 12px; color: var(--ink); text-decoration: none; }
.brand img { height: 44px; width: auto; }
.brand span { font-family: var(--serif); font-size: 16px; letter-spacing: 0.32em; text-transform: uppercase; font-weight: 500; }
.mainnav { display: flex; flex-wrap: wrap; gap: 2px; flex: 1 1 auto; }
.mainnav a { padding: 9px 12px; border-radius: 8px; color: var(--ink-2); font-weight: 600; text-decoration: none; }
.mainnav a[aria-current='page'] { background: var(--accent-soft); color: var(--accent-deep); }
.mainnav a:hover { background: var(--sunken); }
.badge { display: inline-block; min-width: 20px; margin-left: 4px; padding: 0 6px; border-radius: 999px; background: var(--warn); color: #fff; font-size: 12px; text-align: center; }
.searchlink { flex: 0 1 230px; min-height: 40px; display: flex; align-items: center; gap: 8px; padding: 0 14px; border: 1px solid var(--line-strong); border-radius: 999px; color: var(--muted); font-size: 15px; font-weight: 600; text-decoration: none; background: var(--surface); }
.avatar-btn { width: 40px; height: 40px; border-radius: 999px; background: var(--ink); color: var(--bg); display: flex; align-items: center; justify-content: center; font-weight: 700; text-decoration: none; overflow: hidden; flex: none; }
.avatar-btn img { width: 100%; height: 100%; object-fit: cover; }
main { flex: 1; }
.container { max-width: 1200px; margin: 0 auto; padding: 32px 20px 64px; display: flex; flex-direction: column; gap: 24px; }
.narrow { max-width: 860px; }
.footer { border-top: 1px solid var(--line); background: var(--surface); }
.footer-inner { max-width: 1200px; margin: 0 auto; padding: 18px 20px; display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; font-size: 14px; color: var(--muted); }
.footer a { color: var(--muted); }

/* Building blocks */
.eyebrow { font-family: var(--serif); font-size: 13px; letter-spacing: 0.22em; text-transform: uppercase; color: var(--muted); }
.lede { font-size: 18px; color: var(--ink-2); max-width: 720px; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.card.tight { padding: 18px; gap: 12px; }
.row { display: flex; flex-wrap: wrap; gap: 24px; align-items: flex-start; }
.row > .side { flex: 1 1 280px; min-width: 0; }
.row > .grow { flex: 999 1 560px; min-width: 0; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.inline { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.between { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; }
.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.grid.wide { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
hr { border: 0; border-top: 1px solid var(--line); margin: 4px 0; width: 100%; }

/* Forms */
label.field { display: flex; flex-direction: column; gap: 6px; font-size: 14px; font-weight: 600; color: var(--ink-2); }
label.field .hint { font-weight: 400; color: var(--muted); }
input[type=text], input[type=email], input[type=tel], input[type=date], input[type=url], input[type=search], input[type=number], input[type=password], select, textarea {
  font: inherit; font-size: 16px; color: var(--ink); background: #fff; border: 1px solid var(--line-strong); border-radius: 8px; padding: 10px 12px; min-height: 44px; width: 100%;
}
textarea { min-height: 96px; resize: vertical; }
input[type=checkbox], input[type=radio] { width: 20px; height: 20px; accent-color: var(--accent); margin: 0; flex: none; }
fieldset { border: 0; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
legend { font-weight: 700; margin-bottom: 8px; padding: 0; }
.check { display: flex; gap: 10px; align-items: center; padding: 11px 14px; border: 1px solid var(--line); border-radius: 10px; background: #fff; font-weight: 500; }
.check.plain { border: 0; padding: 4px 0; background: transparent; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; border-radius: 999px; background: var(--accent-soft); color: var(--accent-deep); font-size: 14px; font-weight: 600; text-decoration: none; }
.chip.warn { background: var(--warn-soft); color: var(--warn); }
.chip.gray { background: var(--sunken); color: var(--ink-2); }
.chip button { border: 0; background: transparent; color: inherit; font-size: 16px; width: 22px; height: 22px; padding: 0; cursor: pointer; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 18px; border-radius: 10px; border: 1px solid var(--line-strong); background: #fff; color: var(--ink); font: 600 16px/1 var(--sans); text-decoration: none; cursor: pointer; }
.btn:hover { background: var(--sunken); color: var(--ink); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: var(--accent-deep); color: #fff; }
.btn.dark { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.btn.warn { background: var(--warn); border-color: var(--warn); color: #fff; }
.btn.danger { color: var(--danger); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.small { min-height: 36px; padding: 0 12px; font-size: 14px; }
.btn.block { width: 100%; }
form.inline-form { display: inline; }

/* Notices */
.notice { padding: 16px 18px; border-radius: 10px; background: var(--accent-soft); color: var(--accent-deep); display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; }
.notice.warn { background: var(--warn-soft); color: var(--warn); border: 1px solid var(--warn-line); }
.notice.danger { background: var(--danger-soft); color: var(--danger); }
.notice.plain { background: var(--sunken); color: var(--ink-2); }
.flash { max-width: 1200px; margin: 16px auto 0; padding: 0 20px; }

/* Tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 15px; }
th { text-align: left; font-size: 13px; color: var(--muted); font-weight: 700; padding: 10px 14px; background: var(--sunken); }
td { padding: 12px 14px; border-top: 1px solid var(--line); vertical-align: top; }

/* People */
.avatar { width: 48px; height: 48px; border-radius: 999px; background: var(--sunken); color: var(--ink-2); display: flex; align-items: center; justify-content: center; font-weight: 700; flex: none; overflow: hidden; }
.avatar.lg { width: 104px; height: 104px; font-size: 34px; font-family: var(--serif); }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.person-row { display: flex; flex-wrap: wrap; gap: 14px; align-items: center; padding: 14px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; color: var(--ink); text-decoration: none; }
.person-row:hover { border-color: var(--line-strong); color: var(--ink); }
.person-row .meta { flex: 1 1 220px; display: flex; flex-direction: column; gap: 2px; }
dl.facts { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; font-size: 15px; }
dl.facts dt { color: var(--muted); }
dl.facts dd { margin: 0; font-weight: 600; }

/* Tree */
.tree-legend { display: flex; flex-wrap: wrap; gap: 16px; font-size: 14px; color: var(--ink-2); }
.tree-legend span { display: inline-flex; align-items: center; gap: 6px; }
.swatch { width: 14px; height: 14px; border-radius: 4px; display: inline-block; }
.tree-scroll { overflow-x: auto; padding: 8px 0; }
.generations { display: flex; flex-direction: column; gap: 18px; min-width: min-content; }
.gen { display: flex; flex-direction: column; gap: 8px; }
.gen-label { font-family: var(--serif); font-size: 12px; letter-spacing: 0.2em; text-transform: uppercase; color: var(--muted); }
.gen-row { display: flex; gap: 18px; flex-wrap: wrap; }
.family-unit { display: flex; gap: 6px; padding: 6px; border-radius: 12px; background: var(--sunken); }
.leaf { width: 168px; min-height: 64px; padding: 9px 12px; border-radius: 10px; border: 1px solid var(--line-strong); background: #fff; color: var(--ink); text-decoration: none; display: flex; flex-direction: column; justify-content: center; gap: 2px; }
.leaf:hover { border-color: var(--ink); color: var(--ink); }
.leaf strong { font-size: 15px; line-height: 1.2; }
.leaf small { font-size: 13px; color: var(--muted); }
.leaf.me { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.leaf.me small { color: #D9D1C1; }
.leaf.verified { border: 2px solid var(--accent); background: var(--accent-soft); }
.leaf.pending { border: 2px dashed var(--warn); background: var(--warn-soft); }
.leaf.deceased { background: var(--deceased); }
.leaf.shared { border-style: dotted; }

/* Media */
.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 8px; }
.thumb { position: relative; aspect-ratio: 1 / 1; border-radius: 8px; overflow: hidden; background: var(--sunken); display: block; }
.thumb img, .thumb video { width: 100%; height: 100%; object-fit: cover; }
.thumb .play { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(28,26,23,.35); color: #fff; }
.thumb.pick { outline: 3px solid transparent; }
.thumb input { position: absolute; top: 8px; left: 8px; }
.dropzone { padding: 28px; border: 2px dashed var(--line-strong); border-radius: 12px; text-align: center; color: var(--muted); background: var(--surface); }
.media-full { max-height: 70vh; width: auto; margin: 0 auto; border-radius: 10px; }
.meter { height: 12px; border-radius: 999px; background: var(--sunken); display: flex; overflow: hidden; }

/* Posts and notes */
.post { display: flex; flex-direction: column; gap: 10px; }
.post + .post { border-top: 1px solid var(--line); padding-top: 16px; }
.post-body { white-space: pre-wrap; font-size: 17px; line-height: 1.6; }
.post-media { max-width: 360px; border-radius: 10px; }

/* Landing */
.landing { max-width: 1200px; margin: 0 auto; padding: 48px 20px; display: flex; flex-wrap: wrap; gap: 48px; align-items: center; }
.landing-art { flex: 1 1 320px; display: flex; flex-direction: column; align-items: center; gap: 20px; }
.landing-art img { width: min(320px, 70vw); height: auto; }
.wordmark { font-family: var(--serif); font-size: clamp(22px, 3vw, 30px); letter-spacing: 0.32em; text-transform: uppercase; padding-left: 0.32em; }
.landing-copy { flex: 999 1 420px; display: flex; flex-direction: column; gap: 20px; }
.glossary { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px; }
.glossary div { padding: 14px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; font-size: 15px; color: var(--ink-2); }
.glossary strong { display: block; font-family: var(--serif); font-size: 17px; color: var(--ink); }

/* Steps */
.steps { display: flex; flex-direction: column; gap: 4px; padding: 0; margin: 0; list-style: none; }
.steps a { display: flex; gap: 12px; align-items: center; padding: 10px 12px; border-radius: 10px; color: var(--ink-2); text-decoration: none; font-weight: 600; }
.steps a[aria-current='step'] { background: var(--accent-soft); color: var(--accent-deep); }
.steps .num { width: 26px; height: 26px; border-radius: 999px; border: 1.5px solid var(--line-strong); display: flex; align-items: center; justify-content: center; font-size: 13px; flex: none; }
.steps a.done .num { background: var(--accent); border-color: var(--accent); color: #fff; }

/* Admin */
.admin .topbar { background: var(--ink); border-color: var(--ink); }
.admin .brand { color: var(--bg); }
.admin .mainnav a { color: #D9D1C1; }
.admin .mainnav a[aria-current='page'] { background: var(--accent); color: #fff; }
.admin .mainnav a:hover { background: #2E2B26; }
.status-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.status-grid .card { padding: 16px 18px; gap: 4px; }
.ok { color: var(--accent); font-weight: 700; }
.bad { color: var(--danger); font-weight: 700; }
.code-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 8px; font-family: ui-monospace, Menlo, monospace; font-size: 16px; }
.code-list span { padding: 10px; background: var(--sunken); border-radius: 8px; text-align: center; }
.mono { font-family: ui-monospace, Menlo, monospace; }

@media (max-width: 640px) {
  .container { padding: 24px 16px 48px; }
  .card { padding: 18px; }
  .brand span { font-size: 14px; letter-spacing: 0.24em; }
  .searchlink { flex: 1 1 100%; order: 3; }
}
