:root {
  --ink: #252525;
  --muted: #8a8a8a;
  --paper: #fff;
  --surface: #fff;
  --line: #ededed;
  --orange: #f45b36;
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  color: var(--ink);
  background: #f3f4f6;
  font-synthesis: none;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { min-width: 320px; margin: 0; background: #f3f4f6; }
button, a { -webkit-tap-highlight-color: transparent; }
button { font: inherit; }
a { color: inherit; text-decoration: none; }
button:focus-visible, a:focus-visible { outline: 2px solid #ff9c83; outline-offset: 2px; }

.app-shell {
  width: min(100%, 480px);
  min-height: 100vh;
  margin: 0 auto;
  overflow: hidden;
  background: var(--paper);
  box-shadow: 0 0 36px rgba(32, 38, 45, .08);
}

.topbar {
  display: flex;
  height: calc(54px + env(safe-area-inset-top));
  align-items: flex-end;
  padding: max(10px, env(safe-area-inset-top)) 16px 8px;
}

.brand { display: inline-flex; align-items: center; gap: 8px; font-size: 18px; font-weight: 800; letter-spacing: -.2px; }
.brand-mark { display: grid; width: 30px; height: 30px; place-items: center; border-radius: 10px; color: #fff; font-size: 15px; background: var(--orange); }
.source-status { color: #92979b; }
.source-status.live { color: #4c997f; }

.hero {
  position: relative;
  display: grid;
  height: var(--hero-height, 160px);
  margin: 4px 16px 0;
  overflow: hidden;
  grid-template-columns: 1.4fr .6fr;
  border-radius: 12px;
  color: #fff;
  background: linear-gradient(135deg, #fa643f 0%, #f34e31 100%);
  opacity: 1;
  transition: height 180ms ease, opacity 180ms ease;
  isolation: isolate;
}

.hero.hero-loading { opacity: 0; pointer-events: none; }
.hero-media { position: absolute; z-index: 0; width: 100%; height: 100%; inset: 0; transform: scale(1.01); object-fit: contain; background: #191919; filter: brightness(.66); opacity: 0; transition: opacity 240ms ease, transform 320ms ease; }
.hero-media[hidden] { display: none; }
.hero::before { position: absolute; width: 170px; height: 170px; right: -78px; top: -92px; border-radius: 50%; background: rgba(255,161,102,.48); content: ""; transition: opacity 160ms ease; }
.hero::after { position: absolute; z-index: -1; width: 150px; height: 150px; right: -58px; bottom: -118px; border: 24px solid rgba(255,255,255,.08); border-radius: 50%; content: ""; transition: opacity 160ms ease; }
.hero.hero-live::before, .hero.hero-live::after { opacity: 0; }
.hero.hero-live.hero-ready .hero-media { transform: scale(1); opacity: 1; }
.hero.hero-live .hero-art { visibility: hidden; opacity: 0; }
.hero.hero-live .hero-copy { max-width: 78%; text-shadow: 0 1px 2px rgba(0,0,0,.24); }
.hero-meta { display: flex; min-width: 0; align-items: center; gap: 6px; margin-bottom: 7px; }
.hero.hero-live [data-hero-description] { display: block; overflow: hidden; width: max-content; min-width: 0; max-width: 210px; height: 22px; margin: 0; padding: 3px 9px 3px 7px; border-left: 3px solid #ffd267; border-radius: 3px 6px 6px 3px; color: #fff; font-size: 11px; font-weight: 800; line-height: 16px; text-overflow: ellipsis; white-space: nowrap; background: rgba(16,35,42,.48); box-shadow: 0 4px 12px rgba(4,30,38,.13); }
.hero.hero-text-only { grid-template-columns: minmax(0,1fr) 104px; background: linear-gradient(125deg,#167c82 0%,#126d78 58%,#164c68 100%); }
.hero.hero-live.hero-text-only .hero-art { visibility: visible; opacity: 1; }
.hero.hero-live.hero-text-only .hero-copy { max-width: none; padding: 14px 4px 12px 18px; text-shadow: none; }
.hero.hero-live.hero-text-only .hero-label { border: 1px solid rgba(255,255,255,.3); color: #e9ffff; background: rgba(5,53,66,.28); }
.hero.hero-live.hero-text-only h1 { display: -webkit-box; overflow: hidden; max-width: 210px; font-size: 20px; line-height: 1.18; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
.hero.hero-live.hero-text-only [data-hero-description] { max-width: 190px; color: #fff; background: rgba(255,120,89,.94); box-shadow: 0 5px 12px rgba(4,45,56,.2); }
.hero.hero-live.hero-text-only .hero-cta { height: 29px; margin-top: 7px; padding: 0 11px; color: #126b72; box-shadow: 0 5px 14px rgba(3,48,61,.2); }
.hero.hero-text-only .packet, .hero.hero-text-only .coin { display: none; }
.hero.hero-text-only .insurance-visual { display: block; }
.hero.hero-switching .hero-copy, .hero.hero-switching .hero-art { opacity: 0; }
.hero.hero-clicking { cursor: wait; opacity: .92; }
.hero-link { position: absolute; z-index: 5; inset: 0; border-radius: inherit; }
.hero-copy { position: relative; z-index: 2; padding: 16px 0 15px 18px; transition: opacity 140ms ease; }
.hero-label { display: inline-flex; width: auto; height: 22px; flex: 0 0 auto; align-items: center; justify-content: center; padding: 3px 7px; border-radius: 5px; color: #ffe6de; font-size: 9px; font-weight: 700; line-height: 14px; background: rgba(20,20,20,.28); }
.hero-ad-logo { display: block; width: auto; max-width: 76px; height: 12px; object-fit: contain; }
.hero-ad-logo[hidden] { display: none; }
.hero h1 { margin: 0; font-size: 24px; line-height: 1.16; letter-spacing: -.5px; }
.hero p { margin: 6px 0 10px; color: #ffe9e2; font-size: 10px; }
.hero-cta { display: inline-flex; height: 30px; align-items: center; gap: 6px; padding: 0 12px; border-radius: 7px; color: #d94724; font-size: 11px; font-weight: 800; background: #fff; }
.hero-cta b { font-size: 14px; font-weight: 500; }
.hero-art { position: relative; opacity: 1; transition: opacity 140ms ease; }

.packet { position: absolute; z-index: 2; display: grid; width: 70px; height: 88px; right: 18px; bottom: 18px; place-items: center; border-radius: 12px 12px 7px 7px; transform: rotate(8deg); color: #b92e1d; font-size: 18px; font-weight: 900; background: #ffba3b; box-shadow: 0 10px 18px rgba(140,31,13,.2); }
.packet::before { position: absolute; inset: 0 0 auto; height: 42px; border-radius: 12px 12px 55% 55%; background: #eb3f2d; content: ""; }
.packet span { position: relative; z-index: 1; display: grid; width: 34px; height: 34px; place-items: center; border: 3px solid #ffe28d; border-radius: 50%; background: #ffc94b; }
.coin { position: absolute; z-index: 3; display: grid; place-items: center; border: 2px solid #ffe495; border-radius: 50%; color: #d65126; font-weight: 800; background: #ffc94b; }
.coin-small { width: 25px; height: 25px; left: 0; top: 26px; font-size: 10px; }
.coin-large { width: 31px; height: 31px; right: 5px; bottom: 16px; font-size: 12px; }
.insurance-visual { position: absolute; width: 96px; height: 126px; right: 7px; bottom: 8px; display: none; }
.insurance-card { position: absolute; width: 76px; height: 96px; right: 5px; bottom: 8px; border: 1px solid rgba(255,255,255,.55); border-radius: 10px; transform: rotate(4deg); background: rgba(235,255,252,.94); box-shadow: 0 12px 22px rgba(3,39,54,.24); }
.insurance-card::before, .insurance-card::after { position: absolute; height: 4px; left: 13px; border-radius: 4px; background: #a8dcd7; content: ""; }
.insurance-card::before { width: 43px; bottom: 20px; }
.insurance-card::after { width: 30px; bottom: 11px; }
.insurance-shield { position: absolute; z-index: 2; width: 58px; height: 67px; right: 13px; top: 13px; clip-path: polygon(50% 0,91% 15%,86% 66%,50% 100%,14% 66%,9% 15%); background: #ff7859; filter: drop-shadow(0 7px 8px rgba(7,58,67,.2)); }
.insurance-shield i::before, .insurance-shield i::after { position: absolute; left: 50%; top: 43%; border-radius: 2px; transform: translate(-50%,-50%); background: #fff; content: ""; }
.insurance-shield i::before { width: 26px; height: 8px; }
.insurance-shield i::after { width: 8px; height: 26px; }
.insurance-check { position: absolute; z-index: 3; display: grid; width: 25px; height: 25px; right: 0; bottom: 3px; place-items: center; border: 3px solid #fff; border-radius: 50%; color: #184d66; font-size: 14px; font-weight: 900; background: #ffd266; box-shadow: 0 5px 10px rgba(4,45,58,.2); }

.category-section { display: grid; grid-template-columns: repeat(4, 1fr); row-gap: 16px; padding: 20px 8px 20px; }
.category-item { position: relative; display: flex; min-width: 0; min-height: 58px; align-items: center; flex-direction: column; gap: 6px; padding: 0; border: 0; color: #555; font-size: 11px; background: transparent; cursor: pointer; }
.category-item:disabled { cursor: wait; opacity: .78; }
.category-item[data-direct]::after { position: absolute; top: -4px; right: calc(50% - 30px); padding: 1px 4px; border: 1px solid #efe1d8; border-radius: 5px; color: #a4765d; font-size: 7px; line-height: 12px; background: #fff; content: "直达"; }
.category-icon { display: grid; width: 42px; height: 42px; place-items: center; border-radius: 14px; color: #fff; font-size: 15px; font-weight: 800; transition: transform 160ms ease, box-shadow 160ms ease; }
.category-item.active .category-icon { transform: translateY(-1px); box-shadow: 0 0 0 3px rgba(244,91,54,.11); }
.category-item.pending .category-icon { animation: pulse 700ms ease-in-out infinite alternate; }
.category-icon svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.9; }
.icon-hot { background: #f06445; }
.icon-meituan { color: #332809; background: #ffd13c; }
.icon-elm { background: #4b91dc; }
.icon-jd { background: #df453f; }
.icon-coffee { background: #365dac; }
.icon-starbucks { background: #238363; }
.icon-movie { background: #8b68cd; }
.icon-hotel { background: #4c89b6; }

.coupon-section { min-height: 520px; padding: 18px 12px 36px; background: #f6f7f8; }
.section-heading { display: flex; align-items: center; justify-content: space-between; padding: 0 4px 12px; }
.section-heading > div > span { display: block; margin-bottom: 2px; color: var(--orange); font-size: 10px; font-weight: 800; }
.section-heading h2 { margin: 0; font-size: 21px; line-height: 1.25; letter-spacing: -.3px; }
.refresh-button { display: grid; width: 36px; height: 36px; place-items: center; border: 1px solid #e8e8e8; border-radius: 10px; color: #73777a; background: #fff; cursor: pointer; }
.refresh-button svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.8; }
.refresh-button.loading svg { animation: rotate 800ms linear infinite; }
.coupon-list { display: flex; flex-direction: column; gap: 10px; }

.coupon-item {
  display: grid;
  min-height: 108px;
  align-items: center;
  grid-template-columns: 64px minmax(0,1fr) 72px;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
}

.coupon-logo { position: relative; display: grid; width: 64px; height: 64px; overflow: hidden; place-items: center; border-radius: 10px; color: #fff; font-size: 22px; font-weight: 800; }
.coupon-image { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.coupon-logo.meituan { color: #332809; background: #ffd13c; }
.coupon-logo.elm { background: #428cdd; }
.coupon-info { min-width: 0; }
.coupon-info h3 { overflow: hidden; margin: 0; color: #292929; font-size: 14px; line-height: 1.4; text-overflow: ellipsis; white-space: nowrap; }
.coupon-info p { display: -webkit-box; overflow: hidden; margin: 6px 0 8px; color: #62666a; font-size: 10px; line-height: 1.45; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
.coupon-meta { display: flex; min-width: 0; align-items: center; gap: 6px; }
.platform-tag { flex: 0 0 auto; padding: 2px 5px; border-radius: 4px; color: #e45532; font-size: 8px; background: #fff0e9; }
.coupon-meta small { display: block; overflow: hidden; color: #a0a4a7; font-size: 9px; text-overflow: ellipsis; white-space: nowrap; }
.coupon-action { display: flex; align-items: center; justify-content: flex-end; align-self: stretch; padding-left: 9px; border-left: 1px dashed #e9e9e9; }
.claim-button { width: 66px; height: 34px; padding: 0; border: 0; border-radius: 8px; color: #fff; font-size: 10px; font-weight: 800; background: var(--orange); cursor: pointer; }
.claim-button:disabled { color: #8e8781; background: #eeeae6; cursor: default; }

.skeleton-card { display: grid; height: 108px; align-items: center; grid-template-columns: 64px 1fr 66px; gap: 12px; padding: 12px; border-radius: 12px; background: #fff; }
.skeleton-card i, .skeleton-card span, .skeleton-card b { display: block; border-radius: 6px; background: linear-gradient(90deg,#eee9e3 25%,#f7f4ef 50%,#eee9e3 75%); background-size: 200% 100%; animation: shimmer 1.3s infinite; }
.skeleton-card i { width: 64px; height: 64px; }
.skeleton-card span { height: 48px; }
.skeleton-card b { width: 66px; height: 34px; }

.empty-state { padding: 60px 0; color: #aaa39c; text-align: center; }
.empty-state svg { width: 44px; height: 44px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.4; }
.empty-state p { margin: 10px 0 14px; font-size: 12px; }
.empty-state button { height: 32px; padding: 0 14px; border: 1px solid #ddd6cf; border-radius: 5px; color: #6e6862; font-size: 11px; background: #fff; cursor: pointer; }
.list-end { display: flex; align-items: center; justify-content: center; gap: 5px; margin: 22px 0 0; color: #a4a8ab; font-size: 9px; text-align: center; }
.list-end i { color: #c8cacc; font-style: normal; }

.toast { position: fixed; z-index: 40; width: max-content; max-width: min(80vw,340px); left: 50%; bottom: 28px; padding: 9px 14px; border-radius: 5px; transform: translate(-50%,12px); color: #fff; font-size: 11px; text-align: center; background: rgba(36,32,29,.9); opacity: 0; pointer-events: none; transition: opacity 160ms ease, transform 160ms ease; }
.toast.show { transform: translate(-50%,0); opacity: 1; }
.svg-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

@keyframes shimmer { to { background-position: -200% 0; } }
@keyframes rotate { to { transform: rotate(360deg); } }
@keyframes pulse { to { transform: translateY(-2px) scale(.94); opacity: .7; } }

@media (max-width: 360px) {
  .hero { grid-template-columns: 1.5fr .5fr; }
  .hero h1 { font-size: 22px; }
  .hero p { max-width: 190px; }
  .hero.hero-text-only { grid-template-columns: minmax(0,1fr) 90px; }
  .hero.hero-live.hero-text-only h1 { max-width: 184px; font-size: 18px; }
  .hero.hero-live.hero-text-only [data-hero-description] { max-width: 166px; }
  .hero.hero-text-only .insurance-visual { right: 0; transform: scale(.9); }
  .packet { right: 4px; transform: rotate(8deg) scale(.88); }
  .coin-large { right: -5px; }
  .category-section { padding-right: 8px; padding-left: 8px; }
  .coupon-item { grid-template-columns: 56px minmax(0,1fr) 61px; gap: 8px; padding: 10px; }
  .coupon-logo { width: 56px; height: 56px; }
  .coupon-info p { font-size: 9px; }
  .coupon-action { padding-left: 6px; }
  .claim-button { width: 58px; }
}

@media (min-width: 700px) {
  body { padding: 28px 0; }
  .app-shell { min-height: calc(100vh - 56px); border-radius: 16px; }
}

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