@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800;900&display=swap');

:root {
  --yellow: #ffc800;
  --yellow-soft: #fff8e1;
  --yellow-deep: #e6a800;
  --red: #e53935;
  --red-deep: #c62828;
  --red-soft: #ffebee;
  --ink: #1a1a1a;
  --ink-secondary: #3d3d3d;
  --muted: #757575;
  --bg: #fffdf7;
  --bg-warm: #fff9e8;
  --card: #ffffff;
  --line: #f5f0e0;
  --line-strong: #ebe3cc;
  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 2px 8px rgba(0,0,0,0.04), 0 4px 16px rgba(0,0,0,0.03);
  --shadow-md: 0 6px 20px rgba(180,100,0,0.08), 0 2px 6px rgba(0,0,0,0.04);
  --shadow-lg: 0 12px 36px rgba(180,100,0,0.12), 0 4px 12px rgba(0,0,0,0.06);
  --shadow-red: 0 6px 20px rgba(229,57,53,0.25);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --font: 'Inter', system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overscroll-behavior-y: none;
  padding-bottom: env(safe-area-inset-bottom);
  letter-spacing: -0.01em;
}
.modal-open { overflow: hidden; }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
img { max-width: 100%; display: block; }

/* ---------- Header ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--yellow);
  padding-top: env(safe-area-inset-top);
  box-shadow: 0 2px 12px rgba(200,140,0,0.18);
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  max-width: 960px;
  margin: 0 auto;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 900; font-size: 1.2rem; color: var(--red-deep); letter-spacing: -0.03em; }
.brand-text em { font-style: normal; color: var(--ink); }
.brand-mark { font-size: 1.4rem; }
.brand-logo { width: 42px; height: 42px; border-radius: 50%; object-fit: cover; background: #fff; box-shadow: 0 2px 8px rgba(0,0,0,0.1); }
.cart-btn {
  position: relative;
  border: none;
  background: var(--red);
  color: #fff;
  width: 44px; height: 44px;
  border-radius: 50%;
  font-size: 1.1rem;
  display: grid; place-items: center;
  box-shadow: var(--shadow-red);
  transition: transform 0.15s var(--ease), box-shadow 0.15s var(--ease);
}
.cart-btn:active { transform: scale(0.9); }
.cart-count {
  position: absolute; top: -4px; right: -4px;
  background: #fff; color: var(--red);
  min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 9px; font-size: 0.66rem; font-weight: 800;
  display: grid; place-items: center; border: 2px solid var(--red);
}
.toolbar { display: flex; gap: 8px; padding: 8px 16px 10px; max-width: 960px; margin: 0 auto; }
.search, .sort {
  border: none;
  background: rgba(255,255,255,0.85);
  border-radius: 12px;
  padding: 11px 14px;
  font-size: 0.9rem;
  font-weight: 500;
  transition: background 0.15s var(--ease), box-shadow 0.15s var(--ease);
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.04);
}
.search:focus, .sort:focus {
  outline: none;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(229,57,53,0.12), inset 0 0 0 1px var(--red);
}
.search { flex: 1; min-width: 0; }
.sort { flex-shrink: 0; }

/* Category chips */
.category-bar { display: flex; gap: 8px; padding: 4px 16px 12px; overflow-x: auto; -webkit-overflow-scrolling: touch; max-width: 960px; margin: 0 auto; }
.category-bar:empty { display: none; }
.chip {
  flex-shrink: 0; border: none; background: rgba(255,255,255,0.7); color: var(--ink-secondary);
  border-radius: 20px; padding: 7px 16px; font-size: 0.8rem; font-weight: 700; white-space: nowrap;
  transition: all 0.15s var(--ease);
}
.chip:hover { background: #fff; }
.chip:active { transform: scale(0.94); }
.chip.active { background: var(--red); color: #fff; box-shadow: 0 3px 10px rgba(229,57,53,0.3); }

/* ---------- Grid ---------- */
.container { max-width: 960px; margin: 0 auto; padding: 16px 12px 40px; }
.grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}
@media (min-width: 620px) { .grid { grid-template-columns: repeat(3, 1fr); gap: 14px; } }
@media (min-width: 860px) { .grid { grid-template-columns: repeat(4, 1fr); gap: 16px; } }

.card {
  background: var(--card);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  position: relative;
  transition: transform 0.2s var(--ease), box-shadow 0.2s var(--ease);
  animation: cardIn 0.3s var(--ease) both;
}
@keyframes cardIn { from { opacity: 0; transform: translateY(8px) scale(0.97); } to { opacity: 1; transform: none; } }
@media (hover: hover) and (pointer: fine) {
  .card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); }
  .card:hover .card-media img { transform: scale(1.05); }
}
.card:active { transform: translateY(-1px) scale(0.99); }
.card-media {
  aspect-ratio: 1 / 1;
  background: linear-gradient(145deg, var(--yellow-soft), #fff3c4);
  display: grid; place-items: center;
  overflow: hidden;
  position: relative;
}
.card-media img { width: 100%; height: 100%; object-fit: cover; transition: transform 0.4s var(--ease); }
.card-media .ph { font-size: 2.4rem; opacity: 0.4; }
.badges { position: absolute; top: 8px; right: 8px; display: flex; flex-direction: column; gap: 4px; align-items: flex-end; }
.badge {
  font-size: 0.62rem; font-weight: 800; text-transform: uppercase;
  padding: 4px 8px; border-radius: 6px; color: #fff; letter-spacing: 0.04em;
  backdrop-filter: blur(4px);
}
.badge.sale { background: var(--red); }
.badge.feat { background: linear-gradient(135deg, #ff8a00, var(--red)); }
.badge.tag { background: rgba(255,255,255,0.9); color: var(--ink-secondary); backdrop-filter: blur(8px); }
.card-body { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 3px; flex: 1; }
.card-name { font-weight: 700; font-size: 0.88rem; color: var(--ink); line-height: 1.3; letter-spacing: -0.01em; }
.card-unit { color: var(--muted); font-size: 0.7rem; font-weight: 500; }
.rating { font-size: 0.7rem; color: var(--muted); font-weight: 500; }
.stars { color: var(--yellow-deep); letter-spacing: 0.5px; }
.price-row { display: flex; align-items: baseline; gap: 4px; margin-top: auto; padding-top: 4px; }
.price { font-weight: 900; color: var(--red-deep); font-size: 1.02rem; letter-spacing: -0.02em; }
.price-range { font-weight: 700; color: var(--red-deep); font-size: 0.82rem; opacity: 0.7; }
.price-old { color: var(--muted); text-decoration: line-through; font-size: 0.76rem; }
.card-options { font-size: 0.68rem; font-weight: 700; color: var(--red); background: var(--red-soft); display: inline-block; padding: 2px 8px; border-radius: 6px; margin-top: 4px; }
.soldout { color: var(--red); font-weight: 700; font-size: 0.78rem; }

.empty { text-align: center; color: var(--muted); padding: 40px 0; font-size: 0.9rem; }

/* Card floating ADD / stepper */
.card-action { position: absolute; right: 8px; bottom: 8px; z-index: 2; }
.add-fab {
  background: #fff; color: var(--red-deep); font-weight: 800; font-size: 0.76rem;
  letter-spacing: 0.3px; padding: 7px 16px; border-radius: 10px; border: 1.5px solid var(--red);
  box-shadow: 0 3px 10px rgba(229,57,53,0.2); transition: all 0.12s var(--ease);
}
.add-fab:hover { background: var(--red-soft); }
.add-fab:active { transform: scale(0.9); }
.stepper {
  display: inline-flex; align-items: center; background: var(--red); border-radius: 10px;
  box-shadow: 0 3px 10px rgba(229,57,53,0.3); overflow: hidden;
}
.stepper button { border: none; background: transparent; color: #fff; font-weight: 800; font-size: 1rem; width: 32px; height: 32px; transition: background 0.12s; }
.stepper button:active { background: rgba(0,0,0,0.15); }
.stepper-n { color: #fff; font-weight: 800; min-width: 20px; text-align: center; font-size: 0.82rem; }
.soldout-chip { background: rgba(0,0,0,0.6); color: #fff; font-size: 0.68rem; font-weight: 600; padding: 5px 10px; border-radius: 8px; backdrop-filter: blur(4px); }

/* Discount badge */
.disc-badge {
  position: absolute; top: 8px; left: 8px; z-index: 2;
  background: var(--red); color: #fff; font-weight: 900; font-size: 0.78rem;
  padding: 5px 8px; border-radius: 8px; line-height: 1; box-shadow: 0 2px 8px rgba(229,57,53,0.3); text-align: center;
}
.disc-badge span { display: block; font-size: 0.46rem; letter-spacing: 0.5px; margin-top: 1px; text-transform: uppercase; font-weight: 700; }

/* Sticky bottom cart bar */
body.has-cart-bar { padding-bottom: 84px; }
.cart-bar {
  position: fixed; left: 0; right: 0; margin: 0 auto; bottom: calc(12px + env(safe-area-inset-bottom));
  width: calc(100% - 24px); max-width: 680px;
  z-index: 45; display: flex; align-items: center; justify-content: space-between;
  background: var(--red); color: #fff; border: none; border-radius: 16px;
  padding: 14px 20px; box-shadow: 0 8px 28px rgba(229,57,53,0.35);
  animation: barUp 0.28s var(--ease);
}
@keyframes barUp { from { transform: translateY(140%); opacity: 0.6; } to { transform: translateY(0); opacity: 1; } }
.cart-bar-left { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.2; }
.cart-bar-count { font-size: 0.7rem; opacity: 0.85; font-weight: 500; }
.cart-bar-total { font-size: 1.1rem; font-weight: 900; }
.cart-bar-cta { font-weight: 700; font-size: 0.9rem; display: flex; align-items: center; gap: 6px; }
.cart-bar:active { filter: brightness(0.93); transform: scale(0.99); }
.modal-open .cart-bar { display: none !important; }

/* ---------- Sheets / drawers ---------- */
.sheet { position: fixed; inset: 0; z-index: 40; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(20,10,0,0.5); backdrop-filter: blur(3px); animation: fadeIn 0.2s ease; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.sheet-panel {
  position: absolute; left: 0; right: 0; bottom: 0;
  max-height: 88vh; overflow-y: auto; -webkit-overflow-scrolling: touch;
  background: var(--bg);
  border-radius: 24px 24px 0 0;
  padding: 28px 16px calc(24px + env(safe-area-inset-bottom));
  box-shadow: 0 -10px 40px rgba(0,0,0,0.15);
  animation: slideUp 0.3s var(--ease);
}
.sheet-panel::before {
  content: ""; position: absolute; top: 10px; left: 50%; transform: translateX(-50%);
  width: 40px; height: 4px; border-radius: 2px; background: var(--line-strong);
}
.cart-panel {
  position: absolute; top: 0; right: 0; bottom: 0;
  width: min(420px, 92vw);
  background: var(--bg);
  display: flex; flex-direction: column;
  box-shadow: -10px 0 40px rgba(0,0,0,0.12);
  animation: slideLeft 0.3s var(--ease);
}
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
@keyframes slideLeft { from { transform: translateX(100%); } to { transform: translateX(0); } }
.sheet-close {
  border: none; background: var(--yellow-soft); color: var(--ink);
  width: 34px; height: 34px; border-radius: 50%; font-size: 0.85rem; font-weight: 800;
  transition: background 0.12s;
}
.sheet-close:active { background: var(--yellow); }
.sheet-panel .sheet-close { position: sticky; top: 0; float: right; z-index: 3; margin-bottom: -34px; }

/* Product detail */
.detail-media { border-radius: var(--radius); overflow: hidden; background: var(--yellow-soft); aspect-ratio: 4/3; display: grid; place-items: center; max-height: 45vh; }
.detail-media img { width: 100%; height: 100%; object-fit: cover; }
.detail-thumbs { display: flex; gap: 8px; margin-top: 10px; overflow-x: auto; }
.detail-thumbs img { width: 56px; height: 56px; border-radius: 10px; object-fit: cover; border: 2.5px solid transparent; transition: border-color 0.15s var(--ease), transform 0.15s var(--ease); }
.detail-thumbs img:active { transform: scale(0.95); }
.detail-thumbs img.active { border-color: var(--red); }
/* Variant selector */
.variant-selector { margin-bottom: 14px; }
.variant-pills { display: flex; gap: 8px; flex-wrap: wrap; }
.variant-pill {
  border: 1.5px solid var(--line-strong); background: #fff; border-radius: 12px;
  padding: 10px 16px; display: flex; flex-direction: column; align-items: center; gap: 2px;
  cursor: pointer; transition: all 0.15s var(--ease); min-width: 70px;
}
.variant-pill:hover { border-color: var(--red); }
.variant-pill.active { border-color: var(--red); background: var(--red-soft); box-shadow: 0 2px 8px rgba(229,57,53,0.15); }
.vp-label { font-weight: 700; font-size: 0.85rem; color: var(--ink); }
.vp-price { font-weight: 800; font-size: 0.8rem; color: var(--red-deep); }

.detail h2 { margin: 16px 0 4px; font-size: 1.35rem; font-weight: 900; letter-spacing: -0.03em; }
.detail .desc { color: var(--muted); font-size: 0.9rem; line-height: 1.6; }
.detail-price { display: flex; align-items: baseline; gap: 8px; margin: 12px 0; }
.detail-price .price { font-size: 1.35rem; }
.section-title { font-weight: 800; margin: 22px 0 10px; color: var(--red-deep); font-size: 0.9rem; letter-spacing: -0.01em; }
.review { border-top: 1px solid var(--line); padding: 12px 0; }
.review .who { font-weight: 700; font-size: 0.88rem; }
.review .when { color: var(--muted); font-size: 0.7rem; }
.review .body { font-size: 0.88rem; margin-top: 3px; color: var(--ink-secondary); line-height: 1.5; }
.review-form { background: #fff; border: 1.5px solid var(--line); border-radius: var(--radius); padding: 14px; margin-top: 12px; }
.star-input { font-size: 1.6rem; color: #e0d6c0; cursor: pointer; }
.star-input span.on { color: var(--yellow-deep); }
.hint { color: var(--muted); font-size: 0.8rem; }

/* Cart items */
.cart-head { display: flex; align-items: center; justify-content: space-between; padding: 16px; background: var(--yellow); }
.cart-head h2 { margin: 0; color: var(--red-deep); font-size: 1.1rem; font-weight: 900; }
.cart-items { flex: 1; overflow-y: auto; padding: 12px 16px; }
.cart-line { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.cart-thumb { width: 48px; height: 48px; border-radius: 10px; object-fit: cover; flex-shrink: 0; background: var(--yellow-soft); }
.cart-thumb-ph { display: grid; place-items: center; font-size: 1.2rem; }
.cart-line .info { flex: 1; min-width: 0; }
.cart-line .nm { font-weight: 700; font-size: 0.88rem; }
.cart-line .pr { color: var(--muted); font-size: 0.78rem; }
.qty { display: flex; align-items: center; gap: 8px; }
.qty button { width: 32px; height: 32px; border-radius: 10px; border: none; background: var(--yellow); font-weight: 800; font-size: 1rem; transition: all 0.12s var(--ease); }
.qty button:active { transform: scale(0.88); background: var(--yellow-deep); }
.qty span { min-width: 20px; text-align: center; font-weight: 800; }
.cart-empty { color: var(--muted); text-align: center; padding: 30px 0; font-size: 0.9rem; }
.cart-foot { border-top: 1px solid var(--line); padding: 16px 16px calc(16px + env(safe-area-inset-bottom)); background: #fff; }
.cart-total { display: flex; justify-content: space-between; font-size: 1.05rem; margin-bottom: 12px; font-weight: 700; }
.cart-total strong { color: var(--red-deep); }
.checkout { display: flex; flex-direction: column; gap: 10px; }
.checkout input, .checkout textarea, .review-form input, .review-form textarea {
  border: 1.5px solid var(--line-strong); border-radius: 12px; padding: 12px 14px; font-size: 0.9rem; font-family: inherit; width: 100%;
  transition: border-color 0.15s var(--ease), box-shadow 0.15s var(--ease);
  background: #fff;
}
.checkout input:focus, .checkout textarea:focus, .review-form input:focus, .review-form textarea:focus {
  outline: none; border-color: var(--red); box-shadow: 0 0 0 3px rgba(229,57,53,0.08);
}
.btn-primary {
  border: none; background: var(--red); color: #fff; font-weight: 800;
  padding: 14px; border-radius: 14px; font-size: 0.95rem;
  box-shadow: var(--shadow-red);
  transition: transform 0.15s var(--ease), box-shadow 0.15s var(--ease), background 0.15s;
  letter-spacing: -0.01em;
}
.btn-primary:hover { background: var(--red-deep); box-shadow: 0 8px 24px rgba(229,57,53,0.3); }
.btn-primary:active { transform: scale(0.97); }
.btn-primary:disabled { opacity: 0.5; box-shadow: none; }

/* Onboarding + saved delivery details */
.onboard-panel { max-width: 460px; margin: 0 auto; }
.onboard-title { margin: 4px 0 2px; color: var(--red-deep); font-size: 1.3rem; font-weight: 900; letter-spacing: -0.02em; }
.onboard-sub { margin: 0 0 16px; color: var(--muted); font-size: 0.9rem; line-height: 1.5; }
.link-btn { border: none; background: transparent; color: var(--red-deep); font-weight: 700; padding: 8px; text-decoration: underline; font-size: 0.88rem; }
.deliver-to { background: var(--yellow-soft); border: 1.5px solid rgba(230,168,0,0.2); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 12px; }
.deliver-head { display: flex; justify-content: space-between; align-items: center; }
.deliver-title { font-weight: 800; color: var(--red-deep); font-size: 0.76rem; text-transform: uppercase; letter-spacing: 0.05em; }
.deliver-summary { font-size: 0.88rem; color: var(--ink); margin-top: 4px; line-height: 1.5; }
.deliver-summary .muted { color: var(--muted); }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 12px 20px; border-radius: 30px;
  z-index: 60; font-size: 0.88rem; box-shadow: var(--shadow-lg); max-width: 90vw; text-align: center;
  font-weight: 600;
}
.toast.err { background: var(--red-deep); }

/* Payment method selector */
.payment-methods { margin: 4px 0; }
.pm-label { font-size: 0.78rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.03em; margin-bottom: 8px; }
.pm-options { display: flex; gap: 8px; }
.pm-option { flex: 1; display: flex; align-items: center; gap: 10px; padding: 12px 14px; border: 1.5px solid var(--line-strong); border-radius: 12px; cursor: pointer; transition: all 0.15s var(--ease); }
.pm-option:hover { border-color: var(--red); }
.pm-option.active { border-color: var(--red); background: var(--red-soft); box-shadow: 0 2px 8px rgba(229,57,53,0.1); }
.pm-icon { font-size: 1.3rem; flex-shrink: 0; }
.pm-text { display: flex; flex-direction: column; font-weight: 700; font-size: 0.82rem; color: var(--ink); line-height: 1.3; }
.pm-text small { font-weight: 500; font-size: 0.7rem; color: var(--muted); margin-top: 1px; }

/* Payment result */
.payment-result { text-align: center; padding: 20px 0; }
.payment-result h2 { margin: 16px 0 8px; font-size: 1.4rem; font-weight: 900; color: var(--ink); }
.pr-icon { width: 64px; height: 64px; border-radius: 50%; margin: 0 auto; display: grid; place-items: center; font-size: 1.6rem; font-weight: 900; color: #fff; }
.pr-success { background: var(--red); box-shadow: 0 4px 16px rgba(229,57,53,0.3); }
.pr-fail { background: #6b7280; box-shadow: 0 4px 16px rgba(107,114,128,0.3); }
.pr-total { font-size: 1.6rem; font-weight: 900; color: var(--red-deep); margin: 12px 0 4px; }
.pr-msg { color: var(--muted); font-size: 0.9rem; line-height: 1.5; margin: 6px 0; }
.pr-contact { margin-top: 16px; padding: 14px; background: var(--yellow-soft); border-radius: 12px; }
.pr-contact p { margin: 0 0 4px; color: var(--muted); font-size: 0.82rem; }
.pr-phone { display: inline-block; font-size: 1.2rem; font-weight: 900; color: var(--red-deep); text-decoration: none; padding: 4px 0; }
.pr-hint { color: var(--muted); font-size: 0.78rem; margin-top: 4px; }

.site-footer { text-align: center; color: var(--muted); font-size: 0.76rem; padding: 24px 16px; font-weight: 500; letter-spacing: 0.01em; }

.skeleton { background: linear-gradient(90deg, #fff3c4, #fffbeb, #fff3c4); background-size: 200% 100%; animation: sk 1.2s infinite; border-radius: var(--radius); height: 210px; }
@keyframes sk { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

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