/* Match the width breakpoint in app.js. Short, touch-first landscape screens use this layout too. */
@media (max-width:700px), (max-height:560px) and (max-width:1000px) and (pointer:coarse) {
  body {
    display:flex;
    flex-direction:column;
    height:var(--view-height,100dvh);
    padding-inline:env(safe-area-inset-left) env(safe-area-inset-right);
    --muted:#655d73;
  }
  header {
    flex:none;
    height:auto;
    min-height:56px;
    padding:calc(5px + env(safe-area-inset-top)) 12px 5px;
    gap:6px;
  }
  header .identity {font-size:1rem;line-height:1.15;margin-right:auto;min-width:0}
  .identity small {display:none}
  .app-logo {width:36px;height:36px}
  header #installGalaxy,header #newBtn,header #send3dBtn {display:none}
  #exportBtn {font-size:.9375rem;padding:8px 12px}
  .bicsafrica-context {flex:none;margin:0}
  .bicsafrica-context .back-to-bics {display:inline-flex;align-items:center;justify-content:center;min-width:44px;min-height:44px;font-size:1.125rem}
  .back-to-bics-label,.bicsafrica-context .independent-link,body.embedded-galaxy header .bicsafrica-context {display:none}
  body.embedded-galaxy header {padding-top:5px}
  .shell,.library-hidden .shell,.properties-hidden .shell,.library-hidden.properties-hidden .shell {
    position:relative;display:flex;flex:1;flex-direction:column;height:auto;min-height:0;
  }
  .rail {display:none}
  .shell main {flex:1;min-height:0}
  .document-bar {
    display:grid;grid-template-columns:minmax(0,1fr) auto;
    padding:6px 10px;gap:5px;min-height:0;
  }
  .document-bar>div:first-child {display:flex;flex-direction:column;align-items:flex-start;gap:1px}
  #designName {font-size:1rem;width:100%;min-height:26px}
  #saveState {font-size:.8125rem;line-height:1.3;color:#655d73;margin:0;overflow-wrap:anywhere}
  .bar-actions {width:auto;flex-wrap:nowrap;gap:3px}
  .bar-actions button {padding:5px 8px;font-size:.875rem}
  .bar-actions :is(#undoBtn,#redoBtn) {width:44px;font-size:1.25rem;padding:0}
  .bar-actions :is(#blankPage,#toggleLibrary,#toggleProperties,#focusCanvas,#previewBtn) {display:none}
  .canvas-tools {gap:4px;padding:3px 10px;font-size:.875rem;color:#655d73}
  .canvas-tools>div {display:flex;gap:3px}
  .canvas-tools button {font-size:.9375rem;min-width:44px;padding:4px}
  #stageWrap {min-height:72px;display:grid;justify-content:safe center;align-content:safe center;padding:10px}
  .canvas-footer {display:none}
  .mobile-tabs {
    position:relative;inset:auto;display:grid;grid-template-columns:repeat(4,minmax(0,1fr));flex:none;
    height:auto;gap:2px;padding:3px 4px calc(3px + env(safe-area-inset-bottom));
    background:white;border-top:1px solid var(--line);
  }
  .mobile-tabs button {
    display:flex;flex-direction:column;justify-content:center;align-items:center;gap:2px;min-width:0;
    font-size:.875rem;font-weight:700;line-height:1.15;padding:4px 1px;color:#413750;
  }
  .mobile-tabs button span {font-size:1.125rem;line-height:1}
  .mobile-tabs button.active[aria-expanded="false"] {background:white;color:#413750}
  .mobile-tabs [aria-expanded="true"],.mobile-tabs #phoneEdit.layer-selected {
    color:#4f2ca7;background:#f1ebff;
  }
  #panel,#properties {
    position:absolute;inset:0;width:auto;max-height:none;min-height:0;
    overflow:auto;overscroll-behavior:contain;background:#fff;border:0;
    box-shadow:none;border-radius:0;padding:14px 16px 24px;display:none;z-index:16;
  }
  body.panel-open:not(.library-hidden) #panel, body.phone-properties-open:not(.properties-hidden) #properties {display:block}
  body:not(.phone-properties-open).has-selection #properties {display:none}
  :is(#panel,#properties) :is(.panel-close,.prop-close) {float:right;min-width:44px;font-size:1.375rem;margin:0 0 6px 8px}
  :is(#panel,#properties) h2 {font-size:1.375rem!important}
  h3 {font-size:1rem}
  .eyebrow {font-size:.8125rem;letter-spacing:.09em;line-height:1.4}
  p,label,.empty-properties {font-size:1rem;color:#655d73}
  label {font-size:.9375rem}
  .note,.project-card small,.panel-banner p,.template-card small {font-size:.8125rem;color:#655d73}
  .template-card strong,.project-card strong,.panel-banner strong {font-size:.9375rem;overflow-wrap:anywhere}
  button,.bar-actions button,.mobile-tabs button {min-height:44px}
  :is(#panel,#properties,#mockupView,dialog) button {font-size:.9375rem}
  label :is(input:not([type=checkbox]),select,textarea),.search {font-size:1rem;min-height:44px;min-width:0}
  label input[type=checkbox] {width:22px;height:22px;flex:none}
  .field-grid,.action-grid,.template-grid,.export-grid,.phone-tools-grid {grid-template-columns:repeat(2,minmax(0,1fr))}
  .chips {gap:7px}
  .layer {min-height:48px;font-size:.875rem;padding:4px 5px}
  .layer button,.swatches button {min-width:44px;min-height:44px}
  dialog {padding:22px 16px;max-height:min(90dvh,calc(var(--view-height,100dvh) - 24px))}
  dialog h2 {padding-right:44px}
  dialog .close {min-width:44px;font-size:1.375rem}
  .phone-tools-grid {display:grid;gap:8px;margin-top:16px}
  #toast {bottom:calc(64px + env(safe-area-inset-bottom));font-size:.875rem;width:max-content}
}
@media (max-width:360px) {
  .phone-tools-grid,.export-grid {grid-template-columns:minmax(0,1fr)}
}
