/* Modern Minimalist Reset & Base */
@font-face {
    font-family: 'Script4';
    src: url('fonts/script-4.ttf') format('truetype');
}
@font-face {
    font-family: 'Fraktur';
    src: url('fonts/FrakturRegular.ttf') format('truetype');
}
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600&family=JetBrains+Mono:wght@400;700&display=swap');

@keyframes twinkle {
    0%, 100% { opacity: 0.3; transform: scale(0.8); }
    50% { opacity: 1; transform: scale(1.2); }
}

@keyframes float {
    0% { transform: translateY(0px); }
    50% { transform: translateY(-10px); }
    100% { transform: translateY(0px); }
}

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

@keyframes glowPulse {
    0% { box-shadow: 0 0 5px var(--accent-glow); }
    50% { box-shadow: 0 0 20px var(--accent-glow); }
    100% { box-shadow: 0 0 5px var(--accent-glow); }
}

@keyframes aurora {
    0% { transform: translate(0, 0) scale(1); }
    33% { transform: translate(10%, 10%) scale(1.1); }
    66% { transform: translate(-5%, 15%) scale(0.9); }
    100% { transform: translate(0, 0) scale(1); }
}

@keyframes slideIn {
    from { opacity: 0; transform: translateX(-20px); }
    to { opacity: 1; transform: translateX(0); }
}

:root {
    /* Color Palette - Premium Deep Blue/White */
    --bg-main: #02040a;       
    --bg-panel: rgba(10, 15, 30, 0.75);  
    --bg-element: rgba(30, 45, 75, 0.5); 
    --bg-hover: rgba(50, 70, 120, 0.45);   
    
    --border-subtle: rgba(255, 255, 255, 0.06);
    --border-focus: rgba(37, 99, 235, 0.6); 
    
    --text-primary: #ffffff;
    --text-secondary: #f1f5f9;
    --text-muted: #94a3b8;
    
    --accent-primary: #2563eb; /* Deeper Royal Blue */
    --accent-secondary: #f8fafc; /* Near White */
    --accent-glow: rgba(37, 99, 235, 0.4);
    --danger: #ef4444;
    
    /* Dimensions */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --header-height: 72px;
    
    /* Fonts */
    --font-sans: 'Inter', 'Outfit', sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
    --font-brand: 'Orbitron', sans-serif;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 0;
    background-color: var(--bg-main);
    color: var(--text-primary);
    font-family: var(--font-sans);
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: var(--bg-element);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--bg-hover);
}

/* Layout */
.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh; /* Use viewport height */
    overflow: hidden; /* Prevent body scroll */
    position: relative;
    z-index: 1;
}

/* Resize Handles */
.handles-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 20;
    pointer-events: none;
}

.resize-handle {
    pointer-events: auto;
    transition: opacity 0.2s, background 0.2s, transform 0.2s;
    opacity: 0;
    z-index: 30;
}

.resize-handle:hover {
    opacity: 1;
}

/* .canvas-wrapper:hover .resize-handle { opacity: 1; } - Removed */

/* Resize Tooltip */
.resize-tooltip {
    position: fixed;
    background: var(--bg-panel);
    color: var(--text-primary);
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-family: var(--font-mono);
    pointer-events: none;
    z-index: 1000;
    transform: translate(15px, 15px);
    border: 1px solid var(--accent-primary);
    box-shadow: 0 4px 12px rgba(0,0,0,0.5);
    display: none;
    backdrop-filter: blur(4px);
}

/* Resize Handles - Side Styles - Minimalist Modern */
.handle-n {
    position: absolute;
    top: -12px;
    left: 0;
    width: 100%;
    height: 20px;
    cursor: n-resize;
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
}

.handle-n::after {
    content: '';
    display: block;
    width: 16px;
    height: 16px;
    background-color: rgba(39, 39, 42, 0.6); /* Semi-transparent dark */
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="rgba(255,255,255,0.6)" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="18 15 12 9 6 15"></polyline></svg>');
    background-position: center;
    background-repeat: no-repeat;
    background-size: 10px;
    box-shadow: none;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    backdrop-filter: blur(4px);
}

.handle-n:hover::after {
    border-color: var(--accent-primary);
    background-color: var(--bg-element);
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    transform: scale(1.1);
    border-radius: 50%;
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="rgb(244,244,245)" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="18 15 12 9 6 15"></polyline></svg>');
}

.handle-e {
    position: absolute;
    top: 0;
    right: -12px;
    width: 20px;
    height: 100%;
    cursor: e-resize;
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
}

.handle-e::after {
    content: '';
    display: block;
    width: 16px;
    height: 16px;
    background-color: rgba(39, 39, 42, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="rgba(255,255,255,0.6)" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="9 18 15 12 9 6"></polyline></svg>');
    background-position: center;
    background-repeat: no-repeat;
    background-size: 10px;
    box-shadow: none;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    backdrop-filter: blur(4px);
}

.handle-e:hover::after {
    border-color: var(--accent-primary);
    background-color: var(--bg-element);
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    transform: scale(1.1);
    border-radius: 50%;
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="rgb(244,244,245)" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="9 18 15 12 9 6"></polyline></svg>');
}

.handle-s {
    position: absolute;
    bottom: -12px;
    left: 0;
    width: 100%;
    height: 20px;
    cursor: s-resize;
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
}

.handle-s::after {
    content: '';
    display: block;
    width: 16px;
    height: 16px;
    background-color: rgba(39, 39, 42, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="rgba(255,255,255,0.6)" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="6 9 12 15 18 9"></polyline></svg>');
    background-position: center;
    background-repeat: no-repeat;
    background-size: 10px;
    box-shadow: none;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    backdrop-filter: blur(4px);
}

.handle-s:hover::after {
    border-color: var(--accent-primary);
    background-color: var(--bg-element);
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    transform: scale(1.1);
    border-radius: 50%;
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="rgb(244,244,245)" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="6 9 12 15 18 9"></polyline></svg>');
}

.handle-w {
    position: absolute;
    top: 0;
    left: -12px;
    width: 20px;
    height: 100%;
    cursor: w-resize;
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
}

.handle-w::after {
    content: '';
    display: block;
    width: 16px;
    height: 16px;
    background-color: rgba(39, 39, 42, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="rgba(255,255,255,0.6)" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="15 18 9 12 15 6"></polyline></svg>');
    background-position: center;
    background-repeat: no-repeat;
    background-size: 10px;
    box-shadow: none;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    backdrop-filter: blur(4px);
}

.handle-w:hover::after {
    border-color: var(--accent-primary);
    background-color: var(--bg-element);
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    transform: scale(1.1);
    border-radius: 50%;
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="rgb(244,244,245)" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="15 18 9 12 15 6"></polyline></svg>');
}

/* Corner Handles */
.handle-se, .handle-sw, .handle-ne, .handle-nw {
    position: absolute;
    width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    box-shadow: none;
}

.handle-se { bottom: -12px; right: -12px; cursor: se-resize; }
.handle-sw { bottom: -12px; left: -12px; cursor: sw-resize; }
.handle-ne { top: -12px; right: -12px; cursor: ne-resize; }
.handle-nw { top: -12px; left: -12px; cursor: nw-resize; }

.handle-se::after, .handle-sw::after, .handle-ne::after, .handle-nw::after {
    content: '';
    display: block;
    width: 8px;
    height: 8px;
    background-color: var(--bg-main);
    border-radius: 50%;
    border: 2px solid var(--text-muted);
    box-shadow: 0 2px 8px rgba(0,0,0,0.5);
    transition: all 0.2s;
}

.handle-se:hover::after, .handle-sw:hover::after, .handle-ne:hover::after, .handle-nw:hover::after {
    border-color: var(--accent-primary);
    background-color: var(--accent-primary);
    box-shadow: 0 0 10px var(--accent-glow);
    transform: scale(1.3);
}

/* Removed old hover transforms */

/* Window Header (Tabs + Controls) */
.window-header {
    height: 54px; 
    background: rgba(30, 30, 35, 0.6);
    backdrop-filter: blur(12px);
    border-top-left-radius: var(--radius-md);
    border-top-right-radius: var(--radius-md);
    display: flex;
    align-items: center;
    padding: 0 20px;
    gap: 16px;
    border-bottom: 1px solid var(--border-subtle);
    position: relative;
    user-select: none;
}

.window-controls {
    display: flex;
    gap: 8px;
    height: 100%;
    align-items: center;
    margin-right: 4px;
    flex-shrink: 0; /* Prevent shrinking */
}

.control-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    transition: transform 0.2s;
}

.control-dot:hover {
    transform: scale(1.1);
}

.control-dot.red { background-color: #ff5f56; }
.control-dot.yellow { background-color: #ffbd2e; }
.control-dot.green { background-color: #27c93f; }

.window-title {
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 500;
    margin-left: 4px;
    margin-right: 8px;
    white-space: nowrap;
    opacity: 0.7;
    font-family: var(--font-primary);
    flex-shrink: 1; /* Allow title to shrink */
    overflow: hidden;
    text-overflow: ellipsis;
}

.tabs-container {
    display: flex;
    gap: 4px; /* Comfortable gap */
    overflow-x: auto;
    height: 100%;
    align-items: center;
    flex: 0 1 auto; /* Only take needed space, but allow shrinking */
    scrollbar-width: none; /* Firefox: hide scrollbar */
    scroll-behavior: smooth; /* Smooth scrolling */
    padding: 0 8px; /* Minimal padding */
    /* Adjusted fade mask for minimal padding */
    mask-image: linear-gradient(to right, transparent 0%, black 8px, black calc(100% - 8px), transparent 100%);
    -webkit-mask-image: linear-gradient(to right, transparent 0%, black 8px, black calc(100% - 8px), transparent 100%);
}

.tabs-container::-webkit-scrollbar {
    display: none; /* Chrome/Safari: hide scrollbar */
}

.tabs-scroll-btn {
    width: 24px;
    height: 24px;
    min-width: 24px; /* Prevent shrinking */
    border-radius: 4px;
    border: none;
    background: transparent;
    color: var(--text-primary); /* Brighter icon color */
    cursor: pointer;
    display: flex !important; /* Force flex display */
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    /* align-self: center; Remove individual align-self as parent is aligned */
    opacity: 0.8;
}

.tabs-scroll-btn.hidden {
    display: none !important;
}

.tabs-nav-group {
    display: flex;
    gap: 2px;
    align-items: center;
    z-index: 10;
    align-self: center; /* Center vertically in parent */
    height: 24px; /* Fix height */
    margin-right: 4px; /* Spacing from + btn */
}

.tabs-scroll-btn svg {
    width: 16px;
    height: 16px;
    min-width: 16px;
    min-height: 16px;
    pointer-events: none;
    display: block; /* Ensure SVG is block */
}

.tabs-scroll-btn:hover {
    background: var(--bg-hover);
    color: #fff;
    opacity: 1;
}

/* Ensure buttons are visible */
.tabs-scroll-btn {
    display: flex !important; /* Force display if not hidden */
}

.tabs-scroll-btn.hidden {
    display: none !important;
}

.tabs-scroll-btn svg {
    width: 14px;
    height: 14px;
}

.tab {
    padding: 6px 12px; /* Increased padding */
    background: var(--bg-element);
    border-radius: 6px; /* Nicer corners */
    cursor: pointer;
    font-size: 12px; /* Larger font */
    color: var(--text-muted);
    transition: all 0.2s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    display: flex;
    align-items: center;
    gap: 8px; /* Comfortable gap */
    white-space: nowrap;
    border: 1px solid transparent;
    height: 32px;
    transform: scale(1);
    position: relative;
    overflow: hidden;
    min-width: 80px; /* Wider min width */
    max-width: 200px; /* Wider max width */
    flex-shrink: 0; /* Prefer not shrinking */
}

.tab-title {
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    flex: 1;
    min-width: 0;
    text-align: left;
    font-weight: 500;
}

.tab:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    transform: translateY(-1px); /* Slight hover lift */
}

.tab:active {
    transform: scale(0.96); /* Click press effect */
}

.tab.active {
    background: #ffffff;
    color: #1e1e20;
    border-color: transparent;
    transform: translateY(0);
    box-shadow: 0 2px 5px rgba(0,0,0,0.2); /* Subtle lift */
    animation: tab-pop 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    font-weight: 500;
}

.tab.active .tab-close {
    color: #52525b; /* Darker icon for white background */
}

.tab.active .tab-close:hover {
    background: rgba(0, 0, 0, 0.1);
    color: #000;
}

@keyframes tab-pop {
    0% { transform: scale(0.95); opacity: 0.8; }
    100% { transform: scale(1); opacity: 1; }
}

@keyframes tab-switch {
    0% { opacity: 0.8; transform: scale(0.98); filter: blur(2px); }
    100% { opacity: 1; transform: scale(1); filter: blur(0); }
}

.tab-switching {
    animation: tab-switch 0.25s cubic-bezier(0.2, 0.8, 0.2, 1);
}

/* Optional: Slide content in */
.canvas-container {
    animation: fade-in-up 0.3s ease-out;
}

@keyframes fade-in-up {
    0% { opacity: 0.9; transform: translateY(2px); }
    100% { opacity: 1; transform: translateY(0); }
}

.tab-close {
    font-size: 16px;
    opacity: 0;
    border-radius: 4px;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    color: var(--text-muted);
    flex-shrink: 0;
    margin-left: 4px;
}

.tab:hover .tab-close,
.tab.active .tab-close {
    opacity: 0.7;
}

.tab-close:hover {
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
    opacity: 1;
}

.new-tab-btn {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    align-self: center;
}

.new-tab-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.terminal-dimensions {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--text-muted);
    padding: 0 8px;
    align-self: center;
    opacity: 0.6;
}


.tabs-scroll-btn:disabled,
.tabs-scroll-btn[style*="pointer-events: none"] {
    cursor: default;
    opacity: 0.6 !important; /* Force visibility */
}

/* Scroll buttons if needed later, but standard scrollbar is fine for now */
.tabs-container::-webkit-scrollbar {
    height: 0px; /* Hide scrollbar */
    background: transparent;
}

.new-tab-btn {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.new-tab-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

/* Background Stars */
.stars-container {
    position: fixed;
    top: var(--header-height);
    left: 280px; /* Sidebar width */
    width: calc(100% - 280px);
    height: calc(100% - var(--header-height));
    z-index: 0;
    pointer-events: none;
    overflow: hidden;
    transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1), width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar.collapsed + .editor-area .stars-container {
    left: 0;
    width: 100%;
}

.star {
    position: absolute;
    background: white;
    border-radius: 50%;
    animation: twinkle var(--duration) ease-in-out infinite;
    animation-delay: var(--delay);
}

/* Moon */
.moon {
    position: absolute;
    top: 50px;
    right: 80px;
    width: 100px;
    height: 100px;
    border-radius: 50%;
    /* Subtle gradient for moon surface */
    background: radial-gradient(circle at 35% 35%, #fff 0%, #f1f5f9 40%, #cbd5e1 100%);
    /* Multi-layered glow */
    box-shadow: 
        inset -10px -10px 20px rgba(0,0,0,0.1), /* Shadow/Depth */
        0 0 30px rgba(255, 255, 255, 0.6),      /* Inner glow */
        0 0 80px rgba(255, 255, 255, 0.3),      /* Outer glow */
        0 0 140px rgba(255, 255, 255, 0.15);    /* Distant glow */
    z-index: 1;
    pointer-events: none;
    /* Gentle floating animation */
    animation: float 6s ease-in-out infinite;
    opacity: 0.9;
    will-change: transform;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    transform: translateZ(0);
}

/* Zoom controls in header */
.zoom-controls {
    display: flex;
    gap: 4px;
    align-items: center;
    background: var(--bg-element);
    padding: 2px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-subtle);
    margin-left: 12px;
}

.zoom-controls .icon-btn {
    width: 24px;
    height: 24px;
    padding: 0;
}

.zoom-controls .icon-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

#zoom-level {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--text-muted);
    min-width: 36px;
    text-align: center;
    user-select: none;
}

/* Header - Modern Toolbar Style */
header {
    height: var(--header-height);
    background-color: rgba(5, 5, 7, 0.8);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border-subtle);
    padding: 0 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 100;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.icon-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 8px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

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

.brand-font {
    font-family: var(--font-brand);
    font-weight: 700;
    font-size: 1.4rem;
    letter-spacing: -0.01em;
    color: #fff;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 0.75rem;

}

.brand-font span {
    background: linear-gradient(to right, var(--accent-primary), var(--accent-secondary), var(--accent-primary));
    background-size: 200% auto;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    font-weight: 800;
    animation: textGradientMove 3s linear infinite;
}

@keyframes textGradientMove {
    0% { background-position: 200% center; }
    100% { background-position: 0% center; }
}

.brand-logo {
    height: 26px;
    width: auto;
    position: relative;
    top: 10px;
    /* Reset fill color for image */
    -webkit-text-fill-color: initial;
}

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

.tool-group {
    display: flex;
    gap: 0.25rem;
    align-items: center;
    background: var(--bg-panel);
    padding: 0.25rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-subtle);
}

/* Modern Buttons */
button {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-family: var(--font-sans);
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    position: relative;
    overflow: hidden;
}

button::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    transition: width 0.3s, height 0.3s;
}

button:hover::after {
    width: 150%;
    height: 150%;
}

.icon {
    width: 16px;
    height: 16px;
    stroke-width: 2;
}

button:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

button.active {
    background: var(--bg-element);
    color: var(--text-primary);
    box-shadow: inset 0 0 0 1px var(--border-focus);
}

button.danger {
    background: var(--danger);
    color: white;
    border: none;
}

button.danger:hover {
    background: #dc2626; /* Darker red */
    color: white;
    box-shadow: 0 0 10px rgba(239, 68, 68, 0.5);
}

.action-btn {
    background: var(--text-primary);
    color: var(--bg-main);
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275); /* Bardziej sprężysta animacja */
}

.action-btn:hover {
    background: #ffffff;
    color: #000000;
    transform: translateY(-2px) scale(1.02); /* Wyraźniejszy ruch */
    box-shadow: 0 8px 20px rgba(255, 255, 255, 0.25); /* Mocniejsza poświata */
}

.action-btn.outline {
    background: transparent;
    color: var(--text-primary);
    border: 1px solid var(--border-subtle);
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.action-btn.outline:hover {
    background: #ffffff;
    color: #000000;
    border-color: #ffffff;
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 8px 20px rgba(255, 255, 255, 0.2);
}

#btn-download {
    background: linear-gradient(135deg, var(--accent-primary), #1e40af);
    color: white;
    border: none;
    box-shadow: 0 4px 15px rgba(37, 99, 235, 0.3);
    position: relative;
    z-index: 1;
}

#btn-download::before {
    content: "";
    position: absolute;
    inset: -2px;
    background: linear-gradient(90deg, var(--accent-primary), #60a5fa, var(--accent-primary));
    background-size: 200% 100%;
    border-radius: calc(var(--radius-sm) + 2px);
    z-index: -1;
    animation: gradientBorder 3s linear infinite;
    opacity: 0.6;
}

@keyframes gradientBorder {
    0% { background-position: 0% 0%; }
    100% { background-position: 200% 0%; }
}

#btn-download:hover {
    transform: translateY(-2px) scale(1.05);
    box-shadow: 0 8px 25px rgba(37, 99, 235, 0.5);
    filter: brightness(1.15);
}

/* Ensure active state overrides outline style */
.action-btn.active,
.action-btn.outline.active {
    background: var(--accent-primary);
    color: white;
    box-shadow: 0 0 20px var(--accent-glow);
    border-color: var(--accent-primary);
    font-weight: 600;
}

/* Inputs & Selects */
.emoji-list-container {
    background: var(--bg-element);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    padding: 8px;
    height: 200px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--border-subtle) transparent;
}

.emoji-list-container::-webkit-scrollbar {
    width: 6px;
}

.emoji-list-container::-webkit-scrollbar-thumb {
    background-color: var(--border-subtle);
    border-radius: 3px;
}

.emoji-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 4px;
}

.emoji-btn {
    font-size: 18px;
    padding: 6px;
    background: transparent;
    border: 1px solid transparent;
    cursor: pointer;
    border-radius: 4px;
    transition: background 0.2s, transform 0.1s;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    aspect-ratio: 1;
}

.emoji-btn:hover {
    background: var(--bg-hover);
    border-color: var(--border-subtle);
    transform: scale(1.1);
}

label {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 600;
    /* text-transform: uppercase; Removed */
    letter-spacing: 0.02em; /* Reduced spacing */
    margin-bottom: 0.25rem;
    display: block;
}

input[type="number"],
input[type="text"],
select {
    background: var(--bg-element);
    border: 1px solid var(--border-subtle);
    color: var(--text-primary);
    padding: 0.4rem 0.6rem;
    border-radius: var(--radius-sm);
    font-family: var(--font-sans);
    font-size: 0.875rem;
    transition: border-color 0.2s;
    outline: none;
    width: 100%;
}

input[type="number"]:focus,
input[type="text"]:focus,
select:focus {
    border-color: var(--border-focus);
}

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

/* Specific input widths for header */
header input[type="number"] {
    width: 70px;
}

header select {
    width: auto;
}

/* Template Tags */
.template-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}

.tag-btn {
    background: var(--bg-element);
    border: 1px solid var(--border-subtle);
    color: #ffffff; /* White text as requested */
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-family: var(--font-mono);
    cursor: pointer;
    transition: all 0.2s;
    
    /* Flex layout for icon */
    display: inline-flex;
    align-items: center;
    gap: 8px;
    justify-content: space-between;
    min-width: 80px; /* Ensure enough space for longer tags */
}

.tag-btn:hover {
    background: var(--bg-hover);
    color: #ffffff;
    border-color: var(--text-primary);
    transform: translateY(-1px);
}

.tag-btn .tag-text {
    flex: 1;
    text-align: left;
}

.tag-btn .star-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    opacity: 0; /* Default hidden */
    transition: all 0.2s;
    padding: 2px;
    border-radius: 50%;
    z-index: 5;
    position: relative;
}

.tag-btn:hover .star-icon {
    opacity: 0.3; /* Show dim on button hover */
}

.tag-btn .star-icon:hover {
    color: #eab308; /* Yellow/Gold hover */
    background: rgba(255, 255, 255, 0.1);
    transform: scale(1.2);
    opacity: 1 !important; /* Force full opacity on star hover */
}

.tag-btn.favorited {
    border-color: #eab308;
    background: rgba(234, 179, 8, 0.1);
}

.tag-btn.favorited .star-icon {
    color: #eab308;
    opacity: 1; /* Always visible if favorited */
    fill: #eab308;
}

.tag-btn .star-icon svg {
    width: 12px;
    height: 12px;
}

/* Accordion Styles */
.accordion-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-element);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    margin-bottom: 10px;
    position: relative;
    overflow: hidden;
}

.accordion-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.03), transparent);
    transform: translateX(-100%);
    transition: transform 0.5s;
}

.accordion-header:hover::before {
    transform: translateX(100%);
}

.accordion-header:hover {
    background: var(--bg-hover);
    border-color: var(--text-muted);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.accordion-header:active {
    transform: translateY(0);
}

.accordion-header .arrow {
    transition: transform 0.4s cubic-bezier(0.68, -0.55, 0.27, 1.55); /* Bouncy arrow */
}

.accordion-content {
    display: block;
    overflow: hidden;
    max-height: 2000px; /* Enough for content */
    opacity: 1;
    transition: max-height 0.5s ease-in-out, opacity 0.5s ease-in-out;
}

.accordion-content.collapsed {
    max-height: 0;
    opacity: 0;
    pointer-events: none;
}

.accordion-header.collapsed .arrow {
    transform: rotate(-90deg);
}

/* Workspace */
.workspace {
    display: flex;
    flex: 1;
    overflow: hidden;
    min-height: 0;
    position: relative;
}

.workspace::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.1) 50%), linear-gradient(90deg, rgba(255, 0, 0, 0.02), rgba(0, 255, 0, 0.01), rgba(0, 0, 255, 0.02));
    background-size: 100% 2px, 3px 100%;
    pointer-events: none;
    z-index: 5;
    opacity: 0.3;
}

/* Sidebar */
.sidebar {
    width: 340px; 
    background-color: rgba(5, 5, 7, 0.95);
    backdrop-filter: blur(16px);
    border-right: 1px solid var(--border-subtle);
    padding: 0;
    display: flex;
    flex-direction: row;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s ease;
    flex-shrink: 0;
    position: relative;
    z-index: 100;
    overflow: hidden;
    height: 100%;
    max-height: 100%;
}

.sidebar-nav {
    width: 64px;
    background-color: var(--bg-main);
    border-right: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1rem 0;
    gap: 0.5rem;
    flex-shrink: 0;
}

.nav-tab {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    position: relative;
    top: 3px;
    color: var(--text-muted);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    cursor: pointer;
    transition: all 0.2s;
    padding: 0;
}

.nav-tab:hover {
    color: var(--text-primary);
    background-color: var(--bg-hover);
}

.nav-tab.active {
    color: var(--text-primary);
    background-color: var(--bg-element);
}

.nav-tab .icon {
    width: 20px;
    height: 20px;
    stroke-width: 2px;
}

.nav-tab span {
    font-size: 9px;
    font-weight: 500;
}

.sidebar-panel {
    flex: 1;
    padding: 1.5rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    background-color: rgba(20, 20, 25, 0.4); /* Glassy inner bg */
    min-height: 0;
}

.tab-content {
    display: none;
    flex-direction: column;
    gap: 1.5rem;
    height: 100%;
}

.tab-content.active {
    display: flex;
    animation: fadeIn 0.3s ease-out;
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-muted);
    font-size: 0.875rem;
    text-align: center;
    gap: 1rem;
}

/* Gradient Colors Section - Unified Bar */
.gradient-preview-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    padding: 0;
    margin-bottom: 1.5rem;
    background: transparent;
    height: 52px;
    border-radius: 16px;
    position: relative;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    border: 1px solid var(--border-subtle);
}

.gradient-color-input {
    flex: 1;
    height: 100%;
    display: flex;
    flex-direction: column;
    position: relative;
}

.gradient-color-input label {
    position: absolute;
    z-index: 5;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    margin: 0;
    color: rgba(255,255,255,0.95);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    text-shadow: 0 1px 3px rgba(0,0,0,0.4);
    pointer-events: none;
    user-select: none;
}

.color-picker-wrapper {
    width: 100%;
    height: 100%;
    border: none;
    border-radius: 0;
    position: relative;
    overflow: hidden;
    transition: filter 0.2s;
    box-shadow: none;
}

.color-picker-wrapper:hover {
    filter: brightness(1.1);
    transform: none;
    box-shadow: none;
}

/* Rounded corners for the bar ends */
.gradient-color-input:first-of-type .color-picker-wrapper {
    border-top-left-radius: 15px;
    border-bottom-left-radius: 15px;
}

.gradient-color-input:last-of-type .color-picker-wrapper {
    border-top-right-radius: 15px;
    border-bottom-right-radius: 15px;
}

.color-picker-wrapper input[type="color"] {
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    padding: 0;
    margin: 0;
    border: none;
    cursor: pointer;
    background: none;
}

#btn-swap-colors {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #ffffff !important; /* Force white background */
    color: #000000 !important;
    border: 1px solid rgba(0,0,0,0.1) !important;
    flex-shrink: 0;
    transition: all 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

#btn-swap-colors.animate-swap {
    transform: translate(-50%, -50%) rotate(180deg);
}

#btn-swap-colors:hover {
    transform: translate(-50%, -50%) scale(1.15) rotate(180deg);
    box-shadow: 0 4px 12px rgba(0,0,0,0.25);
    background: #ffffff !important;
}

#btn-swap-colors:active {
    transform: translate(-50%, -50%) scale(0.95) rotate(180deg);
}

#btn-swap-colors .icon {
    width: 16px;
    height: 16px;
    stroke-width: 2.5px;
    opacity: 1;
}

.icon-btn.medium .icon {
    width: 20px;
    height: 20px;
}

/* Custom Select for Background Presets */
.custom-select-wrapper {
    position: relative;
    user-select: none;
    width: 100%;
}

.custom-select {
    position: relative;
    display: flex;
    flex-direction: column;
}

.custom-select-trigger {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: flex-start; /* Changed from space-between */
    padding: 0 12px;
    font-size: 0.85rem;
    font-weight: 400;
    color: var(--text-primary);
    height: 36px;
    line-height: 36px;
    background: var(--bg-element);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.3s ease;
}

.custom-select-trigger .arrow {
    margin-left: auto; /* Push arrow to the right */
}

.custom-select-trigger:hover {
    border-color: var(--text-muted);
    background: var(--bg-hover);
}

.custom-select.open .custom-select-trigger {
    border-color: var(--text-primary);
    /* border-bottom-left-radius: 0; REMOVED - keep rounded because of gap */
    /* border-bottom-right-radius: 0; REMOVED */
    background: var(--bg-hover);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2); /* Subtle focus ring */
}

.arrow {
    position: relative;
    height: 8px;
    width: 8px;
}

.arrow::before, .arrow::after {
    content: "";
    position: absolute;
    bottom: 0px;
    width: 0.15rem;
    height: 100%;
    transition: all 0.3s;
}

.arrow::before {
    left: -3px;
    transform: rotate(45deg);
    background-color: var(--text-muted);
}

.arrow::after {
    left: 3px;
    transform: rotate(-45deg);
    background-color: var(--text-muted);
}

.custom-select.open .arrow::before {
    transform: rotate(-45deg);
}

.custom-select.open .arrow::after {
    transform: rotate(45deg);
}

.custom-options {
    position: absolute;
    display: block;
    top: calc(100% + 4px); /* Lekki odstęp od triggera */
    left: 0;
    right: 0;
    background: rgba(9, 9, 11, 0.95); /* Półprzezroczyste tło */
    backdrop-filter: blur(12px); /* Efekt szkła */
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    box-shadow: 0 10px 30px -10px rgba(0,0,0,0.5); /* Miękki, głęboki cień */
    z-index: 100;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(-8px) scale(0.98);
    transition: all 0.2s cubic-bezier(0.2, 0.8, 0.2, 1);
    max-height: 300px;
    overflow-y: auto;
    padding: 4px; /* Padding wewnątrz listy */
}

.custom-select.open .custom-options {
    opacity: 1;
    visibility: visible;
    pointer-events: all;
    transform: translateY(0) scale(1);
}

.bg-preview-icon {
    width: 16px;
    height: 16px;
    border-radius: 4px;
    margin-right: 10px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    flex-shrink: 0;
    box-shadow: 0 1px 2px rgba(0,0,0,0.2) !important; /* Override preset shadows */
    background-size: cover !important; /* Try to fit patterns */
}

.custom-option {
    position: relative;
    display: flex; /* Flex dla lepszego wyrównania */
    align-items: center;
    justify-content: flex-start; /* Zmienione z space-between na start */
    padding: 8px 12px;
    font-size: 0.85rem;
    font-weight: 400;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: 4px; /* Zaokrąglone rogi elementów */
    transition: all 0.15s ease;
    margin-bottom: 2px;
}

.custom-option span {
    flex: 1; /* Tekst zajmuje resztę miejsca */
}

.custom-option:last-child {
    margin-bottom: 0;
}

.custom-option:hover {
    color: var(--text-primary);
    background-color: rgba(255, 255, 255, 0.1);
    transform: translateX(2px); /* Subtelne przesunięcie */
}

.custom-option.selected {
    color: #ffffff;
    background-color: var(--bg-element);
    font-weight: 600;
}

/* Checkmark dla wybranego elementu */
.custom-option.selected::after {
    content: "✓";
    font-weight: bold;
    font-size: 0.8em;
    color: var(--accent-primary); /* Lub biały */
}

/* Splash Screen */
.splash-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle at center, #0a0f1e, #050507);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    transition: opacity 0.8s cubic-bezier(0.4, 0, 0.2, 1), visibility 0.8s;
}

.splash-content {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2rem;
}

.splash-logo img {
    width: 80px;
    height: auto;
    filter: drop-shadow(0 0 20px var(--accent-glow));
    animation: float 4s ease-in-out infinite;
}

.loader-bar {
    width: 240px;
    height: 2px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 1px;
    overflow: hidden;
    position: relative;
}

.loader-progress {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: 40%;
    background: linear-gradient(to right, transparent, var(--accent-primary), transparent);
    animation: loaderMove 2s infinite ease-in-out;
}

@keyframes loaderMove {
    0% { left: -40%; }
    100% { left: 100%; }
}

.splash-status {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--text-muted);
    letter-spacing: 0.2em;
    text-transform: uppercase;
}

.splash-hidden {
    opacity: 0;
    visibility: hidden;
}

/* Custom Cursor/Glow Effect */
.mouse-glow {
    position: fixed;
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, rgba(37, 99, 235, 0.15) 0%, transparent 70%);
    border-radius: 50%;
    pointer-events: none;
    z-index: 0;
    transform: translate(-50%, -50%);
    transition: width 0.3s, height 0.3s;
}

/* Aurora Background Effects */
.aurora-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    overflow: hidden;
    pointer-events: none;
    background: #02040a;
}

.aurora-container::before {
    content: "";
    position: absolute;
    inset: 0;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)'/%3E%3C/svg%3E");
    opacity: 0.05;
    mix-blend-mode: overlay;
    z-index: 1;
}

.aurora-blob {
    position: absolute;
    width: 800px;
    height: 800px;
    border-radius: 50%;
    filter: blur(120px);
    opacity: 0.15;
    animation: aurora 25s infinite alternate;
}

.aurora-1 {
    background: radial-gradient(circle, var(--accent-primary) 0%, transparent 70%);
    top: -200px;
    right: -100px;
    animation-delay: 0s;
}

.aurora-2 {
    background: radial-gradient(circle, #1e40af 0%, transparent 70%);
    bottom: -200px;
    left: -100px;
    animation-delay: -5s;
}

.aurora-3 {
    background: radial-gradient(circle, #ffffff 0%, transparent 70%);
    top: 30%;
    left: 10%;
    width: 500px;
    height: 500px;
    opacity: 0.05;
    animation-delay: -10s;
}

/* Login Overlay Beautification */
.login-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    background: radial-gradient(circle at center, rgba(5, 10, 25, 0.98), #010205);
    backdrop-filter: blur(40px);
    z-index: 10000;
    transition: opacity 0.5s, visibility 0.5s;
}

.login-overlay.shake .login-box {
    animation: shake 0.5s cubic-bezier(.36,.07,.19,.97) both;
}

@keyframes shake {
  10%, 90% { transform: translate3d(-1px, 0, 0); }
  20%, 80% { transform: translate3d(2px, 0, 0); }
  30%, 50%, 70% { transform: translate3d(-4px, 0, 0); }
  40%, 60% { transform: translate3d(4px, 0, 0); }
}

.login-box {
    background: rgba(15, 20, 35, 0.4);
    border: 1px solid rgba(37, 99, 235, 0.2);
    box-shadow: 0 25px 60px -12px rgba(0, 0, 0, 1),
                0 0 50px rgba(37, 99, 235, 0.15);
    padding: 4rem;
    border-radius: var(--radius-lg);
    width: 480px;
    text-align: center;
    backdrop-filter: blur(20px);
}

.login-box h2 {
    font-family: var(--font-brand);
    font-size: 2rem;
    margin-bottom: 2rem;
    background: linear-gradient(to right, #ffffff, var(--accent-primary), #60a5fa, #ffffff);
    background-size: 300% auto;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 0 10px rgba(37, 99, 235, 0.3));
    animation: textGradientMove 4s linear infinite;
}

.login-box input {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 1rem;
    margin-bottom: 1.5rem;
    font-size: 1rem;
    text-align: center;
    letter-spacing: 0.2em;
}

.login-box input:focus {
    border-color: var(--accent-primary);
    background: rgba(255, 255, 255, 0.08);
    box-shadow: 0 0 15px rgba(139, 92, 246, 0.2);
}

.preset-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px;
    background-color: var(--bg-element); /* Ciemniejsze tło elementu */
    border: 1px solid transparent; /* Ukryty border domyślnie */
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    will-change: transform, background-color;
}

.preset-item:hover {
    background-color: var(--bg-hover);
    transform: translateY(-1px);
    border-color: var(--border-subtle);
    box-shadow: 0 4px 12px rgba(0,0,0,0.2); /* Cień przy hover */
}

.preset-item.active {
    background-color: var(--bg-hover);
    border-color: var(--text-muted); /* Subtelniejszy border aktywnego */
    box-shadow: none;
}

.preset-preview {
    width: 36px; /* Nieco większy podgląd */
    height: 36px;
    border-radius: 8px; /* Zaokrąglone rogi zamiast koła */
    border: none;
    flex-shrink: 0;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.preset-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 2px;
    overflow: hidden; /* Ucięcie długich nazw */
}

.preset-name {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Delete button styling inside item */
.preset-item .delete-preset {
    opacity: 0;
    transform: scale(0.8);
    transition: all 0.2s;
    background: rgba(255,255,255,0.05);
    border-radius: 6px;
    padding: 6px;
    color: var(--text-muted);
    margin-left: 4px;
}

.preset-item:hover .delete-preset {
    opacity: 1;
    transform: scale(1);
}

.preset-item .delete-preset:hover {
    background: rgba(239, 68, 68, 0.2);
    color: var(--danger);
}

/* Przycisk Save - Nowoczesny Biały */
#btn-save-preset {
    margin-top: 10px;
    background-color: #ffffff;
    color: #000000;
    border: none;
    font-weight: 600;
    letter-spacing: -0.01em;
    height: 36px;
    border-radius: var(--radius-md);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

#btn-save-preset:hover {
    background-color: #ffffff; /* Pozostaje biały */
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(255, 255, 255, 0.2); /* Biała poświata */
}

#btn-save-preset:active {
    transform: translateY(0);
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

#btn-save-preset .icon {
    width: 16px;
    height: 16px;
    stroke-width: 2.5px; /* Pogrubiona ikona */
}

/* Update Stars Position to account for wider sidebar */
.stars-container {
    left: 340px;
    width: calc(100% - 340px);
}

.sidebar.collapsed {
    width: 0;
    padding: 0;
    opacity: 0;
    overflow: hidden;
    border-right: none;
}

.sidebar h3 {
    margin: 0;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
    /* text-transform: uppercase; Removed */
    letter-spacing: 0.02em;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border-subtle);
}

.control-section {
    display: flex;
    flex-direction: column;
    gap: 0;
    margin-bottom: 2rem;
}

.control-section:last-child {
    margin-bottom: 0;
}

.control-section h4 {
    margin: 0 0 0.5rem 0;
    color: var(--text-muted);
    font-size: 0.75rem;
    letter-spacing: 0.05em;
    font-weight: 600;
    text-transform: uppercase;
    padding-left: 2px;
}

.control-group {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: transparent;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border-subtle);
    border-radius: 0;
}

.control-group:last-child {
    border-bottom: none;
}

.control-group:hover {
    background: transparent;
}

.control-group label {
    margin: 0;
    font-size: 0.875rem;
    color: var(--text-secondary);
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
}

.control-group input[type="color"] {
    width: 32px;
    height: 32px;
    border: 2px solid var(--border-subtle);
    border-radius: 50%;
    overflow: hidden;
    cursor: pointer;
    padding: 0;
    transition: transform 0.2s, border-color 0.2s;
}

.control-group input[type="color"]:hover {
    transform: scale(1.1);
    border-color: var(--text-primary);
}

/* Custom Checkbox */
.control-group input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    width: 20px;
    height: 20px;
    background-color: var(--bg-element);
    border: 1px solid var(--border-subtle);
    border-radius: 4px;
    cursor: pointer;
    position: relative;
    margin-right: 0; /* Reset margin */
    flex-shrink: 0;
    transition: all 0.2s ease;
}

.control-group input[type="checkbox"]:checked {
    background-color: #ffffff; /* White background */
    border-color: #ffffff;
}

.control-group input[type="checkbox"]:checked::after {
    content: '';
    position: absolute;
    top: 45%;
    left: 50%;
    width: 5px;
    height: 9px;
    border: solid #000000; /* Black checkmark */
    border-width: 0 2px 2px 0;
    transform: translate(-50%, -60%) rotate(45deg);
}

.control-group input[type="checkbox"]:hover {
    border-color: var(--text-muted);
}

/* Custom Select */
.control-group select {
    appearance: none;
    -webkit-appearance: none;
    background-color: var(--bg-element);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23a1a1aa' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 32px;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    height: 36px;
    cursor: pointer;
}

.control-group.vertical {
    flex-direction: column;
    align-items: stretch;
    background: transparent;
    padding: 1rem 0;
    border-bottom: none; /* Usually last item */
}

.control-group.vertical label {
    margin-bottom: 0.5rem;
}

.control-group.vertical select {
    background-color: var(--bg-panel);
    border: 1px solid var(--border-subtle);
    padding: 0.5rem;
}

/* Modal Forms */
.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
}

.form-group.checkbox-group {
    display: flex;
    align-items: center;
}

.form-group.checkbox-group input {
    width: auto;
    margin-right: 0.5rem;
}

/* Color Picker Customization */
input[type="color"] {
    -webkit-appearance: none;
    border: none;
    width: 100%;
    height: 32px;
    border-radius: var(--radius-sm);
    padding: 0;
    background: transparent;
    cursor: pointer;
}

/* Custom Range Input */
input[type=range] {
    -webkit-appearance: none;
    width: 100%;
    background: transparent;
    padding: 0;
    height: 20px;
    margin: 0;
    border: none;
}

input[type=range]:focus {
    outline: none;
    border-color: transparent;
}

input[type=range]::-webkit-slider-thumb {
    -webkit-appearance: none;
    height: 14px;
    width: 14px;
    border-radius: 50%;
    background: var(--text-primary);
    cursor: pointer;
    margin-top: -5px; 
    box-shadow: 0 0 0 2px var(--bg-panel);
    transition: transform 0.1s, background 0.1s;
}

input[type=range]::-webkit-slider-thumb:hover {
    transform: scale(1.2);
    background: #fff;
    box-shadow: 0 0 0 2px var(--accent-primary);
}

input[type=range]::-webkit-slider-runnable-track {
    width: 100%;
    height: 4px;
    cursor: pointer;
    background: var(--bg-hover);
    border-radius: 2px;
}

input[type=range]:focus::-webkit-slider-runnable-track {
    background: var(--border-focus);
}

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

input[type="color"]::-webkit-color-swatch {
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
}

/* Eraser Size Control - Dropdown Style */
#eraser-size-control {
    position: absolute;
    top: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-panel);
    border: 1px solid var(--border-subtle);
    padding: 12px;
    border-radius: var(--radius-md);
    z-index: 100;
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 12px;
    min-width: 180px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.5);
}

#eraser-size-control.hidden {
    display: none;
}

#eraser-size-control::before {
    content: '';
    position: absolute;
    top: -5px;
    left: 50%;
    transform: translateX(-50%) rotate(45deg);
    width: 10px;
    height: 10px;
    background: var(--bg-panel);
    border-left: 1px solid var(--border-subtle);
    border-top: 1px solid var(--border-subtle);
}

#eraser-size-control label {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin: 0;
}

#eraser-size-control input[type="range"] {
    width: 100%;
}

#eraser-size-control span {
    align-self: center;
    font-size: 0.875rem;
    color: var(--text-primary);
    font-weight: 600;
    min-width: 1.5em;
    text-align: left;
}

#eraser-size-control label {
    white-space: nowrap;
}

/* Fade Controls & Brush Controls - Dropdown Style */
#fade-controls, #brush-controls {
    position: absolute;
    top: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-panel);
    border: 1px solid var(--border-subtle);
    padding: 12px;
    border-radius: var(--radius-md);
    z-index: 100;
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 160px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.5);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    opacity: 1;
    visibility: visible;
    transform-origin: top center;
}

#fade-controls.hidden, #brush-controls.hidden {
    opacity: 0;
    visibility: hidden;
    transform: translateX(-50%) translateY(-10px) scale(0.95);
    pointer-events: none;
}

#fade-controls::before, #brush-controls::before {
    content: '';
    position: absolute;
    top: -5px;
    left: 50%;
    transform: translateX(-50%) rotate(45deg);
    width: 10px;
    height: 10px;
    background: var(--bg-panel);
    border-left: 1px solid var(--border-subtle);
    border-top: 1px solid var(--border-subtle);
}

.menu-header {
    font-size: 0.7rem;
    text-transform: uppercase;
    color: var(--text-muted);
    font-weight: 600;
    letter-spacing: 0.05em;
    margin-bottom: 4px;
    padding-bottom: 4px;
    border-bottom: 1px solid var(--border-subtle);
}

.toggle-control {
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    padding: 4px 0;
}

.toggle-control .label-text {
    font-size: 0.8rem;
    color: var(--text-primary);
}

/* Modern Toggle Switch */
.toggle-switch {
    position: relative;
    width: 36px;
    height: 20px;
}

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

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--bg-element);
    transition: .3s;
    border-radius: 20px;
    border: 1px solid var(--border-subtle);
}

.slider:before {
    position: absolute;
    content: "";
    height: 14px;
    width: 14px;
    left: 2px;
    bottom: 2px;
    background-color: var(--text-muted);
    transition: .3s;
    border-radius: 50%;
}

input:checked + .slider {
    background-color: var(--accent-primary);
    border-color: var(--accent-primary);
    box-shadow: 0 0 10px var(--accent-glow);
}

input:checked + .slider:before {
    transform: translateX(16px);
    background-color: white;
}

/* Button Visibility Animation */
#btn-brush-opts {
    transition: all 0.3s ease;
    width: 24px; /* Fixed width to animate from */
    opacity: 1;
    overflow: hidden;
    margin-left: 0;
    padding: 0 2px;
}

#btn-brush-opts.hidden {
    width: 0;
    opacity: 0;
    padding: 0;
    margin: 0;
    border: none;
    pointer-events: none;
}

#fade-controls input[type="color"] {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
}

/* Main Editor Area */
.editor-area {
    flex: 1;
    display: flex;
    justify-content: center; /* Center horizontally */
    align-items: center;     /* Center vertically */
    overflow: auto;          /* Allow scrolling if too big */
    padding: 3rem;
    position: relative;
    transition: background 0.3s ease;
    z-index: 1;
}

.canvas-wrapper {
    position: relative;
    flex-shrink: 0; /* Prevent shrinking */
    box-shadow: 
        0 0 0 1px #000000,
        0 20px 50px -12px rgba(0, 0, 0, 0.5);
    border-radius: 8px;
    padding: 0;
    background: #0d1117;
    /* Clean transition for resizing & zooming */
    transition: 
        box-shadow 0.3s ease, 
        transform 0.3s ease;
    will-change: transform;
    animation: fadeIn 0.8s ease-out;
    display: flex;
    flex-direction: column;
}

/* Resize Animation Class - added via JS when switching templates */
.resizing {
    /* No animation */
}

/* Removed pulse-resize keyframes */

.canvas-wrapper:hover {
    /* transform: translateY(-2px); REMOVED */
    box-shadow: 
        0 0 0 1px #000000,
        0 30px 60px -15px rgba(0, 0, 0, 0.6);
}

canvas {
    image-rendering: pixelated; /* Zachowuje ostrość przy skalowaniu */
    cursor: crosshair;
    display: block;
    /* width: 100%; REMOVED to prevent stretching */
    /* height: 100%; REMOVED to prevent stretching */
    filter: brightness(1.0); /* Default brightness */
    margin: 0 auto; /* Center in wrapper if needed */
}

/* Background Presets */
.bg-github-dark {
    background-color: #0d1117;
    background-image: 
        radial-gradient(at 0% 0%, rgba(56, 189, 248, 0.1) 0px, transparent 50%),
        radial-gradient(at 100% 100%, rgba(74, 222, 128, 0.1) 0px, transparent 50%);
}

.bg-midnight-blue {
    background-color: #0f172a;
    background-image: 
        radial-gradient(circle at 50% 50%, rgba(30, 58, 138, 0.2) 0%, transparent 80%),
        linear-gradient(to bottom right, #0f172a, #1e293b);
}

.bg-matrix {
    background-color: #000000;
    background-image: 
        linear-gradient(0deg, transparent 24%, rgba(0, 255, 0, .05) 25%, rgba(0, 255, 0, .05) 26%, transparent 27%, transparent 74%, rgba(0, 255, 0, .05) 75%, rgba(0, 255, 0, .05) 76%, transparent 77%, transparent), 
        linear-gradient(90deg, transparent 24%, rgba(0, 255, 0, .05) 25%, rgba(0, 255, 0, .05) 26%, transparent 27%, transparent 74%, rgba(0, 255, 0, .05) 75%, rgba(0, 255, 0, .05) 76%, transparent 77%, transparent);
    background-size: 50px 50px;
}

.bg-sunset {
    background-color: #2e1065;
    background-image: 
        linear-gradient(to top right, #4c1d95, #be185d);
}

.bg-void {
    background-color: #000000;
    background-image: none;
}

.bg-abyss-blue {
    background-color: #020617;
    background-image: 
        radial-gradient(circle at 10% 20%, rgba(30, 64, 175, 0.15) 0%, transparent 40%),
        radial-gradient(circle at 90% 80%, rgba(15, 23, 42, 0.3) 0%, transparent 40%),
        linear-gradient(to bottom, #020617, #0f172a);
}

.bg-neon-night {
    background-color: #050505;
    background-image: 
        linear-gradient(180deg, rgba(0, 243, 255, 0.03) 0%, transparent 50%, rgba(0, 243, 255, 0.03) 100%),
        radial-gradient(circle at 50% 0%, rgba(56, 189, 248, 0.1) 0%, transparent 60%);
}

.bg-neon-blue {
    background-color: #050508;
    background-image: 
        linear-gradient(180deg, rgba(60, 100, 255, 0.04) 0%, transparent 50%, rgba(60, 100, 255, 0.04) 100%),
        radial-gradient(circle at 50% 0%, rgba(37, 99, 235, 0.15) 0%, transparent 60%);
}

.bg-cyber-grid {
    background-color: #0a0a0a;
    background-image: 
        linear-gradient(rgba(0, 80, 255, 0.05) 1px, transparent 1px),
        linear-gradient(90deg, rgba(0, 80, 255, 0.05) 1px, transparent 1px);
    background-size: 40px 40px;
    box-shadow: inset 0 0 100px rgba(0,0,0,0.9);
}

.bg-deep-space {
    background-color: #030712;
    background-image: 
        radial-gradient(white, rgba(255,255,255,.2) 2px, transparent 3px),
        radial-gradient(white, rgba(255,255,255,.15) 1px, transparent 2px),
        radial-gradient(white, rgba(255,255,255,.1) 2px, transparent 3px);
    background-size: 550px 550px, 350px 350px, 250px 250px;
    background-position: 0 0, 40px 60px, 130px 270px;
}

.bg-retro-terminal {
    background-color: #0d1f0d;
    background-image: 
        linear-gradient(rgba(18, 255, 0, 0.1) 1px, transparent 1px),
        linear-gradient(90deg, rgba(18, 255, 0, 0.1) 1px, transparent 1px);
    background-size: 20px 20px;
    box-shadow: inset 0 0 150px rgba(0,0,0,0.7);
}

.bg-vaporwave {
    background-color: #2b003b;
    background-image: 
        linear-gradient(rgba(255, 0, 218, 0.2) 1px, transparent 1px),
        linear-gradient(90deg, rgba(0, 255, 247, 0.2) 1px, transparent 1px),
        linear-gradient(to bottom, #2b003b, #5e1363);
    background-size: 40px 40px, 40px 40px, 100% 100%;
}

.bg-solarized-dark {
    background-color: #002b36;
    background-image: none;
}

.bg-dracula {
    background-color: #282a36;
    background-image: radial-gradient(at 50% 0%, #44475a 0%, #282a36 70%);
}

.bg-monokai {
    background-color: #272822;
    background-image: none;
}

/* Footer */
footer {
    background-color: var(--bg-main);
    border-top: 1px solid var(--border-subtle);
    padding: 0.75rem;
    text-align: center;
    font-size: 0.75rem;
    color: var(--text-muted);
    position: relative;
    z-index: 10;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(4px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 1;
    transition: opacity 0.2s;
}

.hidden {
    display: none;
    opacity: 0;
}

.modal-content {
    background: var(--bg-panel);
    padding: 2rem;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-subtle);
    width: 90%;
    max-width: 500px;
    position: relative;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

.modal h2 {
    margin-top: 0;
    font-size: 1.25rem;
    color: var(--text-primary);
}

.close-modal {
    position: absolute;
    top: 1rem;
    right: 1.5rem;
    font-size: 1.5rem;
    color: var(--text-muted);
    cursor: pointer;
    transition: color 0.2s;
}

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

textarea {
    width: 100%;
    height: 250px;
    background: var(--bg-element);
    color: var(--text-primary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    font-family: var(--font-mono);
    padding: 1rem;
    margin: 1rem 0;
    resize: none;
    font-size: 13px;
    line-height: 1.4;
    outline: none;
}

textarea:focus {
    border-color: var(--border-focus);
}

/* Template Card Styling */
.template-grid {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.template-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background-color: var(--bg-element);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.template-card:hover {
    background-color: var(--bg-hover);
    transform: translateY(-2px);
    border-color: var(--text-muted);
    box-shadow: 0 8px 16px rgba(0,0,0,0.2);
}

.template-card:active {
    transform: translateY(0);
}

.template-preview {
    width: 64px;
    height: 64px;
    background: linear-gradient(135deg, #18181b 0%, #27272a 100%);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: inset 0 0 0 1px rgba(255,255,255,0.05);
    color: var(--text-muted);
}

.template-preview svg {
    width: 24px;
    height: 24px;
    opacity: 0.5;
}

.template-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
    overflow: hidden;
}

.template-name {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.template-desc {
    font-size: 0.75rem;
    color: var(--text-muted);
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.template-tag {
    display: inline-block;
    padding: 2px 6px;
    background: rgba(255,255,255,0.05);
    border-radius: 4px;
    font-size: 0.65rem;
    color: var(--text-muted);
    margin-top: 4px;
    align-self: flex-start;
}


.login-overlay.hidden {
    display: none;
}
