/* PROOF Research — Dealer Configurator
   Implemented from "Rifle Builder v2 (Real Models)" + "Custom Build" Claude Design files. */

:root {
  --accent: #9E1B22;
  --bg: #f7f6f3;
  --ink: #26251f;
  --ink-strong: #16150f;
  --ink-soft: #4d4c43;
  --muted: #77766b;
  --muted-2: #6e6d63;
  --faint: #8d8c80;
  --faint-2: #9a998e;
  --line: #e5e3dd;
  --line-soft: #e1ded7;
  --line-row: #eae7e1;
  --border-strong: #d6d3cc;
  --on-accent: #f7f6f3;
  --btn: #1d1c18;          /* active buttons / toggles (red reserved for data) */
  --sel-bg: #f0efeb;       /* selected-state tint (was pinkish #f7efec) */
  --font: 'Saira', system-ui, sans-serif;
  --font-cond: 'Saira Condensed', sans-serif;
}

* { box-sizing: border-box; }

/* The hidden attribute must always win, even over display:flex/grid classes */
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
}

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: #cac7bf; border-radius: 8px; }

@keyframes toastIn { from { opacity: 0; transform: translateX(-50%) translateY(8px); } to { opacity: 1; transform: translateX(-50%) translateY(0); } }
@keyframes fadeImg { from { opacity: 0; } to { opacity: 1; } }

button { font: inherit; }

.app { min-height: 100vh; display: flex; flex-direction: column; }

/* ---------- Header ---------- */

.header {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 20px 24px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #ffffff, var(--bg));
}
.brand { display: flex; flex-direction: column; align-items: flex-start; gap: 12px; }
.brand-logo { height: 30px; display: block; }
.nav { display: flex; gap: 6px; }
.nav-link {
  text-decoration: none; padding: 8px 16px; border-radius: 4px;
  font-family: var(--font-cond); font-weight: 600; font-size: 13px;
  letter-spacing: 2px; text-transform: uppercase;
  color: var(--muted-2); border: 1px solid var(--line-soft);
}
.nav-link:hover { color: var(--ink-strong); border-color: var(--border-strong); }
.nav-link.active {
  font-weight: 700; color: var(--on-accent);
  background: var(--btn); border-color: var(--btn);
}
.header-kicker { font-size: 11px; letter-spacing: 2px; color: var(--faint); text-transform: uppercase; }

/* ---------- Layout ---------- */

.layout { display: flex; flex-wrap: wrap; gap: 24px; padding: 24px; flex: 1; align-items: flex-start; }
.stage-col { flex: 1 1 520px; min-width: 320px; display: flex; flex-direction: column; gap: 16px; }
.options-col { flex: 1 1 360px; min-width: 300px; display: flex; flex-direction: column; gap: 22px; }

/* ---------- Stage ---------- */

.stage {
  position: relative; width: 100%; aspect-ratio: 16 / 9;
  border-radius: 12px; overflow: hidden; border: 1px solid var(--line);
  background: radial-gradient(120% 90% at 50% 35%, #ffffff 0%, #f3f1ec 60%, #e9e7e1 100%);
}
.stage.wide { aspect-ratio: 3 / 2; background: radial-gradient(120% 90% at 50% 32%, #ffffff 0%, #f3f1ec 60%, #e9e7e1 100%); }
.stage-texture {
  position: absolute; inset: 0; opacity: 0.1; pointer-events: none;
  background-image:
    repeating-linear-gradient(45deg, rgba(255,255,255,0.02) 0 2px, transparent 2px 4px),
    repeating-linear-gradient(-45deg, rgba(0,0,0,0.06) 0 2px, transparent 2px 4px);
}
.stage-img {
  position: absolute; inset: 7% 6%; width: 88%; height: 86%;
  object-fit: contain; object-position: center;
  filter: drop-shadow(0 24px 30px rgba(0,0,0,.6));
}
.stage-tag {
  position: absolute; left: 18px; top: 16px;
  display: inline-flex; align-items: center; gap: 9px;
  background: rgba(12,14,15,.78); border: 1px solid var(--border-strong);
  border-radius: 999px; padding: 8px 16px;
  font-family: var(--font-cond); font-weight: 600;
  font-size: 15px; letter-spacing: 2px; color: #ffffff; text-transform: uppercase;
  backdrop-filter: blur(4px);
}
.stage-tag-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
.stage-info {
  position: absolute; left: 18px; bottom: 16px; right: 18px;
  display: flex; align-items: flex-end; justify-content: space-between; gap: 12px;
  pointer-events: none;
}
.stage-name { font-family: var(--font-cond); font-weight: 700; font-size: 26px; letter-spacing: 1px; line-height: 1; }
.stage-name.sm { font-size: 22px; letter-spacing: .5px; }
.stage-sub { font-size: 12px; color: var(--muted-2); letter-spacing: 1px; margin-top: 5px; }
.stage-weight-wrap { text-align: right; }
.stage-weight { font-family: var(--font-cond); font-weight: 700; font-size: 24px; color: var(--accent); line-height: 1; }
.stage-weight.sm { font-size: 22px; }
.stage-weight .unit { font-size: 12px; color: var(--muted-2); font-weight: 500; }
.stage-weight-label { font-size: 11px; color: var(--faint); letter-spacing: 1px; margin-top: 4px; }

/* Custom build: Photo / PN-diagram toggle in the viewer */
.stage-toggle {
  position: absolute; right: 14px; top: 12px; z-index: 2;
  display: flex; gap: 3px; padding: 3px;
  background: rgba(255,255,255,.9); border: 1px solid var(--line); border-radius: 10px;
  backdrop-filter: blur(4px);
}
.stage-toggle[hidden] { display: none; }
.stage-toggle-btn {
  border: none; background: transparent; padding: 7px 14px; border-radius: 4px;
  font-family: var(--font-cond); font-weight: 600; font-size: 12px;
  letter-spacing: 1px; text-transform: uppercase; color: var(--muted); cursor: pointer;
}
.stage-toggle-btn.on { background: var(--btn); color: var(--on-accent); }
.stage-toggle-btn:disabled { opacity: .4; cursor: default; }

/* Custom build: empty-state prompt in the viewer */
.stage-empty {
  position: absolute; inset: 0; z-index: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  text-align: center; padding: 24px;
}
.stage-empty[hidden] { display: none; }
.stage-empty-title {
  font-family: var(--font-cond); font-weight: 700; font-size: 34px;
  letter-spacing: 2px; text-transform: uppercase; color: var(--ink-strong);
}
.stage-empty-sub { font-size: 14px; color: var(--muted); letter-spacing: .5px; }
.opt-hint { font-size: 13px; color: var(--faint); letter-spacing: .3px; }

/* Custom build: visual build sheet — one shorter stage card per part */
.build-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; padding: 0 2px; }
.stage.part { aspect-ratio: 5 / 2; }
.stage.part[hidden] { display: none; }
.stage.part.clickable { cursor: pointer; }
.stage.part.clickable:hover { border-color: var(--border-strong); }
.stage.part .stage-tag { left: 12px; top: 12px; padding: 6px 12px; font-size: 12px; letter-spacing: 1.5px; }
.stage.part .stage-info { left: 12px; bottom: 10px; right: 12px; }
.stage.part .stage-name { font-size: 18px; }
.stage.part .stage-img { filter: drop-shadow(0 14px 18px rgba(0,0,0,.45)); }
.stage.part .stage-empty-title { font-size: 22px; letter-spacing: 1.5px; color: var(--faint); }
.stage.part .stage-empty-sub { color: var(--muted); font-weight: 500; }
.stage.part .stage-action-model { font-size: 28px; }

/* Custom build: action "no render" card shown in the viewer */
.stage-action-card {
  position: absolute; inset: 0; z-index: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  text-align: center; padding: 24px;
}
.stage-action-brand {
  font-family: var(--font-cond); font-weight: 600; font-size: 18px;
  letter-spacing: 3px; text-transform: uppercase; color: var(--faint);
}
.stage-action-model { font-family: var(--font-cond); font-weight: 700; font-size: 40px; letter-spacing: 1px; }
.stage-action-note { font-size: 11px; color: var(--faint-2); letter-spacing: .5px; margin-top: 10px; }

/* ---------- Section headings ---------- */

.section-label {
  font-family: var(--font-cond); font-size: 12px; letter-spacing: 2px;
  color: var(--faint); text-transform: uppercase; margin-bottom: 10px;
}
.opt-heading {
  font-family: var(--font-cond); font-size: 13px; letter-spacing: 2px;
  color: var(--ink-strong); text-transform: uppercase; margin-bottom: 10px;
  display: flex; align-items: center; gap: 8px;
}
.accent-bar { width: 4px; height: 14px; background: var(--accent); flex: none; }
.step-heading { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.step-num {
  width: 22px; height: 22px; border-radius: 50%; background: var(--btn);
  color: var(--on-accent); font-family: var(--font-cond); font-weight: 700; font-size: 13px;
  display: grid; place-items: center; flex: none;
}
.step-title { font-family: var(--font-cond); font-size: 13px; letter-spacing: 2px; color: var(--ink-strong); text-transform: uppercase; }
.step-note { font-size: 11px; color: var(--faint); letter-spacing: .5px; }

/* ---------- Swatches ---------- */

.swatches { display: flex; gap: 12px; flex-wrap: wrap; }
.swatches.inline { margin-top: 12px; gap: 10px; align-items: center; }
.swatch-label { font-size: 11px; letter-spacing: 2px; color: var(--faint); text-transform: uppercase; }
.swatch {
  width: 38px; height: 38px; border-radius: 50%; cursor: pointer; padding: 0;
  display: grid; place-items: center; transition: all .15s;
  border: 2px solid var(--line-soft); background: transparent;
}
.swatch.on { border-color: var(--btn); }
.swatch.sm { width: 34px; height: 34px; }
.swatch-dot { width: 24px; height: 24px; border-radius: 50%; box-shadow: inset 0 0 0 1px rgba(255,255,255,.12); }
.swatch.sm .swatch-dot { width: 21px; height: 21px; }

/* ---------- Specs grid ---------- */

.specs {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 1px; background: var(--line); border: 1px solid var(--line);
  border-radius: 10px; overflow: hidden;
}
.spec { background: #ffffff; padding: 14px 16px; }
.spec-label { font-size: 11px; letter-spacing: 1.5px; color: var(--faint); text-transform: uppercase; }
.spec-value { font-family: var(--font-cond); font-weight: 600; font-size: 18px; margin-top: 4px; }

/* ---------- Barrel PN + specs (under the barrel card) ---------- */

.barrel-pn-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; }
.barrel-pn-label { font-size: 11px; letter-spacing: 1.5px; color: var(--faint); text-transform: uppercase; }
.barrel-pn { font-family: var(--font-cond); font-weight: 700; font-size: 24px; color: var(--accent); line-height: 1.2; margin-top: 2px; }
.barrel-note { font-size: 11px; color: var(--faint-2); letter-spacing: .3px; text-align: right; }

.blurb { font-size: 14px; line-height: 1.6; color: var(--ink-soft); margin: 4px 2px; text-wrap: pretty; }
.footnote { font-size: 11px; color: var(--faint-2); margin: 0 2px; letter-spacing: .3px; }

/* ---------- Chips (model / part lists) ---------- */

.model-list { display: flex; flex-direction: column; gap: 8px; max-height: min(48vh, 470px); overflow-y: auto; padding-right: 4px; }
/* Selector cards (Rifles models + Custom stock/action/barrel): render on top, text below */
.model-list .chip, .chip-list .chip { flex-direction: column; align-items: stretch; gap: 6px; padding: 10px 12px; flex-shrink: 0; }
.model-list .chip-img, .chip-list .chip-img {
  width: 100%; height: 64px; border-radius: 5px;
  background: radial-gradient(120% 90% at 50% 40%, #ffffff 0%, #f3f1ec 70%, #edebe5 100%);
  padding: 4px 8px;
}
.model-list .chip-name, .chip-list .chip-name { font-size: 16px; letter-spacing: .5px; }
.model-list .chip-meta, .chip-list .chip-meta { font-size: 12.5px; }
.chip-list { display: flex; flex-direction: column; gap: 8px; }
.chip {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 10px 12px; border-radius: 9px; cursor: pointer; transition: all .15s;
  border: 1px solid var(--line-soft); background: #ffffff;
  color: var(--ink); font-family: var(--font);
}
.chip.col { flex-direction: column; align-items: stretch; gap: 3px; text-align: left; padding: 12px 14px; }
.chip.on { border-color: var(--btn); background: var(--sel-bg); box-shadow: inset 3px 0 0 var(--btn); }
.chip-img { width: 72px; height: 40px; object-fit: contain; flex: none; }
.chip-img.sm { width: 64px; height: 34px; }
.chip-text { display: flex; flex-direction: column; gap: 2px; text-align: left; }
.chip-name { font-family: var(--font-cond); font-weight: 600; font-size: 15px; letter-spacing: .5px; }
.chip-meta { font-size: 12px; color: var(--muted); }
.chip-badge {
  align-self: flex-start; margin-top: 3px; padding: 2px 8px; border-radius: 999px;
  font-family: var(--font-cond); font-weight: 600; font-size: 11px; letter-spacing: 1px;
  text-transform: uppercase; color: var(--ink-soft); border: 1px solid var(--border-strong); background: var(--sel-bg);
}
.sub-label {
  font-size: 11px; letter-spacing: 2px; color: var(--faint); text-transform: uppercase;
  margin: 12px 0 8px;
}
.barrel-list { max-height: 320px; overflow-y: auto; padding-right: 4px; }

/* ---------- Pills ---------- */

.pills { display: flex; flex-wrap: wrap; gap: 8px; }
.pills + .pills { margin-top: 8px; }
.pill {
  padding: 9px 15px; border-radius: 4px; cursor: pointer; transition: all .15s;
  font-family: var(--font-cond); font-weight: 600; font-size: 14px; letter-spacing: .5px;
  border: 1px solid var(--line-soft); background: #ffffff; color: #3a392f;
}
.pill.sm { padding: 8px 14px; font-size: 13px; }
.pill.on { border-color: var(--btn); background: var(--btn); color: var(--on-accent); }

/* ---------- Summary / build sheet card ---------- */

.card { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: #ffffff; }
.card.mt { margin-top: 4px; }
.card-head {
  padding: 14px 16px; border-bottom: 1px solid var(--line);
  font-family: var(--font-cond); font-weight: 700; font-size: 15px;
  letter-spacing: 2px; text-transform: uppercase;
}
.card-body { padding: 6px 16px; }
.summary-row {
  display: flex; justify-content: space-between; gap: 12px;
  padding: 8px 0; border-bottom: 1px solid var(--line-row); font-size: 13px;
}
.summary-k { color: var(--muted); letter-spacing: .5px; }
.summary-v { color: var(--ink); font-weight: 500; text-align: right; }

.card-actions { display: flex; gap: 10px; padding: 14px 16px; }
.stack-actions { display: flex; gap: 10px; }
.card-actions .btn-primary, .stack-actions .btn-primary { flex: none; padding: 13px 26px; }
.card-actions .btn-secondary, .stack-actions .btn-secondary { flex: none; }
.btn-primary {
  flex: 1; padding: 13px; border: none; border-radius: 4px;
  background: var(--btn); color: var(--on-accent);
  font-family: var(--font-cond); font-weight: 700; font-size: 14px;
  letter-spacing: 2px; text-transform: uppercase; cursor: pointer;
}
.btn-secondary {
  padding: 13px 16px; border: 1px solid var(--border-strong); border-radius: 4px;
  background: transparent; color: var(--ink);
  font-family: var(--font-cond); font-weight: 600; font-size: 14px;
  letter-spacing: 1.5px; text-transform: uppercase; cursor: pointer;
}

/* ---------- Inventory ---------- */

.inv-layout { display: flex; flex-direction: column; gap: 16px; padding: 24px; flex: 1; min-height: 0; }
.inv-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.inv-search {
  flex: 1 1 260px; min-width: 200px; padding: 10px 14px;
  border: 1px solid var(--line-soft); border-radius: 8px; background: #ffffff;
  color: var(--ink); font-family: var(--font); font-size: 13px; letter-spacing: .3px;
}
.inv-search:focus { outline: none; border-color: var(--border-strong); }
.inv-select {
  padding: 10px 12px; border: 1px solid var(--line-soft); border-radius: 8px;
  background: #ffffff; color: var(--ink); font-family: var(--font); font-size: 13px;
  max-width: 260px;
}
.inv-count { font-size: 12px; color: var(--faint); letter-spacing: .5px; white-space: nowrap; }
.inv-card { display: flex; flex-direction: column; min-height: 0; }
.inv-scroll { overflow: auto; max-height: calc(100vh - 320px); }
.inv-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.inv-table th {
  position: sticky; top: 0; z-index: 2; background: #ffffff;
  font-family: var(--font-cond); font-weight: 700; font-size: 12px;
  letter-spacing: 1.5px; text-transform: uppercase; color: var(--faint);
  text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--line);
  cursor: pointer; user-select: none; white-space: nowrap;
}
.inv-table th:hover { color: var(--ink-strong); }
.inv-table th.no-sort { cursor: default; }
.inv-table th.no-sort:hover { color: var(--faint); }
.inv-table th.sorted { color: var(--ink-strong); }
.inv-table th.sorted::after { content: " ▲"; font-size: 9px; }
.inv-table th.sorted.desc::after { content: " ▼"; }
.inv-table td {
  padding: 9px 14px; border-bottom: 1px solid var(--line-row);
  color: var(--ink); white-space: nowrap; vertical-align: top;
}
.inv-table td.pn { font-family: var(--font-cond); font-weight: 600; font-size: 14px; letter-spacing: .5px; }
.inv-table td.dim { color: var(--muted); }
.inv-table td.notes { white-space: normal; min-width: 180px; max-width: 340px; color: var(--muted); font-size: 12px; }
.inv-table tbody tr:hover td { background: #faf9f6; }
.inv-cat-badge {
  display: inline-block; padding: 2px 8px; border-radius: 999px;
  font-family: var(--font-cond); font-weight: 600; font-size: 11px;
  letter-spacing: 1px; text-transform: uppercase;
  border: 1px solid var(--line-soft); color: var(--muted);
}
.inv-cat-badge.rifle { border-color: var(--accent); color: var(--accent); }
.inv-cat-badge.action { border-color: #3E7CB1; color: #3E7CB1; }

/* Inventory: image thumbnails + viewer/editor modal */
.inv-thumb {
  width: 56px; height: 30px; padding: 0; border: 1px solid var(--line-soft);
  border-radius: 5px; background: #ffffff; cursor: pointer; overflow: hidden;
  display: grid; place-items: center;
}
.inv-thumb img { width: 100%; height: 100%; object-fit: contain; }
.inv-thumb.none { border-style: dashed; color: var(--faint); font-size: 14px; background: transparent; }
.inv-thumb:hover { border-color: var(--border-strong); }
.img-modal-body { padding: 16px; display: flex; flex-direction: column; gap: 12px; overflow: auto; }
.img-modal-stage {
  border: 1px solid var(--line); border-radius: 10px; min-height: 220px;
  display: grid; place-items: center; padding: 16px;
  background: radial-gradient(120% 90% at 50% 35%, #ffffff 0%, #f3f1ec 60%, #e9e7e1 100%);
}
.img-modal-stage img { max-width: 100%; max-height: 320px; object-fit: contain; }
.img-modal-meta { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 13px; }
.img-modal-meta a { color: var(--accent); }
.img-override-note { font-size: 11px; color: var(--faint-2); letter-spacing: .3px; }
.img-modal-edit { display: flex; gap: 8px; }
.img-modal-edit .inv-search { flex: 1; min-width: 0; }

/* Modal */
.modal-overlay {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(22, 21, 15, .45);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.modal-card {
  background: #ffffff; border: 1px solid var(--line); border-radius: 14px;
  width: min(1160px, 96vw); max-height: 92vh;
  display: flex; flex-direction: column; overflow: hidden;
  box-shadow: 0 24px 80px rgba(0, 0, 0, .35);
}
.modal-scroll { overflow: auto; flex: 1; }
.modal-close {
  border: 1px solid var(--border-strong); background: transparent; border-radius: 8px;
  padding: 8px 12px; cursor: pointer;
  font-family: var(--font-cond); font-weight: 700; font-size: 12px;
  letter-spacing: 1px; text-transform: uppercase; color: var(--ink);
}

/* Compatibility editor */
.compat-platform-note { font-size: 11px; color: var(--faint-2); margin-top: 2px; }
.compat-fits { display: flex; flex-wrap: wrap; gap: 6px; white-space: normal !important; min-width: 340px; }
.compat-brand {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 11px;
  border: 1px solid var(--line-soft); border-radius: 7px;
  font-size: 12px; cursor: pointer; user-select: none;
}
.compat-brand.on { border-color: var(--btn); background: var(--sel-bg); }
.compat-check, .compat-brand input { width: 16px; height: 16px; accent-color: var(--btn); cursor: pointer; }
.btn-secondary.on { border-color: var(--btn); color: var(--ink-strong); background: var(--sel-bg); }

/* ---------- Toast ---------- */

.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: #ffffff; border: 1px solid #cac7bf; color: var(--ink-strong);
  padding: 12px 20px; border-radius: 10px; font-size: 13px; letter-spacing: .5px;
  box-shadow: 0 12px 40px rgba(0,0,0,.5); animation: toastIn .2s ease; z-index: 50;
}

/* ---------- Touch / kiosk ---------- */

button, a { -webkit-tap-highlight-color: transparent; }
.chip, .pill, .swatch, .btn-primary, .btn-secondary, .nav-link, .inv-table th {
  touch-action: manipulation;
  -webkit-user-select: none; user-select: none;
}
/* Press feedback on touch screens (no hover states at a counter kiosk) */
@media (hover: none) {
  .chip:active, .pill:active, .swatch:active, .btn-primary:active, .btn-secondary:active, .nav-link:active {
    transform: scale(.96);
    transition: transform .06s ease;
  }
}

/* Sticky bottom action bar (mobile/tablet only) */
.mobile-bar { display: none; }

/* Step wizard (activated by JS on touch layouts only) */
.wiz-hidden { display: none !important; }

/* One-step-at-a-time flow: only the current step's section shows.
   Desktop only — the mobile wizard already sequences steps one at a time. */
@media (min-width: 821px) {
  .step-locked { display: none !important; }
}

/* "Continue" footer inside each step section (desktop flow only —
   mobile uses the sticky bar's Back/Next instead) */
.step-next { display: none; }
@media (min-width: 821px) {
  .step-next { display: flex; margin-top: 12px; }
  .step-next .btn-primary[disabled] { opacity: .4; cursor: not-allowed; }
}

/* "Edit" button on filled viewer cards — jumps back to that step */
.stage-edit {
  pointer-events: auto;
  flex: none;
  padding: 7px 16px; border-radius: 4px; cursor: pointer;
  border: 1px solid var(--line-soft); background: rgba(255,255,255,.92); color: #3a392f;
  font-family: var(--font-cond); font-weight: 600; font-size: 12px;
  letter-spacing: 1.5px; text-transform: uppercase;
  transition: all .15s;
}
.stage-edit:hover { border-color: var(--border-strong); color: var(--ink-strong); }
.wizard-progress { display: none; }

/* Top build-summary strip (desktop/kiosk only) */
.summary-strip { display: none; }

/* ---------- Desktop / kiosk (single non-scrolling screen) ---------- */

@media (min-width: 821px) {

  html, body { height: 100%; }
  .app { height: 100vh; overflow: hidden; }

  /* Compact one-row header: logo spans the full header height, inline nav, no divider band */
  .header {
    padding: 20px 20px;
  }
  .brand { flex-direction: row; align-items: center; gap: 22px; align-self: stretch; }
  .brand-logo { height: 38px; }

  /* Build summary pinned at the top */
  .summary-strip {
    display: flex; align-items: center; gap: 20px;
    margin: 0 20px; padding: 10px 18px;
    background: #ffffff; border: 1px solid var(--line); border-radius: 10px;
    overflow-x: auto;
  }
  .strip-items { display: flex; align-items: center; gap: 24px; min-width: 0; }
  .strip-item { min-width: 0; }
  .strip-label { font-size: 10px; letter-spacing: 1.5px; color: var(--faint); text-transform: uppercase; white-space: nowrap; }
  .strip-value { font-family: var(--font-cond); font-weight: 600; font-size: 16px; margin-top: 2px; white-space: nowrap; }
  .strip-value.accent { color: var(--accent); }
  .strip-actions { margin-left: auto; display: flex; gap: 8px; flex: none; }
  .strip-actions .btn-primary { flex: none; padding: 11px 18px; font-size: 13px; }
  .strip-actions .btn-secondary { padding: 11px 14px; font-size: 13px; }

  /* Main area fills the rest of the screen; columns scroll internally, page never does */
  .layout { flex: 1; min-height: 0; overflow: hidden; padding: 14px 20px 16px; gap: 20px; }
  .stage-col, .options-col { min-height: 0; max-height: 100%; overflow-y: auto; gap: 12px; }
  .options-col { gap: 14px; }
  .opt-heading, .section-label, .step-heading { margin-bottom: 8px; }
  .model-list { max-height: calc(100vh - 600px); min-height: 260px; }
  .blurb {
    font-size: 13px; margin: 0 2px;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  }

  /* The strip replaces the rifle page's summary card */
  #sec-summary { display: none; }

  .inv-layout { flex: 1; min-height: 0; overflow: auto; }
}

/* ---------- Mobile / tablet layout ---------- */

@media (max-width: 820px) {

  /* App-style compact sticky header */
  .header {
    position: sticky; top: 0; z-index: 30;
    padding: 10px 14px;
    box-shadow: 0 2px 12px rgba(0,0,0,.05);
  }
  .brand { flex-direction: row; align-items: center; gap: 12px; flex-wrap: wrap; }
  .brand-logo { height: 26px; }
  .header-kicker { display: none; }
  .nav-link { padding: 11px 16px; font-size: 13px; }

  .layout { padding: 14px; gap: 18px; }
  .stage-col, .options-col { gap: 14px; min-width: 0; flex-basis: 100%; }

  /* Stage overlays: smaller type + legibility fade so text never fights the render */
  .stage::after {
    content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 44%;
    background: linear-gradient(180deg, rgba(247,246,243,0) 0%, rgba(247,246,243,.92) 78%);
    pointer-events: none; z-index: 0;
  }
  .stage-tag, .stage-info { z-index: 1; }
  .stage-tag { font-size: 12px; padding: 6px 12px; letter-spacing: 1.5px; left: 12px; top: 10px; }
  .stage-info { left: 12px; right: 12px; bottom: 10px; }
  .stage-name { font-size: 18px; letter-spacing: .5px; }
  .stage-name.sm { font-size: 16px; }
  .stage-sub { font-size: 11px; margin-top: 3px; }
  .stage-weight { font-size: 18px; }
  .stage-weight-label { font-size: 9px; }

  /* Model picker: full vertical list (the wizard gives each step the whole screen) */
  .model-list { max-height: none; overflow: visible; padding-right: 0; }

  /* Finger-sized controls */
  .pill { padding: 12px 18px; font-size: 15px; min-height: 44px; }
  .pill.sm { padding: 12px 16px; font-size: 14px; }
  .chip { padding: 12px; min-height: 56px; }
  .stage.part { aspect-ratio: 16 / 10; }
  .stage.part .stage-img { inset: 9% 6% 36% 6%; height: 55%; }
  .swatch, .swatch.sm { width: 46px; height: 46px; }
  .swatch-dot, .swatch.sm .swatch-dot { width: 30px; height: 30px; }
  .btn-primary, .btn-secondary { min-height: 48px; }
  .spec { padding: 12px 14px; }
  .spec-value { font-size: 16px; }
  .blurb { font-size: 13px; }

  /* Sticky bottom bar with live build + quote */
  .mobile-bar {
    display: flex; align-items: center; gap: 12px;
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
    padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
    background: #ffffff; border-top: 1px solid var(--line);
    box-shadow: 0 -8px 24px rgba(0,0,0,.08);
  }
  .mobile-bar-info { flex: 1; min-width: 0; }
  .mobile-bar-name {
    font-family: var(--font-cond); font-weight: 700; font-size: 15px; letter-spacing: .5px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  .mobile-bar-sub {
    font-size: 11px; color: var(--muted); margin-top: 2px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  .mobile-bar .btn-primary { flex: none; padding: 13px 20px; min-width: 96px; }
  .mobile-bar .mbar-back { flex: none; padding: 13px 14px; }

  /* Wizard progress header */
  .wizard-progress {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 14px 16px 0;
  }
  .wizard-progress[hidden] { display: none; }
  .wizard-label {
    font-family: var(--font-cond); font-weight: 700; font-size: 13px;
    letter-spacing: 2px; text-transform: uppercase; color: var(--ink-strong);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  .wizard-dots { display: flex; gap: 9px; flex: none; }
  .wizard-dot {
    width: 16px; height: 16px; border-radius: 50%; padding: 0; cursor: pointer;
    border: 2px solid var(--line-soft); background: #ffffff;
  }
  .wizard-dot.done { border-color: var(--btn); background: var(--sel-bg); }
  .wizard-dot.on { border-color: var(--btn); background: var(--btn); }
  .app { padding-bottom: calc(78px + env(safe-area-inset-bottom)); }
  .toast { bottom: calc(88px + env(safe-area-inset-bottom)); max-width: calc(100vw - 28px); }

  /* Inventory */
  .inv-layout { padding: 14px; gap: 12px; }
  .inv-search { flex-basis: 100%; min-height: 44px; }
  .inv-select { flex: 1; max-width: none; min-height: 44px; }
  .inv-scroll { max-height: calc(100vh - 300px); }
  .inv-table th { padding: 10px 10px; }
  .inv-table td { padding: 9px 10px; font-size: 12px; }
}

/* ---------- Assets page (press-kit browser) ---------- */

.inv-cat-badge.stock { border-color: #6B8E4E; color: #6B8E4E; }
.inv-cat-badge.lifestyle { border-color: #C8A24B; color: #C8A24B; }
.inv-cat-badge.logo { border-color: #77766b; color: #77766b; }

.ast-cat { margin: 0; }
.ast-cat-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.ast-cat-head .inv-cat-badge { margin-left: 10px; vertical-align: 2px; }
.ast-cat-sub {
  margin-left: 10px; font-family: var(--font); font-weight: 400; font-size: 12px;
  letter-spacing: .5px; text-transform: none; color: var(--faint-2);
}
.ast-cat-links { display: flex; flex-wrap: wrap; gap: 14px; font-family: var(--font); font-weight: 500; font-size: 12px; letter-spacing: .3px; text-transform: none; }
.ast-cat-links a { color: var(--accent); text-decoration: none; }
.ast-cat-links a:hover { text-decoration: underline; }

.ast-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 12px; padding: 14px 16px;
}
.ast-tile {
  display: flex; flex-direction: column; gap: 6px; padding: 10px;
  border: 1px solid var(--line-soft); border-radius: 10px; background: #ffffff;
  text-decoration: none; color: var(--muted-2); transition: border-color .15s, box-shadow .15s;
}
.ast-tile:hover { border-color: var(--border-strong); box-shadow: 0 4px 14px rgba(0,0,0,.08); }
.ast-tile img {
  width: 100%; height: 110px; object-fit: contain;
  background: radial-gradient(120% 90% at 50% 35%, #ffffff 0%, #f3f1ec 70%, #edebe5 100%);
  border-radius: 6px;
}
.ast-tile.photo img { object-fit: cover; height: 150px; }
.ast-tile-name {
  font-size: 11px; letter-spacing: .2px; line-height: 1.35;
  overflow-wrap: anywhere;
}

@media (max-width: 700px) {
  .ast-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); padding: 12px; }
  .ast-tile img { height: 90px; }
  .ast-tile.photo img { height: 110px; }
}

/* Compatibility editor: manufacturer chip groups with model checkboxes */
.compat-group {
  display: inline-flex; align-items: center; flex-wrap: wrap; gap: 5px;
  padding: 4px 6px 4px 10px; margin: 2px 6px 2px 0;
  border: 1px solid var(--line-row); border-radius: 9px; background: #fbfaf8;
}
.compat-group-brand { font-weight: 600; font-size: 12px; margin-right: 2px; }
.compat-remove {
  border: none; background: transparent; color: var(--faint); cursor: pointer;
  font-size: 15px; line-height: 1; padding: 2px 4px;
}
.compat-remove:hover { color: var(--accent); }
.compat-add {
  padding: 6px 8px; border: 1px dashed var(--line-soft); border-radius: 7px;
  background: transparent; color: var(--muted); font-family: var(--font); font-size: 12px; cursor: pointer;
}

/* Assets page: inventory-link chips + non-image file tiles */
.ast-link-chip {
  display: inline-flex; align-items: center; gap: 2px;
  padding: 3px 4px 3px 10px; border: 1px solid var(--line-row); border-radius: 9px; background: #fbfaf8;
}
.ast-link-chip a { color: var(--accent); text-decoration: none; }
.ast-file {
  display: flex; align-items: center; justify-content: center;
  width: 100%; height: 110px; border-radius: 6px;
  background: radial-gradient(120% 90% at 50% 35%, #ffffff 0%, #f3f1ec 70%, #edebe5 100%);
  font-family: var(--font-cond); font-weight: 700; font-size: 20px; letter-spacing: 2px; color: var(--faint);
  border: 1px dashed var(--line-soft);
}
@media (max-width: 700px) { .ast-file { height: 90px; } }

/* Inventory part editor (edit / add / soft delete) */
.inv-edit-btn {
  padding: 4px 9px; border: 1px solid var(--line-soft); border-radius: 7px;
  background: #ffffff; color: var(--muted-2); cursor: pointer; font-size: 13px; line-height: 1;
  transition: all .15s;
}
.inv-edit-btn:hover { border-color: var(--border-strong); color: var(--ink-strong); }
.inv-row-deleted td { opacity: .55; }
.inv-row-deleted td.pn, .inv-row-deleted td:nth-child(3) { text-decoration: line-through; }
.edit-body { padding: 16px; display: flex; flex-direction: column; gap: 14px; }
.edit-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.edit-field { display: flex; flex-direction: column; gap: 4px; }
.edit-field.wide { grid-column: 1 / -1; }
.edit-field label {
  font-family: var(--font-cond); font-weight: 600; font-size: 11px;
  letter-spacing: 1.5px; text-transform: uppercase; color: var(--faint);
}
.edit-field input, .edit-field select { flex: none; min-width: 0; }
.edit-field input:disabled { background: #efeeea; color: var(--faint); }
.edit-actions { display: flex; align-items: center; gap: 10px; }
@media (max-width: 700px) { .edit-grid { grid-template-columns: repeat(2, 1fr); } }

/* Shared "device-only edits" note at the top of edit screens */
.edit-note {
  margin: 0; padding: 8px 12px; border: 1px solid #ecd9b8; border-radius: 7px;
  background: #fbf4e6; color: #7a6234; font-size: 11.5px; letter-spacing: .2px;
}

/* Dealer locator modal */
.dealer-body { padding: 16px; display: flex; flex-direction: column; gap: 14px; max-height: 70vh; overflow-y: auto; }
.dealer-contact { display: flex; flex-wrap: wrap; gap: 24px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 8px; background: #ffffff; }
.dealer-contact-label { font-family: var(--font-cond); font-weight: 600; font-size: 11px; letter-spacing: 1.5px; text-transform: uppercase; color: var(--faint); margin-bottom: 3px; }
.dealer-phone { font-family: var(--font-cond); font-weight: 700; font-size: 22px; color: var(--accent); text-decoration: none; }
.dealer-contact-links { display: flex; gap: 16px; padding-top: 4px; }
.dealer-heading { font-family: var(--font-cond); font-weight: 700; font-size: 13px; letter-spacing: 2px; text-transform: uppercase; color: var(--ink-soft); margin: 4px 0 8px; }
.dealer-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 6px 14px; }
.dealer-link { font-size: 13px; color: var(--accent); text-decoration: none; padding: 3px 0; }
.dealer-link:hover { text-decoration: underline; }
.dealer-country { color: var(--muted); }

/* Custom builder: manufacturer tiles (logo on top, name below) + action photo chips */
.brand-pill {
  display: inline-flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 8px; width: 112px; min-height: 96px; padding: 12px 8px; text-align: center;
  font-size: 12.5px; line-height: 1.25; white-space: normal;
}
.brand-logo-badge {
  display: inline-flex; align-items: center; justify-content: center;
  height: 34px; width: 92px; padding: 6px 9px; border-radius: 4px; background: #0d0e10; flex: none;
}
.brand-logo-badge img {
  height: 100%; width: 100%; object-fit: contain; display: block;
  filter: brightness(0) invert(1);   /* normalize any logo color to white */
}
.pill.on .brand-logo-badge { background: rgba(255,255,255,.16); }
