/* iPad/Android tablet landscape is device-detected, separate from phone and desktop. */
#tabletPropertiesToggle{display:none}
body.tabletLandscape[data-page=editor]{--tablet-bar:64px;--tablet-top:env(safe-area-inset-top);height:var(--editor-visible-height,100dvh);overflow:hidden}
body.tabletLandscape #editorBar{display:grid;grid-template-columns:44px minmax(0,1fr) 220px 44px 44px 44px 72px;gap:10px;align-items:center;width:100%;min-width:0;height:calc(var(--tablet-bar) + var(--tablet-top));padding:calc(10px + var(--tablet-top)) max(16px,env(safe-area-inset-right)) 10px max(16px,env(safe-area-inset-left));flex-wrap:nowrap}
body.tabletLandscape #editorBar label{display:block;min-width:0;width:100%;max-width:none;overflow:hidden}
body.tabletLandscape #editorBar .fieldCaption,body.tabletLandscape #projectStatus{display:none}
body.tabletLandscape #projectName{min-width:0;max-width:100%;font-size:16px;min-height:44px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
body.tabletLandscape #editorBar>button{min-width:44px;min-height:44px;margin:0;padding:10px}
body.tabletLandscape #editorBar #saveProject span{display:none}
body.tabletLandscape #editorBar>.primary{min-width:72px;padding:10px 14px;font-size:14px}
body.tabletLandscape #editorBar .canvasTabs{display:grid;grid-template-columns:1fr 1fr;position:static;inset:auto;transform:none;width:220px;height:44px;max-width:none;gap:3px;margin:0;padding:0;border-radius:8px;border:1px solid var(--line);background:var(--ui-eaf0f1,#eaf0f1)}
body.tabletLandscape #editorBar .canvasTabs button{display:flex;align-items:center;justify-content:center;gap:7px;width:100%;min-width:0;min-height:44px;height:44px;padding:5px;font-size:13px;border:0;border-radius:5px;transform:none;background:transparent}
body.tabletLandscape #editorBar .canvasTabs button[aria-pressed=true]{background:var(--ui-fffefa,#fffefa);color:var(--ui-4c6976,#4c6976);box-shadow:0 1px 3px #536f7b08}
body.tabletLandscape #editorBar #tabProperties{display:none}
body.tabletLandscape #phoneViewMenu,body.tabletLandscape #tabletPropertiesToggle{display:block;width:44px;height:44px;min-width:44px}
body.tabletLandscape #tabletPropertiesToggle[aria-expanded=true]{background:var(--ui-e1ebed,#e1ebed);border-color:var(--ui-809ba5,#809ba5)}
body.tabletLandscape #phoneViewMenu>div{top:calc(var(--tablet-bar) + var(--tablet-top));right:max(16px,env(safe-area-inset-right));max-height:calc(var(--editor-visible-height,100dvh) - 88px)}
body.tabletLandscape #editorMain{position:relative;height:calc(var(--editor-visible-height,100dvh) - var(--tablet-bar) - var(--tablet-top));padding:12px max(14px,env(safe-area-inset-right)) max(12px,env(safe-area-inset-bottom)) calc(86px + env(safe-area-inset-left));gap:0;min-height:0}
body.tabletLandscape #editorMain>.canvasTabs,body.tabletLandscape #editorMain>#notice,body.tabletLandscape .canvasHelp,body.tabletLandscape .canvasTag{display:none}
body.tabletLandscape #editorMain>#notice.error{display:block;position:absolute;z-index:35;top:18px;left:calc(94px + env(safe-area-inset-left));right:24px;min-height:0;padding:9px 12px;border:1px solid var(--ui-d7bdb3,#d7bdb3);border-radius:6px;background:#fffefaef;pointer-events:none}
body.tabletLandscape #editorMain>.workspace{display:block!important;position:relative;min-height:0;height:100%;padding:0;flex:1}
body.tabletLandscape #editorMain .workspace>.panel{height:100%;margin:0;border-radius:9px;overflow:hidden}
body.tabletLandscape #editorMain .planPanel,body.tabletLandscape #editorMain .viewPanel{display:flex;flex-direction:column}
body.tabletLandscape #editorMain .panelHead{display:none}
body.tabletLandscape #editorMain .canvasWrap,body.tabletLandscape #editorMain #modelStage{position:relative;flex:1;min-height:0;width:100%;height:100%}
body.tabletLandscape[data-pane=plan] #editorMain .viewPanel,body.tabletLandscape[data-pane=model] #editorMain .planPanel,body.tabletLandscape #editorMain .inspector{display:none}
body.tabletLandscape #editorMain>.toolbar{position:absolute;z-index:100;left:max(12px,env(safe-area-inset-left));right:auto;top:50%;bottom:auto;transform:translateY(-50%);display:flex;flex-direction:column;align-items:center;width:62px;max-width:62px;max-height:calc(100% - 24px);overflow-y:auto;gap:2px;padding:4px;border-radius:10px}
body.tabletLandscape #editorMain .toolbar button{display:flex;flex:none;flex-direction:column;align-items:center;justify-content:center;width:52px;min-width:52px;max-width:52px;min-height:54px;height:54px;padding:5px 2px;font-size:11px;line-height:1.1;gap:4px}
body.tabletLandscape .toolbar .icon{width:22px;height:22px}
body.tabletLandscape #editorMain .toolbar button span{display:block}
body.tabletLandscape #editorMain .toolbar .divider{display:none}
body.tabletLandscape #editorMain .toolbar #undo,body.tabletLandscape #editorMain .toolbar #redo{display:flex}
body.tabletLandscape #editorMain .toolbar #referenceButton small{display:none}
body.tabletLandscape #phoneFit{display:flex;position:absolute;z-index:20;top:12px;right:12px;width:44px;height:44px;padding:10px;background:#fffefae8;border-radius:8px}
body.tabletLandscape .compareLinework{right:68px;top:12px}
body.tabletLandscape.walking #phoneFit{display:none}
body.tabletLandscape #editorMain>.furnitureCatalog{position:absolute;left:calc(86px + env(safe-area-inset-left));right:14px;bottom:12px;width:min(620px,calc(100% - 104px));max-height:calc(100% - 24px)}
body.tabletLandscape :is(#newDoorLabel,#newWindowLabel){position:absolute;left:86px;bottom:16px;min-width:220px;z-index:120}
body.tabletLandscape.tabletPropertiesOpen #editorMain .workspace>.inspector{display:block!important;position:absolute;z-index:80;top:0;right:0;width:320px;max-width:45%;height:100%!important;max-height:100%;overflow-y:auto;border:1px solid var(--line);border-radius:9px;background:var(--ui-fffefa,#fffefa);box-shadow:-6px 0 22px #536f7b12}
body.tabletLandscape #editorMain .inspector .panelHead{display:flex;height:56px;min-height:56px;padding:10px 14px}
body.tabletLandscape .inspector .closeProperties{display:flex;min-width:44px;min-height:44px}
body.tabletLandscape .inspector form{display:block;padding:18px}
body.tabletLandscape .inspector .summary{display:none}
body.tabletLandscape .selectedChip:not([hidden]){display:flex;position:absolute;bottom:16px;left:50%;transform:translateX(-50%);z-index:22;min-height:44px;background:#fffefaed;border-color:var(--ui-d9d7d3,#d9d7d3);font-size:12px;white-space:nowrap}
body.tabletLandscape #studioStatus{bottom:max(20px,env(safe-area-inset-bottom))}

body.tabletLandscape .canvasHistory{display:none}

body.tabletLandscape #editorBar>#tabletPropertiesToggle{border:1px solid var(--line);border-radius:8px;background:var(--ui-fffefa,#fffefa)}
body.tabletLandscape #phoneViewMenu [data-phone-action=dimensions]{display:none}

/* Portrait phones/tablets: retain the two-mode segment; keep ruler independent. */
.portraitControls[hidden]{display:none}
body.portablePortrait #editorMain>.portraitControls{order:2;display:flex;align-items:center;gap:8px;width:100%;max-width:420px;min-width:0;margin-bottom:8px;flex:none}
body.portablePortrait #editorMain .portraitControls>.canvasTabs{display:grid;grid-template-columns:1fr 1fr;flex:1;min-width:0;width:auto;max-width:none;height:44px;margin:0;padding:0;position:static;gap:2px;border:1px solid var(--line);border-radius:8px;background:var(--secondary)}
body.portablePortrait #editorMain .portraitControls .canvasTabs button{display:flex;justify-content:center;align-items:center;gap:6px;min-width:0;min-height:44px;height:44px;padding:7px;border:0;border-radius:6px;background:transparent;font-size:13px;white-space:nowrap}
body.portablePortrait #editorMain .portraitControls .canvasTabs button[aria-pressed=true]{background:var(--ui-fffefa,#fffefa);color:var(--ink)}
body.portablePortrait #editorMain .portraitControls #tabProperties{display:none}
body.portablePortrait #editorMain .portraitControls #tabletPropertiesToggle{display:flex;align-items:center;justify-content:center;flex:0 0 44px;width:44px;min-width:44px;min-height:44px;height:44px;padding:10px;border:1px solid var(--line);border-radius:8px;background:var(--ui-fffefa,#fffefa);color:var(--ink)}
body.portablePortrait #editorMain .portraitControls #tabletPropertiesToggle[aria-expanded=true]{background:var(--ui-e1ebed,#e1ebed);border-color:var(--ui-809ba5,#809ba5)}
body.portablePortrait .portraitControls .icon{width:20px;height:20px}

/* Keep tablet editor chrome opaque and unfiltered; do not affect drawing data. */
body.tabletDevice #editorBar{background:var(--ui-f7f5f1,#f7f5f1);opacity:1;filter:none;backdrop-filter:none;-webkit-backdrop-filter:none;transform:none}
body.tabletDevice #editorBar label,body.tabletDevice #projectName,body.tabletDevice #editorBar button,body.tabletDevice .canvasTabs,body.tabletDevice .portraitControls{opacity:1;filter:none;backdrop-filter:none;-webkit-backdrop-filter:none;transform:none}
body.tabletDevice #projectName{font-size:16px;font-weight:500;color:var(--ui-435b66,#435b66)}
body.tabletDevice #editorBar .fieldCaption{font-size:12px;color:var(--ui-606e76,#606e76)}
body.tabletDevice #projectStatus{font-size:13px;color:var(--ui-606e76,#606e76)}
body.tabletDevice #editorMain>.toolbar{background:var(--ui-fffefa,#fffefa);backdrop-filter:none;-webkit-backdrop-filter:none}

/* Door picker must escape the scroll-clipped vertical tool rail. */
body.tabletLandscape #editorMain>:is(#newDoorLabel,#newWindowLabel){left:calc(86px + env(safe-area-inset-left));bottom:max(16px,env(safe-area-inset-bottom));width:240px;max-width:calc(100% - 110px);min-width:0;background:var(--ui-fffefa,#fffefa)}
body.tabletLandscape #newDoorType{min-height:44px;font-size:16px;width:100%}

body.portablePortrait #editorMain>:is(#newDoorLabel,#newWindowLabel){left:max(16px,env(safe-area-inset-left));bottom:calc(90px + env(safe-area-inset-bottom));width:240px;max-width:calc(100% - 32px);min-width:0;z-index:120;background:var(--ui-fffefa,#fffefa)}
body.portablePortrait #newDoorType{min-height:44px;font-size:16px;width:100%}
/* Respect only the native safe area; do not reserve extra blank header space. */
body.tabletDevice{--tablet-edge-clearance:0px;--tablet-portrait-bar:78px;--tablet-portrait-padding:12px}
body.tabletDevice.portablePortrait #editorBar{height:calc(var(--tablet-portrait-bar) + env(safe-area-inset-top) + var(--tablet-edge-clearance));padding-top:calc(var(--tablet-portrait-padding) + env(safe-area-inset-top) + var(--tablet-edge-clearance))}
body.tabletDevice.portablePortrait #editorMain{height:calc(var(--editor-visible-height,100dvh) - var(--tablet-portrait-bar) - env(safe-area-inset-top) - var(--tablet-edge-clearance))}
body.tabletDevice.tabletLandscape[data-page=editor]{--tablet-top:calc(env(safe-area-inset-top) + var(--tablet-edge-clearance))}
@media(max-width:900px){body.tabletDevice{--tablet-portrait-bar:72px;--tablet-portrait-padding:10px}}
@media(max-width:600px){body.tabletDevice{--tablet-portrait-bar:80px;--tablet-portrait-padding:10px}}


/* Keep the opaque top bar stable across background/foreground restoration. */
body.tabletDevice #editorBar{position:sticky;top:0;z-index:200}


/* A real opaque edge surface, only in installed iPad web apps. No extra layout space. */
body.installedTabletEdge #tabletEdgeSurface{position:fixed;inset:0 0 auto;height:12px;z-index:1100;pointer-events:none;background:var(--ui-f7f5f1,#f7f5f1)}
body.installedTabletEdge.tabletLandscape #editorBar{padding-top:calc(13px + var(--tablet-top));padding-bottom:7px}
/* Keep this same opaque edge above the 1000-level walk overlay on entry and exit. */

/* Compact inspector headers must not inherit the <=1250px desktop column.
   Keep all three controls in normal flow above the selected-object form. */
body.tabletLandscape #editorMain .inspector .panelHead,
body.phoneLandscape #editorMain .inspector .panelHead{
 display:flex;flex-direction:row;flex-wrap:wrap;align-items:center;
 justify-content:space-between;gap:8px;height:auto;min-height:64px;
 padding:10px 14px;border-bottom:1px solid var(--line)
}
body.tabletLandscape #editorMain .inspector .panelHead h2,
body.phoneLandscape #editorMain .inspector .panelHead h2{
 flex:1 1 90px;min-width:0;margin:0;line-height:1.5;overflow-wrap:anywhere
}
body.tabletLandscape #editorMain .inspector .panelHead>button,
body.phoneLandscape #editorMain .inspector .panelHead>button{
 flex:0 0 auto;margin:0;min-height:44px
}
body.phoneLandscape #editorMain .inspector .closeProperties{display:flex}
/* The phone panel is a workspace panel too; override its canvas clipping rule. */
body.phoneLandscape #editorMain .workspace>.inspector{
 overflow-y:auto;overscroll-behavior:contain
}
