@font-face { font-family: "Literata"; src: url("/fonts/literata-latin-400-normal.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Literata"; src: url("/fonts/literata-latin-400-italic.woff2") format("woff2"); font-weight: 400; font-style: italic; font-display: swap; }
@font-face { font-family: "Literata"; src: url("/fonts/literata-latin-600-normal.woff2") format("woff2"); font-weight: 600; font-display: swap; }
@font-face { font-family: "Atkinson"; src: url("/fonts/atkinson-hyperlegible-latin-400-normal.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Atkinson"; src: url("/fonts/atkinson-hyperlegible-latin-700-normal.woff2") format("woff2"); font-weight: 700; font-display: swap; }

:root {
  --paper: #F5F6F2;
  --surface: #FFFFFF;
  --ink: #1D2A2E;
  --muted: #5B696B;
  --creek: #2E6766;
  --creek-dark: #1F4C4B;
  --stone: #D8DCD3;
  --stone-light: #E9ECE5;
  --gold: #A87A12;
  --gold-wash: #F6EED9;
  --danger: #9B2C2C;
  /* One shade per generation, used on tree lines and generation numerals */
  --g0: #1D2A2E; --g1: #1F4C4B; --g2: #2E6766; --g3: #3F8583; --g4: #5E9F9B; --g5: #86B9B3; --g6: #A9CCC6;
  --serif: "Literata", "Iowan Old Style", Georgia, serif;
  --sans: "Atkinson", "Segoe UI", system-ui, sans-serif;
  --radius-s: 4px;
  --radius-m: 8px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 400 1.0625rem/1.55 var(--sans); }
h1, h2, h3 { font-family: var(--serif); font-weight: 600; line-height: 1.2; margin: 0 0 .5em; }
h1 { font-size: 2rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.2rem; }
p { margin: 0 0 1em; max-width: 68ch; }
a { color: var(--creek-dark); text-underline-offset: 2px; }
a:hover { color: var(--creek); }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
[hidden] { display: none !important; }
.skip { position: absolute; left: -999px; top: 0; background: var(--ink); color: #fff; padding: .5rem 1rem; z-index: 10; }
.skip:focus { left: 0; }

/* ---------- masthead ---------- */
.masthead { background: var(--ink); color: var(--paper); }
.masthead-inner { max-width: 1180px; margin: 0 auto; padding: 1.25rem 1.25rem 0; display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 1rem 2rem; }
.brand { color: inherit; text-decoration: none; padding-bottom: 1rem; }
.brand:hover { color: inherit; }
.brand-name { display: block; font-family: var(--serif); font-size: clamp(1.6rem, 3.4vw, 2.3rem); font-weight: 400; letter-spacing: -.01em; }
.brand-sub { display: block; font-family: var(--serif); font-style: italic; color: #B9C6C3; font-size: 1rem; }
.nav { display: flex; flex-wrap: wrap; align-items: flex-end; gap: .25rem; }
.nav a, .nav button.navlink { color: #DDE5E2; text-decoration: none; padding: .6rem .9rem .7rem; border-radius: var(--radius-s) var(--radius-s) 0 0; font-weight: 700; background: none; border: 0; font: inherit; cursor: pointer; }
.nav a:hover { background: rgba(255,255,255,.08); color: #fff; }
.nav a[aria-current="page"] { background: var(--paper); color: var(--ink); }
.nav .edit-state { margin-left: .75rem; padding-bottom: .55rem; display: flex; gap: .5rem; align-items: center; }
.nav .who { color: #B9C6C3; font-size: .9rem; padding: 0 .25rem .7rem .5rem; }

/* ---------- layout ---------- */
main { max-width: 1180px; margin: 0 auto; padding: 2rem 1.25rem 4rem; }
main:focus { outline: none; }
.loading { color: var(--muted); }
.lede { color: var(--muted); }
.narrow { max-width: 30rem; }
.page-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: .5rem 1rem; margin-bottom: 1rem; }
.page-head h1 { margin: 0; }

/* ---------- buttons & forms ---------- */
.btn { display: inline-flex; align-items: center; gap: .4rem; font: 700 1rem/1 var(--sans); padding: .7rem 1.1rem; border-radius: var(--radius-s); border: 1.5px solid var(--creek); background: var(--creek); color: #fff; cursor: pointer; text-decoration: none; min-height: 44px; }
.btn:hover { background: var(--creek-dark); border-color: var(--creek-dark); color: #fff; }
.btn.secondary { background: transparent; color: var(--creek-dark); }
.btn.secondary:hover { background: var(--stone-light); color: var(--creek-dark); }
.btn.danger { background: transparent; border-color: var(--danger); color: var(--danger); }
.btn.danger:hover { background: #FBEDED; }
.btn.small { padding: .45rem .75rem; min-height: 36px; font-size: .92rem; }
.btn.gold { background: var(--gold); border-color: var(--gold); }
.btn.gold:hover { background: #8C650E; border-color: #8C650E; }
.btn.on-dark { background: transparent; border-color: #8FA6A2; color: #EEF3F1; }
.btn.on-dark:hover { background: rgba(255,255,255,.1); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-row { display: flex; flex-wrap: wrap; gap: .6rem; margin-top: 1.25rem; }
.linkish { background: none; border: 0; padding: 0; font: inherit; color: var(--creek-dark); text-decoration: underline; cursor: pointer; }

label { display: block; font-weight: 700; margin-bottom: .3rem; }
.hint { display: block; font-weight: 400; color: var(--muted); font-size: .92rem; }
input[type=text], input[type=email], input[type=password], input[type=tel], input[type=search], input[type=number], select, textarea {
  width: 100%; font: inherit; color: var(--ink); background: var(--surface); border: 1.5px solid #AEB7AF; border-radius: var(--radius-s); padding: .6rem .7rem; min-height: 44px;
}
textarea { min-height: 6rem; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--creek); outline: 3px solid rgba(46,103,102,.25); outline-offset: 0; }
.field { margin-bottom: 1rem; }
.check { display: flex; align-items: center; gap: .5rem; font-weight: 400; }
.check input { width: 1.2rem; height: 1.2rem; accent-color: var(--creek); }
.grid { display: grid; gap: 0 1rem; grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr)); }
fieldset { border: 0; border-top: 1px solid var(--stone); padding: 1rem 0 0; margin: 0 0 1rem; }
legend { font-family: var(--serif); font-weight: 600; font-size: 1.1rem; padding-right: .5rem; }
.form-error { color: var(--danger); font-weight: 700; }
.hp { position: absolute; left: -5000px; }

/* ---------- directory ---------- */
.filters { display: grid; gap: .75rem 1rem; grid-template-columns: minmax(14rem, 2fr) minmax(12rem, 1.4fr) minmax(10rem, 1fr); align-items: end; background: var(--surface); border: 1px solid var(--stone); border-radius: var(--radius-m); padding: 1rem; margin-bottom: 1rem; }
.filters .checks { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: .5rem 1.5rem; }
.filters .field { margin: 0; }
.count { color: var(--muted); margin: 0 0 1.5rem; }
.branch { margin-bottom: 2.25rem; }
.branch-head { display: flex; align-items: baseline; gap: .75rem; border-bottom: 2px solid var(--ink); padding-bottom: .35rem; margin-bottom: .25rem; }
.branch-head h2 { margin: 0; font-size: 1.35rem; }
.branch-head .n { color: var(--muted); }
.dir { width: 100%; border-collapse: collapse; table-layout: fixed; }
.dir col.c-name { width: 33%; } .dir col.c-gen { width: 5rem; } .dir col.c-email { width: 24%; } .dir col.c-phone { width: 9.5rem; }
.dir th { text-align: left; font-size: .9rem; color: var(--muted); font-weight: 700; padding: .5rem .6rem; border-bottom: 1px solid var(--stone); }
.dir th button { background: none; border: 0; font: inherit; color: inherit; cursor: pointer; padding: 0; }
.dir td { padding: .65rem .6rem; border-bottom: 1px solid var(--stone-light); vertical-align: top; }
.dir tr.partner td { background: #FAFBF8; }
.dir tr:hover td { background: var(--stone-light); }
.dir .name a { font-family: var(--serif); font-size: 1.08rem; text-decoration: none; color: var(--ink); }
.dir .name a:hover { text-decoration: underline; }
.dir tr.partner .name { padding-left: 1.6rem; }
.dir .rel { color: var(--muted); font-size: .95rem; }
.dir .contact { font-size: .95rem; overflow-wrap: anywhere; }
.dir .none { color: #98A29F; }

.gen { display: inline-grid; place-items: center; min-width: 1.6rem; height: 1.6rem; padding: 0 .3rem; border-radius: 999px; color: #fff; font: 700 .85rem/1 var(--sans); background: var(--g2); }
.gen[data-g="0"] { background: var(--g0); } .gen[data-g="1"] { background: var(--g1); } .gen[data-g="2"] { background: var(--g2); }
.gen[data-g="3"] { background: var(--g3); } .gen[data-g="4"] { background: var(--g4); color: var(--ink); } .gen[data-g="5"] { background: var(--g5); color: var(--ink); }
.gen[data-g="6"], .gen[data-g="7"], .gen[data-g="8"] { background: var(--g6); color: var(--ink); }
.tag { display: inline-block; font-size: .8rem; font-weight: 700; padding: .1rem .45rem; border-radius: var(--radius-s); border: 1px solid currentColor; margin-left: .35rem; vertical-align: .1em; white-space: nowrap; }
.tag.deceased { color: var(--muted); }
.tag.lineend { color: #6E5B3A; }
.tag.placeholder { color: var(--gold); }
.tag.review { color: var(--danger); }

/* ---------- person page ---------- */
.crumbs { font-size: .95rem; margin-bottom: 1rem; color: var(--muted); }
.person-head { display: flex; gap: 1rem; align-items: flex-start; margin-bottom: 1.5rem; }
.person-head .gen { margin-top: .5rem; min-width: 2.2rem; height: 2.2rem; font-size: 1.05rem; }
.person-head h1 { margin-bottom: .2rem; }
.person-head .rel { font-family: var(--serif); font-style: italic; color: var(--muted); font-size: 1.15rem; }
.cols { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 2rem; }
.panel { background: var(--surface); border: 1px solid var(--stone); border-radius: var(--radius-m); padding: 1.25rem; margin-bottom: 1.25rem; }
.panel h2 { font-size: 1.2rem; display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; }
dl.facts { display: grid; grid-template-columns: max-content 1fr; gap: .5rem 1.25rem; margin: 0; }
dl.facts dt { color: var(--muted); font-weight: 700; }
dl.facts dd { margin: 0; overflow-wrap: anywhere; }
.plist { list-style: none; margin: 0; padding: 0; }
.plist > li { padding: .6rem 0; border-bottom: 1px solid var(--stone-light); }
.plist > li:last-child { border-bottom: 0; }
.plist .sub { color: var(--muted); font-size: .95rem; }
.children-group h3 { font-family: var(--sans); font-size: .95rem; font-weight: 700; color: var(--muted); margin: 1rem 0 .25rem; }
.children-group:first-child h3 { margin-top: 0; }
.edited { color: var(--muted); font-size: .9rem; margin-top: 1rem; }
.review-box { background: #FBF3F3; border-left: 4px solid var(--danger); padding: .75rem 1rem; margin-bottom: 1.25rem; border-radius: 0 var(--radius-s) var(--radius-s) 0; }

/* ---------- family tree ---------- */
.tree-tools { display: flex; flex-wrap: wrap; gap: .6rem 1rem; align-items: end; margin-bottom: 1.5rem; }
.tree-tools .field { margin: 0; min-width: 14rem; }
.tree-legend { display: flex; flex-wrap: wrap; gap: .5rem 1rem; color: var(--muted); font-size: .92rem; margin: -0.5rem 0 1.5rem; }
.tree-legend span { display: inline-flex; align-items: center; gap: .35rem; }
.tree, .tree ul { list-style: none; margin: 0; padding: 0; }
.tree ul { margin-left: 1.1rem; padding-left: 1.4rem; border-left: 3px solid var(--line, var(--g2)); }
.tree li { position: relative; padding: .3rem 0; }
.tree ul > li::before { content: ""; position: absolute; left: -1.4rem; top: 1.45rem; width: 1.1rem; border-top: 3px solid var(--line, var(--g2)); }
.tree ul > li:last-child::after { content: ""; position: absolute; left: calc(-1.4rem - 3px); top: 1.6rem; bottom: 0; border-left: 3px solid var(--paper); }
.node { display: inline-flex; flex-wrap: wrap; align-items: center; gap: .35rem .6rem; background: var(--surface); border: 1px solid var(--stone); border-radius: var(--radius-m); padding: .45rem .7rem; max-width: 100%; }
.node.root { border: 2px solid var(--ink); padding: .7rem 1rem; }
.node.root .pname { font-size: 1.3rem; }
.node.hit { outline: 3px solid var(--gold); background: var(--gold-wash); }
.node .pname { font-family: var(--serif); font-size: 1.05rem; color: var(--ink); text-decoration: none; }
.node .pname:hover { text-decoration: underline; }
.node .partner { color: var(--muted); }
.node .partner a { color: var(--ink); font-family: var(--serif); text-decoration: none; }
.node .partner a:hover { text-decoration: underline; }
.node .ptype { font-size: .85rem; }
.toggle { width: 1.9rem; height: 1.9rem; border-radius: 999px; border: 1.5px solid var(--muted); background: var(--surface); color: var(--ink); font: 700 1rem/1 var(--sans); cursor: pointer; display: inline-grid; place-items: center; padding: 0; }
.toggle:hover { background: var(--stone-light); }
.toggle.spacer { visibility: hidden; }
.with { font-size: .9rem; color: var(--muted); font-style: italic; font-family: var(--serif); padding: .35rem 0 .1rem; }
.tree .kids-count { font-size: .85rem; color: var(--muted); }

/* ---------- admin ---------- */
.tabs { display: flex; flex-wrap: wrap; gap: .25rem; border-bottom: 2px solid var(--ink); margin-bottom: 1.5rem; }
.tabs button { background: none; border: 0; font: 700 1rem var(--sans); padding: .6rem 1rem; cursor: pointer; color: var(--muted); border-radius: var(--radius-s) var(--radius-s) 0 0; }
.tabs button[aria-selected="true"] { background: var(--ink); color: #fff; }
.table-wrap { overflow-x: auto; }
.admin-table { width: 100%; border-collapse: collapse; background: var(--surface); }
.admin-table th, .admin-table td { padding: .6rem .7rem; border-bottom: 1px solid var(--stone-light); text-align: left; vertical-align: top; }
.admin-table th { color: var(--muted); font-size: .9rem; }
.admin-table select { min-height: 36px; padding: .3rem .5rem; width: auto; }
.req { border: 1px solid var(--stone); background: var(--surface); border-radius: var(--radius-m); padding: 1rem; margin-bottom: 1rem; }
.req .msg { white-space: pre-wrap; background: var(--paper); padding: .6rem .8rem; border-radius: var(--radius-s); }

/* ---------- sign-in ---------- */
.signin { max-width: 30rem; margin: 2rem auto; background: var(--surface); border: 1px solid var(--stone); border-radius: var(--radius-m); padding: 2rem; }
.signin h1 { font-size: 1.7rem; }
.code-input { font-size: 1.6rem !important; letter-spacing: .35em; text-align: center; font-family: var(--serif) !important; }

/* ---------- edit banner, modal, toast ---------- */
.edit-banner { background: var(--gold-wash); border: 1px solid #E2CD95; color: #5C430A; border-radius: var(--radius-m); padding: .6rem 1rem; margin-bottom: 1.25rem; display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; }
.modal { border: 0; border-radius: var(--radius-m); padding: 0; max-width: min(40rem, calc(100vw - 2rem)); width: 100%; box-shadow: 0 20px 60px rgba(29,42,46,.35); color: var(--ink); }
.modal::backdrop { background: rgba(29,42,46,.55); }
.modal-body { padding: 1.5rem; max-height: calc(100vh - 4rem); overflow: auto; }
.toast { position: fixed; left: 50%; bottom: 1.5rem; transform: translateX(-50%) translateY(1rem); opacity: 0; visibility: hidden; pointer-events: none; background: var(--ink); color: #fff; padding: .8rem 1.2rem; border-radius: var(--radius-m); font-weight: 700; transition: transform .25s ease, opacity .25s ease, visibility .25s; z-index: 50; max-width: calc(100vw - 2rem); }
.toast.show { transform: translateX(-50%) translateY(0); opacity: 1; visibility: visible; }
.toast.error { background: var(--danger); }

@media (max-width: 860px) {
  .cols { grid-template-columns: 1fr; gap: 0; }
  .filters { grid-template-columns: 1fr; }
  .nav .edit-state { margin-left: 0; }
  /* Directory rows become stacked cards */
  .dir thead { display: none; }
  .dir, .dir tbody, .dir tr, .dir td { display: block; width: 100%; }
  .dir tr { border-bottom: 1px solid var(--stone); padding: .5rem 0; }
  .dir td { border: 0; padding: .15rem .25rem; }
  .dir tr.partner .name { padding-left: .25rem; }
  .dir tr.partner { padding-left: 1rem; border-left: 3px solid var(--stone); }
  .dir td.c-gen { display: none; }
  .tree ul { margin-left: .5rem; padding-left: .9rem; }
  .tree ul > li::before { left: -.9rem; width: .7rem; }
  .tree ul > li:last-child::after { left: calc(-.9rem - 3px); }
}
@media (max-width: 600px) {
  .masthead-inner { padding-top: .9rem; gap: .5rem; }
  .brand { padding-bottom: .4rem; }
  .brand-name { font-size: 1.45rem; }
  .brand-sub { font-size: .88rem; }
  .nav { width: 100%; gap: 0; }
  .nav a { padding: .55rem .7rem .6rem; font-size: .95rem; }
  .nav .edit-state { width: 100%; order: -1; padding: 0 0 .5rem; }
  .page-head h1 { font-size: 1.7rem; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
@media print {
  .masthead nav, .filters, .btn, .btn-row, .toggle, .tree-tools, .edit-banner { display: none !important; }
  body { background: #fff; }
  .masthead { background: #fff; color: #000; }
}
