:root {
  --bg: #f6f5fb;
  --card: #ffffff;
  --text: #1d1b26;
  --muted: #6b6880;
  --line: #e7e4f0;
  --accent: #6d4ae0;
  --accent-2: #8b6cf0;
  --accent-soft: #efeafd;
  --green: #138a5b;
  --green-soft: #e3f5ec;
  --red: #d64545;
  --red-soft: #fdecec;
  --amber: #b7791f;
  --amber-soft: #fdf3e1;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(29, 27, 38, 0.04), 0 4px 16px rgba(29, 27, 38, 0.05);
  --safe-b: env(safe-area-inset-bottom, 0px);
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-size: 17px;
  line-height: 1.45;
  min-height: 100dvh;
}
button, input, textarea, select { font: inherit; color: inherit; }
a { color: var(--accent); }
img { max-width: 100%; }
[hidden] { display: none !important; }

.wrap { max-width: 560px; margin: 0 auto; padding: 16px 16px calc(96px + var(--safe-b)); }

/* ---------- header ---------- */
.top {
  display: flex; align-items: center; gap: 12px;
  padding: 18px 4px 10px;
}
.top .logo {
  width: 44px; height: 44px; border-radius: 12px; flex: none;
  background: var(--accent-soft); display: grid; place-items: center; overflow: hidden;
}
.top .logo img { width: 100%; height: 100%; object-fit: contain; }
.top .logo svg { width: 26px; height: 26px; }
.top h1 { font-size: 20px; margin: 0; line-height: 1.2; letter-spacing: -0.01em; }
.top .sub { color: var(--muted); font-size: 14px; margin: 2px 0 0; }
.top .grow { flex: 1; min-width: 0; }

h2 { font-size: 19px; margin: 0 0 4px; letter-spacing: -0.01em; }
h3 { font-size: 16px; margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.center { text-align: center; }

/* ---------- cards ---------- */
.card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 18px; margin: 12px 0;
}
.card.flat { box-shadow: none; border: 1px solid var(--line); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.section-title { font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin: 22px 4px 6px; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 52px; padding: 0 20px; border-radius: 14px; border: 0;
  background: var(--accent); color: #fff; font-weight: 600; font-size: 17px;
  cursor: pointer; text-decoration: none; transition: transform 0.08s, opacity 0.15s, background 0.15s;
  width: 100%;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn.secondary { background: var(--accent-soft); color: var(--accent); }
.btn.ghost { background: transparent; color: var(--accent); border: 1.5px solid var(--line); }
.btn.danger { background: var(--red-soft); color: var(--red); }
.btn.green { background: #1fa363; }
.btn.sm { min-height: 40px; padding: 0 14px; font-size: 15px; border-radius: 12px; width: auto; }
.btn-row { display: flex; gap: 10px; }
.btn-row > * { flex: 1; }
.stack > * + * { margin-top: 10px; }

.icon-btn {
  width: 42px; height: 42px; border-radius: 12px; border: 0; flex: none;
  background: var(--bg); color: var(--muted); display: grid; place-items: center; cursor: pointer;
}
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn.accent { background: var(--accent-soft); color: var(--accent); }
.icon-btn.wa { background: #e5f7ed; color: #1fa363; }
.icon-btn:active { transform: scale(0.95); }

/* ---------- forms ---------- */
label.field { display: block; margin: 12px 0; }
label.field > span { display: block; font-size: 14px; font-weight: 600; margin: 0 0 6px 2px; color: var(--text); }
label.field > small { display: block; font-size: 13px; color: var(--muted); margin: 6px 2px 0; }
.input, textarea.input, select.input {
  width: 100%; min-height: 52px; padding: 12px 14px; border-radius: 12px;
  border: 1.5px solid var(--line); background: #fff; outline: none; font-size: 17px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
textarea.input { min-height: 88px; resize: vertical; }
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input-row { display: flex; gap: 10px; }
.input-row > * { flex: 1; min-width: 0; }
.prefix { position: relative; }
.prefix > b { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); font-weight: 500; pointer-events: none; }
.prefix > .input { padding-left: 44px; }

.switch { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 6px 0; cursor: pointer; }
.switch input { appearance: none; width: 50px; height: 30px; border-radius: 99px; background: var(--line); position: relative; flex: none; cursor: pointer; transition: background 0.2s; }
.switch input::after { content: ''; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.2); transition: transform 0.2s; }
.switch input:checked { background: var(--accent); }
.switch input:checked::after { transform: translateX(20px); }

/* ---------- segmented tabs ---------- */
.segmented {
  display: flex; background: #ebe8f4; border-radius: 14px; padding: 4px; gap: 4px; margin: 8px 0 4px;
  position: sticky; top: 8px; z-index: 5;
}
.segmented button {
  flex: 1; border: 0; background: transparent; border-radius: 11px; min-height: 44px;
  font-weight: 600; color: var(--muted); cursor: pointer; font-size: 16px;
}
.segmented button.on { background: #fff; color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.08); }

/* ---------- chips / badges ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 1.5px solid var(--line); background: #fff; border-radius: 99px; padding: 8px 14px; min-height: 40px;
  font-size: 15px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
}
.chip.on { background: var(--red-soft); border-color: #f3b9b9; color: var(--red); text-decoration: line-through; }
.badge { display: inline-flex; align-items: center; gap: 4px; font-size: 12.5px; font-weight: 600; padding: 3px 9px; border-radius: 99px; background: var(--bg); color: var(--muted); white-space: nowrap; }
.badge.ok { background: var(--green-soft); color: var(--green); }
.badge.warn { background: var(--amber-soft); color: var(--amber); }
.badge.accent { background: var(--accent-soft); color: var(--accent); }

/* ---------- lists ---------- */
.list { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; margin: 12px 0; }
.row { display: flex; align-items: center; gap: 12px; padding: 14px 14px 14px 16px; border-top: 1px solid var(--line); }
.row:first-child { border-top: 0; }
.row .grow { flex: 1; min-width: 0; }
.row .name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.avatar {
  width: 40px; height: 40px; border-radius: 50%; flex: none; display: grid; place-items: center;
  font-weight: 700; color: #fff; font-size: 16px;
}

/* ---------- wish cards ---------- */
.wish { display: flex; gap: 12px; padding: 14px; border-top: 1px solid var(--line); align-items: flex-start; }
.wish:first-child { border-top: 0; }
.wish .thumb {
  width: 72px; height: 72px; border-radius: 12px; background: var(--bg); flex: none; overflow: hidden;
  display: grid; place-items: center; color: var(--accent);
}
.wish .thumb img { width: 100%; height: 100%; object-fit: contain; background: #fff; }
.wish .thumb svg { width: 28px; height: 28px; opacity: 0.6; }
.wish .info { flex: 1; min-width: 0; }
.wish .title { font-weight: 600; line-height: 1.3; word-break: break-word; }
.wish .price { color: var(--green); font-weight: 700; font-size: 15px; margin-top: 3px; }
.wish .price.out { color: var(--amber); }
.wish .note { color: var(--muted); font-size: 14.5px; margin-top: 4px; white-space: pre-wrap; word-break: break-word; }
.wish .link { display: inline-block; max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 8px; font-weight: 600; font-size: 15px; text-decoration: none; background: var(--accent-soft); padding: 7px 12px; border-radius: 10px; }
.wish .link svg { vertical-align: -2px; margin-left: 2px; }
.wish .actions { display: flex; flex-direction: column; gap: 6px; }

.empty { text-align: center; padding: 28px 18px; color: var(--muted); }
.empty .big { font-size: 40px; line-height: 1; margin-bottom: 8px; }

/* ---------- reveal ---------- */
.reveal {
  text-align: center; padding: 26px 18px 20px; border-radius: 22px; color: #fff;
  background: linear-gradient(145deg, #6d4ae0 0%, #8f5ee8 55%, #b062d6 100%);
  box-shadow: 0 10px 30px rgba(109, 74, 224, 0.28); position: relative; overflow: hidden;
}
.reveal::before, .reveal::after {
  content: ''; position: absolute; border-radius: 50%; background: rgba(255,255,255,.08);
}
.reveal::before { width: 220px; height: 220px; right: -70px; top: -90px; }
.reveal::after { width: 160px; height: 160px; left: -60px; bottom: -80px; }
.reveal > * { position: relative; }
.reveal .label { opacity: 0.85; font-size: 15px; }
.reveal .who { font-size: 38px; font-weight: 800; letter-spacing: -0.02em; margin: 10px 0 14px; min-height: 48px; }
.reveal .who.hiddenname { filter: blur(14px); user-select: none; }
.reveal .btn { background: #fff; color: var(--accent); }
.reveal .btn.ghost { background: rgba(255,255,255,.14); color: #fff; border-color: rgba(255,255,255,.3); }
.reveal .gift { width: 64px; height: 64px; margin: 4px auto 0; }
.pop { animation: pop 0.45s cubic-bezier(.2,1.4,.4,1); }
@keyframes pop { from { transform: scale(0.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* ---------- info grid ---------- */
.facts { display: grid; grid-template-columns: 1fr; gap: 10px; }
.fact { display: flex; gap: 12px; align-items: center; }
.fact .ico { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; flex: none; font-size: 20px; background: var(--bg); }
.fact b { display: block; font-size: 16px; }
.fact span { color: var(--muted); font-size: 14px; }

/* ---------- bottom nav (admin) ---------- */
.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  background: rgba(255,255,255,.96); backdrop-filter: blur(10px); border-top: 1px solid var(--line);
  padding: 6px 6px calc(6px + var(--safe-b));
}
.nav .in { max-width: 560px; margin: 0 auto; display: flex; }
.nav button {
  flex: 1; border: 0; background: none; display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 7px 0; font-size: 12px; font-weight: 600; color: var(--muted); cursor: pointer; border-radius: 12px;
}
.nav button svg { width: 24px; height: 24px; }
.nav button.on { color: var(--accent); }
.nav button.on .pill { background: var(--accent-soft); }
.nav .pill { padding: 3px 16px; border-radius: 99px; display: grid; place-items: center; }

/* ---------- sheet / modal ---------- */
.sheet-bg {
  position: fixed; inset: 0; background: rgba(20, 16, 40, 0.42); z-index: 50;
  display: flex; align-items: flex-end; justify-content: center; animation: fade 0.18s;
}
.sheet {
  background: #fff; width: 100%; max-width: 560px; border-radius: 22px 22px 0 0;
  padding: 10px 18px calc(18px + var(--safe-b)); max-height: 92dvh; overflow: auto;
  animation: up 0.24s cubic-bezier(.2,.9,.3,1);
}
.sheet .grab { width: 40px; height: 5px; background: var(--line); border-radius: 9px; margin: 2px auto 12px; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
@media (min-width: 640px) {
  .sheet-bg { align-items: center; }
  .sheet { border-radius: 22px; }
}
@keyframes fade { from { opacity: 0; } }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(92px + var(--safe-b)); transform: translateX(-50%);
  background: #1d1b26; color: #fff; padding: 12px 18px; border-radius: 14px; font-size: 15px; z-index: 100;
  box-shadow: 0 8px 24px rgba(0,0,0,.2); max-width: calc(100% - 32px); animation: up 0.2s;
}
.toast.err { background: var(--red); }

.alert { padding: 12px 14px; border-radius: 12px; font-size: 15px; margin: 10px 0; }
.alert.warn { background: var(--amber-soft); color: #7a5312; }
.alert.info { background: var(--accent-soft); color: #4b2fb0; }
.alert.ok { background: var(--green-soft); color: #0e6644; }

.loading { display: grid; place-items: center; min-height: 60dvh; color: var(--muted); }
.spinner { width: 34px; height: 34px; border: 3px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.count { font-variant-numeric: tabular-nums; }
.divider { height: 1px; background: var(--line); margin: 14px 0; }
.stat-row { display: flex; gap: 10px; }
.stat { flex: 1; background: var(--bg); border-radius: 14px; padding: 12px; text-align: center; }
.stat b { display: block; font-size: 24px; line-height: 1.1; }
.stat span { font-size: 12.5px; color: var(--muted); font-weight: 600; }
details.exp > summary { list-style: none; cursor: pointer; }
details.exp > summary::-webkit-details-marker { display: none; }
.chev { transition: transform 0.2s; color: var(--muted); }
details[open] .chev { transform: rotate(180deg); }
.table { width: 100%; border-collapse: collapse; }
.table td { padding: 12px 6px; border-top: 1px solid var(--line); }
.table tr:first-child td { border-top: 0; }
