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

:root {
    --bg-primary: #ffffff;
    --bg-secondary: #f8f9fa;
    --bg-tertiary: #f1f3f4;
    --text-primary: #1a1a2e;
    --text-secondary: #6b7280;
    --text-muted: #9ca3af;
    --border-color: #e5e7eb;
    --border-hover: #d1d5db;
    --accent-primary: #4f46e5;
    --accent-hover: #4338ca;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --transition: all 0.2s ease;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-secondary);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.5;
}

.app {
    max-width: 1400px;
    margin: 0 auto;
    padding: 24px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    margin-bottom: 24px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

.header-actions {
    display: flex;
    gap: 12px;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 18px;
    font-size: 0.875rem;
    font-weight: 500;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
}

.btn-primary {
    background: var(--accent-primary);
    color: white;
}

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

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

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

.btn-generate {
    background: var(--text-primary);
    color: white;
    padding: 12px 24px;
    font-size: 0.9375rem;
}

.btn-generate:hover {
    background: #2d2d44;
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-export {
    background: var(--bg-primary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    padding: 10px 16px;
}

.btn-export:hover {
    border-color: var(--border-hover);
    background: var(--bg-secondary);
}

.btn-danger {
    background: #fee2e2;
    color: #dc2626;
    padding: 6px 12px;
    font-size: 0.75rem;
}

.btn-danger:hover {
    background: #fecaca;
}

/* Main Content */
.main {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

/* Toolbar */
.toolbar {
    display: flex;
    align-items: flex-end;
    gap: 16px;
    padding: 20px 24px;
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    flex-wrap: wrap;
}

.toolbar label {
    display: block;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 6px;
}

.toolbar select {
    padding: 10px 14px;
    font-size: 0.875rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-primary);
    color: var(--text-primary);
    min-width: 160px;
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
}

.toolbar select:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.harmony-selector,
.colorblind-selector {
    flex: 1;
    min-width: 140px;
}

/* Palette Container */
.palette-container {
    display: flex;
    height: 400px;
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    overflow: hidden;
}

.color-swatch {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    padding: 24px;
    position: relative;
    cursor: pointer;
    transition: flex 0.3s ease;
}

.color-swatch:hover {
    flex: 1.2;
}

.color-swatch .color-info {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    padding: 16px;
    border-radius: var(--radius-md);
    text-align: center;
    box-shadow: var(--shadow-sm);
}

.color-swatch.dark .color-info {
    background: rgba(0, 0, 0, 0.8);
    color: white;
}

.color-swatch.dark .color-info .color-hex {
    color: white;
}

.color-swatch.dark .color-info .color-rgb {
    color: rgba(255, 255, 255, 0.7);
}

.color-hex {
    font-size: 1.125rem;
    font-weight: 600;
    font-family: 'SF Mono', Monaco, monospace;
    color: var(--text-primary);
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.color-rgb {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 4px;
}

.color-lock {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.9);
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition);
    opacity: 0;
}

.color-swatch:hover .color-lock {
    opacity: 1;
}

.color-lock:hover {
    background: white;
    transform: scale(1.05);
}

.color-lock.locked {
    opacity: 1;
    background: white;
    color: var(--accent-primary);
}

.color-swatch.dark .color-lock {
    background: rgba(0, 0, 0, 0.6);
    color: white;
}

.color-swatch.dark .color-lock:hover {
    background: rgba(0, 0, 0, 0.8);
}

.color-swatch.dark .color-lock.locked {
    background: rgba(0, 0, 0, 0.8);
    color: var(--accent-primary);
}

/* Palette Info */
.palette-info {
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.palette-info kbd {
    display: inline-block;
    padding: 2px 8px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-family: 'SF Mono', Monaco, monospace;
    font-size: 0.75rem;
    font-weight: 600;
}

/* Export Section */
.export-section {
    background: var(--bg-primary);
    padding: 24px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}

.export-section h3 {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 16px;
}

.export-buttons {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 600px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
}

.modal-close {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-tertiary);
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition);
    color: var(--text-secondary);
}

.modal-close:hover {
    background: var(--border-color);
    color: var(--text-primary);
}

.saved-palettes-list {
    padding: 16px;
    overflow-y: auto;
    max-height: 60vh;
}

.saved-palette-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    margin-bottom: 12px;
    transition: var(--transition);
}

.saved-palette-item:hover {
    background: var(--bg-tertiary);
}

.saved-palette-colors {
    display: flex;
    flex: 1;
    height: 48px;
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.saved-palette-color {
    flex: 1;
}

.saved-palette-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.saved-palette-date {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.saved-palette-actions {
    display: flex;
    gap: 8px;
}

.btn-load {
    background: var(--accent-primary);
    color: white;
    padding: 8px 16px;
    font-size: 0.75rem;
}

.btn-load:hover {
    background: var(--accent-hover);
}

.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-secondary);
}

.empty-state svg {
    width: 64px;
    height: 64px;
    margin-bottom: 16px;
    opacity: 0.3;
}

/* Toast */
.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--text-primary);
    color: white;
    padding: 12px 24px;
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    opacity: 0;
    transition: all 0.3s ease;
    z-index: 2000;
}

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

/* Responsive */
@media (max-width: 768px) {
    .app {
        padding: 16px;
    }

    .header {
        flex-direction: column;
        gap: 16px;
        text-align: center;
    }

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

    .harmony-selector,
    .colorblind-selector {
        width: 100%;
    }

    .toolbar select {
        width: 100%;
    }

    .palette-container {
        flex-direction: column;
        height: auto;
    }

    .color-swatch {
        height: 100px;
        flex-direction: row;
        align-items: center;
        padding: 16px;
    }

    .color-swatch:hover {
        flex: 1;
    }

    .color-swatch .color-info {
        margin-left: auto;
        padding: 12px 16px;
    }

    .color-lock {
        position: static;
        margin-right: 12px;
        opacity: 1;
    }

    .export-buttons {
        justify-content: center;
    }

    .saved-palette-item {
        flex-direction: column;
        align-items: stretch;
    }

    .saved-palette-actions {
        justify-content: flex-end;
    }
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.color-swatch {
    animation: fadeIn 0.3s ease forwards;
}

.color-swatch:nth-child(1) { animation-delay: 0ms; }
.color-swatch:nth-child(2) { animation-delay: 50ms; }
.color-swatch:nth-child(3) { animation-delay: 100ms; }
.color-swatch:nth-child(4) { animation-delay: 150ms; }
.color-swatch:nth-child(5) { animation-delay: 200ms; }
