/*
 * Mobile and PWA corrections.
 * Keep native iOS controls stable while allowing page typography to scale.
 */

@media (max-width: 860px) {
  :root {
    --footer-height: 0px;
  }

  html,
  body {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    overflow-x: hidden;
    overscroll-behavior-x: none;
  }

  @supports (overflow: clip) {
    html,
    body { overflow-x: clip; }
  }

  html {
    -webkit-text-size-adjust: 100%;
  }

  body { padding-bottom: env(safe-area-inset-bottom); }

  .files-page .global { display:grid; }
  .files-page .files-workspace { min-height:calc(100dvh - var(--header-height)); }
  .files-page .files-list-pane { min-height:calc(100dvh - var(--header-height)); }
  .files-page .files-mobile-head { padding-top:13px; }

  body,
  #app,
  .page,
  .app-shell,
  .main,
  .app-main {
    min-width: 0;
    max-width: 100%;
  }

  input:not([type="checkbox"]):not([type="radio"]):not([type="color"]):not([type="hidden"]),
  select,
  textarea {
    min-width: 0;
    max-width: 100%;
    font-size: 16px !important;
    line-height: 1.35;
  }

  input:not([type="checkbox"]):not([type="radio"]):not([type="color"]):not([type="hidden"]),
  select {
    min-height: 44px;
    padding-block: 8px;
  }

  textarea {
    min-height: 96px;
  }

  input[type="date"],
  input[type="time"],
  input[type="datetime-local"] {
    display: block;
    box-sizing: border-box;
    inline-size: 100%;
    min-inline-size: 0;
    max-inline-size: 100%;
    width: 100%;
    min-width: 0;
    max-width: 100%;
    min-height: 44px;
    padding: 8px 12px;
    font: inherit;
    font-size: 16px !important;
    line-height: 1.35;
    -webkit-min-logical-width: 0;
  }

  input[type="date"]::-webkit-date-and-time-value,
  input[type="time"]::-webkit-date-and-time-value,
  input[type="datetime-local"]::-webkit-date-and-time-value {
    min-width: 0;
    text-align: left;
  }

  .app-form-dialog input:not([type="checkbox"]):not([type="radio"]):not([type="color"]):not([type="hidden"]),
  .app-form-dialog select {
    min-height: 44px;
  }

  .app-form-dialog textarea {
    min-height: 110px;
  }

  .app-form-dialog .editor-toolbar {
    min-height: 44px;
    padding: 7px;
    gap: 4px;
  }

  .app-form-dialog .editor-toolbar button,
  .app-form-dialog .editor-toolbar label.tool {
    min-height: 34px;
    padding: 5px 8px;
    font-size: 14px;
    line-height: 1.2;
  }

  .collaboration-participant-list {
    padding-inline: 12px;
  }
}

/* Global responsive overrides migrated from app.css. */
@media (max-width: 1280px) {
  .form-grid.four { grid-template-columns: repeat(2,minmax(0,1fr)); }


}

@media (max-width: 980px) {  .form-grid.three { grid-template-columns: repeat(2,minmax(0,1fr)); }


  .workforce-groups { grid-template-columns: 1fr; }
  .workforce-groups > section + section { border-top: 1px solid var(--border); border-left: 0; }
}

@media (max-width: 1023px) {
  .global {
    grid-template-columns:minmax(0,1fr) auto;
    gap:8px;
    padding-inline:10px;
  }
  .global-brand-area { gap:8px; }
  .global-brand { flex:0 0 auto; gap:3px; order:2; min-width:0; font-size:var(--text-lg); }
  .global-brand span { display:inline; white-space:nowrap; }
  .global-brand-logo { margin-right:2px; }
  .global-navigation-open {
    order:1;
    flex:0 0 var(--control-height);
    min-width:var(--control-height);
    height:var(--control-height);
    display:inline-flex;
    align-items:center;
    justify-content:center;
    gap:0;
    padding:0;
    border:1px solid var(--border);
    border-radius:var(--radius);
    background:var(--surface);
    color:var(--text);
    font-size:var(--text-sm);
    font-weight:700;
  }
  .global-navigation-open > span { display:none; }
  .global-navigation-open svg { width:17px; height:17px; }
  .global-navigation-open:hover,
  .global-navigation-open[aria-expanded="true"] { border-color:color-mix(in srgb,var(--accent) 38%,var(--border)); background:var(--accent-soft); color:var(--accent); }
  .workspace-panel-control-header .detail-standalone-open { display:none; }
  .global-navigation-slot { position:absolute; width:0; height:0; min-width:0; }
  .global-navigation {
    position:fixed;
    z-index:var(--z-drawer);
    top:var(--header-height);
    bottom:0;
    left:0;
    width:min(86vw,320px);
    padding-bottom:max(16px,env(safe-area-inset-bottom));
    border-right:1px solid var(--border);
    background:var(--side);
    box-shadow:var(--shadow-popover);
    overflow-y:auto;
    overscroll-behavior:contain;
    transform:translateX(-105%);
    visibility:hidden;
    transition:transform .18s ease,visibility .18s ease;
  }
  body.global-mobile-open .global-navigation { transform:translateX(0); visibility:visible; }
  body.global-mobile-open { overflow:hidden; }
  .global-navigation > header {
    position:sticky;
    z-index:2;
    top:0;
    min-height:52px;
    display:flex;
    align-items:center;
    justify-content:space-between;
    gap:10px;
    padding:0 12px 0 16px;
    border-bottom:1px solid var(--border);
    background:var(--surface);
  }
  .global-navigation > header strong { font-size:var(--text-reading); }
  .global-navigation > header button { width:var(--icon-button-size); height:var(--icon-button-size); display:grid; place-items:center; padding:0; border:1px solid var(--border); border-radius:var(--radius); background:var(--surface); color:var(--text); }
  .global-navigation > header button svg { width:17px; height:17px; }
  .global-navigation-context {
    width:calc(100% - 24px);
    min-height:58px;
    margin:12px;
    padding:8px 10px;
    border:1px solid var(--border);
    border-radius:var(--radius-lg);
    background:var(--surface);
    color:var(--text);
    display:grid;
    grid-template-columns:20px minmax(0,1fr) 16px;
    align-items:center;
    gap:9px;
    text-align:left;
  }
  .global-navigation-context[hidden] { display:none; }
  .global-navigation-context > span { min-width:0; display:grid; gap:2px; }
  .global-navigation-context strong { font-size:var(--text-control); }
  .global-navigation-context small { color:var(--muted); font-size:var(--text-2xs); }
  .global-navigation-context > svg { width:17px; height:17px; }
  .global-navigation-context > svg:last-child { width:14px; height:14px; color:var(--faint); }
  .global-navigation > nav {
    height:auto;
    display:grid;
    align-items:start;
    gap:3px;
    padding:0 12px 14px;
    overflow:visible;
  }
  .global-navigation > nav a { width:100%; min-height:var(--sidebar-row-height); height:auto; padding:8px 10px; border-radius:var(--radius-lg); color:var(--muted); }
  .global-navigation > nav a > svg { width:15px; height:15px; margin-left:auto; display:block; color:var(--faint); }
  .global-navigation > nav a.active { color:var(--text); background:var(--surface-hover); }
  .global-navigation-backdrop {
    position:fixed;
    z-index:calc(var(--z-drawer) - 1);
    inset:var(--header-height) 0 0;
    width:auto;
    height:auto;
    border:0;
    border-radius:0;
    background:rgba(15,23,42,.32);
    opacity:0;
    visibility:hidden;
    pointer-events:none;
    transition:opacity .18s ease,visibility .18s ease;
  }
  body.global-mobile-open .global-navigation-backdrop { display:block; opacity:1; visibility:visible; pointer-events:auto; }
  .global-actions { gap:3px; }
  .notification-menu[open], .user-menu[open] { z-index:var(--z-popover); }
  .notification-menu > summary, .user-menu > summary { touch-action:manipulation; }
  .notification-popover {
    position:fixed;
    top:calc(var(--visual-viewport-top, 0px) + var(--header-height) + 8px) !important;
    right:12px !important;
    bottom:auto !important;
    left:auto !important;
    width:min(390px,90vw) !important;
    height:auto !important;
    min-height:0;
    max-height:min(68dvh,620px);
  }
  .notification-popover { display:grid; grid-template-rows:auto minmax(0,auto) auto; align-self:start; }
  .notification-popover[popover]:popover-open { display:grid; }
  .notification-list { max-height:min(58dvh,520px); min-height:0; overflow:auto; overscroll-behavior:contain; }
  .user-popover { position:fixed; top:calc(var(--header-height) + 8px); right:8px; left:auto; width:min(280px,calc(100vw - 16px)); }
  .user-menu summary { padding-right: 3px; }
  .user-menu summary > svg { display: none; }
  .page, .app-shell { grid-template-columns: 1fr; height: auto; }
  .app-shell > .side { position:fixed; z-index:calc(var(--z-drawer) + 2); top:var(--header-height); bottom:0; left:0; width:min(82vw,280px); max-width:none; max-height:none; padding-bottom:max(18px,env(safe-area-inset-bottom)); overflow-y:auto; overscroll-behavior:contain; scrollbar-gutter:stable; transform:translateX(-105%); box-shadow:var(--shadow-popover); transition:transform .18s ease; }
  .mobile-context-back { position:sticky; z-index:2; top:0; display:flex; width:100%; min-height:44px; align-items:center; gap:8px; padding:0 14px; border:0; border-bottom:1px solid var(--border); border-radius:0; background:var(--surface); color:var(--text); font-size:var(--text-sm); font-weight:700; text-align:left; }
  .mobile-context-back svg { width:16px; height:16px; }
  body.sidebar-open .app-shell > .side { transform: translateX(0); }
  .files-workspace.workspace-3pane { grid-template-columns:minmax(var(--workspace-pane-list-min),1fr) var(--workspace-divider-size) minmax(var(--workspace-preview-min),var(--workspace-preview-width,var(--workspace-preview-default))); }
  .files-workspace > .files-sidebar {
    position:fixed;
    z-index:calc(var(--z-drawer) + 2);
    top:var(--header-height);
    bottom:0;
    left:0;
    width:min(82vw,280px);
    max-width:none;
    max-height:none;
    display:flex;
    padding-bottom:max(18px,env(safe-area-inset-bottom));
    overflow-y:auto;
    overscroll-behavior:contain;
    scrollbar-gutter:stable;
    transform:translateX(-105%);
    box-shadow:var(--shadow-popover);
    transition:transform .18s ease;
  }
  body.sidebar-open .files-workspace > .files-sidebar { transform:translateX(0); }
  body.sidebar-open { overflow:hidden; }
  body.sidebar-open:after { content: ""; position: fixed; z-index:calc(var(--z-drawer) + 1); inset:var(--header-height) 0 0; background:rgba(15,23,42,.32); }
  .board-shell { grid-template-columns:1fr; height:calc(100vh - var(--header-height) - var(--footer-height)); height:calc(var(--visual-viewport-height,100dvh) - var(--header-height) - var(--footer-height)); min-height:0; overflow:hidden; }
  .board-shell > .app-main { height: 100%; min-height: 0; overflow: hidden; }
  .board-shell .board-topbar { flex: 0 0 auto; }
  .board-shell .detail-workspace { flex: 1 1 auto; height: auto; min-height: 0; overflow: hidden; }
  .board-shell .detail-workspace > .panel:first-child { height: 100%; min-height: 0; overflow: hidden; }
  .side-resizer { display: none; }
  .board-shell > .sidebar { position:fixed; z-index:calc(var(--z-drawer) + 2); top:var(--header-height); bottom:0; left:0; width:min(82vw,280px); max-width:none; max-height:none; padding-bottom:max(18px,env(safe-area-inset-bottom)); overflow-y:auto; overscroll-behavior:contain; scrollbar-gutter:stable; visibility:visible; transform:translateX(-105%); border-right:1px solid var(--border); border-bottom:0; box-shadow:var(--shadow-popover); transition:transform .18s ease; }
  body.sidebar-open .board-shell > .sidebar { transform: translateX(0); }
  .main { padding:var(--page-gutter-top) var(--page-gutter-inline) var(--page-gutter-bottom); }
  .grid { grid-template-columns: 1fr; }
  .split.vertical, .split.horizontal { grid-template-columns:1fr; grid-template-rows:minmax(260px,42vh) var(--workspace-divider-size) minmax(420px,1fr); }
  .detail-workspace.detail-modal-mode { grid-template-columns: minmax(0,1fr); grid-template-rows: minmax(0,1fr); }
  .detail-workspace.detail-modal-open > .detail-view-panel,
  html[data-detail-view="modal"] .detail-workspace[data-detail-selected="1"][data-detail-requested="1"] > .detail-view-panel { top: calc(var(--header-height) + 8px); right: 8px; bottom: 8px; left: 8px; }
  .workspace-compose-preview-dialog { width:100vw; max-width:100vw; height:100dvh; max-height:100dvh; margin:0; border:0; border-radius:0; }
  .app-attachment-dialog [data-attachment-expand] { display:none; }
  .app-attachment-dialog .attachment-external-open { box-sizing:border-box; width:var(--icon-button-size); min-width:var(--icon-button-size); height:var(--icon-button-size); min-height:var(--icon-button-size); display:grid; place-items:center; padding:0; }
  .app-attachment-dialog .attachment-external-open > span { display:none; }
  .app-attachment-dialog .attachment-pdf-mode-switch:not(.is-hidden) { display:inline-flex; }
  .app-attachment-dialog .attachment-pdf-mode-switch button { min-height:32px; padding:0 7px; font-size:11px; }
  .workspace-compose-preview-fields { grid-template-columns:minmax(0,1fr); }
  .workspace-compose-preview-structured dl > div { grid-template-columns:minmax(0,1fr); }
  .topbar { height:auto; min-height:72px; align-items:center; padding:14px 18px; flex-direction:row; }
  .topbar > .toolbar, .topbar > .workspace-create-action, .topbar > .btn { flex:0 0 auto; margin-left:auto; }
  .topbar .module-title-row { min-width:0; }
  .topbar .module-title-row > div { min-width:0; }
  .topbar .page-title, .topbar .page-subtitle { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
  .module-header { align-items:flex-start; flex-direction:row; gap:16px; }
  .module-header .module-title-row, .module-header .module-title-row > div { min-width:0; }
  .module-header-actions { width:auto; max-width:55%; margin-left:auto; justify-content:flex-end; flex-wrap:wrap; }
  .module-header h1 { font-size:var(--text-xl); }
  .module-primary { flex:0 0 auto; align-self:center; margin-left:auto; }
  .module-filter:not(.workspace-filter-bar) { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr) auto; }
  .module-filter:not(.workspace-filter-bar) input, .module-filter:not(.workspace-filter-bar) select { width: 100%; min-width: 0; }
  .workspace-head { align-items:center; flex-direction:row; gap:9px; }
  .workspace-head > .workspace-title { flex:0 0 auto; min-width:max-content; }
  .workspace-head > form, .workspace-head > .module-filter { flex:1 1 180px; min-width:0; }
  .workspace-head > .compact-search { flex:1 1 180px; min-width:0; }
  .workspace-head > :last-child:not(:first-child) { flex:0 0 auto; margin-left:auto; }
  .workspace-head > form:last-child, .workspace-head > .module-filter:last-child { flex:1 1 180px; }
  .workspace-head > .compact-search:last-child { flex:1 1 180px; }
  .compact-search { width: 100%; }
  .module-disclosure > summary { align-items: flex-start; flex-direction: column; gap: 5px; }


  .appointment-memo { grid-column: 1; }


  .inline-unit-input.double { grid-template-columns: minmax(0,1fr) auto; }
  .policy-option-row { grid-template-columns: 1fr; align-items: stretch; }
  .policy-option-row .sort-field { justify-self: stretch; width: auto; }

  .workspace-modal.gw-help-dialog { width:calc(100vw - var(--modal-viewport-inset)); height:min(560px,calc(100vh - var(--modal-viewport-block-inset))); }
  .gw-help-content { gap:18px; }
  .gw-help-progress-grid, .gw-help-expense-rules { grid-template-columns:1fr; }
  .gw-help-section-head { align-items:stretch; flex-direction:column; }
  .gw-help-section-head > .status-chip { width:max-content; }
  .gw-help-expense-table { overflow:visible; border:0; }
  .gw-help-expense-table table, .gw-help-expense-table tbody, .gw-help-expense-table tr, .gw-help-expense-table td { display:block; width:100%; min-width:0; }
  .gw-help-expense-table thead { display:none; }
  .gw-help-expense-table tbody { display:grid; gap:10px; }
  .gw-help-expense-table tr { padding:11px 12px; border:1px solid var(--border); border-radius:var(--radius); background:var(--surface); }
  .gw-help-expense-table td, .gw-help-expense-table td:first-child { width:100%; display:grid; grid-template-columns:96px minmax(0,1fr); gap:10px; padding:6px 0; border:0; }
  .gw-help-expense-table td::before { content:attr(data-label); color:var(--faint); font-size:var(--text-3xs); font-weight:700; }
  .gw-help-expense-table td:first-child strong, .gw-help-expense-table td:first-child small { grid-column:2; }
  .gw-help-expense-table td:first-child small { margin-top:-7px; }
  .gw-help-expense-table .gw-help-cost-chip { width:max-content; }
  .gw-help-accordions summary { align-items:flex-start; flex-direction:column; gap:4px; padding-right:42px; position:relative; }
  .gw-help-accordions summary::after { position:absolute; top:13px; right:14px; }
  .gw-help-accordions summary small { margin:0 0 0 26px; }
}

@media (min-width: 721px) and (max-width: 1179px) {
  .form-grid.four,
  .form-grid.three { grid-template-columns:repeat(2,minmax(0,1fr)); }
  .form-grid.two { grid-template-columns:repeat(2,minmax(0,1fr)); }
  .workspace-head { gap:12px; }
  .workspace-head > .workspace-title,
  .workspace-head > div:first-child { min-width:0; }
  .table-wrap,
  .table-scroll { -webkit-overflow-scrolling:touch; overscroll-behavior-x:contain; }
}

.app-mobile-focus-anchor { position:fixed; top:0; left:0; width:1px; height:1px; overflow:hidden; opacity:0; pointer-events:none; }

@media (max-width: 720px) {
  /* Board-style detail is a real full-screen surface on phones. It owns the
     visual viewport and covers the global header instead of nesting below it. */
  .detail-workspace.detail-modal-open:before,
  html[data-detail-view="modal"] .detail-workspace[data-detail-selected="1"][data-detail-requested="1"]:before {
    inset:var(--visual-viewport-top,0px) 0 auto;
    width:100vw;
    height:var(--visual-viewport-height,100dvh);
  }
  .detail-workspace.detail-modal-open > .detail-view-panel,
  html[data-detail-view="modal"] .detail-workspace[data-detail-selected="1"][data-detail-requested="1"] > .detail-view-panel {
    top:var(--visual-viewport-top,0px) !important;
    right:0 !important;
    bottom:auto !important;
    left:0 !important;
    width:100vw;
    height:var(--visual-viewport-height,100dvh);
    border:0;
    border-radius:0;
    box-shadow:none;
  }
  .detail-workspace.detail-modal-open > .detail-view-panel > .panel-header,
  html[data-detail-view="modal"] .detail-workspace[data-detail-selected="1"][data-detail-requested="1"] > .detail-view-panel > .panel-header {
    flex:0 0 var(--list-head-height);
  }

  /* List title/count and live search use two deliberate rows rather than
     truncating the title to force everything into the desktop toolbar. */
  .detail-workspace:not([data-mailbox]) > .panel:first-child > .panel-header:has(.workspace-list-search) {
    display:grid;
    align-content:center;
  }
  .detail-workspace:not([data-mailbox]) > .panel:first-child > .panel-header:has(.workspace-list-search) .panel-title {
    width:100%;
    min-width:0;
    justify-content:flex-start;
  }
  .detail-workspace:not([data-mailbox]) > .panel:first-child > .panel-header:has(.workspace-list-search) .panel-title strong {
    display:block;
    min-width:0;
    overflow:hidden;
    text-overflow:ellipsis;
    white-space:nowrap;
  }
  .detail-workspace:not([data-mailbox]) > .panel:first-child > .panel-header:has(.workspace-list-search) .panel-header-actions,
  .detail-workspace:not([data-mailbox]) > .panel:first-child > .panel-header:has(.workspace-list-search) .workspace-list-search {
    width:100%;
    min-width:0;
  }
  .detail-workspace:not([data-mailbox]) > .panel:first-child > .panel-header:has(.workspace-list-search) .workspace-list-tools {
    width:100%;
    flex-direction:column;
  }
  .detail-workspace:not([data-mailbox]) > .panel:first-child > .panel-header:has(.workspace-list-search) .workspace-list-sort,
  .detail-workspace:not([data-mailbox]) > .panel:first-child > .panel-header:has(.workspace-list-search) .workspace-list-sort select {
    width:100%;
  }

  .detail-workspace.detail-modal-open.is-authoring:before { display:none; }
  .detail-workspace.detail-modal-open.is-authoring > .detail-view-panel {
    top:var(--visual-viewport-top,0px) !important;
    right:0 !important;
    bottom:auto !important;
    left:0 !important;
    width:100vw;
    height:var(--visual-viewport-height,100dvh);
    border:0;
    border-radius:0;
    box-shadow:none;
  }
  dialog.workspace-modal[open]:not(.app-form-dialog-compact):not(.absence-dialog),
  dialog.app-form-dialog[open]:not(.app-form-dialog-compact):not(.absence-dialog),
  dialog.app-remote-dialog[open] {
    position:fixed !important;
    top:var(--visual-viewport-top, 0px) !important;
    right:auto !important;
    bottom:auto !important;
    left:0 !important;
    width:100vw !important;
    max-width:100vw !important;
    height:var(--visual-viewport-height, 100dvh) !important;
    min-height:0 !important;
    max-height:var(--visual-viewport-height, 100dvh) !important;
    margin:0 !important;
    transform:none !important;
    border:0 !important;
    border-radius:0 !important;
    box-shadow:none !important;
  }
  dialog.app-form-dialog[open] {
    display:flex !important;
    flex-direction:column;
    min-width:0 !important;
    max-width:100vw !important;
    overflow:hidden !important;
    overscroll-behavior:none;
    touch-action:pan-y;
  }
  dialog.app-form-dialog[open]:not(.app-form-dialog-compact):not(.absence-dialog) > form {
    width:100%;
    height:100%;
    min-height:0;
    max-height:none;
    flex:1 1 auto;
    display:flex;
    flex-direction:column;
    overflow:hidden;
    overscroll-behavior:none;
    touch-action:pan-y;
  }
  dialog.app-form-dialog.app-form-dialog-compact[open],
  dialog.app-form-dialog.absence-dialog[open] {
    position:fixed !important;
    inset:auto !important;
    top:50% !important;
    right:auto !important;
    bottom:auto !important;
    left:50% !important;
    width:min(500px,calc(100vw - 24px)) !important;
    max-width:calc(100vw - 24px) !important;
    height:auto !important;
    min-height:0 !important;
    max-height:calc(var(--visual-viewport-height, 100dvh) - 24px) !important;
    margin:0 !important;
    transform:translate(-50%,-50%) !important;
    border:1px solid var(--border) !important;
    border-radius:8px !important;
    box-shadow:0 24px 68px rgba(16,24,40,.28) !important;
  }
  dialog.app-form-dialog.app-form-dialog-compact[open] > form,
  dialog.app-form-dialog.absence-dialog[open] > form {
    width:100%;
    height:auto;
    min-height:0;
    max-height:inherit;
    flex:0 1 auto;
    display:grid;
    grid-template-rows:auto minmax(0,1fr) auto;
    overflow:hidden;
  }
  dialog.app-form-dialog[open] > .app-form-dialog-head,
  dialog.app-form-dialog[open] > form > .app-form-dialog-head,
  dialog.app-form-dialog[open] > .app-form-dialog-footer,
  dialog.app-form-dialog[open] > form > .app-form-dialog-footer {
    flex:0 0 auto;
  }
  dialog.app-form-dialog[open]:not(.app-form-dialog-compact):not(.absence-dialog) > .app-form-dialog-body,
  dialog.app-form-dialog[open]:not(.app-form-dialog-compact):not(.absence-dialog) > form > .app-form-dialog-body {
    flex:1 1 auto;
    min-height:0;
    min-width:0;
    max-width:100%;
    overflow-x:hidden;
    overflow-y:auto;
    overscroll-behavior:contain;
    touch-action:pan-y;
  }
  dialog.app-form-dialog.app-form-dialog-compact[open] > .app-form-dialog-body,
  dialog.app-form-dialog.app-form-dialog-compact[open] > form > .app-form-dialog-body,
  dialog.app-form-dialog.absence-dialog[open] > .app-form-dialog-body,
  dialog.app-form-dialog.absence-dialog[open] > form > .app-form-dialog-body {
    flex:0 1 auto;
    min-height:0;
    min-width:0;
    max-width:100%;
    overflow-x:hidden;
    overflow-y:auto;
    overscroll-behavior:contain;
    touch-action:pan-y;
  }
  dialog.app-form-dialog.attendance-checkout-dialog[open] > form {
    height:min(720px,calc(var(--visual-viewport-height, 100dvh) - 24px));
    max-height:calc(var(--visual-viewport-height, 100dvh) - 24px);
  }
  dialog.app-form-dialog[open] :where(.form-grid, .collaboration-form-grid, .collaboration-participant-fields, .collaboration-recipient-list, .app-people-picker, .app-people-picker-list) { min-width:0; max-width:100%; }
  dialog.app-form-dialog.absence-dialog[open] .app-form-dialog-body,
  dialog.app-form-dialog[open] .module-grid {
    align-content:start;
    grid-auto-rows:max-content;
  }
  dialog.app-form-dialog.attendance-checkin-dialog[open] > form,
  dialog.app-form-dialog.attendance-recheckin-dialog[open] > form {
    min-height:0;
    display:flex;
    flex-direction:column;
    overflow:hidden;
  }
  dialog.app-form-dialog.attendance-checkin-dialog[open] .app-form-dialog-body,
  dialog.app-form-dialog.attendance-recheckin-dialog[open] .app-form-dialog-body {
    flex:0 1 auto;
    min-height:0;
    align-content:start;
    grid-auto-rows:max-content;
    overflow-y:auto;
    overscroll-behavior:contain;
  }
  dialog.app-form-dialog.attendance-checkin-dialog[open] .app-form-dialog-footer,
  dialog.app-form-dialog.attendance-recheckin-dialog[open] .app-form-dialog-footer {
    flex:0 0 auto;
    margin-top:0;
  }
  dialog.workspace-modal[open] .app-form-dialog-footer,
  dialog.app-form-dialog[open] .app-form-dialog-footer,
  dialog.workspace-modal[open] .app-pdf-footer {
    padding-bottom:max(10px,env(safe-area-inset-bottom));
  }

  body.global-header-hidden:not(.global-mobile-open):not(.sidebar-open):not(.app-dialog-open) > .global {
    transform:translateY(-100%);
  }

  .main,
  .app-main,
  .module-page,
  .module-grid,
  .workspace-panel,
  .table-wrap,
  .table-scroll {
    min-width:0;
    max-width:100%;
  }
}

@media (max-width: 900px) {  .board-detail-document .document-attachment-row { grid-template-columns:minmax(0,1fr); }
  .board-detail-document .document-attachment-row > .preview-btn { width:100%; margin:0; }
  .document-attachment-row.attachment-row-with-download.attachment-row-actions-auto,
  .document-attachment-row.attachment-row-with-download:has(> .collaboration-google-attachment-actions) { grid-template-columns:minmax(0,1fr)!important; }
  .document-attachment-row.attachment-row-with-download > .attachment-direct-actions { width:100%; min-width:0; justify-content:flex-end; border-top:1px solid var(--border); }
  .document-attachment-row.attachment-row-with-download > .attachment-direct-actions > :is(.attachment-mail-action,.attachment-download-action) { min-height:42px; border-top:0; }
  .document-attachment-row.attachment-row-with-download > .collaboration-google-attachment-actions { width:100%; min-width:0; }
}


@media (max-width: 720px) {
  .module-header { display:grid; grid-template-columns:minmax(0,1fr) auto; align-items:start; gap:10px 12px; margin-bottom:var(--section-gap); }
  .module-header .module-title-row { grid-column:1; min-width:0; align-items:flex-start; }
  .module-header-actions { grid-column:2; grid-row:1; width:auto; max-width:46vw; margin-left:0; justify-content:flex-end; flex-wrap:wrap; }
  .module-header > .module-primary,
  .module-header > .btn,
  .module-header > button,
  .module-header > a:not(.module-title-row) { grid-column:2; grid-row:1; align-self:start; justify-self:end; min-width:0; margin-left:0; }
  .workspace-panel,
  .module-disclosure { margin-bottom:var(--section-gap); }
  .workspace-head { min-height:auto; align-items:flex-start; flex-wrap:wrap; gap:9px 12px; padding:10px var(--panel-padding-inline); }
  .workspace-head > .workspace-title,
  .workspace-head > div:first-child { min-width:0; flex:1 1 100%; flex-wrap:wrap; }
  .workspace-head .workspace-title > h2,
  .workspace-head > div:first-child > h2 { min-width:0; }
  .workspace-head .workspace-title > h2 + span,
  .workspace-head > div:first-child > h2 + span { min-width:0; white-space:normal; }
  .workspace-head > form,
  .workspace-head > .module-filter { width:100%; flex:1 1 100%; margin-left:0; }
  .workspace-head > .compact-search { width:100%; flex:1 1 100%; margin-left:0; }
  .module-filter { width:100%; grid-template-columns:minmax(0,1fr); }
  .module-filter > * { min-width:0; width:100%; }
  .form-grid.four,
  .form-grid.three,
  .form-grid.two { grid-template-columns:minmax(0,1fr); }
  .form-footer { align-items:stretch; flex-direction:column; gap:10px; }
  .form-footer > .actions { width:100%; justify-content:flex-end; }
  .table-wrap,
  .table-scroll { max-width:100%; overflow-x:auto; -webkit-overflow-scrolling:touch; overscroll-behavior-x:contain; }
  .app-pdf-body.is-image-mode { position:relative; overflow:hidden; }
  .app-pdf-body.is-image-mode > iframe { position:absolute; left:-12000px; top:0; display:block; width:1024px; height:1400px; visibility:hidden; pointer-events:none; }
  .app-pdf-body.is-image-mode > .app-pdf-image-viewer { display:grid; }
  .app-pdf-footer { min-height:58px; padding:8px 12px; }
  .app-pdf-footer button, .app-pdf-footer .btn { min-width:0; flex:1; }

  body.app-modal-embed dialog[data-auto-dialog].app-form-dialog[open] {
    inset:0 !important;
    top:0 !important;
    right:0 !important;
    bottom:0 !important;
    left:0 !important;
    width:100% !important;
    max-width:none !important;
    height:100% !important;
    max-height:none !important;
    margin:0 !important;
    transform:none !important;
    border:0 !important;
    border-radius:0 !important;
    box-shadow:none !important;
  }
}

@media (max-width: 420px) {
  .module-header > .module-primary span,
  .module-header > .module-header-actions .btn span,
  .module-header > .module-header-actions button span { position:absolute; width:1px; height:1px; padding:0; margin:-1px; overflow:hidden; clip:rect(0,0,0,0); white-space:nowrap; border:0; }
  .module-header > .module-primary,
  .module-header > .module-header-actions .btn,
  .module-header > .module-header-actions button { width:var(--icon-button-size); min-width:var(--icon-button-size); padding:0; }
  .mailbox-module-header > .mail-header-compose { width:auto; min-width:0; padding:8px 12px; }
  .mailbox-module-header > .mail-header-compose span { position:static; width:auto; height:auto; margin:0; overflow:visible; clip:auto; white-space:nowrap; }
}

@media (orientation: portrait) {  .detail-workspace.detail-modal-mode { grid-template-columns: minmax(0,1fr); grid-template-rows: minmax(0,1fr); }
  .detail-workspace.detail-modal-open > .detail-view-panel,
  html[data-detail-view="modal"] .detail-workspace[data-detail-selected="1"][data-detail-requested="1"] > .detail-view-panel { top: calc(var(--header-height) + 8px); right: 8px; bottom: 8px; left: 8px; }
}
