/* Shared navigation and type scale for every portal page. */
html{-webkit-text-size-adjust:100%;text-size-adjust:100%}
body{--portal-title:30px;--portal-section:21px;--portal-subtitle:18px;--portal-copy:16px;--portal-note:14px;--portal-header-height:86px}
body .portal-header{position:fixed;top:0;left:260px;right:0;z-index:40;height:var(--portal-header-height)!important;min-height:0!important;margin:0;padding:20px 42px;background:var(--paper);color:var(--muted);border:0;border-radius:0;box-shadow:none}
body #main{padding-top:calc(var(--portal-header-height) + 24px)!important}
body #main h2{font-size:var(--portal-section);line-height:1.4}
body #main h3{font-size:var(--portal-subtitle);line-height:1.4}
body #main details>summary{font-family:inherit;font-size:16px;line-height:1.5;font-weight:650}
body #main>details.card>summary,body #main .alarm-page>details.card>summary{font-size:18px}
.history-period{display:block;margin:4px 0 0 22px;font-size:14px;line-height:1.5;font-weight:400;color:var(--muted)}
.alarm-page .alarm-explanation{margin:0 0 20px}
@media(max-width:900px){
 body{--portal-header-height:calc(76px + env(safe-area-inset-top,0px));--portal-section:20px;--portal-subtitle:18px;height:100vh;height:100dvh;overflow:hidden}
 /* Only main scrolls. The header is its sibling, outside the scrolling surface. */
 body .portal-header{position:fixed!important;inset:0 0 auto!important;transform:none!important;height:var(--portal-header-height)!important;min-height:0!important;margin:0!important;padding:calc(16px + env(safe-area-inset-top,0px)) max(16px,env(safe-area-inset-right,0px)) 16px max(16px,env(safe-area-inset-left,0px))!important;display:flex;flex-wrap:nowrap;gap:10px;align-items:center;background:var(--blue);border:0;border-radius:0;box-shadow:none;z-index:40}
 body #main{position:fixed;top:var(--portal-header-height);right:0;bottom:0;left:0;max-width:none;margin:0!important;padding:20px 16px max(24px,env(safe-area-inset-bottom,0px))!important;overflow-y:auto;overflow-x:hidden;overscroll-behavior-y:contain;-webkit-overflow-scrolling:touch;scroll-padding-top:20px}
 body #main h1{font-size:28px!important;line-height:1.2;letter-spacing:-.5px}
 body #main h2{font-size:20px;line-height:1.4}
 body #main h3{font-size:18px;line-height:1.4}
 body #main .alarm-page{padding-top:0}
 body #main .alarm-page>.card{margin-top:20px;padding:20px}
 body #main .alarm-page>.automations-card{padding:0;border:0;background:transparent;box-shadow:none}
 .alarm-page .automation-heading{padding:0 4px}
 .alarm-page .automation-heading p{font-size:14px;margin:0}
 .alarm-page .automation-grid{margin-top:16px}
 .alarm-page .automation-panel{padding:20px;background:white}
 .alarm-page .automation-fields{grid-template-columns:minmax(0,1fr);gap:16px}
 .alarm-page .automation-fields>label:last-child{grid-column:auto}
 .alarm-page .automation-intro{font-size:14px;line-height:1.5}
 .alarm-page .automation-toggle{display:grid;grid-template-columns:minmax(0,1fr) auto 50px;column-gap:10px;row-gap:8px;align-items:center;margin-bottom:16px}
 .alarm-page .automation-toggle h3{grid-column:1/-1;grid-row:1;overflow-wrap:normal}
 .alarm-page .automation-toggle .alarm-toggle-state{grid-column:2;grid-row:2}
 .alarm-page .automation-toggle input{grid-column:3;grid-row:2}
 .alarm-page .automation-toggle::after{content:'Aktiviert';grid-column:1;grid-row:2;font-size:14px;color:var(--muted)}
 .alarm-page .automation-toggle:has(input:not(:checked))::after{content:'Deaktiviert'}
 body #main .alarm-page .automation-status{font-size:14px;line-height:1.5}
 body #main .alarm-page .toggle{font-size:16px;font-weight:600}
 body #main .alarm-page .automation-details summary{font-size:16px}
 body #main .alarm-page>details.card>summary{font-size:18px}
}

/* rc47: approved navigation, aligned vehicle dropdown and compact connection group. */
body .portal-header #vehicle-menu summary{display:flex;align-items:center;justify-content:center;gap:6px;min-width:0;min-height:44px;margin:0;text-align:center;font-family:inherit;line-height:1.4;background:#fff;color:var(--blue);box-shadow:none}
body .portal-header #vehicle-menu summary::after{content:none}
.vehicle-header-name{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.vehicle-header-arrow{flex:0 0 auto;font-size:12px}
body .portal-header #vehicle-menu ul{left:auto;right:0;width:max-content;min-width:100%;max-width:min(420px,calc(100vw - 32px));box-sizing:border-box;margin:8px 0 0;color:var(--ink);text-align:center}
body .portal-header #vehicle-menu ul a{display:block;text-align:center;white-space:normal;word-break:normal;overflow-wrap:break-word;hyphens:none}
@media(max-width:900px){
body .portal-header #vehicle-menu ul{left:50%;right:auto;transform:translateX(-50%);max-width:min(420px,calc(100vw - 32px - env(safe-area-inset-left,0px) - env(safe-area-inset-right,0px)))}
body #main .connection-stages{gap:8px;padding:6px!important;background:#dceaf5!important;border:0;border-radius:18px;box-shadow:none;align-items:start}
body #main .connection-stage{min-width:0;margin:0;padding:12px;border:0;border-radius:12px;background:#fff;box-shadow:none}
body #main .connection-stage>summary{min-height:44px;margin:0;gap:6px;font-family:inherit;font-size:14px;line-height:1.4}
body #main .connection-stage strong{font-size:14px;line-height:1.4;overflow-wrap:anywhere}
body #main .connection-stage strong::before{flex-shrink:0}
body #main .connection-stage>p{overflow-wrap:anywhere}
}
@media(max-width:900px){
 /* Safe area stays light; only the navigation row uses the brand blue. */
 body .portal-header::before{content:'';position:absolute;top:0;left:0;right:0;height:env(safe-area-inset-top,0px);background:var(--paper);pointer-events:none}
 body .portal-header .mobile-brand,body .portal-header #mobile-menu{display:grid;place-items:center;position:static;flex:0 0 44px!important;width:44px!important;min-width:44px!important;max-width:44px;height:44px!important;min-height:44px;margin:0;padding:0;border:1px solid #ffffff80;border-radius:12px;background:transparent;color:white;box-shadow:none;line-height:1}
 body .portal-header .mobile-brand{font-size:23px!important;font-weight:750}
 body .portal-header #mobile-menu{order:3}
 body .portal-header #mobile-menu::after{content:none}
 body .portal-header #mobile-menu .menu-icon{display:block;width:24px;height:24px}
 body .portal-header #vehicle-menu{flex:1 1 0;margin:0;min-width:0;max-width:none}
 body .portal-header #vehicle-menu summary{height:44px;padding:8px;border:0;border-radius:12px;font-size:15px!important}
 body .portal-header>.pill{display:flex;align-items:center;justify-content:center;flex:1;min-width:0;height:44px;margin:0;background:white;color:var(--blue)}
 body .portal-header .mobile-brand:focus-visible,body .portal-header #mobile-menu:focus-visible,body .portal-header #vehicle-menu>summary:focus-visible{outline:3px solid white;outline-offset:3px}
}
@media(max-width:600px){
 body #main .connection-stages{gap:6px;padding:5px!important;border-radius:16px}
 body #main .connection-stage{padding:10px 6px}
 body #main .connection-stage>summary,body #main .connection-stage strong{font-size:12px}
 body #main .connection-stage strong{gap:4px}
}

/* rc48: iOS 26 Safari samples the top document/header surface, not reliably
   the theme-color meta tag. Keep the sampled top strip light and draw only
   the navigation row in blue. The real child node matters on WebKit. */
.portal-header>.status-bar-surface{display:none}
@supports (-webkit-touch-callout: none){
 @media(max-width:900px){
  body .portal-header{background:var(--paper)!important}
  body .portal-header::before{content:'';position:absolute;top:max(8px,env(safe-area-inset-top,0px));right:0;bottom:0;left:0;height:auto;background:var(--blue);pointer-events:none;z-index:0}
  body .portal-header>.status-bar-surface{display:block;position:absolute;top:0;right:0;left:0;height:max(8px,env(safe-area-inset-top,0px));background:var(--paper);pointer-events:none;z-index:1}
  body .portal-header>:not(.status-bar-surface){z-index:2}
 }
}

/* rc49: Put the real navigation controls inside an actual blue layout row.
   This prevents the rc48 overlay from painting across the menu button on iOS
   and centers controls inside the visible blue portion, not the header shell. */
body .portal-header>.nav-row{display:contents}
@media(max-width:900px){
 body .portal-header{background:var(--paper)!important;padding:0!important;isolation:isolate}
 body .portal-header::before{content:none!important;display:none!important}
 body .portal-header>.status-bar-surface{display:block!important;position:absolute;top:0;left:0;right:0;height:max(8px,env(safe-area-inset-top,0px));background:var(--paper);pointer-events:none;z-index:0}
 body .portal-header>.nav-row{display:flex!important;position:absolute;top:max(8px,env(safe-area-inset-top,0px));left:0;right:0;bottom:0;align-items:center;gap:10px;min-width:0;margin:0;padding:0 max(16px,env(safe-area-inset-right,0px)) 0 max(16px,env(safe-area-inset-left,0px));background:var(--blue);z-index:2;box-sizing:border-box}
 body .portal-header>.nav-row>span:not(.pill){display:none!important}
 body .portal-header>.nav-row>.mobile-brand{display:grid!important;place-items:center;flex:0 0 44px!important;min-width:44px;min-height:44px;position:relative;z-index:3}
 body .portal-header>.nav-row>#vehicle-menu{flex:1 1 0;min-width:0;max-width:none;margin:0;position:relative;z-index:3}
 body .portal-header>.nav-row>#mobile-menu{display:grid!important;place-items:center;flex:0 0 44px!important;width:44px!important;height:44px!important;min-width:44px!important;max-width:44px!important;min-height:44px!important;margin:0!important;padding:0!important;position:relative!important;top:auto!important;right:auto!important;bottom:auto!important;left:auto!important;z-index:3!important;visibility:visible!important;opacity:1!important;pointer-events:auto!important;border:1px solid #ffffff80!important;border-radius:12px;background:transparent!important;color:#fff!important;order:3}
 body .portal-header>.nav-row>#mobile-menu .menu-icon{display:block!important;width:24px;height:24px;color:#fff;visibility:visible}
 body .portal-header>.nav-row>.pill{display:flex;align-items:center;justify-content:center;flex:1;min-width:0;min-height:44px;background:#fff;color:var(--blue)}
}

/* rc51: desktop retains its established light header; mobile styling stays scoped. */
body .portal-header .portal-caption{font-family:inherit;font-size:13px;font-weight:400;line-height:1.5;letter-spacing:0;color:var(--muted)}
@media(min-width:901px){
 body .portal-header{font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;font-size:16px;line-height:1.5;letter-spacing:0}
 body .portal-header::after{content:'';position:absolute;left:42px;right:42px;bottom:0;border-bottom:1px solid var(--line);pointer-events:none}
 body .portal-header #vehicle-menu summary{justify-content:flex-start;text-align:left;font-size:16px!important;line-height:1.5}
 body .portal-header #vehicle-menu ul,body .portal-header #vehicle-menu ul a{text-align:left}
 body #main .connection-stage>summary{font-size:14px;line-height:1.4}
}

/* rc55: grouped desktop connection cards, aligned with the mobile design. */
@media(min-width:901px){
 body .portal-header .portal-caption{font-size:20px;font-weight:650;line-height:1.3;letter-spacing:.5px;color:var(--blue);min-width:0}
 body #main .connection-stages{gap:8px;padding:6px!important;background:#dceaf5!important;border:0;border-radius:18px;box-shadow:none;align-items:stretch}
 body #main .connection-stage{min-width:0;margin:0;padding:12px 16px;border:0;border-radius:12px;background:#fff;box-shadow:none}
 body #main .connection-stage>summary{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:6px;min-height:44px;margin:0;padding:0;text-align:center;font-family:inherit;font-size:14px;line-height:1.4}
 body #main .connection-stage>summary>span{min-width:0;max-width:100%;overflow-wrap:anywhere}
 body #main .connection-stage strong{min-width:0;max-width:100%;justify-content:center;font-size:14px;line-height:1.4;overflow-wrap:anywhere}
 body #main .connection-stage strong::before{flex-shrink:0}
 body #main .connection-stage>summary:focus-visible{outline:2px solid var(--blue);outline-offset:3px;border-radius:4px}
 body #main .connection-stage>p{margin:12px 0 0;font-size:13px;line-height:1.5;overflow-wrap:anywhere}
}
@media(min-width:901px) and (max-width:1100px){
 body .portal-header .portal-caption{font-size:16px}
}

/* rc56: compact device cards with clear, keyboard-accessible control buttons. */
body #main .device-status-grid>.control-card{display:flex;flex-direction:column}
body #main .device-planning[hidden],body #main .device-planning:empty{display:none!important}
body #main .device-status-grid [data-device-control]{display:flex;align-items:center;justify-content:center;min-height:44px;width:100%;box-sizing:border-box;margin-top:auto;padding:10px 16px;border:1px solid #c6d9ed;border-radius:12px;background:#eaf3fc;color:var(--blue);font:inherit;font-weight:600;line-height:1.4;text-align:center;text-decoration:none}
body #main .device-status-grid [data-device-control]:hover{background:#dceaf5;border-color:#a6c5e4}
body #main .device-status-grid [data-device-control]:focus-visible{outline:3px solid #79b8ee;outline-offset:3px}

/* rc63: centre both lines in the existing mobile connection cards. */
@media(max-width:900px){
 body #main .connection-stage>summary{align-items:center;text-align:center}
 body #main .connection-stage>summary>span{min-width:0;max-width:100%}
 body #main .connection-stage strong{justify-content:center;min-width:0;max-width:100%;text-align:center}
}
