/* Dialog families share viewport bounds, but each card owns its scrolling.
   In particular, a mobile outer modal must not compete with the issue card. */
:root { --dialog-available-height:min(var(--dialog-height,100dvh),100dvh); }
.modal {
  top:var(--dialog-top,0px);bottom:auto;height:var(--dialog-available-height);
  padding:0;overflow:hidden;
}
.modal .modal-card {
  max-height:calc(var(--dialog-available-height) - 32px);
  overflow:auto;overscroll-behavior:contain;
}
.workspace-panel .workspace-panel-card {
  height:100%;max-height:100%;
}
/* Reserve a separate row for pending updates. A fixed toast can intercept
   clicks anywhere in the issue's scroll surface, especially on narrow screens. */
.workspace-panel:not(.hidden):has(> .live-update-notice:not([hidden])) {
  display:grid;grid-template-rows:minmax(0,1fr) auto;justify-items:end;
}
.workspace-panel:has(> .live-update-notice:not([hidden])) .workspace-panel-card {
  position:relative;inset:auto;grid-row:1;min-height:0;
}
.workspace-panel > .live-update-notice {
  position:relative;inset:auto;transform:none;grid-row:2;z-index:1;
  box-sizing:border-box;width:min(640px,100vw);max-width:100%;max-height:calc(var(--dialog-available-height) * .4);overflow:auto;
  border-radius:0;padding-bottom:max(.75rem,env(safe-area-inset-bottom));
}
.workspace-panel.issue-panel-maximized > .live-update-notice { width:100%; }
@media(max-width:768px) {
  .workspace-panel > .live-update-notice { width:100%; }
}
/* Actions participate in content flow so they cannot cover fields in short
   viewports. The header remains sticky and the entire form can scroll. */
.workspace-panel .actions { position:static; }

dialog:not(.rte-fullscreen) {
  position:fixed;top:var(--dialog-top,0px);
  bottom:calc(100% - var(--dialog-top,0px) - var(--dialog-available-height));
  max-height:calc(var(--dialog-available-height) - 32px);
  overflow:auto;overscroll-behavior:contain;
}
.rte-fullscreen[open] {
  inset:var(--dialog-top,0px) 0 auto;
  height:var(--dialog-available-height);max-height:var(--dialog-available-height);
  padding-top:env(safe-area-inset-top);padding-bottom:env(safe-area-inset-bottom);
}
.rte-fullscreen .rte-toolbar { max-height:calc(var(--dialog-available-height) * .35); }

@media(max-width:900px), (pointer:coarse) {
  .modal:not(.workspace-panel) .modal-card {
    /* Ignore the desktop drag/resize helper's inline coordinates and sizes.
       Reopening and rotating must always expose a complete scroll surface. */
    position:relative!important;inset:auto!important;transform:none!important;
    width:calc(100% - 16px)!important;height:auto!important;min-height:0!important;
    max-height:calc(var(--dialog-available-height) - 16px - env(safe-area-inset-top) - env(safe-area-inset-bottom))!important;
    margin:calc(8px + env(safe-area-inset-top)) auto 0!important;
  }
  .modal-resize-handle { display:none; }
  dialog:not(.rte-fullscreen) {
    max-height:calc(var(--dialog-available-height) - 16px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  }
  dialog :is(input:not([type=hidden]),select,textarea),
  .modal :is(input:not([type=hidden]),select,textarea) { font-size:16px; }
}
