/* Design tokens — Astryx neutral theme reimplemented as vanilla CSS custom properties.
   Source of truth: Project Files/DESIGN.md. No hard-coded colors/sizes in components —
   every screen styles from these variables only. */
:root {
  color-scheme: light dark;

  /* neutral ramp (Astryx = Tailwind neutral, chroma-0) */
  --n-50:#fafafa; --n-100:#f5f5f5; --n-200:#e5e5e5; --n-300:#d4d4d4;
  --n-400:#a3a3a3; --n-500:#737373; --n-600:#525252; --n-700:#404040;
  --n-800:#262626; --n-900:#171717; --n-950:#0a0a0a;

  /* semantic surfaces / text / borders  (light, dark) */
  --bg-body:      light-dark(#f1f1f1, #1b1b1b);
  --bg-surface:   light-dark(#ffffff, #262626);
  --bg-card:      light-dark(#ffffff, #1b1b1b);
  --bg-muted:     light-dark(#f1f1f1, #262626);
  --text-primary:   light-dark(#171717, #fafafa);
  --text-secondary: light-dark(#737373, #a3a3a3);
  --text-disabled:  light-dark(#a3a3a3, #525252);
  --border:          light-dark(#ebebeb, rgba(255,255,255,.10));
  --border-emphasis: light-dark(#d4d4d4, #525252);

  /* accent is NEUTRAL (near-black / near-white) — deliberate, calm */
  --accent:        light-dark(#262626, #ebebeb);
  --on-accent:     light-dark(#ffffff, #171717);
  --accent-muted:  light-dark(#f1f1f1, #262626);

  /* status — meaning only */
  --success: light-dark(#007004, #9fe59b);
  --error:   light-dark(#a50c25, #ffc6c1);
  --warning: light-dark(#745b00, #fdcf4f);
  --success-bg: light-dark(#e7f4e7, #143a15);
  --error-bg:   light-dark(#fbeaec, #4a1620);
  --warning-bg: light-dark(#f7f0d9, #3a2f05);

  /* type — base 14px, ratio 1.2 (Figtree if self-hosted, else system) */
  --font-sans: "Figtree", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: ui-monospace, "SF Mono", Monaco, Consolas, monospace;
  --fs-xs:10px; --fs-sm:12px; --fs-base:14px; --fs-lg:17px; --fs-xl:20px;
  --fs-2xl:24px; --fs-3xl:29px; --fs-4xl:35px;
  --fw-normal:400; --fw-medium:500; --fw-semibold:600; --fw-bold:700;
  --lh-tight:1.333; --lh-normal:1.4286;

  /* spacing — 4px grid */
  --sp-0:0; --sp-1:4px; --sp-2:8px; --sp-3:12px; --sp-4:16px; --sp-5:20px;
  --sp-6:24px; --sp-8:32px; --sp-10:40px; --sp-12:48px;

  /* radius */
  --r-inner:.375rem; --r-element:.625rem; --r-container:.75rem;
  --r-page:1.75rem; --r-full:9999px;

  /* elevation — soft, sparingly */
  --shadow-low: 0 2px 4px rgba(0,0,0,.05), 0 4px 8px rgba(0,0,0,.06);
  --shadow-med: 0 4px 12px rgba(0,0,0,.10);

  /* motion */
  --t-fast:125ms; --t-med:300ms; --t-slow:700ms;

  /* layout */
  --content-max: 640px;         /* mobile-first single column */
  --tap-min: 48px;              /* min touch target — gloves-friendly */
}

/* Explicit theme override (the toggle changes density/layout, NOT color — this is only
   for a forced theme if ever needed). */
:root[data-theme="dark"]  { color-scheme: dark; }
:root[data-theme="light"] { color-scheme: light; }

/* Minimal reset — just enough to normalize the box model and defaults. */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; }
h1, h2, h3, p, ul, figure { margin: 0; }
ul { padding: 0; list-style: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
img, svg { display: block; max-width: 100%; }
:where(a) { color: inherit; }
[hidden] { display: none !important; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* Screen + component styles — token-only (see tokens.css / DESIGN.md). Calm, monochrome,
   content-first. No hard-coded colors, sizes, or radii. */

body {
  font: var(--fw-normal) var(--fs-base)/var(--lh-normal) var(--font-sans);
  background: var(--bg-body);
  color: var(--text-primary);
  min-height: 100dvh;
}

/* top bar (shown after login) */
#topbar {
  display: flex; justify-content: space-between; align-items: center;
  gap: var(--sp-3);
  min-height: var(--tap-min);
  padding: var(--sp-2) var(--sp-4);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
}
#who { font-weight: var(--fw-semibold); }

main {
  padding: var(--sp-4);
  max-width: var(--content-max);
  margin: 0 auto;
  display: grid;
  gap: var(--sp-4);
}

h1 { font-size: var(--fs-2xl); font-weight: var(--fw-semibold); line-height: var(--lh-tight); }

/* form controls (DESIGN.md recipes) */
.input {
  min-height: var(--tap-min); width: 100%;
  padding: 0 var(--sp-3);
  background: var(--bg-surface); color: var(--text-primary);
  border: 1px solid var(--border-emphasis); border-radius: var(--r-element);
  font-size: 16px; /* 16px = no iOS zoom */
}
.input:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.btn {
  min-height: var(--tap-min); padding: 0 var(--sp-4);
  border: 1px solid transparent; border-radius: var(--r-element);
  font: var(--fw-semibold) var(--fs-base)/1 var(--font-sans);
}
.btn-primary { background: var(--accent); color: var(--on-accent); }
.btn-secondary { background: var(--bg-surface); color: var(--text-primary); border-color: var(--border-emphasis); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* name picker — one tap target per teammate */
#pick-name-label { color: var(--text-secondary); font-size: var(--fs-sm); }
#user-list { display: grid; gap: var(--sp-2); }
#user-list .btn { width: 100%; text-align: left; }

.error { color: var(--error); font-size: var(--fs-sm); }

/* home / sync status — a quiet banner, never an alarm */
#sync-status {
  padding: var(--sp-3) var(--sp-4);
  background: var(--bg-muted);
  border: 1px solid var(--border);
  border-radius: var(--r-container);
  color: var(--text-secondary);
}

/* floor capture screen — scan, then dims/weight capture or attach */
.muted { color: var(--text-secondary); font-size: var(--fs-sm); }
#product-view, #scanner, #product-detail, #attach-view { display: grid; gap: var(--sp-3); }
#scan-video {
  width: 100%; aspect-ratio: 3 / 4; max-height: 60dvh;
  background: var(--bg-muted); border: 1px solid var(--border);
  border-radius: var(--r-container); object-fit: cover;
}
.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-3); }
.field-grid label { display: grid; gap: var(--sp-2); font-size: var(--fs-sm); color: var(--text-secondary); }

/* audit screen — location-driven count + two-way variance (token-only) */
#audit-view { display: grid; gap: var(--sp-3); }
.audit-shelf-entry { display: grid; grid-template-columns: 1fr auto; gap: var(--sp-2); align-items: start; }
.audit-add { display: grid; gap: var(--sp-2); }
#audit-video { width: 100%; aspect-ratio: 3 / 4; max-height: 50dvh; background: var(--bg-muted); border: 1px solid var(--border); border-radius: var(--r-container); object-fit: cover; }
.audit-row { display: grid; grid-template-columns: 1fr 5rem auto; gap: var(--sp-2); align-items: center; padding: var(--sp-2) 0; border-bottom: 1px solid var(--border); }
.audit-row-label { font-size: var(--fs-sm); }
.audit-row .muted { grid-column: 1 / -1; }
.audit-variance-block { display: grid; gap: var(--sp-2); }
.audit-variance-block h3 { font-size: var(--fs-base); font-weight: var(--fw-semibold); }
.audit-var { padding: var(--sp-2) var(--sp-3); border-radius: var(--r-element); font-size: var(--fs-sm); background: var(--bg-muted); }
.audit-var-short { color: var(--error); }
.audit-var-over { color: var(--accent); }
.audit-var-match, .audit-var-unknown { color: var(--text-secondary); }

/* office surface — incomplete worklist + SKU editor (token-only) */
#office-view, #office-worklist-wrap, #office-editor { display: grid; gap: var(--sp-3); }
.office-list { display: grid; gap: var(--sp-2); }
.office-row { width: 100%; text-align: left; }
.office-sev-high { border-left: 3px solid var(--error); }
.office-sev-medium { border-left: 3px solid var(--accent); }
.office-sev-low { border-left: 3px solid var(--border-emphasis); }
.office-fields { display: grid; gap: var(--sp-3); }
.office-field { display: grid; gap: var(--sp-2); font-size: var(--fs-sm); color: var(--text-secondary); }
.office-field textarea { min-height: 5rem; padding: var(--sp-2) var(--sp-3); background: var(--bg-surface); color: var(--text-primary); border: 1px solid var(--border-emphasis); border-radius: var(--r-element); font-size: 16px; font-family: inherit; }

/* ── App shell: sticky header, bottom tab bar, More sheet, offline banner (Phase 13) ── */
/* MOBILE-FIRST: the primary nav is a fixed bottom tab bar; the desktop sidebar is a min-width
   enhancement layered on at the very end of this block. Token-only (see DESIGN.md). */

#topbar {
  position: sticky; top: 0; z-index: 20;
  padding-top: calc(var(--sp-2) + env(safe-area-inset-top));
}
.topbar-actions { display: flex; align-items: center; gap: var(--sp-2); }
.icon-btn {
  display: grid; place-items: center;
  width: var(--tap-min); height: var(--tap-min);
  background: var(--bg-surface); color: var(--text-primary);
  border: 1px solid var(--border-emphasis); border-radius: var(--r-element);
}
.icon-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* quiet offline banner — muted, never an alarm */
#offline-banner {
  padding: var(--sp-2) var(--sp-4);
  background: var(--bg-muted); color: var(--text-secondary);
  border-bottom: 1px solid var(--border);
  font-size: var(--fs-sm); text-align: center;
}

/* leave room for the fixed tab bar so content never hides behind it */
main { padding-bottom: calc(var(--tap-min) + var(--sp-8) + env(safe-area-inset-bottom)); }

/* bottom tab bar — thumb reach */
#tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; justify-content: space-around; align-items: stretch;
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--bg-surface); border-top: 1px solid var(--border);
}
.tab {
  flex: 1 1 0; min-height: var(--tap-min);
  display: grid; grid-auto-flow: row; place-items: center; gap: 2px;
  padding: var(--sp-2) var(--sp-1);
  background: transparent; border: 0; color: var(--text-secondary);
}
.tab svg { width: 24px; height: 24px; }
.tab-label { font-size: var(--fs-xs); font-weight: var(--fw-medium); }
.tab[aria-current="page"] { color: var(--accent); }
.tab:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

/* More bottom sheet — slide up, backdrop; NOT a desktop dropdown */
.sheet { position: fixed; inset: 0; z-index: 30; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.32); }
.sheet-panel {
  position: absolute; left: 0; right: 0; bottom: 0;
  padding: var(--sp-3) var(--sp-4) calc(var(--sp-6) + env(safe-area-inset-bottom));
  background: var(--bg-surface); border-top: 1px solid var(--border);
  border-radius: var(--r-page) var(--r-page) 0 0;
  display: grid; gap: var(--sp-2);
  animation: sheet-up var(--t-med) ease;
}
@keyframes sheet-up { from { transform: translateY(100%); } to { transform: translateY(0); } }
.sheet-grabber { justify-self: center; width: 36px; height: 4px; border-radius: var(--r-full); background: var(--border-emphasis); }
.sheet-list { display: grid; gap: var(--sp-2); }
.sheet-item { display: flex; align-items: center; gap: var(--sp-3); text-align: left; }
.sheet-item svg { width: 24px; height: 24px; }

/* placeholder area (Media/Exports/People/Settings until their phase ships) */
.placeholder-card {
  display: grid; gap: var(--sp-2); place-items: center; text-align: center;
  padding: var(--sp-10) var(--sp-4);
  background: var(--bg-muted); border: 1px solid var(--border); border-radius: var(--r-container);
  color: var(--text-secondary);
}

/* ── Desktop enhancement (≥900px): the bottom tab bar becomes a left sidebar ── */
@media (min-width: 900px) {
  #tabbar {
    top: 0; right: auto; bottom: 0; width: 15rem;
    flex-direction: column; justify-content: flex-start; align-items: stretch;
    gap: var(--sp-1);
    border-top: 0; border-right: 1px solid var(--border);
    padding: var(--sp-4) var(--sp-2);
  }
  .tab { flex: 0 0 auto; grid-auto-flow: column; justify-content: flex-start; gap: var(--sp-3); padding: 0 var(--sp-3); }
  .tab-label { font-size: var(--fs-base); }
  #topbar, main { margin-left: 15rem; }
  main { padding-bottom: var(--sp-8); max-width: calc(var(--content-max) + 6rem); }
}

/* skeleton loaders — near-zero-cost pulse, reduced-motion safe */
.skeleton { background: var(--bg-muted); border-radius: var(--r-element); min-height: var(--tap-min); }
.skeleton + .skeleton { margin-top: var(--sp-2); }
@media (prefers-reduced-motion: no-preference) {
  .skeleton { animation: skeleton-pulse var(--t-slow) ease-in-out infinite; }
}
@keyframes skeleton-pulse { 0%, 100% { opacity: 1; } 50% { opacity: .55; } }

/* view transitions — respect reduced motion (the JS also guards startViewTransition) */
@media (prefers-reduced-motion: reduce) {
  ::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*) { animation: none !important; }
}

/* People admin — mobile-first list + sheets (token-only; DESIGN.md). Sheet classes are people-scoped
   so they never clobber the shell's existing .sheet/.sheet-backdrop (the More overflow sheet). */
#people-view { display: grid; gap: var(--sp-3); padding-bottom: calc(var(--tap-min) + env(safe-area-inset-bottom) + var(--sp-4)); }
.people-header { position: sticky; top: 0; z-index: 2; display: flex; align-items: baseline; gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4); background: var(--bg-body); }
.people-count { font-size: var(--fs-sm); }
.people-list { display: grid; gap: var(--sp-2); }
.people-row { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: var(--sp-3);
  width: 100%; text-align: left; min-height: var(--tap-min); padding: var(--sp-2) var(--sp-3);
  background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--r-container); }
.people-row.is-inactive { opacity: .55; }
.avatar { display: grid; place-items: center; width: 2rem; height: 2rem; border-radius: var(--r-full);
  background: var(--bg-muted); color: var(--text-secondary); font-size: var(--fs-sm); font-weight: var(--fw-semibold); }
.people-meta { display: grid; gap: var(--sp-1); min-width: 0; }
.people-name { font-weight: var(--fw-medium); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip { justify-self: start; font-size: var(--fs-xs); font-weight: var(--fw-semibold); padding: 0 var(--sp-2);
  border-radius: var(--r-full); background: var(--bg-muted); color: var(--text-secondary); border: 1px solid var(--border); }
.chip-admin { color: var(--text-primary); border-color: var(--border-emphasis); }
.dot { width: .5rem; height: .5rem; border-radius: var(--r-full); }
.dot-on { background: var(--success); }
.dot-off { background: var(--text-disabled); }
.people-actionbar { position: sticky; bottom: 0; z-index: 2; display: grid;
  padding: var(--sp-3) var(--sp-4) calc(var(--sp-3) + env(safe-area-inset-bottom));
  background: var(--bg-body); border-top: 1px solid var(--border); }
.people-actionbar .btn { width: 100%; }
.offline-banner { padding: var(--sp-2) var(--sp-3); background: var(--bg-muted); color: var(--text-secondary);
  border-radius: var(--r-element); font-size: var(--fs-sm); }

/* People bottom sheet — own classes (do NOT reuse the shell's .sheet/.sheet-backdrop) */
.people-sheet-backdrop { position: fixed; inset: 0; z-index: 20; display: grid; align-items: end; background: rgba(0,0,0,.32); }
.people-sheet { background: var(--bg-surface); border-radius: var(--r-page) var(--r-page) 0 0;
  padding: var(--sp-3) var(--sp-4) calc(var(--sp-4) + env(safe-area-inset-bottom)); display: grid; gap: var(--sp-3); }
@media (prefers-reduced-motion: no-preference) { .people-sheet { animation: people-sheet-up var(--t-med) ease; } }
@keyframes people-sheet-up { from { transform: translateY(100%); } to { transform: translateY(0); } }
.sheet-grip { justify-self: center; width: 2.5rem; height: .25rem; border-radius: var(--r-full); background: var(--border-emphasis); }
.sheet-title { font-size: var(--fs-lg); font-weight: var(--fw-semibold); }
.sheet-body { display: grid; gap: var(--sp-3); }

/* segmented role picker + capability summary */
.segmented { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--sp-1);
  padding: var(--sp-1); background: var(--bg-muted); border-radius: var(--r-element); }
.segmented-item { min-height: var(--tap-min); border: 0; border-radius: var(--r-inner);
  background: transparent; color: var(--text-secondary); font-weight: var(--fw-semibold); }
.segmented-item[aria-pressed="true"] { background: var(--bg-surface); color: var(--text-primary); box-shadow: var(--shadow-low); }
.people-caps { display: grid; gap: var(--sp-1); font-size: var(--fs-sm); color: var(--text-secondary); padding-left: var(--sp-4); list-style: disc; }

@media (min-width: 900px) {
  .people-sheet-backdrop { position: static; background: none; display: block; }
  .people-sheet { max-width: 22rem; border-radius: var(--r-container); box-shadow: var(--shadow-med); }
  .people-actionbar { position: static; border-top: 0; padding: 0; }
  .people-actionbar .btn { width: auto; justify-self: end; }
}

/* ---- first-run wizard (mobile-first: full-viewport stack, sticky top dots + sticky bottom bar) ---- */
#firstrun-view { position: fixed; inset: 0; z-index: 10; display: grid; grid-template-rows: auto 1fr auto;
  background: var(--bg-body); }
.wiz-top { display: flex; align-items: center; gap: var(--sp-3); min-height: var(--tap-min);
  padding: max(var(--sp-2), env(safe-area-inset-top)) var(--sp-4) var(--sp-2); }
.wiz-back { min-height: var(--tap-min); padding: 0 var(--sp-2); background: none; border: 0; color: var(--text-secondary);
  font: var(--fw-semibold) var(--fs-base)/1 var(--font-sans); }
.wiz-dots { display: flex; gap: var(--sp-2); margin-left: auto; }
.wiz-dot { width: 8px; height: 8px; border-radius: var(--r-full); background: var(--border-emphasis); }
.wiz-dot.is-active { background: var(--accent); }
.wiz-dot.is-done { background: var(--text-secondary); }
.wiz-body { overflow-y: auto; -webkit-overflow-scrolling: touch; padding: var(--sp-6) var(--sp-4);
  display: grid; align-content: start; gap: var(--sp-4); }
.wiz-panel { display: grid; gap: var(--sp-3); animation: wiz-fade var(--t-med) ease; }
.wiz-logo { justify-self: start; border-radius: var(--r-container); }
.wiz-users { display: grid; gap: var(--sp-2); }
.wiz-user { width: 100%; text-align: left; }
.wiz-add-name { display: grid; grid-template-columns: 1fr auto; gap: var(--sp-2); }
.wiz-actionbar { padding: var(--sp-3) var(--sp-4) calc(var(--sp-3) + env(safe-area-inset-bottom));
  background: var(--bg-surface); border-top: 1px solid var(--border); }
.wiz-actionbar .btn { width: 100%; }
@keyframes wiz-fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* skeleton loader (initial sync) */
.skeleton-list { display: grid; gap: var(--sp-2); }
.skeleton-list span { height: var(--tap-min); border-radius: var(--r-element); background: var(--bg-muted);
  animation: skel 1.2s ease-in-out infinite; }
@keyframes skel { 0%,100% { opacity: 1; } 50% { opacity: .55; } }

/* ---- iOS install bottom sheet (own classes — do NOT reuse the shell's .sheet) ---- */
.ios-sheet { position: fixed; inset: 0; z-index: 20; }
.ios-sheet-scrim { position: absolute; inset: 0; background: rgba(0,0,0,.4); }
.ios-sheet-card { position: absolute; left: 0; right: 0; bottom: 0; display: grid; gap: var(--sp-3);
  padding: var(--sp-5) var(--sp-4) calc(var(--sp-5) + env(safe-area-inset-bottom));
  background: var(--bg-surface); border-top-left-radius: var(--r-page); border-top-right-radius: var(--r-page);
  animation: ios-sheet-up var(--t-med) ease; }
.ios-steps { display: grid; gap: var(--sp-2); padding-left: var(--sp-5); color: var(--text-secondary); }
@keyframes ios-sheet-up { from { transform: translateY(100%); } to { transform: none; } }

/* ---- persistent install row ---- */
.install-row { position: sticky; bottom: 0; z-index: 5; display: grid; grid-template-columns: 1fr auto auto;
  align-items: center; gap: var(--sp-2); padding: var(--sp-3) var(--sp-4) calc(var(--sp-3) + env(safe-area-inset-bottom));
  background: var(--bg-surface); border-top: 1px solid var(--border); }

/* ---- coach-mark tour (bottom-sheet tooltip anchored to a tab item) ---- */
.coach { position: fixed; inset: 0; z-index: 30; }
.coach-scrim { position: absolute; inset: 0; background: rgba(0,0,0,.45); }
.coach-tip { position: absolute; left: var(--sp-4); right: var(--sp-4); bottom: calc(var(--tap-min) + env(safe-area-inset-bottom) + var(--sp-3));
  display: grid; gap: var(--sp-2); padding: var(--sp-4); background: var(--bg-surface);
  border: 1px solid var(--border); border-radius: var(--r-container); box-shadow: var(--shadow-med); }
.coach-actions { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); }
.coach-dismiss { justify-self: end; }
.coach-anchor { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: var(--r-element); }

/* ---- shared empty-state card ---- */
.empty-card { display: grid; justify-items: center; gap: var(--sp-2); text-align: center;
  padding: var(--sp-8) var(--sp-4); color: var(--text-secondary); }
.empty-glyph { width: 40px; height: 40px; color: var(--text-secondary); }
.empty-glyph svg { width: 100%; height: 100%; }
.empty-card h3 { font-size: var(--fs-lg); font-weight: var(--fw-semibold); color: var(--text-primary); }

@media (prefers-reduced-motion: reduce) {
  .wiz-panel, .ios-sheet-card, .coach-tip { animation: none; }
  .skeleton-list span { animation: none; }
}

/* ---- desktop enhancement (min-width only) ---- */
@media (min-width: 768px) {
  #firstrun-view { display: grid; place-items: center; }
  .wiz-body { max-width: var(--content-max); width: 100%; }
  .wiz-actionbar { max-width: var(--content-max); width: 100%; margin: 0 auto; border: 0; background: none; }
  .ios-sheet-card, .coach-tip { max-width: var(--content-max); margin: 0 auto; }
}

/* ---- Product Explorer (mobile-first) ---- */
#explore-view { display: grid; gap: var(--sp-3); padding-bottom: calc(var(--sp-12) + env(safe-area-inset-bottom)); }
#explore-search-bar { position: sticky; top: 0; z-index: 5; padding: var(--sp-2) 0 var(--sp-3); padding-top: calc(var(--sp-2) + env(safe-area-inset-top)); background: var(--bg-body); }
.breadcrumb { display: flex; flex-wrap: wrap; gap: var(--sp-1); align-items: center; }
.crumb { background: none; border: 0; color: var(--text-secondary); font-size: var(--fs-sm); min-height: var(--tap-min); padding: 0 var(--sp-1); }
.crumb:last-child { color: var(--text-primary); font-weight: var(--fw-semibold); }
.crumb-sep { color: var(--text-disabled); }
.explore-tree { display: grid; }
.tree-row { width: 100%; text-align: start; min-height: var(--tap-min); padding: var(--sp-2) var(--sp-3); background: var(--bg-surface); border: 0; border-bottom: 1px solid var(--border); color: var(--text-primary); }
.explore-results { display: grid; gap: var(--sp-2); }
.explore-sentinel { height: 1px; } /* infinite-scroll trigger; the observer's rootMargin preloads before it shows */
.product-card { display: grid; grid-template-columns: auto 1fr auto; gap: var(--sp-3); align-items: center; width: 100%; text-align: start; min-height: var(--tap-min); padding: var(--sp-2) var(--sp-3); background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--r-container); color: var(--text-primary); }
.card-thumb { width: 48px; height: 48px; object-fit: cover; border-radius: var(--r-element); background: var(--bg-muted); }
.card-thumb-empty { display: inline-block; }
.card-body { display: grid; gap: 2px; min-width: 0; }
.card-title { font-weight: var(--fw-semibold); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-sub { color: var(--text-secondary); font-size: var(--fs-sm); }
.badge { min-width: 2rem; text-align: center; padding: 2px var(--sp-2); border-radius: var(--r-full); background: var(--bg-muted); font-size: var(--fs-sm); }
.badge-zero { color: var(--text-secondary); }
.empty-state { padding: var(--sp-6) var(--sp-3); text-align: center; color: var(--text-secondary); }
.skeleton-row { height: var(--tap-min); border-radius: var(--r-container); background: var(--bg-muted); }
@media (prefers-reduced-motion: no-preference) { .skeleton-row { animation: pulse 1.2s ease-in-out infinite; } @keyframes pulse { 50% { opacity: .55; } } }
.fab { position: fixed; inset-inline-end: var(--sp-4); bottom: calc(var(--sp-12) + env(safe-area-inset-bottom) + var(--sp-3)); z-index: 6; min-height: var(--tap-min); padding: 0 var(--sp-4); border-radius: var(--r-full); background: var(--accent, var(--text-primary)); color: var(--on-accent, var(--bg-surface)); border: 0; box-shadow: var(--shadow-med); }
.filter-sheet { position: fixed; inset: 0; z-index: 20; display: grid; align-items: end; background: rgba(0,0,0,.32); }
.filter-sheet-panel { background: var(--bg-surface); border-radius: var(--r-page) var(--r-page) 0 0; padding: var(--sp-4); padding-bottom: calc(var(--sp-4) + env(safe-area-inset-bottom)); display: grid; gap: var(--sp-3); transform: translateY(100%); }
.filter-sheet.filter-sheet-open .filter-sheet-panel { transform: translateY(0); }
@media (prefers-reduced-motion: no-preference) { .filter-sheet-panel { transition: transform var(--t-med) ease; } }
.filter-group { border: 0; display: grid; gap: var(--sp-1); }
.filter-group legend { font-size: var(--fs-sm); color: var(--text-secondary); }
.filter-group label, .filter-toggle { display: flex; align-items: center; gap: var(--sp-2); min-height: var(--tap-min); }
.sheet-actions { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-2); position: sticky; bottom: 0; }
#sku-detail-view { display: grid; gap: var(--sp-3); padding-bottom: calc(var(--sp-12) + env(safe-area-inset-bottom)); }
.carousel { display: flex; gap: var(--sp-2); overflow-x: auto; scroll-snap-type: x mandatory; -webkit-overflow-scrolling: touch; }
.carousel-img { flex: 0 0 80%; aspect-ratio: 1; object-fit: cover; border-radius: var(--r-container); scroll-snap-align: center; background: var(--bg-muted); }
.carousel-empty { flex: 1; aspect-ratio: 16/9; display: grid; place-items: center; color: var(--text-secondary); background: var(--bg-muted); border-radius: var(--r-container); }
.chips { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.detail-chip { padding: 2px var(--sp-2); border-radius: var(--r-full); font-size: var(--fs-sm); background: var(--bg-muted); }
.detail-chip-missing { color: var(--warning); }
.detail-chip-ok { color: var(--success); }
.sku-block h3 { font-size: var(--fs-base); font-weight: var(--fw-semibold); margin-block-end: var(--sp-1); }
.sku-block dl { display: grid; grid-template-columns: auto 1fr; gap: var(--sp-1) var(--sp-3); font-size: var(--fs-sm); }
.sku-block dt { color: var(--text-secondary); }
.action-bar { position: fixed; inset-inline: 0; bottom: 0; z-index: 6; display: flex; gap: var(--sp-2); padding: var(--sp-3) var(--sp-4); padding-bottom: calc(var(--sp-3) + env(safe-area-inset-bottom)); background: var(--bg-surface); border-top: 1px solid var(--border); }
.action-bar .btn { flex: 1; }
@media (min-width: 900px) {
  .explore-results { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
  .action-bar { position: static; border: 0; padding-inline: 0; }
}
