/* Authoritative page geometry. Tool styles own only the content inside this frame. */
:root {
  --space-1:4px;
  --space-2:8px;
  --space-3:12px;
  --space-4:16px;
  --space-5:24px;
  --space-6:32px;
  --page-top:36px;
  --page-header-height:112px;
  --page-header-gap:12px;
  --surface-gap:12px;
  --surface-padding:24px;
}
/* Keep the page width constant when content starts/stops needing vertical scroll. */
html{scrollbar-gutter:stable}
/* Flow remains a full-width canvas with its existing 12px inset. */
html:has(body.flow-editor-open){scrollbar-gutter:auto}
body:not(.flow-editor-open) .workspace{
  width:100%;max-width:var(--workspace-max-width);
  margin-inline:auto;padding:var(--page-top) var(--workspace-gutter) 0;
}
body:not(.flow-editor-open) :is(.page-title-row,.sx-page-head){
  display:grid;grid-template-columns:minmax(0,1fr) auto;
  align-items:start;gap:var(--space-5);
  min-height:var(--page-header-height);margin:0 0 var(--page-header-gap);
}
body:not(.flow-editor-open) :is(.title-heading-group,.sx-title-wrap){min-width:0;align-items:flex-start}
body:not(.flow-editor-open) :is(.title-heading-group>.open-sidebar,.sx-title-wrap>.sx-mobile-menu){width:32px;height:32px;margin-top:5px;flex-shrink:0}
body:not(.flow-editor-open) :is(#page-title,.sx-page-head h1){
  font-size:var(--text-page);line-height:1.3;font-weight:650;
  letter-spacing:-1px;margin:0;
}
body:not(.flow-editor-open) :is(.page-description,.sx-page-head p){
  font-size:var(--text-body);font-weight:500;line-height:1.6;margin:8px 0 0;
}
body:not(.flow-editor-open) :is(.page-actions,.sx-header-actions){
  display:flex;align-items:center;justify-content:flex-end;flex-wrap:nowrap;
  gap:var(--space-2);margin:6px 0 0;width:auto;align-self:start;
}
body:not(.flow-editor-open) :is(.page-actions .button,.sx-header-actions .sx-button){
  min-height:42px;margin:0;white-space:nowrap;
}
/* Both templates start their dataset strip at the exact same content line. */
.dataset-header,.sx-project-line{min-height:48px;margin:0 0 var(--space-4);padding:0;gap:var(--space-4)}
.stats-grid,.chart-grid,.tool-placeholder-grid,.sx-stat-grid{gap:var(--surface-gap)}
.stats-grid,.chart-grid{margin-bottom:var(--surface-gap)}
.card,.stat-card,.sx-card,.sx-stat-grid .sx-card{padding:var(--surface-padding)}
.card-head{margin-bottom:var(--space-5);gap:var(--space-4)}
.workspace-footer{margin-top:var(--space-5)}
body.survey-explorer-open .page-title-row{display:none}
@media(max-width:1100px){
  body:not(.flow-editor-open) :is(.page-title-row,.sx-page-head){
    grid-template-columns:minmax(0,1fr);grid-template-rows:auto;
    gap:var(--space-4);min-height:var(--page-header-height);
  }
  body:not(.flow-editor-open) :is(.page-actions,.sx-header-actions){justify-content:flex-start;margin:0}
}
@media(max-width:760px){
  :root{--page-top:32px;--surface-padding:20px}
  body:not(.flow-editor-open) :is(.page-actions,.sx-header-actions){width:100%}
  body:not(.flow-editor-open) .sx-header-actions>.sx-primary{width:auto;order:0}
}

/* Headers with no actions keep the same baseline without an empty grid column. */
body:not(.flow-editor-open) .page-title-row:not(:has(.page-actions>:not([hidden]))){grid-template-columns:minmax(0,1fr)}
