* { box-sizing: border-box; }
html, body { height: 100%; }

body {
    margin: 0;
    overflow: hidden;
    font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial, "Noto Sans", "Helvetica Neue", sans-serif;
    background: var(--bg-gradient);
    color: var(--text);
}

/* keep the rest of your styles here unchanged */


h2, h3 { margin: 0 0 12px 0; }

h3 {
    margin-top: 16px;
    color: var(--text);
    opacity: 0.95;
}

/* --- Layout --- */
.app {
    max-width: 1500px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: minmax(280px, 320px) minmax(0, 1fr) minmax(280px, 320px);
    gap: 16px;
    align-items: start;

    height: 100vh;
    padding: 16px;
}

.diag, .main, .params {
    display: flex;
    flex-direction: column;
    gap: 16px;
    min-width: 0;

    overflow: auto;
    min-height: 0;
    max-height: 100%;
    scrollbar-gutter: stable;
}

.card {
    background: linear-gradient(180deg, var(--panel) 0%, var(--panel-2) 100%);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 14px;
}

/* Title+abstract “paper” style */
.title-card {
    padding: 16px 18px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.title-card h2 {
    text-align: center;
    width: 100%;
    margin: 0;
}

.subtitle {
    color: var(--muted);
    font-size: 13px;
    line-height: 1.35;
}

.paper-abstract {
    max-width: 980px;
    margin: 0 auto;
    text-align: left;
}

/* --- Plot containers --- */
#plot, #acf_plot, #deph_plot, #err_plot {
    width: 100%;
    border-radius: calc(var(--radius) - 6px);
    overflow: hidden;
    background: rgba(0, 0, 0, 0.18);
    border: 1px solid var(--border);
}

#plot { height: 300px; }
#acf_plot { height: 260px; }
#deph_plot { height: 260px; margin-top: 12px; }
#err_plot { height: 300px; margin-top: 12px; }

/* --- Controls --- */
.controls {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.control {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 12px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.03);
}

.control-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
}

.control label {
    font-size: 13px;
    color: var(--muted);
}

.value-pill {
    font-variant-numeric: tabular-nums;
    font-size: 12px;
    padding: 4px 8px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: rgba(0, 0, 0, 0.25);
    color: var(--text);
}

input[type="range"] {
    width: 100%;
    accent-color: var(--accent);
}

.actions {
    display: flex;
    gap: 10px;
    margin-top: 4px;
}

button {
    width: 100%;
    padding: 10px 12px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: linear-gradient(180deg, rgba(122, 162, 255, 0.22), rgba(122, 162, 255, 0.10));
    color: var(--text);
    cursor: pointer;
    font-weight: 600;
    box-shadow: 0 8px 18px rgba(0, 0, 0, 0.35);
}

button:hover { border-color: rgba(122, 162, 255, 0.55); }
button:active { transform: translateY(1px); }

/* --- Segmented 3-button controls --- */
.segmented { display: flex; gap: 8px; }

.seg-btn {
    width: auto;
    flex: 1;
    padding: 8px 10px;
    border-radius: 10px;
    font-weight: 700;
    box-shadow: none;
}

.seg-btn.active {
    border-color: rgba(122, 162, 255, 0.70);
    background: linear-gradient(180deg, rgba(122, 162, 255, 0.35), rgba(122, 162, 255, 0.14));
}

/* --- Collapsible cards --- */
.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.card-header h3 { margin: 0; }

.collapse-btn {
    width: auto;
    padding: 6px 10px;
    border-radius: 10px;
    font-weight: 700;
    box-shadow: none;
}

.card-body { margin-top: 10px; }
.card.collapsed .card-body { display: none; }
.card.collapsed { padding-bottom: 10px; }

/* two controls side-by-side inside Dynamics */
.dyn-controls-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 12px;
}

@media (max-width: 850px) {
    .dyn-controls-row { grid-template-columns: 1fr; }
}

/* small section label inside cards */
.section-label {
    margin: 12px 0 6px 0;
    color: var(--muted);
    font-size: 12px;
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

.figure-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    align-items: start;
}

.figure-col { min-width: 0; }

.figure-row .figure-col:only-child {
    grid-column: 1 / -1; /* single figureleft or figureright becomes full width */
}

@media (max-width: 850px) {
    .figure-row { grid-template-columns: 1fr; }
}


/* --- Responsive --- */
@media (max-width: 1250px) {
    .app { grid-template-columns: 1fr; }
}

/* Minimal addition for mode toggling */
.hidden { display: none; }
:root[data-theme="dark"] {
    color-scheme: dark;

    --bg: #0b0f14;
    --panel: #111826;
    --panel-2: #0f1623;
    --text: #e6edf3;
    --muted: #9aa4b2;
    --border: rgba(255, 255, 255, 0.10);
    --accent: #7aa2ff;
    --accent-2: #22c55e;
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
    --radius: 14px;

    /* make the background swappable */
    --bg-gradient: radial-gradient(1200px 700px at 20% 0%, #101a2a 0%, var(--bg) 55%);

    --plot-bg: rgba(0,0,0,0);
}
:root[data-theme="light"] {
    color-scheme: light;

    --bg: #f6f8fb;
    --panel: #ffffff;
    --panel-2: #f2f5fa;
    --text: #0b1220;
    --muted: #52606d;
    --border: rgba(15, 23, 42, 0.12);
    --accent: #2563eb;
    --accent-2: #16a34a;
    --shadow: 0 10px 30px rgba(15, 23, 42, 0.10);
    --radius: 14px;

    --bg-gradient: radial-gradient(1200px 700px at 20% 0%, #ffffff 0%, var(--bg) 55%);

    --plot-bg: #ffffff;
    --plot-border: rgba(15, 23, 42, 0.12);

}
