html, body {
    font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
    overflow-x: hidden;
}

h1:focus {
    outline: none;
}

a, .btn-link {
    color: #0071c1;
}

.btn-primary {
    color: #fff;
    background-color: #1b6ec2;
    border-color: #1861ac;
}

.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus {
  box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem #258cfb;
}

.content {
    padding-top: 1.1rem;
}

.valid.modified:not([type=checkbox]) {
    outline: 1px solid #26b050;
}

.invalid {
    outline: 1px solid red;
}

.validation-message {
    color: red;
}

#blazor-error-ui {
    color-scheme: light only;
    background: lightyellow;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    box-sizing: border-box;
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

    #blazor-error-ui .dismiss {
        cursor: pointer;
        position: absolute;
        right: 0.75rem;
        top: 0.5rem;
    }

.blazor-error-boundary {
    background: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTYiIGhlaWdodD0iNDkiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIG92ZXJmbG93PSJoaWRkZW4iPjxkZWZzPjxjbGlwUGF0aCBpZD0iY2xpcDAiPjxyZWN0IHg9IjIzNSIgeT0iNTEiIHdpZHRoPSI1NiIgaGVpZ2h0PSI0OSIvPjwvY2xpcFBhdGg+PC9kZWZzPjxnIGNsaXAtcGF0aD0idXJsKCNjbGlwMCkiIHRyYW5zZm9ybT0idHJhbnNsYXRlKC0yMzUgLTUxKSI+PHBhdGggZD0iTTI2My41MDYgNTFDMjY0LjcxNyA1MSAyNjUuODEzIDUxLjQ4MzcgMjY2LjYwNiA1Mi4yNjU4TDI2Ny4wNTIgNTIuNzk4N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Ni4wNTQ3IDI2My41NzYgODYuMDU0N1oiIGZpbGw9IiNGRkU1MDAiIGZpbGwtcnVsZT0iZXZlbm9kZCIvPjwvZz48L3N2Zz4=) no-repeat 1rem/1.8rem, #b32121;
    padding: 1rem 1rem 1rem 3.7rem;
    color: white;
}

    .blazor-error-boundary::after {
        content: "An error has occurred."
    }

.loading-progress {
    position: absolute;
    display: block;
    width: 8rem;
    height: 8rem;
    inset: 20vh 0 auto 0;
    margin: 0 auto 0 auto;
}

    .loading-progress circle {
        fill: none;
        stroke: #e0e0e0;
        stroke-width: 0.6rem;
        transform-origin: 50% 50%;
        transform: rotate(-90deg);
    }

        .loading-progress circle:last-child {
            stroke: #1b6ec2;
            stroke-dasharray: calc(3.141 * var(--blazor-load-percentage, 0%) * 0.8), 500%;
            transition: stroke-dasharray 0.05s ease-in-out;
        }

.loading-progress-text {
    position: absolute;
    text-align: center;
    font-weight: bold;
    inset: calc(20vh + 3.25rem) 0 auto 0.2rem;
}

    .loading-progress-text:after {
        content: var(--blazor-load-percentage-text, "Loading");
    }

code {
    color: #c02d76;
}

.form-floating > .form-control-plaintext::placeholder, .form-floating > .form-control::placeholder {
    color: var(--bs-secondary-color);
    text-align: end;
}

.form-floating > .form-control-plaintext:focus::placeholder, .form-floating > .form-control:focus::placeholder {
    text-align: start;
}

/* Ported from MAUI app */
.maui-page {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 30px 20px;
    gap: 25px;
    max-width: 500px;
    margin: 0 auto;
    text-align: center;
}

.maui-page .app-icon {
    width: 185px;
    height: auto;
}

.maui-page h1 {
    font-size: 2rem;
    font-weight: bold;
    color: #512BD4;
}

.maui-page h2 {
    font-size: 1.25rem;
    color: #555;
}

.counter-btn {
    width: 100%;
    padding: 14px;
    font-size: 1rem;
    background-color: #512BD4;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.counter-btn:hover {
    background-color: #3e1fa3;
}

/* ===== Heat Simulation ===== */
body {
    background: #0f0f1a;
    color: #e0e8f0;
}

.sim-root {
    max-width: 860px;
    margin: 0 auto;
    padding: 20px 16px;
}

.sim-title {
    text-align: center;
    color: #a0c8f0;
    margin-bottom: 24px;
    font-size: 1.5rem;
    letter-spacing: 0.04em;
}

.sim-layout {
    display: flex;
    flex-direction: row;
    gap: 32px;
    align-items: flex-start;
    flex-wrap: nowrap;
    justify-content: center;
}

.scene-panel {
    flex-shrink: 0;
}

.controls-panel {
    flex-shrink: 0;
}

/* --- Scene --- */
.scene-panel {
    display: flex;
    flex-direction: column;
    align-items: center;
}

#moleculeCanvas {
    border-radius: 8px;
    background: #0a0a18;
    display: block;
}

/* --- Candle --- */
.candle-scene {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-top: -4px;
}

.flame-wrap {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    height: calc(60px * var(--fscale, 0.2));
    min-height: 12px;
}

.flame {
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    border-radius: 50% 50% 20% 20%;
    transform-origin: center bottom;
    animation: flicker 0.6s ease-in-out infinite alternate;
}

.flame-outer {
    width:  calc(22px * var(--fscale, 0.2));
    height: calc(55px * var(--fscale, 0.2));
    background: radial-gradient(ellipse at 50% 80%, #ff6a00, #ff3300 50%, transparent 90%);
    opacity: calc(var(--fopacity, 0.15) * 0.85);
    animation-duration: 0.7s;
}

.flame-mid {
    width:  calc(14px * var(--fscale, 0.2));
    height: calc(42px * var(--fscale, 0.2));
    background: radial-gradient(ellipse at 50% 80%, #ffcc00, #ff7700 60%, transparent 95%);
    opacity: var(--fopacity, 0.15);
    animation-duration: 0.5s;
}

.flame-inner {
    width:  calc(7px  * var(--fscale, 0.2));
    height: calc(25px * var(--fscale, 0.2));
    background: radial-gradient(ellipse at 50% 80%, #fff8e1, #ffe57a 70%);
    opacity: var(--fopacity, 0.15);
    animation-duration: 0.4s;
}

.flame-glow {
    position: absolute;
    bottom: -8px;
    left: 50%;
    transform: translateX(-50%);
    width:  calc(60px * var(--fscale, 0.2));
    height: calc(60px * var(--fscale, 0.2));
    border-radius: 50%;
    background: radial-gradient(circle, rgba(255,160,0,0.4), transparent 70%);
    pointer-events: none;
}

@keyframes flicker {
    0%   { transform: translateX(-50%) scaleX(1.00) scaleY(1.00) rotate(-1deg); }
    33%  { transform: translateX(-50%) scaleX(0.92) scaleY(1.04) rotate( 1deg); }
    66%  { transform: translateX(-50%) scaleX(1.05) scaleY(0.97) rotate(-2deg); }
    100% { transform: translateX(-50%) scaleX(0.96) scaleY(1.02) rotate( 1deg); }
}

.wick {
    width: 2px;
    height: 10px;
    background: #555;
    border-radius: 1px;
}

.candle-body {
    position: relative;
    width: 52px;
    height: 90px;
    background: linear-gradient(to right, #e8dcc8, #f5edd8 40%, #fff8ee 60%, #e0cebc);
    border-radius: 4px 4px 3px 3px;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0,0,0,0.5);
}

.candle-body::after {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 8px;
    background: linear-gradient(to bottom, rgba(0,0,0,0.15), transparent);
}

.candle-stripe {
    height: 22px;
    background: rgba(200, 170, 130, 0.25);
    border-bottom: 1px solid rgba(180,150,110,0.2);
}

/* --- Controls --- */
.controls-panel {
    display: flex;
    flex-direction: column;
    gap: 20px;
    min-width: 220px;
    padding-top: 8px;
}

.control-card {
    background: #161628;
    border: 1px solid #2a2a48;
    border-radius: 12px;
    padding: 18px 20px;
}

.control-label {
    font-size: 0.95rem;
    color: #a0b8d0;
    display: block;
    margin-bottom: 12px;
    font-weight: 600;
}

.slider-wrap {
    display: flex;
    align-items: center;
}

.intensity-slider {
    -webkit-appearance: none;
    appearance: none;
    writing-mode: vertical-lr;
    direction: rtl;
    width: 36px;
    height: 160px;
    background: transparent;
    margin: 0 auto;
}

.intensity-slider::-webkit-slider-runnable-track {
    width: 6px;
    background: linear-gradient(to top, #ff6a00, #ffcc00, #333);
    border-radius: 4px;
}

.intensity-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #fff;
    border: 2px solid #ff9900;
    cursor: pointer;
    margin-left: -7px;
}

.intensity-slider::-moz-range-track {
    width: 6px;
    background: linear-gradient(to top, #ff6a00, #ffcc00, #333);
    border-radius: 4px;
}

.intensity-slider::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #fff;
    border: 2px solid #ff9900;
    cursor: pointer;
}

.intensity-pct {
    text-align: center;
    font-size: 1rem;
    color: #ffcc66;
    margin-top: 8px;
    font-weight: bold;
}

/* Temperature card */
.temp-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.temp-label {
    font-size: 0.85rem;
    color: #8090a8;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.temp-value {
    font-size: 2.4rem;
    font-weight: 700;
    transition: color 0.4s;
}

.temp-bar-track {
    width: 18px;
    height: 120px;
    background: #0a0a18;
    border: 1px solid #2a2a48;
    border-radius: 9px;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    overflow: hidden;
}

.temp-bar-fill {
    width: 100%;
    border-radius: 9px;
    transition: height 0.4s ease, background 0.4s ease;
}

.temp-bar-labels {
    font-size: 0.7rem;
    color: #556;
    display: flex;
    flex-direction: column;
    gap: 2px;
    text-align: center;
}

/* Info card */
.info-card {
    font-size: 0.85rem;
}

.info-title {
    font-weight: 600;
    color: #8ab4d4;
    margin-bottom: 8px;
}

.info-text {
    color: #7080a0;
    line-height: 1.55;
}

/* ── Mobile responsive overrides ────────────────────────────── */
@media (max-width: 640px) {

    .sim-root {
        padding: 10px 8px;
    }

    .sim-title {
        font-size: 1.1rem;
        margin-bottom: 12px;
    }

    /* stack scene above controls */
    .sim-layout {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }

    /* scene-panel fills full width → canvas fills it via JS */
    .scene-panel {
        width: 100%;
        max-width: 320px;
        align-self: center;
    }

    #moleculeCanvas {
        display: block;
        width: 100% !important;
    }

    /* controls go horizontal on mobile */
    .controls-panel {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
        gap: 10px;
        min-width: unset;
        width: 100%;
        padding-top: 0;
    }

    .control-card {
        padding: 12px 14px;
        flex: 1 1 140px;
        min-width: 120px;
        max-width: 48%;
    }

    .control-label {
        font-size: 0.8rem;
        margin-bottom: 8px;
    }

    /* make vertical slider shorter */
    .intensity-slider {
        height: 100px;
        width: 28px;
    }

    .intensity-pct {
        font-size: 0.85rem;
    }

    /* temperature card compact */
    .temp-value {
        font-size: 1.6rem;
    }

    .temp-bar-track {
        height: 72px;
    }

    .temp-bar-labels {
        font-size: 0.6rem;
    }

    /* info card full width */
    .info-card {
        flex: 1 1 100%;
        max-width: 100%;
        font-size: 0.78rem;
    }
}

/* tablet: keep row but let canvas fill its container */
@media (min-width: 641px) and (max-width: 900px) {
    .sim-layout {
        gap: 16px;
    }

    .scene-panel {
        width: 45vw;
        max-width: 260px;
    }

    #moleculeCanvas {
        display: block;
        width: 100% !important;
    }

    .controls-panel {
        min-width: 180px;
    }

    .temp-value {
        font-size: 1.9rem;
    }

    .temp-bar-track {
        height: 90px;
    }

    .intensity-slider {
        height: 120px;
    }
}
