/* ===== Reset & Base ===== */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

:root {
  --brand-blue: #003C8F;
  --brand-blue-dark: #002560;
  --brand-blue-light: #1a5ab5;
  --brand-gold: #C9A96E;
  --brand-gold-light: #e0c992;
  --brand-gold-dark: #a8873f;
  --bg-primary: #f7fbff;
  --bg-card: #FFFFFF;
  --text-primary: #1C1917;
  --text-secondary: #5f6f86;
  --text-muted: #9caac0;
  --border-color: rgba(82, 125, 193, 0.12);
  --shadow-sm: 0 6px 20px rgba(94, 123, 168, 0.08), 0 2px 6px rgba(94, 123, 168, 0.06);
  --shadow-md: 0 10px 30px rgba(94, 123, 168, 0.1), 0 4px 10px rgba(94, 123, 168, 0.06);
  --shadow-lg: 0 18px 48px rgba(94, 123, 168, 0.12), 0 8px 20px rgba(94, 123, 168, 0.08);
  --shadow-gold: 0 4px 20px rgba(201, 169, 110, 0.14);
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-xl: 28px;
  --transition-fast: 200ms cubic-bezier(0.25, 0.46, 0.45, 0.94);
  --transition-smooth: 400ms cubic-bezier(0.16, 1, 0.3, 1);
  --transition-spring: 500ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ===== Banner / Hero ===== */
.hero {
  position: relative;
  width: 100%;
  padding: 50px 24px 34px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.38) 0%, rgba(250, 253, 255, 0.3) 36%, rgba(238, 245, 255, 0.28) 100%),
    url('https://cos.fhugc.top/task/123123123.png') center center / cover no-repeat;
  text-align: center;
  overflow: hidden;
}

.hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.68) 0%, rgba(255, 255, 255, 0.34) 28%, rgba(255, 255, 255, 0.12) 58%),
    radial-gradient(circle at 18% 18%, rgba(255, 255, 255, 0.28) 0%, rgba(255, 255, 255, 0) 24%);
  pointer-events: none;
}

.hero::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(255,255,255,0.24) 0%, rgba(255,255,255,0.1) 32%, rgba(228, 241, 255, 0.16) 100%);
  opacity: 1;
  pointer-events: none;
}

.hero-waves {
  display: none;
}

.hero-content {
  position: relative;
  z-index: 2;
  animation: heroEnter 0.8s var(--transition-smooth) both;
}

@keyframes heroEnter {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 13px;
  background: rgba(255, 255, 255, 0.62);
  border: 1px solid rgba(107, 149, 216, 0.12);
  border-radius: 100px;
  margin-bottom: 16px;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 10px 22px rgba(135, 170, 223, 0.08);
}

.hero-badge span {
  font-size: 11px;
  color: #1f57b6;
  letter-spacing: 2px;
  font-weight: 600;
}

.hero-title {
  display: block;
  width: min(176px, 46vw);
  height: auto;
  margin: 0 auto 14px;
  filter: drop-shadow(0 10px 22px rgba(111, 149, 211, 0.16));
}

.hero-subtitle {
  font-size: 15px;
  color: #1f57b6;
  letter-spacing: 2px;
  font-weight: 600;
  margin-bottom: 18px;
}

/* ===== Sticky Tab Bar ===== */
.tab-wrapper {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(247, 251, 255, 0.88);
  backdrop-filter: blur(16px) saturate(180%);
  -webkit-backdrop-filter: blur(16px) saturate(180%);
  border-bottom: 1px solid var(--border-color);
  transition: box-shadow var(--transition-fast);
}

.tab-wrapper.scrolled {
  box-shadow: 0 2px 20px rgba(0, 0, 0, 0.06);
}

.tab-shell {
  max-width: 480px;
  margin: 0 auto;
}

.tab-bar {
  position: relative;
  display: flex;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding: 0 8px 12px;
}

.tab-bar::-webkit-scrollbar { display: none; }

.tab-item {
  flex-shrink: 0;
  position: relative;
  padding: 16px 16px;
  font-size: 13px;
  font-weight: 400;
  color: var(--text-muted);
  cursor: pointer;
  white-space: nowrap;
  transition: color var(--transition-fast);
  letter-spacing: 0.5px;
}

.tab-item.active {
  color: #174fa2;
  font-weight: 600;
}

.tab-indicator {
  position: absolute;
  bottom: 12px;
  height: 2.5px;
  background: linear-gradient(90deg, var(--brand-blue), var(--brand-gold));
  border-radius: 2px;
  transition: left var(--transition-smooth), width var(--transition-smooth);
}

.subtab-bar {
  position: relative;
  padding-bottom: 10px;
}

.subtab-scroll {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  width: 100%;
  padding: 0 12px 0;
}

.subtab-scroll::-webkit-scrollbar { display: none; }

.subtab-fade {
  position: absolute;
  top: 0;
  bottom: 10px;
  width: 26px;
  z-index: 2;
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--transition-fast);
}

.subtab-fade.show {
  opacity: 1;
}

.subtab-fade-left {
  left: 0;
  background: linear-gradient(90deg, rgba(247, 251, 255, 0.96), rgba(247, 251, 255, 0));
}

.subtab-fade-right {
  right: 0;
  background: linear-gradient(270deg, rgba(247, 251, 255, 0.96), rgba(247, 251, 255, 0));
}

.subtab-item {
  flex-shrink: 0;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid rgba(90, 132, 199, 0.16);
  background: rgba(255, 255, 255, 0.84);
  color: var(--text-secondary);
  font-size: 12px;
  line-height: 1;
  letter-spacing: 0.5px;
  cursor: pointer;
  transition: transform var(--transition-fast), background var(--transition-fast), color var(--transition-fast), border-color var(--transition-fast), box-shadow var(--transition-fast);
  white-space: nowrap;
}

.subtab-item.active {
  color: #fff;
  background: linear-gradient(135deg, #1650a7, #3a78d0);
  border-color: transparent;
  box-shadow: 0 10px 20px rgba(58, 120, 208, 0.24);
}

/* ===== Product Container ===== */
.product-container {
  padding: 16px 12px 48px;
  max-width: 480px;
  margin: 0 auto;
}

/* ===== Waterfall Layout ===== */
.waterfall {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px 16px;
  opacity: 1;
  transform: translateY(0);
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.waterfall.switching {
  opacity: 0;
  transform: translateY(8px);
}

.category-sections {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.category-section {
  display: block;
}

/* ===== Product Card ===== */
.product-card {
  position: relative;
  background: var(--bg-card);
  border-radius: var(--radius-md);
  overflow: hidden;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  border: 1px solid rgba(127, 159, 212, 0.12);
  opacity: 0;
  transform: translateY(24px);
  transition: transform var(--transition-fast), box-shadow var(--transition-fast), border-color var(--transition-fast);
  display: flex;
  flex-direction: column;
}

.product-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.58) 0%, rgba(255,255,255,0.12) 22%, rgba(255,255,255,0) 40%),
    radial-gradient(circle at top right, rgba(128, 195, 255, 0.14) 0%, rgba(128, 195, 255, 0) 28%);
  pointer-events: none;
  z-index: 1;
}

.product-card.visible {
  animation: cardEnter 0.5s var(--transition-smooth) forwards;
}

.product-card:hover {
  box-shadow: 0 18px 36px rgba(103, 137, 190, 0.16), 0 8px 18px rgba(103, 137, 190, 0.08);
  border-color: rgba(110, 156, 221, 0.2);
}

.product-card:active {
  transform: scale(0.97);
  box-shadow: var(--shadow-sm);
}

@keyframes cardEnter {
  to { opacity: 1; transform: translateY(0); }
}

.card-image {
  position: relative;
  width: 100%;
  overflow: hidden;
  height: 220px;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.08) 0%, rgba(255,255,255,0.02) 100%),
    var(--card-bg, url('https://cos.fhugc.top/task/cardbg.png')) center center / cover no-repeat;
}

.card-image-inner {
  width: 100%;
  height: 100%;
  display: block;
  background: linear-gradient(145deg, rgba(255,255,255,0.18) 0%, rgba(255,255,255,0.04) 55%, rgba(255,255,255,0.12) 100%);
}

.card-image-inner.h-tall { height: 220px; }
.card-image-inner.h-medium { height: 220px; }
.card-image-inner.h-short { height: 170px; }

.card-image img {
  position: absolute;
  top: 12px;
  left: 12px;
  width: calc(100% - 24px);
  height: calc(100% - 24px);
  object-fit: contain;
  object-position: center;
  transition: transform 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

.card-image::after {
  content: '';
  position: absolute;
  inset: auto 0 0;
  height: 38%;
  background: linear-gradient(180deg, rgba(255,255,255,0) 0%, rgba(228, 239, 255, 0.2) 58%, rgba(228, 239, 255, 0.45) 100%);
  pointer-events: none;
}

.product-card:active .card-image img {
  transform: scale(1.06);
}

.placeholder-icon {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  opacity: 0.18;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  text-align: center;
  color: #4c617f;
  width: 120px;
}

.placeholder-icon svg {
  width: 36px;
  height: 36px;
}

.placeholder-icon span {
  font-size: 11px;
  letter-spacing: 0.6px;
  white-space: nowrap;
}

.card-body {
  position: relative;
  z-index: 2;
  padding: 12px 12px 10px;
  background: linear-gradient(180deg, rgba(255,255,255,0.96) 0%, rgba(250,252,255,0.98) 100%);
  min-height: 104px;
  display: flex;
  flex-direction: column;
  flex: 1;
}

.card-name {
  font-size: 14px;
  font-weight: 600;
  color: #253140;
  line-height: 1.5;
  letter-spacing: 0.3px;
  margin-bottom: 8px;
  min-height: 42px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-action {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 0;
  margin-top: 0;
}

.card-action-text {
  font-size: 11px;
  color: #b08a41;
  font-weight: 500;
  letter-spacing: 1px;
}

.card-action-arrow {
  width: 26px;
  height: 26px;
  background: linear-gradient(135deg, #215cb3, #4f91e8);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 10px 18px rgba(61, 127, 217, 0.28);
  transition: transform var(--transition-fast);
}

.product-card:active .card-action-arrow {
  transform: scale(1.1);
}

.card-action-arrow svg {
  width: 12px;
  height: 12px;
}

/* ===== Image Preview ===== */
.image-preview {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 28px 20px;
  background: rgba(244, 249, 255, 0.25);
  backdrop-filter: blur(10px) saturate(120%);
  -webkit-backdrop-filter: blur(16px) saturate(120%);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-fast);
  z-index: 1200;
}

.image-preview.show {
  opacity: 1;
  pointer-events: auto;
}

.image-preview-panel {
  position: relative;
  width: min(96vw, 500px);
  max-height: min(88vh, 820px);
  padding: 0;
  border-radius: 0;
  background: transparent;
  border: 0;
  box-shadow: none;
  transform: translateY(16px) scale(0.96);
  transition: transform var(--transition-smooth);
  overflow: visible;
}

.image-preview.show .image-preview-panel {
  transform: translateY(0) scale(1);
}

.image-preview-media {
  width: 100%;
  aspect-ratio: 3 / 4;
  border-radius: 0;
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: visible;
  position: relative;
  z-index: 1;
}

.image-preview-media::after {
  content: '';
  position: absolute;
  inset: -2% -8%;
  background: linear-gradient(110deg, rgba(255,255,255,0) 18%, rgba(255,255,255,0.58) 46%, rgba(255,255,255,0) 74%);
  opacity: 0;
  transform: translateX(-72%) skewX(-12deg);
  pointer-events: none;
  mix-blend-mode: screen;
}

.image-preview-media::before {
  content: '';
  position: absolute;
  inset: -4% -10%;
  background: linear-gradient(108deg, rgba(255,255,255,0) 12%, rgba(255,255,255,0.26) 44%, rgba(255,255,255,0) 76%);
  opacity: 0;
  transform: translateX(-66%) skewX(-10deg);
  pointer-events: none;
  mix-blend-mode: screen;
}

.image-preview-media img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
  filter: drop-shadow(0 18px 34px rgba(126, 155, 204, 0.22));
  transform: translateY(6px) scale(0.985);
  opacity: 0;
}

.image-preview.show .image-preview-media img {
  animation:
    previewImageSettle 220ms cubic-bezier(0.16, 1, 0.3, 1) forwards,
    previewImageLift 920ms ease-out 140ms forwards;
}

.image-preview.show .image-preview-media::after {
  animation: previewLightSweep 980ms ease-out 140ms forwards;
}

.image-preview.show .image-preview-media::before {
  animation: previewSoftLightSweep 1120ms ease-out 240ms forwards;
}

@keyframes previewImageSettle {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.975);
    filter: drop-shadow(0 12px 24px rgba(126, 155, 204, 0.14));
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
    filter: drop-shadow(0 18px 34px rgba(126, 155, 204, 0.22));
  }
}

@keyframes previewImageLift {
  0% {
    transform: translateY(0) scale(1);
    filter: drop-shadow(0 18px 34px rgba(126, 155, 204, 0.22));
  }
  42% {
    transform: translateY(-3px) scale(1.01);
    filter: drop-shadow(0 24px 40px rgba(112, 144, 196, 0.26));
  }
  100% {
    transform: translateY(0) scale(1);
    filter: drop-shadow(0 18px 34px rgba(126, 155, 204, 0.22));
  }
}

@keyframes previewLightSweep {
  0% {
    opacity: 0;
    transform: translateX(-72%) skewX(-12deg);
  }
  18% {
    opacity: 0.18;
  }
  44% {
    opacity: 0.38;
  }
  100% {
    opacity: 0;
    transform: translateX(72%) skewX(-12deg);
  }
}

@keyframes previewSoftLightSweep {
  0% {
    opacity: 0;
    transform: translateX(-66%) skewX(-10deg);
  }
  30% {
    opacity: 0.16;
  }
  55% {
    opacity: 0.24;
  }
  100% {
    opacity: 0;
    transform: translateX(66%) skewX(-10deg);
  }
}

/* ===== Empty State ===== */
.empty-state {
  display: none;
  text-align: center;
  padding: 64px 20px;
  color: var(--text-muted);
}

.empty-state.show { display: block; }

.empty-state-icon {
  width: 64px;
  height: 64px;
  margin: 0 auto 16px;
  background: rgba(0, 60, 143, 0.05);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.empty-state-icon svg {
  width: 28px;
  height: 28px;
  opacity: 0.3;
}

.empty-state p {
  font-size: 14px;
  letter-spacing: 1px;
}

.page-toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%) translateY(12px);
  padding: 10px 16px;
  border-radius: 999px;
  background: rgba(30, 57, 100, 0.82);
  color: #fff;
  font-size: 13px;
  letter-spacing: 0.2px;
  box-shadow: 0 12px 28px rgba(29, 56, 103, 0.18);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease, transform 180ms ease;
  z-index: 80;
}

.page-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ===== Footer ===== */
.footer {
  text-align: center;
  padding: 24px 20px 32px;
  border-top: 1px solid var(--border-color);
  background: linear-gradient(180deg, rgba(247, 251, 255, 0) 0%, rgba(237, 245, 255, 0.65) 100%);
}

.footer-brand {
  font-family: "Songti SC", "STSong", "SimSun", serif;
  font-size: 13px;
  color: var(--text-muted);
  letter-spacing: 3px;
  margin-bottom: 4px;
}

.footer-copy {
  font-size: 11px;
  color: var(--text-muted);
  opacity: 0.6;
  letter-spacing: 1px;
}

/* ===== Scroll Progress ===== */
.scroll-progress {
  position: fixed;
  top: 0;
  left: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--brand-blue), var(--brand-gold));
  z-index: 200;
  transform-origin: left;
  transform: scaleX(0);
  transition: none;
}

/* ===== Loading Skeleton ===== */
.skeleton-container {
  max-width: 480px;
  margin: 0 auto;
  padding: 0 12px;
}

.skeleton-tabs {
  display: flex;
  gap: 16px;
  padding: 16px 8px;
}

.skeleton-tab {
  width: 60px;
  height: 14px;
  border-radius: 7px;
  background: linear-gradient(90deg, #eee 25%, #e0e0e0 50%, #eee 75%);
  background-size: 200% 100%;
  animation: skeletonPulse 1.5s ease-in-out infinite;
}

.skeleton-waterfall {
  display: flex;
  gap: 10px;
  padding: 8px 0;
}

.skeleton-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.skeleton-card {
  border-radius: var(--radius-md);
  background: linear-gradient(90deg, #eee 25%, #e0e0e0 50%, #eee 75%);
  background-size: 200% 100%;
  animation: skeletonPulse 1.5s ease-in-out infinite;
}

@keyframes skeletonPulse {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ===== Pull to Refresh ===== */
.pull-indicator {
  position: fixed;
  top: -50px;
  left: 50%;
  transform: translateX(-50%);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--bg-card);
  box-shadow: var(--shadow-md);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 300;
  transition: top 0.2s ease;
}

.pull-indicator.visible {
  top: 12px;
}

.pull-indicator.refreshing svg {
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ===== Reduced Motion ===== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
