:root {
    --ink-0: #060a12;
    --ink-1: #0a0e18;
    --ink-2: #0f1624;
    --fog-0: rgba(255, 255, 255, 0.06);
    --fog-1: rgba(255, 255, 255, 0.12);
    --accent-1: #9ad9d9;
    --accent-2: #f6c57a;
    --ui-text: #e8e4db;
    --ui-muted: rgba(232, 228, 219, 0.6);
    --font-display: "Cormorant Garamond", "Times New Roman", serif;
    --font-ui: "Space Grotesk", "Helvetica Neue", sans-serif;
    --organic-ease: cubic-bezier(0.45, 0, 0.2, 1);
}

body,
html {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    background-color: var(--ink-0);
    color: var(--ui-text);
    font-family: var(--font-ui);
    overflow: hidden;
    letter-spacing: 0.02em;
}

#container {
    position: relative;
    width: 100%;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    isolation: isolate;
    background: var(--ink-0);
}

#introBackdrop {
    position: absolute;
    inset: 0;
    z-index: 1;
    pointer-events: none;
    background-color: var(--ink-0);
    background-image:
        radial-gradient(ellipse 72% 64% at 14% 16%, rgba(42, 142, 146, 0.22), transparent 66%),
        radial-gradient(ellipse 58% 52% at 84% 78%, rgba(190, 112, 52, 0.16), transparent 68%),
        radial-gradient(ellipse 46% 42% at 68% 18%, rgba(68, 88, 148, 0.11), transparent 72%),
        radial-gradient(ellipse 50% 44% at 48% 52%, rgba(26, 75, 91, 0.08), transparent 74%),
        linear-gradient(135deg, rgba(10, 24, 34, 0.42), transparent 42%, rgba(22, 10, 17, 0.2));
    opacity: 0;
    transition: opacity 1.8s var(--organic-ease);
    will-change: opacity;
}

body.intro-ready:not(.launching):not(.running) #introBackdrop {
    opacity: 1;
}

#introBackdrop::before {
    content: "";
    position: absolute;
    inset: 0;
    background-image:
        radial-gradient(rgba(255, 255, 255, 0.08) 1px, transparent 1px),
        radial-gradient(rgba(255, 255, 255, 0.04) 1px, transparent 1px);
    background-size: 3px 3px, 6px 6px;
    background-position: 0 0, 2px 2px;
    opacity: 0.12;
    mix-blend-mode: soft-light;
    pointer-events: none;
    z-index: 1;
}

#introBackdrop::after {
    content: "";
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at center, rgba(0, 0, 0, 0) 40%, rgba(0, 0, 0, 0.5) 70%, rgba(0, 0, 0, 0.9) 100%);
    pointer-events: none;
    z-index: 2;
}

canvas {
    position: absolute;
    top: 0;
    left: 0;
    z-index: 0;
}

#vizCanvas {
    opacity: 1;
}

body.launching #introBackdrop,
body.running #introBackdrop {
    opacity: 0;
}

#overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    pointer-events: none;
    z-index: 10;
    mix-blend-mode: screen;
    transition: opacity 0.3s ease;
}

body:not(.running) #overlay {
    opacity: 0;
}

#tokenDisplay {
    font-family: var(--font-display);
    font-size: clamp(2.8rem, 8vw, 7.8rem);
    font-weight: 300;
    letter-spacing: 0.06em;
    color: rgba(248, 245, 238, 0.95);
    margin: 0;
    text-shadow:
        0 0 40px rgba(155, 220, 220, 0.25),
        0 0 80px rgba(245, 198, 122, 0.2);
    min-height: 1em;
    transform-origin: center;
    will-change: opacity, transform, filter;
}

.subtitle {
    font-family: var(--font-ui);
    font-size: 0.7rem;
    color: var(--ui-muted);
    margin-top: 1.2rem;
    text-transform: uppercase;
    letter-spacing: 0.5em;
    font-weight: 500;
    transform-origin: center;
    will-change: opacity, transform, filter;
}

#controls {
    position: absolute;
    bottom: 36px;
    left: 50%;
    transform: translateX(-50%);
    width: min(372px, calc(100vw - 40px));
    box-sizing: border-box;
    background: rgba(255, 255, 255, 0.05);
    -webkit-backdrop-filter: blur(18px) saturate(112%);
    backdrop-filter: blur(18px) saturate(112%);
    padding: 11px 16px 11px 12px;
    border-radius: 999px;
    display: flex;
    align-items: center;
    gap: 8px;
    z-index: 20;
    isolation: isolate;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.16);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.35s ease, border-color 0.35s ease, box-shadow 0.35s ease;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.22);
}

#controls::before,
#inputPanel::before {
    content: none;
}

#controls::after,
#inputPanel::after {
    content: none;
}

#controls > *,
#inputPanel > * {
    position: relative;
    z-index: 1;
}

body.running.show-controls #controls {
    opacity: 1;
    pointer-events: auto;
}

#controls:hover {
    opacity: 1;
    border-color: rgba(255, 255, 255, 0.24);
    box-shadow: 0 18px 54px rgba(0, 0, 0, 0.26);
}

button {
    background: rgba(255, 255, 255, 0.055);
    -webkit-backdrop-filter: blur(12px) saturate(112%);
    backdrop-filter: blur(12px) saturate(112%);
    color: var(--ui-text);
    border: 1px solid rgba(255, 255, 255, 0.18);
    padding: 8px 16px;
    border-radius: 30px;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.2em;
    cursor: pointer;
    transition: transform 0.25s ease, background 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
    font-weight: 600;
    min-width: 90px;
    text-align: center;
    font-family: var(--font-ui);
    box-shadow: none;
}

button:hover {
    transform: translateY(-1px);
    background: rgba(255, 255, 255, 0.07);
    border-color: rgba(255, 255, 255, 0.3);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.14);
}

button:active {
    transform: translateY(0) scale(0.98);
}

button:focus-visible,
input[type=range]:focus-visible {
    outline: 2px solid rgba(255, 255, 255, 0.58);
    outline-offset: 3px;
}

.scrubberShell {
    --scrub-inset: 9px;
    position: relative;
    flex-grow: 1;
    min-width: 0;
    width: 200px;
    height: 24px;
}

.scrubberTrack {
    position: absolute;
    top: 50%;
    left: var(--scrub-inset);
    right: var(--scrub-inset);
    height: 6px;
    transform: translateY(-50%);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.12);
    box-shadow:
        inset 0 1px 2px rgba(0, 0, 0, 0.38),
        0 1px 0 rgba(255, 255, 255, 0.12);
    overflow: visible;
    pointer-events: none;
}

.scrubberFillViewport {
    position: absolute;
    inset: 0;
    border-radius: inherit;
    overflow: hidden;
    contain: strict;
}

.scrubberFillMotion,
.scrubberThumbMotion {
    position: absolute;
    left: 0;
    will-change: transform;
    transform: translate3d(0, 0, 0);
    backface-visibility: hidden;
}

.scrubberFillMotion {
    top: 0;
    bottom: 0;
    width: 100%;
    transform: translate3d(-100%, 0, 0);
}

.scrubberFill {
    position: absolute;
    inset: 0;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.62);
}

.scrubberThumbMotion {
    top: 50%;
}

.scrubberThumb {
    display: block;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.58);
    background: rgba(255, 255, 255, 0.34);
    box-sizing: border-box;
    box-shadow:
        inset 0 1px 1px rgba(255, 255, 255, 0.28),
        0 0 0 3px rgba(255, 255, 255, 0.06),
        0 3px 10px rgba(0, 0, 0, 0.24);
    transform: translate(-50%, -50%);
    transition: box-shadow 0.18s ease;
}

.scrubberShell:hover .scrubberThumb {
    box-shadow:
        inset 0 1px 1px rgba(255, 255, 255, 0.32),
        0 0 0 5px rgba(255, 255, 255, 0.07),
        0 4px 12px rgba(0, 0, 0, 0.26);
}

.scrubberShell:has(input[type=range]:focus-visible) {
    outline: 2px solid rgba(255, 255, 255, 0.58);
    outline-offset: 3px;
    border-radius: 4px;
}

input[type=range] {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    cursor: pointer;
    opacity: 0;
    -webkit-appearance: none;
    appearance: none;
}

input[type=range]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    height: 18px;
    width: 18px;
    cursor: pointer;
}

input[type=range]::-moz-range-thumb {
    height: 18px;
    width: 18px;
    border: 0;
}

#inputPanel {
    position: absolute;
    top: calc(50% - 28px);
    left: 50%;
    opacity: 0;
    pointer-events: none;
    transform: translate(-50%, -50%) scale(0.985);
    z-index: 25;
    width: min(575px, calc(100vw - 32px));
    box-sizing: border-box;
    padding: 0;
    transition: opacity 1.8s var(--organic-ease), transform 1.8s var(--organic-ease);
    will-change: opacity, transform;
}

body.intro-ready:not(.running):not(.launching) #inputPanel {
    opacity: 1;
    pointer-events: auto;
    transform: translate(-50%, -50%) scale(1);
}

body.launching #inputPanel,
body.running #inputPanel {
    opacity: 0;
    pointer-events: none;
    transform: translate(-50%, -50%) scale(1.01);
    transition-duration: 1.8s;
}

#textForm {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 0;
}

.intro {
    text-align: center;
    margin-bottom: 26px;
}

.introTitle {
    font-family: var(--font-display);
    font-size: clamp(2rem, 6vw, 3.6rem);
    font-weight: 300;
    letter-spacing: 0.08em;
    color: rgba(248, 245, 238, 0.9);
    animation: titleBreath 6s ease-in-out infinite;
}

@keyframes titleBreath {
    0% { opacity: 0.82; }
    50% { opacity: 1; }
    100% { opacity: 0.82; }
}

.panelLabel {
    font-size: 0.72rem;
    letter-spacing: 0.3em;
    text-transform: uppercase;
    color: var(--ui-muted);
}

.fieldLabel {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.2em;
    color: rgba(232, 228, 219, 0.65);
}

#textInput {
    flex: 1;
    min-width: 0;
    background: rgba(255, 255, 255, 0.055);
    -webkit-backdrop-filter: blur(12px) saturate(112%);
    backdrop-filter: blur(12px) saturate(112%);
    color: var(--ui-text);
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 30px;
    padding: 10px 18px;
    font-size: 0.78rem;
    font-family: var(--font-ui);
    font-weight: 500;
    letter-spacing: 0.04em;
    height: 44px;
    line-height: 44px;
    box-sizing: border-box;
    outline: none;
    box-shadow: none;
    transition: border-color 0.3s ease, box-shadow 0.3s ease, background 0.3s ease;
}

#textInput::placeholder {
    color: rgba(232, 228, 219, 0.45);
}

#textInput:focus {
    background: rgba(255, 255, 255, 0.075);
    border-color: rgba(255, 255, 255, 0.38);
    box-shadow: none;
}

.formRow {
    display: flex;
    align-items: center;
    gap: 12px;
}

#runBtn {
    height: 44px;
    line-height: 44px;
    padding: 0 18px;
    box-sizing: border-box;
}

@media (max-width: 720px) {
    #inputPanel {
        width: min(575px, calc(100vw - 36px));
    }

    #textForm {
        width: 100%;
    }

    #controls {
        bottom: 20px;
        padding: 10px 14px 10px 10px;
        gap: 8px;
    }
}
