*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}
:root {
  color-scheme: light;
  --ink: 26, 26, 24; /* canaux RVB du texte → pilote tous les voiles/bordures ; bascule en sombre */
  --bg: #e9e4df;
  --bg2: #f2ede8;
  --bg3: #ded8d1;
  --bg-rgb: 233, 228, 223; /* canaux RVB de --bg → dégradés transparents même teinte */
  --fg: #1a1a18;
  --fg2: #5a5a54;
  --fg3: #5f5f59;
  --accent: #1c3028;
  --border: rgba(var(--ink), 0.1);
  /* Dégradé de fond du viewer 3D (le canvas WebGL est transparent : alpha:true) */
  --viewer-grad: radial-gradient(ellipse at 50% 40%, #f1ece3 0%, #e7e0d5 55%, #d9d1c4 100%);
  --sidebar-w: 240px;
  --panel-w: 352px;
  --header-h: 56px;
}

/* ══ Thème SOMBRE ══════════════════════════════════════════════════════════
   Surcharge des variables de surface. La quasi-totalité des styles s'appuient
   sur var(--bg/--fg/--border/--ink) → bascule automatique. Le canvas 3D étant
   transparent, seul --viewer-grad change : aucun re-rendu Three.js nécessaire. */
html[data-theme='dark'] {
  color-scheme: dark;
  --ink: 236, 234, 228;
  --bg: #1a1813;
  --bg2: #221f19;
  --bg3: #2b2822;
  --bg-rgb: 26, 24, 19;
  --fg: #eceae4;
  --fg2: #b3afa4;
  --fg3: #918f85;
  --border: rgba(var(--ink), 0.13);
  --viewer-grad: radial-gradient(ellipse at 50% 38%, #2a251c 0%, #1c1811 55%, #120f09 100%);
}
/* Logo (PNG noir) → inversé en blanc sur fond sombre */
html[data-theme='dark'] #brand-logo {
  filter: invert(1) brightness(1.08);
}
/* Survol d'une matière dans le résumé config (desktop) : accent illisible sur
   sombre → on repasse en texte clair. */
html[data-theme='dark'] .config-line .config-mat:hover {
  color: var(--fg);
  border-bottom-color: rgba(var(--ink), 0.4);
}
html[data-theme='dark'] .config-line .config-mat.config-static:hover {
  color: var(--fg);
  border-bottom-color: transparent;
}
/* Render Tuner (outil dev, touche T, desktop) : verrouillé en clair pour rester
   lisible quel que soit le thème du site. */
html[data-theme='dark'] #render-tuner {
  --ink: 26, 26, 24;
  --bg2: #f2efe9;
  --bg3: #e6e2db;
  --fg: #1a1a18;
  --fg2: #5a5a54;
  --fg3: #5f5f59;
  --border: rgba(var(--ink), 0.1);
}
/* Barres de défilement discrètes en sombre (WebKit) */
html[data-theme='dark'] ::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}
html[data-theme='dark'] ::-webkit-scrollbar-thumb {
  background: rgba(var(--ink), 0.18);
  border-radius: 6px;
}
html[data-theme='dark'] ::-webkit-scrollbar-track {
  background: transparent;
}
html,
body {
  height: 100%;
  overflow: hidden;
}
body {
  font-family:
    'Jost',
    -apple-system,
    sans-serif;
  background: var(--bg);
  color: var(--fg);
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

#header {
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  background: var(--bg);
  border-bottom: 0.5px solid var(--border);
  flex-shrink: 0;
  z-index: 10;
}
#brand-logo {
  height: 50px;
  width: auto;
  display: block;
}
#header-right {
  font-size: 9px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--fg3);
}
#header-actions {
  display: flex;
  align-items: center;
  gap: 14px;
}
/* Bouton bascule clair/sombre */
#theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  flex-shrink: 0;
  background: transparent;
  border: 0.5px solid var(--border);
  border-radius: 50%;
  color: var(--fg2);
  cursor: pointer;
  transition:
    background 0.15s,
    color 0.15s,
    border-color 0.15s;
  -webkit-tap-highlight-color: transparent;
}
#theme-toggle:hover {
  color: var(--fg);
  border-color: rgba(var(--ink), 0.25);
  background: rgba(var(--ink), 0.04);
}
#theme-toggle svg {
  width: 17px;
  height: 17px;
  display: block;
}
/* Lune affichée en clair (→ clic = sombre) ; soleil affiché en sombre (→ clic = clair) */
#theme-toggle .icon-sun {
  display: none;
}
html[data-theme='dark'] #theme-toggle .icon-moon {
  display: none;
}
html[data-theme='dark'] #theme-toggle .icon-sun {
  display: block;
}

#layout {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* ── Mode module / embed (iframe intégrée à une page produit, ?embed=1) ──────
   Verrouille sur un seul produit : masque en-tête, liste, fiche descriptive,
   prix, livraison et panier. Ne conserve que le viewer 3D, les sélecteurs de
   matières et le récapitulatif « Configuration actuelle ». */
body.embed #header,
body.embed #sidebar,
body.embed #sidebar-overlay,
body.embed #product-header,
body.embed #price-side,
body.embed #btn-cart {
  display: none !important;
}

#sidebar {
  width: var(--sidebar-w);
  background: var(--bg);
  border-right: 0.5px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  flex-shrink: 0;
  padding-top: 32px;
}
#sidebar-label {
  font-size: 8px;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--fg3);
  padding: 0 24px 10px;
}

#search-wrap {
  padding: 0 16px 16px;
}
#search-input {
  width: 100%;
  padding: 7px 12px 7px 30px;
  font-family: 'Jost', sans-serif;
  font-size: 11px;
  font-weight: 300;
  color: var(--fg);
  background: var(--bg3);
  border: 0.5px solid transparent;
  border-radius: 3px;
  outline: none;
  transition:
    border-color 0.15s,
    background 0.15s;
  letter-spacing: 0.02em;
  box-sizing: border-box;
}
#search-input::placeholder {
  color: var(--fg3);
}
#search-input:focus {
  border-color: rgba(var(--ink), 0.18);
  background: var(--bg2);
}
#search-wrap {
  position: relative;
  padding: 0 16px 14px;
}
#search-icon {
  position: absolute;
  left: 26px;
  top: 0;
  bottom: 14px; /* exclut le padding bas du wrapper */
  margin: auto 0;
  height: 12px;
  width: 12px;
  color: var(--fg3);
  pointer-events: none;
}
.product-btn.hidden {
  display: none;
}
#search-empty {
  display: none;
  padding: 12px 24px;
  font-size: 11px;
  color: var(--fg3);
  font-weight: 300;
  font-style: italic;
}
.product-btn {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 12px 24px;
  border: none;
  background: transparent;
  cursor: pointer;
  border-left: 1.5px solid transparent;
  transition:
    background 0.2s,
    border-color 0.2s;
  text-align: left;
}
.product-btn:hover {
  background: rgba(var(--ink), 0.03);
}
.product-btn.active {
  background: rgba(var(--ink), 0.05);
  border-left-color: var(--fg);
}
.product-thumb {
  width: 52px;
  height: 52px;
  border-radius: 3px;
  background: var(--bg3);
  overflow: hidden;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.product-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.thumb-placeholder {
  font-size: 8px;
  color: var(--fg3);
  letter-spacing: 0.06em;
}
.product-info {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.product-name-list {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 17px;
  font-weight: 400;
  color: var(--fg);
  line-height: 1.1;
}
.product-btn.active .product-name-list {
  font-weight: 500;
}
.product-type-list {
  font-size: 9px;
  font-weight: 400;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--fg3);
}

#viewer-container {
  flex: 1;
  position: relative;
  overflow: hidden;
  background: var(--bg);
}
#viewer-bg {
  position: absolute;
  inset: 0;
  background: var(--viewer-grad);
  pointer-events: none;
  transition: background 0.3s ease;
}
#viewer {
  width: 100%;
  height: 100%;
  display: block;
  position: relative;
  z-index: 1;
}
/* Loading overlay */
#load-overlay {
  position: absolute;
  inset: 0;
  z-index: 6;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  pointer-events: none;
  background: var(--bg);
  opacity: 0;
  transition: opacity 0.3s ease;
}
#load-overlay.visible {
  opacity: 1;
}
#load-overlay.fade-out {
  opacity: 0;
  transition: opacity 0.5s ease;
}
#canvas-wrap {
  position: absolute;
  inset: 0;
  z-index: 1;
  opacity: 0;
  transition: opacity 0.6s ease;
}
#canvas-wrap.visible {
  opacity: 1;
}

/* Progress bar */
#progress-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
#progress-bar-outer {
  width: 120px;
  height: 1px;
  background: rgba(var(--ink), 0.1);
  border-radius: 1px;
  overflow: hidden;
}
#progress-bar-inner {
  height: 100%;
  width: 0%;
  background: var(--fg2);
  border-radius: 1px;
  transition: width 0.2s ease;
}
#progress-text {
  font-size: 9px;
  color: var(--fg3);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-weight: 300;
}

.viewer-state {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: none;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 14px;
  pointer-events: none;
}
.viewer-state.visible {
  display: flex;
}
.state-text {
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--fg3);
  font-weight: 300;
}
.spinner {
  width: 16px;
  height: 16px;
  border: 1px solid rgba(var(--ink), 0.12);
  border-top-color: var(--fg2);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
#viewer-hint {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 8px;
  color: rgba(var(--ink), 0.22);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  white-space: nowrap;
  pointer-events: none;
  z-index: 2;
}

/* ── Outils viewer : plein écran + export PDF (coin haut-droit) ───────── */
#viewer-tools {
  position: absolute;
  top: 14px;
  left: 14px;
  z-index: 5;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.vtool-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  background: var(--bg);
  border: 0.5px solid var(--border);
  border-radius: 50%;
  color: var(--fg2);
  cursor: pointer;
  transition:
    color 0.15s,
    border-color 0.15s,
    opacity 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.vtool-btn:hover {
  color: var(--fg);
  border-color: var(--fg);
}
.vtool-btn svg {
  width: 16px;
  height: 16px;
  display: block;
}
.vtool-btn.busy {
  opacity: 0.45;
  pointer-events: none;
}
#btn-fs .ic-compress {
  display: none;
}
#viewer-container.is-fs #btn-fs .ic-expand {
  display: none;
}
#viewer-container.is-fs #btn-fs .ic-compress {
  display: block;
}
/* Plein écran natif : fond correct (sinon noir par défaut) */
#viewer-container:fullscreen {
  background: var(--bg);
}
#viewer-container:-webkit-full-screen {
  background: var(--bg);
}
/* Fallback iPhone (pas d'API Fullscreen sur élément) : faux plein écran CSS */
#viewer-container.fs-fake {
  position: fixed !important;
  inset: 0 !important;
  z-index: 9995;
  background: var(--bg);
}
/* ── Panneau debug (#debug-panel) ────────────────────────────────────────
   Masqué en PRODUCTION. Rendu disponible uniquement en mode ?debug (la classe
   body.debug est posée par src/main.js). Affiche nodes/meshes, journal textures
   et métriques ressources (textures, AO, mémoire GPU). */
body:not(.debug) #debug-panel {
  display: none !important;
}
body:not(.debug) #debug-toggle {
  display: none !important;
}
#debug-toggle {
  position: fixed;
  bottom: 12px;
  left: 12px;
  z-index: 201;
  padding: 6px 12px;
  font-family: 'Jost', sans-serif;
  font-size: 11px;
  letter-spacing: 0.04em;
  color: #fff;
  background: rgba(20, 20, 22, 0.85);
  border: 0.5px solid rgba(255, 255, 255, 0.25);
  border-radius: 5px;
  cursor: pointer;
}
#debug-toggle.open {
  background: rgba(60, 60, 66, 0.9);
}
#debug-panel {
  position: fixed;
  bottom: 46px;
  left: 12px;
  z-index: 200;
  width: 340px;
  max-height: calc(100vh - 120px);
  overflow: auto;
  padding: 12px 14px;
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  font-size: 11px;
  line-height: 1.5;
  color: #eaeaea;
  background: rgba(18, 18, 20, 0.92);
  border: 0.5px solid rgba(255, 255, 255, 0.18);
  border-radius: 6px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.35);
  white-space: pre-wrap;
  display: none;
}
#debug-panel.visible {
  display: block;
}

/* ── Render Tuner — panneau de réglage live des paramètres de rendu ───── */
/* Ouvert par la touche T. Permet d'ajuster en live tone mapping, exposure,
   env intensity, lights, shadow. Bouton "Copy" pour figer les valeurs. */
#render-tuner {
  position: fixed;
  top: 80px;
  right: 20px;
  width: 460px;
  background: rgba(252, 250, 247, 0.97);
  backdrop-filter: blur(10px);
  border: 0.5px solid var(--border);
  border-radius: 6px;
  padding: 14px 16px;
  font-size: 10px;
  color: var(--fg);
  z-index: 100;
  display: none;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.1);
  font-family: 'Jost', sans-serif;
  letter-spacing: 0.02em;
  max-height: calc(100vh - 100px);
  overflow-y: auto;
}
#render-tuner.visible {
  display: block;
}
#render-tuner h3 {
  margin: 0 0 10px;
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--fg3);
}
#render-tuner .tuner-row {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-bottom: 5px;
}
#render-tuner .tuner-label {
  flex: 0 0 130px;
  font-size: 10px;
  color: var(--fg2);
}
#render-tuner .tuner-val {
  font-size: 9px;
  color: var(--fg3);
  width: 40px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
#render-tuner input[type='range'] {
  width: 130px;
  flex-shrink: 0;
  cursor: pointer;
}
#render-tuner input[type='color'] {
  width: 22px;
  height: 18px;
  padding: 0;
  border: 0.5px solid var(--border);
  border-radius: 3px;
  cursor: pointer;
  background: transparent;
  flex-shrink: 0;
}
#render-tuner input[type='color']::-webkit-color-swatch-wrapper {
  padding: 1px;
}
#render-tuner input[type='color']::-webkit-color-swatch {
  border: none;
  border-radius: 2px;
}
#render-tuner select {
  font-family: 'Jost', sans-serif;
  font-size: 10px;
  padding: 3px 6px;
  background: var(--bg2);
  border: 0.5px solid var(--border);
  border-radius: 3px;
  color: var(--fg);
  flex: 1;
}
#render-tuner .tuner-section {
  font-size: 8px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--fg3);
  margin: 10px 0 6px;
  border-top: 0.5px solid var(--border);
  padding-top: 8px;
}
#render-tuner .tuner-section:first-of-type {
  border-top: none;
  padding-top: 0;
}
#render-tuner .tuner-actions {
  display: flex;
  gap: 6px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 0.5px solid var(--border);
}
#render-tuner .tuner-btn {
  flex: 1;
  padding: 5px 8px;
  font-size: 9px;
  font-family: 'Jost', sans-serif;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  border-radius: 3px;
  border: 0.5px solid var(--border);
  background: var(--bg2);
  color: var(--fg);
}
#render-tuner .tuner-btn:hover {
  background: var(--fg);
  color: var(--bg);
}
/* Numeric input per slider */
#render-tuner .tuner-num {
  width: 54px;
  flex-shrink: 0;
  font-family: 'Jost', sans-serif;
  font-size: 10px;
  font-variant-numeric: tabular-nums;
  padding: 2px 4px;
  border: 0.5px solid var(--border);
  border-radius: 3px;
  background: var(--bg2);
  color: var(--fg);
  text-align: right;
  -moz-appearance: textfield;
  outline: none;
}
#render-tuner .tuner-num::-webkit-inner-spin-button,
#render-tuner .tuner-num::-webkit-outer-spin-button {
  opacity: 0.4;
}
#render-tuner .tuner-num:focus {
  border-color: var(--fg3);
}
/* Per-row reset button */
#render-tuner .tuner-rst {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  padding: 0;
  font-size: 11px;
  line-height: 1;
  cursor: pointer;
  border-radius: 3px;
  border: 0.5px solid transparent;
  background: transparent;
  color: var(--fg3);
  display: flex;
  align-items: center;
  justify-content: center;
  transition:
    color 0.15s,
    border-color 0.15s;
}
#render-tuner .tuner-rst:hover {
  color: var(--fg);
  border-color: var(--border);
  background: var(--bg3);
}
/* Toggle checkbox (on/off params) */
#render-tuner .tuner-toggle {
  appearance: none;
  -webkit-appearance: none;
  width: 28px;
  height: 15px;
  border-radius: 8px;
  flex-shrink: 0;
  background: var(--bg3);
  border: 0.5px solid var(--border);
  cursor: pointer;
  position: relative;
  transition: background 0.2s;
}
#render-tuner .tuner-toggle:checked {
  background: var(--accent);
  border-color: var(--accent);
}
#render-tuner .tuner-toggle::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.2s;
}
#render-tuner .tuner-toggle:checked::after {
  transform: translateX(13px);
}
/* Disabled range/num when toggle is off */
#render-tuner .tuner-row.disabled .tuner-num,
#render-tuner .tuner-row.disabled input[type='range'] {
  opacity: 0.3;
  pointer-events: none;
}
#render-tuner-hint {
  position: fixed;
  bottom: 14px;
  right: 14px;
  font-size: 8px;
  color: rgba(var(--ink), 0.3);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  z-index: 99;
  pointer-events: none;
}

#details-panel {
  width: var(--panel-w);
  background: var(--bg);
  border-left: 0.5px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: relative;
  z-index: 2;
  overflow: hidden;
}
#panel-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 36px 28px 20px;
}

/* Prix + livraison + panier — sticky bas */
#price-block {
  flex-shrink: 0;
  padding: 16px 28px 24px;
  border-top: 0.5px solid var(--border);
  background: var(--bg);
  display: none;
  flex-direction: column;
  gap: 4px;
}
#price-line {
  display: flex;
  align-items: baseline;
  gap: 8px;
}
/* Configuration actuelle — bloc supérieur, aligné à gauche */
#config-summary {
  display: none;
  text-align: left;
  padding-bottom: 14px;
  margin-bottom: 14px;
  border-bottom: 0.5px solid var(--border);
}
/* Prix + livraison — bloc inférieur, aligné à droite */
#price-side {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  margin-bottom: 14px;
}
#config-summary-title {
  font-size: 8px;
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--fg3);
  margin-bottom: 9px;
}
.config-line {
  display: flex;
  align-items: baseline;
  justify-content: flex-start;
  gap: 7px;
  line-height: 1.7;
}
.config-line .config-cat {
  font-size: 11px;
  letter-spacing: 0.04em;
  color: var(--fg2);
  flex-shrink: 0;
}
.config-line .config-cat::after {
  content: ' :';
}
.config-line .config-mat {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 15px;
  font-style: italic;
  color: var(--fg);
  cursor: pointer;
  border-bottom: 0.5px solid transparent;
  transition:
    border-color 0.15s,
    color 0.15s;
}
.config-line .config-mat:hover {
  color: var(--accent);
  border-bottom-color: rgba(28, 48, 40, 0.4);
}
/* Valeurs informatives du résumé (produit, module, variante, type) :
   même typographie que les matières mais non cliquables — pas de style lien */
.config-line .config-mat.config-static {
  cursor: default;
}
.config-line .config-mat.config-static:hover {
  color: var(--fg);
  border-bottom-color: transparent;
}
/* Empreinte courte de configuration (identifie le contenu, utile au devis) */
.config-fingerprint {
  font-size: 9px;
  color: var(--fg3);
  letter-spacing: 0.08em;
  margin-top: 8px;
}
#price-value {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 28px;
  font-weight: 400;
  letter-spacing: -0.01em;
}
#price-modifier {
  font-size: 11px;
  color: var(--fg3);
}
#delivery-line {
  font-size: 9px;
  color: var(--fg3);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
#btn-cart {
  width: 100%;
  padding: 12px 16px;
  background: var(--fg);
  color: var(--bg);
  border: none;
  border-radius: var(--r);
  font-family: 'Jost', sans-serif;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  cursor: pointer;
  transition: opacity 0.15s;
}
#btn-cart:hover {
  opacity: 0.75;
}

/* Cart drawer */
#cart-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 9990;
  background: rgba(15, 15, 12, 0.45);
  backdrop-filter: blur(2px);
}
#cart-overlay.open {
  display: block;
}
#cart-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 9991;
  width: 400px;
  background: var(--bg);
  border-left: 0.5px solid var(--border);
  box-shadow: -12px 0 32px rgba(0, 0, 0, 0.12);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.32s cubic-bezier(0.22, 1, 0.36, 1);
}
#cart-panel.open {
  transform: translateX(0);
}
#cart-header {
  padding: 22px 24px 16px;
  border-bottom: 0.5px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
#cart-title {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 20px;
  font-weight: 400;
}
#cart-close {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: var(--fg3);
}
#cart-close:hover {
  color: var(--fg);
}
#cart-items {
  flex: 1;
  overflow-y: auto;
  padding: 16px 24px;
}
.cart-item {
  border: 0.5px solid var(--border);
  border-radius: var(--r2);
  padding: 14px;
  margin-bottom: 12px;
  background: var(--bg2);
  position: relative;
}
.cart-item-name {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 17px;
  margin-bottom: 6px;
}
.cart-item-config {
  font-size: 10px;
  color: var(--fg3);
  line-height: 1.7;
}
.cart-item-price {
  font-size: 14px;
  margin-top: 8px;
}
.cart-item-del {
  position: absolute;
  top: 12px;
  right: 12px;
  background: none;
  border: none;
  color: var(--fg3);
  font-size: 16px;
  cursor: pointer;
}
.cart-item-del:hover {
  color: #b03a2e;
}
#cart-footer {
  padding: 16px 24px 24px;
  border-top: 0.5px solid var(--border);
  flex-shrink: 0;
}
#cart-total-line {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 16px;
}
#cart-total-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--fg3);
}
#cart-total-value {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 22px;
}
#btn-cart-send {
  width: 100%;
  padding: 13px;
  background: var(--fg);
  color: var(--bg);
  border: none;
  border-radius: var(--r);
  font-family: 'Jost', sans-serif;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
  margin-bottom: 8px;
  transition: opacity 0.15s;
}
#btn-cart-send:hover {
  opacity: 0.75;
}
#btn-cart-copy {
  width: 100%;
  padding: 10px;
  background: transparent;
  border: 0.5px solid var(--border);
  border-radius: var(--r);
  font-family: 'Jost', sans-serif;
  font-size: 10px;
  color: var(--fg3);
  cursor: pointer;
  transition:
    border-color 0.15s,
    color 0.15s;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
#btn-cart-copy:hover {
  border-color: var(--fg);
  color: var(--fg);
}
#product-header {
  margin-bottom: 28px;
}
#product-brand-label {
  font-size: 8px;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--fg3);
  margin-bottom: 10px;
}
#product-name {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 38px;
  font-weight: 300;
  color: var(--fg);
  line-height: 1;
  letter-spacing: 0.01em;
  margin-bottom: 8px;
}
#product-subtitle {
  font-size: 9px;
  font-weight: 400;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--fg3);
  margin-bottom: 16px;
}
#product-desc-intro {
  display: none;
  font-size: 13px;
  font-weight: 500;
  color: var(--fg);
  line-height: 1.7;
  margin-bottom: 10px;
}
#product-desc {
  font-size: 12px;
  font-weight: 300;
  color: var(--fg2);
  line-height: 1.8;
}
#product-designer {
  display: none;
  margin-top: 14px;
  font-size: 9px;
  font-weight: 400;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--fg3);
}
#product-designer span {
  color: var(--fg2);
  font-weight: 300;
  text-transform: none;
  letter-spacing: 0.02em;
  font-size: 12px;
}

/* MODULES — radio exclusif */
#modules-container {
  display: flex;
  flex-direction: column;
}
.modules-block {
  padding: 20px 0;
  border-top: 0.5px solid var(--border);
}
.modules-label {
  font-size: 8px;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--fg3);
  margin-bottom: 14px;
}
.modules-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.module-radio-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 13px;
  border: 0.5px solid var(--border);
  border-radius: 2px;
  background: transparent;
  cursor: pointer;
  font-family: 'Jost', sans-serif;
  font-size: 10px;
  font-weight: 400;
  letter-spacing: 0.06em;
  color: var(--fg3);
  transition:
    background 0.15s,
    color 0.15s,
    border-color 0.15s;
  white-space: nowrap;
}
.module-radio-btn:hover {
  background: rgba(var(--ink), 0.04);
  color: var(--fg2);
}
.module-radio-btn.active {
  background: rgba(var(--ink), 0.07);
  border-color: rgba(var(--ink), 0.3);
  color: var(--fg);
}
.module-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
  background: rgba(var(--ink), 0.18);
  transition: background 0.15s;
}
.module-radio-btn.active .module-dot {
  background: var(--fg);
}

/* Boutons module/variante avec icône image (remplace le libellé texte)
   → pas de contour ni de fond : on ne voit que le pictogramme sur transparent.
     Icône agrandie ; max-width calé pour garantir 4 icônes par ligne
     (panneau 352px − 56px padding = 296px ; 4×66 + 3×7 gap = 285px). */
.module-radio-btn.has-icon {
  padding: 0;
  border: none;
  background: transparent;
}
.module-radio-btn.has-icon:hover,
.module-radio-btn.has-icon.active {
  border: none;
  background: transparent;
}
.module-icon-img {
  height: 52px;
  width: auto;
  max-width: 66px;
  display: block;
  object-fit: contain;
  pointer-events: none;
  opacity: 0.75;
  transition: opacity 0.15s;
}
.module-radio-btn:hover .module-icon-img,
.module-radio-btn.active .module-icon-img {
  opacity: 1;
}
.variant-btn.has-icon .module-icon-img {
  height: 44px;
}

/* Variantes du module actif — séparées des modules par un filet, comme les
   matières (#category-tabs). Conteneur vide (module sans variante) : rien. */
.variants-row-container:not(:empty) {
  margin-top: 20px;
  padding-top: 20px;
  border-top: 0.5px solid var(--border);
}
.variant-btn {
  font-size: 9.5px;
  padding: 6px 11px;
}

/* MATERIAUX — étiquettes horizontales (BOIS · GALETTE…) + panneaux dépliables */
#categories-container {
  display: flex;
  flex-direction: column;
}
#category-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 22px 0 4px;
  border-top: 0.5px solid var(--border);
}
.category-tab {
  padding: 8px 14px;
  font-family: 'Jost', sans-serif;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--fg2);
  background: transparent;
  border: 0.5px solid var(--border);
  border-radius: 3px;
  cursor: pointer;
  user-select: none;
  transition:
    background 0.15s,
    color 0.15s,
    border-color 0.15s;
}
.category-tab:hover {
  color: var(--fg);
  border-color: rgba(var(--ink), 0.28);
  background: rgba(var(--ink), 0.03);
}
.category-tab.active {
  background: var(--fg);
  color: var(--bg);
  border-color: var(--fg);
}
.category-tab.hidden {
  display: none;
}

#category-panels {
  display: flex;
  flex-direction: column;
}
.category-panel {
  display: none;
  padding: 18px 0 8px;
}
.category-panel.open {
  display: block;
  border-top: 0.5px solid var(--border);
  margin-top: 10px;
}
.category-panel-header {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  margin-bottom: 14px;
  min-height: 18px;
}
.selected-option-name {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 14px;
  font-weight: 400;
  font-style: italic;
  color: var(--fg2);
}
.swatches-row {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 6px;
  overflow: visible;
  padding: 4px;
  margin: -4px;
}
/* Sous-titre palette (ex: "Palette Intra") — affiché quand plusieurs palettes dans une zone */
.palette-group {
  margin-bottom: 14px;
}
.palette-group:last-child {
  margin-bottom: 0;
}
.palette-label {
  font-size: 7px;
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--fg3);
  margin-bottom: 8px;
  padding-bottom: 4px;
  border-bottom: 0.5px solid var(--border);
}

/* Accordéon palette — un seul ouvert à la fois par catégorie */
.palette-accordion {
  border: 0.5px solid var(--border);
  border-radius: 3px;
  margin-bottom: 6px;
  background: var(--bg2);
  position: relative;
}
.palette-accordion:last-child {
  margin-bottom: 0;
}
.palette-accordion-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  cursor: pointer;
  user-select: none;
  font-size: 9px;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--fg2);
  transition:
    background 0.15s,
    color 0.15s;
}
.palette-accordion-header:hover {
  background: rgba(var(--ink), 0.04);
  color: var(--fg);
}
.palette-accordion.open .palette-accordion-header {
  color: var(--fg);
}
.palette-accordion-arrow {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  transition: transform 0.22s ease;
  color: var(--fg3);
  display: flex;
  align-items: center;
  justify-content: center;
}
.palette-accordion.open .palette-accordion-arrow {
  transform: rotate(180deg);
}
.palette-accordion-body {
  overflow: hidden;
  max-height: 0;
  transition: max-height 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.palette-accordion.open .palette-accordion-body {
  max-height: 700px;
}
.palette-accordion-inner {
  padding: 10px 12px 14px;
  border-top: 0.5px solid var(--border);
  overflow: visible;
}
.swatch-wrap {
  position: relative;
  width: auto;
  height: auto;
  aspect-ratio: 1 / 1;
  border-radius: 6px;
}
.mat-tooltip {
  position: absolute;
  z-index: 100;
  bottom: calc(100% + 9px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--fg);
  color: var(--bg);
  padding: 5px 11px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 400;
  letter-spacing: 0.03em;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.12s;
}
.mat-tooltip::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 4px solid transparent;
  border-top-color: var(--fg);
}
.swatch-wrap:hover .mat-tooltip {
  opacity: 1;
}

.swatch-icon-btn {
  width: 100%;
  height: 100%;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  overflow: hidden;
  background: var(--bg3);
  padding: 0;
  display: block;
  transition:
    transform 0.18s cubic-bezier(0.34, 1.56, 0.64, 1),
    box-shadow 0.18s ease,
    filter 0.15s;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.07);
}
.swatch-icon-btn:hover {
  transform: scale(1.08);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  filter: brightness(0.97);
}
.swatch-icon-btn.active {
  transform: scale(1.04);
  /* anneau sombre fin collé au bouton, sans espace blanc */
  box-shadow:
    0 3px 10px rgba(0, 0, 0, 0.12),
    0 0 0 1.5px var(--fg);
}
.swatch-icon-btn img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.swatch-color-fallback {
  width: 100%;
  height: 100%;
}

/* Loupe à gauche du nom du matériau sélectionné */
.cat-loupe-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  background: none;
  border: 0.5px solid var(--border);
  border-radius: 50%;
  cursor: pointer;
  color: var(--fg3);
  padding: 0;
  flex-shrink: 0;
  transition:
    color 0.15s,
    border-color 0.15s,
    background 0.15s;
}
.cat-loupe-btn:hover {
  color: var(--fg);
  border-color: var(--fg);
  background: rgba(var(--ink), 0.05);
}
.cat-loupe-btn svg {
  display: block;
}

/* Photo popup — carte flottante qui glisse DERRIÈRE le panneau droit */
#mat-photo-popup {
  position: fixed;
  z-index: 1; /* derrière #details-panel (z-index:2) */
  top: calc(var(--header-h) + 16px);
  right: calc(var(--panel-w) + 12px);
  width: 340px;
  max-height: calc(100vh - var(--header-h) - 32px);
  background: var(--bg2);
  border-radius: 8px;
  border: 0.5px solid var(--border);
  box-shadow: -4px 8px 28px rgba(0, 0, 0, 0.1);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  /* Caché à droite, derrière le panneau */
  transform: translateX(calc(100% + var(--panel-w) + 20px));
  transition: transform 0.38s cubic-bezier(0.22, 1, 0.36, 1);
  pointer-events: none;
  will-change: transform;
}
#mat-photo-popup.open {
  transform: translateX(0);
  pointer-events: all;
}
#mat-photo-header {
  padding: 12px 14px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 0.5px solid var(--border);
  flex-shrink: 0;
}
#mat-photo-name {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 15px;
  font-weight: 400;
  letter-spacing: 0.01em;
}
#mat-photo-close {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: rgba(var(--ink), 0.06);
  border: none;
  cursor: pointer;
  color: var(--fg3);
  font-size: 14px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  transition:
    background 0.15s,
    color 0.15s;
}
#mat-photo-close:hover {
  background: rgba(var(--ink), 0.12);
  color: var(--fg);
}
#mat-photo-img {
  width: 100%;
  aspect-ratio: 1/1;
  object-fit: cover;
  display: block;
  background: var(--bg3);
}

::-webkit-scrollbar {
  width: 0;
}

/* ════════════════════════════════════════════════════════════════════════
   RESPONSIVE — MOBILE & TABLETTE  (≤ 900px)
   Le layout desktop 3 colonnes (liste · viewer · panneau) est remplacé par :
     · viewer 3D plein écran
     · liste produits en tiroir latéral (off-canvas) ouvert par le bouton ☰
     · panneau produit en feuille basse (bottom sheet) repliable
   Tout est confiné dans les media queries — le rendu desktop reste identique.
   ════════════════════════════════════════════════════════════════════════ */

/* Éléments mobile-only : masqués par défaut (desktop) */
#mobile-menu-btn,
#mobile-cart-btn,
#sidebar-overlay,
#sidebar-close,
#sheet-peek,
#mat-photo-overlay,
#scroll-fade {
  display: none;
}

@media (max-width: 900px) {
  :root {
    --header-h: 54px;
  }
  html,
  body {
    height: 100%;
  }
  /* Hauteur dynamique : évite que la barre d'URL mobile rogne le bas */
  @supports (height: 100dvh) {
    body {
      height: 100dvh;
    }
  }

  /* ── Header compact : [☰]  logo centré  [panier] ───────────────────── */
  #header {
    height: 54px;
    padding: 0 10px;
    position: relative;
  }
  #header-right {
    display: none;
  }
  #brand-logo {
    height: 32px;
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
  }
  #mobile-menu-btn,
  #mobile-cart-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    padding: 0;
    background: transparent;
    border: none;
    cursor: pointer;
    color: var(--fg);
    border-radius: 6px;
    position: relative;
    z-index: 2;
    -webkit-tap-highlight-color: transparent;
  }
  #mobile-menu-btn:active,
  #mobile-cart-btn:active {
    background: rgba(var(--ink), 0.06);
  }
  #mobile-menu-btn svg,
  #mobile-cart-btn svg {
    width: 21px;
    height: 21px;
    display: block;
  }
  #mobile-cart-count {
    position: absolute;
    top: 2px;
    right: 1px;
    min-width: 15px;
    height: 15px;
    padding: 0 4px;
    background: var(--accent);
    color: #fff;
    border-radius: 8px;
    font-size: 9px;
    font-weight: 500;
    line-height: 15px;
    text-align: center;
    letter-spacing: 0;
    display: none;
  }
  #mobile-cart-count.show {
    display: block;
  }

  /* Bascule thème : à droite, à côté du panier ([☰] … [thème][panier]) */
  #header-actions {
    gap: 2px;
  }
  #theme-toggle {
    width: 38px;
    height: 38px;
    border: none;
    border-radius: 6px;
    color: var(--fg);
  }
  #theme-toggle:active {
    background: rgba(var(--ink), 0.06);
  }
  #theme-toggle svg {
    width: 20px;
    height: 20px;
  }

  /* ── Layout : le viewer occupe toute la zone sous le header ─────────── */
  #layout {
    display: block;
    position: relative;
  }
  /* La position `bottom` est pilotée en JS quand la feuille se déplie : le
     canvas se rétrécit pour rester visible AU-DESSUS de la feuille. */
  #viewer-container {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    will-change: bottom;
  }
  #viewer-hint {
    display: none;
  }

  /* ── Tiroir liste produits (off-canvas gauche) ─────────────────────── */
  #sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(85vw, 330px);
    z-index: 9995;
    padding-top: 18px;
    transform: translateX(-100%);
    transition: transform 0.32s cubic-bezier(0.22, 1, 0.36, 1);
    box-shadow: 8px 0 32px rgba(0, 0, 0, 0.18);
    border-right: 0.5px solid var(--border);
  }
  #sidebar.open {
    transform: translateX(0);
  }
  #sidebar-overlay {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(15, 15, 12, 0.42);
    backdrop-filter: blur(2px);
    z-index: 9994;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.32s ease;
  }
  #sidebar-overlay.open {
    opacity: 1;
    pointer-events: auto;
  }
  #sidebar-close {
    display: flex;
    align-items: center;
    justify-content: center;
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 3;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--bg3);
    border: none;
    cursor: pointer;
    color: var(--fg2);
    font-size: 18px;
    line-height: 1;
    -webkit-tap-highlight-color: transparent;
  }
  #sidebar-close:active {
    background: rgba(var(--ink), 0.12);
  }
  #sidebar-label {
    padding-right: 50px;
  }
  .product-btn {
    padding: 13px 22px;
  }

  /* ── Bottom sheet : panneau produit repliable ──────────────────────── */
  #details-panel {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    top: auto;
    width: auto;
    max-height: 92dvh;
    border-left: none;
    border-top: 0.5px solid var(--border);
    border-radius: 18px 18px 0 0;
    box-shadow: 0 -10px 32px rgba(0, 0, 0, 0.16);
    z-index: 9000;
    overflow: hidden;
  }
  /* Barre "peek" toujours visible : poignée + nom + chevron */
  #sheet-peek {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    padding: 0 20px 4px;
    cursor: pointer;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    flex-shrink: 0;
  }
  #sheet-handle {
    width: 38px;
    height: 4px;
    border-radius: 4px;
    background: rgba(var(--ink), 0.16);
    margin: 9px auto 11px;
  }
  #sheet-peek-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding-bottom: 6px;
  }
  #sheet-peek-name {
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-size: 23px;
    font-weight: 400;
    line-height: 1.05;
    color: var(--fg);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    min-width: 0;
  }
  #sheet-chevron {
    flex-shrink: 0;
    width: 22px;
    height: 22px;
    color: var(--fg3);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  }
  #details-panel.expanded #sheet-chevron {
    transform: rotate(180deg);
  }

  /* Zone dépliable : description + modules + matériaux */
  #panel-scroll {
    flex: 0 1 auto;
    max-height: 0;
    padding-top: 0;
    padding-bottom: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    transition:
      max-height 0.36s cubic-bezier(0.4, 0, 0.2, 1),
      padding 0.36s cubic-bezier(0.4, 0, 0.2, 1);
  }
  /* Déplié : feuille volontairement COMPACTE pour garder le modèle 3D grand.
     On n'affiche qu'une partie des options ; un dégradé + chevron (cf. plus bas)
     indiquent qu'il faut faire défiler pour voir le reste. Le modèle se recadre
     tout seul dans la grande bande restante au-dessus (cf. syncViewerToSheet). */
  #details-panel.expanded {
    max-height: 92dvh;
  }
  #details-panel.expanded #panel-scroll {
    max-height: 34dvh;
    padding: 8px 22px 18px;
  }

  /* ── Indicateur de défilement ────────────────────────────────────────
     Quand la zone dépliée déborde (ex. options de matériaux sous la
     description), un dégradé + un chevron qui « respire » signalent qu'il
     reste du contenu à faire défiler. Masqué dès qu'on atteint le bas
     (classe .more-below pilotée en JS). */
  #price-block {
    position: relative;
  }
  #scroll-fade {
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    transform: translateY(-100%);
    height: 54px;
    pointer-events: none;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding-bottom: 4px;
    background: linear-gradient(to top, var(--bg) 18%, rgba(var(--bg-rgb), 0));
    opacity: 0;
    transition: opacity 0.25s ease;
  }
  #details-panel.expanded.more-below #scroll-fade {
    opacity: 1;
  }
  #scroll-fade svg {
    width: 26px;
    height: 26px;
    color: var(--fg2);
    animation: scrollNudge 1.6s ease-in-out infinite;
  }
  @keyframes scrollNudge {
    0%,
    100% {
      transform: translateY(0);
      opacity: 0.55;
    }
    50% {
      transform: translateY(3px);
      opacity: 1;
    }
  }
  @media (prefers-reduced-motion: reduce) {
    #scroll-fade svg {
      animation: none;
    }
  }
  /* Le nom est déjà affiché dans la barre "peek" — éviter le doublon et
     gagner de la hauteur utile dans la zone dépliable. */
  #details-panel #product-brand-label,
  #details-panel #product-name {
    display: none;
  }
  #product-header {
    margin-bottom: 18px;
  }
  #product-subtitle {
    margin-top: 2px;
  }

  /* Bloc prix + livraison + CTA : visible en replié comme en déplié.
     Le résumé "Configuration actuelle" est masqué sur mobile : il fait
     doublon avec les matières sélectionnées (visibles dans la liste) et
     réduirait la zone laissée au modèle 3D. */
  #price-block {
    padding: 14px 22px calc(18px + env(safe-area-inset-bottom));
  }
  #config-summary {
    display: none !important;
  }

  /* ── Panier : plein écran ──────────────────────────────────────────── */
  #cart-panel {
    width: 100vw;
    max-width: 100vw;
    box-shadow: none;
  }
  #cart-footer {
    padding-bottom: calc(24px + env(safe-area-inset-bottom));
  }

  /* ── Photo matériau : modale centrée + fond ────────────────────────── */
  #mat-photo-overlay {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(15, 15, 12, 0.5);
    backdrop-filter: blur(2px);
    z-index: 9995;
    opacity: 0;
    visibility: hidden;
    transition:
      opacity 0.26s ease,
      visibility 0.26s ease;
  }
  #mat-photo-overlay.open {
    opacity: 1;
    visibility: visible;
  }
  #mat-photo-popup {
    position: fixed;
    inset: auto;
    top: 50%;
    left: 50%;
    right: auto;
    width: min(90vw, 360px);
    max-height: 82dvh;
    z-index: 9996;
    transform: translate(-50%, -50%) scale(0.96);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition:
      opacity 0.26s ease,
      transform 0.26s cubic-bezier(0.22, 1, 0.36, 1),
      visibility 0.26s ease;
  }
  #mat-photo-popup.open {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translate(-50%, -50%) scale(1);
  }

  /* Render tuner (outil dev clavier) — sans objet sur mobile */
  #render-tuner,
  #render-tuner-hint {
    display: none !important;
  }
}

/* ── Petits téléphones (≤ 430px) : densité réduite ───────────────────── */
@media (max-width: 430px) {
  #panel-scroll {
    padding-left: 18px;
    padding-right: 18px;
  }
  #details-panel.expanded #panel-scroll {
    max-height: 38dvh;
    padding: 6px 18px 16px;
  }
  #sheet-peek {
    padding: 0 18px 4px;
  }
  #price-block {
    padding-left: 18px;
    padding-right: 18px;
  }
  #sheet-peek-name {
    font-size: 21px;
  }
  .swatches-row {
    grid-template-columns: repeat(5, 1fr);
  }
}

/* ════════════════════════════════════════════════════════════════════════
   ACCESSIBILITÉ (Phase H, §31-39)
   ════════════════════════════════════════════════════════════════════════ */

/* Contenu réservé aux lecteurs d'écran : retiré du flux visuel mais lisible
   par les technologies d'assistance (label recherche, texte de secours canvas,
   région live). */
.sr-only {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Focus clavier visible et cohérent (§33/§34/§35/§48). N'apparaît qu'au
   clavier (:focus-visible) → aucun anneau au clic souris. */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 2px;
}
html[data-theme='dark'] :focus-visible {
  outline-color: var(--fg);
}
/* Swatches ronds : anneau collé, cohérent avec l'état actif */
.swatch-icon-btn:focus-visible {
  outline-offset: 3px;
}

/* §32 — Le déclencheur du bottom sheet est désormais un vrai <button> :
   on neutralise l'apparence native pour conserver l'aspect d'origine. */
#sheet-peek {
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
  border: none;
  margin: 0;
  font-family: inherit;
  color: inherit;
  text-align: left;
  width: 100%;
}
#sheet-handle {
  display: block;
}

/* §39.2 — Composant d'erreur structuré dans le viewer */
#viewer-error {
  z-index: 7;
  background: rgba(var(--bg-rgb), 0.82);
  backdrop-filter: blur(3px);
  pointer-events: none;
}
#viewer-error.visible {
  pointer-events: auto;
}
#viewer-error-card {
  max-width: 340px;
  margin: 0 24px;
  padding: 26px 26px 22px;
  background: var(--bg2);
  border: 0.5px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.14);
  text-align: center;
}
.viewer-error-title {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 22px;
  font-weight: 400;
  color: var(--fg);
  margin-bottom: 10px;
}
.viewer-error-msg {
  font-size: 12px;
  font-weight: 300;
  color: var(--fg2);
  line-height: 1.7;
}
.viewer-error-code {
  margin-top: 10px;
  font-size: 10px;
  letter-spacing: 0.06em;
  color: var(--fg3);
  font-family: ui-monospace, 'SFMono-Regular', Menlo, monospace;
}
#viewer-error-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-top: 20px;
}
.viewer-error-btn {
  padding: 9px 16px;
  font-family: 'Jost', sans-serif;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
  border-radius: 3px;
  border: 0.5px solid var(--fg);
  background: var(--fg);
  color: var(--bg);
  transition: opacity 0.15s;
}
.viewer-error-btn:hover {
  opacity: 0.78;
}
.viewer-error-btn.secondary {
  background: transparent;
  color: var(--fg2);
  border-color: var(--border);
}
.viewer-error-btn.secondary:hover {
  color: var(--fg);
  border-color: var(--fg);
  opacity: 1;
}

/* §39.1 — Toast / confirmation (remplace les alert()) */
#app-toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translate(-50%, 12px);
  z-index: 10000;
  max-width: min(90vw, 420px);
  padding: 12px 18px;
  border-radius: 8px;
  background: var(--fg);
  color: var(--bg);
  font-family: 'Jost', sans-serif;
  font-size: 12px;
  letter-spacing: 0.02em;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.22);
  opacity: 0;
  pointer-events: none;
  transition:
    opacity 0.22s ease,
    transform 0.22s ease;
}
#app-toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}
#app-toast[data-tone='error'] {
  background: #b03a2e;
  color: #fff;
}

/* ════════════════════════════════════════════════════════════════════════
   §37 — RÉDUCTION DES ANIMATIONS (prefers-reduced-motion)
   Rend instantanés crossfades CSS, transitions de panneaux, bottom sheet,
   smooth-scroll et indicateurs animés, SANS retirer d'information (l'état
   final identique reste affiché). Les animations 3D (crossfade WebGL,
   suivi du viewer) sont traitées côté JS via utils/motion.js.
   ════════════════════════════════════════════════════════════════════════ */
@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;
  }
}
