/* Keep elastic parent scrolling from exposing a blank area above the real
   Workspace header. The embedded Portal and its dialogs scroll inside the iframe. */
html:has(body .em-portal-host),body:has(.em-portal-host){overscroll-behavior-y:none}
body:has(.em-portal-host){overflow-y:hidden}
/* Portal content remains inside the actual Workspace, with one global header and no outer card. */
.em-portal-host{min-width:0;width:100%;border:0;border-radius:0;overflow:hidden;background:var(--k-bg)}
.em-portal-frame{display:block;width:100%;min-height:0;border:0;background:var(--k-bg);color-scheme:inherit}
body:has(.em-portal-host)>.top,body:has(.em-portal-host) #app>.top{position:sticky;top:0;z-index:70}
.em-portal-main{padding-bottom:0}.em-portal-main .em-project-tabs{margin-bottom:12px}.em-portal-main .em-project-context{margin-bottom:8px}
@media(max-width:599px){.em-portal-main{padding:12px 8px 0}.em-portal-main .em-project-tabs{gap:2px;margin-bottom:8px}.em-portal-main .em-project-tabs a{padding:8px 10px}}

/* Fjernvarme har sin egen kompakte tegningslinje i iframen. Bare denne
   ruten får bruke hele arbeidsflaten; alle andre Workspace-verktøy beholder
   global navigasjon, prosjektkontekst og ordinære marger. */
body.em-portal-district #app>.top{display:none}
body.em-portal-district #main.em-portal-main{width:100%;max-width:none;margin:0;padding:0}
body.em-portal-district #em-advisor-trigger.em-advisor-docked{display:none!important}
body.em-portal-district #em-advisor.advisor-chat{top:8px;max-height:calc(100dvh - 16px)}

/* Reuse the same assistant button in the shared header; operational content stays uncovered. */
#app>.top #em-advisor-trigger.em-advisor-docked{position:static;inset:auto;display:inline-flex;align-items:center;justify-content:center;flex:none;width:36px;height:36px;min-height:36px;padding:2px;margin:0;border-radius:50%;box-shadow:none;z-index:auto}
#app>.top #em-advisor-trigger.em-advisor-docked img{width:30px;height:30px;margin:0}
#app>.top #em-advisor-trigger.em-advisor-docked>span{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}

/* Open chat belongs below the measured shared header, and must shrink in landscape. */
body:has(.em-portal-host) #em-advisor.advisor-chat{top:calc(var(--em-portal-header-h,68px) + 8px);bottom:8px;height:auto;min-height:0;max-height:calc(100dvh - var(--em-portal-header-h,68px) - 16px);z-index:71}

/* Short landscape: retain a useful message area above a compact, fully operable composer. */
@media(max-height:480px){
 body:has(.em-portal-host) #em-advisor.advisor-chat>header{padding:5px 12px;gap:8px;flex-shrink:0}
 body:has(.em-portal-host) #em-advisor.advisor-chat>header img{width:28px;height:28px}
 body:has(.em-portal-host) #em-advisor.advisor-chat>header h2{font-size:14px;margin:0}
 body:has(.em-portal-host) #em-advisor.advisor-chat>header small{font-size:10px;line-height:1.2}
 body:has(.em-portal-host) #em-advisor.advisor-chat .advisor-messages{padding:8px 12px}
 body:has(.em-portal-host) #em-advisor.advisor-chat .advisor-form{margin:4px 8px 6px;padding:7px 10px;gap:4px;border-radius:16px}
 body:has(.em-portal-host) #em-advisor.advisor-chat .advisor-form textarea{height:32px;min-height:32px;max-height:48px;font-size:12px;line-height:1.4}
 body:has(.em-portal-host) #em-advisor.advisor-chat .gnist-composer-tools{min-height:30px;gap:6px}
 body:has(.em-portal-host) #em-advisor.advisor-chat .gnist-model-toggle{min-height:30px;padding:5px 9px}
 body:has(.em-portal-host) #em-advisor.advisor-chat .gnist-send{width:30px;height:30px;padding:5px}
}

/* Measured short-landscape fit, retaining every real Workspace control. */
@media (min-width:800px) and (max-width:1000px) and (max-height:480px){
body:has(.em-portal-host) #app>.top{min-height:52px;padding:6px 12px;gap:8px;flex-wrap:nowrap}
body:has(.em-portal-host) #app>.top .em-brand-wordmark{display:none}
body:has(.em-portal-host) #app>.top .em-brand-symbol{display:block;width:34px;height:34px}
body:has(.em-portal-host) #app>.top .em-global-nav{order:initial;width:auto;flex:1 1 auto;border-top:0;padding-top:0;gap:2px}
body:has(.em-portal-host) #app>.top .em-global-nav>a,body:has(.em-portal-host) #app>.top .em-rd-nav>a{padding:6px 8px}
body:has(.em-portal-host) #app>.top .em-global-new-task{padding:5px 8px}
body:has(.em-portal-host) #app>.top>.right{gap:6px;margin-left:0}
}

/* Portal preview Documents: featured current documents, searchable, historic records collapsed. */
.em-portal-docs{min-width:0;max-width:100%}
.em-portal-docs [hidden]{display:none}
.em-portal-docs h2{margin:0 0 10px}
.em-portal-docs-bar{display:flex;flex-wrap:wrap;gap:8px;align-items:center;margin-bottom:6px}
.em-portal-docs-bar input{flex:1 1 220px;min-width:0;min-height:44px;box-sizing:border-box;font:inherit}
.em-portal-docs-bar .btn{min-height:44px}
.em-portal-docs-status{margin:0 0 8px;font-size:12px;color:var(--k-muted)}
.em-portal-docs-list{list-style:none;margin:0 0 12px;padding:0}
.em-portal-docs-list li{background:var(--em-row-a,var(--k-surface))}
.em-portal-docs-list li:nth-child(even){background:var(--em-row-b,var(--k-raised,var(--k-surface)))}
.em-portal-docs-list li:hover{background:var(--em-row-hover,var(--k-raised,var(--k-surface)))}
.em-portal-docs-open{display:flex;flex-direction:column;align-items:flex-start;gap:2px;width:100%;min-height:44px;box-sizing:border-box;padding:8px 12px;border:0;border-radius:0;background:transparent;color:var(--k-text);font:inherit;text-align:left;cursor:pointer;overflow-wrap:anywhere}
.em-portal-docs-open small{font-size:11px;color:var(--k-muted)}
.em-portal-docs-open:focus-visible,.em-portal-docs-archive summary:focus-visible{outline:2px solid var(--k-accent);outline-offset:-2px}
.em-portal-docs-archive summary{display:flex;align-items:center;min-height:44px;padding:8px 12px;cursor:pointer;color:var(--k-muted);font-size:13px}
