/* styles.css — Acorn. Oak-leaf green on warm paper; acorn amber for warmth.
   Light and dark are both chosen (not an automatic flip). No web fonts:
   nothing is loaded from anywhere else. */

:root {
  color-scheme: light;
  --bg: #F7F4EE;
  --surface: #FFFFFF;
  --surface-2: #F1ECE3;
  --ink: #1F2A22;
  --ink-2: #4E5A52;
  --muted: #6F7A73;
  --line: #E3DCCF;
  --accent: #2F6B3F;
  --accent-hover: #285C36;
  --on-accent: #FFFFFF;
  --accent-ink: #2F6B3F;
  --accent-soft: #E3EEE5;
  --amber: #B8712A;
  --amber-soft: #F7E9D6;
  --danger: #B3261E;
  --danger-soft: #FBE9E7;
  --warn: #8A5A00;
  --shadow: 0 1px 2px rgba(31, 42, 34, .06), 0 4px 16px rgba(31, 42, 34, .06);
  --shadow-lg: 0 10px 40px rgba(31, 42, 34, .18);
  --radius: 14px;
  --link: #A9A08F;
  --male: #DCE8F5;
  --female: #F6E0E6;
  --unknown: #E8E4DB;
  /* chart series — the dataviz reference palette, light steps */
  --series-1: #2a78d6; --series-2: #eb6834; --series-3: #1baf7a; --series-4: #eda100;
  --series-5: #e87ba4; --series-6: #008300; --series-7: #6250d6; --series-8: #e34948;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #121614; --surface: #1A201C; --surface-2: #222A25; --ink: #ECEFEA; --ink-2: #BAC2BC; --muted: #8E978F;
    --line: #2F3933; --accent: #6DBA80; --accent-hover: #80C891; --on-accent: #0D1A11; --accent-ink: #86CC97; --accent-soft: #1F3326;
    --amber: #E3A55C; --amber-soft: #3A2B19; --danger: #F2847B; --danger-soft: #3A1E1C; --warn: #E3B35C;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 16px rgba(0,0,0,.25); --shadow-lg: 0 10px 40px rgba(0,0,0,.5);
    --link: #56605A; --male: #23303D; --female: #3A2830; --unknown: #2B302C;
    --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70; --series-4: #c98500;
    --series-5: #d55181; --series-6: #008300; --series-7: #9085e9; --series-8: #e66767;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--ink);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased; -webkit-text-size-adjust: 100%;
}
h1, h2, h3 { line-height: 1.25; margin: 0 0 .4em; letter-spacing: -.01em; }
h1 { font-size: 1.55rem; font-weight: 700; }
h2 { font-size: 1.15rem; font-weight: 650; }
h3 { font-size: .95rem; font-weight: 650; color: var(--ink-2); text-transform: none; }
p { margin: 0 0 .8em; }
a { color: var(--accent-ink); text-decoration: none; }
a:hover { text-decoration: underline; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.pad { padding: 16px; }
.pre { white-space: pre-line; }
[hidden] { display: none !important; }
:focus-visible { outline: 2.5px solid var(--accent-ink); outline-offset: 2px; border-radius: 6px; }

.icon { width: 20px; height: 20px; flex: none; }
.icon.sm { width: 15px; height: 15px; vertical-align: -2px; }

/* --- buttons ------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 9px 16px; border-radius: 10px; border: 1px solid transparent;
  font: inherit; font-weight: 600; cursor: pointer; text-decoration: none !important;
  background: var(--surface-2); color: var(--ink); transition: background .15s, transform .05s;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.primary { background: var(--accent); color: var(--on-accent); }
.btn.primary:hover { background: var(--accent-hover); }
.btn.ghost { background: transparent; border-color: var(--line); color: var(--ink); }
.btn.ghost:hover { background: var(--surface-2); }
.btn.danger { background: var(--danger); color: #fff; }
.btn.danger-text { color: var(--danger); }
.btn.sm { padding: 6px 11px; font-size: .88rem; border-radius: 9px; }
.btn.sm .icon { width: 17px; height: 17px; }
.btn.block { width: 100%; padding: 12px 16px; }
.icon-btn {
  display: inline-grid; place-items: center; width: 38px; height: 38px; border-radius: 10px;
  border: 0; background: transparent; color: var(--ink-2); cursor: pointer; flex: none;
}
.icon-btn:hover { background: var(--surface-2); color: var(--ink); text-decoration: none; }
.icon-btn.sm { width: 30px; height: 30px; }
.icon-btn.sm .icon { width: 16px; height: 16px; }
.row-btns { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; margin: 12px 0; }

/* --- forms ----------------------------------------------------------------- */
.field { margin-bottom: 14px; min-width: 0; }
.field label { display: block; font-size: .82rem; font-weight: 600; color: var(--ink-2); margin-bottom: 5px; }
.hint { font-size: .8rem; color: var(--muted); margin-top: 4px; }
input[type=text], input[type=password], input[type=search], input[type=email], input[type=tel], input[type=date], input:not([type]), select, textarea {
  width: 100%; font: inherit; color: var(--ink); background: var(--surface);
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; min-height: 42px;
}
textarea { resize: vertical; min-height: 70px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent-ink); box-shadow: 0 0 0 3px var(--accent-soft); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.grid2.tight { gap: 8px; }
.check { display: flex; gap: 10px; align-items: flex-start; margin: 6px 0 14px; cursor: pointer; font-size: .92rem; }
.check input { width: 18px; height: 18px; margin-top: 2px; accent-color: var(--accent); flex: none; }
.check.inline { margin: 0; align-items: center; }
.form-error { color: var(--danger); font-size: .9rem; min-height: 1.2em; margin-bottom: 8px; }
.date-row-input { display: flex; gap: 6px; }
.date-row-input input[type=text] { flex: 1; }
.date-pick { width: 44px !important; flex: none; padding: 0 !important; color: transparent !important; cursor: pointer; }
.date-pick::-webkit-datetime-edit { display: none; }
.date-pick::-webkit-calendar-picker-indicator { margin: 0 auto; cursor: pointer; opacity: .75; }
details.more-fields { border-top: 1px solid var(--line); padding-top: 10px; }
details summary { cursor: pointer; font-weight: 600; color: var(--accent-ink); margin-bottom: 10px; }

.meter { display: flex; align-items: center; gap: 10px; margin: -6px 0 14px; }
.meter-bar { flex: 1; height: 6px; border-radius: 3px; background: var(--surface-2); position: relative; overflow: hidden; }
.meter-bar::after { content: ""; position: absolute; inset: 0 auto 0 0; width: 0; border-radius: 3px; transition: width .2s, background .2s; }
.meter[data-score="1"] .meter-bar::after { width: 20%; background: var(--danger); }
.meter[data-score="2"] .meter-bar::after { width: 50%; background: var(--amber); }
.meter[data-score="3"] .meter-bar::after { width: 75%; background: var(--accent); }
.meter[data-score="4"] .meter-bar::after { width: 100%; background: var(--accent); }
.meter-label { font-size: .8rem; color: var(--muted); min-width: 60px; text-align: right; }

/* --- gate screens (signed out, locked, setup) ------------------------------ */
.gate { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 32px 16px; gap: 18px; }
.gate-logo { display: flex; align-items: center; gap: 12px; font-size: 1.6rem; font-weight: 750; letter-spacing: -.02em; }
.gate-logo img { width: 52px; height: 52px; border-radius: 13px; box-shadow: var(--shadow); }
.gate-card { width: 100%; max-width: 420px; background: var(--surface); border: 1px solid var(--line); border-radius: 20px; padding: 28px 24px; box-shadow: var(--shadow); text-align: left; }
.gate-card.wide { max-width: 560px; }
.gate-card h1 { font-size: 1.35rem; }
.gate-card .small { margin-top: 12px; text-align: center; }
.lock-badge { width: 54px; height: 54px; border-radius: 50%; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent-ink); margin: -2px auto 14px; }
.lock-badge .icon { width: 26px; height: 26px; }
.gate-card > h1, .gate-card > .lock-badge + h1 { text-align: center; }
.spinner-row { display: flex; align-items: center; gap: 10px; color: var(--muted); justify-content: center; padding: 18px; }
.spinner { width: 18px; height: 18px; border-radius: 50%; border: 2.5px solid currentColor; border-right-color: transparent; animation: spin .8s linear infinite; display: inline-block; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }
.recovery-code { font: 600 1.15rem/1.6 ui-monospace, "SF Mono", Menlo, Consolas, monospace; letter-spacing: .06em; text-align: center; padding: 16px; background: var(--amber-soft); border: 1px dashed var(--amber); border-radius: 12px; word-break: break-all; user-select: all; margin: 12px 0; }
.print-sheet { display: none; }
@media print {
  body.print-recovery > *:not(.print-sheet) { display: none !important; }
  .print-sheet { display: block; padding: 40px; color: #000; }
  .print-sheet .recovery-code { background: none; border: 2px solid #000; font-size: 22px; }
}

/* --- shell ------------------------------------------------------------------- */
.shell { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px;
  padding: 10px 20px; padding-top: max(10px, env(safe-area-inset-top));
  background: color-mix(in srgb, var(--bg) 86%, transparent); backdrop-filter: saturate(1.4) blur(14px); -webkit-backdrop-filter: saturate(1.4) blur(14px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); font-weight: 700; text-decoration: none !important; min-width: 0; }
.brand-mark { width: 32px; height: 32px; border-radius: 9px; flex: none; }
.brand-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 1.05rem; }
.top-nav { display: flex; gap: 4px; margin: 0 auto; }
.top-actions { display: flex; gap: 2px; margin-left: auto; }
.top-nav ~ .top-actions { margin-left: 0; }
.nav-item { display: flex; align-items: center; gap: 7px; padding: 7px 13px; border-radius: 10px; color: var(--ink-2); font-weight: 600; text-decoration: none !important; border: 0; background: none; font: inherit; cursor: pointer; }
.nav-item:hover { background: var(--surface-2); color: var(--ink); }
.nav-item.active { background: var(--accent-soft); color: var(--accent-ink); }
.bottom-nav { display: none; }
.content { flex: 1; width: 100%; max-width: 1180px; margin: 0 auto; padding: 22px 20px 48px; }
.update-bar { display: flex; align-items: center; justify-content: center; gap: 12px; padding: 8px 16px; background: var(--amber-soft); color: var(--ink); font-weight: 600; font-size: .9rem; }

@media (max-width: 860px) {
  .top-nav { display: none; }
  .topbar { padding: 8px 12px; padding-top: max(8px, env(safe-area-inset-top)); }
  .content { padding: 16px 16px calc(84px + env(safe-area-inset-bottom)); }
  .bottom-nav {
    display: flex; position: fixed; z-index: 20; left: 0; right: 0; bottom: 0; justify-content: space-around;
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
    background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
    border-top: 1px solid var(--line);
  }
  .bottom-nav .nav-item { flex-direction: column; gap: 2px; padding: 5px 6px; font-size: .7rem; flex: 1; min-width: 0; border-radius: 10px; }
  .bottom-nav .nav-item .icon { width: 23px; height: 23px; }
  .bottom-nav .nav-item.active { background: none; }
  .hide-sm { display: none; }
  h1 { font-size: 1.35rem; }
}

/* --- view head / toolbar ------------------------------------------------------- */
.view-head { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.vh-title { flex: 1; min-width: 0; }
.vh-title h1 { margin: 0; overflow-wrap: anywhere; }
.vh-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.toolbar { display: flex; gap: 10px; margin-bottom: 14px; }
.toolbar select { width: auto; }
.search-wrap { position: relative; flex: 1; }
.search-wrap .icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.search-wrap input { padding-left: 40px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); min-width: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.card-head h3 { margin: 0; }
.pill { display: inline-block; font-size: .72rem; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: var(--accent-soft); color: var(--accent-ink); margin-left: 8px; vertical-align: 1px; }

.empty { text-align: center; padding: 56px 16px; max-width: 460px; margin: 0 auto; }
.empty-icon { width: 64px; height: 64px; margin: 0 auto 14px; border-radius: 50%; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent-ink); }
.empty-icon .icon { width: 30px; height: 30px; }
.empty p { color: var(--muted); }

/* --- avatars ----------------------------------------------------------------- */
.avatar { border-radius: 50%; display: grid; place-items: center; overflow: hidden; flex: none; background: var(--unknown); color: var(--ink-2); font-weight: 700; letter-spacing: .02em; }
.avatar.sex-M { background: var(--male); }
.avatar.sex-F { background: var(--female); }
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.avatar.xs { width: 24px; height: 24px; font-size: .62rem; }
.avatar.sm { width: 38px; height: 38px; font-size: .8rem; }
.avatar.md { width: 46px; height: 46px; font-size: .9rem; }
.avatar.xl { width: 104px; height: 104px; font-size: 1.9rem; box-shadow: 0 0 0 4px var(--surface), var(--shadow); }

/* --- tree chart -------------------------------------------------------------- */
.today-strip { display: flex; align-items: center; gap: 10px; padding: 10px 14px; margin-bottom: 14px; border-radius: 12px; background: var(--amber-soft); color: var(--ink); font-weight: 600; font-size: .92rem; text-decoration: none !important; }
.today-strip .icon { color: var(--amber); }
.chart-wrap { overflow: auto; -webkit-overflow-scrolling: touch; background: var(--surface); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); padding: 28px 12px; scrollbar-width: thin; }
.chart { position: relative; display: flex; flex-direction: column; gap: 44px; min-width: 100%; width: max-content; margin: 0 auto; padding: 0 12px; }
.chart .links { position: absolute; inset: 0; pointer-events: none; overflow: visible; }
.chart .link { fill: none; stroke: var(--link); stroke-width: 2; stroke-linejoin: round; }
.chart .partner-link { stroke: var(--amber); stroke-width: 2.5; }
.chart .partner-link.ended { stroke-dasharray: 5 5; }
.chart .partner-link.unlinked { stroke: var(--link); }
.gen { display: flex; justify-content: center; gap: 36px; position: relative; }
.group { display: flex; gap: 14px; }
.pcard {
  position: relative; z-index: 1; display: flex; align-items: center; gap: 10px; width: 176px; padding: 9px 12px 9px 9px;
  background: var(--surface); border: 1.5px solid var(--line); border-radius: 14px; cursor: pointer; text-align: left;
  font: inherit; color: var(--ink); box-shadow: var(--shadow); transition: transform .12s, border-color .12s, box-shadow .12s;
}
.pcard:hover { transform: translateY(-2px); border-color: var(--accent-ink); }
.pcard.focus { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft), var(--shadow); width: 196px; }
.pcard.focus .pc-name { font-size: 1rem; }
.pcard.sib { opacity: .88; width: 160px; }
.pcard.deceased .avatar { filter: grayscale(.6); }
.pcard.ghost { border-style: dashed; background: transparent; box-shadow: none; color: var(--muted); width: 150px; }
.pcard.ghost:hover { color: var(--accent-ink); border-color: var(--accent-ink); }
.ghost-plus { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); flex: none; }
.pc-text { display: flex; flex-direction: column; min-width: 0; }
.pc-name { font-weight: 650; font-size: .92rem; line-height: 1.25; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.pc-years { font-size: .78rem; color: var(--muted); }
.chart-hint { font-size: .82rem; text-align: center; margin-top: 10px; }
@media (max-width: 860px) {
  .chart-wrap { margin: 0 -16px; border-radius: 0; border-left: 0; border-right: 0; padding: 22px 4px; }
  .pcard { width: 148px; padding: 7px 9px 7px 7px; gap: 8px; }
  .pcard.focus { width: 164px; }
  .pcard.sib { width: 136px; }
  .pcard.ghost { width: 126px; }
  .pcard .avatar.sm { width: 32px; height: 32px; }
  .gen { gap: 22px; }
  .group { gap: 10px; }
  .chart { gap: 36px; }
}

/* --- people list ------------------------------------------------------------- */
.plist { display: flex; flex-direction: column; gap: 2px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 6px; box-shadow: var(--shadow); }
.prow { display: flex; align-items: center; gap: 12px; padding: 9px 10px; border-radius: 10px; color: var(--ink); text-decoration: none !important; border: 0; background: none; font: inherit; text-align: left; width: 100%; cursor: pointer; }
.prow:hover { background: var(--surface-2); }
.prow.picked { background: var(--accent-soft); outline: 2px solid var(--accent); }
.prow.deceased .avatar { filter: grayscale(.6); }
.prow-text { min-width: 0; flex: 1; }
.prow-name { font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.prow-sub { font-size: .83rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.picklist { max-height: 46vh; overflow: auto; margin-top: 10px; display: flex; flex-direction: column; gap: 2px; }

/* --- person page -------------------------------------------------------------- */
.person-hero { display: flex; align-items: center; gap: 20px; margin: 4px 0 22px; }
.person-hero h1 { margin-bottom: 4px; overflow-wrap: anywhere; }
.person-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; align-items: start; }
.person-grid > .card:nth-child(3) { grid-column: 1 / -1; }
main.content > .card { margin-bottom: 16px; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0 0 16px; }
.facts dt { color: var(--muted); font-size: .88rem; }
.facts dd { margin: 0; overflow-wrap: anywhere; }
.notes { white-space: pre-wrap; background: var(--surface-2); padding: 12px 14px; border-radius: 10px; }
.fam { margin-bottom: 16px; }
.fam:last-child { margin-bottom: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip-wrap { display: inline-flex; align-items: center; background: var(--surface-2); border-radius: 999px; }
.chip { display: inline-flex; align-items: center; gap: 7px; padding: 4px 12px 4px 4px; border-radius: 999px; color: var(--ink); text-decoration: none !important; font-weight: 600; font-size: .9rem; border: 0; background: var(--surface-2); font: inherit; cursor: pointer; }
.chip:hover { background: var(--accent-soft); }
.chip-sub { font-weight: 400; color: var(--muted); font-size: .8rem; }
.chip.add { padding: 5px 12px; color: var(--accent-ink); background: transparent; border: 1.5px dashed var(--line); font-size: .88rem; }
.chip.add .icon { width: 15px; height: 15px; }
.chip.toggle { padding: 5px 12px 5px 8px; border: 1.5px solid var(--line); background: var(--surface); }
.chip.toggle.on { border-color: var(--accent); background: var(--accent-soft); }
.chip-x { width: 26px; height: 26px; border: 0; background: none; color: var(--muted); border-radius: 50%; display: grid; place-items: center; cursor: pointer; margin-right: 3px; }
.chip-x:hover { color: var(--danger); background: var(--danger-soft); }
.chip-x.edit:hover { color: var(--accent-ink); background: var(--accent-soft); }
.chip-x .icon { width: 14px; height: 14px; }
.chip-wrap.partner > .chip-wrap { background: none; }
.photos { display: flex; flex-wrap: wrap; gap: 8px; }
.thumb { width: 86px; height: 86px; border-radius: 12px; overflow: hidden; border: 0; padding: 0; background: var(--surface-2); cursor: pointer; display: grid; place-items: center; color: var(--muted); }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb.add { border: 1.5px dashed var(--line); background: transparent; }
.thumb.add:hover { color: var(--accent-ink); border-color: var(--accent-ink); }
.viewer { display: grid; place-items: center; }
.viewer img { max-width: 100%; max-height: 70vh; border-radius: 10px; }
.danger-zone { display: flex; gap: 10px; flex-wrap: wrap; justify-content: flex-end; border-top: 1px solid var(--line); padding-top: 16px; margin-top: 8px; }
@media (max-width: 860px) {
  .person-grid { grid-template-columns: 1fr; }
  .person-hero { flex-direction: column; text-align: center; gap: 12px; }
  .danger-zone { justify-content: center; }
}

/* timeline */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: grid; grid-template-columns: 130px 1fr auto; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); align-items: start; }
.timeline li:first-child { border-top: 0; }
.tl-date { color: var(--amber); font-weight: 650; font-size: .88rem; }
.tl-body p { margin: 4px 0 0; color: var(--ink-2); white-space: pre-wrap; }
@media (max-width: 560px) { .timeline li { grid-template-columns: 1fr auto; } .tl-date { grid-column: 1 / -1; } }

/* --- growth ---------------------------------------------------------------------- */
.stat-row { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.stat { background: var(--surface-2); border-radius: 12px; padding: 10px 14px; min-width: 120px; }
.stat-v { font-size: 1.2rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat-l { font-size: .78rem; color: var(--muted); }
.charts { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin: 14px 0; }
@media (max-width: 860px) { .charts { grid-template-columns: 1fr; } }
.chart-fig { margin: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 14px 10px; min-width: 0; }
.chart-title { font-weight: 650; margin-bottom: 6px; }
.chart-box { position: relative; }
svg.chart { width: 100%; height: auto; display: block; overflow: visible; font-size: 15px; }
svg.chart .grid line { stroke: var(--line); stroke-width: 1; }
svg.chart .grid .baseline { stroke: var(--muted); }
svg.chart .tick { fill: var(--muted); font-size: 15px; font-variant-numeric: tabular-nums; }
svg.chart .line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
svg.chart .dot { stroke: var(--surface); stroke-width: 2; }
svg.chart .end-label { fill: var(--ink-2); font-size: 15px; font-weight: 600; }
svg.chart .hair { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 3 3; }
svg.chart .ring { fill: none; stroke-width: 2.5; }
svg.chart .hit { fill: transparent; cursor: crosshair; outline: none; }
.chart-tip { position: absolute; top: 6px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; box-shadow: var(--shadow-lg); font-size: .82rem; pointer-events: none; white-space: nowrap; z-index: 2; }
.tip-head { color: var(--muted); font-size: .76rem; margin-bottom: 3px; }
.tip-row { display: flex; align-items: center; gap: 6px; }
.tip-key { display: inline-block; width: 14px; height: 3px; border-radius: 2px; background: var(--series-1); flex: none; }
.tip-key[data-slot="2"] { background: var(--series-2); } .tip-key[data-slot="3"] { background: var(--series-3); }
.tip-key[data-slot="4"] { background: var(--series-4); } .tip-key[data-slot="5"] { background: var(--series-5); }
.tip-key[data-slot="6"] { background: var(--series-6); } .tip-key[data-slot="7"] { background: var(--series-7); }
.tip-key[data-slot="8"] { background: var(--series-8); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: .82rem; color: var(--ink-2); margin-top: 6px; }
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.measure-table { margin-top: 6px; }
.measure-table table { width: 100%; border-collapse: collapse; font-size: .88rem; font-variant-numeric: tabular-nums; }
.measure-table th, .measure-table td { text-align: left; padding: 7px 8px; border-top: 1px solid var(--line); }
.measure-table th { color: var(--muted); font-weight: 600; border-top: 0; }
.measure-table { overflow-x: auto; }
.growth-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.growth-card { display: flex; align-items: center; gap: 12px; color: var(--ink); text-decoration: none !important; }
.growth-card:hover { border-color: var(--accent-ink); }
main.content > .chips { margin-bottom: 4px; }
.card .chart-fig { border: 0; padding: 0; background: none; }

/* --- dates -------------------------------------------------------------------------- */
.date-group { margin-bottom: 22px; }
.date-group h3 { text-transform: uppercase; letter-spacing: .06em; font-size: .75rem; color: var(--muted); margin-bottom: 8px; }
.date-row { display: flex; align-items: center; gap: 14px; padding: 10px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; margin-bottom: 8px; color: var(--ink); text-decoration: none !important; box-shadow: var(--shadow); }
.date-row:hover { border-color: var(--accent-ink); }
.date-row.today { border-color: var(--amber); box-shadow: 0 0 0 3px var(--amber-soft), var(--shadow); }
.date-badge { width: 50px; flex: none; text-align: center; border-radius: 10px; overflow: hidden; border: 1px solid var(--line); }
.date-badge .dm { display: block; background: var(--accent); color: var(--on-accent); font-size: .68rem; font-weight: 700; text-transform: uppercase; padding: 2px 0; }
.date-badge .dd { display: block; font-size: 1.25rem; font-weight: 700; padding: 2px 0 3px; }
.date-row.anniversary .date-badge .dm { background: var(--amber); color: #fff; }
.date-row.remember-birth .date-badge .dm, .date-row.remember-death .date-badge .dm { background: var(--muted); color: var(--surface); }
.avatars { display: flex; }
.avatars .avatar + .avatar { margin-left: -10px; box-shadow: 0 0 0 2px var(--surface); }
.date-kind { color: var(--muted); }
.date-row.anniversary .date-kind { color: var(--amber); }

/* --- settings --------------------------------------------------------------------- */
.settings { display: grid; gap: 16px; max-width: 760px; }
.settings-card h2 { margin-bottom: 8px; }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 0; border-top: 1px solid var(--line); }
.settings-card h2 + .set-row, .settings-card p + .set-row { border-top: 0; }
.set-label { font-weight: 600; }
.set-sub { font-size: .84rem; color: var(--muted); }
.set-ctrl { display: flex; gap: 8px; align-items: center; flex: none; max-width: 60%; }
.set-ctrl input, .set-ctrl select { width: auto; min-width: 0; }
@media (max-width: 600px) { .set-row { flex-direction: column; align-items: stretch; } .set-ctrl { max-width: none; } .set-ctrl input { flex: 1; } }
.about { padding-left: 1.1em; color: var(--ink-2); }
.about li { margin-bottom: 6px; }
.release ul { padding-left: 1.1em; }
.release li { margin-bottom: 5px; }
.release + .release { border-top: 1px solid var(--line); padding-top: 12px; margin-top: 12px; }
.history { list-style: none; margin: 0; padding: 0; }
.history li { padding: 12px 0; border-top: 1px solid var(--line); display: grid; gap: 6px; justify-items: start; }
.history li:first-child { border-top: 0; }
.audit-table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.audit-table td { padding: 8px 6px; border-top: 1px solid var(--line); vertical-align: top; }
.audit-table td:first-child { white-space: nowrap; width: 1%; }
.warnings { color: var(--warn); font-size: .88rem; }

/* --- modals & toasts ------------------------------------------------------------------- */
.backdrop { position: fixed; inset: 0; z-index: 50; background: rgba(15, 20, 17, .45); display: grid; place-items: center; padding: 16px; animation: fade .15s; }
@keyframes fade { from { opacity: 0; } }
.modal { width: 100%; max-width: 460px; max-height: calc(100dvh - 32px); display: flex; flex-direction: column; background: var(--surface); border-radius: 18px; box-shadow: var(--shadow-lg); animation: pop .18s cubic-bezier(.2, .9, .3, 1.2); }
.modal.wide { max-width: 640px; }
@keyframes pop { from { transform: translateY(8px) scale(.98); opacity: 0; } }
.modal-head { display: flex; align-items: center; gap: 10px; padding: 16px 18px 6px; }
.modal-head h2 { flex: 1; margin: 0; font-size: 1.1rem; }
.modal-body { padding: 10px 18px; overflow: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 18px 16px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.modal-foot .btn.danger { margin-right: auto; }
@media (max-width: 600px) {
  .backdrop { place-items: end center; padding: 0; }
  .modal, .modal.wide { max-width: none; border-radius: 18px 18px 0 0; max-height: 92dvh; padding-bottom: env(safe-area-inset-bottom); }
  .grid2 { grid-template-columns: 1fr; }
}
.tabs { display: flex; gap: 4px; background: var(--surface-2); padding: 4px; border-radius: 11px; margin-bottom: 14px; }
.tab { flex: 1; border: 0; background: none; font: inherit; font-weight: 600; padding: 7px; border-radius: 8px; color: var(--ink-2); cursor: pointer; }
.tab.active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.toasts { position: fixed; z-index: 60; left: 50%; bottom: calc(92px + env(safe-area-inset-bottom)); transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; align-items: center; width: max-content; max-width: calc(100vw - 32px); pointer-events: none; }
@media (min-width: 861px) { .toasts { bottom: 28px; } }
.toast { background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 12px; box-shadow: var(--shadow-lg); font-weight: 550; font-size: .92rem; animation: pop .2s; transition: opacity .3s; }
.toast.error { background: var(--danger); color: #fff; }
.toast.warn { background: var(--amber); color: #fff; }
.toast.out { opacity: 0; }

/* --- life timeline, stories, facts (0.1.1) ---------------------------------- */
.timeline .tl-body { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 8px; }
.timeline .tl-body p { flex-basis: 100%; }
.tl-icon { color: var(--muted); display: inline-grid; place-items: center; align-self: center; }
.tl-icon .icon { width: 16px; height: 16px; }
.tl-age { color: var(--muted); font-weight: 400; }
.tl-family-birth .tl-body a, .tl-family-death .tl-body a { color: var(--ink-2); }
.tl-marriage .tl-icon, .tl-birth .tl-icon { color: var(--amber); }
.stories { display: grid; gap: 12px; }
.story { border-left: 3px solid var(--amber); padding: 4px 0 4px 14px; }
.story-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.story-head .icon-btn { margin-left: auto; }
.story-body { white-space: pre-wrap; margin: 6px 0 8px; color: var(--ink-2); }
.kind-pill { font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; padding: 2px 8px; border-radius: 999px; background: var(--amber-soft); color: var(--amber); }
.kind-pill.k-recipe { background: var(--accent-soft); color: var(--accent-ink); }
.kind-pill.k-heirloom { background: var(--surface-2); color: var(--ink-2); }
.chips.small .chip { font-size: .8rem; }
.plist.compact { box-shadow: none; margin-bottom: 12px; }
.stat-row.big { margin-bottom: 16px; }
.stat-row.big .stat { flex: 1 1 150px; }
.facts-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.fact-people { display: grid; gap: 8px; }
.fact-person { display: flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none !important; }
.tally { margin: 0; padding: 0; list-style: none; counter-reset: t; }
.tally li { display: flex; justify-content: space-between; padding: 5px 0; border-top: 1px solid var(--line); }
.tally li:first-child { border-top: 0; }

.reminder-prefs { padding: 6px 0 4px; border-top: 1px solid var(--line); margin-top: 4px; }
.reminder-prefs .check { margin: 8px 0; }
.reminder-prefs input:disabled + span { color: var(--muted); }

/* --- fan chart (0.1.2) ------------------------------------------------------------ */
:root {
  --fan-p1: #EBC89A; --fan-p2: #F1D6B2; --fan-p3: #F5E1C7; --fan-p4: #F8EAD8; --fan-p5: #FAF1E6; --fan-p6: #FCF7F0;
  --fan-m1: #B9DABF; --fan-m2: #CAE3CE; --fan-m3: #D8EBDB; --fan-m4: #E3F0E5; --fan-m5: #ECF5EE; --fan-m6: #F4F9F5;
  --fan-ink: #1F2A22; --fan-years: #6F7A73; --fan-stroke: #FFFFFF;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --fan-p1: #6B4B27; --fan-p2: #5C4122; --fan-p3: #4D371E; --fan-p4: #402E1A; --fan-p5: #352717; --fan-p6: #2B2114;
    --fan-m1: #2F5A3A; --fan-m2: #294F33; --fan-m3: #24442C; --fan-m4: #1F3A26; --fan-m5: #1B3221; --fan-m6: #182B1D;
    --fan-ink: #ECEFEA; --fan-years: #AAB3AC; --fan-stroke: #121614;
  }
}
.fan-sheet { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 18px 12px 8px; box-shadow: var(--shadow); }
.print-title { display: none; }
svg.fan { width: 100%; height: auto; display: block; max-height: 78vh; }
.fan-seg, .fan-centre, .fan-empty { stroke: var(--fan-stroke); stroke-width: 2; }
.fan-seg { cursor: pointer; transition: filter .12s; }
.fan-seg:hover, .fan-seg:focus-visible { filter: brightness(1.06) saturate(1.2); outline: none; }
.fan-seg.p1 { fill: var(--fan-p1); } .fan-seg.p2 { fill: var(--fan-p2); } .fan-seg.p3 { fill: var(--fan-p3); }
.fan-seg.p4 { fill: var(--fan-p4); } .fan-seg.p5 { fill: var(--fan-p5); } .fan-seg.p6 { fill: var(--fan-p6); }
.fan-seg.m1 { fill: var(--fan-m1); } .fan-seg.m2 { fill: var(--fan-m2); } .fan-seg.m3 { fill: var(--fan-m3); }
.fan-seg.m4 { fill: var(--fan-m4); } .fan-seg.m5 { fill: var(--fan-m5); } .fan-seg.m6 { fill: var(--fan-m6); }
.fan-centre { fill: var(--accent); cursor: pointer; }
.fan-empty { fill: transparent; stroke: var(--line); stroke-dasharray: 4 4; }
.fan-empty.can-add { cursor: copy; }
.fan-empty.can-add:hover { fill: var(--accent-soft); }
.fan-text { pointer-events: none; fill: var(--fan-ink); font-weight: 600; }
.fan-text .yr { font-weight: 400; fill: var(--fan-years); }
.fan-text.on-accent { fill: var(--on-accent); }
.fan-text.on-accent .yr { fill: var(--on-accent); opacity: .85; }
@media print {
  @page { size: landscape; margin: 10mm; }
  body.print-fan { background: #fff; }
  body.print-fan .topbar, body.print-fan .bottom-nav, body.print-fan .update-bar, body.print-fan .view-head, body.print-fan .chart-hint, body.print-fan .toasts { display: none !important; }
  body.print-fan .content { padding: 0; max-width: none; }
  body.print-fan .fan-sheet { border: 0; box-shadow: none; padding: 0; background: #fff; }
  body.print-fan .print-title { display: block; text-align: center; font-size: 16pt; color: #000; margin-bottom: 6mm; }
  body.print-fan svg.fan { max-height: 165mm; }
  body.print-fan {
    --fan-p1: #EBC89A; --fan-p2: #F1D6B2; --fan-p3: #F5E1C7; --fan-p4: #F8EAD8; --fan-p5: #FAF1E6; --fan-p6: #FCF7F0;
    --fan-m1: #B9DABF; --fan-m2: #CAE3CE; --fan-m3: #D8EBDB; --fan-m4: #E3F0E5; --fan-m5: #ECF5EE; --fan-m6: #F4F9F5;
    --fan-ink: #1F2A22; --fan-years: #555; --fan-stroke: #fff; --accent: #2F6B3F; --on-accent: #fff; --line: #ccc;
    -webkit-print-color-adjust: exact; print-color-adjust: exact;
  }
}
.vh-actions select { width: auto; min-height: 36px; padding: 6px 10px; font-size: .9rem; }
@media (max-width: 600px) { .vh-title { flex-basis: 100%; } .vh-actions { width: 100%; } }
