:root {
    --bg-dark: #181a1f;
    --bg-panel: #21252b;
    --bg-input: #2c313a;
    --border: #333842;
    --accent: #3b82f6;
    --accent-hover: #2563eb;
    --text-main: #e5e7eb;
    --text-muted: #9ca3af;
    --danger: #ef4444;
    --danger-hover: #dc2626;
    --success: #10b981;
    --warning: #f59e0b;
    --warning-hover: #d97706;
}

* { box-sizing: border-box; margin: 0; padding: 0; user-select: none; }
body, html {
    width: 100%; height: 100%; overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-dark); color: var(--text-main);
    font-size: 13px;
}

.toolbar {
    height: 48px; background: var(--bg-panel); border-bottom: 1px solid var(--border);
    display: flex; align-items: center; padding: 0 12px; gap: 6px; z-index: 20; overflow-x: auto;
}
.brand {
    font-weight: 700; font-size: 15px; color: #fff; margin-right: 8px;
    display: flex; align-items: center; gap: 6px; white-space: nowrap;
}
.brand span { color: var(--accent); }
.divider { width: 1px; height: 24px; background: var(--border); margin: 0 3px; flex-shrink: 0; }

.btn {
    background: var(--bg-input); color: var(--text-main); border: 1px solid var(--border);
    padding: 6px 10px; border-radius: 5px; cursor: pointer; font-size: 12px;
    display: inline-flex; align-items: center; gap: 5px; transition: all 0.15s;
    white-space: nowrap;
}
.btn:hover:not(:disabled) { background: #383e4a; border-color: #4b5263; }
.btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 500; }
.btn.primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn.success { background: var(--success); border-color: var(--success); color: #fff; font-weight: 500; }
.btn.success:hover:not(:disabled) { background: #059669; }
.btn.danger { background: rgba(239, 68, 68, 0.15); border-color: var(--danger); color: #fca5a5; }
.btn.danger:hover:not(:disabled) { background: var(--danger); color: #fff; }
.btn.warning { background: rgba(245, 158, 11, 0.15); border-color: var(--warning); color: #fde68a; }
.btn.warning:hover:not(:disabled) { background: var(--warning-hover); color: #fff; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.workspace {
    display: flex; width: 100%; height: calc(100% - 48px); position: relative;
}

.sidebar {
    width: 330px; background: var(--bg-panel); border-right: 1px solid var(--border);
    display: flex; flex-direction: column; z-index: 10;
}
.panel-section { padding: 12px; border-bottom: 1px solid var(--border); }
.panel-title {
    font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.6px;
    color: var(--text-muted); margin-bottom: 8px; display: flex; justify-content: space-between; align-items: center;
}
.search-box { display: flex; gap: 6px; margin-bottom: 6px; }
.input {
    width: 100%; background: var(--bg-input); border: 1px solid var(--border);
    color: var(--text-main); padding: 7px 10px; border-radius: 4px; font-size: 12.5px;
    outline: none; user-select: text;
}
.input:focus { border-color: var(--accent); }

.search-results {
    max-height: 165px; overflow-y: auto; background: var(--bg-dark);
    border: 1px solid var(--border); border-radius: 4px; display: none;
}
.search-item {
    padding: 6px 10px; border-bottom: 1px solid var(--border); cursor: pointer;
    display: flex; justify-content: space-between; align-items: center; font-size: 12px;
}
.search-item:hover { background: var(--bg-input); }
.search-item:last-child { border-bottom: none; }
.badge {
    font-size: 10px; padding: 2px 6px; border-radius: 3px; background: var(--bg-panel); color: var(--text-muted);
}

.layers-container { flex: 1; overflow-y: auto; padding: 8px 12px; }
.layer-item {
    display: flex; align-items: center; gap: 8px; padding: 5px 6px;
    border-radius: 4px; cursor: pointer; font-size: 12px;
}
.layer-item:hover { background: var(--bg-input); }
.color-dot { width: 12px; height: 12px; border-radius: 3px; border: 1px solid rgba(255,255,255,0.2); flex-shrink: 0; }
.layer-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.layer-count { font-size: 11px; color: var(--text-muted); }

.properties-panel { height: 450px; overflow-y: auto; padding: 12px; background: #1c1f26; }
.prop-table { width: 100%; border-collapse: collapse; font-size: 12px; margin-bottom: 10px; }
.prop-table td { padding: 4px 6px; border-bottom: 1px solid var(--border); user-select: text; }
.prop-table td:first-child { color: var(--text-muted); width: 42%; font-weight: 500; }
.prop-actions { display: flex; gap: 6px; margin-top: 8px; }
.prop-actions .btn { flex: 1; justify-content: center; }

.canvas-area { flex: 1; position: relative; background: #111317; overflow: hidden; }
canvas { display: block; width: 100%; height: 100%; cursor: crosshair; }

.drop-overlay {
    position: absolute; inset: 16px; border: 2px dashed #4b5563; border-radius: 12px;
    background: rgba(24, 26, 31, 0.88); display: flex; flex-direction: column;
    align-items: center; justify-content: center; gap: 12px; z-index: 15;
    transition: opacity 0.2s;
}
.drop-overlay.hidden { opacity: 0; pointer-events: none; }
.drop-overlay.dragover { border-color: var(--accent); background: rgba(59, 130, 246, 0.12); }

.statusbar {
    position: absolute; bottom: 12px; left: 12px; right: 12px;
    display: flex; justify-content: space-between; pointer-events: none;
}
.status-pill {
    background: rgba(33, 37, 43, 0.92); border: 1px solid var(--border);
    padding: 6px 12px; border-radius: 6px; font-family: "SFMono-Regular", Consolas, monospace;
    font-size: 12px; color: var(--text-main); pointer-events: auto;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.hud-banner {
    position: absolute; top: 12px; left: 50%; transform: translateX(-50%);
    background: rgba(33, 37, 43, 0.95); border: 1px solid var(--accent);
    padding: 8px 16px; border-radius: 6px; font-size: 13px; color: #fff;
    display: none; align-items: center; gap: 12px; z-index: 12;
    box-shadow: 0 4px 15px rgba(0,0,0,0.4);
}

.modal-backdrop {
    position: fixed; inset: 0; background: rgba(0,0,0,0.65);
    display: none; align-items: center; justify-content: center; z-index: 50;
}
.modal {
    background: var(--bg-panel); border: 1px solid var(--border); border-radius: 8px;
    width: 460px; padding: 18px; box-shadow: 0 10px 25px rgba(0,0,0,0.5);
}
.modal h3 { margin-bottom: 12px; font-size: 15px; }
.modal p { font-size: 12px; color: var(--text-muted); margin-bottom: 10px; line-height: 1.4; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }