:root {
  --bg-0: #060b12;
  --bg-1: #0a1420;
  --panel: #0d1826;
  --panel-2: #0a141f;
  --line: rgba(126, 180, 214, 0.14);
  --line-strong: rgba(126, 180, 214, 0.26);
  --text: #e8f1f8;
  --muted: #8aa0b6;
  --teal: #19c2ae;
  --teal-2: #0e9b8b;
  --teal-soft: rgba(25, 194, 174, 0.14);
  --yellow: #ffd45e;
  --danger: #ff6d6d;
  --radius: 18px;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  padding: 14px 16px 40px;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, sans-serif;
  background:
    radial-gradient(900px 520px at 18% -10%, rgba(25, 194, 174, 0.16), transparent 60%),
    radial-gradient(700px 460px at 88% 8%, rgba(36, 96, 168, 0.18), transparent 62%),
    linear-gradient(180deg, var(--bg-1), var(--bg-0) 42%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
}

.phone {
  width: 100%;
  max-width: 430px;
  padding: 18px 20px 24px;
  border: 1px solid var(--line);
  border-radius: 26px;
  background: linear-gradient(180deg, rgba(16, 28, 43, 0.94), rgba(8, 15, 24, 0.96));
  box-shadow: var(--shadow);
}

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

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  letter-spacing: 0.04em;
  color: #b9cddd;
}

.brand-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--teal);
  box-shadow: 0 0 0 4px rgba(25, 194, 174, 0.14), 0 0 12px rgba(25, 194, 174, 0.7);
}

.env-badge {
  padding: 5px 10px;
  border: 1px solid rgba(255, 212, 94, 0.35);
  border-radius: 999px;
  background: rgba(255, 212, 94, 0.08);
  color: var(--yellow);
  font-size: 11.5px;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

body.real-mode .env-badge {
  border-color: rgba(255, 92, 92, 0.55);
  background: rgba(255, 92, 92, 0.12);
  color: #ff9d9d;
}

.hero { margin-bottom: 16px; }

.hero h1 {
  margin: 0 0 6px;
  font-size: 25px;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.hero .sub {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.card {
  padding: 16px 16px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(20, 34, 50, 0.7), rgba(10, 19, 29, 0.7));
}

.field-label {
  display: block;
  margin-bottom: 8px;
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: #a9bfd2;
}

.ecid-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 8px 0 14px;
  height: 54px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: var(--panel-2);
  transition: border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

.ecid-wrap:focus-within {
  border-color: rgba(25, 194, 174, 0.7);
  box-shadow: 0 0 0 4px rgba(25, 194, 174, 0.12);
  background: #0b1622;
}

.ecid-wrap.valid { border-color: rgba(25, 194, 174, 0.55); }
.ecid-wrap.invalid {
  border-color: rgba(255, 109, 109, 0.75);
  box-shadow: 0 0 0 4px rgba(255, 109, 109, 0.1);
  animation: shake 0.4s ease;
}

#ecid {
  flex: 1;
  min-width: 0;
  height: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 17px;
  letter-spacing: 0.06em;
  font-variant-numeric: tabular-nums;
}

#ecid::placeholder {
  color: #5f7488;
  letter-spacing: 0.02em;
  font-family: inherit;
  font-size: 14px;
}

.paste-btn {
  flex: none;
  height: 36px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.04);
  color: #cfe0ee;
  font-size: 12.5px;
  cursor: pointer;
  transition: background 0.16s ease, border-color 0.16s ease;
}

.paste-btn:hover { background: rgba(25, 194, 174, 0.12); border-color: rgba(25, 194, 174, 0.5); }
.paste-btn:active { transform: translateY(1px); }

.field-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin: 8px 2px 18px;
  color: var(--muted);
  font-size: 11.5px;
}

.field-meta .error-text { color: var(--danger); }

.types { margin-bottom: 18px; }

.types-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: #a9bfd2;
}

.optional {
  padding: 1px 7px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: #7f95aa;
  font-size: 10.5px;
  font-weight: 400;
  letter-spacing: 0.04em;
}

.type-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.type {
  flex: 1 1 86px;
  padding: 9px 4px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.02);
  color: #a9bfd2;
  font-size: 12.5px;
  text-align: center;
  white-space: nowrap;
  cursor: pointer;
  transition: all 0.16s ease;
}

.type:only-child { flex: 0 0 120px; }

.type:hover { border-color: rgba(25, 194, 174, 0.45); color: #d8f6f1; }

.type.selected {
  border-color: var(--teal);
  background: var(--teal-soft);
  color: #dbfffa;
  box-shadow: inset 0 0 0 1px rgba(25, 194, 174, 0.25);
}

.submit {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 52px;
  border: 0;
  border-radius: 12px;
  background: linear-gradient(135deg, #22cdb7, #0e9b8b);
  color: #04201c;
  font-size: 16.5px;
  font-weight: 700;
  letter-spacing: 0.04em;
  cursor: pointer;
  box-shadow: 0 10px 24px rgba(25, 194, 174, 0.24);
  transition: transform 0.12s ease, box-shadow 0.16s ease, filter 0.16s ease;
}

.submit:hover { filter: brightness(1.05); box-shadow: 0 12px 28px rgba(25, 194, 174, 0.3); }
.submit:active { transform: scale(0.99); }

.submit-price {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  padding: 3px 9px;
  border-radius: 999px;
  background: rgba(4, 32, 28, 0.16);
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.submit-hint {
  margin: 9px 0 16px;
  color: #778da2;
  font-size: 11.5px;
  text-align: center;
}

.links {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.link-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 42px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.03);
  color: #c2d6e6;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.16s ease, border-color 0.16s ease;
}

.link-btn:hover { background: rgba(25, 194, 174, 0.1); border-color: rgba(25, 194, 174, 0.45); }
.link-icon { color: var(--teal); font-size: 12px; }

.steps {
  margin-top: 22px;
  padding: 0 4px;
}

.steps h2 {
  margin: 0 0 10px;
  color: var(--yellow);
  font-size: clamp(15px, 4vw, 16px);
  font-weight: 700;
  letter-spacing: 0.02em;
}

.steps ol {
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: step;
}

.steps li {
  position: relative;
  counter-increment: step;
  margin-bottom: 7px;
  padding-left: 20px;
  color: #ffd968;
  font-size: clamp(15px, 4vw, 16px);
  font-weight: 600;
  line-height: 1.65;
}

.steps li::before {
  content: counter(step) "：";
  position: absolute;
  left: 0;
  top: 0;
  color: #ffd968;
  font-weight: 600;
}

.debug {
  margin-top: 26px;
  padding-top: 14px;
  border-top: 1px dashed rgba(126, 180, 214, 0.16);
}

.debug summary {
  color: #64798d;
  font-size: 11.5px;
  cursor: pointer;
  user-select: none;
  list-style: none;
}

.debug summary::-webkit-details-marker { display: none; }
.debug summary::after { content: "  ▾"; font-size: 10px; }
.debug[open] summary::after { content: "  ▴"; }

.log {
  margin: 10px 0;
  max-height: 168px;
  overflow: auto;
  padding: 10px;
  border: 1px solid rgba(126, 180, 214, 0.1);
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.3);
  color: #8fb0c8;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11px;
  line-height: 1.7;
}

.log .t { color: #5c7a91; }
.log .ok { color: #5fe3cd; }
.log .warn { color: #ffd45e; }
.log .bad { color: #ff8a8a; }

.clear-log {
  border: 0;
  background: none;
  color: #64798d;
  font-size: 11px;
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal[hidden] { display: none; }

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(3, 8, 13, 0.72);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  animation: fade 0.18s ease;
}

.modal-panel {
  position: relative;
  width: 100%;
  max-width: 360px;
  max-height: calc(100vh - 40px);
  overflow: auto;
  padding: 18px 18px 20px;
  border: 1px solid rgba(126, 180, 214, 0.2);
  border-radius: 20px;
  background: linear-gradient(180deg, #122030, #0b1622);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6);
  animation: modal-in 0.24s cubic-bezier(0.22, 0.72, 0.24, 1);
}

.image-panel { max-width: 420px; }

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
}

.modal-head h3 {
  margin: 0;
  font-size: 15.5px;
  font-weight: 600;
}

.icon-btn {
  width: 30px;
  height: 30px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: #8aa0b6;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}

.icon-btn:hover { background: rgba(255, 255, 255, 0.06); color: #fff; }

.mock-tag {
  padding: 2px 8px;
  border: 1px solid rgba(255, 212, 94, 0.3);
  border-radius: 999px;
  color: var(--yellow);
  font-size: 10.5px;
  letter-spacing: 0.06em;
}

.image-body {
  border-radius: 14px;
  overflow: hidden;
  background: #061019;
  border: 1px solid rgba(126, 180, 214, 0.1);
}

.image-body img {
  display: block;
  width: 100%;
  height: auto;
}

.image-tip {
  margin: 12px 2px 0;
  color: #7f95aa;
  font-size: 11.5px;
  line-height: 1.6;
}

.pay-amount {
  margin: 4px 0 2px;
  text-align: center;
  font-size: 34px;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.pay-amount .cny { font-size: 17px; font-weight: 500; color: #9fb4c6; margin-right: 2px; }

.pay-sub {
  margin: 0 0 16px;
  text-align: center;
  color: var(--muted);
  font-size: 12px;
}

.pay-meta {
  margin-bottom: 16px;
  padding: 12px 13px;
  border: 1px solid rgba(126, 180, 214, 0.12);
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.22);
  font-size: 12px;
  line-height: 1.9;
  color: #9fb4c6;
}

.pay-meta div { display: flex; justify-content: space-between; gap: 14px; }
.pay-meta b { color: #dceaf6; font-weight: 500; text-align: right; word-break: break-all; }

.qr-slot {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
  padding: 16px;
  border: 1px dashed rgba(25, 194, 174, 0.4);
  border-radius: 14px;
  background: rgba(25, 194, 174, 0.05);
  color: #86a6b8;
  font-size: 11.5px;
  text-align: center;
}

.qr-box {
  width: 118px;
  height: 118px;
  border-radius: 8px;
  background:
    repeating-linear-gradient(90deg, #0d2430 0 6px, transparent 6px 12px),
    repeating-linear-gradient(0deg, #0d2430 0 6px, transparent 6px 12px),
    #0f2b38;
  border: 6px solid #eaf6ff;
}

.pay-actions { display: grid; gap: 9px; }

.btn {
  height: 46px;
  border-radius: 11px;
  border: 1px solid var(--line-strong);
  background: rgba(255, 255, 255, 0.03);
  color: #d5e5f2;
  font-size: 14px;
  cursor: pointer;
  transition: filter 0.15s ease, background 0.15s ease;
}

.btn:hover { filter: brightness(1.08); }
.btn.primary { border: 0; background: linear-gradient(135deg, #22cdb7, #0e9b8b); color: #04201c; font-weight: 700; }
.btn.ghost { background: transparent; color: #93a9bd; }
.btn.danger { color: #ffb4b4; border-color: rgba(255, 109, 109, 0.3); background: rgba(255, 109, 109, 0.06); }

.pay-note {
  margin: 12px 0 0;
  color: #5f7488;
  font-size: 10.5px;
  text-align: center;
  line-height: 1.6;
}

.processing { padding: 18px 4px 6px; text-align: center; }

.spinner {
  width: 34px;
  height: 34px;
  margin: 0 auto 14px;
  border: 3px solid rgba(25, 194, 174, 0.18);
  border-top-color: var(--teal);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.processing p { margin: 0 0 14px; color: #b8cddb; font-size: 13px; }

.flow {
  display: grid;
  gap: 8px;
  margin: 0 auto;
  max-width: 260px;
  text-align: left;
}

.flow-line {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #6d8398;
  font-size: 12px;
}

.flow-line .dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 1px solid rgba(126, 180, 214, 0.3);
  flex: none;
  position: relative;
}

.flow-line.done { color: #cdeae4; }
.flow-line.done .dot { border-color: var(--teal); background: rgba(25, 194, 174, 0.18); }
.flow-line.done .dot::after {
  content: "";
  position: absolute;
  left: 3px;
  top: 4px;
  width: 6px;
  height: 3px;
  border-left: 1.6px solid var(--teal);
  border-bottom: 1.6px solid var(--teal);
  transform: rotate(-45deg);
}

.success-view { text-align: center; padding: 6px 0 2px; }

.success-icon {
  width: 54px;
  height: 54px;
  margin: 0 auto 12px;
  border-radius: 50%;
  background: rgba(25, 194, 174, 0.14);
  border: 1px solid rgba(25, 194, 174, 0.5);
  position: relative;
  animation: pop 0.3s cubic-bezier(0.2, 0.9, 0.3, 1.2);
}

.success-icon::after {
  content: "";
  position: absolute;
  left: 18px;
  top: 20px;
  width: 16px;
  height: 8px;
  border-left: 3px solid var(--teal);
  border-bottom: 3px solid var(--teal);
  transform: rotate(-45deg);
}

.success-icon.error {
  background: rgba(255, 92, 92, 0.14);
  border-color: rgba(255, 92, 92, 0.5);
}

.success-icon.error::after {
  content: "!";
  left: 50%;
  top: 50%;
  width: auto;
  height: auto;
  border: 0;
  color: #ff8f8f;
  font-size: 26px;
  font-weight: 700;
  transform: translate(-50%, -50%);
}

.success-view h4 { margin: 0 0 6px; font-size: 17px; }
.success-view .msg { margin: 0 0 16px; color: var(--muted); font-size: 12.5px; line-height: 1.6; }
.success-view .api-state { color: var(--yellow); font-size: 11.5px; }

.receipt {
  margin-bottom: 16px;
  padding: 12px 13px;
  border: 1px solid rgba(126, 180, 214, 0.12);
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.22);
  text-align: left;
  font-size: 12px;
  line-height: 1.9;
  color: #9fb4c6;
}

.receipt div { display: flex; justify-content: space-between; gap: 14px; }
.receipt b { color: #dceaf6; font-weight: 500; }

.toast {
  position: fixed;
  left: 50%;
  top: 22px;
  transform: translateX(-50%);
  z-index: 80;
  max-width: 88vw;
  padding: 10px 16px;
  border: 1px solid rgba(126, 180, 214, 0.22);
  border-radius: 999px;
  background: rgba(12, 22, 33, 0.96);
  color: #d9e8f4;
  font-size: 12.5px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.5);
  animation: fade 0.2s ease;
}

.toast[hidden] { display: none; }

body.modal-open { overflow: hidden; }

@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(0.98); } to { opacity: 1; transform: none; } }
@keyframes modal-in {
  from { opacity: 0; transform: translateY(6px) scale(0.985); }
  to { opacity: 1; transform: none; }
}
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-5px); }
  40% { transform: translateX(5px); }
  60% { transform: translateX(-3px); }
  80% { transform: translateX(3px); }
}

@media (min-width: 481px) {
  body { padding: 10px 16px 24px; }
  .phone {
    max-width: 560px;
    padding: 14px 20px 18px;
  }
  .topbar { margin-bottom: 11px; }
  .hero { margin-bottom: 11px; }
  .hero h1 { margin-bottom: 4px; font-size: 23px; }
  .card { padding: 13px 16px 12px; }
  .ecid-wrap { height: 49px; }
  .field-meta { margin: 6px 2px 12px; }
  .types { margin-bottom: 12px; }
  .type { padding: 7px 4px; }
  .submit { height: 48px; }
  .submit-hint { margin: 7px 0 11px; }
  .link-btn { height: 38px; }
  .steps { margin-top: 15px; padding: 0 2px; }
  .steps h2 { margin-bottom: 7px; font-size: 15px; }
  .steps li { margin-bottom: 3px; font-size: 15px; line-height: 1.45; }
  .debug { margin-top: 15px; padding-top: 10px; }
}

@media (max-width: 480px) {
  body { padding: 0; display: block; background: var(--bg-0); }
  .phone {
    max-width: none;
    min-height: 100dvh;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    padding: 20px 16px 34px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}
