:root {
  --primary: #7850dc;
  --primary-rgb: 120, 80, 220;
  --primary-light: #ede6ff;
  --accent: #1ea0dc;
  --bg: #f5f5fa;
  --card-bg: #ffffff;
  --text: #1e1e2d;
  --text-secondary: #64647d;
  --text-light: #a0a0b4;
  --border: #e1e1eb;
  --shadow: #00000014;
  --shadow-lg: #0000001f;
  --success: #1eb464;
  --gradient-warm: linear-gradient(135deg, #7850dc, #b43ce6);
  --gradient-green: linear-gradient(135deg, #1eb464, #00aa96);
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  background: var(--bg);
}

body {
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  font-size: 13px;
  -webkit-font-smoothing: antialiased;
}

button,
a {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

.app-container {
  max-width: 960px;
  min-height: 100vh;
  margin: 0 auto;
  padding: 0 16px;
}

.cat-nav {
  margin-bottom: 8px;
}

.cat-nav__page {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px 0;
  padding: 8px 0 4px;
}

.cat-nav__item {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-width: 0;
  padding: 2px;
  background: transparent;
  -webkit-tap-highlight-color: transparent;
}

.cat-nav__icon {
  display: flex;
  width: 40px;
  height: 40px;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 6px #00000014;
  transition: transform 0.15s, box-shadow 0.15s, outline 0.15s;
}

.cat-nav__item:active .cat-nav__icon {
  transform: scale(0.92);
}

.cat-nav__item--active .cat-nav__icon {
  background: rgba(var(--primary-rgb), 0.12);
  box-shadow: 0 2px 10px rgba(var(--primary-rgb), 0.35);
  outline: 2px solid var(--primary);
  outline-offset: 1px;
}

.cat-nav__img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

.cat-nav__name {
  max-width: 62px;
  overflow: hidden;
  color: var(--text-secondary);
  font-size: 10px;
  font-weight: 500;
  line-height: 1.2;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cat-nav__item--active .cat-nav__name {
  color: var(--primary);
  font-weight: 700;
}

.cat-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 1px 0 8px;
  padding: 6px 10px;
  border: 1px solid #cbc1ee;
  border-radius: 9px;
  background: #f4f1fb;
}

.cat-summary__left {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 6px;
}

.cat-summary__icon {
  display: inline-flex;
  width: 16px;
  height: 16px;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  background: #ff6b7c;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
}

.cat-summary__name {
  overflow: hidden;
  color: var(--text);
  font-size: 11px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cat-summary__count {
  flex-shrink: 0;
  padding: 2px 7px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg);
  color: var(--text-secondary);
  font-size: 10px;
}

.coupon-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  padding-bottom: 24px;
}

.coupon-card {
  position: relative;
  display: flex;
  overflow: hidden;
  flex-direction: column;
  border-radius: 12px;
  background: var(--card-bg);
  box-shadow: 0 2px 12px var(--shadow);
  transition: box-shadow 0.25s, transform 0.25s;
}

.coupon-card:hover {
  box-shadow: 0 4px 20px var(--shadow-lg);
  transform: translateY(-2px);
}

.coupon-card__img {
  position: relative;
  display: flex;
  width: 100%;
  aspect-ratio: 16 / 7;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: linear-gradient(135deg, #e6e1f5, #f0e6fa);
}

.coupon-card__img::after {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  height: 24px;
  background: linear-gradient(to top, var(--card-bg), transparent);
  content: "";
}

.coupon-card__img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.coupon-card__expire {
  position: absolute;
  right: 3px;
  bottom: 3px;
  z-index: 1;
  padding: 2px 5px;
  border-radius: 3px;
  background: #000000a6;
  color: #fff;
  font-size: 8px;
}

.fav-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 2;
  display: inline-flex;
  width: 30px;
  height: 30px;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: #00000055;
  color: #fff;
  font-size: 23px;
  line-height: 1;
  transition: background 0.15s, transform 0.15s;
}

.fav-btn:hover,
.fav-btn--active {
  background: rgba(var(--primary-rgb), 0.85);
}

.fav-btn:active {
  transform: scale(0.92);
}

.coupon-card__body {
  display: flex;
  flex: 1;
  flex-direction: column;
  padding: 8px;
}

.coupon-card__title {
  display: -webkit-box;
  overflow: hidden;
  margin-bottom: 3px;
  color: var(--text);
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.3;
}

.coupon-card__desc {
  display: -webkit-box;
  overflow: hidden;
  margin-bottom: 3px;
  color: var(--text-secondary);
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  font-size: 10px;
  line-height: 1.3;
  white-space: pre-line;
}

.coupon-card__tags {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  margin-bottom: 4px;
}

.coupon-tag {
  display: inline-block;
  padding: 1px 5px;
  border-radius: 3px;
  color: #fff;
  font-size: 9px;
  font-weight: 600;
  line-height: 1.4;
}

.coupon-card__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  margin-top: auto;
}

.coupon-card__wx-btn-wrap {
  position: relative;
  z-index: 1;
  display: block;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  border-radius: 6px;
}

.wx-launch-layer {
  position: absolute;
  inset: 0;
  z-index: 2;
  overflow: hidden;
  border-radius: 6px;
}

.coupon-btn {
  flex: 1;
  min-width: 0;
  padding: 7px 4px;
  border-radius: 6px;
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.2px;
  text-align: center;
  text-decoration: none;
  transition: transform 0.15s, filter 0.15s;
}

.coupon-btn:active {
  transform: scale(0.96);
}

.coupon-btn--mini {
  width: 100%;
  background: var(--gradient-green);
  box-shadow: 0 2px 8px #28c86440;
}

.coupon-btn--link {
  background: var(--gradient-warm);
  box-shadow: 0 2px 8px rgba(var(--primary-rgb), 0.25);
}

.coupon-btn--disabled {
  background: var(--border);
  color: var(--text-light);
  cursor: not-allowed;
}

.empty-state {
  padding: 80px 20px;
  color: var(--text-light);
  text-align: center;
}

.empty-state__icon {
  margin-bottom: 16px;
  font-size: 32px;
  font-weight: 700;
}

.empty-state__text {
  font-size: 15px;
  font-weight: 500;
}

.fan-menu-root {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 920;
}

.fan-menu {
  position: relative;
  width: 48px;
  height: 48px;
}

.fan-menu__guide {
  position: absolute;
  right: 56px;
  bottom: 8px;
  padding: 7px 10px;
  border-radius: 10px;
  background: #111827eb;
  box-shadow: 0 8px 16px #0000002e;
  color: #fff;
  font-size: 12px;
  line-height: 1;
  white-space: nowrap;
  animation: fan-guide-float 1.6s ease-in-out infinite;
}

.fan-menu__guide::after {
  position: absolute;
  right: -6px;
  bottom: 10px;
  width: 0;
  height: 0;
  border-top: 6px solid transparent;
  border-bottom: 6px solid transparent;
  border-left: 6px solid #111827eb;
  content: "";
}

.fan-menu--touched .fan-menu__guide {
  display: none;
}

.fan-menu__trigger {
  position: absolute;
  right: 0;
  bottom: 0;
  display: inline-flex;
  width: 48px;
  height: 48px;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--gradient-warm);
  box-shadow: 0 8px 20px var(--shadow-lg);
  color: #fff;
  transition: transform 0.18s, box-shadow 0.2s;
}

.fan-menu__trigger:active {
  transform: scale(0.96);
}

.fan-menu--open .fan-menu__trigger {
  background: #64748b;
}

.fan-menu__bars,
.fan-menu__bars::before,
.fan-menu__bars::after {
  display: block;
  width: 18px;
  height: 2px;
  border-radius: 999px;
  background: currentColor;
  transition: transform 0.2s;
  content: "";
}

.fan-menu__bars {
  position: relative;
}

.fan-menu__bars::before,
.fan-menu__bars::after {
  position: absolute;
  left: 0;
}

.fan-menu__bars::before {
  top: -6px;
}

.fan-menu__bars::after {
  top: 6px;
}

.fan-menu--open .fan-menu__bars {
  transform: rotate(90deg);
}

.fan-menu__dial {
  position: absolute;
  right: 0;
  bottom: 56px;
  display: flex;
  flex-direction: column-reverse;
  align-items: flex-end;
  gap: 10px;
}

.fan-menu__item {
  display: inline-flex;
  height: 40px;
  align-items: center;
  gap: 8px;
  padding: 0 14px 0 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--card-bg);
  box-shadow: 0 4px 14px var(--shadow-lg);
  color: var(--text);
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px) scale(0.92);
  transition: transform 0.2s, opacity 0.2s, box-shadow 0.15s;
  white-space: nowrap;
}

.fan-menu--open .fan-menu__item {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}

.fan-menu__item-icon {
  display: inline-flex;
  width: 24px;
  height: 24px;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--bg);
  font-size: 13px;
  font-weight: 700;
}

.fan-menu__item-label {
  font-size: 13px;
  font-weight: 500;
  line-height: 1;
}

.fan-menu__item--active {
  border-color: transparent;
  background: var(--gradient-warm);
  color: #fff;
}

.fan-menu__item--active .fan-menu__item-icon {
  background: #ffffff38;
}

.toast {
  position: fixed;
  top: max(40px, calc(env(safe-area-inset-top) + 24px));
  left: 50%;
  z-index: 10000;
  max-width: min(85vw, 360px);
  padding: 11px 16px;
  border-radius: 14px;
  background: #14161eeb;
  box-shadow: 0 8px 24px #00000047, 0 2px 6px #0000002e;
  color: #fff;
  font-size: 14px;
  line-height: 1.45;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -16px) scale(0.92);
  transition: opacity 0.2s, transform 0.25s;
}

.toast--visible {
  opacity: 1;
  transform: translate(-50%, 0) scale(1);
}

.icp-fixed {
  display: block;
  margin: 24px auto calc(8px + env(safe-area-inset-bottom));
  color: var(--text-light);
  font-size: 11px;
  line-height: 1;
  text-align: center;
  user-select: none;
  pointer-events: none;
}

@keyframes fan-guide-float {
  0%,
  100% {
    opacity: 0.9;
    transform: translateY(0);
  }
  50% {
    opacity: 1;
    transform: translateY(-2px);
  }
}

@media (max-width: 640px) {
  .coupon-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }

  .app-container {
    padding: 0 10px;
  }
}

@media (max-width: 400px) {
  .coupon-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 380px) {
  .fan-menu-root {
    right: 16px;
    bottom: 20px;
  }
}
