:root {
    /* Premium Dark Theme */
    --bg-main: #0B0E14;
    --bg-surface: #151A23;
    --bg-surface-elevated: #1E2532;
    --bg-input: #10141C;
    
    --primary: #8b5cf6;
    --primary-hover: #7c3aed;
    --primary-active: #6d28d9;
    
    --text-main: #FFFFFF;
    --text-secondary: #94A3B8;
    --text-muted: #64748B;
    
    --border-light: #2A3441;
    --border-focus: #8b5cf6;
    --border-hover: #3E4C5F;
    
    --danger: #EF4444;
    --danger-hover: #DC2626;
    
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    
    --shadow-sm: 0 4px 6px -1px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 10px 15px -3px rgba(0, 0, 0, 0.3);
    --shadow-glow: 0 0 20px rgba(139, 92, 246, 0.2);
}

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

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background-color: var(--bg-main);
    color: var(--text-main);
    line-height: 1.5;
    min-height: 100vh;
    overflow-x: hidden;
}

/* Layout */
.app-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1.5rem 2rem;
    display: flex;
    flex-direction: column;
    height: 100vh;
}

/* Header */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border-light);
    margin-bottom: 1.5rem;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.logo-icon {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    background: linear-gradient(135deg, #FF0080 0%, #7928CA 100%);
    box-shadow: 0 0 12px rgba(121, 40, 202, 0.5);
}

h1 {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

/* Workspace Grid */
.workspace {
    display: flex;
    flex-direction: column;
    gap: 2rem;
    flex: 1;
    min-height: 0; /* Important for scrollable flex child */
}

@media (min-width: 900px) {
    .workspace {
        flex-direction: row;
    }
}

.panel {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.editor-panel {
    flex: 0 0 340px;
    background-color: var(--bg-surface);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-light);
    padding: 1.5rem;
    overflow-y: auto;
    /* Custom Scrollbar */
    scrollbar-width: thin;
    scrollbar-color: var(--border-hover) transparent;
}

.editor-panel::-webkit-scrollbar { width: 6px; }
.editor-panel::-webkit-scrollbar-track { background: transparent; }
.editor-panel::-webkit-scrollbar-thumb { background-color: var(--border-hover); border-radius: 10px; }

.output-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* Buttons */
button {
    font-family: inherit;
    cursor: pointer;
    border: none;
    background: none;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.primary-btn {
    background-color: var(--primary);
    color: white;
    padding: 0.625rem 1.25rem;
    border-radius: var(--radius-md);
    font-weight: 600;
    font-size: 0.875rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    box-shadow: 0 4px 12px rgba(139, 92, 246, 0.3);
}

.primary-btn:hover {
    background-color: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(139, 92, 246, 0.4);
}

.tertiary-btn {
    background-color: var(--bg-surface-elevated);
    color: var(--text-main);
    border: 1px solid var(--border-light);
    padding: 0.5rem 1rem;
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.375rem;
}

.tertiary-btn:hover {
    background-color: var(--border-light);
    border-color: var(--border-hover);
}

.icon-text-btn {
    color: var(--primary);
    font-size: 0.8125rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.icon-text-btn:hover {
    color: var(--primary-hover);
}

.icon-btn {
    color: var(--text-secondary);
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    background-color: var(--bg-input);
    border: 1px solid var(--border-light);
}

.icon-btn:hover {
    color: var(--text-main);
    background-color: var(--bg-surface-elevated);
    border-color: var(--border-hover);
}

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

.icon-btn.danger:hover:not(:disabled) {
    background-color: var(--danger);
    color: white;
}

.icon-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Form Controls */
.control-group {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

label {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.split-label {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.value-display {
    font-family: 'Fira Code', monospace;
    font-size: 0.75rem;
    color: var(--primary);
    background-color: var(--bg-input);
    padding: 0.125rem 0.375rem;
    border-radius: 4px;
    border: 1px solid var(--border-light);
}

.mt-3 {
    margin-top: 0.75rem;
}

/* Type Selector */
.type-selector {
    display: flex;
    background-color: var(--bg-input);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    padding: 0.25rem;
}

.type-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.375rem;
    padding: 0.5rem 0;
    color: var(--text-secondary);
    font-size: 0.8125rem;
    font-weight: 500;
    border-radius: var(--radius-sm);
}

.type-btn svg {
    opacity: 0.7;
}

.type-btn:hover {
    color: var(--text-main);
}

.type-btn.active {
    background-color: var(--bg-surface-elevated);
    color: var(--text-main);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-light);
}

.type-btn.active svg {
    color: var(--primary);
    opacity: 1;
}

/* Standard Inputs */
input[type="range"] {
    -webkit-appearance: none;
    width: 100%;
    height: 6px;
    background: var(--bg-input);
    border: 1px solid var(--border-light);
    border-radius: 3px;
    outline: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #fff;
    cursor: grab;
    border: 2px solid var(--primary);
    box-shadow: 0 0 10px rgba(139, 92, 246, 0.4);
    transition: transform 0.1s;
}

input[type="range"]::-webkit-slider-thumb:active {
    cursor: grabbing;
    transform: scale(1.1);
}

.dial-presets {
    display: flex;
    justify-content: space-between;
    margin-top: 0.25rem;
}

.dial-btn {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background-color: var(--bg-input);
    border: 1px solid var(--border-light);
    color: var(--text-secondary);
    font-size: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.dial-btn:hover {
    color: var(--primary);
    border-color: var(--primary);
    background-color: var(--bg-surface-elevated);
}

/* Stop Slider Editor */
.gradient-slider-container {
    position: relative;
    height: 40px;
    margin: 1rem 0.5rem;
}

.gradient-slider-track {
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    transform: translateY(-50%);
    height: 16px;
    border-radius: 8px;
    background: linear-gradient(90deg, #8b5cf6 0%, #3b82f6 100%);
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.3);
    border: 1px solid rgba(255,255,255,0.1);
}

.stops-container {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
}

.color-stop {
    position: absolute;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background-color: #fff;
    border: 3px solid #fff;
    box-shadow: 0 2px 8px rgba(0,0,0,0.5);
    cursor: grab;
    z-index: 2;
    transition: transform 0.1s;
}

.color-stop::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border-width: 6px 5px 0 5px;
    border-style: solid;
    border-color: #fff transparent transparent transparent;
    opacity: 0;
    transition: opacity 0.2s;
}

.color-stop:hover {
    transform: translate(-50%, -50%) scale(1.1);
}

.color-stop.active {
    z-index: 3;
    transform: translate(-50%, -50%) scale(1.2);
    box-shadow: 0 0 0 2px var(--primary), 0 4px 12px rgba(0,0,0,0.6);
}

.color-stop.active::after {
    opacity: 1;
}

/* Stop Tweaker Card */
.card {
    background-color: var(--bg-surface-elevated);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.stop-controls {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

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

.input-col label {
    font-size: 0.6875rem;
}

.color-input-wrapper {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background-color: var(--bg-input);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    padding: 0.25rem 0.5rem;
}

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

input[type="color"] {
    -webkit-appearance: none;
    border: none;
    width: 24px;
    height: 24px;
    border-radius: 4px;
    cursor: pointer;
    background: none;
    padding: 0;
}

input[type="color"]::-webkit-color-swatch-wrapper {
    padding: 0;
}

input[type="color"]::-webkit-color-swatch {
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 4px;
}

input[type="text"], input[type="number"] {
    background: transparent;
    border: none;
    color: var(--text-main);
    font-family: 'Fira Code', monospace;
    font-size: 0.8125rem;
    outline: none;
    width: 100%;
}

.pos-input-wrapper {
    display: flex;
    align-items: center;
    background-color: var(--bg-input);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    padding: 0.5rem 0.75rem;
}

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

.pos-input-wrapper .unit {
    color: var(--text-muted);
    font-size: 0.8125rem;
    font-weight: 500;
}

.divider {
    height: 1px;
    background-color: var(--border-light);
    margin: 0.5rem 0;
}

/* Presets */
.presets-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.5rem;
}

.preset-swatch {
    width: 100%;
    aspect-ratio: 1;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-light);
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.preset-swatch:hover {
    transform: scale(1.05);
    box-shadow: var(--shadow-md);
    border-color: var(--text-secondary);
}

/* Preview Output */
.preview-box {
    flex: 1;
    border-radius: var(--radius-xl);
    background: linear-gradient(90deg, #8b5cf6 0%, #3b82f6 100%);
    box-shadow: inset 0 0 20px rgba(0,0,0,0.2), var(--shadow-md);
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 300px;
    position: relative;
    overflow: hidden;
    transition: background 0.1s;
}

/* Transparency grid underneath */
.preview-box::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background-image: 
        linear-gradient(45deg, #1A202C 25%, transparent 25%),
        linear-gradient(-45deg, #1A202C 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #1A202C 75%),
        linear-gradient(-45deg, transparent 75%, #1A202C 75%);
    background-size: 20px 20px;
    background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
    z-index: -1;
}

.preview-content {
    background: rgba(0, 0, 0, 0.2);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: var(--radius-lg);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 2rem 3rem;
    text-align: center;
    color: white;
    text-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

.preview-content h2 {
    font-size: 3rem;
    font-weight: 800;
    letter-spacing: -0.05em;
    margin-bottom: 0.25rem;
}

.preview-content p {
    font-size: 1.125rem;
    font-weight: 500;
    opacity: 0.9;
}

/* Code Output */
.export-box {
    background-color: var(--bg-surface);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-light);
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.export-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.code-wrapper {
    background-color: var(--bg-main);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    padding: 1.25rem;
    overflow-x: auto;
}

.code-wrapper pre {
    margin: 0;
    font-family: 'Fira Code', monospace;
    font-size: 0.875rem;
    color: #E2E8F0;
    line-height: 1.6;
    white-space: pre-wrap;
    word-break: break-all;
}

/* Toast */
.toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background-color: white;
    color: black;
    padding: 0.75rem 1.5rem;
    border-radius: 100px;
    font-size: 0.875rem;
    font-weight: 600;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.3);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    z-index: 50;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
    visibility: visible;
}
