/* Shared layout contract. Geometry overrides also cover the legacy compiled shell. */
html, body { min-height: 100%; }
.main, .main-inner, .workspace-panel { min-width: 0; min-height: 0; }
.main-inner { display: flex; flex-direction: column; width: 100%; }
.page, .automatic-task-page, .brief-workspace, .models-page, .insight-page {
  width: 100% !important;
  max-width: none !important;
  margin: 0 !important;
  min-width: 0;
  flex: 1;
}
body:has(> main.page) { display: flex; flex-direction: column; min-height: 100dvh; }
.prose, .brief-rules, .brief-metrics, .login-pitch, .login-form, .insight-help {
  width: 100%;
  max-width: none !important;
}
.login { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.login-main { display: flex; flex-direction: column; align-items: stretch; justify-content: flex-start; min-width: 0; }
.login-form { margin: 0; }

/* Native dialogs and shell overlays share viewport-sized content surfaces. */
.overlay { padding: 0 !important; place-items: stretch !important; }
.modal, .drawer, .palette, dialog[open] {
  box-sizing: border-box;
  width: 100vw !important;
  height: 100dvh !important;
  max-width: none !important;
  max-height: none !important;
  margin: 0 !important;
  border-radius: 0 !important;
  min-width: 0;
  min-height: 0;
}
dialog[open] { position: fixed; inset: 0; border: 0; }
.modal, .palette { display: flex; flex-direction: column; transform: none !important; }
.modal-head, .modal-foot, .drawer-head, .palette-input, .palette-foot,
.school-task-dialog header, .school-task-dialog footer, .programmes-header, .programmes-pager {
  flex-shrink: 0;
}
.modal-body, .drawer-body, .palette-list, dialog[open] { overscroll-behavior: contain; }
.modal-body, .drawer-body, .palette-list { flex: 1; min-height: 0; overflow: auto; }
.palette-list { max-height: none; }
.modal-foot { border-radius: 0; }
.drawer-footer { bottom: 0; margin-bottom: 0; }
.batch-dialog[open] { display: flex; flex-direction: column; gap: 12px; overflow: auto; }
.batch-dialog > :not(.batch-options) { flex-shrink: 0; }
.batch-dialog .batch-options { flex: 1; min-height: 0; max-height: none; overflow: auto; }
.batch-dialog footer { position: sticky; bottom: 0; padding-block: 12px; background: var(--surface); }

@media (max-width: 900px) { .login { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 900px) {
  .segmented { max-width: 100%; min-width: 0; overflow-x: auto; flex-shrink: 1; }
  .toolbar-row, .reader-toolbar { min-width: 0; flex-wrap: wrap; }
  .toolbar-search { min-width: 0; }
}
