@import url(https://fonts.googleapis.com/css2?family=Poppins:wght@400;600;700&display=swap);
:root {
    /* Color Palettes */
    --palette-ocean: {
        --primary-color: #2563eb;
        --accent-color: #0ea5e9;
        --tertiary-color: #38bdf8;
    }

    --palette-forest: {
        --primary-color: #059669;
        --accent-color: #10b981;
        --tertiary-color: #34d399;
    }

    --palette-sunset: {
        --primary-color: #db2777;
        --accent-color: #ec4899;
        --tertiary-color: #f472b6;
    }

    /* Light Theme */
    --primary-color: #2563eb;
    --primary-dark: #1d4ed8;
    --secondary-color: #64748b;
    --background-color: #eaeaea;
    --surface-color: #ffffff;
    --text-color: #1e293b;
    --border-color: #f1f5f9;
    --border-radius: 12px;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

/* Dark Theme */
[data-theme="dark"] {
    --primary-color: #60a5fa;
    --primary-dark: #3b82f6;
    --secondary-color: #94a3b8;
    --background-color: #0f172a;
    --surface-color: #1e293b;
    --text-color: #f8fafc;
    --border-color: #334155;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.3);
}

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

body {
    background-color: var(--background-color);
    color: var(--text-color);
    font-family: "Poppins", sans-serif;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 2rem;
    transition: background-color 0.3s ease, color 0.3s ease;
}

.app-container {
    border-radius: var(--border-radius);
    padding: 2rem;
    max-width: 1200px;
    width: 100%;
    transition: background-color 0.3s ease;
}

/* Theme Switcher */
.theme-switcher {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 1000;
}

.palette-switcher {
    position: fixed;
    top: 1rem;
    left: 1rem;
    display: flex;
    gap: 0.5rem;
    z-index: 1000;
}

.palette-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 2px solid var(--surface-color);
    cursor: pointer;
    transition: transform 0.2s ease;
}

.palette-btn:hover {
    transform: scale(1.1);
}

.palette-btn.ocean {
    background: linear-gradient(45deg, #2563eb, #0ea5e9, #38bdf8);
}

.palette-btn.forest {
    background: linear-gradient(45deg, #059669, #10b981, #34d399);
}

.palette-btn.sunset {
    background: linear-gradient(45deg, #db2777, #ec4899, #f472b6);
}

#header {
    margin-bottom: 2rem;
}

h1 {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 1.5rem;
    text-align: center;
    color: var(--primary-color);
}

.toolbar {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
    margin-bottom: 1.5rem;
}

.btn-group {
    display: flex;
    gap: 0.5rem;
    padding: 0.5rem;
    background-color: var(--background-color);
    border-radius: var(--border-radius);
    transition: background-color 0.3s ease;
}

.btn {
    background-color: var(--surface-color);
    color: var(--text-color);
    border: none;
    border-radius: 8px;
    padding: 0.75rem;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    box-shadow: var(--shadow-sm);
}

.btn:hover {
    background-color: var(--primary-color);
    color: var(--surface-color);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.btn.active {
    background-color: var(--primary-color);
    color: var(--surface-color);
}

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

#color-picker {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    width: 40px;
    height: 40px;
    padding: 0;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    background-color: transparent;
}

#color-picker::-webkit-color-swatch {
    border: none;
    border-radius: 8px;
    box-shadow: var(--shadow-sm);
}

#color-picker::-moz-color-swatch {
    border: none;
    border-radius: 8px;
    box-shadow: var(--shadow-sm);
}

.grid-controls {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

#grid-range-output {
    font-size: 1rem;
    color: var(--primary-color);
}

input[type="range"] {
    -webkit-appearance: none;
    width: 100%;
    max-width: 300px;
    height: 8px;
    border-radius: 4px;
    background: var(--secondary-color);
    outline: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--primary-dark);
    cursor: pointer;
    box-shadow: var(--shadow-sm);
}

input[type="range"]::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--primary-dark);
    cursor: pointer;
    box-shadow: var(--shadow-sm);
}

#container {
    display: grid;
    margin: 0 auto;
    width: min(500px, 100%);
    height: min(500px, 100vw);
    aspect-ratio: 1;
    grid-template-rows: repeat(var(--grid-rows), 1fr);
    grid-template-columns: repeat(var(--grid-cols), 1fr);
    background-color: var(--surface-color);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}

#container > div {
    border: 1px solid var(--border-color);
    transition: background-color 0.1s ease;
}

.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal.active {
    display: flex;
}

.modal-content {
    background-color: var(--surface-color);
    padding: 2rem;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    max-width: 500px;
    width: 90%;
}

.modal-content h2 {
    margin-bottom: 1rem;
    color: var(--primary-color);
}

#saved-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 1rem;
    margin: 1rem 0;
    max-height: 400px;
    overflow-y: auto;
}

.saved-item {
    background-color: var(--background-color);
    padding: 0.5rem;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: all 0.2s ease;
}

.saved-item:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.saved-item img {
    width: 100%;
    aspect-ratio: 1;
    object-fit: contain;
    border-radius: 4px;
}

@media (max-width: 768px) {
    body {
        padding: 1rem;
    }

    .app-container {
        padding: 1rem;
    }

    h1 {
        font-size: 2rem;
    }

    .toolbar {
        flex-direction: column;
        align-items: center;
    }

    .btn-group {
        width: 100%;
        justify-content: center;
    }
}

