/* ========================================
   Image Dithering Studio — Styles
   ======================================== */

:root {
    --bg: #0D1117;
    --bg-secondary: #161B22;
    --bg-card: rgba(22, 27, 34, 0.8);
    --bg-input: rgba(13, 17, 23, 0.9);
    --text: #E6EDF3;
    --text-secondary: #B2BEC3;
    --text-muted: #636E72;
    --primary: #636E72;
    --secondary: #B2BEC3;
    --accent: #6C5CE7;
    --accent-glow: rgba(108, 92, 231, 0.25);
    --border: rgba(255, 255, 255, 0.06);
    --radius: 12px;
    --radius-sm: 8px;
    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
    --transition: 250ms ease;
}

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

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
}

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    background-image:
        radial-gradient(ellipse 60% 40% at 50% 0%, rgba(108, 92, 231, 0.08), transparent);
}

/* Header */
.header {
    padding: 14px 20px;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(13, 17, 23, 0.9);
    backdrop-filter: blur(16px);
}

.header-inner {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
}

.brand h1 {
    font-size: 1.1rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--accent), #A29BFE);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

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

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border: none;
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 0.8125rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
}

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

.btn-primary {
    width: 100%;
    justify-content: center;
    padding: 10px 20px;
    background: linear-gradient(135deg, var(--accent), #4834D4);
    color: #fff;
    box-shadow: 0 0 16px var(--accent-glow);
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 0 24px var(--accent-glow);
}

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

.btn-secondary:hover:not(:disabled) {
    background: rgba(108, 92, 231, 0.08);
    border-color: rgba(108, 92, 231, 0.3);
    color: var(--accent);
}

/* Layout */
.main {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

.layout {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 20px;
    align-items: start;
}

/* Controls */
.controls {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.control-group {
    padding: 14px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    backdrop-filter: blur(12px);
}

.group-label {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    margin-bottom: 10px;
    display: flex;
    justify-content: space-between;
}

.val {
    color: var(--accent);
    font-weight: 700;
}

/* Drop Zone */
.drop-zone {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 20px;
    border: 2px dashed var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    text-align: center;
    font-size: 0.8125rem;
    color: var(--text-muted);
    transition: all var(--transition);
}

.drop-zone:hover,
.drop-zone.dragover {
    border-color: var(--accent);
    background: rgba(108, 92, 231, 0.06);
    color: var(--accent);
}

/* Radio Grid */
.radio-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
}

.radio-grid.small {
    grid-template-columns: 1fr 1fr;
}

.radio-btn {
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-secondary);
    font-family: var(--font);
    font-size: 0.6875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    text-align: center;
}

.radio-btn:hover {
    border-color: rgba(108, 92, 231, 0.3);
    color: var(--text);
}

.radio-btn.active {
    background: rgba(108, 92, 231, 0.15);
    border-color: rgba(108, 92, 231, 0.4);
    color: var(--accent);
}

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

.slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--accent);
    cursor: pointer;
    box-shadow: 0 0 8px var(--accent-glow);
}

.slider::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--accent);
    cursor: pointer;
    border: none;
}

/* Palette */
.palette-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 10px;
}

.palette-swatch {
    width: 28px;
    height: 28px;
    border: 2px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
    padding: 0;
    -webkit-appearance: none;
}

.palette-swatch::-webkit-color-swatch-wrapper {
    padding: 0;
}

.palette-swatch::-webkit-color-swatch {
    border: none;
    border-radius: 4px;
}

.palette-presets {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.preset-btn {
    padding: 4px 10px;
    border: 1px solid var(--border);
    border-radius: 100px;
    background: transparent;
    color: var(--text-muted);
    font-family: var(--font);
    font-size: 0.6875rem;
    cursor: pointer;
    transition: all var(--transition);
}

.preset-btn:hover {
    border-color: rgba(108, 92, 231, 0.3);
    color: var(--accent);
    background: rgba(108, 92, 231, 0.06);
}

/* Preview */
.preview {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.canvas-container {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    min-height: 400px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    color: var(--text-muted);
    font-size: 0.875rem;
}

.canvas-wrapper {
    display: flex;
    gap: 2px;
    width: 100%;
    justify-content: center;
    padding: 12px;
}

.canvas-wrapper canvas {
    max-width: 100%;
    max-height: 70vh;
    border-radius: var(--radius-sm);
    image-rendering: pixelated;
}

.canvas-wrapper.side-by-side {
    gap: 8px;
}

.canvas-wrapper.side-by-side canvas {
    max-width: 49%;
}

.canvas-info {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-align: center;
}

/* Toast */
.toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    padding: 10px 20px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.8125rem;
    color: var(--text);
    backdrop-filter: blur(12px);
    opacity: 0;
    pointer-events: none;
    transition: all 250ms ease;
    z-index: 2000;
}

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

/* Responsive */
@media (max-width: 768px) {
    .layout {
        grid-template-columns: 1fr;
    }

    .controls {
        order: 2;
    }

    .preview {
        order: 1;
    }

    .canvas-wrapper.side-by-side {
        flex-direction: column;
        align-items: center;
    }

    .canvas-wrapper.side-by-side canvas {
        max-width: 100%;
    }
}