:root {
    --bg-base: #0f172a;
    /* Slate 900 */
    --bg-panel: rgba(30, 41, 59, 0.85);
    /* Slate 800 glass */
    --border-light: rgba(255, 255, 255, 0.1);

    --primary: #6366f1;
    /* Indigo */
    --primary-hover: #4f46e5;

    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --text-dark: #0f172a;

    --danger: #ef4444;

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

    --radius-sm: 6px;
    --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;
    height: 100vh;
    width: 100vw;
    overflow: hidden;
}

/* App Container */
.app-container {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* 
 * The large visual background. 
 * Using absolute positioning to sit behind the glass panel.
 */
.gradient-preview {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    transition: background 0.1s;
}

/* Floating Controls */
.control-panel {
    position: relative;
    z-index: 10;
    width: 100%;
    max-width: 480px;
    padding: 2rem;
    border-radius: var(--radius-lg);
    /* Extra spacing off bottom on mobile if necessary */
    margin: 1rem;
}

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

.header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 2rem;
}

.logo {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.1), transparent);
    border: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    justify-content: center;
}

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

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

/* Control Layouts */
.controls {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.control-row {
    display: flex;
    gap: 1rem;
}

.two-col>* {
    flex: 1;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.row-align {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

label {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-muted);
    display: flex;
    justify-content: space-between;
}

.hint {
    font-size: 0.75rem;
    color: rgba(148, 163, 184, 0.6);
    font-weight: 400;
}

.input {
    width: 100%;
    background: rgba(0, 0, 0, 0.4);
    color: #FFF;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    padding: 0.6rem;
    font-family: var(--font-ui);
    font-size: 0.9rem;
    outline: none;
    appearance: none;
    transition: border-color 0.2s;
}

.input:focus {
    border-color: var(--primary);
}

.slider {
    -webkit-appearance: none;
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: rgba(255, 255, 255, 0.1);
    outline: none;
    margin-top: 0.5rem;
}

.slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #FFF;
    cursor: pointer;
    border: 2px solid var(--primary);
}

.divider {
    border: none;
    border-top: 1px solid var(--border-light);
}

.flex-between {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 0.75rem;
}

/* Color track - Complex styling for handles */
.color-track-section {
    display: flex;
    flex-direction: column;
}

.slider-wrapper {
    position: relative;
    width: 100%;
    height: 32px;
    border-radius: var(--radius-sm);
    margin: 0.5rem 0;
    /* padding logic applied to handles to allow edge grabbing */
}

/* Background checkerboard */
.slider-checker {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: var(--radius-sm);
    z-index: 1;
    background-image:
        linear-gradient(45deg, #333 25%, transparent 25%),
        linear-gradient(-45deg, #333 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #333 75%),
        linear-gradient(-45deg, transparent 75%, #333 75%);
    background-size: 10px 10px;
    background-position: 0 0, 0 5px, 5px -5px, -5px 0px;
}

.slider-track {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: var(--radius-sm);
    z-index: 2;
    border: 1px solid var(--border-light);
}

/* Interaction container preventing boundary cutoffs */
.slider-handles {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 3;
    cursor: copy;
    /* clicking adds a stop */
}

.stop-handle {
    position: absolute;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 20px;
    height: 26px;
    background: #FFF;
    border-radius: 4px;
    border: 2px solid #FFF;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.4);
    cursor: grab;
    z-index: 10;
}

.stop-handle.active {
    z-index: 11;
    border-color: var(--primary);
    transform: translate(-50%, -50%) scale(1.1);
}

.stop-handle:active {
    cursor: grabbing;
}

/* The visible color chunk inside the handle */
.stop-color-view {
    width: 100%;
    height: 100%;
    border-radius: 2px;
    border: 1px solid rgba(0, 0, 0, 0.1);
}


/* Active Stop Detail panel */
.active-stop-panel {
    background: rgba(0, 0, 0, 0.2);
    border-radius: var(--radius-sm);
    padding: 1rem;
    display: flex;
    gap: 1rem;
    align-items: center;
    border: 1px solid var(--border-light);
}

/* Custom Native Color Picker wrapped */
.color-picker-wrapper {
    width: 40px;
    height: 32px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    border: 1px solid var(--border-light);
    cursor: pointer;
}

.color-picker-wrapper input[type="color"] {
    width: 150%;
    height: 150%;
    transform: translate(-25%, -25%);
    border: none;
    padding: 0;
    cursor: pointer;
}

.position-control {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.position-control input {
    width: 60px;
    background: rgba(0, 0, 0, 0.4);
    color: #FFF;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    padding: 0.4rem;
    text-align: center;
    font-family: var(--font-mono);
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    justify-content: center;
    padding: 0.6rem 1rem;
    border-radius: var(--radius-sm);
    font-family: var(--font-ui);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
}

.btn-sm {
    padding: 0.3rem 0.6rem;
    font-size: 0.75rem;
}

.btn-text {
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border-light);
}

.btn-text:hover {
    color: #FFF;
    background: rgba(255, 255, 255, 0.1);
}

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

.btn-icon:hover {
    color: var(--danger);
    background: rgba(239, 68, 68, 0.1);
}

.code-box {
    background: #000;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    padding: 1rem;
    font-family: var(--font-mono);
    font-size: 0.85rem;
    color: #a5b4fc;
    word-break: break-all;
}

/* Toast */
.toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    background: #FFF;
    color: var(--text-dark);
    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;
    z-index: 100;
    opacity: 0;
    pointer-events: none;
}

.toast.visible {
    opacity: 1;
    pointer-events: auto;
}

.hidden {
    display: none !important;
}

@media (max-width: 600px) {
    .control-panel {
        padding: 1.5rem;
        margin: 0.5rem;
    }

    .two-col {
        flex-direction: column;
    }
}