/* ============================================================
 * Duolingo Super 卡密兑换站 — 样式
 * 明亮白主题 + 多邻国绿(#58cc02)强调色，移动端优先
 * ============================================================ */
* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --bg: #f5f7fa;
  --card: #ffffff;
  --accent: #58cc02;
  --accent-dark: #46a302;
  --accent-soft: #eaf9dd;
  --accent2: #0f9be0;
  --text: #1a1a2e;
  --dim: #6b7280;
  --err: #e74c3c;
  --warn: #f39c12;
  --border: #e4e8ef;
  --hover: #f2f4f8;
  --radius: 16px;
  --shadow: 0 2px 12px rgba(26, 26, 46, .07);
}

html {
  -webkit-text-size-adjust: 100%;
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
  touch-action: pan-y;
  overscroll-behavior-x: none;
}

body {
  overflow-x: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
               "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", sans-serif;
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  padding-bottom: env(safe-area-inset-bottom);
}

.page {
  width: 100%;
  max-width: 460px;
  margin: 0 auto;
  padding: 24px 16px 48px;
}

/* ---------- 头部 ---------- */
.hero { text-align: center; margin-bottom: 20px; }

.logo-row {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.site-logo { width: 30px; height: 30px; border-radius: 8px; }

.brand {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: .2px;
  color: var(--dim);
}

.brand b { color: var(--accent-dark); }

.hero h1 {
  font-size: 23px;
  font-weight: 700;
  letter-spacing: -.3px;
  margin-bottom: 4px;
}

.subtitle { font-size: 13.5px; color: var(--dim); }

/* ---------- 状态提示 ---------- */
.status {
  font-size: 13.5px;
  line-height: 1.5;
  margin: 0 0 14px;
  padding: 0 4px;
  text-align: center;
  word-break: break-word;
  display: none;
}

.status:not(:empty) { display: block; }
.status.err { color: var(--err); }
.status.ok { color: var(--accent-dark); }
.status.info { color: var(--dim); }

/* ---------- 卡片 ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 18px;
  margin-bottom: 14px;
}

.step-head {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 16px;
}

.step-no {
  width: 22px;
  height: 22px;
  flex: 0 0 22px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 12.5px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.step-title { font-size: 15.5px; font-weight: 650; }

.hidden { display: none !important; }

/* ---------- 表单 ---------- */
.field { margin-bottom: 16px; }

.field label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--dim);
  margin-bottom: 7px;
}

.input-wrap { position: relative; display: flex; align-items: center; }

.input-wrap input {
  width: 100%;
  height: 48px;
  padding: 0 14px;
  font-size: 16px;           /* ≥16px 防 iOS 聚焦缩放 */
  font-family: inherit;
  color: var(--text);
  background: #fbfcfe;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  outline: none;
  transition: border-color .15s, background .15s, box-shadow .15s;
  letter-spacing: .5px;
}

.input-wrap input::placeholder { color: #b6bdc9; letter-spacing: .5px; }

.input-wrap input:focus {
  border-color: var(--accent);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(88, 204, 2, .12);
}

.input-wrap input:read-only { background: #f4f6f9; color: var(--dim); }

.input-wrap input:disabled { opacity: .6; }

#identifier { letter-spacing: 0; }

.icon-btn {
  position: absolute;
  right: 8px;
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: #9aa3b2;
  font-size: 14px;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
}

.icon-btn:hover { background: var(--hover); color: var(--dim); }
.input-wrap input:not(:placeholder-shown) ~ .icon-btn.clear { display: flex; }

.badge {
  position: absolute;
  right: 12px;
  font-size: 12.5px;
  font-weight: 600;
  display: none;
  white-space: nowrap;
  pointer-events: none;
}

.badge.ok { color: var(--accent-dark); }
.badge.bad { color: var(--err); }

.hint {
  font-size: 12px;
  color: #9aa3b2;
  margin-top: 6px;
  padding-left: 2px;
}

/* ---------- 按钮 ---------- */
.btn {
  width: 100%;
  height: 48px;
  border: 0;
  border-radius: 12px;
  font-size: 15.5px;
  font-weight: 650;
  font-family: inherit;
  cursor: pointer;
  transition: transform .08s, background .15s, opacity .15s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.btn.primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 2px 0 var(--accent-dark);
}

.btn.primary:hover { background: #61dd05; }
.btn.primary:active { transform: translateY(1px); box-shadow: none; }

.btn.ghost {
  background: transparent;
  color: var(--dim);
  border: 1.5px solid var(--border);
}

.btn.ghost:hover { background: var(--hover); }

.btn:disabled { opacity: .62; cursor: not-allowed; box-shadow: none; }

.btn-row { display: flex; gap: 10px; margin-top: 16px; }
.btn-row .btn { flex: 1; }

/* ---------- Tabs ---------- */
.tabs {
  display: flex;
  gap: 8px;
  background: #f4f6f9;
  padding: 4px;
  border-radius: 12px;
  margin-bottom: 16px;
}

.tab {
  flex: 1;
  height: 38px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--dim);
  font-size: 13.5px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background .15s, color .15s, box-shadow .15s;
}

.tab.active {
  background: #fff;
  color: var(--text);
  box-shadow: 0 1px 4px rgba(26, 26, 46, .09);
}

/* ---------- 账号信息 ---------- */
.user-info {
  display: none;
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px dashed var(--border);
}

.u-top { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }

.u-top.compact { margin-bottom: 12px; }

.avatar {
  width: 48px;
  height: 48px;
  flex: 0 0 48px;
  border-radius: 50%;
  background: var(--accent-soft);
  object-fit: cover;
  border: 1px solid var(--border);
}

.u-main { flex: 1; min-width: 0; }

.u-name {
  font-size: 15.5px;
  font-weight: 650;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.u-sub {
  font-size: 12.5px;
  color: var(--dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.u-flag {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--accent-dark);
  background: var(--accent-soft);
  border-radius: 20px;
  padding: 4px 11px;
  white-space: nowrap;
}

.u-flag.plus { color: var(--warn); background: #fef5e3; }

/* ---------- 键值表 ---------- */
.kv { display: flex; flex-direction: column; gap: 1px; }

.kv-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 8px 0;
  border-bottom: 1px solid #f2f4f8;
}

.kv-row:last-child { border-bottom: 0; }

.kv-row dt {
  font-size: 13px;
  color: var(--dim);
  flex: 0 0 auto;
  white-space: nowrap;
}

.kv-row dd {
  font-size: 13.5px;
  font-weight: 600;
  text-align: right;
  word-break: break-all;
}

.kv-row dd.ok { color: var(--accent-dark); }
.kv-row dd.bad { color: var(--warn); }

/* ---------- 结果卡 ---------- */
.result-card {
  display: none;
  text-align: center;
  border-color: #cdf0a8;
  background: linear-gradient(180deg, #fbfff6 0%, #fff 46%);
}

.result-card.show { display: block; }

.result-head { margin-bottom: 16px; }

.result-icon { font-size: 40px; line-height: 1; margin-bottom: 8px; }

.result-head h2 { font-size: 20px; font-weight: 700; margin-bottom: 6px; }

.result-head p { font-size: 13.5px; color: var(--dim); line-height: 1.55; }

.result-card .kv { text-align: left; margin-top: 4px; }

/* ---------- 教程 ---------- */
.tutorial {
  display: none;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 14px;
}

.tutorial h3 {
  font-size: 14.5px;
  font-weight: 650;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.tutorial h3::before { content: "📖"; font-size: 15px; }

.tutorial-steps p {
  font-size: 13.5px;
  color: var(--dim);
  line-height: 1.75;
  padding-left: 22px;
  position: relative;
  counter-increment: step;
}

.tutorial-steps { counter-reset: step; }

.tutorial-steps p::before {
  content: counter(step);
  position: absolute;
  left: 0;
  top: 5px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent-dark);
  font-size: 10.5px;
  font-weight: 700;
  line-height: 16px;
  text-align: center;
}

.tutorial-steps b { color: var(--text); }

.tutorial-shots {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 14px 0 8px;
}

.shot {
  aspect-ratio: 9 / 16;
  border-radius: 10px;
  overflow: hidden;
  background: #f4f6f9;
  border: 1px solid var(--border);
  cursor: zoom-in;
  display: flex;
  align-items: center;
  justify-content: center;
}

.shot img { width: 100%; height: 100%; object-fit: cover; display: block; }

.shot-ph { font-size: 11.5px; color: #aab2c0; }

.shot-tip { font-size: 12px; color: #9aa3b2; text-align: center; }

/* ---------- 页脚 ---------- */
.foot {
  margin-top: 22px;
  text-align: center;
  font-size: 12px;
  color: #9aa3b2;
  line-height: 1.85;
}

.foot-dim { margin-top: 6px; opacity: .75; }

/* ---------- 遮罩弹窗 ---------- */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: rgba(20, 22, 30, .5);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  overflow-y: auto;
}

.overlay.show { display: flex; }

.overlay-card {
  background: #fff;
  border-radius: 18px;
  padding: 26px 22px;
  width: 100%;
  max-width: 340px;
  text-align: center;
  box-shadow: 0 12px 40px rgba(0, 0, 0, .2);
  animation: pop .18s ease-out;
}

.overlay-card.wide { max-width: 400px; text-align: left; }

@keyframes pop {
  from { transform: scale(.94); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.overlay-icon { font-size: 34px; margin-bottom: 10px; }

.overlay-card h2 { font-size: 17px; font-weight: 700; margin-bottom: 8px; }

.overlay-card p { font-size: 13.5px; color: var(--dim); line-height: 1.6; }

.confirm-title { text-align: center; margin-bottom: 16px; }

.warn {
  display: none;
  background: #fff8ec;
  border: 1px solid #f7dfb3;
  border-radius: 10px;
  padding: 11px 13px;
  font-size: 13px;
  color: #a56a00;
  line-height: 1.6;
  margin-top: 12px;
}

.warn-sub { font-size: 12.5px; opacity: .85; }

.confirm-hint {
  font-size: 12.5px;
  color: var(--dim);
  line-height: 1.8;
  margin-top: 14px;
}

/* ---------- 图片查看器 ---------- */
.viewer {
  position: fixed;
  inset: 0;
  z-index: 120;
  background: rgba(0, 0, 0, .92);
  display: none;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  touch-action: none;
}

.viewer.show { display: flex; }

.viewer-wrap { max-width: 100%; max-height: 100%; padding: 16px; }

.viewer-wrap img {
  max-width: 100%;
  max-height: 88vh;
  border-radius: 10px;
  display: block;
}

/* ---------- 转圈 ---------- */
.spinner {
  width: 15px;
  height: 15px;
  border: 2px solid rgba(255, 255, 255, .45);
  border-top-color: #fff;
  border-radius: 50%;
  display: inline-block;
  animation: spin .7s linear infinite;
  vertical-align: -2px;
}

.btn.ghost .spinner { border-color: rgba(0, 0, 0, .15); border-top-color: var(--dim); }

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

@media (max-width: 360px) {
  .page { padding: 18px 12px 40px; }
  .card { padding: 17px 15px; }
  .hero h1 { font-size: 21px; }
}
