:root {
  --bg: #f5f5f5;
  --card: #ffffff;
  --ink: #2c2c2c;
  --ink-2: #6b6b6b;
  --ink-3: #9e9e9e;
  --line: #ececec;
  --accent: #e8734a;
  --accent-weak: #fdefe9;
  --ok: #3f9d6a;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(0, 0, 0, .04), 0 6px 20px rgba(0, 0, 0, .04);
  --tap: 44px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body { margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Source Han Sans SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }

.page {
  max-width: 480px;
  margin: 0 auto;
  padding: 12px 16px 96px;
  min-height: 100vh;
}

.page-plain { padding-bottom: 24px; }

/* ---------------- 文本 ---------------- */
.h1 { font-size: 20px; font-weight: 600; letter-spacing: .2px; margin: 4px 0 12px; }
.h2 { font-size: 16px; font-weight: 600; margin: 0 0 8px; }
.muted { color: var(--ink-2); font-size: 13px; }
.muted-2 { color: var(--ink-3); font-size: 12px; }
.num { font-variant-numeric: tabular-nums; }
.center { text-align: center; }
.row { display: flex; align-items: center; gap: 8px; }
.between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.stack > * + * { margin-top: 12px; }

/* ---------------- 卡片 ---------------- */
.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}
.card-flat { box-shadow: none; border: 1px solid var(--line); }
.card + .card { margin-top: 12px; }

/* ---------------- 按钮 ---------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: var(--tap);
  padding: 0 18px;
  border-radius: 12px;
  border: 1px solid transparent;
  background: #f2f2f2;
  color: var(--ink);
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: opacity .15s ease, background .15s ease;
}
.btn:active { opacity: .82; }
.btn-block { display: flex; width: 100%; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-outline { background: #fff; color: var(--accent); border-color: var(--accent); }
.btn-ghost { background: #fff; color: var(--ink); border-color: var(--line); }
.btn-quiet { background: transparent; color: var(--ink-2); min-height: 36px; padding: 0 8px; }
.btn[disabled], .btn.is-disabled {
  background: #e6e6e6; color: var(--ink-3); border-color: transparent; pointer-events: none;
}
.btn-sm { min-height: 36px; font-size: 13px; padding: 0 12px; border-radius: 10px; }

/* ---------------- 表单 ---------------- */
.field { margin-bottom: 16px; }
.field > label {
  display: block;
  font-size: 13px;
  color: var(--ink-2);
  margin-bottom: 6px;
}
.input, .select, .textarea {
  width: 100%;
  min-height: var(--tap);
  padding: 10px 12px;
  font-size: 15px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  outline: none;
  font-family: inherit;
}
.input:focus, .select:focus, .textarea:focus { border-color: var(--accent); }
.textarea { min-height: 72px; resize: vertical; }
.hint { font-size: 12px; color: var(--ink-3); margin-top: 6px; }
.checkline { display: flex; align-items: flex-start; gap: 8px; font-size: 13px; color: var(--ink-2); }
.checkline input { width: 18px; height: 18px; margin-top: 2px; accent-color: var(--accent); }

/* ---------------- 标签 ---------------- */
.tag {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 8px;
  border-radius: 6px;
  font-size: 12px;
  background: #f3f3f3;
  color: var(--ink-2);
}
.tag-accent { background: var(--accent-weak); color: var(--accent); }
.tag-ok { background: #eaf5ef; color: var(--ok); }
.tag-mute { background: #f0f0f0; color: var(--ink-3); }

/* ---------------- 券 ---------------- */
.cover {
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: 12px;
  object-fit: cover;
  background: #ededed;
}
.face { color: var(--accent); font-weight: 700; letter-spacing: -.5px; }
.face-xl { font-size: 32px; }
.face-lg { font-size: 26px; }
.face-md { font-size: 18px; }
.face small { font-size: 13px; font-weight: 500; margin-left: 4px; }

.rules { list-style: none; margin: 0; padding: 0; }
.rules li {
  position: relative;
  padding-left: 14px;
  font-size: 13px;
  color: var(--ink-2);
  line-height: 1.6;
}
.rules li + li { margin-top: 6px; }
.rules li::before {
  content: "";
  position: absolute;
  left: 0; top: 8px;
  width: 4px; height: 4px;
  border-radius: 50%;
  background: var(--ink-3);
}

/* ---------------- 券列表卡 ---------------- */
.coupon-row {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 14px 16px;
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.coupon-row.dim { opacity: .68; filter: saturate(.5); }
.coupon-thumb {
  width: 56px; height: 56px;
  border-radius: 10px;
  object-fit: cover;
  background: #f0f0f0;
  flex: 0 0 auto;
}
.coupon-main { flex: 1 1 auto; min-width: 0; }
.coupon-main .name { font-size: 15px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.coupon-main .sub { font-size: 12px; color: var(--ink-3); margin-top: 2px; }
.coupon-side { text-align: right; flex: 0 0 auto; }
.warn { color: var(--accent); font-size: 12px; }

/* ---------------- 分段控件 ---------------- */
.segmented {
  display: flex;
  background: #ededed;
  border-radius: 12px;
  padding: 3px;
  margin-bottom: 14px;
}
.segmented a {
  flex: 1;
  text-align: center;
  padding: 9px 0;
  font-size: 14px;
  color: var(--ink-2);
  border-radius: 10px;
}
.segmented a.on { background: #fff; color: var(--ink); font-weight: 600; box-shadow: 0 1px 2px rgba(0,0,0,.06); }

/* ---------------- 底部 Tab ---------------- */
.tabbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  display: flex;
  background: rgba(255,255,255,.96);
  backdrop-filter: blur(8px);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 20;
}
.tabbar a {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: 56px;
  font-size: 11px;
  color: var(--ink-3);
}
.tabbar a.on { color: var(--accent); }
.tabbar svg { width: 20px; height: 20px; }

/* ---------------- 固定底栏 ---------------- */
.bottom-bar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
  background: rgba(255,255,255,.97);
  border-top: 1px solid var(--line);
  max-width: 480px;
  margin: 0 auto;
  z-index: 25;
}
.bottom-bar .btn { width: 100%; height: 48px; }

/* ---------------- 二维码 ---------------- */
.qr-card {
  background: #fff;
  border-radius: 16px;
  padding: 20px 16px 16px;
  text-align: center;
  box-shadow: var(--shadow);
}
.qr-box {
  width: 240px; height: 240px;
  margin: 0 auto;
  display: flex; align-items: center; justify-content: center;
  position: relative;
}
.qr-box img, .qr-box canvas { width: 240px !important; height: 240px !important; }
.qr-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 20px;
  letter-spacing: 4px;
  margin-top: 14px;
}
.qr-tip { font-size: 12px; color: var(--ink-2); margin-top: 8px; }
.done-mark {
  width: 64px; height: 64px; border-radius: 50%;
  background: #eaf5ef; color: var(--ok);
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 12px; font-size: 34px;
}

/* ---------------- 摄像头 ---------------- */
.scan-stage {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  background: #111;
  border-radius: var(--radius);
  overflow: hidden;
}
.scan-stage video { width: 100%; height: 100%; object-fit: cover; }
.scan-frame {
  position: absolute;
  inset: 18%;
  border-radius: 8px;
}
.scan-frame i {
  position: absolute; width: 22px; height: 22px; border: 2px solid var(--accent);
}
.scan-frame i:nth-child(1) { top: 0; left: 0; border-right: 0; border-bottom: 0; border-top-left-radius: 6px; }
.scan-frame i:nth-child(2) { top: 0; right: 0; border-left: 0; border-bottom: 0; border-top-right-radius: 6px; }
.scan-frame i:nth-child(3) { bottom: 0; left: 0; border-right: 0; border-top: 0; border-bottom-left-radius: 6px; }
.scan-frame i:nth-child(4) { bottom: 0; right: 0; border-left: 0; border-top: 0; border-bottom-right-radius: 6px; }

/* ---------------- 列表 ---------------- */
.list { background: #fff; border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.list-item { padding: 14px 16px; border-bottom: 1px solid var(--line); }
.list-item:last-child { border-bottom: 0; }
.kv { display: flex; justify-content: space-between; gap: 12px; font-size: 13px; }
.kv + .kv { margin-top: 6px; }
.kv .k { color: var(--ink-3); }
.kv .v { color: var(--ink); text-align: right; }

/* ---------------- 提示 ---------------- */
.toast {
  position: fixed;
  left: 50%; bottom: 96px;
  transform: translateX(-50%) translateY(8px);
  background: rgba(30,30,30,.92);
  color: #fff;
  font-size: 13px;
  padding: 10px 16px;
  border-radius: 10px;
  opacity: 0;
  transition: all .2s ease;
  max-width: 80vw;
  z-index: 60;
  pointer-events: none;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.flash {
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 13px;
  margin-bottom: 12px;
  background: #eaf5ef;
  color: var(--ok);
}
.flash.error { background: var(--accent-weak); color: var(--accent); }

.empty { text-align: center; color: var(--ink-3); font-size: 13px; padding: 48px 0; }
.divider { height: 1px; background: var(--line); margin: 16px 0; }
.footer-note { text-align: center; color: var(--ink-3); font-size: 11px; padding: 24px 0 8px; }
