:root {
  --bg: #f6f3ee;
  --surface: #ffffff;
  --ink: #23201c;
  --muted: #6f675d;
  --line: #e4ddd2;
  --brand: #b23a3a;
  --brand-ink: #ffffff;
  --brand-soft: #f8e7e4;
  --ok: #2f7d4f;
  --ok-soft: #e3f2e8;
  --err: #a8322d;
  --err-soft: #fbe5e3;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 2px 8px rgba(0,0,0,.04);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1b1916;
    --surface: #25221e;
    --ink: #eee8df;
    --muted: #a69d90;
    --line: #3a352e;
    --brand: #e0675f;
    --brand-ink: #1b1916;
    --brand-soft: #3a2422;
    --ok: #6cc08c;
    --ok-soft: #1f3327;
    --err: #f08a82;
    --err-soft: #3a2220;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--brand); }
h1 { font-size: 1.6rem; margin: 1.2rem 0 .6rem; }
h2 { font-size: 1.15rem; margin: 0 0 .6rem; }
code { background: var(--brand-soft); padding: 0 .3em; border-radius: 4px; }

.wrap { max-width: 1040px; margin: 0 auto; padding: 0 16px; }
/* Header stays locked at the top while the page scrolls. */
.topbar {
  position: sticky; top: 0; z-index: 100;
  background: var(--surface); border-bottom: 1px solid var(--line);
  box-shadow: 0 1px 6px rgba(0,0,0,.06);
}
/* Jumping to #item-12 etc. lands below the header instead of under it (height set by script). */
html { scroll-padding-top: calc(var(--header-h, 64px) + 12px); }
.topbar-inner { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; padding-top: 10px; padding-bottom: 10px; }
.brand { font-weight: 700; color: var(--ink); text-decoration: none; font-size: 1.05rem; }
.nav { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
.nav a, .linkish {
  color: var(--muted); text-decoration: none; padding: 6px 10px; border-radius: 6px;
  font: inherit; background: none; border: 0; cursor: pointer;
}
.nav a:hover, .linkish:hover { color: var(--ink); background: var(--bg); }
.nav a.active { color: var(--brand); background: var(--brand-soft); font-weight: 600; }
.foot { color: var(--muted); font-size: .85rem; padding-top: 32px; padding-bottom: 32px; text-align: center; }

.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; margin: 0 0 16px; box-shadow: var(--shadow);
}
.card.narrow { max-width: 420px; margin: 40px auto; }
.danger-zone { border-color: var(--err); }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.right { text-align: right; }
.center { text-align: center; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.dim { opacity: .55; }
.inline { display: inline; margin: 0; }

.flash { padding: 10px 14px; border-radius: 8px; margin: 12px 0; }
.flash-ok { background: var(--ok-soft); color: var(--ok); }
.flash-err { background: var(--err-soft); color: var(--err); }

/* Forms */
label { display: flex; flex-direction: column; gap: 4px; font-size: .9rem; color: var(--muted); }
label.check { flex-direction: row; align-items: center; gap: 8px; color: var(--ink); }
input, select, textarea {
  font: inherit; color: var(--ink); background: var(--bg);
  border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; width: 100%;
}
input[type=checkbox], input[type=radio] { width: 18px; height: 18px; flex: none; margin: 0; padding: 0; accent-color: var(--brand); }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand); outline-offset: 0; border-color: transparent; }
input:disabled { opacity: .6; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.grid-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; align-items: end; margin-top: 12px; }
.span-2 { grid-column: 1 / -1; }
.inline-form { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.inline-form input:not(.w-sm) { flex: 1 1 200px; width: auto; }
.w-sm { width: 90px; }
.row-form { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.row-form:last-child { border-bottom: 0; }
.row-form .inline-form { flex: 1 1 auto; }
.two-col { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }

.btn {
  display: inline-flex; align-items: center; gap: 6px; justify-content: center;
  font: inherit; font-weight: 600; text-decoration: none; cursor: pointer;
  padding: 8px 14px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); white-space: nowrap;
}
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.primary:hover { filter: brightness(1.05); }
.btn.danger { color: var(--err); }
.btn.danger:hover { border-color: var(--err); background: var(--err-soft); }
.btn.small { padding: 4px 10px; font-size: .85rem; }

/* Tabs */
.tabs { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0 16px; }
.tabs a {
  padding: 6px 12px; border-radius: 999px; text-decoration: none; color: var(--muted);
  border: 1px solid var(--line); background: var(--surface); font-size: .9rem;
}
.tabs a.active { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); font-weight: 600; }

/* Tables */
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 8px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
.table thead th { font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.table tr:last-child td { border-bottom: 0; }
.scroll-x { overflow-x: auto; }
.matrix th.center, .matrix td.center { text-align: center; min-width: 80px; }
.pill { display: inline-block; font-size: .75rem; font-weight: 600; padding: 1px 8px; border-radius: 999px; background: var(--brand-soft); color: var(--brand); margin-left: 6px; vertical-align: middle; }
.pill.ok { background: var(--ok-soft); color: var(--ok); }

/* Wish-list items */
.add-card summary { cursor: pointer; color: var(--brand); }
.list-section { margin: 20px 0; }
.items { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.item {
  display: flex; flex-wrap: wrap; gap: 12px; justify-content: space-between; align-items: flex-start;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px;
}
.item.bought { border-color: var(--ok); background: var(--ok-soft); }
.item-main { flex: 1 1 260px; min-width: 0; }
.item-title { font-weight: 600; overflow-wrap: anywhere; }
.item-meta { display: flex; flex-wrap: wrap; gap: 10px; font-size: .85rem; color: var(--muted); margin-top: 2px; }
.item-details { font-size: .9rem; margin-top: 6px; color: var(--ink); overflow-wrap: anywhere; }
.item-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.prio-1 { color: var(--brand); font-weight: 600; }

/* Questions & answers */
.flash-info { background: var(--brand-soft); color: var(--ink); }
.badge {
  display: inline-block; min-width: 1.4em; padding: 0 6px; border-radius: 999px;
  background: var(--brand); color: var(--brand-ink); font-size: .75rem; font-weight: 700;
  line-height: 1.4em; text-align: center; vertical-align: 1px;
}
/* Counts next to menu items and admin tabs: a red circle with the number inside. */
.nav .badge, .tabs .badge {
  display: inline-flex; align-items: center; justify-content: center;
  box-sizing: border-box; min-width: 22px; height: 22px; padding: 0 5px; margin-left: 4px;
  border-radius: 11px; /* a perfect circle for 1 digit, stretches into a pill for 10+ */
  background: #d93025; color: #fff; border: 2px solid var(--surface);
  font-size: .72rem; font-weight: 700; line-height: 1; vertical-align: middle;
}
.tabs a.active .badge { border-color: var(--brand); }
.item.needs-answer { border-color: var(--brand); }
.item-qa { flex: 1 1 100%; border-top: 1px dashed var(--line); padding-top: 8px; display: flex; flex-direction: column; gap: 8px; }
.qa { font-size: .92rem; padding: 6px 8px; border-radius: 8px; }
.qa-new { background: var(--brand-soft); }
.qa-q, .qa-a { overflow-wrap: anywhere; }
.qa-a { margin-top: 4px; }
.qa-label { font-weight: 700; font-style: normal; color: var(--ok); }
.qa-text { font-style: italic; }
.ask summary { cursor: pointer; color: var(--brand); font-size: .9rem; }
.ask-form { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; }
.ask-form .btn { align-self: flex-start; }
.ask form.inline { display: inline-block; margin-top: 4px; }
.linkish.small { padding: 2px 4px; font-size: .85rem; color: var(--muted); text-decoration: underline; }
.answers { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.answers li { border-left: 3px solid var(--brand); padding-left: 10px; }

/* Things you've gotten */
.subtotal td { font-size: .85rem; color: var(--muted); font-style: italic; }
.nowrap { white-space: nowrap; }
.list-section > .add-card { margin-top: 12px; }

/* Collapsible category sections (All view) */
.foldable > h2 { cursor: pointer; user-select: none; display: flex; align-items: baseline; gap: 6px; }
.foldable > h2::before {
  content: ""; flex: none; width: .55em; height: .55em; margin-right: 2px;
  border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted);
  transform: rotate(45deg) translate(-2px, -2px); transition: transform .15s;
}
.foldable.collapsed > h2::before { transform: rotate(-45deg); }
.foldable > h2:hover { color: var(--brand); }
.foldable > h2:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 4px; }
.foldable.collapsed > :not(h2) { display: none; }
.foldable.collapsed { margin-bottom: 8px; }
.fold-toolbar { display: flex; gap: 8px; justify-content: flex-end; margin: -4px 0 -8px; }

/* Categories & access */
.check-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 8px 16px; margin-top: 8px; }
fieldset.plain { border: 0; padding: 0; margin: 0; }
.choice-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 10px; margin-top: 6px; }
.choice-row label.check {
  justify-content: flex-start; align-items: flex-start; gap: 10px; text-align: left;
  border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; cursor: pointer;
}
.choice-row label.check > span { flex: 1; text-align: left; }
.choice-row label.check:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); }
.choice-row input { margin-top: 2px; }
.card:target { outline: 2px solid var(--brand); }
button:disabled { opacity: .5; cursor: not-allowed; }
.section-title { margin-top: 28px; }
.w-auto { width: auto; flex: 0 1 auto; }
.tabs a.tab-action { border-style: dashed; color: var(--brand); }
.tabs a.active .cat-tag { color: var(--brand-ink); border-color: var(--brand-ink); }
.cat-tag { font-size: .7rem; font-weight: 600; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 0 6px; margin-left: 4px; vertical-align: 1px; }

/* Contact page */
.placeholder-select:invalid { color: var(--muted); }
.placeholder-select option { color: var(--ink); }
.card.narrow.wide { max-width: 560px; }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

/* Message threads */
.contact-page { max-width: 760px; margin: 0 auto; }
.contact-page .card.narrow { margin-top: 16px; }
.thread { display: flex; flex-direction: column; gap: 10px; }
.bubble { max-width: 85%; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line); overflow-wrap: anywhere; }
.bubble.them { align-self: flex-start; background: var(--bg); }
.bubble.me { align-self: flex-end; background: var(--brand-soft); border-color: transparent; }
.bubble-head { margin-bottom: 4px; font-size: .9rem; }
.reply-form { margin-top: 16px; border-top: 1px solid var(--line); padding-top: 12px; }
.msg-list { list-style: none; margin: 0; padding: 0; }
.msg-list li { padding: 10px 0; border-bottom: 1px solid var(--line); }
.msg-list li:last-child { border-bottom: 0; }
.msg-list li.unread a { font-weight: 700; }

/* Help page */
html { scroll-behavior: smooth; }
.help section { scroll-margin-top: 16px; }
.help h3 { font-size: 1rem; margin: 1rem 0 .4rem; }
.help p, .help li, .help dd { max-width: 70ch; }
.help li { margin: 4px 0; }
.toc ol { margin: 6px 0 0; padding-left: 22px; columns: 2 220px; }
.faq dt { font-weight: 600; margin-top: 12px; }
.faq dt:first-child { margin-top: 0; }
.faq dd { margin: 2px 0 0; color: var(--ink); }

/* Family grid */
.member-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.member { display: flex; align-items: center; gap: 12px; text-decoration: none; color: var(--ink); margin: 0; }
.member:hover { border-color: var(--brand); }
.avatar {
  width: 42px; height: 42px; border-radius: 50%; flex: none;
  display: grid; place-items: center; font-weight: 700;
  background: var(--brand-soft); color: var(--brand);
}
