:root {
    --bg-color: #050505;
    --accent-primary: #ff0080;
    --accent-secondary: #7928ca;
    --glass-bg: rgba(255, 255, 255, 0.05);
    --glass-border: rgba(255, 255, 255, 0.1);
    --text-main: #ffffff;
    --text-muted: #a0a0a0;
    --danger: #ff4d4d;
    --sidebar-width: 280px;
    --header-height: 70px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-font-smoothing: antialiased;
}

body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    overflow: hidden;
    height: 100vh;
    width: 100vw;
}

#app {
    display: flex;
    height: 100vh;
    width: 100vw;
    position: relative;
    background: radial-gradient(circle at center, #1a1a2e 0%, #050505 100%);
}

/* Glass Panels */
.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
}

/* Canvas Area */
.canvas-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: crosshair;
}

canvas {
    position: absolute;
    max-width: 100%;
    max-height: 100%;
}

#cursorCanvas {
    pointer-events: none;
}

#flashOverlay {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: white;
    opacity: 0;
    pointer-events: none;
    z-index: 100;
}

@keyframes flashAnim {
    0% { opacity: 0; }
    50% { opacity: 0.8; }
    100% { opacity: 0; }
}

.flashing { animation: flashAnim 0.3s ease-out 2; }

/* Header */
.main-header {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    width: calc(100% - 40px);
    height: var(--header-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    z-index: 10;
}

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

.brand h1 {
    font-size: 1.5rem;
    font-weight: 600;
    letter-spacing: 1px;
    background: linear-gradient(45deg, var(--accent-primary), var(--accent-secondary));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

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

/* Sidebars */
.sidebar-left,
.sidebar-right {
    position: absolute;
    top: 100px;
    bottom: 100px;
    width: var(--sidebar-width);
    padding: 24px;
    z-index: 10;
    display: flex;
    flex-direction: column;
    gap: 24px;
    overflow-y: auto;
    transition: transform 0.5s cubic-bezier(0.165, 0.84, 0.44, 1), opacity 0.3s ease;
}

.sidebar-left {
    left: 20px;
}

.sidebar-right {
    right: 20px;
}

.panel-section h3 {
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--text-muted);
    margin-bottom: 16px;
}

/* Brushes Grid */
.brush-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

.brush-item {
    aspect-ratio: 1;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--glass-border);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    padding: 8px;
    text-align: center;
}

.brush-item:hover {
    background: rgba(255, 255, 255, 0.08);
    transform: translateY(-2px);
}

.brush-item.active {
    background: linear-gradient(45deg, var(--accent-primary), var(--accent-secondary));
    border-color: transparent;
}

.brush-item i {
    width: 20px;
    height: 20px;
}

.brush-item span {
    font-size: 0.7rem;
    margin-top: 4px;
}

/* Control Groups */
.control-group {
    margin-bottom: 16px;
}

.control-group label {
    display: block;
    font-size: 0.85rem;
    margin-bottom: 8px;
    color: var(--text-muted);
}

.value-display {
    float: right;
    font-size: 0.85rem;
    color: var(--accent-primary);
}

input[type="range"] {
    width: 100%;
    accent-color: var(--accent-primary);
    background: rgba(255, 255, 255, 0.1);
    height: 4px;
    border-radius: 2px;
}

/* Buttons */
.primary-btn,
.secondary-btn,
.danger-btn,
.icon-btn {
    border: none;
    border-radius: 12px;
    padding: 10px 20px;
    cursor: pointer;
    font-family: inherit;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s ease;
}

.primary-btn {
    background: linear-gradient(45deg, var(--accent-primary), var(--accent-secondary));
    color: white;
}

.primary-btn:hover {
    filter: brightness(1.1);
    transform: scale(1.02);
}

.secondary-btn {
    background: rgba(255, 255, 255, 0.08);
    color: white;
}

.icon-btn {
    background: transparent;
    color: white;
    padding: 10px;
}

.icon-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

.icon-btn.btn-autoplay.active {
    color: var(--accent-primary);
    background: rgba(255, 0, 128, 0.15);
    box-shadow: 0 0 20px rgba(255, 0, 128, 0.2);
}

.danger-btn {
    background: rgba(255, 77, 77, 0.1);
    color: var(--danger);
    border: 1px solid rgba(255, 77, 77, 0.2);
    width: 100%;
    justify-content: center;
}

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

/* Mode Selector */
.mode-selector {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.mode-selector.grid-2x2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.mode-btn {
    flex: 1;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 12px;
    color: white;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
}

.mode-btn.active {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--accent-primary);
    box-shadow: 0 0 15px rgba(255, 0, 128, 0.3);
}

/* Color Presets */
.color-presets {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 8px;
    margin-bottom: 16px;
}

.color-swatch {
    aspect-ratio: 1;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid transparent;
}

.color-swatch.active {
    border-color: white;
    transform: scale(1.1);
}

/* Bottom Bar */
.bottom-bar {
    position: absolute;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    padding: 8px 16px;
    display: flex;
    align-items: center;
    gap: 16px;
    z-index: 10;
    transition: transform 0.5s cubic-bezier(0.165, 0.84, 0.44, 1), opacity 0.3s ease;
}

/* Zen Mode Transitions */
.zen-mode .sidebar-left {
    transform: translateX(calc(-100% - 40px));
    opacity: 0;
    pointer-events: none;
}

.zen-mode .sidebar-right {
    transform: translateX(calc(100% + 40px));
    opacity: 0;
    pointer-events: none;
}

.zen-mode .bottom-bar {
    transform: translate(-50%, calc(100% + 40px));
    opacity: 0;
    pointer-events: none;
}

#btnZen.active {
    background: var(--accent-primary);
    box-shadow: 0 0 15px var(--accent-primary);
}

/* Footer */
.main-footer {
    position: absolute;
    bottom: 20px;
    left: 20px;
    z-index: 10;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.main-footer a {
    color: var(--accent-primary);
    text-decoration: none;
    font-weight: 600;
    transition: color 0.2s ease;
}

.main-footer a:hover {
    color: white;
}

.divider {
    width: 1px;
    height: 24px;
    background: var(--glass-border);
    margin: 0 8px;
}

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

.modal.active {
    display: flex;
}

.modal-content {
    width: 80%;
    max-width: 900px;
    max-height: 80vh;
    padding: 32px;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 24px;
}

.gallery-item {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.3s ease;
}

.gallery-item:hover {
    transform: translateY(-5px);
    background: rgba(255, 255, 255, 0.08);
}

.thumb-container {
    width: 100%;
    aspect-ratio: 1.5;
    background: #111;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.thumb-container img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.gallery-info {
    padding: 16px;
    background: rgba(0, 0, 0, 0.4);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.gallery-info span {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.gallery-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

.icon-btn.danger {
    color: var(--danger);
}

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

.empty-msg,
.loading-msg,
.error-msg {
    grid-column: 1 / -1;
    text-align: center;
    padding: 60px;
    color: var(--text-muted);
}

.empty-msg h3 {
    margin-bottom: 12px;
    color: white;
}

/* Switch UI */
.switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255, 255, 255, 0.1);
    transition: .4s;
}

.slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .4s;
}

input:checked+.slider {
    background: linear-gradient(45deg, var(--accent-primary), var(--accent-secondary));
}

input:checked+.slider:before {
    transform: translateX(20px);
}

.slider.round {
    border-radius: 34px;
}

.slider.round:before {
    border-radius: 50%;
}

.toggle-group {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.9rem;
}

/* Gradient Preview */
.gradient-preview {
    height: 30px;
    border-radius: 8px;
    margin-bottom: 10px;
    background: linear-gradient(to right, var(--accent-primary), var(--accent-secondary));
}

.color-inputs {
    display: flex;
    gap: 10px;
}

.color-inputs input[type="color"] {
    flex: 1;
    height: 40px;
    background: transparent;
    border: none;
    cursor: pointer;
}