: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: 15px; cursor: pointer; color: #cbd5e1; line-height: 1; padding: 0 2px; }
.fav-btn.on { color: #ef4444; }
.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-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; }
