:root {
    --bg: #121418;
    --panel: #1c2330;
    --text: #e8ecf4;
    --muted: #9aa3b5;
    --accent: #3dd68c;
    --cold: #4a9eff;
    --hot: #ff6b35;
    --tray: rgba(255, 255, 255, 0.08);
    --border: rgba(255, 255, 255, 0.12);
    --layout-pad: clamp(0.5rem, 2vw, 0.75rem);
}

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

html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body {
    margin: 0;
    min-height: 100dvh;
    min-height: 100svh;
    max-width: 100%;
    overflow-x: clip;
    font-family: "Segoe UI", system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
    display: flex;
    flex-direction: column;
    padding-left: env(safe-area-inset-left, 0);
    padding-right: env(safe-area-inset-right, 0);
    padding-bottom: env(safe-area-inset-bottom, 0);
}

.site-header {
    position: relative;
    text-align: center;
    padding: max(0.75rem, env(safe-area-inset-top)) max(1rem, env(safe-area-inset-right)) 0.85rem
        max(1rem, env(safe-area-inset-left));
    border-bottom: 2px solid var(--accent);
    background: #0a0c10;
    flex-shrink: 0;
}

.site-header h1 {
    margin: 0;
    font-size: clamp(1.05rem, 2.5vw, 1.45rem);
    font-weight: 700;
    letter-spacing: 0.02em;
}

.tagline {
    margin: 0.35rem 0 0;
    font-size: 0.82rem;
    color: var(--muted);
    max-width: 52rem;
    margin-left: auto;
    margin-right: auto;
    line-height: 1.45;
}

.science-bite {
    margin: 0.45rem auto 0;
    max-width: 40rem;
    font-size: 0.78rem;
    color: #c5d0e8;
    line-height: 1.45;
}

.alpha-hint {
    margin: 0 0 0.85rem;
    padding: 0.5rem 0.65rem;
    border-radius: 8px;
    background: rgba(61, 214, 140, 0.08);
    border: 1px solid rgba(61, 214, 140, 0.2);
    font-size: 0.78rem;
    line-height: 1.45;
    color: var(--muted);
}

.alpha-char {
    font-weight: 600;
    color: var(--accent);
}

.panel-toggle-btn {
    display: none;
    position: absolute;
    right: max(10px, env(safe-area-inset-right));
    top: 50%;
    transform: translateY(-50%);
    padding: 0.5rem 0.75rem;
    min-height: 44px;
    min-width: 44px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--panel);
    color: var(--text);
    font-size: 0.8rem;
    cursor: pointer;
    touch-action: manipulation;
}

.layout {
    flex: 1;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, min(23.75rem, 100%));
    gap: var(--layout-pad);
    padding: var(--layout-pad);
    min-height: 0;
    width: 100%;
    max-width: 100%;
    align-items: start;
}

.simulation-area {
    position: relative;
    background: rgba(0, 0, 0, 0.25);
    border-radius: 12px;
    border: 1px solid var(--border);
    padding: clamp(0.65rem, 2.5vw, 0.9rem);
    display: flex;
    flex-direction: column;
    gap: clamp(0.5rem, 2vw, 0.75rem);
    min-height: 0;
    min-width: 0;
    width: 100%;
    max-width: 100%;
    overflow-x: clip;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    transition: box-shadow 0.4s ease, border-color 0.4s ease;
}

.simulation-area--nuclear-win {
    border-color: rgba(61, 214, 140, 0.55);
    box-shadow:
        0 0 0 1px rgba(61, 214, 140, 0.25),
        0 0 28px rgba(61, 214, 140, 0.22),
        0 0 48px rgba(241, 196, 15, 0.12);
    animation: nuclear-area-pulse 2.2s ease-in-out infinite;
}

@keyframes nuclear-area-pulse {
    0%,
    100% {
        box-shadow:
            0 0 0 1px rgba(61, 214, 140, 0.25),
            0 0 24px rgba(61, 214, 140, 0.18);
    }
    50% {
        box-shadow:
            0 0 0 1px rgba(61, 214, 140, 0.45),
            0 0 36px rgba(61, 214, 140, 0.32),
            0 0 52px rgba(241, 196, 15, 0.15);
    }
}

.overlay {
    position: absolute;
    inset: 0;
    z-index: 5;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: clamp(1rem, 4vw, 1.5rem);
    background: rgba(10, 12, 16, 0.92);
    border-radius: 12px;
    gap: 0.75rem;
    overflow: auto;
    overscroll-behavior: contain;
}

.overlay.hidden {
    display: none;
}

.gs-lock-overlay {
    position: fixed;
    inset: 0;
    z-index: 10000;
    border-radius: 0;
    max-height: none;
    background: rgba(8, 10, 14, 0.97);
    border: none;
    justify-content: center;
}

.gs-lock-overlay .hook {
    color: #f1c40f;
}

.gs-lock-icon {
    font-size: clamp(2rem, 8vw, 2.75rem);
    line-height: 1;
    margin-bottom: 0.25rem;
    filter: grayscale(0.15);
}

.gs-lock-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    margin-top: 0.5rem;
}

.hook {
    font-size: clamp(1rem, 3.5vw, 1.15rem);
    font-weight: 600;
    color: var(--accent);
    max-width: 28rem;
    margin: 0;
}

.overlay p {
    max-width: 36rem;
    margin: 0;
    color: var(--muted);
    font-size: clamp(0.85rem, 2.8vw, 0.92rem);
    line-height: 1.55;
}

.btn-primary,
.btn-secondary {
    font: inherit;
    cursor: pointer;
    border-radius: 10px;
    padding: 0.55rem 1.2rem;
    min-height: 44px;
    border: none;
    margin-top: 0.35rem;
    touch-action: manipulation;
}

.btn-primary {
    background: linear-gradient(135deg, #2ecc71, #27ae60);
    color: #fff;
    font-weight: 600;
}

.btn-secondary {
    background: var(--panel);
    color: var(--text);
    border: 1px solid var(--border);
    padding: 0.45rem 0.75rem;
    font-size: 0.85rem;
    margin-top: 0;
}

.column-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: clamp(4px, 1.2vw, 8px);
    flex: 1 1 auto;
    width: 100%;
    min-width: 0;
    min-height: min(280px, 45dvh);
}

.reflux-bridge {
    width: min(100%, 14rem);
    max-width: 100%;
    height: clamp(2.5rem, 8vw, 2.75rem);
    position: relative;
    margin: 2px 0;
    flex-shrink: 0;
}

.reflux-svg {
    display: block;
    width: 100%;
    height: 100%;
}

.reflux-path {
    opacity: 0.35;
    transition: opacity 0.25s ease;
}

.reflux-bridge--live .reflux-path {
    animation: reflux-dash 1.05s linear infinite;
}

@keyframes reflux-dash {
    to {
        stroke-dashoffset: -24;
    }
}

.reflux-caption {
    display: block;
    text-align: center;
    font-size: 0.65rem;
    color: var(--muted);
    margin-top: 2px;
    line-height: 1.3;
}

.reflux-bridge--obvious .reflux-path {
    stroke-width: 3.4;
    filter: drop-shadow(0 0 5px rgba(184, 220, 255, 0.55));
}

.reflux-drip-column {
    width: min(4.5rem, 100%);
    min-height: 3.5rem;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    margin: 2px 0 0;
    opacity: 0.35;
    transition: opacity 0.35s ease;
}

.reflux-drip-column--live {
    opacity: 1;
}

.reflux-drip-track {
    position: absolute;
    left: 50%;
    top: 4px;
    bottom: 22px;
    width: 5px;
    transform: translateX(-50%);
    border-radius: 3px;
    background: linear-gradient(
        180deg,
        rgba(200, 230, 255, 0.55) 0%,
        rgba(140, 180, 220, 0.25) 45%,
        rgba(241, 196, 15, 0.35) 100%
    );
    box-shadow: 0 0 10px rgba(120, 190, 255, 0.25);
}

.reflux-droplets {
    position: absolute;
    left: 50%;
    top: 0;
    bottom: 24px;
    width: 14px;
    transform: translateX(-50%);
    pointer-events: none;
}

.reflux-droplet {
    position: absolute;
    left: 50%;
    width: 7px;
    height: 9px;
    margin-left: -3.5px;
    border-radius: 50% 50% 55% 55%;
    background: radial-gradient(circle at 32% 28%, rgba(255, 255, 255, 0.95), rgba(160, 210, 255, 0.75) 45%, rgba(230, 200, 90, 0.85));
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
    opacity: 0;
    animation: none;
}

.reflux-drip-column--live .reflux-droplet {
    animation: reflux-drip-fall var(--drip-period, 1.15s) cubic-bezier(0.33, 0, 0.66, 0.5) infinite;
}

.reflux-droplet:nth-child(1) {
    animation-delay: 0s;
}
.reflux-droplet:nth-child(2) {
    animation-delay: 0.18s;
}
.reflux-droplet:nth-child(3) {
    animation-delay: 0.36s;
}
.reflux-droplet:nth-child(4) {
    animation-delay: 0.54s;
}
.reflux-droplet:nth-child(5) {
    animation-delay: 0.72s;
}
.reflux-droplet:nth-child(6) {
    animation-delay: 0.9s;
}

@keyframes reflux-drip-fall {
    0% {
        top: 0;
        opacity: 0;
        transform: scale(0.65);
    }
    12% {
        opacity: 1;
    }
    88% {
        opacity: 0.95;
    }
    100% {
        top: calc(100% - 6px);
        opacity: 0;
        transform: scale(1);
    }
}

.reflux-drip-cta {
    position: relative;
    z-index: 1;
    margin-top: auto;
    padding-top: 6px;
    font-size: 0.62rem;
    font-weight: 600;
    text-align: center;
    color: #b8dcff;
    text-shadow: 0 0 8px rgba(74, 158, 255, 0.35);
    line-height: 1.25;
    max-width: 7.5rem;
}

.reflux-drip-column:not(.reflux-drip-column--live) .reflux-drip-cta {
    color: var(--muted);
    font-weight: 500;
    text-shadow: none;
}

.condenser,
.reboiler {
    width: min(100%, 17.5rem);
    max-width: 100%;
    padding: clamp(6px, 2vw, 10px) clamp(8px, 2.5vw, 12px);
    border-radius: 10px;
    border: 1px solid var(--border);
    text-align: center;
    position: relative;
    flex-shrink: 0;
}

.condenser {
    background: linear-gradient(180deg, rgba(74, 158, 255, 0.2), rgba(74, 158, 255, 0.05));
}

.reboiler {
    background: linear-gradient(180deg, rgba(255, 107, 53, 0.08), rgba(255, 107, 53, 0.22));
}

.unit-label {
    display: block;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--muted);
}

.flow {
    font-size: 0.78rem;
    color: var(--cold);
}

.product {
    margin-top: 6px;
    font-size: 0.8rem;
}

.product strong {
    display: block;
    font-size: clamp(0.95rem, 3.2vw, 1.15rem);
    margin-top: 4px;
    color: var(--text);
    word-break: break-word;
}

.product small {
    color: var(--muted);
    font-size: 0.72rem;
}

.temp-badge {
    display: inline-block;
    margin-top: 6px;
    padding: 2px 8px;
    border-radius: 999px;
    background: rgba(255, 107, 53, 0.25);
    font-size: 0.8rem;
    font-variant-numeric: tabular-nums;
}

.column-shell {
    position: relative;
    width: min(100%, 14rem);
    margin-inline: auto;
    flex: 1 1 auto;
    min-height: clamp(10rem, 28dvh, 16rem);
    height: clamp(12rem, 38dvh, 26rem);
    max-height: min(56dvh, 26rem);
    border-radius: 14px;
    border: 2px solid var(--border);
    overflow: hidden;
}

.flow-particles {
    position: absolute;
    inset: 0;
    z-index: 2;
    pointer-events: none;
    width: 100%;
    height: 100%;
}

.column-gradient {
    position: absolute;
    inset: 0;
    background: linear-gradient(
        180deg,
        rgba(74, 158, 255, 0.35) 0%,
        rgba(120, 140, 180, 0.12) 45%,
        rgba(255, 107, 53, 0.4) 100%
    );
    pointer-events: none;
}

.trays {
    position: absolute;
    inset: 8px 14px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 2px;
    z-index: 3;
}

.tray-row {
    flex: 1;
    min-height: 4px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.tray-plate {
    flex: 1;
    height: 3px;
    border-radius: 2px;
    background: var(--tray);
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.06);
    transition: background 0.2s, box-shadow 0.2s;
    cursor: help;
}

.tray-plate--rich {
    background: rgba(241, 196, 15, 0.45);
    box-shadow: 0 0 8px rgba(241, 196, 15, 0.25);
}

.tray-label {
    font-size: 0.58rem;
    color: var(--muted);
    width: 1.5rem;
    text-align: right;
    font-variant-numeric: tabular-nums;
    opacity: 0.85;
}

.flow-legend {
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 0.58rem;
    z-index: 4;
    color: var(--muted);
    max-width: 5.2rem;
    line-height: 1.25;
}

.flow-legend sub {
    font-size: 0.85em;
}

.product .dist-sub {
    display: block;
    font-size: 0.72rem;
    font-weight: 400;
    color: var(--muted);
    margin-top: 0.25rem;
    line-height: 1.35;
}

.flow-legend__item--up {
    color: var(--cold);
}

.flow-legend__item--down {
    color: #c9d4e8;
}

.readouts {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 7.5rem), 1fr));
    gap: 8px;
    width: 100%;
    min-width: 0;
}

.readout {
    background: rgba(0, 0, 0, 0.35);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 8px 10px;
    text-align: center;
}

.readout__label {
    display: block;
    font-size: 0.68rem;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.readout__value {
    font-size: 1rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.readout--tip {
    cursor: help;
}

.process-banner {
    min-height: 2.5rem;
    padding: 0.55rem 0.75rem;
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.35);
    border: 1px solid rgba(61, 214, 140, 0.2);
    font-size: 0.84rem;
    line-height: 1.45;
    color: #c5d8e8;
    transition: opacity 0.25s ease, border-color 0.25s ease;
}

.process-banner--hidden {
    display: none;
}

.nuclear-milestone {
    position: relative;
    text-align: center;
    padding: 0.75rem 1rem;
    border-radius: 12px;
    background: linear-gradient(135deg, rgba(61, 214, 140, 0.18), rgba(241, 196, 15, 0.12));
    border: 1px solid rgba(61, 214, 140, 0.45);
    overflow: hidden;
    animation: nuclear-banner-in 0.55s ease-out;
}

.nuclear-milestone[hidden] {
    display: none;
}

.nuclear-milestone__glow {
    position: absolute;
    inset: -40%;
    background: radial-gradient(circle, rgba(61, 214, 140, 0.25) 0%, transparent 65%);
    animation: nuclear-glow-spin 4s linear infinite;
    pointer-events: none;
}

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

@keyframes nuclear-banner-in {
    from {
        opacity: 0;
        transform: scale(0.96);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.nuclear-milestone__title {
    position: relative;
    margin: 0;
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--accent);
    text-shadow: 0 0 14px rgba(61, 214, 140, 0.45);
}

.nuclear-milestone__sub {
    position: relative;
    margin: 0.35rem 0 0;
    font-size: 0.78rem;
    color: var(--muted);
}

.preset-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 0.85rem;
}

.preset-btn {
    flex: 1;
    min-width: min(5.5rem, 100%);
    min-height: 44px;
    padding: 0.45rem 0.5rem;
    border-radius: 10px;
    border: 1px solid var(--border);
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    color: var(--text);
    background: rgba(0, 0, 0, 0.25);
    transition: transform 0.12s ease, box-shadow 0.2s ease;
}

.preset-btn:hover {
    transform: translateY(-1px);
}

.preset-btn--rapid {
    border-color: rgba(46, 204, 113, 0.45);
    background: rgba(46, 204, 113, 0.12);
}

.preset-btn--balanced {
    border-color: rgba(241, 196, 15, 0.45);
    background: rgba(241, 196, 15, 0.1);
}

.preset-btn--industrial {
    border-color: rgba(231, 76, 60, 0.5);
    background: rgba(231, 76, 60, 0.12);
}

.temp-warning {
    margin: 0.35rem 0 0;
    font-size: 0.76rem;
    line-height: 1.4;
    color: #f1c40f;
}

.temp-warning--hidden {
    display: none;
}

.info-box__extra {
    display: block;
    margin-top: 0.65rem;
    padding-top: 0.65rem;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.controls-panel {
    background: var(--panel);
    border-radius: 12px;
    border: 1px solid var(--border);
    padding: clamp(0.65rem, 2vw, 14px);
    overflow: auto;
    max-height: min(calc(100dvh - 5.5rem), 58rem);
    position: relative;
    min-width: 0;
    width: 100%;
    -webkit-overflow-scrolling: touch;
}

.panel-close-btn {
    display: none;
    position: absolute;
    top: 8px;
    right: 10px;
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.08);
    color: var(--text);
    font-size: 1.4rem;
    line-height: 1;
    cursor: pointer;
}

.panel-section {
    margin-bottom: 1rem;
}

.panel-heading {
    margin: 0 0 0.65rem;
    font-size: 0.95rem;
    font-weight: 600;
}

.panel-note {
    margin: 0 0 0.5rem;
    font-size: 0.78rem;
    color: var(--muted);
    line-height: 1.4;
}

.control-group {
    margin-bottom: 0.85rem;
}

.control-group label {
    display: block;
    font-size: clamp(0.76rem, 2.4vw, 0.82rem);
    margin-bottom: 0.35rem;
    color: var(--muted);
    word-wrap: break-word;
    hyphens: auto;
}

.control-group input[type="range"] {
    width: 100%;
    accent-color: var(--accent);
}

.chart-wrap {
    width: 100%;
    max-width: 100%;
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid var(--border);
    background: #0e1118;
}

#purityChart {
    display: block;
    width: 100%;
    height: auto;
}

.chart-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}

.info-box {
    font-size: 0.78rem;
    line-height: 1.5;
    color: var(--muted);
    border-top: 1px solid var(--border);
    padding-top: 12px;
    margin-top: 8px;
}

.panel-backdrop {
    display: none;
}

/* Îngust (zoom mare, tabletă): o coloană, panou în flux — fără sertar */
@media (max-width: 1100px) {
    .layout {
        grid-template-columns: 1fr;
    }

    .controls-panel {
        position: relative;
        right: auto;
        top: auto;
        bottom: auto;
        width: 100%;
        max-width: 100%;
        max-height: none;
        transform: none;
        border-radius: 12px;
    }

    .controls-panel.is-open {
        transform: none;
    }

    .panel-toggle-btn,
    .panel-close-btn {
        display: none;
    }

    .panel-backdrop {
        display: none !important;
    }
}

/* Telefon îngust: sertar parametri ca să nu împingă tot conținutul */
@media (max-width: 720px) {
    .site-header {
        padding-right: max(4.5rem, env(safe-area-inset-right));
    }

    .panel-toggle-btn {
        display: block;
    }

    .panel-close-btn {
        display: block;
    }

    .controls-panel {
        position: fixed;
        right: 0;
        top: 0;
        bottom: 0;
        width: min(22rem, calc(100vw - env(safe-area-inset-left, 0px) - env(safe-area-inset-right, 0px)));
        max-width: 100%;
        max-height: none;
        z-index: 200;
        transform: translateX(100%);
        transition: transform 0.25s ease;
        border-radius: 0;
        padding-top: max(14px, env(safe-area-inset-top));
    }

    .controls-panel.is-open {
        transform: translateX(0);
    }

    .panel-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 199;
    }

    .panel-backdrop[hidden] {
        display: none;
    }
}

@media (max-width: 26rem) {
    .flow-legend {
        right: 2px;
        max-width: 3.75rem;
        font-size: 0.5rem;
        gap: 4px;
    }

    .reflux-drip-cta {
        font-size: 0.55rem;
        max-width: 6.5rem;
    }

    .tagline,
    .science-bite {
        padding-inline: 0.35rem;
    }
}
