/* ========== Theme tokens ========== */
:root,
[data-theme="dark"] {
  --bg: #09090b;
  --bg-elevated: #0f0f12;
  --surface: rgba(24, 24, 31, 0.72);
  --surface-solid: #18181f;
  --surface-2: #22222c;
  --text: #f4f4f5;
  --text-muted: #a1a1aa;
  --accent: #8b7cf7;
  --accent-hover: #a59bff;
  --accent-soft: rgba(139, 124, 247, 0.14);
  --success: #34d399;
  --success-soft: rgba(52, 211, 153, 0.15);
  --error: #f87171;
  --error-soft: rgba(248, 113, 113, 0.15);
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.12);
  --shadow: 0 20px 50px rgba(0, 0, 0, 0.45);
  --nav-bg: rgba(9, 9, 11, 0.75);
  --glass: blur(16px) saturate(1.4);
  --blob-1: rgba(139, 124, 247, 0.22);
  --blob-2: rgba(52, 211, 153, 0.12);
  --blob-3: rgba(251, 191, 36, 0.08);
  --qr-bg: #ffffff;
  --radius: 14px;
  --radius-lg: 20px;
  color-scheme: dark;
}

[data-theme="light"] {
  --bg: #f6f7fb;
  --bg-elevated: #ffffff;
  --surface: rgba(255, 255, 255, 0.78);
  --surface-solid: #ffffff;
  --surface-2: #f0f1f5;
  --text: #18181b;
  --text-muted: #71717a;
  --accent: #6d5ef5;
  --accent-hover: #5a4ae8;
  --accent-soft: rgba(109, 94, 245, 0.12);
  --success: #10b981;
  --success-soft: rgba(16, 185, 129, 0.12);
  --error: #ef4444;
  --error-soft: rgba(239, 68, 68, 0.12);
  --border: rgba(0, 0, 0, 0.07);
  --border-strong: rgba(0, 0, 0, 0.1);
  --shadow: 0 16px 40px rgba(24, 24, 40, 0.1);
  --nav-bg: rgba(246, 247, 251, 0.8);
  --glass: blur(16px) saturate(1.2);
  --blob-1: rgba(109, 94, 245, 0.18);
  --blob-2: rgba(16, 185, 129, 0.1);
  --blob-3: rgba(245, 158, 11, 0.08);
  --qr-bg: #ffffff;
  color-scheme: light;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: 'Noto Sans SC', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  position: relative;
  overflow-x: hidden;
}

/* Background blobs */
.bg-blobs {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.9;
}

.blob-1 {
  width: 420px;
  height: 420px;
  background: var(--blob-1);
  top: -120px;
  left: 50%;
  transform: translateX(-50%);
}

.blob-2 {
  width: 320px;
  height: 320px;
  background: var(--blob-2);
  bottom: 10%;
  right: -80px;
}

.blob-3 {
  width: 280px;
  height: 280px;
  background: var(--blob-3);
  bottom: -40px;
  left: -60px;
}

/* Nav */
.nav {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--nav-bg);
  backdrop-filter: var(--glass);
  -webkit-backdrop-filter: var(--glass);
  border-bottom: 1px solid var(--border);
}

.nav-inner {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0.85rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.nav-brand {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  text-decoration: none;
  color: var(--text);
  font-weight: 600;
  font-size: 1.05rem;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), #c084fc);
  color: #fff;
  font-size: 0.95rem;
  box-shadow: 0 4px 14px var(--accent-soft);
}

.theme-toggle {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface-solid);
  color: var(--text-muted);
  cursor: pointer;
  transition: color 0.2s, background 0.2s, border-color 0.2s, transform 0.15s;
}

.theme-toggle:hover {
  color: var(--text);
  border-color: var(--border-strong);
  transform: scale(1.04);
}

[data-theme="dark"] .icon-sun { display: none; }
[data-theme="dark"] .icon-moon { display: block; }
[data-theme="light"] .icon-sun { display: block; }
[data-theme="light"] .icon-moon { display: none; }

/* Hero */
.hero {
  position: relative;
  z-index: 1;
  text-align: center;
  padding: 3rem 1.5rem 1.5rem;
  max-width: 720px;
  margin: 0 auto;
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.3rem 0.85rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid transparent;
  margin-bottom: 1rem;
}

.hero-badge::before {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent);
  animation: pulse 1.6s ease infinite;
}

.hero-title {
  font-size: clamp(1.75rem, 4vw, 2.45rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.25;
  margin-bottom: 0.75rem;
  background: linear-gradient(135deg, var(--text) 30%, var(--accent));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

[data-theme="light"] .hero-title {
  background: linear-gradient(135deg, #18181b 20%, #6d5ef5 90%);
  -webkit-background-clip: text;
  background-clip: text;
}

.hero-sub {
  color: var(--text-muted);
  font-size: 1rem;
  max-width: 420px;
  margin: 0 auto;
}

/* 谷歌式搜索框 */
.search-box {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  width: min(560px, 100%);
  margin: 1.6rem auto 0;
  padding: 0.35rem 0.55rem 0.35rem 1.15rem;
  background: var(--surface-solid);
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.12);
  transition: box-shadow 0.2s, border-color 0.2s;
  position: relative;
  z-index: 1;
}

.search-box:hover {
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.18);
}

.search-box:focus-within {
  box-shadow: 0 6px 26px rgba(0, 0, 0, 0.22);
  border-color: var(--accent);
}

.search-icon {
  display: flex;
  color: var(--text-muted);
  flex-shrink: 0;
}

.search-box input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font-size: 1rem;
  font-family: inherit;
  padding: 0.55rem 0;
}

/* 用自定义清除按钮，隐藏浏览器原生的 */
.search-box input::-webkit-search-cancel-button {
  display: none;
}

.search-box input::placeholder {
  color: var(--text-muted);
}

.search-clear {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 0;
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: 0.85rem;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  transition: color 0.15s, background 0.15s;
}

.search-clear:hover {
  color: var(--text);
}

/* 搜索无结果 */
.wall-empty {
  color: var(--text-muted);
  font-size: 0.95rem;
  text-align: center;
  padding: 3rem 1.5rem;
  line-height: 1.8;
}

/* Wall section */
.wall-section {
  position: relative;
  z-index: 1;
  max-width: 1120px;
  margin: 0 auto;
  padding: 1rem 1.5rem 3.5rem;
}

.wall-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.85rem;
  padding: 0 0.25rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.wall-toolbar-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.shuffle-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.42rem 0.9rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-solid);
  color: var(--text-muted);
  font-size: 0.82rem;
  font-family: inherit;
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s, transform 0.2s;
}

.shuffle-btn:hover {
  color: var(--accent);
  border-color: var(--accent);
  transform: rotate(-6deg) scale(1.05);
}

.shuffle-btn:active {
  transform: scale(0.96);
}

.wall-count {
  font-weight: 500;
  color: var(--text);
}

.word-wall {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 0.7rem 0.9rem;
  min-height: 380px;
  padding: 2rem 1.5rem;
  background: var(--surface);
  backdrop-filter: var(--glass);
  -webkit-backdrop-filter: var(--glass);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  position: relative;
}

/* 面板顶部柔光 */
.word-wall::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.045), transparent 32%);
}

.wall-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  color: var(--text-muted);
  font-size: 0.9rem;
  padding: 2rem;
}

.spinner {
  width: 28px;
  height: 28px;
  border: 2.5px solid var(--border-strong);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.word-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.45em;
  padding: 0.5em 1.05em;
  border-radius: 999px;
  font-weight: 500;
  cursor: pointer;
  transition: transform 0.22s cubic-bezier(0.34, 1.56, 0.64, 1),
              box-shadow 0.22s ease,
              filter 0.2s;
  border: 1px solid transparent;
  user-select: none;
  position: relative;
  z-index: 1;
  animation: floatIn 0.55s ease backwards;
  background: var(--surface-2);
  font-family: inherit;
  line-height: 1.3;
}

.word-tag:hover {
  transform: scale(1.1) translateY(-3px);
  box-shadow: 0 10px 28px color-mix(in srgb, var(--tag-color, #7c6af5) 42%, transparent);
  filter: brightness(1.08);
  z-index: 2;
}

.word-tag:active {
  transform: scale(1.04);
}

/* 标签内部：文字 */
.tag-text {
  white-space: nowrap;
}

/* 置顶标签：金色描边 + 微光 */
.pin-badge {
  font-size: 0.85em;
  line-height: 1;
}

.word-tag.pinned {
  box-shadow: 0 0 0 1.5px rgba(245, 179, 1, 0.55),
              0 6px 18px rgba(245, 179, 1, 0.16);
}

.word-tag.pinned:hover {
  box-shadow: 0 0 0 1.5px rgba(245, 179, 1, 0.85),
              0 10px 28px color-mix(in srgb, var(--tag-color, #7c6af5) 42%, transparent);
}

@keyframes floatIn {
  from {
    opacity: 0;
    transform: scale(0.7) translateY(14px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1rem;
  opacity: 1;
  transition: opacity 0.25s ease;
}

[data-theme="light"] .modal-overlay {
  background: rgba(15, 15, 25, 0.35);
}

.modal-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.modal {
  background: var(--surface-solid);
  border: 1px solid var(--border);
  border-radius: 18px;
  width: 100%;
  max-width: 420px;
  padding: 1.75rem;
  position: relative;
  box-shadow: var(--shadow);
  max-height: 90vh;
  overflow-y: auto;
  animation: modalIn 0.28s cubic-bezier(0.34, 1.2, 0.64, 1);
}

@keyframes modalIn {
  from {
    opacity: 0;
    transform: scale(0.94) translateY(12px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.modal-close {
  position: absolute;
  top: 0.85rem;
  right: 0.85rem;
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text-muted);
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
}

.modal-close:hover {
  color: var(--text);
  background: var(--surface-2);
}

.modal-kicker {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 0.4rem;
}

.step h2 {
  font-size: 1.3rem;
  margin-bottom: 0.65rem;
  font-weight: 650;
  letter-spacing: -0.02em;
  padding-right: 2rem;
}

.modal-desc {
  color: var(--text-muted);
  font-size: 0.92rem;
  margin-bottom: 1.25rem;
  white-space: pre-line; /* 描述支持多行换行 */
}

.price-tag {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
  padding: 1rem 1.15rem;
  background: var(--accent-soft);
  border: 1px solid transparent;
  border-radius: var(--radius);
}

.price-label {
  color: var(--text-muted);
  font-size: 0.88rem;
}

.price-value {
  font-size: 1.7rem;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: -0.02em;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0.75rem 1.25rem;
  border: none;
  border-radius: 12px;
  font-size: 0.95rem;
  font-weight: 550;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.2s, transform 0.15s, box-shadow 0.2s;
}

.btn:active {
  transform: scale(0.98);
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-block {
  width: 100%;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent), #a78bfa);
  color: #fff;
  box-shadow: 0 6px 20px var(--accent-soft);
}

.btn-primary:hover:not(:disabled) {
  filter: brightness(1.06);
  box-shadow: 0 8px 24px var(--accent-soft);
}

[data-theme="light"] .btn-primary {
  background: linear-gradient(135deg, #6d5ef5, #8b5cf6);
}

.btn-secondary {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  width: auto;
  padding: 0.5rem 1rem;
  font-size: 0.88rem;
}

.btn-secondary:hover:not(:disabled) {
  border-color: var(--border-strong);
}

/* QR step */
.qr-hint {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 1.1rem;
}

.qr-box {
  display: flex;
  justify-content: center;
  margin-bottom: 1rem;
  padding: 0.85rem;
  background: var(--qr-bg);
  border-radius: 14px;
  width: fit-content;
  margin-left: auto;
  margin-right: auto;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
}

.qr-box img {
  display: block;
  border-radius: 6px;
  max-width: 200px;
  height: auto;
}

.amount-hint {
  text-align: center;
  font-size: 0.98rem;
  margin-bottom: 0.45rem;
}

.amount-hint strong {
  color: var(--accent);
  font-size: 1.15rem;
}

.order-id {
  text-align: center;
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-bottom: 1.15rem;
}

.order-id code {
  background: var(--surface-2);
  padding: 0.15em 0.45em;
  border-radius: 5px;
  font-size: 0.88em;
}

.status-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.65rem;
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.9rem;
  font-weight: 500;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
  animation: pulse 1.4s ease infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

.status.pending {
  color: #f59e0b;
}

.status.paid {
  color: var(--success);
}

.poll-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-align: center;
}

/* Success / Error */
.success-icon {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: var(--success-soft);
  color: var(--success);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 1rem;
}

.success-keyword {
  text-align: center;
  color: var(--text-muted);
  margin-bottom: 1.2rem;
  font-size: 0.95rem;
}

.resource-box {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 1.2rem;
  max-height: 220px;
  overflow-y: auto;
}

.resource-box pre {
  white-space: pre-wrap;
  word-break: break-word;
  font-family: 'Noto Sans SC', ui-monospace, monospace;
  font-size: 0.88rem;
  line-height: 1.65;
  color: var(--text);
}

.error-icon {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: var(--error-soft);
  color: var(--error);
  font-size: 1.6rem;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 1rem;
  font-weight: 700;
}

.error-msg {
  text-align: center;
  color: var(--text-muted);
  margin-bottom: 1.2rem;
}

.hidden {
  display: none !important;
}

/* Footer */
.footer {
  position: relative;
  z-index: 1;
  text-align: center;
  padding: 1.5rem 1rem 2.5rem;
  color: var(--text-muted);
  font-size: 0.8rem;
}

.footer a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
}

.footer a:hover {
  text-decoration: underline;
}

/* Responsive */
@media (max-width: 600px) {
  .hero {
    padding: 2rem 1.15rem 1rem;
  }
  .word-wall {
    min-height: 300px;
    padding: 1.25rem 0.85rem;
    gap: 0.5rem 0.6rem;
    border-radius: 16px;
  }
  .modal {
    padding: 1.4rem;
    border-radius: 16px;
  }
  .wall-toolbar {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.25rem;
  }
}
