:root {
  --bg: #f6f3ee;
  --card: #ffffff;
  --ink: #1d2420;
  --muted: #6b726d;
  --line: #e4ded4;
  --pine: #1f3b2d;
  --pine-2: #2e5a43;
  --berry: #b3362f;
  --gold: #c89b3c;
  --soft-green: #e3efe7;
  --soft-red: #f8e4e2;
  --soft-gold: #f6ecd6;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 2px 8px rgba(0,0,0,.04);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background: var(--bg);
}
* { box-sizing: border-box; }
body { margin: 0; padding-bottom: calc(76px + env(safe-area-inset-bottom)); min-height: 100vh; }
a { color: var(--pine-2); }
h1 { font-size: 1.5rem; margin: .2rem 0 .3rem; letter-spacing: -.01em; }
h2 { font-size: 1.1rem; margin: 1.4rem 0 .6rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.center { text-align: center; }
.pad { padding: 2rem 1rem; }

.top {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between;
  padding: .8rem 1rem; padding-top: calc(.8rem + env(safe-area-inset-top));
  background: var(--pine); color: #fff;
}
.brand { color: #fff; text-decoration: none; font-weight: 700; font-size: 1.1rem; }
.who { font-size: .85rem; opacity: .85; }
.who a { color: #fff; }

main { max-width: 760px; margin: 0 auto; padding: 1rem; }

.tabs {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 5;
  display: flex; justify-content: center; gap: .25rem;
  background: #fff; border-top: 1px solid var(--line);
  padding: .35rem .5rem calc(.35rem + env(safe-area-inset-bottom));
}
.tabs a {
  flex: 1; max-width: 140px; display: flex; flex-direction: column; align-items: center;
  font-size: .75rem; color: var(--muted); text-decoration: none; padding: .3rem; border-radius: 10px;
}
.tabs a span { font-size: 1.3rem; line-height: 1.4; }
.tabs a.active { color: var(--pine); background: var(--soft-green); font-weight: 600; }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: .9rem 1rem; margin-bottom: .7rem; box-shadow: var(--shadow);
}
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .7rem; }
.person {
  display: block; text-decoration: none; color: inherit; text-align: center;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1rem .5rem; box-shadow: var(--shadow);
}
.person .avatar {
  width: 52px; height: 52px; border-radius: 50%; margin: 0 auto .5rem;
  display: grid; place-items: center; font-weight: 700; font-size: 1.2rem; color: #fff;
}
.person .name { font-weight: 600; }
.person.me { border-color: var(--pine-2); }

.item { display: flex; flex-direction: column; gap: .35rem; }
.item.taken { background: #faf9f7; }
.item.taken .title { color: var(--muted); }
.item .row { display: flex; align-items: flex-start; gap: .6rem; justify-content: space-between; }
.item .title { font-weight: 600; word-break: break-word; }
.item .title a { color: inherit; text-decoration-color: var(--line); }
.item .price { font-weight: 600; white-space: nowrap; color: var(--pine-2); }
.item .notes { font-size: .9rem; color: var(--muted); white-space: pre-wrap; }
.item .actions { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; margin-top: .2rem; }

.badge { display: inline-block; font-size: .72rem; font-weight: 600; padding: .12rem .5rem; border-radius: 999px; vertical-align: middle; }
.badge.high { background: var(--soft-red); color: var(--berry); }
.badge.med { background: var(--soft-gold); color: #8a6a1f; }
.badge.low { background: #eee; color: var(--muted); }
.badge.claimed { background: var(--soft-gold); color: #8a6a1f; }
.badge.bought { background: var(--soft-green); color: var(--pine); }
.badge.secret { background: #ece6f7; color: #5a3e8f; }

.btn {
  appearance: none; border: 1px solid var(--line); background: #fff; color: var(--ink);
  border-radius: 10px; padding: .5rem .85rem; font: inherit; font-size: .9rem; cursor: pointer;
  text-decoration: none; display: inline-flex; align-items: center; gap: .3rem; min-height: 38px;
}
.btn:hover { border-color: #cfc7ba; }
.btn.primary { background: var(--pine); color: #fff; border-color: var(--pine); }
.btn.primary:hover { background: var(--pine-2); }
.btn.berry { background: var(--berry); color: #fff; border-color: var(--berry); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn.sm { padding: .3rem .6rem; min-height: 32px; font-size: .82rem; }
.btn.block { width: 100%; justify-content: center; }
.btn:disabled { opacity: .5; cursor: default; }

.notice { border-radius: var(--radius); padding: .75rem 1rem; margin-bottom: .8rem; font-size: .92rem; }
.notice.info { background: var(--soft-green); }
.notice.warn { background: var(--soft-red); }
.notice.secret { background: #f1ecfa; }

.about { white-space: pre-wrap; }

label { display: block; font-size: .85rem; font-weight: 600; margin: .7rem 0 .25rem; }
input, textarea, select {
  width: 100%; font: inherit; font-size: 16px; padding: .55rem .7rem;
  border: 1px solid var(--line); border-radius: 10px; background: #fff; color: var(--ink);
}
textarea { min-height: 76px; resize: vertical; }
input:focus, textarea:focus, select:focus { outline: 2px solid var(--pine-2); outline-offset: 0; border-color: transparent; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; }

dialog {
  border: none; border-radius: 18px; padding: 0; width: min(520px, calc(100vw - 1.5rem));
  box-shadow: 0 10px 40px rgba(0,0,0,.25);
}
dialog::backdrop { background: rgba(20,30,25,.45); }
dialog form { padding: 1.1rem 1.2rem 1.2rem; }
dialog h3 { margin: 0 0 .2rem; }
dialog .foot { display: flex; justify-content: flex-end; gap: .5rem; margin-top: 1.1rem; }

.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(86px + env(safe-area-inset-bottom)); z-index: 20;
  background: var(--ink); color: #fff; padding: .6rem 1rem; border-radius: 10px; font-size: .9rem;
  max-width: calc(100vw - 2rem);
}

/* shopping */
.totals { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; margin-bottom: 1rem; }
.totals .t { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: .6rem; text-align: center; }
.totals .t b { display: block; font-size: 1.15rem; }
.totals .t span { font-size: .75rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.recip summary { list-style: none; cursor: pointer; }
.recip summary::-webkit-details-marker { display: none; }
.recip .head { display: flex; justify-content: space-between; align-items: baseline; gap: .5rem; }
.recip .head .n { font-weight: 700; }
.recip.done .head .n::after { content: " ✓"; color: var(--pine-2); }
.recip .nums { font-size: .85rem; color: var(--muted); white-space: nowrap; }
.recip .nums b.over { color: var(--berry); }
.bar { height: 8px; background: #eee9e1; border-radius: 99px; overflow: hidden; margin-top: .5rem; display: flex; }
.bar i { display: block; height: 100%; }
.bar i.spent { background: var(--pine-2); }
.bar i.planned { background: var(--gold); opacity: .55; }
.bar.over i.spent { background: var(--berry); }
.line { display: flex; align-items: center; gap: .5rem; padding: .5rem 0; border-top: 1px dashed var(--line); }
.line:first-child { border-top: none; }
.line .t { flex: 1; min-width: 0; word-break: break-word; }
.line .t .sub { font-size: .78rem; color: var(--muted); }
.line .amt { font-weight: 600; white-space: nowrap; }
.line input[type=checkbox] { width: 20px; height: 20px; accent-color: var(--pine-2); flex: none; }
.line.bought .t > span:first-child { text-decoration: line-through; text-decoration-color: #aaa; }
.recip .tools { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .6rem; }

.linkbox { display: flex; gap: .4rem; margin-top: .5rem; }
.linkbox input { font-size: .85rem; }
.empty { text-align: center; color: var(--muted); padding: 1.5rem 1rem; border: 2px dashed var(--line); border-radius: var(--radius); }
.back { display: inline-block; margin-bottom: .4rem; text-decoration: none; font-size: .9rem; }
.autofill { margin-top: .3rem; }
