:root {
  --bg: #f6efe2;
  --bg-2: #efe5d2;
  --card: #fffbf3;
  --ink: #2b2420;
  --muted: #7a6d60;
  --line: #e4d8c3;
  --green: #1f4d3a;
  --green-2: #2e6a50;
  --green-soft: #dfeadf;
  --berry: #a3243b;
  --berry-soft: #f6dfe2;
  --gold: #b8892e;
  --gold-soft: #f5e8c8;
  --shadow: 0 1px 2px rgba(60, 40, 20, .06), 0 4px 14px rgba(60, 40, 20, .06);
  --radius: 16px;
  --serif: "Fraunces", Georgia, "Times New Roman", serif;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111b16; --bg-2: #0d1511; --card: #1a2720; --ink: #efe6d6; --muted: #a59a88; --line: #2b3a31;
    --green: #8cc7a6; --green-2: #6fb08d; --green-soft: #213a2d; --berry: #f08a9a; --berry-soft: #3a1f25;
    --gold: #e2b65c; --gold-soft: #3a3020; --shadow: 0 1px 2px rgba(0,0,0,.3); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #111b16; --bg-2: #0d1511; --card: #1a2720; --ink: #efe6d6; --muted: #a59a88; --line: #2b3a31;
  --green: #8cc7a6; --green-2: #6fb08d; --green-soft: #213a2d; --berry: #f08a9a; --berry-soft: #3a1f25;
  --gold: #e2b65c; --gold-soft: #3a3020; --shadow: 0 1px 2px rgba(0,0,0,.3); color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  background-image: radial-gradient(rgba(120, 90, 50, .05) 1px, transparent 1px);
  background-size: 6px 6px;
  color: var(--ink);
  font: 15px/1.45 var(--sans);
  -webkit-tap-highlight-color: transparent;
  min-height: 100dvh;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--green-2); }
h1, h2, h3 { font-family: var(--serif); font-weight: 600; margin: 0; letter-spacing: -.01em; }
h1 { font-size: 26px; }
h2 { font-size: 19px; }
h3 { font-size: 16px; }

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 10px;
  padding: calc(env(safe-area-inset-top) + 10px) 16px 10px;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.topbar h1 { font-size: 21px; flex: 1; display: flex; align-items: center; gap: 8px; }
.topbar .holly { width: 22px; height: 22px; }
.iconbtn {
  border: 0; background: transparent; width: 40px; height: 40px; border-radius: 12px;
  display: grid; place-items: center; cursor: pointer; color: var(--ink);
}
.iconbtn:active { background: var(--bg-2); }
.sync-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green-2); }
.sync-dot.pending { background: var(--gold); }
.sync-dot.offline { background: var(--muted); }

main { padding: 14px 16px calc(env(safe-area-inset-bottom) + 96px); max-width: 720px; margin: 0 auto; }

.tabs {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 30;
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: var(--card); border-top: 1px solid var(--line);
  padding: 6px 4px calc(env(safe-area-inset-bottom) + 6px);
}
.tabs a {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  font-size: 11px; color: var(--muted); text-decoration: none; padding: 4px 0; border-radius: 12px;
}
.tabs a svg { width: 22px; height: 22px; }
.tabs a.on { color: var(--berry); font-weight: 600; }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 14px; margin-bottom: 12px;
}
.card h2 { margin-bottom: 8px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.card-head h2 { margin: 0; }
.section-title {
  font-family: var(--serif); font-size: 15px; color: var(--muted); margin: 18px 2px 8px;
  display: flex; align-items: center; gap: 8px;
}
.section-title::after { content: ""; flex: 1; height: 1px; background: var(--line); }

/* Countdown hero */
.hero {
  position: relative; overflow: hidden; color: #fff8ec;
  background: linear-gradient(135deg, #1f4d3a, #173a2c 60%, #10291f);
  border: 0; padding: 18px 16px 16px;
}
.hero .big { font-family: var(--serif); font-size: 44px; line-height: 1; font-weight: 600; }
.hero .sub { opacity: .9; margin-top: 4px; }
.hero .chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.hero .chip { background: rgba(255,255,255,.14); color: #fff8ec; }
.hero .gold { color: #f1cf7e; }
.snow { position: absolute; inset: 0; pointer-events: none; }
.snow i {
  position: absolute; top: -10px; width: 4px; height: 4px; border-radius: 50%;
  background: rgba(255,255,255,.75); animation: fall linear infinite;
}
@keyframes fall { to { transform: translateY(190px) translateX(14px); opacity: .2; } }
@media (prefers-reduced-motion: reduce) { .snow { display: none; } }

.chip {
  display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: 999px;
  font-size: 12.5px; background: var(--bg-2); color: var(--ink); white-space: nowrap; border: 0;
}
.chip.green { background: var(--green-soft); color: var(--green); }
.chip.berry { background: var(--berry-soft); color: var(--berry); }
.chip.gold { background: var(--gold-soft); color: var(--gold); }
.chip.tap { cursor: pointer; }
.iconbtn svg { width: 22px; height: 22px; }
.chip.on { background: var(--green); color: #fff; }
.chips-row { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 10px; scrollbar-width: none; }

.status { font-size: 12px; padding: 3px 9px; border-radius: 999px; font-weight: 600; border: 0; cursor: pointer; white-space: nowrap; }
.st-Idea { background: var(--bg-2); color: var(--muted); }
.st-To-buy { background: var(--gold-soft); color: var(--gold); }
.st-Ordered { background: #e3e8f6; color: #3a4f8f; }
.st-Arrived { background: var(--green-soft); color: var(--green); }
.st-Wrapped { background: var(--berry-soft); color: var(--berry); }
.st-Given { background: var(--green); color: #fff; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .st-Ordered { background: #232c45; color: #a9b8ea; } }

.row {
  display: flex; align-items: center; gap: 10px; padding: 10px 2px; border-bottom: 1px solid var(--line);
  text-decoration: none; color: inherit;
}
.row:last-child { border-bottom: 0; }
.row .grow { flex: 1; min-width: 0; }
.row .title { font-weight: 550; overflow: hidden; text-overflow: ellipsis; }
.row .meta { color: var(--muted); font-size: 12.5px; }
.row .amt { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.row.done .title { text-decoration: line-through; color: var(--muted); }
.locked-row .title { color: var(--muted); }

.check {
  width: 24px; height: 24px; border-radius: 8px; border: 2px solid var(--line); background: var(--card);
  display: grid; place-items: center; flex: none; cursor: pointer; padding: 0;
}
.check.on { background: var(--green); border-color: var(--green); color: #fff; }
.check svg { width: 14px; height: 14px; }

.bar { height: 8px; border-radius: 99px; background: var(--bg-2); overflow: hidden; display: flex; }
.bar > span { display: block; height: 100%; }
.bar .spent { background: var(--green-2); }
.bar .planned { background: var(--gold); opacity: .7; }
.bar.over .spent { background: var(--berry); }

.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.stat { background: var(--bg-2); border-radius: 12px; padding: 10px; }
.stat .k { font-size: 12px; color: var(--muted); }
.stat .v { font-family: var(--serif); font-size: 22px; font-variant-numeric: tabular-nums; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 0; border-radius: 12px; padding: 10px 14px; font-weight: 600; cursor: pointer;
  background: var(--green); color: #fff;
}
.btn.secondary { background: var(--bg-2); color: var(--ink); }
.btn.danger { background: var(--berry-soft); color: var(--berry); }
.btn.block { width: 100%; }
.btn.small { padding: 6px 10px; font-size: 13px; border-radius: 10px; }
.btn:disabled { opacity: .5; }
.fab {
  position: fixed; right: 16px; bottom: calc(env(safe-area-inset-bottom) + 76px); z-index: 25;
  width: 56px; height: 56px; border-radius: 18px; border: 0; background: var(--berry); color: #fff;
  box-shadow: 0 6px 18px rgba(163, 36, 59, .35); display: grid; place-items: center; cursor: pointer;
}

.field { display: block; margin-bottom: 12px; }
.field > span { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 4px; }
.input, select.input, textarea.input {
  width: 100%; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--card); outline: none; min-height: 42px;
}
.input:focus { border-color: var(--green-2); box-shadow: 0 0 0 3px color-mix(in srgb, var(--green-2) 20%, transparent); }
textarea.input { min-height: 70px; resize: vertical; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.toggle { display: flex; align-items: center; gap: 10px; padding: 8px 0; cursor: pointer; }
.toggle input { width: 20px; height: 20px; accent-color: var(--green); }
.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg button { border: 1px solid var(--line); background: var(--card); border-radius: 999px; padding: 6px 12px; cursor: pointer; font-size: 13px; }
.seg button.on { background: var(--green); border-color: var(--green); color: #fff; }
.warn { background: var(--gold-soft); color: var(--ink); border-radius: 12px; padding: 10px 12px; font-size: 13.5px; margin-bottom: 12px; }

.sheet-back {
  position: fixed; inset: 0; background: rgba(20, 15, 10, .45); z-index: 50;
  display: flex; align-items: flex-end; justify-content: center;
}
.sheet {
  background: var(--bg); width: 100%; max-width: 720px; max-height: 92dvh; overflow-y: auto;
  border-radius: 20px 20px 0 0; padding: 8px 16px calc(env(safe-area-inset-bottom) + 18px);
}
.sheet .grab { width: 40px; height: 4px; border-radius: 4px; background: var(--line); margin: 4px auto 12px; }
.sheet-actions { display: flex; gap: 8px; margin-top: 8px; }
.sheet-actions .btn { flex: 1; }

.lock-card {
  display: flex; align-items: center; gap: 12px; padding: 14px; border-radius: var(--radius);
  background: var(--card); border: 1px dashed var(--line); color: var(--muted); cursor: pointer; width: 100%; text-align: left;
}
.lock-card svg { flex: none; }

.pinpad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; max-width: 280px; margin: 16px auto 0; }
.pinpad button { height: 58px; border-radius: 16px; border: 1px solid var(--line); background: var(--card); font-size: 22px; cursor: pointer; }
.pindots { display: flex; justify-content: center; gap: 14px; margin: 14px 0 4px; }
.pindots i { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--green); }
.pindots i.on { background: var(--green); }

.week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; text-align: center; }
.week div { border-radius: 10px; padding: 6px 0; font-size: 12px; background: var(--green-soft); color: var(--green); }
.week div.away { background: var(--bg-2); color: var(--muted); }
.week b { display: block; font-size: 15px; }

.empty { text-align: center; color: var(--muted); padding: 24px 10px; }
.empty svg { width: 54px; height: 54px; opacity: .7; margin-bottom: 6px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.right { text-align: right; }
.spacer { height: 8px; }
.thumb { width: 44px; height: 44px; border-radius: 10px; object-fit: cover; flex: none; background: var(--bg-2); }
.photo-preview { width: 100%; max-height: 220px; object-fit: contain; border-radius: 12px; background: var(--bg-2); margin-bottom: 8px; }
.toast {
  position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 84px); transform: translateX(-50%);
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 12px; z-index: 60; font-size: 14px;
  max-width: calc(100% - 32px);
}
.auth { max-width: 380px; margin: 10vh auto 0; padding: 0 16px; text-align: center; }
.auth .card { text-align: left; }
.keybox { font-family: ui-monospace, monospace; word-break: break-all; background: var(--bg-2); padding: 10px; border-radius: 10px; font-size: 13px; }
details summary { cursor: pointer; color: var(--muted); font-size: 13px; padding: 6px 0; }
.hist { display: grid; gap: 6px; }
.hist .hrow { display: grid; grid-template-columns: 44px 1fr 64px; align-items: center; gap: 8px; font-size: 13px; }
