:root {
  --tea-950: #0c2a24;
  --tea-900: #12372f;
  --tea-800: #173f35;
  --tea-700: #24594a;
  --tea-100: #dfe9e3;
  --paper: #f7f1e4;
  --paper-deep: #eee4cf;
  --surface: #fffdf7;
  --ink: #17231f;
  --muted: #5d6b65;
  --gold: #b58a42;
  --gold-dark: #846127;
  --cinnabar: #a54835;
  --danger: #a5372d;
  --border: rgba(23, 63, 53, 0.14);
  --shadow-sm: 0 6px 18px rgba(23, 48, 39, 0.08);
  --shadow-lg: 0 18px 48px rgba(16, 46, 38, 0.18);
  --radius-sm: 12px;
  --radius-md: 20px;
  --radius-lg: 28px;
  --safe-bottom: max(20px, env(safe-area-inset-bottom));
  --font-serif: "STSong", "Songti SC", "Noto Serif CJK SC", serif;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100dvh;
  background:
    radial-gradient(circle at 15% 2%, rgba(181, 138, 66, 0.13), transparent 32%),
    linear-gradient(180deg, #f9f5ea 0%, var(--paper) 60%, #f2ead9 100%);
}

button, input, textarea { font: inherit; }
button, a { touch-action: manipulation; }
a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }

:focus-visible {
  outline: 3px solid rgba(165, 72, 53, 0.58);
  outline-offset: 3px;
}

.skip-link {
  position: fixed;
  left: 12px;
  top: -100px;
  z-index: 1000;
  padding: 10px 16px;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
}
.skip-link:focus { top: 12px; }

.app-shell {
  width: min(100%, 720px);
  min-height: 100dvh;
  margin: 0 auto;
  position: relative;
}

.topbar {
  min-height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: max(12px, env(safe-area-inset-top)) 18px 12px;
}

.brand { display: inline-flex; align-items: center; gap: 10px; min-height: 48px; }
.brand img { width: 44px; height: 44px; border-radius: 12px; box-shadow: var(--shadow-sm); }
.brand span { display: flex; flex-direction: column; line-height: 1.2; }
.brand strong { font-family: var(--font-serif); font-size: 18px; letter-spacing: 0.18em; }
.brand small { margin-top: 5px; color: var(--muted); font-size: 10px; letter-spacing: 0.12em; }

.profile-chip {
  display: flex;
  align-items: center;
  gap: 7px;
  max-width: 46%;
  padding: 5px 7px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(255,255,255,.55);
}
.profile-chip img { width: 34px; height: 34px; object-fit: cover; border-radius: 50%; background: var(--tea-100); }
.profile-chip span { max-width: 72px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.profile-chip b { padding: 2px 6px; border-radius: 999px; background: var(--tea-100); color: var(--tea-800); font-size: 10px; white-space: nowrap; }

.page-content { padding: 10px 18px calc(104px + var(--safe-bottom)); }
.page-content > :first-child { margin-top: 0; }

.eyebrow {
  display: inline-block;
  color: var(--gold-dark);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .16em;
  text-transform: uppercase;
}

.page-heading { margin: 14px 2px 24px; }
.page-heading h1 { margin: 7px 0 6px; font-family: var(--font-serif); font-size: clamp(28px, 8vw, 38px); line-height: 1.2; letter-spacing: .04em; }
.page-heading p { margin: 0; color: var(--muted); font-size: 14px; }

.button {
  min-height: 50px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 15px;
  padding: 12px 20px;
  cursor: pointer;
  font-weight: 700;
  letter-spacing: .04em;
  transition: background-color .18s ease, box-shadow .18s ease, opacity .18s ease;
}
.button:active { opacity: .82; }
.button-primary { background: var(--tea-800); color: #fff; box-shadow: 0 9px 24px rgba(23, 63, 53, .2); }
.button-primary:hover { background: var(--tea-700); }
.button-gold { background: linear-gradient(135deg, #cfaa67, var(--gold)); color: #292014; box-shadow: 0 9px 24px rgba(112, 76, 24, .26); }
.button-block { width: 100%; }
.button:disabled, .button-disabled { cursor: not-allowed; background: #d7d4ca; color: #74746f; box-shadow: none; opacity: .72; }

.privacy-note { margin: 12px 0 0; color: var(--muted); font-size: 12px; text-align: center; }
.muted { margin: 0; color: var(--muted); font-size: 13px; }

.toast {
  position: sticky;
  top: max(8px, env(safe-area-inset-top));
  z-index: 100;
  width: calc(100% - 36px);
  margin: 0 auto 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid rgba(23, 63, 53, .17);
  border-radius: 14px;
  background: #f8fff9;
  box-shadow: var(--shadow-lg);
  color: var(--tea-900);
  font-size: 14px;
}
.toast-error { border-color: rgba(165,55,45,.24); background: #fff5f2; color: var(--danger); }
.toast-info { background: #f8f3e6; color: var(--gold-dark); }
.toast button { min-width: 44px; min-height: 44px; display: grid; place-items: center; border: 0; background: transparent; color: currentColor; cursor: pointer; }
.toast button svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }

.bottom-nav {
  position: fixed;
  z-index: 90;
  left: 50%;
  bottom: 0;
  width: min(100%, 720px);
  min-height: calc(66px + var(--safe-bottom));
  transform: translateX(-50%);
  display: flex;
  align-items: flex-start;
  justify-content: space-around;
  padding: 7px 8px var(--safe-bottom);
  border-top: 1px solid rgba(23,63,53,.12);
  background: rgba(255, 253, 247, .94);
  box-shadow: 0 -8px 30px rgba(27,50,43,.08);
  backdrop-filter: blur(14px);
}
.bottom-nav a { min-width: 64px; min-height: 50px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; border-radius: 12px; color: #748079; font-size: 11px; }
.bottom-nav svg { width: 23px; height: 23px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.bottom-nav a[aria-current="page"] { background: var(--tea-100); color: var(--tea-800); font-weight: 700; }

.welcome-hero {
  overflow: hidden;
  position: relative;
  padding: 32px 26px;
  border-radius: var(--radius-lg);
  background:
    linear-gradient(160deg, rgba(14,45,37,.96), rgba(27,75,61,.95)),
    url("poster-bg.png") center / cover;
  box-shadow: var(--shadow-lg);
  color: #fff;
}
.welcome-hero::after { content: ""; position: absolute; right: -80px; bottom: -90px; width: 240px; height: 240px; border: 1px solid rgba(210,178,113,.22); border-radius: 50%; box-shadow: 0 0 0 28px rgba(210,178,113,.05), 0 0 0 56px rgba(210,178,113,.04); pointer-events: none; }
.welcome-hero > * { position: relative; z-index: 1; }
.welcome-hero > img { width: 88px; height: 88px; margin-bottom: 26px; border-radius: 20px; }
.welcome-hero .eyebrow { color: #dec38a; }
.welcome-hero h1 { margin: 8px 0 14px; font-family: var(--font-serif); font-size: clamp(38px, 12vw, 55px); line-height: 1.18; letter-spacing: .08em; }
.welcome-hero > p:not(.privacy-note) { max-width: 480px; margin: 0 0 26px; color: rgba(255,255,255,.8); font-size: 14px; }
.welcome-hero .privacy-note { color: rgba(255,255,255,.62); }

.feature-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 16px; }
.feature-grid div { padding: 18px; border: 1px solid var(--border); border-radius: 18px; background: rgba(255,253,247,.7); }
.feature-grid strong { display: block; font-family: var(--font-serif); color: var(--tea-800); font-size: 20px; }
.feature-grid span { display: block; margin-top: 4px; color: var(--muted); font-size: 12px; }

.dashboard-hero { padding: 28px 22px; border-radius: var(--radius-lg); background: var(--tea-900); color: #fff; box-shadow: var(--shadow-lg); }
.dashboard-hero .eyebrow { color: #d5b676; }
.dashboard-hero h1 { margin: 8px 0 7px; font-family: var(--font-serif); font-size: 28px; line-height: 1.35; }
.dashboard-hero > p { margin: 0 0 22px; color: rgba(255,255,255,.66); font-size: 14px; }
.dashboard-pass { min-height: 96px; display: grid; grid-template-columns: 1fr auto; grid-template-rows: auto auto; align-items: center; padding: 18px; border: 1px solid rgba(222,195,138,.35); border-radius: 18px; background: linear-gradient(135deg, rgba(255,255,255,.12), rgba(255,255,255,.04)); }
.dashboard-pass span { color: #e5d1a5; font-size: 13px; }
.dashboard-pass strong { grid-row: 1 / 3; grid-column: 2; padding-left: 16px; font-family: var(--font-serif); color: #e3c17c; font-size: 48px; line-height: 1; }
.dashboard-pass small { color: rgba(255,255,255,.68); }

.admin-panel { margin-top: 26px; }
.section-title { display: flex; align-items: end; justify-content: space-between; gap: 16px; }
.section-title h2 { margin: 4px 0 0; font-family: var(--font-serif); font-size: 24px; }
.section-title > a { min-height: 44px; display: inline-flex; align-items: center; color: var(--tea-800); font-size: 14px; font-weight: 700; }
.stats-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 14px; }
.stats-grid div { padding: 17px 10px; border: 1px solid var(--border); border-radius: 16px; background: rgba(255,253,247,.78); text-align: center; }
.stats-grid strong { display: block; color: var(--tea-800); font-size: 25px; font-variant-numeric: tabular-nums; }
.stats-grid span { color: var(--muted); font-size: 11px; }
.scan-tip { min-height: 80px; display: flex; align-items: center; gap: 13px; margin-top: 12px; padding: 14px; border-radius: 17px; background: var(--surface); box-shadow: var(--shadow-sm); }
.scan-tip svg { flex: 0 0 auto; width: 38px; height: 38px; padding: 8px; border-radius: 12px; background: var(--tea-100); fill: none; stroke: var(--tea-800); stroke-width: 1.6; }
.scan-tip > span { min-width: 0; flex: 1; }
.scan-tip strong, .scan-tip small { display: block; }
.scan-tip small { color: var(--muted); font-size: 11px; }
.scan-tip > b { color: var(--gold-dark); font-size: 12px; white-space: nowrap; }

.form-card { padding: 22px; border: 1px solid var(--border); border-radius: var(--radius-md); background: rgba(255,253,247,.86); box-shadow: var(--shadow-sm); }
.field { display: block; margin: 0 0 20px; border: 0; padding: 0; }
.field > span, .field legend { display: block; margin-bottom: 7px; color: var(--ink); font-size: 14px; font-weight: 700; }
.field b { color: var(--cinnabar); }
.field input:not([type="radio"]), .field textarea { width: 100%; min-height: 48px; border: 1px solid rgba(23,63,53,.2); border-radius: 12px; padding: 11px 13px; background: #fffefa; color: var(--ink); font-size: 16px; transition: border-color .18s ease, box-shadow .18s ease; }
.field textarea { resize: vertical; }
.field input:focus, .field textarea:focus { border-color: var(--tea-700); box-shadow: 0 0 0 3px rgba(36,89,74,.12); outline: none; }
.field small { display: block; margin-top: 6px; color: var(--muted); font-size: 12px; }
.segmented { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 4px; border-radius: 14px; background: var(--paper-deep); }
.segmented label { cursor: pointer; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented span { min-height: 44px; display: flex; align-items: center; justify-content: center; padding: 8px; border-radius: 11px; color: var(--muted); font-size: 13px; font-weight: 700; text-align: center; }
.segmented input:checked + span { background: var(--tea-800); color: #fff; box-shadow: 0 3px 10px rgba(23,63,53,.18); }
.segmented input:focus-visible + span { outline: 3px solid rgba(165,72,53,.58); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.error-summary { margin: 0 0 16px; padding: 16px 18px; border-left: 4px solid var(--danger); border-radius: 10px; background: #fff3ef; color: #76261f; }
.error-summary ul { margin: 6px 0 0; padding-left: 20px; font-size: 13px; }

.claim-hero { overflow: hidden; position: relative; padding: 35px 24px 28px; border-radius: var(--radius-lg); background: linear-gradient(rgba(255,253,247,.91), rgba(255,253,247,.94)), url("poster-bg.png") center / cover; box-shadow: var(--shadow-lg); text-align: center; }
.claim-hero::before { content: ""; position: absolute; inset: 11px; border: 1px solid rgba(181,138,66,.36); border-radius: 21px; pointer-events: none; }
.claim-hero > * { position: relative; }
.claim-hero h1 { margin: 8px 0 14px; font-family: var(--font-serif); font-size: 29px; }
.claim-amount { display: flex; justify-content: center; align-items: baseline; color: var(--cinnabar); font-variant-numeric: tabular-nums; line-height: 1; }
.claim-amount small { margin-right: 5px; font-size: 26px; }
.claim-amount strong { font-family: var(--font-serif); font-size: clamp(68px, 22vw, 100px); }
.condition { margin: 10px 0 14px; color: var(--tea-800); font-weight: 700; }
.description { margin: 0 auto 24px; max-width: 440px; color: var(--muted); font-size: 13px; }
.claim-meta { display: flex; justify-content: center; gap: 20px; margin-bottom: 22px; color: var(--muted); font-size: 12px; }
.claim-meta b { color: var(--cinnabar); }

.coupon-list { display: grid; gap: 16px; }
.coupon-ticket { overflow: hidden; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface); box-shadow: var(--shadow-sm); }
.coupon-main { min-height: 138px; display: grid; grid-template-columns: 105px 1fr; align-items: center; position: relative; }
.coupon-main::before, .coupon-main::after { content: ""; position: absolute; left: 96px; width: 18px; height: 18px; border-radius: 50%; background: var(--paper); }
.coupon-main::before { top: -9px; }
.coupon-main::after { bottom: -9px; }
.coupon-value { height: 100%; display: flex; align-items: center; justify-content: center; padding: 14px; background: var(--tea-800); color: #f1d9a6; font-variant-numeric: tabular-nums; }
.coupon-value small { font-size: 18px; }
.coupon-value strong { font-family: var(--font-serif); font-size: 40px; }
.coupon-main > div:last-child { min-width: 0; padding: 16px 16px 16px 20px; }
.coupon-state { display: inline-block; padding: 2px 8px; border-radius: 99px; background: var(--tea-100); color: var(--tea-800); font-size: 10px; font-weight: 700; }
.coupon-main h2 { margin: 6px 0 2px; overflow-wrap: anywhere; font-family: var(--font-serif); font-size: 19px; }
.coupon-main p { margin: 0; color: var(--ink); font-size: 13px; }
.coupon-main small { color: var(--muted); font-size: 11px; }
.coupon-code { border-top: 1px dashed rgba(23,63,53,.22); }
.coupon-code summary { min-height: 50px; display: flex; align-items: center; justify-content: center; cursor: pointer; color: var(--tea-800); font-size: 14px; font-weight: 700; list-style: none; }
.coupon-code summary::-webkit-details-marker { display: none; }
.coupon-code[open] { padding-bottom: 22px; }
.qr-box { width: 210px; min-height: 210px; display: grid; place-items: center; margin: 6px auto 10px; padding: 10px; border-radius: 14px; background: #fff; }
.qr-box canvas, .qr-box img { width: 190px !important; height: 190px !important; }
.coupon-code p { margin: 0; color: var(--muted); font-size: 12px; text-align: center; }
.coupon-muted { opacity: .68; filter: saturate(.45); }
.coupon-muted .coupon-value { background: #66716c; color: #fff; }
.coupon-used-time { padding: 12px 16px; border-top: 1px dashed var(--border); color: var(--muted); font-size: 12px; text-align: center; }

.verify-card, .state-card { margin: 16px 0; padding: 30px 22px; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); box-shadow: var(--shadow-lg); text-align: center; }
.verify-status span { display: inline-block; padding: 5px 12px; border-radius: 999px; background: var(--tea-100); color: var(--tea-800); font-size: 12px; font-weight: 700; }
.verify-avatar { width: 72px; height: 72px; margin: 20px auto 8px; border: 3px solid #fff; border-radius: 50%; object-fit: cover; box-shadow: var(--shadow-sm); }
.verify-card h1 { margin: 2px 0 18px; font-family: var(--font-serif); font-size: 28px; }
.verify-coupon { display: flex; flex-direction: column; gap: 4px; margin-bottom: 22px; padding: 18px; border-radius: 15px; background: var(--paper); }
.verify-coupon strong { font-family: var(--font-serif); font-size: 20px; }
.verify-coupon span { color: var(--cinnabar); font-weight: 700; }
.verify-card.is-used .verify-status span { background: #ece9e1; color: #666; }
.used-detail { margin: 0; color: var(--muted); font-size: 13px; }
.used-detail p { margin: 4px 0; }
.state-mark { width: 58px; height: 58px; display: grid; place-items: center; margin: 0 auto 18px; border: 2px solid var(--gold); border-radius: 50%; color: var(--gold-dark); font-family: var(--font-serif); font-size: 30px; font-weight: 700; }
.state-leaf { font-size: 20px; }
.state-card h1, .state-card h2 { margin: 0 0 7px; font-family: var(--font-serif); }
.state-card p { margin: 0 0 22px; color: var(--muted); }
.center-screen { min-height: 100dvh; display: grid; align-items: center; padding: 18px; }

.poster-wrap { width: min(100%, 480px); margin: 0 auto; }
.poster-loading { aspect-ratio: 3 / 4; display: grid; place-items: center; border-radius: 20px; background: var(--paper-deep); color: var(--muted); }
.poster-image { width: 100%; aspect-ratio: 3 / 4; object-fit: cover; margin-bottom: 16px; border-radius: 20px; box-shadow: var(--shadow-lg); }
.qr-source { position: fixed; left: -10000px; top: -10000px; }
.poster-preview-open { overflow: hidden; }
.poster-preview { position: fixed; z-index: 500; inset: 0; display: grid; place-items: center; padding: max(14px, env(safe-area-inset-top)) 14px max(14px, env(safe-area-inset-bottom)); background: rgba(5, 15, 12, .92); }
.poster-preview-panel { width: min(100%, 480px); max-height: 100%; display: flex; flex-direction: column; }
.poster-preview-panel header { min-height: 62px; display: flex; align-items: center; justify-content: space-between; gap: 16px; color: #fff; }
.poster-preview-panel header div { min-width: 0; }
.poster-preview-panel strong, .poster-preview-panel small { display: block; }
.poster-preview-panel strong { font-family: var(--font-serif); font-size: 19px; }
.poster-preview-panel small { color: rgba(255,255,255,.72); font-size: 12px; }
.poster-preview-panel button { flex: 0 0 auto; width: 48px; height: 48px; display: grid; place-items: center; border: 1px solid rgba(255,255,255,.24); border-radius: 50%; background: rgba(255,255,255,.1); color: #fff; cursor: pointer; }
.poster-preview-panel button svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.poster-preview-panel > img { min-height: 0; max-height: calc(100dvh - 104px - env(safe-area-inset-top) - env(safe-area-inset-bottom)); margin: 0 auto; border-radius: 14px; object-fit: contain; box-shadow: 0 20px 60px rgba(0,0,0,.45); -webkit-touch-callout: default; user-select: auto; }

.record-list { display: grid; gap: 10px; }
.record-item { display: flex; align-items: center; gap: 12px; padding: 14px; border: 1px solid var(--border); border-radius: 16px; background: var(--surface); }
.record-item img { flex: 0 0 auto; width: 48px; height: 48px; border-radius: 50%; object-fit: cover; background: var(--tea-100); }
.record-item > div { min-width: 0; flex: 1; }
.record-item h2 { margin: 0; overflow-wrap: anywhere; font-size: 14px; }
.record-item p, .record-item small { display: block; margin: 1px 0 0; color: var(--muted); font-size: 11px; }
.record-item > span { flex: 0 0 auto; color: var(--tea-700); font-size: 11px; font-weight: 700; }

@media (min-width: 600px) {
  .page-content { padding-inline: 28px; }
  .topbar { padding-inline: 28px; }
  .form-card { padding: 30px; }
  .welcome-hero { padding: 45px; }
  .coupon-list { grid-template-columns: 1fr 1fr; }
  .coupon-main { grid-template-columns: 96px 1fr; }
  .coupon-main::before, .coupon-main::after { left: 87px; }
}

@media (orientation: landscape) and (max-height: 520px) {
  .topbar { min-height: 62px; }
  .welcome-hero { padding: 24px; }
  .welcome-hero > img { float: right; margin: 0 0 12px 20px; }
  .welcome-hero h1 { font-size: 38px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #101a17;
    --paper-deep: #1b2823;
    --surface: #18241f;
    --ink: #f4efe3;
    --muted: #b7c0ba;
    --tea-100: #29473d;
    --border: rgba(232,240,234,.14);
  }
  body { background: radial-gradient(circle at 15% 2%, rgba(181,138,66,.12), transparent 32%), #101a17; }
  .profile-chip, .feature-grid div, .form-card, .stats-grid div { background: rgba(24,36,31,.88); }
  .field input:not([type="radio"]), .field textarea { background: #121d19; color: var(--ink); }
  .bottom-nav { background: rgba(19,30,26,.95); }
  .claim-hero { background: linear-gradient(rgba(24,36,31,.91), rgba(24,36,31,.94)), url("poster-bg.png") center / cover; }
  .qr-box { background: #fff; }
  .toast { background: #183229; color: #eaf6ee; }
  .toast-error, .error-summary { background: #3a211e; color: #ffd5cf; }
  .toast-info { background: #342b1c; color: #efd49d; }
}
