:root {
    --primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --secondary-gradient: linear-gradient(135deg, #2af598 0%, #009efd 100%);
    --text-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    /* Same as primary for light mode */
    --glass-bg: rgba(255, 255, 255, 0.7);
    --glass-border: rgba(0, 0, 0, 0.1);
    --glass-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.15);
    --text-primary: #2d3748;
    --text-secondary: #718096;
    --bg-color: #f7fafc;
    --card-bg: #ffffff;
    --accent-color: #667eea;
    --success-color: #48bb78;
    --error-color: #f56565;
}

body.dark-mode {
    --glass-bg: rgba(10, 22, 46, 0.7);
    --glass-border: rgba(255, 255, 255, 0.05);
    /* reduced border opacity for cleaner look */
    --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
    --text-primary: #f7fafc;
    --text-secondary: #a0aec0;
    --bg-color: #050A1E;
    --card-bg: #0A162E;
    --accent-color: #6366f1;
    /* Matched with script.js default */
    --text-gradient: linear-gradient(135deg, #0ea5e9 0%, #6366f1 100%);
    /* Deep Blue compatible gradient */
}

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

body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    transition: background-color 0.3s ease, color 0.3s ease;
    display: flex;
    flex-direction: column;
}

/* Background Shapes */
.background-shapes {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    overflow: hidden;
}

.shape {
    position: absolute;
    filter: blur(80px);
    opacity: 0.6;
    animation: float 20s infinite;
}

body.dark-mode .shape {
    opacity: 0.4;
    /* Reduce opacity in dark mode to help text stand out */
}

.shape-1 {
    top: -10%;
    left: -10%;
    width: 500px;
    height: 500px;
    background: var(--primary-gradient);
    border-radius: 50%;
}

.shape-2 {
    bottom: -10%;
    right: -10%;
    width: 600px;
    height: 600px;
    background: var(--secondary-gradient);
    border-radius: 50%;
    animation-delay: -5s;
}

.shape-3 {
    top: 40%;
    left: 40%;
    width: 300px;
    height: 300px;
    background: linear-gradient(135deg, #ff9a9e 0%, #fecfef 99%, #fecfef 100%);
    border-radius: 50%;
    animation-delay: -10s;
}

@keyframes float {
    0% {
        transform: translate(0, 0) rotate(0deg);
    }

    33% {
        transform: translate(30px, -50px) rotate(10deg);
    }

    66% {
        transform: translate(-20px, 20px) rotate(-5deg);
    }

    100% {
        transform: translate(0, 0) rotate(0deg);
    }
}

/* Glassmorphism Utilities */
.glass-header,
.glass-footer,
.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    box-shadow: var(--glass-shadow);
}

/* Header */
.glass-header {
    /* Reverted sticky per user request */
    position: relative;
    z-index: 10;
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-radius: 16px;
    margin: 1rem;
    transition: all 0.3s ease;
}

.logo {
    font-weight: 700;
    font-size: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* ... existing nav styles ... */

/* Download Summary Button Styling */
#download-btn {
    background: var(--primary-gradient);
    color: white;
    border: none;
    padding: 0.8rem 1.5rem;
    border-radius: 12px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.3s ease;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

#download-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
}

/* Deep Blue Theme for Download Button in Dark Mode */
body.dark-mode #download-btn {
    /* Darker, subdued button (User Request) */
    background: #0A162E;
    /* Match card background */
    border: 1px solid #6366f1;
    /* Thin accent border */
    color: #a3bffa;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
}

body.dark-mode #download-btn:hover {
    background: #111d3b;
    /* Slightly lighter on hover */
    box-shadow: 0 0 15px rgba(99, 102, 241, 0.3);
    /* Subtle glow */
    transform: translateY(-2px);
    color: #ffffff;
}

.badge {
    background: var(--primary-gradient);
    color: white;
    padding: 0.2rem 0.5rem;
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: 600;
}

nav {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.nav-link {
    text-decoration: none;
    color: var(--text-primary);
    font-weight: 500;
    transition: color 0.2s;
}

.nav-link:hover {
    color: var(--accent-color);
}

/* Language Switcher */
.lang-switcher {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
    font-size: 1.2rem;
    border: 2px solid var(--accent-color);
    padding: 4px 12px;
    border-radius: 50px;
    background: var(--bg-color);
    height: 34px;
    box-sizing: border-box;
    transition: all 0.3s ease;
}

.lang-switcher:hover {
    box-shadow: 0 0 8px rgba(102, 126, 234, 0.3);
}

.lang-link {
    text-decoration: none;
    color: var(--text-secondary);
    transition: color 0.2s;
}

.lang-link:hover,
.lang-link.active {
    color: var(--accent-color);
}

.separator {
    color: var(--glass-border);
}

/* Theme Switcher */
.theme-switcher {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
    font-size: 1.2rem;
    border: 2px solid var(--accent-color);
    padding: 4px 12px;
    border-radius: 50px;
    background: var(--bg-color);
    height: 34px;
    box-sizing: border-box;
    transition: all 0.3s ease;
    cursor: pointer;
}

.theme-switcher:hover {
    box-shadow: 0 0 8px rgba(102, 126, 234, 0.3);
}

.theme-btn {
    cursor: pointer;
    opacity: 0.5;
    transition: opacity 0.2s, transform 0.2s;
}

.theme-btn:hover {
    opacity: 0.8;
}

.theme-btn.active {
    opacity: 1;
    transform: scale(1.1);
}

/* Main Content */
.main-content {
    max-width: 1200px;
    margin: 4rem auto;
    padding: 0 1.5rem;
    flex: 1;
    width: 100%;
}

.hero-section {
    text-align: center;
    margin-bottom: 4rem;
}

.hero-title {
    font-size: 3.5rem;
    font-weight: 700;
    margin-bottom: 1rem;
    background: var(--text-gradient);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    line-height: 1.2;
}

.hero-subtitle {
    font-size: 1.2rem;
    color: var(--text-secondary);
    margin-bottom: 3rem;
}

/* Upload Card */
.upload-card {
    max-width: 600px;
    margin: 0 auto;
    border-radius: 24px;
    padding: 2rem;
    transition: transform 0.3s ease;
}

.upload-card:hover {
    transform: translateY(-5px);
}

.upload-area {
    border: 2px dashed var(--accent-color);
    border-radius: 16px;
    padding: 3rem 2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    transition: all 0.3s ease;
    background: rgba(255, 255, 255, 0.05);
}

.upload-area:hover,
.upload-area.dragover {
    background: rgba(102, 126, 234, 0.1);
    border-color: #764ba2;
}

.upload-icon-wrapper {
    color: var(--accent-color);
    margin-bottom: 1rem;
    padding: 1rem;
    background: rgba(102, 126, 234, 0.1);
    border-radius: 50%;
}

.upload-text {
    font-weight: 600;
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
}

.upload-hint {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

/* Controls Panel */
.controls-panel {
    max-width: 800px;
    margin: 2rem auto;
    padding: 1.5rem;
    border-radius: 16px;
    display: flex;
    flex-wrap: wrap;
    gap: 2rem;
    align-items: center;
    justify-content: center;
}

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

.control-group label {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.checkbox-group {
    flex-direction: row;
    align-items: center;
    padding-top: 1.2rem;
}

select {
    padding: 0.5rem 1rem;
    border-radius: 8px;
    border: 2px solid var(--glass-border);
    background: var(--card-bg);
    color: var(--text-primary);
    font-family: inherit;
    cursor: pointer;
    transition: border-color 0.3s ease;
}

select:hover,
select:focus {
    border-color: var(--accent-color);
    outline: none;
}

/* Color Selector */
.color-selector {
    display: flex;
    gap: 0.5rem;
}

.color-option {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid transparent;
    transition: transform 0.2s;
}

.color-option:hover {
    transform: scale(1.1);
}

.color-option.selected {
    border-color: var(--text-primary);
    box-shadow: 0 0 0 2px var(--bg-color);
}

/* Buttons */
.btn-primary {
    background: var(--primary-gradient);
    color: white;
    border: none;
    padding: 0.8rem 2rem;
    border-radius: 12px;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(118, 75, 162, 0.3);
}

.btn-secondary {
    background: var(--card-bg);
    color: var(--text-primary);
    border: 1px solid var(--glass-border);
    padding: 0.8rem 2rem;
    border-radius: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-secondary:hover {
    background: var(--bg-color);
}

/* Results Section */
.section-title {
    text-align: center;
    font-size: 2rem;
    margin-bottom: 2rem;
}

.plots-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(450px, 1fr));
    gap: 2rem;
    width: 100%;
}

.plot-card {
    border-radius: 20px;
    padding: 1.5rem;
    min-height: 450px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    /* Prevent content from spilling out */
    width: 100%;
    /* Ensure card stays within grid cell */
    min-width: 0;
    /* Allow grid item to shrink below content size */
}

.plot-header {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    margin-bottom: 1rem;
}

.plot-header h3 {
    font-size: 1.2rem;
    font-weight: 600;
}

.plot-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.plot-content {
    flex: 1;
    width: 100%;
    min-height: 0;
}

.plot-download-btn {
    color: var(--text-secondary);
    transition: color 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4px;
    border-radius: 6px;
}

.plot-download-btn:hover {
    color: var(--accent-color);
    background: rgba(0, 0, 0, 0.05);
}

body.dark-mode .plot-download-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* Toggle Switch */
.toggle-switch {
    background: var(--bg-color);
    border-radius: 8px;
    padding: 2px;
    display: flex;
}

.toggle-btn {
    background: transparent;
    border: none;
    padding: 4px 12px;
    border-radius: 6px;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 600;
    transition: all 0.2s;
}

.toggle-btn.active {
    background: white;
    color: var(--accent-color);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

body.dark-mode .toggle-btn.active {
    background: var(--card-bg);
}

/* Status Message */
.status-message {
    text-align: center;
    margin: 1rem auto;
    padding: 1rem;
    border-radius: 12px;
    font-weight: 500;
    display: none;
    max-width: 600px;
}

.status-message.show {
    display: block;
    background: rgba(72, 187, 120, 0.1);
    color: var(--success-color);
    border: 1px solid rgba(72, 187, 120, 0.2);
}

.status-message.error.show {
    background: rgba(245, 101, 101, 0.1);
    color: var(--error-color);
    border: 1px solid rgba(245, 101, 101, 0.2);
}

/* Footer */
.glass-footer {
    text-align: center;
    padding: 2rem;
    margin: 2rem 1rem 1rem;
    border-radius: 16px;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* Responsive */
@media (max-width: 768px) {
    .hero-title {
        font-size: 2.5rem;
    }

    .plots-grid {
        grid-template-columns: 1fr;
    }

    .controls-panel {
        flex-direction: column;
        align-items: stretch;
    }

    .glass-header {
        padding: 1rem;
    }
}

.download-section {
    display: flex;
    justify-content: center;
    margin-top: 3rem;
    display: none;
}

/* Glow Effect */
.glow-effect {
    position: relative;
    overflow: hidden;
}

.glow-effect::after {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.3) 0%, transparent 60%);
    transform: scale(0);
    opacity: 0;
    transition: transform 0.5s, opacity 0.5s;
}

.glow-effect:hover::after {
    transform: scale(1);
    opacity: 1;
    transition: 0s;
}

@keyframes pulse-glow {
    0% {
        box-shadow: 0 0 0 0 rgba(102, 126, 234, 0.4);
    }

    70% {
        box-shadow: 0 0 0 10px rgba(102, 126, 234, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(102, 126, 234, 0);
    }
}

.glow-effect:hover {
    animation: pulse-glow 2s infinite;
}