/* ADR 0110: retain the primary action and errors when the usable height shrinks. */
#lesson-flow.lf-compact > .lf-panel {
  top:max(8px,env(safe-area-inset-top,0px));
  bottom:max(8px,env(safe-area-inset-bottom,0px));
  height:auto;
  transform:none;
}
#lesson-flow.lf-compact > .bottom-nav { display:none; }
#lesson-flow.lf-compact .lc-panel[data-catalog-view="message"] .lc-header { padding-block:6px; }
#lesson-flow.lf-compact .lf-footer.lm-footer { padding:8px 16px; gap:6px; }
#lesson-flow.lf-compact .lm-footer textarea { height:54px; min-height:54px; }
#lesson-flow.lf-compact .lm-footer > .lm-send-row { display:flex; flex-direction:row; gap:0; }
#lesson-flow.lf-compact .lm-send-row > p { display:none; }
#lesson-flow.lf-compact .lm-send-row > button { flex:1; width:100%; min-width:0; min-height:48px; }
#lesson-flow .lm-footer .lm-send-row > button { min-height:48px; }
#modal[open] {
  top:calc(var(--modal-top,0px) + max(12px,env(safe-area-inset-top,0px)));
  bottom:auto;
  height:calc(var(--modal-height,100dvh) - max(12px,env(safe-area-inset-top,0px)) - 92px - env(safe-area-inset-bottom,0px));
}
#modal.modal-compact[open] {
  top:calc(var(--modal-top,0px) + 8px);
  height:calc(var(--modal-height,100dvh) - 16px);
  transform:none;
}
body:has(#modal.modal-compact[open]) > .app-shell .bottom-nav { visibility:hidden; }
#modal.modal-compact > .modal-top { padding:6px 16px; }
#modal.modal-compact #modal-content { padding:16px; }
.ct-request-actions { display:flex; flex-wrap:wrap; gap:8px; margin:16px 0; }
.ct-request-actions > button { min-height:44px; padding:10px 14px; border:1px solid var(--line); border-radius:12px; background:var(--surface); color:var(--text); font:inherit; font-size:13px; }
.ct-request-confirm { margin-top:12px; padding:14px; border:1px solid var(--line); border-radius:12px; }
@media(min-width:960px) {
  #modal[open]:not(.modal-compact) {
    top:calc(var(--modal-top,0px) + var(--modal-height,100dvh) / 2);
    height:min(780px,calc(var(--modal-height,100dvh) - 48px));
    transform:translateY(-50%);
  }
}
@media(max-width:359px) {
  #instructor-flow .im-time-hours { grid-template-columns:repeat(4,minmax(44px,1fr)); gap:6px; }
}

/* ADR 0116: each task keeps the same frame while only its content scrolls. */
#login-preview > .lp-panel { display:flex; flex-direction:column; }
#login-preview .lp-header { flex:none; }
:is(#login-preview,#my-profile-dialog,#plan-journey,#lesson-flow,#instructor-flow,#contact-preview) > :is(.lp-panel,.mp-panel,.j-panel,.lf-panel,.ic-panel,.ic-panel.ic-registration,.ct-panel) {
 --popup-height:var(--ic-height,var(--lp-height,var(--mp-height,var(--j-height,var(--lf-height,var(--contact-height,100dvh))))));
 position:absolute; top:max(12px,env(safe-area-inset-top,0px)); bottom:max(12px,env(safe-area-inset-bottom,0px)); left:12px; right:12px;
 width:auto; max-width:580px; height:auto; max-height:none; min-height:0; margin:0 auto; transform:none;
 border:1px solid var(--line); border-radius:26px; overflow:hidden;
}
#modal[open] { top:calc(var(--modal-top,0px) + max(12px,env(safe-area-inset-top,0px))); bottom:auto; height:calc(var(--modal-height,100dvh) - max(12px,env(safe-area-inset-top,0px)) - max(12px,env(safe-area-inset-bottom,0px))); }
body:has(:is(#login-preview,#my-profile-dialog,#plan-journey,#lesson-flow,#instructor-flow,#contact-preview,#modal)[open]) .bottom-nav { visibility:hidden; }
:is(.ic-header,.ic-registration .ic-header,.mp-dialog-head,.j-dialog-header,.ct-panel > header,.lp-header) { min-height:72px; padding:14px var(--dialog-space); }
:is(.ic-scroll,.ic-registration .ic-scroll,.mp-scroll,.j-scroll,.ct-scroll,.lp-content) { flex:1; min-height:0; padding:var(--dialog-space); overflow-y:auto; overscroll-behavior:contain; }
:is(.ic-footer,.ic-registration .ic-footer,.mp-footer,.j-footer,.ct-panel > footer) { flex:none; padding:14px var(--dialog-space); }
@media(min-width:960px) {
 :is(#login-preview,#my-profile-dialog,#plan-journey,#lesson-flow,#instructor-flow,#contact-preview) > :is(.lp-panel,.mp-panel,.j-panel,.lf-panel,.ic-panel,.ic-panel.ic-registration,.ct-panel) { top:50%; bottom:auto; height:min(780px,calc(var(--popup-height) - 48px)); transform:translateY(-50%); }
 #modal[open]:not(.modal-compact) { height:min(780px,calc(var(--modal-height,100dvh) - 48px)); }
}
@media(max-height:560px) {
 :is(#login-preview,#my-profile-dialog,#plan-journey,#lesson-flow,#instructor-flow,#contact-preview) > :is(.lp-panel,.mp-panel,.j-panel,.lf-panel,.ic-panel,.ic-panel.ic-registration,.ct-panel) { top:8px; bottom:8px; height:auto; transform:none; }
 :is(.ic-header,.ic-registration .ic-header,.mp-dialog-head,.j-dialog-header,.ct-panel > header,.lp-header) { min-height:52px; padding-block:6px; }
 :is(.ic-scroll,.ic-registration .ic-scroll,.mp-scroll,.j-scroll,.ct-scroll,.lp-content) { padding-block:16px; }
 :is(.ic-footer,.ic-registration .ic-footer,.mp-footer,.j-footer,.ct-panel > footer) { padding-block:8px; }
}

/* A native status dialog keeps the same viewport width as the other popups. */
html:has(#modal[open]),body:has(#modal[open]) { overflow:hidden; }
