/* Phones / narrow screens (≤760 px): library slides over, compact bars, editor panel as a bottom sheet. */
.only-phone,.only-compact{display:none!important}
@media (max-width:760px){
  .only-phone,.only-compact{display:inline-grid!important}
  .no-phone{display:none!important}
  :root{--toph:52px}
  /* top bar */
  #top{gap:4px;padding:0 6px}
  #top .mid{position:static;transform:none;margin:0 auto}
  #top .mid .seg button{padding:6px 10px}
  #top .mid .seg button span:not(.ico){display:none}
  .brand span,.projname,#saveDot,#top>.divider{display:none}
  .brand{padding:6px 4px}
  #top .right{margin-left:0;gap:0}
  #top .right .divider,#top .right .ib[aria-label^="Undo"],#top .right .ib[aria-label^="Redo"],#top .right .ib[aria-label="Theme"],#top .right .ib[aria-label="Project settings"]{display:none}
  #top .ib{width:34px;height:34px}
  /* library drawer */
  #lib{position:absolute;left:0;top:0;bottom:0;width:min(86vw,320px);z-index:40;margin-left:0!important;transform:translateX(0);transition:transform .25s;box-shadow:var(--shadow)}
  #lib.hide{transform:translateX(-105%);box-shadow:none}
  #lib:not(.hide)+#view::before{content:'';position:absolute;inset:0;background:rgba(0,0,0,.4);z-index:30}
  /* boards */
  .bbar{flex-wrap:wrap;gap:8px;padding:10px 12px}
  .bbar .seg button{padding:6px 10px}
  .bbar .seg button span:not(.ico){display:none}
  .bzoom,.bprint{display:none!important}
  .bstat{order:5;flex:1 1 100%;font-size:11px}
  .bbar .btn.primary{padding:7px 12px}
  .bbody{padding:12px 10px 80px}
  .bv[data-layout=grid] .bbody{gap:12px}
  .shot{min-width:0;width:100%;padding:10px 10px 12px}
  .bcard{width:calc((100% - 14px - 44px) / 2)}
  .shrow{gap:10px}
  .addboard{width:36px}
  .bhover{opacity:1}
  .page{padding:14px;aspect-ratio:auto}
  .pggrid{grid-template-columns:repeat(2,1fr)!important;gap:12px}
  .cartrack{width:84%}
  .carinfo{grid-template-columns:1fr;gap:10px;padding:10px 14px}
  .carnotes{grid-template-columns:1fr}
  .carprev,.carnext{display:none}
  .empty h2{font-size:22px}
  /* modals + popovers */
  .scrim{padding:10px;place-items:end center}
  .modal,.modal.wide{width:100%;max-height:88vh;border-radius:20px}
  .fgrid{grid-template-columns:repeat(2,1fr)}
  /* editor */
  .ed-top{height:50px;padding:0 6px;gap:2px}
  .ed-top>.divider,.ed-label span:last-child,.ed-right .divider,.ed-right .ib[aria-label^="Fit"]{display:none}
  .ed-top>.btn.ghost{padding:6px 8px}.ed-top>.btn.ghost{font-size:0;gap:0}.ed-top>.btn.ghost .ico{font-size:20px}
  .ed-label b{font-size:12px}
  .ed-mid{position:static;transform:none;margin:0 auto}
  .ed-mid .seg button{padding:6px 10px}.ed-mid .seg button span:not(.ico){display:none}
  .dr-readout{display:none!important}
  .ed-label{display:none}
  .ed-right .btn.accent{font-size:0;gap:0;padding:8px}.ed-right .btn.accent .ico{font-size:18px}
  .ed-body{position:relative}
  .ed-rail{width:50px;padding:6px 0}
  .ed-side{position:absolute;left:0;right:0;bottom:0;width:auto;height:min(62%,560px);z-index:20;background:var(--glass-solid);backdrop-filter:var(--blur);
    border:0;border-top:1px solid var(--stroke2);border-radius:18px 18px 0 0;box-shadow:0 -12px 40px rgba(0,0,0,.35);transform:translateY(102%);transition:transform .25s}
  #editor.sheet .ed-side{transform:none}
  .ed-side::before{content:'';display:block;width:38px;height:5px;border-radius:5px;background:var(--stroke2);margin:7px auto 0;flex:none}
  /* edit mode */
  .nle-bar{padding:6px 8px}
  .nle-bc .ib:not(.play){width:32px;height:32px}
  .nle-insp{gap:10px;padding:6px 10px}
}

/* Portrait iPads (761–900 px): library and the editor panel become drawers so the canvas gets the width. */
@media (min-width:761px) and (max-width:900px){
  .only-compact{display:inline-grid!important}
  .projname,#saveDot{display:none}
  #lib{position:absolute;left:0;top:0;bottom:0;width:300px;z-index:40;margin-left:0!important;transform:translateX(0);transition:transform .25s;box-shadow:var(--shadow)}
  #lib.hide{transform:translateX(-105%);box-shadow:none}
  .bbar{flex-wrap:wrap}.bstat{order:5;flex:1 1 100%}
  .ed-body{position:relative}
  .ed-side{position:absolute;right:0;top:0;bottom:0;width:320px;z-index:20;background:var(--glass-solid);backdrop-filter:var(--blur);
    box-shadow:-12px 0 40px rgba(0,0,0,.3);transform:translateX(102%);transition:transform .25s}
  #editor.sheet .ed-side{transform:none}
  .ed-label span:last-child,.dr-readout{display:none!important}
  .ed-label{white-space:nowrap}
  /* top bars: the centre switch flows with the buttons instead of sitting under them */
  #top .mid,.ed-mid{position:static;transform:none;margin:0 auto}
  .ed-right .divider,#top .right .divider,#top .right .ib[aria-label="Theme"]{display:none}
  #top .ib{width:34px;height:34px}#top{gap:4px}
  #top .viewseg button{padding:4px 6px}
  .ed-right .btn.accent{font-size:0;gap:0;padding:8px}.ed-right .btn.accent .ico{font-size:18px}
  .ed-top>.btn.ghost{font-size:0;gap:0;padding:6px 8px}.ed-top>.btn.ghost .ico{font-size:20px}
}
/* iPad + Apple Pencil: no callouts, selection or double-tap zoom while drawing / dragging */
html{-webkit-text-size-adjust:100%}
#app,#editor,#demo,#narrator{-webkit-touch-callout:none;-webkit-user-select:none;user-select:none}
input,textarea,[contenteditable]{-webkit-user-select:text;user-select:text}
button,.ib,.btn,.chip,.seg button{touch-action:manipulation}
@media (pointer:coarse){ .ib{width:40px;height:40px}.ib.sm{width:34px;height:34px} }
