:root {
  --bg: #14161a;
  --panel: #1c1f26;
  --panel-2: #232733;
  --line: #2e333f;
  --ink: #e8eaee;
  --muted: #9aa0ac;
  --accent: #c9a24a;
  --accent-2: #6ea8fe;
  --good: #4caf7d;
  --warn: #d98b5f;
  --radius: 12px;
  --shadow: 0 10px 30px rgba(0,0,0,.45);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: radial-gradient(1200px 600px at 70% -10%, #1b2030, var(--bg));
  color: var(--ink);
  font: 14px/1.45 'Segoe UI', system-ui, -apple-system, sans-serif;
}
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

/* Topbar */
.topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 22px; border-bottom: 1px solid var(--line);
  background: rgba(20,22,26,.7); backdrop-filter: blur(6px);
}
.brand { display: flex; gap: 14px; align-items: center; }
.brand .mark { font-size: 26px; color: var(--accent); }
.brand h1 { font-size: 17px; margin: 0; letter-spacing: .3px; }
.brand p { margin: 0; color: var(--muted); font-size: 12px; }
.flag {
  font-size: 12px; color: #1a1206; background: var(--accent);
  padding: 5px 10px; border-radius: 999px; font-weight: 600;
}

/* Layout */
.layout {
  display: grid;
  grid-template-columns: 320px 1fr 320px;
  gap: 18px; padding: 18px; align-items: start;
  min-height: calc(100dvh - 71px);
}
/* Grid/flex children must allow shrinking below content size or large
 * preview children force horizontal page overflow (responsive P0). */
.layout > * { min-width: 0; }
.controls, .readout { display: flex; flex-direction: column; gap: 18px; }
.controls {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px; overflow-y: auto; max-height: 100%;
}
section { display: block; }
.field-label {
  display: block; font-size: 11px; text-transform: uppercase;
  letter-spacing: .8px; color: var(--muted); margin-bottom: 7px;
}
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.row2 > div { min-width: 0; }

.text-input, .select {
  width: 100%; background: var(--panel-2); border: 1px solid var(--line);
  color: var(--ink); border-radius: 9px; padding: 9px 11px; font-size: 13px;
}
.text-input:focus, .select:focus { outline: 1px solid var(--accent-2); border-color: var(--accent-2); }
.chip:focus-visible, .swatch:focus-visible, .check input:focus-visible,
.btn-ghost:focus-visible, .bind-tile:focus-visible, .fold-range:focus-visible,
.catalogue-preview:focus-visible {
  outline: 3px solid var(--accent-2);
  outline-offset: 2px;
}

/* Chips */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  border: 1px solid var(--line); background: var(--panel-2); color: var(--muted);
  padding: 6px 10px; border-radius: 999px; font-size: 12px; cursor: pointer;
  transition: .12s;
}
.chip:hover { color: var(--ink); border-color: #3a4151; }
.chip.active { background: var(--accent); color: #1a1206; border-color: var(--accent); font-weight: 600; }

/* Color swatches */
.colors { display: flex; flex-wrap: wrap; gap: 7px; align-items: center; }
.color-group {
  width: 100%; font-size: 10px; text-transform: uppercase; letter-spacing: .6px;
  color: var(--muted); margin: 6px 0 1px;
}
.swatch {
  width: 28px; height: 28px; border-radius: 7px; cursor: pointer;
  border: 2px solid transparent; background: var(--mat);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.06); transition: .12s;
}
.swatch:hover { transform: translateY(-1px); }
.swatch.active { border-color: var(--ink); box-shadow: 0 0 0 2px var(--accent); }
.swatch.metal { background: linear-gradient(135deg, color-mix(in srgb, var(--mat) 70%, #fff), var(--mat) 55%, color-mix(in srgb, var(--mat) 60%, #000)); }
.swatch.cork { background: var(--mat); background-image: radial-gradient(rgba(0,0,0,.18) 1px, transparent 1px); background-size: 5px 5px; }
.swatch.wood { background: repeating-linear-gradient(90deg, var(--mat), color-mix(in srgb, var(--mat) 82%, #000) 3px, var(--mat) 6px); }

/* Checks */
.checks { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px; }
.check { display: flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--ink); cursor: pointer; }
.check input { accent-color: var(--accent); }

/* Workspace */
.workspace {
  position: relative;
  background: linear-gradient(180deg, #1a1d24, #161922);
  border: 1px solid var(--line); border-radius: var(--radius);
  height: 100%; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 18px; padding: 24px; min-height: 0;
}
.preview { display: flex; align-items: center; justify-content: center; flex: 1; width: 100%; min-width: 0; }
.workspace { min-width: 0; }
.stage { display: flex; flex-direction: column; align-items: center; gap: 14px; min-width: 0; max-width: 100%; }

/* COVER view — single front panel with real material */
.cover-book { --ratio: .62; height: 56vh; max-height: 540px; max-width: 100%; aspect-ratio: var(--ratio); }
.cover-panel {
  position: relative; width: 100%; height: 100%; border-radius: 6px;
  box-shadow: var(--shadow); border: 1px solid rgba(0,0,0,.55);
  display: flex; flex-direction: column; justify-content: center; align-items: center;
  overflow: hidden;
}
.spine { position: absolute; left: 0; top: 0; bottom: 0; width: 10px;
  background: linear-gradient(90deg, rgba(0,0,0,.45), rgba(0,0,0,0)); }
.sheen { position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(118deg, rgba(255,255,255,.18), rgba(255,255,255,0) 42%); }
.cover-art { text-align: center; padding: 0 26px; position: relative; z-index: 2; max-width: 100%; }
.emboss {
  font-family: 'Georgia', serif; font-size: clamp(18px, 3.4vh, 30px);
  color: rgba(255,255,255,.94); letter-spacing: 1px;
  text-shadow: 0 1px 1px rgba(0,0,0,.55), 0 -1px 0 rgba(255,255,255,.14);
  max-width: 100%; overflow-wrap: anywhere; word-break: break-word;
}
.deco-line { margin-top: 9px; font-size: 10.5px; letter-spacing: 2.5px; text-transform: uppercase; color: rgba(255,255,255,.72); }
.mat-label { position: absolute; bottom: 12px; left: 0; right: 0; text-align: center;
  font-size: 11px; color: rgba(255,255,255,.6); z-index: 2; text-shadow: 0 1px 2px rgba(0,0,0,.6); }
.mat-label strong { color: rgba(255,255,255,.92); margin-left: 5px; }

/* INSIDE view — the real panel count, laid open */
.open-book { display: flex; align-items: stretch; height: 52vh; max-height: 500px;
  max-width: 100%; box-shadow: var(--shadow); border-radius: 6px; overflow: hidden; }
.inside-panel { position: relative; aspect-ratio: var(--pratio); background: #f6f3ec;
  display: flex; flex-direction: column; min-width: 90px; }
.panel-edge { height: 12px; flex: none; box-shadow: inset 0 -3px 5px rgba(0,0,0,.25); }
.panel-face { flex: 1; padding: clamp(8px, 2vw, 14px); overflow: hidden; color: #232323; }
.fold { width: 2px; background: linear-gradient(180deg, rgba(0,0,0,.18), rgba(0,0,0,.05)); }

/* design pages */
.dp { height: 100%; font-size: clamp(7px, 1.4vw, 10px); }
.dp-none .dp-lines { display: flex; flex-direction: column; gap: 11px; margin-top: 8px; }
.dp-none .dp-lines span { height: 6px; background: #e4ded2; border-radius: 3px; }
.dp-none .dp-lines span:nth-child(3n) { width: 60%; }
.dp-head { font-family: Georgia, serif; font-size: 15px; color: #1a1a1a; }
.dp-sub { font-size: 8.5px; letter-spacing: 1.5px; text-transform: uppercase; color: #9a7d3a; margin-bottom: 8px; }
.dp-sec { font-weight: 700; text-transform: uppercase; letter-spacing: .8px; font-size: 8.5px; color: #8a6d2a; margin: 9px 0 3px; }
.dp-item { display: flex; justify-content: space-between; font-size: 9.5px; padding: 1.5px 0; }
.dp-item em { font-style: normal; color: #555; }
.dp-modern .dp-head { font-family: 'Segoe UI'; font-weight: 300; letter-spacing: 3px; text-transform: lowercase; }
.dp-modern .dp-sec { color: #444; letter-spacing: 2px; }
.dp-winelist { font-family: Georgia, serif; }

.panel-badge { font-size: 11px; color: var(--muted); letter-spacing: .6px;
  background: var(--panel-2); border: 1px solid var(--line); padding: 4px 11px; border-radius: 999px; }
/* Pinned to the bottom of the workspace so the controls stay visible at any
   zoom level (browser zoom or 3D scroll) instead of scrolling out of view. */
.flip-controls {
  position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); z-index: 5;
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap; justify-content: center;
  max-width: calc(100% - 28px);
  background: rgba(20,22,26,.82); border: 1px solid var(--line); border-radius: 16px;
  padding: 8px 14px; backdrop-filter: blur(6px); box-shadow: 0 6px 20px rgba(0,0,0,.35);
}
.view-btn.active { background: var(--accent); color: #1a1206; border-color: var(--accent); font-weight: 600; }
.fold-range { width: 160px; accent-color: var(--accent); }
.hint { font-size: 11px; color: var(--muted); }
.page-nav { display: inline-flex; align-items: center; gap: 6px; }
.page-nav .btn-ghost { padding: 6px 11px; font-size: 15px; line-height: 1; }
#page-ind { min-width: 78px; text-align: center; }
.opt { color: var(--muted); font-weight: 400; text-transform: none; letter-spacing: 0; }
.swatch.real { background-size: cover; background-position: center; box-shadow: inset 0 0 0 1px rgba(255,255,255,.12); }

/* 3D preview canvas host */
#preview { min-height: 56vh; max-width: 100%; overflow-x: auto; overflow-y: hidden; }
#preview canvas { display: block; border-radius: 10px; }

/* Binding picker — clickable construction tiles */
.bind-picker { display: grid; grid-template-columns: repeat(4, 1fr); gap: 7px; }
.bind-tile {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 9px;
  padding: 7px 4px 6px; cursor: pointer; color: var(--muted); transition: .12s;
}
.bind-tile:hover { color: var(--ink); border-color: #3a4151; transform: translateY(-1px); }
.bind-tile.active { border-color: var(--accent); background: rgba(201,162,74,.12); color: var(--ink); }
.bind-svg { width: 30px; height: 38px; color: currentColor; }
.bind-tile.active .bind-svg { color: var(--accent); }
.bt-name { font-size: 11px; font-weight: 600; }
.bt-sub { font-size: 8.5px; line-height: 1.1; text-align: center; opacity: .7; }

.btn-ghost {
  background: var(--panel-2); border: 1px solid var(--line); color: var(--ink);
  padding: 8px 14px; border-radius: 9px; cursor: pointer; font-size: 13px; transition: .12s;
}
.btn-ghost:hover { border-color: var(--accent-2); color: #fff; }

/* Readout */
.price-card, .ref-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px;
}
.code-row { display: flex; justify-content: space-between; align-items: center; font-size: 12px; color: var(--muted); }
.code-row strong { font-size: 15px; color: var(--accent); letter-spacing: 1px; font-family: ui-monospace, monospace; }
.big-total { display: flex; justify-content: space-between; align-items: baseline; margin: 12px 0 4px; }
.big-total .total { font-size: 30px; font-weight: 700; color: var(--ink); }
.muted { color: var(--muted); }
.sub-row, .unit-row { display: flex; justify-content: space-between; font-size: 12.5px; color: var(--muted); padding: 2px 0; }
.unit-row { margin-top: 6px; border-top: 1px solid var(--line); padding-top: 8px; }
.break-note { font-size: 12px; color: var(--muted); margin: 6px 0; line-height: 1.4; }
.source-badge { display: inline-block; font-size: 11px; font-weight: 600; padding: 3px 9px; border-radius: 999px; margin-top: 10px; }
.source-badge.real { background: rgba(76,175,125,.16); color: var(--good); border: 1px solid rgba(76,175,125,.4); }
.source-badge.moq { background: rgba(217,139,95,.16); color: var(--warn); border: 1px solid rgba(217,139,95,.4); }
.source-badge.est { background: rgba(110,168,254,.12); color: var(--accent-2); border: 1px solid rgba(110,168,254,.35); }
.breakdown tr.tier-active td { color: var(--accent); font-weight: 600; }
.breakdown { width: 100%; margin-top: 12px; border-collapse: collapse; }
.breakdown td { font-size: 12.5px; padding: 4px 0; color: var(--muted); border-top: 1px dashed var(--line); }
.breakdown td:last-child { text-align: right; color: var(--ink); }
.warn { margin-top: 10px; font-size: 12px; color: var(--warn); }
.quote-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 14px; }
.quote-status { grid-column: 1 / -1; min-height: 16px; font-size: 11.5px; color: var(--muted); }
.quote-print { display: none; }

.ref-head { font-size: 12px; color: var(--muted); margin-bottom: 10px; }
.ref-img { width: 100%; border-radius: 8px; border: 1px solid var(--line); display: block; }
.ref-empty { color: var(--muted); font-size: 12px; }

@media (max-width: 1100px) {
  .layout { grid-template-columns: 1fr; height: auto; }
  .cover-book { height: 60vh; }
  /* stacked: let the controls flow instead of becoming a tiny scroll box,
     and give the 3D preview real height (#147, #146-lite) */
  .controls { max-height: none; overflow: visible; }
  .workspace { min-height: 60vh; }
  .preview { min-height: 56vh; }
}

/* Mobile touch comfort + single-column controls (responsive P1/P2) */
@media (max-width: 480px) {
  .chip, .btn-ghost, .text-input, .select { min-height: 44px; }
  .chip { display: inline-flex; align-items: center; }
  .swatch { width: 40px; height: 40px; }
  .bind-picker { grid-template-columns: repeat(2, 1fr); }
  .checks, .row2 { grid-template-columns: 1fr; }
  .quote-actions { grid-template-columns: 1fr; }
  .fold-range { width: 100%; min-height: 44px; }
}

/* Fallback / error states for the preview region */
.load-error {
  margin: auto; max-width: 420px; text-align: center; color: var(--warn);
  background: rgba(217,139,95,.10); border: 1px solid rgba(217,139,95,.4);
  border-radius: var(--radius); padding: 18px 20px; font-size: 13px; line-height: 1.5;
}

@media print {
  body { background: #fff; color: #111; font: 12pt/1.45 system-ui, sans-serif; }
  .topbar, .layout { display: none !important; }
  .quote-print { display: block; padding: 24px; }
  .quote-doc { max-width: 760px; margin: 0 auto; }
  .quote-doc h1 { margin: 0 0 4px; font-size: 22pt; }
  .quote-date { color: #555; margin: 0 0 18px; }
  .quote-doc dl { display: grid; grid-template-columns: 170px 1fr; gap: 6px 14px; }
  .quote-doc dt { font-weight: 700; color: #333; }
  .quote-doc dd { margin: 0; }
  .quote-disclaimer { margin-top: 20px; padding-top: 12px; border-top: 1px solid #ccc; color: #333; }
}

/* 3D rendered catalogue page */
.nav-link { text-decoration: none; display: inline-flex; align-items: center; justify-content: center; }
.catalogue-page { min-height: 100dvh; background: #0e1014; color: #f4efe5; }
.catalogue-layout { width: min(1440px, calc(100% - 32px)); margin: 0 auto; padding: 24px 0 48px; }
.catalogue-hero { display: grid; grid-template-columns: minmax(280px, 0.86fr) minmax(320px, 1.14fr); gap: 24px; align-items: stretch; }
.catalogue-copy, .catalogue-stage-card, .catalogue-grid-section { border: 1px solid rgba(255,255,255,.11); background: linear-gradient(180deg, rgba(255,255,255,.065), rgba(255,255,255,.028)); border-radius: 24px; box-shadow: 0 24px 70px rgba(0,0,0,.32); }
.catalogue-copy { padding: clamp(20px, 3vw, 36px); }
.eyebrow { margin: 0 0 8px; color: #d9b45f; text-transform: uppercase; letter-spacing: .14em; font-size: .72rem; font-weight: 800; }
.catalogue-copy h2, .section-head h2 { margin: 0; font-size: clamp(1.6rem, 4vw, 3.4rem); line-height: .98; letter-spacing: -.05em; }
.catalogue-copy p { color: #c9c0af; line-height: 1.65; max-width: 66ch; }
.catalogue-detail { display: grid; grid-template-columns: max-content 1fr; gap: 10px 18px; margin: 22px 0 0; font-size: .94rem; }
.catalogue-detail dt { color: #918978; }
.catalogue-detail dd { margin: 0; color: #fff6e6; min-width: 0; overflow-wrap: anywhere; }
.catalogue-stage-card { min-width: 0; padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.catalogue-preview { min-height: clamp(390px, 58vh, 680px); height: auto; overflow: hidden; }
.catalogue-stage-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.catalogue-grid-section { margin-top: 24px; padding: clamp(18px, 2vw, 28px); }
.section-head { display: flex; justify-content: space-between; gap: 16px; align-items: end; margin-bottom: 18px; }
.catalogue-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 14px; }
.catalogue-card { display: grid; grid-template-columns: 82px 1fr; gap: 12px; text-align: left; border: 1px solid rgba(255,255,255,.11); background: rgba(255,255,255,.045); color: #f4efe5; border-radius: 18px; padding: 10px; cursor: pointer; min-width: 0; transition: transform .16s ease, border-color .16s ease, background .16s ease; }
.catalogue-card:hover, .catalogue-card:focus-visible { transform: translateY(-2px); border-color: rgba(217,180,95,.62); outline: none; }
.catalogue-card.active { background: rgba(217,180,95,.13); border-color: rgba(217,180,95,.85); box-shadow: inset 0 0 0 1px rgba(217,180,95,.28); }
.catalogue-thumb-wrap { position: relative; width: 82px; height: 104px; border-radius: 12px; overflow: hidden; background: #201b14; display: block; }
.catalogue-thumb { width: 100%; height: 100%; object-fit: cover; display: block; }
.catalogue-thumb.is-3d { object-fit: contain; background: radial-gradient(120% 90% at 50% 30%, #2a2620, #14110c); }
.catalogue-thumb-empty { background: linear-gradient(135deg, #332916, #15171d); }
.catalogue-thumb-badge { position: absolute; left: 4px; bottom: 4px; padding: 1px 6px; border-radius: 999px; font-size: .58rem; font-weight: 700; letter-spacing: .03em; text-transform: uppercase; color: #d8cdb6; background: rgba(20,17,12,.78); border: 1px solid rgba(255,255,255,.14); }
.catalogue-thumb-badge.is-3d { color: #15110a; background: rgba(217,180,95,.92); border-color: rgba(217,180,95,.95); }
.catalogue-card-body { display: flex; flex-direction: column; justify-content: center; min-width: 0; gap: 5px; }
.catalogue-card-body strong { font-size: .98rem; line-height: 1.1; overflow-wrap: anywhere; }
.catalogue-card-body span { color: #c8beaa; font-size: .82rem; line-height: 1.25; }
.catalogue-card-body em { color: #d9b45f; font-style: normal; font-weight: 800; font-size: .8rem; }

/* Variant rail (binding cards) reuses .catalogue-card visuals via .catalogue-variant */
.catalogue-variant { display: grid; grid-template-columns: 82px 1fr; gap: 12px; text-align: left; border: 1px solid rgba(255,255,255,.11); background: rgba(255,255,255,.045); color: #f4efe5; border-radius: 18px; padding: 10px; cursor: pointer; min-width: 0; transition: transform .16s ease, border-color .16s ease, background .16s ease; }
.catalogue-variant:hover, .catalogue-variant:focus-visible { transform: translateY(-2px); border-color: rgba(217,180,95,.62); outline: none; }
.catalogue-variant.active { background: rgba(217,180,95,.13); border-color: rgba(217,180,95,.85); box-shadow: inset 0 0 0 1px rgba(217,180,95,.28); }
.catalogue-variants-section { margin-top: 24px; padding: clamp(18px, 2vw, 28px); border: 1px solid rgba(255,255,255,.11); background: linear-gradient(180deg, rgba(255,255,255,.065), rgba(255,255,255,.028)); border-radius: 24px; box-shadow: 0 24px 70px rgba(0,0,0,.32); }
.catalogue-variants-note { color: #c9c0af; line-height: 1.6; max-width: 76ch; margin: 4px 0 18px; font-size: .92rem; }

/* Panel/size chips on the hero stage — live re-render of the focused variant */
.catalogue-variant-options { display: flex; flex-direction: column; gap: 8px; }
.catalogue-chip-row { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; }
.catalogue-chip-label { color: #918978; font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; min-width: 52px; }
.catalogue-chip { padding: 4px 11px; border-radius: 999px; border: 1px solid rgba(255,255,255,.16); background: rgba(255,255,255,.05); color: #e7dec9; font-size: .82rem; font-weight: 600; cursor: pointer; transition: border-color .14s ease, background .14s ease; }
.catalogue-chip:hover, .catalogue-chip:focus-visible { border-color: rgba(217,180,95,.62); outline: none; }
.catalogue-chip.active { color: #15110a; background: rgba(217,180,95,.92); border-color: rgba(217,180,95,.95); }

/* Compare toggle (hero) reflects whether the focused variant is shortlisted */
#catalogue-compare-toggle.active { color: #15110a; background: rgba(217,180,95,.92); border-color: rgba(217,180,95,.95); }

/* Comparison shortlist tray */
.catalogue-shortlist-section { margin-top: 24px; padding: clamp(18px, 2vw, 28px); border: 1px solid rgba(217,180,95,.4); background: linear-gradient(180deg, rgba(217,180,95,.07), rgba(255,255,255,.028)); border-radius: 24px; box-shadow: 0 24px 70px rgba(0,0,0,.32); }
.shortlist-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 14px; flex-wrap: wrap; }
.shortlist-actions { display: flex; align-items: center; gap: 12px; }
.shortlist-count { color: #d9b45f; font-weight: 800; font-size: .86rem; letter-spacing: .02em; white-space: nowrap; }
.catalogue-compare-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 14px; margin-top: 8px; }
.catalogue-compare-card { display: flex; flex-direction: column; gap: 10px; border: 1px solid rgba(255,255,255,.11); background: rgba(255,255,255,.045); border-radius: 18px; padding: 12px; min-width: 0; }
.compare-thumb-wrap { width: 100%; height: 168px; border-radius: 12px; }
.compare-thumb { width: 100%; height: 100%; object-fit: contain; background: radial-gradient(120% 90% at 50% 30%, #2a2620, #14110c); display: block; }
.compare-body { gap: 5px; }
.compare-card-actions { display: flex; align-items: center; gap: 8px; margin-top: auto; }
.compare-configure { flex: 1; text-align: center; }
.compare-remove { color: #e7c9c0; border-color: rgba(255,120,120,.35); }
.compare-remove:hover, .compare-remove:focus-visible { border-color: rgba(255,120,120,.7); color: #ffd9d2; outline: none; }

/* Local-only printable comparison sheet — screen-hidden; shown only by @media
   print (below), which swaps the catalogue chrome for this artifact alone. */
.compare-print { display: none; }

/* Catalogue print: hide all app chrome, render the comparison sheet alone.
   Scoped to .catalogue-page so it never interferes with the configurator's
   own quote-print rules earlier in this file. */
@media print {
  .catalogue-page { background: #fff; color: #111; }
  .catalogue-page .topbar,
  .catalogue-page .catalogue-layout { display: none !important; }
  .catalogue-page .compare-print { display: block; padding: 24px; }
  .compare-doc { max-width: 900px; margin: 0 auto; font: 12pt/1.45 system-ui, sans-serif; color: #111; }
  .compare-doc h1 { margin: 0 0 4px; font-size: 22pt; }
  .compare-print-meta { color: #555; margin: 0 0 18px; }
  .compare-print-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
  .compare-print-card { border: 1px solid #ccc; border-radius: 8px; padding: 12px; break-inside: avoid; }
  .compare-print-thumb { width: 100%; height: auto; border: 1px solid #ddd; border-radius: 6px; margin-bottom: 10px; display: block; }
  .compare-print-spec { display: grid; grid-template-columns: 92px 1fr; gap: 4px 12px; margin: 0; }
  .compare-print-spec dt { font-weight: 700; color: #333; }
  .compare-print-spec dd { margin: 0; }
  .compare-print-provenance { margin-top: 18px; color: #555; font-size: 10pt; }
  .compare-disclaimer { margin-top: 8px; padding-top: 12px; border-top: 1px solid #ccc; color: #222; font-weight: 600; }
  .compare-empty { color: #555; }
}

@media (max-width: 900px) {
  .catalogue-layout { width: min(100% - 20px, 760px); padding-top: 12px; }
  .catalogue-hero { grid-template-columns: 1fr; }
  .catalogue-preview { min-height: 380px; }
  .section-head { display: block; }
}
@media (max-width: 480px) {
  .catalogue-layout { width: min(100% - 12px, 480px); }
  .catalogue-copy, .catalogue-stage-card, .catalogue-grid-section { border-radius: 18px; }
  .catalogue-card, .catalogue-variant { grid-template-columns: 70px 1fr; }
  .catalogue-thumb-wrap { width: 70px; height: 92px; }
  .catalogue-detail { grid-template-columns: 1fr; gap: 4px; }
}

/* Reduced motion (WCAG 2.3.3): users who request reduced motion get no CSS
   transition/animation easing. The 3D stage honors the same preference in JS
   (preview3d.js applyReducedMotionPref) by snapping transitions and disabling
   orbit damping. Final layout/visual state is unchanged — only motion is removed. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

/* Lead capture + quote actions */
.btn-primary { background: var(--accent); color: #1a1206; border: 1px solid var(--accent);
  padding: 8px 14px; border-radius: 9px; cursor: pointer; font-size: 13px; font-weight: 600; transition: .12s; }
.btn-primary:hover { filter: brightness(1.08); }
.quote-actions { display: flex; flex-wrap: wrap; gap: 7px; align-items: center; margin-top: 12px; }
.lead-form { display: flex; flex-direction: column; gap: 7px; margin-top: 10px;
  border-top: 1px solid var(--line); padding-top: 10px; }
.lead-title { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .6px; }
.lead-form textarea.text-input { resize: vertical; font: inherit; }
.lead-actions { display: flex; gap: 7px; }

.lead-form[hidden] { display: none; }

/* AR overlay (model-viewer "view in your space") */
.ar-overlay { position: fixed; inset: 0; z-index: 100; background: rgba(10,12,16,.88);
  display: flex; align-items: center; justify-content: center; }
.ar-overlay[hidden] { display: none; }
.ar-inner { position: relative; width: min(92vw, 900px); height: min(86vh, 700px);
  border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.ar-close { position: absolute; top: 10px; right: 10px; z-index: 2; }
.ar-launch { position: absolute; bottom: 16px; left: 50%; transform: translateX(-50%); }
.ar-status { position: absolute; top: 12px; left: 12px; z-index: 2; font-size: 12px; color: var(--ink);
  background: rgba(0,0,0,.5); padding: 6px 10px; border-radius: 8px; }

.ref-page-link { display: inline-block; margin-top: 10px; font-size: 12px; }

.color-name { margin-top: 8px; font-size: 12px; color: var(--muted, #9aa3af); font-weight: 600; }

.ref-card .ref-img { border: 1px solid var(--line, #2a2f38); border-radius: 8px; box-shadow: 0 2px 10px rgba(0,0,0,.25); }

/* Printable quote: header, meta, render image */
.quote-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; border-bottom: 2px solid #222; padding-bottom: 10px; margin-bottom: 12px; }
.quote-studio { margin: 2px 0 0; font-size: 12px; color: #666; }
.quote-meta { font-size: 12px; text-align: right; line-height: 1.5; }
.quote-render { display: block; width: 100%; max-height: 320px; object-fit: contain; margin: 0 0 14px; border-radius: 8px; }
.quote-render[hidden] { display: none; }

/* Quantity presets */
.qty-presets { display: flex; flex-wrap: wrap; gap: 6px; }
.chip-sm { padding: 5px 12px; font-size: 12px; font-weight: 600; border: 1px solid var(--line); background: var(--panel-2); color: var(--ink); border-radius: 999px; cursor: pointer; }
.chip-sm:hover { border-color: var(--accent); }
.chip-sm:focus-visible { outline: 2px solid var(--accent-2); outline-offset: 2px; }

/* Next price break hint */
.next-break { margin-top: 8px; padding: 8px 10px; font-size: 12px; color: var(--ink); background: rgba(110,168,254,.10); border: 1px solid rgba(110,168,254,.35); border-radius: 8px; }
.next-break[hidden] { display: none; }

/* Breakdown savings column */
.breakdown .save { text-align: right; color: var(--good); font-weight: 600; font-size: 11px; }

/* #8 emphasize the total */
.big-total .total { font-size: 30px; font-weight: 800; letter-spacing: -0.5px; }

/* #12 visible focus on selects */
.select:focus-visible, .text-input:focus-visible { outline: 2px solid var(--accent-2); outline-offset: 2px; }

/* 3D preview loading placeholder (cleared once the engine mounts) */
.preview-loading { display: flex; align-items: center; justify-content: center; width: 100%; height: 100%; min-height: 280px; color: var(--muted); font-size: 13px; }

/* Logo low-res warning */
.logo-warn { margin-top: 7px; font-size: 11.5px; color: var(--warn); }
.logo-warn[hidden] { display: none; }

/* Mobile: stack the quote action buttons full-width */
@media (max-width: 720px) {
  .quote-actions { flex-direction: column; align-items: stretch; }
  .quote-actions .btn-primary, .quote-actions .btn-ghost { width: 100%; }
}

/* #10 consistent control button heights */
.btn-ghost, .btn-primary { min-height: 34px; display: inline-flex; align-items: center; justify-content: center; }

/* Logo controls (size / placement / emboss) */
.logo-controls { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); display: grid; gap: 6px; }
.logo-controls[hidden] { display: none; }

/* First-run coachmark over the preview */
.coachmark { position: absolute; left: 50%; bottom: 64px; transform: translateX(-50%); z-index: 6;
  display: flex; align-items: center; gap: 12px; padding: 8px 12px; font-size: 12px;
  background: rgba(20,22,26,.92); color: var(--ink); border: 1px solid var(--line); border-radius: 999px; box-shadow: var(--shadow); }
.coachmark[hidden] { display: none; }

/* Empty states */
.ref-empty { padding: 16px; text-align: center; color: var(--muted); font-size: 12px; border: 1px dashed var(--line); border-radius: 8px; }

.btn-ghost.active { background: var(--accent); color: #1a1206; border-color: var(--accent); }

/* Help / how-it-works panel */
.help-panel { position: fixed; inset: 0; z-index: 120; background: rgba(10,12,16,.78); display: flex; align-items: center; justify-content: center; }
.help-panel[hidden] { display: none; }
.help-card { position: relative; width: min(92vw, 540px); max-height: 86vh; overflow: auto; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px 24px; }
.help-card h2 { margin: 0 0 12px; font-size: 18px; }
.help-card ol { margin: 0; padding-left: 20px; display: grid; gap: 9px; font-size: 13px; color: var(--ink); }
.help-card .help-foot { margin: 14px 0 0; font-size: 12px; color: var(--muted); }
.help-close { position: absolute; top: 12px; right: 12px; }

.break-note.warn-note { color: var(--warn); }

/* Toast notifications */
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(8px);
  z-index: 200; background: var(--accent); color: #1a1206; font-weight: 600; font-size: 13px;
  padding: 10px 16px; border-radius: 999px; box-shadow: var(--shadow); opacity: 0; transition: opacity .18s, transform .18s; pointer-events: none; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast[hidden] { display: none; }

/* ===========================================================================
   Visual polish bundle (Section A backlog) — appended overrides so they sit
   on top of the base rules above without touching them.
   =========================================================================== */

/* #1 consistent 16px rhythm + #2 subtle dividers between control groups.
   The .controls aside is a stack of <section> groups (some [hidden]); drop the
   flex gap in favor of even per-section padding so spacing stays a uniform 16px
   whether or not the conditional foil/deboss sections are showing, and hairline
   the boundary between groups for scannability. */
.controls { gap: 0; }
.controls > section { padding-block: 16px; }
.controls > section:first-child { padding-top: 0; }
.controls > section + section { border-top: 1px solid var(--line); }

/* #7 binding-tile baseline alignment. Tiles vary by sub-label length (1 vs 2
   lines), which pushed the names/icons out of alignment across a grid row.
   Pin the icon row and reserve two lines for the sub so every tile's name and
   glyph land on the same baseline. */
.bind-tile { justify-content: flex-start; }
.bind-svg { flex: none; }
.bt-name { min-height: 1.1em; display: flex; align-items: center; }
.bt-sub { min-height: 2.2em; display: flex; align-items: center; justify-content: center; }

/* #11 unify border-radius. Base rules mixed 8/9/10px on interactive controls;
   collapse them onto a single --radius-control token (cards keep --radius 12px,
   pills keep 999px — a deliberate scale, not the old ad-hoc mix). */
:root { --radius-control: 8px; }
.text-input, .select,
.btn-ghost, .btn-primary,
.bind-tile, .next-break,
.ref-img, .logo-warn,
#preview canvas { border-radius: var(--radius-control); }
