:root {
  --bg: #f3f5f1; --bg2: #e6efe9; --surface: #ffffff; --ink: #18221f; --muted: #5d6c66;
  --line: #dbe2dc; --accent: #17695a; --accent-hover: #115246; --accent-ink: #ffffff; --accent-soft: #dff0e9;
  --danger: #b3382c; --done: #8a948f; --gold: #c9892b; --gold-soft: #fbf0dc;
  --shadow: 0 1px 2px rgba(20, 40, 33, .06), 0 6px 18px rgba(20, 40, 33, .06);
  --display: "Bricolage Grotesque", system-ui, sans-serif;
  --body: "Figtree", system-ui, sans-serif;
  --av0: #17695a; --av1: #8a4fa3; --av2: #c9582c; --av3: #2f6fb5; --av4: #b0801f; --av5: #b0435f;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101614; --bg2: #16211d; --surface: #19211e; --ink: #e8eeeb; --muted: #97a69f;
    --line: #2a3733; --accent: #4cb59a; --accent-hover: #6cc9b0; --accent-ink: #08130f; --accent-soft: #1d322b;
    --danger: #ef7a6d; --done: #6c7a74; --gold: #e0a64e; --gold-soft: #2f2616;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 18px rgba(0, 0, 0, .25);
    --av0: #3a9a85; --av1: #b07acb; --av2: #e07a4f; --av3: #5a95d8; --av4: #d6a23f; --av5: #d8708a;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.55 var(--body); min-height: 100vh; }
a { color: var(--accent); text-underline-offset: 3px; }
h1, h2 { font-family: var(--display); line-height: 1.15; text-wrap: balance; margin: 0; letter-spacing: -.01em; }
h1 { font-size: clamp(1.9rem, 6vw, 2.8rem); }
h2 { font-size: 1.2rem; }

/* header */
.topwrap { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.top, main { max-width: 780px; margin: 0 auto; padding-inline: max(16px, env(safe-area-inset-left, 0px)); }
.top { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding-block: 12px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; font: 700 1.15rem var(--display); color: var(--ink); text-decoration: none; }
.logo { width: 32px; height: 32px; border-radius: 9px; background: var(--accent); position: relative; flex: none; }
.logo::before { content: ""; position: absolute; left: 50%; top: 0; bottom: 0; width: 6px; margin-left: -3px; background: var(--gold-soft); }
.logo::after { content: ""; position: absolute; top: 50%; left: 0; right: 0; height: 6px; margin-top: -3px; background: var(--gold-soft); }
nav { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: .95rem; }
main { padding-block: 28px 80px; display: grid; gap: 22px; }
.sub { color: var(--muted); margin: 6px 0 0; max-width: 60ch; }
.row { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.back { display: inline-block; margin-bottom: 10px; font-weight: 600; text-decoration: none; font-size: .95rem; }
.back:hover { text-decoration: underline; }

/* buttons */
button, .btn { font: 600 .95rem var(--body); padding: 9px 16px; border-radius: 99px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); cursor: pointer; text-decoration: none; display: inline-block; line-height: 1.3; }
button:hover, .btn:hover { border-color: var(--accent); color: var(--accent); }
.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--accent-ink); }
.link { background: none; border: 0; padding: 4px 8px; color: var(--accent); border-radius: 6px; }
.link:hover { background: var(--accent-soft); color: var(--accent); }
.link.danger { color: var(--danger); }
.link.danger:hover { background: transparent; text-decoration: underline; color: var(--danger); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* people */
.people { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); }
.people a { display: flex; gap: 14px; align-items: center; padding: 16px; background: var(--surface); border: 1px solid var(--line);
  border-radius: 16px; text-decoration: none; color: var(--ink); box-shadow: var(--shadow); min-width: 0; }
.people a:hover { border-color: var(--accent); transform: translateY(-1px); }
.people .who { display: grid; min-width: 0; flex: 1; }
.people .name { font: 600 1.1rem var(--display); overflow-wrap: anywhere; }
.people .count { color: var(--muted); font-size: .9rem; }
.avatar { width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; flex: none;
  font: 700 1.1rem var(--display); color: #fff; background: var(--av0); }
.avatar.c1 { background: var(--av1); } .avatar.c2 { background: var(--av2); } .avatar.c3 { background: var(--av3); }
.avatar.c4 { background: var(--av4); } .avatar.c5 { background: var(--av5); }
.pill { font-size: .82rem; font-weight: 600; padding: 3px 11px; border-radius: 99px; background: var(--accent-soft); color: var(--accent); white-space: nowrap; }
.pill.gold { background: var(--gold-soft); color: var(--gold); }
.heading { display: flex; gap: 16px; align-items: center; }
.heading .avatar { width: 60px; height: 60px; font-size: 1.5rem; }

/* items */
.items { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.item { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 16px 18px; display: grid; gap: 8px; min-width: 0; box-shadow: var(--shadow); }
.item h2 { overflow-wrap: anywhere; }
.item.bought { background: var(--bg2); box-shadow: none; }
.item.bought h2 { text-decoration: line-through; text-decoration-thickness: 1.5px; color: var(--done); }
.meta { display: flex; gap: 8px 14px; flex-wrap: wrap; align-items: center; color: var(--muted); font-size: .92rem; }
.price { font-weight: 700; color: var(--ink); font-size: 1.05rem; white-space: nowrap; font-variant-numeric: tabular-nums; }
.shop { font-weight: 600; text-decoration: none; }
.shop:hover { text-decoration: underline; }
.notes { margin: 0; overflow-wrap: anywhere; white-space: pre-wrap; color: var(--muted); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 2px; }
.bought-by { display: inline-flex; gap: 6px; align-items: center; color: var(--accent); font-weight: 600; font-size: .92rem; }
.bought-by::before { content: "✓"; display: grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); font-size: .75rem; }

/* forms */
form.card { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 20px; display: grid; gap: 14px; box-shadow: var(--shadow); }
label { display: grid; gap: 5px; font-weight: 600; font-size: .9rem; }
input, textarea { font: 400 1rem var(--body); padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); color: var(--ink); width: 100%; }
input:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--accent); }
textarea { min-height: 76px; resize: vertical; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 520px) { .two { grid-template-columns: 1fr; } }
.error { color: var(--danger); margin: 0; }
.hint { color: var(--muted); font-size: .88rem; margin: 0; }
.empty { padding: 36px 16px; text-align: center; color: var(--muted); border: 1.5px dashed var(--line); border-radius: 16px; }
.buy-form { display: flex; gap: 8px; flex-wrap: wrap; }
.buy-form input { flex: 1 1 160px; width: auto; border-radius: 99px; padding-inline: 16px; }
.auth { max-width: 460px; width: 100%; margin: 0 auto; display: grid; gap: 18px; }
#toast { position: fixed; bottom: calc(20px + env(safe-area-inset-bottom, 0px)); left: 50%; transform: translateX(-50%);
  background: var(--ink); color: var(--bg); padding: 10px 20px; border-radius: 99px; max-width: 90vw; box-shadow: var(--shadow); font-weight: 500; }

/* admin */
.admin-person { display: grid; gap: 10px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 18px; box-shadow: var(--shadow); }
.admin-person .item { box-shadow: none; background: var(--bg); }
.admin-person .item.bought { background: var(--bg2); }
.admin-pill { margin-left: 8px; vertical-align: middle; font-family: var(--body); }
.invite-result { display: grid; gap: 8px; padding: 12px; background: var(--accent-soft); border-radius: 12px; }
.invite-result input { font-size: .85rem; border-radius: 10px; }
.pending .items li { padding: 8px 0; border-top: 1px solid var(--line); }

@media (prefers-reduced-motion: no-preference) {
  button, .btn, .people a { transition: border-color .15s, transform .15s, background-color .15s, color .15s; }
}

/* wishlist rows */
.hero { text-align: center; display: grid; justify-items: center; gap: 6px; padding-top: 4px; }
.hero .back { font-size: .8rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 0; }
.hero h1 { font-size: clamp(2.2rem, 8vw, 3.4rem); }
.hero .sub { text-align: center; }
.heart { width: 54px; height: 54px; fill: none; stroke: var(--ink); stroke-width: 1.3; stroke-linejoin: round; margin-top: 8px; }
.items-wrap { display: grid; gap: 8px; }
.row-item, .colhead { grid-template-columns: 76px minmax(0, 1fr) 90px minmax(170px, 210px); gap: 8px 16px; align-items: center; }
.colhead { display: grid; padding: 0 18px; color: var(--muted); font: 600 .78rem var(--body); letter-spacing: .08em; text-transform: uppercase; }
.colhead span:nth-child(3), .row-item .cost { text-align: center; }
.row-item { display: grid; }
.thumb { width: 76px; height: 76px; border-radius: 12px; object-fit: cover; background: var(--bg2); display: block; }
.thumb.tile { display: grid; place-items: center; font: 700 1.6rem var(--display); color: #fff; background: var(--av0); }
.thumb.c1 { background: var(--av1); } .thumb.c2 { background: var(--av2); } .thumb.c3 { background: var(--av3); }
.thumb.c4 { background: var(--av4); } .thumb.c5 { background: var(--av5); }
.row-item.bought .thumb { opacity: .55; }
.info { display: grid; gap: 4px; min-width: 0; }
.info .notes { font-size: .92rem; }
.act { display: grid; gap: 6px; justify-items: stretch; text-align: center; }
.added { font-size: .78rem; color: var(--muted); }
.act .buy-form { flex-direction: column; }
.act .buy-form input { flex: none; width: 100%; padding-block: 8px; font-size: .92rem; }
.act .buy-form button { width: 100%; }
.act .actions { justify-content: center; }
@media (max-width: 640px) {
  .colhead { display: none; }
  .row-item { grid-template-columns: 64px minmax(0, 1fr); }
  .thumb { width: 64px; height: 64px; }
  .row-item .cost { grid-column: 2; text-align: left; margin-top: -4px; }
  .row-item .act { grid-column: 1 / -1; text-align: left; }
  .row-item .act .actions { justify-content: flex-start; }
}

/* avatar picker */
.hero-avatar { margin-top: 6px; }
.hero-avatar .avatar { width: 84px; height: 84px; font-size: 2.4rem; }
.avatar { font-size: 1.4rem; line-height: 1; }
.auth .hero-avatar { justify-self: center; }
.pick-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(48px, 1fr)); gap: 8px; }
.pick { width: 100%; aspect-ratio: 1; padding: 0; font-size: 1.5rem; border-radius: 12px; display: grid; place-items: center; font-family: var(--display); }
.pick.on { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
.pick.swatch { border: 0; }
.pick.swatch.on { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--ink); }
.pick-grid.colors { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.swatch.c0 { background: var(--av0); } .swatch.c1 { background: var(--av1); } .swatch.c2 { background: var(--av2); }
.swatch.c3 { background: var(--av3); } .swatch.c4 { background: var(--av4); } .swatch.c5 { background: var(--av5); }

/* lookup */
.lookup-row { display: flex; gap: 10px; align-items: end; flex-wrap: wrap; }
.lookup-row label { flex: 1 1 240px; }
.photo-preview { display: flex; gap: 12px; align-items: center; margin-top: 8px; }
.photo-preview:empty { display: none; }

.offscreen { position: fixed; left: -9999px; top: 0; opacity: 0; }
.invite-result textarea { width: 100%; margin-top: 8px; font: inherit; }
.invite-result input { width: 100%; margin-top: 8px; }
