/* ShopMV — mobile-first styles (no build step needed) */

:root {
  --brand: #0d9488;
  --brand-600: #0f766e;
  --brand-soft: #ccfbf1;
  --brand-ink: #115e59;
  --accent: #2563eb;

  --bg: #f4f7f8;
  --surface: #ffffff;
  --surface-2: #f1f5f9;
  --border: #e2e8f0;
  --text: #0f172a;
  --text-2: #475569;
  --muted: #64748b;

  --ok: #059669;
  --ok-soft: #d1fae5;
  --warn: #b45309;
  --warn-soft: #fef3c7;
  --danger: #dc2626;
  --danger-soft: #fee2e2;
  --ig: #db2777;
  --fb: #1d4ed8;
  --viber: #7c3aed;
  --viber-soft: #ede9fe;

  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 4px 16px rgba(15, 23, 42, .05);
  --shadow-lg: 0 20px 50px rgba(15, 23, 42, .25);
  --gutter: 14px;

  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}

[data-theme="dark"] {
  --brand: #14b8a6;
  --brand-600: #0d9488;
  --brand-soft: rgba(20, 184, 166, .16);
  --brand-ink: #5eead4;
  --accent: #60a5fa;

  --bg: #0b1220;
  --surface: #121a2b;
  --surface-2: #1a2438;
  --border: #243049;
  --text: #e5ebf5;
  --text-2: #b3bfd3;
  --muted: #8592a8;

  --ok: #34d399;
  --ok-soft: rgba(52, 211, 153, .14);
  --warn: #fbbf24;
  --warn-soft: rgba(251, 191, 36, .14);
  --danger: #f87171;
  --danger-soft: rgba(248, 113, 113, .14);
  --ig: #f472b6;
  --fb: #60a5fa;
  --viber: #a78bfa;
  --viber-soft: rgba(167, 139, 250, .14);
  --shadow: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow-lg: 0 20px 50px rgba(0, 0, 0, .55);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}
body.locked { overflow: hidden; }
img { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
[hidden] { display: none !important; }
code { font-family: ui-monospace, Menlo, monospace; font-size: .9em; background: var(--surface-2); padding: 1px 5px; border-radius: 5px; }

.wrap { width: 100%; max-width: 1240px; margin: 0 auto; padding: 0 var(--gutter); }
.page { flex: 1; padding-top: 16px; padding-bottom: 28px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

/* ---------------- Sticky header ---------------- */
.sticky-top {
  position: sticky; top: 0; z-index: 30;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(160%) blur(10px);
  -webkit-backdrop-filter: saturate(160%) blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas: "brand actions" "search search";
  gap: 10px 12px;
  align-items: center;
  padding-top: 10px; padding-bottom: 10px;
}
.brand { grid-area: brand; display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-mark {
  width: 38px; height: 38px; flex: none; border-radius: 11px;
  display: grid; place-items: center; color: #fff; font-size: 17px;
  background: linear-gradient(135deg, #0d9488, #2563eb);
  box-shadow: 0 4px 12px rgba(13, 148, 136, .3);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.05; min-width: 0; }
.brand-name { font-weight: 800; font-size: 20px; letter-spacing: -.02em; }
.brand-sub { font-size: 10.5px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .06em; white-space: nowrap; }

.top-actions { grid-area: actions; display: flex; gap: 4px; }
.icon-btn {
  position: relative; min-width: 40px; height: 40px; padding: 0 8px; border-radius: 11px;
  display: grid; place-items: center; color: var(--text-2); font-size: 17px;
}
.icon-btn:hover { background: var(--surface-2); }
.currency-btn { font-size: 12px; font-weight: 800; color: var(--brand-ink); background: var(--brand-soft); padding: 0 10px; }
.count-badge {
  position: absolute; top: 3px; right: 2px; min-width: 17px; height: 17px; padding: 0 4px;
  border-radius: 9px; background: var(--danger); color: #fff; font-size: 10px; font-weight: 700;
  display: grid; place-items: center;
}

.search {
  grid-area: search; position: relative; display: flex; align-items: center;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px;
  height: 42px; padding: 0 6px 0 14px; gap: 8px;
}
.search:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.search > i { color: var(--muted); font-size: 14px; }
.search input {
  flex: 1; min-width: 0; height: 100%; border: 0; background: none; outline: none;
  font-size: 16px; /* 16px stops iOS zoom-on-focus */
}
.search input::-webkit-search-cancel-button { display: none; }
.search-clear { width: 32px; height: 32px; border-radius: 50%; color: var(--muted); }
.search-sm { height: 40px; width: 100%; }

/* ---------------- Filter bar ---------------- */
.filterbar { border-top: 1px solid var(--border); }
.chip-row {
  display: flex; gap: 8px; overflow-x: auto; padding: 10px 0 2px;
  scrollbar-width: none; -webkit-overflow-scrolling: touch;
  scroll-snap-type: x proximity;
  /* let rows bleed to the screen edge on phones */
  margin: 0 calc(var(--gutter) * -1); padding-left: var(--gutter); padding-right: var(--gutter);
}
.chip-row::-webkit-scrollbar { display: none; }
.chip-row-secondary { padding-top: 8px; padding-bottom: 10px; }

.chip, .select-chip {
  flex: none; scroll-snap-align: start;
  display: inline-flex; align-items: center; gap: 7px;
  height: 36px; padding: 0 14px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface);
  font-size: 13px; font-weight: 600; color: var(--text-2); white-space: nowrap;
  transition: background .15s, border-color .15s, color .15s;
}
.chip i { font-size: 12px; }
.chip[aria-pressed="true"], .chip.active {
  background: var(--brand); border-color: var(--brand); color: #fff;
}
.select-chip { padding: 0 6px 0 12px; position: relative; }
.select-chip i { color: var(--brand); font-size: 12px; }
.select-chip select {
  border: 0; background: none; outline: none; font-weight: 600; font-size: 13px;
  height: 100%; padding-right: 4px; color: var(--text); cursor: pointer;
}

/* ---------------- Section head ---------------- */
.section-head { margin-bottom: 14px; }
.section-title { display: flex; align-items: center; gap: 8px; margin: 0; font-size: 19px; font-weight: 800; letter-spacing: -.01em; }
.section-head p { margin: 2px 0 0; }
.pill {
  display: inline-grid; place-items: center; min-width: 22px; height: 22px; padding: 0 8px;
  border-radius: 999px; background: var(--brand-soft); color: var(--brand-ink);
  font-size: 11.5px; font-weight: 700;
}

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

.card {
  position: relative; display: flex; flex-direction: column; min-width: 0;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; box-shadow: var(--shadow);
  transition: transform .2s, box-shadow .2s;
}
.card-media { position: relative; display: block; width: 100%; aspect-ratio: 1; background: var(--surface-2); overflow: hidden; }
.card-media img { width: 100%; height: 100%; object-fit: cover; transition: transform .4s; }
.stock-badge {
  position: absolute; left: 8px; top: 8px; font-size: 10px; font-weight: 700;
  padding: 3px 8px; border-radius: 999px; color: #fff; background: rgba(5, 150, 105, .92);
}
.stock-badge.pre { background: rgba(217, 119, 6, .92); }
.stock-badge.out { background: rgba(71, 85, 105, .92); }
.save-btn {
  position: absolute; right: 8px; top: 8px; width: 34px; height: 34px; border-radius: 50%;
  display: grid; place-items: center; background: rgba(255, 255, 255, .9); color: #334155;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .15); font-size: 14px;
}
.save-btn[aria-pressed="true"] { color: var(--brand-600); }

.card-body { padding: 10px; display: flex; flex-direction: column; gap: 4px; flex: 1; }
.card-shop { display: flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--muted); font-weight: 600; min-width: 0; }
.card-shop span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.plat { width: 18px; height: 18px; flex: none; border-radius: 50%; display: grid; place-items: center; color: #fff; font-size: 10px; }
.plat.ig { background: linear-gradient(45deg, #f59e0b, #db2777 55%, #7c3aed); }
.plat.fb { background: #1d4ed8; }
.card-title {
  margin: 0; font-size: 13.5px; font-weight: 700; line-height: 1.3; text-align: left;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  min-height: 2.6em;
}
.card-caption { display: none; }
.card-price-row { display: flex; align-items: baseline; justify-content: space-between; gap: 6px; margin-top: 2px; }
.price { font-size: 16px; font-weight: 800; color: var(--brand-600); letter-spacing: -.01em; }
[data-theme="dark"] .price { color: var(--brand); }
.price.ask { font-size: 13px; color: var(--text-2); }
.pay-icons { display: flex; gap: 6px; font-size: 12px; }
.pay-icons .fa-building-columns { color: var(--accent); }
.pay-icons .fa-hand-holding-dollar { color: var(--ok); }
.card-loc { font-size: 11.5px; color: var(--muted); display: flex; gap: 5px; align-items: center; }
.card-loc i { color: var(--brand); font-size: 10px; }
.card-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-top: auto; padding-top: 8px; }
.card-actions.single { grid-template-columns: 1fr; }

/* ---------------- Buttons ---------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 42px; padding: 0 16px; border-radius: 12px; border: 1px solid transparent;
  font-size: 14px; font-weight: 700; white-space: nowrap;
  transition: background .15s, transform .1s;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .6; pointer-events: none; }
.btn-sm { height: 36px; padding: 0 10px; font-size: 12.5px; border-radius: 10px; gap: 6px; }
.btn-block { width: 100%; }
.btn-primary { background: var(--brand); color: #fff; box-shadow: 0 4px 12px rgba(13, 148, 136, .25); }
.btn-primary:hover { background: var(--brand-600); }
.btn-dark { background: #0f172a; color: #fff; }
[data-theme="dark"] .btn-dark { background: #2a3650; }
.btn-viber { background: var(--viber-soft); color: var(--viber); border-color: color-mix(in srgb, var(--viber) 25%, transparent); }
.btn-ghost { background: var(--surface); border-color: var(--border); color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-danger-ghost { background: var(--danger-soft); color: var(--danger); }
.btn .fa-instagram { color: #f472b6; }
.btn .fa-facebook-messenger { color: #93c5fd; }

/* ---------------- Skeleton / empty ---------------- */
.skeleton { pointer-events: none; }
.skeleton .card-media, .sk-line { background: linear-gradient(90deg, var(--surface-2) 25%, var(--border) 50%, var(--surface-2) 75%); background-size: 200% 100%; animation: sk 1.2s infinite; }
.sk-line { height: 11px; border-radius: 6px; margin: 4px 0; }
@keyframes sk { to { background-position: -200% 0; } }

.empty { text-align: center; padding: 48px 16px; }
.empty-icon { width: 64px; height: 64px; margin: 0 auto 14px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); color: var(--muted); font-size: 24px; }
.empty h2 { margin: 0 0 4px; font-size: 18px; }
.empty p { margin: 0 auto 18px; max-width: 360px; }

/* ---------------- Footer ---------------- */
.site-footer { border-top: 1px solid var(--border); background: var(--surface); padding: 16px 0 calc(16px + var(--safe-b)); font-size: 12.5px; color: var(--muted); }
.footer-inner { display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
.footer-link { font-weight: 600; color: var(--text-2); display: inline-flex; gap: 6px; align-items: center; padding: 6px 0; }

/* ---------------- Sheets (bottom sheet on phone, dialog on desktop) ---------------- */
.sheet { position: fixed; inset: 0; z-index: 60; display: flex; align-items: flex-end; justify-content: center; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(2, 6, 23, .55); animation: fade .2s ease; }
.sheet-panel {
  position: relative; width: 100%; max-height: 92dvh; overflow-y: auto; overscroll-behavior: contain;
  background: var(--surface); border-radius: 20px 20px 0 0; box-shadow: var(--shadow-lg);
  padding-bottom: calc(16px + var(--safe-b));
  animation: slideUp .25s cubic-bezier(.2, .9, .3, 1);
}
.sheet-grabber { width: 40px; height: 5px; border-radius: 3px; background: var(--border); margin: 8px auto 0; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 16px 8px; position: sticky; top: 0; background: var(--surface); z-index: 2; }
.sheet-head h2 { margin: 0; font-size: 17px; display: flex; gap: 8px; align-items: center; }
.sheet-head h2 i { color: var(--brand); }
.sheet-body { padding: 4px 16px 4px; }
.sheet-close {
  position: absolute; top: 12px; right: 12px; z-index: 3; width: 36px; height: 36px; border-radius: 50%;
  display: grid; place-items: center; background: rgba(15, 23, 42, .55); color: #fff; font-size: 16px;
}
.sheet-close.static { position: static; background: var(--surface-2); color: var(--text-2); }
@keyframes slideUp { from { transform: translateY(40px); opacity: .4; } }
@keyframes fade { from { opacity: 0; } }

/* Product detail */
.detail-media { aspect-ratio: 1; background: var(--surface-2); margin-top: 10px; }
.detail-media img { width: 100%; height: 100%; object-fit: cover; }
.detail-body { padding: 14px 16px 4px; display: flex; flex-direction: column; gap: 10px; }
.detail-shop { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); font-weight: 600; }
.detail-title { margin: 0; font-size: 19px; line-height: 1.25; font-weight: 800; }
.detail-price { font-size: 24px; font-weight: 800; color: var(--brand-600); }
[data-theme="dark"] .detail-price { color: var(--brand); }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { display: inline-flex; align-items: center; gap: 5px; height: 26px; padding: 0 10px; border-radius: 999px; background: var(--surface-2); font-size: 12px; font-weight: 600; color: var(--text-2); }
.tag.ok { background: var(--ok-soft); color: var(--ok); }
.tag.warn { background: var(--warn-soft); color: var(--warn); }
.detail-caption { white-space: pre-wrap; word-break: break-word; font-size: 14px; color: var(--text-2); background: var(--surface-2); border-radius: 12px; padding: 12px; margin: 0; max-height: 240px; overflow: auto; }
.detail-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.detail-actions .btn { height: 46px; }
.detail-actions .full { grid-column: 1 / -1; }

/* Saved */
.saved-list { padding: 4px 16px; display: flex; flex-direction: column; gap: 8px; }
.saved-item { display: grid; grid-template-columns: 60px 1fr auto; gap: 12px; align-items: center; padding: 8px; border: 1px solid var(--border); border-radius: 12px; }
.saved-item img { width: 60px; height: 60px; border-radius: 9px; object-fit: cover; background: var(--surface-2); }
.saved-item .t { font-weight: 700; font-size: 14px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; text-align: left; }
.saved-item .s { font-size: 12px; color: var(--muted); }
.saved-empty { text-align: center; padding: 30px 10px; color: var(--muted); }

/* ---------------- Forms ---------------- */
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; min-width: 0; }
.field label { font-size: 12.5px; font-weight: 700; color: var(--text-2); }
.field input, .field select, .field textarea, .input-prefix {
  width: 100%; min-height: 44px; padding: 10px 12px; border-radius: 11px;
  border: 1px solid var(--border); background: var(--surface-2); outline: none;
  font-size: 16px; /* prevents iOS zoom */
}
.field textarea { resize: vertical; min-height: 84px; }
.field input:focus, .field select:focus, .field textarea:focus, .input-prefix:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.input-prefix { display: flex; align-items: center; gap: 4px; padding: 0 0 0 12px; }
.input-prefix span { color: var(--muted); font-weight: 700; }
.input-prefix input { border: 0 !important; box-shadow: none !important; background: none; padding-left: 0; min-height: 42px; }
.field-row { display: grid; grid-template-columns: 1fr; gap: 0 10px; }
.field-error { color: var(--danger); font-size: 12.5px; font-weight: 600; margin: 2px 0 0; }
.hint { font-size: 12px; color: var(--muted); margin: 0; font-family: ui-monospace, Menlo, monospace; }
.hint.ok { color: var(--ok); font-weight: 700; }
.check-row { display: flex; flex-wrap: wrap; gap: 8px 18px; padding: 6px 0 12px; }
.check { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 600; min-height: 36px; }
.check input { width: 20px; height: 20px; accent-color: var(--brand); }
.form-actions { display: grid; grid-template-columns: 1fr 2fr; gap: 10px; position: sticky; bottom: calc(-16px - var(--safe-b)); background: var(--surface); padding: 10px 0 calc(6px + var(--safe-b)); margin-bottom: calc(-16px - var(--safe-b)); border-top: 1px solid var(--border); }

/* ---------------- Admin ---------------- */
.admin-head { display: flex; flex-direction: column; gap: 12px; margin-bottom: 16px; }
.eyebrow { font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .1em; color: var(--brand); }
.admin-title { margin: 0; font-size: 22px; font-weight: 800; }
.admin-actions { display: grid; grid-template-columns: 1fr 1.3fr auto; gap: 8px; }
.admin-actions .btn { padding: 0 12px; }
.admin-actions .btn-danger-ghost span { display: none; }

.setup-alert { border: 1px solid color-mix(in srgb, var(--warn) 35%, transparent); background: var(--warn-soft); color: var(--text); border-radius: var(--radius); padding: 12px 14px; font-size: 13.5px; margin-bottom: 14px; }
.setup-alert b { color: var(--warn); }
.setup-alert ul { margin: 6px 0 0; padding-left: 18px; }

.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-bottom: 16px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; display: flex; flex-direction: column; gap: 4px; }
.stat-label { font-size: 11.5px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; display: flex; gap: 6px; align-items: center; }
.stat-label i { color: var(--brand); }
.stat b { font-size: 22px; font-weight: 800; }

.tabs { display: flex; gap: 4px; padding: 4px; border-radius: 13px; background: var(--surface-2); margin-bottom: 12px; }
.tab { flex: 1; height: 38px; border-radius: 10px; font-size: 13.5px; font-weight: 700; color: var(--muted); display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.tab.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; min-width: 0; }
.panel-pad { padding: 16px; height: fit-content; }
.panel-title { margin: 0 0 2px; font-size: 16px; font-weight: 800; }
.panel-pad .muted { margin: 0 0 14px; }
.panel-toolbar { padding: 12px; border-bottom: 1px solid var(--border); display: flex; gap: 10px; align-items: center; }

.admin-list > .arow:not(:last-child) { border-bottom: 1px solid var(--border); }
.arow {
  display: grid; grid-template-columns: 52px minmax(0, 1fr); gap: 4px 12px; padding: 12px;
  grid-template-areas: "img main" "actions actions";
  align-items: center;
}
.arow-img { grid-area: img; width: 52px; height: 52px; border-radius: 10px; object-fit: cover; background: var(--surface-2); }
.arow-icon { grid-area: img; width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; font-size: 20px; color: #fff; }
.arow-main { grid-area: main; min-width: 0; }
.arow-title { font-weight: 700; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.arow-meta { font-size: 12px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 2px 10px; margin-top: 2px; }
.arow-meta b { color: var(--brand-600); }
[data-theme="dark"] .arow-meta b { color: var(--brand); }
.arow-meta .err { color: var(--danger); }
.arow-actions { grid-area: actions; display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.arow-actions .btn { flex: 1 1 auto; }
.arow-actions .btn.icon-only { flex: 0 0 40px; padding: 0; }
.status-btn.on { background: var(--ok-soft); color: var(--ok); }
.status-btn.off { background: var(--surface-2); color: var(--muted); }
.list-empty { padding: 28px 16px; text-align: center; color: var(--muted); font-size: 14px; }

.shops-layout { display: grid; gap: 14px; }

/* ---------------- Toasts ---------------- */
.toasts { position: fixed; left: 0; right: 0; bottom: calc(14px + var(--safe-b)); z-index: 90; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; padding: 0 14px; }
.toast { max-width: 440px; width: fit-content; background: #0f172a; color: #fff; border: 1px solid #334155; padding: 11px 16px; border-radius: 12px; box-shadow: var(--shadow-lg); font-size: 13.5px; font-weight: 600; display: flex; gap: 9px; align-items: center; animation: slideUp .2s ease; }
.toast i { color: #34d399; }
.toast.error i { color: #f87171; }

/* ---------------- ≥ 480px (large phones) ---------------- */
@media (min-width: 480px) {
  .grid { gap: 12px; }
  .card-body { padding: 12px; }
  .field-row { grid-template-columns: 1fr 1fr; }
  .field-row.three { grid-template-columns: 1fr 1fr 1fr; }
  .admin-actions { display: flex; flex-wrap: wrap; }
  .admin-actions .btn-danger-ghost span { display: inline; }
}

/* ---------------- ≥ 640px (tablet): sheets become centered dialogs ---------------- */
@media (min-width: 640px) {
  :root { --gutter: 20px; }
  .sheet { align-items: center; padding: 24px; }
  .sheet-panel { max-width: 560px; border-radius: 20px; max-height: 88vh; padding-bottom: 16px; animation: pop .2s ease; }
  .sheet-narrow { max-width: 420px; }
  .sheet-grabber { display: none; }
  .sheet-head { padding-top: 16px; }
  .form-actions { bottom: -16px; margin-bottom: -16px; padding-bottom: 12px; }
  @keyframes pop { from { transform: scale(.97); opacity: 0; } }

  .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
  .card-caption { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; margin: 0; font-size: 12.5px; color: var(--muted); }
  .card-title { min-height: 0; -webkit-line-clamp: 1; font-size: 14.5px; }
  .stats { grid-template-columns: repeat(4, 1fr); gap: 12px; }
  .footer-inner { flex-direction: row; justify-content: space-between; align-items: center; }

  .arow { grid-template-columns: 52px minmax(0, 1fr) auto; grid-template-areas: "img main actions"; }
  .arow-actions { margin-top: 0; flex-wrap: nowrap; }
  .arow-actions .btn { flex: none; }
}

/* ---------------- ≥ 900px (desktop) ---------------- */
@media (min-width: 900px) {
  .topbar-inner { grid-template-columns: auto minmax(0, 1fr) auto; grid-template-areas: "brand search actions"; gap: 24px; padding-top: 12px; padding-bottom: 12px; }
  .search { max-width: 520px; width: 100%; justify-self: center; }
  .filterbar .wrap { display: flex; align-items: center; gap: 16px; justify-content: space-between; }
  .chip-row { margin: 0; padding-left: 0; padding-right: 0; }
  .chip-row-secondary { padding-top: 10px; flex: none; }
  .sheet-wide { max-width: 860px; }
  .sheet-wide #productDetail { display: grid; grid-template-columns: 1fr 1fr; }
  .sheet-wide .detail-media { margin: 0; }
  .sheet-wide .detail-body { padding: 24px; overflow: auto; }
  .sheet-wide .sheet-close { background: var(--surface-2); color: var(--text-2); }
  .admin-head { flex-direction: row; justify-content: space-between; align-items: flex-end; }
  .shops-layout { grid-template-columns: 360px 1fr; align-items: start; }
  .card:hover { transform: translateY(-2px); box-shadow: 0 12px 30px rgba(15, 23, 42, .12); }
  .card:hover .card-media img { transform: scale(1.04); }
}

@media (min-width: 1100px) {
  .grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 20px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* desktop filter bar: categories take remaining space and scroll */
@media (min-width: 900px) {
  .filterbar .chip-row:first-child { flex: 1 1 auto; min-width: 0; }
}

/* small phones */
@media (max-width: 379px) {
  .brand-sub { display: none; }
  .brand-name { font-size: 18px; }
  .top-actions { gap: 0; }
}
/* keep the product photo from filling the whole phone screen */
@media (max-width: 899px) {
  .detail-media { aspect-ratio: auto; height: min(100vw, 52dvh); }
}
