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

body {
    font-family: "IBM Plex Sans", sans-serif;
    background-color: #f4f5f7;
    color: #1c1c1c;
    min-height: 100vh;
}

#sim-layout {
    display: grid;
    grid-template-columns: 320px 1fr;
    height: calc(100vh - 69px);
}

#sim-left {
    background-color: #fff;
    border-right: 1px solid #dde1e7;
    padding: 18px 16px 32px;
    overflow-y: auto;
}

#parameters {
    display: flex;
    flex-direction: column;
}

.section {
    padding: 14px 0;
    border-bottom: 1px solid #eaecef;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.section:last-of-type { border-bottom: none; }

.section-label {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: #aaa;
}

.slider-row {
    display: flex;
    align-items: center;
    gap: 10px;
    opacity: 0.55;
    transition: opacity 0.15s;
}

.slider-row.active { opacity: 1; }

.toggle {
    position: relative;
    display: inline-block;
    width: 28px;
    height: 16px;
    flex-shrink: 0;
    cursor: pointer;
}

.toggle input { opacity: 0; width: 0; height: 0; position: absolute; }

.toggle-track {
    position: absolute;
    inset: 0;
    background-color: #999;
    border-radius: 16px;
    transition: background-color 0.15s;
}

.toggle-track::after {
    content: "";
    position: absolute;
    top: 3px;
    left: 3px;
    width: 10px;
    height: 10px;
    background: #fff;
    border-radius: 50%;
    transition: transform 0.15s;
}

.toggle input:checked + .toggle-track { background-color: #0b5190; }
.toggle input:checked + .toggle-track::after { transform: translateX(12px); }

.slider-body { flex: 1; min-width: 0; }

.slider-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 5px;
}

.slider-name { font-size: 12px; font-weight: 400; color: #555; }

.slider-readout {
    font-family: "IBM Plex Mono", monospace;
    font-size: 11px;
    color: #0b5190;
    font-weight: 500;
}

.slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 4px;
    background: #aaa;
    border-radius: 4px;
    outline: none;
    cursor: pointer;
}

.slider:not(:disabled)::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 15px;
    height: 15px;
    border-radius: 50%;
    background-color: #0b5190;
    cursor: pointer;
    box-shadow: 0 0 0 3px rgba(11, 81, 144, 0.18);
}

.slider:not(:disabled)::-moz-range-thumb {
    width: 15px;
    height: 15px;
    border-radius: 50%;
    background-color: #0b5190;
    cursor: pointer;
    border: none;
    box-shadow: 0 0 0 3px rgba(11, 81, 144, 0.18);
}

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

.radio-row {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.radio-row label {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 12px;
    color: #555;
    cursor: pointer;
}

.radio-row input[type="radio"] { accent-color: #0b5190; cursor: pointer; }

.dropdown {
    width: 100%;
    padding: 6px 10px;
    border: 1px solid #dde1e7;
    border-radius: 3px;
    font-size: 12px;
    font-family: "IBM Plex Sans", sans-serif;
    color: #333;
    background-color: #fff;
    cursor: pointer;
    outline: none;
}

.dropdown:focus { border-color: #0b5190; }

#inference-wrap { margin-top: 8px; display: flex; flex-direction: column; gap: 20px; }

.dep-input-wrap { display: flex; align-items: center; gap: 4px; }

.dep-number-input {
    width: 64px;
    font-family: "IBM Plex Mono", monospace;
    font-size: 11px;
    font-weight: 500;
    color: #0b5190;
    border: none;
    border-bottom: 1px solid #0b5190;
    background: transparent;
    outline: none;
    padding: 0;
    text-align: right;
    -moz-appearance: textfield;
}
.dep-number-input::-webkit-inner-spin-button,
.dep-number-input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }

#dependent-unit {
    font-size: 11px;
    color: #666;
    font-family: "IBM Plex Mono", monospace;
}

#drag-preset-wrap, #drag-custom-wrap,
#density-preset-wrap, #density-custom-wrap,
#dependent-section {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

#submit-btn {
    margin-top: 16px;
    width: 100%;
    padding: 10px;
    background-color: #0b5190;
    color: #fff;
    border: none;
    border-radius: 3px;
    font-size: 13px;
    font-weight: 600;
    font-family: "IBM Plex Sans", sans-serif;
    cursor: pointer;
}

#submit-btn:hover    { background-color: #094477; }
#submit-btn:disabled { background-color: #5e8db5; cursor: not-allowed; }

#sim-right {
    padding: 20px 24px;
    overflow-y: auto;
    background-color: #f4f5f7;
}

#placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    min-height: 300px;
    color: #bbb;
    font-size: 13px;
}

#error-banner {
    background-color: #fef2f2;
    border: 1px solid #fca5a5;
    border-radius: 3px;
    padding: 10px 14px;
    color: #b91c1c;
    font-size: 12px;
    margin-bottom: 16px;
}

#results-content {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

#top-results {
    display: flex;
    gap: 14px;
    align-items: flex-start;
}

#top-results #stats-panel {
    flex: 2;
    min-width: 0;
}

#top-results #trajectory-section {
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
}

.section-label-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 4px;
}
.section-label-row .section-label {
    margin-bottom: 0;
}

#results-guide-link {
    padding: 10px 0 4px;
    text-align: right;
}
#results-guide-link a {
    font-size: 13px;
    color: #0b5190;
    text-decoration: none;
    font-weight: 500;
    opacity: 0.75;
    transition: opacity 0.15s;
}
#results-guide-link a:hover { opacity: 1; }

#stats-panel {
    background: #fff;
    border: 1px solid #dde1e7;
}

#trajectory-section {
    background: #fff;
    border: 1px solid #dde1e7;
}

#energy-section {
    display: grid;
    grid-template-columns: 2fr 3fr;
    gap: 14px;
    margin-top: 24px;
}

#energy-left {
    grid-column: 1 / -1;
    background: #fff;
    border: 1px solid #dde1e7;
}

#energy-right {
    grid-column: 1 / -1;
    background: #fff;
    border: 1px solid #dde1e7;
    display: flex;
    flex-direction: column;
    align-items: center;
}

#energy-right .panel-heading {
    width: 100%;
}

.panel-heading {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: #999;
    padding: 7px 12px;
    border-bottom: 1px solid #eaecef;
    background: #f9fafb;
}

.result-table + .panel-heading {
    border-top: 1px solid #eaecef;
}

#trajectory-section img {
    flex: 1;
    min-height: 0;
    width: auto;
    height: 100%;
    display: block;
}

#energy-right img {
    display: block;
    max-width: 60%;
    height: auto;
    margin: 0 auto;
}

.result-table { padding: 2px 0; }

.result-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding: 5px 12px;
    border-bottom: 1px solid #f4f5f7;
    gap: 10px;
}

.result-row:last-child { border-bottom: none; }

.result-label { font-size: 11px; color: #666; flex: 1; line-height: 1.4; }

.result-value {
    font-family: "IBM Plex Mono", monospace;
    font-size: 11px;
    color: #0b5190;
    font-weight: 500;
    text-align: right;
    word-break: break-word;
}

#clear-btn {
    margin-top: 10px;
    background-color: #fff;
    color: #333;
    border: 1px solid #aab0ba;
    border-radius: 3px;
    padding: 6px 14px;
    font-size: 12px;
    font-weight: 500;
    font-family: "IBM Plex Sans", sans-serif;
    cursor: pointer;
}

#clear-btn:hover { background-color: #f0f2f4; }

/* Intro modal */
#intro-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

#intro-modal {
    background: #fff;
    border-radius: 16px;
    padding: 32px;
    max-width: 520px;
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

#intro-title {
    font-size: 22px;
    font-weight: 700;
    color: #0b5190;
    margin: 0;
}

#intro-subtitle {
    font-size: 13px;
    color: #888;
    margin: -14px 0 0;
}

#intro-steps {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.intro-step {
    display: flex;
    gap: 14px;
    align-items: flex-start;
}

.intro-step-num {
    background: #0b5190;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-top: 1px;
}

.intro-step-text {
    font-size: 12px;
    color: #444;
    line-height: 1.6;
}

.intro-step-text strong {
    color: #1c1c1c;
}

#intro-close-btn {
    padding: 10px;
    background-color: #0b5190;
    color: #fff;
    border: none;
    border-radius: 3px;
    font-size: 13px;
    font-weight: 600;
    font-family: "IBM Plex Sans", sans-serif;
    cursor: pointer;
}
#intro-close-btn:hover { background-color: #094477; }

#intro-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

#intro-results-link {
    text-align: center;
    font-size: 12px;
    color: #0b5190;
    text-decoration: none;
    font-weight: 500;
}
#intro-results-link:hover { text-decoration: underline; }

#intro-skip-label {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 11px;
    color: #888;
    cursor: pointer;
    margin-top: -10px;
}
#intro-skip-label input { accent-color: #0b5190; cursor: pointer; }

.slider-readout { cursor: default; }

#drag-custom-wrap .slider + .slider-header,
#density-custom-wrap .slider + .slider-header { margin-top: 8px; }

.section-label-group {
    display: flex;
    align-items: center;
    gap: 6px;
}

.beta-tag {
    font-size: 8px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #fff;
    background: #0b5190;
    border-radius: 3px;
    padding: 1px 4px;
    vertical-align: middle;
    opacity: 0.75;
}

.info-tip {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #ccc;
    color: #fff;
    font-size: 9px;
    font-weight: 700;
    cursor: default;
    flex-shrink: 0;
}

.tip-box {
    display: none;
    position: absolute;
    right: -8px;
    top: 20px;
    width: 200px;
    background: #1c1c1c;
    color: #f0f0f0;
    font-size: 11px;
    font-weight: 400;
    text-transform: none;
    letter-spacing: 0;
    line-height: 1.6;
    padding: 10px 12px;
    border-radius: 4px;
    z-index: 100;
    pointer-events: none;
}

.info-tip:hover .tip-box,
.info-tip:focus .tip-box { display: block; }

.readout-edit {
    width: 70px;
    font-family: "IBM Plex Mono", monospace;
    font-size: 11px;
    font-weight: 500;
    color: #0b5190;
    border: none;
    border-bottom: 1px solid #0b5190;
    background: transparent;
    outline: none;
    padding: 0;
    text-align: right;
}
.readout-edit::-webkit-inner-spin-button,
.readout-edit::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.readout-edit { -moz-appearance: textfield; }

#classroom-section { border-top: 1px solid #eaecef; }

.classroom-input {
    width: 100%;
    padding: 6px 10px;
    border: 1px solid #dde1e7;
    border-radius: 3px;
    font-size: 12px;
    font-family: "IBM Plex Sans", sans-serif;
    color: #333;
    outline: none;
}
.classroom-input:focus { border-color: #0b5190; }

#generate-link-btn {
    width: 100%;
    padding: 8px;
    background-color: #f4f5f7;
    color: #0b5190;
    border: 1px solid #0b5190;
    border-radius: 3px;
    font-size: 12px;
    font-weight: 600;
    font-family: "IBM Plex Sans", sans-serif;
    cursor: pointer;
}
#generate-link-btn:hover { background-color: #e8eef5; }

#classroom-link-box {
    display: flex;
    gap: 6px;
    align-items: center;
}

.classroom-link-output {
    flex: 1;
    min-width: 0;
    padding: 6px 8px;
    border: 1px solid #dde1e7;
    border-radius: 3px;
    font-size: 11px;
    font-family: "IBM Plex Mono", monospace;
    color: #555;
    background: #f9fafb;
    outline: none;
}

#copy-link-btn {
    padding: 6px 10px;
    background-color: #0b5190;
    color: #fff;
    border: none;
    border-radius: 3px;
    font-size: 11px;
    font-weight: 600;
    font-family: "IBM Plex Sans", sans-serif;
    cursor: pointer;
    white-space: nowrap;
}
#copy-link-btn:hover { background-color: #094477; }

#classroom-banner {
    background-color: #e8eef5;
    border: 1px solid #b8cfe0;
    border-radius: 3px;
    padding: 8px 14px;
    font-size: 12px;
    font-weight: 600;
    color: #0b5190;
    margin-bottom: 16px;
}

@media (max-width: 900px) {
    #sim-layout {
        grid-template-columns: 1fr;
        height: auto;
    }

    #sim-left {
        border-right: none;
        border-bottom: 1px solid #dde1e7;
        overflow-y: visible;
    }

    #sim-right {
        padding: 16px;
        overflow-y: visible;
    }

    .result-label, .result-value { font-size: 13px; }
}