/* ══════════════════════════════════════════════════════════════
   The Gehmlich Family — warm archival / letterpress heirloom
   Fraunces (display, soft + wonk axes) over Karla (body)
   ══════════════════════════════════════════════════════════════ */

:root {
  /* paper & ink */
  --paper:      #F6F1E7;
  --paper-2:    #EFE7D9;
  --card:       #FBF8F2;
  --ink:        #241F1A;
  --ink-2:      #574C41;
  --ink-3:      #8B7D6D;
  --hair:       #D9CDB8;
  --hair-soft:  #E6DCCA;

  /* accents */
  --rust:       #B4472C;
  --rust-deep:  #8E3520;
  --sage:       #667C5E;
  --gold:       #B8862F;

  --shadow-sm:  0 1px 0 rgba(36,31,26,.05), 0 1px 3px rgba(36,31,26,.06);
  --shadow-md:  0 2px 4px rgba(36,31,26,.05), 0 12px 28px -12px rgba(36,31,26,.22);
  --shadow-lg:  0 30px 70px -28px rgba(36,31,26,.45);

  --serif: "Fraunces", "Iowan Old Style", Georgia, serif;
  --sans:  "Karla", "Helvetica Neue", Helvetica, sans-serif;

  --measure: 62ch;
  --shell: 1180px;
  --r: 3px;

  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper:     #1A1614;
    --paper-2:   #221D1A;
    --card:      #241F1B;
    --ink:       #F1E8DA;
    --ink-2:     #C3B5A2;
    --ink-3:     #8D7F6E;
    --hair:      #3A322C;
    --hair-soft: #2E2723;
    --rust:      #E0785A;
    --rust-deep: #C55E3F;
    --sage:      #93AA88;
    --gold:      #D8A94E;
    --shadow-sm: 0 1px 0 rgba(0,0,0,.3), 0 1px 3px rgba(0,0,0,.35);
    --shadow-md: 0 2px 4px rgba(0,0,0,.3), 0 12px 28px -12px rgba(0,0,0,.6);
    --shadow-lg: 0 30px 70px -28px rgba(0,0,0,.8);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

/* `hidden` must win over any display rule below — the whole app toggles
   screens with el.hidden, and .boot/.gate set display:grid. */
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.6;
  font-variant-numeric: oldstyle-nums;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* paper grain ------------------------------------------------- */
.grain {
  position: fixed; inset: 0; z-index: 9999; pointer-events: none;
  opacity: .5; mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='4' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)' opacity='.32'/%3E%3C/svg%3E");
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .grain { mix-blend-mode: screen; opacity: .16; }
}

::selection { background: var(--rust); color: var(--paper); }

/* type primitives --------------------------------------------- */
.eyebrow {
  margin: 0 0 .5rem;
  font-size: .68rem;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: var(--ink-3);
  font-weight: 600;
}
.rule {
  height: 1px; border: 0; margin: 1.1rem 0;
  background: linear-gradient(90deg, var(--hair) 0%, var(--hair) 42%, transparent 100%);
}
.ink { color: var(--ink); }

/* buttons ------------------------------------------------------ */
.btn {
  --bg: transparent;
  display: inline-flex; align-items: center; gap: .6rem;
  padding: .72rem 1.15rem;
  font: 500 .9rem/1 var(--sans);
  letter-spacing: .015em;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--hair);
  border-radius: var(--r);
  cursor: pointer;
  transition: transform .18s cubic-bezier(.2,.8,.3,1), box-shadow .18s, background .18s, border-color .18s, color .18s;
  box-shadow: var(--shadow-sm);
}
.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow-md); border-color: var(--ink-3); }
.btn:active { transform: translateY(0); box-shadow: var(--shadow-sm); }
.btn:focus-visible { outline: 2px solid var(--rust); outline-offset: 3px; }
.btn--sm { padding: .55rem .9rem; font-size: .82rem; }
.btn--solid { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.btn--solid:hover { background: var(--rust); border-color: var(--rust); color: #FBF8F2; }
.btn--ghost { box-shadow: none; border-color: transparent; color: var(--ink-2); }
.btn--ghost:hover { border-color: var(--hair); background: var(--paper-2); }
.btn--google { background: var(--card); padding: .85rem 1.4rem; font-size: .95rem; }
.btn--google svg { width: 18px; height: 18px; }

/* ══════════════ BOOT ══════════════ */
.boot {
  position: fixed; inset: 0; display: grid; place-items: center;
  background: var(--paper); z-index: 50;
}
.boot__mark {
  font: 300 4rem/1 var(--serif);
  font-variation-settings: "SOFT" 60, "WONK" 1, "opsz" 120;
  color: var(--ink-3);
  animation: breathe 1.9s ease-in-out infinite;
}
@keyframes breathe { 0%,100% { opacity:.25; transform: scale(.97);} 50% { opacity:.75; transform: scale(1);} }

/* ══════════════ GATE ══════════════ */
.gate {
  position: relative; min-height: 100svh;
  display: grid; place-items: center;
  padding: 3rem 1.5rem;
  background:
    radial-gradient(120% 90% at 50% -10%, var(--paper-2) 0%, transparent 60%),
    var(--paper);
  overflow: hidden;
}
.gate__inner { position: relative; z-index: 2; max-width: 34rem; text-align: center; }
.gate__title { margin: 0; line-height: .92; }
.gate__the {
  display: block; font: 400 1rem/1 var(--sans);
  letter-spacing: .38em; text-transform: uppercase;
  color: var(--ink-3); margin-bottom: .7rem; padding-left: .38em;
}
.gate__name {
  display: block;
  font-family: var(--serif);
  font-size: clamp(3rem, 12vw, 5.6rem);
  font-weight: 400;
  font-variation-settings: "SOFT" 45, "WONK" 1, "opsz" 144;
  letter-spacing: -.025em;
  color: var(--ink);
}
.gate__fam {
  display: block; margin-top: .35rem;
  font-family: var(--serif); font-style: italic; font-weight: 300;
  font-size: clamp(1.4rem, 5vw, 2.1rem);
  font-variation-settings: "SOFT" 80, "WONK" 1;
  color: var(--rust);
  letter-spacing: .02em;
}
.gate__title--sm .gate__name { font-size: clamp(2rem, 7vw, 3rem); }
.gate .rule {
  margin: 1.6rem auto;
  width: 4.5rem;
  background: var(--gold);
  opacity: .8;
}
.gate__blurb {
  margin: 0 auto 2rem; max-width: 30rem;
  color: var(--ink-2); font-size: 1.02rem; line-height: 1.72;
}
.gate__note {
  margin: 1.2rem 0 0; font-size: .85rem; color: var(--rust-deep);
  background: color-mix(in oklab, var(--rust) 10%, transparent);
  border: 1px solid color-mix(in oklab, var(--rust) 25%, transparent);
  border-radius: var(--r); padding: .7rem .9rem;
}
.gate__ornament {
  position: absolute; z-index: 1; pointer-events: none;
  width: min(90vmin, 640px); aspect-ratio: 1;
  color: var(--hair); opacity: .5;
  animation: turn 90s linear infinite;
}
.gate__ornament svg { width: 100%; height: 100%; }
@keyframes turn { to { transform: rotate(360deg); } }

.reveal { animation: rise .8s cubic-bezier(.2,.8,.25,1) both; animation-delay: var(--d, 0ms); }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

/* ══════════════ TOPBAR ══════════════ */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 1.5rem;
  padding: .85rem clamp(1rem, 4vw, 2.5rem);
  background: color-mix(in oklab, var(--paper) 88%, transparent);
  backdrop-filter: saturate(1.3) blur(10px);
  border-bottom: 1px solid var(--hair-soft);
}
.wordmark { display: flex; align-items: center; gap: .6rem; text-decoration: none; color: inherit; }
.wordmark__g {
  display: grid; place-items: center;
  width: 34px; height: 34px; flex: none;
  border: 1px solid var(--hair); border-radius: 50%;
  font: 400 1.15rem/1 var(--serif);
  font-variation-settings: "SOFT" 60, "WONK" 1;
  color: var(--rust); background: var(--card);
  padding-bottom: 2px;
}
.wordmark__txt {
  display: flex; flex-direction: column; line-height: 1.05;
  font: 500 .95rem/1 var(--sans); letter-spacing: .01em;
}
.wordmark__txt em {
  font: 300 .68rem/1 var(--serif); font-style: italic;
  color: var(--ink-3); letter-spacing: .18em; text-transform: lowercase;
  margin-top: 3px;
}
.tabs { display: flex; gap: .25rem; margin-inline: auto; }
.tab {
  position: relative; background: none; border: 0; cursor: pointer;
  padding: .5rem .95rem;
  font: 500 .88rem/1 var(--sans); color: var(--ink-3);
  border-radius: var(--r);
  transition: color .2s, background .2s;
}
.tab:hover { color: var(--ink); background: var(--paper-2); }
.tab[aria-selected="true"] { color: var(--ink); }
.tab[aria-selected="true"]::after {
  content: ""; position: absolute; left: .95rem; right: .95rem; bottom: .1rem;
  height: 2px; background: var(--rust); border-radius: 2px;
}
.tab:focus-visible { outline: 2px solid var(--rust); outline-offset: 2px; }

.acct { position: relative; }
.acct__btn {
  display: flex; align-items: center; gap: .55rem;
  background: none; border: 1px solid transparent; border-radius: 100px;
  padding: .25rem .7rem .25rem .25rem; cursor: pointer;
  font: 500 .85rem/1 var(--sans); color: var(--ink-2);
  transition: border-color .2s, background .2s;
}
.acct__btn:hover { border-color: var(--hair); background: var(--card); }
.acct__btn:focus-visible { outline: 2px solid var(--rust); outline-offset: 2px; }
.acct__btn img { border-radius: 50%; background: var(--hair-soft); object-fit: cover; }
.menu {
  position: absolute; right: 0; top: calc(100% + .5rem); z-index: 40;
  min-width: 12rem; padding: .3rem;
  background: var(--card); border: 1px solid var(--hair);
  border-radius: var(--r); box-shadow: var(--shadow-md);
  animation: rise .18s ease-out both;
}
.menu button {
  display: block; width: 100%; text-align: left;
  padding: .55rem .7rem; background: none; border: 0; border-radius: 2px;
  font: 400 .87rem/1.3 var(--sans); color: var(--ink); cursor: pointer;
}
.menu button:hover { background: var(--paper-2); color: var(--rust); }

/* ══════════════ VIEWS ══════════════ */
.view {
  max-width: var(--shell); margin: 0 auto;
  padding: clamp(2rem, 6vw, 4rem) clamp(1rem, 4vw, 2.5rem) 2rem;
  animation: rise .5s cubic-bezier(.2,.8,.25,1) both;
}
.viewhead {
  display: flex; flex-wrap: wrap; gap: 1.25rem;
  align-items: flex-end; justify-content: space-between;
  padding-bottom: 1.4rem; margin-bottom: 2rem;
  border-bottom: 1px solid var(--hair-soft);
}
.viewhead__title {
  margin: 0; font-family: var(--serif); font-weight: 400;
  font-size: clamp(2rem, 5.5vw, 3rem); line-height: 1;
  font-variation-settings: "SOFT" 40, "WONK" 1, "opsz" 100;
  letter-spacing: -.02em;
}
.viewhead__tools { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }

.search {
  display: flex; align-items: center; gap: .55rem;
  padding: .5rem .85rem;
  background: var(--card); border: 1px solid var(--hair); border-radius: var(--r);
  transition: border-color .2s, box-shadow .2s;
}
.search:focus-within { border-color: var(--ink-3); box-shadow: var(--shadow-sm); }
.search svg { width: 15px; height: 15px; flex: none; fill: none; stroke: var(--ink-3); stroke-width: 1.7; stroke-linecap: round; }
.search input {
  border: 0; background: none; outline: none; min-width: 15rem;
  font: 400 .88rem/1.4 var(--sans); color: var(--ink);
}
.search input::placeholder { color: var(--ink-3); }

.empty {
  padding: 4rem 1rem; text-align: center;
  font-family: var(--serif); font-style: italic; font-size: 1.15rem;
  color: var(--ink-3);
}

/* ══════════════ DIRECTORY CARDS ══════════════ */
.grid {
  display: grid; gap: 1.1rem;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 20rem), 1fr));
}
.card {
  position: relative;
  padding: 1.5rem 1.5rem 1.35rem;
  background: var(--card);
  border: 1px solid var(--hair-soft);
  border-radius: var(--r);
  box-shadow: var(--shadow-sm);
  transition: transform .22s cubic-bezier(.2,.8,.3,1), box-shadow .22s, border-color .22s;
}
.card::before {
  content: ""; position: absolute; left: 0; top: 1.5rem; bottom: 1.5rem; width: 2px;
  background: var(--gold); opacity: 0;
  transition: opacity .22s;
}
.card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); border-color: var(--hair); }
.card:hover::before { opacity: .8; }
.card--me { border-color: color-mix(in oklab, var(--rust) 35%, var(--hair-soft)); }
.card--me::before { opacity: .9; background: var(--rust); }

/* line sections */
.linehead {
  display: flex; align-items: baseline; gap: .9rem;
  margin: 2.6rem 0 1.1rem;
}
.lineblock:first-child .linehead { margin-top: 0; }
.linehead__name {
  margin: 0; font-family: var(--serif); font-weight: 400;
  font-size: 1.5rem; line-height: 1; letter-spacing: -.015em;
  font-variation-settings: "SOFT" 45, "WONK" 1, "opsz" 70;
  white-space: nowrap;
}
.linehead__rule { flex: 1; height: 1px; background: var(--hair-soft); }
.linehead__count {
  font-size: .64rem; letter-spacing: .16em; text-transform: uppercase;
  color: var(--ink-3); white-space: nowrap;
}

.card__top { display: flex; align-items: baseline; gap: .6rem; flex-wrap: wrap; }
.card__edit {
  position: absolute; top: .8rem; right: .8rem;
  background: none; border: 1px solid var(--hair); border-radius: 2px;
  padding: .25rem .5rem; cursor: pointer;
  font: 500 .62rem/1 var(--sans); letter-spacing: .12em; text-transform: uppercase;
  color: var(--ink-3); opacity: 0;
  transition: opacity .2s, color .2s, border-color .2s;
}
.card:hover .card__edit, .card__edit:focus-visible { opacity: 1; }
.card__edit:hover { color: var(--rust); border-color: var(--rust); }
.card__name {
  margin: 0; font-family: var(--serif); font-weight: 400;
  font-size: 1.42rem; line-height: 1.15; letter-spacing: -.015em;
  font-variation-settings: "SOFT" 40, "WONK" 1, "opsz" 60;
}
.card__tag {
  font: 600 .6rem/1 var(--sans); letter-spacing: .16em; text-transform: uppercase;
  color: var(--rust); border: 1px solid color-mix(in oklab, var(--rust) 30%, transparent);
  padding: .3rem .45rem; border-radius: 2px;
}
.card__house {
  margin: .3rem 0 0; font-size: .78rem; letter-spacing: .12em;
  text-transform: uppercase; color: var(--ink-3);
}
.card__note {
  margin: .85rem 0 0; font-family: var(--serif); font-style: italic;
  font-size: .95rem; line-height: 1.55; color: var(--ink-2);
}
.card__lines { margin: 1.1rem 0 0; padding: 0; list-style: none; display: grid; gap: .5rem; }
.card__lines li { display: flex; gap: .7rem; align-items: baseline; font-size: .89rem; }
.card__lines dt, .card__k {
  flex: none; width: 4.6rem;
  font-size: .63rem; letter-spacing: .15em; text-transform: uppercase;
  color: var(--ink-3); padding-top: .18rem;
}
.card__v { color: var(--ink-2); min-width: 0; overflow-wrap: anywhere; }
.card__v a { color: var(--ink); text-decoration: none; border-bottom: 1px solid var(--hair); transition: color .18s, border-color .18s; }
.card__v a:hover { color: var(--rust); border-color: var(--rust); }

/* ══════════════ AGENDA ══════════════ */
.agenda { list-style: none; margin: 0; padding: 0; }
.agenda__month {
  margin: 2.4rem 0 1rem; padding-bottom: .5rem;
  border-bottom: 1px solid var(--hair-soft);
  font: 600 .68rem/1 var(--sans); letter-spacing: .24em; text-transform: uppercase;
  color: var(--ink-3);
}
.agenda__month:first-child { margin-top: 0; }
.ev {
  display: grid; grid-template-columns: 5.2rem 1fr auto; gap: 1.4rem;
  align-items: start;
  padding: 1.15rem .6rem 1.15rem .3rem;
  border-bottom: 1px solid var(--hair-soft);
  animation: rise .5s cubic-bezier(.2,.8,.25,1) both;
  animation-delay: var(--d, 0ms);
  transition: background .2s;
}
.ev:hover { background: var(--paper-2); }
.ev__when { text-align: center; padding-top: .1rem; }
.ev__day {
  display: block; font-family: var(--serif); font-weight: 400;
  font-size: 2.1rem; line-height: 1;
  font-variation-settings: "SOFT" 50, "WONK" 1, "opsz" 90;
  letter-spacing: -.03em;
}
.ev__dow {
  display: block; margin-top: .25rem;
  font-size: .6rem; letter-spacing: .18em; text-transform: uppercase; color: var(--ink-3);
}
.ev__title { margin: 0; font-size: 1.05rem; font-weight: 500; line-height: 1.35; }
.ev__meta { margin: .3rem 0 0; font-size: .84rem; color: var(--ink-3); }
.ev__desc {
  margin: .55rem 0 0; font-family: var(--serif); font-size: .93rem;
  line-height: 1.6; color: var(--ink-2); max-width: var(--measure);
}
.ev__side { display: flex; align-items: center; gap: .5rem; padding-top: .3rem; }
.ev__badge {
  font: 600 .58rem/1 var(--sans); letter-spacing: .16em; text-transform: uppercase;
  padding: .35rem .5rem; border-radius: 2px; white-space: nowrap;
}
.ev--birthday .ev__badge { color: var(--sage); border: 1px solid color-mix(in oklab, var(--sage) 35%, transparent); }
.ev--event .ev__badge { color: var(--gold); border: 1px solid color-mix(in oklab, var(--gold) 40%, transparent); }
.ev--soon .ev__day { color: var(--rust); }
.ev__del {
  background: none; border: 0; cursor: pointer; padding: .3rem;
  color: var(--ink-3); font-size: .78rem; border-radius: 2px;
  opacity: 0; transition: opacity .2s, color .2s;
}
.ev:hover .ev__del, .ev__del:focus-visible { opacity: 1; }
.ev__del:hover { color: var(--rust); }

/* ══════════════ DIALOGS ══════════════ */
.dlg {
  width: min(38rem, calc(100vw - 2rem));
  padding: 0; border: 1px solid var(--hair); border-radius: var(--r);
  background: var(--card); color: var(--ink);
  box-shadow: var(--shadow-lg);
}
.dlg::backdrop { background: color-mix(in oklab, #241F1A 55%, transparent); backdrop-filter: blur(3px); }
.dlg[open] { animation: rise .28s cubic-bezier(.2,.8,.25,1) both; }
.dlg__form { padding: clamp(1.5rem, 4vw, 2.2rem); margin: 0; }
.dlg__title {
  margin: 0; font-family: var(--serif); font-weight: 400;
  font-size: 1.85rem; line-height: 1.1; letter-spacing: -.02em;
  font-variation-settings: "SOFT" 40, "WONK" 1, "opsz" 80;
}
.fields { display: grid; grid-template-columns: 1fr 1fr; gap: .9rem 1rem; margin-top: 1.4rem; }
.f { display: flex; flex-direction: column; gap: .4rem; min-width: 0; }
.f--wide { grid-column: 1 / -1; }
.f > span { font-size: .64rem; letter-spacing: .16em; text-transform: uppercase; color: var(--ink-3); }
.bday { display: grid; grid-template-columns: minmax(0,1.5fr) minmax(0,.8fr) minmax(0,1.1fr); gap: .5rem; }
.bday select, .bday input { min-width: 0; }
.f input, .f textarea, .bday select {
  font: 400 .92rem/1.5 var(--sans); color: var(--ink);
  background: var(--paper); border: 1px solid var(--hair); border-radius: var(--r);
  padding: .6rem .75rem; outline: none; resize: vertical;
  transition: border-color .2s, box-shadow .2s;
}
.f input:focus, .f textarea:focus, .bday select:focus { border-color: var(--rust); box-shadow: 0 0 0 3px color-mix(in oklab, var(--rust) 14%, transparent); }
.dlg__err {
  margin: 1rem 0 0; padding: .65rem .8rem; font-size: .84rem;
  color: var(--rust-deep); background: color-mix(in oklab, var(--rust) 10%, transparent);
  border: 1px solid color-mix(in oklab, var(--rust) 25%, transparent); border-radius: var(--r);
}
.dlg__actions {
  display: flex; justify-content: flex-end; gap: .6rem;
  margin: 1.6rem 0 0; padding: 0;
}
@media (max-width: 34rem) { .fields { grid-template-columns: 1fr; } }

/* ══════════════ FOOT + TOAST ══════════════ */
.foot {
  max-width: var(--shell); margin: 3rem auto 0;
  padding: 0 clamp(1rem, 4vw, 2.5rem) 3rem;
  font-size: .8rem; color: var(--ink-3);
}
.foot p { margin: 0; font-family: var(--serif); font-style: italic; }

.toast {
  position: fixed; left: 50%; bottom: 2rem; transform: translateX(-50%);
  z-index: 9998;
  padding: .7rem 1.1rem;
  background: var(--ink); color: var(--paper);
  font-size: .87rem; border-radius: var(--r);
  box-shadow: var(--shadow-md);
  animation: rise .3s cubic-bezier(.2,.8,.25,1) both;
}

@media (max-width: 46rem) {
  .topbar { flex-wrap: wrap; gap: .75rem 1rem; }
  .tabs { order: 3; width: 100%; margin-inline: 0; }
  .acct__btn span { display: none; }
  .search input { min-width: 0; width: 100%; }
  .search { flex: 1; }
  .viewhead__tools { width: 100%; }
  .ev { grid-template-columns: 3.6rem 1fr; gap: 1rem; }
  .ev__side { grid-column: 2; }
  .ev__day { font-size: 1.7rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important; animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}

/* ══════════════ FAMILY TREE ══════════════ */
:root {
  --l-root:         #6E6257;
  --l-jeri-bill:    #B4472C;
  --l-doug-deloris: #5E7A56;
  --l-brett-lisa:   #B0801F;
  --l-sharon-harry: #57678F;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --l-root:         #A2937F;
    --l-jeri-bill:    #E0785A;
    --l-doug-deloris: #93AA88;
    --l-brett-lisa:   #D8A94E;
    --l-sharon-harry: #93A2CC;
  }
}

.view--tree { max-width: 1560px; }

.chips { display: flex; flex-wrap: wrap; gap: .35rem; }
.chip {
  background: var(--card); border: 1px solid var(--hair);
  border-radius: 100px; padding: .38rem .75rem; cursor: pointer;
  font: 500 .74rem/1 var(--sans); color: var(--ink-2);
  display: inline-flex; align-items: center; gap: .42rem;
  transition: border-color .18s, color .18s, background .18s;
}
.chip:hover { border-color: var(--ink-3); color: var(--ink); }
.chip[aria-pressed="true"] { border-color: currentColor; color: var(--ink); background: var(--paper-2); }
.chip__dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex: none; }
.chip:focus-visible { outline: 2px solid var(--rust); outline-offset: 2px; }

.treewrap {
  position: relative;
  height: clamp(520px, calc(100svh - 230px), 900px);
  border: 1px solid var(--hair-soft); border-radius: var(--r);
  background:
    radial-gradient(90% 70% at 50% 0%, var(--paper-2) 0%, transparent 70%),
    var(--paper);
  overflow: hidden; touch-action: none; cursor: grab;
}
.treewrap.is-panning { cursor: grabbing; }
.treewrap svg { display: block; width: 100%; height: 100%; }

.tnode { cursor: pointer; }
.tnode rect {
  fill: var(--card); stroke: var(--hair);
  transition: stroke .18s, fill .18s;
}
.tnode:hover rect { stroke: currentColor; }
.tnode.is-sel rect { stroke: currentColor; stroke-width: 1.8; fill: var(--paper-2); }
.tnode.is-dim { opacity: .28; }
.tnode__name {
  font: 500 13px/1 var(--sans); fill: var(--ink);
  dominant-baseline: middle; pointer-events: none;
}
.tnode__sub {
  font: 400 9px/1 var(--sans); fill: var(--ink-3);
  letter-spacing: .06em; dominant-baseline: middle; pointer-events: none;
}
.tnode__spine { pointer-events: none; }
.tedge { fill: none; stroke: var(--hair); stroke-width: 1.2; }
.tedge--line { stroke: currentColor; opacity: .5; }
.tbond { stroke: currentColor; stroke-width: 1.4; opacity: .65; }
.tgen {
  font: 600 9px/1 var(--sans); fill: var(--ink-3);
  letter-spacing: .2em; text-transform: uppercase;
}

.treehint, .treezoom { position: absolute; z-index: 3; }
.treehint {
  left: .75rem; bottom: .7rem;
  font-size: .7rem; color: var(--ink-3);
  background: color-mix(in oklab, var(--paper) 82%, transparent);
  padding: .3rem .55rem; border-radius: var(--r);
  pointer-events: none; transition: opacity .4s;
}
.treezoom { right: .7rem; bottom: .7rem; display: flex; gap: .3rem; }
.treezoom button {
  width: 30px; height: 30px; cursor: pointer;
  background: var(--card); border: 1px solid var(--hair); border-radius: var(--r);
  font: 400 1rem/1 var(--sans); color: var(--ink-2);
}
.treezoom button:hover { border-color: var(--ink-3); color: var(--rust); }

.treecard {
  position: absolute; top: .7rem; right: .7rem; z-index: 4;
  width: min(19rem, calc(100% - 1.4rem));
  background: var(--card); border: 1px solid var(--hair);
  border-radius: var(--r); box-shadow: var(--shadow-md);
  padding: 1.05rem 1.15rem;
  animation: rise .2s ease-out both;
}
.treecard__close {
  position: absolute; top: .5rem; right: .55rem;
  background: none; border: 0; cursor: pointer;
  color: var(--ink-3); font-size: 1rem; line-height: 1; padding: .2rem;
}
.treecard__close:hover { color: var(--rust); }
.treecard__name {
  margin: 0 1.2rem .1rem 0; font-family: var(--serif); font-weight: 400;
  font-size: 1.25rem; line-height: 1.15; letter-spacing: -.015em;
}
.treecard__house {
  margin: 0 0 .7rem; font-size: .63rem; letter-spacing: .14em;
  text-transform: uppercase; color: var(--ink-3);
}
.treecard dl { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: .35rem .7rem; }
.treecard dt {
  font-size: .58rem; letter-spacing: .13em; text-transform: uppercase;
  color: var(--ink-3); padding-top: .2rem;
}
.treecard dd { margin: 0; font-size: .82rem; color: var(--ink-2); overflow-wrap: anywhere; }
.treecard dd a { color: var(--ink); text-decoration: none; border-bottom: 1px solid var(--hair); }
.treecard dd a:hover { color: var(--rust); border-color: var(--rust); }

@media (max-width: 46rem) {
  .treewrap { height: clamp(420px, calc(100svh - 280px), 680px); }
  .treehint { display: none; }
  .treecard { top: auto; bottom: .7rem; right: .7rem; left: .7rem; width: auto; }
}

/* ══════════════ SUBSCRIBE DIALOG ══════════════ */
.sub__lede { margin: 1.2rem 0 1.4rem; color: var(--ink-2); font-size: .92rem; line-height: 1.65; }
.sub__or { margin: 1.1rem 0 .5rem; font-size: .82rem; color: var(--ink-3); }
.sub__or em { font-style: normal; color: var(--ink-2); }
.sub__url { display: flex; gap: .5rem; }
.sub__url input {
  flex: 1; min-width: 0;
  font: 400 .78rem/1.4 ui-monospace, SFMono-Regular, Menlo, monospace;
  color: var(--ink-2); background: var(--paper);
  border: 1px solid var(--hair); border-radius: var(--r); padding: .55rem .7rem;
}
.sub__url input:focus { outline: 2px solid var(--rust); outline-offset: 1px; }
.sub__warn {
  margin: 1.2rem 0 0; padding: .75rem .9rem;
  font-size: .8rem; line-height: 1.6; color: var(--ink-2);
  background: color-mix(in oklab, var(--gold) 10%, transparent);
  border: 1px solid color-mix(in oklab, var(--gold) 30%, transparent);
  border-radius: var(--r);
}
#subMissing code { font-size: .95em; }

/* household / line controls in the edit dialog */
.f select {
  font: 400 .92rem/1.5 var(--sans); color: var(--ink);
  background: var(--paper); border: 1px solid var(--hair); border-radius: var(--r);
  padding: .6rem .75rem; outline: none;
  transition: border-color .2s, box-shadow .2s;
}
.f select:focus { border-color: var(--rust); box-shadow: 0 0 0 3px color-mix(in oklab, var(--rust) 14%, transparent); }
.f select + input { margin-top: .45rem; }
.f__hint { margin: .4rem 0 0; font-size: .74rem; line-height: 1.5; color: var(--ink-3); }

/* ══════════════ EMAIL-LINK SIGN IN ══════════════ */
.gate__alt { margin-top: 1.8rem; }
.gate__or {
  display: block; margin-bottom: 1.1rem;
  font-size: .68rem; letter-spacing: .22em; text-transform: uppercase; color: var(--ink-3);
  position: relative;
}
.gate__or::before, .gate__or::after {
  content: ""; position: absolute; top: 50%; width: 22%; height: 1px; background: var(--hair);
}
.gate__or::before { left: 8%; }
.gate__or::after  { right: 8%; }

.linkform { display: flex; gap: .5rem; justify-content: center; flex-wrap: wrap; }
.linkform--centred { margin-top: 1.6rem; }
.linkform input {
  flex: 1 1 15rem; max-width: 20rem; min-width: 0;
  font: 400 .9rem/1.4 var(--sans); color: var(--ink);
  background: var(--card); border: 1px solid var(--hair); border-radius: var(--r);
  padding: .6rem .8rem; outline: none;
  transition: border-color .2s, box-shadow .2s;
}
.linkform input::placeholder { color: var(--ink-3); }
.linkform input:focus { border-color: var(--rust); box-shadow: 0 0 0 3px color-mix(in oklab, var(--rust) 14%, transparent); }
.linkform button { white-space: nowrap; }

.gate__hint { margin: .9rem auto 0; max-width: 26rem; font-size: .8rem; line-height: 1.6; color: var(--ink-3); }
.gate__sent {
  margin-top: 1.6rem; padding: 1.1rem 1.2rem;
  background: color-mix(in oklab, var(--sage) 10%, transparent);
  border: 1px solid color-mix(in oklab, var(--sage) 30%, transparent);
  border-radius: var(--r);
}
.gate__sent p { margin: 0; font-size: .92rem; color: var(--ink-2); }
.gate__sent .gate__hint { margin-top: .5rem; }
.linkish {
  background: none; border: 0; padding: 0; cursor: pointer;
  font: inherit; color: var(--rust); text-decoration: underline;
}
.linkish:hover { color: var(--rust-deep); }

/* ══════════════ SIGN-IN ADDRESSES ══════════════ */
.addrs { list-style: none; margin: 0 0 .55rem; padding: 0; display: grid; gap: .35rem; }
.addrs:empty { display: none; }
.addrs li {
  display: flex; align-items: center; gap: .6rem;
  padding: .45rem .5rem .45rem .7rem;
  background: var(--paper); border: 1px solid var(--hair); border-radius: var(--r);
  font: 400 .82rem/1.4 ui-monospace, SFMono-Regular, Menlo, monospace;
  color: var(--ink-2); overflow-wrap: anywhere;
}
.addrs li span { flex: 1; min-width: 0; }
.addrs__none {
  padding: .5rem .7rem; border: 1px dashed var(--hair); border-radius: var(--r);
  font: italic 400 .82rem/1.4 var(--serif); color: var(--ink-3);
}
.addrs__drop {
  flex: none; background: none; border: 0; cursor: pointer; padding: .1rem .3rem;
  color: var(--ink-3); font-size: 1rem; line-height: 1; border-radius: 2px;
}
.addrs__drop:hover { color: var(--rust); }
.addrs__add { display: flex; gap: .5rem; }
.addrs__add input {
  flex: 1; min-width: 0;
  font: 400 .88rem/1.4 var(--sans); color: var(--ink);
  background: var(--paper); border: 1px solid var(--hair); border-radius: var(--r);
  padding: .55rem .7rem; outline: none;
}
.addrs__add input:focus { border-color: var(--rust); box-shadow: 0 0 0 3px color-mix(in oklab, var(--rust) 14%, transparent); }

/* ══════════════ PORTRAITS ══════════════ */
.avatar {
  flex: none; display: grid; place-items: center; overflow: hidden;
  width: 44px; height: 44px; border-radius: 50%;
  background: var(--paper-2); border: 1px solid var(--hair-soft);
  color: currentColor;
  font: 500 .85rem/1 var(--sans); letter-spacing: .04em;
  user-select: none;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.avatar__initials { color: var(--ink-3); }
.avatar--lg { width: 84px; height: 84px; font-size: 1.5rem; }
.avatar--sm { width: 32px; height: 32px; font-size: .68rem; }

.card__head { display: flex; align-items: center; gap: .85rem; }
.card__head .avatar { border-color: color-mix(in oklab, currentColor 30%, var(--hair-soft)); }
.card__headtext { min-width: 0; }
.card--me .avatar { border-color: color-mix(in oklab, var(--rust) 45%, var(--hair-soft)); }

.picker { display: flex; align-items: center; gap: 1rem; }
.picker__actions { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; min-width: 0; }
.picker__actions .f__hint { flex-basis: 100%; margin: 0; }

.treecard__portrait { display: flex; justify-content: center; margin-bottom: .8rem; }
.treecard__portrait .avatar { width: 76px; height: 76px; font-size: 1.35rem; }

/* ══════════════ ACTIVITY ══════════════ */
.feed { display: grid; gap: 1.4rem; max-width: 46rem; }
.post {
  background: var(--card); border: 1px solid var(--hair-soft);
  border-radius: var(--r); box-shadow: var(--shadow-sm);
  padding: 1.4rem 1.5rem 1.25rem;
}
.post__head { display: flex; align-items: center; gap: .8rem; margin-bottom: .9rem; }
.post__who { min-width: 0; flex: 1; }
.post__author { display: block; font-weight: 500; font-size: .92rem; }
.post__when {
  display: block; font-size: .7rem; letter-spacing: .1em;
  text-transform: uppercase; color: var(--ink-3); margin-top: .15rem;
}
.post__del {
  flex: none; background: none; border: 0; cursor: pointer; padding: .25rem .4rem;
  font: 500 .62rem/1 var(--sans); letter-spacing: .12em; text-transform: uppercase;
  color: var(--ink-3); border: 1px solid transparent; border-radius: 2px;
  opacity: 0; transition: opacity .2s, color .2s, border-color .2s;
}
.post:hover .post__del, .post__del:focus-visible { opacity: 1; }
.post__del:hover { color: var(--rust); border-color: var(--rust); }
.post__subject {
  margin: 0 0 .5rem; font-family: var(--serif); font-weight: 400;
  font-size: 1.5rem; line-height: 1.2; letter-spacing: -.015em;
  font-variation-settings: "SOFT" 40, "WONK" 1, "opsz" 70;
}
.post__body {
  margin: 0; font-size: .95rem; line-height: 1.7; color: var(--ink-2);
  white-space: pre-wrap; overflow-wrap: anywhere;
}
.post__pics {
  display: grid; gap: .4rem; margin-top: 1.1rem;
  grid-template-columns: repeat(auto-fit, minmax(0, 1fr));
}
.post__pics[data-n="1"] { grid-template-columns: 1fr; }
.post__pics[data-n="2"], .post__pics[data-n="4"] { grid-template-columns: repeat(2, 1fr); }
.post__pics[data-n="3"], .post__pics[data-n="5"], .post__pics[data-n="6"],
.post__pics[data-n="7"], .post__pics[data-n="8"], .post__pics[data-n="9"],
.post__pics[data-n="10"] { grid-template-columns: repeat(3, 1fr); }
.post__pic {
  position: relative; display: block; width: 100%; padding: 0; border: 0;
  background: var(--paper-2); border-radius: 2px; overflow: hidden; cursor: zoom-in;
  aspect-ratio: 1;
}
.post__pics[data-n="1"] .post__pic { aspect-ratio: auto; max-height: 30rem; cursor: zoom-in; }
.post__pic img { width: 100%; height: 100%; object-fit: cover; display: block; }
.post__pics[data-n="1"] .post__pic img { object-fit: contain; max-height: 30rem; }
.post__pic--loading { min-height: 6rem; }

.pics { display: flex; flex-wrap: wrap; gap: .45rem; margin-bottom: .55rem; }
.pics:empty { display: none; }
.pics figure {
  position: relative; margin: 0; width: 74px; height: 74px;
  border-radius: 2px; overflow: hidden; border: 1px solid var(--hair);
}
.pics img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pics button {
  position: absolute; top: 2px; right: 2px; width: 18px; height: 18px;
  display: grid; place-items: center; cursor: pointer;
  background: color-mix(in oklab, #241F1A 65%, transparent); color: #FBF8F2;
  border: 0; border-radius: 50%; font-size: .72rem; line-height: 1;
}
.pics button:hover { background: var(--rust); }

.lightbox {
  border: 0; padding: 0; background: transparent; max-width: 96vw; max-height: 96vh;
}
.lightbox::backdrop { background: color-mix(in oklab, #241F1A 88%, transparent); }
.lightbox img { display: block; max-width: 96vw; max-height: 96vh; border-radius: var(--r); }
.lightbox__close {
  position: fixed; top: 1rem; right: 1.2rem; z-index: 2;
  background: none; border: 0; cursor: pointer; color: #FBF8F2; font-size: 2rem; line-height: 1;
}

/* ══════════════ REACTIONS & COMMENTS ══════════════ */
.avatar--xs { width: 26px; height: 26px; font-size: .58rem; }

.reacts {
  display: flex; flex-wrap: wrap; gap: .35rem;
  margin-top: 1.1rem; padding-top: .9rem;
  border-top: 1px solid var(--hair-soft);
}
.react {
  display: inline-flex; align-items: center; gap: .35rem;
  padding: .3rem .6rem; cursor: pointer;
  background: var(--paper); border: 1px solid var(--hair); border-radius: 100px;
  font: 500 .78rem/1 var(--sans); color: var(--ink-3);
  transition: border-color .18s, background .18s, color .18s, transform .12s;
}
.react:hover { border-color: var(--ink-3); transform: translateY(-1px); }
.react:active { transform: none; }
.react.is-mine {
  border-color: color-mix(in oklab, var(--rust) 50%, transparent);
  background: color-mix(in oklab, var(--rust) 8%, transparent);
  color: var(--ink);
}
.react__g { font-size: .95rem; line-height: 1; }
.react__n { font-variant-numeric: tabular-nums; }
.react:focus-visible { outline: 2px solid var(--rust); outline-offset: 2px; }

.comments { margin-top: .9rem; display: grid; gap: .7rem; }
.comment { display: flex; gap: .6rem; align-items: flex-start; }
.comment__main { flex: 1; min-width: 0; }
.comment__who { font: 500 .82rem/1.3 var(--sans); }
.comment__when {
  margin-left: .45rem; font-size: .66rem; letter-spacing: .08em;
  text-transform: uppercase; color: var(--ink-3);
}
.comment__text {
  margin: .15rem 0 0; font-size: .89rem; line-height: 1.6; color: var(--ink-2);
  white-space: pre-wrap; overflow-wrap: anywhere;
}
.comment__del {
  flex: none; background: none; border: 0; cursor: pointer;
  color: var(--ink-3); font-size: .95rem; line-height: 1; padding: .1rem .25rem;
  opacity: 0; transition: opacity .18s, color .18s;
}
.comment:hover .comment__del, .comment__del:focus-visible { opacity: 1; }
.comment__del:hover { color: var(--rust); }

.comment__add { display: flex; gap: .5rem; margin-top: .2rem; }
.comment__add input {
  flex: 1; min-width: 0;
  font: 400 .88rem/1.4 var(--sans); color: var(--ink);
  background: var(--paper); border: 1px solid var(--hair); border-radius: 100px;
  padding: .5rem .9rem; outline: none;
  transition: border-color .2s, box-shadow .2s;
}
.comment__add input::placeholder { color: var(--ink-3); }
.comment__add input:focus {
  border-color: var(--rust);
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--rust) 12%, transparent);
}
.comment__add button { border-radius: 100px; }

/* Entrance animations run on first appearance only — a redraw caused by a
   comment landing elsewhere should not replay thirty of them. */
.post.is-new { animation: rise .45s cubic-bezier(.2,.8,.25,1) both; animation-delay: var(--d, 0ms); }
.card.is-new { animation: rise .5s cubic-bezier(.2,.8,.25,1) both; animation-delay: var(--d, 0ms); }

/* ══════════════ MAP ══════════════ */
.land { fill: color-mix(in oklab, var(--ink) 7%, var(--paper));
        stroke: var(--hair); stroke-width: .6; vector-effect: non-scaling-stroke; }
.border { fill: none; stroke: color-mix(in oklab, var(--ink) 16%, transparent);
          stroke-width: .6; vector-effect: non-scaling-stroke; }
.pin { cursor: pointer; }
.pin__halo { fill: currentColor; opacity: .14; }
.pin__dot {
  fill: currentColor; stroke: var(--card); stroke-width: 1.5;
  vector-effect: non-scaling-stroke; transition: opacity .18s;
}
.pin__n {
  font: 600 7px/1 var(--sans); fill: var(--card);
  text-anchor: middle; dominant-baseline: central; pointer-events: none;
}
.pin:hover .pin__halo { opacity: .3; }
.pin.is-dim { opacity: .2; }
.pin.is-sel .pin__dot { stroke: var(--ink); stroke-width: 2.5; }
.maplabel {
  font: 500 8px/1 var(--sans); fill: var(--ink-3);
  text-anchor: middle; pointer-events: none;
}
.mapcredit {
  position: absolute; left: .75rem; bottom: .7rem; margin: 0; z-index: 2;
  max-width: 22rem; font-size: .62rem; line-height: 1.45; color: var(--ink-3);
  background: color-mix(in oklab, var(--paper) 78%, transparent);
  padding: .25rem .45rem; border-radius: var(--r); pointer-events: none;
}
.mapcard__who { margin: .2rem 0 0; padding: 0; list-style: none; display: grid; gap: .45rem; }
.mapcard__who li { display: flex; align-items: center; gap: .5rem; font-size: .84rem; }
.mapcard__approx {
  margin: .7rem 0 0; font-size: .72rem; line-height: 1.5; color: var(--ink-3);
  border-top: 1px solid var(--hair-soft); padding-top: .55rem;
}
@media (max-width: 46rem) { .mapcredit { display: none; } }
