:root {
    --bg-color: #0d1117;
    --card-bg: rgba(22, 27, 34, 0.8);
    --primary-color: #58a6ff;
    --accent-color: #1f6feb;
    --text-color: #c9d1d9;
    --text-muted: #8b949e;
    --border-color: #30363d;
    --glass-bg: rgba(255, 255, 255, 0.05);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
    overflow-x: hidden;
}

.container {
    display: grid;
    grid-template-columns: 300px 1fr;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    background-color: var(--card-bg);
    border-right: 1px border var(--border-color);
    padding: 2rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    backdrop-filter: blur(10px);
    position: sticky;
    top: 0;
    height: 100vh;
}

.logo {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

label {
    font-size: 0.85rem;
    color: var(--text-muted);
}

input[type="range"], select {
    width: 100%;
}

.checkbox-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    cursor: pointer;
}

button {
    background: linear-gradient(135deg, var(--accent-color), var(--primary-color));
    border: none;
    color: white;
    padding: 0.8rem;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, background 0.2s;
}

button:hover {
    transform: translateY(-2px);
    filter: brightness(1.1);
}

/* Main Content */
.main-content {
    padding: 2rem;
}

header {
    margin-bottom: 2rem;
}

h1 {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 2rem;
    margin-bottom: 3rem;
}

.card {
    background: var(--glass-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1.5rem;
    backdrop-filter: blur(5px);
}

.card h3 {
    margin-bottom: 1rem;
    font-size: 1.1rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.5rem;
}

.plot-container img {
    width: 100%;
    border-radius: 8px;
}

.metrics-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-top: 1rem;
}

.metric-box {
    background: rgba(255,255,255,0.03);
    padding: 0.8rem;
    border-radius: 8px;
    text-align: center;
}

.metric-label {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.metric-value {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--primary-color);
}

.delta {
    font-size: 0.8rem;
    margin-left: 0.4rem;
}

.delta.positive { color: #3fb950; }
.delta.negative { color: #f85149; }

/* Loader */
#loader {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: none;
    z-index: 1000;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 5px solid var(--glass-bg);
    border-top: 5px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

footer {
    padding: 2rem;
    border-top: 1px solid var(--border-color);
    color: var(--text-muted);
    font-size: 0.8rem;
    text-align: center;
}

/* ========== MSE vs Pilots Section ========== */
.mse-pilots-section {
    margin-top: 3rem;
    margin-bottom: 3rem;
}

.mse-pilots-section h2 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
    color: var(--text-color);
}

.mse-description-card {
    margin-bottom: 2rem;
}

.mse-description-card p {
    color: var(--text-muted);
    margin-bottom: 1rem;
}

.mse-desc-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
    padding: 0;
}

.mse-desc-list li {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.7rem 1rem;
    background: rgba(88, 166, 255, 0.05);
    border-left: 3px solid var(--accent-color);
    border-radius: 0 6px 6px 0;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.mse-desc-list li strong {
    color: var(--primary-color);
}

.desc-icon {
    font-size: 1.3rem;
    flex-shrink: 0;
}

/* SNR Selector */
.mse-snr-selector {
    margin-bottom: 1.5rem;
}

.mse-snr-selector label {
    display: block;
    margin-bottom: 0.75rem;
    font-size: 0.9rem;
    color: var(--text-muted);
    font-weight: 600;
}

.snr-btn-group {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.snr-btn {
    background: var(--glass-bg);
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    padding: 0.4rem 1rem;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.snr-btn:hover {
    transform: translateY(-1px);
    border-color: var(--primary-color);
    color: var(--primary-color);
    filter: none;
}

.snr-btn.active {
    background: linear-gradient(135deg, var(--accent-color), var(--primary-color));
    border-color: transparent;
    color: white;
    transform: none;
}

/* Plot Wrapper */
.mse-plot-wrapper {
    padding: 1.5rem;
}

.mse-plot-header {
    margin-bottom: 1rem;
}

.mse-plot-header h3 {
    border-bottom: none;
    padding-bottom: 0;
    margin-bottom: 0.25rem;
}

.mse-plot-subtitle {
    font-size: 0.85rem;
    color: var(--text-muted);
    line-height: 1.5;
}

.mse-plot-container {
    display: flex;
    justify-content: center;
    margin: 1rem 0;
}

.mse-plot-img {
    max-width: 100%;
    width: 100%;
    max-height: 500px;
    object-fit: contain;
    border-radius: 8px;
    transition: opacity 0.3s ease;
    background: transparent;
}

.mse-plot-img.fade {
    opacity: 0;
}

/* Insight Bar */
.mse-insight-bar {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.9rem 1.2rem;
    background: rgba(31, 111, 235, 0.12);
    border: 1px solid rgba(88, 166, 255, 0.25);
    border-radius: 8px;
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 0.5rem;
}


/* ========== Training Process Section ========== */
.training-section h2 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
    color: var(--text-color);
}

.training-tabs {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.training-tab {
    background: var(--glass-bg);
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    padding: 0.55rem 1.25rem;
    border-radius: 24px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.training-tab:hover {
    transform: translateY(-1px);
    border-color: var(--primary-color);
    color: var(--primary-color);
    filter: none;
}

.training-tab.active {
    background: linear-gradient(135deg, var(--accent-color), var(--primary-color));
    border-color: transparent;
    color: white;
    transform: none;
}

.training-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(420px, 1fr));
    gap: 1.5rem;
}

.training-card {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding: 1.25rem;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.training-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

.training-img-wrap {
    border-radius: 8px;
    line-height: 0;
}

.training-img-wrap img {
    width: 100%;
    display: block;
    border-radius: 8px;
    cursor: zoom-in;
    transition: opacity 0.2s ease;
}

.training-img-wrap img:hover {
    opacity: 0.85;
}

/* ========== Lightbox ========== */
#lightbox {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(0, 0, 0, 0.88);
    backdrop-filter: blur(6px);
    align-items: center;
    justify-content: center;
    cursor: zoom-out;
}

#lightbox.active {
    display: flex;
}

#lightbox img {
    max-width: 90vw;
    max-height: 90vh;
    border-radius: 10px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.6);
    cursor: default;
    animation: lbFadeIn 0.2s ease;
}

#lightbox-close {
    position: fixed;
    top: 1.25rem;
    right: 1.5rem;
    font-size: 2rem;
    color: white;
    cursor: pointer;
    line-height: 1;
    opacity: 0.8;
    transition: opacity 0.2s;
    background: none;
    border: none;
    padding: 0;
}

#lightbox-close:hover {
    opacity: 1;
    transform: none;
    filter: none;
}

@keyframes lbFadeIn {
    from { opacity: 0; transform: scale(0.95); }
    to   { opacity: 1; transform: scale(1); }
}

.training-desc h4 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--primary-color);
    margin: 0;
}

.training-desc p {
    font-size: 0.85rem;
    color: var(--text-muted);
    line-height: 1.55;
}
