/*
  Mobile Step Wizard for MijnBouwProject Lead Configurator
  Only active at max-width: 768px
  Desktop is completely untouched.

  Audit fixes applied:
  - dvh units with vh fallback for mobile browser chrome (address bar)
  - Safe area insets for iPhone notch / home indicator
  - Touch targets enlarged to >= 44px (iOS HIG)
  - Vendor prefixes for older mobile WebKit
  - Small-screen overrides for < 375px
  - z-index layering documented and corrected
  - Overflow guards on grids
*/

@media (max-width: 768px) {

  /* ========== LAYOUT: viewer top, wizard bottom ========== */
  #app {
    -webkit-flex-direction: column !important;
    flex-direction: column !important;
    height: 100vh !important;
    height: 100dvh !important;                    /* dynamic viewport — respects mobile chrome */
    overflow: hidden !important;
    /* Safe area padding for edge-to-edge displays */
    padding-left: env(safe-area-inset-left) !important;
    padding-right: env(safe-area-inset-right) !important;
  }

  /* Hide the desktop sidebar visually but keep it in DOM for wizard to read options */
  #configurator {
    position: fixed !important;
    left: -9999px !important;
    width: 280px !important;
    height: 100vh !important;
    height: 100dvh !important;
    opacity: 0 !important;
    pointer-events: none !important;
    overflow: hidden !important;
  }

  /* 3D viewer takes top portion — scales with screen height */
  .cfg-main-content {
    -webkit-flex: 0 0 42vh !important;
    flex: 0 0 42vh !important;
    flex: 0 0 clamp(35dvh, 42dvh, 48dvh) !important;
    display: -webkit-flex !important;
    display: flex !important;
    -webkit-flex-direction: column !important;
    flex-direction: column !important;
    min-height: 0 !important;
    overflow: hidden !important;
  }

  /* === MOBILE TOPBAR: logo left, price center, offerte right === */
  .cfg-viewer-header {
    all: unset !important;
    display: grid !important;
    grid-template-columns: clamp(60px, 22vw, 100px) 1fr auto !important;
    align-items: center !important;
    height: auto !important;
    padding: clamp(6px, 1.2vh, 10px) clamp(8px, 3vw, 12px) !important;
    padding-top: calc(clamp(8px, 1.5vh, 14px) + env(safe-area-inset-top, 0px)) !important;
    background: #fff !important;
    border-bottom: 1px solid #e5e7eb !important;
    box-sizing: border-box !important;
    flex-shrink: 0 !important;
    z-index: 50 !important;
  }

  /* Logo left — scales with viewport */
  .cfg-viewer-header::before {
    content: '' !important;
    display: block !important;
    width: clamp(60px, 22vw, 100px) !important;
    height: clamp(22px, 3.5vw, 28px) !important;
    background: url('./assets/logo-mijnbouwproject.svg') no-repeat left center/contain !important;
  }

  /* Price center */
  .topbar-price-preview {
    all: unset !important;
    display: block !important;
    text-align: center !important;
  }
  .topbar-price-label {
    display: none !important;
  }
  .topbar-price-value {
    font-size: clamp(14px, 4.2vw, 18px) !important;
    font-weight: 700 !important;
    color: #01b900 !important;
    font-family: 'Barlow', sans-serif !important;
  }

  /* Offerte right */
  .header-actions {
    all: unset !important;
    display: flex !important;
    justify-content: flex-end !important;
  }
  .header-actions .btn {
    white-space: nowrap !important;
    padding: clamp(5px, 1vw, 8px) clamp(8px, 3vw, 14px) !important;
    font-size: clamp(11px, 3.2vw, 13px) !important;
    font-weight: 600 !important;
    background: #fc6b03 !important;
    color: #fff !important;
    border: none !important;
    border-radius: 8px !important;
    cursor: pointer !important;
    font-family: 'Barlow', sans-serif !important;
  }


  #viewer {
    flex: 1 !important;
    height: auto !important;
    min-height: 0 !important;
    position: relative !important;
    touch-action: none !important;             /* prevent browser zoom on 3D canvas */
  }

  #canvas {
    width: 100% !important;
    height: 100% !important;
    touch-action: none !important;             /* Three.js handles all touch gestures */
  }

  /* ========== MOBILE WIZARD PANEL ========== */
  .mbp-wizard {
    background: #fff;
    border-top: 2px solid #fc6b03;
    display: -webkit-flex;
    display: flex;
    -webkit-flex-direction: column;
    flex-direction: column;
    height: 58vh;
    height: clamp(52dvh, 58dvh, 65dvh);           /* dynamic viewport — address bar safe */
    -webkit-flex-shrink: 0;
    flex-shrink: 0;
    overflow: hidden;
    position: relative;
    z-index: 100;                                 /* above 3D canvas (z:1-50), below modals */
  }

  /* Drag handle */
  .mbp-wizard-handle {
    width: 40px;
    height: 4px;
    background: #e6e6ed;
    border-radius: 2px;
    margin: 8px auto 0;
    cursor: grab;
  }

  /* Step header with progress */
  .mbp-wizard-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: clamp(6px, 1.2vh, 12px) clamp(12px, 4vw, 16px) clamp(4px, 0.8vh, 8px);
    flex-shrink: 0;
  }

  .mbp-wizard-title {
    font-family: 'Barlow', sans-serif;
    font-size: clamp(13px, 3.8vw, 16px);
    font-weight: 700;
    color: #041959;
  }

  .mbp-wizard-step-count {
    font-family: 'Barlow', sans-serif;
    font-size: clamp(10px, 2.8vw, 12px);
    color: #9ca2b4;
    font-weight: 500;
  }

  /* Progress bar */
  .mbp-wizard-progress {
    height: 3px;
    background: #f3f3f5;
    margin: 0 clamp(12px, 4vw, 16px) clamp(4px, 0.8vh, 8px);
    border-radius: 2px;
    flex-shrink: 0;
  }

  .mbp-wizard-progress-bar {
    height: 100%;
    background: #fc6b03;
    border-radius: 2px;
    -webkit-transition: width 0.3s ease;
    transition: width 0.3s ease;
  }

  /* Step content area — scrollable with fade hint */
  .mbp-wizard-content {
    flex: 1;
    overflow-y: auto;
    padding: 0 clamp(12px, 4vw, 16px) clamp(4px, 0.8vh, 8px);
    -webkit-overflow-scrolling: touch;
    position: relative;
  }

  .mbp-wizard-content::after {
    display: none;
  }

  /* Dimension inputs in wizard */
  .mbp-wizard-dims {
    display: flex;
    flex-direction: column;
    gap: 10px;
  }

  .mbp-wizard-dim-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #f5f5f7;
    padding: clamp(8px, 1.2vh, 10px) clamp(10px, 3vw, 12px);
    border-radius: 0.5rem;
  }

  .mbp-wizard-dim-label {
    font-family: 'Barlow', sans-serif;
    font-size: clamp(12px, 3.5vw, 14px);
    font-weight: 500;
    color: #041959;
  }

  .mbp-wizard-dim-input {
    width: clamp(65px, 20vw, 80px);
    text-align: center;
    padding: clamp(4px, 0.8vh, 6px) 8px;
    border: 1px solid #e6e6ed;
    border-radius: 0.375rem;
    font-family: 'Barlow', sans-serif;
    font-size: clamp(13px, 3.6vw, 15px);
    font-weight: 600;
    color: #041959;
  }

  .mbp-wizard-dim-input:focus {
    border-color: #fc6b03;
    box-shadow: 0 0 0 3px rgba(252, 107, 3, 0.15);
    outline: none;
  }

  .mbp-wizard-dim-unit {
    font-family: 'Barlow', sans-serif;
    font-size: 12px;
    color: #9ca2b4;
    margin-left: 4px;
  }

  .mbp-wizard-area {
    display: flex;
    gap: clamp(8px, 2.5vw, 12px);
    margin-top: clamp(6px, 1vh, 8px);
  }

  .mbp-wizard-area-item {
    flex: 1;
    background: #f5f5f7;
    border-radius: 0.5rem;
    padding: clamp(6px, 1vh, 8px) clamp(8px, 2.5vw, 12px);
    text-align: center;
    font-family: 'Barlow', sans-serif;
    font-size: clamp(13px, 3.6vw, 15px);
    font-weight: 700;
    color: #041959;
  }

  /* Options rendered by the wizard (reuses configurator groups) */
  .mbp-wizard-content .cfg-group {
    border: none !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  .mbp-wizard-content .cfg-group-header {
    display: none !important;
  }

  .mbp-wizard-content .cfg-group-body {
    display: block !important;
    max-height: none !important;
    padding: 0 !important;
  }

  /* Sub-category labels in wizard steps — subtle orange accent */
  .mbp-wizard-content .cfg-swatch-category {
    background: none !important;
    color: #041959 !important;
    padding: 0 0 clamp(4px, 0.6vh, 6px) 0 !important;
    border-bottom: 2px solid #fc6b03 !important;
    border-radius: 0 !important;
    font-size: clamp(10px, 2.8vw, 11px) !important;
    font-weight: 600 !important;
    text-transform: uppercase !important;
    letter-spacing: 0.04em !important;
    margin: clamp(12px, 2vh, 20px) 0 clamp(10px, 1.5vh, 16px) !important;
    display: block !important;
  }

  .mbp-wizard-content .cfg-swatch-category:first-child {
    margin-top: clamp(4px, 0.8vh, 8px) !important;
  }

  /* Swatches — spaced across screen with labels */
  .mbp-wizard-content .cfg-swatch-grid,
  .mbp-wizard-content .cfg-icon-grid,
  .mbp-wizard-content .cfg-overhang-grid-material {
    gap: clamp(12px, 3vw, 20px) clamp(14px, 4vw, 24px) !important;
    justify-content: center !important;
    display: -webkit-flex !important;
    display: flex !important;
    -webkit-flex-wrap: wrap !important;
    flex-wrap: wrap !important;
    max-width: 100% !important;                   /* overflow guard */
  }

  .mbp-wizard-content .cfg-frame-grid-material {
    display: grid !important;
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 12px !important;
  }

  .mbp-wizard-content .cfg-frame-grid {
    display: flex !important;
    justify-content: flex-start !important;
  }

  .mbp-wizard-content .cfg-gutter-grid,
  .mbp-wizard-content .cfg-outlight-grid,
  .mbp-wizard-content .cfg-outlet-grid,
  .mbp-wizard-content .cfg-tap-grid {
    display: flex !important;
    justify-content: space-between !important;
    gap: 12px !important;
    padding: 0 8px !important;
  }

  .mbp-wizard-content .cfg-door-grid {
    display: flex !important;
    flex-wrap: wrap !important;
    justify-content: center !important;
    gap: clamp(12px, 3vw, 20px) clamp(14px, 4vw, 24px) !important;
  }

  .mbp-wizard-content .cfg-window-grid {
    display: flex !important;
    flex-wrap: wrap !important;
    justify-content: center !important;
    gap: clamp(10px, 3vw, 16px) !important;
  }

  .mbp-wizard-content .cfg-window-grid.mbp-ramen-grid {
    display: grid !important;
    grid-template-columns: repeat(4, 1fr) !important;
    gap: 8px 6px !important;
    justify-items: center !important;
    max-width: 100% !important;                   /* overflow guard */
    overflow-x: hidden !important;
  }

  .mbp-wizard-content .cfg-door-grid .cfg-window-icon,
  .mbp-wizard-content .cfg-window-grid .cfg-window-icon {
    width: auto !important;
    height: auto !important;
  }

  .mbp-wizard-content .cfg-door-grid .cfg-window-icon svg,
  .mbp-wizard-content .cfg-window-grid .cfg-window-icon svg {
    width: 64px !important;
    height: auto !important;
  }

  /* Hide built-in labels inside icon buttons — we add our own underneath */
  .mbp-wizard-content .cfg-icon-label {
    display: none !important;
  }

  .mbp-wizard-content .cfg-window-icon,
  .mbp-wizard-content .cfg-overhang-icon,
  .mbp-wizard-content .cfg-skylight-icon,
  .mbp-wizard-content .cfg-gutter-icon,
  .mbp-wizard-content .cfg-outlight-icon,
  .mbp-wizard-content .cfg-tap-icon {
    padding: 0 !important;
    gap: 0 !important;
    margin: 0 !important;
    height: auto !important;
    min-height: 0 !important;
    line-height: 0 !important;
  }

  .mbp-wizard-content .cfg-window-icon svg,
  .mbp-wizard-content .cfg-overhang-icon svg,
  .mbp-wizard-content .cfg-overhang-icon img {
    display: block !important;
  }

  .mbp-wizard-content .cfg-outlet-icon {
    padding: 0 !important;
    gap: 0 !important;
    margin: 0 !important;
    height: auto !important;
    min-height: 0 !important;
    line-height: 0 !important;
  }

  .mbp-wizard-content .cfg-outlet-icon[data-id*="L+R"] {
    transform: scale(1.4) !important;
  }

  .mbp-wizard-content .cfg-swatch-grid,
  .mbp-wizard-content .cfg-icon-grid {
    display: flex !important;
    flex-wrap: wrap !important;
    justify-content: center !important;
    gap: clamp(12px, 3vw, 20px) clamp(12px, 3vw, 20px) !important;
    margin-bottom: clamp(8px, 1.5vh, 14px) !important;
  }

  /* Nee/geen buttons: left aligned, full width row */
  .mbp-wizard-content .is-none,
  .mbp-wizard-content [data-id="geen"],
  .mbp-wizard-content [data-id="Nee"],
  .mbp-wizard-content [data-id="nee"] {
    margin-right: auto !important;
  }

  .mbp-wizard-content .cfg-swatch-grid:has(.is-none),
  .mbp-wizard-content .cfg-icon-grid:has(.is-none),
  .mbp-wizard-content .cfg-swatch-grid:has([data-id="geen"]) {
    justify-content: flex-start !important;
  }

  .mbp-wizard-content .cfg-swatch-wrap {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    width: auto !important;
    min-width: 56px !important;
    gap: 2px !important;
  }

  .mbp-wizard-content .cfg-swatch {
    width: clamp(40px, 11vw, 48px) !important;
    height: clamp(40px, 11vw, 48px) !important;
  }

  .mbp-wizard-content .cfg-swatch-label {
    font-family: 'Barlow', sans-serif !important;
    font-size: clamp(10px, 2.8vw, 12px) !important;
    color: #041959 !important;
    text-transform: capitalize !important;
    text-align: center !important;
    line-height: 1.2 !important;
    max-width: 100% !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
  }

  /* Hide all 3D interaction popups on mobile — options go in wizard */
  #front-pui-panel,
  #window-size-panel,
  #door-size-panel,
  #front-window-panel,
  #front-door-panel {
    display: none !important;
  }

  /* Wizard overlay for 3D element options */
  .mbp-wizard-overlay {
    padding: 4px 0;
  }

  .mbp-wizard-overlay-header {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 6px;
  }

  .mbp-wizard-overlay-title {
    font-family: 'Barlow', sans-serif;
    font-size: 13px;
    font-weight: 700;
    color: #041959;
  }

  .mbp-wizard-overlay-close {
    width: 44px;                                  /* iOS min touch target */
    height: 44px;                                 /* iOS min touch target */
    border: 2px solid #dc2626;
    background: #fef2f2;
    border-radius: 8px;
    font-size: 22px;
    font-weight: 700;
    color: #dc2626;
    cursor: pointer;
    display: -webkit-flex;
    display: flex;
    -webkit-align-items: center;
    align-items: center;
    -webkit-justify-content: center;
    justify-content: center;
  }

  .mbp-wizard-overlay-body {
    padding: 0;
  }

  .mbp-overlay-btn-close {
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .mbp-overlay-btn {
    -webkit-flex: 1;
    flex: 1;
    background: #f5f5f7;
    border: 1.5px solid #e6e6ed;
    border-radius: 0.375rem;
    padding: 8px 8px;                             /* slightly taller for touch */
    min-height: 44px;                             /* iOS min touch target */
    cursor: pointer;
    text-align: center;
    -webkit-transition: all 0.2s ease;
    transition: all 0.2s ease;
    font-family: 'Barlow', sans-serif;
  }

  .mbp-overlay-btn:active {
    border-color: #fc6b03;
    background: #fff9f5;
  }

  .mbp-overlay-btn.is-active {
    border-color: #fc6b03;
    background: #fff3e6;
  }

  .mbp-overlay-btn-label {
    font-size: 9px;
    color: #9ca2b4;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    margin-bottom: 1px;
  }

  .mbp-overlay-btn-value {
    font-size: 12px;
    font-weight: 600;
    color: #041959;
  }

  .mbp-overlay-btn-delete {
    background: #fef2f2;
    border-color: #fecaca;
  }

  .mbp-overlay-btn-delete:active {
    background: #fee2e2;
    border-color: #dc2626;
  }

  .mbp-overlay-btn-delete .mbp-overlay-btn-value {
    color: #dc2626;
    font-size: 12px;
  }

  /* Overlay layout — compact rows */
  .mbp-wizard-overlay-body > div {
    margin-bottom: 8px !important;
  }

  .mbp-wizard-overlay-body > div:last-child {
    margin-bottom: 0 !important;
  }

  /* Pane buttons inside overlay */
  .mbp-panes-portal label {
    font-size: 10px !important;
  }

  .mbp-panes-portal button {
    padding: 5px 0 !important;
    font-size: 10px !important;
    max-width: 55px !important;
  }

  /* Overstek spotjes — compact visually, but 44px touch target via padding */
  .mbp-wizard-content .cfg-swatch.cfg-skylight-swatch {
    width: 38px !important;
    height: 38px !important;
    min-width: 38px !important;
    /* Invisible padding expands touch target to 44px without changing visual size */
    padding: 3px !important;
    box-sizing: content-box !important;
  }

  /* Tighter gap when wrapping spotjes swatches */
  .mbp-wizard-content .cfg-swatch-grid:has(.cfg-skylight-swatch) {
    gap: 10px 10px !important;
  }

  /* Pill buttons (binnenzijde options) — min-height 44px for iOS */
  .mbp-pill-btn {
    font-family: 'Barlow', sans-serif;
    font-size: clamp(11px, 3.2vw, 13px);
    font-weight: 500;
    padding: clamp(8px, 1vh, 10px) clamp(12px, 3.5vw, 16px);
    min-height: 44px;
    border: 2px solid #e6e6ed;
    border-radius: 2rem;
    touch-action: manipulation;
    background: #fff;
    color: #041959;
    cursor: pointer;
    -webkit-transition: all 0.2s ease;
    transition: all 0.2s ease;
  }

  .mbp-pill-btn:hover {
    border-color: #fc6b03;
    background: #fff9f5;
  }

  .mbp-pill-btn.is-active {
    border-color: #fc6b03;
    background: #fc6b03;
    color: #fff;
  }

  /* Counter buttons — 44px min for iOS touch target */
  .mbp-counter-btn {
    width: 44px;
    height: 44px;
    border: 2px solid #e6e6ed;
    border-radius: 50%;
    background: #fff;
    color: #041959;
    font-size: 20px;
    font-weight: 600;
    touch-action: manipulation;
    cursor: pointer;
    display: -webkit-flex;
    display: flex;
    -webkit-align-items: center;
    align-items: center;
    -webkit-justify-content: center;
    justify-content: center;
    font-family: 'Barlow', sans-serif;
    -webkit-transition: all 0.2s ease;
    transition: all 0.2s ease;
  }

  .mbp-counter-btn:hover {
    border-color: #fc6b03;
    color: #fc6b03;
  }

  .mbp-counter-value {
    font-family: 'Barlow', sans-serif;
    font-size: clamp(16px, 4.5vw, 20px);
    font-weight: 700;
    color: #041959;
    min-width: 30px;
    text-align: center;
  }

  /* Navigation buttons — safe-area-inset-bottom for home indicator */
  .mbp-wizard-nav {
    display: -webkit-flex;
    display: flex;
    gap: clamp(4px, 0.8vh, 10px);
    padding: clamp(4px, 0.6vh, 6px) clamp(12px, 4vw, 16px) clamp(8px, 1.5vh, 16px);
    /* Use safe area inset instead of hardcoded 28px for home indicator */
    padding-bottom: calc(clamp(8px, 1.5vh, 16px) + env(safe-area-inset-bottom, 0px));
    border-top: 1px solid #f3f3f5;
    -webkit-flex-shrink: 0;
    flex-shrink: 0;
    background: #fff;
    margin-bottom: 0;                            /* replaced by padding-bottom safe area */
  }

  .mbp-wizard-btn {
    -webkit-flex: 1;
    flex: 1;
    padding: clamp(8px, 1.2vh, 12px) clamp(12px, 3vw, 16px);
    min-height: 44px;                             /* iOS min touch target */
    border-radius: 0.5rem;
    font-family: 'Barlow', sans-serif;
    font-size: clamp(12px, 3.5vw, 14px);
    font-weight: 600;
    cursor: pointer;
    -webkit-transition: all 0.2s ease;
    transition: all 0.2s ease;
    text-align: center;
    border: none;
    touch-action: manipulation;                /* prevent double-tap zoom */
  }

  .mbp-wizard-btn-back {
    background: #f5f5f7;
    color: #454a5c;
    -webkit-flex: 0 0 auto;
    flex: 0 0 auto;
    padding: clamp(8px, 1.2vh, 12px) clamp(14px, 4vw, 20px);
  }

  .mbp-wizard-btn-back:hover {
    background: #e6e6ed;
  }

  .mbp-wizard-btn-next {
    background: #fc6b03;
    color: #fff;
  }

  .mbp-wizard-btn-next:hover {
    background: #c75402;
  }

  /* Nav layout: main row on top, secondary row below */
  .mbp-wizard-nav {
    flex-direction: column;
    gap: clamp(4px, 0.8vh, 8px);
  }
  .mbp-wizard-nav-main {
    display: flex;
    gap: clamp(6px, 2vw, 10px);
  }
  .mbp-wizard-nav-main .mbp-wizard-btn-back {
    flex: 0 0 auto;
  }
  .mbp-wizard-nav-main .mbp-wizard-btn-next {
    flex: 1;
  }
  .mbp-wizard-nav-secondary {
    display: flex;
    gap: clamp(4px, 2vw, 8px);
  }
  .mbp-wizard-btn-sec {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: clamp(6px, 1vh, 10px) clamp(8px, 2.5vw, 12px);
    min-height: clamp(34px, 5vh, 40px);
    border-radius: 0.5rem;
    font-family: 'Barlow', sans-serif;
    font-size: clamp(11px, 3.2vw, 13px);
    font-weight: 600;
    cursor: pointer;
    text-align: center;
    text-decoration: none;
    border: 1px solid #e5e7eb;
    background: #fff;
    color: #6b7280;
    transition: color 0.2s, border-color 0.2s;
    touch-action: manipulation;
  }
  .mbp-wizard-btn-sec:hover {
    color: #fc6b03;
    border-color: #fc6b03;
  }

  /* Touch hint — full-width bar below topbar */
  .mbp-touch-hint {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    background: #fc6b03;
    color: #fff;
    font-family: 'Barlow', sans-serif;
    font-size: 12px;
    font-weight: 500;
    padding: 6px 0;
    z-index: 50;                                  /* above 3D scene (z:1-8), below wizard(100) */
    pointer-events: none;
    opacity: 1;
    -webkit-transition: opacity 0.8s ease;
    transition: opacity 0.8s ease;
    text-align: center;
    letter-spacing: 0.02em;
  }

  .mbp-touch-hint.is-hidden {
    opacity: 0;
  }

  /* Powered by — center bottom of 3D scene */
  .powered-by-axiops {
    display: block !important;
    position: absolute !important;
    bottom: 4px !important;
    left: 50% !important;
    -webkit-transform: translateX(-50%) !important;
    transform: translateX(-50%) !important;
    font-size: 10px !important;
    color: #222 !important;
    z-index: 10 !important;
  }

  /* View toggle buttons on mobile */
  .view-toggle-container {
    top: auto !important;
    bottom: 8px !important;
    left: 50% !important;
    -webkit-transform: translateX(-50%) !important;
    transform: translateX(-50%) !important;
  }

  /* ========== OFFERTE MOBILE — fullscreen ========== */

  .quote-preview-modal.is-visible {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    z-index: 9999 !important;
    background: #fff !important;
    backdrop-filter: none !important;
  }

  .quote-preview-overlay {
    display: none !important;
  }

  .quote-preview-container {
    height: 100vh !important;
    height: 100dvh !important;
    max-height: 100vh !important;
    max-height: 100dvh !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
    background: #fff !important;
    /* Safe area for notch + home indicator */
    padding-top: env(safe-area-inset-top) !important;
    padding-bottom: env(safe-area-inset-bottom) !important;
  }

  .quote-preview-paper {
    box-shadow: none !important;
    border: none !important;
    border-radius: 0 !important;
    max-width: 100% !important;
    width: 100% !important;
  }

  /* ========== OFFERTE MOBILE STYLES ========== */

  /* Hide the X close button — we use the header bar instead */
  .quote-preview-close {
    display: none !important;
  }

  .quote-preview-paper {
    padding: 0 !important;
  }

  .quote-preview-content {
    padding: clamp(12px, 2vh, 16px) clamp(10px, 3vw, 14px) !important;
  }

  /* Mobile offerte header — centered title */
  .mbp-offerte-header {
    text-align: center !important;
  }

  /* 3 steps on mobile — horizontal compact */
  .mbp-offerte-steps-row {
    display: flex !important;
    flex-direction: row !important;
    gap: clamp(4px, 2vw, 8px) !important;
  }

  .mbp-offerte-steps-row > div {
    flex: 1 !important;
    padding: clamp(8px, 1.5vh, 12px) clamp(4px, 2vw, 8px) !important;
    border-radius: 0.5rem !important;
  }

  .mbp-offerte-steps-row .mbp-step-num {
    width: clamp(22px, 6vw, 28px) !important;
    height: clamp(22px, 6vw, 28px) !important;
    font-size: clamp(11px, 3vw, 13px) !important;
    margin-bottom: clamp(4px, 0.6vh, 6px) !important;
  }

  .mbp-offerte-steps-row p {
    font-size: clamp(10px, 2.6vw, 11px) !important;
    line-height: 1.3 !important;
  }

  .mbp-offerte-steps-row p:first-of-type {
    font-size: clamp(10px, 2.8vw, 12px) !important;
  }

  /* Element placement tip */
  .mbp-element-tip {
    position: absolute;
    top: 50%;
    left: 50%;
    -webkit-transform: translate(-50%, -50%);
    transform: translate(-50%, -50%);
    z-index: 200;                                 /* above wizard(100), below modals(9999) */
    opacity: 1;
    -webkit-transition: opacity 0.5s ease;
    transition: opacity 0.5s ease;
  }

  .mbp-element-tip.is-hidden {
    opacity: 0;
  }

  .mbp-element-tip-content {
    background: #fff;
    border-radius: 0.75rem;
    padding: 18px 20px;
    box-shadow: 0 8px 30px rgba(4, 25, 89, 0.2);
    text-align: center;
    max-width: 260px;
  }

  .mbp-element-tip-btn {
    font-family: 'Barlow', sans-serif;
    font-size: 13px;
    font-weight: 600;
    padding: 8px 24px;
    background: #fc6b03;
    color: #fff;
    border: none;
    border-radius: 0.5rem;
    cursor: pointer;
  }

  /* ========== PRESELECT MOBILE ========== */

  .preselect {
    padding: 0 !important;
    padding-top: env(safe-area-inset-top) !important;    /* notch clearance */
    -webkit-align-items: flex-start !important;
    align-items: flex-start !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
    background: #fff !important;
  }

  .preselect-card {
    width: 100% !important;
    max-width: 100% !important;
    padding: clamp(16px, 3vh, 24px) clamp(14px, 5vw, 20px) clamp(14px, 2.5vh, 20px) !important;
    padding-bottom: calc(clamp(14px, 2.5vh, 20px) + env(safe-area-inset-bottom, 0px)) !important;
    min-height: auto !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    box-sizing: border-box !important;
  }

  .preselect-header {
    text-align: center !important;
    padding: clamp(16px, 3vh, 24px) 0 clamp(14px, 2.5vh, 20px) !important;
    border-bottom: 1px solid #f3f3f5 !important;
    margin-bottom: clamp(16px, 3vh, 24px) !important;
  }

  .preselect-header::before {
    width: min(200px, 60vw) !important;           /* won't overflow on < 320px screens */
    height: 50px !important;
    margin-bottom: 18px !important;
  }

  .preselect-title {
    font-size: 1.1rem !important;
  }

  .preselect-sub {
    font-size: 13px !important;
  }

  .preselect-h2 {
    font-size: 14px !important;
  }

  .preselect-grid {
    grid-template-columns: 1fr 1fr !important;
    gap: 8px !important;
  }

  .preselect-option {
    height: auto !important;
    min-height: 44px !important;
    max-height: none !important;
    padding: clamp(8px, 1.2vh, 10px) clamp(10px, 3vw, 14px) !important;
    border-width: 2px !important;
    border-color: #f3f3f5 !important;
    border-radius: 0.5rem !important;
    background: #fafafa !important;
  }

  .preselect-option:hover {
    border-color: #fc6b03 !important;
    background: #fff !important;
  }

  .preselect-option:has(input:checked) {
    border-color: #fc6b03 !important;
    background: #fff3e6 !important;
  }

  .preselect-option-title {
    font-size: clamp(12px, 3.5vw, 14px) !important;
    font-weight: 600 !important;
  }

  .preselect-option-meta {
    font-size: clamp(10px, 2.6vw, 11px) !important;
    color: #9ca2b4 !important;
  }

  .preselect-option-full {
    grid-column: 1 / -1 !important;
  }

  .preselect-actions {
    padding-top: clamp(14px, 2.5vh, 20px) !important;
    border-top: 1px solid #f3f3f5 !important;
    margin-top: clamp(4px, 1vh, 8px) !important;
  }

  .preselect-btn {
    width: 100% !important;
    min-width: auto !important;
    min-height: 44px !important;                  /* comfortable touch target */
    padding: clamp(10px, 1.5vh, 14px) clamp(14px, 4vw, 20px) !important;
    font-size: clamp(14px, 3.8vw, 16px) !important;
    border-radius: 0.5rem !important;
  }

  .preselect-h2 {
    font-size: 13px !important;
    font-weight: 600 !important;
    color: #041959 !important;
    margin: 0 0 8px !important;
    text-transform: uppercase !important;
    letter-spacing: 0.03em !important;
    font-family: 'Barlow', sans-serif !important;
  }

  .preselect-step-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    background: #fc6b03;
    color: #fff;
    border-radius: 50%;
    font-size: 11px;
    font-weight: 700;
    margin-right: 6px;
    vertical-align: middle;
    flex-shrink: 0;
  }

  /* More space before second question */
  .preselect-h2[style*="margin-top"] {
    margin-top: 32px !important;
    padding-top: 24px !important;
    border-top: 1px solid #f3f3f5 !important;
  }

  .preselect-title {
    font-size: 1.2rem !important;
    color: #041959 !important;
    margin-bottom: 4px !important;
  }

  .preselect-sub {
    font-size: 13px !important;
    color: #9ca2b4 !important;
    line-height: 1.4 !important;
  }

  /* ========== MEDIUM PHONES (375-430px, e.g. iPhone 16, iPhone 14, Pixel 7) ========== */
  /* Most sizing is now handled by fluid clamp() values above.                          */
  /* This breakpoint only contains overrides that clamp() alone can't handle.           */
  @media (max-width: 430px) {

    /* Ramen grid: ensure 4 columns don't overflow */
    .mbp-wizard-content .cfg-window-grid.mbp-ramen-grid {
      gap: 6px 4px !important;
    }

    /* SVG icons in grids — scale down */
    .mbp-wizard-content .cfg-door-grid .cfg-window-icon svg,
    .mbp-wizard-content .cfg-window-grid .cfg-window-icon svg {
      width: clamp(48px, 14vw, 64px) !important;
    }
  }

  /* ========== SHORT SCREENS (height < 700px) ========== */
  /* On short screens, give more space to the wizard panel (buttons/options)          */
  @media (max-height: 700px) {

    .cfg-main-content {
      -webkit-flex: 0 0 36vh !important;
      flex: 0 0 36vh !important;
      flex: 0 0 35dvh !important;
    }

    .mbp-wizard {
      height: 64vh !important;
      height: 65dvh !important;
    }
  }

  /* ========== VERY SMALL SCREENS (< 375px, e.g. iPhone SE, Galaxy S) ========== */
  /* Most sizing now handled by fluid clamp() — only layout-specific overrides here */
  @media (max-width: 374px) {

    /* Ramen grid: 3 columns on tiny screens instead of 4 */
    .mbp-wizard-content .cfg-window-grid.mbp-ramen-grid {
      grid-template-columns: repeat(3, 1fr) !important;
    }

    /* Offerte steps row — tighter on tiny screens */
    .mbp-offerte-steps-row {
      gap: 4px !important;
    }

    .mbp-offerte-steps-row > div {
      padding: clamp(6px, 1vh, 10px) clamp(4px, 1.5vw, 6px) !important;
    }

    .mbp-offerte-steps-row p {
      font-size: clamp(9px, 2.5vw, 10px) !important;
    }
  }

}
