/* ── canvas-card flex column (lets children fill height) ────────────────── */

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

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

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

/* ── decision-boundary grid ─────────────────────────────────────────────── */

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

.boundary-card {
    position: relative;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.55);
    overflow: hidden;
    min-height: 0;
}

.boundary-header {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    padding: 3px 8px;
    font-size: 0.76rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    gap: 6px;
    background: rgba(255, 255, 255, 0.72);
    backdrop-filter: blur(4px);
    border-radius: 13px 13px 0 0;
    pointer-events: none;
}

.boundary-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;
    background: var(--brand-soft);
    color: var(--brand);
}

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

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

.boundary-plot {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

/* ── accuracy pill ──────────────────────────────────────────────────────── */

.acc-pill {
    display: inline-flex;
    align-items: center;
    height: 20px;
    padding: 0 7px;
    border-radius: 999px;
    font-size: 0.76rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    background: rgba(23, 33, 29, 0.07);
    color: var(--text);
    margin-left: auto;
}

/* ── 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;
}

/* ── boundary home buttons ──────────────────────────────────────────────── */

.boundary-home-row {
    display: flex;
    gap: 6px;
    align-items: center;
    margin-left: auto;
}

.home-btn {
    padding: 3px 11px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: white;
    color: var(--muted);
    font: inherit;
    font-size: 0.76rem;
    font-weight: 700;
    cursor: pointer;
    transition: background 120ms ease, color 120ms ease;
}

.home-btn:hover {
    background: var(--brand-soft);
    color: var(--brand);
}

/* ── dataset toggle ─────────────────────────────────────────────────────── */

.dataset-toggle {
    display: inline-flex;
    gap: 4px;
    padding: 4px;
    border-radius: 999px;
    background: rgba(23, 33, 29, 0.07);
    flex: 0 0 auto;
}

.dataset-toggle-btn {
    padding: 4px 14px;
    border: none;
    border-radius: 999px;
    background: transparent;
    color: var(--muted);
    font: inherit;
    font-size: 0.82rem;
    font-weight: 700;
    cursor: pointer;
    transition: background 160ms ease, color 160ms ease;
}

.dataset-toggle-btn.is-active {
    background: white;
    color: var(--brand);
    box-shadow: 0 2px 8px rgba(20, 30, 28, 0.1);
}

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

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

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

    .content-pane > .canvas-card:first-child,
    .content-pane > .canvas-card:last-child {
        flex: none;
        min-height: 480px;
    }

    .boundary-grid {
        grid-template-rows: repeat(3, 240px);
    }
}
