/* All app flows use the viewport. Dialog semantics retain focus and Back handling. */
html body dialog[open]{position:fixed!important;inset:var(--app-viewport-top,0px) 0 auto!important;margin:0!important;width:100%!important;min-width:0!important;max-width:none!important;height:var(--app-viewport-height,100dvh)!important;max-height:var(--app-viewport-height,100dvh)!important;box-sizing:border-box;border:0!important;border-radius:0!important;box-shadow:none!important;overscroll-behavior:contain}
html body dialog.nb-editor-dialog[open]{top:var(--nb-visible-top,var(--app-viewport-top,0px))!important;height:var(--nb-visible-height,var(--app-viewport-height,100dvh))!important;max-height:var(--nb-visible-height,var(--app-viewport-height,100dvh))!important}
html body dialog::backdrop{background:var(--bg,#0c0d0e)!important;backdrop-filter:none!important}
html body dialog[open]:not(.nb-editor-dialog):not(.lecture-dialog):not(.reader-dialog):not(.schedule-dialog){padding:calc(20px + env(safe-area-inset-top)) max(20px,env(safe-area-inset-right)) calc(20px + env(safe-area-inset-bottom)) max(20px,env(safe-area-inset-left));overflow:auto;text-align:left}
html body dialog[open] :is(.quiz-close,.schedule-close,[data-challenge-close],[data-reader-close],[data-close]){flex-shrink:0;width:auto;min-width:88px;min-height:44px;height:auto;font-size:14px;white-space:nowrap}
html body #info-dialog[open]{padding-top:calc(76px + env(safe-area-inset-top))}
html body #info-dialog .dialog-close{left:20px;right:auto;top:calc(14px + env(safe-area-inset-top));min-height:44px;padding:8px 12px;font-size:14px}

/* The lesson body takes the remaining height rather than a narrow central popup. */
html body .lecture-dialog[open],html body .reader-dialog[open]{display:flex;flex-direction:column;padding:0;overflow:hidden}
html body .lecture-dialog-head,html body .reader-header{flex:none;padding:calc(12px + env(safe-area-inset-top)) max(20px,env(safe-area-inset-right)) 12px max(20px,env(safe-area-inset-left));gap:12px}
html body .lecture-dialog-head>div,html body .reader-header>div{min-width:0}
html body .lecture-dialog-head h2{font-size:24px;line-height:1.3;margin:4px 0}
html body .lecture-dialog-head p{margin:4px 0;font-size:13px}
html body .lecture-tabs{flex:none;padding:0 20px;flex-wrap:wrap}
html body .lecture-tabs button{min-height:44px;padding:9px 14px}
html body .lecture-dialog-body{flex:1;min-height:0;overflow:auto;padding:16px 20px;scrollbar-gutter:stable}
html body .lecture-dialog-footer{position:static;flex:none;justify-content:flex-start;gap:8px;padding:10px 20px calc(10px + env(safe-area-inset-bottom));border-top:1px solid var(--line);background:#132126}
html body .lecture-dialog-footer button{min-height:44px}
html body .lecture-dialog>.lecture-error{flex:none;margin:0;padding:0 20px}
html body .lecture-dialog [data-result-update]{flex:none;margin:4px 20px;padding:0}
html body .reader-content{height:auto;flex:1;min-height:0;scrollbar-gutter:stable;padding-bottom:calc(16px + env(safe-area-inset-bottom))}
html body .reader-tools,html body .reader-status{flex:none}
html body .nb-popover footer{flex-wrap:wrap;justify-content:flex-start}

/* Card actions share the UPMED green, while navigation and drawing tools keep their roles. */
html body :is(.lecture-dashboard,.challenge-dashboard,.mascot-evolution,.study-empty,.study-today,.material-item,.material-video,.challenge-card,.nb-card,.nb-empty,.nb-welcome,.profile-card,.device-panel,.approval-request,.lecture-row-actions,.lecture-dialog-footer,.lecture-dialog-body) :is(.material-secondary,.secondary-button,.nb-button,.resource-delete,.profile-photo-label){background:var(--green,#b6f34a)!important;color:#162105!important;border-color:var(--green,#b6f34a)!important;font-weight:700}
html body :is(.lecture-dashboard,.challenge-dashboard,.mascot-evolution,.study-empty,.study-today,.material-item,.material-video,.challenge-card,.nb-card,.nb-empty,.nb-welcome,.profile-card,.device-panel,.approval-request,.lecture-row-actions,.lecture-dialog-footer,.lecture-dialog-body) :is(.material-secondary,.secondary-button,.nb-button,.resource-delete,.profile-photo-label):hover{background:#c4ff62!important;border-color:#c4ff62!important}
@media(max-width:650px){
 html body .lecture-dialog-head,html body .reader-header{padding-left:12px;padding-right:12px}
 html body .lecture-dialog-head h2{font-size:20px}
 html body .lecture-dialog-body{padding:12px}
 html body .lecture-tabs{padding:0 12px}
 html body .lecture-dialog-footer{padding-left:12px;padding-right:12px}
 html body .lecture-dialog-footer button{flex:1 1 130px}
}
