:root {
  --purple-900: #1E1B4B;
  --purple-700: #4338CA;
  --purple-600: #4F46E5;
  --purple-500: #6366F1;
  --purple-400: #A5B4FC;
  --purple-100: #EEF2FF;
  --pink-500: #F0245C;
  --pink-100: #FDE6ED;
  --gold-500: #C9A227;
  --gold-100: #FBF3D9;
  --profile-pink: #EC4899;
  --profile-hotpink: #F5005B;
  --profile-orange: #FF5A1F;
  --profile-avatar: #F0492B;
  --stat-green-bg: #E3F8EA;
  --stat-green-fg: #16A34A;
  --stat-red-bg: #FBE2E2;
  --stat-red-fg: #FF524A;
  --stat-pink-bg: #FCE0EA;
  --stat-pink-fg: #EC4899;
  --stat-gold-bg: #FDECC8;
  --stat-gold-fg: #F59E0B;
  --ink-900: #14132B;
  --ink-600: #5B5A78;
  --ink-400: #9795B5;
  --paper: #F6F6FB;
  --white: #FFFFFF;
  --success: #16A34A;
  --warn: #C9A227;
  --danger: #DC2626;
  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --shadow-soft: 0 14px 34px rgba(30, 27, 75, 0.22);
  --shadow-card: 0 4px 16px rgba(20, 19, 43, 0.06);
  font-size: 16px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--ink-900);
  overscroll-behavior-y: none;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans Thai", "Sarabun", Tahoma, sans-serif;
  color: var(--ink-900);
  -webkit-tap-highlight-color: transparent;
}

#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  background: var(--paper);
  position: relative;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Default: no bottom nav bar on most pages (chat, cart, checkout, wallet, orders,
   referral, etc.), so a small normal page-end margin is enough — this used to be a
   flat 88px on every single page "just in case", which was pure wasted blank space
   everywhere except the handful of pages that actually have a nav bar overlapping
   the bottom of the screen. Those pages opt back into real nav clearance below. */
.view { display: none; flex-direction: column; flex: 1; min-height: 100vh; padding-bottom: 20px; animation: fadeIn .25s ease; }
.view.active { display: flex; }

/* Pages that actually render a <div class="bottom-nav"> (see buildShopBottomNav in
   app.js) need real clearance so their content doesn't end up hidden underneath it —
   sized to the nav's actual rendered height + safe-area, not a rough guess. */
#view-report.view, #view-kb.view, #view-history.view, #view-profile.view,
#view-products.view, #view-withdraw.view, #view-topup.view {
  padding-bottom: calc(68px + env(safe-area-inset-bottom));
}

@keyframes fadeIn { from { opacity: 0; transform: translateY(6px);} to { opacity: 1; transform: none; } }

/* ---------- Top bar ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px; background: var(--white);
  position: sticky; top: 0; z-index: 20;
  border-bottom: 1px solid rgba(26,26,46,0.06);
}
.topbar .brand { display: flex; align-items: center; gap: 10px; font-weight: 700; }
.brand-store-badge {
  background: var(--ink-900); color: white; font-size: 10px; font-weight: 800; letter-spacing: .2px;
  padding: 3px 8px; border-radius: 6px; text-transform: lowercase;
}
.topbar .brand .logo {
  width: 34px; height: 34px; border-radius: 10px;
  background: linear-gradient(155deg, var(--purple-600), var(--pink-500));
  display: flex; align-items: center; justify-content: center; color: white; font-size: 16px;
}
.topbar .actions { display: flex; gap: 14px; align-items: center; }
.icon-btn { position: relative; background: none; border: none; font-size: 20px; cursor: pointer; color: var(--ink-600); }
.badge-dot {
  position: absolute; top: -4px; right: -6px; background: var(--danger); color: white;
  font-size: 10px; font-weight: 700; border-radius: 20px; padding: 1px 5px; min-width: 16px; text-align: center;
}
.back-btn { background: none; border: none; font-size: 20px; cursor: pointer; color: var(--ink-900); padding: 4px 8px 4px 0; }
.topbar-title { font-weight: 700; font-size: 17px; }

/* ---------- Scrollable content ---------- */
.content { padding: 16px 18px 24px; overflow-y: auto; flex: 1; }

/* ---------- Hero card ---------- */
.hero {
  background: linear-gradient(120deg, var(--purple-700), var(--purple-600) 55%, var(--pink-500) 130%);
  border-radius: var(--radius-lg);
  padding: 22px 20px;
  color: white;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-soft);
}
.hero::before {
  content: ""; position: absolute; inset: 0;
  background-image: repeating-linear-gradient(45deg, rgba(255,255,255,0.05) 0, rgba(255,255,255,0.05) 2px, transparent 2px, transparent 14px);
  pointer-events: none;
}
.hero::after {
  content: ""; position: absolute; width: 180px; height: 180px; border-radius: 50%;
  background: rgba(255,255,255,0.10); right: -60px; top: -70px;
}
.hero .hero-badge {
  position: absolute; top: 14px; right: 14px; background: var(--ink-900); color: #FFD84D;
  font-size: 10.5px; font-weight: 800; padding: 4px 10px; border-radius: 20px; letter-spacing: .3px;
  display: flex; align-items: center; gap: 4px; box-shadow: 0 3px 8px rgba(0,0,0,0.25);
}
.hero h1 { margin: 0 0 4px; font-size: 20px; font-weight: 800; }
.hero p { margin: 0; font-size: 13.5px; opacity: 0.95; line-height: 1.5; }
.hero .avatar-badge {
  position: absolute; right: 18px; bottom: 14px; width: 46px; height: 46px; border-radius: 50%;
  background: rgba(255,255,255,0.2); display: flex; align-items: center; justify-content: center; font-size: 22px;
  border: 2px solid rgba(255,255,255,0.35);
}

/* ---------- Menu grid ---------- */
.menu-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 18px; }
.menu-tile {
  background: var(--white); border-radius: var(--radius-md); padding: 16px 14px;
  box-shadow: var(--shadow-card); display: flex; flex-direction: column; gap: 10px;
  cursor: pointer; border: none; text-align: left; font-family: inherit;
}
.menu-tile.shop-tile { grid-column: 1 / -1; flex-direction: row; align-items: center; background: linear-gradient(120deg, var(--purple-700), var(--pink-500)); }
.menu-tile.shop-tile .ico { width: 48px; height: 48px; font-size: 22px; }
.menu-tile.shop-tile .label { color: white; font-size: 15px; }
.menu-tile.shop-tile small { color: rgba(255,255,255,0.85); }
.menu-tile .ico {
  width: 40px; height: 40px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 19px; color: white;
}
.menu-tile span.label { font-weight: 700; font-size: 14px; color: var(--ink-900); }
.menu-tile small { color: var(--ink-400); font-size: 11.5px; }

/* ---------- Shop (Lazmall) ---------- */
.shop-topbar .logo.shop-logo { background: linear-gradient(135deg, var(--purple-700), var(--pink-500)); }
.shop-banner {
  background: radial-gradient(120% 160% at 15% 15%, #FF6A5A 0%, #E11D2E 42%, #A80F1F 100%);
  border-radius: var(--radius-lg); padding: 20px; color: white; position: relative; overflow: hidden;
  box-shadow: var(--shadow-soft); margin-bottom: 6px; display: flex; flex-direction: column; justify-content: center;
}
.shop-banner::before {
  content: ""; position: absolute; inset: 0;
  background-image: repeating-linear-gradient(45deg, rgba(255,255,255,0.05) 0, rgba(255,255,255,0.05) 2px, transparent 2px, transparent 14px);
}
.shop-banner-badge { display: inline-block; background: var(--gold-500); color: #3A1400; border: 1px solid rgba(255,255,255,0.35); font-size: 10.5px; font-weight: 800; padding: 4px 11px; border-radius: 20px; margin-bottom: 10px; letter-spacing: .2px; position: relative; }
.shop-banner h2 { margin: 0 0 4px; font-size: 22px; font-weight: 900; position: relative; text-shadow: 0 2px 10px rgba(0,0,0,0.25); }
.shop-banner p { margin: 0 0 12px; font-size: 12.5px; opacity: 0.95; position: relative; }
.shop-banner .sb-cta { position: relative; align-self: flex-start; background: var(--ink-900); color: white; font-size: 11.5px; font-weight: 800; padding: 8px 16px; border-radius: 20px; }

/* Floating pill nav — the shop page's nav on both mobile and desktop, replacing
   the old icon bottom-nav bar. Pinned to the bottom edge and always visible,
   so it "follows" as the page scrolls.

   Bug fixed: `.content`'s own padding-bottom (90px + safe-area) and `.view`'s
   own padding-bottom (90px) were BOTH reserving clearance for the same pill nav
   at the same time — since `.content` sits inside `.view`, those two stack
   instead of overlapping, reserving ~180px + safe-area when the pill itself
   (16px offset + ~46px tall) only needs about 70px. That's what was showing up
   as the large empty gap below the footer on this page specifically (the same
   double-stacking bug was already fixed on the profile page, but this page has
   its own separate set of clearance rules that hadn't been touched yet).
   Same sticky-footer treatment as the profile page: push `.shop-footer-full`
   down via margin-top:auto rather than relying on padding to create empty space. */
#view-shop .bottom-nav { display: none; }
#view-shop .content { display: flex; flex-direction: column; padding-bottom: 0; }
#view-shop .shop-footer-full { margin-top: auto; margin-bottom: 0; }
#view-shop.view { padding-bottom: calc(76px + env(safe-area-inset-bottom)); }
.shop-sticky-nav {
  display: block; position: fixed; left: 50%; bottom: calc(16px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  width: calc(100% - 32px); max-width: 640px; z-index: 60;
}
.shop-sticky-nav .ssn-inner {
  background: var(--white); border-radius: 999px; box-shadow: var(--shadow-soft);
  display: flex; align-items: center; justify-content: space-between; gap: 2px;
  padding: 5px; overflow-x: auto; scrollbar-width: none;
}
.shop-sticky-nav .ssn-inner::-webkit-scrollbar { display: none; }
.ssn-item {
  flex: 1; background: none; border: none; font-family: inherit; cursor: pointer; white-space: nowrap;
  font-size: 12px; font-weight: 700; color: var(--ink-600); padding: 10px 12px; border-radius: 999px;
  transition: background .15s, color .15s;
}
.ssn-item.active { background: linear-gradient(120deg, #FCE7F0, #FBD5E4); color: #DB2777; }

/* ---------- Dedicated "สินค้า" (products) page — separate from หน้าหลัก ---------- */
.products-topbar {
  display: flex; align-items: center; gap: 10px; padding: 10px 14px; background: white; position: relative;
}
.products-topbar::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 3px;
  background: linear-gradient(90deg, #E11D2E, #FF6A9C);
}
.products-hot-badge { flex-shrink: 0; background: linear-gradient(120deg, #FF3B5C, #E11D2E); color: white; font-size: 11px; font-weight: 900; padding: 6px 10px; border-radius: 8px; letter-spacing: .3px; }
.products-search-input { flex: 1; min-width: 0; border: none; outline: none; background: none; font-size: 13px; font-family: inherit; color: var(--ink-900); }
.products-search-input::placeholder { color: var(--ink-400); }
.products-camera-btn { flex-shrink: 0; background: none; border: none; font-size: 18px; line-height: 1; cursor: pointer; color: var(--ink-500); padding: 0; }
.products-search-btn { flex-shrink: 0; background: linear-gradient(120deg, #FF3B5C, #E11D2E); color: white; border: none; border-radius: 20px; padding: 9px 18px; font-size: 12.5px; font-weight: 800; cursor: pointer; font-family: inherit; }
.view-all-products-btn {
  display: block; width: 100%; margin: 4px 0 18px; background: white; border: 1.5px solid #F3D2DE; color: var(--pink-500);
  font-size: 13px; font-weight: 800; padding: 12px; border-radius: var(--radius-md); cursor: pointer; font-family: inherit; box-shadow: var(--shadow-card);
}
/* Full-width banner on the products page (no side promo-cards column, matches the reference design) */
.products-banner-full { margin-bottom: 16px; }
.products-banner-full .shop-banner { min-height: 200px; }

/* Two large promo image cards under หมวดหมู่ทั่วไป */
.promo-image-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 18px; }
.promo-img-card { display: block; border-radius: var(--radius-md); overflow: hidden; box-shadow: var(--shadow-card); aspect-ratio: 1/1; background: var(--paper); }
.promo-img-card img { width: 100%; height: 100%; object-fit: cover; display: block; }
.promo-img-placeholder {
  width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; text-align: center; padding: 12px;
  background: linear-gradient(135deg, var(--purple-600), var(--pink-500)); color: white; font-weight: 800; font-size: 13px;
}
.hero-row { display: flex; gap: 8px; align-items: stretch; }
.hero-row .home-hero-banner { flex: 2; min-width: 0; }
.hero-row .home-hero-banner .shop-banner { height: 100%; margin-bottom: 0; }
/* Image banners size to the uploaded image's own aspect ratio (no cropping, no letterbox
   background) — width fills the column, height follows naturally from the image itself. */
.hero-row .home-hero-banner-link { display: block; width: 100%; }
.hero-row .home-hero-banner-img { display: block; width: 100%; height: auto; border-radius: var(--radius-lg); }
.promo-cards-col { flex: 1; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.promo-card { flex: 1; border-radius: var(--radius-md); padding: 10px 12px; display: flex; flex-direction: column; justify-content: center; gap: 3px; color: white; cursor: pointer; box-shadow: var(--shadow-card); }
.promo-card .pc-title { font-size: 12px; font-weight: 800; }
.promo-card .pc-sub { font-size: 9.5px; opacity: .92; line-height: 1.3; }
.promo-card-a { background: linear-gradient(135deg, var(--purple-700), var(--purple-500)); }
.promo-card-b { background: linear-gradient(135deg, #EA580C, #F59E0B); }

/* Trust badge strip below stats */
.trust-badge-row { display: flex; justify-content: space-between; gap: 4px; padding: 2px 2px 14px; }
.trust-badge { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 5px; text-align: center; }
.trust-badge .tb-ico { width: 34px; height: 34px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 15px; }
.trust-badge span:last-child { font-size: 9px; font-weight: 700; color: var(--ink-600); line-height: 1.25; }

.cat-scroll { display: flex; gap: 10px; overflow-x: auto; padding: 4px 2px 6px; margin-top: 14px; scrollbar-width: none; }
.cat-scroll::-webkit-scrollbar { display: none; }
.cat-chip { flex-shrink: 0; display: flex; flex-direction: column; align-items: center; gap: 6px; cursor: pointer; width: 64px; }
.cat-chip .cc-ico { width: 52px; height: 52px; border-radius: 16px; background: white; box-shadow: var(--shadow-card); display: flex; align-items: center; justify-content: center; font-size: 24px; border: 2px solid transparent; }
.cat-chip.active .cc-ico { border-color: var(--purple-600); background: var(--purple-100); }
.cat-chip span { font-size: 10.5px; font-weight: 700; text-align: center; color: var(--ink-600); line-height: 1.2; }

.product-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 10px; }

/* Real product photos inside any image container (pc-image, pt-image, pd-image, ci-image, fp-icon).
   Falls back to the emoji icon (.prod-fallback-icon) when no photo is set or it fails to load. */
.prod-photo { width: 100%; height: 100%; object-fit: cover; display: block; }
.prod-fallback-icon { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; }

.product-card { background: white; border-radius: var(--radius-md); overflow: hidden; box-shadow: var(--shadow-card); cursor: pointer; }
.product-card .pc-image { height: 110px; display: flex; align-items: center; justify-content: center; font-size: 44px; background: var(--purple-100); position: relative; overflow: hidden; }
.product-card .pc-discount { position: absolute; top: 8px; left: 8px; background: var(--pink-500); color: white; font-size: 10px; font-weight: 800; padding: 3px 7px; border-radius: 6px; }
.product-card .pc-body { padding: 10px; }
.product-card .pc-name { font-size: 12.5px; font-weight: 600; color: var(--ink-900); line-height: 1.35; margin-bottom: 6px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 34px; }
.product-card .pc-price-row { display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; }
.product-card .pc-price { font-size: 15px; font-weight: 800; color: var(--pink-500); }
.product-card .pc-compare { font-size: 10.5px; color: var(--ink-400); text-decoration: line-through; }
.product-card .pc-meta { display: flex; justify-content: space-between; align-items: center; margin-top: 5px; font-size: 10px; color: var(--ink-400); }

/* Product detail */
.pd-image { width: 100%; aspect-ratio: 1.3; border-radius: var(--radius-lg); background: var(--purple-100); display: flex; align-items: center; justify-content: center; font-size: 90px; margin-bottom: 16px; overflow: hidden; position: relative; }

/* ---------- Lightweight loading skeleton (product detail deep-link fallback) ---------- */
@keyframes skelShimmer { 0% { background-position: -120% 0; } 100% { background-position: 120% 0; } }
.skel-block, .skel-line {
  background: linear-gradient(90deg, var(--paper) 25%, #ECEBF7 37%, var(--paper) 63%);
  background-size: 400% 100%;
  animation: skelShimmer 1.4s ease infinite;
  border-radius: var(--radius-sm);
}
.skel-block.pd-image { background-color: transparent; }
.skel-line { display: block; border-radius: 8px; }
.pd-name { font-size: 17px; font-weight: 800; margin: 0 0 8px; }
.pd-price-row { display: flex; align-items: baseline; gap: 10px; margin-bottom: 10px; }
.pd-price { font-size: 24px; font-weight: 800; color: var(--pink-500); }
.pd-compare { font-size: 14px; color: var(--ink-400); text-decoration: line-through; }
.pd-discount-badge { background: var(--pink-100); color: var(--pink-500); font-size: 11px; font-weight: 800; padding: 3px 8px; border-radius: 6px; }
.pd-meta-row { display: flex; gap: 16px; font-size: 12px; color: var(--ink-400); margin-bottom: 16px; }
.pd-desc { font-size: 13px; color: var(--ink-600); line-height: 1.7; margin-bottom: 20px; }
.pd-qty-row { display: flex; align-items: center; gap: 14px; margin-bottom: 20px; }
.qty-stepper { display: flex; align-items: center; border: 1.5px solid #E5E5E5; border-radius: 10px; overflow: hidden; }
.qty-stepper button { width: 36px; height: 36px; border: none; background: var(--paper); font-size: 16px; cursor: pointer; }
.qty-stepper span { width: 40px; text-align: center; font-weight: 700; font-size: 14px; }
.pd-actions { display: flex; gap: 10px; position: sticky; bottom: 0; background: var(--paper); padding-top: 10px; }

/* Cart */
.cart-item { display: flex; gap: 12px; background: white; border-radius: var(--radius-md); padding: 12px; margin-bottom: 10px; box-shadow: var(--shadow-card); align-items: center; }
.cart-item .ci-image { width: 56px; height: 56px; min-width: 56px; border-radius: 12px; background: var(--purple-100); display: flex; align-items: center; justify-content: center; font-size: 26px; overflow: hidden; position: relative; }
.cart-item .ci-body { flex: 1; min-width: 0; }
.cart-item .ci-name { font-size: 12.5px; font-weight: 700; margin-bottom: 4px; }
.cart-item .ci-price { font-size: 13px; font-weight: 800; color: var(--pink-500); }
.cart-item .ci-remove { background: none; border: none; color: var(--ink-400); font-size: 16px; cursor: pointer; padding: 4px; }
.cart-summary-bar { position: fixed; bottom: 0; left: 50%; transform: translateX(-50%); width: 100%; max-width: 480px; background: white; padding: 14px 18px calc(14px + env(safe-area-inset-bottom)); box-shadow: 0 -6px 20px rgba(0,0,0,0.08); display: flex; align-items: center; gap: 14px; }
.cart-summary-bar .cs-total { flex: 1; }
.cart-summary-bar .cs-total .cs-label { font-size: 10.5px; color: var(--ink-400); }
.cart-summary-bar .cs-total .cs-value { font-size: 18px; font-weight: 800; color: var(--pink-500); }
.cart-summary-bar button { flex-shrink: 0; width: auto; padding: 13px 24px; }

/* Checkout */
.checkout-section { background: white; border-radius: var(--radius-md); padding: 14px; margin-bottom: 12px; box-shadow: var(--shadow-card); }
.checkout-section h3 { margin: 0 0 10px; font-size: 13px; }
.checkout-row { display: flex; justify-content: space-between; font-size: 13px; padding: 6px 0; }
.checkout-row.total { font-weight: 800; font-size: 15px; border-top: 1px dashed #E5E5E5; margin-top: 6px; padding-top: 12px; color: var(--pink-500); }
.wallet-mini { display: flex; align-items: center; justify-content: space-between; background: var(--purple-100); border-radius: 12px; padding: 12px 14px; }
.wallet-mini.insufficient { background: var(--pink-100); }

/* Orders */
.order-card { background: white; border-radius: var(--radius-md); padding: 14px; margin-bottom: 10px; box-shadow: var(--shadow-card); }
.order-card .oc-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.order-card .oc-id { font-size: 11.5px; color: var(--ink-400); }
.order-card .oc-status { font-size: 10.5px; font-weight: 700; color: var(--success); background: #E4F9EC; padding: 3px 9px; border-radius: 20px; }
.order-card .oc-items { font-size: 12px; color: var(--ink-600); margin-bottom: 6px; }
.order-card .oc-total { font-weight: 800; color: var(--pink-500); font-size: 14px; display: flex; align-items: center; gap: 8px; }
.oc-payment-pending { font-size: 9.5px; font-weight: 700; background: #FFF4DC; color: #B8790C; padding: 2px 8px; border-radius: 20px; }

/* ---------- Coupon ---------- */
.coupon-input-row { display: flex; gap: 8px; }
.coupon-input-row input { flex: 1; border: 1.5px solid #E3DEF7; border-radius: 10px; padding: 10px 12px; font-size: 13px; font-family: inherit; }
.coupon-applied { display: flex; justify-content: space-between; align-items: center; background: var(--purple-100); color: var(--purple-700); border-radius: 10px; padding: 10px 12px; font-size: 12.5px; font-weight: 700; }
.coupon-applied a { color: var(--danger); cursor: pointer; font-size: 11.5px; }

/* ---------- Payment method picker ---------- */
.payment-method-list { display: flex; flex-direction: column; gap: 8px; }
.payment-method-opt { display: flex; justify-content: space-between; align-items: center; border: 1.5px solid #E3DEF7; border-radius: 12px; padding: 12px 14px; font-size: 13px; font-weight: 600; cursor: pointer; }
.payment-method-opt.selected { border-color: var(--purple-600); background: var(--purple-100); color: var(--purple-700); }

/* ---------- Reviews ---------- */
.reviewable-card { display: flex; justify-content: space-between; align-items: center; background: white; border-radius: var(--radius-sm); padding: 12px; margin-bottom: 8px; box-shadow: var(--shadow-card); font-size: 12.5px; font-weight: 600; }
.review-item { background: white; border-radius: var(--radius-sm); padding: 12px; margin-bottom: 8px; box-shadow: var(--shadow-card); }
.review-item .ri-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.review-item .ri-name { font-weight: 700; font-size: 12.5px; }
.review-item .ri-stars { color: #F59E0B; font-size: 12px; }
.review-item .ri-comment { font-size: 12px; color: var(--ink-600); line-height: 1.5; }
.review-item .ri-date { font-size: 10px; color: var(--ink-400); margin-top: 4px; }
.review-stars-picker { display: flex; gap: 6px; justify-content: center; margin: 6px 0 16px; }
.review-star { font-size: 32px; cursor: pointer; opacity: 0.3; }
.review-star.selected { opacity: 1; }

/* ---------- Modal (customer) ---------- */
.modal-overlay-c { position: fixed; inset: 0; background: rgba(26,26,46,0.55); z-index: 300; display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal-box-c { background: white; border-radius: 20px; padding: 22px; max-width: 400px; width: 100%; max-height: 85vh; overflow-y: auto; }

.system-alert-box { text-align: center; padding: 36px 26px 26px; }
.system-alert-icon {
  width: 76px; height: 76px; border-radius: 50%; margin: 0 auto 20px;
  display: flex; align-items: center; justify-content: center;
  border: 2px solid #BBF7D0; color: #22C55E;
}
.system-alert-icon.error { border-color: #FECACA; color: #DC2626; }
.system-alert-title { font-size: 20px; font-weight: 800; color: #1a1a2e; margin: 0 0 8px; }
.system-alert-message { font-size: 17px; font-weight: 600; color: var(--ink-600); margin: 0 0 26px; line-height: 1.5; }
.system-alert-box .btn-primary { max-width: 220px; margin: 0 auto; background: var(--purple-500); }

/* ---------- Flash sale ---------- */
.flash-banner { background: linear-gradient(120deg, #FF3B30, #EA580C); border-radius: var(--radius-md) var(--radius-md) 0 0; padding: 14px 16px; color: white; margin: 14px 0 0; display: flex; align-items: center; justify-content: space-between; box-shadow: var(--shadow-soft); }
.flash-banner .fb-left { display: flex; align-items: center; gap: 10px; }
.flash-banner .fb-ico { width: 34px; height: 34px; border-radius: 10px; background: rgba(255,255,255,0.22); display: flex; align-items: center; justify-content: center; font-size: 16px; flex-shrink: 0; }
.flash-banner .fb-title { font-weight: 800; font-size: 15px; letter-spacing: .3px; }
.flash-banner .fb-sub { font-size: 10px; opacity: .85; margin-top: 2px; }
.fb-view-all { background: rgba(255,255,255,0.22); border: none; color: white; font-size: 11px; font-weight: 700; padding: 7px 14px; border-radius: 20px; cursor: pointer; white-space: nowrap; font-family: inherit; }
.flash-timer { font-size: 12px; font-weight: 700; background: rgba(0,0,0,0.22); border-radius: 20px; padding: 5px 12px; }
.flash-product-row {
  display: flex; gap: 10px; overflow-x: auto; padding: 12px 4px 14px;
  background: var(--white); border-radius: 0 0 var(--radius-md) var(--radius-md); box-shadow: var(--shadow-card);
}
.flash-product-card { min-width: 150px; max-width: 150px; background: white; border-radius: var(--radius-sm); padding: 0 8px 10px; box-shadow: var(--shadow-card); cursor: pointer; }
.flash-product-card .fp-icon { height: 110px; font-size: 34px; display: flex; align-items: center; justify-content: center; margin-bottom: 20px; border-radius: 10px; background: var(--paper); overflow: hidden; position: relative; }
.flash-product-card .fp-seller-badge {
  position: absolute; top: 0; left: 0; right: 0; z-index: 2; display: flex; align-items: center; gap: 4px;
  background: linear-gradient(180deg, rgba(0,0,0,0.55), rgba(0,0,0,0)); padding: 5px 6px 12px; font-size: 8px; font-weight: 700; color: white;
}
.flash-product-card .fp-seller-avatar { width: 14px; height: 14px; border-radius: 50%; background: white; color: var(--ink-900); display: flex; align-items: center; justify-content: center; font-size: 8px; flex-shrink: 0; }
.flash-product-card .fp-stock-tag { position: absolute; top: 4px; right: 4px; z-index: 2; background: var(--purple-600); color: white; font-size: 7.5px; font-weight: 700; padding: 2px 6px; border-radius: 20px; }
.flash-product-card .fp-disc-tag { position: absolute; bottom: 4px; left: 4px; z-index: 2; background: #EA580C; color: white; font-size: 8.5px; font-weight: 800; padding: 2px 6px; border-radius: 5px; }
.flash-product-card .fp-ring {
  position: absolute; bottom: -14px; right: -6px; z-index: 3; width: 36px; height: 36px; border-radius: 50%;
  background: conic-gradient(var(--ring-color) calc(var(--pct)*1%), #F1EEFB 0); display: flex; align-items: center; justify-content: center; box-shadow: 0 0 0 3px white;
}
.flash-product-card .fp-ring::before { content: ""; position: absolute; inset: 3px; background: white; border-radius: 50%; }
.flash-product-card .fp-ring { color: var(--ring-color); font-size: 7.5px; font-weight: 800; }
.flash-product-card .fp-name { font-size: 11.5px; font-weight: 700; color: var(--ink-900); min-height: 30px; padding: 0 1px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.flash-product-card .fp-price-row { display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; padding: 0 1px; margin-top: 2px; }
.flash-product-card .fp-price { font-weight: 800; color: #EA580C; font-size: 15px; }
.flash-product-card .fp-old-price { font-size: 10px; color: var(--ink-400); text-decoration: line-through; }
.flash-product-card .fp-bottom-row { display: flex; align-items: center; justify-content: space-between; gap: 6px; margin-top: 8px; padding: 0 1px; }
.flash-product-card .fp-countdown { font-size: 9px; color: var(--ink-400); font-weight: 600; white-space: nowrap; }
.flash-product-card .fp-buy-btn { flex-shrink: 0; background: #EA580C; color: white; border: none; border-radius: 16px; padding: 6px 14px; font-size: 10.5px; font-weight: 800; cursor: pointer; font-family: inherit; }
.pc-flash-badge { position: absolute; top: 6px; left: 6px; background: var(--pink-500); color: white; font-size: 9px; font-weight: 800; padding: 2px 6px; border-radius: 6px; }

/* ---------- Mega menu ---------- */
.mega-menu-overlay { position: fixed; inset: 0; background: rgba(26,26,46,0.5); z-index: 250; display: flex; }
.mega-menu-panel { background: white; width: 82%; max-width: 320px; height: 100%; overflow-y: auto; padding: 18px; }
.mega-cat-item { padding: 12px 8px; border-bottom: 1px solid #F1EEFB; font-size: 13.5px; font-weight: 700; cursor: pointer; }
.mega-subcat-item { padding: 10px 8px 10px 20px; font-size: 12.5px; color: var(--ink-600); cursor: pointer; }

/* ---------- Referral ---------- */
.referral-code-box { background: linear-gradient(120deg, var(--purple-700), var(--pink-500)); border-radius: var(--radius-lg); padding: 24px 20px; text-align: center; color: white; margin-bottom: 16px; }
.referral-code-box .rc-code { font-size: 26px; font-weight: 800; letter-spacing: 2px; background: rgba(255,255,255,0.15); border-radius: 12px; padding: 10px; margin: 10px 0; }
.referral-stat-row { display: flex; gap: 10px; margin-bottom: 16px; }
.referral-stat-card { flex: 1; background: white; border-radius: var(--radius-sm); padding: 14px; text-align: center; box-shadow: var(--shadow-card); }
.referral-stat-card .rs-val { font-size: 20px; font-weight: 800; color: var(--purple-600); }
.referral-stat-card .rs-label { font-size: 10.5px; color: var(--ink-400); }

/* ---------- VIP tier badge ---------- */
.vip-badge-row { margin-bottom: 12px; }
.vip-badge-card { display: flex; align-items: center; justify-content: space-between; background: linear-gradient(120deg, #1A1A2E, #3A2A20); border-radius: var(--radius-md); padding: 14px 16px; color: white; }
.vip-badge-card .vb-tier { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 14px; }
.vip-badge-card .vb-tier .vb-icon { font-size: 26px; }
.vip-badge-card .vb-progress { font-size: 10.5px; color: rgba(255,255,255,0.7); margin-top: 2px; }
.vip-progress-bar { height: 5px; background: rgba(255,255,255,0.15); border-radius: 6px; overflow: hidden; margin-top: 6px; }
.vip-progress-bar-fill { height: 100%; background: linear-gradient(90deg, #F97316, #FFD84D); }

/* ---------- Wallet 4-card stat grid ---------- */
.wallet-stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 14px 0; }
.wallet-stat-card { background: white; border-radius: var(--radius-md); padding: 14px; text-align: center; box-shadow: var(--shadow-card); }
.wallet-stat-card .wsc-ico { width: 36px; height: 36px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 16px; margin: 0 auto 8px; }
.wallet-stat-card .wsc-val { font-weight: 800; font-size: 15px; }
.wallet-stat-card .wsc-label { font-size: 10.5px; color: var(--ink-400); margin-top: 2px; }

/* ---------- Search bar with camera icon (visual search) ---------- */
.search-bar-row { display: flex; gap: 8px; margin: 14px 0 4px; }
.search-bar-row input { flex: 1; border: 1.5px solid #E3DEF7; border-radius: 22px; padding: 11px 16px; font-size: 13.5px; font-family: inherit; background: white; }
.search-camera-btn { width: 42px; height: 42px; min-width: 42px; border-radius: 50%; border: none; background: linear-gradient(135deg, var(--purple-600), var(--pink-500)); color: white; font-size: 17px; cursor: pointer; }

/* ---------- Popular products row (horizontal thumbnail scroll) ---------- */
.popular-section { margin: 16px 0; }
.popular-section-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.popular-section-head h3 { margin: 0; font-size: 13.5px; font-weight: 800; }
.popular-section-head a { font-size: 11px; color: var(--purple-600); font-weight: 700; cursor: pointer; }
.cat-pill-row { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
.cat-pill-row::-webkit-scrollbar { display: none; }
.cat-pill { flex-shrink: 0; background: white; border: 1.5px solid #E3DEF7; border-radius: 20px; padding: 8px 14px; font-size: 11.5px; font-weight: 700; color: var(--ink-600); cursor: pointer; white-space: nowrap; font-family: inherit; }
.cat-pill:hover, .cat-pill:active { background: var(--purple-100); border-color: var(--purple-400); color: var(--purple-700); }
.popular-thumb-row { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 4px; }
.popular-thumb-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.popular-thumb-card { min-width: 0; background: white; border-radius: var(--radius-sm); box-shadow: var(--shadow-card); cursor: pointer; overflow: hidden; }
.popular-thumb-card .pt-image { height: 90px; background: var(--paper); display: flex; align-items: center; justify-content: center; font-size: 32px; position: relative; overflow: hidden; }
.popular-thumb-card .pt-badge { position: absolute; top: 4px; left: 4px; background: var(--pink-500); color: white; font-size: 9px; font-weight: 800; padding: 2px 5px; border-radius: 5px; z-index: 1; }
.popular-thumb-card .pt-body { padding: 7px 8px 9px; }
.popular-thumb-card .pt-name { font-size: 11px; font-weight: 600; color: var(--ink-900); line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.popular-thumb-card .pt-price { font-weight: 800; font-size: 12.5px; color: var(--ink-900); }
.popular-thumb-card .pt-sold { font-size: 9.5px; color: var(--ink-400); margin-top: 2px; }

/* ---------- Section block header (shared by "หมวดหมู่ยอดนิยม" + "สินค้ายอดนิยม") ---------- */
.section-block { margin: 18px 0; }
.section-block-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 12px; }
.sb-head-left { display: flex; align-items: center; gap: 10px; }
.sb-ico { width: 32px; height: 32px; min-width: 32px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 15px; }
.sb-ico-blue { background: linear-gradient(135deg, var(--purple-600), var(--purple-500)); color: white; }
.sb-ico-gold { background: linear-gradient(135deg, #FBBF24, #F59E0B); color: white; }
.sb-head-left h3 { margin: 0; font-size: 14px; font-weight: 800; color: var(--ink-900); }
.sb-head-left p { margin: 2px 0 0; font-size: 10.5px; color: var(--ink-400); }
.sb-view-all { flex-shrink: 0; background: var(--purple-100); color: var(--purple-700); border: none; border-radius: 20px; padding: 7px 14px; font-size: 11px; font-weight: 700; cursor: pointer; font-family: inherit; white-space: nowrap; }

/* ---------- หมวดหมู่ยอดนิยม: wrapping category pills ---------- */
.popular-cat-pills { display: flex; flex-wrap: wrap; gap: 8px; }
.popular-cat-pills .cat-pill { flex-shrink: 1; }

/* ---------- สินค้ายอดนิยม: rated product row ---------- */
.rated-product-row { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
.rated-product-row::-webkit-scrollbar { display: none; }
.rated-product-card { flex-shrink: 0; width: 132px; background: white; border-radius: var(--radius-md); box-shadow: var(--shadow-card); cursor: pointer; overflow: hidden; }
.rated-product-card .rpc-image { width: 100%; height: 110px; background: var(--paper); display: flex; align-items: center; justify-content: center; font-size: 32px; position: relative; overflow: hidden; }
.rated-product-card .rpc-badge { position: absolute; top: 6px; left: 6px; background: var(--pink-500); color: white; font-size: 9.5px; font-weight: 800; padding: 2px 6px; border-radius: 6px; z-index: 1; }
.rated-product-card .rpc-rating { position: absolute; bottom: 6px; right: 6px; background: rgba(20,19,43,0.72); color: white; font-size: 9.5px; font-weight: 700; padding: 2px 6px; border-radius: 20px; z-index: 1; }
.rated-product-card .rpc-name { font-size: 11.5px; font-weight: 600; color: var(--ink-900); line-height: 1.35; padding: 8px 9px 0; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; text-overflow: ellipsis; min-height: 30px; }
.rated-product-card .rpc-price-row { display: flex; align-items: baseline; gap: 5px; padding: 4px 9px 10px; }
.rated-product-card .rpc-price { font-weight: 800; font-size: 13.5px; color: #EA580C; }
.rated-product-card .rpc-old { font-size: 10px; color: var(--ink-400); text-decoration: line-through; }

/* ---------- Help Centre ---------- */
.help-topic-item { background: white; border-radius: var(--radius-sm); padding: 13px 14px; margin-bottom: 8px; box-shadow: var(--shadow-card); }
.help-topic-item h4 { margin: 0 0 4px; font-size: 13px; }
.help-topic-item p { margin: 0; font-size: 12px; color: var(--ink-600); line-height: 1.5; }
.payment-logo-grid, .shipping-logo-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 8px; }
.payment-logo-item, .shipping-logo-item { background: white; border-radius: var(--radius-sm); padding: 12px; text-align: center; font-size: 12px; font-weight: 700; box-shadow: var(--shadow-card); }

/* ---------- Bank account / withdraw ---------- */
.bank-account-card { background: white; border-radius: var(--radius-md); padding: 16px; box-shadow: var(--shadow-card); margin-bottom: 16px; }
.bank-account-card .ba-bank { font-weight: 800; font-size: 14px; margin-bottom: 4px; }
.bank-account-card .ba-number { font-size: 13px; color: var(--ink-600); letter-spacing: 1px; }
.bank-account-card .ba-name { font-size: 12px; color: var(--ink-400); margin-top: 2px; }
.withdraw-row { display: flex; justify-content: space-between; align-items: center; background: white; border-radius: var(--radius-sm); padding: 12px 14px; margin-bottom: 8px; box-shadow: var(--shadow-card); }
.withdraw-row .wr-status { font-size: 10.5px; font-weight: 700; padding: 3px 9px; border-radius: 20px; }
.wr-status.pending { background: #FFF4DC; color: #B8790C; }
.wr-status.done { background: #E4F9EC; color: #16A34A; }
.wr-status.rejected { background: #FDE8E8; color: #DC2626; }

/* ---------- Withdraw page header + warning card + bank-link modal ---------- */
.withdraw-header-gradient {
  background: linear-gradient(120deg, var(--purple-700), var(--purple-600) 55%, var(--pink-500) 130%);
  padding: 18px; text-align: center; position: sticky; top: 0; z-index: 20;
}
.withdraw-header-title { margin: 0; color: white; font-size: 17px; font-weight: 700; letter-spacing: .2px; }
.withdraw-warning-card {
  background: white; border-radius: var(--radius-md); padding: 20px; box-shadow: var(--shadow-card);
  display: flex; gap: 14px; position: relative; overflow: hidden; margin-bottom: 16px;
}
.withdraw-warning-card::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 5px; background: #F4B400; }
.ww-icon {
  width: 45px; height: 45px; border-radius: 50%; background: #FFF3E0; color: #F4A000;
  display: flex; align-items: center; justify-content: center; font-size: 19px; flex-shrink: 0;
}
.ww-title { font-size: 16px; font-weight: 700; color: var(--ink-900); margin-bottom: 3px; }
.ww-text { font-size: 12.5px; color: var(--ink-400); margin-bottom: 12px; }
.ww-btn {
  background: #FF4D2D; color: white; border: none; padding: 10px 16px; border-radius: 8px;
  font-size: 13px; font-weight: 700; cursor: pointer; font-family: inherit;
}
.withdraw-balance-card {
  background: #F7EFEC; border-radius: var(--radius-md); padding: 18px 20px;
  display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px;
}
.wb-label { font-size: 12.5px; color: var(--ink-600); margin-bottom: 4px; }
.wb-amount { font-size: 22px; font-weight: 800; color: #FF4D2D; }
.wb-icon { width: 50px; height: 50px; border-radius: 50%; background: white; display: flex; align-items: center; justify-content: center; font-size: 22px; color: #FF4D2D; box-shadow: 0 2px 6px rgba(0,0,0,0.08); }

/* ---------- Top-up page (เติมเงิน | TOPUP) ---------- */
.topup-header-gradient {
  background: linear-gradient(120deg, var(--purple-700), var(--purple-600) 55%, var(--pink-500) 130%);
  padding: 18px; text-align: center; position: sticky; top: 0; z-index: 20;
}
.topup-header-title { margin: 0; color: white; font-size: 17px; font-weight: 700; letter-spacing: .2px; }
.topup-card { background: var(--white); border-radius: var(--radius-lg); box-shadow: var(--shadow-card); padding: 20px; margin-bottom: 16px; }
.topup-card-title { font-size: 15.5px; font-weight: 800; color: var(--ink-900); margin: 0 0 14px; }
.topup-notice-box { background: var(--ink-900); border-radius: var(--radius-md); padding: 16px 18px; margin-bottom: 18px; }
.topup-notice-box .tnb-title { color: white; font-size: 13.5px; font-weight: 800; line-height: 1.5; }
.topup-notice-box .tnb-sub { color: rgba(255,255,255,0.75); font-size: 12px; font-weight: 500; margin-top: 4px; line-height: 1.5; }
.topup-info-row { display: flex; align-items: center; gap: 12px; background: var(--paper); border-radius: var(--radius-md); padding: 13px 15px; margin-bottom: 12px; }
.topup-info-row:last-of-type { margin-bottom: 0; }
.tir-ico { width: 40px; height: 40px; min-width: 40px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 17px; }
.tir-title { font-size: 13.5px; font-weight: 800; color: var(--ink-900); }
.tir-sub { font-size: 11.5px; color: var(--ink-400); margin-top: 1px; }
.topup-history-table { border: 1px solid #ECEBF3; border-radius: var(--radius-md); overflow: hidden; }
.tht-head, .tht-row { display: grid; grid-template-columns: 1fr 1fr 1.1fr 0.8fr 1fr; gap: 4px; }
.tht-head { background: var(--paper); padding: 10px 8px; }
.tht-head span { font-size: 10.5px; font-weight: 800; color: var(--ink-600); }
.tht-row { padding: 10px 8px; border-top: 1px solid #ECEBF3; }
.tht-row span { font-size: 10.5px; color: var(--ink-900); font-weight: 600; word-break: break-word; }
.topup-history-empty { padding: 34px 10px; text-align: center; color: var(--ink-400); font-size: 12.5px; }

.bank-link-modal-box { width: min(92vw, 400px); border-radius: 20px; overflow: hidden; padding: 0; }
.bank-link-modal-header { padding: 16px 18px; border-bottom: 1px solid #EEE; display: flex; justify-content: space-between; align-items: center; }
.bank-link-modal-title { font-size: 16px; font-weight: 700; color: var(--ink-900); }
.bank-link-modal-close { font-size: 20px; cursor: pointer; color: var(--ink-600); }
.bank-link-modal-body { padding: 18px; }
.bank-link-label { font-size: 12.5px; color: var(--ink-600); margin-bottom: 6px; font-weight: 600; }
.bank-link-modal-body select, .bank-link-modal-body input {
  width: 100%; padding: 12px 14px; border-radius: 12px; border: 1px solid #DDD; font-size: 13.5px;
  margin-bottom: 16px; font-family: inherit; background: white;
}
.bank-link-modal-footer { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; border-top: 1px solid #EEE; }
.bank-link-cancel { color: #555; cursor: pointer; font-size: 13.5px; }
.bank-link-save-btn { background: #22C55E; color: white; border: none; padding: 11px 18px; border-radius: 12px; font-size: 13.5px; font-weight: 700; cursor: pointer; font-family: inherit; }

/* ---------- Category row + mega menu button ---------- */
.cat-scroll-row { display: flex; align-items: center; gap: 8px; }
.cat-scroll-row .cat-scroll { flex: 1; }
.mega-menu-btn { flex-shrink: 0; background: white; border: 1.5px solid #E3DEF7; border-radius: 20px; padding: 8px 12px; font-size: 11px; font-weight: 700; color: var(--ink-600); cursor: pointer; white-space: nowrap; }

/* ---------- Home page: hero banner rotator ---------- */
.home-hero-banner-link { display: block; border-radius: var(--radius-lg); overflow: hidden; box-shadow: var(--shadow-soft); margin-bottom: 6px; }
.home-hero-banner-link img { width: 100%; display: block; height: auto; }

/* ---------- Home page: stats row ---------- */
.home-stats-row {
  display: flex; justify-content: space-between; gap: 6px;
  background: var(--white); border-radius: var(--radius-lg); box-shadow: var(--shadow-card);
  padding: 16px 14px; margin: 14px 0 10px;
}
.home-stat { flex: 1; text-align: left; display: flex; align-items: center; gap: 10px; padding: 0 6px; position: relative; }
.home-stat + .home-stat::before {
  content: ""; position: absolute; left: -3px; top: 50%; transform: translateY(-50%);
  width: 1px; height: 30px; background: var(--purple-100);
}
.home-stat .home-stat-ico {
  width: 38px; height: 38px; flex-shrink: 0; border-radius: 11px; background: var(--purple-100);
  display: flex; align-items: center; justify-content: center;
}
.home-stat svg { width: 19px; height: 19px; color: var(--purple-500); }
.home-stat b { display: block; font-size: 17px; font-weight: 800; color: var(--purple-900); line-height: 1.2; }
.home-stat span { font-size: 10.5px; color: var(--ink-400); line-height: 1.3; }

/* ---------- Home page: marketing quick-tabs ---------- */
.home-cat-tabs {
  display: flex; justify-content: space-between; gap: 8px; overflow-x: auto;
  background: var(--white); border-radius: var(--radius-lg); box-shadow: var(--shadow-card);
  padding: 18px 14px; margin-bottom: 10px; scrollbar-width: none;
}
.home-cat-tabs::-webkit-scrollbar { display: none; }
.home-cat-tab { display: flex; flex-direction: column; align-items: center; gap: 8px; flex-shrink: 0; cursor: pointer; opacity: .65; background: none; border: none; font-family: inherit; }
.home-cat-tab.active { opacity: 1; }
.home-cat-tab-ico {
  width: 56px; height: 56px; border-radius: 50%; background: var(--white);
  border: 1px solid var(--purple-100); box-shadow: var(--shadow-card);
  display: flex; align-items: center; justify-content: center; overflow: hidden; font-size: 24px;
}
.home-cat-tab-ico img { width: 68%; height: 68%; object-fit: contain; }
.home-cat-tab span { font-size: 11px; font-weight: 700; color: var(--ink-600); }
.home-cat-tab.active span { color: #EA580C; }

/* ---------- Home page: CTA banner ---------- */
.home-cta { background: linear-gradient(to bottom right, #4338CA, #F0245C); border-radius: var(--radius-lg); padding: 26px 24px; color: white; text-align: left; margin: 18px 0; box-shadow: var(--shadow-soft); }
.home-cta h3 { margin: 0 0 8px; font-size: 19px; font-weight: 800; line-height: 1.3; }
.home-cta p { margin: 0 0 18px; font-size: 12.5px; opacity: .92; line-height: 1.6; max-width: 320px; }
.home-cta button { background: white; color: var(--profile-orange); border: none; border-radius: 12px; padding: 11px 22px; font-weight: 800; font-size: 13px; cursor: pointer; display: inline-flex; align-items: center; gap: 8px; }

/* Full company / legal footer, mirrors marketplace-style footer layout.
   Note: bottom clearance for the fixed nav bar is already handled by the outer
   `.view { padding-bottom: 88px }` (and, on the shop/home view specifically, its
   own extra rules) — this used to ALSO reserve 90px here, effectively double-
   stacking the clearance and leaving a big dead gap above the nav. Kept small now. */
.shop-footer-full { margin: 18px 0 16px; padding-top: 26px; border-top: 1px solid #E3DEF7; text-align: left; }
.sf-about-title { margin: 0 0 12px; font-size: 13.5px; font-weight: 800; color: var(--ink-900); line-height: 1.4; }
.sf-about-section { margin-bottom: 12px; }
.sf-about-section h5 { margin: 0 0 4px; font-size: 11.5px; font-weight: 800; color: var(--ink-900); }
.sf-about-section p { margin: 0; font-size: 10.5px; line-height: 1.7; color: var(--ink-400); }
.sf-campaign-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 20px 0 8px; }
.sf-campaign-pill { background: var(--purple-100); color: var(--purple-600); font-size: 11.5px; font-weight: 800; padding: 7px 13px; border-radius: 20px; }
.sf-campaign-pill.hl { background: linear-gradient(120deg, #FF3B30, #EA580C); color: white; }
.sf-nav-cols { display: flex; flex-wrap: wrap; gap: 20px; margin: 28px 0; }
.sf-col { flex: 1 1 40%; min-width: 130px; }
.sf-col h4 { margin: 0 0 14px; font-size: 14px; font-weight: 800; color: var(--ink-900); }
.sf-col a { display: block; font-size: 13px; color: var(--ink-600); margin-bottom: 13px; cursor: pointer; text-decoration: none; }
.sf-col a:hover { color: var(--purple-600); }
.sf-payment-block { margin: 12px 0 28px; }
.sf-label { font-size: 13.5px; font-weight: 700; color: var(--ink-400); margin-bottom: 14px; }
.sf-badge-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.sf-badge { background: white; border: 1px solid #E3DEF7; border-radius: 10px; padding: 9px 15px; font-size: 12px; font-weight: 700; color: var(--ink-600); box-shadow: var(--shadow-card); display: flex; align-items: center; justify-content: center; }
.sf-badge-img { width: 100%; height: auto; aspect-ratio: 7 / 4; padding: 2px; border-radius: 12px; }
.sf-badge-img img { width: 100%; height: 100%; object-fit: contain; }
.sf-copyright { margin: 22px 0 0; text-align: center; font-size: 11.5px; color: var(--ink-400); }

/* Profile page: the balance card's top-right slot now shows the username instead
   of a repeated VIP chip (VIP tier already has its own card below — see
   .vip-badge-row — so repeating it here was redundant). See #pf-username-chip,
   populated in loadProfile(). */
.pf-username-chip { font-size: 12.5px; align-self: flex-start; }

/* Profile page: real fix for the leftover blank space below the footer. The
   culprit is `.content` being a flex-fill child (flex:1) that always stretches to
   the full available height regardless of how much content it actually holds —
   no amount of margin/padding tuning above closes that gap, since the gap is
   empty space *after* the last element, not spacing *within* the footer. Turning
   `.content` into a flex column and giving the footer `margin-top: auto` pushes it
   (and only it) down to hug the bottom of the visible area — a page with lots of
   content still scrolls normally, but a short page no longer leaves dead space. */
#view-profile .content { display: flex; flex-direction: column; }
#view-profile .shop-footer-full { margin-top: auto; }

/* Standalone "กระเป๋าเงินของฉัน" page: same sticky-footer treatment. This page has
   no bottom nav bar at all (unlike shop/profile), so the generic `.view {
   padding-bottom: 88px }` clearance meant for a nav bar was pure wasted space
   here — reduced to a normal small page-end gap instead. */
#view-wallet .content { display: flex; flex-direction: column; padding-bottom: 0; }
#view-wallet .shop-footer-full { margin-top: auto; margin-bottom: 0; }
#view-wallet.view { padding-bottom: 24px; }

/* ---------- Home page: SEO footer text ---------- */
.home-seo-text { font-size: 11px; color: var(--ink-400); line-height: 1.75; text-align: left; white-space: pre-line; margin: 0 0 16px; padding: 14px; background: white; border-radius: var(--radius-md); box-shadow: var(--shadow-card); }

/* ---------- Store notifications feed ---------- */
.store-notif-card { background: white; border-radius: var(--radius-md); padding: 14px; box-shadow: var(--shadow-card); margin-bottom: 10px; display: flex; gap: 12px; }
.store-notif-card .snc-ico { width: 38px; height: 38px; min-width: 38px; border-radius: 10px; background: var(--purple-100); color: var(--purple-600); display: flex; align-items: center; justify-content: center; font-size: 16px; }
.store-notif-card h4 { margin: 0 0 4px; font-size: 13px; }
.store-notif-card p { margin: 0; font-size: 11.5px; color: var(--ink-600); line-height: 1.45; }
.store-notif-card time { font-size: 10px; color: var(--ink-400); }

/* Wallet */
.wallet-card { background: linear-gradient(135deg, var(--purple-500), var(--profile-pink)); border-radius: var(--radius-lg); padding: 20px; color: white; box-shadow: var(--shadow-soft); position: relative; overflow: hidden; }
.wallet-card::after {
  content: '฿'; position: absolute; right: -6px; bottom: -30px; font-size: 130px; font-weight: 800;
  color: rgba(255,255,255,0.12); line-height: 1; pointer-events: none; font-family: inherit;
}
.wallet-bal-row { display: flex; justify-content: space-between; align-items: flex-end; position: relative; z-index: 1; }
.wallet-label-row { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.wallet-coin-ico {
  width: 26px; height: 26px; min-width: 26px; border-radius: 50%; border: 1.5px solid var(--gold-500);
  background: rgba(255,255,255,0.12); display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 800; color: white;
}
.wallet-label { font-size: 12px; opacity: 0.9; font-weight: 600; }
.wallet-amount { font-size: 30px; font-weight: 800; position: relative; z-index: 1; }
.wallet-points-val { font-size: 16px; font-weight: 800; text-align: right; }
.wallet-tx-row { display: flex; justify-content: space-between; align-items: center; background: white; border-radius: 12px; padding: 12px 14px; margin-bottom: 8px; box-shadow: var(--shadow-card); }
.wallet-tx-row .wtx-desc { font-size: 12px; font-weight: 600; }
.wallet-tx-row .wtx-date { font-size: 10.5px; color: var(--ink-400); margin-top: 2px; }
.wallet-tx-row .wtx-amount { font-weight: 800; font-size: 13px; }
.wallet-tx-row .wtx-amount.positive { color: var(--success); }
.wallet-tx-row .wtx-amount.negative { color: var(--pink-500); }

#view-cart .content { padding-bottom: 100px; }

/* ---------- Section header ---------- */
.section-head { display: flex; align-items: center; justify-content: space-between; margin: 22px 0 10px; }
.section-head h2 { font-size: 15.5px; margin: 0; font-weight: 800; }
.section-head a { font-size: 12.5px; color: var(--purple-600); text-decoration: none; font-weight: 700; }

/* ---------- Ticket card ---------- */
.ticket-card {
  background: var(--white); border-radius: var(--radius-md); padding: 14px; margin-bottom: 10px;
  box-shadow: var(--shadow-card); display: flex; gap: 12px; align-items: flex-start; cursor: pointer;
}
.ticket-card .ticon {
  width: 38px; height: 38px; min-width: 38px; border-radius: 10px; display: flex; align-items: center; justify-content: center;
  font-size: 16px; color: white;
}
.ticket-card .tbody { flex: 1; min-width: 0; }
.ticket-card .ttitle { font-weight: 700; font-size: 13.5px; margin-bottom: 3px; }
.ticket-card .tmeta { font-size: 11.5px; color: var(--ink-400); }
.status-chip { font-size: 10.5px; font-weight: 700; padding: 4px 9px; border-radius: 20px; white-space: nowrap; }
.status-progress { background: #FFF4DC; color: #B8790C; }
.status-done { background: #E4F9EC; color: #16A34A; }
.status-wait { background: #FDE8E8; color: #DC2626; }

/* ---------- FAQ ---------- */
.faq-item {
  background: var(--white); border-radius: var(--radius-sm); padding: 13px 14px; margin-bottom: 8px;
  box-shadow: var(--shadow-card); font-size: 13.5px; font-weight: 600; display: flex; justify-content: space-between; align-items: center; cursor: pointer;
}
.faq-item .plus { color: var(--purple-500); font-size: 16px; }

/* ---------- Bottom nav ---------- */
.bottom-nav {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 480px; background: var(--white);
  display: flex; justify-content: space-around; padding: 10px 6px calc(10px + env(safe-area-inset-bottom));
  border-top: 1px solid rgba(26,26,46,0.07); z-index: 30;
}
.nav-btn {
  background: none; border: none; display: flex; flex-direction: column; align-items: center; gap: 4px;
  font-size: 10.5px; color: #9CA0AE; font-family: inherit; cursor: pointer; font-weight: 600;
}
.nav-btn .n-ico { font-size: 19px; display: flex; align-items: center; justify-content: center; width: 24px; height: 24px; }
.nav-btn .n-ico svg { width: 21px; height: 21px; }
.nav-btn.active { color: var(--profile-hotpink); font-weight: 800; }
.nav-btn.active .n-ico { background: var(--profile-hotpink); color: white; border-radius: 50%; width: 30px; height: 30px; box-shadow: 0 4px 10px rgba(245,0,91,0.35); }
.nav-btn.active .n-ico svg { width: 17px; height: 17px; }

/* ---------- Buttons ---------- */
.btn-primary {
  background: linear-gradient(135deg, var(--purple-600), var(--pink-500));
  color: white; border: none; border-radius: 14px; padding: 14px; font-weight: 700; font-size: 14.5px;
  width: 100%; cursor: pointer; box-shadow: 0 8px 18px rgba(108,60,233,0.28);
}
.btn-secondary {
  background: var(--white); color: var(--purple-600); border: 1.5px solid var(--purple-400);
  border-radius: 14px; padding: 13px; font-weight: 700; font-size: 14px; width: 100%; cursor: pointer;
}
.btn-block-row { display: flex; gap: 10px; }

/* ---------- Form ---------- */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12.5px; font-weight: 700; color: var(--ink-600); margin-bottom: 6px; }
.field input, .field select, .field textarea {
  width: 100%; border: 1.5px solid #E3DEF7; border-radius: 12px; padding: 12px 13px; font-size: 14px;
  font-family: inherit; background: var(--white); color: var(--ink-900);
}
.field textarea { min-height: 100px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--purple-500); }
.chip-select { display: flex; gap: 8px; flex-wrap: wrap; }
.chip-opt {
  padding: 9px 14px; border-radius: 20px; border: 1.5px solid #E3DEF7; font-size: 12.5px; font-weight: 700;
  cursor: pointer; background: white; color: var(--ink-600);
}
.chip-opt.selected { background: var(--purple-600); border-color: var(--purple-600); color: white; }

/* ---------- Login ---------- */
.login-view {
  --login-grad-start: #845EDB;
  --login-grad-end: #CA50AF;
  --login-accent: #7c3aed;
  --login-cta: #FF2F63;
  justify-content: center; padding: 32px 26px; min-height: 100vh; position: relative; overflow: hidden;
  background: linear-gradient(135deg, var(--login-grad-start), var(--login-grad-end));
}
.login-view .logo-big {
  width: 112px; height: 112px; border-radius: 14px; margin: 0 auto 30px;
  overflow: hidden;
  /* No placeholder background/border here on purpose — showing a colored box before the
     real logo has loaded causes a flash-then-swap on every page load. We simply reserve
     the space and let the logo (added via .has-logo-img below) fade in once it's ready. */
}
.login-view .logo-big.has-logo-img {
  background: none;
  border: none;
  box-shadow: 0 12px 26px rgba(45,10,80,0.35);
  animation: fadeIn .25s ease;
}
.login-card {
  background: white; border-radius: 28px; padding: 34px 26px 28px; position: relative; z-index: 1;
  box-shadow: 0 24px 60px -20px rgba(43,12,74,0.55);
}
.login-card-title { font-size: 27px; font-weight: 800; color: #201A2B; margin: 0 0 22px; }
.login-card .field { margin-bottom: 16px; }
.login-card .field input {
  width: 100%; background: #fff; border: 1.5px solid #ECECEC; border-radius: 18px; padding: 17px 20px; font-size: 15px;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.login-card .field input:focus { border-color: var(--login-accent); box-shadow: 0 0 0 4px rgba(201,183,247,0.5); }
.login-card .field input::placeholder { color: #8d8a99; font-weight: 400; }
.login-view .btn-primary {
  background: var(--login-cta); border-radius: 14px; padding: 17px; font-size: 16px; font-weight: 700;
  box-shadow: 0 14px 26px -10px rgba(255,47,99,0.55);
  transition: transform .15s ease, filter .15s ease;
}
.login-view .btn-primary:hover { filter: brightness(1.05); transform: translateY(-1px); }
.login-divider { text-align: center; margin: 22px 0 18px; color: var(--ink-400); font-size: 13px; }
.login-social-row { display: flex; gap: 12px; }
.login-social-btn {
  flex: 1; height: 56px; border-radius: 16px; border: 1.5px solid #F0F0F0; background: white;
  display: flex; align-items: center; justify-content: center; cursor: pointer; transition: border-color .15s, background .15s, transform .1s ease;
}
.login-social-btn:hover { border-color: #d8d8d8; background: #fafafa; transform: translateY(-1px); }
.login-card-footnote { text-align: center; font-size: 13px; color: #6B6878; margin: 22px 0 0; }
.login-card-footnote a { color: var(--login-cta); font-weight: 700; text-decoration: none; cursor: pointer; }
.login-foot-note { color: rgba(255,255,255,0.85); font-size: 11.5px; text-align: center; margin-top: 18px; line-height: 1.7; }
.login-foot-note a { color: white; text-decoration: underline; }

/* ---------- Register (multi-step wizard) ---------- */
.reg-progress-row { display: flex; justify-content: space-between; align-items: center; font-size: 13.5px; color: #201A2B; margin-bottom: 8px; }
.reg-progress-row span:last-child { font-weight: 700; color: var(--login-cta); }
.reg-progress-track { height: 7px; background: #ECECEC; border-radius: 20px; overflow: hidden; margin-bottom: 26px; }
.reg-progress-fill { height: 100%; background: var(--login-cta); border-radius: 20px; transition: width .3s ease; }
.reg-step .field label { font-size: 14px; font-weight: 700; color: #201A2B; margin-bottom: 10px; }
.btn-gray {
  background: #9CA0AC; color: white; border: none; border-radius: 14px; padding: 17px; font-size: 16px;
  font-weight: 700; width: 100%; cursor: pointer; margin-top: 12px; transition: filter .15s ease, transform .15s ease;
}
.btn-gray:hover { filter: brightness(1.05); transform: translateY(-1px); }

/* ---------- Chat ---------- */
.chat-scroll { flex: 1; overflow-y: auto; padding: 16px 16px 6px; display: flex; flex-direction: column; gap: 4px; }
.msg-row { display: flex; align-items: flex-start; gap: 8px; max-width: 82%; width: fit-content; }
.msg-row.me { margin-left: auto; flex-direction: row-reverse; }
.msg-row.them { margin-right: auto; }
.msg-avatar { width: 28px; height: 28px; border-radius: 50%; background: var(--purple-100); display: flex; align-items: center; justify-content: center; font-size: 13px; flex-shrink: 0; overflow: hidden; }
.msg-avatar img { width: 100%; height: 100%; object-fit: cover; }
.msg-bubble { padding: 10px 16px; border-radius: 20px; font-size: 15px; font-weight: 500; line-height: 1.4; background: white; box-shadow: var(--shadow-card); white-space: pre-wrap; word-break: break-word; position: relative; width: fit-content; max-width: 100%; }
.msg-bubble .msg-image { display: block; width: 100%; max-width: 440px; border-radius: 14px; margin-bottom: 4px; }
.msg-bubble a { color: inherit; text-decoration: underline; word-break: break-all; }
.msg-row.me .msg-bubble { background: linear-gradient(135deg, var(--purple-600), var(--purple-500)); color: white; border-bottom-right-radius: 8px; }
.msg-row.them .msg-bubble { border-bottom-left-radius: 8px; }
.msg-time { font-size: 10.5px; color: var(--ink-400); margin-top: 3px; display: block; line-height: 1.05; }

/* ---------- Delete a message: press-and-hold a deletable bubble ---------- */
.msg-bubble[data-can-delete="1"] { cursor: pointer; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; transition: transform 0.15s ease, filter 0.15s ease; }
.msg-bubble-pressing { transform: scale(0.96); filter: brightness(0.9); }
.msg-bubble.msg-deleted { background: transparent; box-shadow: none; color: var(--ink-400); font-style: italic; padding: 6px 4px; }
.msg-row.me .msg-time { text-align: right; color: rgba(255,255,255,0.7); }

/* ---------- Link preview card (LINE/Messenger-style "unfurled" link) ---------- */
.msg-link-preview { display: block; margin-top: 4px; border-radius: 12px; overflow: hidden; background: var(--paper, #F7F5FC); border: 1px solid rgba(0,0,0,0.06); text-decoration: none; color: inherit; max-width: 240px; }
.msg-row.me .msg-link-preview { background: rgba(255,255,255,0.14); border-color: rgba(255,255,255,0.2); }
.msg-link-preview img { display: block; width: 100%; max-height: 160px; object-fit: cover; background: #eee; }
.msg-link-preview .mlp-body { padding: 5px 9px; }
.msg-link-preview .mlp-site { font-size: 10px; font-weight: 700; letter-spacing: .3px; text-transform: uppercase; opacity: .65; }
.msg-link-preview .mlp-title { font-size: 12.5px; font-weight: 700; margin-top: 2px; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.msg-link-preview .mlp-desc { font-size: 11px; opacity: .8; margin-top: 3px; line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* ---------- Chat header: agent photo, name, role badge, greeting (Admin > ตั้งค่า > โหมดวิดีโอคอล) ---------- */
.chat-header-gradient {
  background: white; padding: 14px 18px 16px; position: sticky; top: 0; z-index: 20;
  border-bottom: 1px solid rgba(26,26,46,0.06);
}
.chat-header-top { display: flex; align-items: flex-start; gap: 10px; }
.chat-back-btn { background: none; border: none; font-size: 20px; cursor: pointer; color: var(--ink-900); padding: 4px 4px 4px 0; flex-shrink: 0; }
.chat-header-avatar-wrap { position: relative; flex-shrink: 0; }
.chat-header-avatar {
  width: 46px; height: 46px; border-radius: 50%; overflow: hidden; background: var(--purple-100);
  display: flex; align-items: center; justify-content: center; font-size: 20px; border: 2px solid var(--paper);
}
.chat-header-avatar img { width: 100%; height: 100%; object-fit: cover; }
.chat-online-dot {
  position: absolute; bottom: 0; right: 0; width: 12px; height: 12px; border-radius: 50%;
  background: var(--success); border: 2px solid white;
}
.chat-header-info { flex: 1; min-width: 0; padding-top: 2px; }
.chat-header-name-row { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.chat-header-name { color: var(--ink-900); font-weight: 800; font-size: 15px; }
.chat-header-title {
  background: var(--stat-pink-bg); color: #7C3AED; font-size: 10px; font-weight: 700;
  padding: 3px 9px; border-radius: 20px; white-space: nowrap;
}
.chat-header-greeting { margin: 4px 0 0; color: var(--ink-600); font-size: 11.5px; line-height: 1.5; display: flex; align-items: flex-start; gap: 5px; }
.chat-header-verified {
  flex-shrink: 0; width: 14px; height: 14px; border-radius: 50%; background: #2563EB; color: white;
  font-size: 9px; display: flex; align-items: center; justify-content: center; margin-top: 1px;
}
.chat-call-btn { color: var(--purple-600); flex-shrink: 0; font-size: 19px; margin-top: 4px; }

/* Quick-stat pills under the header (Admin > ตั้งค่า > โหมดวิดีโอคอล > สถิติในหน้าแชท) */
.chat-stats-row { display: flex; gap: 8px; padding: 12px 14px 2px; background: var(--paper); }
.chat-stat-card {
  flex: 1; min-width: 0; background: white; border-radius: var(--radius-md); padding: 10px 10px;
  display: flex; align-items: center; gap: 8px; box-shadow: var(--shadow-card); cursor: default;
}
.chat-stat-ico { width: 30px; height: 30px; border-radius: 9px; display: flex; align-items: center; justify-content: center; font-size: 14px; flex-shrink: 0; color: white; }
.chat-stat-body { min-width: 0; flex: 1; }
.chat-stat-label { font-size: 9.5px; color: var(--ink-600); font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-stat-value { font-size: 13px; font-weight: 800; color: var(--ink-900); }
.chat-stat-sub { font-size: 8.5px; color: var(--ink-400); }
.chat-stat-chevron { color: var(--ink-400); font-size: 13px; flex-shrink: 0; }

.chat-input-bar { display: flex; gap: 8px; padding: 10px 14px calc(10px + env(safe-area-inset-bottom)); background: white; border-top: 1px solid rgba(26,26,46,0.07); align-items: flex-end; }
.chat-input-bar input { flex: 1; border: 1.5px solid #E3DEF7; border-radius: 22px; padding: 11px 16px; font-size: 13.5px; font-family: inherit; }
.chat-input-bar textarea {
  flex: 1; border: 1.5px solid #E3DEF7; border-radius: 18px; padding: 11px 16px; font-size: 13.5px; font-family: inherit;
  resize: none; max-height: 120px; line-height: 1.4; overflow-y: auto;
}
.chat-input-bar .round-btn.send { flex-shrink: 0; }
.chat-attach-btn { background: none; border: none; font-size: 19px; cursor: pointer; color: var(--ink-400); flex-shrink: 0; padding: 0 2px; }
.round-btn { width: 40px; height: 40px; border-radius: 50%; border: none; display: flex; align-items: center; justify-content: center; cursor: pointer; flex-shrink: 0; }
.round-btn.send { background: var(--purple-600); color: white; }
.round-btn.send svg { display: block; }
.round-btn.call { background: var(--purple-100); color: var(--purple-600); }
.typing-dots span { display: inline-block; width: 5px; height: 5px; border-radius: 50%; background: var(--ink-400); margin-right: 3px; animation: blink 1.2s infinite; }
.typing-dots span:nth-child(2) { animation-delay: .2s; } .typing-dots span:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%,80%,100% { opacity: .25; } 40% { opacity: 1; } }

/* ---------- AI Avatar Call ---------- */
.call-view { background: radial-gradient(circle at 50% 20%, #3B2593, #1A1130 75%); color: white; min-height: 100vh; padding-bottom: 0; }
.call-stage { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; position: relative; padding: 0 20px; }
.call-tag { position: absolute; top: 18px; left: 50%; transform: translateX(-50%); background: rgba(255,255,255,0.12); padding: 6px 14px; border-radius: 20px; font-size: 11.5px; font-weight: 700; display: flex; align-items: center; gap: 6px; }
.call-tag .dot { width: 6px; height: 6px; border-radius: 50%; background: #4ADE80; }
.remote-video-frame { width: 240px; height: 240px; border-radius: 28px; overflow: hidden; position: relative; background: linear-gradient(160deg, #3B2E6B, #241a45); box-shadow: 0 10px 30px rgba(0,0,0,0.35); border: 2px solid rgba(255,255,255,0.12); transition: border-radius .3s; }
.remote-video-frame.mode-ai { border-radius: 50%; }
.remote-video-frame video { width: 100%; height: 100%; object-fit: cover; display: block; }
.remote-video-fallback { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; background: linear-gradient(160deg, var(--purple-700), var(--purple-500)); }
.remote-video-fallback .waiting-avatar { font-size: 56px; }
.remote-video-fallback p { font-size: 11.5px; color: rgba(255,255,255,0.85); margin: 0; }
.real-badge { position: absolute; top: 10px; left: 10px; background: rgba(0,0,0,0.4); color: #fff; font-size: 10px; font-weight: 700; padding: 4px 9px; border-radius: 20px; display: flex; align-items: center; gap: 5px; }
.real-badge .dot { width: 6px; height: 6px; border-radius: 50%; background: #EF4444; }
.local-pip { position: absolute; width: 84px; height: 112px; object-fit: cover; border-radius: 14px; border: 2px solid rgba(255,255,255,0.5); top: 70px; right: 22px; background: #1A1130; transform: scaleX(-1); box-shadow: 0 6px 16px rgba(0,0,0,0.35); }
.call-name { font-weight: 800; font-size: 17px; margin-top: 6px; }
.call-sub { font-size: 12.5px; color: rgba(255,255,255,0.6); }
.call-controls { display: flex; justify-content: center; gap: 20px; padding: 30px 20px calc(30px + env(safe-area-inset-bottom)); }
.call-ctrl-btn { width: 56px; height: 56px; border-radius: 50%; border: none; background: rgba(255,255,255,0.14); color: white; font-size: 20px; cursor: pointer; }
.call-ctrl-btn.end { background: var(--danger); }
.wave-bars { display: flex; align-items: center; gap: 3px; height: 22px; }
.wave-bars span { width: 3px; background: rgba(255,255,255,0.6); border-radius: 2px; animation: wave 1s ease-in-out infinite; }
.wave-bars span:nth-child(1){height:8px;animation-delay:0s} .wave-bars span:nth-child(2){height:16px;animation-delay:.1s}
.wave-bars span:nth-child(3){height:22px;animation-delay:.2s} .wave-bars span:nth-child(4){height:14px;animation-delay:.3s}
.wave-bars span:nth-child(5){height:9px;animation-delay:.4s}
@keyframes wave { 0%,100% { transform: scaleY(0.5); } 50% { transform: scaleY(1); } }

/* ---------- KB article ---------- */
.kb-card { background: white; border-radius: var(--radius-md); padding: 15px; box-shadow: var(--shadow-card); margin-bottom: 10px; }
.kb-card h3 { margin: 0 0 6px; font-size: 14px; }
.kb-card p { margin: 0; font-size: 12.5px; color: var(--ink-600); line-height: 1.5; }
.kb-tag { display: inline-block; font-size: 10.5px; font-weight: 700; color: var(--purple-600); background: var(--purple-100); padding: 3px 9px; border-radius: 20px; margin-bottom: 8px; }

/* ---------- Announcement ---------- */
.ann-card { background: white; border-radius: var(--radius-md); padding: 14px; box-shadow: var(--shadow-card); margin-bottom: 10px; display: flex; gap: 12px; }
.ann-ico { width: 38px; height: 38px; min-width:38px; border-radius: 10px; background: var(--pink-100); color: var(--pink-500); display: flex; align-items: center; justify-content: center; font-size: 16px; }
.ann-card h4 { margin: 0 0 4px; font-size: 13.5px; }
.ann-card p { margin: 0; font-size: 12px; color: var(--ink-600); line-height: 1.45; }
.ann-card time { font-size: 10.5px; color: var(--ink-400); }

/* ---------- Toast ---------- */
.toast {
  position: fixed; top: 0; left: 50%; z-index: 999;
  width: calc(100% - 32px); max-width: 420px; text-align: center;
  background: var(--ink-900); color: white; padding: 13px 20px; padding-top: calc(13px + env(safe-area-inset-top));
  border-radius: 0 0 16px 16px; font-size: 12.5px; font-weight: 600;
  box-shadow: 0 10px 28px rgba(0,0,0,0.22);
  opacity: 0; transform: translate(-50%, -110%); transition: opacity .25s, transform .3s;
  pointer-events: none;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* Utility */
.incoming-call-banner-c { position: fixed; top: 14px; left: 50%; transform: translateX(-50%); width: calc(100% - 28px); max-width: 452px; z-index: 200; background: white; border-radius: 16px; box-shadow: 0 12px 34px rgba(26,26,46,0.25); padding: 12px 14px; display: flex; align-items: center; justify-content: space-between; gap: 14px; animation: pulseInC .3s ease; }
@keyframes pulseInC { from { transform: translateX(-50%) translateY(-14px); opacity: 0; } to { transform: translateX(-50%) translateY(0); opacity: 1; } }
.icbc-info { display: flex; align-items: center; gap: 10px; min-width: 0; }
.icbc-avatar { width: 38px; height: 38px; min-width: 38px; border-radius: 50%; background: linear-gradient(135deg, var(--purple-600), var(--pink-500)); color: white; display: flex; align-items: center; justify-content: center; font-size: 16px; }
.icbc-name { font-weight: 800; font-size: 13px; }
.icbc-sub { font-size: 10.5px; color: var(--ink-400); }
.icbc-actions { display: flex; gap: 8px; flex-shrink: 0; }
.icbc-btn { width: 40px; height: 40px; border-radius: 50%; border: none; font-size: 16px; cursor: pointer; }
.icbc-btn.accept { background: var(--success); color: white; }
.icbc-btn.reject { background: #F1EEFB; color: var(--ink-600); }

.empty-state { text-align: center; padding: 40px 20px; color: var(--ink-400); }
.empty-state .e-ico { font-size: 40px; margin-bottom: 10px; }
.rating-row { display: flex; gap: 6px; font-size: 22px; }
.profile-card { background: white; border-radius: var(--radius-lg); padding: 18px; box-shadow: var(--shadow-card); display: flex; align-items: center; gap: 14px; }
.profile-gradient-topbar { background: linear-gradient(135deg, var(--purple-500), var(--profile-pink)); border-bottom: none; }
.pf-vip-chip { background: rgba(255,255,255,0.2); border: 1px solid rgba(255,255,255,0.5); border-radius: 20px; padding: 6px 12px; font-size: 12px; font-weight: 700; }
.pi-avatar-wrap { position: relative; display: flex; flex-direction: column; align-items: center; margin: 10px 0 34px; }
.pi-avatar-ring { width: 116px; height: 116px; border-radius: 50%; background: #F9DCD5; display: flex; align-items: center; justify-content: center; }
.pi-avatar-circle { width: 96px; height: 96px; border-radius: 50%; background: var(--profile-avatar); color: white; font-size: 15px; font-weight: 800; display: flex; align-items: center; justify-content: center; box-shadow: var(--shadow-soft); padding: 0 6px; text-align: center; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.pi-avatar-circle img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
.pi-avatar-edit-btn { position: absolute; left: 50%; top: 78px; transform: translateX(22px); width: 30px; height: 30px; border-radius: 50%; background: white; border: 2px solid var(--profile-orange); color: var(--profile-orange); font-size: 14px; display: flex; align-items: center; justify-content: center; cursor: pointer; box-shadow: var(--shadow-soft); padding: 0; }
.pi-avatar-edit-btn:disabled { opacity: 0.6; cursor: default; }
.pi-vip-tag { position: absolute; left: 50%; bottom: -2px; transform: translateX(6px); background: linear-gradient(120deg, #FFB020, var(--profile-orange)); color: white; font-weight: 800; font-size: 12px; padding: 5px 14px; border-radius: 20px; box-shadow: 0 4px 10px rgba(255,90,31,0.35); }
.pi-field { background: white; border-radius: var(--radius-md); box-shadow: var(--shadow-card); padding: 14px 16px; margin-bottom: 10px; }
.pi-label { font-size: 11.5px; color: var(--ink-400); margin-bottom: 4px; }
.pi-value { font-size: 14px; font-weight: 700; color: var(--ink-900); }
.profile-avatar { width: 56px; height: 56px; border-radius: 50%; background: var(--purple-100); display: flex; align-items: center; justify-content: center; font-size: 24px; color: var(--purple-600); }
.settings-list { margin-top: 16px; background: white; border-radius: var(--radius-md); box-shadow: var(--shadow-card); overflow: hidden; }
.settings-row { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; font-size: 13.5px; font-weight: 600; border-bottom: 1px solid #F1EEFB; cursor: pointer; }
.settings-row:last-child { border-bottom: none; }
.settings-row .left { display: flex; align-items: center; gap: 10px; }

/* =====================================================================
   DESKTOP LAYOUT — Lazmall (shop view only)
   The rest of the app (support/chat/tickets) stays the original
   phone-width (480px) layout intentionally; only the shop view widens
   into a marketplace-style desktop layout above 960px.
   ===================================================================== */
.shop-nav-links { display: none; }

/* Mobile shop header: logo | search pill (flex) | TH lang toggle | bell | cart.
   Wallet stays reachable from the sticky bottom nav ("ถอนเงิน") and Profile on
   mobile, so the header row itself stays compact like a typical marketplace app. */
#view-shop .shop-topbar { gap: 8px; padding: 10px 12px; }
#view-shop .shop-topbar .brand { flex-shrink: 0; gap: 6px; }
#view-shop .shop-topbar .brand .logo.shop-logo { width: 28px; height: 28px; }
#view-shop .shop-topbar .brand .brand-name-dynamic { font-size: 14px; white-space: nowrap; }
.shop-search-top-wrap {
  display: flex; align-items: center; gap: 6px; flex: 1; min-width: 0;
  background: var(--paper); border: 1px solid #E3DEF7; border-radius: 20px; padding: 7px 6px 7px 12px;
}
.ssw-search-ico { flex-shrink: 0; color: var(--ink-400); }
#shop-search-top { flex: 1; min-width: 0; border: none; background: none; outline: none; font-size: 12.5px; font-family: inherit; color: var(--ink-900); }
.shop-search-top-wrap .search-camera-btn {
  background: var(--purple-600); color: white; border: none; border-radius: 50%;
  width: 26px; height: 26px; font-size: 11px; cursor: pointer; flex-shrink: 0; display: flex; align-items: center; justify-content: center; padding: 0;
}
.lang-toggle-btn {
  flex-shrink: 0; height: 30px; border-radius: 20px; border: 1.5px solid #E3DEF7; background: var(--white);
  color: var(--ink-600); font-size: 10.5px; font-weight: 800; cursor: pointer; display: flex; align-items: center; gap: 4px; justify-content: center; padding: 0 10px;
}
.lang-toggle-btn::before { content: "🌐"; font-size: 12px; }
#view-shop .shop-topbar .actions { gap: 12px; flex-shrink: 0; }
#view-shop .shop-topbar .wallet-topbar-btn { display: none; }

/* Mobile hero: single full-width banner (no side promo cards, matching a typical
   marketplace app's home banner carousel) — the side promo cards return on desktop. */
.promo-cards-col { display: none; }
.hero-row .home-hero-banner { flex: 1; }

/* Mobile stats card: 2-column grid (icon + number/label per cell) instead of one
   cramped row of four, so numbers stay legible on narrow phones. */
.home-stats-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 8px; }
.home-stat + .home-stat::before { display: none; }
.home-stat:nth-child(odd)::after {
  content: ""; position: absolute; right: -7px; top: 50%; transform: translateY(-50%);
  width: 1px; height: 28px; background: var(--purple-100);
}

@media (min-width: 960px) {
  #app:has(#view-shop.active), #app:has(#view-products.active) {
    max-width: 1280px;
    box-shadow: 0 0 60px rgba(0,0,0,0.12);
  }

  /* ---- Top nav bar: logo | nav links | search | language pill | icons ---- */
  #view-shop .shop-topbar {
    padding: 14px 32px;
    gap: 24px;
    justify-content: flex-start;
  }
  #view-shop .shop-topbar .brand { flex-shrink: 0; }
  #view-shop .shop-topbar .brand .logo.shop-logo { width: 34px; height: 34px; }
  #view-shop .shop-topbar .brand .brand-name-dynamic { font-size: 18px; }
  .shop-nav-links {
    display: flex; align-items: center; gap: 6px; flex-shrink: 0;
  }
  .shop-nav-links a {
    font-size: 13.5px; font-weight: 700; color: var(--ink-600); cursor: pointer; white-space: nowrap;
    padding: 7px 14px; border-radius: 20px; transition: background .15s, color .15s;
  }
  .shop-nav-links a:hover { color: var(--purple-600); }
  .shop-nav-links a.active { background: var(--purple-100); color: var(--purple-700); }
  .shop-search-top-wrap {
    gap: 8px; flex: 1; max-width: 380px; margin-left: 4px;
    border: 1.5px solid #E7E4F2; background: var(--white); border-radius: 24px; padding: 6px 8px 6px 18px;
  }
  #shop-search-top { font-size: 13px; }
  .shop-search-top-wrap .search-camera-btn {
    width: 30px; height: 30px; font-size: 13px;
  }
  /* Language selector: outlined globe+TH pill sitting next to the icon actions
     (matches the reference desktop header) instead of the mobile-only circular button. */
  .lang-toggle-btn {
    display: flex; align-items: center; gap: 5px; width: auto; height: 36px; border-radius: 20px;
    border: 1.5px solid #E3DEF7; background: var(--white); color: var(--ink-600); font-size: 13px; font-weight: 700; padding: 0 14px;
  }
  .lang-toggle-btn::before { content: "🌐"; font-size: 14px; }
  #view-shop .shop-topbar .actions { flex-shrink: 0; gap: 14px; margin-left: auto; }
  #view-shop .shop-topbar .wallet-topbar-btn { display: none; }

  /* ---- Content gets desktop gutters ---- */
  #view-shop .content, #view-products .content { padding: 28px 32px 100px; }

  /* ---- Hero row: taller banner + side promo cards return on desktop ---- */
  .hero-row { gap: 20px; }
  .hero-row .home-hero-banner { flex: 2; }
  .hero-row .home-hero-banner .shop-banner { min-height: 260px; padding: 32px; }
  .hero-row .home-hero-banner-img { height: auto; }
  .shop-banner h2 { font-size: 30px; }
  .shop-banner p { font-size: 14px; }
  .promo-cards-col { display: flex; gap: 12px; }
  .promo-card { padding: 18px 20px; }
  .promo-card .pc-title { font-size: 15px; }
  .promo-card .pc-sub { font-size: 11.5px; }

  /* ---- Stats & trust badges: back to one row, breathing room ---- */
  .home-stats-row { display: flex; padding: 26px 4px 14px; }
  .home-stat + .home-stat::before { display: block; }
  .home-stat:nth-child(odd)::after { display: none; }
  .trust-badge-row { padding: 4px 4px 22px; }

  /* ---- Hide the secondary mobile search bar (replaced by topbar search) ---- */
  #view-shop .search-bar-row { display: none; }

  /* ---- Flash sale: grid instead of horizontal scroll ---- */
  .flash-product-row {
    flex-wrap: wrap; overflow: visible; gap: 16px;
  }
  .flash-product-card { min-width: 0; max-width: none; flex: 1 1 calc(16.6% - 14px); padding: 0 10px 12px; }
  .flash-product-card .fp-icon { height: 150px; }
  .flash-product-card .fp-name { font-size: 12.5px; min-height: 32px; }

  /* ---- Popular products: keep the same 4-column grid as mobile (matches the reference design at any width) ---- */
  .popular-thumb-card .pt-image { height: 130px; }

  /* ---- Main product grid: keep the same 2-column grid as mobile (matches the reference design at any width) ---- */
  .product-card .pc-image { height: 160px; }

  /* ---- Footer: nav columns side by side with more breathing room ---- */
  .shop-footer-full { margin: 24px 0 40px; padding-top: 28px; }
  .sf-nav-cols { flex-wrap: nowrap; gap: 48px; margin: 24px 0; }
  .sf-col { min-width: 0; }
  .sf-payment-block { margin: 10px 0 20px; }

  /* ---- Floating pill nav: a bit roomier on desktop ---- */
  .shop-sticky-nav { bottom: calc(20px + env(safe-area-inset-bottom)); width: calc(100% - 48px); }
  .ssn-item { font-size: 12.5px; padding: 10px 16px; }
}

/* ---------- Image viewer (lightbox) — tap any photo (chat images, product photo, etc.)
   to view it full-size. Previously there was no way to enlarge a picture anywhere in
   the customer app. ---------- */
.msg-image, .zoomable-img { cursor: zoom-in; }
.img-viewer-overlay {
  position: fixed; inset: 0; background: rgba(10,10,18,0.92); z-index: 999;
  display: flex; align-items: center; justify-content: center; padding: 28px;
  cursor: zoom-out; animation: imgViewerFadeIn .15s ease;
}
@keyframes imgViewerFadeIn { from { opacity: 0; } to { opacity: 1; } }
.img-viewer-overlay img { max-width: 100%; max-height: 100%; border-radius: 14px; box-shadow: 0 20px 60px rgba(0,0,0,0.5); cursor: default; }
.img-viewer-close {
  position: absolute; top: max(18px, env(safe-area-inset-top)); right: 18px; width: 40px; height: 40px; border-radius: 50%;
  border: none; background: rgba(255,255,255,0.15); color: white; font-size: 18px; cursor: pointer;
  display: flex; align-items: center; justify-content: center; backdrop-filter: blur(4px);
}
.img-viewer-close:hover { background: rgba(255,255,255,0.3); }
.img-viewer-toolbar {
  position: absolute; bottom: max(18px, env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%);
  display: flex; gap: 10px; cursor: default;
}
.img-viewer-toolbar button {
  border: none; background: rgba(255,255,255,0.15); color: white; font-size: 12.5px; font-weight: 700;
  padding: 10px 16px; border-radius: 20px; cursor: pointer; backdrop-filter: blur(4px); white-space: nowrap;
}
.img-viewer-toolbar button:hover { background: rgba(255,255,255,0.3); }
