/* ============================================================================
   FutureGen — "Midnight Reading Room" design system (v2, July 2026)
   Deep iron-gall indigo chrome · warm porcelain paper · gilt brass hairlines
   Display: Newsreader · UI/body: Instrument Sans
   Contract note: every class/ID generated by app.js is styled here. Do not
   rename selectors without grepping app.js first.
   ========================================================================== */

:root {
  /* paper — the documents */
  --paper:       #f3f1ea;   /* porcelain page */
  --paper-deep:  #eae6da;   /* aged sheet / wells */
  --card:        #fcfbf7;   /* fresh leaf */
  --line:        #e0dbcd;   /* hairline rule */
  --line-strong: #cfc8b4;

  /* ink — the writing */
  --ink:         #212836;   /* iron-gall blue-black */
  --ink-soft:    #6a7180;
  --ink-faint:   #9aa0ab;

  /* chrome — the reading room */
  --midnight:    #141b2a;
  --midnight-2:  #1d2739;
  --midnight-3:  #263349;
  --chrome-text: #c7cddc;

  /* metals & wax */
  --brass:       #a5823d;   /* gilt tooling */
  --brass-deep:  #8a6a2c;
  --brass-soft:  #ece2c6;
  --brass-glow:  rgba(196, 162, 84, .45);
  --wax:         #96382b;   /* sealing wax */
  --wax-deep:    #7c2d22;

  /* action */
  --action:      #24344f;   /* indigo button */
  --action-hover:#1a2740;

  --radius: 10px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(20, 27, 42, .05), 0 10px 30px rgba(20, 27, 42, .07);
  --shadow-lift: 0 2px 4px rgba(20, 27, 42, .06), 0 16px 40px rgba(20, 27, 42, .12);

  --display: "Newsreader", "Iowan Old Style", Georgia, serif;
  --body: "Instrument Sans", -apple-system, "Segoe UI", system-ui, sans-serif;

  /* legacy vars referenced by app.js inline styles — keep these aliases */
  --linen: #f3f1ea;
  --moss: #38614a;          /* success text (auth message) */
  --gold: var(--brass);     /* tree connector lines */
}

/* ---------------------------------------------------------------- base */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--body);
  background: var(--paper);
  color: var(--ink);
  font-size: 16px;
  line-height: 1.6;
  font-feature-settings: "ss01";
}
h1, h2, h3, h4 {
  font-family: var(--display);
  font-weight: 500;
  letter-spacing: .002em;
  margin: 0 0 .35em;
  line-height: 1.16;
  color: var(--ink);
}
h1 { font-size: 2rem; }
h2 { font-size: 1.45rem; }
h3 { font-size: 1.15rem; }
p { margin: .3em 0; }
button { font-family: var(--body); cursor: pointer; color: inherit; }
input, select, textarea { font-family: var(--body); font-size: 1rem; color: var(--ink); }
img { max-width: 100%; }
.hidden { display: none !important; }
.muted { color: var(--ink-soft); }
::selection { background: var(--brass-soft); color: var(--ink); }
:focus-visible { outline: 2px solid var(--brass); outline-offset: 2px; border-radius: 3px; }
::placeholder { color: var(--ink-faint); }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

/* thin, quiet scrollbars in the chrome */
* { scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }

/* ---------------------------------------------------------------- auth */
.auth-shell { min-height: 100vh; display: grid; grid-template-columns: 1.08fr 1fr; }

.auth-brand {
  position: relative;
  background:
    radial-gradient(120% 90% at 85% -10%, rgba(165, 130, 61, .18), transparent 55%),
    linear-gradient(165deg, #0f1522, var(--midnight) 45%, var(--midnight-2));
  color: #eef0ea;
  padding: 8vh 8%;
  display: flex; flex-direction: column; justify-content: center; gap: 16px;
  overflow: hidden;
}
/* gilt tooling: the signature frame */
.auth-brand::before {
  content: ""; position: absolute; inset: 22px;
  border: 1px solid rgba(196, 162, 84, .38);
  pointer-events: none;
}
.auth-brand::after {
  content: ""; position: absolute; inset: 27px;
  border: 1px solid rgba(196, 162, 84, .16);
  pointer-events: none;
}
.auth-brand h1 {
  font-size: clamp(2.4rem, 4.5vw, 3.4rem);
  font-weight: 500; color: #f6f3ea; letter-spacing: .01em;
}
.brand-mark { width: 56px; height: 56px; color: var(--brass); }
.brand-mark svg { width: 100%; height: 100%; display: block; }
.tagline {
  color: #cdb877; font-size: .82rem; letter-spacing: .32em;
  text-transform: uppercase; font-weight: 600;
}
.auth-quote {
  margin: 30px 0 0; padding: 4px 0 4px 26px;
  border-left: 1px solid var(--brass);
  font-family: var(--display); font-size: 1.3rem; font-weight: 400;
  font-style: italic; color: #dfe2da; max-width: 34ch; line-height: 1.5;
}

.auth-card {
  display: flex; flex-direction: column; justify-content: center;
  padding: 8vh 9%; background: var(--paper);
}
.tabs { display: flex; gap: 4px; margin-bottom: 30px; border-bottom: 1px solid var(--line); }
.tab {
  background: none; border: none; padding: 12px 18px; font-size: 1.02rem;
  color: var(--ink-soft); border-bottom: 2px solid transparent; margin-bottom: -1px;
  letter-spacing: .01em;
}
.tab:hover { color: var(--ink); }
.tab.active { color: var(--ink); border-bottom-color: var(--brass); font-weight: 600; }

.auth-form { display: flex; flex-direction: column; gap: 16px; }
.auth-form label, .field {
  display: flex; flex-direction: column; gap: 7px;
  font-weight: 600; font-size: .86rem; color: var(--ink);
  letter-spacing: .015em;
}
.auth-form input, .field input, .field select, .field textarea {
  padding: 12px 14px; border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm); background: var(--card);
  font-weight: 400; transition: border-color .15s, box-shadow .15s;
}
.auth-form input:focus, .field :is(input, select, textarea):focus {
  border-color: var(--action); outline: none;
  box-shadow: 0 0 0 3px rgba(36, 52, 79, .14);
}
.join-mode {
  display: flex; flex-direction: column; gap: 10px; padding: 14px 16px;
  background: var(--paper-deep); border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}
.radio { display: flex; align-items: center; gap: 9px; font-size: .95rem; font-weight: 500; flex-direction: row; }
.radio input { accent-color: var(--action); width: 16px; height: 16px; }
.message { min-height: 1.3em; color: var(--wax); font-size: .92rem; font-weight: 500; }

/* ---------------------------------------------------------------- buttons */
.primary-btn {
  background: var(--action); color: #f4f1e8; border: 1px solid var(--action);
  border-radius: var(--radius-sm); padding: 12px 20px;
  font-size: .98rem; font-weight: 600; letter-spacing: .015em;
  transition: background .15s, transform .1s, box-shadow .15s;
  box-shadow: 0 1px 2px rgba(20, 27, 42, .18);
}
.primary-btn:hover { background: var(--action-hover); }
.primary-btn:active { transform: translateY(1px); }

.ghost-btn {
  background: transparent; border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm); padding: 11px 18px;
  color: var(--ink); font-weight: 500; transition: border-color .15s, color .15s, background .15s;
}
.ghost-btn:hover { border-color: var(--action); color: var(--action); background: var(--card); }

.small-btn {
  background: var(--card); border: 1px solid var(--line-strong);
  border-radius: 7px; padding: 6px 13px; font-size: .84rem; font-weight: 600;
  color: var(--ink); letter-spacing: .01em;
  transition: border-color .15s, background .15s;
}
.small-btn:hover { border-color: var(--brass); background: #fffef9; }

.danger-btn {
  background: none; border: 1px solid transparent; border-radius: 7px;
  padding: 6px 13px; font-size: .84rem; font-weight: 500; color: var(--wax);
  transition: border-color .15s, background .15s;
}
.danger-btn:hover { border-color: var(--wax); background: rgba(150, 56, 43, .06); }

.icon-btn {
  background: var(--card); border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm); width: 40px; height: 40px;
  font-size: 1.1rem; color: var(--ink);
  display: inline-flex; align-items: center; justify-content: center;
  transition: border-color .15s, background .15s;
}
.icon-btn:hover { border-color: var(--brass); }
.icon-btn svg { width: 19px; height: 19px; }

.linklike {
  background: none; border: none; color: var(--action); font-weight: 600;
  padding: 0; text-decoration: underline; text-underline-offset: 3px;
  text-decoration-color: var(--brass);
}
.linklike:hover { color: var(--brass-deep); }

/* ---------------------------------------------------------------- app frame */
.app { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }

.sidebar {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: 18px;
  padding: 24px 14px 18px;
  color: var(--chrome-text);
  background:
    radial-gradient(140% 50% at 50% -12%, rgba(196, 162, 84, .12), transparent 60%),
    linear-gradient(180deg, #101725, var(--midnight) 30%, var(--midnight-2));
  border-right: 1px solid rgba(196, 162, 84, .18);
}
.logo-row { display: flex; gap: 12px; align-items: center; padding: 2px 10px 14px; border-bottom: 1px solid rgba(196, 162, 84, .22); }
.logo-icon { width: 30px; height: 30px; color: var(--brass); flex: none; }
.logo-icon svg { width: 100%; height: 100%; display: block; }
.logo-row strong {
  font-family: var(--display); font-size: 1.22rem; font-weight: 500;
  display: block; color: #f2efe4; letter-spacing: .02em;
}
.logo-row small {
  color: #b6a065; display: block; font-size: .74rem; letter-spacing: .04em;
  max-width: 150px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

#main-nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav-item {
  position: relative;
  display: flex; align-items: center; gap: 12px; padding: 11px 13px;
  background: none; border: none; border-radius: var(--radius-sm);
  color: var(--chrome-text); font-size: .95rem; font-weight: 500;
  letter-spacing: .015em; text-align: left; width: 100%;
  transition: background .15s, color .15s;
}
.nav-item .ni { width: 20px; height: 20px; flex: none; display: inline-flex; align-items: center; justify-content: center; opacity: .82; }
.nav-item .ni svg { width: 19px; height: 19px; }
.nav-item:hover { background: rgba(236, 226, 198, .07); color: #fdfbf3; }
.nav-item.active {
  background: linear-gradient(90deg, rgba(196, 162, 84, .2), rgba(196, 162, 84, .08));
  color: #f6edd7; font-weight: 600;
}
.nav-item.active::before {
  content: ""; position: absolute; left: 0; top: 8px; bottom: 8px; width: 3px;
  border-radius: 2px; background: var(--brass);
}
.nav-item.active .ni { opacity: 1; color: var(--brass); }
.nav-item.danger:hover { color: #f0b3a6; background: rgba(150, 56, 43, .16); }
.sidebar-bottom { display: flex; flex-direction: column; gap: 2px; padding-top: 12px; border-top: 1px solid rgba(196, 162, 84, .18); }
.scrim { display: none; }

/* family switcher (multi-family accounts) */
#family-switcher { padding: 0 4px 4px; }
#family-switcher select {
  width: 100%; padding: 9px 11px; border-radius: var(--radius-sm);
  border: 1px solid rgba(196, 162, 84, .3); background: rgba(236, 226, 198, .06);
  color: #e9e4d3; font-family: var(--body); font-size: .86rem; cursor: pointer;
}
#family-switcher select:hover { border-color: rgba(196, 162, 84, .55); }
#family-switcher select option { color: var(--ink); background: var(--card); }

/* ---------------------------------------------------------------- topbar */
.main { display: flex; flex-direction: column; min-width: 0; }
.topbar {
  display: flex; align-items: center; gap: 16px; padding: 16px 32px;
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.topbar-titles { flex: 1; min-width: 0; }
.topbar h2 { margin: 0; font-size: 1.4rem; }
.topbar p {
  margin: 0; color: var(--brass-deep); font-size: .72rem; font-weight: 600;
  letter-spacing: .18em; text-transform: uppercase;
}
.top-actions { display: flex; align-items: center; gap: 10px; }
#global-search {
  padding: 10px 16px; border: 1px solid var(--line-strong);
  border-radius: 999px; background: var(--card); width: 250px;
  font-size: .92rem; transition: border-color .15s, box-shadow .15s, width .2s;
}
#global-search:focus {
  outline: none; border-color: var(--action);
  box-shadow: 0 0 0 3px rgba(36, 52, 79, .12);
}
.avatar {
  width: 40px; height: 40px; border-radius: 50%;
  background: linear-gradient(150deg, var(--midnight-3), var(--midnight));
  color: #ecdfb8; border: 1px solid var(--brass);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: .92rem; letter-spacing: .03em;
  cursor: pointer; flex: none; overflow: hidden;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }

.page { display: none; padding: 30px 32px 70px; max-width: 1240px; }
.page.active { display: block; animation: pagein .22s ease; }
@keyframes pagein { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; } }

/* ---------------------------------------------------------------- shared */
.section-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 14px; margin-bottom: 22px; flex-wrap: wrap;
}
.section-head h2, .section-head h3 { margin-bottom: 0; }

.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 15px 20px; border-bottom: 1px solid var(--line);
}
.card-header h3 { margin: 0; }
.card-body { padding: 20px; }
.stack { display: flex; flex-direction: column; gap: 13px; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(290px, 1fr)); gap: 20px; }
.content-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(265px, 1fr)); gap: 20px; }

.empty {
  color: var(--ink-soft); text-align: center; padding: 40px 16px;
  font-family: var(--display); font-style: italic; font-size: 1.05rem;
}
.notice {
  background: var(--paper-deep); border: 1px solid var(--brass-soft);
  border-left: 3px solid var(--brass);
  border-radius: var(--radius-sm); padding: 13px 16px; font-size: .92rem;
}

/* hero — the gilt-tooled cover */
.hero {
  position: relative; overflow: hidden;
  color: #f0ede3; border-radius: var(--radius);
  padding: 40px 38px; margin-bottom: 26px;
  background:
    radial-gradient(110% 130% at 92% -20%, rgba(196, 162, 84, .28), transparent 52%),
    radial-gradient(80% 100% at 0% 110%, rgba(38, 51, 73, .8), transparent 60%),
    linear-gradient(150deg, #101725, var(--midnight) 45%, var(--midnight-2));
  box-shadow: var(--shadow-lift);
}
.hero::before {
  content: ""; position: absolute; inset: 12px;
  border: 1px solid rgba(196, 162, 84, .4); border-radius: 4px;
  pointer-events: none;
}
.hero small {
  letter-spacing: .3em; color: #cdb877; font-weight: 600; font-size: .72rem;
}
.hero h1 { color: #f8f5ec; font-size: clamp(1.8rem, 3vw, 2.4rem); margin: 8px 0 10px; font-weight: 500; }
.hero p { color: #c9cdd6; max-width: 58ch; margin-bottom: 20px; font-size: 1.02rem; }
.hero .primary-btn {
  background: var(--brass); border-color: var(--brass); color: #171308;
  box-shadow: 0 2px 10px rgba(0, 0, 0, .3);
}
.hero .primary-btn:hover { background: #b3904a; }

.stat { display: flex; align-items: baseline; gap: 12px; }
.stat strong {
  font-family: var(--display); font-size: 1.9rem; font-weight: 500;
  color: var(--ink); min-width: 1.4ch; text-align: right;
  font-variant-numeric: lining-nums;
}
.quick-list { display: flex; flex-direction: column; gap: 9px; }
.quick-list button, .prompt-chip {
  text-align: left; background: var(--paper); border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm); padding: 12px 15px; font-size: .95rem;
  font-weight: 500; color: var(--ink);
  transition: border-color .15s, background .15s, transform .1s;
}
.quick-list button:hover, .prompt-chip:hover {
  border-color: var(--brass); background: #fdf9ee;
}

/* ---------------------------------------------------------------- timeline */
.ledger { position: relative; padding-left: 28px; }
.ledger::before {
  content: ""; position: absolute; left: 8px; top: 8px; bottom: 8px; width: 1px;
  background: linear-gradient(180deg, var(--brass) 0%, var(--brass-soft) 100%);
}
.timeline-item {
  position: relative; display: flex; gap: 14px; padding: 15px 0;
  border-bottom: 1px solid var(--line);
}
.timeline-item:last-child { border-bottom: none; }
.timeline-item .dot {
  position: absolute; left: -24px; top: 23px; width: 9px; height: 9px;
  background: var(--brass); transform: rotate(45deg);
  box-shadow: 0 0 0 3px var(--paper), 0 0 0 4px var(--brass-soft);
}
.card .timeline-item .dot { box-shadow: 0 0 0 3px var(--card), 0 0 0 4px var(--brass-soft); }
.timeline-item time {
  font-size: .74rem; letter-spacing: .14em; text-transform: uppercase;
  color: var(--brass-deep); font-weight: 700;
}
.timeline-item h4 { margin: 3px 0 3px; font-size: 1.08rem; }
.timeline-item > div { flex: 1; min-width: 0; }
.timeline-item small { color: var(--ink-soft); white-space: nowrap; font-size: .8rem; padding-top: 4px; }

.year-rule {
  display: flex; align-items: center; gap: 14px;
  font-family: var(--display); font-size: 1.5rem; font-weight: 500;
  color: var(--ink); padding: 22px 0 8px; margin-bottom: 8px;
  font-variant-numeric: lining-nums;
}
.year-rule::after {
  content: ""; flex: 1; height: 3px;
  border-top: 1px solid var(--brass); border-bottom: 1px solid var(--brass-soft);
}

/* ---------------------------------------------------------------- cards: people/stories/photos/capsules */
.person-card, .story-card, .photo-card, .capsule-card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden; display: flex; flex-direction: column;
  transition: transform .15s, box-shadow .15s, border-color .15s;
}
.person-card:hover, .story-card:hover, .photo-card:hover {
  transform: translateY(-2px); box-shadow: var(--shadow-lift); border-color: var(--line-strong);
}
.person-card .inner, .story-card .inner, .capsule-card .inner {
  padding: 20px; display: flex; flex-direction: column; gap: 7px; flex: 1;
}
.person-card .avatar { width: 54px; height: 54px; font-size: 1.15rem; cursor: default; }
.person-card.deceased { background: linear-gradient(180deg, var(--card), var(--paper-deep)); }
.person-card.deceased .avatar { filter: saturate(.55); border-color: var(--line-strong); }

.legacy-badge {
  display: inline-block; background: var(--brass-soft); color: #5c4718;
  font-size: .68rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase;
  padding: 4px 10px; border-radius: 999px;
}
.member-badge {
  display: inline-block; background: var(--action); color: #eef0ea;
  font-size: .68rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase;
  padding: 4px 10px; border-radius: 999px;
}
.story-meta { font-size: .8rem; color: var(--ink-soft); letter-spacing: .01em; }
.story-actions { display: flex; gap: 8px; margin-top: auto; padding-top: 12px; flex-wrap: wrap; }
.clamp { display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.story-card .clamp { font-size: .98rem; line-height: 1.65; }

/* reactions & comments */
.react-row { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.react-btn {
  background: var(--paper); border: 1px solid var(--line-strong); border-radius: 999px;
  padding: 4px 11px; font-size: .88rem; transition: border-color .15s, background .15s, transform .1s;
}
.react-btn:hover { border-color: var(--brass); }
.react-btn:active { transform: scale(.94); }
.react-btn.mine { border-color: var(--brass); background: var(--brass-soft); }
.react-btn.mini { padding: 2px 9px; font-size: .78rem; }
.creact-menu { display: inline-flex; gap: 4px; }
.creact-menu.hidden { display: none; }

.comment {
  background: var(--paper); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 10px 14px; font-size: .93rem;
}
.comment .who { font-weight: 700; font-size: .78rem; color: var(--action); letter-spacing: .02em; }
.comment-row { display: flex; gap: 8px; }
.comment-row input {
  flex: 1; padding: 10px 14px; border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm); background: var(--card);
}
.comment-row input:focus { outline: none; border-color: var(--action); box-shadow: 0 0 0 3px rgba(36, 52, 79, .12); }

/* ---------------------------------------------------------------- photos */
.photo-card img {
  width: 100%; aspect-ratio: 4 / 3; object-fit: cover; display: block;
  background: var(--paper-deep);
}
.photo-card .caption { padding: 13px 15px; display: flex; flex-direction: column; gap: 4px; flex: 1; }

.photo-card { position: relative; }
.photo-card.selected {
  border-color: var(--action);
  box-shadow: 0 0 0 2px rgba(36, 52, 79, .28), var(--shadow);
}
.photo-pick {
  position: absolute; top: 10px; left: 10px; z-index: 2;
  display: flex; align-items: center; gap: 6px;
  background: rgba(252, 251, 247, .95); border: 1px solid var(--line-strong);
  border-radius: 999px; padding: 4px 12px 4px 9px;
  font-size: .78rem; font-weight: 600; cursor: pointer;
  backdrop-filter: blur(3px);
}
.photo-pick input { accent-color: var(--action); }
.select-bar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 18px;
  background: #f6efdd; border: 1px solid var(--brass);
  border-radius: var(--radius-sm); padding: 12px 16px;
}

/* albums */
.album-shelf { display: flex; gap: 14px; overflow-x: auto; padding: 4px 2px 18px; }
.album-tile {
  flex: none; width: 158px; background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 10px; text-align: left;
  display: flex; flex-direction: column; gap: 5px; box-shadow: var(--shadow);
  transition: transform .15s, border-color .15s, box-shadow .15s; cursor: pointer;
}
.album-tile:hover { transform: translateY(-2px); border-color: var(--brass); }
.album-tile.on { border-color: var(--action); box-shadow: 0 0 0 2px rgba(36, 52, 79, .2), var(--shadow); }
.album-cover {
  width: 100%; aspect-ratio: 4 / 3; border-radius: 6px; overflow: hidden;
  background: var(--paper-deep); display: flex; align-items: center; justify-content: center;
}
.album-cover img { width: 100%; height: 100%; object-fit: cover; }
.album-empty { font-size: 1.6rem; color: var(--line-strong); }
.album-tile strong { font-size: .9rem; line-height: 1.3; }
.album-tile small { color: var(--ink-soft); font-size: .78rem; }

/* ---------------------------------------------------------------- tree */
.tree-wrap {
  overflow-x: auto; padding: 30px 16px; position: relative;
  background:
    radial-gradient(circle at 1px 1px, rgba(33, 40, 54, .05) 1px, transparent 0) 0 0 / 26px 26px,
    var(--card);
  border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
}
.tree { display: flex; flex-direction: column; gap: 58px; min-width: min-content; position: relative; }
.generation { display: flex; gap: 36px; justify-content: center; align-items: flex-start; }
.gen-label {
  font-size: .68rem; letter-spacing: .26em; text-transform: uppercase;
  color: var(--brass-deep); font-weight: 700; text-align: center; margin-bottom: -42px;
}
.member-node {
  display: flex; flex-direction: column; align-items: center; gap: 5px;
  width: 134px; text-align: center;
  background: var(--card); border: 1px solid var(--line-strong); border-radius: var(--radius);
  padding: 15px 10px 13px; box-shadow: var(--shadow);
  cursor: pointer; transition: transform .13s, border-color .13s, box-shadow .13s;
}
.member-node:hover { transform: translateY(-3px); border-color: var(--brass); box-shadow: var(--shadow-lift); }
.member-node .circle {
  width: 50px; height: 50px; border-radius: 50%;
  background: linear-gradient(150deg, var(--midnight-3), var(--midnight));
  color: #ecdfb8; box-shadow: 0 0 0 1px var(--brass), 0 0 0 4px var(--brass-soft);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; overflow: hidden; margin-bottom: 3px;
}
.member-node .circle img { width: 100%; height: 100%; object-fit: cover; }
.member-node.deceased .circle {
  background: linear-gradient(150deg, #5d6067, #43464d);
  box-shadow: 0 0 0 1px var(--line-strong), 0 0 0 4px var(--paper-deep);
}
.member-node.deceased { background: linear-gradient(180deg, var(--card), var(--paper-deep)); }
.member-node strong { font-size: .87rem; line-height: 1.25; }
.member-node small { font-size: .74rem; color: var(--ink-soft); }
.couple { display: flex; gap: 12px; align-items: center; position: relative; }
.couple .knot { font-size: 1rem; color: var(--brass); }
#tree-lines { position: absolute; inset: 0; pointer-events: none; }
#tree-lines path, #tree-lines line { stroke: var(--brass); stroke-opacity: .55; }

/* ---------------------------------------------------------------- capsules */
.capsule-card .inner { position: relative; }
.capsule-card.locked {
  border: 1px dashed var(--brass);
  background:
    repeating-linear-gradient(0deg, transparent, transparent 27px, rgba(165, 130, 61, .07) 27px, rgba(165, 130, 61, .07) 28px),
    #f8f4e8;
}
.capsule-card.locked .inner { background: transparent; }
.seal {
  width: 46px; height: 46px; border-radius: 50%; flex: none;
  background: radial-gradient(circle at 35% 30%, #b0503f, var(--wax) 55%, var(--wax-deep));
  color: #f7e9dd; font-size: 1.15rem;
  display: flex; align-items: center; justify-content: center;
  box-shadow: inset 0 0 0 3px rgba(247, 233, 221, .28), 0 2px 6px rgba(124, 45, 34, .35);
}
.capsule-letter {
  font-family: var(--display); font-size: 1.12rem; line-height: 1.7;
  white-space: pre-wrap; color: var(--ink);
}

.addressed-capsule {
  display: flex; gap: 12px; align-items: flex-start; padding: 13px 14px;
  border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--card);
}
.addressed-capsule.sealed {
  background: #f8f4e8; border: 1px dashed var(--brass);
}

/* ---------------------------------------------------------------- settings */
.settings-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(310px, 1fr)); gap: 20px; align-items: start; }
.invite-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 1.35rem; letter-spacing: .18em; color: var(--ink);
  background: #f8f4e8; border: 1px dashed var(--brass);
  border-radius: var(--radius-sm); padding: 14px 18px; text-align: center;
}
.member-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 11px 0; border-bottom: 1px solid var(--line);
}
.member-row:last-child { border-bottom: none; }
.role-select {
  text-transform: capitalize; padding: 7px 10px; border: 1px solid var(--line-strong);
  border-radius: 7px; background: var(--card); font-size: .86rem; cursor: pointer;
}

.invite-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap;
}
.invite-row:last-child { border-bottom: none; }

/* ---------------------------------------------------------------- chips & filters */
.filter-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 0 0 20px; }
.chip {
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--card); border: 1px solid var(--line-strong);
  border-radius: 999px; padding: 7px 15px; font-size: .88rem; font-weight: 500;
  color: var(--ink); cursor: pointer;
  transition: border-color .15s, background .15s, color .15s;
}
.chip:hover { border-color: var(--brass); }
.chip.on { background: var(--action); border-color: var(--action); color: #f2f0e8; }
.chip-count {
  background: rgba(33, 40, 54, .08); border-radius: 999px; padding: 1px 8px;
  font-size: .74rem; font-weight: 700; font-variant-numeric: lining-nums;
}
.chip.on .chip-count { background: rgba(242, 240, 232, .22); color: #fff; }

/* person tag chips inside modals */
.tag-grid { display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0 14px; }
.tag-check {
  display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px;
  border: 1px solid var(--line-strong); border-radius: 999px; cursor: pointer;
  font-size: .86rem; font-weight: 500; background: var(--card);
  transition: border-color .15s, background .15s, color .15s; user-select: none;
}
.tag-check:hover { border-color: var(--brass); }
.tag-check input { display: none; }
.tag-check.on { background: var(--action); color: #f2f0e8; border-color: var(--action); }

/* ---------------------------------------------------------------- modal & toast */
.modal {
  position: fixed; inset: 0; background: rgba(16, 21, 33, .58);
  backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center; z-index: 100; padding: 18px;
}
.modal-card {
  background: var(--paper); border: 1px solid var(--line);
  border-top: 3px solid var(--brass);
  border-radius: var(--radius); padding: 30px; width: 100%; max-width: 580px;
  max-height: 88vh; overflow-y: auto; position: relative;
  box-shadow: 0 24px 70px rgba(10, 14, 24, .4);
  animation: modalin .18s ease;
}
@keyframes modalin { from { opacity: 0; transform: translateY(8px) scale(.99); } to { opacity: 1; } }
.modal-close {
  position: absolute; top: 12px; right: 14px; background: none; border: none;
  font-size: 1.6rem; line-height: 1; color: var(--ink-soft); padding: 6px;
  border-radius: 6px; transition: color .15s, background .15s;
}
.modal-close:hover { color: var(--ink); background: var(--paper-deep); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.modal-card form { display: flex; flex-direction: column; gap: 14px; margin-top: 10px; }
.modal-card textarea {
  min-height: 140px; resize: vertical; padding: 12px 14px;
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  background: var(--card); line-height: 1.6;
}
.modal-card textarea:focus { outline: none; border-color: var(--action); box-shadow: 0 0 0 3px rgba(36, 52, 79, .12); }

.toast {
  position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%);
  background: var(--midnight); color: #f0ede3;
  border: 1px solid rgba(196, 162, 84, .45);
  padding: 12px 22px; border-radius: 999px; font-size: .92rem; font-weight: 500;
  z-index: 200; box-shadow: 0 10px 30px rgba(10, 14, 24, .35);
  animation: toastin .2s ease;
}
@keyframes toastin { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* ---------------------------------------------------------------- responsive */
.mobile-only { display: none; }
@media (max-width: 920px) {
  body { font-size: 15.5px; }
  .auth-shell { grid-template-columns: 1fr; }
  .auth-brand { padding: 46px 8%; min-height: 38vh; }
  .auth-brand::before { inset: 14px; }
  .auth-brand::after { display: none; }
  .auth-card { padding: 40px 7% 60px; }
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; width: 262px; z-index: 60;
    transform: translateX(-100%); transition: transform .22s ease; height: 100dvh;
    box-shadow: 8px 0 40px rgba(10, 14, 24, .35);
  }
  .sidebar.open { transform: translateX(0); }
  .scrim.show { display: block; position: fixed; inset: 0; background: rgba(16, 21, 33, .45); z-index: 50; }
  .mobile-only { display: inline-flex; align-items: center; justify-content: center; }
  .topbar { padding: 12px 16px; }
  #global-search { width: 120px; }
  #global-search:focus { width: 160px; }
  .page { padding: 20px 16px 70px; }
  .hero { padding: 28px 22px; }
  .hero::before { inset: 8px; }
  .form-row { grid-template-columns: 1fr; }
  .year-rule { font-size: 1.3rem; }
}

/* profile avatar block */
.profile-avatar-wrap { display: flex; flex-direction: column; align-items: center; min-width: 88px; gap: 6px; }
.profile-avatar-wrap .avatar { border: 2px solid var(--brass); box-shadow: 0 3px 12px rgba(20, 27, 42, .2); }

/* print: the archive should print like a document */
@media print {
  .sidebar, .topbar, .scrim, .toast, .modal { display: none !important; }
  .app { grid-template-columns: 1fr; }
  body { background: #fff; }
  .card, .person-card, .story-card, .capsule-card { box-shadow: none; }
}
