:root {
  --navy: #001a72;
  --navy-muted: #2a3f7a;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e8edf4;
  --surface: #ffffff;
  --bg: #f4f6fa;
  --whatsapp: #128c43;
  --max-width: 480px;
  --header-h: 4.25rem;
  --radius: 16px;
  --radius-sm: 10px;
}

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

html { scroll-behavior: smooth; }

html, body {
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }
button, input { font: inherit; }
button { cursor: pointer; border: none; background: none; }

.app-shell { width: 100%; min-height: 100dvh; }

/* ── Header (hidden until past landing) ── */
.app-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 40;
  padding: max(0.5rem, env(safe-area-inset-top)) 1rem 0.5rem;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
  transform: translateY(-110%);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.35s ease, opacity 0.35s ease;
}

body.past-landing .app-header {
  transform: translateY(0);
  opacity: 1;
  pointer-events: auto;
}

.app-toolbar {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.5rem;
  align-items: stretch;
}

.search-field {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  min-height: 42px;
  padding: 0 0.85rem;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 999px;
}

.search-icon {
  width: 1rem;
  height: 1rem;
  fill: var(--muted);
  flex-shrink: 0;
}

.search-field input {
  flex: 1;
  min-width: 0;
  border: none;
  background: none;
  color: var(--ink);
  font-size: 0.88rem;
  font-weight: 500;
  outline: none;
}

.search-field input::placeholder { color: #94a3b8; }

.search-clear {
  width: 1.4rem;
  height: 1.4rem;
  border-radius: 999px;
  background: var(--line);
  color: var(--muted);
  font-size: 1rem;
  line-height: 1;
  padding: 0;
}

.category-toggle {
  display: flex;
  align-items: center;
  gap: 0.2rem;
  min-height: 42px;
  max-width: 8.5rem;
  padding: 0 0.75rem;
  border-radius: 999px;
  background: var(--navy);
  color: #fff;
  font-size: 0.74rem;
  font-weight: 600;
}

.category-toggle span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.category-toggle svg {
  width: 0.95rem;
  height: 0.95rem;
  fill: currentColor;
  flex-shrink: 0;
  transition: transform 0.2s ease;
}

.category-toggle[aria-expanded='true'] svg { transform: rotate(180deg); }

.progress-track {
  margin-top: 0.45rem;
  height: 2px;
  background: var(--line);
  border-radius: 999px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0;
  background: var(--navy);
  transition: width 0.15s ease-out;
}

/* ── Dropdowns ── */
.category-backdrop {
  position: fixed;
  inset: 0;
  z-index: 38;
  background: rgba(15, 23, 42, 0.35);
}

.category-menu {
  position: fixed;
  top: calc(var(--header-h) + env(safe-area-inset-top, 0px) + 0.35rem);
  left: 1rem;
  right: 1rem;
  z-index: 39;
  max-height: min(50vh, 360px);
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 12px 40px rgba(15, 23, 42, 0.1);
  padding: 0.35rem;
}

.category-menu button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 0.7rem 0.8rem;
  border-radius: var(--radius-sm);
  color: var(--ink);
  font-size: 0.84rem;
  font-weight: 500;
  text-align: left;
}

.category-menu button:hover,
.category-menu button.active {
  background: var(--bg);
  color: var(--navy);
}

.category-menu .cat-count {
  color: var(--muted);
  font-size: 0.72rem;
}

.search-panel {
  position: fixed;
  top: calc(var(--header-h) + env(safe-area-inset-top, 0px) + 0.35rem);
  left: 1rem;
  right: 1rem;
  z-index: 37;
  max-height: min(55vh, 400px);
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 12px 40px rgba(15, 23, 42, 0.1);
  padding: 0.4rem;
}

.search-panel-label {
  margin: 0.3rem 0.6rem 0.35rem;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.search-results button {
  display: block;
  width: 100%;
  padding: 0.7rem 0.75rem;
  border-radius: var(--radius-sm);
  text-align: left;
}

.search-results button:hover { background: var(--bg); }

.search-results .result-name {
  display: block;
  color: var(--ink);
  font-size: 0.88rem;
  font-weight: 600;
}

.search-results .result-meta {
  display: block;
  margin-top: 0.12rem;
  color: var(--muted);
  font-size: 0.74rem;
}

.search-empty {
  padding: 1.25rem;
  text-align: center;
  color: var(--muted);
  font-size: 0.86rem;
}

/* ── Catalogue ── */
.catalogue {
  width: 100%;
  padding-top: 0;
  transition: padding-top 0.35s ease;
}

body.past-landing .catalogue {
  padding-top: calc(var(--header-h) + env(safe-area-inset-top, 0px));
}

/* ── Landing ── */
.landing-screen {
  position: relative;
  min-height: 100dvh;
  min-height: 100svh;
  background: var(--navy);
  overflow: hidden;
}

.landing-cover {
  width: 100%;
  height: 100dvh;
  height: 100svh;
  object-fit: cover;
  object-position: center top;
}

.landing-overlay {
  position: absolute;
  inset: auto 0 0;
  padding: 2rem 1.25rem calc(1.75rem + env(safe-area-inset-bottom));
  background: linear-gradient(transparent, rgba(0, 10, 50, 0.55));
  display: flex;
  justify-content: center;
}

.landing-cta {
  min-width: 12rem;
  min-height: 48px;
  padding: 0.85rem 1.75rem;
  border-radius: 999px;
  background: #fff;
  color: var(--navy);
  font-size: 0.92rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
}

.landing-cta:active { transform: scale(0.98); }

/* ── Browse screen (5×5 grid, one viewport) ── */
.browse-screen {
  min-height: 100dvh;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  padding: 0.55rem 0.45rem 0.45rem;
  background: var(--bg);
  overflow: hidden;
}

.browse-head {
  flex-shrink: 0;
  margin-bottom: 0.45rem;
  text-align: center;
}

.browse-eyebrow {
  margin: 0;
  color: var(--muted);
  font-size: 0.58rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.browse-head h1 {
  margin: 0.15rem 0 0;
  color: var(--ink);
  font-size: clamp(0.95rem, 4vw, 1.15rem);
  font-weight: 600;
  letter-spacing: -0.02em;
}

.browse-sub {
  margin: 0.12rem 0 0;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 400;
}

.category-grid {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  grid-template-rows: repeat(5, minmax(0, 1fr));
  gap: 0.3rem;
}

.category-tile {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  text-align: center;
  transition: border-color 0.15s ease;
}

.category-tile:active {
  border-color: #c7d2e4;
  background: #fafbfd;
}

.category-tile-media {
  flex: 1;
  min-height: 0;
  display: grid;
  place-items: center;
  padding: 0.2rem;
  background: #fafbfd;
}

.category-tile-media img {
  width: 100%;
  height: 100%;
  max-height: 100%;
  object-fit: contain;
}

.category-tile-body {
  flex-shrink: 0;
  padding: 0.12rem 0.15rem 0.18rem;
}

.category-tile-name {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  color: var(--ink);
  font-size: clamp(0.42rem, 2.35vw, 0.56rem);
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.category-tile-count {
  display: none;
}

/* ── Product pages ── */
.product-page {
  min-height: calc(100dvh - var(--header-h) - env(safe-area-inset-top, 0px));
  margin: 0 1rem 0.65rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.product-page.category-start { margin-top: 0.5rem; }

.product-inner {
  padding: 1.1rem 1rem 1.15rem;
  display: flex;
  flex-direction: column;
  min-height: calc(100dvh - var(--header-h) - env(safe-area-inset-top, 0px) - 1.3rem);
}

.product-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.product-category {
  margin: 0;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.product-count {
  margin: 0;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 500;
}

.product-image-wrap {
  flex: 1;
  display: grid;
  place-items: center;
  min-height: clamp(200px, 36vh, 300px);
  margin: 0.75rem 0;
  padding: 0.75rem;
  background: #fafbfd;
  border-radius: var(--radius-sm);
  width: 100%;
  position: relative;
}

.product-image-wrap.is-zoomable { cursor: zoom-in; }

.product-image-wrap img {
  width: min(100%, 280px);
  height: min(36vh, 280px);
  object-fit: contain;
  pointer-events: none;
}

.zoom-badge {
  position: absolute;
  right: 0.5rem;
  bottom: 0.5rem;
  padding: 0.25rem 0.5rem;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.75);
  color: #fff;
  font-size: 0.62rem;
  font-weight: 600;
}

.product-image-wrap img[data-loaded='false'] { opacity: 0; }
.product-image-wrap img[data-loaded='true'] { opacity: 1; transition: opacity 0.3s ease; }

.image-placeholder {
  width: min(100%, 240px);
  height: min(32vh, 240px);
  border-radius: var(--radius-sm);
  background: var(--bg);
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 0.8rem;
}

.product-brand {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.product-name {
  margin: 0.2rem 0 0;
  color: var(--ink);
  font-size: clamp(1.1rem, 4.5vw, 1.4rem);
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -0.02em;
}

.product-description {
  margin: 0.55rem 0 0;
  color: var(--navy-muted);
  font-size: 0.86rem;
  font-weight: 400;
  line-height: 1.55;
}

.size-block { margin-top: 0.85rem; }

.size-label {
  margin: 0 0 0.25rem;
  color: var(--muted);
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.size-values { margin: 0; padding: 0; list-style: none; }
.size-values li {
  font-size: 0.9rem;
  font-weight: 500;
  line-height: 1.45;
}

.meta-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.55rem;
  margin-top: 0.9rem;
  padding-top: 0.9rem;
  border-top: 1px solid var(--line);
}

.meta-item span {
  display: block;
  color: var(--muted);
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.meta-item strong {
  display: block;
  margin-top: 0.1rem;
  font-size: 0.86rem;
  font-weight: 600;
  word-break: break-word;
}

.action-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  margin-top: auto;
  padding-top: 1rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  padding: 0.65rem 0.85rem;
  border-radius: var(--radius-sm);
  font-size: 0.84rem;
  font-weight: 600;
}

.btn-primary { background: var(--navy); color: #fff; }
.btn-whatsapp { background: var(--whatsapp); color: #fff; }

/* ── End page ── */
.end-page {
  margin: 0.5rem 1rem 1.5rem;
  padding: 2rem 1rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  text-align: center;
}

.end-inner h2 {
  margin: 0.85rem 0 0.3rem;
  font-size: 1.2rem;
  font-weight: 600;
}

.end-inner p {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.end-actions {
  display: grid;
  gap: 0.5rem;
  margin-top: 1.1rem;
}

/* ── Loading & zoom ── */
.loading-screen {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  gap: 0.65rem;
  background: var(--surface);
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.loading-screen.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.loading-screen p {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
}

body.menu-open,
body.search-open,
body.zoom-open { overflow: hidden; }

.zoom-dialog {
  border: none;
  padding: 0;
  width: 100vw;
  max-width: 100vw;
  height: 100dvh;
  max-height: 100dvh;
  background: rgba(15, 23, 42, 0.94);
}

.zoom-dialog::backdrop { background: rgba(15, 23, 42, 0.94); }

.zoom-shell {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  cursor: zoom-out;
}

.zoom-close {
  position: absolute;
  top: max(0.75rem, env(safe-area-inset-top));
  right: 0.75rem;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  font-size: 1.5rem;
}

.zoom-caption {
  margin: 0 0 0.65rem;
  color: #fff;
  font-size: 0.9rem;
  font-weight: 500;
  text-align: center;
}

.zoom-stage {
  flex: 1;
  width: 100%;
  display: grid;
  place-items: center;
  overflow: auto;
}

.zoom-stage img {
  max-width: min(96vw, 900px);
  max-height: min(78vh, 900px);
  object-fit: contain;
}

.zoom-hint {
  margin: 0.65rem 0 0;
  color: rgba(255, 255, 255, 0.65);
  font-size: 0.76rem;
}

.product-page.search-hit {
  outline: 2px solid var(--navy);
  outline-offset: 1px;
}

.back-to-top {
  position: fixed;
  right: 1rem;
  bottom: calc(1rem + env(safe-area-inset-bottom));
  z-index: 36;
  width: 2.75rem;
  height: 2.75rem;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: var(--navy);
  color: #fff;
  box-shadow: 0 6px 20px rgba(0, 26, 114, 0.28);
  opacity: 0;
  transform: translateY(0.75rem);
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.back-to-top.is-visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.back-to-top svg {
  width: 1.35rem;
  height: 1.35rem;
  fill: currentColor;
}

.back-to-top:active {
  transform: scale(0.96);
}

@media (min-width: 520px) {
  .app-header,
  .category-menu,
  .search-panel {
    left: 50%;
    right: auto;
    width: min(var(--max-width), calc(100% - 2rem));
    transform: translateX(-50%);
  }

  body.past-landing .app-header {
    transform: translateX(-50%) translateY(0);
  }

  .app-header {
    transform: translateX(-50%) translateY(-110%);
  }

  .catalogue {
    width: min(var(--max-width), 100%);
    margin: 0 auto;
  }

  .back-to-top {
    right: calc(50% - (var(--max-width) / 2) + 1rem);
  }
}

@media (max-width: 380px) {
  .app-toolbar { grid-template-columns: 1fr; }
  .category-toggle { max-width: none; width: 100%; justify-content: space-between; }
  .action-row { grid-template-columns: 1fr; }
  .category-grid { gap: 0.22rem; }
  .browse-screen { padding: 0.45rem 0.35rem 0.35rem; }
}