/* Impedance matching — walk on the left, lab fills the window. */

body.cl-page {
    height: 100dvh;
    max-height: 100dvh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

body.cl-page .ai-header,
body.cl-page .im-series-mount,
body.cl-page .ai-site-footer { flex-shrink: 0; }

body.cl-page .ai-site-footer {
    margin-top: 0;
    padding: 4px 12px 6px;
}

body.cl-page .control-loops-series-mount--bottom,
body.cl-page .control-loops-series-nav--bottom { display: none; }

body.cl-page .cl-workspace {
    flex: 1 1 auto;
    min-height: 0;
    max-width: none;
    overflow: hidden;
    align-items: stretch;
}

body.cl-page .cl-walk { max-height: 100%; }

body.cl-page .cl-lab {
    min-width: 0;
    min-height: 0;
    height: 100%;
    overflow: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

body.cl-page .im-demo {
    max-width: none;
    margin: 0;
    padding: 0;
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

body.cl-page .im-panel {
    flex: 1 1 auto;
    min-height: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 10px 12px 8px;
}

body.cl-page .im-panel-head { margin-bottom: 6px; }
body.cl-page .im-controls,
body.cl-page .im-legend,
body.cl-page .im-readouts,
body.cl-page .im-schematic { flex-shrink: 0; }

body.cl-page .im-schematic svg {
    height: 72px;
    max-width: 360px;
}

body.cl-page .im-readouts { margin-bottom: 0; }

body.cl-page .im-two-col {
    flex: 1 1 auto;
    min-height: 0;
    align-items: stretch;
}

body.cl-page .im-two-col > div {
    min-width: 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

body.cl-page .im-canvas-wrap,
body.cl-page .im-canvas-wrap--wide,
body.cl-page .im-canvas-wrap--smith {
    max-width: none;
    flex: 1 1 auto;
    min-height: 150px;
    margin: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

body.cl-page .im-canvas-wrap--wide canvas,
body.cl-page .im-chart-stack canvas {
    width: 100%;
    height: 100%;
}

body.cl-page .im-canvas-wrap--smith canvas {
    width: auto;
    height: 100%;
    max-width: 100%;
    aspect-ratio: 1;
}

body.cl-page .im-chart-stack {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin: 6px 0 0;
}

body.cl-page .im-chart-stack > div {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

body.cl-page .im-chart-stack .im-canvas-wrap { min-height: 140px; }

body.cl-page .lab-card.is-on {
    border-color: #2563eb;
    box-shadow: 0 0 0 2px #bfdbfe;
}

body.cl-page .on-deeper {
    flex: 0 0 auto;
    background: #fff;
    border: 1px solid var(--ai-gray-200);
    border-radius: var(--ai-radius-lg);
    padding: 8px 12px 12px;
}

body.cl-page .on-deeper summary {
    cursor: pointer;
    font-weight: 700;
    color: var(--ai-blue-800);
}

body.cl-page .on-deeper[open] summary { margin-bottom: 8px; }

@media (max-width: 1100px) {
    body.cl-page { height: auto; max-height: none; overflow: auto; }
    body.cl-page .cl-workspace { overflow: visible; height: auto; }
    body.cl-page .im-panel { overflow: visible; height: auto; }
    body.cl-page .im-canvas-wrap--smith { min-height: 0; height: auto; flex: none; }
    body.cl-page .im-canvas-wrap--smith canvas {
        width: min(100%, 340px);
        height: auto;
    }
    body.cl-page .im-canvas-wrap--wide { height: 200px; flex: none; }
    body.cl-page .im-chart-stack { height: auto; flex: none; }
    body.cl-page .im-chart-stack .im-canvas-wrap { height: 150px; flex: none; }
}

/* Listed labs keep the live chart heights; the lab scrolls. */
body.cl-page.chart-main .im-demo,
body.cl-page.chart-main .im-panel,
body.cl-page.chart-main .im-two-col,
body.cl-page.chart-main .im-two-col > div,
body.cl-page.chart-main .im-chart-stack,
body.cl-page.chart-main .im-chart-stack > div {
    flex: none;
    height: auto;
    min-height: 0;
    overflow: visible;
}

body.cl-page.chart-main .im-canvas-wrap,
body.cl-page.chart-main .im-canvas-wrap--wide {
    flex: none;
    height: auto;
    min-height: 0;
}

body.cl-page.im-z .im-canvas-wrap:has(#phasorCanvas),
body.cl-page.im-z #phasorCanvas { height: 320px; min-height: 320px; }
body.cl-page.im-z .im-canvas-wrap:has(#magCanvas),
body.cl-page.im-z #magCanvas { height: 160px; min-height: 160px; }
body.cl-page.im-z .im-canvas-wrap:has(#phaseCanvas),
body.cl-page.im-z #phaseCanvas { height: 140px; min-height: 140px; }

body.cl-page.im-need .im-canvas-wrap:has(#powerCanvas),
body.cl-page.im-need #powerCanvas { height: 300px; min-height: 300px; }
