:root {
    --primary-color: #6366f1;
    --primary-hover: #4f46e5;
    --secondary-color: #ec4899;
    --bg-color: #f8fafc;
    --card-bg: #ffffff;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --border-color: #e2e8f0;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --danger-color: #ef4444;
    --font-family: 'Inter', system-ui, -apple-system, sans-serif;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --radius-lg: 1rem;
    --radius-md: 0.75rem;
    --radius-sm: 0.5rem;
}

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

body {
    font-family: var(--font-family);
    background-color: var(--bg-color);
    color: var(--text-main);
    line-height: 1.6;
    min-height: 100vh;
    padding: 2rem;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 2.5rem;
    border: 1px solid rgba(255, 255, 255, 0.5);
}

/* Header */
header {
    text-align: center;
    margin-bottom: 3rem;
}

h1 {
    font-size: 2.5rem;
    font-weight: 800;
    color: var(--text-main);
    margin-bottom: 0.5rem;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -0.025em;
}

.subtitle {
    color: var(--text-muted);
    font-size: 1.1rem;
}

/* Tabs */
.tabs {
    display: flex;
    gap: 1rem;
    margin-bottom: 2rem;
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 1px;
}

.tab {
    padding: 0.75rem 1.5rem;
    background: transparent;
    border: none;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s ease;
    border-bottom: 2px solid transparent;
    margin-bottom: -3px;
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}

.tab:hover {
    color: var(--primary-color);
    background-color: rgba(99, 102, 241, 0.05);
}

.tab.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
}

.tab-content {
    display: none;
    animation: fadeIn 0.3s ease-out;
}

.tab-content.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Controls */
.controls {
    background: #f1f5f9;
    padding: 1.5rem;
    border-radius: var(--radius-md);
    margin-bottom: 2rem;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    border: 1px solid var(--border-color);
}

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

label {
    font-weight: 600;
    color: var(--text-main);
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.value-display {
    background: var(--primary-color);
    color: white;
    padding: 0.1rem 0.6rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
}

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

select {
    padding: 0.6rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background-color: white;
    font-size: 0.95rem;
    color: var(--text-main);
    transition: border-color 0.2s, box-shadow 0.2s;
    cursor: pointer;
}

select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    height: 6px;
    background: #cbd5e1;
    border-radius: 3px;
    outline: none;
    margin-top: 0.5rem;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    background: var(--primary-color);
    border-radius: 50%;
    cursor: pointer;
    transition: transform 0.1s, background-color 0.2s;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.1);
    background: var(--primary-hover);
}

/* Plots & Visualizations */
.plots {
    display: grid;
    grid-template-columns: 1fr;
    gap: 2rem;
}

.plot-container {
    background: white;
    padding: 1.5rem;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
}

.plot-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-color);
}

/* Three.js Container */
#threejs-container {
    width: 100%;
    height: 600px;
    background: linear-gradient(135deg, #0f172a 0%, #1e1b4b 100%);
    border-radius: var(--radius-md);
    position: relative;
    overflow: hidden;
    box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.5);
}

.overlay-panel {
    position: absolute;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(8px);
    padding: 1rem;
    border-radius: var(--radius-md);
    z-index: 10;
    box-shadow: var(--shadow-md);
    border: 1px solid rgba(255, 255, 255, 0.5);
}

.view-selector {
    top: 1.5rem;
    left: 1.5rem;
    width: 160px;
}

.view-selector h4,
.threejs-info h4 {
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
    font-weight: 700;
}

.view-btn {
    display: block;
    width: 100%;
    margin-bottom: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: white;
    color: var(--text-main);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    transition: all 0.2s;
    text-align: left;
}

.view-btn:hover {
    background: #f8fafc;
    border-color: var(--primary-color);
}

.view-btn.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.threejs-controls {
    top: 1.5rem;
    right: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.icon-btn {
    padding: 0.6rem 1rem;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-weight: 600;
    color: var(--text-main);
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
}

.icon-btn:hover {
    background: #f8fafc;
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.threejs-info {
    bottom: 1.5rem;
    left: 1.5rem;
    max-width: 300px;
}

.threejs-info p {
    font-size: 0.85rem;
    color: var(--text-main);
    line-height: 1.5;
}

/* Image Analysis */
.image-controls {
    background: #f1f5f9;
    padding: 2rem;
    border-radius: var(--radius-md);
    margin-bottom: 2rem;
    border: 1px solid var(--border-color);
}

.upload-area {
    border: 2px dashed var(--primary-color);
    border-radius: var(--radius-md);
    padding: 3rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s;
    background: white;
    margin-bottom: 1.5rem;
}

.upload-area:hover {
    background: rgba(99, 102, 241, 0.05);
    transform: translateY(-2px);
}

.upload-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    color: var(--primary-color);
}

.upload-area h3 {
    color: var(--text-main);
    margin-bottom: 0.5rem;
}

.upload-area p {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.btn-group {
    display: flex;
    justify-content: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.btn {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: var(--shadow-sm);
}

.btn:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-secondary {
    background: white;
    color: var(--text-main);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: #f8fafc;
    border-color: var(--text-muted);
}

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

.image-box {
    background: white;
    padding: 1rem;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
}

.image-box h3 {
    text-align: center;
    margin-bottom: 1rem;
    font-size: 1rem;
    color: var(--text-main);
}

.image-box canvas {
    width: 100%;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
}

.info-box {
    background: #eff6ff;
    padding: 1.5rem;
    border-radius: var(--radius-md);
    margin-bottom: 2rem;
    border-left: 4px solid var(--primary-color);
}

.info-box h3 {
    color: var(--primary-color);
    margin-bottom: 0.5rem;
    font-size: 1.1rem;
}

.info-box p {
    color: var(--text-main);
    font-size: 0.95rem;
}

/* Experiments */
.sub-tabs {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 2rem;
}

.sub-tab {
    padding: 0.5rem 1.2rem;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 999px;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s;
}

.sub-tab:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.sub-tab.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
    box-shadow: var(--shadow-sm);
}

.exp-content {
    display: none;
    animation: fadeIn 0.3s ease-out;
}

.exp-content.active {
    display: block;
}

.harmonics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
    gap: 10px;
    margin-top: 20px;
}

.harmonic-slider {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.harmonic-slider input[type="range"] {
    writing-mode: bt-lr;
    /* IE */
    -webkit-appearance: slider-vertical;
    /* WebKit */
    width: 8px;
    height: 100px;
    padding: 0 5px;
}

.harmonic-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 5px;
}

.radio-group {
    display: flex;
    gap: 1.5rem;
    margin-top: 0.5rem;
}

.radio-group label {
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

input[type="radio"] {
    accent-color: var(--primary-color);
    width: 1.2em;
    height: 1.2em;
}

/* Responsive */
@media (max-width: 768px) {
    body {
        padding: 1rem;
    }

    .container {
        padding: 1.5rem;
    }

    h1 {
        font-size: 1.8rem;
    }

    .tabs {
        flex-direction: column;
        gap: 0.5rem;
    }

    .tab {
        width: 100%;
        text-align: center;
        border-bottom: none;
        border-left: 3px solid transparent;
        border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    }

    .tab.active {
        border-left-color: var(--primary-color);
        background: rgba(99, 102, 241, 0.05);
    }

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

    #threejs-container {
        height: 450px;
    }

    .view-selector,
    .threejs-controls,
    .threejs-info {
        position: relative;
        top: auto;
        left: auto;
        right: auto;
        bottom: auto;
        width: 100%;
        max-width: none;
        margin-bottom: 1rem;
    }

    .threejs-controls {
        flex-direction: row;
        flex-wrap: wrap;
    }
}