:root {
  --bg: #fff4f1;
  --bg-2: #ffe6e0;
  --ink: #2b1d22;
  --muted: #7a6369;
  --card: #ffffff;
  --line: #f1d6d0;
  --accent: #e2566f;
  --accent-ink: #ffffff;
  --soft: #ffeef0;
  --ok: #2f8f5b;
  --warn: #b7791f;
  --radius: 18px;
  --shadow: 0 1px 0 rgba(43, 29, 34, .04), 0 8px 24px -12px rgba(43, 29, 34, .18);
  --display: "Fraunces", Georgia, serif;
  --body: "DM Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
}
[data-theme="sage"] { --bg: #f1f5ef; --bg-2: #e2ebde; --ink: #1f2a22; --muted: #5e6d61; --line: #d5e0d1; --accent: #3f7a55; --soft: #e8f1e8; }
[data-theme="butter"] { --bg: #fff9e8; --bg-2: #fff0c2; --ink: #2d2412; --muted: #76684a; --line: #f0e2b5; --accent: #c2741b; --soft: #fff4d6; }
[data-theme="midnight"] { --bg: #16141f; --bg-2: #221e33; --ink: #f4f0ff; --muted: #a59fbf; --card: #201c2e; --line: #312b47; --accent: #b79cff; --accent-ink: #16141f; --soft: #2a2440; }

* { box-sizing: border-box; }
html, body { margin: 0; }
html { background: var(--bg); }
body {
  font-family: var(--body);
  color: var(--ink);
  background: radial-gradient(1200px 600px at 50% -200px, var(--bg-2), var(--bg)) fixed;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  line-height: 1.45;
}
a { color: inherit; }
h1, h2, h3 { font-family: var(--display); font-weight: 700; letter-spacing: -0.01em; margin: 0; }
.loading { padding: 40vh 0; text-align: center; color: var(--muted); }

.wrap { max-width: 560px; margin: 0 auto; padding: 28px 18px 80px; }
.wrap.wide { max-width: 760px; }
.topbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; gap: 12px; }
.brand { font-family: var(--display); font-weight: 700; font-size: 20px; text-decoration: none; }
.brand span { color: var(--accent); }
.muted { color: var(--muted); }
.small { font-size: 14px; }

/* buttons & inputs */
.btn {
  appearance: none; border: 0; cursor: pointer; font: inherit; font-weight: 700;
  background: var(--accent); color: var(--accent-ink);
  padding: 12px 18px; border-radius: 999px; text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  transition: transform .08s ease, opacity .15s;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.ghost { background: transparent; color: var(--ink); box-shadow: inset 0 0 0 1.5px var(--line); }
.btn.soft { background: var(--soft); color: var(--ink); }
.btn.sm { padding: 7px 12px; font-size: 14px; }
.btn.block { width: 100%; }
.btn.danger { background: transparent; color: #c0392b; box-shadow: inset 0 0 0 1.5px #f0c6c0; }

label { display: block; font-size: 14px; font-weight: 700; margin: 14px 0 6px; }
input, textarea, select {
  width: 100%; font: inherit; color: var(--ink); background: var(--card);
  border: 1.5px solid var(--line); border-radius: 12px; padding: 11px 13px;
}
input:focus, textarea:focus, select:focus, .btn:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 35%, transparent); outline-offset: 1px; border-color: var(--accent); }
textarea { resize: vertical; min-height: 70px; }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; }
.hp { position: absolute; left: -9999px; }

/* cards */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
.card + .card, .section + .section { margin-top: 18px; }
.section h2 { font-size: 22px; margin-bottom: 4px; }

/* profile header */
.profile { text-align: center; margin: 10px 0 26px; }
.avatar {
  width: 96px; height: 96px; border-radius: 50%; object-fit: cover;
  border: 3px solid var(--card); box-shadow: var(--shadow); background: var(--soft);
  display: inline-grid; place-items: center; font-family: var(--display); font-size: 40px; color: var(--accent);
}
.profile h1 { font-size: 30px; margin-top: 12px; }
.profile .handle { color: var(--muted); font-weight: 500; }
.profile p { margin: 8px auto 0; max-width: 40ch; }

/* gift list */
.gifts { display: grid; gap: 12px; }
.gift {
  display: grid; grid-template-columns: 76px 1fr; gap: 14px; align-items: center;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px; box-shadow: var(--shadow);
}
.gift.no-img { grid-template-columns: 1fr; }
.gift img, .gift .ph { width: 76px; height: 76px; border-radius: 12px; object-fit: cover; background: var(--soft); }
.gift .ph { display: grid; place-items: center; font-size: 28px; }
.gift h3 { font-family: var(--body); font-size: 16px; font-weight: 700; line-height: 1.3; }
.gift .meta { font-size: 13px; color: var(--muted); margin-top: 2px; }
.gift .note { font-size: 14px; margin-top: 4px; }
.gift .actions { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.gift.claimed { opacity: .62; }
.pill { display: inline-block; font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 999px; background: var(--soft); }
.pill.private { background: var(--ink); color: var(--bg); }
.pill.ok { background: #e3f4ea; color: var(--ok); }
.pill.warn { background: #fdf1dc; color: var(--warn); }
.pill.no { background: #fbe3e0; color: #c0392b; }

.lock {
  text-align: center; margin-top: 26px; padding: 26px 20px;
  border: 2px dashed var(--line); border-radius: var(--radius); background: color-mix(in srgb, var(--card) 60%, transparent);
}
.lock .icon { font-size: 30px; }
.lock h2 { font-size: 22px; margin: 6px 0 4px; }
.lock form { text-align: left; margin-top: 10px; }
.empty { text-align: center; color: var(--muted); padding: 24px; }
.footer { text-align: center; margin-top: 40px; font-size: 13px; color: var(--muted); }
.footer a { font-weight: 700; text-decoration: none; }

/* landing */
.hero { text-align: center; padding: 8vh 0 30px; }
.hero h1 { font-size: clamp(38px, 8vw, 58px); line-height: 1.02; }
.hero h1 em { font-style: italic; color: var(--accent); }
.hero p { font-size: 18px; color: var(--muted); max-width: 34ch; margin: 16px auto 26px; }
.steps { display: grid; gap: 12px; margin-top: 34px; }
.step { display: flex; gap: 14px; align-items: flex-start; }
.step b { font-family: var(--display); font-size: 22px; color: var(--accent); min-width: 26px; }
.biolink {
  margin: 24px auto 0; max-width: 300px; border-radius: 18px; background: var(--card);
  border: 1px solid var(--line); padding: 14px; box-shadow: var(--shadow); text-align: left; font-size: 14px;
}
.biolink .u { color: #00376b; font-weight: 700; }

/* dashboard */
.sharebox { display: flex; gap: 8px; align-items: center; background: var(--soft); border-radius: 14px; padding: 10px 10px 10px 14px; margin-top: 12px; }
.sharebox code { flex: 1; font-family: var(--body); font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tabs { display: flex; gap: 6px; margin: 22px 0 14px; background: var(--card); border: 1px solid var(--line); border-radius: 999px; padding: 4px; }
.tabs button { flex: 1; white-space: nowrap; font-size: 15px !important; padding-left: 4px !important; padding-right: 4px !important; border: 0; background: transparent; font: inherit; font-weight: 700; padding: 9px; border-radius: 999px; cursor: pointer; color: var(--muted); }
.tabs button[aria-selected="true"] { background: var(--accent); color: var(--accent-ink); }
.badge { display: inline-block; vertical-align: 1px; min-width: 20px; padding: 0 6px; border-radius: 999px; background: var(--ink); color: var(--bg); font-size: 12px; margin-left: 4px; }
.seg { display: flex; gap: 6px; }
.seg label { flex: 1; margin: 0; }
.seg input { position: absolute; opacity: 0; width: 1px; }
.seg span { display: block; text-align: center; padding: 10px; border-radius: 12px; border: 1.5px solid var(--line); font-weight: 700; cursor: pointer; background: var(--card); }
.seg input:checked + span { border-color: var(--accent); background: var(--soft); }
.seg input:focus-visible + span { outline: 3px solid color-mix(in srgb, var(--accent) 35%, transparent); }
.swatches { display: flex; gap: 8px; }
.swatches label { margin: 0; }
.swatches input { position: absolute; opacity: 0; width: 1px; }
.swatches span { display: block; width: 36px; height: 36px; border-radius: 50%; border: 3px solid var(--card); box-shadow: 0 0 0 1.5px var(--line); cursor: pointer; }
.swatches input:checked + span { box-shadow: 0 0 0 3px var(--ink); }
.req { display: grid; gap: 4px; padding: 14px 0; border-top: 1px solid var(--line); }
.req:first-child { border-top: 0; padding-top: 0; }
.req .actions { display: flex; gap: 8px; margin-top: 6px; flex-wrap: wrap; }
.mgr .gift { grid-template-columns: 56px 1fr; }
.mgr .gift img, .mgr .gift .ph { width: 56px; height: 56px; }
.err { color: #c0392b; font-size: 14px; margin-top: 10px; min-height: 1em; }

/* friends, address */
.banner { background: var(--soft); border: 1px solid var(--line); border-radius: 14px; padding: 10px 14px; font-size: 14px; margin-bottom: 8px; }
.banner a { font-weight: 700; }
.person { display: flex; gap: 12px; align-items: center; }
.person img, .person .mini-av { width: 44px; height: 44px; border-radius: 50%; object-fit: cover; flex: none; background: var(--soft); display: grid; place-items: center; font-family: var(--display); font-size: 20px; color: var(--accent); }
.person .who a { text-decoration: none; }
.addr { margin-top: 18px; }
.addr address { font-style: normal; font-weight: 500; margin-top: 6px; line-height: 1.5; }
.addr-note { text-align: center; margin-top: 18px; }
.provider { background: var(--card); color: var(--ink); box-shadow: inset 0 0 0 1.5px var(--line); }

/* add page */
.addcta { display: flex; gap: 14px; align-items: center; text-decoration: none; border-style: dashed; border-width: 2px; }
.addcta .plus { width: 46px; height: 46px; flex: none; border-radius: 50%; display: grid; place-items: center; background: var(--accent); color: var(--accent-ink); font-size: 24px; font-weight: 700; }
details summary { cursor: pointer; }
.preview { display: flex; gap: 14px; align-items: center; margin-top: 18px; }
.preview img, .preview .ph { width: 96px; height: 96px; border-radius: 14px; object-fit: cover; background: var(--soft); display: grid; place-items: center; font-size: 32px; flex: none; }
.results { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; margin-top: 16px; }
.result { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; display: flex; flex-direction: column; gap: 8px; box-shadow: var(--shadow); }
.result img, .result .ph { width: 100%; aspect-ratio: 1; object-fit: contain; border-radius: 12px; background: #fff; display: grid; place-items: center; font-size: 32px; }
.result .body { flex: 1; }
.result h3 { font-family: var(--body); font-size: 14px; font-weight: 700; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.result .meta { font-size: 13px; color: var(--muted); margin: 3px 0; }
.result .row { flex: none; }
.result .row .btn:last-child { flex: 0 0 auto; }
.storegrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.results:has(> .card), .results:has(> .empty), .results:has(> p) { grid-template-columns: 1fr; }

#toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 140%);
  background: var(--ink); color: var(--bg); padding: 11px 18px; border-radius: 999px; font-weight: 700;
  transition: transform .25s ease, opacity .25s, visibility .25s; z-index: 10; max-width: 90vw;
  opacity: 0; visibility: hidden;
}
#toast.show { transform: translate(-50%, 0); opacity: 1; visibility: visible; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

[hidden] { display: none !important; }

/* ---------- ✨ bling ---------- */
.spark { position: fixed; z-index: 9999; pointer-events: none; line-height: 1; transform: translate(-50%, -50%);
  text-shadow: 0 0 6px currentColor, 0 0 12px #fff, 0 0 2px #d9a93a; animation: spark var(--life, 800ms) ease-out forwards; }
@keyframes spark {
  0% { opacity: 1; transform: translate(-50%, -50%) scale(.3) rotate(0); }
  35% { opacity: 1; transform: translate(calc(-50% + var(--dx) * .6), calc(-50% + var(--dy) * .6)) scale(1.15) rotate(70deg); }
  100% { opacity: 0; transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(.4) rotate(180deg); }
}
.twinkles { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }
.twinkles i { position: absolute; font-style: normal; color: #e9b949; opacity: 0;
  text-shadow: 0 0 6px #ff9ad5, 0 0 12px #c9a7ff, 0 0 3px #fff; animation: twinkle 3s ease-in-out infinite; }
[data-theme="midnight"] .twinkles i { color: #ffe9a8; }
@keyframes twinkle { 0%, 100% { opacity: 0; transform: scale(.4) rotate(0); } 50% { opacity: .9; transform: scale(1) rotate(45deg); } }
#app, .wrap { position: relative; z-index: 1; }

/* shine sweeping across buttons, cards and items */
.btn, .gift, .card.shine, .shine, .tabs button[aria-selected="true"] { position: relative; overflow: hidden; }
.btn::after, .gift::after, .card.shine::after, .shine::after, .tabs button[aria-selected="true"]::after {
  content: ""; position: absolute; top: 0; left: -75%; width: 50%; height: 100%; pointer-events: none;
  background: linear-gradient(100deg, transparent, rgba(255,255,255,.55), transparent); transform: skewX(-20deg);
  animation: glint 5.5s ease-in-out infinite;
}
.gift:nth-child(2n)::after { animation-delay: 1.8s; }
.gift:nth-child(3n)::after { animation-delay: 3.4s; }
.btn:hover::after, .btn:focus-visible::after { animation-duration: 1.1s; }
@keyframes glint { 0%, 72% { left: -75%; } 100% { left: 135%; } }
.btn:not(.ghost):not(.soft):not(.danger) { box-shadow: 0 0 0 0 transparent, 0 4px 18px -6px var(--accent); }
.btn:not(.ghost):not(.soft):not(.danger):hover { box-shadow: 0 0 22px -2px var(--accent); }
.gift { transition: transform .2s ease, box-shadow .2s ease; }
.gift:hover { transform: translateY(-2px); box-shadow: 0 10px 26px -12px var(--accent); }

/* photo tab */
.photo-pick { display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; cursor: pointer;
  padding: 28px 16px; border: 2px dashed var(--accent); border-radius: var(--radius); background: var(--soft); color: var(--ink); margin: 0; }
.photo-pick .big { font-size: 40px; }
.batch { list-style: none; padding: 0; margin: 16px 0 0; display: grid; gap: 10px; }
.batch li { display: flex; align-items: center; gap: 10px; }
.batch li img { width: 52px; height: 52px; object-fit: cover; border-radius: 10px; }
.batch li .pill { margin-left: auto; }

@media (prefers-reduced-motion: reduce) {
  .btn::after, .gift::after, .card.shine::after, .shine::after, .tabs button::after, .twinkles { display: none; }
}
.twinkles i:nth-child(3n) { color: #f08cc0; }
.twinkles i:nth-child(4n) { color: #b99cff; }
