/* ── canvas-card flex column ─────────────────────────────────────────── */

.content-pane > .canvas-card {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.content-pane > .canvas-card {
    flex: 1 1 0;
    min-height: 0;
}

/* probe section: fixed height so Plotly always has a non-zero container */
#probe-section {
    flex: 0 0 auto;
    min-height: 480px;
}

/* training curves */
.content-pane > .canvas-card:last-child {
    flex: 1.1 1 0;
    min-height: 0;
}

/* ── confusion matrix grid ─────────────────────────────────────────── */

.confusion-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
    margin-top: 10px;
}

.confusion-card {
    display: flex;
    flex-direction: row;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.55);
    overflow: hidden;
    min-height: 0;
}

.confusion-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 7px;
    border-right: 1px solid var(--line);
    flex: 0 0 auto;
}

.confusion-header-text {
    writing-mode: vertical-rl;
    transform: rotate(180deg);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    color: var(--muted, #888);
    white-space: nowrap;
}

.confusion-method-tag {
    display: inline-flex;
    align-items: center;
    height: 20px;
    padding: 0 7px;
    border-radius: 999px;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.confusion-method-tag.tag-mlp {
    background: rgba(91, 80, 200, 0.12);
    color: #3a2f8a;
}

.confusion-method-tag.tag-qnn {
    background: rgba(239, 131, 84, 0.12);
    color: #8a4b10;
}

.confusion-plot {
    flex: 1 1 auto;
    min-height: 0;
    width: 100%;
    overflow: hidden;
}

/* ── loss / accuracy chart ─────────────────────────────────────────── */

.chart-wrap {
    flex: 1 1 auto;
    min-height: 0;
    position: relative;
    display: flex;
    flex-direction: column;
    padding-top: 4px;
}

#loss-chart {
    flex: 1 1 auto;
    min-height: 0;
    width: 100%;
    border-radius: 18px;
    border: 1px solid rgba(23, 33, 29, 0.08);
    background:
        linear-gradient(180deg, rgba(13, 143, 113, 0.05), rgba(13, 143, 113, 0)),
        white;
}

.plot-surface {
    width: 100%;
    height: 100%;
}

.plot-surface-wide {
    min-height: 160px;
    flex: 1 1 auto;
}

.chart-empty {
    position: absolute;
    inset: 4px 0 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    font-size: 0.9rem;
    color: var(--muted);
    text-align: center;
    border: 1px dashed rgba(23, 33, 29, 0.18);
    border-radius: 18px;
    background: rgba(255, 252, 245, 0.85);
}

.chart-empty[hidden] {
    display: none !important;
}

/* ── t-SNE + confusion combined section ────────────────────────────── */

#tsne-section {
    flex: 2.2 1 0;
    min-height: 500px;
}

/* scatter and CM equal height, sub-heading moved to top row */
.tsne-grid {
    flex: 1 1 0;
    min-height: 120px;
}

.cm-grid {
    flex: 1.1 1 0;
    min-height: 0;
    margin-top: 8px;
}

/* secondary heading inline with primary */
.tsne-heading-secondary {
    flex: 0 0 auto;
    white-space: nowrap;
    font-size: 1.1rem;
    color: var(--muted, #888);
}

.tsne-section-divider {
    flex: 0 0 auto;
    color: var(--muted, #aaa);
    font-size: 1.2rem;
    margin: 0 2px;
    user-select: none;
}

/* heading: title left, step label right */
.tsne-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: nowrap;
}

.tsne-heading h2 {
    flex: 0 0 auto;
    white-space: nowrap;
}

.tsne-step-label {
    flex: 0 0 auto;
    font-size: 0.78rem;
    color: var(--muted, #888);
    min-width: 5em;
    text-align: right;
}

/* Play button — used in training curves heading */
.tsne-play-btn {
    flex: 0 0 auto;
    height: 28px;
    padding: 0 12px;
    border: 1px solid rgba(23, 33, 29, 0.18);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.72);
    font-family: "IBM Plex Sans", sans-serif;
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 120ms ease;
}

.tsne-play-btn:hover {
    background: rgba(255, 255, 255, 0.95);
}

/* ── responsive ────────────────────────────────────────────────────── */

@media (max-width: 1100px) {
    body {
        height: auto;
        overflow: auto;
    }

    .page-shell {
        grid-template-columns: 1fr;
        height: auto;
    }

    .content-pane > .canvas-card {
        flex: none;
        min-height: 400px;
    }

    #tsne-section {
        min-height: 480px;
    }

    #probe-section {
        min-height: 520px;
    }

    .confusion-grid {
        grid-template-columns: 1fr;
        grid-template-rows: repeat(2, 300px);
    }
}
