/* Room Designer — touch / mobile / tablet */

/* Kiosk scroll mode (opt-in): scrollable page hides mobile browser chrome */
html.rd-mobile-kiosk-scroll,
body.rd-mobile-kiosk-scroll {
  overflow-x: hidden !important;
  overflow-y: auto !important;
  height: auto !important;
  min-height: calc(var(--rd-kiosk-height, 100dvh) + 52px) !important;
  max-height: none !important;
  overscroll-behavior-y: auto;
  touch-action: manipulation;
  -webkit-overflow-scrolling: touch;
}

body:not(.rd-mobile-kiosk-scroll) .rd-kiosk-scroll-shim {
  display: none !important;
}

html:fullscreen,
html:fullscreen body.rd-touch-device {
  overflow: hidden !important;
  height: 100% !important;
  min-height: 0 !important;
  max-height: none !important;
}

html:fullscreen .rd-kiosk-scroll-shim,
body.rd-mobile-fullscreen-active .rd-kiosk-scroll-shim {
  display: none !important;
}

.rd-kiosk-scroll-shim {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 52px;
  min-height: 52px;
  flex-shrink: 0;
  margin: 0;
  padding: 6px 10px;
  border: none;
  border-top: 1px solid rgba(148, 163, 184, 0.35);
  background: rgba(15, 23, 42, 0.92);
  color: rgba(248, 250, 252, 0.88);
  font-size: 11px;
  font-weight: 600;
  line-height: 1.2;
  text-align: center;
  cursor: pointer;
  pointer-events: auto;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

body.theme-light .rd-kiosk-scroll-shim {
  background: rgba(248, 250, 252, 0.96);
  color: rgba(15, 23, 42, 0.82);
  border-top-color: rgba(148, 163, 184, 0.45);
}

body.rd-touch-device.rd-mobile-landscape.rd-mobile-kiosk main#designer-app.room-designer-layout,
body.rd-touch-device.rd-mobile-landscape.rd-mobile-kiosk .room-designer-layout {
  position: static !important;
  top: auto !important;
  left: auto !important;
  right: auto !important;
  width: auto !important;
  z-index: auto !important;
}

body.rd-touch-device {
  overscroll-behavior-x: none;
  -webkit-overflow-scrolling: touch;
}

/* Viewer first on phones/tablets so the canvas is not buried under the library */
@media (max-width: 900px) {
  .room-designer-layout .panel-middle {
    order: 1 !important;
  }

  .room-designer-layout .panel-left {
    order: 2 !important;
  }

  .room-designer-layout .panel-right {
    order: 3 !important;
  }
}

/* Portrait: split screen — library top, viewer bottom */
@media (max-width: 900px) and (orientation: portrait) {
  body.rd-touch-device.rd-mobile-portrait:not(.rd-mobile-kiosk-scroll).theme-dark,
  body.rd-touch-device.rd-mobile-portrait:not(.rd-mobile-kiosk-scroll).theme-light {
    display: flex !important;
    flex-direction: column !important;
    height: 100dvh !important;
    max-height: 100dvh !important;
    overflow: hidden !important;
  }

  body.rd-touch-device.rd-mobile-portrait #innosaw-review-banner-host {
    flex-shrink: 0;
    width: 100%;
  }

  body.rd-touch-device.rd-mobile-portrait .nav-header {
    display: block !important;
    flex-shrink: 0 !important;
    position: sticky !important;
    top: 0 !important;
    z-index: 100001 !important;
    margin-bottom: 0 !important;
    padding: 0 !important;
    height: auto !important;
    max-height: none !important;
  }

  body.rd-touch-device.rd-mobile-portrait .nav-container {
    height: auto !important;
    min-height: 0 !important;
    padding: 4px 6px !important;
    flex-wrap: nowrap !important;
    gap: 4px !important;
  }

  body.rd-touch-device.rd-mobile-portrait .nav-brand img {
    height: 26px !important;
    max-width: 120px !important;
    object-fit: contain !important;
  }

  body.rd-touch-device.rd-mobile-portrait .nav-mobile-menu-toggle,
  body.rd-touch-device.rd-mobile-portrait .nav-experience-gate,
  body.rd-touch-device.rd-mobile-portrait .room-help-btn {
    display: none !important;
  }

  /* Layer toggles live in Opts menu on portrait — keep header to logo + price + cart */
  body.rd-touch-device.rd-mobile-portrait .nav-actions > div:first-of-type {
    display: none !important;
  }

  body.rd-touch-device.rd-mobile-portrait .nav-actions > div:nth-of-type(2) {
    border-right: none !important;
    padding-right: 0 !important;
  }

  body.rd-touch-device.rd-mobile-portrait #total-items-summary {
    display: none;
  }

  body.rd-touch-device.rd-mobile-portrait .nav-actions {
    gap: 4px !important;
    flex: 1 1 auto !important;
    min-width: 0 !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
  }

  body.rd-touch-device.rd-mobile-portrait .nav-icon-btn {
    min-width: 30px !important;
    min-height: 30px !important;
    padding: 3px !important;
  }

  body.rd-touch-device.rd-mobile-portrait .nav-icon-btn svg {
    width: 16px !important;
    height: 16px !important;
  }

  body.rd-touch-device.rd-mobile-portrait #total-items-summary {
    font-size: 9px !important;
  }

  body.rd-touch-device.rd-mobile-portrait #total-price-summary {
    font-size: 11px !important;
  }

  body.rd-touch-device.rd-mobile-portrait .header-theme-toggle {
    min-width: 34px !important;
    width: 34px !important;
    min-height: 30px !important;
    height: 30px !important;
    padding: 0 !important;
    font-size: 16px !important;
    line-height: 1 !important;
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    white-space: nowrap;
  }

  body.rd-touch-device.rd-mobile-portrait #add-room-to-cart-btn,
  body.rd-touch-device.rd-mobile-portrait .header-cart,
  body.rd-touch-device.rd-mobile-portrait #cart-toggle {
    font-size: 10px !important;
    padding: 4px 7px !important;
    min-height: 30px !important;
    max-height: 30px !important;
    line-height: 1.1 !important;
    white-space: nowrap !important;
    flex-shrink: 0;
  }

  body.rd-touch-device.rd-mobile-portrait #add-room-to-cart-btn {
    gap: 4px !important;
    font-weight: 600 !important;
  }

  body.rd-touch-device.rd-mobile-portrait #add-room-to-cart-btn .add-room-cart-icon {
    font-size: 12px;
    line-height: 1;
  }

  body.rd-touch-device.rd-mobile-portrait .nav-actions > div:nth-of-type(2) > div:first-child {
    min-width: 0 !important;
  }

  body.rd-touch-device.rd-mobile-portrait #total-price-summary {
    white-space: nowrap;
  }

  body.rd-touch-device.rd-mobile-portrait main#designer-app.room-designer-layout,
  body.rd-touch-device.rd-mobile-portrait .room-designer-layout {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) !important;
    grid-template-rows: minmax(0, 35fr) minmax(0, 65fr) !important;
    grid-template-areas:
      "library"
      "viewer" !important;
    flex: 1 1 0 !important;
    min-height: 0 !important;
    height: var(--rd-mobile-content-height, calc(100dvh - 42px)) !important;
    max-height: var(--rd-mobile-content-height, calc(100dvh - 42px)) !important;
    overflow: hidden !important;
    width: 100% !important;
    padding: 0 2px 2px !important;
    gap: 2px !important;
  }

  body.rd-touch-device.rd-mobile-portrait .room-designer-layout .panel-right {
    display: none !important;
  }

  body.rd-touch-device.rd-mobile-portrait main#designer-app.room-designer-layout .panel-left,
  body.rd-touch-device.rd-mobile-portrait .room-designer-layout .panel-left {
    grid-area: library !important;
    order: unset !important;
    flex: unset !important;
    min-height: 0 !important;
    max-height: 100% !important;
    height: 100% !important;
    width: 100% !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
    padding: 2px !important;
    position: relative !important;
    z-index: 3 !important;
    isolation: isolate !important;
    contain: layout paint !important;
  }

  body.rd-touch-device.rd-mobile-portrait.rd-rail-view-openings main#designer-app.room-designer-layout,
  body.rd-touch-device.rd-mobile-portrait.rd-rail-view-doors main#designer-app.room-designer-layout,
  body.rd-touch-device.rd-mobile-portrait.rd-rail-view-appliances main#designer-app.room-designer-layout {
    grid-template-rows: minmax(0, 35fr) minmax(0, 65fr) !important;
  }

  body.rd-touch-device.rd-mobile-portrait main#designer-app.room-designer-layout .panel-middle,
  body.rd-touch-device.rd-mobile-portrait .room-designer-layout .panel-middle {
    grid-area: viewer !important;
    order: unset !important;
    flex: unset !important;
    min-height: 0 !important;
    max-height: 100% !important;
    height: auto !important;
    width: 100% !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
    position: relative !important;
    z-index: 1 !important;
  }

  body.rd-touch-device.rd-mobile-portrait .panel-left .tab-nav {
    display: none !important;
  }

  body.rd-touch-device.rd-mobile-portrait .rd-landscape-rail-bar {
    display: flex !important;
    flex: 0 0 auto;
    width: 100%;
  }

  body.rd-touch-device.rd-mobile-portrait .panel-left .tab-container {
    flex: 1 1 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }

  body.rd-touch-device.rd-mobile-portrait .panel-left .tab-content.active {
    flex: 1 1 0;
    min-height: 0;
    overflow: hidden;
    display: flex !important;
    flex-direction: column;
  }

  body.rd-touch-device.rd-mobile-portrait #tab-room.tab-content.active {
    overflow-y: auto !important;
    overflow-x: hidden !important;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
  }

  body.rd-touch-device.rd-mobile-portrait #tab-cabinets.tab-content.active {
    overflow: hidden !important;
    flex: 1 1 0 !important;
    min-height: 0 !important;
    display: flex !important;
    flex-direction: column !important;
  }

  body.rd-touch-device.rd-mobile-portrait #cabinet-library-body {
    display: flex !important;
    flex-direction: column !important;
    flex: 1 1 0 !important;
    min-height: 0 !important;
    overflow: hidden !important;
    padding: 2px !important;
    gap: 4px;
  }

  body.rd-touch-device.rd-mobile-portrait #cabinet-library-body .cabinet-library-classic,
  body.rd-touch-device.rd-mobile-portrait #cabinet-library-body .cabinet-chain-placement-sidebar,
  body.rd-touch-device.rd-mobile-portrait #cabinet-library-body .cabinet-actions,
  body.rd-touch-device.rd-mobile-portrait .panel-left .panel-card-header {
    display: none !important;
  }

  body.rd-touch-device.rd-mobile-portrait #cabinet-library-body .cabinet-filter-row {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 4px;
    flex-shrink: 0;
  }

  body.rd-touch-device.rd-mobile-portrait #cabinet-library-body .field-block label {
    display: none;
  }

  body.rd-touch-device.rd-mobile-portrait .cabinet-library-grid-panel {
    flex: 1 1 0 !important;
    min-height: 0 !important;
    overflow: hidden !important;
    display: flex !important;
    flex-direction: column !important;
  }

  body.rd-touch-device.rd-mobile-portrait .cabinet-library-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    gap: 4px !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    flex: 1 1 0 !important;
    min-height: 0 !important;
    height: 0 !important;
    max-height: 100% !important;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
    overscroll-behavior: contain;
    padding-bottom: max(16px, env(safe-area-inset-bottom, 0px));
    scroll-padding-bottom: 16px;
    box-sizing: border-box !important;
  }

  body.rd-touch-device.rd-mobile-portrait .cabinet-library-grid.rd-mobile-cabinet-grid-locked,
  body.rd-touch-device.rd-mobile-cabinet-pointer-down .cabinet-library-grid {
    touch-action: none !important;
    overflow-y: hidden !important;
  }

  body.rd-touch-device.rd-mobile-portrait .cabinet-grid-tile {
    touch-action: none;
  }

  body.rd-touch-device.rd-mobile-portrait .panel-left button.cabinet-grid-tile,
  body.rd-touch-device.rd-mobile-portrait .rd-mobile-rail-embedded button.opening-preset-btn {
    height: auto !important;
    min-height: 0 !important;
    line-height: 1.2 !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
  }

  body.rd-touch-device.rd-mobile-portrait main#designer-app.room-designer-layout .panel-left .cabinet-grid-tile,
  body.rd-touch-device.rd-mobile-portrait #cabinet-library-grid .cabinet-grid-tile,
  body.rd-touch-device.rd-mobile-portrait .cabinet-grid-tile {
    min-height: 58px !important;
    max-height: none !important;
    height: auto !important;
    padding: 3px !important;
    gap: 2px !important;
    align-items: stretch !important;
    overflow: hidden !important;
  }

  body.rd-touch-device.rd-mobile-portrait main#designer-app.room-designer-layout .panel-left .cabinet-grid-tile-media,
  body.rd-touch-device.rd-mobile-portrait #cabinet-library-grid .cabinet-grid-tile-media,
  body.rd-touch-device.rd-mobile-portrait .cabinet-grid-tile-media {
    flex: 0 0 auto !important;
    flex-shrink: 0 !important;
    min-height: 72px !important;
    height: 72px !important;
    max-height: 72px !important;
    padding: 2px !important;
    width: 100%;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    overflow: hidden !important;
  }

  body.rd-touch-device.rd-mobile-portrait .cabinet-grid-tile-media--parametric .room-face-editor-card.grid-tile,
  body.rd-touch-device.rd-mobile-portrait .cabinet-grid-tile-media--parametric .cabinet-grid-face-editor-shell,
  body.rd-touch-device.rd-mobile-portrait .cabinet-grid-tile-media--parametric innosaw-face-interior-editor,
  body.rd-touch-device.rd-mobile-portrait .cabinet-grid-tile-media--parametric .cabinet-parametric-preview-host {
    width: 100% !important;
    height: 100% !important;
    min-height: 0 !important;
    max-height: 100% !important;
    flex: 1 1 auto !important;
  }

  body.rd-touch-device.rd-mobile-portrait .cabinet-grid-tile-media img {
    width: auto !important;
    height: 100% !important;
    max-width: 100% !important;
    max-height: 100% !important;
    object-fit: contain !important;
    object-position: center center !important;
    display: block !important;
    margin: 0 auto !important;
  }

  body.rd-touch-device.rd-mobile-portrait .cabinet-grid-tile-name {
    font-size: 8px !important;
    line-height: 1.1 !important;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    flex: 0 0 auto !important;
    flex-shrink: 0 !important;
    margin: 0;
    min-height: 0 !important;
    padding: 0 1px;
  }

  body.rd-touch-device.rd-mobile-portrait .panel-left .tab-container.rd-rail-slot-hidden {
    display: none !important;
  }

  body.rd-touch-device.rd-mobile-portrait .rd-mobile-rail-slot {
    flex: 1 1 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }

  body.rd-touch-device.rd-mobile-portrait .rd-mobile-rail-slot[hidden] {
    display: none !important;
  }

  body.rd-touch-device.rd-mobile-portrait .rd-mobile-rail-embedded {
    position: static !important;
    inset: auto !important;
    width: 100% !important;
    max-width: 100% !important;
    height: 100% !important;
    max-height: none !important;
    flex: 1 1 0;
    min-height: 0;
    display: flex !important;
    flex-direction: column;
    overflow: hidden !important;
    margin: 0 !important;
    transform: none !important;
    z-index: auto !important;
    box-shadow: none !important;
    border-radius: 0 !important;
  }

  body.rd-touch-device.rd-mobile-portrait .rd-mobile-rail-embedded .left-column-library-close,
  body.rd-touch-device.rd-mobile-portrait .rd-mobile-rail-embedded .modal-footer {
    display: none !important;
  }

  body.rd-touch-device.rd-mobile-portrait .rd-mobile-rail-embedded .left-column-library-header,
  body.rd-touch-device.rd-mobile-portrait .rd-mobile-rail-embedded .opening-library-header {
    flex-shrink: 0;
    padding: 4px 6px !important;
  }

  body.rd-touch-device.rd-mobile-portrait .rd-mobile-rail-embedded .left-column-library-header h3,
  body.rd-touch-device.rd-mobile-portrait .rd-mobile-rail-embedded .opening-library-header h3 {
    font-size: 10px !important;
    margin: 0;
  }

  body.rd-touch-device.rd-mobile-portrait .rd-mobile-rail-embedded .left-column-library-hint,
  body.rd-touch-device.rd-mobile-portrait .rd-mobile-rail-embedded .opening-library-body > .left-column-library-hint {
    display: none;
  }

  body.rd-touch-device.rd-mobile-portrait .rd-mobile-rail-embedded .left-column-library-body,
  body.rd-touch-device.rd-mobile-portrait .rd-mobile-rail-embedded .opening-library-body {
    flex: 1 1 0;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto !important;
    display: flex;
    flex-direction: column;
    padding: 2px !important;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
    overscroll-behavior: contain;
  }

  body.rd-touch-device.rd-mobile-portrait .rd-mobile-rail-embedded .appliance-categories,
  body.rd-touch-device.rd-mobile-portrait .rd-mobile-rail-embedded .left-column-library-filters {
    flex-shrink: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 2px;
    max-height: none;
    overflow: visible;
    margin-bottom: 2px !important;
  }

  body.rd-touch-device.rd-mobile-portrait .rd-mobile-rail-embedded .category-btn {
    padding: 2px 4px !important;
    font-size: 8px !important;
    min-height: 22px;
    line-height: 1.1;
  }

  body.rd-touch-device.rd-mobile-portrait .rd-mobile-rail-embedded .appliance-categories .category-btn,
  body.rd-touch-device.rd-mobile-portrait .rd-mobile-rail-embedded .left-column-library-filters .category-btn {
    width: auto !important;
    flex: 1 1 calc(50% - 2px);
    min-width: 0;
  }

  body.rd-touch-device.rd-mobile-portrait .rd-mobile-rail-embedded .appliance-grid,
  body.rd-touch-device.rd-mobile-portrait .rd-mobile-rail-embedded .opening-presets,
  body.rd-touch-device.rd-mobile-portrait .rd-mobile-rail-embedded .left-column-library-tile-grid {
    flex: 0 0 auto;
    min-height: 0;
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) !important;
    gap: 4px;
    width: 100%;
    max-width: 100%;
    padding: 0 1px;
    box-sizing: border-box;
    overflow: visible;
    align-content: start;
    justify-items: stretch;
  }

  body.rd-touch-device.rd-mobile-portrait .rd-mobile-rail-embedded .opening-category {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) !important;
    gap: 4px;
    margin-bottom: 6px;
  }

  body.rd-touch-device.rd-mobile-portrait .rd-mobile-rail-embedded .appliance-card,
  body.rd-touch-device.rd-mobile-portrait .rd-mobile-rail-embedded .left-column-library-tile,
  body.rd-touch-device.rd-mobile-portrait .rd-mobile-rail-embedded .opening-preset-btn {
    width: 100% !important;
    max-width: 100% !important;
    min-height: 72px !important;
    height: auto !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    padding: 4px 3px !important;
    box-sizing: border-box;
    overflow: hidden;
    text-align: center;
  }

  body.rd-touch-device.rd-mobile-portrait .rd-mobile-rail-embedded .appliance-preview-host,
  body.rd-touch-device.rd-mobile-portrait .rd-mobile-rail-embedded .left-column-library-tile-media {
    width: 100% !important;
    max-width: 100%;
    flex: 0 0 56px !important;
    flex-shrink: 0 !important;
    height: 56px !important;
    min-height: 56px !important;
    margin: 0 !important;
    padding: 2px !important;
    box-sizing: border-box;
  }

  body.rd-touch-device.rd-mobile-portrait .rd-mobile-rail-embedded .appliance-preview-image {
    width: auto;
    height: auto;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    object-position: center;
    display: block;
    margin: 0 auto;
  }

  body.rd-touch-device.rd-mobile-portrait .rd-mobile-rail-embedded .appliance-name,
  body.rd-touch-device.rd-mobile-portrait .rd-mobile-rail-embedded .left-column-library-tile-label,
  body.rd-touch-device.rd-mobile-portrait .rd-mobile-rail-embedded .opening-name {
    width: 100%;
    max-width: 100%;
    font-size: 8px !important;
    line-height: 1.15;
    text-align: center;
    padding: 0 1px;
    box-sizing: border-box;
    word-break: break-word;
    overflow-wrap: anywhere;
    -webkit-line-clamp: 3;
    min-height: 0;
  }

  body.rd-touch-device.rd-mobile-portrait .rd-mobile-rail-embedded .appliance-dims,
  body.rd-touch-device.rd-mobile-portrait .rd-mobile-rail-embedded .left-column-library-tile-meta,
  body.rd-touch-device.rd-mobile-portrait .rd-mobile-rail-embedded .opening-dims {
    width: 100%;
    max-width: 100%;
    font-size: 7px !important;
    line-height: 1.15;
    text-align: center;
    padding: 0 1px;
    box-sizing: border-box;
    word-break: break-word;
    overflow-wrap: anywhere;
  }

  body.rd-touch-device.rd-mobile-portrait main#designer-app.room-designer-layout .panel-middle #designer-canvas-container,
  body.rd-touch-device.rd-mobile-portrait .panel-middle #designer-canvas-container {
    flex: 1 1 0 !important;
    height: auto !important;
    min-height: 0 !important;
    max-height: none !important;
  }

  body.rd-touch-device.rd-mobile-portrait #designer-toolbar {
    flex-shrink: 0;
    padding: 2px 4px !important;
    margin: 0 !important;
  }

  body.rd-touch-device.rd-mobile-portrait #designer-toolbar .toolbar-group {
    flex-wrap: wrap;
    gap: 3px;
    font-size: 10px;
    padding: 3px 4px !important;
    width: 100% !important;
  }

  body.rd-touch-device.rd-mobile-portrait #designer-toolbar label,
  body.rd-touch-device.rd-mobile-portrait #open-room-settings-bottom-btn,
  body.rd-touch-device.rd-mobile-portrait #pictures-btn,
  body.rd-touch-device.rd-mobile-portrait #designer-toolbar .toolbar-divider,
  body.rd-touch-device.rd-mobile-portrait #designer-toolbar .rd-toolbar-logo {
    display: none !important;
  }

  body.rd-touch-device.rd-mobile-portrait #designer-toolbar .rd-top-options-btn,
  body.rd-touch-device.rd-mobile-portrait #designer-toolbar .rd-top-fullscreen-btn {
    margin-left: 4px;
    padding: 3px 8px !important;
    font-size: 10px !important;
    min-height: 28px;
  }

  body.rd-touch-device.rd-mobile-portrait #designer-toolbar button {
    font-size: 10px !important;
    padding: 3px 6px !important;
  }

  body.rd-touch-device.rd-mobile-portrait #designer-status-line {
    display: none !important;
  }

  body.rd-touch-device.rd-mobile-portrait .rd-bottom-place-btn {
    display: none !important;
  }

  body.rd-touch-device.rd-mobile-portrait .rd-bottom-move-btn {
    display: inline-flex !important;
  }

  body.rd-touch-device.rd-mobile-portrait #viewer-bottom-controls {
    flex-shrink: 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  body.rd-touch-device.rd-mobile-portrait.rd-rail-panel-expanded main#designer-app.room-designer-layout,
  body.rd-touch-device.rd-mobile-portrait.rd-rail-panel-expanded .room-designer-layout {
    grid-template-rows: minmax(0, 52fr) minmax(0, 48fr) !important;
  }

  body.rd-touch-device.rd-mobile-portrait.rd-rail-panel-collapsed main#designer-app.room-designer-layout,
  body.rd-touch-device.rd-mobile-portrait.rd-rail-panel-collapsed .room-designer-layout {
    grid-template-rows: auto minmax(0, 1fr) !important;
  }

  body.rd-touch-device.rd-mobile-portrait.rd-rail-panel-collapsed .panel-left .tab-container,
  body.rd-touch-device.rd-mobile-portrait.rd-rail-panel-collapsed .rd-mobile-rail-slot {
    display: none !important;
  }

  body.rd-touch-device.rd-mobile-portrait.rd-rail-panel-collapsed .panel-left {
    height: auto !important;
    min-height: 0 !important;
    flex: 0 0 auto !important;
  }
}

@media (max-width: 900px) and (orientation: landscape),
(max-height: 520px) and (orientation: landscape) {
  /* Side-by-side: narrow cabinet rail + full-height viewer (no page scroll) */
  html:not(.rd-mobile-kiosk),
  body.rd-mobile-landscape:not(.rd-mobile-kiosk).theme-dark,
  body.rd-mobile-landscape:not(.rd-mobile-kiosk).theme-light {
    overflow: hidden !important;
    height: 100% !important;
    max-height: 100% !important;
  }

  body.rd-touch-device.rd-mobile-landscape:not(.rd-mobile-kiosk).theme-dark,
  body.rd-touch-device.rd-mobile-landscape:not(.rd-mobile-kiosk).theme-light {
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
    height: 100dvh !important;
    max-height: 100dvh !important;
  }

  body.rd-touch-device.rd-mobile-landscape.rd-mobile-kiosk.theme-dark,
  body.rd-touch-device.rd-mobile-landscape.rd-mobile-kiosk.theme-light {
    display: flex !important;
    flex-direction: column !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    height: auto !important;
    min-height: calc(var(--rd-kiosk-height, 100dvh) + 52px) !important;
    max-height: none !important;
  }

  body.rd-touch-device.rd-mobile-landscape #innosaw-review-banner-host {
    flex-shrink: 0;
    width: 100%;
  }

  /* Top nav: logo, layer toggles, price, cart */
  body.rd-touch-device.rd-mobile-landscape .nav-header {
    display: block !important;
    flex-shrink: 0 !important;
    position: sticky !important;
    top: 0 !important;
    z-index: 100001 !important;
    margin-bottom: 0 !important;
    padding: 0 !important;
    height: auto !important;
    max-height: none !important;
    box-shadow: 0 1px 0 rgba(148, 163, 184, 0.25);
  }

  body.rd-touch-device.rd-mobile-landscape .nav-container {
    height: auto !important;
    min-height: 0 !important;
    max-width: 100% !important;
    padding: 4px 6px !important;
    flex-wrap: nowrap !important;
    gap: 4px !important;
    align-items: center !important;
  }

  body.rd-touch-device.rd-mobile-landscape .nav-brand {
    order: 1 !important;
    margin: 0 !important;
    flex-shrink: 0 !important;
  }

  body.rd-touch-device.rd-mobile-landscape .nav-brand img {
    height: 24px !important;
    width: auto !important;
    max-width: 72px !important;
    object-fit: contain !important;
  }

  body.rd-touch-device.rd-mobile-landscape .nav-mobile-menu-toggle,
  body.rd-touch-device.rd-mobile-landscape .nav-experience-gate {
    display: none !important;
  }

  body.rd-touch-device.rd-mobile-landscape .nav-actions {
    order: 2 !important;
    margin-left: auto !important;
    flex: 1 1 auto !important;
    min-width: 0 !important;
    gap: 4px !important;
    justify-content: flex-end !important;
    flex-wrap: nowrap !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
  }

  body.rd-touch-device.rd-mobile-landscape .room-help-btn {
    display: none !important;
  }

  body.rd-touch-device.rd-mobile-landscape .nav-actions > div {
    flex-shrink: 0;
    gap: 3px !important;
    padding-right: 4px !important;
    border-right: 1px solid rgba(148, 163, 184, 0.35) !important;
  }

  body.rd-touch-device.rd-mobile-landscape .nav-icon-btn {
    min-width: 30px !important;
    min-height: 30px !important;
    padding: 3px !important;
  }

  body.rd-touch-device.rd-mobile-landscape .nav-icon-btn svg {
    width: 16px !important;
    height: 16px !important;
  }

  body.rd-touch-device.rd-mobile-landscape #total-items-summary {
    font-size: 9px !important;
    line-height: 1.1 !important;
  }

  body.rd-touch-device.rd-mobile-landscape #total-price-summary {
    font-size: 11px !important;
    line-height: 1.1 !important;
  }

  body.rd-touch-device.rd-mobile-landscape #add-room-to-cart-btn {
    font-size: 10px !important;
    padding: 4px 7px !important;
    min-height: 30px !important;
    white-space: nowrap;
  }

  body.rd-touch-device.rd-mobile-landscape .header-cart,
  body.rd-touch-device.rd-mobile-landscape .nav-cart-btn {
    font-size: 10px !important;
    padding: 4px 7px !important;
    min-height: 30px !important;
    white-space: nowrap;
  }

  body.rd-touch-device.rd-mobile-landscape main#designer-app.room-designer-layout,
  body.rd-touch-device.rd-mobile-landscape .room-designer-layout {
    display: grid !important;
    grid-template-columns: minmax(156px, 172px) minmax(0, 1fr) !important;
    grid-template-rows: minmax(0, 1fr) !important;
    flex: 1 1 0 !important;
    flex-direction: row !important;
    align-items: stretch !important;
    height: auto !important;
    max-height: none !important;
    min-height: 0 !important;
    overflow: hidden !important;
    padding: 2px !important;
    gap: 2px !important;
  }

  body.rd-touch-device.rd-mobile-landscape.rd-mobile-kiosk-scroll main#designer-app.room-designer-layout,
  body.rd-touch-device.rd-mobile-landscape.rd-mobile-kiosk-scroll .room-designer-layout {
    height: var(--rd-kiosk-height, calc(100dvh - 44px)) !important;
    max-height: var(--rd-kiosk-height, calc(100dvh - 44px)) !important;
    flex: 0 0 auto !important;
  }

  body.rd-touch-device.rd-mobile-landscape.rd-rail-panel-expanded main#designer-app.room-designer-layout,
  body.rd-touch-device.rd-mobile-landscape.rd-rail-panel-expanded .room-designer-layout {
    grid-template-columns: minmax(220px, 280px) minmax(0, 1fr) !important;
  }

  body.rd-touch-device.rd-mobile-landscape.rd-rail-panel-collapsed main#designer-app.room-designer-layout,
  body.rd-touch-device.rd-mobile-landscape.rd-rail-panel-collapsed .room-designer-layout {
    grid-template-columns: minmax(44px, 52px) minmax(0, 1fr) !important;
  }

  body.rd-touch-device.rd-mobile-landscape .room-designer-layout .panel-right {
    display: none !important;
  }

  body.rd-touch-device.rd-mobile-landscape main#designer-app.room-designer-layout .panel-left,
  body.rd-touch-device.rd-mobile-landscape .room-designer-layout .panel-left {
    order: 0 !important;
    width: auto !important;
    height: 100% !important;
    max-height: 100% !important;
    min-height: 0 !important;
    overflow: hidden !important;
    display: flex !important;
    flex-direction: column !important;
    padding: 2px !important;
    position: relative !important;
  }

  body.rd-touch-device.rd-mobile-landscape.rd-rail-panel-collapsed .panel-left .tab-container,
  body.rd-touch-device.rd-mobile-landscape.rd-rail-panel-collapsed .rd-mobile-rail-slot {
    display: none !important;
  }

  body.rd-touch-device.rd-mobile-landscape.rd-rail-panel-collapsed .rd-landscape-rail-bar {
    flex-direction: column;
    align-items: stretch;
    padding: 2px 1px;
    min-height: 0;
    border-bottom: none;
    border-right: 1px solid var(--theme-border-panel, rgba(148, 163, 184, 0.35));
  }

  body.rd-touch-device.rd-mobile-landscape.rd-rail-panel-collapsed .rd-rail-tab-btn {
    flex: 0 0 auto;
    writing-mode: vertical-rl;
    text-orientation: mixed;
    min-height: 36px;
    padding: 2px 1px;
    font-size: 8px;
  }

  body.rd-touch-device.rd-mobile-landscape.rd-rail-panel-collapsed .rd-rail-menu-btn {
    flex: 0 0 auto;
    min-width: 28px;
    width: 28px;
  }

  body.rd-touch-device.rd-mobile-landscape main#designer-app.room-designer-layout .panel-middle,
  body.rd-touch-device.rd-mobile-landscape .room-designer-layout .panel-middle {
    order: 1 !important;
    width: auto !important;
    height: 100% !important;
    max-height: 100% !important;
    min-height: 0 !important;
    overflow: hidden !important;
    display: flex !important;
    flex-direction: column !important;
  }

  body.rd-touch-device.rd-mobile-landscape main#designer-app.room-designer-layout .panel-middle #designer-canvas-container,
  body.rd-touch-device.rd-mobile-landscape .panel-middle #designer-canvas-container {
    flex: 1 1 auto !important;
    height: auto !important;
    min-height: 0 !important;
    max-height: none !important;
  }

  body.rd-touch-device.rd-mobile-landscape #designer-toolbar {
    position: static !important;
    order: -1;
    flex-shrink: 0;
    top: auto !important;
    left: auto !important;
    margin: 0 0 2px 0 !important;
    padding: 2px 4px !important;
    max-width: 100%;
    z-index: 1;
    background: transparent !important;
  }

  body.rd-touch-device.rd-mobile-landscape #designer-toolbar .toolbar-group {
    flex-wrap: wrap;
    gap: 3px;
    font-size: 10px;
    padding: 4px 6px !important;
    width: 100% !important;
    align-items: center;
  }

  body.rd-touch-device.rd-mobile-landscape #designer-toolbar .rd-toolbar-logo {
    display: none !important;
  }

  body.rd-touch-device.rd-mobile-landscape #designer-toolbar .rd-top-options-btn,
  body.rd-touch-device.rd-mobile-landscape #designer-toolbar .rd-top-fullscreen-btn {
    margin-left: 4px;
    padding: 3px 8px !important;
    font-size: 10px !important;
    min-height: 28px;
  }

  body.rd-touch-device.rd-mobile-landscape #designer-toolbar label,
  body.rd-touch-device.rd-mobile-landscape #open-room-settings-bottom-btn,
  body.rd-touch-device.rd-mobile-landscape #pictures-btn,
  body.rd-touch-device.rd-mobile-landscape #designer-toolbar .toolbar-divider {
    display: none !important;
  }

  body.rd-touch-device.rd-mobile-landscape .panel-left .tab-nav {
    display: none !important;
  }

  body.rd-touch-device.rd-mobile-landscape #designer-status-line {
    display: none !important;
  }

  body.rd-touch-device.rd-mobile-landscape #viewer-bottom-controls {
    flex-shrink: 0;
    padding: 2px 4px !important;
    gap: 4px !important;
    font-size: 10px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  body.rd-touch-device.rd-mobile-landscape #viewer-bottom-controls button,
  body.rd-touch-device.rd-mobile-landscape #viewer-bottom-controls .btn-secondary {
    min-height: 32px;
    padding: 3px 6px;
    font-size: 10px;
    white-space: nowrap;
  }

  body.rd-touch-device.rd-mobile-landscape #designer-toolbar button {
    font-size: 10px !important;
    padding: 3px 6px !important;
  }

  body.rd-touch-device.rd-mobile-landscape .rd-bottom-move-btn {
    display: none !important;
  }

  body.rd-touch-device.rd-mobile-landscape .panel-left .tab-container {
    flex: 1 1 0;
    min-height: 0;
    max-height: 100%;
    height: auto !important;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }

  body.rd-touch-device.rd-mobile-landscape .panel-left .tab-content.active {
    flex: 1 1 0;
    min-height: 0;
    max-height: 100%;
    height: auto !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
  }

  body.rd-touch-device.rd-mobile-landscape #tab-cabinets.tab-content.active {
    overflow: hidden !important;
  }

  body.rd-touch-device.rd-mobile-landscape #tab-export.tab-content.active {
    padding-right: 2px !important;
    padding-bottom: 8px !important;
  }

  body.rd-touch-device.rd-mobile-landscape .panel-left .panel-card.collapsible .panel-card-header {
    padding: 4px 6px !important;
  }

  body.rd-touch-device.rd-mobile-landscape .panel-left .panel-card.collapsible .panel-card-header h3 {
    font-size: 10px !important;
    margin: 0;
  }

  body.rd-touch-device.rd-mobile-landscape .panel-left .collapse-icon {
    display: none;
  }

  body.rd-touch-device.rd-mobile-landscape #cabinet-library-body {
    display: flex !important;
    flex-direction: column !important;
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden !important;
    padding: 2px !important;
    gap: 4px;
  }

  body.rd-touch-device.rd-mobile-landscape #cabinet-library-body .cabinet-library-classic,
  body.rd-touch-device.rd-mobile-landscape .cabinet-chain-placement-sidebar,
  body.rd-touch-device.rd-mobile-landscape .cabinet-actions {
    display: none !important;
  }

  body.rd-touch-device.rd-mobile-landscape #cabinet-library-body > .field-block {
    flex-shrink: 0;
    margin: 0;
  }

  body.rd-touch-device.rd-mobile-landscape #cabinet-library-body .cabinet-filter-row {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 3px;
    flex-shrink: 0;
    margin: 0;
  }

  body.rd-touch-device.rd-mobile-landscape #cabinet-library-body .cabinet-filter-row .field-block {
    margin: 0;
    min-width: 0;
  }

  body.rd-touch-device.rd-mobile-landscape #designer-category-select,
  body.rd-touch-device.rd-mobile-landscape #designer-subcategory-select {
    width: 100%;
    min-height: 28px;
    max-height: 28px;
    padding: 2px 4px;
    font-size: 9px;
    line-height: 1.1;
  }

  body.rd-touch-device.rd-mobile-landscape #designer-cabinet-search {
    padding: 4px 6px;
    font-size: 11px;
    min-height: 32px;
  }

  body.rd-touch-device.rd-mobile-landscape .cabinet-library-grid-panel {
    flex: 1 1 auto !important;
    min-height: 0 !important;
    max-height: none !important;
    overflow: hidden !important;
    display: flex !important;
    flex-direction: column !important;
  }

  body.rd-touch-device.rd-mobile-landscape .cabinet-library-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 3px !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    flex: 1 1 auto;
    min-height: 0;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
    padding-right: 2px;
  }

  body.rd-touch-device.rd-mobile-landscape .cabinet-grid-category-header {
    font-size: 8px !important;
    padding: 2px 0 !important;
    margin: 2px 0 0 0 !important;
    grid-column: 1 / -1;
  }

  /* unified-layout-base.css forces .panel-left button { height: 24px } in landscape — exclude library tiles */
  body.rd-touch-device.rd-mobile-landscape .panel-left button.cabinet-grid-tile,
  body.rd-touch-device.rd-mobile-landscape .rd-mobile-rail-embedded button.opening-preset-btn {
    height: auto !important;
    min-height: 0 !important;
    line-height: 1.2 !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
  }

  body.rd-touch-device.rd-mobile-landscape main#designer-app.room-designer-layout .panel-left .cabinet-grid-tile,
  body.rd-touch-device.rd-mobile-landscape #cabinet-library-grid .cabinet-grid-tile,
  body.rd-touch-device.rd-mobile-landscape .cabinet-grid-tile {
    min-height: 58px !important;
    max-height: none !important;
    height: auto !important;
    padding: 3px !important;
    gap: 2px !important;
    align-items: stretch !important;
    overflow: hidden !important;
  }

  body.rd-touch-device.rd-mobile-landscape .cabinet-grid-tile-media {
    flex: 0 0 auto !important;
    flex-shrink: 0 !important;
    min-height: 56px !important;
    height: 56px !important;
    max-height: 56px !important;
    padding: 2px !important;
    width: 100%;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    overflow: hidden !important;
  }

  body.rd-touch-device.rd-mobile-landscape .cabinet-grid-tile-media--parametric .room-face-editor-card.grid-tile,
  body.rd-touch-device.rd-mobile-landscape .cabinet-grid-tile-media--parametric .cabinet-grid-face-editor-shell,
  body.rd-touch-device.rd-mobile-landscape .cabinet-grid-tile-media--parametric innosaw-face-interior-editor,
  body.rd-touch-device.rd-mobile-landscape .cabinet-grid-tile-media--parametric .cabinet-parametric-preview-host {
    width: 100% !important;
    height: 100% !important;
    min-height: 0 !important;
    max-height: 100% !important;
  }

  body.rd-touch-device.rd-mobile-landscape .cabinet-grid-tile-media img {
    width: auto !important;
    height: 100% !important;
    max-width: 100% !important;
    max-height: 100% !important;
    object-fit: contain !important;
    object-position: center center !important;
    display: block !important;
    margin: 0 auto !important;
  }

  body.rd-touch-device.rd-mobile-landscape .cabinet-grid-tile-name {
    font-size: 8px !important;
    line-height: 1.1 !important;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    flex: 0 0 auto !important;
    flex-shrink: 0 !important;
    margin: 0;
    min-height: 0;
    padding: 0 1px;
  }

  body.rd-touch-device.rd-mobile-landscape #cabinet-library-body .field-block label {
    display: none;
  }

  body.rd-touch-device.rd-mobile-landscape .panel-left .panel-card-header {
    display: none !important;
  }

  body.rd-touch-device.rd-mobile-landscape #rd-bottom-options {
    display: none !important;
  }

  body.rd-touch-device.rd-mobile-landscape #selection-toolbar {
    display: none !important;
  }

  /* Embedded doors/appliances fill the left rail below tab buttons */
  body.rd-touch-device.rd-mobile-landscape .panel-left .tab-container.rd-rail-slot-hidden {
    display: none !important;
  }

  body.rd-touch-device.rd-mobile-landscape .rd-mobile-rail-slot {
    flex: 1 1 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }

  body.rd-touch-device.rd-mobile-landscape .rd-mobile-rail-slot[hidden] {
    display: none !important;
  }

  body.rd-touch-device.rd-mobile-landscape .rd-mobile-rail-embedded {
    position: static !important;
    inset: auto !important;
    width: 100% !important;
    max-width: 100% !important;
    height: 100% !important;
    max-height: none !important;
    flex: 1 1 0;
    min-height: 0;
    display: flex !important;
    flex-direction: column;
    overflow: hidden !important;
    margin: 0 !important;
    transform: none !important;
    z-index: auto !important;
    box-shadow: none !important;
    border-radius: 0 !important;
  }

  body.rd-touch-device.rd-mobile-landscape .rd-mobile-rail-embedded .left-column-library-close,
  body.rd-touch-device.rd-mobile-landscape .rd-mobile-rail-embedded .modal-footer {
    display: none !important;
  }

  body.rd-touch-device.rd-mobile-landscape .rd-mobile-rail-embedded .left-column-library-header,
  body.rd-touch-device.rd-mobile-landscape .rd-mobile-rail-embedded .opening-library-header {
    flex-shrink: 0;
    padding: 4px 6px !important;
  }

  body.rd-touch-device.rd-mobile-landscape .rd-mobile-rail-embedded .left-column-library-header h3,
  body.rd-touch-device.rd-mobile-landscape .rd-mobile-rail-embedded .opening-library-header h3 {
    font-size: 10px !important;
    margin: 0;
  }

  body.rd-touch-device.rd-mobile-landscape .rd-mobile-rail-embedded .left-column-library-hint,
  body.rd-touch-device.rd-mobile-landscape .rd-mobile-rail-embedded .opening-library-body > .left-column-library-hint {
    display: none;
  }

  body.rd-touch-device.rd-mobile-landscape .rd-mobile-rail-embedded .left-column-library-body,
  body.rd-touch-device.rd-mobile-landscape .rd-mobile-rail-embedded .opening-library-body {
    flex: 1 1 0;
    min-height: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    padding: 2px !important;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
  }

  body.rd-touch-device.rd-mobile-landscape .rd-mobile-rail-embedded .appliance-categories,
  body.rd-touch-device.rd-mobile-landscape .rd-mobile-rail-embedded .left-column-library-filters {
    flex-shrink: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 2px;
    max-height: 44px;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    margin-bottom: 2px !important;
  }

  body.rd-touch-device.rd-mobile-landscape .rd-mobile-rail-embedded .category-btn {
    padding: 2px 4px !important;
    font-size: 8px !important;
    min-height: 22px;
    line-height: 1.1;
  }

  body.rd-touch-device.rd-mobile-landscape .rd-mobile-rail-embedded .appliance-categories .category-btn,
  body.rd-touch-device.rd-mobile-landscape .rd-mobile-rail-embedded .left-column-library-filters .category-btn {
    width: auto !important;
    flex: 1 1 calc(50% - 2px);
    min-width: 0;
  }

  body.rd-touch-device.rd-mobile-landscape .rd-mobile-rail-embedded .appliance-grid,
  body.rd-touch-device.rd-mobile-landscape .rd-mobile-rail-embedded .opening-presets,
  body.rd-touch-device.rd-mobile-landscape .rd-mobile-rail-embedded .left-column-library-tile-grid {
    flex: 1 1 0;
    min-height: 0;
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) !important;
    gap: 4px;
    width: 100%;
    max-width: 100%;
    padding: 0 1px;
    box-sizing: border-box;
    overflow-y: auto !important;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
    overscroll-behavior: contain;
    align-content: start;
    justify-items: stretch;
  }

  body.rd-touch-device.rd-mobile-landscape .rd-mobile-rail-embedded .opening-category {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) !important;
    gap: 4px;
    margin-bottom: 6px;
  }

  body.rd-touch-device.rd-mobile-landscape .rd-mobile-rail-embedded .appliance-card,
  body.rd-touch-device.rd-mobile-landscape .rd-mobile-rail-embedded .left-column-library-tile,
  body.rd-touch-device.rd-mobile-landscape .rd-mobile-rail-embedded .opening-preset-btn {
    width: 100% !important;
    max-width: 100% !important;
    min-height: 72px !important;
    height: auto !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    padding: 4px 3px !important;
    box-sizing: border-box;
    overflow: hidden;
    text-align: center;
  }

  body.rd-touch-device.rd-mobile-landscape .rd-mobile-rail-embedded .appliance-preview-host,
  body.rd-touch-device.rd-mobile-landscape .rd-mobile-rail-embedded .left-column-library-tile-media {
    width: 100% !important;
    max-width: 100%;
    flex: 0 0 56px !important;
    flex-shrink: 0 !important;
    height: 56px !important;
    min-height: 56px !important;
    margin: 0 !important;
    padding: 2px !important;
    box-sizing: border-box;
  }

  body.rd-touch-device.rd-mobile-landscape .rd-mobile-rail-embedded .appliance-preview-image {
    width: auto;
    height: auto;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    object-position: center;
    display: block;
    margin: 0 auto;
  }

  body.rd-touch-device.rd-mobile-landscape .rd-mobile-rail-embedded .appliance-name,
  body.rd-touch-device.rd-mobile-landscape .rd-mobile-rail-embedded .left-column-library-tile-label,
  body.rd-touch-device.rd-mobile-landscape .rd-mobile-rail-embedded .opening-name {
    width: 100%;
    max-width: 100%;
    font-size: 8px !important;
    line-height: 1.15;
    text-align: center;
    padding: 0 1px;
    box-sizing: border-box;
    word-break: break-word;
    overflow-wrap: anywhere;
    -webkit-line-clamp: 3;
    min-height: 0;
  }

  body.rd-touch-device.rd-mobile-landscape .rd-mobile-rail-embedded .appliance-dims,
  body.rd-touch-device.rd-mobile-landscape .rd-mobile-rail-embedded .left-column-library-tile-meta,
  body.rd-touch-device.rd-mobile-landscape .rd-mobile-rail-embedded .opening-dims {
    width: 100%;
    max-width: 100%;
    font-size: 7px !important;
    line-height: 1.15;
    text-align: center;
    padding: 0 1px;
    box-sizing: border-box;
    word-break: break-word;
    overflow-wrap: anywhere;
  }
}

/* Touch: disable native image long-press / drag on library previews */
body.rd-touch-device .cabinet-grid-tile-media img,
body.rd-touch-device .appliance-preview-host,
body.rd-touch-device .appliance-preview-image {
  -webkit-user-drag: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  pointer-events: none;
}

body.rd-touch-device .cabinet-grid-tile,
body.rd-touch-device .appliance-card,
body.rd-touch-device .opening-preset-btn {
  -webkit-touch-callout: none;
}

/* Portrait: allow cabinet grid scroll; drag uses pointer handler after downward move */
body.rd-touch-device.rd-mobile-portrait .cabinet-grid-tile {
  touch-action: pan-y;
}

body.rd-touch-device.rd-mobile-portrait .rd-mobile-rail-embedded .appliance-card,
body.rd-touch-device.rd-mobile-portrait .rd-mobile-rail-embedded .opening-preset-btn,
body.rd-touch-device.rd-mobile-portrait .rd-mobile-rail-embedded .left-column-library-tile {
  touch-action: pan-y;
}

body.rd-touch-device.rd-mobile-portrait.rd-mobile-library-item-dragging .cabinet-library-grid,
body.rd-touch-device.rd-mobile-portrait.rd-mobile-library-item-dragging .rd-mobile-rail-embedded .appliance-grid,
body.rd-touch-device.rd-mobile-portrait.rd-mobile-library-item-dragging .rd-mobile-rail-embedded .opening-presets,
body.rd-touch-device.rd-mobile-portrait.rd-mobile-library-item-dragging .rd-mobile-rail-embedded .left-column-library-tile-grid {
  touch-action: none !important;
  overscroll-behavior: contain;
}

/* Compact single-line bottom toolbar for all touch devices */
body.rd-touch-device.rd-touch-compact-bottom #rd-mobile-place-bar,
body.rd-touch-device.rd-touch-compact-bottom #rd-mobile-viewer-controls {
  display: none !important;
}

body.rd-touch-device.rd-touch-compact-bottom #viewer-bottom-controls {
  padding: 2px 4px !important;
  gap: 4px !important;
  flex-wrap: nowrap !important;
  min-height: 0 !important;
}

body.rd-touch-device.rd-touch-compact-bottom #viewer-bottom-controls > div {
  flex-wrap: nowrap !important;
  gap: 4px !important;
  align-items: center !important;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

body.rd-touch-device.rd-touch-compact-bottom #viewer-bottom-controls > div:last-child {
  display: none !important;
}

.rd-mobile-bottom-strip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.rd-bottom-chip {
  min-height: 30px;
  min-width: 30px;
  padding: 2px 7px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.08);
  color: #f8fafc;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.2;
  cursor: pointer;
  flex-shrink: 0;
  white-space: nowrap;
}

.rd-bottom-chip:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.rd-bottom-chip.is-armed,
.rd-bottom-chip.is-active {
  background: #15803d;
  border-color: #22c55e;
  color: #ecfdf5;
}

.rd-bottom-chip.rd-mobile-multi-btn.is-active {
  background: rgba(6, 95, 70, 0.85);
  border-color: #34d399;
  color: #ecfdf5;
}

.rd-bottom-chip.rd-bottom-delete-btn:not(:disabled) {
  background: rgba(127, 29, 29, 0.55);
  border-color: #f87171;
  color: #fecaca;
}

.rd-bottom-chip.rd-bottom-move-btn.is-active {
  background: rgba(29, 78, 216, 0.55);
  border-color: #60a5fa;
  color: #e0f2fe;
}

.rd-bottom-move-btn {
  display: none;
}

.rd-mobile-cabinet-select-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
  min-width: 58px;
  max-width: 92px;
  min-height: 28px;
  border: 1px solid #60a5fa;
  border-radius: 4px;
  background: rgba(30, 41, 59, 0.95);
  overflow: hidden;
}

.rd-mobile-cabinet-select-display {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  padding: 0 18px 0 5px;
  pointer-events: none;
  font-size: 11px;
  font-weight: 700;
  color: #f8fafc;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  z-index: 2;
}

.rd-mobile-cabinet-select-wrap .selection-toolbar-cabinet-select {
  position: relative;
  z-index: 3;
  width: 100%;
  min-width: 0;
  max-width: none;
  min-height: 28px;
  margin: 0;
  padding: 2px 18px 2px 5px;
  border: none !important;
  background: transparent !important;
  color: transparent !important;
  -webkit-text-fill-color: transparent;
  appearance: auto;
}

.rd-bottom-chip.rd-bottom-options-btn {
  background: rgba(29, 78, 216, 0.35);
  border-color: #60a5fa;
}

body.rd-touch-device.rd-touch-compact-bottom #undo-redo-toolbar {
  padding: 0 !important;
  margin: 0 !important;
  gap: 3px !important;
  flex-shrink: 0;
}

body.rd-touch-device.rd-touch-compact-bottom #undo-redo-toolbar .undo-redo-btn {
  min-height: 30px;
  min-width: 30px;
  padding: 2px 6px !important;
  font-size: 11px;
}

body.rd-touch-device.rd-touch-compact-bottom #undo-redo-toolbar .undo-redo-btn .btn-label {
  display: none;
}

body.rd-touch-device.rd-touch-compact-bottom #undo-redo-toolbar #history-status {
  display: none;
}

/* Hide non-essential bottom controls on touch; tablet keeps bump */
body.rd-touch-device.rd-touch-compact-bottom #bump-left-btn,
body.rd-touch-device.rd-touch-compact-bottom #bump-right-btn,
body.rd-touch-device.rd-touch-compact-bottom .viewer-toolbar-group-label,
body.rd-touch-device.rd-touch-compact-bottom .chain-placement-btn,
body.rd-touch-device.rd-touch-compact-bottom #measure-toggle-btn,
body.rd-touch-device.rd-touch-compact-bottom #left-click-rotate-btn,
body.rd-touch-device.rd-touch-compact-bottom #left-click-pan-btn,
body.rd-touch-device.rd-touch-compact-bottom #shortcuts-btn,
body.rd-touch-device.rd-touch-compact-bottom #viewer-delete-selected-btn,
body.rd-touch-device.rd-touch-compact-bottom .viewer-toolbar-divider {
  display: none !important;
}

body.rd-touch-device.rd-tablet-layout.rd-touch-compact-bottom #bump-left-btn,
body.rd-touch-device.rd-tablet-layout.rd-touch-compact-bottom #bump-right-btn {
  display: inline-flex !important;
  min-height: 30px;
  padding: 2px 6px !important;
  font-size: 11px;
}

.rd-mobile-option-row {
  display: flex !important;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  cursor: pointer;
}

.rd-mobile-option-row input[type="checkbox"] {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.rd-mobile-option-action {
  width: 100%;
  text-align: left;
  border: none;
  background: transparent;
  cursor: pointer;
  font: inherit;
}

/* Mobile docked: room options in Opts menu, compact room picker */
body.rd-touch-device.rd-mobile-portrait #tab-room .layout-display-options,
body.rd-touch-device.rd-mobile-landscape #tab-room .layout-display-options,
body.rd-touch-device.rd-mobile-portrait #tab-room .room-library-launch-grid,
body.rd-touch-device.rd-mobile-landscape #tab-room .room-library-launch-grid,
body.rd-touch-device.rd-mobile-portrait .room-select-hint,
body.rd-touch-device.rd-mobile-landscape .room-select-hint {
  display: none !important;
}

body.rd-touch-device.rd-mobile-portrait #room-select.room-select-dropdown,
body.rd-touch-device.rd-mobile-landscape #room-select.room-select-dropdown {
  width: 100%;
  max-height: none;
  height: auto;
  min-height: 32px;
  font-size: 12px;
  padding: 4px 6px;
}

body.rd-touch-device.rd-mobile-portrait #tab-room .room-action-row,
body.rd-touch-device.rd-mobile-landscape #tab-room .room-action-row {
  margin-top: 6px;
  gap: 4px;
}

body.rd-touch-device.rd-mobile-portrait #tab-room .room-action-row .btn-secondary,
body.rd-touch-device.rd-mobile-landscape #tab-room .room-action-row .btn-secondary {
  padding: 4px 6px;
  font-size: 10px;
  min-height: 30px;
}

body.rd-touch-device.rd-mobile-portrait #tab-room .room-panel-card .panel-card-header,
body.rd-touch-device.rd-mobile-landscape #tab-room .room-panel-card .panel-card-header {
  padding: 4px 6px !important;
}

body.rd-touch-device.rd-mobile-portrait #tab-room .room-panel-card .panel-card-header h3,
body.rd-touch-device.rd-mobile-landscape #tab-room .room-panel-card .panel-card-header h3 {
  font-size: 11px !important;
  margin: 0;
}

body.rd-touch-device.rd-mobile-landscape #tab-room.tab-content.active {
  overflow-y: auto !important;
  overflow-x: hidden !important;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
}

/* Landscape rail bar — Cabs / Room tabs + menu always visible */
.rd-landscape-rail-bar {
  display: none;
  flex: 0 0 auto;
  flex-wrap: nowrap;
  align-items: stretch;
  gap: 1px;
  padding: 1px 2px;
  min-height: 22px;
  border-bottom: 1px solid var(--theme-border-panel, rgba(148, 163, 184, 0.35));
  background: var(--theme-bg-panel, rgba(15, 23, 42, 0.94));
}

body.rd-touch-device.rd-mobile-landscape .rd-landscape-rail-bar,
body.rd-touch-device.rd-mobile-portrait .rd-landscape-rail-bar {
  display: flex;
}

.rd-rail-tab-btn {
  flex: 1 1 0;
  min-width: 0;
  min-height: 20px;
  padding: 0 2px;
  border-radius: 4px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--theme-fg-muted, rgba(248, 250, 252, 0.72));
  font-size: 7px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
  cursor: pointer;
}

.rd-rail-panel-toggle-btn {
  flex: 0 0 36px;
  min-width: 36px;
  min-height: 36px;
  padding: 0;
  border-radius: 8px;
  border: 1px solid var(--theme-border-panel, rgba(148, 163, 184, 0.45));
  background: rgba(30, 41, 59, 0.85);
  color: var(--theme-fg-base, #f8fafc);
  font-size: 16px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  touch-action: manipulation;
}

.rd-rail-panel-toggle-btn.is-expanded {
  color: #7dd3fc;
  border-color: rgba(56, 189, 248, 0.55);
}

body.rd-touch-device.rd-mobile-portrait .rd-rail-panel-toggle-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

body.rd-touch-device.rd-mobile-landscape .rd-rail-panel-toggle-btn {
  display: none !important;
}

.rd-rail-tab-btn.active {
  color: var(--theme-accent-color, #38bdf8);
  border-color: rgba(56, 189, 248, 0.45);
  background: rgba(56, 189, 248, 0.12);
}

/* Landscape menu button sits in the rail bar row */
.rd-rail-menu-btn {
  display: none;
  flex: 0 0 22px;
  position: static;
  min-width: 22px;
  min-height: 22px;
  padding: 0 2px;
  border-radius: 5px;
  border: 1px solid var(--theme-border-panel, rgba(148, 163, 184, 0.45));
  background: var(--theme-bg-panel, rgba(15, 23, 42, 0.94));
  color: var(--theme-fg-base, #f8fafc);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: none;
}

body.rd-touch-device.rd-mobile-landscape .rd-landscape-rail-bar .rd-rail-menu-btn {
  display: block;
}

/* Inline cabinet picker + W/H/D on the bottom toolbar row */
.rd-bottom-selection-inline {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  flex-shrink: 1;
  min-width: 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.rd-bottom-selection-inline[hidden] {
  display: none !important;
}

.rd-bottom-selection-inline .rd-selection-count-label {
  font-size: 9px;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.75);
  white-space: nowrap;
  flex-shrink: 0;
}

.rd-bottom-selection-inline .selection-toolbar-cabinet-select {
  max-width: 72px;
  min-width: 52px;
  min-height: 28px;
  padding: 1px 3px;
  font-size: 9px;
  flex-shrink: 0;
}

.rd-bottom-selection-inline > div {
  display: inline-flex !important;
  align-items: center;
  gap: 2px !important;
  flex-shrink: 0;
}

.rd-bottom-selection-inline input[type="text"] {
  width: 36px !important;
  min-width: 36px !important;
  padding: 1px 2px !important;
  font-size: 10px !important;
}

.rd-bottom-selection-inline .unit {
  display: none !important;
}

.rd-bottom-selection-inline span:first-child {
  font-size: 8px !important;
  color: rgba(255, 255, 255, 0.65) !important;
}

.rd-bottom-selection-actions {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.rd-bottom-selection-actions[hidden] {
  display: none !important;
}

/* Mobile docked: row 1 = cabinet/opening info; row 2 = action chips */
body.rd-touch-device.rd-landscape-selection-inline .rd-mobile-bottom-strip {
  flex-wrap: wrap;
  align-items: center;
  row-gap: 2px;
}

body.rd-touch-device.rd-landscape-selection-inline #viewer-bottom-controls {
  min-height: 68px;
  align-items: flex-start;
}

body.rd-touch-device.rd-landscape-selection-inline .rd-bottom-selection-actions:not([hidden]) {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  flex-shrink: 0;
}

body.rd-touch-device.rd-landscape-selection-inline .rd-bottom-selection-inline:not([hidden]) {
  flex: 0 0 100%;
  width: 100%;
  max-width: 100%;
  order: -1;
  flex-wrap: wrap;
  overflow-x: visible;
  row-gap: 4px;
  padding-bottom: 4px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

body.rd-touch-device.rd-landscape-selection-inline .rd-bottom-selection-inline:not([hidden]) > div {
  flex-wrap: wrap;
}

body.rd-touch-device.rd-landscape-selection-inline .rd-bottom-selection-inline .rd-selection-count-label {
  font-size: 11px;
}

body.rd-touch-device.rd-landscape-selection-inline .rd-bottom-selection-inline .selection-toolbar-cabinet-select {
  max-width: 88px;
  min-width: 56px;
  min-height: 30px;
  padding: 2px 4px;
  font-size: 11px;
}

body.rd-touch-device.rd-landscape-selection-inline .rd-mobile-cabinet-select-wrap {
  max-width: 88px;
  min-width: 56px;
}

body.rd-touch-device.rd-landscape-selection-inline .rd-bottom-selection-inline input[type="text"] {
  width: 50px !important;
  min-width: 50px !important;
  padding: 1px 2px !important;
  font-size: 11px !important;
  letter-spacing: -0.02em;
}

body.rd-touch-device.rd-landscape-selection-inline .rd-bottom-selection-inline > div span:first-child {
  font-size: 10px !important;
  color: rgba(255, 255, 255, 0.75) !important;
  min-width: 10px;
}

body.rd-touch-device.rd-landscape-selection-inline .rd-bottom-selection-inline .rd-selection-name-label {
  font-size: 11px !important;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.9) !important;
  max-width: 100px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

body.rd-touch-device.rd-landscape-selection-inline .rd-bottom-chip {
  min-height: 26px;
  min-width: 26px;
  padding: 1px 5px;
  font-size: 10px;
}

.rd-bottom-chip.rd-bottom-edit-btn {
  background: rgba(29, 78, 216, 0.55);
  border-color: #60a5fa;
}

.rd-bottom-chip.rd-bottom-actions-btn {
  background: rgba(71, 85, 105, 0.65);
}

.rd-bottom-chip.rd-bottom-resize-btn.is-active {
  background: rgba(29, 78, 216, 0.45);
  border-color: #60a5fa;
}

/* Floating controls — legacy fallback when compact bottom bar is unavailable */
.rd-mobile-viewer-controls {
  position: absolute;
  top: 8px;
  right: 8px;
  left: auto;
  z-index: 1200;
  display: none;
  flex-direction: column;
  gap: 6px;
  pointer-events: none;
}

body.rd-touch-device:not(.rd-touch-compact-bottom) .rd-mobile-viewer-controls {
  display: flex;
}

.rd-mobile-viewer-controls button {
  pointer-events: auto;
  min-height: 44px;
  min-width: 44px;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: rgba(14, 23, 38, 0.88);
  color: #f8fafc;
  font-size: 13px;
  font-weight: 700;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
  cursor: pointer;
}

.rd-mobile-viewer-controls button.active {
  border-color: #38bdf8;
  background: rgba(14, 165, 233, 0.22);
  color: #e0f2fe;
}

/* Tap-to-place bar above bottom toolbar */
.rd-mobile-place-bar {
  display: none;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 8px 10px;
  margin: 0;
  background: rgba(14, 165, 233, 0.14);
  border-top: 1px solid rgba(56, 189, 248, 0.35);
  border-bottom: 1px solid rgba(56, 189, 248, 0.2);
  color: #e2e8f0;
  font-size: 13px;
}

body.rd-touch-device .rd-mobile-place-bar.is-visible {
  display: flex;
}

.rd-mobile-place-bar .rd-mobile-place-label {
  flex: 1 1 140px;
  min-width: 0;
  font-weight: 600;
  line-height: 1.3;
}

.rd-mobile-place-bar button {
  min-height: 44px;
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.08);
  color: #f8fafc;
}

.rd-mobile-place-bar .rd-mobile-place-primary {
  background: #1d4ed8;
  border-color: #3b82f6;
}

.rd-mobile-place-bar .rd-mobile-place-primary.is-armed {
  background: #15803d;
  border-color: #22c55e;
}

/* Touch-friendly selection toolbar actions */
#selection-toolbar .rd-mobile-toolbar-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

#selection-toolbar .rd-mobile-toolbar-btn {
  min-height: 40px;
  min-width: 40px;
  padding: 6px 10px;
  border-radius: 6px;
  border: 1px solid var(--theme-border-panel, #cbd5e1);
  background: var(--theme-bg-panel, #fff);
  color: var(--theme-fg-base, #0f172a);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  flex-shrink: 0;
}

#selection-toolbar .rd-mobile-toolbar-btn.rd-mobile-delete-btn {
  background: #fef2f2;
  border-color: #fca5a5;
  color: #b91c1c;
}

body.theme-dark #selection-toolbar .rd-mobile-toolbar-btn.rd-mobile-delete-btn {
  background: rgba(127, 29, 29, 0.35);
  border-color: #f87171;
  color: #fecaca;
}

#selection-toolbar .rd-mobile-toolbar-btn.rd-mobile-resize-btn.is-active {
  background: #eff6ff;
  border-color: #60a5fa;
  color: #1d4ed8;
}

body.theme-dark #selection-toolbar .rd-mobile-toolbar-btn.rd-mobile-resize-btn.is-active {
  background: rgba(29, 78, 216, 0.25);
  border-color: #60a5fa;
  color: #bfdbfe;
}

#selection-toolbar .rd-mobile-toolbar-btn.rd-mobile-multi-btn.is-active,
.rd-mobile-viewer-controls button[data-rd-multi-toggle].is-active {
  background: #ecfdf5;
  border-color: #34d399;
  color: #047857;
}

body.theme-dark #selection-toolbar .rd-mobile-toolbar-btn.rd-mobile-multi-btn.is-active,
body.theme-dark .rd-mobile-viewer-controls button[data-rd-multi-toggle].is-active {
  background: rgba(6, 95, 70, 0.35);
  border-color: #34d399;
  color: #a7f3d0;
}

/* Touch context menu sheet + dismiss backdrop */
.rd-context-menu-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 11990;
  background: rgba(15, 23, 42, 0.45);
  touch-action: none;
}

.rd-context-menu-backdrop.is-visible {
  display: block;
}

body.rd-touch-device .context-menu.rd-context-menu-sheet {
  position: fixed !important;
  left: 50% !important;
  top: auto !important;
  bottom: max(8px, env(safe-area-inset-bottom)) !important;
  transform: translateX(-50%);
  z-index: 12000 !important;
  max-width: min(360px, calc(100vw - 16px));
  max-height: min(52vh, calc(100dvh - 96px));
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: 10px;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.35);
  padding: 4px !important;
}

body.rd-touch-device .context-menu.rd-context-menu-sheet .context-menu-item {
  padding: 7px 10px !important;
  font-size: 12px !important;
  min-height: 0 !important;
}

body.rd-touch-device .context-menu.rd-context-menu-sheet .context-menu-divider {
  margin: 2px 0 !important;
}

.rd-context-menu-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 8px 4px;
  margin: -2px -2px 2px;
  border-bottom: 1px solid var(--theme-border-panel, rgba(148, 163, 184, 0.35));
  font-weight: 700;
  font-size: 12px;
  position: sticky;
  top: 0;
  background: inherit;
  z-index: 1;
}

.rd-context-menu-close {
  min-width: 32px;
  min-height: 32px;
  padding: 0;
  border: none;
  border-radius: 6px;
  background: rgba(148, 163, 184, 0.15);
  color: inherit;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
}

/* Floating wall-draw controls — always reachable while drawing on touch */
.rd-mobile-wall-draw-bar {
  position: fixed;
  left: 50%;
  top: max(44px, calc(env(safe-area-inset-top, 0px) + 40px));
  transform: translateX(-50%);
  z-index: 11500;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  border-radius: 10px;
  border: 1px solid rgba(56, 189, 248, 0.55);
  background: rgba(15, 23, 42, 0.94);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  pointer-events: auto;
  touch-action: manipulation;
}

.rd-mobile-wall-draw-bar[hidden] {
  display: none !important;
}

body.rd-mobile-landscape.rd-mobile-fullscreen-active .rd-mobile-wall-draw-bar,
body.rd-mobile-landscape:fullscreen .rd-mobile-wall-draw-bar {
  top: max(6px, env(safe-area-inset-top, 0px));
}

.rd-mobile-wall-draw-progress {
  font-size: 11px;
  font-weight: 600;
  color: var(--theme-fg-muted, rgba(248, 250, 252, 0.8));
  white-space: nowrap;
  padding: 0 2px;
}

.rd-mobile-wall-draw-btn {
  min-height: 36px;
  min-width: 64px;
  padding: 4px 10px;
  border-radius: 8px;
  border: 1px solid var(--theme-border-panel, rgba(148, 163, 184, 0.45));
  background: rgba(30, 41, 59, 0.9);
  color: var(--theme-fg-base, #f8fafc);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  touch-action: manipulation;
}

.rd-mobile-wall-draw-btn.rd-mobile-wall-draw-done {
  background: #15803d;
  border-color: #22c55e;
  color: #ecfdf5;
}

body.rd-multi-select-mode #designer-canvas-container {
  outline: 2px dashed rgba(52, 211, 153, 0.55);
  outline-offset: -2px;
}

@media (max-width: 900px) {
  #selection-toolbar {
    flex-wrap: wrap !important;
    justify-content: center !important;
    max-width: calc(100% - 12px) !important;
    padding: 8px 10px !important;
    gap: 8px !important;
    bottom: 6px !important;
  }

  #selection-toolbar .selection-toolbar-cabinet-select {
    max-width: 100%;
    min-height: 40px;
  }

  #viewer-bottom-controls button,
  #viewer-bottom-controls .btn-secondary {
    min-height: 44px;
  }

  body.rd-touch-device.rd-mobile-landscape .cabinet-grid-tile,
  body.rd-touch-device.rd-mobile-portrait main#designer-app.room-designer-layout .panel-left .cabinet-grid-tile,
  body.rd-touch-device.rd-mobile-portrait #cabinet-library-grid .cabinet-grid-tile,
  body.rd-touch-device.rd-mobile-portrait .cabinet-grid-tile {
    min-height: 58px !important;
  }

  .cabinet-grid-tile {
    min-height: 120px !important;
  }

  .cabinet-actions .btn-secondary,
  .cabinet-actions .btn-primary,
  #cabinet-drag-handle {
    min-height: 44px;
  }
}

/* Keep account FAB out of the way during guided setup / design settings modal */
body.rd-touch-device:has(#doorStyleModal.modal[style*="display: block"]) .innosaw-account-fab,
body.rd-touch-device:has(#doorStyleModal.modal[style*="display:block"]) .innosaw-account-fab,
body.rd-touch-device:has(#doorStyleModal.modal[style*="display: flex"]) .innosaw-account-fab,
body.rd-touch-device:has(#doorStyleModal.modal[style*="display:flex"]) .innosaw-account-fab {
  display: none !important;
}
