:root {
    --primary-color: #007bff;
    /* Strong Blue */
    --secondary-color: #e83e8c;
    /* Strong Pink/Magenta */
    --bg-color: #f0f2f5;
    /* Light Greyish Blue instead of pure white for contrast */
    --glass-bg: rgba(255, 255, 255, 0.65);
    --glass-border: rgba(255, 255, 255, 0.4);
    --glass-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.15);
    --text-main: #333333;
    /* Dark Grey */
    --text-muted: #666666;
    --font-family: 'Outfit', sans-serif;
    --card-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.1);
}

body {
    margin: 0;
    padding: 0;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    /* Gradient for glass visibility */
    color: var(--text-main);
    font-family: var(--font-family);
    overflow-y: auto;
    /* Allow scrolling if content is tall */
    width: 100vw;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
}

.background-blobs {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
    overflow: hidden;
}

.blob {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.6;
    animation: float 20s infinite ease-in-out;
}

.blob-1 {
    background: #ff9a9e;
    width: 500px;
    height: 500px;
    top: -100px;
    left: -100px;
    animation-delay: 0s;
}

.blob-2 {
    background: #a1c4fd;
    width: 400px;
    height: 400px;
    bottom: -50px;
    right: -50px;
    animation-delay: -5s;
}

.blob-3 {
    background: #c2e9fb;
    width: 300px;
    height: 300px;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -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);
    }
}

#bg-canvas {
    /* Particles on top of blobs but under app */
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    pointer-events: none;
    opacity: 0.4;
    /* Subtle particles */
}

#app {
    position: relative;
    z-index: 10;
    width: 100%;
    max-width: 900px;
    padding: 2rem;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    gap: 2rem;
    align-items: center;
}

header {
    text-align: center;
    margin-bottom: 1rem;
}

h1 {
    font-size: 2.5rem;
    font-weight: 700;
    margin: 0;
    background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    text-transform: uppercase;
    letter-spacing: 2px;
}

.subtitle {
    color: var(--text-muted);
    font-weight: 300;
    margin-top: 0.5rem;
    font-size: 1.1rem;
}

.glass-panel {
    background: rgba(255, 255, 255, 0.4);
    /* More transparent */
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.8);
    border-radius: 24px;
    padding: 2.5rem;
    width: 100%;
    box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.1);
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.visualization-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 2rem;
    padding-bottom: 2rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.metric {
    flex: 1;
    text-align: center;
    background: rgba(255, 255, 255, 0.4);
    /* Glassy child */
    backdrop-filter: blur(4px);
    padding: 2rem;
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.5);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.02);
}

.metric .label {
    display: block;
    font-size: 1rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--secondary-color);
    margin-bottom: 0.5rem;
    font-weight: 600;
}

.metric .value {
    display: block;
    font-size: 5rem;
    font-weight: 700;
    line-height: 1;
    color: var(--primary-color);
    text-shadow: 2px 2px 0px rgba(0, 0, 0, 0.05);
}

.metric .formula-display {
    display: block;
    margin-top: 1rem;
    font-family: 'Courier New', monospace;
    color: var(--text-muted);
    font-size: 1.2rem;
    background: rgba(0, 0, 0, 0.03);
    padding: 0.5rem;
    border-radius: 8px;
}

.metric .dynamic-params {
    display: block;
    margin-top: 0.5rem;
    font-family: 'Courier New', monospace;
    color: var(--primary-color);
    font-weight: 600;
    font-size: 1rem;
    background: rgba(0, 123, 255, 0.1);
    padding: 0.5rem;
    border-radius: 8px;
    letter-spacing: 0.5px;
}

.visual-representation {
    flex: 1;
    height: 280px;
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    /* changed from center to stack from top */
    align-items: center;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.5);
    box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.5);
    padding: 10px;
    overflow: hidden;
    /* Prevent spill */
}

.visual-legend {
    width: 100%;
    text-align: center;
    color: #777;
    font-size: 14px;
    font-style: italic;
    margin-top: 10px;
    flex-shrink: 0;
    /* Don't shrink the legend */
}

#sample-canvas {
    width: 100%;
    flex: 1;
    /* Take remaining height */
    border-radius: 12px;
}

.controls-container {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    background: rgba(255, 255, 255, 0.5);
    /* Semi-transparent */
    backdrop-filter: blur(4px);
    padding: 1.5rem;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.6);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.03);
}

.control-group label {
    display: flex;
    justify-content: space-between;
    font-weight: 600;
    font-size: 1.1rem;
    color: var(--text-main);
}

.control-group label span {
    color: var(--primary-color);
    background: rgba(0, 123, 255, 0.1);
    padding: 0.2rem 0.6rem;
    border-radius: 6px;
}

.description-text {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-top: -0.5rem;
    margin-bottom: 0.5rem;
    line-height: 1.4;
}

/* Custom Range Slider - High Visibility & Refined */
input[type=range] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    background: transparent;
    margin: 10px 0;
    height: 24px;
    /* Adjusted container height */
}

input[type=range]:focus {
    outline: none;
}

/* Track Styling */
input[type=range]::-webkit-slider-runnable-track {
    width: 100%;
    height: 8px;
    /* Thinner track */
    cursor: pointer;
    background: #bdc3c7;
    border-radius: 4px;
    border: 1px solid #95a5a6;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* Firefox Track */
input[type=range]::-moz-range-track {
    width: 100%;
    height: 8px;
    /* Thinner track */
    cursor: pointer;
    background: #bdc3c7;
    border-radius: 4px;
    border: 1px solid #95a5a6;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* Thumb Styling */
input[type=range]::-webkit-slider-thumb {
    height: 22px;
    /* Smaller thumb */
    width: 22px;
    border-radius: 50%;
    background: var(--primary-color);
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
    margin-top: -8px;
    /* Centered: (8px track - 22px thumb) / 2 = -7px. -8px for visual balance with border. */
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    border: 3px solid #ffffff;
    /* Slightly thinner border */
    transition: transform 0.1s ease, background 0.2s, box-shadow 0.2s;
}

input[type=range]::-moz-range-thumb {
    height: 22px;
    width: 22px;
    border: 3px solid #ffffff;
    border-radius: 50%;
    background: var(--primary-color);
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

input[type=range]::-webkit-slider-thumb:hover {
    transform: scale(1.15);
    background: var(--secondary-color);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
}

/* Specific colors for different sliders (optional but good for visibility) */
#prevalence::-webkit-slider-thumb {
    background: var(--primary-color);
}

#prevalence::-webkit-slider-thumb:hover {
    background: #0056b3;
}

#precision::-webkit-slider-thumb {
    background: var(--secondary-color);
    box-shadow: 0 4px 8px rgba(232, 62, 140, 0.5);
}

#precision::-webkit-slider-thumb:hover {
    background: #c91f6e;
}

/* Colored tracks for active feel? 
   Let's keep track neutral to let thumb pop, or add a fill?
   Webkit doesn't support fill-lower easy without JS or complex CSS.
   Distinct grey is "clearly visible".
*/

.info-section {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-top: 1rem;
    padding-top: 2rem;
    border-top: 1px solid rgba(0, 0, 0, 0.05);
}

.info-card {
    background: rgba(255, 255, 255, 0.6);
    padding: 1.5rem;
    border-radius: 12px;
    border: 1px solid rgba(0, 0, 0, 0.05);
}

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

.info-card p {
    margin: 0;
    font-size: 0.9rem;
    color: var(--text-muted);
    line-height: 1.5;
}

footer {
    margin-top: 2rem;
    font-size: 0.9rem;
    color: var(--text-muted);
    text-align: center;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.8);
    border-radius: 50px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.developer-name {
    color: var(--secondary-color);
    font-weight: 700;
}

@media (max-width: 768px) {
    #app {
        padding: 1rem;
        gap: 1.5rem;
    }

    h1 {
        font-size: 1.8rem;
        line-height: 1.2;
    }

    .subtitle {
        font-size: 1rem;
    }

    .glass-panel {
        padding: 1.5rem;
        border-radius: 20px;
    }

    /* Stack Visualization on Mobile */
    .visualization-container {
        flex-direction: column;
        gap: 1.5rem;
        padding-bottom: 1.5rem;
    }

    .metric {
        width: 100%;
        padding: 1.5rem;
        box-sizing: border-box;
    }

    .metric .value {
        font-size: 3.5rem;
        /* Smaller for mobile to prevent wrapping */
    }

    .metric .formula-display {
        font-size: 0.9rem;
        padding: 0.4rem;
        overflow-x: auto;
        /* Allow formula scroll if too long */
    }

    .metric .dynamic-params {
        font-size: 0.8rem;
        padding: 0.4rem;
        white-space: normal;
        word-break: break-word;
    }

    .visual-representation {
        width: 100%;
        height: 300px;
        /* Taller on mobile for better visibility */
        margin-top: 1rem;
    }

    .study-selector-container {
        flex-direction: column;
        gap: 0.5rem;
        width: 100%;
        box-sizing: border-box;
    }

    .study-dropdown {
        width: 100%;
        text-align: center;
        font-size: 1.1rem;
        /* Larger touch target */
        padding: 0.8rem;
    }

    /* Bigger touch targets for sliders */
    input[type=range] {
        height: 30px;
        margin: 15px 0;
    }

    input[type=range]::-webkit-slider-thumb {
        width: 28px;
        height: 28px;
    }

    .control-group label {
        font-size: 1rem;
    }

    .info-section {
        grid-template-columns: 1fr;
        /* Stack info cards */
    }

    footer {
        padding: 1.5rem;
        font-size: 0.85rem;
    }
}

/* New Styles for Study Selector */
.study-selector-container {
    margin-top: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    background: rgba(255, 255, 255, 0.4);
    padding: 0.5rem 1rem;
    border-radius: 50px;
    border: 1px solid rgba(255, 255, 255, 0.6);
}

.selector-label {
    font-weight: 600;
    color: var(--text-main);
}

.study-dropdown {
    padding: 0.5rem 1rem;
    border-radius: 8px;
    border: 1px solid #bdc3c7;
    background: rgba(255, 255, 255, 0.9);
    font-family: var(--font-family);
    font-size: 1rem;
    color: var(--text-main);
    cursor: pointer;
    outline: none;
    transition: all 0.2s ease;
}

.study-dropdown:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.1);
}

/* Checkbox / Toggle Switch Styles */
.checkbox-wrapper {
    display: flex;
    align-items: center;
    /* or flex-start if label is multiline */
    gap: 0.8rem;
    margin-bottom: 0.5rem;
    justify-content: space-between;
    /* Put toggle on right? or keep left? Standard is usually left or right. User didn't specify, but preventing shrink is key. */
}

.tgl {
    display: none;
}

.tgl,
.tgl:after,
.tgl:before,
.tgl *,
.tgl *:after,
.tgl *:before,
.tgl+.tgl-btn {
    box-sizing: border-box;
}

.tgl::-moz-selection,
.tgl:after::-moz-selection,
.tgl:before::-moz-selection,
.tgl *::-moz-selection,
.tgl *:after::-moz-selection,
.tgl *:before::-moz-selection,
.tgl+.tgl-btn::-moz-selection {
    background: none;
}

.tgl::selection,
.tgl:after::selection,
.tgl:before::selection,
.tgl *::selection,
.tgl *:after::selection,
.tgl *:before::selection,
.tgl+.tgl-btn::selection {
    background: none;
}

.tgl+.tgl-btn {
    outline: 0;
    display: block;
    width: 44px;
    height: 24px;
    position: relative;
    cursor: pointer;
    user-select: none;
    flex-shrink: 0;
    /* Critical: Prevent compression */
}

.tgl+.tgl-btn:after,
.tgl+.tgl-btn:before {
    position: relative;
    display: block;
    content: "";
    width: 50%;
    height: 100%;
}

.tgl+.tgl-btn:after {
    left: 0;
}

.tgl+.tgl-btn:before {
    display: none;
}

.tgl:checked+.tgl-btn:after {
    left: 50%;
}

.tgl-ios+.tgl-btn {
    background: #fbfbfb;
    border-radius: 2em;
    padding: 2px;
    transition: all .4s ease;
    border: 1px solid #e8eae9;
}

.tgl-ios+.tgl-btn:after {
    border-radius: 2em;
    background: #fbfbfb;
    transition: left 0.3s cubic-bezier(0.175, 0.885, 0.320, 1.275), padding 0.3s ease, margin 0.3s ease;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.1), 0 4px 0 rgba(0, 0, 0, 0.08);
}

.tgl-ios+.tgl-btn:active {
    box-shadow: inset 0 0 0 2em #e8eae9;
}

.tgl-ios+.tgl-btn:active:after {
    padding-right: .8em;
}

.tgl-ios:checked+.tgl-btn {
    background: var(--primary-color);
}

.tgl-ios:checked+.tgl-btn:active {
    box-shadow: none;
}

.tgl-ios:checked+.tgl-btn:active:after {
    margin-left: -.8em;
}

/* Number Input Styling */
input[type="number"] {
    width: 100%;
    padding: 0.6rem 0.8rem;
    border-radius: 8px;
    border: 1px solid #ccc;
    font-family: var(--font-family);
    font-size: 1rem;
    background: rgba(255, 255, 255, 0.8);
    margin-top: 0.5rem;
}

input[type="number"]:focus {
    border-color: var(--primary-color);
    outline: none;
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.1);
}

/* Footer */
footer {
    text-align: center;
    padding: 2rem;
    margin-top: 2rem;
    font-size: 0.95rem;
    background: rgba(255, 255, 255, 0.4);
    border-top: 1px solid rgba(255, 255, 255, 0.5);
    width: 100%;
}

.footer-line {
    margin-bottom: 0.4rem;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.blue-text {
    color: var(--primary-color);
    font-size: 1.1rem;
    /* Slightly larger for 'Developed By' */
}

.pink-text {
    color: var(--secondary-color);
}

.disclaimer {
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid rgba(0, 0, 0, 0.05);
    font-size: 0.85rem;
    color: #666;
    max-width: 800px;
    margin-left: auto;
    margin-right: auto;
    line-height: 1.4;
}

.disclaimer a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 600;
}

.disclaimer a:hover {
    text-decoration: underline;
}