/* Calculator-only responsive rules; shared planner/scanner layouts stay untouched. */
body:has(.tile-3d-modal-backdrop.is-open) #giko-fab,
body:has(.tile-3d-modal-backdrop.is-open) #giko-fab > * { display: none !important; }
@media (max-width: 780px) {
  .main-content { min-width: 0; width: 100%; margin-inline: 0; padding-inline: 12px; }
  .main-content #appTiles, .main-content #appWallpaper {
    min-width: 0; width: 100%; padding: 0; border: 0;
    background: transparent; box-shadow: none; border-radius: 0;
  }
  .app-view .content-grid { grid-template-columns: minmax(0, 1fr); gap: 16px; }
  .app-view :is(.input-column, .output-column, .card, .card-body, .card-section, .form-group, .input-wrap, .walls-container) { min-width: 0; max-width: 100%; }
  .app-view .topbar { padding: 18px 16px; margin-bottom: 16px; gap: 16px; }
  .app-view .topbar-left { min-width: 0; margin-left: 0; }
  .app-view .page-title { font-size: 24px; overflow-wrap: anywhere; }
  .app-view .topbar-right { width: 100%; min-width: 0; flex-wrap: wrap; gap: 8px; }
  .app-view .topbar-right .btn { justify-content: center; white-space: normal; min-height: 44px; }
  .app-view .card-header { padding: 16px; gap: 10px; }
  .app-view .card-header > div { min-width: 0; }
  .app-view .card-icon { flex-shrink: 0; }
  .app-view .card-body { padding: 16px; }
  .app-view .card-section { padding: 16px; }
  .app-view .section-header { min-width: 0; }
  .app-view .section-title { font-size: 18px; line-height: 1.5; overflow-wrap: anywhere; }
  .app-view .section-header .section-title, .app-view #addWallBtn { margin-inline: 0; }
  .app-view .calc-method-row { flex-wrap: wrap; gap: 10px; }
  .app-view .calc-method-row .form-label { margin-left: 0 !important; }
  .app-view .toggle-switch { margin: 0; flex-shrink: 0; }
  .app-view .calc-mode-selector { margin-bottom: 0 !important; }
  .app-view .walls-container { margin: 0; padding: 0; }
  .app-view .wall-item.card-sub-item { min-width: 0; margin: 16px 0 0; padding: 12px; box-shadow: none; }
  .app-view .wall-item-header { display: grid; grid-template-columns: minmax(0, 1fr) 36px; gap: 8px; }
  .app-view .wall-name-wrap { min-width: 0; width: 100%; }
  .app-view .wall-name { min-width: 0; width: 100%; }
  .app-view .wall-type-select { grid-column: 1 / -1; grid-row: 2; min-width: 0; max-width: none; width: 100%; min-height: 44px; }
  .app-view .btn-remove-wall { grid-column: 2; grid-row: 1; }
  .app-view .form-row, .app-view .form-row--three { grid-template-columns: minmax(0, 1fr); }
  .app-view :is(input, select, textarea) { min-width: 0; max-width: 100%; }
  .app-view :is(.form-input, .form-input-sm, .form-input-inline) { font-size: 16px; }
  .app-view :is(.form-input, .form-input-sm) { min-height: 44px; }
  .app-view :is(.opening-row, .opening-header, .header-controls, .results-actions) { min-width: 0; flex-wrap: wrap; }
  .app-view :is(.card-title, .card-desc, .form-label) { overflow-wrap: anywhere; }
  .app-view .btn { max-width: 100%; white-space: normal; }
  .app-view .metrics-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  #appTiles .pattern-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  #appTiles .pattern-btn { min-width: 0; }
  #appTiles .pattern-info { min-width: 0; width: 100%; }
  #appTiles .pattern-name, #appTiles .pattern-desc { max-width: 100%; white-space: normal; overflow-wrap: anywhere; }
}

@media (max-width: 760px), (max-height: 500px) and (pointer: coarse) {
  .tile-3d-modal-backdrop, body.has-site-header .tile-3d-modal-backdrop {
    inset: 0; padding: 0; overflow: hidden; align-items: stretch;
  }
  .tile-3d-modal, body.has-site-header .tile-3d-modal {
    width: 100%; max-width: 100%; height: 100vh; height: 100dvh;
    min-height: 0; max-height: 100dvh; border: 0; border-radius: 0;
    grid-template-rows: auto minmax(0, 1fr);
  }
  .tile-3d-modal__header { padding: max(8px, env(safe-area-inset-top)) 12px 8px; gap: 8px; min-width: 0; }
  .tile-3d-modal__header > div:first-child { flex: 1; min-width: 0; }
  .tile-3d-modal__title { font-size: 17px; line-height: 1.4; margin: 0; overflow-wrap: anywhere; }
  .tile-3d-modal__eyebrow, .tile-3d-modal__subtitle, .tile-3d-modal__hint,
  .tile-3d-modal__mobile-toggle--inline { display: none; }
  .tile-3d-modal__header-actions { flex: 0 0 auto; gap: 6px; }
  .tile-3d-modal__header-actions .tile-3d-modal__mobile-toggle,
  .tile-3d-modal__close { display: grid; place-items: center; min-width: 44px; width: 44px; height: 44px; padding: 0; margin: 0; flex: 0 0 44px; border-radius: 8px; font-size: 24px; }
  .tile-3d-modal__body { display: block; position: relative; min-height: 0; overflow: hidden; }
  .tile-3d-modal__canvas { position: absolute; inset: 0; width: 100%; height: 100%; min-height: 0; display: block; touch-action: none; }
  .tile-3d-modal__meta { position: absolute; bottom: env(safe-area-inset-bottom, 0px); left: 8px; right: 8px; margin: 0; padding: 4px 0; height: 32px; gap: 6px; pointer-events: auto; overflow-x: auto; overscroll-behavior: contain; }
  .tile-3d-modal__pill { padding: 4px 8px; font-size: 11px; white-space: nowrap; }
  .tile-3d-modal__navigation { position: absolute; bottom: calc(42px + env(safe-area-inset-bottom, 0px)); right: max(12px, env(safe-area-inset-right)); display: flex; gap: 6px; z-index: 2; }
  .tile-3d-modal__navigation button { width: 44px; height: 44px; border: 1px solid #ded7cc; background: #fffdf8; color: #24324b; border-radius: 8px; font-size: 24px; cursor: pointer; }
  .tile-3d-modal__navigation button[aria-pressed="true"] { border-color: #ff6a00; color: #d95500; background: #fff2e7; }
  .tile-3d-modal__toolbar { display: none; position: absolute; inset: 8px 8px auto; width: auto; margin: 0; padding: 12px; max-height: calc(100% - 108px); overflow: auto; overscroll-behavior: contain; background: #fffcf7; border-radius: 8px; box-shadow: 0 8px 24px #0002; }
  .tile-3d-modal__toolbar.is-open { display: flex; opacity: 1; pointer-events: auto; }
  .tile-3d-modal__tool { min-height: 44px; font-size: 14px; border-radius: 8px; white-space: normal; }
  .tile-3d-modal__dropdown-menu { position: static; min-width: 0; }
  .tile-3d-modal__inspector { position: absolute; top: auto; bottom: calc(100px + env(safe-area-inset-bottom, 0px)); left: 8px; right: 8px; width: auto; margin: 0; max-height: calc(100% - 112px); overflow: auto; padding: 12px; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 8px; border-radius: 8px; }
  .tile-3d-modal__inspector-close { grid-row: 1; grid-column: 3; width: 44px; height: 44px; }
  .tile-3d-modal__inspector-title { grid-row: 1; grid-column: 1 / 3; align-self: center; }
  .tile-3d-modal__field { min-width: 0; font-size: 12px; }
  .tile-3d-modal__field input { min-width: 0; min-height: 44px; font-size: 16px; padding: 8px; }
  .tile-3d-modal__body:has(.tile-3d-modal__toolbar.is-open) .tile-3d-modal__inspector { display: none; }
  .tile-3d-modal__wall-upload { left: 8px; right: auto; top: 8px; bottom: auto; max-width: calc(100% - 16px); min-height: 44px; }
  .tile-3d-modal__texture-popup { padding: 8px; align-items: start; overflow: auto; overscroll-behavior: contain; }
  .tile-3d-modal__texture-popup-card { min-width: 0; max-width: 100%; padding: 14px; border-radius: 8px; }
  .tile-3d-modal__texture-head { gap: 8px; }
  .tile-3d-modal__texture-head > div { min-width: 0; }
  .tile-3d-modal__texture-close { flex: 0 0 44px; width: 44px; height: 44px; }
  .tile-3d-modal__texture-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .tile-texture-card__actions { flex-wrap: wrap; }
  .tile-texture-card__name { max-width: 100%; overflow-wrap: anywhere; }
  .tile-3d-modal button:focus-visible { outline: 2px solid #ff6a00; outline-offset: 2px; }
}
