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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #7B2D3B 0%, #5C1A2A 100%);
    min-height: 100vh;
    padding: 20px;
    color: #333;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    overflow: hidden;
}

.header {
    background: linear-gradient(135deg, #7B2D3B 0%, #5C1A2A 100%);
    color: white;
    padding: 30px;
    text-align: center;
}

.header h1 {
    font-size: 2.5em;
    margin-bottom: 10px;
    font-weight: 300;
}

.header p {
    font-size: 1.1em;
    opacity: 0.9;
}

/* Tabs */
.tab-bar {
    display: flex;
    background: #f0f0f0;
    border-bottom: 2px solid #e0e0e0;
}

.tab-button {
    padding: 14px 30px;
    border: none;
    background: transparent;
    font-size: 1.05em;
    font-weight: 600;
    color: #888;
    cursor: pointer;
    border-bottom: 3px solid transparent;
    transition: all 0.2s;
    font-family: inherit;
}

.tab-button:hover {
    color: #7B2D3B;
    background: #f8f5f6;
}

.tab-button.active {
    color: #7B2D3B;
    border-bottom-color: #7B2D3B;
    background: white;
}

.tab-content {
    display: none;
}

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

/* Simulation tab layout */
.content {
    display: grid;
    grid-template-columns: 350px 1fr;
    gap: 0;
}

#tab-bloch .content,
#tab-simulation .content {
    grid-template-columns: 480px 1fr;
}

#tab-bloch .controls-panel,
#tab-simulation .controls-panel {
    font-size: 0.92em;
}

.bloch-equations .eq-line {
    font-size: 1.35em;
    padding: 6px 0 6px 20px;
}

/* Animation tab layout */
.animation-container {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 0;
    min-height: 600px;
}

.animation-controls {
    background: #f8f5f6;
    padding: 20px;
    border-right: 1px solid #e0e0e0;
    font-size: 0.9em;
}

.animation-controls h2 {
    color: #7B2D3B;
    margin-bottom: 15px;
    font-size: 1.3em;
    border-bottom: 2px solid #7B2D3B;
    padding-bottom: 6px;
}

.anim-button {
    width: 100%;
    padding: 10px;
    margin-top: 10px;
    border: none;
    border-radius: 8px;
    background: linear-gradient(135deg, #7B2D3B 0%, #5C1A2A 100%);
    color: white;
    font-size: 1em;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.2s;
    font-family: inherit;
}

.anim-button:hover {
    opacity: 0.9;
}

.view-toggle {
    display: flex;
    gap: 0;
    border-radius: 8px;
    overflow: hidden;
    border: 2px solid #7B2D3B;
}

.view-btn {
    flex: 1;
    padding: 8px 12px;
    border: none;
    background: white;
    color: #7B2D3B;
    font-weight: 600;
    font-size: 0.9em;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.2s;
}

.view-btn.active {
    background: linear-gradient(135deg, #7B2D3B 0%, #5C1A2A 100%);
    color: white;
}

.view-btn:hover:not(.active) {
    background: #f5eef0;
}

.animation-right {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.animation-plots {
    display: flex;
    flex-direction: row;
    overflow-y: auto;
}

.animation-plot-wrapper {
    padding: 10px;
    flex: 3;
}

.signal-plot-wrapper {
    padding: 10px;
    flex: 1;
    min-width: 200px;
}

#animation-plot {
    width: 100%;
    height: 500px;
}

#signal-plot {
    width: 100%;
    height: 500px;
}

.mx-plot-wrapper {
    padding: 10px 20px 20px 20px;
    border-top: 1px solid #e0e0e0;
}

#mx-plot {
    width: 100%;
    height: 220px;
}

.controls-panel {
    background: #f8f5f6;
    padding: 15px 20px;
    border-right: 1px solid #e0e0e0;
    overflow-y: auto;
    font-size: 0.82em;
}

.controls-panel h2 {
    color: #7B2D3B;
    margin-bottom: 10px;
    font-size: 1.3em;
    border-bottom: 2px solid #7B2D3B;
    padding-bottom: 6px;
}

.control-group {
    margin-bottom: 10px;
}

.control-label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
    font-weight: 600;
    color: #555;
}

.control-label .math {
    font-family: 'Times New Roman', serif;
    font-style: italic;
    color: #7B2D3B;
}

.control-label .value {
    color: #9B3A4A;
    font-weight: 700;
    font-size: 0.95em;
}

.slider {
    width: 100%;
    height: 6px;
    border-radius: 5px;
    background: #ddd;
    outline: none;
    -webkit-appearance: none;
    margin: 4px 0;
}

.slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: linear-gradient(135deg, #7B2D3B 0%, #5C1A2A 100%);
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

.slider:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.slider:disabled::-webkit-slider-thumb {
    background: #aaa;
    cursor: not-allowed;
}

.slider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: linear-gradient(135deg, #7B2D3B 0%, #5C1A2A 100%);
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

.checkbox-group {
    display: flex;
    align-items: center;
    padding: 8px;
    border: 2px solid #ddd;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
}

.checkbox-group:hover {
    border-color: #7B2D3B;
    background: #f5eef0;
}

.checkbox-group input[type="checkbox"] {
    margin-right: 10px;
    cursor: pointer;
}

.visualization-panel {
    padding: 30px;
    background: white;
}

.images-container {
    display: flex;
    gap: 20px;
    margin-bottom: 30px;
    flex-wrap: wrap;
    justify-content: center;
}

.image-wrapper {
    flex: 1;
    min-width: 300px;
    max-width: 500px;
}

.image-wrapper img {
    width: 100%;
    height: auto;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.chart-container {
    margin-bottom: 30px;
    background: white;
    border-radius: 10px;
    padding: 20px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

#spectrum-plot, #fid-plot,
#bloch-spectrum-plot, #bloch-fid-plot, #bloch-vector-plot {
    width: 100%;
    height: 400px;
    min-height: 400px;
}

.chart-title {
    font-size: 1.3em;
    color: #7B2D3B;
    margin-bottom: 15px;
    font-weight: 600;
}

.info-box {
    background: #f3e5e8;
    border-left: 4px solid #7B2D3B;
    padding: 10px;
    margin-bottom: 10px;
    border-radius: 5px;
}

.info-box h3 {
    color: #7B2D3B;
    margin-bottom: 10px;
}

.info-box p {
    color: #555;
    line-height: 1.6;
}

/* Bloch equations display */
.bloch-equations {
    background: #faf6f7;
    border-left: 4px solid #7B2D3B;
    padding: 14px 18px;
    margin-bottom: 14px;
    border-radius: 5px;
    line-height: 1.6;
}

.bloch-equations .eq-intro {
    color: #555;
    font-size: 0.92em;
    margin-bottom: 10px;
}

.bloch-equations .eq-section-title {
    font-weight: 700;
    color: #7B2D3B;
    font-size: 0.88em;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 12px;
    margin-bottom: 4px;
}

.bloch-equations .eq-line {
    font-family: 'Georgia', 'Times New Roman', 'Cambria', serif;
    font-size: 1.05em;
    padding: 3px 0 3px 16px;
    color: #222;
    letter-spacing: 0.3px;
}

.bloch-equations .eq-note {
    color: #555;
    font-size: 0.88em;
    margin: 4px 0;
}

.bloch-equations .eq-line.eq-small {
    font-size: 1.05em;
    padding: 2px 0 2px 20px;
}

/* Matrix display */
.eq-matrix {
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 8px 0;
    font-family: 'Georgia', 'Times New Roman', 'Cambria', serif;
    font-size: 1.05em;
}

.eq-matrix-label {
    margin-right: 4px;
    font-size: 1.1em;
}

.eq-matrix-bracket {
    font-size: 2.6em;
    font-weight: 200;
    line-height: 1;
    color: #444;
}

.eq-matrix-table {
    border-collapse: collapse;
    margin: 0 4px;
}

.eq-matrix-table td {
    padding: 6px 10px;
    text-align: center;
    white-space: nowrap;
    color: #222;
    letter-spacing: 0.2px;
}

/* Dispersion tab layout */
.dispersion-container {
    display: grid;
    grid-template-columns: 480px 1fr;
    gap: 0;
}

.dispersion-controls {
    background: #f8f5f6;
    padding: 15px 20px;
    border-right: 1px solid #e0e0e0;
    overflow-y: auto;
    font-size: 0.88em;
}

.dispersion-controls h2 {
    color: #7B2D3B;
    margin-bottom: 10px;
    font-size: 1.3em;
    border-bottom: 2px solid #7B2D3B;
    padding-bottom: 6px;
}

.dispersion-right {
    padding: 30px;
    background: white;
    overflow-y: auto;
}

#dispersion-plot {
    width: 100%;
    height: 400px;
    min-height: 400px;
}

#dispersion-spectrum-plot {
    width: 100%;
    height: 350px;
    min-height: 350px;
}

.preset-buttons {
    display: flex;
    gap: 6px;
    margin-top: 10px;
    flex-wrap: wrap;
}

.preset-btn {
    flex: 1;
    min-width: 60px;
    padding: 8px 4px;
    border: 2px solid #7B2D3B;
    border-radius: 8px;
    background: white;
    color: #7B2D3B;
    font-weight: 600;
    font-size: 0.85em;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.2s;
}

.preset-btn:hover {
    background: linear-gradient(135deg, #7B2D3B 0%, #5C1A2A 100%);
    color: white;
}

.regime-indicator {
    margin-top: 12px;
    padding: 12px;
    background: #f3e5e8;
    border-radius: 8px;
    border-left: 4px solid #7B2D3B;
    line-height: 1.8;
}

@media (max-width: 1024px) {
    .content,
    #tab-bloch .content,
    #tab-simulation .content {
        grid-template-columns: 1fr;
    }

    .controls-panel {
        border-right: none;
        border-bottom: 1px solid #e0e0e0;
    }

    .dispersion-container {
        grid-template-columns: 1fr;
    }

    .dispersion-controls {
        border-right: none;
        border-bottom: 1px solid #e0e0e0;
    }
}
