/* 心愿焰火 · 基础样式与通用组件 */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; min-height: 100%; }
body {
  font-family: var(--font-ui);
  font-size: 14px;
  line-height: 1.6;
  color: var(--ink);
  background:
    radial-gradient(circle at 50% 12%, rgba(226, 196, 120, .12), transparent 40%),
    linear-gradient(145deg, #211d18, #12100d 70%);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { appearance: none; border: 0; background: none; padding: 0; cursor: pointer; }
button:disabled { cursor: default; opacity: .55; }
input, textarea { appearance: none; border: 0; outline: 0; background: transparent; }
textarea { resize: none; }
a { color: inherit; text-decoration: none; }
svg { display: block; }
::selection { background: rgba(185, 145, 63, .24); }

.app {
  position: relative;
  width: min(100vw, var(--shell-max));
  height: min(100dvh, 920px);
  background: var(--paper);
  overflow: hidden;
  isolation: isolate;
  border-radius: 26px;
  box-shadow: 0 40px 110px rgba(0, 0, 0, .38);
}
.app::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: .32;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.08'/%3E%3C/svg%3E");
  mix-blend-mode: multiply;
}
.viewport {
  position: relative;
  z-index: 1;
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: none;
  scroll-behavior: smooth;
}
.viewport::-webkit-scrollbar { display: none; }
.view { min-height: 100%; padding-bottom: calc(28px + var(--safe-bottom)); animation: viewIn .26s ease-out both; }
.view.with-tabbar { padding-bottom: calc(var(--tab-h) + var(--safe-bottom) + 22px); }
.view.with-actions { padding-bottom: calc(112px + var(--safe-bottom)); }
.view.full-dark { background: var(--accent-night); color: #f8f2e6; }
@keyframes viewIn { from { opacity: .01; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes glowPulse { 0%, 100% { opacity: .38; transform: scale(.94); } 50% { opacity: .82; transform: scale(1.04); } }
@keyframes shimmer { 0% { opacity: .55; } 50% { opacity: .9; } 100% { opacity: .55; } }

@media (prefers-reduced-motion: reduce) {
  .view { animation: none; }
  * { animation-duration: .001ms !important; animation-iteration-count: 1 !important; }
}

/* ---- 排版 ---- */
.display { font-family: var(--font-display); font-weight: 600; letter-spacing: -.01em; }
.eyebrow { font-size: 10px; letter-spacing: .18em; text-transform: uppercase; color: var(--ink-3); font-weight: 600; }
.muted { color: var(--ink-2); }
.faint { color: var(--ink-3); }
.gold { color: var(--gold-deep); }
.hairline { height: 1px; background: var(--line); }
.h1 { font-size: 30px; line-height: 1.26; margin: 0; }
.h2 { font-size: 18px; line-height: 1.35; margin: 0; font-weight: 600; }
.h3 { font-size: 15px; margin: 0; font-weight: 600; }
.body-sm { font-size: 13px; line-height: 1.75; }
.tiny { font-size: 11px; line-height: 1.6; }
.mono-num { font-family: ui-monospace, "SFMono-Regular", Menlo, monospace; letter-spacing: .02em; }

/* ---- 布局 ---- */
.pad { padding-left: 20px; padding-right: 20px; }
.section { padding: 24px 20px 0; }
.section-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 14px; margin-bottom: 12px; }
.row { display: flex; align-items: center; }
.row.between { justify-content: space-between; }
.row.gap { gap: 10px; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.stack > * + * { margin-top: 10px; }
.mt-6 { margin-top: 6px; } .mt-10 { margin-top: 10px; } .mt-14 { margin-top: 14px; }
.mt-18 { margin-top: 18px; } .mt-24 { margin-top: 24px; } .mt-32 { margin-top: 32px; }
.mb-6 { margin-bottom: 6px; } .mb-10 { margin-bottom: 10px; } .mb-14 { margin-bottom: 14px; }
.divider { height: 1px; background: var(--line); margin: 16px 0; }

/* ---- 页面头 ---- */
.page-head {
  position: sticky;
  top: 0;
  z-index: 20;
  height: calc(54px + var(--safe-top));
  padding: var(--safe-top) 12px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: rgba(243, 238, 228, .93);
  backdrop-filter: blur(18px);
  border-bottom: 1px solid rgba(23, 19, 15, .055);
}
.page-head.dark { background: rgba(10, 9, 8, .76); color: #f8f2e6; border-bottom-color: rgba(255, 255, 255, .07); }
.page-head .head-title { font-size: 14px; font-weight: 600; letter-spacing: .02em; }
.page-head .head-sub { font-size: 10px; letter-spacing: .12em; color: var(--ink-3); }
.page-head.dark .head-sub { color: rgba(248, 242, 230, .6); }
.head-slot { width: 44px; height: 44px; display: grid; place-items: center; }

.icon-btn {
  width: 40px; height: 40px;
  display: grid; place-items: center;
  border-radius: 50%;
  color: inherit;
  transition: background .2s, transform .15s;
}
.icon-btn:active { transform: scale(.94); }
.icon-btn.ghost { background: rgba(255, 253, 249, .7); border: 1px solid var(--line); }
.icon-btn.dark { background: rgba(10, 9, 8, .34); border: 1px solid rgba(255, 255, 255, .12); color: #fff8e9; }
.svg-ico { width: 21px; height: 21px; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

/* ---- 按钮 ---- */
.btn {
  width: 100%;
  min-height: 50px;
  border-radius: var(--r-btn);
  display: flex; align-items: center; justify-content: center; gap: 8px;
  font-size: 15px; font-weight: 600;
  transition: transform .15s, background .2s, opacity .2s;
}
.btn:active { transform: scale(.982); }
.btn-primary { background: var(--ink); color: #fff9ec; box-shadow: 0 6px 18px rgba(23, 19, 15, .13); }
.btn-accent { background: var(--accent); color: #1b150b; box-shadow: 0 8px 24px rgba(0, 0, 0, .18); }
.btn-secondary { background: var(--white); color: var(--ink); border: 1px solid var(--line); box-shadow: var(--shadow-1); }
.btn-quiet { background: transparent; color: var(--ink-2); border: 1px solid var(--line); }
.btn-danger { background: transparent; color: var(--danger); border: 1px solid rgba(156, 74, 68, .34); }
.btn-sm { min-height: 40px; font-size: 13px; width: auto; padding: 0 16px; border-radius: var(--r-pill); }
.btn-block { width: 100%; }
.btn-actions {
  position: sticky;
  bottom: 0;
  z-index: 18;
  padding: 12px 20px calc(14px + var(--safe-bottom));
  background: linear-gradient(180deg, rgba(243, 238, 228, 0), rgba(243, 238, 228, .95) 34%);
  display: grid;
  gap: 8px;
}
.btn-actions.floating { position: fixed; left: 50%; transform: translateX(-50%); width: min(100vw, var(--shell-max)); }

/* ---- 卡片 ---- */
.card {
  background: var(--white);
  border-radius: var(--r-card);
  border: 1px solid rgba(23, 19, 15, .045);
  box-shadow: var(--shadow-1);
  padding: 16px;
}
.card.flush { padding: 0; overflow: hidden; }
.card.dark { background: rgba(255, 255, 255, .05); border-color: rgba(255, 255, 255, .12); color: #f6efe2; }
.card-title { font-size: 14px; font-weight: 600; margin: 0 0 4px; }
.card-note { font-size: 12px; color: var(--ink-3); }

.pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px;
  border-radius: var(--r-pill);
  font-size: 11px;
  border: 1px solid var(--line-strong);
  color: var(--ink-2);
  background: rgba(255, 253, 249, .8);
  white-space: nowrap;
}
.pill.accent { border-color: color-mix(in srgb, var(--accent) 42%, transparent); color: var(--accent-deep); background: color-mix(in srgb, var(--accent) 10%, transparent); }
.pill.warn { border-color: rgba(163, 120, 46, .4); color: var(--warn); background: rgba(163, 120, 46, .08); }
.pill.danger { border-color: rgba(156, 74, 68, .4); color: var(--danger); background: rgba(156, 74, 68, .08); }
.pill.success { border-color: rgba(85, 115, 94, .4); color: var(--success); background: rgba(85, 115, 94, .08); }
.pill.ghost { border-color: rgba(255, 255, 255, .22); color: rgba(255, 248, 232, .82); background: rgba(255, 255, 255, .06); }

.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.stat { background: var(--white); border-radius: 16px; padding: 14px; border: 1px solid rgba(23, 19, 15, .045); }
.stat .num { font-family: var(--font-display); font-size: 26px; line-height: 1.1; }
.stat .lab { font-size: 11px; color: var(--ink-3); margin-top: 4px; }

.list-row {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  width: 100%;
  text-align: left;
}
.list-row:last-child { border-bottom: 0; }
.list-row .chev { color: var(--ink-3); flex: none; }
.list-swatch { width: 42px; height: 42px; border-radius: 12px; flex: none; overflow: hidden; }

/* ---- 表单 ---- */
.field { margin-bottom: 16px; }
.field-label { display: block; font-size: 12px; color: var(--ink-2); margin-bottom: 6px; font-weight: 600; }
.field-hint { font-size: 11px; color: var(--ink-3); margin-top: 6px; }
.field-error { font-size: 12px; color: var(--danger); margin-top: 6px; }
.input, .textarea, .select {
  width: 100%;
  background: var(--white);
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 14px;
  color: var(--ink);
}
.textarea { min-height: 132px; line-height: 1.8; font-family: var(--font-display); font-size: 16px; }
.input:focus, .textarea:focus, .select:focus { border-color: color-mix(in srgb, var(--accent) 60%, transparent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 14%, transparent); }
.input.invalid, .textarea.invalid { border-color: rgba(156, 74, 68, .55); }
.counter { font-size: 11px; color: var(--ink-3); text-align: right; }
.counter.over { color: var(--danger); }
.chip-row { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  padding: 8px 14px;
  border-radius: var(--r-pill);
  border: 1px solid var(--line-strong);
  font-size: 13px;
  color: var(--ink-2);
  background: var(--white);
  min-height: 38px;
}
.chip[aria-pressed="true"] { background: var(--ink); color: #fff9ec; border-color: var(--ink); }
.switch-row {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  padding: 14px 0; border-bottom: 1px solid var(--line);
}
.switch-row:last-child { border-bottom: 0; }
.switch {
  width: 50px; height: 30px; border-radius: var(--r-pill);
  background: rgba(23, 19, 15, .16); position: relative; flex: none;
  transition: background .2s;
}
.switch[aria-checked="true"] { background: var(--accent); }
.switch::after {
  content: ""; position: absolute; top: 3px; left: 3px;
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--white); box-shadow: var(--shadow-1);
  transition: transform .2s;
}
.switch[aria-checked="true"]::after { transform: translateX(20px); }

/* ---- 状态 ---- */
.empty { text-align: center; padding: 34px 22px; }
.empty .mark { width: 54px; height: 54px; margin: 0 auto 14px; border-radius: 50%; display: grid; place-items: center; border: 1px solid color-mix(in srgb, var(--accent) 34%, transparent); color: var(--accent-deep); background: color-mix(in srgb, var(--accent) 8%, transparent); }
.skeleton { border-radius: 14px; background: linear-gradient(90deg, rgba(23, 19, 15, .06), rgba(23, 19, 15, .12), rgba(23, 19, 15, .06)); animation: shimmer 1.4s ease-in-out infinite; }
.skeleton.line { height: 12px; margin-bottom: 10px; }
.skeleton.block { height: 92px; }
.skeleton.hero { height: 240px; border-radius: 22px; }
.notice { border-radius: 14px; padding: 12px 14px; font-size: 12.5px; line-height: 1.65; border: 1px solid var(--line-strong); background: rgba(255, 253, 249, .75); color: var(--ink-2); }
.notice.warn { border-color: rgba(163, 120, 46, .38); background: rgba(163, 120, 46, .07); color: #7c5a1c; }
.notice.danger { border-color: rgba(156, 74, 68, .38); background: rgba(156, 74, 68, .07); color: #7b322c; }
.notice.success { border-color: rgba(85, 115, 94, .38); background: rgba(85, 115, 94, .07); color: #3f5a49; }
.notice.dark { background: rgba(255, 255, 255, .06); border-color: rgba(255, 255, 255, .16); color: rgba(248, 242, 230, .86); }
.spinner { width: 18px; height: 18px; border-radius: 50%; border: 2px solid rgba(23, 19, 15, .18); border-top-color: var(--accent-deep); animation: spin .8s linear infinite; }

/* ---- 底部 Tab ---- */
.tabbar {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  z-index: 22;
  height: calc(var(--tab-h) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  background: rgba(255, 253, 249, .94);
  backdrop-filter: blur(20px);
  border-top: 1px solid var(--line);
}
.tabbar[hidden] { display: none; }
.tab {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  font-size: 10px; letter-spacing: .06em; color: var(--ink-3);
}
.tab[aria-current="page"] { color: var(--ink); }
.tab[aria-current="page"] .svg-ico { stroke-width: 2.1; }

/* ---- Toast 与底部弹层 ---- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 96px;
  transform: translateX(-50%) translateY(12px);
  z-index: 60;
  max-width: min(88vw, 360px);
  padding: 11px 16px;
  border-radius: 14px;
  background: rgba(23, 19, 15, .92);
  color: #fdf7ea;
  font-size: 13px;
  line-height: 1.5;
  opacity: 0;
  transition: opacity .22s, transform .22s;
  pointer-events: none;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.warn { background: rgba(124, 90, 28, .95); }
.toast.danger { background: rgba(123, 50, 44, .95); }
.toast.success { background: rgba(63, 90, 73, .95); }

.sheet-mask {
  position: absolute;
  inset: 0;
  z-index: 50;
  background: rgba(10, 9, 8, .42);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: flex-end;
  opacity: 0;
  transition: opacity .22s;
}
.sheet-mask.show { opacity: 1; }
.sheet {
  width: 100%;
  max-height: 84%;
  overflow-y: auto;
  background: var(--paper);
  border-radius: 22px 22px 0 0;
  padding: 20px 20px calc(22px + var(--safe-bottom));
  transform: translateY(16px);
  transition: transform .24s;
}
.sheet-mask.show .sheet { transform: none; }
.sheet h3 { margin: 0 0 6px; font-size: 17px; }
.sheet .sheet-sub { font-size: 12px; color: var(--ink-3); margin-bottom: 16px; }
.sheet-actions { display: grid; gap: 8px; margin-top: 18px; }
