/* Responsive controls preserve the photograph and original overlay sources. */
@media screen {
  html { -webkit-text-size-adjust:100%; text-size-adjust:100%; }
  select { font:inherit; }
  select:focus-visible { outline:3px solid #2686b8; outline-offset:3px; }
  main { padding-left:max(3.2%,env(safe-area-inset-left)); padding-right:max(3.2%,env(safe-area-inset-right)); }
  .room-nav { scroll-padding-inline:12px; }
  .room-tab { min-height:44px; flex-shrink:0; }
  .room-panel,.panel-contents { min-height:0; }
  .panel-heading { position:relative; flex-shrink:0; }
  .panel-contents { overscroll-behavior:contain; -webkit-overflow-scrolling:touch; }
  .panel-tip,.panel-budget-note { flex-shrink:0; }
  .upgrade-label { min-height:44px; }
  .upgrade-checkbox { width:24px; height:24px; min-width:24px; }
  .upgrade-card summary { min-height:44px; font-size:14px; margin-top:0; }
  .upgrade-card details p { font-size:14px; }
  .upgrade-price.custom { font-size:14px; }
  .text-button,.icon-button,.billy-close,.billy-greeting-dismiss,.remove-item { min-width:44px; min-height:44px; }
  .billy-greeting-dismiss { top:0; right:0; }
  .billy-greeting-open>strong { padding-right:30px; }
  .scene-view-switch { flex-wrap:wrap; }
  .scene-view-switch button,.preview-toggle button,.explorer-button { min-height:44px; font-size:14px; }
  .viewer-bottom { flex-wrap:wrap; }
  .zoom-controls { height:46px; flex-shrink:0; }
  .zoom-controls button,.zoom-controls #pan-tool { width:44px; min-width:44px; height:44px; }
  .zoom-controls #pan-tool { width:auto; padding-inline:12px; font-size:14px; }
  .zoom-controls span#zoom-level { min-width:48px; font-size:14px; }
  .zoom-controls svg { width:18px; height:18px; }
  .visual-toolbar { flex-wrap:wrap; }
  #visual-status { font-size:14px; }
  .visual-caption { pointer-events:auto; }
  .visual-caption>div { min-width:0; }
  .visual-caption strong { overflow-wrap:anywhere; }
  .visual-caption small { font-size:12px; letter-spacing:.06em; }
  .visual-caption .text-button { font-size:14px; }
  .environment-track { margin-top:0; }
  .environment-track input { appearance:none; -webkit-appearance:none; height:44px; min-width:0; background:transparent; touch-action:pan-y; }
  .environment-track input::-webkit-slider-runnable-track { height:6px; border-radius:6px; background:linear-gradient(90deg,#b7d7e4,#173d52); }
  .environment-track input::-moz-range-track { height:6px; border-radius:6px; background:linear-gradient(90deg,#b7d7e4,#173d52); }
  .environment-track input::-webkit-slider-thumb { appearance:none; -webkit-appearance:none; width:28px; height:28px; margin-top:-11px; border:3px solid #fff; border-radius:50%; background:#246b90; box-shadow:0 1px 5px #173d5270; }
  .environment-track input::-moz-range-thumb { width:22px; height:22px; border:3px solid #fff; border-radius:50%; background:#246b90; box-shadow:0 1px 5px #173d5270; }
  .concept-note { font-size:12px; color:#5e7682; }
  .plan-title,.plan-total,.plan-item strong,.plan-summary>* { min-width:0; }
  .plan-total strong,.plan-summary strong { overflow-wrap:anywhere; }
  .plan-summary { flex-wrap:wrap; }
  .plan-item { display:grid; grid-template-columns:minmax(0,1fr) auto 44px; }
  .primary-button,.secondary-button { min-height:44px; white-space:normal; }
  .clear-plan { min-height:44px; font-size:14px; }
  dialog:not(#room-explorer) { max-height:calc(100dvh - 32px - env(safe-area-inset-top) - env(safe-area-inset-bottom)); overscroll-behavior:contain; }
  .dialog-header { position:sticky; top:0; z-index:2; }
  .dialog-footer { padding-bottom:max(20px,env(safe-area-inset-bottom)); }
  .scene.pan-enabled { touch-action:none; -webkit-user-select:none; }
  .scene.is-panning .scene-inner { transition:none; }
  #room-explorer { width:100%; height:100vh; height:100dvh; padding:env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); }
  .explorer-topbar { min-height:68px; flex-wrap:wrap; }
  #explorer-room { font-size:16px; min-height:44px; min-width:0; }
  #explorer-content { isolation:isolate; }
  #room-explorer .viewer { grid-template-columns:minmax(0,1fr); grid-template-rows:minmax(0,1fr) auto auto auto auto; }
  #room-explorer .visual-toolbar { grid-column:1; grid-row:2; justify-content:center; margin:8px 16px 4px; }
  #room-explorer .viewer-bottom { grid-column:1; grid-row:3; justify-content:center; margin:4px 16px 8px; }
  #room-explorer .environment-controls { grid-column:1; grid-row:4; width:min(600px,calc(100% - 32px)); padding:6px 12px; margin:0 16px 6px; }
  #room-explorer .concept-note { grid-column:1; grid-row:5; margin:0 16px 8px; font-size:12px; }
  #room-explorer .visual-caption { max-width:calc(100% - 24px); left:12px; top:12px; padding:6px 10px; }
  #room-explorer .visual-caption strong { font-size:16px; }
  #room-explorer .room-panel { width:360px; max-width:100%; z-index:8; }
  #close-upgrades { position:absolute; inset:12px 12px auto auto; width:44px; min-height:44px; padding:10px; z-index:9; }
  body:not(.explorer-open) #close-upgrades { display:none; }
  #room-explorer .panel-heading { padding:20px 66px 16px 20px; }
  #room-explorer .panel-contents { padding:0 20px 12px; }
  #room-explorer .panel-budget-note { padding:10px 20px; font-size:12px; }
}

/* Tablets keep a generous image width; the overview follows the photograph. */
@media screen and (min-width:1101px) and (min-height:601px) {
  #room-explorer .viewer { grid-template-columns:minmax(0,1fr) auto; grid-template-rows:minmax(0,1fr) auto auto auto; }
  #room-explorer .visual-toolbar { grid-column:1; grid-row:2; justify-content:flex-start; margin:8px 16px; }
  #room-explorer .viewer-bottom { grid-column:2; grid-row:2; margin:8px 16px 8px 0; }
  #room-explorer .environment-controls { grid-column:1/-1; grid-row:3; }
  #room-explorer .concept-note { grid-column:1/-1; grid-row:4; }
}
@media screen and (max-width:1100px) {
  main { padding-left:max(20px,env(safe-area-inset-left)); padding-right:max(20px,env(safe-area-inset-right)); }
  .workspace { grid-template-columns:minmax(0,1fr); }
  .room-panel { max-height:none; }
  .panel-contents { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:0 24px; }
  .panel-heading>p { max-width:600px; }
  .panel-heading>p,.upgrade-desc { font-size:16px; }
  .plan-bar { gap:14px; }
  .plan-title>div>span { display:none; }
  .plan-total { min-width:0; }
  .plan-total strong { font-size:16px; }
  .explorer-topbar h2 { display:none; }
  #explorer-room { margin-right:auto; }
}

/* A docked drawer on spacious landscape screens leaves the scene unobstructed. */
@media screen and (min-width:901px) and (min-height:601px) {
  #room-explorer.upgrades-open .workspace { padding-right:360px; }
}

/* Portrait tablets and phones share an anchored, scrollable bottom sheet. */
@media screen and (max-width:900px) and (min-height:501px) {
  #room-explorer .room-panel { inset:auto 0 0; width:100%; max-width:none; height:min(56dvh,620px); max-height:calc(100% - 56px); border:0; border-top:1px solid #d7e3e9; border-radius:18px 18px 0 0; box-shadow:0 -10px 40px #173d5228; }
  #room-explorer .panel-heading>p { display:none; }
}

@media screen and (max-width:600px) {
  main { padding:10px max(12px,env(safe-area-inset-right)) 0 max(12px,env(safe-area-inset-left)); }
  .intro { min-height:98px; gap:10px; margin-bottom:8px; }
  .intro h1 { font-size:clamp(25px,7vw,34px); }
  .intro .eyebrow { font-size:12px; letter-spacing:.06em; line-height:1.45; }
  .intro .billy-launcher img,.intro .billy-widget.is-minimized .billy-launcher img { height:78px; width:52px; }
  .intro .billy-panel { position:fixed; inset:auto 12px max(12px,env(safe-area-inset-bottom)); width:auto; max-width:none; max-height:calc(100dvh - 24px - env(safe-area-inset-top) - env(safe-area-inset-bottom)); }
  .room-nav { margin:0; padding:4px 0 12px; scroll-snap-type:x proximity; }
  .room-tab { scroll-snap-align:start; font-size:14px; padding:10px 12px; }
  .scene-view-switch { padding:10px 10px 0; gap:4px; }
  .scene-view-switch button { font-size:14px; padding:8px; gap:5px; }
  #expand-view { margin-left:0; flex-basis:100%; justify-content:center; border-color:#d9e4e8; }
  .viewer-top { padding:8px 12px 0; min-height:36px; }
  .view-label { font-size:14px; }
  .model-label { display:none; }
  .scene { aspect-ratio:3/2; }
  .hotspot { min-width:44px; min-height:44px; padding:6px; justify-content:center; }
  .hotspot .pin-icon { width:30px; height:30px; }
  .hotspot .pin-icon svg { width:18px; height:18px; }
  .hotspot>span:not(.pin-icon) { display:none; }
  .hotspot.has-selections { outline:2px solid #337468; outline-offset:1px; }
  .viewer-bottom { justify-content:center; margin:0 12px; }
  .legend { display:none; }
  .zoom-controls #pan-tool { width:44px; padding:0; justify-content:center; }
  .pan-label { display:none; }
  .visual-toolbar { margin:8px 12px; justify-content:center; gap:6px; }
  .preview-toggle button { font-size:14px; padding:8px 12px; }
  #visual-status { width:100%; max-width:none; text-align:center; font-size:12px; line-height:1.4; }
  .visual-caption { margin:0 12px 10px; gap:8px; }
  .visual-caption strong { font-size:16px; }
  .visual-caption small { font-size:12px; }
  .visual-caption .text-button { font-size:14px; }
  .environment-controls { margin:0 12px 10px; padding:8px 12px; }
  .concept-note { margin:10px 12px 12px; }
  .panel-contents { display:block; }
  .upgrade-desc { font-size:16px; }
  .panel-kicker { font-size:12px; letter-spacing:.07em; }
  .overview-row small,.panel-tip { font-size:14px; }
  .plan-bar { position:static; display:flex; flex-wrap:wrap; padding:14px; gap:12px; }
  .plan-title { flex:1 1 140px; }
  .plan-title p { font-size:16px; white-space:normal; }
  .plan-total { flex:1 1 130px; padding:0; border:0; text-align:right; }
  .plan-total>span { font-size:12px; letter-spacing:.03em; }
  .plan-total strong { font-size:16px; }
  .plan-bar>.primary-button { flex:1 0 100%; min-height:48px; }
  footer { font-size:12px; gap:12px; padding-bottom:max(20px,env(safe-area-inset-bottom)); }
  footer>p { flex-basis:100%; }
  footer .text-button { font-size:14px; }
  .dialog-header { gap:12px; padding:16px; }
  .dialog-header h2 { font-size:21px; overflow-wrap:anywhere; }
  #plan-content { padding:16px; }
  .plan-item { grid-template-columns:minmax(0,1fr) 44px; gap:2px 8px; }
  .plan-item strong { font-size:16px; }
  .plan-item>span { grid-column:1; grid-row:2; font-size:14px; }
  .plan-item .remove-item { grid-column:2; grid-row:1/3; }
  .plan-summary { display:block; }
  .plan-summary p { font-size:14px; }
  .plan-summary strong { display:block; margin-top:8px; font-size:20px; }
  .disclaimer { font-size:12px; }
  .dialog-footer { padding:16px; gap:10px; }
  .dialog-footer .primary-button,.dialog-footer .secondary-button { flex:1 0 100%; font-size:16px; }
  .explorer-topbar { display:grid; grid-template-columns:minmax(0,1fr) minmax(0,1fr); gap:6px 8px; padding:8px 10px; min-height:0; }
  #exit-explorer { order:0; font-size:14px; padding:8px; }
  #explorer-room { order:1; width:100%; max-width:none; margin:0; }
  #toggle-upgrades { order:2; }
  #explorer-plan { order:3; }
  #room-explorer .visual-toolbar { grid-row:2; grid-column:1; margin:6px 10px 2px; width:auto; }
  #room-explorer .viewer-bottom { grid-row:3; grid-column:1; margin:2px 10px 6px; }
  #room-explorer #visual-status { display:block; }
  #room-explorer .environment-controls { grid-row:4; width:calc(100% - 20px); margin:0 10px 4px; }
  #room-explorer .concept-note { grid-row:5; font-size:12px; margin:0 12px 6px; }
  #room-explorer .visual-caption { max-width:calc(100% - 16px); top:8px; left:8px; gap:6px; padding:4px 8px; }
  #room-explorer .visual-caption>span { display:none; }
  #room-explorer .visual-caption strong { font-size:14px; }
  #room-explorer .visual-caption small { font-size:12px; }
  #room-explorer .visual-caption .text-button { font-size:14px; }
  #room-explorer .room-panel { height:min(56dvh,620px); }
  #room-explorer .panel-heading h2 { font-size:21px; }
  #room-explorer .panel-budget-note { max-height:92px; overflow-y:auto; }
  .driveway-detail { width:clamp(140px,40%,190px); right:8px; bottom:8px; }
  .driveway-detail strong { font-size:14px; }
  .driveway-detail>span { font-size:12px; }
}

/* Landscape phones use one clear control row and a side drawer. */
@media screen and (max-height:600px) and (min-width:601px) {
  .explorer-topbar { padding:6px 12px; min-height:56px; gap:8px; flex-wrap:nowrap; }
  #room-explorer .viewer { grid-template-columns:minmax(0,1fr) auto; grid-template-rows:minmax(0,1fr) auto auto; }
  #room-explorer .visual-toolbar { grid-column:1; grid-row:2; width:auto; margin:4px 12px; justify-content:flex-start; }
  #room-explorer .viewer-bottom { grid-column:2; grid-row:2; margin:4px 12px 4px 0; }
  #room-explorer .environment-controls { grid-row:3; grid-column:1/-1; display:flex; align-items:center; gap:14px; width:min(620px,calc(100% - 24px)); margin:0 12px 4px; padding:0 10px; }
  #room-explorer .environment-controls>label { gap:8px; flex-shrink:0; }
  #room-explorer .environment-track { flex:1; min-width:0; }
  #room-explorer .concept-note { display:none; }
  #room-explorer #visual-status { position:absolute; width:1px; height:1px; overflow:hidden; clip-path:inset(50%); }
  #room-explorer .room-panel { inset:0 0 0 auto; height:100%; width:360px; max-width:75%; max-height:none; border-radius:0; border-left:1px solid #d7e3e9; }
  #room-explorer .panel-heading>p { display:none; }
  #room-explorer .panel-budget-note { max-height:64px; overflow:auto; }
  .zoom-controls #pan-tool { width:44px; padding:0; justify-content:center; }
  .pan-label { display:none; }
}

/* Very short/narrow windows retain scrolling instead of clipping controls. */
@media screen and (max-height:600px) and (max-width:600px) {
  #room-explorer .viewer { overflow-y:auto; grid-template-rows:minmax(160px,1fr) auto auto auto auto; }
  #room-explorer .concept-note { display:none; }
  #room-explorer .room-panel { inset:0; height:100%; max-height:none; border-radius:0; }
  #room-explorer .panel-budget-note { max-height:64px; overflow:auto; }
}
