:root {
    
    --bg: #0a0a0b;
    --surface: #141416;
    --accent: #ff3e3e;
    --accent-glow: rgba(255, 62, 62, 0.4);
    --accent-muted: #4a1515;
    --text-main: #e4e4e7;
    --text-dim: #71717a;
    --border: #27272a;
    
    
    --grid-size: 25px;
    --panel-width: 280px;
    --flux-glow: 0 0 20px rgba(139, 92, 246, 0.3);
}

/* 1. Global Reset & Body Setup */
* { 
    box-sizing: border-box; 
    margin: 0; 
    padding: 0; 
    user-select: none; 
}

body {
    background: var(--bg);
    color: var(--text-main);
    font-family: 'Inter', Helvetica, Arial, sans-serif;
    height: 100vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* 2. Top Navigation & Toolbar */
header {
    height: 60px;
    border-bottom: 2px solid var(--accent);
    display: flex;
    align-items: center;
    padding: 0 20px;
    background: var(--surface);
    z-index: 100;
    justify-content: space-between;
}

h1 { 
    font-size: 1.5rem; 
    color: var(--accent); 
    text-transform: uppercase; 
}

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

/* 3. Reusable Button Styles */
.btn {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-main);
    padding: 8px 16px;
    cursor: pointer;
    transition: all 0.2s;
    text-transform: uppercase;
    font-size: 11px;
    font-weight: bold;
}

.btn:hover:not(:disabled) { 
    border-color: var(--accent); 
    background: var(--accent-muted); 
}

.btn:disabled { 
    opacity: 0.3; 
    cursor: not-allowed; 
}


.btn.danger { 
    background: #3f0f0f; 
    color: #ff6b6b; 
    border-color: #ff3e3e; 
    margin-top: 15px; 
    width: 100%; 
    display: none; 
}

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

/* 4. Layout Panels (Sidebars) */
main { 
    display: flex; 
    flex: 1; 
    height: calc(100vh - 60px); 
}

.panel {
    width: var(--panel-width);
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
}

.panel-right { 
    border-right: none; 
    border-left: 1px solid var(--border); 
}

.panel-header {
    padding: 12px 15px;
    font-size: 10px;
    color: var(--text-dim);
    text-transform: uppercase;
    border-bottom: 1px solid var(--border);
    letter-spacing: 2px;
    background: #000;
}

#layers-list { 
    flex: 1; 
    overflow-y: auto; 
}

/* 5. The Canvas (Working Area) */
#canvas-viewport {
    flex: 1;
    background-color: var(--bg);
    background-image: radial-gradient(circle at 2px 2px, var(--border) 1px, transparent 0);
    background-size: var(--grid-size) var(--grid-size);
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

#canvas-container {
    position: relative;
    padding: 4px;
    background: #27272a;
    border-radius: 12px;
}


#canvas-container.active-flux {
    background: linear-gradient(45deg, #7c3aed, #db2777, #7c3aed);
    background-size: 200% 200%;
    animation: flux-animation 3s linear infinite;
    box-shadow: var(--flux-glow);
}



#canvas {
    width: 800px;
    height: 600px;
    background: #0d0d0e;
    position: relative;
    border-radius: 8px;
    overflow: hidden;
}

/* 6. Canvas Elements (Shapes & Text) */
.forge-element {
    position: absolute;
    cursor: move;
    min-width: 20px;
    min-height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    overflow: hidden;
}

.forge-element.selected {
    outline: 2px solid var(--accent);
    box-shadow: 0 0 15px var(--accent-glow);
}

.forge-element.text-element {
    color: white;
    white-space: pre-wrap;
    text-align: center;
    padding: 5px;
}

/* 7. Manipulation Handles (Resizing/Rotating) */
.handle {
    width: 10px; 
    height: 10px; 
    background: #fff;
    border: 2px solid var(--accent); 
    position: absolute;
    display: none; 
    z-index: 100;
}

.selected .handle { display: block; }

.handle-tl { top: -6px; left: -6px; cursor: nwse-resize; }
.handle-tr { top: -6px; right: -6px; cursor: nesw-resize; }
.handle-bl { bottom: -6px; left: -6px; cursor: nesw-resize; }
.handle-br { bottom: -6px; right: -6px; cursor: nwse-resize; }

.handle-rotate {
    width: 14px; 
    height: 14px; 
    background: var(--accent);
    border-radius: 50%; 
    top: -30px; 
    left: calc(50% - 7px);
    cursor: crosshair; 
    position: absolute; 
    display: none;
}

.selected .handle-rotate { display: block; }

/* 8. Properties Panel Inputs */
.prop-group { 
    padding: 15px; 
    border-bottom: 1px solid var(--border); 
}

.prop-label { 
    font-size: 10px; 
    color: var(--text-dim); 
    margin-bottom: 8px; 
    display: block; 
}

.prop-input {
    width: 100%; 
    background: #000; 
    border: 1px solid var(--border);
    color: var(--accent); 
    padding: 10px; 
    font-size: 12px; 
    outline: none;
}

#size-input-row { 
    display: flex; 
    gap: 5px; 
}

/* 9. Layer List Items */
.layer-item {
    padding: 12px; 
    border-bottom: 1px solid var(--border);
    font-size: 11px; 
    cursor: pointer; 
    display: flex; 
    justify-content: space-between;
}

.layer-item.active { 
    background: var(--accent-muted); 
    border-left: 4px solid var(--accent); 
}

/* 10. Utility & Control Groups */
#page-controls {
    display: flex;
    align-items: center;
    margin-right: 15px;
    border-right: 1px solid var(--border);
    padding-right: 15px;
}

#page-label { 
    font-size: 11px; 
    margin: 0 8px; 
    font-weight: bold; 
}

.export-group { 
    padding: 15px; 
    border-top: 1px solid var(--border); 
    margin-top: auto; 
}

#text-prop-group { 
    display: none; 
}