:root {
  --bg: #f5f6f8;
  --card: #ffffff;
  --text: #1c1e21;
  --muted: #6b7280;
  --line: #e5e7eb;
  --brand: #10a37f;
  --brand-dark: #0b7f63;
  --brand-soft: #e7f6f1;
  --warn: #b45309;
  --warn-soft: #fef3c7;
  --err: #c0262d;
  --err-soft: #fde8e8;
  --radius: 14px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.6 -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

.wrap { max-width: 560px; margin: 0 auto; padding: 24px 16px 48px; }

.head { text-align: center; margin: 12px 0 20px; }
.head h1 { font-size: 24px; margin: 0 0 4px; }
.sub { margin: 0; color: var(--muted); font-size: 14px; }

.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 14px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .04), 0 4px 16px rgba(0, 0, 0, .04);
}

h2 { font-size: 17px; margin: 0 0 14px; display: flex; align-items: center; gap: 8px; }

.num {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--brand); color: #fff; font-size: 13px;
}

.input {
  width: 100%;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 16px; /* 不小于 16px，避免 iOS 输入时自动放大 */
  color: var(--text);
  background: #fff;
  outline: none;
  transition: border-color .15s;
}
.input:focus { border-color: var(--brand); }
.input.is-ok { border-color: var(--brand); }
.input.is-err { border-color: var(--err); }
.textarea { resize: vertical; min-height: 110px; font-size: 13px; line-height: 1.5; }

.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; letter-spacing: .02em; }

.code-row { position: relative; }
.code-row .input { padding-right: 120px; }
.tag {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  background: var(--brand-soft); color: var(--brand-dark);
  font-size: 12px; font-weight: 600; padding: 3px 8px; border-radius: 999px;
  white-space: nowrap;
}

.hint { font-size: 13px; color: var(--muted); margin: 8px 0 14px; min-height: 1.2em; }
.hint.is-err { color: var(--err); }
.hint.is-warn { color: var(--warn); }
.hint.is-ok { color: var(--brand-dark); }

.btn {
  width: 100%;
  border: 0; border-radius: 10px;
  padding: 13px 16px;
  font-size: 16px; font-weight: 600;
  background: var(--brand); color: #fff;
  cursor: pointer;
  transition: background .15s, opacity .15s;
}
.btn:hover:not(:disabled) { background: var(--brand-dark); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn:focus-visible, .input:focus-visible, a:focus-visible, summary:focus-visible {
  outline: 3px solid rgba(16, 163, 127, .35); outline-offset: 2px;
}
.btn-ghost { background: transparent; color: var(--brand-dark); border: 1.5px solid var(--brand); margin-top: 12px; }
.btn-ghost:hover:not(:disabled) { background: var(--brand-soft); }
.btn.is-loading { position: relative; color: transparent; }
.btn.is-loading::after {
  content: ""; position: absolute; left: 50%; top: 50%;
  width: 18px; height: 18px; margin: -9px 0 0 -9px;
  border: 2px solid rgba(255, 255, 255, .5); border-top-color: #fff; border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.result-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.result-product { font-size: 18px; font-weight: 700; }
.badge { font-size: 13px; font-weight: 600; padding: 4px 10px; border-radius: 999px; white-space: nowrap; }
.badge.unused { background: var(--brand-soft); color: var(--brand-dark); }
.badge.processing { background: var(--warn-soft); color: var(--warn); }
.badge.used, .badge.void { background: #f1f2f4; color: var(--muted); }

.info { margin: 12px 0 0; display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; font-size: 14px; }
.info:empty { display: none; }
.info dt { color: var(--muted); }
.info dd { margin: 0; word-break: break-all; }

.steps { margin: 0 0 14px; padding-left: 20px; font-size: 14px; color: #374151; }
.steps li { margin: 4px 0; }
.steps a { color: var(--brand-dark); word-break: break-all; }

.preview {
  display: grid; gap: 4px;
  background: #f8fafb; border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 14px; margin-bottom: 14px; font-size: 14px;
}
.preview strong { word-break: break-all; }

.status { text-align: center; padding: 28px 20px; }
.status h2 { justify-content: center; font-size: 20px; margin-bottom: 6px; }
.status-icon {
  width: 56px; height: 56px; margin: 0 auto 12px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 28px; font-weight: 700;
}
.status.success .status-icon { background: var(--brand-soft); color: var(--brand); }
.status.success .status-icon::before { content: "✓"; }
.status.failed .status-icon { background: var(--err-soft); color: var(--err); }
.status.failed .status-icon::before { content: "!"; }
.status.processing .status-icon { border: 3px solid var(--warn-soft); border-top-color: var(--warn); animation: spin 1s linear infinite; }

.faq summary { cursor: pointer; font-weight: 600; }
.faq dl { margin: 12px 0 0; font-size: 14px; }
.faq dt { font-weight: 600; margin-top: 10px; }
.faq dd { margin: 2px 0 0; color: var(--muted); }

.muted { color: var(--muted); }
.small { font-size: 13px; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  max-width: calc(100% - 32px);
  background: rgba(28, 30, 33, .92); color: #fff;
  padding: 10px 16px; border-radius: 10px; font-size: 14px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .2);
  z-index: 10;
}

.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;
}

[hidden] { display: none !important; }

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