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

:root {
  --bois:        #3B2A1A;
  --bois-light:  #6B4C35;
  --or:          #C8A96E;
  --or-light:    #E8D5B0;
  --fond:        #F7F4F0;
  --blanc:       #FFFFFF;
  --gris:        #8A8A8A;
  --gris-light:  #E8E4DF;
  --texte:       #1A1A1A;
  --vert:        #2D6A4F;
  --rouge:       #C0392B;
  --radius:      10px;
  --shadow:      0 2px 12px rgba(0,0,0,0.08);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--fond);
  color: var(--texte);
  min-height: 100vh;
  font-size: 15px;
  line-height: 1.5;
}

/* ── Header ── */
header {
  background: var(--bois);
  color: var(--blanc);
  padding: 14px 32px;
  display: flex;
  align-items: center;
  gap: 16px;
}
.header-logo { height: 40px; width: auto; display: block; }
.header-divider {
  width: 1px; height: 32px;
  background: rgba(255,255,255,0.2);
}
header h1 { font-size: 17px; font-weight: 600; }
header span { font-size: 12px; color: var(--or-light); margin-top: 1px; display: block; }

/* ── Layout ── */
.layout {
  max-width: 1120px;
  margin: 0 auto;
  padding: 28px 24px;
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 24px;
  align-items: start;
}

/* ── Sections du formulaire ── */
.section {
  background: var(--blanc);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px 28px;
  margin-bottom: 16px;
}
.section-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--gris);
  margin-bottom: 18px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.section-title::before {
  content: '';
  display: inline-block;
  width: 3px; height: 13px;
  background: var(--or);
  border-radius: 2px;
}

/* ── Slider longueur ── */
.slider-row {
  display: flex;
  align-items: center;
  gap: 14px;
}
.slider-label { font-size: 13px; color: var(--gris); width: 80px; flex-shrink: 0; }
input[type=range] {
  flex: 1;
  height: 4px;
  -webkit-appearance: none;
  appearance: none;
  background: var(--gris-light);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
}
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px; height: 18px;
  background: var(--bois);
  border-radius: 50%;
  cursor: pointer;
  border: 3px solid var(--blanc);
  box-shadow: 0 0 0 2px var(--bois);
}
.slider-value {
  font-size: 20px;
  font-weight: 700;
  color: var(--bois);
  min-width: 72px;
  text-align: right;
}

/* Size badge + lien références */
.size-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
  margin-left: 94px;
}
.size-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 700;
}
.size-S  { background: #E8F5E9; color: #2E7D32; }
.size-M  { background: #FFF8E1; color: #F57F17; }
.size-L  { background: #FFF3E0; color: #E65100; }
.size-XL { background: #FCE4EC; color: #B71C1C; }
.btn-refs {
  font-size: 12px;
  color: var(--or);
  cursor: pointer;
  background: none;
  border: none;
  font-family: inherit;
  text-decoration: underline;
  padding: 0;
}
.btn-refs:hover { color: var(--bois); }

/* ── Radios groupés ── */
.radio-group {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 14px;
}
.radio-group label {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 13px;
  border: 2px solid var(--gris-light);
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.15s;
  font-weight: 500;
}
.radio-group input[type=radio] { display: none; }
.radio-group input[type=radio]:checked + label {
  border-color: var(--bois);
  background: var(--bois);
  color: var(--blanc);
}
.radio-group-label {
  font-size: 12px;
  color: var(--gris);
  margin-bottom: 2px;
  margin-top: 14px;
}

/* ── Cartes bois ── */
.bois-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 4px;
}
.bois-card {
  border: 2px solid var(--gris-light);
  border-radius: var(--radius);
  padding: 12px 14px;
  cursor: pointer;
  transition: all 0.15s;
  position: relative;
}
.bois-card:hover { border-color: var(--or); }
.bois-card.selected { border-color: var(--bois); background: #FBF8F5; }
.bois-card input[type=radio] { position: absolute; opacity: 0; width: 0; height: 0; }
.bois-card .card-tag {
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--or); margin-bottom: 5px;
}
.bois-card .card-name { font-size: 13px; font-weight: 600; color: var(--bois); margin-bottom: 3px; }
.bois-card .card-desc { font-size: 11px; color: var(--gris); line-height: 1.4; }
.bois-card .card-format { font-size: 10px; color: var(--gris); margin-top: 6px; font-family: monospace; }
.bois-card .card-prix { font-size: 12px; font-weight: 600; color: var(--bois-light); margin-top: 4px; }

/* ── Toggles ── */
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 11px 0;
  border-bottom: 1px solid var(--gris-light);
}
.toggle-row:last-child { border-bottom: none; }
.toggle-info { flex: 1; }
.toggle-info strong { font-size: 14px; font-weight: 600; display: block; }
.toggle-info small { font-size: 11px; color: var(--gris); }
.toggle {
  position: relative; width: 44px; height: 24px;
  flex-shrink: 0; margin-left: 16px;
}
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute; inset: 0;
  background: var(--gris-light);
  border-radius: 24px; cursor: pointer; transition: background 0.2s;
}
.toggle-slider::before {
  content: ''; position: absolute;
  left: 3px; top: 3px; width: 18px; height: 18px;
  background: var(--blanc); border-radius: 50%;
  transition: transform 0.2s; box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.toggle input:checked ~ .toggle-slider { background: var(--bois); }
.toggle input:checked ~ .toggle-slider::before { transform: translateX(20px); }

/* Sous-options */
.sub-options { margin-top: 8px; padding-top: 4px; display: none; }
.sub-options.visible { display: block; }

/* Champs texte libre */
.text-note {
  width: 100%;
  margin-top: 10px;
  padding: 8px 12px;
  border: 1.5px solid var(--gris-light);
  border-radius: 8px;
  font-size: 13px;
  font-family: inherit;
  color: var(--texte);
  resize: vertical;
  outline: none;
  transition: border-color 0.15s;
  background: var(--fond);
}
.text-note:focus { border-color: var(--bois); background: var(--blanc); }
.text-note::placeholder { color: #BBBBB0; }

/* Distance livraison */
.distance-row {
  display: flex; align-items: center; gap: 10px; margin-top: 10px;
}
.distance-row input[type=number] {
  width: 80px; padding: 7px 10px;
  border: 2px solid var(--gris-light); border-radius: 8px;
  font-size: 14px; font-family: inherit; outline: none;
  transition: border-color 0.15s;
}
.distance-row input[type=number]:focus { border-color: var(--bois); }
.distance-row span { font-size: 13px; color: var(--gris); }

/* ── Panneau résultat ── */
.result-panel {
  background: var(--blanc);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  position: sticky;
  top: 20px;
}
.result-title {
  font-size: 12px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.09em;
  color: var(--gris); margin-bottom: 16px;
}

/* Fourchette principale */
.result-fourchette {
  background: var(--fond); border-radius: 8px;
  padding: 14px; text-align: center; margin-bottom: 16px;
}
.fourchette-label { font-size: 10px; color: var(--gris); margin-bottom: 3px; text-transform: uppercase; letter-spacing: 0.06em; }
.fourchette-range { font-size: 21px; font-weight: 800; color: var(--bois); letter-spacing: -0.5px; }
.fourchette-estimate { font-size: 11px; color: var(--gris); margin-top: 3px; }
.fourchette-estimate strong { color: var(--bois-light); }

/* Lignes détail */
.result-lines { margin-bottom: 14px; }
.result-line {
  display: flex; justify-content: space-between; align-items: center;
  padding: 7px 0; border-bottom: 1px solid var(--gris-light); font-size: 13px;
}
.result-line:last-child { border-bottom: none; }
.result-line .line-label { color: var(--gris); }
.result-line .line-val { font-weight: 600; color: var(--texte); }
.result-line.total {
  padding-top: 11px; font-weight: 700; font-size: 14px;
  border-top: 2px solid var(--gris-light); border-bottom: none;
}
.result-line.total .line-label { color: var(--texte); }

/* Détail technique (collapsible) */
.detail-toggle {
  font-size: 11px; color: var(--or); cursor: pointer;
  background: none; border: none; font-family: inherit;
  padding: 0; margin-bottom: 12px; text-decoration: underline;
}
.detail-toggle:hover { color: var(--bois); }
.detail-block { display: none; margin-bottom: 12px; }
.detail-block.visible { display: block; }
.detail-block table {
  width: 100%; font-size: 11px; border-collapse: collapse;
}
.detail-block td {
  padding: 3px 4px; vertical-align: top;
}
.detail-block td:first-child { color: var(--gris); white-space: nowrap; padding-right: 8px; }
.detail-block td:last-child { font-weight: 500; text-align: right; }
.detail-planches {
  margin-top: 8px; padding-top: 8px;
  border-top: 1px solid var(--gris-light);
}
.planches-line {
  display: flex; justify-content: space-between;
  font-size: 11px; padding: 3px 0;
}
.planches-line .pl-label { color: var(--gris); }
.planches-line .pl-val { font-weight: 600; }
.planches-line .pl-warn { color: var(--rouge); font-size: 10px; }

/* Plan de découpe */
.decoupe-block {
  margin-top: 10px; padding-top: 10px;
  border-top: 1px solid var(--gris-light);
}
.decoupe-title {
  font-size: 10px; font-weight: 700; letter-spacing: .05em;
  text-transform: uppercase; color: var(--gris); margin-bottom: 6px;
}
.decoupe-planche {
  background: #f7f4ef; border-radius: 5px;
  padding: 6px 8px; margin-bottom: 5px;
}
.decoupe-planche-header {
  font-size: 11px; font-weight: 700; color: var(--bois);
  margin-bottom: 3px;
}
.decoupe-piece {
  font-size: 10.5px; color: var(--gris-dark);
  padding: 1px 0 1px 10px; display: flex; justify-content: space-between;
}
.decoupe-piece .dp-rot {
  color: var(--gris); font-size: 9px; margin-left: 4px;
}
.decoupe-piece .dp-dims { color: var(--gris); white-space: nowrap; margin-left: 8px; }

/* CTA */
.btn-cta {
  width: 100%; background: var(--bois); color: var(--blanc);
  border: none; border-radius: 8px; padding: 13px;
  font-size: 14px; font-weight: 600; cursor: pointer;
  font-family: inherit; transition: background 0.15s;
  display: flex; align-items: center; justify-content: center; gap: 8px;
}
.btn-cta:hover { background: var(--bois-light); }
.btn-cta.copied { background: var(--vert); }
.note-fourchette {
  font-size: 10px; color: var(--gris); text-align: center;
  margin-top: 8px; line-height: 1.4;
}
.input-custom-h {
  width: 72px; padding: 6px 10px; margin-left: 4px;
  border: 2px solid var(--gris-light); border-radius: 8px;
  font-size: 14px; font-weight: 600; font-family: inherit;
  outline: none; transition: border-color 0.15s; display: none;
}
.input-custom-h.visible { display: inline-block; }
.input-custom-h:focus { border-color: var(--bois); }
.btn-ruby {
  width: 100%; background: transparent; color: var(--bois);
  border: 1.5px solid var(--bois); border-radius: 8px; padding: 11px;
  font-size: 13px; font-weight: 600; cursor: pointer;
  font-family: inherit; transition: all 0.15s; margin-top: 8px;
  display: flex; align-items: center; justify-content: center; gap: 7px;
}
.btn-ruby:hover { background: var(--bois); color: var(--blanc); }

/* ── Modal réalisations ── */
.modal-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,0.55); z-index: 1000;
  align-items: center; justify-content: center;
  padding: 20px;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--blanc); border-radius: 14px;
  max-width: 820px; width: 100%;
  max-height: 88vh; overflow-y: auto;
  padding: 28px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.25);
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 20px;
}
.modal-header h2 { font-size: 17px; font-weight: 700; }
.modal-close {
  background: none; border: none; cursor: pointer;
  font-size: 22px; color: var(--gris); line-height: 1;
  padding: 4px 8px; border-radius: 6px;
}
.modal-close:hover { background: var(--gris-light); }
.modal-tabs {
  display: flex; gap: 6px; margin-bottom: 20px;
  border-bottom: 2px solid var(--gris-light);
  padding-bottom: 0;
}
.modal-tab {
  padding: 7px 14px; font-size: 13px; font-weight: 600;
  cursor: pointer; border: none; background: none;
  font-family: inherit; color: var(--gris);
  border-bottom: 2px solid transparent; margin-bottom: -2px;
  transition: all 0.15s;
}
.modal-tab.active { color: var(--bois); border-bottom-color: var(--bois); }
.modal-tab:hover:not(.active) { color: var(--bois-light); }
.modal-content { display: none; }
.modal-content.active { display: block; }
.refs-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}
.ref-card { border: 1px solid var(--gris-light); border-radius: 8px; overflow: hidden; }
.ref-img {
  width: 100%; aspect-ratio: 4/3; object-fit: cover;
  background: var(--fond); cursor: zoom-in;
}
.ref-info { padding: 10px 12px; }
.ref-info h4 { font-size: 12px; font-weight: 700; margin-bottom: 3px; }
.ref-info p { font-size: 11px; color: var(--gris); line-height: 1.4; }
.ref-info .ref-prix {
  font-size: 12px; font-weight: 700; color: var(--bois);
  margin-top: 5px;
}
.ref-dims {
  display: inline-block; font-size: 10px; font-family: monospace;
  background: var(--fond); padding: 2px 6px; border-radius: 4px;
  margin-top: 4px; color: var(--bois-light);
}
/* Lightbox image */
.lightbox {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,0.85); z-index: 2000;
  align-items: center; justify-content: center;
  cursor: zoom-out;
}
.lightbox.open { display: flex; }
.lightbox img { max-width: 90vw; max-height: 90vh; object-fit: contain; border-radius: 4px; }

/* ── Presets (configs standard) ── */
.presets-section {
  background: var(--blanc); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 20px 28px; margin-bottom: 16px;
}
.presets-title {
  font-size: 12px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.09em; color: var(--gris); margin-bottom: 14px;
  display: flex; align-items: center; gap: 8px;
}
.presets-title::before {
  content: ''; display: inline-block; width: 3px; height: 13px;
  background: var(--or); border-radius: 2px;
}
.preset-cards {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
}
.preset-card {
  border: 2px solid var(--gris-light); border-radius: 8px;
  padding: 12px 14px; cursor: pointer; transition: all 0.15s;
}
.preset-card:hover { border-color: var(--or); background: #FFFDF8; }
.preset-card.active { border-color: var(--bois); background: #FBF8F5; }
.preset-card-name { font-size: 13px; font-weight: 700; color: var(--bois); margin-bottom: 2px; }
.preset-card-dims { font-size: 11px; font-family: monospace; color: var(--bois-light); margin-bottom: 4px; }
.preset-card-desc { font-size: 11px; color: var(--gris); line-height: 1.4; }
.preset-card-prix { font-size: 12px; font-weight: 600; color: var(--or); margin-top: 6px; }
.preset-note { font-size: 11px; color: var(--gris); margin-top: 10px; font-style: italic; }

/* ── Quantité ── */
.qty-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 12px; background: var(--fond); border-radius: 6px;
  margin-bottom: 14px;
}
.qty-label { font-size: 13px; color: var(--gris); }
.qty-controls { display: flex; align-items: center; gap: 0; }
.qty-btn {
  width: 28px; height: 28px; border: 1.5px solid var(--gris-light);
  background: var(--blanc); cursor: pointer; font-size: 16px;
  font-weight: 600; color: var(--bois); line-height: 1;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.15s; font-family: inherit;
}
.qty-btn:first-child { border-radius: 6px 0 0 6px; }
.qty-btn:last-child  { border-radius: 0 6px 6px 0; }
.qty-btn:hover { background: var(--bois); color: var(--blanc); border-color: var(--bois); }
.qty-val {
  min-width: 36px; height: 28px; text-align: center;
  border-top: 1.5px solid var(--gris-light); border-bottom: 1.5px solid var(--gris-light);
  font-size: 15px; font-weight: 700; color: var(--bois);
  display: flex; align-items: center; justify-content: center;
  background: var(--blanc);
}
.result-line.unit { opacity: 0.55; }

/* ── Mode expert bois ── */
.bois-auto-summary {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 10px; padding: 8px 12px;
  background: var(--fond); border-radius: 6px;
  font-size: 12px;
}
.bois-auto-summary .summary-text { color: var(--gris); }
.bois-auto-summary .summary-text strong { color: var(--bois); }
.btn-expert {
  font-size: 11px; font-weight: 600; color: var(--or);
  background: none; border: none; cursor: pointer;
  font-family: inherit; padding: 0; text-decoration: underline;
}
.btn-expert:hover { color: var(--bois); }
.expert-panel {
  display: none; margin-top: 12px;
  border: 1.5px solid var(--or-light); border-radius: 8px;
  padding: 14px; background: #FFFDF8;
}
.expert-panel.visible { display: block; }
.expert-panel-title {
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.07em; color: var(--bois-light); margin-bottom: 10px;
}
.expert-line {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 8px; flex-wrap: wrap;
}
.expert-line select {
  flex: 1; min-width: 160px; padding: 6px 8px;
  border: 1.5px solid var(--gris-light); border-radius: 6px;
  font-size: 12px; font-family: inherit; outline: none;
  background: var(--blanc); cursor: pointer;
  transition: border-color 0.15s;
}
.expert-line select:focus { border-color: var(--bois); }
.expert-line input[type=number] {
  width: 60px; padding: 6px 8px; text-align: center;
  border: 1.5px solid var(--gris-light); border-radius: 6px;
  font-size: 13px; font-weight: 700; font-family: inherit; outline: none;
  transition: border-color 0.15s;
}
.expert-line input[type=number]:focus { border-color: var(--bois); }
.expert-line .el-unit { font-size: 12px; color: var(--gris); white-space: nowrap; }
.expert-line .el-prix { font-size: 12px; font-weight: 600; color: var(--bois-light); min-width: 56px; text-align: right; }
.expert-line .el-del {
  background: none; border: none; cursor: pointer;
  color: var(--gris); font-size: 15px; padding: 0 2px; line-height: 1;
}
.expert-line .el-del:hover { color: var(--rouge); }
.expert-line .el-label {
  width: 100%; font-size: 10px; color: var(--gris);
  font-style: italic; margin-bottom: -4px;
}
.expert-actions {
  display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap;
}
.btn-expert-add {
  font-size: 12px; color: var(--bois); background: none;
  border: 1.5px dashed var(--or-light); border-radius: 6px;
  padding: 5px 10px; cursor: pointer; font-family: inherit;
  transition: all 0.15s;
}
.btn-expert-add:hover { border-color: var(--or); background: var(--or-light); }
.btn-expert-reset {
  font-size: 11px; color: var(--gris); background: none;
  border: none; cursor: pointer; font-family: inherit;
  text-decoration: underline; padding: 0;
}
.btn-expert-reset:hover { color: var(--bois); }
.btn-expert-exit {
  font-size: 11px; color: var(--gris); background: none;
  border: none; cursor: pointer; font-family: inherit;
  text-decoration: underline; padding: 0; margin-left: auto;
}
.btn-expert-exit:hover { color: var(--rouge); }
.expert-badge {
  display: inline-block; font-size: 10px; font-weight: 700;
  background: #FFF3CD; color: #856404; border-radius: 4px;
  padding: 1px 6px; margin-left: 6px; vertical-align: middle;
}

/* ── Responsive ── */
@media (max-width: 820px) {
  .layout { grid-template-columns: 1fr; padding: 14px; }
  .result-panel { position: static; }
  .bois-cards { grid-template-columns: 1fr; }
  header { padding: 12px 16px; }
}
