*, *::before, *::after { box-sizing: border-box; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: #f0eff5;
    margin: 0;
    padding: 24px 16px;
    color: #2d2d35;
    min-height: 100vh;
}

.all-container {
    background-color: #ffffff;
    padding: 48px 52px;
    margin: 0 auto;
    max-width: 1100px;
    box-shadow: 0 2px 20px rgba(0,0,0,0.07), 0 8px 40px rgba(100,60,160,0.05);
    border-radius: 20px;
}

/* === Headings === */
h1.titre {
    color: #6b2fa0;
    text-decoration: none;
    font-size: 1.75em;
    font-weight: 700;
    text-align: center;
    margin-bottom: 12px;
    letter-spacing: -0.02em;
}

h2.titre {
    color: #6b2fa0;
    text-decoration: none;
    font-size: 1.15em;
    font-weight: 600;
    margin: 32px 0 16px;
    padding-bottom: 10px;
    border-bottom: 2px solid #ede8f5;
}

p {
    color: #4a4a55;
    line-height: 1.65;
    margin: 0 0 12px;
}

a { color: #7b3db5; }

/* === Parameter form === */
.container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    max-width: 100%;
}

/* Parameter cards */
#global, #PSM, #NT {
    background: #f9f7fd;
    border: 1px solid #e4daf2;
    border-radius: 14px;
    padding: 20px 24px;
}

#global {
    grid-column: 1 / span 2;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px 28px;
}

#PSM { grid-column: 1; display: flex; flex-direction: column; gap: 14px; }
#NT  { grid-column: 2; display: flex; flex-direction: column; gap: 14px; }

.param_title {
    font-weight: 700;
    font-size: 0.78em;
    color: #6b2fa0;
    text-transform: uppercase;
    letter-spacing: 0.09em;
    margin: 0 0 4px;
    grid-column: 1 / span 2;
}

#PSM .param_title,
#NT  .param_title { grid-column: unset; }

#global .param { display: flex; flex-direction: column; gap: 2px; }

label {
    font-style: normal;
    font-size: 0.855em;
    color: #4a4a55;
    font-weight: 500;
}

/* === Sliders === */
input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 5px;
    background: #ddd8ea;
    border-radius: 3px;
    outline: none;
    cursor: pointer;
    margin-top: 5px;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 17px;
    height: 17px;
    border-radius: 50%;
    background: #7b3db5;
    cursor: pointer;
    box-shadow: 0 1px 5px rgba(100,50,160,0.3);
    transition: background 0.15s, transform 0.1s;
}

input[type="range"]::-webkit-slider-thumb:hover {
    background: #5b2a90;
    transform: scale(1.12);
}

input[type="range"]::-moz-range-thumb {
    width: 17px;
    height: 17px;
    border-radius: 50%;
    background: #7b3db5;
    cursor: pointer;
    border: none;
    box-shadow: 0 1px 5px rgba(100,50,160,0.3);
}

input[type="range"]::-moz-range-track {
    height: 5px;
    background: #ddd8ea;
    border-radius: 3px;
}

/* === Run button === */
.button-container {
    grid-column: 1 / span 2;
    display: flex;
    justify-content: center;
    margin-top: 24px;
}

#run {
    background: linear-gradient(135deg, #7b3db5 0%, #a05dd4 100%);
    color: white;
    border: none;
    padding: 13px 44px;
    font-size: 0.975em;
    font-weight: 600;
    border-radius: 50px;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(123,61,181,0.35);
    transition: all 0.2s ease;
    letter-spacing: 0.03em;
}

#run:hover {
    background: linear-gradient(135deg, #5b2a90 0%, #7b3db5 100%);
    box-shadow: 0 6px 18px rgba(123,61,181,0.45);
    transform: translateY(-1px);
}

#run:active {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(123,61,181,0.3);
}

/* === Simulation panel === */
#simulation {
    background: #f9f7fd;
    padding: 24px;
    margin: 28px auto 0;
    border-radius: 16px;
    border: 1px solid #e4daf2;
    display: flex;
    flex-direction: column;
    gap: 16px;
    position: relative;
}

/* === Two-plot row === */
#plots-row {
    display: flex;
    flex-direction: row;
    gap: 14px;
}

/* === Plot areas === */
#surfacePlot, #velocityPlot {
    flex: 1;
    min-width: 0;
    height: clamp(500px, 78vh, 820px);
    border-radius: 10px;
    background: white;
}

/* === Controls bar (horizontal, below plot) === */
#controls {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.controls-label {
    font-size: 0.75em;
    font-weight: 700;
    color: #6b2fa0;
    text-transform: uppercase;
    letter-spacing: 0.09em;
    margin: 0;
    white-space: nowrap;
}

#frameSlider {
    flex: 1;
    min-width: 180px;
}

#pauseBtn {
    background: white;
    color: #7b3db5;
    border: 2px solid #c9aee8;
    padding: 7px 20px;
    font-size: 0.85em;
    font-weight: 600;
    border-radius: 50px;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.18s;
}

#pauseBtn:hover {
    background: #7b3db5;
    color: white;
    border-color: #7b3db5;
}

/* === Density / Pressure toggle === */
.view-toggle {
    display: flex;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid #c9aee8;
    background: white;
    min-width: 160px;
}

input[type="radio"][name="data_choice"] { display: none; }

input[type="radio"][name="data_choice"] + label {
    flex: 1;
    text-align: center;
    padding: 7px 12px;
    font-size: 0.8em;
    font-weight: 500;
    font-style: normal;
    cursor: pointer;
    background: transparent;
    color: #7b3db5;
    transition: all 0.15s;
    margin: 0;
}

input[type="radio"][name="data_choice"]:checked + label {
    background: #7b3db5;
    color: white;
}

/* === Loader === */
#loader {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    background: rgba(255,255,255,0.97);
    padding: 28px 40px;
    border-radius: 16px;
    box-shadow: 0 4px 28px rgba(100,60,160,0.15);
    min-width: 240px;
    z-index: 10;
}

#loaderMessage {
    margin: 12px 0 0;
    font-size: 0.875em;
    color: #6b2fa0;
    font-weight: 500;
}

.spinner {
    border: 4px solid #ede8f5;
    border-top: 4px solid #7b3db5;
    border-radius: 50%;
    width: 38px;
    height: 38px;
    animation: spin 0.75s linear infinite;
    margin: 0 auto;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}
