/* Phone layout fixes. Loaded last; every rule is scoped to phone portrait
   (max-width:767px) or phone landscape (wide but short), so desktop is unchanged. */

/* ---------- Phone portrait ---------- */
@media(max-width:767px){
 /* Facilities sits in the bottom row between the OPET logo and the fullscreen toolbar,
    at its designed 150px width where space allows (labels were clipped, and it vanished at 320px). */
 html #root [data-ui-edge=end-inner].bottom-4{bottom:var(--ui-edge)!important;height:60px;width:auto!important;min-width:0;max-width:calc(100vw - 210px)!important;padding-top:8px!important;padding-bottom:8px!important}
 html #root [data-ui-edge=end-inner].bottom-4>div{width:150px;max-width:calc(100vw - 226px);height:100%}
 /* The opened list may be wider than the button so names stay readable on narrow phones. */
 html #root [data-ui-edge=end-inner].bottom-4>div>div{width:176px!important;left:auto!important;right:-8px!important}
 html[dir=rtl] #root [data-ui-edge=end-inner].bottom-4>div>div{right:auto!important;left:-8px!important}
 html #root [data-ui-edge=end-inner].bottom-4 p{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
 /* An open facilities list takes the place of the selection card and filter panel, so cards never stack. */
 #root:has([data-ui-edge=end-inner].bottom-4 .max-h-\[300px\]) .opet-property-card,
 #root:has([data-ui-edge=end-inner].bottom-4 .max-h-\[300px\]) [data-ui-edge=start]:has(.opet-filter-panel){visibility:hidden;pointer-events:none}

 /* The location menu stays left of the right-hand toolbars instead of covering them. */
 html .opet-navigation>div:nth-child(2){width:calc(100vw - 168px)!important}

 /* Card actions stay visible while long details scroll. */
 html #root .opet-property-card>div:last-child{position:sticky;bottom:0;z-index:1;background:inherit;padding-bottom:12px}
}
@media(max-width:767px) and (max-height:600px){html #root [data-ui-edge=end-inner].bottom-4{height:44px;padding-top:6px!important;padding-bottom:6px!important}}
@media(max-width:374px){
 .opet-language{width:96px}
 .opet-language>span{display:none}
 html .opet-navigation{width:calc(100vw - 140px)!important}
}

/* ---------- Phone landscape: too short for stacked toolbars (any width) ---------- */
@media(orientation:landscape) and (max-height:500px){
 :root{--ui-edge:16px;--ui-inner:86px;--ui-top:92px}
 html .opet-navigation,html[dir=rtl] .opet-navigation{top:16px!important}
 .opet-nav-bar{height:64px!important}
 .opet-language{inset-block-start:16px;inset-inline-end:16px;height:64px}
 .opet-signature,html[dir=rtl] .opet-signature{bottom:16px!important;height:52px;padding:4px 14px}
 html #root .absolute.bottom-4[data-ui-edge]{bottom:16px!important}

 /* Zoom controls become a row beside the bottom toolbar, freeing the right column for the layer toolbar. */
 html #root .bg-bg1[data-ui-edge=end][class*='translate-y-1/2']{flex-direction:row!important;top:auto!important;bottom:16px!important;inset-inline-end:var(--ui-inner)!important;transform:none!important}
 /* Facilities sits left of that zoom row. */
 html #root [data-ui-edge=end-inner].bottom-4{inset-inline-end:calc(var(--ui-inner) + 166px)!important;bottom:16px!important;width:auto!important;max-width:none!important;height:auto}
 html #root [data-ui-edge=end-inner].bottom-4>div{width:150px;max-width:none}
 html #root [data-ui-edge=end-inner].bottom-4 .max-h-\[300px\]{max-height:calc(100svh - 120px)!important}

 /* Selection card: below the nav, beside the phases button, above the bottom row. */
 html #root .opet-property-card{top:var(--ui-top)!important;inset-inline-end:calc(var(--ui-inner) + 70px)!important;max-height:calc(100svh - 178px)!important;max-width:calc(100vw - 420px)}
 html #root .opet-property-card>div:last-child{position:sticky;bottom:0;z-index:1;background:inherit;padding-bottom:12px}
 html #root .bg-bg1[data-ui-edge=end].z-50{top:var(--ui-top)!important;max-height:calc(100svh - 178px)}
 #root:has([data-ui-edge=end-inner].bottom-4 .max-h-\[300px\]) .opet-property-card{visibility:hidden;pointer-events:none}

 /* Filters and floor lists fit between the nav and the footer. */
 html #root [data-ui-edge=start]:has(.opet-filter-panel),html #root [data-ui-edge=start].md\:hidden:not(.max-h-0):has(.opet-filter-panel){top:var(--ui-top)!important;width:232px!important;max-height:calc(100svh - 180px)!important}
 .opet-filter-panel{max-height:calc(100svh - 180px)!important}
 html #root [data-ui-floor]{top:var(--ui-top)!important}
 html [data-ui-actions]{bottom:16px!important}
 .opet-project-info-open{max-height:calc(100svh - 120px)}

 form.modal-box{padding:20px 24px}
 form.modal-box>h3{font-size:22px;margin-bottom:4px}
 .modal-box{max-height:calc(100svh - 24px)!important}
}
