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

:root {
  --red: #E60012;
  --red-dark: #C4000F;
  --red-light: #fff0f1;
  --bg: #f5f5f5;
  --white: #fff;
  --text: #1a1a1a;
  --muted: #767676;
  --border: #e5e5e5;
  --shadow: 0 2px 12px rgba(0,0,0,.06);
  --shadow-lg: 0 8px 32px rgba(0,0,0,.1);
  --radius: 10px;
  --font: 'Inter', system-ui, -apple-system, sans-serif;
  --nav-h: 60px;
  --header-h: 108px;
  --sat: env(safe-area-inset-top, 0px);
  --sar: env(safe-area-inset-right, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
}

html { scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  padding-bottom: calc(var(--nav-h) + var(--sab));
}

@media (min-width: 769px) { body { padding-bottom: 0; } }

.wrap { max-width: 1100px; margin: 0 auto; padding: 0 16px; }
a { color: inherit; text-decoration: none; }
button, input { font: inherit; }
button { cursor: pointer; border: none; background: none; }
img { display: block; max-width: 100%; }

.hide-desktop { display: none; }
@media (max-width: 768px) { .hide-desktop { display: flex; } }

/* Ticker */
.ticker {
  background: var(--red);
  color: #fff;
  overflow: hidden;
  font-size: 0.75rem;
  font-weight: 600;
  height: 28px;
  display: flex;
  align-items: center;
}

.ticker__track {
  display: flex;
  gap: 48px;
  white-space: nowrap;
  animation: ticker 25s linear infinite;
}

.ticker__track span { flex-shrink: 0; }

@keyframes ticker {
  0% { transform: translateX(0); }
  100% { transform: translateX(-50%); }
}

/* Header — white like tops.co.th */
.header {
  background: var(--white);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: var(--shadow);
  padding-top: var(--sat);
  padding-left: var(--sal);
  padding-right: var(--sar);
}

.header__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 0 8px;
}

.header__actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.header__search-row {
  padding-bottom: 10px;
}

.header__inner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
}

.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.logo__mark { flex-shrink: 0; }

.logo__text {
  font-weight: 800;
  font-size: 1.35rem;
  letter-spacing: -0.03em;
  color: var(--red);
  line-height: 1;
}

.logo__text em {
  font-style: normal;
  font-weight: 500;
  font-size: 0.65rem;
  color: var(--text);
  display: block;
  letter-spacing: 0;
  margin-top: 1px;
}

.search {
  flex: 1;
  min-width: 0;
  position: relative;
  display: flex;
  align-items: center;
}

.search__icon {
  position: absolute;
  left: 12px;
  color: var(--muted);
  pointer-events: none;
}

.search input {
  width: 100%;
  padding: 10px 12px 10px 38px;
  border: 1.5px solid var(--border);
  border-radius: 24px;
  font-size: 16px;
  background: var(--bg);
  transition: border-color .15s, box-shadow .15s;
}

.search input:focus {
  outline: none;
  border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(230,0,18,.1);
  background: var(--white);
}

.cart-btn {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  color: var(--text);
  transition: background .15s;
  flex-shrink: 0;
}

.cart-btn:hover { background: var(--bg); }

.cart-btn [data-cart-count] {
  position: absolute;
  top: 2px; right: 2px;
  background: var(--red);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--white);
}

.cart-btn [data-cart-count][hidden] { display: none; }

.header-auth {
  flex-shrink: 0;
  padding: 10px 14px;
  border-radius: 20px;
  background: var(--red);
  color: #fff;
  font-size: 0.8rem;
  font-weight: 700;
  white-space: nowrap;
  text-decoration: none;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
}

.header-auth:active { opacity: 0.85; }

.header-auth__short { display: none; }

@media (max-width: 768px) {
  .header__inner { display: none; }

  .logo__text {
    font-size: 1.05rem;
  }

  .logo__text em {
    font-size: 0.58rem;
  }

  .header-auth__long { display: none; }
  .header-auth__short { display: inline; }

  .header-auth {
    padding: 10px 12px;
    font-size: 0.78rem;
  }

  .delivery {
    padding-bottom: 8px;
  }
}

@media (min-width: 769px) {
  .header__top,
  .header__search-row { display: none; }
}

.shop-install {
  position: fixed;
  bottom: calc(var(--nav-h) + 12px + env(safe-area-inset-bottom, 0px));
  left: 50%;
  transform: translateX(-50%);
  z-index: 35;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  border: none;
  border-radius: 24px;
  background: var(--red);
  color: #fff;
  font-weight: 700;
  font-size: 0.85rem;
  box-shadow: var(--shadow-lg);
  font-family: inherit;
}

.shop-install[hidden] { display: none; }

.shop-install:active { opacity: 0.9; }

@media (min-width: 769px) {
  .shop-install { bottom: 24px; }
}

.install-modal {
  position: fixed;
  inset: 0;
  z-index: 300;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 16px;
  padding-bottom: calc(16px + env(safe-area-inset-bottom));
}

.install-modal[hidden] { display: none !important; }

.install-modal__box {
  background: #fff;
  color: var(--text);
  border-radius: 16px;
  padding: 24px 20px;
  width: 100%;
  max-width: 400px;
  position: relative;
  text-align: center;
}

.install-modal__close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 36px;
  height: 36px;
  border: none;
  background: #f0f0f0;
  border-radius: 50%;
  font-size: 1.25rem;
  cursor: pointer;
}

.install-modal__icon img { border-radius: 14px; margin: 0 auto 12px; }
.install-modal__sub { font-size: 0.85rem; color: var(--muted); margin-bottom: 16px; }

.install-steps {
  text-align: left;
  background: #f8f8f8;
  border-radius: 12px;
  padding: 14px 16px 14px 28px;
  margin-bottom: 16px;
}

.install-steps[hidden] { display: none; }
.install-steps__title { font-weight: 700; font-size: 0.9rem; margin-bottom: 8px; margin-left: -12px; color: var(--red); }
.install-steps ol { font-size: 0.85rem; line-height: 1.6; }

.install-modal__ok {
  width: 100%;
  padding: 14px;
  background: var(--red);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-weight: 700;
  font-size: 1rem;
  cursor: pointer;
}

.delivery {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0 0 10px;
  font-size: 0.8rem;
  flex-wrap: wrap;
}

.delivery__loc {
  display: flex;
  align-items: center;
  gap: 4px;
  color: var(--muted);
  font-weight: 500;
}

.delivery__loc svg { color: var(--red); flex-shrink: 0; }

.delivery__tabs { display: flex; gap: 4px; }

.delivery-tab {
  padding: 5px 12px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  background: var(--bg);
  color: var(--muted);
  border: 1px solid var(--border);
  transition: all .15s;
}

.delivery-tab.is-active {
  background: var(--red);
  border-color: var(--red);
  color: #fff;
}

/* Hero */
.hero {
  background: linear-gradient(135deg, var(--red) 0%, #ff3344 50%, #ff6b6b 100%);
  color: #fff;
  padding: 24px 0 0;
  overflow: hidden;
}

.hero__inner {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  align-items: center;
}

@media (min-width: 700px) {
  .hero__inner { grid-template-columns: 1fr 1fr; padding-bottom: 24px; }
}

.hero__content { padding-bottom: 24px; }

.hero__badge {
  display: inline-block;
  background: rgba(255,255,255,.2);
  backdrop-filter: blur(4px);
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 700;
  margin-bottom: 12px;
}

.hero h1 {
  font-size: clamp(1.5rem, 4vw, 2.25rem);
  font-weight: 800;
  line-height: 1.15;
  margin-bottom: 8px;
  letter-spacing: -0.02em;
}

.hero__content p {
  font-size: 0.95rem;
  opacity: 0.9;
  margin-bottom: 16px;
}

.hero__cta {
  display: inline-block;
  background: var(--white);
  color: var(--red);
  font-weight: 700;
  font-size: 0.9rem;
  padding: 12px 24px;
  border-radius: 24px;
  box-shadow: var(--shadow-lg);
  transition: transform .15s;
}

.hero__cta:active { transform: scale(.97); }

.hero__visual {
  border-radius: var(--radius) var(--radius) 0 0;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  max-height: 220px;
}

@media (min-width: 700px) {
  .hero__visual { border-radius: var(--radius); max-height: 280px; }
}

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

/* Trust strip */
.trust {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1px;
  background: var(--border);
  margin: -1px 0 20px;
  border-radius: 0 0 var(--radius) var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}

@media (min-width: 600px) {
  .trust { grid-template-columns: repeat(4, 1fr); margin: -12px auto 24px; border-radius: var(--radius); max-width: calc(1100px - 32px); }
}

.trust__item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 14px 8px;
  background: var(--white);
  text-align: center;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text);
}

.trust__item svg { flex-shrink: 0; }

/* Sections */
.section { margin-bottom: 28px; }

.section__title {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 12px;
  letter-spacing: -0.01em;
}

/* Coupons */
.coupons {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 4px;
}

.coupons::-webkit-scrollbar { display: none; }

.coupon {
  flex: 0 0 auto;
  min-width: 150px;
  background: var(--white);
  border: 2px dashed var(--red);
  border-radius: var(--radius);
  padding: 14px 12px;
  text-align: center;
  box-shadow: var(--shadow);
}

.coupon__val {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--red);
  line-height: 1.1;
}

.coupon__val small {
  display: block;
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--muted);
  margin-top: 2px;
}

.coupon p { font-size: 0.72rem; color: var(--muted); margin: 6px 0 10px; }

.coupon__btn {
  width: 100%;
  padding: 7px;
  background: var(--red);
  color: #fff;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 600;
  transition: background .15s;
}

.coupon__btn:active { background: var(--red-dark); }

/* Categories */
.cats {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  margin-bottom: 16px;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 4px;
}

.cats::-webkit-scrollbar { display: none; }

.cat {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: var(--white);
  border: 1.5px solid var(--border);
  border-radius: 24px;
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
  transition: all .15s;
  box-shadow: var(--shadow);
}

.cat__emoji { font-size: 1rem; line-height: 1; }

.cat.is-active {
  background: var(--red);
  border-color: var(--red);
  color: #fff;
}

/* Grid */
.grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

@media (min-width: 600px) {
  .grid { grid-template-columns: repeat(3, 1fr); gap: 14px; }
}

@media (min-width: 900px) {
  .grid { grid-template-columns: repeat(4, 1fr); }
}

.card {
  background: var(--white);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform .15s, box-shadow .15s;
  border: 1px solid transparent;
}

.card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
  border-color: var(--border);
}

.card__img {
  aspect-ratio: 1;
  background: #fafafa;
  position: relative;
  overflow: hidden;
}

.card__img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform .3s;
}

.card:hover .card__img img { transform: scale(1.04); }

.tag {
  position: absolute;
  top: 8px; left: 8px;
  font-size: 9px;
  font-weight: 700;
  padding: 3px 7px;
  border-radius: 4px;
  background: var(--red);
  color: #fff;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.tag--disc { left: auto; right: 8px; background: #222; }

.card__body { padding: 10px 12px 12px; }

.card__name {
  font-size: 0.82rem;
  font-weight: 600;
  line-height: 1.3;
  margin-bottom: 6px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 2.1em;
}

.card__price {
  display: flex;
  align-items: baseline;
  gap: 5px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.card__price strong { color: var(--red); font-size: 1rem; font-weight: 800; }
.card__price s { font-size: 0.72rem; color: var(--muted); }
.card__unit { font-size: 0.65rem; color: var(--muted); }

.card__add {
  width: 100%;
  padding: 8px;
  background: var(--red-light);
  border: 1.5px solid transparent;
  border-radius: 8px;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--red);
  transition: all .15s;
}

.card__add:hover { background: var(--red); color: #fff; }

.empty {
  grid-column: 1 / -1;
  text-align: center;
  color: var(--muted);
  padding: 48px 16px;
  background: var(--white);
  border-radius: var(--radius);
}

/* Footer */
.footer {
  background: var(--white);
  border-top: 1px solid var(--border);
  margin-top: 32px;
  padding-top: 32px;
}

.footer__grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 24px;
  margin-bottom: 24px;
}

@media (min-width: 600px) {
  .footer__grid { grid-template-columns: 2fr 1fr 1fr; }
}

.footer__logo {
  font-size: 1.5rem;
  color: var(--red);
  display: block;
  margin-bottom: 8px;
}

.footer__brand p { font-size: 0.85rem; color: var(--muted); max-width: 280px; }

.footer__col h3 {
  font-size: 0.85rem;
  font-weight: 700;
  margin-bottom: 10px;
}

.footer__col a {
  display: block;
  font-size: 0.82rem;
  color: var(--muted);
  padding: 3px 0;
  transition: color .15s;
}

.footer__col a:hover { color: var(--red); }

.footer__copy {
  border-top: 1px solid var(--border);
  padding: 16px 0 24px;
  text-align: center;
}

.footer__copy small { font-size: 0.75rem; color: var(--muted); }

/* Bottom nav */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  display: flex;
  background: var(--white);
  border-top: 1px solid var(--border);
  padding-bottom: var(--sab);
  padding-left: var(--sal);
  padding-right: var(--sar);
  z-index: 40;
  box-shadow: 0 -4px 16px rgba(0,0,0,.06);
}

.bottom-nav__item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 8px 4px;
  font-size: 10px;
  font-weight: 600;
  color: var(--muted);
  min-height: var(--nav-h);
  transition: color .15s;
}

.bottom-nav__item.is-active { color: var(--red); }
.bottom-nav__item svg { flex-shrink: 0; }

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(0,0,0,.45);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity .2s, visibility .2s;
}

.modal[data-open="1"] {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.modal__box {
  background: var(--white);
  width: 100%;
  max-width: 480px;
  max-height: 85vh;
  overflow-y: auto;
  border-radius: 16px 16px 0 0;
  padding: 20px;
  position: relative;
}

@media (min-width: 769px) {
  .modal { align-items: center; padding: 16px; }
  .modal__box { border-radius: var(--radius); max-height: 90vh; }
}

.modal__x {
  position: absolute;
  top: 12px; right: 12px;
  width: 36px; height: 36px;
  background: var(--bg);
  border-radius: 50%;
  font-size: 1.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1;
}

.modal__img {
  width: 100%;
  max-height: 240px;
  object-fit: cover;
  border-radius: var(--radius);
  margin-bottom: 14px;
}

.modal__cat { font-size: 0.7rem; color: var(--red); font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; }

.modal__box h2 { font-size: 1.15rem; font-weight: 700; margin: 4px 0 10px; }

.modal__price { margin-bottom: 8px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.modal__price strong { color: var(--red); font-size: 1.35rem; font-weight: 800; }
.modal__price s { color: var(--muted); }

.modal__unit { font-size: 0.82rem; color: var(--muted); margin-bottom: 14px; }

.modal__qty {
  display: inline-flex;
  align-items: center;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 14px;
  overflow: hidden;
}

.modal__qty button {
  width: 40px; height: 40px;
  background: var(--bg);
  font-size: 1.1rem;
  font-weight: 600;
}

.modal__qty span { min-width: 36px; text-align: center; font-weight: 700; }

.modal__add {
  width: 100%;
  padding: 14px;
  background: var(--red);
  color: #fff;
  border-radius: var(--radius);
  font-weight: 700;
  font-size: 0.95rem;
  transition: background .15s;
}

.modal__add:active { background: var(--red-dark); }

/* Cart */
.backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.4);
  z-index: 60;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity .25s, visibility .25s;
}

#cart[data-open="1"] + .backdrop {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.cart {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: min(100%, 400px);
  background: var(--white);
  z-index: 70;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.3s cubic-bezier(.4,0,.2,1);
  box-shadow: -8px 0 32px rgba(0,0,0,.12);
}

.cart[data-open="1"] { transform: translateX(0); }

.cart__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(16px + var(--sat)) calc(20px + var(--sar)) 16px calc(20px + var(--sal));
  background: var(--red);
  color: #fff;
}

.cart__head h2 { font-size: 1.05rem; font-weight: 700; }

.cart__head button {
  color: #fff;
  font-size: 1.5rem;
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.cart__list {
  flex: 1;
  overflow-y: auto;
  padding: 12px 20px;
}

.cart-empty { text-align: center; color: var(--muted); padding: 40px 16px; }

.cart-row {
  display: grid;
  grid-template-columns: 56px 1fr auto;
  gap: 10px;
  align-items: start;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
}

.cart-row img {
  width: 56px;
  height: 56px;
  object-fit: cover;
  border-radius: 8px;
  background: var(--bg);
}

.cart-row__info strong { display: block; font-size: 0.82rem; font-weight: 600; margin-bottom: 2px; }
.cart-row__info span { color: var(--muted); font-size: 0.72rem; }
.cart-row__info em { color: var(--red); font-weight: 700; font-style: normal; display: block; margin-top: 4px; }

.cart-row__qty {
  display: flex;
  align-items: center;
  gap: 6px;
  grid-column: 2 / -1;
  margin-top: 4px;
}

.cart-row__qty button {
  width: 30px; height: 30px;
  background: var(--bg);
  border-radius: 6px;
  font-weight: 600;
  border: 1px solid var(--border);
}

.cart-row__rm {
  color: var(--muted);
  font-size: 1.1rem;
  padding: 4px;
  margin-left: 4px;
}

.cart__foot {
  padding: 16px calc(20px + var(--sar)) calc(16px + var(--sab)) calc(20px + var(--sal));
  border-top: 1px solid var(--border);
  background: var(--bg);
}

.cart__row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 8px;
  font-size: 1.05rem;
  font-weight: 600;
}

.cart__row strong { color: var(--red); font-size: 1.2rem; }

.cart__note { font-size: 0.75rem; color: var(--muted); margin-bottom: 12px; }

#checkout {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

#checkout input {
  padding: 11px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: 16px;
  background: var(--white);
}

#checkout input:focus {
  outline: none;
  border-color: var(--red);
}

#checkout button {
  padding: 14px;
  background: var(--red);
  color: #fff;
  border-radius: var(--radius);
  font-weight: 700;
  font-size: 0.95rem;
  margin-top: 4px;
  transition: background .15s;
}

#checkout button:active { background: var(--red-dark); }

/* Toast */
.toast {
  position: fixed;
  bottom: calc(var(--nav-h) + 16px + env(safe-area-inset-bottom, 0px));
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: #222;
  color: #fff;
  padding: 11px 22px;
  border-radius: 24px;
  font-size: 0.85rem;
  font-weight: 500;
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s, transform .25s;
  white-space: nowrap;
  box-shadow: var(--shadow-lg);
}

@media (min-width: 769px) {
  .toast { bottom: 28px; }
}

.toast[data-show="1"] {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
