/* Shared content-driven workflow. Loaded after legacy page-specific layouts. */
body.home-page, body.rcwa-page { display:block; height:auto; min-height:100vh; }
.home-page .page-container, .rcwa-page .page-container {
 display:block; width:100%; max-width:none; height:auto; min-height:0;
 margin:0; padding:0 clamp(12px,2vw,32px); overflow:visible; box-sizing:border-box;
}
.home-page .layout-grid, .rcwa-page .layout-grid {
 display:grid; grid-template-columns:minmax(320px,28fr) minmax(350px,30fr) minmax(440px,42fr);
 grid-template-rows:auto; align-items:start; gap:16px; margin:16px 0;
 height:auto; min-height:0; max-height:none;
}
.home-page .layout-grid { grid-template-areas:'section materials plots'; }
.rcwa-page .layout-grid { grid-template-areas:'settings layers preview'; }
.home-page .layout-grid > .main-section,
.home-page .layout-grid > .materials-column,
.home-page .layout-grid > .plots-column,
.rcwa-page .rcwa-settings, .rcwa-page .rcwa-layers,
.rcwa-page .layout-grid > .structure-preview {
 height:auto; min-height:0; max-height:none; overflow:visible;
 min-width:0; box-sizing:border-box; scrollbar-gutter:auto;
}
.home-page .simulation-settings-content,
.home-page .structure-preview > .stack-editor,
.home-page .stack-editor > .material-selection,
.home-page .material-selection .ms-grid,
.home-page .structure-preview > #si-model-panel,
.home-page #si-model-panel > .silicon-model-content,
.home-page #config-summary > .summary-content,
.rcwa-page #config-summary > .summary-content {
 height:auto; min-height:0; max-height:none; overflow:visible;
 flex:none; scrollbar-gutter:auto;
}
.home-page .simulation-settings-content { display:block; }
.home-page .materials-column > .structure-preview,
.home-page .materials-column > .structure-preview:has(> #si-model-panel[hidden]) {
 display:flex; flex-direction:column; flex:none; height:auto; min-height:0; gap:16px;
}
.home-page .structure-preview > .editor-actions { margin-top:0; width:100%; box-sizing:border-box; }
.home-page .simulation-settings-content > .material-selection-panel { flex:none; }
.home-page .plots-column > .plots-content { flex:none; min-height:0; overflow:visible; }
.home-page .plots-content > .material-chart-panel:not([hidden]):not(.inactive-plot) { flex:none; }
.home-page .plots-content .material-chart-wrap,
.home-page .plots-column #tmm-results-panel .material-chart-wrap,
.rcwa-page #material-chart-panel .material-chart-wrap,
.rcwa-page .layout-grid > .structure-preview .plot-content {
 position:relative; flex:none; width:100%; height:clamp(280px,28vw,480px); min-height:0;
}
.home-page #layer-coherence-note { margin:8px 0 0; }
.rcwa-page .rcwa-output-choices > div { flex-wrap:wrap; }
.rcwa-page .rcwa-structure-choices { flex-wrap:wrap; }
.rcwa-page .layer-count-control { flex-wrap:wrap; }
.home-page .summary-item, .rcwa-page .summary-item { min-width:0; overflow-wrap:anywhere; }
.home-page .site-footer, .rcwa-page .site-footer { margin-top:16px; }
/* Two configuration panels followed by a full-width results panel. */
@media(max-width:1199px) {
 .home-page .layout-grid, .rcwa-page .layout-grid { grid-template-columns:repeat(2,minmax(0,1fr)); }
 .home-page .layout-grid { grid-template-areas:'section materials' 'plots plots'; }
 .rcwa-page .layout-grid { grid-template-areas:'settings layers' 'preview preview'; }
}
/* Preserve workflow order on phones and small tablets. */
@media(max-width:767px) {
 .home-page .layout-grid, .rcwa-page .layout-grid { grid-template-columns:minmax(0,1fr); gap:12px; }
 .home-page .layout-grid { grid-template-areas:'section' 'materials' 'plots'; }
 .rcwa-page .layout-grid { grid-template-areas:'settings' 'layers' 'preview'; }
 .rcwa-page .layer-environment-fields { grid-template-columns:repeat(2,minmax(0,1fr)); }
 .rcwa-page .layer-environment-fields > div:first-child { grid-column:1 / -1; }
 .rcwa-page .layout-grid > .structure-preview #output,
 .rcwa-page #recent-runs-list { max-height:none !important; overflow:visible; }
}
/* Full-width bars without the scrollbar-width overflow caused by 100vw. */
.home-page .page-container, .rcwa-page .page-container { --workspace-gutter:clamp(12px,2vw,32px); }
.home-page .site-header, .rcwa-page .site-header,
.home-page .site-footer, .rcwa-page .site-footer {
 width:calc(100% + var(--workspace-gutter) + var(--workspace-gutter));
 margin-left:calc(-1 * var(--workspace-gutter));
}

/* The old grid's start alignment must not shrink children in the flex stack. */
.home-page .materials-column > .structure-preview,
.home-page .materials-column > .structure-preview:has(> #si-model-panel[hidden]) {
 align-items:stretch;
}
.home-page .materials-column .structure-preview > .stack-editor,
.home-page .materials-column .structure-preview > #si-model-panel,
.home-page .materials-column .structure-preview > #silicon-model-empty {
 width:100%; min-width:0; max-width:100%; align-self:stretch; box-sizing:border-box;
}

/* Keep the footer at the page bottom without stretching the workspace to the viewport. */
.home-page .page-container, .rcwa-page .page-container {
 display:flex; flex-direction:column; min-height:100vh; min-height:100dvh;
}
.home-page .layout-grid, .rcwa-page .layout-grid { flex:none; width:100%; }
.home-page .site-footer, .rcwa-page .site-footer { margin-top:auto; flex-shrink:0; }
/* Desktop panels share the tallest content height, not a fixed screen height. */
@media(min-width:1200px) {
 .home-page .layout-grid, .rcwa-page .layout-grid { align-items:stretch; }
 .home-page .layout-grid > .main-section,
 .home-page .layout-grid > .materials-column,
 .home-page .layout-grid > .plots-column,
 .rcwa-page .rcwa-settings, .rcwa-page .rcwa-layers,
 .rcwa-page .layout-grid > .structure-preview { align-self:stretch; }
}
