:root {
  --brand: #6d28d9;
  --brand-dark: #5b21b6;
  --brand-soft: #f3e8ff;
  --bg: #f3f4f6;
  --card: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --border: #e5e7eb;
  --radius: 16px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 4px 16px rgba(0, 0, 0, 0.05);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

.app { max-width: 480px; margin: 0 auto; padding: 16px 16px 80px; }

/* Header */
.app-header {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 8px 4px 16px;
}
.h1-title { font-size: 22px; font-weight: 800; }
.app-version { font-size: 12px; color: var(--muted); }
.hdr-nav { display: flex; gap: 6px; }
.hdr-btn { background: #fff; border: 1px solid var(--border); border-radius: 20px; padding: 6px 10px; font-size: 12px; color: var(--brand-dark); cursor: pointer; white-space: nowrap; }
.hdr-btn:active { background: var(--brand-soft); }

.view { display: block; }
.view.hidden, .hidden { display: none !important; }

/* Cards */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  margin-bottom: 16px;
}
.hero { background: linear-gradient(135deg, var(--brand-soft), #ffffff); text-align: center; }
.hero-title { font-size: 22px; font-weight: 800; color: var(--brand-dark); }
.hero-sub { font-size: 13px; color: var(--muted); margin: 6px 0 0; line-height: 1.5; }
.hero .btn { margin-top: 12px; }
.step-title { font-size: 17px; font-weight: 700; margin-bottom: 12px; }

/* Mode / style */
.mode-row { display: flex; gap: 8px; margin-bottom: 14px; }
.mode-btn {
  flex: 1; padding: 12px; border-radius: 12px; border: 1px solid var(--border);
  background: #fff; font-size: 15px; font-weight: 600; color: var(--text);
  cursor: pointer;
}
.mode-btn.active { background: var(--brand-soft); border-color: var(--brand); color: var(--brand-dark); }

.field-label { display: block; font-size: 13px; color: var(--muted); margin: 12px 0 6px; font-weight: 600; }
.label-sub { font-weight: 400; }

.style-row { display: flex; flex-wrap: wrap; gap: 8px; }
.style-btn {
  padding: 8px 14px; border-radius: 20px; border: 1px solid var(--border);
  background: #fff; font-size: 14px; cursor: pointer; color: var(--text);
}
.style-btn.active { background: var(--brand); color: #fff; border-color: var(--brand); }

textarea {
  width: 100%; min-height: 76px; padding: 12px; border-radius: 12px;
  border: 1px solid var(--border); font-size: 15px; font-family: inherit; resize: none;
}
textarea:focus { outline: none; border-color: var(--brand); }

/* Buttons */
.btn { border: none; border-radius: 12px; padding: 14px; font-size: 16px; font-weight: 700; cursor: pointer; width: 100%; }
.btn-primary { background: var(--brand); color: #fff; margin-top: 14px; }
.btn-primary:active { background: var(--brand-dark); }
.btn-outline { background: #fff; color: var(--brand-dark); border: 1px solid var(--brand); margin-top: 10px; }
.btn-block { display: block; }
.btn-row { display: flex; gap: 10px; }
.btn-row .btn { flex: 1; }

/* Invite */
.invite-box, .unique-box {
  text-align: center; background: var(--brand-soft); border-radius: 12px;
  padding: 14px; margin-bottom: 6px;
}
.invite-label { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.invite-code, .unique-code { font-size: 28px; font-weight: 800; letter-spacing: 2px; color: var(--brand-dark); font-family: "SF Mono", Menlo, monospace; }
.hint { font-size: 12px; color: var(--muted); margin-top: 12px; text-align: center; line-height: 1.5; }

.quote {
  background: var(--brand-soft); border-radius: 12px; padding: 14px; margin-bottom: 4px;
  color: var(--brand-dark); font-size: 15px; line-height: 1.6; font-weight: 600;
}

/* Result */
.result-wrap { text-align: center; }
.result-img {
  width: 100%; aspect-ratio: 1/1; object-fit: cover; border-radius: 14px;
  background: #eee;
}
.claimed-tip { margin-top: 10px; color: #16a34a; text-align: center; font-weight: 600; font-size: 14px; }

/* Gallery */
.wall-note { font-size: 12px; color: var(--muted); margin: -6px 0 12px; }
.gallery {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px;
}
.gallery .cell {
  border-radius: 10px; overflow: hidden; background: #fff;
  box-shadow: var(--shadow); cursor: pointer;
}
.gallery .cell img { width: 100%; aspect-ratio: 1/1; object-fit: cover; display: block; background: #eee; }
.gallery .cell-caption {
  display: flex; align-items: center; justify-content: space-between; gap: 4px;
  padding: 6px 8px; font-size: 11px; color: var(--muted);
  font-family: "SF Mono", Menlo, monospace; border-top: 1px solid var(--border);
  white-space: nowrap; overflow: hidden;
}
.gallery .cell-caption span { overflow: hidden; text-overflow: ellipsis; }
.fav-btn { background: transparent; border: none; font-size: 20px; cursor: pointer; color: #cbd5e1; line-height: 1; padding: 0 3px; }
.fav-btn.on { color: #ef4444; }
.cell-btns { display: inline-flex; align-items: center; gap: 2px; }
.mine-badge { background: var(--brand); color: #fff; font-size: 10px; border-radius: 8px; padding: 1px 6px; font-weight: 600; flex: none; }
.dis-btn { background: transparent; border: none; font-size: 12px; cursor: pointer; color: #cbd5e1; line-height: 1; padding: 0 2px; opacity: .5; }
.dis-btn.on { color: #f59e0b; opacity: 1; }
.lb-dis { background: transparent; border: 1px solid var(--border); color: var(--muted); }
.lb-dis.on { color: #b45309; border-color: #f59e0b; }
.dis-pill { background: #fef3c7; color: #b45309; }
/* 详图：不喜欢=纯 emoji，放编号右侧（低调） */
.lb-code { display: flex; align-items: center; gap: 6px; }
.lb-dis-emoji { background: transparent; border: none; font-size: 16px; cursor: pointer; color: #cbd5e1; line-height: 1; padding: 0 2px; opacity: .4; }
.lb-dis-emoji.on { color: #f59e0b; opacity: .9; }
/* 圆形头像模式（一键） */
.gallery-actions { margin: -4px 0 10px; }
.round-toggle.active { background: var(--brand-dark); color: #fff; border-color: var(--brand-dark); }
body.avatars-round .cell img,
body.avatars-round .cell.pair .pair-img img,
body.avatars-round .cell.group .group-item img,
body.avatars-round .lb-img { border-radius: 50%; }
/* 情侣/CP 对：整行一组两张 */
.gallery .cell.pair { grid-column: 1 / -1; padding: 6px; }
.gallery .cell.pair .pair-imgs { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.gallery .cell.pair .pair-img img { width: 100%; aspect-ratio: 1/1; object-fit: cover; display: block; background: #eee; border-radius: 8px; cursor: pointer; }
.gallery .cell.pair .pair-tag { color: #6c5ce7; font-weight: 700; flex: none; }
.gallery .cell.pair .pair-plus { color: var(--muted); }
/* 一组（兄弟/MBTI/星座 一套） */
.gallery .cell.group { grid-column: 1 / -1; padding: 8px; }
.gallery .cell.group .group-head { font-size: 12px; color: #6c5ce7; font-weight: 700; margin-bottom: 6px; }
.gallery .cell.group .group-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); gap: 6px; }
.gallery .cell.group .group-item img { width: 100%; aspect-ratio: 1/1; object-fit: cover; display: block; border-radius: 8px; cursor: pointer; background: #eee; }
/* 头像等级框（B 方案：免费/黄金/白金 · 描边+角标） */
.gallery .cell { position: relative; }
.pair-img, .group-item { position: relative; }
.tier-badge {
  position: absolute; top: 6px; right: 6px; z-index: 3;
  font-size: 10px; font-weight: 700; letter-spacing: .5px;
  padding: 2px 8px; border-radius: 999px; color: #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,.25); pointer-events: none; white-space: nowrap;
}
.tier-badge.free { background: #94a3b8; }
.tier-badge.gold { background: linear-gradient(135deg,#f7c948,#e0a800); }
.tier-badge.platinum { background: linear-gradient(135deg,#e8f0ff,#b7c6e8); color: #334155; }
.cell.tier-free { border: 2px solid #e2e8f0; }
.cell.tier-gold { border: 2px solid #f5c542; box-shadow: 0 0 10px rgba(245,197,66,.45), var(--shadow); }
.cell.tier-platinum { border: 2px solid #cdd9f5; box-shadow: 0 0 12px rgba(190,210,255,.55), var(--shadow); }
.pair-img.tier-gold img, .group-item.tier-gold img { box-shadow: 0 0 0 2px #f5c542 inset; }
.pair-img.tier-platinum img, .group-item.tier-platinum img { box-shadow: 0 0 0 2px #cdd9f5 inset; }
.lb-img.tier-gold { outline: 3px solid #f5c542; outline-offset: -3px; }
.lb-img.tier-platinum { outline: 3px solid #cdd9f5; outline-offset: -3px; }
.empty { text-align: center; color: var(--muted); padding: 24px 0; font-size: 14px; }

/* Loading */
.loading {
  position: fixed; inset: 0; background: rgba(255,255,255,0.85);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px;
  z-index: 50;
}
.spinner {
  width: 46px; height: 46px; border: 4px solid var(--brand-soft);
  border-top-color: var(--brand); border-radius: 50%; animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-text { color: var(--muted); font-size: 14px; text-align: center; padding: 0 24px; line-height: 1.5; }

/* Lightbox / 详图 */
.lightbox {
  position: fixed; inset: 0; background: rgba(0,0,0,0.9); display: none;
  align-items: center; justify-content: center; z-index: 60;
}
.lightbox.open { display: flex; }
.lb-card { max-width: 92vw; width: min(92vw, 420px); background: #1f1f2e; border-radius: 14px; overflow: hidden; }
.lb-img { width: 100%; aspect-ratio: 1/1; object-fit: cover; display: block; background: #111; }
.lb-info { padding: 12px 14px 14px; color: #fff; }
.lb-code { font-size: 18px; font-weight: 800; font-family: "SF Mono", Menlo, monospace; letter-spacing: 1px; }
.lb-meta { font-size: 12px; color: #cbd5e1; margin-top: 4px; }
.lb-ai { font-size: 11px; color: #a78bfa; margin-top: 4px; font-weight: 600; }
.lb-actions { display: flex; gap: 10px; margin-top: 12px; }
.lb-actions .btn { flex: 1; margin-top: 0; padding: 10px; font-size: 14px; border-radius: 10px; }
.lb-fav.on { background: #ef4444; color: #fff; }
.lightbox .lb-close { position: absolute; top: 16px; right: 20px; color: #fff; font-size: 32px; cursor: pointer; }

/* 筛选 chips */
.filter-row { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
#reco-refresh { margin-bottom: 14px; }
.lb-gift { background: #7c3aed; color: #fff; }
.lb-gift:active { background: #5b21b6; }
.chip { padding: 6px 12px; border-radius: 18px; border: 1px solid var(--border); background: #fff; font-size: 13px; color: var(--muted); cursor: pointer; }
.chip.active { background: var(--brand); color: #fff; border-color: var(--brand); font-weight: 600; }

/* 同步码 */
.sync-box { background: var(--brand-soft); border-radius: 12px; padding: 14px; margin-bottom: 12px; }
.sync-label { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.sync-code { font-size: 22px; font-weight: 800; letter-spacing: 2px; color: var(--brand-dark); font-family: "SF Mono", Menlo, monospace; margin-bottom: 8px; }
.sync-box input { width: 100%; padding: 10px; border-radius: 10px; border: 1px solid var(--border); margin-top: 10px; font-size: 14px; }

/* 骨架屏 */
.cell.skel { pointer-events: none; }
.skel-img { width: 100%; aspect-ratio: 1/1; background: linear-gradient(90deg, #ececec 25%, #f7f7f7 37%, #ececec 63%); background-size: 400% 100%; animation: shimmer 1.3s ease infinite; }
.skel-line { height: 12px; margin: 8px 8px 6px; background: #ececec; border-radius: 6px; }
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }

/* 画像 */
.p-row { font-size: 15px; margin-bottom: 10px; }
.p-label { font-size: 12px; color: var(--muted); margin: 12px 0 6px; font-weight: 600; }
.p-pills { display: flex; flex-wrap: wrap; gap: 8px; }
.pill { padding: 5px 12px; border-radius: 16px; background: var(--brand-soft); color: var(--brand-dark); font-size: 13px; }
.p-persona { margin-top: 14px; background: linear-gradient(135deg, var(--brand-soft), #fff); border-radius: 12px; padding: 14px; font-size: 14px; line-height: 1.7; color: var(--text); white-space: pre-line; }

/* 买断模拟弹窗 */
.modal-mask { position: fixed; inset: 0; background: rgba(0,0,0,.5); display: flex; align-items: center; justify-content: center; z-index: 60; padding: 16px; }
/* 微信支付二维码 */
.pay-qr { display: flex; align-items: center; justify-content: center; padding: 12px 0 4px; }
.pay-qr svg, .pay-qr img { width: 200px; height: 200px; }
.pay-tip { font-size: 12px; color: #9ca3af; text-align: center; margin: 0 0 14px; }
/* 买断/支付成功 仪式感动画 */
.celebrate-mask { position: fixed; inset: 0; z-index: 80; display: flex; align-items: center; justify-content: center; }
.celebrate-burst { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.confetti { position: absolute; top: -10%; font-size: 22px; animation: confetti-fall 2.2s linear forwards; }
@keyframes confetti-fall { 0% { transform: translateY(-10vh) rotate(0deg); opacity: 1; } 100% { transform: translateY(110vh) rotate(340deg); opacity: .15; } }
.celebrate-card { position: relative; background: #fff; border-radius: 18px; padding: 26px 32px; text-align: center; box-shadow: 0 12px 40px rgba(0,0,0,.22); animation: celebrate-pop .5s ease; max-width: 82vw; }
.celebrate-icon { font-size: 52px; animation: celebrate-bounce .8s ease infinite; }
.celebrate-title { font-size: 20px; font-weight: 800; margin-top: 8px; color: var(--brand-dark); }
.celebrate-sub { font-size: 13px; color: var(--muted); margin-top: 6px; }
@keyframes celebrate-pop { 0% { transform: scale(.6); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }
@keyframes celebrate-bounce { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }
.modal-card { background: #fff; border-radius: 14px; padding: 20px; max-width: 320px; width: 100%; box-shadow: 0 12px 30px rgba(0,0,0,.2); }
.modal-title { font-weight: 700; font-size: 17px; margin-bottom: 8px; color: var(--text); }
.modal-desc { font-size: 13px; color: var(--muted); line-height: 1.5; margin: 0 0 16px; }
.modal-actions { display: flex; flex-direction: column; gap: 8px; }
.modal-actions .btn { width: 100%; }
.modal-cancel { background: transparent; border: 1px solid var(--border); color: var(--muted); }
