:root {
  --bg: #f7f3ec;
  --card: #ffffff;
  --ink: #1f2a24;
  --muted: #66736b;
  --line: #e4ddd1;
  --pine: #1d5c3f;
  --pine-dark: #144430;
  --pine-soft: #e6f0ea;
  --berry: #b3263a;
  --berry-soft: #fbe9ec;
  --gold: #c58b1b;
  --gold-soft: #fdf3dc;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(31, 42, 36, .06), 0 6px 20px rgba(31, 42, 36, .06);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.5;
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; }
a { color: var(--pine); }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5rem; }
h1 { font-size: clamp(1.6rem, 4vw, 2.2rem); letter-spacing: -.01em; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 .75rem; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: .9rem clamp(1rem, 4vw, 2rem);
  background: var(--pine); color: #fff;
}
.brand { color: #fff; text-decoration: none; font-weight: 700; font-size: 1.15rem; letter-spacing: .01em; }
.brand-mark { margin-right: .25rem; }
.userbar { display: flex; align-items: center; gap: .75rem; font-size: .9rem; min-width: 0; }
.userbar span { opacity: .85; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.userbar button { background: rgba(255,255,255,.12); border-color: rgba(255,255,255,.25); padding: .3rem .7rem; font-size: .85rem; }
.userbar button:hover { background: rgba(255,255,255,.22); }
.code-input { font-size: 1.6rem; letter-spacing: .4em; text-align: center; font-variant-numeric: tabular-nums; }
.list-link { display: flex; align-items: center; gap: .75rem; padding: .7rem 0; border-bottom: 1px solid var(--line); text-decoration: none; color: inherit; }
.list-link:last-child { border-bottom: 0; }
.list-link:hover .list-title { text-decoration: underline; }
.list-title { font-weight: 600; color: var(--pine); }

main { max-width: 960px; margin: 0 auto; padding: clamp(1rem, 4vw, 2rem); }
.narrow { max-width: 620px; margin: 0 auto; }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: clamp(1rem, 3vw, 1.5rem); box-shadow: var(--shadow); margin-bottom: 1.25rem;
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: .75rem; }
.card-head h2, .card-head h3 { margin: 0; }

.hero { text-align: center; padding: 1.5rem 0 1rem; }
.hero p { color: var(--muted); max-width: 520px; margin: .5rem auto 0; }

.muted { color: var(--muted); }
.small { font-size: .875rem; }
.center { text-align: center; }
.stack > * + * { margin-top: .75rem; }
.row { display: flex; gap: .75rem; flex-wrap: wrap; align-items: center; }
.spacer { flex: 1; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 1rem; }

label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: .3rem; }
label .opt { font-weight: 400; color: var(--muted); }
input, textarea, select {
  width: 100%; font: inherit; color: inherit; background: #fff;
  border: 1px solid var(--line); border-radius: 10px; padding: .6rem .75rem;
}
input:focus, textarea:focus, select:focus { outline: 2px solid var(--pine); outline-offset: 1px; border-color: transparent; }
textarea { min-height: 110px; resize: vertical; }
.field { margin-bottom: .9rem; }
.money-field { display: flex; align-items: center; gap: .5rem; }
.money-field span { font-weight: 600; color: var(--muted); }

button, .btn {
  font: inherit; font-weight: 600; cursor: pointer; border-radius: 10px; border: 1px solid transparent;
  padding: .6rem 1rem; background: var(--pine); color: #fff; text-decoration: none; display: inline-flex;
  align-items: center; justify-content: center; gap: .4rem; white-space: nowrap;
}
button:hover, .btn:hover { background: var(--pine-dark); }
button:disabled { opacity: .55; cursor: not-allowed; }
.btn-secondary { background: #fff; color: var(--ink); border-color: var(--line); }
.btn-secondary:hover { background: var(--pine-soft); }
.btn-danger { background: #fff; color: var(--berry); border-color: #efc5cc; }
.btn-danger:hover { background: var(--berry-soft); }
.btn-berry { background: var(--berry); }
.btn-berry:hover { background: #921d2f; }
.btn-sm { padding: .35rem .65rem; font-size: .85rem; border-radius: 8px; }
.btn-lg { padding: .85rem 1.4rem; font-size: 1.05rem; }
.btn-link { background: none; color: var(--pine); padding: 0; border: 0; text-decoration: underline; font-weight: 500; }
.btn-link:hover { background: none; }

.pill {
  display: inline-block; font-size: .78rem; font-weight: 600; padding: .15rem .55rem; border-radius: 999px;
  background: var(--pine-soft); color: var(--pine); white-space: nowrap;
}
.pill-gold { background: var(--gold-soft); color: #8a5f0f; }
.pill-berry { background: var(--berry-soft); color: var(--berry); }
.pill-grey { background: #eeebe5; color: var(--muted); }

.notice { border-radius: 12px; padding: .9rem 1rem; margin-bottom: 1rem; border: 1px solid; }
.notice-gold { background: var(--gold-soft); border-color: #f0dca9; }
.notice-berry { background: var(--berry-soft); border-color: #efc5cc; }
.notice-pine { background: var(--pine-soft); border-color: #c5dccf; }
.notice > :last-child { margin-bottom: 0; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: .6rem .5rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; }
tr:last-child td { border-bottom: 0; }
.table-wrap { overflow-x: auto; }

.person-name { font-weight: 600; }
.contact { font-size: .85rem; color: var(--muted); }

.wish { border: 1px solid var(--line); border-radius: 12px; padding: .8rem 1rem; display: flex; gap: 1rem; align-items: flex-start; }
.wish + .wish { margin-top: .6rem; }
.wish-body { flex: 1; min-width: 0; }
.wish-title { font-weight: 600; word-break: break-word; }
.wish-note { color: var(--muted); font-size: .9rem; margin-top: .15rem; white-space: pre-wrap; }
.wish a { font-size: .9rem; word-break: break-all; }
.wish.extra { border-color: #f0dca9; background: #fffcf4; }

.instructions { white-space: pre-wrap; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: .75rem; margin-bottom: 1.25rem; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: .75rem 1rem; }
.stat b { display: block; font-size: 1.4rem; }
.stat span { font-size: .8rem; color: var(--muted); }

.big-name { font-size: clamp(1.8rem, 6vw, 2.6rem); font-weight: 800; color: var(--berry); letter-spacing: -.01em; }

.ledger { display: grid; grid-template-columns: 1fr auto; gap: .25rem 1rem; font-size: .95rem; }
.ledger .total { font-weight: 700; border-top: 1px solid var(--line); padding-top: .35rem; }

.choice-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: .75rem; margin-top: .75rem; }
.choice { text-align: left; background: #fff; color: var(--ink); border: 1px solid var(--line); border-radius: 12px; padding: .85rem 1rem; display: block; white-space: normal; }
.choice:hover { background: var(--pine-soft); border-color: #c5dccf; }
.choice b { display: block; margin-bottom: .2rem; }
.choice span { font-weight: 400; font-size: .88rem; color: var(--muted); }

.tabs { display: flex; gap: .5rem; margin-bottom: 1rem; flex-wrap: wrap; }
.tab { background: #fff; color: var(--ink); border: 1px solid var(--line); }
.tab:hover { background: var(--pine-soft); }
.tab[aria-selected="true"] { background: var(--pine); color: #fff; border-color: var(--pine); }

dialog { border: 0; border-radius: var(--radius); padding: 0; width: min(520px, calc(100vw - 2rem)); box-shadow: 0 20px 60px rgba(0,0,0,.25); }
dialog::backdrop { background: rgba(20, 30, 25, .45); }
dialog form { padding: 1.5rem; }
.dialog-actions { display: flex; justify-content: flex-end; gap: .5rem; margin-top: 1rem; }

#toast {
  position: fixed; left: 50%; bottom: 1.5rem; transform: translateX(-50%); z-index: 50;
  background: var(--ink); color: #fff; padding: .7rem 1.1rem; border-radius: 10px; box-shadow: var(--shadow);
  max-width: calc(100vw - 2rem);
}
#toast.error { background: var(--berry); }

.share-links { display: flex; gap: .35rem; flex-wrap: wrap; }
.empty { text-align: center; color: var(--muted); padding: 1.5rem 1rem; border: 1px dashed var(--line); border-radius: 12px; }

@media (max-width: 640px) {
  .hide-sm { display: none; }
  th, td { padding: .5rem .35rem; }
}
