:root {
    --bg-base: #020617;
    /* Very Dark Blue */
    --bg-glass: rgba(15, 23, 42, 0.6);
    --border-glass: rgba(56, 189, 248, 0.2);

    --primary: #0ea5e9;
    /* Light Blue */
    --primary-hover: #0284c7;

    --accent: #f43f5e;
    /* Rose */

    --text-main: #f8fafc;
    --text-muted: #94a3b8;

    --blueprint-grid: rgba(56, 189, 248, 0.1);
    --blueprint-line: rgba(56, 189, 248, 0.4);

    --font-ui: 'Inter', system-ui, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;

    --radius-md: 12px;
    --radius-lg: 20px;
}

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

body {
    background-color: var(--bg-base);
    color: var(--text-main);
    font-family: var(--font-ui);
    line-height: 1.5;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    position: relative;
    overflow: hidden;
}

.bg-pulse {
    position: absolute;
    top: -20%;
    left: -10%;
    right: -10%;
    bottom: -20%;
    background: radial-gradient(circle at 30% 30%, rgba(14, 165, 233, 0.1), transparent 40%),
        radial-gradient(circle at 70% 70%, rgba(244, 63, 94, 0.05), transparent 40%);
    z-index: -1;
    filter: blur(60px);
}

.glass {
    background: var(--bg-glass);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid var(--border-glass);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

.header {
    border-radius: var(--radius-md);
    padding: 1.25rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.brand {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.logo {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-md);
    background: linear-gradient(135deg, var(--primary), #3b82f6);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #FFF;
    box-shadow: 0 4px 15px rgba(14, 165, 233, 0.4);
}

.header h1 {
    font-size: 1.25rem;
    font-weight: 600;
    letter-spacing: -0.02em;
}

.subtitle {
    color: var(--text-muted);
    font-size: 0.85rem;
}

.header-actions {
    display: flex;
    gap: 0.5rem;
}

.app-wrapper {
    width: 100%;
    max-width: 1400px;
    height: 90vh;
    display: flex;
    flex-direction: column;
}

.main-layout {
    display: grid;
    grid-template-columns: 1fr 400px;
    gap: 2rem;
    flex: 1;
    min-height: 0;
}

/* Editor Pane (Blueprint style) */
.editor-pane {
    border-radius: var(--radius-lg);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    /* Static blueprint grid fallback if SVG doesn't fill immediately */
    background-image:
        linear-gradient(var(--blueprint-grid) 1px, transparent 1px),
        linear-gradient(90deg, var(--blueprint-grid) 1px, transparent 1px);
    background-size: 20px 20px;
    background-color: var(--bg-glass);
}

.editor-header {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    padding: 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 10;
    background: linear-gradient(to bottom, rgba(2, 6, 23, 0.8), transparent);
    pointer-events: none;
    /* Let clicks pass to SVG, but keep the UI text clickable below */
}

.editor-header h2 {
    font-size: 1.1rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--primary);
    pointer-events: auto;
}

.code-output {
    background: rgba(0, 0, 0, 0.6);
    border: 1px solid var(--border-glass);
    padding: 0.75rem 1.25rem;
    border-radius: 30px;
    font-family: var(--font-mono);
    font-size: 0.95rem;
    color: var(--accent);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
    transition: all 0.2s;
    pointer-events: auto;
}

.code-output:hover {
    background: rgba(0, 0, 0, 0.8);
    border-color: var(--primary);
}

.svg-wrapper {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    touch-action: none;
    overflow: hidden;
}

.svg-wrapper svg {
    width: 100%;
    height: 100%;
    cursor: crosshair;
}

/* SVG Graph Elements Styles via CSS (Not directly in SVG) */
.svg-line-base {
    stroke: var(--blueprint-line);
    stroke-width: 2;
    fill: none;
}

.svg-line-curve {
    stroke: #FFF;
    stroke-width: 4;
    fill: none;
    stroke-linecap: round;
}

.svg-handle-line {
    stroke: var(--primary);
    stroke-width: 2;
    stroke-dasharray: 4;
}

.svg-handle-line-2 {
    stroke: var(--accent);
    stroke-width: 2;
    stroke-dasharray: 4;
}

.svg-point-static {
    fill: var(--text-muted);
    r: 6;
}

.svg-point-p1 {
    fill: var(--primary);
    r: 10;
    cursor: grab;
    stroke: #FFF;
    stroke-width: 2;
    transition: r 0.1s;
}

.svg-point-p2 {
    fill: var(--accent);
    r: 10;
    cursor: grab;
    stroke: #FFF;
    stroke-width: 2;
    transition: r 0.1s;
}

.svg-point-p1:hover,
.svg-point-p2:hover {
    r: 14;
}

.svg-point-p1.dragging,
.svg-point-p2.dragging {
    cursor: grabbing;
    r: 14;
}

/* Controls Pane */
.controls-pane {
    display: grid;
    grid-template-rows: auto 1fr;
    gap: 2rem;
    overflow-y: auto;
    padding-right: 0.5rem;
}

.controls-pane::-webkit-scrollbar {
    width: 4px;
}

.controls-pane::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
}

.preview-panel,
.settings-panel {
    padding: 1.5rem;
    border-radius: var(--radius-lg);
}

.preview-panel h2,
.settings-panel h2 {
    font-size: 1.1rem;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid var(--border-glass);
    padding-bottom: 0.75rem;
}

/* Animators */
.anim-track {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-md);
    padding: 1rem;
    margin-bottom: 1rem;
    position: relative;
    overflow: hidden;
}

.track-label {
    position: absolute;
    top: 0.5rem;
    left: 0.5rem;
    font-size: 0.7rem;
    font-family: var(--font-mono);
    color: var(--text-muted);
}

.anim-box {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    margin-top: 1rem;
    /* CSS Variables overwritten by JS */
    --duration: 600ms;
    --ease: linear;
}

.linear-box {
    background: var(--text-muted);
}

.custom-box {
    background: linear-gradient(135deg, var(--accent), var(--primary));
    box-shadow: 0 4px 15px rgba(244, 63, 94, 0.4);
}

/* Applying the animation */
.playing .anim-box {
    animation-name: defaultAnim;
    animation-duration: var(--duration);
    animation-timing-function: var(--ease);
    animation-fill-mode: forwards;
}

@keyframes defaultAnim {
    0% {
        transform: translateX(0);
    }

    100% {
        transform: translateX(calc(100cqw - 40px - 2rem));
    }
}

@keyframes scaleAnim {
    0% {
        transform: scale(1);
    }

    100% {
        transform: scale(2.5);
    }
}

@keyframes rotateAnim {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

@keyframes opacityAnim {
    0% {
        opacity: 0;
    }

    100% {
        opacity: 1;
    }
}

/* Params */
.param-row {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1.25rem;
}

.param-row label {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-muted);
}

.float-right {
    float: right;
}

.input {
    width: 100%;
    background: rgba(0, 0, 0, 0.4);
    color: #FFF;
    border: 1px solid var(--border-glass);
    border-radius: 8px;
    padding: 0.75rem;
    font-family: var(--font-ui);
    font-size: 0.9rem;
    outline: none;
}

/* Slider Custom */
.slider {
    -webkit-appearance: none;
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: rgba(255, 255, 255, 0.1);
    outline: none;
}

.slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
    transition: transform 0.1s;
}

.slider::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

.divider {
    border: none;
    border-top: 1px solid var(--border-glass);
    margin: 2rem 0;
}

.preset-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
}

.btn-preset {
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid var(--border-glass);
    color: var(--text-muted);
    border-radius: 6px;
    padding: 0.5rem;
    font-size: 0.8rem;
    font-family: var(--font-mono);
    text-align: left;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-preset:hover,
.btn-preset.active {
    background: rgba(14, 165, 233, 0.15);
    color: #FFF;
    border-color: var(--primary);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-family: var(--font-ui);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
}

.w-full {
    width: 100%;
}

.mt-4 {
    margin-top: 1rem;
}

.btn-primary {
    background: var(--primary);
    color: #FFF;
    box-shadow: 0 4px 12px rgba(14, 165, 233, 0.3);
}

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
}

.btn-outline {
    background: transparent;
    color: var(--text-main);
    border: 1px solid var(--border-glass);
}

.btn-outline:hover {
    background: rgba(255, 255, 255, 0.05);
}

.btn-icon {
    background: transparent;
    color: var(--text-muted);
    padding: 0.5rem;
    border-radius: 8px;
}

.btn-icon:hover {
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.05);
}

/* Toast */
.toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    background: #FFF;
    color: var(--bg-base);
    padding: 0.75rem 2rem;
    border-radius: 30px;
    font-weight: 600;
    font-size: 0.9rem;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4);
    transition: opacity 0.3s, transform 0.3s;
    z-index: 100;
}

.hidden {
    display: none !important;
    opacity: 0;
    pointer-events: none;
}

@media (max-width: 900px) {
    .main-layout {
        grid-template-columns: 1fr;
        grid-template-rows: 60vh auto;
    }
}