/* Touch workspace. Scoped to the existing mobile editor and Studio. */
#pfPhoneQuick,#pfPhoneBoxActions{display:none}
@media(max-width:920px){
  body[data-pf-phone-ui=true]:not(.presentation):not(.pf-pbr-active):not(.viewer-open){
    --pf-phone-panel:min(38dvh,310px);--pf-phone-dock:calc(60px + env(safe-area-inset-bottom));
  }
  body[data-pf-phone-ui=true][data-pf-phone-expanded=true]:not(.presentation):not(.pf-pbr-active):not(.viewer-open){--pf-phone-panel:min(52dvh,410px)}
  body[data-pf-phone-ui=true]:not(.presentation):not(.pf-pbr-active):not(.viewer-open) #pfPhoneQuick{
    position:fixed;display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1fr) 44px 44px;gap:5px;
    top:var(--pf-phone-header,52px);left:0;right:0;padding:4px 8px;
    background:var(--app-panel);border-bottom:1px solid var(--app-border);z-index:46;
  }
  #pfPhoneQuick button,#pfPhoneProductsToggle,#pfPhoneHeading .pf-phone-panel-actions button{
    display:inline-flex;justify-content:center;align-items:center;gap:7px;
    min-height:44px;min-width:0;margin:0;padding:5px 8px;
    border:1px solid var(--app-border);border-radius:10px;
    background:var(--app-card);color:var(--app-text);font:650 12px/1.25 system-ui;
  }
  #pfPhoneQuick button[hidden]{display:none!important}
  #pfPhoneProducts{min-width:0;margin:0}
  #pfPhoneProductsToggle{display:flex;width:100%;cursor:pointer;list-style:none;white-space:nowrap}
  #pfPhoneProductsToggle::-webkit-details-marker{display:none}
  #pfPhoneProductsToggle svg:last-child{width:13px;height:13px}
  #pfPhoneProducts[open] #pfPhoneProductsToggle{border-color:var(--app-accent);color:var(--app-accent);background:var(--app-hover)}
  #pfPhoneProductMenu{
    position:absolute;top:100%;left:8px;width:min(340px,calc(100% - 16px));max-height:calc(100dvh - var(--pf-phone-header,52px) - 65px);
    overflow:auto;overscroll-behavior:contain;padding:10px;border:1px solid var(--app-border);border-radius:12px;
    background:var(--app-panel);box-shadow:0 10px 30px #112d3b45;
  }
  #pfPhoneQuick #pfPhoneSearchModels{display:flex;width:100%}
  #pfPhoneProductMenu #pfDesignProducts{display:grid;gap:7px;margin-top:8px;padding:0;border:0;background:transparent}
  #pfPhoneProductMenu #pfDesignProducts [data-products]{display:grid;gap:5px;overflow:visible}
  #pfPhoneProductMenu #pfDesignProducts :is(.dp-product,.dp-group,#dpAdd){width:100%;max-width:none;min-height:44px}
  #pfPhoneProductMenu #pfDesignProducts :is(.dp-product,.dp-group){justify-content:flex-start;text-align:left}
  #pfPhoneProductMenu #pfDesignProducts [aria-selected=true]{color:var(--app-accent);background:var(--app-hover);outline-color:var(--app-accent)}
  #pfPhoneQuick #pfPhoneSave{color:var(--app-accent);border-color:var(--app-accent)}
  #pfPhoneQuick button:disabled{opacity:.42}
  #pfPhoneQuick svg,#pfPhoneHeading svg,.pf-mobile-all-tools svg{width:19px;height:19px;flex:none}
  body[data-pf-phone-ui=true]:not(.presentation):not(.pf-pbr-active):not(.viewer-open) #stage{top:calc(var(--pf-phone-header,52px) + 53px)!important}
  #pfPhoneView #pfDirectDock{position:static;grid-template-columns:1fr;gap:8px;padding:0;border:0;background:transparent}
  #pfPhoneView #pfDirectDock :is(button,select){min-height:44px;font-size:13px}
  #pfPhoneView #pfDirectDock .pf-direct-zone{display:grid;gap:4px;font-size:12px}
  #pfPhoneView #pfDirectDock #pfDirectZone{width:100%;max-width:none;margin:0}
  #pfPhoneView #pfDirectDock button[aria-pressed=true]{background:var(--app-hover);color:var(--app-accent);border-color:var(--app-accent)}
  #pfPhoneView #zoomtools{position:static;margin:4px 0 10px}
  #pfPhoneView #zoomtools button{min-width:44px}
  #pfPhoneView #zoomtools #fitview{flex:1}
  #pfPhoneView :is(#pfAppearanceModes,#pfPreviewBackground,#pfAppearanceItems){position:static;max-height:none}
  #pfPhoneView #pfAppearanceModes{margin-bottom:8px;flex-wrap:wrap}
  #pfPhoneView #pfAppearanceLabelsToggle{display:none!important}
  #pfPhoneView :is(#pfAppearanceModes,#pfAppearanceItems) button,#pfPhoneView #pfPreviewBackground{min-height:44px}
  #pfPhoneView #pfAppearanceItems:not([hidden]){display:grid;margin-top:8px}
  #pfPhoneView #pfAppearanceItems button{display:flex;align-items:center;gap:7px;text-align:left}
  #pfPhoneViewStatus{display:none}
  body[data-pf-phone-ui=true]:not(.presentation):not(.pf-pbr-active):not(.viewer-open) #pfPhoneViewStatus{
    display:flex;align-items:center;gap:8px;flex:none;min-height:25px;padding:3px 9px;
    color:var(--app-muted);background:var(--app-panel);border-bottom:1px solid var(--app-border);font:11px/1.2 system-ui;
  }
  #pfPhoneViewStatus strong{color:var(--app-text);font-variant-numeric:tabular-nums}
  #pfPhoneViewStatus #viewname{position:static;margin-left:auto;white-space:nowrap;color:var(--app-muted);font-size:10px}
  #pfPhoneViewStatus #issueBadge{position:static;min-height:44px;box-shadow:none}
  body[data-pf-phone-ui=true]:not(.presentation):not(.viewer-open) #stage>:is(.stats,.jar-switch){display:none!important}
  body[data-pf-phone-ui=true] #pfPhoneView .stats{max-height:none!important}
  #pfPhoneView #pfCapacity{position:static;width:auto;max-width:none;box-shadow:none}
  #pfPhoneView #pfCapacity summary{min-height:44px;padding:12px 10px}
  #pfPhoneView #pfCapacity .pf-capacity-fields{width:auto;max-height:none;overflow:visible}
  body[data-pf-phone-ui=true] #pfPhoneBoxActions{display:block}
  body[data-pf-phone-ui=true] #pfPhoneBoxActions #pfFitBoxOpen{position:static;max-width:none;width:100%;min-height:44px}
  body[data-pf-phone-ui=true] #controls #pfCurrentProduct{position:static!important;display:flex!important;flex-wrap:wrap;max-width:none!important;padding:8px 0;min-height:0}
  body[data-pf-phone-ui=true] #controls #pfCurrentProduct #pfBrowseModels{display:inline-flex!important;min-height:44px}
  body[data-pf-phone-ui=true] #controls{border-radius:17px 17px 0 0;box-shadow:0 -4px 16px #112d3b24;scroll-padding-top:110px}
  @supports (grid-template-rows:subgrid){
    body[data-pf-phone-ui=true] #controls .grid:has(>label>.measure-slider){row-gap:2px}
    body[data-pf-phone-ui=true] #controls .grid>label:has(>.measure-slider){
      display:grid;grid-row:span 4;grid-template-rows:subgrid;align-self:stretch;
      align-items:start;line-height:1.3;margin:4px 0 8px;
    }
    body[data-pf-phone-ui=true] #controls .grid>label:has(>.measure-slider)>input:not(.measure-slider){
      grid-row:2;width:100%;min-width:0;max-width:none;margin:0;
    }
    body[data-pf-phone-ui=true] #controls .grid>label>.measure-slider{grid-row:3;margin:0}
    body[data-pf-phone-ui=true] #controls .grid>label>.pf-measure-feedback{grid-row:4;margin:0}
  }
  body[data-pf-phone-ui=true] #pfPhoneHeading{gap:3px 8px;padding:5px 0!important}
  #pfPhoneHeading .pf-phone-panel-title{min-width:0;display:flex;flex-direction:column;justify-content:center;gap:2px}
  #pfPhoneHeading .pf-phone-panel-title span{color:var(--app-muted);font:700 9px/1.2 system-ui;letter-spacing:.12em}
  #pfPhoneHeading .pf-phone-panel-title strong{font-size:16px}
  #pfPhoneHeading .pf-phone-panel-actions{display:flex;gap:5px}
  #pfPhoneHeading .pf-phone-panel-actions button,#pfPBRDialog.pf-mobile-studio .pf-mobile-drawer-title :is([data-expand],[data-collapse]){min-width:44px;min-height:44px}
  #pfPhoneHeading .pf-phone-panel-actions button[aria-pressed=true]{border-color:var(--app-accent);color:var(--app-accent)!important}
  body[data-pf-phone-ui=true] #pfPhoneNav{overflow:hidden;gap:2px;padding:3px 4px env(safe-area-inset-bottom);align-items:stretch}
  #pfPhoneNav button{flex:1 1 0;min-width:0;min-height:44px;font:600 10px/1.15 system-ui;border-radius:10px;gap:4px}
  #pfPhoneNav button[aria-expanded=false]{border-color:transparent;box-shadow:none}
  #pfPhoneNav button[aria-expanded=true]{box-shadow:none;border:1px solid var(--app-accent)}
  body[data-pf-phone-ui=true] #controls :is(.pf-phone-actions button,#pfPhoneLegal a,summary){min-height:44px}
  body[data-pf-phone-ui=true] #controls #pfPhoneLegal a{display:inline-flex;align-items:center;font-size:12px}
  body[data-pf-phone-ui=true] #controls input[type=range],#pfPBRDialog.pf-mobile-studio input[type=range]{min-height:38px;accent-color:var(--app-accent,#79d7c6)}
  body[data-pf-phone-ui=true] #controls input:not([type=range]):not([type=checkbox]):not([type=color]),
  body[data-pf-phone-ui=true] #controls select,#pfPBRDialog.pf-mobile-studio .pf-pbr-scroll input:not([type=range]):not([type=checkbox]):not([type=color]),
  #pfPBRDialog.pf-mobile-studio .pf-pbr-scroll select{min-height:44px;font-size:16px}
  body[data-pf-phone-ui=true] #controls #pfSizeFields .grid{align-items:start;gap:8px 10px}
  body[data-pf-phone-ui=true] #controls .pf-mobile-root-summary,#pfPBRDialog.pf-mobile-studio .pf-mobile-root-summary{display:none!important}
  .pf-mobile-toolstrip{display:flex;align-items:center;gap:7px;min-width:0;border-top:1px solid var(--app-border,#ffffff25);padding:3px 0}
  .pf-mobile-toolstrip .pf-mobile-subtools{min-width:0;flex:1;padding:0 0 3px;scrollbar-width:thin;touch-action:pan-x;position:relative}
  #controls .pf-mobile-toolstrip .pf-mobile-subtools button,#pfPBRDialog .pf-mobile-toolstrip .pf-mobile-subtools button{min-height:42px;font-size:12px}
  #controls .pf-mobile-all-tools,#pfPBRDialog .pf-mobile-all-tools{
    display:inline-flex;align-items:center;justify-content:center;gap:5px;flex:none;min-height:44px;
    padding:5px 8px!important;font:700 11px/1 system-ui;color:var(--app-accent,#b4eee6)!important;
    border:1px solid var(--app-border,#52727b);background:var(--app-card,#243b43)!important;border-radius:8px;
  }
  #controls .pf-mobile-all-tools[hidden],#pfPBRDialog .pf-mobile-all-tools[hidden]{display:none!important}
  .pf-mobile-tool-picker{
    box-sizing:border-box;width:min(460px,calc(100vw - 24px));max-height:75dvh;overflow:auto;
    border:1px solid var(--app-border);border-radius:18px;padding:14px;
    background:var(--app-panel);color:var(--app-text);box-shadow:0 12px 38px #08273555;
  }
  .pf-mobile-tool-picker::backdrop{background:#0b253b83}
  .pf-mobile-tool-picker>header{position:static!important;display:flex;justify-content:space-between;align-items:center;gap:12px;padding:0 0 10px;height:auto;border:0;background:transparent}
  .pf-mobile-tool-picker h2{margin:0;font:700 17px/1.3 system-ui;letter-spacing:0;text-transform:none}
  .pf-mobile-tool-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px}
  .pf-mobile-tool-picker button{min-height:44px;padding:8px;border:1px solid var(--app-border);border-radius:9px;background:var(--app-card);color:var(--app-text);text-align:left}
  .pf-mobile-tool-picker button[hidden]{display:none}
  .pf-mobile-tool-picker button[aria-pressed=true]{color:var(--app-accent);border-color:var(--app-accent);font-weight:750}
  :is(#pfPhoneQuick,#pfPhoneNav,#pfPhoneHeading,#pfMobileStudioNav,#pfMobileStudioHead,.pf-mobile-tool-picker) button:focus-visible,#pfPhoneProductsToggle:focus-visible{
    outline:2px solid var(--app-accent,#90dfd2);outline-offset:-3px;
  }
  #pfPBRDialog.pf-mobile-studio{--pf-mobile-drawer:min(34dvh,245px)}
  #pfPBRDialog.pf-mobile-studio.pf-mobile-expanded{--pf-mobile-drawer:min(56dvh,450px)}
  #pfPBRDialog.pf-mobile-studio #pfMobileStudioHead{border-radius:16px 16px 0 0;padding:5px 12px 0}
  #pfPBRDialog.pf-mobile-studio .pf-mobile-drawer-title strong{font-size:16px}
  #pfPBRDialog.pf-mobile-studio .pf-mobile-drawer-title [data-expand][aria-pressed=true]{background:#2d5659;color:#b8f5eb}
  #pfPBRDialog.pf-mobile-studio #pfMobileStudioNav button{min-height:48px;border-radius:10px;font:650 11px/1.2 system-ui}
  #pfPBRDialog.pf-mobile-studio #pfStudioPhotoActions{flex-wrap:nowrap;bottom:7px;gap:5px;padding:4px;border-radius:11px;max-width:calc(100% - 14px)}
  #pfPBRDialog.pf-mobile-studio #pfStudioPhotoActions :is(#pfPhotoToggle,#pfPBRExport){width:auto;min-height:44px;white-space:nowrap;font-size:11px;padding:5px 8px!important}
  #pfPBRDialog.pf-mobile-studio #pfWorkspaceTools{padding:4px;max-width:calc(100vw - 18px)}
  #pfPBRDialog.pf-mobile-studio #pfWorkspaceTools .pf-workspace-modes button{min-height:40px}
  #pfPBRDialog.pf-mobile-studio #pfWorkspaceHint{display:none}
  #pfPBRDialog.pf-mobile-studio .pf-pbr-scroll .pf-workspace-grid-tools{display:flex;align-items:end;gap:9px;flex-wrap:wrap}
  #pfPBRDialog.pf-mobile-studio .pf-pbr-scroll .pf-workspace-grid-tools select{display:block;margin-top:4px}
}
@media(max-width:360px){
  body[data-pf-phone-ui=true] #mobileBrand{width:76px!important;min-width:76px!important}
  body[data-pf-phone-ui=true] #mobileBrand img{width:100%!important;object-fit:contain}
  #pfPhoneQuick #pfPhoneProductsToggle{gap:4px;padding-inline:4px;font-size:11px}
  #pfPhoneProductsToggle svg:first-child{width:15px;height:15px}
  #pfPhoneProductsToggle svg:last-child{width:11px;height:11px}
  #pfPhoneNav button{font-size:9.5px}
}
@media(max-width:920px) and (orientation:landscape) and (max-height:560px){
  body[data-pf-phone-ui=true]:not(.presentation):not(.pf-pbr-active):not(.viewer-open){
    --pf-phone-dock:calc(52px + env(safe-area-inset-bottom));--pf-side-tools:min(44vw,390px);
  }
  body[data-pf-phone-ui=true][data-pf-phone-expanded=true]:not(.presentation):not(.pf-pbr-active):not(.viewer-open){--pf-side-tools:min(53vw,470px)}
  body[data-pf-phone-ui=true][data-pf-phone-collapsed=false]:not(.presentation):not(.pf-pbr-active):not(.viewer-open) #stage{right:var(--pf-side-tools)!important;bottom:var(--pf-phone-dock)!important}
  body[data-pf-phone-ui=true][data-pf-phone-collapsed=false]:not(.presentation):not(.pf-pbr-active):not(.viewer-open) #controls{
    left:auto;width:var(--pf-side-tools);height:auto;max-height:none;top:calc(var(--pf-phone-header,52px) + 53px);
    border-radius:12px 0 0 0;border-left:1px solid var(--app-border)!important;
  }
  #pfPBRDialog.pf-mobile-studio:not(.pf-mobile-closed) .pf-pbr-layout{grid-template-columns:minmax(0,1fr) minmax(275px,43%)!important;grid-template-rows:minmax(0,1fr)!important}
  #pfPBRDialog.pf-mobile-studio.pf-mobile-expanded:not(.pf-mobile-closed) .pf-pbr-layout{grid-template-columns:minmax(0,1fr) minmax(300px,53%)!important}
  #pfPBRDialog.pf-mobile-studio:not(.pf-mobile-closed) .pf-pbr-controls{height:100%!important}
  #pfPBRDialog.pf-mobile-studio.pf-mobile-closed .pf-pbr-layout{grid-template-columns:1fr!important;grid-template-rows:minmax(0,1fr) 60px!important}
  #pfPBRDialog.pf-mobile-studio.pf-mobile-closed .pf-pbr-controls{height:60px!important}
}
