:root {
  --bg: #f6f1e8;
  --surface: #ffffff;
  --surface-2: #fbf8f2;
  --ink: #1f2a24;
  --muted: #69706a;
  --line: #e7dfd1;
  --green: #1d5c3f;
  --green-ink: #ffffff;
  --green-soft: #e3eee6;
  --red: #b3262e;
  --red-soft: #f9e5e4;
  --gold: #b7862a;
  --gold-soft: #f7edd5;
  --plum: #6a3d7c;
  --plum-soft: #f1e7f4;
  --shadow: 0 1px 2px rgba(31, 42, 36, 0.06), 0 4px 14px rgba(31, 42, 36, 0.05);
  --radius: 16px;
  --serif: ui-serif, "New York", "Iowan Old Style", Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121714;
    --surface: #1b221e;
    --surface-2: #161c19;
    --ink: #ecebe5;
    --muted: #a3aaa4;
    --line: #2d3731;
    --green: #4fa57a;
    --green-ink: #0d1510;
    --green-soft: #1f3328;
    --red: #e5737a;
    --red-soft: #3a2224;
    --gold: #e0b45a;
    --gold-soft: #3a3020;
    --plum: #c79bdb;
    --plum-soft: #2f2236;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 17px/1.45 var(--sans);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { font-family: var(--serif); line-height: 1.2; margin: 0; font-weight: 650; }
h1 { font-size: 30px; }
h2 { font-size: 21px; }
h3 { font-size: 19px; }
p { margin: 0; }
a { color: var(--green); }
small, .muted { color: var(--muted); }
.muted { font-size: 15px; }

.wrap { max-width: 760px; margin: 0 auto; padding: 0 16px 64px; }
.narrow { max-width: 460px; }
.center-page { min-height: 100vh; display: flex; align-items: center; padding-top: 24px; }
.center-page .card { width: 100%; text-align: center; display: grid; gap: 14px; }
.stack { display: grid; gap: 14px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.hidden { display: none !important; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  -webkit-backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
}
.topbar-inner { max-width: 760px; margin: 0 auto; padding: 10px 16px; display: flex; align-items: center; gap: 10px; }
.topbar .brand { min-width: 0; }
.who { margin-left: auto; display: flex; align-items: center; gap: 8px; color: var(--ink); text-decoration: none; font-weight: 600; font-size: 15px; flex: none; }
.who /* ---------- people ---------- */
.avatar { width: 30px; height: 30px; font-size: 14px; }
.name-btn:disabled { cursor: default; border-color: var(--green); }
.brand { font-family: var(--serif); font-weight: 650; font-size: 18px; color: var(--ink); text-decoration: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand .season { color: var(--muted); font-weight: 500; }

.page-head { padding: 22px 0 14px; display: grid; gap: 6px; }
.back { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); text-decoration: none; font-size: 15px; margin-bottom: 4px; width: fit-content; }
.back:hover { color: var(--ink); }

/* ---------- cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
}
.card + .card { margin-top: 14px; }
.section-title { margin: 28px 0 12px; font-size: 20px; }

.big-link { display: flex; align-items: center; gap: 14px; text-decoration: none; color: inherit; }
.big-link .chev { margin-left: auto; color: var(--muted); font-size: 26px; line-height: 1; }
.big-link .emoji { font-size: 30px; }
.big-link p { color: var(--muted); font-size: 15px; margin-top: 2px; }

.avatar {
  width: 44px; height: 44px; border-radius: 50%; flex: none;
  display: grid; place-items: center;
  font-family: var(--serif); font-weight: 700; font-size: 19px; color: #fff;
}
.av-0 { background: #1d5c3f; } .av-1 { background: #b3262e; } .av-2 { background: #b7862a; }
.av-3 { background: #2f5d7c; } .av-4 { background: #6a3d7c; } .av-5 { background: #8a5a3c; }

/* ---------- buttons & forms ---------- */
.btn {
  appearance: none; border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  font: 600 16px/1 var(--sans); padding: 12px 16px; border-radius: 12px; min-height: 44px;
  cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  text-decoration: none; white-space: nowrap;
}
.btn:hover { border-color: color-mix(in srgb, var(--ink) 25%, var(--line)); }
.btn:disabled { opacity: 0.55; cursor: default; }
.btn-primary { background: var(--green); border-color: var(--green); color: var(--green-ink); }
.btn-primary:hover { border-color: var(--green); filter: brightness(1.06); }
.btn-claim { background: var(--red); border-color: var(--red); color: #fff; }
.btn-claim:hover { border-color: var(--red); filter: brightness(1.06); }
.btn-soft { background: var(--surface-2); }
.btn-small { font-size: 14px; padding: 8px 12px; min-height: 36px; border-radius: 10px; }
.btn-big { font-size: 18px; padding: 16px 22px; min-height: 54px; width: 100%; }
.btn-link { background: none; border: none; padding: 4px 2px; min-height: 0; color: var(--muted); font-weight: 500; text-decoration: underline; text-underline-offset: 3px; }
.btn-link:hover { color: var(--ink); }
.btn-danger-text { color: var(--red); }

.field { display: grid; gap: 6px; }
.field .label, .label { font-weight: 600; font-size: 15px; }
.field .hint { font-weight: 400; color: var(--muted); }
input[type=text], input[type=email], input[type=tel], input[type=url], input[type=search], input:not([type]), textarea, select {
  width: 100%; font: 17px/1.35 var(--sans); color: var(--ink);
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px;
  padding: 12px 13px; min-height: 48px;
}
textarea { min-height: 76px; resize: vertical; }
input:focus, textarea:focus, select:focus, .btn:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--green) 35%, transparent); outline-offset: 1px; border-color: var(--green);
}
.two-col { display: grid; gap: 12px; grid-template-columns: 1fr 2fr; }
@media (max-width: 420px) { .two-col { grid-template-columns: 1fr; } }

.check { display: flex; gap: 10px; align-items: flex-start; font-size: 16px; cursor: pointer; }
.check input { width: 22px; height: 22px; margin: 1px 0 0; accent-color: var(--green); flex: none; }

.form-card h2 { margin-bottom: 4px; }
/* Add forms start as one field; the rest appears once you start. */
.collapsible .more { display: none; }
.collapsible:focus-within .more, .collapsible[data-dirty] .more { display: grid; }
.wrap > .notice + .card, .wrap > .card + .notice, .wrap > .notice + .quick { margin-top: 14px; }
.form-card form { display: grid; gap: 12px; margin-top: 12px; }

/* ---------- notices ---------- */
.notice { border-radius: 14px; padding: 12px 14px; font-size: 15px; display: flex; gap: 10px; align-items: flex-start; }
.notice .ico { font-size: 20px; line-height: 1.1; }
.notice-calm { background: var(--green-soft); }
.notice-secret { background: var(--plum-soft); }
.notice-warn { background: var(--gold-soft); }
.notice-dev { background: var(--gold-soft); font-family: ui-monospace, monospace; font-size: 14px; }

/* ---------- badges & tags ---------- */
.badge { font-size: 13px; font-weight: 600; padding: 3px 9px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
.badge-ready { background: var(--green-soft); border-color: transparent; color: var(--green); }
.bought-tag { font-size: 13px; color: var(--green); font-weight: 700; }

.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.actions .spacer { flex: 1; }
.thread { display: grid; gap: 8px; background: var(--surface-2); border-radius: 12px; padding: 10px 12px; }
.note-row { font-size: 15px; display: grid; gap: 1px; }
.note-row .by { font-weight: 700; font-size: 14px; }
.note-row .when { color: var(--muted); font-weight: 400; }
.note-row .body { white-space: pre-wrap; word-break: break-word; }
.inline-form { display: flex; gap: 8px; align-items: flex-end; }
.inline-form input, .inline-form textarea { min-height: 44px; }
.inline-form textarea { min-height: 44px; height: 44px; }

.empty { text-align: center; color: var(--muted); padding: 28px 12px; }
.empty .big { font-size: 40px; display: block; margin-bottom: 6px; }

/* ---------- login ---------- */
.hero { text-align: center; padding: 40px 0 22px; display: grid; gap: 6px; }
.hero .tree { font-size: 54px; line-height: 1; }
.hero h1 { font-size: 32px; }
.name-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; margin-top: 14px; }
.name-btn { font: 650 19px/1.2 var(--serif); padding: 18px 10px; border-radius: 14px; border: 1px solid var(--line); background: var(--surface-2); color: var(--ink); cursor: pointer; display: grid; justify-items: center; gap: 8px; }
.name-btn:hover { border-color: var(--green); }
.code-input { font: 700 32px/1 ui-monospace, monospace !important; letter-spacing: 10px; text-align: center; padding: 14px !important; }

/* ---------- admin ---------- */
.person-admin { display: grid; gap: 10px; padding: 14px 0; border-top: 1px solid var(--line); }
.person-admin:first-of-type { border-top: none; padding-top: 4px; }
.person-admin.inactive { opacity: 0.6; }
.person-admin .grid { display: grid; gap: 8px; grid-template-columns: 1fr 1fr 1fr; }
@media (max-width: 560px) { .person-admin .grid { grid-template-columns: 1fr; } }
.person-admin details summary { cursor: pointer; font-size: 15px; }
.keeper-choices { gap: 6px 16px; margin-top: 8px; }
.linkbox { display: grid; gap: 8px; background: var(--green-soft); padding: 12px; border-radius: 12px; }
.linkbox input { font-size: 14px; font-family: ui-monospace, monospace; }
.status-line { display: flex; gap: 8px; align-items: baseline; font-size: 15px; }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: max(18px, env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(20px);
  background: var(--ink); color: var(--bg); padding: 12px 18px; border-radius: 12px; font-size: 15px; font-weight: 600;
  opacity: 0; transition: opacity 0.2s, transform 0.2s; pointer-events: none; z-index: 50; max-width: calc(100% - 32px); text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.error { background: var(--red); color: #fff; }

.loading { text-align: center; padding: 60px 0; color: var(--muted); }
footer.foot { margin-top: 36px; display: flex; gap: 16px; justify-content: center; flex-wrap: wrap; }
.linkbox .btn-link { white-space: normal; text-align: left; line-height: 1.35; }

/* ---------- spreadsheet ---------- */
.quick { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.quick .card + .card { margin-top: 0; }
.sheet-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; margin-top: 14px; }
.sheet { width: 100%; border-collapse: collapse; font-size: 15px; }
.sheet th {
  text-align: left; font: 700 12px/1.2 var(--sans); text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--muted); background: var(--surface-2); padding: 9px 12px; border-bottom: 1px solid var(--line);
}
.sheet td { padding: 11px 12px; border-top: 1px solid var(--line); vertical-align: top; }
.sheet tbody tr:first-child td { border-top: none; }
.sheet .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; width: 1%; }
.sheet td.num { font-weight: 600; }
.sheet .act { width: 1%; text-align: right; }
.sheet .giving { width: 1%; white-space: nowrap; text-align: right; }
.sheet .check-col { width: 1%; text-align: center; }
.sheet .check-col input { width: 22px; height: 22px; accent-color: var(--green); margin: 0; }
.sheet tfoot td { font-weight: 700; background: var(--surface-2); }
.sheet a { text-decoration: none; }

.row-link, .row-toggle { cursor: pointer; }
.row-link:hover td, .row-toggle:hover td { background: color-mix(in srgb, var(--surface-2) 70%, transparent); }
.row-secret td:first-child { box-shadow: inset 3px 0 0 var(--plum); }
.row-removed .item-title { text-decoration: line-through; color: var(--muted); }
.row-open td { background: var(--surface-2); }
.row-done .item-title { text-decoration: line-through; color: var(--muted); }
.row-detail td { border-top: none; background: var(--surface-2); padding-top: 0; }
.row-editing td { background: var(--surface-2); }

.cell-item { display: grid; gap: 3px; min-width: 0; }
.item-title { font-weight: 650; word-break: break-word; }
.item-sub {
  color: var(--muted); font-size: 14px; word-break: break-word;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.item-meta { display: flex; gap: 6px 10px; flex-wrap: wrap; align-items: center; font-size: 13px; color: var(--muted); }
.item-meta a { font-weight: 600; }
.more-toggle { color: var(--green); font-weight: 600; }

.person-cell { display: flex; gap: 10px; align-items: center; color: inherit; }
.person-cell .avatar { width: 34px; height: 34px; font-size: 15px; }
.person-cell span { display: grid; }
.person-cell small { color: var(--muted); font-size: 13px; }

.giver { font-weight: 650; }
.giver.me { color: var(--red); }
.giving small { color: var(--muted); }
.removed-tag { color: var(--red); font-weight: 600; font-size: 13px; }

.tag { font-size: 12px; font-weight: 650; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
.tag-secret { background: var(--plum-soft); border-color: transparent; color: var(--plum); }
.tag-new { background: var(--red); border-color: transparent; color: #fff; }

.detail-body { display: grid; gap: 12px; padding: 4px 0 6px; }
.detail-body .details { white-space: pre-wrap; word-break: break-word; }
.detail-section { display: grid; gap: 8px; }
.detail-section .label { font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
.claim-line { font-size: 15px; }
.small { font-size: 13px; }
.hint-line { color: var(--muted); font-size: 14px; }
.stack-sm { display: grid; gap: 6px; }

/* ---------- tabs (like the old sheet's tabs) ---------- */
.tabs { border-top: 1px solid var(--line); }
.tabs-inner { max-width: 760px; margin: 0 auto; padding: 0 12px; display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; }
.tabs-inner::-webkit-scrollbar { display: none; }
.tab {
  position: relative; flex: none; padding: 10px 12px; font-size: 15px; font-weight: 600; color: var(--muted);
  text-decoration: none; border-bottom: 3px solid transparent; white-space: nowrap;
}
.tab:hover { color: var(--ink); }
.tab.on { color: var(--ink); border-bottom-color: var(--green); }
.tab .dot { position: absolute; top: 8px; right: 4px; width: 7px; height: 7px; border-radius: 50%; background: var(--red); }

/* ---------- dialog ---------- */
.dialog {
  border: none; border-radius: 18px; padding: 0; width: min(92vw, 400px);
  background: var(--surface); color: var(--ink); box-shadow: 0 24px 70px rgba(0, 0, 0, 0.28);
}
.dialog::backdrop { background: rgba(18, 24, 20, 0.45); }
.dialog-body { padding: 22px 20px 18px; display: grid; gap: 10px; }
.dialog-body p { color: var(--muted); }
.dialog-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 8px; }
.btn-danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn-danger:hover { border-color: var(--red); filter: brightness(1.06); }

@media (max-width: 480px) {
  .sheet { font-size: 14px; }
  .sheet td, .sheet th { padding-left: 9px; padding-right: 9px; }
}
.sheet-wrap + .card, .card + .sheet-wrap { margin-top: 14px; }

/* ---------- photos, partners, search ---------- */
img.avatar { object-fit: cover; background: var(--surface-2); }
.avatar-xl { width: 96px; height: 96px; font-size: 40px; }
.photo-row { display: flex; gap: 16px; align-items: center; }
.photo-pick { cursor: pointer; display: inline-flex; position: relative; }
.photo-pick::after { content: '📷'; position: absolute; right: -4px; bottom: -4px; font-size: 13px; background: var(--surface); border-radius: 50%; line-height: 1; padding: 2px; }
.people-search { margin: 10px 0 4px; }
.inline-field { grid-template-columns: auto 1fr; align-items: center; gap: 10px; }
