/* =============================================================================
 * Pergolia - Habillage graphique (VERSION DE DEMONSTRATION)
 * -----------------------------------------------------------------------------
 * Reprend la maquette Docs-travail/ChartePergolia_2.png. Cette feuille n'habille
 * QUE la coquille neuve (bandeau, cartes, outils 3D, prix, pied). Le markup
 * d'origine reste en place, masque par .pg-legacy : c'est lui qui porte les 196
 * champs, leurs valeurs et leurs ecouteurs. Voir js/Pergolia_ui.js.
 *
 * Palette relevee au pixel sur la maquette. Le bronze #845C38 est l'accent
 * unique : boutons, bascules, curseurs, pilule 3D.
 * ============================================================================= */

/* ---------------------------------------------------------------- 1. Police */
/* Poppins, sous-ensemble latin (accents francais inclus), servie en local :
   la demo doit s'ouvrir chez un prospect sans connexion. 31 Ko au total. */
@font-face {
  font-family: "Poppins";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("../fonts/poppins-latin-400.woff2") format("woff2");
}
@font-face {
  font-family: "Poppins";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("../fonts/poppins-latin-500.woff2") format("woff2");
}
@font-face {
  font-family: "Poppins";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("../fonts/poppins-latin-600.woff2") format("woff2");
}
@font-face {
  font-family: "Poppins";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("../fonts/poppins-latin-700.woff2") format("woff2");
}

/* ---------------------------------------------------------------- 2. Jetons */
:root {
  --pg-font: "Poppins", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;

  --pg-accent:        #845c38;
  --pg-accent-hover:  #6e4c2e;
  --pg-accent-soft:   #fbf7f4;
  --pg-accent-line:   #d8c3ab;

  --pg-bg:      #f5f5f6;
  --pg-surface: #ffffff;
  --pg-raised:  #fafafa;
  --pg-border:  #e9e9ea;
  --pg-border-strong: #dcdcde;
  --pg-track:   #e2e2e4;

  --pg-ink:       #22262a;
  --pg-ink-soft:  #5c6269;
  --pg-ink-muted: #8a9097;

  --pg-header-h: 76px;
  --pg-footer-h: 46px;
  --pg-panel-w:  clamp(340px, 30vw, 500px);
  --pg-gap:      12px;
  /* Bord gauche de la scene 3D : le canvas est cale dessus pour que la pergola
     soit centree dans la zone visible, et pas sous le panneau. */
  --pg-stage-left: calc(var(--pg-panel-w) + 2 * var(--pg-gap));

  --pg-radius:    14px;
  --pg-radius-sm: 10px;
  --pg-radius-xs: 8px;

  --pg-shadow:    0 1px 2px rgba(24, 28, 33, .04), 0 6px 18px rgba(24, 28, 33, .05);
  --pg-shadow-sm: 0 1px 2px rgba(24, 28, 33, .05);
  --pg-shadow-lg: 0 2px 6px rgba(24, 28, 33, .06), 0 18px 46px rgba(24, 28, 33, .13);
}

/* La maquette n'existe qu'en clair. Le theme sombre transpose la meme grammaire :
   memes rayons, memes ombres, bronze eclairci pour rester lisible sur #182433. */
[data-bs-theme="dark"] {
  --pg-accent:        #c09a6c;
  --pg-accent-hover:  #d0ab7d;
  --pg-accent-soft:   #2b2318;
  --pg-accent-line:   #4a3c2b;

  --pg-bg:      #0f1720;
  --pg-surface: #182433;
  --pg-raised:  #1e2c3d;
  --pg-border:  #27374a;
  --pg-border-strong: #33465c;
  --pg-track:   #2c3d51;

  --pg-ink:       #e9edf2;
  --pg-ink-soft:  #b3bfcc;
  --pg-ink-muted: #8695a5;

  --pg-shadow:    0 1px 2px rgba(0, 0, 0, .3), 0 6px 18px rgba(0, 0, 0, .3);
  --pg-shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
  --pg-shadow-lg: 0 2px 6px rgba(0, 0, 0, .34), 0 18px 46px rgba(0, 0, 0, .44);
}

/* ---------------------------------------------------------------- 3. Socle */
body {
  font-family: var(--pg-font);
  color: var(--pg-ink);
  background: var(--pg-bg) !important;
  -webkit-font-smoothing: antialiased;
}

/* L'ancien markup reste dans le DOM : il porte les champs, les valeurs et les
   ecouteurs. Plusieurs fonctions (lightDarkMode, initConfig, les listeners de
   Pergolia_forms.js) ecrivent dedans par id et planteraient s'il disparaissait. */
.pg-legacy {
  display: none !important;
}

/* Repli purement visuel. On n'utilise PAS l'attribut hidden : la fonction
   isBusinessHiddenByKey() de Pergolia_saveLoad.js le lit pour decider qu'un
   champ est masque par les regles metier, et l'exclurait alors de la
   configuration enregistree. Une classe passe inapercue, c'est ce qu'on veut. */
.pg-off {
  display: none;
}

/* ------------------------------------------------------------- 4. Bandeau */
#pgHeader {
  position: fixed;
  inset: 0 0 auto 0;
  height: var(--pg-header-h);
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 22px;
  padding: 0 26px;
  background: var(--pg-surface);
  border-bottom: 1px solid var(--pg-border);
}

#pgHeader .pg-brand {
  display: flex;
  align-items: center;
  flex: 0 0 auto;
}

#pgHeader .pg-brand img {
  height: 48px;
  width: auto;
  display: block;
}

.pg-head-rule {
  width: 1px;
  height: 42px;
  background: var(--pg-border-strong);
  flex: 0 0 auto;
}

.pg-head-titles {
  flex: 1 1 auto;
  min-width: 0;
}

.pg-head-titles h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -.2px;
  color: var(--pg-ink);
  white-space: nowrap;
}

.pg-head-titles p {
  margin: 1px 0 0;
  font-size: 13.5px;
  font-weight: 400;
  color: var(--pg-ink-muted);
  white-space: nowrap;
}

.pg-head-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 0 0 auto;
}

/* Entrees decoratives : elles reproduisent la maquette mais ne pointent sur
   aucune fonctionnalite. Elles sont volontairement inertes. */
.pg-head-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  border: 0;
  border-radius: var(--pg-radius-xs);
  background: transparent;
  font-family: inherit;
  font-size: 14px;
  font-weight: 400;
  color: var(--pg-ink-soft);
  cursor: default;
  transition: background .15s ease, color .15s ease;
}

.pg-head-link svg {
  width: 19px;
  height: 19px;
  stroke-width: 1.7;
  flex: 0 0 auto;
}

.pg-head-link:hover {
  background: var(--pg-raised);
  color: var(--pg-ink);
}

.pg-head-user {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 5px 8px 5px 5px;
  border-radius: 999px;
  color: var(--pg-ink);
  font-size: 14px;
  font-weight: 500;
  cursor: default;
}

.pg-head-user .pg-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--pg-ink);
  color: var(--pg-surface);
  display: grid;
  place-items: center;
  flex: 0 0 auto;
}

.pg-head-user .pg-avatar svg {
  width: 19px;
  height: 19px;
}

/* -------------------------------------------------------------- 5. Corps */
#pgMain {
  position: fixed;
  inset: var(--pg-header-h) 0 var(--pg-footer-h) 0;
  z-index: 20;
  display: flex;
  pointer-events: none; /* la scene 3D dessous reste manipulable */
}

#pgMain > * {
  pointer-events: auto;
}

/* Le canvas n'est pas deplace dans le DOM : deplacer un canvas WebGL apres
   l'initialisation de Babylon est inutilement risque. On le repositionne sur la
   zone visible - c'est ce qui centre la pergola entre le panneau et le bord
   droit - et Pergolia_ui.js appelle engine.resize() quand la mise en page bouge. */
#canvasZone {
  position: fixed !important;
  inset: var(--pg-header-h) 0 var(--pg-footer-h) var(--pg-stage-left);
  width: auto !important;
  height: auto !important;
  margin: 0 !important;
  z-index: 10;
}

/* ------------------------------------------------------------- 6. Panneau */
/* Maquette 2 : plus d'etapes ni de conteneur blanc. Les cartes flottent sur le
   fond gris. */
#pgPanel {
  flex: 0 0 auto;
  width: var(--pg-panel-w);
  margin: var(--pg-gap);
  display: flex;
  flex-direction: column;
  gap: var(--pg-gap);
  overflow-y: auto;
  overflow-x: hidden;
}

#pgPanel::-webkit-scrollbar {
  width: 8px;
}

#pgPanel::-webkit-scrollbar-thumb {
  background: var(--pg-border-strong);
  border-radius: 999px;
}

#pgPanel::-webkit-scrollbar-thumb:hover {
  background: var(--pg-ink-muted);
}

/* --------------------------------------------------------------- 7. Cartes */
.pg-card {
  flex: 0 0 auto;
  border: 1px solid var(--pg-border);
  border-radius: var(--pg-radius);
  background: var(--pg-surface);
  box-shadow: var(--pg-shadow);
  overflow: hidden;
}

.pg-card-head {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 18px 10px;
  width: 100%;
  border: 0;
  background: none;
  font-family: inherit;
  text-align: left;
  color: inherit;
}

.pg-card-icon {
  width: 28px;
  height: 28px;
  flex: 0 0 auto;
  color: var(--pg-accent);
  display: grid;
  place-items: center;
}

.pg-card-icon svg {
  width: 26px;
  height: 26px;
  stroke-width: 1.5;
}

.pg-card-titles {
  flex: 1 1 auto;
  min-width: 0;
}

.pg-card-titles h2 {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -.1px;
  color: var(--pg-ink);
}

.pg-card-titles p {
  margin: 1px 0 0;
  font-size: 13px;
  font-weight: 400;
  color: var(--pg-ink-muted);
}

/* Carte Eclairage : sous-titre sur la meme ligne que le titre */
.pg-titles-inline {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
}

.pg-titles-inline p {
  margin: 0;
}

.pg-card-aside {
  flex: 0 0 auto;
  font-size: 13px;
  color: var(--pg-ink-muted);
}

.pg-card-body {
  padding: 6px 18px 18px;
}

/* Le repli des cartes n'existe qu'en mobile : le chevron reste cache au-dessus
   de 820 px (voir la section 16). */
.pg-card-chevron {
  display: none;
  flex: 0 0 auto;
  width: 20px;
  height: 20px;
  color: var(--pg-ink-muted);
  transition: transform .2s ease;
}

.pg-card.is-open .pg-card-chevron {
  transform: rotate(180deg);
}

/* ------------------------------------------------------- 8. Champs deplaces */
/* Les .mb-3 d'origine sont deplaces tels quels dans les cartes. On les rehabille
   sans toucher a leur structure : label + controle. */
#pgPanel .mb-3 {
  margin-bottom: 14px !important;
}

#pgPanel .mb-3:last-child {
  margin-bottom: 0 !important;
}

#pgPanel .form-label {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--pg-ink-soft);
}

#pgPanel .form-control,
#pgPanel .form-select {
  width: 100%;
  min-height: 42px;
  padding: 9px 12px;
  border: 1px solid var(--pg-border-strong);
  border-radius: var(--pg-radius-sm);
  background-color: var(--pg-surface);
  color: var(--pg-ink);
  font-family: inherit;
  font-size: 14.5px;
  box-shadow: none;
}

#pgPanel .form-control:focus,
#pgPanel .form-select:focus {
  border-color: var(--pg-accent);
  box-shadow: 0 0 0 3px rgba(132, 92, 56, .16);
  outline: none;
}

/* ------------------------------------------------------------ 9. Dimensions */
.pg-dims {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.pg-dim-label {
  display: block;
  margin-bottom: 7px;
  font-size: 13px;
  font-weight: 500;
  color: var(--pg-ink-soft);
}

/* Stepper : - [valeur] + , les boutons hors du cadre comme sur la maquette */
.pg-stepper {
  display: flex;
  align-items: center;
  gap: 5px;
}

.pg-stepper button {
  width: 26px;
  height: 26px;
  flex: 0 0 auto;
  border: 0;
  border-radius: 50%;
  background: none;
  color: var(--pg-ink-soft);
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background .15s ease, color .15s ease;
}

.pg-stepper button:hover {
  background: var(--pg-raised);
  color: var(--pg-ink);
}

.pg-stepper button:disabled {
  opacity: .3;
  cursor: not-allowed;
  background: none;
}

.pg-stepper input {
  flex: 1 1 auto;
  min-width: 0;
  width: 100%;
  height: 38px;
  border: 1px solid var(--pg-border-strong);
  border-radius: var(--pg-radius-xs);
  background: var(--pg-surface);
  text-align: center;
  font-family: inherit;
  font-size: 15px;
  font-weight: 500;
  color: var(--pg-ink);
  padding: 0 2px;
}

.pg-stepper input:focus {
  outline: none;
  border-color: var(--pg-accent);
  box-shadow: 0 0 0 3px rgba(132, 92, 56, .16);
}

/* Curseur : c'est le <input type="range"> d'origine, deplace ici. Il reste
   synchronise avec le champ numerique par initDimensionSliders(). */
.pg-dim-slider {
  margin-top: 14px;
}

#pgPanel .pg-dim-slider .form-range {
  display: block !important;
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  margin: 0;
  padding: 0;
  border-radius: 999px;
  background: var(--pg-track);
  cursor: pointer;
}

#pgPanel .pg-dim-slider .form-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border: 0;
  border-radius: 50%;
  background: var(--pg-accent);
  box-shadow: 0 1px 3px rgba(0, 0, 0, .25);
  cursor: pointer;
}

#pgPanel .pg-dim-slider .form-range::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border: 0;
  border-radius: 50%;
  background: var(--pg-accent);
}

#pgPanel .pg-dim-slider .form-range:focus {
  outline: none;
}

.pg-dim-bounds {
  display: flex;
  justify-content: space-between;
  margin-top: 6px;
  font-size: 11.5px;
  color: var(--pg-ink-muted);
  font-variant-numeric: tabular-nums;
}

/* ---------------------------------------------------------- 10. Tuiles store */
.pg-tiles {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
}

.pg-tile {
  border: 1px solid var(--pg-border);
  border-radius: var(--pg-radius-sm);
  background: var(--pg-surface);
  padding: 10px 4px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  cursor: pointer;
  transition: border-color .15s ease, background .15s ease;
}

.pg-tile:hover {
  border-color: var(--pg-border-strong);
}

.pg-tile.is-on {
  border-color: var(--pg-accent-line);
  background: var(--pg-accent-soft);
}

.pg-tile-art {
  width: 44px;
  height: 32px;
  color: var(--pg-ink-soft);
  flex: 0 0 auto;
}

.pg-tile.is-on .pg-tile-art {
  color: var(--pg-ink);
}

.pg-tile-label {
  font-size: 12.5px;
  font-weight: 500;
  line-height: 1.25;
  text-align: center;
  color: var(--pg-ink);
}

/* ------------------------------------------------------- 10b. Pastilles couleur */
.pg-swatch-row {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 7px 0;
}

.pg-swatch-row + .pg-swatch-row {
  border-top: 1px solid var(--pg-border);
}

.pg-swatch-label {
  flex: 0 0 auto;
  width: 132px;
  font-size: 13px;
  font-weight: 500;
  color: var(--pg-ink-soft);
}

.pg-swatches {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

/* Le liseré de selection est un box-shadow : il n'occupe pas de place et ne
   fait donc pas sauter la rangee au changement de couleur. */
.pg-swatch {
  width: 30px;
  height: 30px;
  flex: 0 0 auto;
  border: 1px solid rgba(0, 0, 0, .14);
  border-radius: 50%;
  padding: 0;
  cursor: pointer;
  transition: box-shadow .15s ease, transform .15s ease;
}

.pg-swatch:hover {
  transform: scale(1.08);
}

.pg-swatch.is-on {
  box-shadow: 0 0 0 2px var(--pg-surface), 0 0 0 4px var(--pg-accent);
}

/* ------------------------------------------------------------ 11. Bascules */
.pg-switch {
  width: 42px;
  height: 23px;
  flex: 0 0 auto;
  border: 0;
  padding: 0;
  border-radius: 999px;
  background: var(--pg-track);
  position: relative;
  cursor: pointer;
  transition: background .18s ease;
}

.pg-switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .22);
  transition: transform .18s ease;
}

.pg-switch.is-on {
  background: var(--pg-accent);
}

.pg-switch.is-on::after {
  transform: translateX(19px);
}

.pg-switch-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.pg-switch-row .pg-switch-label {
  font-size: 14px;
  font-weight: 500;
  color: var(--pg-ink);
}

/* Carte Eclairage : la bascule a gauche, le nombre de spots a droite */
.pg-lighting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.pg-spot-count {
  display: flex;
  align-items: center;
  gap: 10px;
}

.pg-spot-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--pg-ink-soft);
  white-space: nowrap;
}

.pg-spot-count .pg-stepper {
  width: 112px;
}

.pg-spot-count .pg-stepper input {
  height: 34px;
  font-size: 14px;
}

/* Sans eclairage, il n'y a rien a compter. */
.pg-spot-count.is-off {
  opacity: .45;
  pointer-events: none;
}

/* Carte Accessoires : deux bascules cote a cote, separees d'un filet */
.pg-duo {
  display: grid;
  grid-template-columns: 1fr 1px 1fr;
  align-items: center;
  gap: 16px;
}

.pg-duo-rule {
  align-self: stretch;
  background: var(--pg-border);
}

/* ------------------------------------------------------- 12. Scene et outils */
#pgStage {
  flex: 1 1 auto;
  min-width: 0;
  position: relative;
  pointer-events: none !important;
}

#pgStage > * {
  pointer-events: auto;
}

#pgViewTools {
  position: absolute;
  top: 16px;
  right: 16px;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px;
  background: var(--pg-surface);
  border: 1px solid var(--pg-border);
  border-radius: var(--pg-radius-sm);
  box-shadow: var(--pg-shadow-sm);
}

.pg-toolbtn {
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: var(--pg-radius-xs);
  background: none;
  color: var(--pg-ink-soft);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background .15s ease, color .15s ease;
}

.pg-toolbtn svg {
  width: 20px;
  height: 20px;
}

.pg-toolbtn:hover {
  background: var(--pg-raised);
  color: var(--pg-ink);
}

/* La bascule de theme reprend l'element #switchTheme d'origine, deplace ici :
   ses ecouteurs voyagent avec lui. On neutralise son positionnement en ligne. */
#pgViewTools #switchTheme {
  position: static !important;
  width: 38px !important;
  height: 38px !important;
  border-radius: var(--pg-radius-xs);
  background: transparent !important;
  display: grid;
  place-items: center;
  color: var(--pg-ink-soft);
}

#pgViewTools #switchTheme:hover {
  background: var(--pg-raised) !important;
  color: var(--pg-ink);
}

#pgViewTools #switchTheme svg {
  margin: 0 !important;
  width: 21px;
  height: 21px;
}

/* Rappel des commandes de navigation, en bas a gauche de la scene */
#pgHint {
  position: absolute;
  left: 16px;
  bottom: 16px;
  /* Le panneau de prix occupe le coin oppose : on borne la largeur pour que les
     deux ne se recouvrent pas. En dessous, le rappel passe a la ligne. */
  max-width: calc(100% - 524px);
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 9px;
  padding: 9px 16px;
  border-radius: 999px;
  background: var(--pg-surface);
  border: 1px solid var(--pg-border);
  box-shadow: var(--pg-shadow-sm);
  font-size: 12.5px;
  color: var(--pg-ink-soft);
  pointer-events: none !important;
}

.pg-hint-item {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  white-space: nowrap;
}

#pgHint svg {
  width: 17px;
  height: 17px;
  color: var(--pg-ink-muted);
  flex: 0 0 auto;
}

#pgHint .pg-hint-sep {
  width: 1px;
  height: 15px;
  background: var(--pg-border-strong);
}

/* ----------------------------------------------------------- 13. Pied de page */
#pgFooter {
  position: fixed;
  inset: auto 0 0 0;
  height: var(--pg-footer-h);
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 0 26px;
  background: var(--pg-surface);
  border-top: 1px solid var(--pg-border);
  font-size: 12.5px;
  color: var(--pg-ink-muted);
}

.pg-foot-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.pg-foot-leaf {
  width: 17px;
  height: 17px;
  color: var(--pg-accent);
  flex: 0 0 auto;
}

.pg-foot-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.pg-foot-brand {
  font-weight: 600;
  letter-spacing: .04em;
  color: var(--pg-ink-soft);
}

.pg-foot-sep {
  color: var(--pg-border-strong);
}

/* -------------------------------------------------------- 14. Panneau de prix */
#pgPriceBox {
  position: absolute !important;
  right: 16px;
  bottom: 16px;
  left: auto !important;
  top: auto !important;
  width: min(500px, calc(100% - 32px));
  background: var(--pg-surface);
  border: 1px solid var(--pg-border);
  border-radius: var(--pg-radius);
  box-shadow: var(--pg-shadow-lg);
  overflow: hidden;
  font-family: var(--pg-font);
  color: var(--pg-ink);
}

#pgPriceHeader {
  display: flex;
  align-items: center;
  gap: 22px;
  padding: 18px 20px;
  background: none !important;
  cursor: pointer;
}

#pgPriceHeader:hover {
  background: none !important;
}

.pg-price-head-left {
  flex: 1 1 auto;
  min-width: 0;
}

.pg-price-caption {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13.5px;
  font-weight: 400;
  color: var(--pg-ink-soft);
}

.pg-price-caption svg {
  color: var(--pg-ink-muted);
  flex: 0 0 auto;
}

.pg-price-total {
  display: block;
  margin-top: 3px;
  font-size: 34px;
  font-weight: 600;
  letter-spacing: -.7px;
  line-height: 1.12;
  color: var(--pg-ink);
}

.pg-price-ht {
  display: block;
  margin-top: 1px;
  font-size: 12.5px;
  color: var(--pg-ink-muted);
}

.pg-price-actions {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 224px;
}

.pg-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  width: 100%;
  padding: 12px 16px;
  border: 1px solid transparent;
  border-radius: var(--pg-radius-sm);
  font-family: inherit;
  font-size: 14.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease, color .15s ease;
}

.pg-btn svg {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
}

.pg-btn-primary {
  background: var(--pg-accent);
  color: #fff;
}

[data-bs-theme="dark"] .pg-btn-primary {
  color: #1a1206;
}

.pg-btn-primary:hover {
  background: var(--pg-accent-hover);
}

.pg-btn-ghost {
  background: var(--pg-surface);
  border-color: var(--pg-border-strong);
  color: var(--pg-ink-soft);
  font-weight: 500;
}

.pg-btn-ghost:hover {
  background: var(--pg-raised);
  color: var(--pg-ink);
}

/* Boutons decoratifs : ils gardent l'aspect de la maquette mais ne font rien.
   On ne les passe pas en disabled, sinon Chrome n'affiche plus l'infobulle qui
   explique justement pourquoi ils ne font rien. */
.pg-btn[data-pg-inert] {
  cursor: default;
}

#pgPriceChevron {
  flex: 0 0 auto;
  color: var(--pg-ink-muted);
  transition: transform .2s ease;
}

#pgPriceBody {
  border-top: 1px solid var(--pg-border);
  padding: 14px 20px 16px;
  background: none !important;
  max-height: 42vh;
  overflow-y: auto;
  font-size: 13.5px;
}

.pg-price-legal {
  margin: 12px 0 0;
  font-size: 11.5px;
  line-height: 1.45;
  color: var(--pg-ink-muted);
}

/* Detail du devis, rendu par Pergolia_pricing.js sous forme de .pg-price-row */
.pg-price-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
  padding: 8px 0;
  border-top: 1px solid var(--pg-border);
}

.pg-price-row:first-child {
  border-top: 0;
}

.pg-price-sep {
  margin-top: 6px;
  border-top: 2px solid var(--pg-border-strong);
}

.pg-price-label {
  min-width: 0;
  color: var(--pg-ink-soft);
}

.pg-price-label em {
  font-style: normal;
  font-size: 11.5px;
  color: var(--pg-ink-muted);
  white-space: nowrap;
  margin-left: 6px;
}

.pg-price-value {
  flex: 0 0 auto;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  color: var(--pg-ink);
  white-space: nowrap;
}

/* --------------------------------------------------- 14b. Modale d'explication */
.pg-modal {
  position: fixed;
  inset: 0;
  z-index: 1060; /* au-dessus du voile de chargement (1048) */
  display: grid;
  place-items: center;
  padding: 20px;
}

/* .pg-off est declare plus haut avec la meme specificite : sans cette regle,
   c'est display:grid qui l'emporte et la modale reste affichee en permanence. */
.pg-modal.pg-off {
  display: none;
}

.pg-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(22, 26, 30, .42);
  backdrop-filter: blur(3px);
}

.pg-modal-card {
  position: relative;
  width: min(400px, 100%);
  padding: 28px 26px 22px;
  border-radius: var(--pg-radius);
  background: var(--pg-surface);
  box-shadow: var(--pg-shadow-lg);
  text-align: center;
  animation: pg-modal-in .18s cubic-bezier(.2, .8, .2, 1) both;
}

@media (prefers-reduced-motion: reduce) {
  .pg-modal-card { animation: none; }
}

@keyframes pg-modal-in {
  from { opacity: 0; transform: translateY(8px) scale(.98); }
  to   { opacity: 1; transform: none; }
}

.pg-modal-icon {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  margin: 0 auto 14px;
  border-radius: 50%;
  background: var(--pg-accent-soft);
  color: var(--pg-accent);
}

[data-bs-theme="dark"] .pg-modal-icon {
  background: var(--pg-accent-soft);
}

.pg-modal-icon svg {
  width: 26px;
  height: 26px;
}

.pg-modal-card h2 {
  margin: 0 0 8px;
  font-size: 17.5px;
  font-weight: 600;
  color: var(--pg-ink);
}

.pg-modal-card p {
  margin: 0 0 20px;
  font-size: 14px;
  line-height: 1.5;
  color: var(--pg-ink-soft);
}

.pg-modal-card .pg-btn {
  width: auto;
  min-width: 140px;
  margin: 0 auto;
}

/* ----------------------------------------------------------- 15. Chargement */
.app-veil {
  background: var(--pg-bg) !important;
}

.loader-logo {
  width: 260px !important;
}

.loader-progress-bar {
  background: var(--pg-accent) !important;
}

/* ---------------------------------------------------- 16. Mobile et tablette */
/* Reprend Docs-travail/ChartePergolia_3_Mobile.png : la scene passe en haut, les
   cartes deviennent une feuille qui remonte par-dessus, le prix se cale en barre
   basse. Rien n'est reconstruit - seules les variables de mise en page changent,
   et le canvas suit parce qu'il est positionne par elles. */
@media (max-width: 820px) {
  :root {
    --pg-header-h: 58px;
    --pg-footer-h: 0px;
    --pg-price-h:  122px;
    --pg-stage-h:  42vh;
    --pg-gap:      10px;
  }

  /* --- bandeau : logo et icones seulement --- */
  #pgHeader {
    gap: 12px;
    padding: 0 14px;
  }

  #pgHeader .pg-brand img {
    height: 34px;
  }

  #pgHeader .pg-head-rule,
  #pgHeader .pg-head-user {
    display: none;
  }

  /* Le titre quitte le bandeau et se pose sur la scene, comme sur la maquette.
     Il reste le meme element : pas de duplication de contenu. */
  .pg-head-titles {
    position: fixed;
    top: calc(var(--pg-header-h) + 12px);
    left: 16px;
    z-index: 25;
    pointer-events: none;
  }

  .pg-head-titles h1 {
    font-size: 21px;
  }

  .pg-head-titles p {
    display: block;
    font-size: 13px;
    color: var(--pg-ink-soft);
  }

  .pg-head-link {
    padding: 8px;
  }

  .pg-head-link svg {
    width: 21px;
    height: 21px;
  }

  /* --- corps : scene en haut, feuille de cartes en dessous --- */
  #pgMain {
    inset: var(--pg-header-h) 0 var(--pg-price-h) 0;
    flex-direction: column;
  }

  /* La regle de bureau pose height: auto !important : il faut le meme poids
     ici, sinon le canvas ne prend pas la hauteur de la scene. */
  #canvasZone {
    inset: var(--pg-header-h) 0 auto 0;
    height: var(--pg-stage-h) !important;
  }

  /* Dans le DOM le panneau precede la scene (mise en page de bureau : colonne
     de gauche puis colonne de droite). En colonne, il faut donc remonter la
     scene explicitement, sinon les cartes se posent sur le canvas. */
  #pgStage {
    order: -1;
    flex: 0 0 var(--pg-stage-h);
    height: var(--pg-stage-h);
  }

  #pgPanel {
    flex: 1 1 auto;
    width: auto;
    margin: 0;
    padding: 16px 12px 12px;
    gap: 10px;
    background: var(--pg-surface);
    border-radius: 18px 18px 0 0;
    box-shadow: 0 -4px 18px rgba(24, 28, 33, .10);
    position: relative;
  }

  [data-bs-theme="dark"] #pgPanel {
    box-shadow: 0 -4px 18px rgba(0, 0, 0, .4);
  }

  /* Poignee de la feuille */
  #pgPanel::before {
    content: "";
    position: sticky;
    top: 0;
    align-self: center;
    width: 46px;
    height: 4px;
    margin-bottom: 4px;
    border-radius: 999px;
    background: var(--pg-border-strong);
    flex: 0 0 auto;
  }

  #pgFooter {
    display: none;
  }

  /* --- outils de vue et rappel --- */
  #pgViewTools {
    top: 12px;
    right: 12px;
    padding: 4px;
  }

  .pg-toolbtn,
  #pgViewTools #switchTheme {
    width: 34px !important;
    height: 34px !important;
  }

  /* La maquette ne garde qu'un rappel : les autres n'ont pas de sens au doigt. */
  #pgHint {
    left: 12px;
    bottom: 12px;
    max-width: none;
    padding: 8px 14px;
  }

  #pgHint .pg-hint-sep,
  #pgHint .pg-hint-item:not(:first-child) {
    display: none;
  }

  /* --- cartes --- */
  .pg-card-head {
    padding: 14px 14px 8px;
    cursor: pointer;
  }

  .pg-card-body {
    padding: 4px 14px 14px;
  }

  .pg-card-chevron {
    display: block;
  }

  /* --- dimensions --- */
  .pg-dims {
    gap: 10px;
  }

  .pg-stepper button {
    width: 24px;
    height: 24px;
  }

  .pg-stepper input {
    height: 36px;
    font-size: 14px;
  }

  /* --- tuiles : defilement horizontal plutot que cinq colonnes ecrasees --- */
  .pg-tiles {
    grid-template-columns: none;
    grid-auto-flow: column;
    grid-auto-columns: 104px;
    overflow-x: auto;
    scroll-snap-type: x proximity;
    padding-bottom: 4px;
  }

  .pg-tile {
    scroll-snap-align: start;
  }

  .pg-tiles::-webkit-scrollbar {
    height: 4px;
  }

  .pg-tiles::-webkit-scrollbar-thumb {
    background: var(--pg-border-strong);
    border-radius: 999px;
  }

  /* --- pastilles --- */
  .pg-swatch-label {
    width: 96px;
    font-size: 12.5px;
  }

  .pg-swatches {
    gap: 8px;
  }

  .pg-swatch {
    width: 28px;
    height: 28px;
  }

  /* --- prix en barre basse --- */
  #pgPriceBox {
    position: fixed !important;
    left: 0;
    right: 0;
    bottom: 0;
    width: auto;
    border-radius: 16px 16px 0 0;
    border-left: 0;
    border-right: 0;
    border-bottom: 0;
  }

  #pgPriceHeader {
    gap: 14px;
    padding: 14px 16px;
  }

  .pg-price-total {
    font-size: 28px;
  }

  .pg-price-actions {
    width: 190px;
  }

  .pg-btn {
    padding: 10px 12px;
    font-size: 13.5px;
  }

  #pgPriceBody {
    max-height: 40vh;
  }
}

/* Telephone etroit : le rappel de navigation passerait devant le prix. */
@media (max-width: 480px) {
  .pg-price-actions {
    width: 158px;
  }

  .pg-price-total {
    font-size: 25px;
  }

  .pg-head-titles h1 {
    font-size: 19px;
  }

  .pg-swatch-label {
    width: 84px;
  }
}

/* Paysage sur telephone : la scene ne doit pas manger tout l'ecran. */
@media (max-width: 940px) and (orientation: landscape) and (max-height: 560px) {
  :root {
    --pg-stage-h: 54vh;
    --pg-price-h: 104px;
  }

  .pg-head-titles {
    display: none;
  }
}

/* ------------------------------------------------------------- 17. Etroit */
@media (max-width: 1280px) {
  .pg-head-titles p {
    display: none;
  }

  .pg-price-actions {
    width: 190px;
  }
}

@media (max-width: 1080px) {
  .pg-head-link span {
    display: none;
  }

  .pg-price-total {
    font-size: 28px;
  }

  #pgHint {
    font-size: 12px;
    gap: 10px;
    padding: 8px 14px;
  }
}
