/* finesse · register=h5 · morph=A-app-shell(commerce stack)
 * A=暖纸+赭石 · B=单权重对比 · C=单列堆叠+底部主操作 · D=状态反馈动效 · E=票券/兑换凭条
 * SOUL=4 SPECTACLE=2 DENSITY=4
 */

html, body { height: 100%; }

body.redeem {
  background: var(--bg);
  min-height: 100dvh;
  display: flex;
  justify-content: center;
  align-items: flex-start;
}

.screen {
  width: 100%;
  max-width: 460px;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  position: relative;
  background: var(--bg);
}

/* ---------------- 顶部 ---------------- */
.hd {
  padding: calc(env(safe-area-inset-top) + 22px) 22px 0;
  flex: none;
}
.hd-brand {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 26px;
}
.hd-mark {
  width: 28px; height: 28px;
  border-radius: 8px;
  background: var(--ink);
  color: #FBF8F3;
  display: grid; place-items: center;
  font-family: var(--font-mono);
  font-size: 12px; font-weight: 700;
  letter-spacing: -0.03em;
}
.hd-name { font-size: 13px; font-weight: 620; letter-spacing: -0.01em; }
.hd-sub { font-size: 10.5px; color: var(--ink-3); letter-spacing: 0.06em; }

.hd h1 {
  font-size: 26px;
  line-height: 1.2;
  font-weight: 700;
  letter-spacing: -0.03em;
  margin: 0;
}
.hd .lead {
  margin-top: 7px;
  font-size: 13.5px;
  color: var(--ink-3);
  line-height: 1.5;
}

/* ---------------- 主体 ---------------- */
.body {
  flex: 1;
  padding: 22px 22px calc(env(safe-area-inset-bottom) + 120px);
  min-width: 0;
}

/* 输入 */
.inp-code {
  width: 100%;
  height: 58px;
  padding: 0 18px;
  font-family: var(--font-mono);
  font-size: 21px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-align: center;
  text-transform: uppercase;
  color: var(--ink);
  background: var(--surface);
  border: 1.5px solid var(--line-strong);
  border-radius: var(--radius-3);
  transition: border-color 140ms ease, box-shadow 140ms ease;
  -webkit-appearance: none;
}
.inp-code::placeholder {
  color: #B5ABA0;
  letter-spacing: 0.1em;
  font-weight: 500;
}
.inp-code:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}
.inp-code.err { border-color: var(--bad); box-shadow: 0 0 0 4px var(--bad-soft); }

.inp-field {
  width: 100%;
  height: 50px;
  padding: 0 15px;
  font-size: 16px; /* iOS 不缩放 */
  color: var(--ink);
  background: var(--surface);
  border: 1.5px solid var(--line-strong);
  border-radius: var(--radius-2);
  transition: border-color 140ms ease, box-shadow 140ms ease;
  -webkit-appearance: none;
}
.inp-field::placeholder { color: #B5ABA0; }
.inp-field:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.inp-field.err { border-color: var(--bad); }
select.inp-field { background-image: none; }

.lbl {
  display: block;
  font-size: 12px;
  font-weight: 620;
  color: var(--ink-2);
  letter-spacing: 0.02em;
  margin-bottom: 7px;
}
.help { font-size: 12px; color: var(--ink-3); margin-top: 7px; line-height: 1.5; }
.err-msg { font-size: 12.5px; color: var(--bad); margin-top: 7px; display: none; }
.err-msg.show { display: block; }

/* 商品卡 */
.product {
  margin-top: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-3);
  padding: 18px;
  animation: rise 260ms cubic-bezier(0.32, 0.72, 0, 1);
}
@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.product-top {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}
.product-ico {
  width: 44px; height: 44px;
  border-radius: 11px;
  display: grid; place-items: center;
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-size: 19px;
  flex: none;
  font-weight: 700;
}
.product-info { min-width: 0; flex: 1; }
.product-info h2 {
  font-size: 16px;
  font-weight: 660;
  letter-spacing: -0.02em;
  overflow-wrap: anywhere;
}
.product-info .meta {
  font-size: 12.5px;
  color: var(--ink-3);
  margin-top: 3px;
}
.product-face {
  font-family: var(--font-mono);
  font-size: 15px;
  font-weight: 620;
  color: var(--accent-ink);
  white-space: nowrap;
  text-align: right;
  line-height: 1.25;
}
.product-face i {
  display: block;
  font-style: normal;
  font-family: var(--font-sans);
  font-size: 10.5px;
  font-weight: 600;
  color: var(--ink-3);
  letter-spacing: 0.04em;
}

.product-note {
  margin-top: 14px;
  padding-top: 13px;
  border-top: 1px dashed var(--line-strong);
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  color: var(--ink-3);
}
.product-note svg { flex: none; opacity: 0.65; }

/* 表单区 */
.form-block { margin-top: 22px; }
.form-block .field + .field { margin-top: 16px; }

/* 进度 / 结果 */
.state-wrap {
  text-align: center;
  padding: 22px 10px 0;
  animation: rise 260ms cubic-bezier(0.32, 0.72, 0, 1);
}
.state-icon {
  width: 62px; height: 62px;
  border-radius: 50%;
  display: grid; place-items: center;
  margin: 0 auto 16px;
  font-size: 26px;
  font-weight: 700;
}
.state-icon.run { background: var(--accent-soft); color: var(--accent-ink); }
.state-icon.ok { background: var(--ok-soft); color: var(--ok); }
.state-icon.bad { background: var(--bad-soft); color: var(--bad); }
.state-wrap h2 {
  font-size: 19px;
  font-weight: 680;
  letter-spacing: -0.022em;
}
.state-wrap p {
  margin-top: 8px;
  font-size: 13.5px;
  color: var(--ink-3);
  line-height: 1.6;
  overflow-wrap: anywhere;
}

.spin {
  width: 26px; height: 26px;
  border: 2.5px solid var(--accent-line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 780ms linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.receipt {
  margin-top: 20px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-3);
  padding: 4px 16px;
  text-align: left;
}
.receipt-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 0;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}
.receipt-row:last-child { border-bottom: none; }
.receipt-row span { color: var(--ink-3); font-size: 12.5px; flex: none; }
.receipt-row b {
  font-weight: 600;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
  text-align: right;
}

/* 底部操作 */
.foot {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 0;
  width: 100%;
  max-width: 460px;
  padding: 14px 22px calc(env(safe-area-inset-bottom) + 16px);
  background: var(--bg);
  border-top: 1px solid var(--line);
  z-index: 30;
}
.foot .btn-fill,
.foot .btn-line {
  width: 100%;
  display: flex;
}
.foot .btn-fill {
  height: 52px;
  font-size: 16px;
  font-weight: 620;
  border-radius: 10px;
}
.foot .btn-line {
  height: 46px;
  border-radius: 10px;
}

.btn-fill {
  display: inline-flex; align-items: center; justify-content: center;
  border: none; font-family: inherit; cursor: pointer;
  background: var(--ink); color: #FBF8F3;
  transition: background 130ms ease, opacity 130ms ease;
  -webkit-tap-highlight-color: transparent;
}
.btn-fill:active:not(:disabled) { background: #35312C; }
.btn-fill:disabled { opacity: 0.4; }
.btn-fill.accent { background: var(--accent); }
.btn-fill.accent:active:not(:disabled) { background: var(--accent-ink); }

.btn-line {
  display: inline-flex; align-items: center; justify-content: center;
  border: 1.5px solid var(--line-strong); background: transparent;
  color: var(--ink-2); font-family: inherit; font-size: 14px; font-weight: 560;
  height: 46px; border-radius: 10px; cursor: pointer; width: 100%;
  -webkit-tap-highlight-color: transparent;
}
.btn-line:active { background: var(--surface-2); }

/* 步骤条 */
.steps {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 18px;
}
.step {
  height: 3px;
  flex: 1;
  border-radius: 2px;
  background: var(--surface-3);
  transition: background 240ms ease;
}
.step.on { background: var(--accent); }

/* 错误提示条 */
.alert {
  display: flex;
  gap: 9px;
  padding: 12px 14px;
  background: var(--bad-soft);
  border: 1px solid rgba(163, 52, 42, 0.18);
  border-radius: var(--radius-2);
  font-size: 13px;
  color: #7C2620;
  line-height: 1.5;
  margin-top: 14px;
  animation: rise 200ms ease;
}
.alert.warn {
  background: var(--warn-soft);
  border-color: rgba(138, 97, 20, 0.2);
  color: #6C4C10;
}

/* 小程序式提示 */
.toast-h5 {
  position: fixed;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom) + 96px);
  transform: translateX(-50%) translateY(6px);
  background: rgba(27, 25, 23, 0.93);
  color: #FBF8F3;
  padding: 9px 16px;
  border-radius: 9px;
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease, transform 180ms ease;
  z-index: 50;
  max-width: 86vw;
  text-align: center;
}
.toast-h5.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---- 充值进度：时间线 ---- */
.timeline {
  display: flex;
  align-items: flex-start;
  margin: 22px 2px 0;
}
.tl-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  flex: none;
  width: 62px;
}
.tl-dot {
  width: 11px; height: 11px;
  border-radius: 50%;
  background: var(--surface-3);
  border: 2px solid var(--bg);
  transition: background 240ms ease, box-shadow 240ms ease;
}
.tl-item.done .tl-dot { background: var(--accent); }
.tl-item.active .tl-dot {
  background: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}
.tl-label {
  font-size: 11px;
  color: var(--ink-3);
  letter-spacing: 0.01em;
  white-space: nowrap;
}
.tl-item.done .tl-label { color: var(--ink-2); }
.tl-item.active .tl-label { color: var(--accent-ink); font-weight: 650; }
.tl-line {
  flex: 1;
  height: 2px;
  background: var(--surface-3);
  margin-top: 5px;
  border-radius: 1px;
  transition: background 240ms ease;
}
.tl-line.done { background: var(--accent); }

.elapsed {
  margin-top: 14px;
  font-size: 12px;
  color: var(--ink-3);
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

/* ---- 卡密查询 ---- */
.link-row {
  margin-top: 26px;
  text-align: center;
}
.link-btn {
  background: none;
  border: none;
  padding: 8px 4px;
  font-family: inherit;
  font-size: 13px;
  color: var(--ink-2);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: var(--line-strong);
  -webkit-tap-highlight-color: transparent;
}
.link-btn:active { color: var(--accent-ink); }

.result-card {
  margin-top: 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-3);
  overflow: hidden;
  animation: rise 240ms cubic-bezier(0.32, 0.72, 0, 1);
}
.result-head {
  padding: 16px 16px 14px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: flex-start;
  gap: 12px;
}
.result-head .info { flex: 1; min-width: 0; }
.result-head h2 {
  font-size: 16px;
  font-weight: 660;
  letter-spacing: -0.02em;
  overflow-wrap: anywhere;
}
.result-head .sub {
  font-size: 12.5px;
  color: var(--ink-3);
  margin-top: 3px;
}
.result-rows { padding: 4px 16px; }
.result-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}
.result-row:last-child { border-bottom: none; }
.result-row span { color: var(--ink-3); font-size: 12.5px; flex: none; }
.result-row b {
  font-weight: 600;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
  text-align: right;
}
.result-section-title {
  font-size: 11.5px;
  font-weight: 650;
  color: var(--ink-3);
  letter-spacing: 0.04em;
  padding: 14px 16px 6px;
  background: var(--surface-2);
  border-top: 1px solid var(--line);
}

.badge-inline {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 21px;
  padding: 0 9px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 650;
  white-space: nowrap;
}
.badge-inline.ok { background: var(--ok-soft); color: var(--ok); }
.badge-inline.warn { background: var(--accent-soft); color: var(--accent-ink); }
.badge-inline.bad { background: var(--bad-soft); color: var(--bad); }
.badge-inline.idle { background: var(--surface-3); color: var(--ink-2); }

/* ---- 兑换码（餐饮/卡密类）---- */
.code-card {
  margin-top: 16px;
  background: var(--accent-soft);
  border: 1px solid var(--accent-line);
  border-radius: var(--radius-3);
  padding: 16px;
  animation: rise 240ms cubic-bezier(0.32, 0.72, 0, 1);
}
.code-card h3 {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--accent-ink);
  letter-spacing: 0.06em;
  margin-bottom: 8px;
}
.code-url {
  display: block;
  font-size: 13px;
  color: var(--accent-ink);
  word-break: break-all;
  text-decoration: underline;
  text-underline-offset: 2px;
  margin-bottom: 4px;
}
.code-value {
  font-family: var(--font-mono);
  font-size: 21px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--ink);
  background: var(--surface);
  border: 1px dashed var(--accent-line);
  border-radius: var(--radius-2);
  padding: 13px 10px;
  text-align: center;
  margin: 10px 0 8px;
  word-break: break-all;
  user-select: all;
}
.code-meta {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 11.5px;
  color: var(--accent-ink);
}
.copy-btn {
  margin-top: 12px;
  width: 100%;
  height: 44px;
  border-radius: var(--radius-2);
  border: 1px solid var(--accent-line);
  background: var(--surface);
  color: var(--accent-ink);
  font-family: inherit;
  font-size: 14px;
  font-weight: 620;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.copy-btn:active { background: var(--surface-2); }

.hidden { display: none !important; }

/* 使用说明 */
.howto {
  margin-top: 30px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}.howto h3 {
  font-size: 12px;
  font-weight: 620;
  color: var(--ink-3);
  letter-spacing: 0.05em;
  margin-bottom: 12px;
}
.howto-item {
  display: flex;
  gap: 11px;
  padding: 7px 0;
  font-size: 12.5px;
  color: var(--ink-3);
  line-height: 1.5;
}
.howto-n {
  width: 19px; height: 19px;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--ink-2);
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 700;
  display: grid; place-items: center;
  flex: none;
  margin-top: 1px;
}
.howto-item b { color: var(--ink-2); font-weight: 600; }

@media (min-width: 620px) and (min-height: 760px) {
  body.redeem { align-items: center; padding: 28px 0; }
  .screen {
    min-height: auto;
    max-height: min(88dvh, 880px);
    overflow-y: auto;
    border: 1px solid var(--line-strong);
    border-radius: 18px;
    box-shadow: 0 1px 2px rgba(27,25,23,.04), 0 24px 64px -32px rgba(27,25,23,.35);
  }
  .foot { position: sticky; left: auto; transform: none; max-width: none; bottom: 0; }
}
