/* Phone studio shell. Desktop presentation remains owned by style.css. */
.phone-ui { display: none; }
@media (max-width:1150px), (max-width:950px) and (max-height:600px), (pointer:coarse) and (max-width:1150px) and (min-height:601px) {
  body.phone-active { --phone-dock:80px; --phone-header:64px; --phone-bottom:env(safe-area-inset-bottom,0px); height:100dvh; overflow:hidden; background:#000; color:#f3eef9; }
  .phone-active .phone-ui:not([hidden]) { display:flex; }
  .phone-active>.topbar,.phone-active .workspace>.rail,.phone-active .workspace>.library,.phone-active .workspace>.inspector,.phone-active .editor>.canvas-toolbar,.phone-active .editor>.timeline,.phone-active .editor>.quick-text,.phone-active>.app-footer,.phone-active #liveBar,.phone-active .phone-panel-backdrop,.phone-active .phone-panel-close,.phone-active #stageCueBar { display:none!important; }
  .phone-active .workspace { display:block; position:absolute; inset:var(--phone-header) 0 calc(var(--phone-dock) + var(--phone-bottom)); min-height:0; height:auto; padding:0; overflow:hidden; }
  .phone-active .editor { display:flex; flex-direction:column; height:100%; min-height:0; padding:0; background:#000; overflow:hidden; }
  .phone-active .editor>.stage { order:0; flex:1 1 0; min-height:0; padding:10px 16px 12px; background:none; overflow:hidden; container-type:size; }
  .phone-active .stage-caption,.phone-active .stage-tip,.phone-active .stage-doodle { display:none; }
  .phone-active .canvas-wrap { width:auto; height:100%; height:min(100cqh,calc((100cqw - 4px)*16/9)); max-height:100%; max-width:100%; flex:none; aspect-ratio:9/16; border-radius:14px; border:1px solid #423949; box-shadow:0 8px 30px #0005; }
  .phone-active.landscape .canvas-wrap { width:auto; height:min(100cqh,calc((100cqw - 4px)*9/16)); aspect-ratio:16/9; }
  .phone-active .canvas-wrap canvas { display:block; width:100%; height:100%; object-fit:contain; }
  .phone-active #phoneHeader { position:fixed; z-index:85; inset:0 0 auto; height:var(--phone-header); align-items:center; gap:8px; padding:8px 14px; background:#000; border-bottom:1px solid #302837; }
  .phone-active #phoneHeader button { min-height:44px; border-radius:11px; }
  .phone-active #phoneProject { flex:1; min-width:0; text-align:left; padding:0; font-size:19px; font-weight:750; letter-spacing:-.6px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
  .phone-active #phoneProject span { color:#cfb5ff; }
  .phone-active #phoneUndo { width:44px; font-size:25px; background:#27212f; }
  .phone-active #phoneExport { background:#ccb5ff; color:#261b36; padding:0 16px; font-size:14px; font-weight:700; }
  .phone-active #phoneDock { position:fixed; z-index:90; inset:auto 0 0; height:calc(var(--phone-dock) + var(--phone-bottom)); padding:7px 10px calc(7px + var(--phone-bottom)); display:grid; grid-template-columns:repeat(5,minmax(0,1fr)); gap:3px; border-top:1px solid #362d40; background:#000; }
  .phone-active #phoneDock button { display:flex; flex-direction:column; align-items:center; justify-content:center; gap:6px; min-width:0; min-height:56px; padding:5px 2px; border-radius:12px; font-size:14px; line-height:18px; color:#d4c9e2; }
  .phone-active #phoneDock button[aria-expanded=true],.phone-active #phoneDock button.active { color:#efddff; background:#3a2b4b; }
  .phone-active .phone-icon { width:24px; height:24px; display:block; font-size:23px; line-height:24px; }
  .phone-active .phone-icon svg { width:24px; height:24px; }
  .phone-active .editor>.transport { order:1; flex:none; display:grid; grid-template-columns:52px minmax(0,1fr) auto; grid-template-rows:52px 40px; height:104px; min-height:104px; gap:0 12px; padding:6px 16px; background:#000; border-top:1px solid #322938; border-bottom:0; }
  .phone-active .transport #restart,.phone-active .transport .preview-label { display:none; }
  .phone-active .transport #play { grid-column:1; grid-row:1; width:50px; height:50px; min-height:50px; border-radius:14px; padding:0; background:#e9dbff; color:#281b37; font-size:23px; }
  .phone-active .transport .time-display { grid-column:2; grid-row:1; font-size:14px; color:#bfb3cd; }
  .phone-active .transport #scrubber { grid-column:1/4; grid-row:2; width:100%; height:40px; min-height:40px; margin:0; accent-color:#cdb4ff; }
  .phone-active #phoneLayers { grid-column:3; grid-row:1; align-items:center; justify-content:center; min-height:44px; font-size:14px; padding:0 10px; border:1px solid #4a3b57; border-radius:10px; }
  .phone-active #phoneWelcome { position:absolute; z-index:6; inset:24px 28px; flex-direction:column; align-items:center; justify-content:center; gap:12px; padding:18px; background:transparent; border:0; border-radius:20px; text-align:center; }
  .phone-active .stage:has(#phoneWelcome:not([hidden])) .canvas-wrap { opacity:0; }
  .phone-active #phoneWelcome { background:#000; border:1px solid #45384e; inset:12px 16px; }
  .phone-active .stage:has(#phoneWelcome:not([hidden])) .canvas-wrap canvas { opacity:0; }
  .phone-active #phoneWelcome h1,.phone-active #phoneWelcome h2 { font-size:24px; line-height:1.2; letter-spacing:-.7px; margin:0 0 12px; }
  .phone-active #phoneWelcome p { font-size:14px; color:#bcafc9; line-height:1.5; margin:0 0 8px; }
  .phone-active #phoneWelcome button { width:min(100%,260px); min-height:50px; border:1px solid #564364; border-radius:12px; padding:10px 16px; background:#2c2238; font-size:16px; }
  .phone-active #phoneWelcome button:first-of-type { background:#cdb5ff; color:#271932; border-color:#cdb5ff; font-weight:700; }
  .phone-active #phonePreviewBadge { position:absolute; left:24px; top:20px; z-index:5; align-items:center; pointer-events:none; padding:7px 10px; border-radius:8px; background:#19141dc9; color:#eadcf6; font-size:14px; }
  .phone-active #phoneSelection { position:absolute; z-index:5; bottom:20px; left:24px; right:24px; align-items:center; justify-content:space-between; gap:8px; padding:5px 6px 5px 12px; border:1px solid #725889; border-radius:12px; background:#211829ee; }
  .phone-active #phoneSelectedName { min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; font-size:14px; }
  .phone-active #phoneAdjustSelected { flex:none; min-height:44px; padding:0 12px; border-radius:9px; background:#d3bbff; color:#24182e; font-size:14px; font-weight:650; }
  .phone-active #phoneShade { position:fixed; z-index:70; inset:var(--phone-header) 0 calc(var(--phone-dock) + var(--phone-bottom)); background:#09060d26; }
  .phone-active #phoneSheet { position:fixed; z-index:80; left:0; right:0; bottom:calc(var(--phone-dock) + var(--phone-bottom)); max-height:72dvh; min-height:0; flex-direction:column; padding:10px 16px 14px; border:1px solid #665173; border-bottom:0; border-radius:22px 22px 0 0; background:#000; box-shadow:0 -12px 45px #0006; overflow:hidden; }
  .phone-active .phone-sheet-head { display:flex; flex:none; align-items:center; gap:8px; min-height:52px; padding-bottom:8px; }
  .phone-active #phoneSheetTitle { flex:1; min-width:0; margin:0; font-size:19px; font-weight:700; letter-spacing:-.4px; line-height:1.25; }
  .phone-active #phoneClose,.phone-active #phoneBack { flex:none; width:48px; height:48px; min-height:48px; border:1px solid #735a87; border-radius:12px; background:#40304d; color:#f6ebff; font-size:24px; }
  .phone-active #phoneClose { width:auto; min-width:64px; padding:0 12px; font-size:14px; font-weight:650; }
  .phone-active #phoneSheetBody { min-height:0; overflow:auto; overscroll-behavior:contain; -webkit-overflow-scrolling:touch; padding:4px 0 2px; font-size:14px; scrollbar-width:thin; scrollbar-color:#786185 transparent; }
  .phone-active #phoneSheetBody .timeline,.phone-active #phoneSheetBody .inspector { position:static; display:block; width:auto; min-height:0; max-height:none; padding:0; border:0; background:transparent; overflow:visible; }
  .phone-active #phoneSheetBody button { min-height:44px; font-size:14px; border-radius:9px; }
  .phone-active #phoneSheetBody input:not([type=range]),.phone-active #phoneSheetBody textarea,.phone-active #phoneSheetBody select { font-size:16px; min-height:44px; }
  .phone-active #phoneSheetBody input[type=range] { min-height:44px; height:44px; margin:4px 0 8px; }
  .phone-active #phoneSheetBody label,.phone-active #phoneSheetBody label output { font-size:14px; }
  .phone-active #phoneSheetBody .text-composer { margin:0; padding:0; border:0; background:transparent; }
  .phone-active #phoneSheetBody #newWords { min-height:72px; height:72px; }
  .phone-active #phoneSheetBody .helper { font-size:14px; line-height:1.45; }
  .phone-active #phoneSheetBody .library-heading,.phone-active #phoneSheetBody .collection-title,.phone-active #phoneSheetBody .inspector>.eyebrow,.phone-active #phoneSheetBody .inspector>h2,.phone-active #phoneSheetBody .inspector>.selected-asset,.phone-active #phoneSheetBody #textComposer>.helper,.phone-active #phoneSheetBody #dimensionalHint { display:none; }
  .phone-active #phoneSheetBody .categories { display:flex; flex-wrap:nowrap; gap:7px; overflow-x:auto; margin:8px 0 12px; padding-bottom:3px; scrollbar-width:thin; scrollbar-color:#786185 transparent; }
  .phone-active #phoneSheetBody .categories button { flex:none; min-height:44px; white-space:nowrap; padding:8px 12px; }
  .phone-active #maskCategories { flex-wrap:nowrap; overflow-x:auto; overscroll-behavior-x:contain; -webkit-overflow-scrolling:touch; padding:4px 0 9px; margin:6px 0 10px; scrollbar-width:thin; }
  .phone-active #maskCategories button { flex:none; white-space:nowrap; padding:8px 13px; }
  .phone-active #faceMaskGrid { max-height:none; overflow:visible; grid-template-columns:repeat(2,minmax(0,1fr)); }
  .phone-active #cameraSavePhotos,.phone-active #saveExportPhotos { min-height:52px; font-size:16px; width:100%; }
  .phone-active #saveTakePhotos { min-height:48px; font-size:14px; background:#d7baff; color:#251833; font-weight:700; }
  .phone-active #phoneSheetBody .asset-grid { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:8px; max-height:none; overflow:visible; }
  .phone-active #phoneSheetBody .asset-card { min-width:0; }
  .phone-active #phoneSheetBody .asset-card strong,.phone-active #phoneSheetBody .asset-card span { font-size:14px; }
  .phone-active #phoneSheetBody .search { margin:0; min-height:44px; }
  .phone-active .phone-menu-grid { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:10px; }
  .phone-active .phone-menu-grid button { min-height:56px!important; border:1px solid #5f496f; background:#35283f; text-align:left; padding:12px; }
  .phone-active .phone-section { margin:0 0 12px; }
  .phone-active .phone-section h3 { font-size:15px; margin:8px 0 12px; }
  .phone-active .phone-details { border-top:1px solid #4f3e5c; margin:12px 0; }
  .phone-active .phone-details summary { padding:14px 0; min-height:48px; font-size:14px; cursor:pointer; }
  .phone-active #phoneSheetActions:not([hidden]) { display:flex; flex:none; gap:8px; padding-top:10px; background:#000; border-top:1px solid #493753; }
  .phone-active #phoneSheetActions button { flex:1; min-width:0; min-height:48px; padding:8px 12px; margin:0; border-radius:10px; font-size:14px; }
  .phone-active #phoneSheetActions #createText { background:#cbb1ff; color:#261830; font-weight:650; }
  .phone-active #phoneSheetActions #applyLettering { border:1px solid #79618a; }
  .phone-active.phone-empty .time-display { visibility:hidden; }
  .phone-active.phone-keyboard #phoneDock { display:none; }
  .phone-active.phone-keyboard.phone-sheet-open #phoneSheet { bottom:var(--phone-keyboard-bottom,0px); max-height:calc(var(--phone-visible-height,100dvh) - var(--phone-header) - 12px); }
  .phone-active #phoneSheetBody .track { min-height:46px; }
  .phone-active #phoneSheetBody .track-lane { height:44px; }
  .phone-active #phoneSheetBody .track-bar { height:42px; font-size:14px; }
  .phone-active #phoneSheetBody .track-label { width:82px; font-size:14px; }
  .phone-active #phoneCameraControls { order:1; flex:none; flex-wrap:wrap; align-items:center; justify-content:center; gap:8px; padding:8px 12px; background:#000; border-top:1px solid #493044; min-height:104px; }
  .phone-active:not(.phone-camera) #phoneCameraControls { display:none; }
  .phone-active.phone-camera .editor>.transport { display:none; }
  .phone-active #phoneCameraControls button { min-width:44px; min-height:44px; border-radius:11px; background:#352838; padding:8px 11px; font-size:14px; }
  .phone-active #phoneRecord { background:#c94960!important; color:#fff; font-weight:700; }
  .phone-active #phoneRecordStatus { width:100%; text-align:center; font-size:14px; color:#f2c4d0; }
  .phone-active.phone-camera.phone-sheet-open #phoneSheet { bottom:calc(var(--phone-dock) + var(--phone-bottom) + 104px); max-height:58dvh; }
  .phone-active.phone-camera.phone-sheet-open #phoneCameraControls { position:relative; z-index:85; }
  .phone-active.phone-keyboard.phone-sheet-open #phoneSheet { bottom:var(--phone-keyboard-bottom,0px); max-height:calc(var(--phone-visible-height,100dvh) - var(--phone-header) - 12px); }
}
@media (max-width:720px) and (orientation:landscape) and (max-height:600px), (max-width:950px) and (max-height:600px) and (orientation:landscape) {
  body.phone-active { --phone-header:56px; --phone-dock:72px; --phone-side:300px; }
  .phone-active .workspace { bottom:0; }
  .phone-active .editor { display:grid; grid-template-columns:minmax(0,1fr) var(--phone-side); grid-template-rows:minmax(0,1fr); }
  .phone-active .editor>.stage { grid-column:1; grid-row:1; padding:8px 12px 12px; }
  .phone-active .editor>.transport { grid-column:2; grid-row:1; grid-template-columns:52px minmax(0,1fr); grid-template-rows:52px 44px 40px; align-self:start; height:156px; min-height:156px; padding:6px 12px; margin-bottom:var(--phone-dock); border:0; background:transparent; gap:4px 10px; }
  .phone-active #phoneDock { left:auto; width:var(--phone-side); height:calc(80px + var(--phone-bottom)); grid-template-columns:repeat(5,minmax(0,1fr)); padding:5px 8px calc(5px + var(--phone-bottom)); border-left:1px solid #362d40; }
  .phone-active .editor>.transport { align-self:start; margin-top:12px; }
  .phone-active .transport #phoneLayers { grid-column:1/3; grid-row:2; justify-self:end; min-width:100px; }
  .phone-active .transport #scrubber { grid-column:1/3; grid-row:3; }
  .phone-active #phoneSheet { left:auto; width:var(--phone-side); top:var(--phone-header); bottom:calc(80px + var(--phone-bottom)); max-height:none; border-radius:14px 0 0 0; padding:8px 10px; }
  .phone-active #phoneSheetBody .asset-grid { grid-template-columns:repeat(2,minmax(0,1fr)); }
  .phone-active #phoneSheetTitle { font-size:17px; }
  .phone-active #phoneShade { right:var(--phone-side); bottom:0; }
  .phone-active #phoneWelcome { inset:16px 18px; gap:8px; padding:10px; }
  .phone-active #phoneWelcome h1,.phone-active #phoneWelcome h2 { font-size:20px; margin-bottom:4px; }
  .phone-active #phoneWelcome p { display:none; }
  .phone-active #phoneWelcome button { min-height:44px; }
  .phone-active #phoneCameraControls { grid-column:2; grid-row:1; align-self:start; margin-bottom:80px; padding:8px; min-height:104px; }
  .phone-active.phone-camera.phone-sheet-open #phoneSheet { left:auto; right:var(--phone-side); width:min(260px,calc(100vw - var(--phone-side) - 200px)); top:var(--phone-header); bottom:0; max-height:none; }
  .phone-active.phone-camera.phone-sheet-open .editor>.stage { width:calc(100% - min(260px,calc(100vw - var(--phone-side) - 200px))); }
  .phone-active.phone-camera.phone-sheet-open #phoneShade { right:var(--phone-side); }
  .phone-active.phone-keyboard.phone-sheet-open #phoneSheet { top:auto; bottom:var(--phone-keyboard-bottom,0px); max-height:calc(var(--phone-visible-height,100dvh) - var(--phone-header) - 12px); }
}

/* Keep the canvas above editing tools rather than underneath them. */
@media (max-width:1150px), (max-width:950px) and (max-height:600px), (pointer:coarse) and (max-width:1150px) and (min-height:601px) {
  body.phone-active { padding:0; --phone-header:calc(56px + env(safe-area-inset-top,0px)); --phone-sheet-height:min(42dvh,380px); }
  .phone-active #phoneHeader { padding-top:calc(6px + env(safe-area-inset-top,0px)); padding-left:max(12px,env(safe-area-inset-left,0px)); padding-right:max(12px,env(safe-area-inset-right,0px)); }
  .phone-active #phoneSheetBody>* { min-width:0; max-width:100%; }
  .phone-active #phoneSheetBody .categories { flex-wrap:nowrap; overflow-x:auto; padding-bottom:6px; margin:10px 0; }
  .phone-active #phoneSheetBody .categories button { flex:none; }
  .phone-active #phoneSheetBody .collection-title { gap:8px; }
  .phone-active #phoneSheetBody #selectionControls { display:block; }
  .phone-active #phoneSheetBody .timeline-top { flex-wrap:wrap; }
  .phone-active #phoneSheetBody .timeline-top button { margin-left:0; }
  .phone-active #phoneSelection { bottom:10px; left:12px; right:12px; }
  .phone-active #toast { bottom:calc(var(--phone-dock) + var(--phone-bottom) + 12px); z-index:100; }
}

/* Edge-to-edge phone canvas; every control floats above the video. */
@media (max-width:1150px), (max-width:950px) and (max-height:600px), (pointer:coarse) and (max-width:1150px) and (min-height:601px) {
  .phone-active .workspace,.phone-active.phone-sheet-open:not(.phone-camera):not(.phone-keyboard) .workspace { position:fixed; inset:0; width:100%; height:100dvh; }
  .phone-active .editor { display:block; position:relative; width:100%; height:100%; }
  .phone-active .editor>.stage,.phone-active.phone-camera.phone-sheet-open .editor>.stage { position:absolute; inset:0; width:100%; height:100%; padding:0; container-type:size; background:#000; }
  .phone-active .canvas-wrap { position:absolute; left:50%; top:50%; transform:translate(-50%,-50%); width:max(100cqw,calc(100cqh * 9 / 16)); height:max(100cqh,calc(100cqw * 16 / 9)); max-width:none; max-height:none; border:0; border-radius:0; box-shadow:none; }
  .phone-active.landscape .canvas-wrap { width:max(100cqw,calc(100cqh * 16 / 9)); height:max(100cqh,calc(100cqw * 9 / 16)); }
  .phone-active #phoneHeader { background:linear-gradient(#000b,#0000); border:0; }
  .phone-active #phoneDock { inset:auto 0 0; width:100%; height:calc(var(--phone-dock) + var(--phone-bottom)); background:linear-gradient(#0000,#000c); border:0; }
  .phone-active #phoneDock button { background:#201928bd; text-shadow:0 1px 3px #000; }
  .phone-active .editor>.transport { position:absolute; z-index:65; bottom:calc(var(--phone-dock) + var(--phone-bottom)); left:12px; right:12px; width:auto; height:92px; min-height:92px; margin:0; padding:4px 10px; display:grid; grid-template-columns:44px minmax(0,1fr) auto; grid-template-rows:44px 36px; gap:0 8px; border:0; border-radius:14px; background:#17111dc4; }
  .phone-active .transport #play { width:48px; height:48px; min-height:48px; }
  .phone-active .transport #phoneLayers { grid-column:3; grid-row:1; min-width:0; }
  .phone-active .transport #scrubber { grid-column:1/4; grid-row:2; height:36px; min-height:36px; }
  .phone-active #phoneSelection { top:calc(var(--phone-header) + 8px); bottom:auto; }
  .phone-active #phonePreviewBadge { display:none; }
  .phone-active #phoneSheet,.phone-active.phone-camera.phone-sheet-open #phoneSheet { inset:auto 0 calc(var(--phone-dock) + var(--phone-bottom)); width:100%; height:auto; max-height:72dvh; border-radius:22px 22px 0 0; background:#000000ee; backdrop-filter:blur(12px); animation:phone-tools-in .18s ease-out; }
  .phone-active #phoneShade,.phone-active.phone-camera.phone-sheet-open #phoneShade { inset:var(--phone-header) 0 calc(var(--phone-dock) + var(--phone-bottom)); background:#0002; }
  .phone-active.phone-sheet-open .editor>.transport,.phone-active.phone-sheet-open #phoneSelection { visibility:hidden; }
  .phone-active #phoneCameraControls { position:absolute; z-index:85; bottom:calc(var(--phone-dock) + var(--phone-bottom)); left:12px; right:12px; margin:0; border-radius:14px; background:#211829cc; }
  .phone-active.phone-camera.phone-sheet-open #phoneSheet { bottom:calc(var(--phone-dock) + var(--phone-bottom) + 120px); max-height:58dvh; }
  .phone-active #phoneWelcome { inset:0; background:#000; border:0; border-radius:0; }
  .phone-active.phone-keyboard.phone-sheet-open #phoneSheet { bottom:var(--phone-keyboard-bottom,0px); max-height:calc(var(--phone-visible-height,100dvh) - var(--phone-header)); }
}
@media (max-width:950px) and (orientation:landscape) and (max-height:600px) {
  .phone-active #phoneSheet,.phone-active.phone-camera.phone-sheet-open #phoneSheet { left:auto; right:env(safe-area-inset-right,0px); width:min(360px,55vw); top:var(--phone-header); bottom:calc(var(--phone-dock) + var(--phone-bottom)); max-height:none; border-radius:16px 0 0 0; }
  .phone-active .editor>.transport { right:auto; width:min(340px,48vw); }
}
@keyframes phone-tools-in { from { opacity:0; transform:translateY(24px); } to { opacity:1; transform:translateY(0); } }
@media (prefers-reduced-motion:reduce) { .phone-active #phoneSheet { animation:none; } }
/* Editing bar inside the phone Layers sheet: narrower track names. */
.phone-active #phoneSheetBody .tl-content{--tl-head:82px}
.phone-active #phoneSheetBody .tl-content .track-label{font-size:13px}
.phone-active #phoneSheetBody .tl-video .track-lane{height:56px}
/* Small round × buttons and trim handles keep their own size (with a larger invisible tap area). */
.phone-active #phoneSheetBody .clip-x,.phone-active #phoneSheetBody .track-delete{min-height:0;border-radius:50%;font-size:15px}
/* Editing-bar tools scroll sideways in one row instead of wrapping. */
.phone-active #phoneSheetBody .timeline-top .tl-tools{flex-wrap:nowrap;overflow-x:auto;width:100%;margin-left:0;scrollbar-width:none}
.phone-active #phoneSheetBody .timeline-top .tl-tools button{flex:0 0 auto;min-height:40px}
.phone-active #phoneSheetBody .tl-zoom{width:100%}
.phone-active #phoneSheetBody .tl-zoom input{flex:1;width:auto}
.phone-active #phoneSheetBody .timeline-top .tl-zoom button{min-height:36px}
/* Throw buttons stay on screen: the phone picture is centred and wider than the screen, so measure from the screen's left edge. */
@media (max-width:1150px), (max-width:950px) and (max-height:600px), (pointer:coarse) and (max-width:1150px) and (min-height:601px) {
  .phone-active .cam-fx-bar { margin:0 -12px 2px; width:calc(100% + 24px); flex:0 0 auto; justify-content:flex-start; padding:2px 10px 6px; }
  .phone-active #phoneCameraControls .cam-fx-bar button { min-width:52px; border-radius:12px; background:#1d1824; padding:5px 2px; font-size:inherit; }
  .phone-active #phoneCameraControls .cam-fx-bar .cam-fx-pop { min-width:66px; background:#2a1f3a; }
  .phone-active .cam-fx-bar button { width:52px; min-height:54px; }
}

/* Tools sheet (2026-10-16): it rises to about three quarters of the screen, and after you pick something it drops to a
   short "peek" (instead of closing) so you see the result and can pick again. Tap the grip or the title to raise it. */
@media (max-width:1150px), (max-width:950px) and (max-height:600px), (pointer:coarse) and (max-width:1150px) and (min-height:601px) {
  .phone-active .phone-sheet-grip { display:block; flex:none; align-self:center; width:100%; height:22px; margin:-6px 0 0; padding:0; border:0; background:none; }
  .phone-active .phone-sheet-grip::before { content:''; display:block; width:54px; height:5px; margin:8px auto 0; border-radius:3px; background:#bfaee0; }
  .phone-active #phoneSheet { transition:max-height .22s ease; }
  .phone-active.phone-sheet-open.phone-sheet-peek #phoneSheet,.phone-active.phone-camera.phone-sheet-open.phone-sheet-peek #phoneSheet { max-height:32dvh; }
  .phone-active.phone-sheet-peek .phone-sheet-head { cursor:pointer; }
  .phone-active.phone-sheet-peek #phoneSheetBody .search,.phone-active.phone-sheet-peek #phoneSheetBody .categories,.phone-active.phone-sheet-peek #phoneSheetBody .collection-title,.phone-active.phone-sheet-peek #phoneSheetBody .lab-intro,.phone-active.phone-sheet-peek #phoneSheetBody .director-hero { display:none; }
  /* While peeking, play/Layers sit just above the sheet and the selected layer's Adjust bar stays at the top. */
  .phone-active.phone-sheet-open.phone-sheet-peek .editor>.transport,.phone-active.phone-sheet-open.phone-sheet-peek #phoneSelection { visibility:visible; }
  .phone-active.phone-sheet-open.phone-sheet-peek .editor>.transport { bottom:calc(var(--phone-dock) + var(--phone-bottom) + 32dvh); }
  /* The mascot steps below the selected layer's Adjust bar instead of covering its button. */
  .phone-active.phone-selected .mascot-buddy { top:calc(var(--phone-header) + 74px); }
  /* Recording controls stay above the dock (under the sheet's gap) while tools are open, so Stop is always reachable. */
  .phone-active.phone-camera.phone-sheet-open #phoneCameraControls { position:absolute; }
  .phone-active #phoneDock button { color:#fff; font-weight:600; text-shadow:0 0 8px #ffffff40; }
  .phone-active #phoneSheetTitle { color:#fff; text-shadow:0 0 9px #ffffff50; }
}
/* iPad and other tablets held upright: the same touch studio, with roomier tool grids. */
@media (pointer:coarse) and (min-width:721px) and (max-width:1150px) and (min-height:601px) {
  body.phone-active { --phone-dock:92px; --phone-header:68px; }
  .phone-active #phoneDock { padding-left:max(24px,calc(50vw - 360px)); padding-right:max(24px,calc(50vw - 360px)); }
  .phone-active #phoneDock button { font-size:16px; }
  .phone-active #phoneDock .phone-icon { font-size:26px; }
  .phone-active #phoneSheet { padding-left:max(20px,calc(50vw - 380px)); padding-right:max(20px,calc(50vw - 380px)); }
  .phone-active #phoneSheetBody .asset-grid { grid-template-columns:repeat(5,minmax(0,1fr)); }
  .phone-active .phone-menu-grid { grid-template-columns:repeat(3,minmax(0,1fr)); }
  .phone-active #phoneSheetBody { font-size:16px; }
}
@media (pointer:coarse) and (min-width:721px) and (max-width:1150px) and (min-height:601px) and (prefers-reduced-motion:reduce) { .phone-active #phoneSheet { transition:none; } }

#phoneSwitches,#phoneCamSwitch,#phoneStageSwitch{display:none}.phone-active .transport #phoneSwitches{display:flex;gap:6px;grid-column:2;grid-row:1;justify-self:end;align-items:center}
.phone-active .transport #phoneStageSwitch,.phone-active .transport #phoneCamSwitch{display:flex;grid-column:2;grid-row:1;justify-self:end;align-items:center;min-height:44px;padding:0 12px;font-size:14px;font-weight:700;border-radius:10px;border:1px solid #6b55a0;background:#2c2338;color:#f1e9ff;white-space:nowrap}.phone-active .transport #phoneCamSwitch.on{background:#5a1f2e;border-color:#ff5f7e}.phone-active .transport #phoneStageSwitch.on{background:#3b2a6e;border-color:#c4adff}

/* Fitted mobile studio. Reserve space for controls instead of covering the video. */
@media(max-width:1150px){
 body.phone-active{--phone-header:calc(52px + env(safe-area-inset-top,0px));--phone-dock:62px;--phone-controls:88px;--tool-space:0px;--phone-bottom:env(safe-area-inset-bottom,0px)}
 .phone-active.phone-camera{--phone-controls:142px}
 .phone-active.phone-sheet-open{--tool-space:min(40dvh,340px)}
 .phone-active.phone-sheet-open.phone-sheet-peek{--tool-space:148px}
 .phone-active .workspace,.phone-active.phone-sheet-open:not(.phone-camera):not(.phone-keyboard) .workspace{position:fixed;inset:var(--phone-header) 0 calc(var(--phone-dock) + var(--phone-bottom));height:auto;min-height:0;max-height:none;width:auto;padding:0}
 .phone-active .editor{display:flex;flex-direction:column;width:100%;height:100%;min-height:0;padding:0;gap:0}
 .phone-active .editor>.stage,.phone-active.phone-camera.phone-sheet-open .editor>.stage{position:relative;inset:auto;flex:1;min-height:0;width:100%;height:auto;container-type:size;padding:0;margin:0 0 var(--tool-space);overflow:hidden;background:#08080b}
 .phone-active .canvas-wrap{position:absolute;left:50%;top:50%;transform:translate(-50%,-50%);width:min(100cqw,calc(100cqh * 9 / 16));height:min(100cqh,calc(100cqw * 16 / 9));max-width:100%;max-height:100%;border-radius:0;box-shadow:none}
 .phone-active.landscape .canvas-wrap{width:min(100cqw,calc(100cqh * 16 / 9));height:min(100cqh,calc(100cqw * 9 / 16))}
 .phone-active #phoneHeader{height:var(--phone-header);padding:4px max(12px,env(safe-area-inset-right)) 4px max(12px,env(safe-area-inset-left));padding-top:calc(4px + env(safe-area-inset-top));background:#101014;border-bottom:1px solid #27272d}
 .phone-active #phoneHeader button{height:44px;min-height:44px;border-radius:8px;font-size:14px}.phone-active #phoneHeader #phoneProject{font-size:20px}
 .phone-active #phoneDock{inset:auto 0 0;height:calc(var(--phone-dock) + var(--phone-bottom));width:auto;padding:4px max(8px,env(safe-area-inset-right)) calc(4px + var(--phone-bottom)) max(8px,env(safe-area-inset-left));gap:4px;background:#101014;border-top:1px solid #27272d}
 .phone-active #phoneDock button{background:transparent;border:0;border-radius:8px;min-height:48px;font-size:11px;gap:3px;text-shadow:none}.phone-active #phoneDock button[aria-expanded=true]{background:#292333;color:#d8c8ff}.phone-active .phone-icon{font-size:22px}
 .phone-active .editor>.transport{position:relative;inset:auto;flex:0 0 var(--phone-controls);width:100%;height:var(--phone-controls);min-height:0;grid-template-columns:44px minmax(0,1fr) auto;grid-template-rows:44px 32px;margin:0;padding:4px 12px;border-radius:0;background:#101014;visibility:visible}
 .phone-active.phone-sheet-open .editor>.transport{visibility:visible}.phone-active .transport #play{width:44px;height:44px;min-height:44px}
 .phone-active #phoneSwitches{gap:4px}.phone-active #phoneSwitches button{min-height:44px;padding:6px 8px;font-size:12px}.phone-active .transport #phoneLayers{min-height:44px;padding:6px 8px;font-size:12px}
 .phone-active.phone-empty .transport #phoneSwitches{visibility:hidden}
 .phone-active #phoneCameraControls{position:relative;inset:auto;flex:0 0 var(--phone-controls);width:100%;height:var(--phone-controls);min-height:0;margin:0;padding:6px 12px;gap:4px 8px;background:#101014;border:0;border-radius:0;align-content:center}
 .phone-active #phoneRecordStatus{font-size:11px;margin:0;line-height:16px}.phone-active #phoneCameraControls button{min-height:44px;border-radius:8px}
 .phone-active #phoneCameraControls .cam-fx-bar{padding:0 10px 4px;margin:0 -12px;width:calc(100% + 24px)}.phone-active #phoneCameraControls .cam-fx-bar button{min-height:44px;height:44px;background:#202026;border:0}.phone-active .cam-fx-bar small{font-size:10px}
 .phone-active #phoneSheet,.phone-active.phone-camera.phone-sheet-open #phoneSheet{position:fixed;inset:auto 0 calc(var(--phone-dock) + var(--phone-bottom) + var(--phone-controls));height:var(--tool-space);max-height:var(--tool-space);width:100%;padding:4px 12px 8px;border-radius:14px 14px 0 0;background:#16161c;border:1px solid #34343e;box-shadow:none;backdrop-filter:none;animation:none}
 .phone-active .phone-sheet-grip{height:16px;min-height:16px;padding:0}.phone-active .phone-sheet-head{min-height:44px;margin:0 0 4px}.phone-active #phoneSheetTitle{font-size:16px}.phone-active #phoneClose,.phone-active #phoneBack{min-height:44px;background:transparent;padding:6px 12px}
 .phone-active #phoneSheetBody{padding:0;font-size:14px}.phone-active .phone-menu-grid{gap:6px}.phone-active .phone-menu-grid button{background:#23232c;border:1px solid #363640;min-height:48px!important;padding:10px}
 .phone-active #phoneShade,.phone-active.phone-camera.phone-sheet-open #phoneShade{inset:var(--phone-header) 0 calc(var(--phone-dock) + var(--phone-bottom) + var(--phone-controls) + var(--tool-space));background:transparent}
 .phone-active #phoneWelcome{inset:0;padding:20px;gap:12px;justify-content:center;background:#08080b}.phone-active #phoneWelcome h2{font-size:22px;line-height:1.25;margin:0}.phone-active #phoneWelcome p{font-size:14px;margin:0 0 8px}.phone-active #phoneWelcome button{min-height:44px;padding:10px 16px;max-width:300px;width:100%;border-radius:10px;font-size:15px}
 .phone-active #phoneSelection{top:4px;left:8px;right:8px;bottom:auto;font-size:12px}.phone-active #phoneSelection button{min-height:44px}
 .phone-active #mascotBuddy{position:fixed;top:calc(var(--phone-header) + 6px);right:8px;width:40px!important;min-height:44px;z-index:75}.phone-active #toggleTimeline{display:none}
 .phone-active.phone-keyboard.phone-sheet-open #phoneSheet{bottom:var(--phone-keyboard-bottom,0px);height:calc(var(--phone-visible-height) - var(--phone-header));max-height:calc(var(--phone-visible-height) - var(--phone-header))}
 .phone-active.phone-keyboard .editor>.transport,.phone-active.phone-keyboard #phoneCameraControls{visibility:hidden}
}
/* Tablets and wide phones: keep tools beside the entire preview. */
@media(min-width:721px) and (max-width:1150px){
 .phone-active{--tablet-tools:320px}.phone-active.phone-sheet-open{--tool-space:0px}
 .phone-active.phone-sheet-open .workspace{right:var(--tablet-tools)!important}
 .phone-active #phoneSheet,.phone-active.phone-camera.phone-sheet-open #phoneSheet{top:var(--phone-header);right:0;left:auto;bottom:calc(var(--phone-dock) + var(--phone-bottom));width:var(--tablet-tools);height:auto;max-height:none;border-radius:0;border-right:0;padding:8px 12px}
 .phone-active #phoneShade,.phone-active.phone-camera.phone-sheet-open #phoneShade{right:var(--tablet-tools);bottom:calc(var(--phone-dock) + var(--phone-bottom))}
 .phone-active #phoneDock{justify-content:center;padding-left:max(12px,calc((100vw - 600px)/2));padding-right:max(12px,calc((100vw - 600px)/2))}
 .phone-active.phone-sheet-open #mascotBuddy{right:calc(var(--tablet-tools) + 8px)}
 .phone-active.phone-sheet-peek #phoneSheet{height:auto;max-height:none}
}
@media(max-height:500px) and (max-width:950px){
 body.phone-active{--phone-header:48px;--phone-dock:52px;--phone-controls:64px}.phone-active.phone-camera{--phone-controls:100px}
 .phone-active #phoneRecordStatus{display:none}.phone-active .editor>.transport{grid-template-rows:32px 24px;padding-top:0}.phone-active .transport #play{min-height:32px;height:32px;width:36px}.phone-active #phoneDock button{min-height:44px}
}
@media(max-width:1150px){
 .phone-active .editor>.stage{order:0}
 .phone-active .editor>.transport,.phone-active #phoneCameraControls{order:3}
 .phone-active #mascotBuddy{width:36px!important;filter:none}
 .phone-active.phone-sheet-open #mascotBuddy{display:none}
 .phone-active.phone-empty .editor>.transport{display:none}
 .phone-active.phone-empty:not(.phone-camera){--phone-controls:0px}
}
@media(max-width:1150px){
 .phone-active.phone-camera.phone-sheet-open #phoneCameraControls{position:relative;inset:auto}
 .phone-active.phone-sheet-open.phone-sheet-peek .editor>.transport{inset:auto}
 .phone-active.phone-sheet-open.phone-sheet-peek #phoneSheet,.phone-active.phone-camera.phone-sheet-open.phone-sheet-peek #phoneSheet{max-height:var(--tool-space)}
 .phone-active #phoneSheet{transition:none}.phone-active #phoneSheetTitle{text-shadow:none}
 .phone-active .cam-fx-menu{z-index:90;max-height:min(50dvh,400px)}.phone-active .cam-fx-menu button{min-height:44px}
}
@media(min-width:721px) and (max-width:1150px){
 .phone-active .phone-menu-grid{grid-template-columns:repeat(2,minmax(0,1fr))}
 .phone-active #phoneSheetBody .asset-grid{grid-template-columns:repeat(2,minmax(0,1fr))}
 .phone-active.phone-sheet-open.phone-sheet-peek #phoneSheet,.phone-active.phone-camera.phone-sheet-open.phone-sheet-peek #phoneSheet{max-height:none}
}
@media(min-width:721px) and (max-width:1150px){
 .phone-active.phone-sheet-open.phone-sheet-peek{--tool-space:0px}
}

/* Keep the buddy inside the preview, clear of capture tabs and controls. */
.phone-active #mascotBuddy,.phone-active.phone-sheet-open #mascotBuddy{position:absolute;top:10px;right:10px;z-index:5}

/* Reserve a usable preview when capture tabs and the tools drawer share a small phone. */
@media (max-width:600px) and (min-height:501px){
 .phone-active.phone-sheet-open{--tool-space:min(40dvh,340px,max(100px,calc(100dvh - var(--phone-header) - var(--phone-dock) - var(--phone-bottom) - var(--phone-controls) - 170px)))}
 .phone-active.timeline-capture.phone-sheet-open{--tool-space:min(32dvh,240px,max(100px,calc(100dvh - var(--phone-header) - var(--phone-dock) - var(--phone-bottom) - var(--phone-controls) - 270px)))}
 .phone-active.phone-sheet-open.phone-sheet-peek{--tool-space:120px}
}
