:root {
  --bg-page: #f5f5f7;
  --bg-subtle: #f3f4f7;
  --text: #1d1d1f;
  --text-muted: #6e6e73;
  --text-faint: #86868b;
  --border: rgba(15, 23, 42, .1);
  --border-strong: rgba(15, 23, 42, .16);
  --primary: #0071e3;
  --primary-soft: #e9f2fe;
  --grad: linear-gradient(135deg, #0a84ff 0%, #0071e3 100%);
  --success: #1a9e54;
  --success-soft: #e7f8ee;
  --amber: #b9770a;
  --amber-soft: #fdf3e2;
  --error: #e5484d;
  --error-soft: #fdecec;
  --shadow-xs: 0 1px 2px rgba(15, 23, 42, .06);
  --shadow-md: 0 2px 4px rgba(15, 23, 42, .05), 0 8px 24px rgba(15, 23, 42, .09);
  --shadow-lg: 0 10px 40px rgba(15, 23, 42, .12), 0 2px 8px rgba(15, 23, 42, .05);
}

* { box-sizing: border-box; }

html {
  min-width: 320px;
  min-height: 100%;
  background: var(--bg-page);
}

body {
  margin: 0;
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
  background: var(--bg-page);
}

button, input, textarea {
  font: inherit;
}

a { color: var(--primary); }

.page {
  min-height: 100vh;
  background: var(--bg-page);
  color: var(--text);
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  height: 64px;
  background: rgba(255, 255, 255, 0.94);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(18px) saturate(180%);
}

.header-inner {
  width: min(1184px, 100% - 48px);
  height: 100%;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  border: 0;
  background: transparent;
  color: var(--text);
  cursor: pointer;
}

.brand-mark {
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  color: #fff;
  background: var(--grad);
  box-shadow: rgba(0, 113, 227, 0.28) 0 7px 18px;
}

.header-actions,
.system-status,
.header-link {
  display: flex;
  align-items: center;
}

.header-actions { gap: 18px; }

.system-status {
  gap: 8px;
  color: var(--text-muted);
  font-size: 13px;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 4px var(--success-soft);
}

.system-status.is-error .status-dot {
  background: var(--error);
  box-shadow: 0 0 0 4px var(--error-soft);
}

.header-link {
  gap: 7px;
  min-height: 38px;
  padding: 0 14px;
  background: #fff;
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  cursor: pointer;
  transition: border-color .2s, color .2s, background .2s;
}

.header-link:hover,
.header-link.is-active {
  color: var(--primary);
  border-color: rgba(0, 113, 227, 0.35);
  background: var(--primary-soft);
}

.announcement {
  width: min(920px, 100% - 36px);
  margin: 16px auto 0;
  min-height: 40px;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid rgba(185, 119, 10, 0.2);
  border-radius: 12px;
  background: var(--amber-soft);
  color: var(--amber);
  font-size: 13px;
  font-weight: 600;
}

.announcement[hidden] {
  display: none !important;
}

body.review-mode .announcement,
body.review-mode .guide-bar,
body.review-mode .help-panel,
body.review-mode [data-view="subscription"],
body.review-mode .system-status {
  display: none !important;
}

.announcement b {
  flex: 0 0 auto;
  padding: 2px 8px;
  border-radius: 999px;
  background: #fff;
  font-size: 11px;
}

.page-main {
  width: min(920px, 100% - 36px);
  margin: 0 auto;
  padding: 38px 0 52px;
}

.hero {
  text-align: center;
  margin-bottom: 30px;
}

.hero h1 {
  margin: 0;
  color: var(--primary);
  font-size: clamp(32px, 5vw, 44px);
  font-weight: 800;
  line-height: 1.15;
}

.hero > p {
  margin: 13px 0 0;
  color: var(--text-muted);
  font-size: 15px;
}

.trust-list {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}

.trust-list span {
  min-height: 30px;
  padding: 0 13px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.78);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  box-shadow: var(--shadow-xs);
}

.trust-list svg { color: var(--primary); }

.redeem-card {
  padding: 34px 36px 30px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 22px;
  box-shadow: var(--shadow-lg);
}

.card-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 22px;
}

.card-kicker {
  margin: 0 0 4px;
  color: var(--text-muted);
  font-size: 13px;
}

.card-heading h2 {
  margin: 0;
  font-size: 28px;
  line-height: 1.2;
}

.stage-badge {
  min-height: 34px;
  padding: 0 15px;
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  color: var(--text-muted);
  background: #fff;
  font-size: 13px;
  font-weight: 600;
}

.stage-badge.stage-2 {
  color: var(--amber);
  background: var(--amber-soft);
  border-color: rgba(185, 119, 10, 0.2);
}

.stage-badge.stage-3 {
  color: var(--success);
  background: var(--success-soft);
  border-color: rgba(26, 158, 84, 0.2);
}

.guide-bar {
  min-height: 46px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg-subtle);
  color: var(--text-muted);
  font-size: 13px;
}

.guide-bar p { margin: 0; line-height: 1.55; }

.guide-bar button {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 7px;
  border: 0;
  background: transparent;
  color: var(--primary);
  cursor: pointer;
}

.help-panel {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-top: 12px;
  padding: 15px;
  border: 1px solid rgba(185, 119, 10, 0.16);
  border-radius: 12px;
  background: var(--amber-soft);
}

.help-step {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.6;
}

.help-step span {
  min-width: 0;
  flex: 1;
}

.help-step b {
  width: 20px;
  height: 20px;
  flex: 0 0 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: #fff;
  color: var(--amber);
  font-size: 11px;
}

.stepper {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  margin: 24px 0;
  border-bottom: 1px solid var(--border);
}

.step-item {
  position: relative;
  min-height: 46px;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: 8px;
  color: var(--text-faint);
  font-size: 13px;
  font-weight: 600;
}

.step-item::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 2px;
  background: transparent;
}

.step-item.active { color: var(--text); }
.step-item.active::after { background: var(--primary); }
.step-item.done::after { background: var(--success); }

.step-number {
  width: 23px;
  height: 23px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--bg-subtle);
  color: var(--text-faint);
  font-size: 12px;
}

.step-item.active .step-number {
  background: var(--primary);
  color: #fff;
}

.step-item.done .step-number { background: var(--success); color: #fff; }

.section-heading {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.section-icon {
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  color: var(--primary);
  background: var(--primary-soft);
}

.section-heading h3 {
  margin: 0;
  font-size: 16px;
  line-height: 1.3;
}

.section-heading p {
  margin: 3px 0 0;
  color: var(--text-muted);
  font-size: 12px;
}

.verify-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: start;
  gap: 12px;
}

.field { min-width: 0; }

.field label {
  display: block;
  margin-bottom: 8px;
  color: var(--text);
  font-size: 13px;
  font-weight: 650;
}

.input-shell {
  min-height: 50px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 14px;
  border: 1px solid var(--border-strong);
  border-radius: 13px;
  background: #fff;
  color: var(--text-faint);
  transition: border-color .2s, box-shadow .2s, background .2s;
}

.input-shell:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(0, 113, 227, 0.1);
}

.input-shell.is-success {
  border-color: rgba(26, 158, 84, 0.55);
  background: #fbfffc;
}

.input-shell.is-error {
  border-color: rgba(229, 72, 77, 0.6);
  background: #fffdfd;
}

.input-shell input,
.input-shell textarea {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
}

.input-shell input::placeholder,
.input-shell textarea::placeholder {
  color: #a3a3a8;
}

.textarea-shell {
  min-height: 128px;
  align-items: flex-start;
  padding-top: 14px;
}

.input-shell textarea {
  min-height: 98px;
  resize: vertical;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 13px;
}

.primary-button,
.secondary-button {
  min-height: 50px;
  padding: 0 19px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 13px;
  white-space: nowrap;
  cursor: pointer;
  transition: transform .2s, box-shadow .2s, border-color .2s, background .2s;
}

.primary-button {
  color: #fff;
  border: 1px solid transparent;
  background: var(--grad);
  box-shadow: 0 8px 24px rgba(0, 113, 227, 0.27);
}

.primary-button:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 10px 28px rgba(0, 113, 227, 0.34);
}

.primary-button:disabled {
  cursor: not-allowed;
  opacity: .5;
  box-shadow: none;
}

.secondary-button {
  color: var(--text);
  border: 1px solid var(--border-strong);
  background: #fff;
}

.secondary-button:hover {
  color: var(--primary);
  border-color: rgba(0, 113, 227, 0.36);
  background: var(--primary-soft);
}

.field-error,
.submit-error,
.privacy-note {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 7px 0 0;
  font-size: 12px;
}

.field-error,
.submit-error { color: var(--error); }

.privacy-note { color: var(--text-faint); }

.account-detected {
  min-height: 34px;
  margin-top: 8px;
  padding: 7px 10px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
  border: 1px solid rgba(26, 158, 84, 0.2);
  border-radius: 9px;
  background: var(--success-soft);
  color: var(--success);
  font-size: 12px;
}

.account-detected strong {
  min-width: 0;
  margin-left: auto;
  color: #126c3c;
  overflow-wrap: anywhere;
}

.account-detected.missing {
  border-color: rgba(229, 72, 77, 0.18);
  background: rgba(229, 72, 77, 0.06);
  color: var(--error);
}

.success-banner {
  display: flex;
  align-items: center;
  gap: 11px;
  margin-bottom: 20px;
  padding: 12px 14px;
  border: 1px solid rgba(26, 158, 84, 0.2);
  border-radius: 12px;
  background: var(--success-soft);
}

.success-banner strong { color: #126c3c; font-size: 13px; }
.success-banner p { margin: 2px 0 0; color: #4e745f; font-size: 12px; }

.form-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 17px;
}

.submit-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 22px;
}

.submit-button { min-width: 190px; }

.success-panel { text-align: center; padding-top: 4px; }

.success-mark {
  width: 62px;
  height: 62px;
  margin: 0 auto 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 18px;
  color: var(--primary);
  background: var(--primary-soft);
}

.success-mark.state-completed {
  color: var(--success);
  background: var(--success-soft);
}

.success-mark.state-failed {
  color: var(--error);
  background: rgba(229, 72, 77, 0.09);
}

.success-panel h3 {
  margin: 0;
  font-size: 24px;
}

.success-copy {
  margin: 7px 0 20px;
  color: var(--text-muted);
  font-size: 13px;
}

.order-info {
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 13px;
  text-align: left;
}

.info-row {
  display: grid;
  grid-template-columns: 86px minmax(0, 1fr) 34px;
  align-items: center;
  gap: 12px;
  min-height: 54px;
  padding: 8px 13px;
  border-bottom: 1px solid var(--border);
}

.info-row:last-child { border-bottom: 0; }
.info-row > span { color: var(--text-muted); font-size: 12px; }
.info-row code {
  overflow: hidden;
  color: var(--text);
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.info-row button {
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: #fff;
  color: var(--primary);
  cursor: pointer;
}

.processing-note,
.delivery-tip,
.result-box {
  display: flex;
  align-items: center;
  gap: 11px;
  margin-top: 14px;
  padding: 13px 15px;
  border-radius: 12px;
  text-align: left;
}

.processing-note {
  background: var(--bg-subtle);
  color: var(--text-muted);
}

.processing-note strong,
.delivery-tip strong,
.result-box strong {
  display: block;
  color: var(--text);
  font-size: 13px;
}

.processing-note span,
.delivery-tip span,
.result-box span {
  font-size: 12px;
}

.delivery-tip {
  border: 1px solid rgba(0, 113, 227, 0.18);
  background: var(--primary-soft);
  color: var(--text-muted);
}

.result-box.state-completed { background: var(--success-soft); }
.result-box.state-failed { background: rgba(229, 72, 77, 0.07); }
.result-box.state-warning { background: var(--amber-soft); }

.waiting-dots {
  width: 30px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  flex: 0 0 30px;
}

.waiting-dots i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--primary);
  animation: 1.1s ease-in-out infinite waiting-bounce;
}

.waiting-dots i:nth-child(2) { animation-delay: .14s; }
.waiting-dots i:nth-child(3) { animation-delay: .28s; }

.footer {
  min-height: 72px;
  padding: 20px 18px 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--text-faint);
  font-size: 12px;
}

.footer span:last-child {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.toast-message {
  position: fixed;
  left: 50%;
  bottom: 28px;
  z-index: 50;
  min-height: 44px;
  padding: 0 18px;
  display: flex;
  align-items: center;
  gap: 8px;
  transform: translate(-50%);
  border: 1px solid rgba(26, 158, 84, 0.2);
  border-radius: 12px;
  background: #fff;
  color: var(--success);
  font-size: 13px;
  font-weight: 600;
  box-shadow: var(--shadow-md);
}

.toast-message.is-error {
  border-color: rgba(229, 72, 77, 0.2);
  color: var(--error);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.spin { animation: .8s linear infinite spin; }

.sub-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 16px;
}

.sub-item {
  min-height: 72px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg-subtle);
}

.sub-item span {
  display: block;
  color: var(--text-muted);
  font-size: 12px;
  margin-bottom: 6px;
}

.sub-item strong {
  color: var(--text);
  font-size: 14px;
  overflow-wrap: anywhere;
}

@keyframes spin {
  100% { transform: rotate(360deg); }
}

@keyframes waiting-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: .45; }
  30% { transform: translateY(-4px); opacity: 1; }
}

@media (max-width: 760px) {
  .header-inner { width: min(100% - 28px, 1184px); }
  .system-status { display: none; }
  .page-main { width: min(100% - 24px, 920px); padding-top: 28px; }
  .announcement { width: min(100% - 24px, 920px); }
  .hero { margin-bottom: 22px; }
  .hero h1 { font-size: 32px; }
  .redeem-card { padding: 26px 22px 24px; border-radius: 18px; }
  .guide-bar { grid-template-columns: auto 1fr; }
  .guide-bar button { grid-column: 2; justify-self: start; padding-left: 0; }
  .help-panel { grid-template-columns: 1fr; }
  .verify-row { grid-template-columns: 1fr 1fr; }
  .verify-field { grid-column: 1 / -1; }
  .primary-button,
  .secondary-button { width: 100%; }
  .sub-grid { grid-template-columns: 1fr; }
}

@media (max-width: 520px) {
  .site-header { height: 58px; }
  .brand { gap: 8px; font-size: 15px; }
  .brand-mark { width: 32px; height: 32px; border-radius: 9px; }
  .header-link {
    width: 36px;
    height: 36px;
    min-height: 36px;
    padding: 0;
    justify-content: center;
  }
  .header-link span { display: none; }
  .page-main { padding: 24px 0 34px; }
  .hero h1 { font-size: 28px; }
  .hero > p { font-size: 13px; line-height: 1.65; }
  .redeem-card { padding: 22px 16px 20px; }
  .card-heading h2 { font-size: 24px; }
  .verify-row { grid-template-columns: 1fr; }
  .verify-field { grid-column: auto; }
  .submit-actions { flex-direction: column-reverse; }
  .submit-button { min-width: 0; }
  .info-row { grid-template-columns: 70px minmax(0, 1fr) 34px; }
}
