/* On a phone the preview stays on top and the panels take turns underneath it. Nothing moves
   in the DOM: .workspace steps aside with display:contents, so its parts and the two side
   panels all become rows of one grid. Larger windows never reach the media query. */
#phone-tabs,#selection-actions .phone-only{display:none}
/* Sliders fill the settings panel, so a vertical swipe that lands on one has to scroll it. */
@media(pointer:coarse){.dialkit-slider{touch-action:pan-y}}

@media(max-width:800px),(max-height:500px){
 :root{--editor-control-height:42px;-webkit-tap-highlight-color:transparent;touch-action:manipulation}
 html,body{overscroll-behavior:none}
 body{height:100dvh}
 main{height:100dvh;grid-template:"toolbar" auto "preview" minmax(0,1fr) "playback" auto "panel" minmax(0,1.15fr) "tabs" auto/minmax(0,1fr)}
 body.preview-expanded main{grid-template:"toolbar" auto "preview" minmax(0,1fr) "playback" auto/minmax(0,1fr)}
 body.preview-expanded #phone-tabs{display:none}
 .workspace{display:contents}
 /* Undo and Redo move to the right, which leaves the name room to be read. */
 .workspace>.stage-toolbar{grid-area:toolbar;height:44px;min-height:44px;grid-template-columns:minmax(0,1fr) auto auto}
 .preview-panel{grid-area:preview}
 .preview-viewport{--preview-fit:.94}
 .playback{grid-area:playback;height:44px;min-height:44px;padding:2px 3px}
 .library,.shots,.inspector-shell{grid-area:panel;min-width:0;min-height:0}

 /* One panel at a time. Settings and Export are the two halves of the inspector. */
 main:not([data-panel=templates])>.library,main:not([data-panel=media]) .shots,main:not([data-panel=settings],[data-panel=export])>.inspector-shell,main[data-panel=settings] .inspector-bottom,main[data-panel=export] :is(.inspector-top,.inspector,.card-editor){display:none}

 #phone-tabs{grid-area:tabs;display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:2px;height:54px;padding:3px;background:var(--panel);border-radius:var(--editor-panel-radius)}
 #phone-tabs button{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:3px;min-width:0;padding:0;border:0;border-radius:var(--editor-control-radius);background:transparent;color:var(--ui-secondary);font-size:11px;line-height:14px}
 #phone-tabs button[aria-pressed=true]{background:var(--editor-field);color:var(--ui-text)}
 #phone-tabs svg{width:20px;height:20px;fill:none;stroke:currentColor;stroke-width:1.6;stroke-linecap:round;stroke-linejoin:round}

 /* Fingers: room around everything small, and 16px text so iOS does not zoom in on a field. */
 :root[data-theme] body :is(input:not([type=range],[type=checkbox],[type=color],[type=file]),select,textarea),:root[data-theme] body .inspector-shell .dialkit-slider-input{font-size:16px}
 .workspace>.stage-toolbar .history-actions button{min-width:44px;min-height:36px;font-size:12px}
 .workspace>.stage-toolbar #expand-preview{width:36px;height:36px}
 .playback #play{width:38px;height:38px;flex-basis:38px}
 .playback #keyframe-timeline #scrub{height:38px}
 .playback #keyframe-timeline #scrub::-webkit-slider-thumb{width:22px;height:22px;margin-top:-10px}
 .playback #keyframe-timeline #scrub::-moz-range-thumb{width:22px;height:22px;border:0}
 .playback.has-keyframes #time{margin-top:0}
 .inspector-shell .has-keyframe>.keyframe-toggle{flex-basis:36px;width:36px;height:42px}
 :root[data-theme] body .template-library-header>.template-filters>button{min-height:36px;font-size:12px}
 :root[data-theme] body .inspector-top .inspector-modes button{min-height:38px;font-size:12px}
 :root[data-theme] body .inspector-shell .dialkit-segmented-button{min-height:34px}
 .workspace>.stage-toolbar .preview-project-name input{min-height:36px}
 #keyframe-lanes{max-height:92px;touch-action:pan-y}
 .template-card,.shot,#phone-tabs,.keyframe-marker{-webkit-user-select:none;user-select:none;-webkit-touch-callout:none}
 .library-content,.inspector,.card-editor,#shot-strip{overscroll-behavior:contain}

 /* Templates. */
 :root[data-theme] body main:not(.library-collapsed)>.library{padding:5px 5px 0}
 .template-grid{grid-template-columns:repeat(auto-fill,minmax(104px,1fr))}

 /* Media: a grid that scrolls down, rather than a strip that scrolls across. */
 .shots{display:flex;flex-direction:column;overflow:hidden}
 :root[data-theme] body #asset-tray-handle{display:none}
 .asset-viewport{flex:1;min-height:0}
 .asset-viewport #shot-strip{display:grid;grid-template-columns:repeat(auto-fill,minmax(104px,1fr));grid-auto-rows:min-content;height:100%;overflow:hidden auto;touch-action:pan-y}
 .shots.assets-empty .asset-viewport #shot-strip{display:flex}
 :root[data-theme] body .shot{width:auto}
 :root[data-theme] body .shot canvas{width:100%;height:auto;aspect-ratio:208/128}
 .shot-label span{max-width:none}
 #selection-actions .phone-only{display:block}
 #selection-actions .phone-only[hidden]{display:none}
 /* Two rows: what is selected, then what to do with it. */
 :root[data-theme] body .shots-heading{flex:none;height:auto;margin:0;overflow:visible}
 :root[data-theme] body .shots-heading #selection-actions{flex:1;flex-wrap:wrap;min-width:0;margin:0 0 8px;gap:5px}
 #selection-actions::after{content:'';order:2;flex-basis:100%}
 #selection-count{flex:1;font-size:12px}
 :root[data-theme] body .shots-heading #selection-actions button{min-height:36px;padding:0 10px;font-size:12px;color:var(--ui-text)}
 #selection-actions :is(#select-all-shots,#clear-shots){order:1}
 #selection-actions :is(.phone-only,#delete-shots){order:3}
 #selection-actions :is(#shot-edit,#delete-shots){flex:1}

 /* Export: the action first, then the project, with the brand and theme below. */
 main[data-panel=export] .inspector-bottom{flex:1;display:flex;flex-direction:column;padding:10px;border-top:0;overflow:auto}
 :root[data-theme] body .inspector-bottom .project-bar .header-actions>#export{order:-1;min-height:48px;font-size:14px}
 :root[data-theme] body .inspector-bottom .project-bar .header-actions>button{font-size:12px}
 #save-status{font-size:11px}
 .inspector-bottom .library-footer{margin-top:auto;padding:12px 3px 0}
 :root[data-theme] body .library-footer button{width:36px;height:36px}
 #collapse-library{display:none}

 :root[data-theme] body dialog:not(#startup-screen){max-width:calc(100vw - 24px);padding:20px}
 /* left:50% would leave a toast half the screen to wrap in. */
 #toast{left:12px;right:12px;max-width:none;transform:none;justify-content:center}
 #promo{left:10px;right:10px;bottom:74px;width:auto}
 #promo-link{position:relative;padding:12px 44px 12px 100px}
 #promo-link img{position:absolute;inset:0 auto 0 0;width:88px;height:100%;aspect-ratio:auto;margin:0}
 #promo-link strong,#promo-link>span{padding:0}
 #promo-link>span:not(.promo-cta){display:none}
 #promo-link>.promo-cta{margin-top:2px}
 #promo-close{width:32px;height:32px;top:50%;right:6px;margin-top:-16px}
}

/* A phone on its side: preview on the left, panels on the right. */
@media(max-height:500px) and (orientation:landscape){
 main{grid-template:"toolbar panel" auto "preview panel" minmax(0,1fr) "playback tabs" auto/minmax(0,1fr) minmax(0,1fr)}
 #phone-tabs{height:auto}
 #phone-tabs button{flex-direction:row;gap:5px}
 #promo{right:auto;bottom:54px;width:calc(50% - 15px)}
}
