:root {
  --bg: #f2f3f5;
  --card: #ffffff;
  --brand: #ffd100;
  --brand-hover: #f4c700;
  --brand-focus: #e8bb00;
  --accent: #ff9500;
  --text: #222222;
  --text-sub: #7b8491;
  --border: #e7e9ee;
  --shadow: 0 4px 18px rgba(27, 31, 37, 0.055);
  --radius: 14px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.6;
  min-height: 100vh;
}

.hidden { display: none !important; }

/* Sticky Frosted Top Nav */
.nav-root {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.nav-inner {
  max-width: 520px;
  margin: 0 auto;
  min-height: 58px;
  padding: 0 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.nav-brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.nav-logo {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  object-fit: contain;
  background: #fffbeb;
  border: 1px solid rgba(255, 209, 0, 0.35);
  padding: 2px;
  flex-shrink: 0;
}
.nav-title { font-size: 15px; font-weight: 700; color: #222; line-height: 1.25; }
.nav-sub { font-size: 11px; color: #999; line-height: 1.2; margin-top: 2px; }

.nav-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 600;
  color: #536170;
  background: #f5f7fa;
  border: 1px solid #e7e9ee;
  padding: 4px 10px;
  border-radius: 999px;
}
.nav-dot { width: 6px; height: 6px; border-radius: 50%; background: #10b981; }

/* Main Page Container */
.page-wrap {
  max-width: 520px;
  margin: 0 auto;
  padding: 14px 12px 96px;
}

.card {
  background: var(--card);
  border-radius: var(--radius);
  border: 1px solid rgba(0, 0, 0, 0.035);
  box-shadow: var(--shadow);
}

/* ==================== QUERY TAB ==================== */
.page-head { padding: 2px 2px 12px; }
.page-title { font-size: 21px; font-weight: 700; color: #222; letter-spacing: -0.01em; }
.page-lead { font-size: 13px; color: var(--text-sub); margin-top: 4px; line-height: 1.55; }

.coupon-query-card {
  padding: 16px 14px 15px;
  position: relative;
  overflow: hidden;
}
.coupon-query-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--brand), var(--accent), #10b981);
}

.input-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.input-label { font-size: 14px; font-weight: 700; color: #333; }
.clear-text-btn { background: none; border: none; font-size: 12px; color: #7b8491; cursor: pointer; }

.coupon-query-textarea {
  width: 100%;
  min-height: 112px;
  padding: 11px 12px;
  border-radius: 10px;
  border: 1px solid #dfe3e8;
  background: #fafbfc;
  color: #222;
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  font-size: 13px;
  line-height: 1.55;
  resize: none;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}
.coupon-query-textarea:focus {
  border-color: var(--brand-focus);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(255, 209, 0, 0.18);
}

.input-hint { font-size: 12px; color: #8a96af; margin-top: 6px; }

/* Live Detection Status Pill */
.coupon-detect {
  margin-top: 10px;
  padding: 8px 12px;
  border-radius: 10px;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid #e2e8f0;
  background: #f8fafc;
  color: #64748b;
}
.detect-dot { width: 8px; height: 8px; border-radius: 50%; background: #cbd5e1; flex-shrink: 0; }

.coupon-detect.is-ok {
  background: #ecfdf5;
  border-color: #a7f3d0;
  color: #047857;
}
.coupon-detect.is-ok .detect-dot {
  background: #10b981;
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.2);
}
.coupon-detect.is-warn {
  background: #fffbeb;
  border-color: #fde68a;
  color: #b45309;
}
.coupon-detect.is-warn .detect-dot { background: #f59e0b; }

/* Action Grid */
.coupon-submit-row {
  margin-top: 12px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.coupon-query-submit {
  grid-column: 1 / -1;
  width: 100%;
  min-height: 48px;
  border: none;
  border-radius: 14px;
  background: var(--brand);
  color: #111;
  font-size: 15px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}
.coupon-query-submit:hover { background: var(--brand-hover); }
.coupon-query-submit:active { transform: scale(0.985); }
.coupon-query-submit:disabled { opacity: 0.7; cursor: not-allowed; }

.coupon-tutorial-btn {
  min-height: 42px;
  border-radius: 12px;
  background: #fff;
  border: 1px solid #dfe3e8;
  color: #536170;
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  box-shadow: 0 2px 7px rgba(47, 60, 75, 0.06);
}

.coupon-redpacket-btn {
  min-height: 42px;
  border-radius: 12px;
  background: linear-gradient(135deg, #ef4444, #f97316);
  color: #fff;
  text-decoration: none;
  font-size: 13px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  box-shadow: 0 5px 16px -4px rgba(239, 68, 68, 0.55);
}

.btn-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(17, 17, 17, 0.25);
  border-top-color: #111;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.alert-box {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  background: #fffbeb;
  border: 1px solid #fde68a;
  color: #b45309;
  font-size: 13px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.alert-action {
  align-self: flex-start;
  border: none;
  background: #f59e0b;
  color: #fff;
  border-radius: 8px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

/* Result Card */
.result-wrap { margin-top: 12px; animation: fadeIn 0.22s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

.shop-result-card { padding: 14px; }
.shop-top { display: flex; align-items: center; gap: 10px; }
.shop-logo {
  width: 46px;
  height: 46px;
  border-radius: 11px;
  background: #fff9db;
  color: #8a4b00;
  font-weight: 800;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
  border: 1px solid rgba(0, 0, 0, 0.05);
}
.shop-logo img { width: 100%; height: 100%; object-fit: cover; }
.shop-meta-col { flex: 1; min-width: 0; }
.shop-title-row { display: flex; align-items: center; gap: 6px; }
.shop-name { font-size: 15px; font-weight: 700; color: #1e1e2d; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cache-pill { font-size: 10px; padding: 1px 6px; border-radius: 5px; background: #ecfdf5; color: #047857; font-weight: 600; flex-shrink: 0; }
.shop-sub { font-size: 12px; color: var(--text-sub); margin-top: 2px; }

.fav-toggle-btn {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  border: 1px solid #e7e9ee;
  background: #fafbfc;
  color: #94a3b8;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}
.fav-toggle-btn.is-fav { background: #fffbeb; border-color: #fde68a; color: #f59e0b; }
.fav-toggle-btn.is-fav svg { fill: #f59e0b; }

.result-block { margin-top: 14px; padding-top: 12px; border-top: 1px solid #f1f3f6; }
.result-block-title { font-size: 13px; font-weight: 700; color: #333; margin-bottom: 8px; }

.coupon-items { display: flex; flex-direction: column; gap: 8px; }
.coupon-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px;
  border-radius: 11px;
  background: #fff;
  border: 1px solid rgba(15, 23, 42, 0.08);
}
.coupon-row-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.coupon-ticket-badge {
  min-width: 68px;
  padding: 6px 8px;
  border-radius: 8px;
  background: linear-gradient(135deg, #ffe9a8, #ffc93c);
  color: #8a4b00;
  text-align: center;
  flex-shrink: 0;
}
.ct-amt { font-size: 18px; font-weight: 800; line-height: 1.1; }
.ct-amt small { font-size: 11px; }
.ct-cond { font-size: 10px; margin-top: 2px; opacity: 0.9; }
.coupon-row-title { font-size: 13px; font-weight: 700; color: #222; }
.coupon-row-sub { font-size: 11px; color: var(--text-sub); margin-top: 2px; }

.go-btn {
  padding: 7px 13px;
  border-radius: 9px;
  background: linear-gradient(135deg, #ffe066 0%, #ffc300 55%, #ff9500 100%);
  color: #4a2900;
  text-decoration: none;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.cashback-box {
  padding: 12px;
  border-radius: 11px;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
}
.cb-badges { display: flex; flex-wrap: wrap; gap: 6px; }
.cb-pill {
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 6px;
  background: linear-gradient(135deg, #d1fae5, #6ee7b7);
  color: #047857;
}
.cb-sub { font-size: 12px; color: #065f46; margin-top: 6px; }
.cb-go-btn {
  margin-top: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 38px;
  border-radius: 9px;
  background: #059669;
  color: #fff;
  text-decoration: none;
  font-size: 13px;
  font-weight: 700;
}

.empty-result { text-align: center; padding: 18px 8px 6px; }
.empty-title { font-size: 14px; font-weight: 700; color: #333; }
.empty-sub { font-size: 12px; color: var(--text-sub); margin-top: 4px; }

/* Recent Quick History */
.quick-hist-card { margin-top: 12px; padding: 12px 14px; }
.qh-head { display: flex; justify-content: space-between; font-size: 12px; color: var(--text-sub); margin-bottom: 8px; }
.link-muted { background: none; border: none; color: #8a96af; font-size: 12px; cursor: pointer; }
.qh-list { display: flex; flex-wrap: wrap; gap: 6px; }
.qh-chip {
  font-size: 12px;
  padding: 5px 10px;
  border-radius: 8px;
  background: #f5f7fa;
  border: 1px solid #e7e9ee;
  color: #334155;
  cursor: pointer;
  max-width: 170px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.footer { text-align: center; margin-top: 22px; }
.footer-main { font-size: 13px; color: #5b6782; }
.footer-sub { font-size: 12px; color: #8895b0; margin-top: 2px; }

/* ==================== HOME TAB ==================== */
.hm-quickbar {
  background: #fff;
  border-radius: 12px;
  border: 1px solid #ececec;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  height: 44px;
  margin-bottom: 10px;
  overflow: hidden;
}
.hm-qtab {
  background: none;
  border: none;
  font-size: 13px;
  color: #777;
  font-weight: 500;
  cursor: pointer;
  position: relative;
}
.hm-qtab.active { color: #171717; font-weight: 700; }
.hm-qtab.active::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 24px;
  height: 3px;
  border-radius: 2px;
  background: var(--brand);
}

.home-support {
  background: #fff;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  height: 50px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  margin-bottom: 14px;
}
.support-item {
  background: none;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  color: #333;
  cursor: pointer;
}
.support-item + .support-item { border-left: 1px solid #edf0f3; }

.hm-section-title {
  font-size: 15px;
  font-weight: 700;
  color: #1e1e2d;
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 14px 2px 10px;
}
.hm-section-title::before {
  content: "";
  width: 4px;
  height: 15px;
  border-radius: 99px;
  background: var(--brand);
}

.home-hero-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px;
  border-radius: var(--radius);
  background: linear-gradient(135deg, #fff8d6 0%, #ffe680 100%);
  border: 1px solid #ffd84d;
  text-decoration: none;
  color: #2c1d00;
  box-shadow: var(--shadow);
}
.hhb-pill { display: inline-block; font-size: 10px; font-weight: 700; background: #111; color: #ffd100; padding: 2px 7px; border-radius: 5px; }
.hhb-title { font-size: 17px; font-weight: 800; margin-top: 5px; }
.hhb-desc { font-size: 12px; color: #664900; margin-top: 2px; }
.hhb-btn {
  padding: 8px 15px;
  border-radius: 999px;
  background: #111;
  color: #ffd100;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.hm-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 8px;
}
.hm-card {
  background: #fff;
  border-radius: var(--radius);
  overflow: hidden;
  text-decoration: none;
  color: #1e1e2d;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
  display: flex;
  flex-direction: column;
}
.hm-cover {
  aspect-ratio: 166 / 93;
  padding: 12px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  color: #fff;
}
.hm-cover-tag { align-self: flex-start; font-size: 10px; font-weight: 700; background: rgba(0, 0, 0, 0.22); padding: 2px 7px; border-radius: 5px; }
.hm-cover-big { font-size: 16px; font-weight: 800; letter-spacing: -0.01em; }
.hm-body { padding: 10px; flex: 1; display: flex; flex-direction: column; justify-content: space-between; }
.hm-title { font-size: 13px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hm-desc { font-size: 11px; color: #64647d; margin-top: 3px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; line-height: 1.4; }
.hm-tags { display: flex; gap: 5px; margin-top: 8px; }
.hm-tag-1 { font-size: 10px; font-weight: 700; padding: 1px 6px; border-radius: 4px; background: var(--brand); color: #342700; }
.hm-tag-2 { font-size: 10px; font-weight: 600; padding: 1px 6px; border-radius: 4px; background: #fff2c2; color: #8a6200; }

/* ==================== MINE TAB ==================== */
.mine-header-card { padding: 16px; display: flex; align-items: center; gap: 12px; }
.mine-logo { width: 52px; height: 52px; border-radius: 14px; object-fit: contain; background: #fffbeb; padding: 3px; border: 1px solid rgba(255, 209, 0, 0.35); }
.mine-name { font-size: 17px; font-weight: 700; }
.mine-desc { font-size: 12px; color: var(--text-sub); margin-top: 2px; }

.mine-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 10px; }
.stat-box { background: #fff; border-radius: var(--radius); padding: 14px; text-align: center; box-shadow: var(--shadow); }
.stat-num { font-size: 22px; font-weight: 800; color: #111; }
.stat-label { font-size: 12px; color: var(--text-sub); margin-top: 2px; }

.mine-list-card { padding: 6px 12px; }
.mine-empty { padding: 16px 6px; text-align: center; font-size: 12px; color: #94a3b8; }
.mine-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 2px;
  border-bottom: 1px solid #f1f3f6;
}
.mine-row:last-child { border-bottom: none; }
.mine-row-name { font-size: 13px; font-weight: 600; color: #222; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mine-row-actions { display: flex; gap: 6px; flex-shrink: 0; }
.mini-btn {
  padding: 4px 10px;
  border-radius: 7px;
  border: none;
  background: var(--brand);
  color: #111;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}
.mini-btn.ghost { background: #f1f5f9; color: #64748b; font-weight: 600; }

.mine-menu-card { margin-top: 14px; overflow: hidden; }
.menu-row {
  width: 100%;
  background: #fff;
  border: none;
  border-bottom: 1px solid #f1f3f6;
  padding: 14px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 14px;
  color: #222;
  cursor: pointer;
}
.menu-row:last-child { border-bottom: none; }
.menu-row.danger { color: #dc2626; }
.menu-arrow { color: #94a3b8; font-size: 18px; line-height: 1; }

/* ==================== FIXED 3-TAB BOTTOM NAV ==================== */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 60;
  background: rgba(255, 255, 255, 0.97);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
  box-shadow: 0 -8px 22px rgba(31, 41, 55, 0.06);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  max-width: 520px;
  margin: 0 auto;
  min-height: 64px;
}

.bnav-item {
  background: none;
  border: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: #7f8792;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  padding: 6px 0;
}
.bnav-item.active { color: #111; font-weight: 700; }

.bnav-center { position: relative; }
.bnav-fab {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--brand);
  color: #151515;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: -26px;
  border: 5px solid var(--bg);
  box-shadow: 0 8px 18px rgba(144, 112, 0, 0.22);
  transition: transform 0.12s;
}
.bnav-center:active .bnav-fab { transform: scale(0.94); }

/* ==================== MODALS ==================== */
.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal-card {
  width: 100%;
  max-width: 420px;
  background: #fff;
  border-radius: 16px;
  padding: 18px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.2);
}
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.modal-head h3 { font-size: 16px; font-weight: 700; }
.modal-close { width: 28px; height: 28px; border-radius: 50%; border: none; background: #f1f5f9; color: #475569; font-size: 18px; cursor: pointer; }
.guide-steps { list-style: none; display: flex; flex-direction: column; gap: 11px; font-size: 13px; margin-bottom: 14px; }
.guide-steps li { display: flex; gap: 10px; align-items: flex-start; }
.step-idx {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff2c2;
  color: #8a4b00;
  font-weight: 800;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.guide-tip { padding: 10px 12px; border-radius: 10px; background: #fffbeb; border: 1px solid #fde68a; color: #92400e; font-size: 12px; margin-bottom: 14px; }
.privacy-text { font-size: 13px; color: #475569; line-height: 1.75; margin-bottom: 14px; }
code { background: #f1f5f9; padding: 1px 5px; border-radius: 4px; font-size: 11px; }
