:root {
    --primary: #8b5cf6;
    --primary-hover: #7c3aed;
    --bg-dark: #0f172a;
    --bg-card: rgba(30, 41, 59, 0.7);
    --bg-sidebar: rgba(15, 23, 42, 0.8);
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --border: rgba(255, 255, 255, 0.1);
    --accent-red: #ef4444;
    --accent-green: #10b981;
    --accent-yellow: #f59e0b;
    --shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.5);
    --glass: blur(12px) saturate(180%);
}

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

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

/* ─── HEADER ─────────────────────────────────────────────────────────────────── */
.site-header {
    background: var(--bg-sidebar);
    backdrop-filter: var(--glass);
    border-bottom: 1px solid var(--border);
    padding: 0 24px;
    height: 64px;
    display: flex;
    align-items: center;
    z-index: 100;
}

.header-inner {
    display: flex;
    justify-content: space-between;
    width: 100%;
    align-items: center;
}

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

.brand-icon {
    font-size: 24px;
    background: linear-gradient(135deg, var(--primary), #d946ef);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.brand-name {
    font-weight: 800;
    font-size: 18px;
    letter-spacing: -0.5px;
}

.brand-tag {
    background: rgba(139, 92, 246, 0.1);
    color: var(--primary);
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
}

.tool-nav {
    display: flex;
    gap: 8px;
    margin-left: 24px;
}

.tool-nav-link {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    padding: 6px 12px;
    border-radius: 6px;
    transition: 0.2s;
}

.tool-nav-link:hover {
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.05);
}

.tool-nav-link.active {
    color: var(--primary);
    background: rgba(139, 92, 246, 0.1);
}

/* ─── MAIN LAYOUT ────────────────────────────────────────────────────────────── */
.studio-container {
    display: flex;
    flex: 1;
    overflow: hidden;
    position: relative;
}

/* SIDEBARS */
.sidebar {
    width: 260px;
    background: var(--bg-sidebar);
    backdrop-filter: var(--glass);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 90;
}

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

.sidebar-section {
    padding: 20px;
    border-bottom: 1px solid var(--border);
}

.sidebar-section h3 {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--text-muted);
    letter-spacing: 1px;
    margin-bottom: 16px;
}

/* TOOLS */
.tool-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
}

.tool-btn {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border);
    color: var(--text-main);
    padding: 12px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    transition: 0.2s;
}

.tool-btn:hover {
    background: rgba(255, 255, 255, 0.07);
    border-color: rgba(255, 255, 255, 0.2);
}

.tool-btn.active {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
    box-shadow: 0 4px 12px rgba(139, 92, 246, 0.3);
}

.tool-icon {
    font-size: 18px;
}

/* WORKSPACE */
.workspace {
    flex: 1;
    background: #000;
    background-image: 
        radial-gradient(circle at 2px 2px, rgba(255,255,255,0.05) 1px, transparent 0);
    background-size: 20px 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: auto;
    position: relative;
    padding: 100px;
}

#canvas {
    background: white;
    box-shadow: 0 20px 50px rgba(0,0,0,0.5);
    border-radius: 2px;
    max-width: 100%;
}

/* INPUTS & CONTROLS */
.control-group {
    margin-bottom: 16px;
}

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

.btn {
    width: 100%;
    padding: 10px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.05);
    color: white;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.1);
}

.btn-primary {
    background: var(--primary);
    border: none;
}

.btn-primary:hover:not(:disabled) {
    background: var(--primary-hover);
}

.btn-danger {
    color: var(--accent-red);
    border-color: rgba(239, 68, 68, 0.2);
}

.btn-danger:hover {
    background: rgba(239, 68, 68, 0.1);
}

input[type="color"] {
    -webkit-appearance: none;
    border: none;
    width: 100%;
    height: 32px;
    border-radius: 6px;
    background: none;
    cursor: pointer;
}

input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
input[type="color"]::-webkit-color-swatch { border: none; border-radius: 6px; }

/* SELECTION LIST */
.selection-list {
    list-style: none;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    overflow: hidden;
}

.selection-item {
    padding: 10px 14px;
    font-size: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: 0.2s;
}

.selection-item:hover {
    background: rgba(255, 255, 255, 0.05);
}

.selection-item.active-red {
    background: rgba(239, 68, 68, 0.1);
    color: var(--accent-red);
}

.remove-btn {
    opacity: 0.5;
    transition: 0.2s;
}

.remove-btn:hover {
    opacity: 1;
    color: var(--accent-red);
}

/* TOP TOOLBAR */
.top-toolbar {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-sidebar);
    backdrop-filter: var(--glass);
    border: 1px solid var(--border);
    padding: 6px;
    border-radius: 12px;
    display: flex;
    gap: 6px;
    z-index: 110;
    box-shadow: var(--shadow);
}

.tb-btn {
    background: none;
    border: none;
    color: var(--text-main);
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: 0.2s;
}

.tb-btn:hover {
    background: rgba(255, 255, 255, 0.07);
}

.tb-sep {
    width: 1px;
    background: var(--border);
    margin: 4px;
}

/* SVG STYLES */
.selectable { cursor: pointer; }
.selected { outline: 2px dashed var(--primary); outline-offset: 4px; }
.highlight-red { outline: 3px solid var(--accent-red) !important; outline-offset: 4px; }
.marquee { fill: rgba(139, 92, 246, 0.1); stroke: var(--primary); stroke-dasharray: 4; pointer-events: none; }
.crop-box { fill: rgba(0, 0, 0, 0.4); stroke: var(--primary); stroke-dasharray: 4; stroke-width: 2px; pointer-events: none; }

/* FILE INPUTS */
.hidden-input { display: none; }

/* IMAGE CONTROLS PANEL */
.img-control-panel {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px;
    margin-top: 12px;
}

.img-control-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 4px;
    margin-top: 8px;
}

.ic-btn {
    padding: 8px;
    font-size: 14px;
}

.zoom-group {
    grid-column: span 4;
    display: flex;
    gap: 4px;
    margin-top: 4px;
}

.asset-gallery {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    max-height: 200px;
    overflow-y: auto;
    padding: 4px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    margin-top: 10px;
}

.asset-item {
    aspect-ratio: 1;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: 0.2s;
    position: relative;
}

.asset-item:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--primary);
    transform: translateY(-2px);
}

.asset-item img, .asset-item svg {
    max-width: 90%;
    max-height: 90%;
    object-fit: contain;
    pointer-events: none;
}

.asset-badge {
    position: absolute;
    bottom: 2px;
    right: 2px;
    font-size: 8px;
    background: var(--primary);
    color: white;
    padding: 1px 3px;
    border-radius: 3px;
    text-transform: uppercase;
}

.edit-badge {
    position: absolute;
    top: 2px;
    right: 2px;
    font-size: 10px;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    padding: 2px;
    border-radius: 4px;
    cursor: pointer;
    opacity: 0;
    transition: 0.2s;
    z-index: 5;
}

.asset-item:hover .edit-badge {
    opacity: 1;
}

.edit-badge:hover {
    background: var(--primary);
}
.workspace-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: #000;
}

.tab-bar {
    background: rgba(255, 255, 255, 0.03);
    border-bottom: 1px solid var(--border);
    display: flex;
    padding: 8px 12px 0;
    gap: 4px;
    backdrop-filter: blur(10px);
}

.tab-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    border-bottom: none;
    color: var(--text-muted);
    padding: 8px 16px;
    border-radius: 8px 8px 0 0;
    font-size: 11px;
    cursor: pointer;
    transition: 0.2s;
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
}

.tab-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

.tab-btn.active {
    background: var(--bg-sidebar);
    color: var(--primary);
    border-color: var(--primary);
    border-bottom: 2px solid var(--bg-sidebar);
    margin-bottom: -1px;
    font-weight: 600;
}

.tab-close {
    font-size: 10px;
    opacity: 0.5;
    transition: 0.2s;
}

.tab-close:hover {
    opacity: 1;
    color: var(--accent-red);
}

.tab-btn.new-tab {
    border-radius: 8px;
    padding: 8px 12px;
    margin-bottom: 8px;
    margin-left: 4px;
    background: var(--primary);
    color: white;
    border: none;
    font-weight: bold;
}

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

.modal-overlay.visible {
    display: flex;
    animation: modalFadeIn 0.25s ease-out;
}

@keyframes modalFadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.modal-content {
    background: var(--bg-sidebar);
    width: 400px;
    border: 1px solid var(--border);
    border-radius: 20px;
    box-shadow: 0 20px 50px rgba(0,0,0,0.5);
    animation: modalSlide 0.3s ease-out;
    overflow: hidden;
}

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

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

.modal-header h3 { margin: 0; font-size: 18px; color: var(--primary); }

.modal-close {
    font-size: 18px;
    cursor: pointer;
    color: var(--text-muted);
    transition: 0.2s;
}

.modal-close:hover { color: white; transform: rotate(90deg); }

.modal-body { padding: 25px; }

.input-dark {
    width: 100%;
    padding: 12px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: white;
    font-family: inherit;
    font-size: 14px;
    outline: none;
    transition: 0.2s;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='white' 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 12px center;
    background-size: 16px;
}


.export-badge {
    position: absolute;
    top: 2px;
    left: 2px;
    font-size: 10px;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    padding: 2px;
    border-radius: 4px;
    cursor: pointer;
    opacity: 0;
    transition: 0.2s;
    z-index: 5;
}

.asset-item:hover .export-badge {
    opacity: 1;
}

.export-badge:hover {
    background: #10b981;
}
