/* ---- Self-hosted fonts (Roboto 400/500/700) ---- */
@font-face {
  font-family: 'Roboto';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('assets/fonts/roboto-400.woff2') format('woff2');
}
@font-face {
  font-family: 'Roboto';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('assets/fonts/roboto-500.woff2') format('woff2');
}
@font-face {
  font-family: 'Roboto';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('assets/fonts/roboto-700.woff2') format('woff2');
}

:root {
  /* Batavia brand palette — verified against bataviastore.com / bataviapower.com */
  --font: 'Roboto', -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
  --bg: #f4f4f7;
  --panel: #ffffff;
  --panel-2: #f9f9f9;
  --panel-hover: #f0f1f4;
  --border: #ebebeb;
  --border-strong: #cccccc;
  --text: #232323;
  --text-dim: #666666;
  --accent: #F59C00;        /* Batavia orange */
  --accent-deep: #C27C00;
  --accent-soft: rgba(245, 156, 0, 0.14);
  --accent-glow: rgba(245, 156, 0, 0.32);
  --danger: #d64545;
}

* { box-sizing: border-box; }

html,
body {
  height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

.app {
  /* Two tracks only: the build panel floats over the stage (M12) instead of
     owning a third column, so the 3D stage gets the rest of the window. */
  display: grid;
  grid-template-columns: 320px 1fr;
  height: 100vh;
  width: 100vw;
}

/* ---------- Sidebar ---------- */
.sidebar {
  background: var(--panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  padding: 22px 18px 16px 18px;
  gap: 6px;
}

.brand {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 18px;
}

.brand-logo {
  /* Maxxclick wordmark is 8.24:1 (much wider than the old 5:1 Batavia mark), so
     it needs more width to keep a comparable cap height in the header. */
  width: 180px;
  height: auto;
  display: block;
}

.brand-sub {
  font-size: 11px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.11em;
  font-weight: 500;
}

.section-label {
  font-size: 11px;
  letter-spacing: 0.02em;
  color: var(--text-dim);
  margin: 6px 4px 10px 4px;
  font-weight: 500;
}

.product-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
}

.product-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
  user-select: none;
  /* desktop layout: vertical list may scroll; horizontal pull toward the canvas is ours */
  touch-action: pan-y;
}

/* .product-card is a <button> since M9 — neutralize UA button styles */
button.product-card {
  appearance: none;
  font-family: inherit;
  font-size: inherit;
  color: inherit;
  text-align: left;
  width: 100%;
  margin: 0;
}

.product-card:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.product-card:hover {
  background: var(--panel-2);
  border-color: var(--accent);
  transform: translateX(1px);
  box-shadow: 0 2px 10px rgba(245, 156, 0, 0.12);
}

.product-card:active {
  transform: translateX(1px) scale(0.99);
}

.product-card.dragging {
  opacity: 0.45;
}

.product-card.pressed {
  border-color: var(--accent);
  background: var(--panel-2);
}

.product-thumb {
  width: 48px;
  height: 48px;
  border-radius: 8px;
  background: linear-gradient(135deg, #fafafc 0%, #ececef 100%);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
}

.product-thumb img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  transition: transform 0.35s cubic-bezier(0.22, 1, 0.3, 1);
  -webkit-user-drag: none;
  user-select: none;
}

.product-card:hover .product-thumb img {
  transform: rotate(8deg) scale(1.08);
}

.product-thumb.thumb-fallback {
  color: #8a94a6;
  font-size: 10px;
  font-weight: 500;
}

.product-info {
  flex: 1;
  min-width: 0;
}

.product-name {
  font-weight: 500;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.product-price {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 2px;
}

.product-add {
  color: var(--accent);
  font-size: 18px;
  font-weight: 400;
  line-height: 1;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1px solid var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s ease, color 0.15s ease;
}

.product-card:hover .product-add {
  background: var(--accent);
  color: #fff;
}

/* ---------- Floating stage actions (all breakpoints — spec M-E) ---------- */
.stage-actions {
  position: absolute;
  left: 14px;
  bottom: 14px;
  display: flex;
  gap: 8px;
  z-index: 4;
}

.btn-clear,
.btn-reset {
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 0 14px;
  min-height: 36px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  touch-action: manipulation;
  transition: background 0.15s ease, border-color 0.15s ease;
}

@media (pointer: coarse) {
  .btn-clear,
  .btn-reset {
    min-height: 44px;
    padding: 0 16px;
  }
}

.btn-clear:hover {
  background: #fff0ee;
  border-color: var(--danger);
  color: var(--danger);
}

.btn-reset:hover {
  background: var(--panel-2);
  border-color: var(--border-strong);
}

/* ---------- Stage / Canvas ---------- */
.stage {
  position: relative;
  background: var(--bg);
  overflow: hidden;
}

canvas#scene {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: pan-y; /* JS re-asserts this — OrbitControls forces inline 'none' */
}

.stage-hud {
  position: absolute;
  top: 18px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
  z-index: 2;
}

.hud-pill {
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--border);
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text);
}

.hud-hint {
  font-size: 11px;
  color: var(--text-dim);
  letter-spacing: 0.02em;
  font-weight: 500;
  background: rgba(255, 255, 255, 0.7);
  padding: 4px 10px;
  border-radius: 999px;
}

/* ---------- Drop overlay ---------- */
.drop-overlay {
  position: absolute;
  inset: 0;
  background: var(--accent-soft);
  border: 2px dashed var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s ease;
  z-index: 3;
}

.drop-overlay.active { opacity: 1; }

.drop-overlay-inner {
  background: #fff;
  border: 1px solid var(--accent);
  border-radius: 14px;
  padding: 18px 26px;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15), 0 0 30px var(--accent-glow);
}

.drop-icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  font-size: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.drop-text { font-weight: 500; }

/* ---------- Loader ---------- */
.loader {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  background: var(--bg);
  z-index: 10;
  transition: opacity 0.3s ease;
}

.loader.hidden { opacity: 0; pointer-events: none; }

.loader-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.loader-text {
  font-size: 12px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 500;
}

/* ---------- Fatal error panel (WebGL unavailable) ---------- */
.fatal-error {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: var(--bg);
  z-index: 10;
  text-align: center;
  padding: 24px;
}

.fatal-error-title {
  font-size: 16px;
  font-weight: 700;
}

.fatal-error-body {
  font-size: 13px;
  color: var(--text-dim);
  max-width: 380px;
  line-height: 1.5;
}

.fatal-error-link {
  margin-top: 8px;
  font-size: 13px;
  font-weight: 500;
  color: var(--accent);
}

/* ---------- Context-lost overlay ---------- */
.context-lost {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  background: rgba(244, 244, 247, 0.92);
  z-index: 9;
}

/* display:flex above would defeat the hidden attribute without this */
.context-lost[hidden] { display: none; }

.context-lost-text {
  font-size: 12px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 500;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Toast ---------- */
.toast {
  position: absolute;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: rgba(20, 20, 20, 0.94);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 10px 12px 10px 18px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: min(92%, 480px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 5;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.toast.visible {
  opacity: 1;
  pointer-events: auto; /* the action button must be clickable */
  transform: translateX(-50%) translateY(0);
}

.toast-text {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.toast-action {
  appearance: none;
  flex-shrink: 0;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: 6px 14px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s ease;
  touch-action: manipulation;
}

.toast-action:hover { background: var(--accent-deep); }

/* ---------- "Your build" panel (floating dropdown over the stage) ---------- */
/* Lives inside <main class="stage"> and floats BOTTOM-right so the 3D stage
   keeps the full width. Anchoring to the bottom is what lets it open as far as
   it can: the card grows upward from a fixed corner, so "expanded" is bounded
   by the stage rather than by a guessed pixel height, and the footer (Total +
   Add all to cart) never moves.
   No conflict in the bottom-right: the floating "Open in shop" lives there only
   in display mode, where this panel is display:none. .stage-actions is
   bottom-LEFT. z-index 2 is deliberate: above the canvas, but BELOW the
   selection chip / stage actions (4) and the suggested-rail CTA (3) — an opaque
   card must never swallow those. */
.cart-panel {
  position: absolute;
  bottom: 14px;
  right: 14px;
  width: 252px;
  max-width: calc(100% - 28px);
  /* Never taller than the stage; .cart-body is the part that gives. */
  max-height: calc(100% - 28px);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.13), 0 2px 6px rgba(0, 0, 0, 0.05);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  text-align: left;
  z-index: 2;
}

/* Wrapper around the list + footer. display:contents makes it vanish on desktop
   so the panel's flex column (toggle / body / footer) is byte-for-byte the same
   as before; on mobile (≤860px) it becomes a real card that slides up over the
   stage while the summary stays docked in the bottom bar. */
.cart-drawer { display: contents; }

/* Dims the stage behind the open mobile drawer. Never painted on desktop. */
.cart-scrim { display: none; }

.cart-toggle {
  /* The whole header is the expand/collapse control (aria-expanded in JS). */
  appearance: none;
  background: var(--panel);
  border: none;
  border-bottom: 1px solid var(--border);
  padding: 11px 13px;
  display: flex;
  align-items: center;
  gap: 9px;
  text-align: left;
  cursor: pointer;
  font-family: inherit;
  color: var(--text);
  width: 100%;
  touch-action: manipulation;
}

.cart-toggle:hover { background: var(--panel-hover); }
.cart-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

.cart-toggle-icon {
  width: 26px;
  height: 26px;
  border-radius: 7px;
  background: var(--accent-soft);
  color: var(--accent-deep);
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
}

.cart-toggle-main {
  flex: 1;
  min-width: 0;
  display: block;
}

.cart-toggle-label {
  display: block;
  font-weight: 700;
  font-size: 13px;
  letter-spacing: -0.01em;
}

.cart-sub {
  display: block;
  font-size: 11.5px;
  color: var(--text-dim);
  margin-top: 1px;
  font-weight: 400;
}

.cart-toggle-total {
  display: none; /* the footer total is always visible now — see .cart-footer */
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.cart-toggle-chevron {
  color: var(--text-dim);
  transition: transform 0.18s ease;
  flex-shrink: 0;
}

.cart-panel.expanded .cart-toggle-chevron { transform: rotate(180deg); }

@media (prefers-reduced-motion: reduce) {
  .cart-toggle-chevron { transition: none; }
}

/* Collapsed: a ~96 px peek of the rows, clipped, with .cart-fade over it.
   Open: taller and scrollable. The footer is NOT inside here. */
.cart-body {
  position: relative;
  max-height: 96px;
  overflow: hidden;
}

/* Open: take every pixel the panel's max-height allows. `flex: 1 1 auto` +
   `min-height: 0` is what makes the flex column actually shrink the rows list
   (and only it) when the card hits the top of the stage — the toggle and the
   footer keep their natural height, and a long build scrolls inside here. A
   fixed max-height would either clip a short build early or overflow a short
   stage, so the breakpoint overrides that used to set one are gone. */
.cart-panel.expanded .cart-body {
  max-height: none;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
}

.cart-items {
  display: flex;
  flex-direction: column;
}

.cart-empty {
  color: var(--text-dim);
  font-size: 11.5px;
  text-align: center;
  padding: 14px 12px;
  line-height: 1.5;
}

/* White gradient over the clipped peek, carrying "Show all N". The fade itself
   is inert so the rows under it stay clickable; only the pill takes clicks. */
.cart-fade {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 54px;
  pointer-events: none;
  background: linear-gradient(
    to bottom,
    rgba(255, 255, 255, 0) 0%,
    rgba(255, 255, 255, 0.86) 52%,
    #ffffff 100%
  );
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 5px;
}

.cart-fade[hidden] { display: none; }
.cart-panel.expanded .cart-fade { display: none; }

.cart-more {
  appearance: none;
  pointer-events: auto;
  background: none;
  border: none;
  padding: 2px 8px;
  font-family: inherit;
  font-size: 10.5px;
  font-weight: 700;
  color: var(--accent-deep);
  cursor: pointer;
  touch-action: manipulation;
}

.cart-more:hover { text-decoration: underline; }

.cart-row {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 13px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  transition: background 0.15s ease;
}

.cart-row:hover { background: var(--panel-2); }

.cart-row-thumb {
  width: 38px;
  height: 38px;
  border-radius: 8px;
  background: linear-gradient(135deg, #fafafc 0%, #ececef 100%);
  border: 1px solid var(--border);
  flex: none;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* No snapshot yet (rows can be built before the boot prefetch reaches that
   product) — the empty tile IS the placeholder, never a broken <img>. */
.cart-row-thumb img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  -webkit-user-drag: none;
  user-select: none;
}

.cart-row-main { flex: 1; min-width: 0; }

.cart-row-name {
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Wraps rather than ellipsizes: the pack/price line is the honest-pricing copy
   (U1) and must stay readable in a card this narrow. Two short lines cost no
   row height — the 38 px thumbnail already sets the floor. */
.cart-row-meta {
  font-size: 10.5px;
  color: var(--text-dim);
  margin-top: 2px;
  line-height: 1.3;
}

.cart-row-note {
  font-size: 10px;
  color: var(--accent-deep);
  margin-top: 3px;
  line-height: 1.35;
  white-space: normal;
}

.cart-row-side {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  flex: none;
}

.cart-row-qty {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}

.cart-qty-btn {
  appearance: none;
  width: 22px;
  height: 22px;
  border-radius: 6px;
  border: 1px solid var(--border-strong);
  background: var(--panel);
  color: var(--text);
  font-family: inherit;
  line-height: 0;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease,
    opacity 0.12s ease;
  touch-action: manipulation;
}

.cart-qty-btn:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent-deep);
  opacity: 1;
}

/* Last one of its kind: the minus is dimmed to say "this empties the row".
   It stays CLICKABLE on purpose — removing the last adapter of a brand (or the
   last of any product) from the panel would otherwise be impossible. */
.cart-qty-btn.qty-dim { opacity: 0.42; }

.cart-qty-count {
  min-width: 17px;
  text-align: center;
  font-size: 12px;
  font-weight: 700;
  color: var(--accent-deep);
  font-variant-numeric: tabular-nums;
}

.cart-row-price {
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.cart-footer {
  /* OUTSIDE .cart-body: Total and the CTA stay visible while collapsed. */
  padding: 11px 13px;
  display: flex;
  flex-direction: column;
  gap: 9px;
  background: var(--panel);
}

.cart-total-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  font-size: 12px;
}

.cart-total-row span:first-child {
  color: var(--text-dim);
  font-weight: 500;
}

.cart-total {
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
}

.btn-cart {
  background: linear-gradient(144deg, #FAB234, #F59C00);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 10px 12px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition: filter 0.15s ease, transform 0.05s ease, opacity 0.15s ease;
  box-shadow: 1px 0 7px -1px rgba(245, 156, 0, 0.35);
  touch-action: manipulation;
}

.btn-cart:not(:disabled):hover { filter: brightness(0.96); }
.btn-cart:not(:disabled):active { transform: translateY(1px); }
.btn-cart:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  box-shadow: none;
}

/* 44 px touch targets, same rule as the selection chip / suggest CTA. The card
   widens to keep the name column readable next to the bigger steppers. */
@media (pointer: coarse) {
  .cart-panel { width: 276px; }
  .btn-cart,
  .btn-share { min-height: 44px; }
  .cart-qty-btn {
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    border-radius: 8px;
  }
  .cart-more { padding: 6px 12px; font-size: 11px; }
  /* 44 px steppers will not fit beside the name in a card this narrow, so the
     subtotal + stepper drop onto their own full-width line and the peek grows
     to keep showing about a row and a half. */
  .cart-row { flex-wrap: wrap; }
  .cart-row-side {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    gap: 10px;
  }
  .cart-body { max-height: 132px; } /* collapsed peek only — open is stage-bounded */
}

.btn-share {
  appearance: none;
  background: var(--panel);
  border: 1px solid var(--border-strong);
  color: var(--text);
  border-radius: 8px;
  padding: 8px 12px;
  font-family: inherit;
  font-size: 11.5px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
  touch-action: manipulation;
}

.btn-share:hover {
  background: var(--panel-2);
  border-color: var(--accent);
}

.btn-share.share-floating {
  position: absolute;
  right: 16px;
  bottom: 16px;
  z-index: 4;
  background: #fff;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12);
}

/* ---------- Selection chip (Move/Remove — Confirm/Cancel in move mode) ---------- */
.selection-chip {
  position: absolute;
  left: 0;
  top: 0;
  display: none;
  gap: 4px;
  padding: 4px;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.14), 0 2px 6px rgba(0, 0, 0, 0.05);
  transform: translate(-50%, -130%);
  z-index: 4;
  will-change: transform;
}

.selection-chip.visible { display: flex; }

.chip-btn {
  height: 30px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text);
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 0 10px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  touch-action: manipulation;
  transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}

.chip-btn[hidden] { display: none; }

.chip-btn:hover {
  background: var(--panel-2);
  border-color: var(--border);
}

.chip-danger:hover {
  background: #ffecec;
  border-color: var(--danger);
  color: var(--danger);
}

.chip-confirm {
  background: var(--accent);
  color: #fff;
}

.chip-confirm:hover {
  background: var(--accent-deep);
  border-color: transparent;
}

/* 44 px touch targets (spec section 3, nice-to-have folded into M-A) */
@media (pointer: coarse) {
  .selection-chip { gap: 8px; padding: 6px; }
  .chip-btn {
    min-height: 44px;
    min-width: 44px;
    padding: 0 14px;
    font-size: 13px;
  }
}

/* ---------- Move-mode travel track ---------- */
/* Shown only while an item is in move mode. Anchored under the item and spanning
 * how far it can actually slide on its rail chain, so the arrows say "drag me"
 * and the dashes say "this far". Same absolute/transform conventions as
 * .selection-chip; sits one layer below it so the chip always wins. */
.move-track {
  position: absolute;
  left: 0;
  top: 0;
  display: none;
  align-items: center;
  gap: 6px;
  color: var(--accent-deep);
  pointer-events: none; /* never steals a drag from the canvas underneath */
  z-index: 3;
  will-change: transform, width;
}

.move-track.visible { display: flex; }

.move-track-line {
  flex: 1 1 auto;
  min-width: 0;
  height: 0;
  border-top: 2px dashed var(--accent);
}

.move-arrow {
  flex: none;
  filter: drop-shadow(0 1px 2px rgba(255, 255, 255, 0.9));
}

.move-arrow-left { animation: move-arrow-left 1.6s ease-in-out infinite; }
.move-arrow-right { animation: move-arrow-right 1.6s ease-in-out infinite; }

@keyframes move-arrow-left {
  0%, 60%, 100% { transform: translateX(0); }
  30% { transform: translateX(-3px); }
}

@keyframes move-arrow-right {
  0%, 60%, 100% { transform: translateX(0); }
  30% { transform: translateX(3px); }
}

@media (prefers-reduced-motion: reduce) {
  .move-arrow-left,
  .move-arrow-right { animation: none; }
}

/* Matches the 44 px touch sizing of .selection-chip above. */
@media (pointer: coarse) {
  .move-track { gap: 9px; }
  .move-arrow { width: 17px; height: 17px; }
  .move-track-line { border-top-width: 2.5px; }
}

/* ---------- Dimension label ---------- */
.dim-label {
  position: absolute;
  left: 0;
  top: 0;
  background: #ffffff;
  border: 1.5px solid var(--accent);
  color: var(--accent-deep);
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
  pointer-events: none;
  white-space: nowrap;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.1), 0 0 10px var(--accent-glow);
  /* z-index 1: these are projected onto the scene and are appended to the
     stage at runtime, i.e. AFTER the build panel in DOM order — at an equal
     z-index they would paint over the panel's own text (M12). */
  z-index: 1;
  transition: opacity 0.12s ease;
  will-change: transform;
}

/* ---------- Empty-wall placeholder label ---------- */
.empty-rail-label {
  position: absolute;
  left: 0;
  top: 0;
  background: #ffffff;
  border: 1.5px dashed var(--accent);
  color: var(--accent-deep);
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  pointer-events: none;
  white-space: nowrap;
  z-index: 1; /* below the build panel — see .dim-label */
  transition: opacity 0.12s ease;
  will-change: transform;
}

/* ---------- Suggested-rail CTA (projected from a 3D anchor, like .dim-label) ---------- */
.suggest-cta {
  position: absolute;
  left: 0;
  top: 0;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  background: #ffffff;
  border: 1.5px solid var(--accent);
  border-radius: 999px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.14), 0 0 12px var(--accent-glow);
  white-space: nowrap;
  z-index: 3;
  transition: opacity 0.12s ease;
  will-change: transform;
}

.suggest-cta[hidden] { display: none; }

.suggest-add {
  min-height: 30px;
  padding: 0 14px;
  border: none;
  border-radius: 999px;
  background: var(--accent);
  color: #ffffff;
  font-family: inherit;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  touch-action: manipulation;
  transition: background 0.15s ease;
}

.suggest-add:hover { background: var(--accent-deep); }
.suggest-add:disabled { opacity: 0.6; cursor: default; }

.suggest-dismiss {
  min-height: 26px;
  min-width: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: 999px;
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  touch-action: manipulation;
  transition: background 0.12s ease, color 0.12s ease;
}

.suggest-dismiss:hover {
  background: #ffecec;
  color: var(--danger);
}

/* 44 px touch targets, same rule as the selection chip */
@media (pointer: coarse) {
  .suggest-cta { gap: 8px; padding: 6px; }
  .suggest-add { min-height: 44px; padding: 0 18px; font-size: 13px; }
  .suggest-dismiss { min-height: 44px; min-width: 44px; }
}

/* ---------- Touch coach overlay ---------- */
.touch-coach {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(20, 20, 20, 0.35);
  z-index: 6;
  pointer-events: none; /* never traps a gesture — purely informational */
}

.touch-coach[hidden] { display: none; }

.touch-coach-inner {
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 20px;
  font-size: 13px;
  font-weight: 500;
  max-width: 260px;
  text-align: center;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
}

/* ---------- Mobile: Add product → sheet → place mode (M14) ----------
   Everything below is inert on desktop: .mobile-bar is display:none outside
   the phone breakpoint and the sheet is only ever opened from that bar, so
   the desktop sidebar's click + press-drag placement is untouched. */

.mobile-bar {
  display: none; /* the ≤860px block above turns this on */
  background: var(--panel);
  border-top: 1px solid var(--border);
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom, 0px)) 12px;
  z-index: 5; /* above the stage's projected overlays, below the sheet */
}

/* Batavia gradient CTA — same treatment as .btn-cart, full width and
   thumb-reachable at the bottom of the screen. */
.mobile-add {
  appearance: none;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 48px; /* > the 44 px coarse-pointer floor */
  background: linear-gradient(144deg, #FAB234, #F59C00);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.01em;
  cursor: pointer;
  touch-action: manipulation;
  box-shadow: 0 2px 10px -1px rgba(245, 156, 0, 0.4);
  transition: filter 0.15s ease, transform 0.05s ease;
}
.mobile-add:hover { filter: brightness(0.96); }
.mobile-add:active { transform: translateY(1px); }
.mobile-add:focus-visible { outline: 2px solid var(--accent-deep); outline-offset: 2px; }
.mobile-add[hidden] { display: none; }

.mobile-add-plus {
  font-size: 19px;
  font-weight: 400;
  line-height: 1;
  margin-top: -2px;
}

/* Place mode replaces the button in the same bar, so the bar never changes
   height and the stage never reflows mid-placement. */
.place-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
}
.place-bar[hidden] { display: none; }

.place-bar-text {
  flex: 1;
  min-width: 0;
  font-size: 12.5px;
  line-height: 1.35;
  color: var(--text-dim);
}
.place-bar-text b {
  color: var(--text);
  font-weight: 600;
}

.place-bar-cancel {
  flex: none;
  appearance: none;
  min-height: 44px;
  padding: 0 16px;
  background: var(--panel);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  touch-action: manipulation;
}
.place-bar-cancel:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* ---- Bottom sheet ---- */
.sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(20, 20, 20, 0.32);
  z-index: 30;
  animation: sheet-fade 0.16s ease;
}
.sheet-backdrop[hidden] { display: none; }

.product-sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 31;
  display: flex;
  flex-direction: column;
  max-height: 78vh;
  max-height: 78dvh;
  background: var(--panel);
  border-radius: 16px 16px 0 0;
  box-shadow: 0 -8px 26px rgba(0, 0, 0, 0.18);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  animation: sheet-rise 0.2s ease;
}
.product-sheet[hidden] { display: none; }

@keyframes sheet-rise {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}
@keyframes sheet-fade {
  from { opacity: 0; }
  to { opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  .product-sheet,
  .sheet-backdrop { animation: none; }
}

/* The grab handle + title are the swipe-down surface, so they own the
   gesture (touch-action:none) while the list below scrolls normally. */
.sheet-header {
  flex: none;
  padding: 8px 14px 8px 14px;
  border-bottom: 1px solid var(--border);
  touch-action: none;
  cursor: grab;
}

.sheet-grab {
  display: block;
  width: 36px;
  height: 4px;
  margin: 0 auto 10px;
  border-radius: 2px;
  background: var(--border-strong);
}

.sheet-title {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.sheet-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding-bottom: 8px;
}

.sheet-row {
  appearance: none;
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  min-height: 60px;
  padding: 10px 14px;
  background: none;
  border: none;
  border-bottom: 1px solid var(--border);
  font-family: inherit;
  text-align: left;
  color: inherit;
  cursor: pointer;
  touch-action: manipulation;
}
.sheet-row:active { background: var(--panel-hover); }
.sheet-row:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

.sheet-row-thumb {
  flex: none;
  width: 44px;
  height: 44px;
  border-radius: 8px;
  background: linear-gradient(135deg, #fafafc 0%, #ececef 100%);
  border: 1px solid var(--border);
  display: grid;
  place-items: center;
  overflow: hidden;
}
.sheet-row-thumb img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.sheet-row-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sheet-row-name {
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text);
}

.sheet-row-meta {
  font-size: 11.5px;
  color: var(--text-dim);
}

.sheet-row-chevron {
  flex: none;
  color: var(--text-dim);
}

/* Out of stock reads as unavailable but stays placeable, exactly like the
   desktop cards (M11.3) — the builder lets you plan with it, only the cart
   refuses it. Kept as an attribute rule too in case a row is ever disabled. */
.sheet-row.sheet-row-unavailable,
.sheet-row[disabled] {
  opacity: 0.7;
}
.sheet-row.sheet-row-unavailable .sheet-row-thumb img,
.sheet-row[disabled] .sheet-row-thumb img { filter: saturate(0.25); }

/* The adapter needs a battery platform before it can be placed, so its row
   expands in place into the six ADAPTER_PLATFORMS options (step 2 of the
   sheet) instead of arming straight away. */
.sheet-platforms {
  display: none;
  flex-direction: column;
  background: var(--panel-2);
  border-bottom: 1px solid var(--border);
}
.sheet-platforms.open { display: flex; }

.sheet-platform {
  appearance: none;
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 46px;
  padding: 10px 14px 10px 34px;
  background: none;
  border: none;
  border-top: 1px solid var(--border);
  font-family: inherit;
  font-size: 12.5px;
  text-align: left;
  color: var(--text);
  cursor: pointer;
  touch-action: manipulation;
}
.sheet-platform:first-child { border-top: none; }
.sheet-platform:active { background: var(--panel-hover); }
.sheet-platform:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

/* ---------- Mobile layout ---------- */
@media (max-width: 1100px) {
  .app {
    grid-template-columns: 280px 1fr;
  }
  .brand-logo { width: 158px; }
}

@media (max-width: 860px) {
  html, body { overflow: hidden; }

  .app {
    /* Row 3 is the mobile add / place bar; the build panel still floats on
       the stage rather than owning a row of its own. */
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr auto;
    height: 100vh;
    height: 100dvh;
  }

  /* Sidebar becomes top bar — logo + horizontally scrolling product row */
  .sidebar {
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding: 10px 12px 12px 12px;
    gap: 10px;
  }
  .brand {
    flex-direction: row;
    align-items: center;
    gap: 10px;
    padding-bottom: 0;
    border-bottom: none;
    margin-bottom: 0;
  }
  .brand-logo { width: 150px; }
  .brand-sub { display: none; }

  .section-label { display: none; }

  /* The horizontally-scrolling product strip is GONE on phones. At 456px it
     showed exactly one card with no affordance that it scrolled, so nine of
     ten products were undiscoverable. display:none removes the cards from
     layout AND from the a11y tree — there is no dead scrolling row left
     behind the button. Adding now goes through #mobile-bar → #product-sheet.
     The sidebar keeps the brand mark and nothing else. */
  .product-list { display: none; }

  .sidebar { padding: 8px 12px; }

  /* Row 3 of .app — the docked build panel + Add button live here, and it's
     still the only way to add a product on a phone. position/z-index give the
     scrim a stacking context above the stage. */
  .mobile-bar {
    display: block;
    position: relative;
    z-index: 5;
  }

  /* One row: the build panel (left) + Add button (right). Raised above the scrim
     so both stay bright while the drawer is open, and the containing block the
     drawer anchors to. */
  .mobile-bar-main {
    position: relative;
    z-index: 6;
    display: flex;
    align-items: stretch;
    gap: 8px;
  }
  .mobile-bar-main[hidden] { display: none; } /* place mode hides the whole row */

  /* The build panel was a floating bubble bottom-right; now it's the docked left
     half of the bar. It stays a plain flow box (position:static) so the drawer
     anchors to .mobile-bar-main and can span the FULL bar width, not just this
     half. The row height never changes — the drawer escapes upward. */
  .cart-panel {
    position: static;
    flex: 1 1 auto;
    min-width: 0;
    width: auto;
    max-width: none;
    max-height: none;
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: none;
    overflow: visible;
  }

  /* The summary row IS the toggle. */
  .cart-toggle {
    border-bottom: none;
    border-radius: 10px;
    min-height: 48px;
    padding: 8px 10px;
    gap: 8px;
  }
  .cart-toggle-icon { width: 26px; height: 26px; border-radius: 7px; }
  .cart-toggle-label { font-size: 12.5px; }
  .cart-sub { display: none; } /* the total carries the collapsed summary */
  /* No footer when collapsed, so surface the total in the summary itself. */
  .cart-toggle-total { display: block; }

  /* "Add product" is now a floating action button on the stage's bottom-left
     (JS moves it out of the bar and into .stage on mobile). A pill with the +
     glyph, echoing the sidebar's orange add affordance. */
  .mobile-add {
    position: absolute;
    left: 12px;
    bottom: 12px;
    z-index: 4; /* same layer as .stage-actions / the selection chip */
    width: auto;
    flex: none;
    min-height: 44px;
    padding: 0 16px 0 13px;
    border-radius: 999px;
    gap: 6px;
    box-shadow: 0 4px 14px -2px rgba(245, 156, 0, 0.5), 0 2px 6px rgba(0, 0, 0, 0.12);
  }

  /* "Add all to cart" now lives in the bar (right of the summary), always
     visible so checkout is one tap away even with the drawer collapsed. */
  .btn-cart {
    flex: none;
    min-height: 48px;
    padding: 0 18px;
    border-radius: 10px;
    font-size: 14px;
  }

  /* Collapsed: only the summary shows — the drawer is out of layout. */
  .cart-drawer { display: none; }

  /* Expanded: the list + footer slide UP over the stage as a full-width card,
     anchored just above the summary row. */
  .cart-panel.expanded .cart-toggle {
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
  }
  .cart-panel.expanded .cart-drawer {
    display: flex;
    flex-direction: column;
    position: absolute;
    left: 0;
    right: 0;
    bottom: calc(100% + 8px);
    max-height: 60vh;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 -10px 34px rgba(0, 0, 0, 0.16), 0 2px 6px rgba(0, 0, 0, 0.05);
    overflow: hidden;
    z-index: 7;
  }
  /* Inside the drawer the list scrolls; the footer stays pinned at the bottom. */
  .cart-panel.expanded .cart-body {
    max-height: none;
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
  }

  .cart-row { padding: 8px 10px; gap: 7px; }
  .cart-row-thumb { width: 32px; height: 32px; }
  .cart-footer { padding: 10px 12px; gap: 8px; border-top: 1px solid var(--border); }
  .cart-total { font-size: 16px; }

  /* Scrim over the stage while the drawer is open (JS toggles [hidden]). */
  .cart-scrim:not([hidden]) {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 5;
    background: rgba(20, 20, 20, 0.30);
  }

  /* The build panel used to own the top-right of a phone-width stage, which is
     why the HUD was pushed off-centre and squeezed to calc(100% - 240px). The
     panel is bottom-right now, so the top belongs to the HUD again — but the
     bottom no longer fits two things. On a 375 px stage a bottom-LEFT button
     strip runs straight into the panel (measured: 33x36 px, collapsed AND
     expanded, so narrowing or state-toggling would not save it). The secondary
     actions move to the top-left instead and the HUD drops below them. */
  .stage-actions {
    top: 10px;
    left: 10px;
    bottom: auto;
  }
  .stage-hud {
    top: 58px;
    max-width: calc(100% - 20px);
  }
  .hud-pill {
    font-size: 11px;
    padding: 5px 10px;
  }
  .hud-hint {
    font-size: 10px;
    padding: 3px 8px;
  }
}

/* Phone + touch: the docked drawer already uses the (pointer: coarse) row-wrap
   and 44 px steppers from the base coarse block. No collapsed peek to size now —
   the summary is a single fixed-height row and the drawer is stage-bounded. */


/* ---------- Display mode (?mode=display — bataviapower.com embed) ---------- */
/* Builder only: the floating build panel (with its Add-all-to-cart CTA) is
   removed entirely. Since M12 the panel no longer occupies a grid track, so
   there is nothing else for display mode to re-flow — the stage is already
   full width. Overrides live at the end of the file; the body.mode-display
   prefix also out-specifies the base rules. */
body.mode-display .cart-panel {
  display: none;
}

/* ---- Out-of-stock products (M11.3) ----
   Unavailable products stay fully visible and placeable; only the money
   stops. Do not hide or disable these cards. */
.stock-badge {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 6px;
  border-radius: 999px;
  background: #eceef2;
  border: 1px solid var(--border-strong, #cccccc);
  color: var(--text-dim);
  font-size: 9px;
  font-weight: 500;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  vertical-align: middle;
}

.product-card.product-unavailable .product-thumb {
  filter: saturate(0.35);
}

.cart-row.cart-row-unavailable .cart-row-name,
.cart-row.cart-row-unavailable .cart-row-meta {
  color: var(--text-dim);
}

.cart-row.cart-row-unavailable .cart-row-thumb img {
  filter: saturate(0.35);
}

.cart-row-price-void {
  color: var(--text-dim);
  font-size: 10px;
  font-weight: 500;
  white-space: nowrap;
}

/* ---- Per-adapter battery-platform picker (M11.5) ----
   The adapter card places nothing by itself: it opens this panel, and the
   panel places. Each option is a real <button> so Tab/Enter/Space work. */
.product-card[role='button'] {
  flex-wrap: wrap;
}

.platform-picker {
  display: none;
  width: 100%;
  flex-basis: 100%;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
  gap: 4px;
  flex-direction: column;
}

.product-card.picker-open .platform-picker {
  display: flex;
}

.platform-picker-hint {
  font-size: 10px;
  color: var(--text-dim);
  margin-bottom: 2px;
}

.platform-option {
  display: block;
  width: 100%;
  text-align: left;
  font: inherit;
  font-size: 11px;
  line-height: 1.2;
  color: inherit;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 7px 8px;
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease;
}

.platform-option:hover {
  background: var(--panel-hover, #f0f1f4);
  border-color: var(--accent);
}

.platform-option:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.platform-option.dragging {
  opacity: 0.45;
}

/* ---- Calibration warning badge (M10) ---- */
.product-card { position: relative; }
.cal-badge {
  position: absolute;
  top: 6px;
  right: 6px;
  padding: 2px 6px;
  border-radius: 4px;
  background: #d92d20;
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  pointer-events: none;
  z-index: 2;
}

