/* ===== CSS Variables ===== */
:root {
  --primary: #FF6B6B;
  --primary-dark: #e85555;
  --primary-light: #fff0f0;
  --text-dark: #1A1A1A;
  --text-mid: #555;
  --text-light: #999;
  --border: #e8e8e8;
  --bg-light: #fafafa;
  --white: #fff;
  --shadow-sm: 0 2px 8px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 20px rgba(0,0,0,0.12);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --font: 'DM Sans', 'Noto Sans TC', sans-serif;
  --header-h: 68px;
}

/* ===== Reset ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body { font-family: var(--font); color: var(--text-dark); background: var(--white); -webkit-font-smoothing: antialiased; }
a { text-decoration: none; color: inherit; }
ul { list-style: none; }
img { max-width: 100%; display: block; }
button { cursor: pointer; border: none; background: none; font-family: inherit; }
input { font-family: inherit; }

/* ===== Header ===== */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--white);
  border-bottom: 1px solid var(--border);
  height: var(--header-h);
  display: flex;
  align-items: center;
  transition: box-shadow .2s;
}
.header.scrolled { box-shadow: var(--shadow-md); }
.header-inner {
  max-width: 1440px;
  margin: 0 auto;
  padding: 0 40px;
  width: 100%;
  display: flex;
  align-items: center;
  gap: 32px;
}
.logo {
  font-size: 22px;
  font-weight: 700;
  color: var(--primary);
  letter-spacing: -0.5px;
  flex-shrink: 0;
}
.logo span { color: var(--text-dark); }

/* Desktop Nav */
.nav { display: flex; gap: 4px; }
.nav a {
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  color: var(--text-mid);
  transition: color .2s, background .2s;
  white-space: nowrap;
}
.nav a:hover, .nav a.active { color: var(--primary); background: var(--primary-light); }

/* Search */
.search-wrap {
  flex: 1;
  max-width: 320px;
  position: relative;
}
.search-wrap input {
  width: 100%;
  height: 40px;
  padding: 0 16px 0 40px;
  border: 1.5px solid var(--border);
  border-radius: 20px;
  font-size: 14px;
  outline: none;
  background: var(--bg-light);
  transition: border-color .2s, box-shadow .2s;
}
.search-wrap input:focus { border-color: var(--primary); background: var(--white); box-shadow: 0 0 0 3px rgba(255,107,107,.12); }
.search-wrap .search-icon {
  position: absolute;
  left: 14px; top: 50%;
  transform: translateY(-50%);
  color: var(--text-light);
  pointer-events: none;
}

/* Header Icons */
.header-icons { display: flex; align-items: center; gap: 4px; margin-left: auto; }
.icon-btn {
  width: 40px; height: 40px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-mid);
  transition: background .2s, color .2s;
  position: relative;
}
.icon-btn:hover { background: var(--bg-light); color: var(--primary); }
.icon-btn .badge {
  position: absolute;
  top: 4px; right: 4px;
  width: 17px; height: 17px;
  background: var(--primary);
  color: var(--white);
  font-size: 10px;
  font-weight: 700;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  border: 2px solid var(--white);
  transition: transform .2s;
}
.icon-btn .badge.bump { transform: scale(1.4); }
.avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary) 0%, #FFB347 100%);
  display: flex; align-items: center; justify-content: center;
  color: var(--white); font-size: 13px; font-weight: 700;
  cursor: pointer; margin-left: 4px;
}

/* Hamburger */
.hamburger { display: none; flex-direction: column; gap: 5px; padding: 8px; }
.hamburger span {
  width: 22px; height: 2px;
  background: var(--text-dark);
  border-radius: 2px;
  transition: transform .25s, opacity .25s;
}
.hamburger.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.hamburger.open span:nth-child(2) { opacity: 0; }
.hamburger.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* Mobile Menu */
.mobile-menu {
  display: none;
  position: fixed;
  top: var(--header-h); left: 0; right: 0; bottom: 0;
  background: var(--white);
  z-index: 99;
  flex-direction: column;
  padding: 24px 24px 40px;
  gap: 8px;
  overflow-y: auto;
  transform: translateX(-100%);
  transition: transform .3s ease;
}
.mobile-menu.open { transform: translateX(0); }
.mobile-menu a {
  padding: 14px 16px;
  font-size: 16px;
  font-weight: 500;
  border-radius: var(--radius-md);
  color: var(--text-dark);
  border-bottom: 1px solid var(--border);
}
.mobile-menu a:hover, .mobile-menu a.active { color: var(--primary); background: var(--primary-light); }
.mobile-search {
  margin-bottom: 8px;
  position: relative;
}
.mobile-search input {
  width: 100%;
  height: 44px;
  padding: 0 16px 0 44px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 15px;
  outline: none;
}
.mobile-search input:focus { border-color: var(--primary); }
.mobile-search .search-icon { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--text-light); }

/* ===== Hero ===== */
.hero {
  position: relative;
  height: 540px;
  overflow: hidden;
  display: flex; align-items: center;
}
.hero-img {
  position: absolute; inset: 0;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 40%, #f093fb 100%);
  background-image: url('https://images.unsplash.com/photo-1556742049-0cfed4f6a45d?w=1440&q=80');
  background-size: cover; background-position: center;
}
.hero-overlay {
  position: absolute; inset: 0;
  background: linear-gradient(90deg, rgba(26,26,26,.75) 0%, rgba(26,26,26,.2) 60%, transparent 100%);
}
.hero-content {
  position: relative;
  z-index: 2;
  padding: 0 80px;
  max-width: 620px;
}
.hero-badge {
  display: inline-block;
  background: var(--primary);
  color: var(--white);
  font-size: 12px; font-weight: 700;
  padding: 4px 12px;
  border-radius: 20px;
  margin-bottom: 16px;
  letter-spacing: .5px;
  text-transform: uppercase;
}
.hero h1 {
  font-size: 48px; font-weight: 700; line-height: 1.15;
  color: var(--white);
  margin-bottom: 16px;
  text-shadow: 0 2px 12px rgba(0,0,0,.3);
}
.hero p {
  font-size: 17px; color: rgba(255,255,255,.85);
  margin-bottom: 28px; line-height: 1.6;
}
.hero-actions { display: flex; gap: 12px; flex-wrap: wrap; }
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 13px 28px;
  border-radius: 24px;
  font-size: 15px; font-weight: 600;
  transition: transform .15s, box-shadow .15s, background .15s;
}
.btn:active { transform: scale(.97); }
.btn-primary {
  background: var(--primary); color: var(--white);
  box-shadow: 0 4px 16px rgba(255,107,107,.45);
}
.btn-primary:hover { background: var(--primary-dark); box-shadow: 0 6px 20px rgba(255,107,107,.55); transform: translateY(-1px); }
.btn-outline {
  background: rgba(255,255,255,.15);
  color: var(--white);
  border: 1.5px solid rgba(255,255,255,.5);
  backdrop-filter: blur(8px);
}
.btn-outline:hover { background: rgba(255,255,255,.25); }

/* ===== Section Layout ===== */
.section { padding: 64px 0; }
.section-alt { background: var(--bg-light); }
.container { max-width: 1440px; margin: 0 auto; padding: 0 40px; }
.section-header { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 32px; }
.section-title { font-size: 26px; font-weight: 700; }
.section-link { font-size: 14px; color: var(--primary); font-weight: 500; }
.section-link:hover { text-decoration: underline; }

/* ===== Categories ===== */
.categories-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 16px;
}
.cat-card {
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  padding: 20px 8px;
  background: var(--white);
  border-radius: var(--radius-lg);
  border: 1.5px solid var(--border);
  cursor: pointer;
  transition: border-color .2s, box-shadow .2s, transform .15s;
}
.cat-card:hover { border-color: var(--primary); box-shadow: var(--shadow-sm); transform: translateY(-2px); }
.cat-card.active { border-color: var(--primary); background: var(--primary-light); }
.cat-icon {
  width: 52px; height: 52px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
}
.cat-card span { font-size: 13px; font-weight: 500; text-align: center; }

/* ===== Product Cards ===== */
.products-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 24px;
}
.product-card {
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--white);
  border: 1.5px solid var(--border);
  transition: box-shadow .2s, transform .2s;
  cursor: pointer;
}
.product-card:hover { box-shadow: var(--shadow-md); transform: translateY(-4px); }
.product-img-wrap {
  position: relative;
  aspect-ratio: 1;
  overflow: hidden;
  background: #f0f0f0;
}
.product-img-wrap img {
  width: 100%; height: 100%;
  object-fit: cover;
  transition: transform .4s ease;
}
.product-card:hover .product-img-wrap img { transform: scale(1.06); }
.wish-btn {
  position: absolute; top: 10px; right: 10px;
  width: 34px; height: 34px;
  border-radius: 50%;
  background: rgba(255,255,255,.9);
  backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-light);
  transition: color .2s, background .2s, transform .15s;
  z-index: 1;
}
.wish-btn:hover { color: var(--primary); transform: scale(1.1); }
.wish-btn.active { color: var(--primary); }
.wish-btn.active svg { fill: var(--primary); }
.product-badge {
  position: absolute; bottom: 10px; left: 10px;
  background: var(--primary); color: var(--white);
  font-size: 11px; font-weight: 700;
  padding: 3px 8px; border-radius: 4px;
}
.product-info { padding: 14px; }
.product-brand { font-size: 11px; color: var(--primary); font-weight: 600; text-transform: uppercase; letter-spacing: .5px; margin-bottom: 4px; }
.product-name { font-size: 14px; font-weight: 500; color: var(--text-dark); margin-bottom: 8px; line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.product-price-row { display: flex; align-items: center; gap: 8px; }
.product-price { font-size: 16px; font-weight: 700; color: var(--text-dark); }
.product-price-orig { font-size: 13px; color: var(--text-light); text-decoration: line-through; }
.product-rating { display: flex; align-items: center; gap: 4px; font-size: 12px; color: var(--text-light); margin-top: 6px; }
.stars { color: #FFB347; }
.add-cart-btn {
  display: flex; align-items: center; justify-content: center;
  width: 100%; padding: 10px;
  background: var(--primary-light);
  color: var(--primary);
  font-size: 13px; font-weight: 600;
  border-top: 1px solid var(--border);
  gap: 6px;
  transition: background .2s, color .2s;
}
.add-cart-btn:hover { background: var(--primary); color: var(--white); }
.add-cart-btn.added { background: var(--primary); color: var(--white); }

/* ===== Promo Banner ===== */
.promo-banner {
  background: linear-gradient(135deg, var(--primary) 0%, #FFB347 100%);
  border-radius: var(--radius-lg);
  padding: 48px 60px;
  display: flex; align-items: center; justify-content: space-between;
  position: relative; overflow: hidden;
}
.promo-banner::before, .promo-banner::after {
  content: '';
  position: absolute;
  border-radius: 50%;
  background: rgba(255,255,255,.12);
}
.promo-banner::before { width: 300px; height: 300px; top: -100px; right: -60px; }
.promo-banner::after { width: 180px; height: 180px; bottom: -60px; right: 120px; }
.promo-text h2 { font-size: 36px; font-weight: 700; color: var(--white); margin-bottom: 8px; }
.promo-text p { font-size: 16px; color: rgba(255,255,255,.85); }
.promo-banner .btn-outline { color: var(--white); border-color: rgba(255,255,255,.6); position: relative; z-index: 1; }

/* ===== Footer ===== */
.footer { background: var(--text-dark); color: rgba(255,255,255,.7); padding: 60px 0 0; }
.footer-grid { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr; gap: 40px; padding-bottom: 40px; }
.footer-brand .logo { color: var(--primary); margin-bottom: 12px; font-size: 20px; }
.footer-brand p { font-size: 14px; line-height: 1.7; max-width: 240px; }
.footer-col h4 { font-size: 13px; font-weight: 700; color: var(--white); text-transform: uppercase; letter-spacing: .8px; margin-bottom: 16px; }
.footer-col ul { display: flex; flex-direction: column; gap: 10px; }
.footer-col ul li a { font-size: 14px; color: rgba(255,255,255,.6); transition: color .2s; }
.footer-col ul li a:hover { color: var(--white); }
.social-links { display: flex; gap: 12px; margin-top: 20px; }
.social-btn {
  width: 38px; height: 38px;
  border-radius: 50%;
  border: 1.5px solid rgba(255,255,255,.2);
  display: flex; align-items: center; justify-content: center;
  color: rgba(255,255,255,.7);
  font-size: 14px; font-weight: 700;
  transition: border-color .2s, color .2s;
}
.social-btn:hover { border-color: var(--primary); color: var(--primary); }
.footer-bottom {
  border-top: 1px solid rgba(255,255,255,.1);
  padding: 20px 0;
  display: flex; align-items: center; justify-content: space-between;
  font-size: 13px;
}

/* ===== Product Listing Page ===== */
.breadcrumb { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--text-light); padding: 20px 0; }
.breadcrumb a { color: var(--text-light); transition: color .2s; }
.breadcrumb a:hover { color: var(--primary); }
.breadcrumb-sep { color: var(--border); }
.breadcrumb .current { color: var(--text-dark); font-weight: 500; }

.listing-layout { display: flex; gap: 32px; align-items: flex-start; }

/* Sidebar */
.sidebar {
  width: 240px;
  flex-shrink: 0;
  position: sticky;
  top: calc(var(--header-h) + 20px);
}
.sidebar-section { margin-bottom: 28px; }
.sidebar-title { font-size: 14px; font-weight: 700; margin-bottom: 14px; padding-bottom: 10px; border-bottom: 1px solid var(--border); }
.filter-item {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 0; cursor: pointer;
  font-size: 14px; color: var(--text-mid);
}
.filter-item:hover { color: var(--primary); }
.filter-item input[type="checkbox"] { accent-color: var(--primary); width: 15px; height: 15px; cursor: pointer; }
.filter-item.active { color: var(--primary); font-weight: 600; }
.price-range-wrap { padding: 8px 0; }
.price-range {
  width: 100%; -webkit-appearance: none;
  height: 4px;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--primary) var(--val, 60%), var(--border) var(--val, 60%));
  outline: none;
}
.price-range::-webkit-slider-thumb { -webkit-appearance: none; width: 18px; height: 18px; border-radius: 50%; background: var(--primary); cursor: pointer; box-shadow: 0 2px 6px rgba(255,107,107,.4); }
.price-display { display: flex; justify-content: space-between; font-size: 13px; color: var(--text-mid); margin-top: 10px; }
.clear-filters { width: 100%; padding: 10px; border: 1.5px solid var(--border); border-radius: var(--radius-sm); font-size: 13px; color: var(--text-mid); font-weight: 500; transition: border-color .2s, color .2s; }
.clear-filters:hover { border-color: var(--primary); color: var(--primary); }

/* Product Listing Main */
.listing-main { flex: 1; min-width: 0; }
.listing-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 24px; flex-wrap: wrap; gap: 12px;
}
.listing-title { font-size: 22px; font-weight: 700; }
.listing-meta { font-size: 14px; color: var(--text-light); margin-top: 2px; }
.sort-wrap { display: flex; align-items: center; gap: 8px; }
.sort-label { font-size: 14px; color: var(--text-mid); }
.sort-select {
  padding: 8px 32px 8px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: var(--font);
  background: var(--white);
  color: var(--text-dark);
  outline: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23999' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  cursor: pointer;
}
.sort-select:focus { border-color: var(--primary); }
.products-grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}

/* Mobile Filter Drawer */
.filter-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.4);
  z-index: 200;
}
.filter-overlay.open { display: block; }
.filter-drawer {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: var(--white);
  border-radius: 20px 20px 0 0;
  padding: 24px;
  z-index: 201;
  max-height: 85vh;
  overflow-y: auto;
  transform: translateY(100%);
  transition: transform .3s ease;
}
.filter-drawer.open { transform: translateY(0); }
.filter-drawer-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.filter-drawer-header h3 { font-size: 17px; font-weight: 700; }
.close-drawer { width: 32px; height: 32px; border-radius: 50%; background: var(--bg-light); display: flex; align-items: center; justify-content: center; }

/* Filter Tags */
.filter-tags { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.filter-tag {
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 13px; font-weight: 500;
  border: 1.5px solid var(--border);
  color: var(--text-mid);
  cursor: pointer;
  transition: border-color .2s, color .2s, background .2s;
}
.filter-tag:hover, .filter-tag.active { border-color: var(--primary); color: var(--primary); background: var(--primary-light); }

/* Mobile Bottom Nav */
.mobile-bottom-nav {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: var(--white);
  border-top: 1px solid var(--border);
  padding: 8px 0 calc(8px + env(safe-area-inset-bottom));
  z-index: 90;
  box-shadow: 0 -4px 20px rgba(0,0,0,.08);
}
.bottom-nav-inner { display: flex; justify-content: space-around; }
.bottom-nav-item {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 4px 12px;
  color: var(--text-light);
  font-size: 11px;
  cursor: pointer;
  transition: color .2s;
}
.bottom-nav-item.active { color: var(--primary); }
.bottom-nav-item svg { width: 22px; height: 22px; }

/* ===== Toast ===== */
.toast {
  position: fixed; bottom: 80px; left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--text-dark);
  color: var(--white);
  padding: 12px 20px;
  border-radius: 24px;
  font-size: 14px; font-weight: 500;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
  z-index: 300;
  white-space: nowrap;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ===== Back to Top ===== */
.back-top {
  position: fixed; bottom: 32px; right: 32px;
  width: 44px; height: 44px;
  background: var(--primary);
  color: var(--white);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow-md);
  opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .2s;
  z-index: 80;
}
.back-top.visible { opacity: 1; pointer-events: auto; }
.back-top:hover { transform: translateY(-2px); }

/* ===== Responsive ===== */
@media (max-width: 1200px) {
  .categories-grid { grid-template-columns: repeat(4, 1fr); }
  .products-grid { grid-template-columns: repeat(3, 1fr); }
  .footer-grid { grid-template-columns: 1fr 1fr; gap: 32px; }
}

@media (max-width: 960px) {
  .header-inner { padding: 0 24px; gap: 16px; }
  .nav { display: none; }
  .search-wrap { display: none; }
  .hamburger { display: flex; }
  .mobile-menu { display: flex; }
  .hero { height: 420px; }
  .hero h1 { font-size: 34px; }
  .hero-content { padding: 0 40px; }
  .container { padding: 0 24px; }
  .products-grid { grid-template-columns: repeat(2, 1fr); }
  .products-grid-3 { grid-template-columns: repeat(2, 1fr); }
  .listing-layout { flex-direction: column; }
  .sidebar { width: 100%; position: static; display: none; }
  .sidebar.mobile-open { display: block; }
  .mobile-bottom-nav { display: block; }
  body { padding-bottom: 64px; }
  .promo-banner { flex-direction: column; text-align: center; padding: 40px 32px; gap: 20px; }
  .promo-text h2 { font-size: 28px; }
}

@media (max-width: 640px) {
  .section { padding: 40px 0; }
  .hero { height: 340px; }
  .hero h1 { font-size: 26px; }
  .hero p { font-size: 15px; }
  .hero-content { padding: 0 24px; max-width: 100%; }
  .hero-actions { gap: 10px; }
  .btn { padding: 11px 22px; font-size: 14px; }
  .section-title { font-size: 20px; }
  .categories-grid { grid-template-columns: repeat(4, 1fr); gap: 10px; }
  .cat-card { padding: 14px 6px; }
  .cat-icon { width: 44px; height: 44px; font-size: 18px; }
  .cat-card span { font-size: 11px; }
  .footer-grid { grid-template-columns: 1fr; gap: 24px; }
  .footer-brand p { max-width: 100%; }
  .footer-bottom { flex-direction: column; gap: 12px; text-align: center; }
  .back-top { bottom: 80px; right: 16px; }
  .toast { bottom: 90px; font-size: 13px; }
}
