/* ============================================
   Pattern Generator - Figma-inspired Design
   ============================================ */

/* ============================================================================
   Typography & Font Loading
   ============================================================================ */

/**
 * Inter Variable Font
 * Supports weights 100-900 for flexible typography
 * Uses woff2-variations format for optimal performance
 */
@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-weight: 100 900;
    font-display: swap;
    src: url('assets/fonts/InterVariable.woff2') format('woff2-variations');
}

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

/* ============================================================================
   CSS Variables & Design Tokens
   ============================================================================ */

/**
 * Design system variables for consistent theming
 * Light mode values defined here, dark mode overrides below
 */
:root {
    /* Colors - Light Mode */
    --bg-primary: #ffffff;
    --bg-secondary: #f7f7f7;
    --bg-tertiary: #f0f0f0;
    --bg-hover: #f5f5f5;
    --bg-active: #e5e5e5;
    
    --text-primary: #000000;
    --text-secondary: #666666;
    --text-tertiary: #999999;
    
    /* Toolbar specific */
    --toolbar-icon-color: #000000;
    --toolbar-icon-opacity: 0.6;
    --toolbar-icon-opacity-hover: 1;
    
    --border-primary: #e5e5e5;
    --border-secondary: #d0d0d0;
    --border-focus: #ffffff;
    
    --accent: #ffffff;
    --accent-hover: #e5e5e5;
    
    /* Shadows - Enhanced with depth */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.12);
    --shadow-xl: 0 12px 40px rgba(0, 0, 0, 0.16);
    --shadow-layered: 0 2px 4px rgba(0, 0, 0, 0.06), 0 4px 12px rgba(0, 0, 0, 0.08), 0 8px 24px rgba(0, 0, 0, 0.1);
    
    /* Texture & Grain */
    --grain-opacity: 0.03;
    --paper-texture: url("data:image/svg+xml,%3Csvg viewBox='0 0 400 400' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.4'/%3E%3C/svg%3E");
    
    /* Layout */
    --header-height: 48px;
    --controls-width: 280px;
    --spacing-xs: 4px;
    --spacing-sm: 8px;
    --spacing-md: 12px;
    --spacing-lg: 16px;
    --spacing-xl: 24px;
    
    /* Typography */
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-size-xs: 11px;
    --font-size-sm: 12px;
    --font-size-md: 13px;
    --font-size-lg: 14px;
    
    /* Border radius */
    --radius-sm: 4px;
    --radius-md: 6px;
    --radius-lg: 8px;
}

/**
 * Dark mode theme overrides
 * Maintains same structure as light mode for easy maintenance
 */
[data-theme="dark"] {
    --bg-primary: #1e1e1e;
    --bg-secondary: #2a2a2a;
    --bg-tertiary: #333333;
    --bg-hover: #3a3a3a;
    --bg-active: #444444;
    
    --text-primary: #ffffff;
    --text-secondary: #b0b0b0;
    --text-tertiary: #808080;
    
    /* Toolbar specific */
    --toolbar-icon-color: #ffffff;
    --toolbar-icon-opacity: 0.6;
    --toolbar-icon-opacity-hover: 1;
    
    --border-primary: #3a3a3a;
    --border-secondary: #4a4a4a;
    --border-focus: #ffffff;
    
    --accent: #ffffff;
    --accent-hover: #d0d0d0;
    
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.4);
    --shadow-xl: 0 12px 40px rgba(0, 0, 0, 0.5);
    --shadow-layered: 0 2px 4px rgba(0, 0, 0, 0.2), 0 4px 12px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.4);
}

body {
    font-family: var(--font-family);
    font-size: var(--font-size-md);
    line-height: 1.5;
    color: var(--text-primary);
    background: var(--bg-primary);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow: hidden;
    position: relative;
}

/* Subtle paper texture overlay for visual depth */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: var(--paper-texture);
    opacity: var(--grain-opacity);
    pointer-events: none;
    z-index: 9999;
    mix-blend-mode: multiply;
}

/* ============================================
   App Layout
   ============================================ */

.app {
    display: flex;
    flex-direction: column;
    height: 100vh;
    width: 100vw;
}

.header {
    height: var(--header-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 var(--spacing-lg);
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border-primary);
    position: relative;
    z-index: 100;
    
    /* Initial state for animation */
    opacity: 0;
    transform: translateY(-10px);
    animation: headerFadeIn 0.5s cubic-bezier(0.21, 1.02, 0.73, 1) forwards;
}

@keyframes headerFadeIn {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.title {
    font-size: var(--font-size-md);
    font-weight: 600;
    letter-spacing: -0.01em;
    color: var(--text-primary);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

/* Windows Menu */
.windows-menu-container {
    position: relative;
}

.windows-menu {
    position: absolute;
    top: calc(100% + var(--spacing-xs));
    right: 0;
    background: var(--bg-primary);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    padding: var(--spacing-xs);
    min-width: 160px;
    z-index: 1000;
}

.windows-menu-item {
    padding: var(--spacing-xs);
}

.windows-menu-item label {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    padding: var(--spacing-sm);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: var(--font-size-sm);
    color: var(--text-primary);
    user-select: none;
    transition: background 0.15s ease;
}

.windows-menu-item label:hover {
    background: var(--bg-hover);
}

.windows-menu-item input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: var(--text-primary);
}

.theme-toggle {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    color: var(--text-secondary);
    transition: all 0.15s ease;
    will-change: background, color;
    margin: 0 2px;
}

.theme-toggle:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.theme-icon {
    position: absolute;
    animation: iconFadeIn 0.3s ease;
    will-change: opacity, transform, filter;
}

@keyframes iconFadeIn {
    0% {
        opacity: 0;
        transform: scale(0.8);
        filter: blur(4px);
    }
    100% {
        opacity: 1;
        transform: scale(1);
        filter: blur(0px);
    }
}

@keyframes iconFadeOut {
    0% {
        opacity: 1;
        transform: scale(1);
        filter: blur(0px);
    }
    100% {
        opacity: 0;
        transform: scale(0.8);
        filter: blur(4px);
    }
}

.layout {
    display: flex;
    flex: 1;
    overflow: hidden;
    position: relative;
}

/* ============================================
   Preview Section
   ============================================ */

.preview-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-secondary);
    overflow: hidden;
    position: relative;
    
    /* Subtle gradient overlay for depth */
    background-image: 
        radial-gradient(circle at 20% 30%, rgba(0, 0, 0, 0.01) 0%, transparent 50%),
        radial-gradient(circle at 80% 70%, rgba(0, 0, 0, 0.01) 0%, transparent 50%);
}

.canvas-container {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: auto;
    position: relative;
    padding: var(--spacing-xl);
}

.canvas-wrapper {
    position: relative;
    box-shadow: var(--shadow-layered);
    border-radius: 2px;
    will-change: transform;
    
    /* Enhanced depth with multiple shadow layers */
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.04));
    
    /* Subtle paper texture on canvas wrapper */
    background: var(--bg-primary);
}

.canvas-wrapper::before {
    content: '';
    position: absolute;
    inset: -2px;
    border-radius: 2px;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.1) 0%, rgba(0, 0, 0, 0.05) 100%);
    pointer-events: none;
    z-index: -1;
    opacity: 0.5;
}

#pattern-canvas {
    display: block;
    background: white;
    cursor: grab;
    user-select: none;
    will-change: transform;
}

#pattern-canvas:active {
    cursor: grabbing;
}

/* Floating Toolbar */
.preview-toolbar {
    position: absolute;
    bottom: var(--spacing-xl);
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 2px;
    background: var(--bg-primary);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-lg);
    padding: var(--spacing-xs);
    box-shadow: var(--shadow-layered);
    backdrop-filter: blur(8px);
    z-index: 10;
    pointer-events: auto;
    
    /* Initial state for animation */
    opacity: 0;
    transform: translateX(-50%) translateY(20px);
    transition: opacity 0.5s cubic-bezier(0.21, 1.02, 0.73, 1) 0.4s,
                transform 0.5s cubic-bezier(0.21, 1.02, 0.73, 1) 0.4s;
}

.preview-toolbar.toolbar-loaded {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.toolbar-btn {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    color: var(--text-secondary);
    transition: all 0.15s ease;
    will-change: background, opacity;
}

.toolbar-btn img {
    width: 16px;
    height: 16px;
    opacity: var(--toolbar-icon-opacity);
    transition: all 0.2s ease;
    will-change: transform, filter;
}

/* Light mode - black icons */
.toolbar-btn img {
    filter: brightness(0) saturate(100%) invert(0%) sepia(0%) saturate(0%) hue-rotate(180deg) brightness(0%) contrast(100%);
}

/* Dark mode - white icons */
[data-theme="dark"] .toolbar-btn img {
    filter: brightness(0) saturate(100%) invert(100%) sepia(0%) saturate(0%) hue-rotate(180deg) brightness(100%) contrast(100%);
}

.flip-horizontal {
    transform: scaleX(-1);
}

.toolbar-btn {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    color: var(--text-secondary);
    transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
    will-change: background, opacity, transform;
    position: relative;
}

.toolbar-btn::before {
    content: '';
    position: absolute;
    inset: -2px;
    border-radius: var(--radius-sm);
    background: var(--bg-hover);
    opacity: 0;
    transition: opacity 0.2s ease;
    z-index: -1;
}

.toolbar-btn:hover::before {
    opacity: 1;
}

.toolbar-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    transform: scale(1.1);
}

.toolbar-btn:hover img {
    opacity: var(--toolbar-icon-opacity-hover);
    transform: scale(1.1);
}

.toolbar-btn:hover img.flip-horizontal {
    transform: scaleX(-1) scale(1.1);
}

.toolbar-btn:active {
    background: var(--bg-active);
}

.toolbar-btn:active img {
    transform: scale(0.95);
}

.toolbar-btn:active img.flip-horizontal {
    transform: scaleX(-1) scale(0.95);
}

.toolbar-btn svg {
    opacity: var(--toolbar-icon-opacity);
    transition: all 0.2s ease;
}

.toolbar-btn:hover svg {
    opacity: var(--toolbar-icon-opacity-hover);
    transform: scale(1.1);
}

.toolbar-btn:active svg {
    transform: scale(0.95);
}

.zoom-display {
    font-size: var(--font-size-sm);
    color: var(--text-primary);
    opacity: var(--toolbar-icon-opacity);
    padding: 0 var(--spacing-sm);
    min-width: 48px;
    text-align: center;
    font-weight: 500;
    font-variant-numeric: tabular-nums;
}

.toolbar-divider {
    width: 1px;
    height: 20px;
    background: var(--border-primary);
    margin: 0 var(--spacing-xs);
}

/* ============================================
   Draggable Windows
   ============================================ */

.windows-container {
    position: fixed;
    top: var(--header-height);
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: 100;
}

.draggable-window {
    position: absolute;
    width: 280px;
    min-width: 200px;
    max-width: 400px;
    background: var(--bg-primary);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-layered);
    display: flex;
    flex-direction: column;
    pointer-events: auto;
    will-change: left, top, transform, opacity;
    overflow: hidden;
    z-index: 100;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    
    /* Initial state for staggered animation */
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    transition: opacity 0.4s cubic-bezier(0.21, 1.02, 0.73, 1),
                transform 0.4s cubic-bezier(0.21, 1.02, 0.73, 1),
                box-shadow 0.3s ease;
}

.draggable-window.window-loaded {
    opacity: 1;
    transform: translateY(0) scale(1);
}

.draggable-window.dragging {
    cursor: grabbing;
    box-shadow: var(--shadow-xl);
    transform: translateY(-2px) scale(1.01);
    transition: opacity 0.4s cubic-bezier(0.21, 1.02, 0.73, 1),
                transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1),
                box-shadow 0.3s ease;
}

.draggable-window.dragging * {
    pointer-events: none;
}

.draggable-window.minimized {
    height: auto;
}

.draggable-window.minimized .window-content {
    display: none;
}

.draggable-window.hidden {
    display: none;
}

.window-titlebar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--spacing-sm) var(--spacing-md);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-primary);
    cursor: move;
    user-select: none;
    flex-shrink: 0;
}

.window-titlebar[data-drag-handle] {
    cursor: grab;
}

.window-titlebar[data-drag-handle]:active {
    cursor: grabbing;
}

.window-title {
    font-size: var(--font-size-sm);
    font-weight: 600;
    color: var(--text-primary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.window-controls {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
}

.window-btn {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 16px;
    line-height: 1;
    padding: 0;
    transition: all 0.15s ease;
    will-change: background, color;
}

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

.window-btn:active {
    background: var(--bg-active);
    transform: scale(0.95);
}

/* Icon styling for all window buttons */
.window-btn img {
    filter: brightness(0) saturate(100%) invert(47%) sepia(0%) saturate(0%) hue-rotate(180deg) brightness(95%) contrast(88%);
    transition: filter 0.2s ease;
}

.window-btn:hover img {
    filter: brightness(0) saturate(100%) invert(47%) sepia(0%) saturate(0%) hue-rotate(180deg) brightness(95%) contrast(88%);
}

[data-theme="dark"] .window-btn img {
    filter: brightness(0) saturate(100%) invert(87%) sepia(0%) saturate(0%) hue-rotate(180deg) brightness(95%) contrast(88%);
}

.window-content {
    padding: var(--spacing-lg);
    overflow-y: auto;
    flex: 1;
    max-height: calc(100vh - var(--header-height) - 60px);
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

/* Allow text selection only in input fields */
.window-content input[type="text"],
.window-content input[type="number"],
.window-content input[type="color"],
.window-content textarea {
    user-select: text;
    -webkit-user-select: text;
    -moz-user-select: text;
    -ms-user-select: text;
}

.draggable-window.dragging .window-content {
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

/* Asymmetric default window positions - breaking spatial predictability */
#window-pattern {
    top: 60px;
    left: 24px;
    animation-delay: 0.1s;
}

#window-properties {
    top: 100px;
    left: 320px; /* Overlapping with pattern window for depth */
    animation-delay: 0.2s;
    z-index: 101; /* Slightly above pattern window */
}

#window-page-setup {
    top: 140px;
    left: 80px; /* Asymmetric positioning */
    animation-delay: 0.3s;
    z-index: 102; /* Highest z-index for visual hierarchy */
}

/* Responsive: stack windows on smaller screens */
@media (max-width: 1200px) {
    #window-properties {
        top: 320px;
        left: 20px;
        z-index: 101;
    }
    
    #window-page-setup {
        top: 620px;
        left: 20px;
        z-index: 102;
    }
}

.section-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: var(--font-size-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-tertiary);
    margin-bottom: var(--spacing-xs);
}

.section-reset-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    padding: 0;
    background: transparent;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    opacity: 0.5;
    transition: opacity 0.2s ease, background-color 0.2s ease;
    will-change: opacity, background-color;
}

.section-reset-btn:hover {
    opacity: 1;
    background: var(--bg-secondary);
}

.section-reset-btn img {
    filter: brightness(0) saturate(100%) invert(47%) sepia(0%) saturate(0%) hue-rotate(180deg) brightness(95%) contrast(88%);
    transition: filter 0.2s ease;
    will-change: filter;
}

[data-theme="dark"] .section-reset-btn img {
    filter: brightness(0) saturate(100%) invert(87%) sepia(0%) saturate(0%) hue-rotate(180deg) brightness(95%) contrast(88%);
}

.section-divider {
    height: 1px;
    background: var(--border-primary);
    margin: var(--spacing-lg) 0;
}

/* Pattern Tabs */
.pattern-tabs {
    display: flex;
    gap: var(--spacing-xs);
    margin-bottom: var(--spacing-md);
    border-bottom: 1px solid var(--border-primary);
}

.pattern-tab {
    flex: 1;
    padding: var(--spacing-sm) var(--spacing-md);
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-secondary);
    font-size: var(--font-size-xs);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.pattern-tab:hover {
    color: var(--text-primary);
}

.pattern-tab.active {
    color: var(--text-primary);
    border-bottom-color: var(--text-primary);
}

.pattern-category {
    display: none;
}

.pattern-category.active {
    display: block;
}

/* Pattern Cards */
.pattern-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--spacing-md);
    margin-top: var(--spacing-md);
}

.pattern-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-sm);
    padding: var(--spacing-md) var(--spacing-sm);
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
    color: var(--text-secondary);
    font-size: var(--font-size-xs);
    font-weight: 500;
    will-change: background, border-color, transform;
    position: relative;
    overflow: hidden;
}

.pattern-card::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.1) 0%, rgba(0, 0, 0, 0.05) 100%);
    opacity: 0;
    transition: opacity 0.2s ease;
    pointer-events: none;
}

.pattern-card:hover {
    background: var(--bg-hover);
    border-color: var(--border-secondary);
    transform: translateY(-2px) scale(1.02);
    box-shadow: var(--shadow-md);
}

.pattern-card:hover::before {
    opacity: 1;
}

.pattern-card.active {
    background: var(--text-primary);
    border-color: var(--text-primary);
    color: var(--bg-primary);
}

.pattern-card svg,
.pattern-card img {
    width: 24px;
    height: 24px;
}

.pattern-card img {
    filter: brightness(0) saturate(100%) invert(47%) sepia(0%) saturate(0%) hue-rotate(180deg) brightness(95%) contrast(88%);
    transition: filter 0.1s ease, transform 0.2s ease, opacity 0.2s ease;
    will-change: transform, filter, opacity;
}

[data-theme="dark"] .pattern-card img {
    filter: brightness(0) saturate(100%) invert(70%) sepia(0%) saturate(0%) hue-rotate(180deg) brightness(95%) contrast(88%);
}

.pattern-card:hover img {
    transform: scale(1.05);
}

.pattern-card.active img {
    filter: brightness(0) saturate(100%) invert(100%) sepia(0%) saturate(0%) hue-rotate(180deg) brightness(100%) contrast(100%);
}

[data-theme="dark"] .pattern-card.active img {
    filter: brightness(0) saturate(100%) invert(0%) sepia(0%) saturate(0%) hue-rotate(180deg) brightness(0%) contrast(100%);
}

.theme-toggle img {
    filter: brightness(0) saturate(100%) invert(47%) sepia(0%) saturate(0%) hue-rotate(180deg) brightness(95%) contrast(88%);
    transition: filter 0.15s ease;
}

[data-theme="dark"] .theme-toggle img {
    filter: brightness(0) saturate(100%) invert(70%) sepia(0%) saturate(0%) hue-rotate(180deg) brightness(95%) contrast(88%);
}

.theme-toggle:hover img {
    filter: brightness(0) saturate(100%) invert(0%) sepia(0%) saturate(0%) hue-rotate(180deg) brightness(0%) contrast(100%);
}

[data-theme="dark"] .theme-toggle:hover img {
    filter: brightness(0) saturate(100%) invert(100%) sepia(0%) saturate(0%) hue-rotate(180deg) brightness(100%) contrast(100%);
}

.download-button svg {
    width: 16px;
    height: 16px;
}

/* Property Rows */
.property-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--spacing-md);
    min-height: 36px;
    margin-bottom: var(--spacing-md);
}

.property-row:last-child {
    margin-bottom: 0;
}

.property-label {
    font-size: var(--font-size-sm);
    color: var(--text-primary);
    font-weight: 500;
    flex-shrink: 0;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

.property-label[data-slider] {
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
    padding: 4px 8px;
    margin: -4px -8px;
    border-radius: var(--radius-sm);
    transition: background-color 0.15s ease;
}

.property-label[data-slider]:hover {
    color: var(--text-secondary);
    background-color: var(--bg-hover);
}

.property-label[data-slider].dragging {
    background-color: var(--bg-active);
    color: var(--text-primary);
}

body.dragging-slider {
    user-select: none !important;
}

.property-select {
    flex: 1;
    height: 28px;
    padding: 0 var(--spacing-sm);
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: var(--font-size-sm);
    font-family: var(--font-family);
    cursor: pointer;
    transition: all 0.15s ease;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg width='12' height='12' viewBox='0 0 12 12' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M3 5l3 3 3-3' stroke='%23666' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
    padding-right: 28px;
}

.property-select:hover {
    background-color: var(--bg-hover);
    border-color: var(--border-secondary);
}

.property-select:focus {
    outline: none;
    border-color: var(--text-primary);
}

.property-input-group {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-sm);
    padding: 0 var(--spacing-sm);
    height: 28px;
    flex: 1;
    transition: all 0.15s ease;
}

.property-input-group:focus-within {
    border-color: var(--text-primary);
    box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.1);
}

[data-theme="dark"] .property-input-group:focus-within {
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.1);
}

.property-input {
    flex: 1;
    border: none;
    background: transparent;
    color: var(--text-primary);
    font-size: var(--font-size-sm);
    font-family: var(--font-family);
    font-variant-numeric: tabular-nums;
    outline: none;
    min-width: 0;
}

.property-input::-webkit-inner-spin-button,
.property-input::-webkit-outer-spin-button {
    opacity: 1;
    height: 20px;
}

.property-unit {
    font-size: var(--font-size-xs);
    color: var(--text-tertiary);
    flex-shrink: 0;
}

.property-slider {
    width: 100%;
    height: 2px;
    -webkit-appearance: none;
    appearance: none;
    background: var(--border-primary);
    outline: none;
    border-radius: 2px;
    cursor: pointer;
    margin-bottom: var(--spacing-md);
}

.property-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    background: var(--text-primary);
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid var(--bg-primary);
    box-shadow: var(--shadow-sm);
    transition: all 0.15s ease;
}

.property-slider::-webkit-slider-thumb:hover {
    transform: scale(1.1);
}

.property-slider::-moz-range-thumb {
    width: 16px;
    height: 16px;
    background: var(--text-primary);
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid var(--bg-primary);
    box-shadow: var(--shadow-sm);
    transition: all 0.15s ease;
}

.property-slider::-moz-range-thumb:hover {
    transform: scale(1.1);
}

/* Custom Color Picker - Unified Input Field */
.color-picker-wrapper {
    display: flex;
    align-items: center;
    flex: 1;
    height: 28px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-sm);
    padding: 0;
    transition: border-color 0.1s ease, background-color 0.1s ease, box-shadow 0.1s ease;
    cursor: text;
    overflow: hidden;
    position: relative;
}

.color-picker-wrapper:hover {
    border-color: var(--border-secondary);
    background: var(--bg-hover);
}

.color-picker-wrapper:focus-within {
    border-color: var(--text-primary);
    background: var(--bg-primary);
    box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.1);
}

[data-theme="dark"] .color-picker-wrapper:focus-within {
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.1);
}

.color-swatch {
    position: absolute;
    left: 0;
    top: 0;
    width: 28px;
    height: 28px;
    flex-shrink: 0;
    cursor: pointer;
    z-index: 1;
    background-image: 
        linear-gradient(45deg, #ccc 25%, transparent 25%),
        linear-gradient(-45deg, #ccc 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #ccc 75%),
        linear-gradient(-45deg, transparent 75%, #ccc 75%);
    background-size: 6px 6px;
    background-position: 0 0, 0 3px, 3px -3px, -3px 0px;
    transition: border-color 0.1s ease;
    border-right: 1px solid var(--border-primary);
}

[data-theme="dark"] .color-swatch {
    background-image: 
        linear-gradient(45deg, #444 25%, transparent 25%),
        linear-gradient(-45deg, #444 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #444 75%),
        linear-gradient(-45deg, transparent 75%, #444 75%);
}

.color-swatch::after {
    content: '';
    position: absolute;
    inset: 0;
    background-color: inherit;
    border-radius: var(--radius-sm) 0 0 var(--radius-sm);
    transition: background-color 0.05s ease;
}

.color-picker-wrapper:hover .color-swatch {
    border-right-color: var(--border-secondary);
}

.color-picker-wrapper:focus-within .color-swatch {
    border-right-color: var(--text-primary);
}

.color-picker-hidden {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
    pointer-events: none;
}

.color-hex-input {
    flex: 1;
    height: 100%;
    padding: 0 var(--spacing-sm) 0 36px;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: var(--font-size-sm);
    font-family: 'SF Mono', 'Monaco', 'Courier New', monospace;
    font-variant-numeric: tabular-nums;
    outline: none;
    text-transform: uppercase;
    cursor: text;
    min-width: 0;
    letter-spacing: 0.5px;
    transition: none;
    position: relative;
    z-index: 0;
}

.color-hex-input::placeholder {
    color: var(--text-tertiary);
    text-transform: none;
    letter-spacing: 0;
}

.color-hex-input:focus {
    cursor: text;
}

.color-hex-input:focus::placeholder {
    opacity: 0.5;
}

/* Color Input */
.color-input-group {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    flex: 1;
}

.color-picker {
    width: 28px;
    height: 28px;
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-sm);
    cursor: pointer;
    background: transparent;
    padding: 0;
}

.color-picker::-webkit-color-swatch-wrapper {
    padding: 2px;
}

.color-picker::-webkit-color-swatch {
    border: none;
    border-radius: 3px;
}


/* Custom Size Group */
.custom-size-group {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
    margin-top: var(--spacing-md);
}

.dimension-row {
    position: relative;
}

.dimension-controls {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
}

.lock-btn {
    background: transparent;
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-sm);
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-secondary);
    transition: all 0.15s ease;
    flex-shrink: 0;
    will-change: background, border-color, color;
}

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

.lock-btn.locked {
    background: var(--bg-active);
    border-color: var(--text-secondary);
    color: var(--text-primary);
}

.lock-btn .lock-open,
.lock-btn .lock-closed {
    transition: all 0.2s ease;
    will-change: opacity, transform, filter;
}

.lock-btn .lock-open {
    display: block;
}

.lock-btn .lock-closed {
    display: none;
}

.lock-btn.locked .lock-open {
    display: none;
    animation: iconFadeOut 0.2s ease;
}

.lock-btn.locked .lock-closed {
    display: block;
    animation: iconFadeIn 0.3s ease;
}

.lock-icon {
    flex-shrink: 0;
}

/* Toggle Switch */
.toggle-group {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
    margin-top: var(--spacing-md);
    margin-bottom: var(--spacing-md);
}

.toggle-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--spacing-sm);
    cursor: pointer;
    user-select: none;
    position: relative;
}

.toggle-input {
    position: absolute;
    opacity: 0;
    width: 36px;
    height: 20px;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    margin: 0;
    cursor: pointer;
    z-index: 2;
}

.toggle-switch {
    position: relative;
    width: 36px;
    height: 20px;
    background: var(--border-primary);
    border-radius: 10px;
    transition: background-color 0.2s ease;
    flex-shrink: 0;
}

.toggle-switch::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 16px;
    height: 16px;
    background: var(--bg-primary);
    border-radius: 50%;
    transition: transform 0.2s ease;
    box-shadow: var(--shadow-sm);
}

.toggle-input:checked ~ .toggle-switch {
    background: var(--text-primary);
}

.toggle-input:checked ~ .toggle-switch::after {
    transform: translateX(16px);
}

.toggle-text {
    font-size: var(--font-size-sm);
    color: var(--text-primary);
    font-weight: 500;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

/* Disabled state for options */
.property-row[data-disabled] {
    opacity: 0.5;
    pointer-events: none;
}

.property-row[data-disabled] .property-input,
.property-row[data-disabled] .property-input-group,
.property-row[data-disabled] .color-picker-wrapper {
    opacity: 0.5;
    pointer-events: none;
}

.color-picker-wrapper[data-disabled] {
    opacity: 0.5;
    pointer-events: none;
    cursor: not-allowed;
}

.color-picker-wrapper[data-disabled] .color-swatch {
    cursor: not-allowed;
}

.color-picker-wrapper[data-disabled] .color-hex-input {
    cursor: not-allowed;
}

/* Checkbox Group */
.checkbox-group {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
    margin-top: var(--spacing-md);
}

.checkbox-item {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    cursor: pointer;
    padding: var(--spacing-xs) 0;
    font-size: var(--font-size-sm);
    color: var(--text-primary);
    user-select: none;
}

.checkbox-item input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: var(--accent);
}

.checkbox-item:hover {
    color: var(--text-primary);
}

/* Action buttons */
.secondary-button {
    width: 100%;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-sm);
    padding: 12px 20px;
    background: var(--bg-secondary);
    border: 1px solid var(--text-secondary);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: var(--font-size-sm);
    font-weight: 500;
    font-family: var(--font-family);
    cursor: pointer;
    transition: all 0.2s ease;
    will-change: transform, background-color, border-color;
}

.secondary-button:hover {
    background: var(--bg-hover);
    border-color: var(--text-secondary);
}

.secondary-button:active {
    transform: scale(0.98);
}

.secondary-button img {
    filter: brightness(0) saturate(100%) invert(47%) sepia(0%) saturate(0%) hue-rotate(180deg) brightness(95%) contrast(88%);
    transition: filter 0.2s ease;
    will-change: filter;
}

[data-theme="dark"] .secondary-button img {
    filter: brightness(0) saturate(100%) invert(87%) sepia(0%) saturate(0%) hue-rotate(180deg) brightness(95%) contrast(88%);
}

/* Download Button */
.download-button {
    width: 100%;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-sm);
    background: var(--text-primary);
    color: var(--bg-primary);
    border: none;
    border-radius: var(--radius-md);
    font-size: var(--font-size-sm);
    font-weight: 600;
    font-family: var(--font-family);
    cursor: pointer;
    transition: all 0.15s ease;
    margin-top: auto;
    will-change: transform, background;
}

.download-button:hover {
    opacity: 0.9;
}

.download-button:active {
    opacity: 0.8;
}

.download-button svg {
    transition: all 0.2s ease;
    will-change: transform;
}

.download-button:hover svg {
    transform: translateY(2px);
}

/* ============================================
   Modals
   ============================================ */

.modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: var(--spacing-xl);
}

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

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

.modal-header h2 {
    font-size: var(--font-size-lg);
    font-weight: 600;
    color: var(--text-primary);
}

.modal-close {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 24px;
    line-height: 1;
    transition: all 0.15s ease;
}

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

.modal-body {
    padding: var(--spacing-lg);
    overflow-y: auto;
}

/* Shortcuts Grid */
.shortcuts-grid {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-xl);
}

.shortcut-group h4 {
    font-size: var(--font-size-sm);
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: var(--spacing-md);
}

.shortcut-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--spacing-sm) 0;
    font-size: var(--font-size-sm);
}

kbd {
    display: inline-block;
    padding: var(--spacing-xs) var(--spacing-sm);
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-sm);
    font-family: 'SF Mono', 'Monaco', 'Courier New', monospace;
    font-size: var(--font-size-xs);
    color: var(--text-primary);
    box-shadow: var(--shadow-sm);
}

/* ============================================
   Toast Notifications
   ============================================ */

/* ============================================
   Toast Notifications (Sonner-inspired)
   ============================================ */

#toast-container {
    position: fixed;
    bottom: 0;
    right: 0;
    padding: var(--spacing-lg);
    display: flex;
    flex-direction: column-reverse;
    gap: var(--spacing-sm);
    z-index: 2000;
    pointer-events: none;
    max-width: 420px;
    width: 100%;
}

.toast {
    display: flex;
    align-items: flex-start;
    gap: var(--spacing-md);
    background: var(--bg-primary);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-lg);
    padding: var(--spacing-md);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    font-size: var(--font-size-sm);
    color: var(--text-primary);
    pointer-events: all;
    cursor: pointer;
    user-select: none;
    position: relative;
    
    /* Initial state */
    opacity: 0;
    transform: translateY(100%) scale(0.95);
    transition: all 0.4s cubic-bezier(0.21, 1.02, 0.73, 1);
}

.toast-visible {
    opacity: 1;
    transform: translateY(0) scale(1);
}

.toast-removing {
    opacity: 0;
    transform: translateX(100%) scale(0.95);
    transition: all 0.2s ease;
}

.toast-content {
    display: flex;
    align-items: flex-start;
    gap: var(--spacing-md);
    flex: 1;
    min-width: 0;
}

.toast-icon {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: 2px;
}

.toast-success .toast-icon {
    color: #10b981;
}

.toast-error .toast-icon {
    color: #ef4444;
}

.toast-info .toast-icon {
    color: #0ea5e9;
}

.toast-message {
    flex: 1;
    line-height: 1.5;
    padding-top: 2px;
}

.toast-close {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    color: var(--text-tertiary);
    transition: all 0.15s ease;
    padding: 0;
    margin-top: 2px;
    opacity: 0;
}

.toast:hover .toast-close {
    opacity: 1;
}

.toast-close:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

/* Rich colors variant */
.toast-success {
    background: linear-gradient(to right, #10b981 0%, #10b981 3px, var(--bg-primary) 3px);
}

.toast-error {
    background: linear-gradient(to right, #ef4444 0%, #ef4444 3px, var(--bg-primary) 3px);
}

.toast-info {
    background: linear-gradient(to right, #0ea5e9 0%, #0ea5e9 3px, var(--bg-primary) 3px);
}

/* Hover state */
.toast:hover {
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
    transform: translateY(-2px) scale(1.01);
}

/* Dark mode adjustments */
[data-theme="dark"] .toast {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

[data-theme="dark"] .toast:hover {
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6);
}

/* ============================================
   Responsive
   ============================================ */

@media (max-width: 768px) {
    .layout {
        flex-direction: column-reverse;
    }
    
    .controls-section {
        width: 100%;
        border-left: none;
        border-top: 1px solid var(--border-primary);
        max-height: 50vh;
    }
    
    .preview-toolbar {
        bottom: var(--spacing-md);
        scale: 0.9;
    }
}

/* ============================================
   Scrollbar Styling
   ============================================ */

::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border-secondary);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-tertiary);
}
