:root {
  --bg: #ffffff;
  --fg: #1a1a1a;
  --muted: #6b7280;
  --line: #e5e7eb;
  --accent: #128c7e;
  --accent-strong: #075e54;
  --danger: #b91c1c;
  --radius: 12px;
  --space: 16px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 17px;
  line-height: 1.5;
  color: var(--fg);
  background: var(--bg);
}
body.has-bottom-nav {
  padding-bottom: calc(64px + env(safe-area-inset-bottom, 0px));
}

a { color: var(--accent-strong); }

.container {
  max-width: 720px;
  margin: 0 auto;
  padding: var(--space);
}

/* Header */
.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px var(--space);
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.header-top {
  display: flex;
  align-items: center;
  gap: 12px;
}
.brand {
  font-size: 1.15rem;
  font-weight: 700;
  text-decoration: none;
  color: var(--fg);
}
.store-info-name {
  margin: 0 0 10px;
  font-size: 1.35rem;
  font-weight: 700;
}
.store-info-description {
  margin: 0 0 18px;
  color: var(--muted);
  font-size: 1rem;
}
.store-info-contacts {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
  font-size: 1rem;
}
.store-info-label {
  display: block;
  color: var(--muted);
  font-size: 0.8rem;
  margin-bottom: 2px;
}
.store-info-contacts a { text-decoration: none; }

/* Bottom tab bar: full width on mobile; capped to catalog column on desktop */
.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 40;
  display: flex;
  justify-content: center;
  pointer-events: none;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.bottom-nav-inner {
  pointer-events: auto;
  display: flex;
  width: 100%;
  max-width: 720px;
  min-height: 56px;
  background: var(--bg);
  border-top: 1px solid var(--line);
  box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.04);
}
.bottom-nav-item {
  flex: 1 1 0;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 56px;
  padding: 8px 12px;
  border: 0;
  background: transparent;
  text-decoration: none;
  color: var(--muted);
  font: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
}
.bottom-nav-item:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.bottom-nav-item.is-active {
  color: var(--accent-strong);
  background: #e8f5f3;
}
.bottom-nav-label { line-height: 1.2; }

/* Info bottom sheet — slides up; width matches catalog column on desktop */
.info-sheet {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  justify-content: center;
  align-items: flex-end;
}
.info-sheet[hidden] { display: none; }
.info-sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(17, 24, 39, 0.45);
  opacity: 0;
  transition: opacity 0.22s ease;
}
.info-sheet-panel {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 720px;
  max-height: min(85vh, 640px);
  display: flex;
  flex-direction: column;
  background: var(--bg);
  border-radius: 16px 16px 0 0;
  box-shadow: 0 -8px 28px rgba(0, 0, 0, 0.12);
  transform: translateY(105%);
  transition: transform 0.28s cubic-bezier(0.22, 1, 0.36, 1);
  padding-bottom: calc(64px + env(safe-area-inset-bottom, 0px));
}
.info-sheet.is-open .info-sheet-backdrop { opacity: 1; }
.info-sheet.is-open .info-sheet-panel { transform: translateY(0); }
.info-sheet-grab {
  width: 40px;
  height: 4px;
  margin: 10px auto 4px;
  border-radius: 999px;
  background: #d1d5db;
}
.info-sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 4px 16px 10px;
  border-bottom: 1px solid var(--line);
}
.info-sheet-title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
}
.info-sheet-close {
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 999px;
  background: #f3f4f6;
  color: var(--fg);
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
}
.info-sheet-body {
  overflow-y: auto;
  padding: 16px;
  -webkit-overflow-scrolling: touch;
}
body.info-sheet-open {
  overflow: hidden;
}

.search {
  display: flex;
  width: 100%;
  gap: 8px;
}
.search input {
  flex: 1;
  min-height: 46px;
  padding: 0 12px;
  font-size: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.search button {
  min-height: 46px;
  padding: 0 16px;
  font-size: 16px;
  color: #fff;
  background: var(--accent);
  border: 0;
  border-radius: var(--radius);
}

/* Intro / headings */
.page-intro h1 { font-size: 1.5rem; margin: 8px 0 12px; }

/* Categories — horizontal chip scroller with edge fades when more is off-screen */
.categories {
  position: relative;
  margin: 0 calc(-1 * var(--space)) 20px;
}
.categories::before,
.categories::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  width: 48px;
  pointer-events: none;
  z-index: 1;
  opacity: 0;
  transition: opacity 0.15s ease;
}
.categories::before {
  left: 0;
  background: linear-gradient(to right, var(--bg) 30%, rgba(255, 255, 255, 0));
}
.categories::after {
  right: 0;
  background: linear-gradient(to left, var(--bg) 30%, rgba(255, 255, 255, 0));
}
.categories.is-overflow-left::before { opacity: 1; }
.categories.is-overflow-right::after { opacity: 1; }
.categories ul {
  display: flex;
  flex-wrap: nowrap;
  gap: 8px;
  list-style: none;
  margin: 0;
  padding: 2px var(--space) 4px;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
  scroll-snap-type: x proximity;
  scrollbar-width: none;
}
.categories ul::-webkit-scrollbar { display: none; }
.categories li {
  flex: 0 0 auto;
  scroll-snap-align: start;
}
.categories a {
  display: inline-block;
  padding: 10px 14px;
  background: #f3f4f6;
  border-radius: 999px;
  text-decoration: none;
  color: var(--fg);
  white-space: nowrap;
}
.categories a.is-active {
  background: var(--accent);
  color: #fff;
}

/* Product grid */
.product-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  list-style: none;
  padding: 0;
  margin: 0;
}
.card { border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.card-link {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-bottom: 12px;
  text-decoration: none;
  color: var(--fg);
}
.card-img {
  display: block;
  width: 100%;
  max-width: 100%;
  height: auto;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  background: #f3f4f6;
}
.card-img--placeholder,
.gallery-img--placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 0.85rem;
}
.card-name { padding: 0 12px; font-weight: 600; }
.card-price { padding: 0 12px; font-size: 1.05rem; font-weight: 700; }

/* Availability badge */
.badge {
  display: inline-block;
  margin: 0 12px;
  padding: 3px 10px;
  width: fit-content;
  font-size: 0.8rem;
  border-radius: 999px;
}
.badge--in { color: #065f46; background: #d1fae5; }
.badge--out { color: var(--danger); background: #fee2e2; }

/* Product page */
.product { display: flex; flex-direction: column; gap: 20px; }
.gallery {
  display: flex;
  flex-direction: column;
  gap: 10px;
  /* Flex children default to min-width:auto; large intrinsic images
     (up to ~1600px) otherwise refuse to shrink and blow out desktop row layout. */
  min-width: 0;
  max-width: 100%;
}
.gallery-img {
  display: block;
  width: 100%;
  max-width: 100%;
  height: auto;
  border-radius: var(--radius);
  background: #f3f4f6;
  aspect-ratio: 1 / 1;
  object-fit: cover;
}
.gallery-main {
  display: block;
  width: 100%;
  max-width: 100%;
  height: auto;
  border-radius: var(--radius);
  background: #f3f4f6;
  aspect-ratio: 1 / 1;
  object-fit: cover;
}
.gallery-thumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}
.gallery-thumb {
  width: 64px;
  height: 64px;
  padding: 0;
  border: 2px solid transparent;
  border-radius: 8px;
  background: #f3f4f6;
  overflow: hidden;
  cursor: pointer;
}
.gallery-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.gallery-thumb.is-active { border-color: var(--accent); }
.product-name { font-size: 1.4rem; margin: 0 0 8px; }
.product-price-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 10px;
}
.product-price-row .badge { margin: 0; flex-shrink: 0; }
.product-price {
  font-size: 1.6rem;
  font-weight: 800;
  margin: 0 0 0 auto;
  text-align: right;
}
.product-sku, .product-category { color: var(--muted); margin: 6px 0; }
.product-description { margin-top: 16px; }
.product-description h2 { font-size: 1.1rem; }

/* WhatsApp CTA */
.wa-button {
  display: block;
  width: 100%;
  margin: 18px 0;
  padding: 16px;
  text-align: center;
  font-size: 1.1rem;
  font-weight: 700;
  color: #fff;
  background: var(--accent);
  border-radius: var(--radius);
  text-decoration: none;
}
.wa-button:active { background: var(--accent-strong); }

/* States */
.empty { color: var(--muted); padding: 24px 0; }
.error-page { text-align: center; padding: 40px 0; }
.debug-detail {
  text-align: left;
  white-space: pre-wrap;
  background: #f3f4f6;
  padding: 12px;
  border-radius: var(--radius);
  overflow-x: auto;
}

@media (min-width: 560px) {
  .product-grid { grid-template-columns: repeat(3, 1fr); }
  .product {
    flex-direction: row;
    align-items: flex-start;
  }
  .gallery {
    flex: 0 1 48%;
    max-width: 340px;
  }
  .product-info {
    flex: 1 1 0;
    min-width: 0;
  }
}
