/* ============================================
   Bogade Table Configurator — Styles
   ============================================ */

:root {
  --sidebar-width: 400px;
  --color-bg: #f7f6f3;
  --color-white: #ffffff;
  --color-text: #1a1a1a;
  --color-text-light: #6b6b6b;
  --color-border: #e8e6e1;
  --color-accent: #c8965a;
  --color-accent-hover: #b5843f;
  --color-surface: #faf9f7;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 30px rgba(0,0,0,0.1);
  --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: var(--font);
  color: var(--color-text);
  background: var(--color-bg);
  -webkit-font-smoothing: antialiased;
}

/* ---- Loader ---- */
.loader {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: var(--color-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.5s ease;
}

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

.loader-inner {
  text-align: center;
}

.loader-inner p {
  margin-top: 16px;
  font-size: 14px;
  color: var(--color-text-light);
  font-weight: 400;
  letter-spacing: 0.02em;
}

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

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

.mini-loader {
  position: absolute;
  inset: 0;
  z-index: 50;
  background: rgba(245, 244, 242, 0.85);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  transition: opacity 0.3s ease;
  pointer-events: none;
}

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

#mini-loader-text {
  font-size: 13px;
  color: var(--color-text-light);
  font-weight: 400;
  letter-spacing: 0.02em;
}

.mini-spinner {
  width: 28px;
  height: 28px;
  border: 3px solid rgba(0,0,0,0.1);
  border-top-color: var(--color-accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

/* ---- Main Layout ---- */
.configurator {
  display: flex;
  height: 100vh;
  width: 100vw;
}

/* ---- 3D Viewer ---- */
.viewer {
  flex: 1;
  position: relative;
  background: linear-gradient(180deg, #f0efec 0%, #e8e6e1 100%);
  overflow: hidden;
}

#canvas3d {
  display: block;
  width: 100%;
  height: 100%;
}

.viewer-header {
  position: absolute;
  top: 16px;
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
  z-index: 10;
  pointer-events: none;
}

.brand {
  pointer-events: auto;
  font-size: 36px;
  font-weight: 600;
  letter-spacing: 0.15em;
  color: var(--color-text);
  opacity: 0.7;
}

.viewer-controls {
  position: absolute;
  bottom: 24px;
  left: 24px;
  display: flex;
  flex-direction: row;
  gap: 8px;
  z-index: 10;
}

.viewer-controls-row {
  display: flex;
  flex-direction: row;
  gap: 8px;
}
.viewer-controls-right {
  position: absolute;
  bottom: 20px;
  right: 20px;
  display: flex;
  flex-direction: row-reverse;
  gap: 10px;
  align-items: center;
  z-index: 10;
}

.viewer-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--color-border);
  background: var(--color-white);
  color: var(--color-text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  box-shadow: var(--shadow-sm);
}

.viewer-btn:hover {
  background: var(--color-text);
  color: var(--color-white);
  border-color: var(--color-text);
}

.dimension-badge {
  position: absolute;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--color-white);
  padding: 8px 18px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
  color: var(--color-text);
  box-shadow: var(--shadow-md);
  letter-spacing: 0.02em;
  z-index: 10;
}

/* AR Button */
.ar-btn {
  position: absolute;
  bottom: 20px;
  right: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  padding: 10px;
  border-radius: 50%;
  border: 1px solid var(--color-border);
  background: var(--color-white);
  color: var(--color-text);
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  box-shadow: var(--shadow-md);
  transition: var(--transition);
  z-index: 10;
}
.ar-btn:hover {
  background: var(--color-text);
  color: var(--color-white);
  border-color: var(--color-text);
}
.ar-btn:hover svg { stroke: var(--color-white); }
.ar-btn.loading { opacity: 0.6; pointer-events: none; }

/* AR Popup (desktop) */
.ar-popup {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  backdrop-filter: blur(4px);
}
.ar-popup.hidden { display: none; }
.ar-popup-inner {
  background: #fff;
  border-radius: 16px;
  padding: 36px 32px;
  max-width: 380px;
  width: 90%;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
  position: relative;
}
.ar-popup-close {
  position: absolute;
  top: 12px; right: 16px;
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: #999;
  line-height: 1;
}
.ar-popup-close:hover { color: #333; }
.ar-popup-icon { margin-bottom: 16px; }
.ar-popup-inner h3 {
  font-size: 18px;
  font-weight: 600;
  margin: 0 0 8px;
  color: var(--color-text);
}
.ar-popup-inner p {
  font-size: 14px;
  color: #666;
  margin: 0 0 20px;
  line-height: 1.5;
}
.ar-qr {
  display: flex;
  justify-content: center;
  margin-bottom: 16px;
}
.ar-qr canvas { border-radius: 8px; }
.ar-popup-hint {
  font-size: 12px !important;
  color: #999 !important;
  margin: 0 !important;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: #1a1a1a;
  color: #fff;
  padding: 12px 24px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 500;
  z-index: 10000;
  opacity: 0;
  transition: opacity 0.3s, transform 0.3s;
  pointer-events: none;
  white-space: nowrap;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.toast.hidden { display: none; }

/* Saved config cards */
.saved-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border: 1px solid #eee;
  border-radius: 10px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: background 0.2s;
}
.saved-card:hover { background: #f9f8f6; }
.saved-card-img {
  width: 64px;
  height: 48px;
  border-radius: 6px;
  object-fit: cover;
  background: #f0eeeb;
}
.saved-card-info { flex: 1; min-width: 0; }
.saved-card-title {
  font-size: 13px;
  font-weight: 600;
  color: #1a1a1a;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.saved-card-sub {
  font-size: 11px;
  color: #999;
  margin-top: 2px;
}
.saved-card-del {
  background: none;
  border: none;
  color: #ccc;
  font-size: 18px;
  cursor: pointer;
  padding: 4px 8px;
}
.saved-card-del:hover { color: #e44; }

/* Share popup */
.share-options {
  display: flex;
  gap: 16px;
  justify-content: center;
  margin-top: 20px;
}
.share-opt {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  background: none;
  border: 1px solid #eee;
  border-radius: 12px;
  padding: 16px 20px;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
  font-size: 12px;
  color: #555;
  min-width: 80px;
}
.share-opt:hover {
  background: #f9f8f6;
  border-color: #ccc;
}

/* ---- Sidebar ---- */
.sidebar {
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--color-white);
  border-left: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar-scroll {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding-bottom: 12px;
}

.sidebar-scroll::-webkit-scrollbar {
  width: 4px;
}

.sidebar-scroll::-webkit-scrollbar-thumb {
  background: var(--color-border);
  border-radius: 4px;
}

/* ---- Sections (Accordion) ---- */
.section {
  border-bottom: 1px solid var(--color-border);
}

.section-header {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px 22px;
  background: none;
  border: none;
  cursor: pointer;
  text-align: left;
  font-family: var(--font);
  transition: background var(--transition);
}

.section-header:hover {
  background: var(--color-surface);
}

.section-icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--color-text);
  overflow: hidden;
}

.section-icon img {
  width: 28px;
  height: 28px;
  object-fit: contain;
}

.section-label {
  flex: 1;
  min-width: 0;
}

.section-title {
  display: block;
  font-size: 15px;
  font-weight: 600;
  color: var(--color-text);
  line-height: 1.2;
}

.section-value {
  display: block;
  font-size: 12px;
  font-weight: 400;
  color: var(--color-text-light);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.section-chevron {
  flex-shrink: 0;
  transition: transform var(--transition);
  color: var(--color-text-light);
}

.section.active .section-chevron {
  transform: rotate(180deg);
}

.section-content {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.section.active .section-content {
  max-height: 800px;
  overflow-y: auto;
}

.section-content > * {
  padding: 0 22px;
}

.section-content > *:last-child {
  padding-bottom: 20px;
}

/* ---- Shape Grid ---- */
.shape-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.shape-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 8px 4px 6px;
  border: 2px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-white);
  cursor: pointer;
  transition: var(--transition);
  text-align: center;
}

.shape-option:hover {
  border-color: var(--color-text-light);
  background: var(--color-surface);
}

.shape-option.active {
  border-color: var(--color-accent);
  background: #fdf8f2;
}

.shape-option svg {
  width: 40px;
  height: 26px;
  color: var(--color-text);
}

.shape-option img {
  width: 48px;
  height: 30px;
  object-fit: contain;
}

.shape-option.active svg {
  color: var(--color-accent);
}

.shape-option span {
  font-size: 11px;
  font-weight: 500;
  color: var(--color-text-light);
  line-height: 1.2;
}

.shape-option.active span {
  color: var(--color-accent);
}

/* ---- Material Toggle ---- */
.material-type-toggle {
  display: flex;
  justify-content: center;
  gap: 16px;
  margin-top: 6px;
  padding: 6px;
  margin-bottom: 16px;
}

.mat-type-swatch {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 0;
  border: none;
  background: none;
  cursor: pointer;
  font-family: var(--font);
  font-size: 11px;
  font-weight: 500;
  color: var(--color-text-light);
  transition: var(--transition);
}

.mat-swatch-img {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  border: 3px solid transparent;
  background-size: cover;
  background-position: center;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.1);
  transition: var(--transition);
  position: relative;
}

.mat-type-swatch:hover .mat-swatch-img {
  border-color: var(--color-text-light);
}

.mat-type-swatch.active .mat-swatch-img {
  border-color: var(--color-accent);
}

.mat-type-swatch.active .mat-swatch-img::after {
  content: '';
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  border: 2px solid var(--color-accent);
}

.mat-type-swatch.active span {
  color: var(--color-accent);
}

/* Legacy support */
.mat-type-btn { display: none; }

/* ---- Color Swatches ---- */
.color-swatches {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
  padding: 6px;
}

.swatch {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  border: none;
  background: none;
  padding: 0;
  font-family: var(--font);
}

.swatch-circle,
.swatch-preview {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 3px solid transparent;
  transition: var(--transition);
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.1);
  position: relative;
}

.swatch-preview {
  background-size: cover;
  background-position: center;
}

.swatch:hover .swatch-circle,
.swatch:hover .swatch-preview {
  border-color: var(--color-text-light);
}

.swatch.active .swatch-circle,
.swatch.active .swatch-preview {
  border-color: var(--color-accent);
}

.swatch.active .swatch-circle::after,
.swatch.active .swatch-preview::after {
  content: '';
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  border: 2px solid var(--color-accent);
}

.swatch-name {
  font-size: 10px;
  font-weight: 400;
  color: var(--color-text-light);
  text-align: center;
  line-height: 1.2;
  max-width: 60px;
}

.swatch.active .swatch-name {
  font-weight: 500;
  color: var(--color-accent);
}

/* ---- Dimensions ---- */
.dim-section {
  margin-bottom: 16px;
}

.shape-sub-option {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--color-border);
}

.dim-section-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--color-text-light);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 8px;
}

.dim-btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.dim-btn {
  padding: 7px 12px;
  border: 2px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-white);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 500;
  color: var(--color-text);
  cursor: pointer;
  transition: var(--transition);
  min-width: 44px;
  text-align: center;
}

.dim-btn:hover {
  border-color: var(--color-text-light);
  background: var(--color-surface);
}

.dim-btn.active {
  border-color: var(--color-accent);
  background: #fdf8f2;
  color: var(--color-accent);
}

.dim-btn.locked {
  opacity: 0.35;
  pointer-events: none;
  position: relative;
}

.dim-btn.locked::after {
  content: '';
  position: absolute;
  top: 3px;
  right: 3px;
  width: 11px;
  height: 11px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23999' stroke-width='2'%3E%3Crect x='3' y='11' width='18' height='11' rx='2'/%3E%3Cpath d='M7 11V7a5 5 0 0110 0v4'/%3E%3C/svg%3E");
  background-size: contain;
  background-repeat: no-repeat;
}

/* Fixed dimension buttons (L x B pairs) */
.dim-btn-fixed {
  padding: 8px 14px;
  border: 2px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-white);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 500;
  color: var(--color-text);
  cursor: pointer;
  transition: var(--transition);
  text-align: center;
}

.dim-btn-fixed:hover {
  border-color: var(--color-text-light);
  background: var(--color-surface);
}

.dim-btn-fixed.active {
  border-color: var(--color-accent);
  background: #fdf8f2;
  color: var(--color-accent);
}

.dim-fixed-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.dimension-info {
  display: flex;
  justify-content: space-between;
  padding-top: 4px;
  font-size: 12px;
  color: var(--color-text-light);
}

/* ---- Edge Options ---- */
.edge-options {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
}

.edge-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px 3px 4px;
  border: 2px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-white);
  cursor: pointer;
  transition: var(--transition);
  text-align: center;
}

.edge-option:hover {
  border-color: var(--color-text-light);
}

.edge-option.active {
  border-color: var(--color-accent);
  background: #fdf8f2;
}

.edge-swatch {
  width: 40px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border-radius: 4px;
}

.edge-swatch svg {
  width: 100%;
  height: 100%;
}

.edge-swatch img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.edge-option-name {
  display: block;
  font-size: 10px;
  font-weight: 600;
  color: var(--color-text);
  line-height: 1.2;
}

.edge-option.active .edge-option-name {
  color: var(--color-accent);
}

.edge-option-desc {
  display: none;
}

/* ---- Leg Grid ---- */
.leg-grid {
  max-height: 400px;
  overflow-y: auto;
  padding-bottom: 14px !important;
}

.leg-category-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--color-text-light);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin: 12px 0 6px;
}

.leg-category-label:first-child {
  margin-top: 0;
}

.leg-category-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
}

.leg-grid::-webkit-scrollbar {
  width: 3px;
}

.leg-grid::-webkit-scrollbar-thumb {
  background: var(--color-border);
  border-radius: 3px;
}

.leg-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 4px;
  padding: 6px 4px;
  border: 2px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-white);
  cursor: pointer;
  transition: var(--transition);
  font-family: var(--font);
  font-size: 10px;
  font-weight: 500;
  color: var(--color-text-light);
  line-height: 1.2;
  min-height: 52px;
  word-break: break-word;
}

.leg-swatch-svg, .leg-swatch-img {
  width: 53px;
  height: 43px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--color-text-light);
  transition: var(--transition);
  overflow: hidden;
  border-radius: 4px;
}

.leg-swatch-svg svg, .leg-swatch-img svg {
  width: 100%;
  height: 100%;
}

.leg-swatch-img img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.leg-option.active .leg-swatch-svg,
.leg-option.active .leg-swatch-img {
  color: var(--color-accent);
}

.leg-option:hover {
  border-color: var(--color-text-light);
  background: var(--color-surface);
}

.leg-option.active {
  border-color: var(--color-accent);
  background: #fdf8f2;
  color: var(--color-accent);
}

.leg-option .leg-type-badge {
  display: inline-block;
  font-size: 9px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 1px 5px;
  border-radius: 3px;
  margin-top: 3px;
}

.leg-type-badge.wood {
  background: #f0e8d8;
  color: #8b6f42;
}

.leg-type-badge.metal {
  background: #e4e4e8;
  color: #555;
}

.subsection-label {
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-light);
  margin-bottom: 10px;
  margin-top: 4px;
}

.leg-powder-section {
  padding-top: 6px !important;
}

.leg-powder-section.hidden {
  display: none;
}

/* ---- Sidebar Footer ---- */
.sidebar-footer {
  border-top: 1px solid var(--color-border);
  padding: 18px 22px;
  background: var(--color-white);
}

.summary {
  margin-bottom: 14px;
}

.summary-label {
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-text-light);
}

.summary-line {
  font-size: 13px;
  color: var(--color-text);
  margin-top: 4px;
  line-height: 1.5;
}

.price-divider {
  border-top: 1px solid #e0ddd8;
  margin: 8px 0 0;
}

.price-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0 4px;
}

.price-label {
  font-family: var(--font);
  font-size: 12px;
  color: var(--color-text-light);
}

#total-price {
  font-family: var(--font);
  font-size: 12px;
  font-weight: 700;
  color: var(--color-text);
}

#total-price.price-loading {
  font-weight: 400;
  color: var(--color-text-light);
}

.free-shipping {
  font-family: var(--font);
  font-size: 11px;
  font-weight: 500;
  color: var(--color-accent);
  text-align: center;
  padding: 2px 0 6px;
}

.cta-button {
  width: auto;
  margin: 0 auto;
  padding: 12px 28px;
  border: none;
  border-radius: var(--radius-md);
  background: var(--color-accent);
  color: var(--color-white);
  font-family: var(--font);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: var(--transition);
  letter-spacing: 0.01em;
}

.cta-button:hover {
  background: var(--color-accent-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.cta-button:active {
  transform: translateY(0);
}

/* Mobile price row (hidden on desktop) */
.mobile-price-row {
  display: none;
}

#total-price-mobile {
  font-size: 13px;
  font-weight: 700;
  color: var(--color-text);
}

#total-price-mobile.price-loading {
  font-weight: 400;
  font-size: 12px;
  color: var(--color-text-light);
}

.mobile-shipping {
  display: block;
  font-size: 10px;
  color: var(--color-accent);
  font-weight: 500;
}

.mobile-price-info {
  text-align: center;
  flex: 1;
}

/* ---- Mobile Toggle ---- */
.mobile-toggle {
  display: none;
}

/* ---- Responsive ---- */
@media (max-width: 900px) {
  /* Strategy: JS sets configurator to exactly visualViewport.height px.
     The configurator becomes the scroll container (overflow-y: auto).
     position:sticky on both viewer (top) and footer (bottom) gives the
     "sticky header + sticky footer + scrolling middle" pattern.
     The iframe height = configurator height = visible screen space — no
     wasted blank area on the Shopify page. */

  html, body {
    height: 100%;
    overflow: hidden;
  }

  .configurator {
    flex-direction: column;
    height: 100%; /* JS overrides with visualViewport.height in px */
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: none; /* hide scrollbar */
  }
  .configurator::-webkit-scrollbar { display: none; }

  .viewer {
    flex: none;
    height: 58vw;
    min-height: 200px;
    position: sticky;
    top: 0;
    z-index: 10;
  }

  .sidebar {
    width: 100%;
    flex: 1;
    min-height: 0;
    border-left: none;
    border-top: none;
    overflow: visible;
  }

  .sidebar-scroll {
    overflow: visible;
    max-height: none;
  }

  /* Checkout bar: sticky at bottom of the configurator scroll container */
  .sidebar-footer {
    order: 0; /* natural order: after sidebar-scroll */
    position: sticky;
    bottom: 0;
    z-index: 200;
    padding: 10px 16px;
    background: var(--color-white);
    border-top: 1px solid var(--color-border);
    box-shadow: 0 -2px 10px rgba(0,0,0,0.06);
    display: flex;
    align-items: center;
    gap: 12px;
  }

  .sidebar-footer .summary {
    flex: 1;
    min-width: 0;
    margin-bottom: 0;
  }

  .sidebar-footer .summary-label {
    font-size: 9px;
  }

  .sidebar-footer .summary-line {
    font-size: 11px;
    margin-top: 2px;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }

  .sidebar-footer .price-divider {
    display: none;
  }

  .sidebar-footer .price-bar {
    display: none;
  }

  .sidebar-footer .free-shipping {
    display: none;
  }

  .sidebar-footer .cta-desktop {
    display: none;
  }

  .sidebar-footer .mobile-price-row {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
  }

  .sidebar-footer .cta-mobile {
    flex-shrink: 0;
    padding: 10px 18px;
    font-size: 13px;
    white-space: nowrap;
  }

  .viewer-header {
    display: none;
  }

  .dimension-badge {
    display: none !important;
  }

  .viewer-controls {
    bottom: 14px;
    left: 14px;
  }

  .section-header {
    padding: 14px 16px;
    gap: 12px;
  }

  .section-content > * {
    padding: 0 16px;
  }

  .shape-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
  }

  .shape-option {
    padding: 10px 4px 8px;
  }

  .color-swatches {
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
  }

  .swatch-circle,
  .swatch-preview {
    width: 38px;
    height: 38px;
  }

  .mat-swatch-img {
    width: 64px;
    height: 64px;
  }
}

@media (max-width: 500px) {
  .shape-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .color-swatches {
    grid-template-columns: repeat(4, 1fr);
  }
}
