/* ======================================================================================== */
/* PIXEL ART STUDIO PRO - STYLESHEET */
/* Comprehensive styling with dark theme and neon accents */
/* ======================================================================================== */

/* ============================================= */
/* 1. CSS VARIABLES */
/* ============================================= */

:root {
    /* Color Palette */
    --bg-darkest: #0f0f1b;
    --bg-dark: #1a1a2e;
    --bg-medium: #16213e;
    --bg-light: #1e293b;
    --accent-primary: #00ff41;
    --accent-secondary: #ff006e;
    --accent-tertiary: #00d9ff;
    --text-primary: #e0e7ff;
    --text-secondary: #94a3b8;
    --border-color: #2d3748;
    --border-glow: rgba(0, 255, 65, 0.3);

    /* Layout Dimensions */
    --header-height: 50px;
    --tools-width: 60px;
    --right-panel-width: 280px;
    --tab-height: 50px;


    --hover-bg: #2a2a3e;
    --active-bg: #3a3a4e;


}

/* ============================================= */
/* 2. BASE RESET AND GLOBAL STYLES */
/* ============================================= */

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

body {
    font-family: 'Inter', sans-serif;
    background: linear-gradient(135deg, var(--bg-darkest) 0%, var(--bg-dark) 50%, var(--bg-medium) 100%);
    background-attachment: fixed;
    color: var(--text-primary);
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    user-select: none;
}

/* Scanline effect overlay */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    background:
        linear-gradient(rgba(0, 255, 65, 0.01) 1px, transparent 1px),
        linear-gradient(90deg, rgba(0, 217, 255, 0.01) 1px, transparent 1px);
    background-size: 2px 2px;
    pointer-events: none;
    z-index: 9999;
    opacity: 0.3;
}

/* ============================================= */
/* 3. HEADER */
/* ============================================= */

header {
    height: var(--header-height);
    background: linear-gradient(135deg, var(--bg-dark), var(--bg-medium));
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    z-index: 20;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(5px);
}

.logo-area {
    display: flex;
    align-items: baseline;
    gap: 8px;
}

.logo-area h1 {
    font-family: 'Press Start 2P', 'Inter', sans-serif;
    font-size: 16px;
    font-weight: normal;
    color: transparent;
    background-image: linear-gradient(90deg, var(--accent-primary), var(--accent-tertiary), var(--accent-primary));
    background-size: 200%;
    background-position: 0% 50%;
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: animate-background 2s infinite alternate linear;
}

.badge {
    font-size: 10px;
    background: var(--accent-secondary);
    color: white;
    padding: 2px 6px;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.header-controls {
    display: flex;
    gap: 10px;
    align-items: center;
}

.zoom-controls-header {
    display: flex;
    align-items: center;
    gap: 5px;
}

.zoom-display {
    font-family: 'Inter', sans-serif;
    font-size: 10px;
    min-width: 30px;
    text-align: center;
    color: var(--accent-tertiary);
    text-shadow: 0 0 5px rgba(0, 217, 255, 0.5);
}

/* ============================================= */
/* 4. BUTTONS */
/* ============================================= */

button {
    cursor: pointer;
    font-family: inherit;
    border: none;
    outline: none;
    transition: all 0.2s;
}

.btn {
    background: var(--bg-light);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 12px;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.btn:hover {
    background: var(--bg-medium);
    border-color: var(--text-secondary);
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

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

.btn.primary {
    background: var(--accent-primary);
    color: #000;
    font-weight: bold;
    border: none;
    box-shadow: 0 0 10px rgba(0, 255, 65, 0.2);
    animation: subtlePulse 2s ease infinite;
}

.btn.primary:hover {
    box-shadow: 0 0 15px rgba(0, 255, 65, 0.3);
    transform: translateY(-1px) scale(1.02);
}

.btn.icon-only {
    padding: 6px;
    width: 32px;
    height: 32px;
    justify-content: center;
}

.btn.active {
    background: var(--accent-primary);
    color: #000;
    border-color: var(--accent-primary);
}

.full-btn {
    background: var(--bg-light);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 100%;
    transition: all 0.2s;
}

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

.full-btn.secondary {
    background: var(--bg-medium);
    color: var(--text-secondary);
}

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

/* Close and slide-out buttons for panels */
.close-panel-btn,
.slide-out-btn {
    background: var(--accent-secondary);
    color: white;
    border: none;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
    transition: all 0.2s;
}

.close-panel-btn:hover,
.slide-out-btn:hover {
    background: var(--accent-primary);
    transform: scale(1.1);
}

/* ============================================= */
/* 5. MAIN LAYOUT */
/* ============================================= */

.main-container {
    display: flex;
    flex: 1;
    overflow: hidden;
    position: relative;
    z-index: 1;
}

.separator {
    background: linear-gradient(to right, transparent, var(--border-color), transparent);
    height: 1px;
    width: 80%;
    margin: 5px 0;
}

/* ============================================= */
/* 6. WORKSPACE & CANVAS */
/* ============================================= */

.workspace {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: linear-gradient(to bottom right, rgba(0, 217, 255, 0.01), rgba(255, 0, 110, 0.01), rgba(0, 255, 65, 0.01));
    position: relative;
    overflow: hidden;
    z-index: 1;
}

canvas {
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    position: absolute;
    top: 0;
    left: 0;
    pointer-events: auto;
}

#canvas-wrapper {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: scroll;
    background-image:
        linear-gradient(rgba(255, 255, 255, 0.02) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.02) 1px, transparent 1px),
        linear-gradient(45deg, #111 25%, transparent 25%),
        linear-gradient(-45deg, #111 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #111 75%),
        linear-gradient(-45deg, transparent 75%, #111 75%);
    background-size: 20px 20px, 20px 20px, 20px 20px, 20px 20px, 20px 20px, 20px 20px;
    background-position: 0 0, 0 0, 0 0, 0 10px, 10px -10px, -10px 0px;
    position: relative;
}

#drawing-area {
    position: relative;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
    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: 20px 20px;
    background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
    background-color: white;
    transform-origin: top left;
}

#canvas-wrapper,
#drawing-area,
canvas,
#grid-overlay,
#previewLayer,
#tilemap-overlay {
    z-index: 1;
    pointer-events: none;
}

#layer-composition {
    z-index: 5;
    pointer-events: auto;
}

#previewLayer {
    z-index: 20;
    cursor: crosshair;
    mix-blend-mode: normal;
    pointer-events: auto;
}

#grid-overlay {
    z-index: 30;
    pointer-events: none;
    mix-blend-mode: difference;
    opacity: 0.3;
}

#tilemap-overlay {
    z-index: 25;
    pointer-events: none;
    display: none;
}

/* ============================================= */
/* 7. TOOLBAR */
/* ============================================= */

.toolbar {
    width: var(--tools-width);
    background: linear-gradient(to bottom, var(--bg-dark), var(--bg-medium));
    border-right: 1px solid rgba(45, 55, 72, 0.3);
    box-shadow: 1px 0 5px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 12px 0;
    gap: 8px;
    z-index: 10000;
    position: relative;
    pointer-events: none;
}

.tool-btn,
.tool-btn.menu-parent {
    pointer-events: auto;
}

.tool-btn {
    width: 40px;
    height: 40px;
    background: transparent;
    color: var(--text-secondary);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    border: 1px solid transparent;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
    cursor: pointer;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.tool-btn:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
}

.tool-btn.active {
    color: var(--accent-primary);
    border-color: var(--accent-primary);
    background: rgba(0, 255, 65, 0.1);
    box-shadow: 0 0 12px rgba(0, 255, 65, 0.3);
    transform: translateY(-1px);
    animation: toolPulse 0.3s ease, subtlePulse 2s ease infinite;
}

.tool-btn.active::after {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    border-radius: 8px;
    background: linear-gradient(135deg, rgba(0, 255, 65, 0.2), rgba(0, 217, 255, 0.2));
    opacity: 0.8;
}

.tool-btn.active-tab {
    background-color: var(--bg-light);
    border-left: 2px solid var(--accent-tertiary);
}

/* Menu parent buttons */
.tool-btn.menu-parent {
    position: relative;
    transition: all 0.3s ease;
}

.tool-btn.menu-parent::after {
    content: '▶';
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.6rem;
    color: var(--text-secondary);
    opacity: 0.7;
}

.tool-btn.menu-parent.active::after {
    content: '▼';
    color: var(--accent-tertiary);
    opacity: 1;
}


.tool-btn.menu-parent.persistent-menu-active {
    background-color: rgba(0, 255, 65, 0.2);
    border: 1px solid var(--accent-primary);
    box-shadow: 0 0 12px var(--border-glow);
}

/* Special tool styling */
.tool-btn[data-tool="select-rect"]::after,
.tool-btn[data-tool="select-circle"]::after,
.tool-btn[data-tool="select-lasso"]::after {
    content: '';
    position: absolute;
    bottom: 4px;
    right: 4px;
    width: 8px;
    height: 8px;
    background: var(--accent-secondary);
    border-radius: 50%;
    opacity: 0.7;
}

.tool-btn[data-tool="lighten-darken"] {
    background: linear-gradient(45deg, #ffffff 50%, #000000 50%);
    background-size: 200% 200%;
    transition: background-position 0.3s ease;
}

.tool-btn[data-tool="lighten-darken"]:hover {
    background-position: 100% 100%;
}

.tool-btn[data-tool="lighten-darken"] .fas {
    color: var(--bg-dark);
    text-shadow: 0 0 2px rgba(0, 0, 0, 0.5);
}

.tool-btn.menu-parent[data-tooltip*="Drawing Tools"]::after {
    content: '';
    position: absolute;
    bottom: 4px;
    right: 4px;
    width: 6px;
    height: 6px;
    background: var(--accent-primary);
    border-radius: 50%;
    opacity: 0.8;
}

/* Active menu indicator - green dot for last clicked menu */
.tool-btn.menu-parent.active-menu::after {
    content: '';
    position: absolute;
    bottom: 4px;
    right: 4px;
    width: 6px;
    height: 6px;
    background: var(--accent-primary);
    border-radius: 50%;
    opacity: 0.8;
}

/* ============================================= */
/* 8. TOOL SUBMENUS */
/* ============================================= */

.tool-submenu {
    display: none;
    position: fixed;
    left: 60px;
    margin-left: 0;
    top: var(--submenu-top, 100px);
    background: var(--bg-dark);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 8px;
    flex-direction: column;
    gap: 6px;
    z-index: 100;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
    min-width: 48px;
    backdrop-filter: blur(10px);
    pointer-events: auto;
    transition: opacity 0.15s ease 0.1s, transform 0.15s ease; /* Add delay */
}

.tool-submenu.visible {
    display: flex;
    opacity: 1;
    transform: translateY(0);
    animation: fadeIn 0.15s ease forwards;
}

.tool-submenu::before {
    content: '';
    position: absolute;
    left: -8px;
    top: 16px;
    width: 8px;
    background: transparent;
    height: 0;
    border-top: 8px solid transparent;
    border-bottom: 8px solid transparent;
    border-right: 8px solid var(--border-color);
}

.tool-submenu .tool-btn {
    width: 40px;
    height: 40px;
    font-size: 16px;
    background: transparent;
    border: 1px solid transparent;
    z-index: 100;
    pointer-events: auto;
    cursor: pointer;
    transition: all 0.1s ease;
}


.persistent-submenu {
    display: flex;
    /*opacity: 1;*/
    /*transform: translateY(0);*/
    /*pointer-events: auto;*/
}

/* ============================================= */
/* 9. TIMELINE PANEL */
/* ============================================= */

.timeline-panel {
    height: 160px;
    background: var(--bg-dark);
    border-top: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
}

.timeline-controls {
    padding: 8px 12px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-medium);
}

.timeline-frames {
    flex: 1;
    overflow-x: auto;
    padding: 10px;
    display: flex;
    gap: 8px;
    align-items: center;
}

.frame-thumb {
    width: 60px;
    height: 60px;
    background: #FFF;
    border: 2px solid var(--border-color);
    border-radius: 4px;
    position: relative;
    cursor: pointer;
    flex-shrink: 0;
}

.frame-thumb.active {
    border-color: var(--accent-tertiary);
    box-shadow: 0 0 10px rgba(0, 217, 255, 0.3);
}

/* Onion skin frame indicators */
.frame-thumb.onion-before {
    border-color: rgba(0, 128, 255, 0.5);
    box-shadow: 0 0 6px rgba(0, 128, 255, 0.3);
}

.frame-thumb.onion-after {
    border-color: rgba(255, 128, 0, 0.5);
    box-shadow: 0 0 6px rgba(255, 128, 0, 0.3);
}

.frame-thumb canvas {
    width: 100%;
    height: 100%;
}

.frame-number {
    position: absolute;
    top: 2px;
    left: 2px;
    font-size: 9px;
    background: rgba(0, 0, 0, 0.7);
    padding: 1px 4px;
    border-radius: 2px;
}

/* ============================================= */
/* 10. LAYERS */
/* ============================================= */

.layers-list {
    max-height: 200px;
    overflow-y: auto;
}

.layer-item {
    background: var(--bg-medium);
    border: 1px solid var(--border-color);
    padding: 8px;
    margin-bottom: 6px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.layer-item.active {
    border-color: var(--accent-primary);
    background: rgba(0, 255, 65, 0.05);
}

.layer-item.drag-over {
    border-top: 2px solid var(--accent-tertiary);
}

.layer-vis-btn {
    cursor: pointer;
    color: var(--text-secondary);
    transition: color 0.2s;
}

.layer-vis-btn:hover {
    color: var(--accent-primary);
}

.layer-vis-btn.hidden-layer {
    color: var(--text-secondary);
    opacity: 0.5;
}

.layer-vis-btn.hidden-layer::before {
    content: "\f070";
}

.drag-handle {
    cursor: move;
    color: var(--text-secondary);
    transition: color 0.2s;
}

.drag-handle:hover {
    color: var(--accent-primary);
}

.layer-item .fa-trash {
    cursor: pointer;
    color: var(--text-secondary);
    transition: color 0.2s;
}

.layer-item .fa-trash:hover {
    color: var(--accent-primary);
}

/* ============================================= */
/* 11. FORM CONTROLS */
/* ============================================= */

/* Range Sliders */
input[type="range"] {
    -webkit-appearance: none;
    width: 100%;
    height: 6px;
    background: linear-gradient(to right, rgba(0, 255, 65, 0.2), rgba(0, 217, 255, 0.2));
    border-radius: 3px;
    outline: none;
    opacity: 0.8;
    transition: opacity 0.2s;
}

input[type="range"]:hover {
    opacity: 1;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    background: var(--accent-primary);
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid var(--bg-dark);
    box-shadow: 0 0 8px rgba(0, 255, 65, 0.3);
}

input[type="range"]::-moz-range-thumb {
    width: 16px;
    height: 16px;
    background: var(--accent-primary);
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid var(--bg-dark);
    box-shadow: 0 0 8px rgba(0, 255, 65, 0.3);
}

input[type="range"]::-webkit-slider-track {
    height: 6px;
    background: linear-gradient(to right, rgba(0, 255, 65, 0.2), rgba(0, 217, 255, 0.2));
    border-radius: 3px;
}

input[type="range"]::-moz-range-track {
    height: 6px;
    background: linear-gradient(to right, rgba(0, 255, 65, 0.2), rgba(0, 217, 255, 0.2));
    border-radius: 3px;
    border: none;
}

/* Number, Text, and Color Inputs */
#widthInput,
#heightInput,
input[type="number"],
input[type="text"],
input[type="color"] {
    background: #6b7280;
    border: 1px solid #9ca3af;
    color: #f3f4f6;
    border-radius: 4px;
    padding: 4px 8px;
}

input[type="number"]:focus,
input[type="text"]:focus,
input[type="color"]:focus {
    background: #9ca3af;
    border-color: #d1d5db;
    outline: none;
    box-shadow: 0 0 0 2px rgba(156, 163, 175, 0.3);
}

/* Slider with value layout */
.slider-value-container {
    display: flex;
    align-items: center;
    width: 100%;
    margin-bottom: 8px;
}

.slider-container {
    flex: 0 0 80%;
    max-width: 80%;
}

.slider-container input[type="range"] {
    width: 100%;
}

.value-container {
    flex: 0 0 20%;
    max-width: 20%;
    padding-left: 8px;
    text-align: right;
    font-family: 'Inter', sans-serif;
    font-size: 12px;
}

/* Tool options controls */
.tool-options-control {
    margin-bottom: 12px;
    padding: 6px 0;
    border-bottom: 1px solid var(--border-color);
}

.tool-options-control:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

.tool-option-label {
    display: block;
    margin-bottom: 4px;
    font-size: 11px;
    color: var(--text-secondary);
    font-weight: 500;
}

/* ============================================= */
/* 12. PALETTE */
/* ============================================= */

.palette-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    min-height: 5px;
    padding: 5px;
    background: rgba(255, 255, 255, 0.02);
    border-radius: 4px;
}

.swatch {
    width: 24px;
    height: 24px;
    border-radius: 3px;
    border: 1px solid var(--border-color);
    cursor: pointer;
    transition: all 0.2s ease;
}

.swatch:hover {
    transform: scale(1.2);
    border-color: var(--accent-primary);
    box-shadow: 0 0 8px var(--border-glow);
}

.swatch.active {
    border: 2px solid var(--accent-primary);
    transform: scale(1.1);
    box-shadow: 0 0 8px var(--border-glow);
}

/* Preset brush sizes */
.preset-brush-size {
    transition: all 0.2s ease;
    font-family: inherit;
}

.preset-brush-size:hover {
    background: var(--bg-medium);
    border-color: var(--accent-primary);
    color: var(--accent-primary);
    box-shadow: 0 0 8px var(--border-glow);
}

.preset-brush-size.active {
    background: var(--accent-primary);
    color: #000;
    border-color: var(--accent-primary);
    box-shadow: 0 0 8px var(--border-glow);
}

/* ============================================= */
/* 13. MIRROR OPTIONS */
/* ============================================= */

.mirror-axis-container, .flip-axis-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 8px;
}




/* ============================================= */
/* 14. TILEMAP PANEL */
/* ============================================= */

.tilemap-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.tilemap-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    gap: 2px;
    background: var(--bg-medium);
    padding: 4px;
    border-radius: 4px;
    border: 1px solid var(--border-color);
    width: fit-content;
    height: fit-content;
}

.tilemap-square {
    background: var(--bg-dark);
    border: 1px solid var(--border-color);
    border-radius: 2px;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    overflow: hidden;
    width: fit-content;
    height: fit-content;
    min-width: 32px;
    min-height: 32px;
}

.tilemap-square:hover {
    border-color: var(--accent-tertiary);
    box-shadow: 0 0 4px rgba(0, 217, 255, 0.3);
}

.tilemap-square.active {
    border-color: var(--accent-primary);
    box-shadow: 0 0 6px var(--border-glow);
    background: var(--accent-primary);
}

.tilemap-square.center {
    background: var(--bg-light);
    cursor: default;
    border-color: var(--accent-tertiary);
}

.tilemap-square.center:hover {
    border-color: var(--accent-tertiary);
    box-shadow: none;
}

.tilemap-square.center.active {
    background: var(--accent-tertiary);
    border-color: var(--accent-tertiary);
}

.tilemap-square canvas {
    width: 100%;
    height: 100%;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    display: block;
}

.tilemap-controls,
.tilemap-info {
    width: 100%;
    text-align: center;
}

/* ============================================= */
/* 15. SEAMLESS GRID OVERLAY */
/* ============================================= */

.seamless-grid-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 300%;
    height: 300%;
    transform: translate(-33.333%, -33.333%);
    display: none;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    gap: 0;
    z-index: 15;
    pointer-events: none;
}

.seamless-grid-overlay.enabled {
    display: grid;
}

.seamless-grid-cell {
    border: 1px solid rgba(0, 255, 65, 0.2);
    background: transparent;
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.seamless-grid-cell canvas {
    width: 100%;
    height: 100%;
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
    display: block;
    opacity: 0.5;
}

.seamless-grid-cell.center {
    border: none;
    background: transparent;
    pointer-events: none;
    opacity: 0;
}

.seamless-grid-cell.center canvas {
    display: none;
}

.seamless-grid-overlay.enabled .seamless-grid-cell:not(.center) {
    pointer-events: auto;
    cursor: crosshair;
}

.seamless-grid-overlay.enabled .seamless-grid-cell:not(.center):hover {
    border-color: rgba(0, 255, 65, 0.5);
}

.seamless-grid-overlay.enabled .seamless-grid-cell:not(.center):hover canvas {
    opacity: 0.7;
}

/* ============================================= */
/* 16. TOOLTIPS */
/* ============================================= */

.custom-tooltip {
    position: absolute;
    background: rgba(10, 10, 30, 0.96);
    color: #e0e7ff;
    padding: 12px 16px;
    border-radius: 10px;
    font-size: 13.5px;
    font-family: 'Inter', sans-serif;
    line-height: 1.6;
    pointer-events: none;
    z-index: 99999;
    opacity: 0;
    transition: opacity 0.22s ease, transform 0.22s ease;
    transform: translateY(8px);
    max-width: 320px;
    box-shadow: 0 10px 40px rgba(0, 255, 65, 0.35);
    border: 1px solid rgba(0, 255, 65, 0.5);
    backdrop-filter: blur(12px);
    white-space: pre-line;
    word-wrap: break-word;
}

/* ============================================= */
/* 16.5 SELECTION NOTE STYLING */
/* ============================================= */

/* Style for the selectnote element that shows selection tool instructions */
#selectnote {
    color: var(--text-secondary);
    font-size: 11px;
    margin-left: 4px;
    transition: all 0.2s ease;
    line-height: 1.4;
}

#selectnote strong {
    color: var(--accent-primary);
    font-weight: 500;
}

#selectnote .pill {
    display: inline-block;
    background: rgba(0, 255, 65, 0.1);
    border: 1px solid rgba(0, 255, 65, 0.3);
    border-radius: 12px;
    padding: 2px 6px;
    margin: 0 2px;
    font-size: 10px;
    color: var(--accent-primary);
    font-weight: 500;
    vertical-align: middle;
}

/* Hide the selection-description elements since we're using selectnote instead */
.selection-description {
    display: none !important;
}

/* ============================================= */
/* 17. NOTIFICATIONS */
/* ============================================= */

.notification-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 10000;
}

/* ============================================= */
/* 18. FLOATING PANEL TOGGLE */
/* ============================================= */

#panel-toggle {
    position: fixed;
    right: 280px;
    top: 50%;
    transform: translateY(-50%);
    background: var(--bg-dark);
    border: 1px solid var(--border-color);
    border-right: none;
    padding: 10px 4px;
    border-radius: 8px 0 0 8px;
    cursor: pointer;
    z-index: 100;
    color: var(--accent-tertiary);
    transition: right 0.3s ease-in-out;
    box-shadow: -2px 0 8px rgba(0, 0, 0, 0.3);
}

#panel-toggle.closed-toggle {
    right: 0;
}

#panel-toggle:hover {
    background: var(--bg-medium);
    transform: translateY(-50%) scale(1.1);
    box-shadow: -2px 0 12px rgba(0, 217, 255, 0.3);
}

/* ============================================= */
/* 19. ZOOM OVERLAY */
/* ============================================= */

.zoom-overlay {
    position: absolute;
    bottom: 20px;
    left: 20px;
    background: rgba(0, 0, 0, 0.6);
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 10px;
    color: var(--text-secondary);
    pointer-events: none;
    border: 1px solid var(--border-color);
}

/* ============================================= */
/* 20. TABBED PANELS */
/* ============================================= */


/* Panel headers and bodies */
#layers-panel .section-header,
#tilemap-panel .section-header {
    background: var(--bg-medium);
    border-bottom: 1px solid var(--border-color);
    padding: 8px 12px;
    position: sticky;
    top: 0;
    z-index: 1;
}

#layers-panel .section-body,
#tilemap-panel .section-body {
    padding: 12px;
}

#tilemap-panel .close-panel-btn {
    position: absolute;
    top: 8px;
    right: 8px;
}

#layers-panel .slide-out-btn {
    /* Positioned as needed */
}

/* Hide original side panel when using dropins */
#side-panel {
    display: none;
}

/* ============================================= */
/* 21. UTILITY CLASSES */
/* ============================================= */

.hidden {
    display: none;
}

/* ============================================= */
/* 22. ANIMATIONS */
/* ============================================= */

@keyframes animate-background {
    0% {
        background-position: 0% 50%;
    }
    100% {
        background-position: 100% 50%;
    }
}

@keyframes subtleGlow {
    0% {
        text-shadow: 0 0 8px var(--border-glow);
        color: var(--accent-primary);
    }
    50% {
        text-shadow: 0 0 12px rgba(0, 255, 65, 0.4);
        color: rgba(0, 255, 65, 0.9);
    }
    100% {
        text-shadow: 0 0 15px var(--border-glow);
        color: var(--accent-primary);
    }
}

@keyframes toolPulse {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
    100% {
        transform: scale(1);
    }
}

@keyframes subtlePulse {
    0% {
        opacity: 1;
    }
    50% {
        opacity: 0.9;
    }
    100% {
        opacity: 1;
    }
}

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

/* ============================================= */
/* 23. RESPONSIVE ADJUSTMENTS */
/* ============================================= */

@media (max-width: 320px) {
    .mirror-axis-option {
        flex-direction: column;
        text-align: center;
        gap: 8px;
    }

    .mirror-info {
        justify-content: center;
    }

    .mirror-grid {
        width: 35px;
        height: 35px;
    }
}

/* Floating Color History Overlay */
.floating-color-history {
    position: fixed;
    bottom: 180px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    background: var(--bg-light);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.color-history-swatches {
    display: flex;
    gap: 4px;
}

/* Color swatch */
.color-swatch {
    width: 32px;
    height: 32px;
    border-radius: 4px;
    cursor: pointer;
    border: 2px solid transparent;
    transition: all 0.2s ease;
}

.color-swatch:hover {
    transform: scale(1.1);
    border-color: var(--accent-color);
}

.color-swatch.active {
    border-color: var(--accent-color);
    box-shadow: 0 0 0 2px rgba(168, 85, 247, 0.5);
}

/* Color history label */
.color-history-label {
    font-size: 10px;
    color: var(--text-secondary);
    text-align: center;
    margin-top: 2px;
    font-family: 'Inter', sans-serif;
}


/* ============================================= */
/* 25. MOVE CONTAINER TOOL BUTTONS HIGHLIGHT */
/* ============================================= */

/* Highlight for selection buttons in move-container */
#move-options .move-container.tool-buttons .tool-btn {
    position: relative;
    overflow: hidden;
    transition: all 0.2s ease;
}

#move-options .move-container.tool-buttons .tool-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, rgba(0, 255, 65, 0.2), rgba(0, 217, 255, 0.2));
    opacity: 0;
    transition: opacity 0.3s ease;
    border-radius: inherit;
    z-index: 0;
}

#move-options .move-container.tool-buttons .tool-btn:hover::before {
    opacity: 1;
}

#move-options .move-container.tool-buttons .tool-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 255, 65, 0.3);
    border-color: var(--accent-primary);
}

#move-options .move-container.tool-buttons .tool-btn.selected {
    background: rgba(0, 255, 65, 0.1);
    border-color: var(--accent-primary);
    box-shadow: 0 0 12px rgba(0, 255, 65, 0.3);
    transform: translateY(-2px);
}

#move-options .move-container.tool-buttons .tool-btn.selected::after {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    border-radius: 8px;
    background: linear-gradient(135deg, rgba(0, 255, 65, 0.2), rgba(0, 217, 255, 0.2));
    z-index: -1;
    opacity: 0.8;
}


/* ============================================= */
/* 26. FLOATING BRUSH SIZE PANEL */
/* ============================================= */


/* Floating Color History Overlay */
.floating-brush-sizes {
    position: fixed;
    top: 80px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    background: var(--bg-light);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
    gap: 4px;
    transition: all 0.3s ease;
}

/* Hidden state for floating elements */
.floating-color-history.hidden,
.floating-brush-sizes.hidden {
    opacity: 0;
    visibility: hidden;
    transform: translateX(-50%) translateY(20px);
    pointer-events: none;
}

/* UI Button styling */
#uiBtn.ui-hidden {
    background: rgba(255, 0, 110, 0.2);
    border: 1px solid var(--accent-secondary);
}

#uiBtn.ui-hidden:hover {
    background: rgba(255, 0, 110, 0.3);
}

/* ============================================= */
/* 27. BRUSH PRESETS PANEL */
/* ============================================= */

/* Brush Presets Panel Container */
.brush-presets-panel {
    background: var(--bg-medium);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 12px;
    margin-top: 12px;
}

.brush-presets-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-color);
}

.brush-presets-title {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.brush-presets-actions {
    display: flex;
    gap: 6px;
}

.preset-action-btn {
    background: var(--bg-light);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    width: 28px;
    height: 28px;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.preset-action-btn:hover {
    background: var(--bg-dark);
    border-color: var(--accent-primary);
    color: var(--accent-primary);
}

/* Special styling for the load default presets button */
#loadDefaultPresetsBtn {
    background: var(--accent-tertiary);
    color: #000;
}

#loadDefaultPresetsBtn:hover {
    background: var(--accent-primary);
    color: #000;
    transform: scale(1.05);
}

/* Presets Container */
.presets-container {
    max-height: 300px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Individual Preset Item */
.preset-item {
    background: var(--bg-light);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 8px;
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
}

.preset-item:hover {
    background: var(--bg-dark);
    border-color: var(--accent-primary);
    transform: translateX(2px);
}

.preset-item.active {
    background: rgba(0, 255, 65, 0.1);
    border-color: var(--accent-primary);
    box-shadow: 0 0 8px var(--border-glow);
}

/* Preset Preview Swatch */
.preset-preview {
    width: 30px;
    height: 30px;
    border-radius: 4px;
    border: 2px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    color: var(--text-primary);
    background: white;
}

/* Preset Info Section */
.preset-info {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 12px;
    overflow: hidden;
}

.preset-name {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 80px;
}

/* Preset details shown inline */
.preset-details-inline {
    display: flex;
    gap: 12px;
    font-size: 10px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
}

.preset-detail-inline {
    display: flex;
    align-items: center;
    gap: 4px;
}

.preset-detail-inline::before {
    content: '•';
    color: var(--accent-primary);
    font-size: 8px;
}

/* Preset Details Tooltip - shown on hover */
.preset-details {
    position: absolute;
    left: 50%;
    top: -40px;
    transform: translateX(-50%);
    background: var(--bg-dark);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 8px 12px;
    font-size: 11px;
    color: var(--text-secondary);
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
    pointer-events: none;
    z-index: 100;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    white-space: nowrap;
    flex-direction: column;
    text-align: center;
}

.preset-item:hover .preset-details {
    opacity: 1;
    visibility: visible;
    top: -50px;
}

.preset-detail {
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 2px 0;
}

.preset-detail::before {
    content: '•';
    color: var(--accent-primary);
    font-size: 8px;
}

/* Tooltip arrow */
.preset-details::after {
    content: '';
    position: absolute;
    bottom: -8px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-top: 6px solid var(--border-color);
}

/* Preset Action Buttons */
.preset-actions {
    display: flex;
    gap: 4px;
    margin-left: auto;
}

.preset-action-btn {
    width: 24px;
    height: 24px;
    border-radius: 4px;
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    font-size: 10px;
}

.preset-action-btn:hover {
    background: var(--accent-primary);
    color: #000;
    border-color: var(--accent-primary);
}

.apply-btn {
    color: #00ff41;
}

.apply-btn:hover {
    background: rgba(0, 255, 65, 0.2);
}

.edit-btn {
    color: #00d9ff;
}

.edit-btn:hover {
    background: rgba(0, 217, 255, 0.2);
}

.delete-btn {
    color: #ff006e;
}

.delete-btn:hover {
    background: rgba(255, 0, 110, 0.2);
}

/* Preset Dialog */
.preset-dialog {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--bg-dark);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 16px;
    z-index: 10000;
    width: 300px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.preset-dialog-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 9999;
    backdrop-filter: blur(2px);
}

.preset-dialog-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-color);
}

.preset-dialog-title {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
}

.preset-dialog-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 16px;
    cursor: pointer;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.preset-dialog-content {
    margin-bottom: 16px;
}

.preset-dialog-input {
    width: 100%;
    padding: 8px;
    background: var(--bg-light);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 12px;
}

.preset-dialog-input:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 2px rgba(0, 255, 65, 0.2);
}

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

/* Empty State */
.presets-empty-state {
    display: none;
    text-align: center;
    padding: 20px;
    color: var(--text-secondary);
    font-size: 12px;
}

.presets-empty-state i {
    font-size: 24px;
    margin-bottom: 8px;
    color: var(--accent-primary);
}


.brush-size-swatches {
    display: flex;
    flex-direction: row;
    gap: 6px;
}

.brush-size-swatch {
    width: 30px;
    height: 20px;
    background: var(--bg-light);
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Inter', sans-serif;
    font-size: 12px;
    font-weight: bold;
    color: var(--text-primary);
    transition: all 0.2s;
    border: 1px solid var(--border-color);
}

.brush-size-swatch:hover {
    transform: scale(1.1);
    background: var(--bg-medium);
    border-color: var(--accent-primary);
    box-shadow: 0 0 8px var(--border-glow);
}

.brush-size-swatch.active {
    background: var(--accent-primary);
    color: #000;
    border-color: var(--accent-primary);
    box-shadow: 0 0 8px var(--border-glow);
}

.brush-size-swatch::before {
    content: attr(data-brush-size);
}

/* ======================================================================================== */
/* END OF PIXEL ART STUDIO PRO STYLESHEET */
/* ======================================================================================== */
