/* This layer applies only to phone portrait and short phone landscape. */
#phoneHeader,#phoneControls,#phonePanel{display:none}
body.phone-preview{position:fixed;inset:0;width:100%;height:var(--phone-height,100dvh);display:flex;flex-direction:column;overflow:hidden;overscroll-behavior:none;padding:0}
body.phone-preview>header{display:none!important}
body.phone-preview #phoneHeader{order:-1;display:flex;flex:none;align-items:center;gap:4px;min-height:52px;padding:max(4px,env(safe-area-inset-top)) max(8px,env(safe-area-inset-right)) 4px max(8px,env(safe-area-inset-left));background:#f4f2ec}
#phoneHeader strong{font-size:17px;letter-spacing:-.7px;margin-right:auto;white-space:nowrap}
#phoneHeader button{min-width:44px;min-height:44px;padding:6px;font-size:12px;border:1px solid #b6c8be;background:#fff;color:#264a40;border-radius:9px}
body.phone-preview>main{display:flex;flex:1;min-height:0;width:100%;padding:0 max(0px,env(safe-area-inset-right)) 0 max(0px,env(safe-area-inset-left))}
body.phone-preview .instrument,body.phone-preview[data-handedness=left] .instrument{display:grid;flex:1;min-height:0;border-radius:0;border:0;grid-template-columns:minmax(0,1fr);grid-template-rows:auto minmax(0,1fr)}
body.phone-preview #stage,body.phone-preview[data-handedness=left] #stage{grid-column:1;grid-row:2;width:100%;min-height:0}
body.phone-preview #paletteViewport{display:none;grid-column:1;grid-row:1}
body.phone-preview.phone-bells #paletteViewport{display:block}
body.phone-preview #phoneControls{display:flex;flex:none;justify-content:space-around;gap:4px;padding:5px max(8px,env(safe-area-inset-right)) max(5px,env(safe-area-inset-bottom)) max(8px,env(safe-area-inset-left));background:#edf1e9;border-top:1px solid #bbc9c0}
#phoneControls button{flex:1;min-height:48px;min-width:44px;padding:4px;font-size:12px;font-weight:600;border:1px solid #b9c9bf;border-radius:9px;color:#264a40;background:#fdfdf9}
#phoneControls button[aria-pressed=true]{background:#254d45;color:#fff;border-color:#254d45}
#phoneControls #phoneFinish{background:#96343a;color:white;border-color:#96343a}
body.phone-preview :is(#phoneHeader,#phoneControls) [hidden]{display:none!important}
body.phone-preview #phonePanel:not([hidden]){display:flex;flex-direction:column;position:fixed;z-index:40;left:max(6px,env(safe-area-inset-left));right:max(6px,env(safe-area-inset-right));bottom:calc(env(safe-area-inset-bottom) + 64px);max-height:min(46dvh,420px);max-height:min(calc(var(--phone-height,100dvh)*.46),420px);padding:0 10px 10px;background:#f4f5ee;border:1px solid #a9beb2;border-radius:14px;box-shadow:0 -5px 26px #09181e40;color:#294b40;overflow:hidden}
.phone-panel-heading{display:flex;align-items:center;justify-content:space-between;gap:10px;min-height:52px;flex:none;border-bottom:1px solid #c7d3c9}
.phone-panel-heading h2{font-size:16px;margin:0}.phone-panel-heading button{min-height:44px;min-width:60px;border:0;background:#dce9df;color:#294b40;padding:6px 10px;margin:4px 0}
#phonePanelContent{min-height:0;overflow:auto;overscroll-behavior:contain;touch-action:pan-y}
#phonePanelContent>[hidden]{display:none!important}
body.phone-preview .canvas-tools{display:flex;position:static;width:auto;max-height:none;overflow:visible;border:0;padding:10px 0;background:transparent}
body.phone-preview .canvas-tools .rail-scroll{overflow:visible;flex:none;width:100%}
body.phone-preview .canvas-tools .tool-grid{grid-template-columns:repeat(4,minmax(0,1fr));gap:5px}
body.phone-preview .canvas-tools .tool-group[aria-labelledby=toolsPlay]{display:none}
body.phone-preview .canvas-tools .tool-group h2{text-align:left;font-size:11px}
body.phone-preview .canvas-tools button{height:52px!important;min-height:44px;width:100%;min-width:44px}
body.phone-preview .canvas-tools :is(#mute,#draw){grid-column:span 2;flex-direction:row}
body.phone-preview .canvas-tools .pitch-caption{display:none}
body.phone-preview .canvas-tools .rail-recover{width:100%}
body.phone-preview .canvas-tools .rail-recover .tool-grid{grid-template-columns:1fr}
body.phone-preview #phoneSettingsContent .workspace-panel{position:static;display:block;width:100%;max-height:none;padding:4px 0;border:0;border-radius:0;box-shadow:none;overflow:visible;background:transparent}
body.phone-preview .workspace-panel>.drawer-heading,body.phone-preview .workspace-panel>.tool-position{display:none}
.phone-preferences{display:flex;align-items:center;gap:8px;flex-wrap:wrap;padding:10px 0}
body.phone-preview .palette-top{display:flex;position:static;padding:10px 0;gap:10px}
body.phone-preview .palette-options{width:100%;gap:8px}
body.phone-preview .palette-top .octave-controls{width:100%;display:flex;justify-content:space-between}
body.phone-preview .timbres{display:flex;flex-wrap:wrap;width:100%;gap:5px}
body.phone-preview .timbres button{flex:1;min-height:44px;min-width:48px;font-size:11px}
body.phone-preview #modeHint{max-width:calc(100% - 16px);padding:4px 7px;bottom:7px;left:7px}
body.phone-preview #modeHint>span{display:none}
body.phone-preview #modeHint>strong{font-size:11px;font-weight:500}
body.phone-preview #toolHint{display:none!important}
body.phone-preview #empty h2{font-size:22px;margin:10px 0}body.phone-preview #empty p{font-size:12px}
body.phone-preview #empty button{min-height:44px}
body.phone-preview :is(.bell,.path-button)::before{content:'';position:absolute;left:50%;top:50%;transform:translate(-50%,-50%);width:max(100%,var(--phone-hit-size,44px));height:max(100%,var(--phone-hit-size,44px));border-radius:50%;background:transparent}
body.phone-preview .record-bar.recording{right:8px;bottom:44px;font-size:11px}
body.phone-preview #startGuide{max-height:45%;width:calc(100% - 24px)}
body.phone-preview .terrain-dialog{max-height:calc(var(--phone-height,100dvh) - env(safe-area-inset-top) - env(safe-area-inset-bottom) - 20px);max-width:calc(100vw - env(safe-area-inset-left) - env(safe-area-inset-right) - 16px);overscroll-behavior:contain}
body.phone-preview :is(input,textarea,select){font-size:16px}
body.phone-preview button:focus-visible{outline:3px solid #3869ba;outline-offset:-3px}
@media(max-height:500px){body.phone-preview #phoneHeader{min-height:44px;padding-top:max(0px,env(safe-area-inset-top));padding-bottom:0}body.phone-preview #phoneControls{padding-top:3px;padding-bottom:max(3px,env(safe-area-inset-bottom))}#phoneControls button{min-height:44px}body.phone-preview #phonePanel:not([hidden]){max-height:60%;bottom:calc(env(safe-area-inset-bottom) + 54px);left:45%;right:max(6px,env(safe-area-inset-right))}body.phone-preview.phone-bells #paletteViewport #palette{height:88px}body.phone-preview.phone-bells #paletteViewport .white-key{top:30px}body.phone-preview.phone-bells #paletteViewport .black-key{top:0}body.phone-preview.phone-bells #paletteViewport:is([data-palette=diatonic],[data-palette=pentatonic]):not(.piano-overlay) #palette{height:60px}body.phone-preview.phone-bells #paletteViewport:is([data-palette=diatonic],[data-palette=pentatonic]):not(.piano-overlay) .white-key{top:4px}}

/* The immutable player has no tray; its stage must occupy the flexible row. */
body.phone-preview[data-activity-preview="true"] .instrument{grid-template-rows:minmax(0,1fr)!important}
body.phone-preview[data-activity-preview="true"] #stage{grid-row:1}
#phoneControls #phoneSaveState{background:#fff0d8;color:#743b16;border-color:#b77c42;font-weight:750}
