:root {
  --paper: #f4eee5;
  --paper-deep: #e8ddce;
  --surface: rgba(255, 253, 249, 0.94);
  --surface-solid: #fffdf9;
  --ink: #202722;
  --muted: #697069;
  --line: #d9cdbd;
  --line-strong: #b9aa97;
  --accent: #b94f2c;
  --accent-dark: #8d351b;
  --accent-soft: #f3ddd2;
  --success: #247052;
  --success-soft: #dcece4;
  --warning: #9a641d;
  --warning-soft: #f3e7cf;
  --danger: #a2392e;
  --danger-soft: #f7dfdc;
  --wechat: #147d55;
  --alipay: #1677ff;
  --shadow: 0 22px 60px rgba(77, 57, 36, 0.12), 0 2px 8px rgba(77, 57, 36, 0.06);
  --radius-large: 24px;
  --radius-medium: 15px;
  --radius-small: 10px;
  --font-body: "Segoe UI", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  --font-display: "Iowan Old Style", "Songti SC", STSong, Georgia, serif;
  color-scheme: light;
  font-family: var(--font-body);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--paper);
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 8%, rgba(203, 106, 67, 0.13), transparent 32rem),
    radial-gradient(circle at 88% 82%, rgba(95, 115, 91, 0.09), transparent 28rem),
    linear-gradient(145deg, #f8f3ec 0%, var(--paper) 56%, #eee4d7 100%);
}

button,
input {
  font: inherit;
}

button,
a,
input {
  -webkit-tap-highlight-color: transparent;
}

button {
  color: inherit;
}

[hidden] {
  display: none !important;
}

.page-grid {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: 0.35;
  background-image:
    linear-gradient(rgba(87, 72, 52, 0.07) 1px, transparent 1px),
    linear-gradient(90deg, rgba(87, 72, 52, 0.07) 1px, transparent 1px);
  background-size: 32px 32px;
  mask-image: linear-gradient(to bottom, black, transparent 78%);
}

.shell {
  width: min(100% - 32px, 720px);
  margin: 0 auto;
  padding: 34px 0 28px;
}

.masthead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 22px;
}

.identity {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  color: var(--ink);
  text-decoration: none;
}

.identity-mark {
  display: grid;
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 1px solid rgba(142, 54, 28, 0.28);
  border-radius: 12px;
  color: #fffaf4;
  background: linear-gradient(145deg, #cb6844, var(--accent-dark));
  box-shadow: 0 8px 18px rgba(142, 54, 28, 0.2);
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 20px;
  font-weight: 800;
}

.identity strong {
  display: block;
  overflow: hidden;
  max-width: 420px;
  font-size: 16px;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.eyebrow,
.step-label {
  display: block;
  margin: 0 0 3px;
  color: var(--accent-dark);
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.13em;
}

.secure-chip {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 7px;
  padding: 7px 10px;
  border: 1px solid rgba(36, 112, 82, 0.24);
  border-radius: 999px;
  color: var(--success);
  background: rgba(238, 248, 242, 0.7);
  font-size: 12px;
  font-weight: 700;
}

.secure-chip span {
  font-size: 7px;
}

.checkout-card {
  overflow: hidden;
  border: 1px solid rgba(177, 159, 137, 0.68);
  border-radius: var(--radius-large);
  background: var(--surface);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.card-heading {
  padding: 34px 38px 27px;
  border-bottom: 1px solid var(--line);
  background:
    linear-gradient(100deg, rgba(244, 223, 211, 0.42), transparent 50%),
    rgba(255, 253, 249, 0.55);
}

.step-label {
  margin-bottom: 9px;
}

h1,
h2,
p {
  overflow-wrap: anywhere;
}

h1,
h2 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 760;
  letter-spacing: -0.025em;
}

h1 {
  font-size: clamp(25px, 5vw, 34px);
  line-height: 1.18;
}

h2 {
  font-size: clamp(22px, 4vw, 28px);
  line-height: 1.25;
}

.heading-note {
  max-width: 540px;
  margin: 11px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.7;
}

.loading-panel,
.payment-progress {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-height: 180px;
  padding: 34px;
  color: var(--muted);
  font-size: 14px;
}

.spinner {
  display: inline-block;
  flex: 0 0 auto;
  width: 20px;
  height: 20px;
  border: 2px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

#paymentForm {
  padding: 31px 38px 38px;
}

.form-section {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.form-section + .form-section {
  margin-top: 29px;
}

.form-section legend {
  width: 100%;
  margin-bottom: 13px;
  padding: 0;
  font-size: 14px;
  font-weight: 800;
}

.amount-options {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.amount-choice {
  min-height: 48px;
  padding: 10px 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius-small);
  color: var(--ink);
  background: var(--surface-solid);
  cursor: pointer;
  font-weight: 750;
  transition: border-color 150ms ease, background 150ms ease, color 150ms ease, transform 150ms ease;
}

.amount-choice:hover {
  border-color: var(--line-strong);
  transform: translateY(-1px);
}

.amount-choice[aria-pressed="true"] {
  border-color: var(--accent);
  color: var(--accent-dark);
  background: var(--accent-soft);
  box-shadow: inset 0 0 0 1px rgba(185, 79, 44, 0.14);
}

.amount-input-label {
  display: inline-block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.amount-input-wrap {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
  min-height: 56px;
  padding: 0 15px;
  border: 1px solid var(--line);
  border-radius: var(--radius-medium);
  background: var(--surface-solid);
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

.amount-input-wrap:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(185, 79, 44, 0.12);
}

.currency-symbol {
  color: var(--accent-dark);
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 19px;
  font-weight: 800;
}

#customAmount {
  width: 100%;
  min-width: 0;
  padding: 13px 0;
  border: 0;
  outline: 0;
  color: var(--ink);
  background: transparent;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 22px;
  font-weight: 750;
}

#customAmount::placeholder {
  color: #aaa197;
}

.currency-code {
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.field-help,
.field-error,
.form-error {
  margin: 8px 1px 0;
  font-size: 12px;
  line-height: 1.55;
}

.field-help {
  color: var(--muted);
}

.field-error {
  color: var(--danger);
  font-weight: 650;
}

.form-error,
.result-message {
  padding: 11px 13px;
  border: 1px solid rgba(162, 57, 46, 0.25);
  border-radius: var(--radius-small);
  color: var(--danger);
  background: var(--danger-soft);
  font-size: 13px;
  line-height: 1.55;
}

.submit-note {
  margin: 22px 2px 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
  text-align: center;
}

.provider-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.provider-option {
  position: relative;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 11px;
  min-height: 72px;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-medium);
  background: var(--surface-solid);
  cursor: pointer;
  transition: border-color 150ms ease, box-shadow 150ms ease, transform 150ms ease;
}

.provider-option:hover {
  border-color: var(--line-strong);
  transform: translateY(-1px);
}

.provider-option:has(input:checked),
.provider-option.is-selected {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px rgba(185, 79, 44, 0.14), 0 6px 16px rgba(80, 57, 34, 0.06);
}

.provider-option:has(input:focus-visible),
.provider-option:focus-within {
  outline: 3px solid rgba(185, 79, 44, 0.22);
  outline-offset: 2px;
}

.provider-option input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.provider-icon {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 11px;
  color: white;
  font-size: 16px;
  font-weight: 850;
}

.provider-icon--wechat { background: var(--wechat); }
.provider-icon--alipay { background: var(--alipay); }

.provider-copy {
  min-width: 0;
}

.provider-copy strong,
.provider-copy small {
  display: block;
}

.provider-copy strong {
  font-size: 14px;
}

.provider-copy small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
}

.radio-dot {
  width: 17px;
  height: 17px;
  border: 1.5px solid var(--line-strong);
  border-radius: 50%;
  background: #fff;
  box-shadow: inset 0 0 0 4px #fff;
}

.provider-option:has(input:checked) .radio-dot,
.provider-option.is-selected .radio-dot {
  border-color: var(--accent);
  background: var(--accent);
}

.primary-button,
.secondary-button,
.text-button {
  border-radius: var(--radius-small);
  cursor: pointer;
  font-weight: 800;
  transition: transform 150ms ease, background 150ms ease, border-color 150ms ease, opacity 150ms ease;
}

.primary-button {
  display: flex;
  width: 100%;
  min-height: 54px;
  align-items: center;
  justify-content: space-between;
  margin-top: 10px;
  padding: 0 18px;
  border: 1px solid var(--accent-dark);
  color: #fffaf6;
  background: linear-gradient(115deg, var(--accent), var(--accent-dark));
  box-shadow: 0 10px 22px rgba(142, 54, 28, 0.18);
}

.primary-button:not(:disabled):hover,
.secondary-button:not(:disabled):hover,
.text-button:not(:disabled):hover {
  transform: translateY(-1px);
}

.primary-button:disabled,
.secondary-button:disabled,
.text-button:disabled {
  cursor: wait;
  opacity: 0.55;
}

.primary-button:focus-visible,
.secondary-button:focus-visible,
.text-button:focus-visible,
.amount-choice:focus-visible,
.redirect-panel a:focus-visible,
.identity:focus-visible {
  outline: 3px solid rgba(185, 79, 44, 0.28);
  outline-offset: 3px;
}

#paymentView {
  padding: 30px 38px 38px;
}

.payment-headline {
  text-align: center;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 27px;
  margin-bottom: 11px;
  padding: 4px 10px;
  border-radius: 999px;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 11px;
  font-weight: 850;
  letter-spacing: 0.04em;
}

.status-badge--pending {
  color: var(--warning);
  background: var(--warning-soft);
}

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

.status-badge--closed,
.status-badge--abandoned,
.status-badge--refunded {
  color: var(--muted);
  background: #ece9e4;
}

.status-badge--unknown,
.status-badge--error {
  color: var(--danger);
  background: var(--danger-soft);
}

.payment-headline > p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.order-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin: 24px 0 0;
  padding: 14px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.order-summary > div {
  min-width: 0;
  padding: 0 14px;
}

.order-summary > div + div {
  border-left: 1px solid var(--line);
}

.order-summary dt {
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.order-summary dd {
  overflow: hidden;
  margin: 0;
  font-size: 13px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.payment-progress {
  min-height: 214px;
}

.qr-panel {
  margin: 25px 0 0;
  text-align: center;
}

.qr-frame {
  display: inline-flex;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 10px 30px rgba(71, 55, 37, 0.1);
}

.qr-frame img {
  display: block;
  width: min(64vw, 280px);
  height: auto;
  aspect-ratio: 1;
}

.qr-panel figcaption {
  margin-top: 12px;
  color: var(--muted);
  font-size: 13px;
}

.redirect-panel {
  margin-top: 25px;
  padding: 28px 18px;
  border: 1px solid rgba(22, 119, 255, 0.23);
  border-radius: var(--radius-medium);
  background: rgba(230, 240, 255, 0.58);
  text-align: center;
}

.redirect-mark {
  display: grid;
  width: 42px;
  height: 42px;
  margin: 0 auto 11px;
  place-items: center;
  border-radius: 12px;
  color: white;
  background: var(--alipay);
  font-size: 21px;
  font-weight: 800;
}

.redirect-panel p {
  margin: 0 0 7px;
  font-weight: 800;
}

.redirect-panel a {
  color: #0d58bd;
  font-size: 13px;
  font-weight: 700;
}

.result-message {
  margin: 20px 0 0;
}

.result-message.is-neutral {
  border-color: var(--line);
  color: var(--muted);
  background: #f4f1ec;
}

.result-message.is-success {
  border-color: rgba(36, 112, 82, 0.25);
  color: var(--success);
  background: var(--success-soft);
}

.payment-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 11px;
  margin-top: 24px;
}

.secondary-button,
.text-button {
  min-height: 48px;
  padding: 0 17px;
}

.secondary-button {
  border: 1px solid var(--accent-dark);
  color: var(--accent-dark);
  background: var(--accent-soft);
}

.text-button {
  border: 1px solid var(--line);
  color: var(--muted);
  background: transparent;
}

.page-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 18px 10px 0;
  color: #7b746b;
  font-size: 11px;
  text-align: center;
}

.noscript-message {
  position: fixed;
  inset: auto 16px 16px;
  z-index: 5;
  max-width: 680px;
  margin: auto;
  padding: 14px;
  border-radius: 10px;
  color: #fff;
  background: var(--danger);
  text-align: center;
}

@media (max-width: 600px) {
  .shell {
    width: min(100% - 20px, 720px);
    padding-top: 18px;
  }

  .masthead {
    margin-bottom: 14px;
  }

  .identity strong {
    max-width: 220px;
  }

  .secure-chip {
    padding: 7px;
    font-size: 0;
  }

  .secure-chip span {
    font-size: 8px;
  }

  .checkout-card {
    border-radius: 19px;
  }

  .card-heading,
  #paymentForm,
  #paymentView {
    padding-right: 21px;
    padding-left: 21px;
  }

  .card-heading {
    padding-top: 27px;
    padding-bottom: 22px;
  }

  #paymentForm,
  #paymentView {
    padding-top: 24px;
    padding-bottom: 25px;
  }

  .amount-options {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .provider-options {
    grid-template-columns: 1fr;
  }

  .order-summary {
    grid-template-columns: 1fr 1fr;
  }

  .order-summary > div {
    padding: 0 10px;
  }

  .order-summary > div:nth-child(3) {
    grid-column: 1 / -1;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--line);
    border-left: 0;
  }

  .payment-actions {
    grid-template-columns: 1fr;
  }

  .page-footer {
    flex-wrap: wrap;
  }
}

@media (max-width: 390px) {
  .identity-mark {
    width: 38px;
    height: 38px;
  }

  .identity strong {
    max-width: 180px;
    font-size: 14px;
  }

  .amount-options {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

@media (prefers-contrast: more) {
  :root {
    --line: #8f8375;
    --muted: #4f554f;
  }
}
