:root {
    --bg-dark: #F5F3ED;
    --bg-panel: #FFFFFF;
    --border-color: #E6E4DE;
    --text-main: #1A1A1A;
    --text-muted: #8A8883;
    --highlight: #F9F8F5;
    --accent-color: #E63946;
    --radius: 4px;
    --shadow-sm: 0 2px 6px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 6px 18px rgba(0, 0, 0, 0.10);
    --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
}

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

.jb-app {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", sans-serif;
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
}

button {
    background: none;
    border: none;
    color: inherit;
    cursor: pointer;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-family: inherit;
}
button:focus-visible,
input:focus-visible,
select:focus-visible {
    outline: 2px solid var(--accent-color);
    outline-offset: 2px;
}

/* ---------- TOP BAR ---------- */
.top-bar {
    position: relative;
    height: 56px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 24px;
    background: var(--bg-panel);
    flex-shrink: 0;
}
.logo { font-weight: 800; letter-spacing: 2px; font-size: 16px; display: flex; align-items: center; gap: 10px; }
.badge { background: var(--text-main); color: var(--bg-panel); padding: 3px 6px; border-radius: 2px; font-size: 9px; font-weight: 800; letter-spacing: 1px; }
.actions { display: flex; gap: 8px; }

/* ---------- GLOBAL PALETTES ---------- */
.global-controls {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--highlight);
    padding: 6px 12px;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    overflow-x: visible;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.02);
}
.global-controls::-webkit-scrollbar { height: 0; }
.palette-swatch {
    min-width: 30px;
    height: 30px;
    border-radius: 50%;
    overflow: hidden;
    display: flex;
    cursor: pointer;
    border: 2px solid transparent;
    transition: transform 0.3s var(--ease), box-shadow 0.3s var(--ease), border-color 0.3s var(--ease);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}
.palette-swatch:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }
.palette-swatch.active { border-color: var(--text-main); transform: scale(1.15); box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2); }
.palette-color { flex: 1; height: 100%; }

/* ---------- BUTTONS ---------- */
.primary-btn, .secondary-btn, .tool-btn {
    padding: 10px 16px;
    border-radius: var(--radius);
    font-weight: 700;
    transition: transform 0.25s var(--ease), box-shadow 0.25s var(--ease), background 0.25s var(--ease), border-color 0.25s var(--ease);
}
.primary-btn { background: var(--text-main); color: var(--bg-panel); }
.secondary-btn { background: var(--highlight); border: 1px solid var(--border-color); color: var(--text-main); }
.primary-btn:hover { transform: translateY(-1px); box-shadow: var(--shadow-md); }
.secondary-btn:hover { background: #fff; transform: translateY(-1px); box-shadow: var(--shadow-sm); border-color: #d0cece; }
.primary-btn:active, .secondary-btn:active, .tool-btn:active { transform: scale(0.97); }
button:disabled { opacity: 0.4; cursor: not-allowed; transform: none !important; box-shadow: none !important; }

.secondary-btn.recording { background: var(--accent-color); color: #fff; border-color: var(--accent-color); animation: pulse 1.5s infinite; }
@keyframes pulse { 0% { opacity: 1; } 50% { opacity: 0.65; } 100% { opacity: 1; } }

/* ---------- WORKSPACE / PANELS ---------- */
.workspace { display: flex; flex: 1; height: calc(100vh - 56px); min-height: 0; }
.panel { width: 340px; background: var(--bg-panel); border-right: 1px solid var(--border-color); display: flex; flex-direction: column; z-index: 10; min-height: 0; }
.properties { border-right: none; border-left: 1px solid var(--border-color); }
.panel-header { padding: 14px 20px; border-bottom: 1px solid var(--border-color); display: flex; justify-content: space-between; align-items: center; flex-shrink: 0; gap: 8px; }
.panel-header h3 { font-size: 11px; color: var(--text-muted); letter-spacing: 1.5px; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.header-actions { display: flex; gap: 6px; }

/* ---------- EFFECT BROWSER ---------- */
.effect-browser { border-bottom: 1px solid var(--border-color); background: var(--highlight); display: flex; flex-direction: column; max-height: 44%; }
.effect-search {
    margin: 10px 10px 6px;
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    background: var(--bg-panel);
    font-family: inherit;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-main);
    outline: none;
}
.effect-search::placeholder { color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; font-weight: 700; font-size: 10px; }

.add-effect-menu { overflow-y: auto; padding: 0 10px 10px; }
.effect-category { font-size: 9px; font-weight: 800; letter-spacing: 1.2px; color: var(--text-muted); padding: 10px 2px 6px; position: sticky; top: 0; background: var(--highlight); z-index: 1; }
.effect-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }
.add-effect-menu button {
    padding: 7px 3px;
    background: var(--bg-panel);
    font-size: 8px;
    font-weight: 700;
    border: 1px solid var(--border-color);
    border-radius: 3px;
    color: var(--text-main);
    transition: all 0.2s var(--ease);
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.add-effect-menu button:hover { border-color: var(--text-main); box-shadow: var(--shadow-sm); transform: translateY(-1px); background: #fff; }
.add-effect-menu button.used { opacity: 0.3; background: var(--text-main); color: var(--bg-panel); border-color: var(--text-main); }
.no-results { font-size: 10px; color: var(--text-muted); padding: 14px 4px; font-weight: 600; }

/* ---------- LAYER LIST ---------- */
.layer-list { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 6px; min-height: 0; }
.empty-pipeline { text-align: center; }
.layer {
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    font-size: 11px;
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
    background: var(--bg-panel);
    cursor: pointer;
    transition: border-color 0.2s var(--ease), transform 0.2s var(--ease), background 0.2s var(--ease);
    font-weight: 700;
}
.layer:hover { border-color: #C0BDB6; transform: translateX(2px); }
.layer.active { border-color: var(--text-main); background: var(--highlight); }
.layer-top { display: flex; justify-content: space-between; align-items: center; }
.layer-left { display: flex; align-items: center; gap: 8px; min-width: 0; }
.layer-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.visibility-btn { font-size: 13px; color: var(--text-main); padding: 2px; border-radius: 3px; }
.visibility-btn.disabled { opacity: 0.4; }
.layer-actions { display: flex; gap: 2px; opacity: 0; transition: opacity 0.2s; }
.layer:hover .layer-actions, .layer.active .layer-actions { opacity: 1; }
.layer-actions button { font-size: 12px; font-weight: 800; color: var(--text-muted); padding: 3px; border-radius: 3px; }
.layer-actions button:hover { color: var(--text-main); }
.layer-actions .del-btn:hover { color: var(--accent-color); }
.layer-opacity { display: flex; align-items: center; gap: 8px; }
.layer-opacity input[type=range] { flex: 1; }
.layer-opacity .op-val { font-size: 9px; color: var(--text-muted); min-width: 30px; text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- CANVAS ---------- */
.canvas-container { flex: 1; position: relative; display: flex; align-items: center; justify-content: center; background: var(--bg-dark); overflow: hidden; }
.canvas-container.dragging-file { background: var(--highlight); }
.canvas-container.dragging-file::after { content: ""; position: absolute; inset: 16px; border: 2px dashed var(--accent-color); border-radius: 8px; pointer-events: none; }
.empty-state { text-align: center; color: var(--text-muted); border: 2px dashed var(--border-color); padding: 60px; border-radius: 8px; background: var(--bg-panel); z-index: 5; display: flex; flex-direction: column; align-items: center; }
.empty-state h2 { color: var(--text-main); font-size: 18px; margin-bottom: 8px; font-weight: 800; letter-spacing: 2px; }
.empty-state p { font-size: 12px; font-weight: 600; }
.helper-text { color: var(--text-muted); font-size: 11px; padding: 16px; line-height: 1.5; font-weight: 600; }

.zoom-lock-btn {
    position: absolute; top: 20px; left: 20px;
    background: var(--bg-panel); color: var(--text-main);
    padding: 8px 12px; border-radius: var(--radius);
    border: 1px solid var(--border-color);
    font-weight: 800; font-size: 16px; cursor: pointer;
    z-index: 10; box-shadow: var(--shadow-sm);
    transition: all 0.3s var(--ease);
}
.zoom-lock-btn:hover { border-color: var(--text-main); box-shadow: var(--shadow-md); transform: translateY(-1px); }
.zoom-lock-btn.locked { border-color: var(--text-main); background: var(--text-main); color: var(--bg-panel); }

.compare-btn {
    position: absolute; top: 20px; right: 20px;
    background: var(--bg-panel); color: var(--text-main);
    padding: 8px 14px; border-radius: var(--radius);
    border: 1px solid var(--border-color);
    font-weight: 800; font-size: 10px; cursor: pointer;
    z-index: 10; box-shadow: var(--shadow-sm);
    transition: all 0.2s var(--ease);
    user-select: none;
}
.compare-btn:hover { border-color: var(--text-main); box-shadow: var(--shadow-md); transform: translateY(-1px); }
.compare-btn.comparing { background: var(--accent-color); color: #fff; border-color: var(--accent-color); }

canvas {
    max-width: 90%; max-height: 90%;
    object-fit: contain; display: none;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.08);
    border-radius: var(--radius);
    cursor: crosshair;
    transition: transform 0.6s var(--ease);
}

.canvas-bottom-bar { position: absolute; bottom: 20px; right: 20px; display: flex; align-items: center; gap: 8px; z-index: 10; }
.canvas-meta { font-size: 10px; font-weight: 700; color: var(--text-muted); background: var(--bg-panel); border: 1px solid var(--border-color); padding: 8px 12px; border-radius: var(--radius); box-shadow: var(--shadow-sm); font-variant-numeric: tabular-nums; }
.tool-btn { background: var(--bg-panel); color: var(--text-main); padding: 8px 16px; border-radius: var(--radius); border: 1px solid var(--border-color); font-weight: 800; font-size: 10px; box-shadow: var(--shadow-sm); }
.tool-btn:hover { border-color: var(--text-main); box-shadow: var(--shadow-md); transform: translateY(-1px); }
.tool-btn.danger { color: var(--bg-panel); background: var(--accent-color); border: none; }
.tool-btn.danger:hover { background: #c62f3b; }
.tool-btn.accent { background: var(--text-main); color: var(--bg-panel); padding: 6px 12px; }
.tool-btn.accent:hover { background: #333; }

/* ---------- PROPERTY CONTROLS ---------- */
.controls-container { padding: 20px; overflow-y: auto; display: flex; flex-direction: column; gap: 22px; }
.control-group label { display: flex; justify-content: space-between; align-items: center; font-size: 10px; margin-bottom: 10px; color: var(--text-muted); font-weight: 800; letter-spacing: 1px; }
.control-group span.val { color: var(--text-main); font-variant-numeric: tabular-nums; }
.control-note { font-size: 10px; color: var(--text-muted); line-height: 1.5; font-weight: 600; padding: 10px; background: var(--highlight); border-radius: var(--radius); border: 1px solid var(--border-color); }

input[type=range] { appearance: none; -webkit-appearance: none; width: 100%; background: transparent; cursor: pointer; }
input[type=range]::-webkit-slider-runnable-track { width: 100%; height: 4px; background: var(--border-color); border-radius: 2px; }
input[type=range]::-moz-range-track { width: 100%; height: 4px; background: var(--border-color); border-radius: 2px; }
input[type=range]::-webkit-slider-thumb { height: 16px; width: 16px; border-radius: 50%; background: var(--text-main); appearance: none; -webkit-appearance: none; margin-top: -6px; border: 2px solid var(--bg-panel); transition: transform 0.1s; }
input[type=range]::-moz-range-thumb { height: 14px; width: 14px; border-radius: 50%; background: var(--text-main); border: 2px solid var(--bg-panel); }
input[type=range]:active::-webkit-slider-thumb { transform: scale(1.2); }
input[type=color] { appearance: none; -webkit-appearance: none; border: none; width: 100%; height: 32px; border-radius: var(--radius); cursor: pointer; background: none; }
input[type=color]::-webkit-color-swatch-wrapper { padding: 0; }
input[type=color]::-webkit-color-swatch { border: 1px solid var(--border-color); border-radius: var(--radius); }
select { width: 100%; background: var(--highlight); color: var(--text-main); border: 1px solid var(--border-color); padding: 8px; border-radius: var(--radius); font-family: inherit; font-size: 11px; font-weight: 700; cursor: pointer; outline: none; appearance: none; }

/* ---------- TOAST ---------- */
.toast {
    position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(20px);
    background: var(--text-main); color: var(--bg-panel);
    padding: 10px 18px; border-radius: 6px; font-size: 11px; font-weight: 700;
    letter-spacing: 0.5px; box-shadow: var(--shadow-md); z-index: 100;
    opacity: 0; pointer-events: none;
    transition: opacity 0.3s var(--ease), transform 0.3s var(--ease);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- SCROLLBARS ---------- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #c9c6bf; }

/* ---------- RESPONSIVE ---------- */
@media (max-width: 1100px) {
    .panel { width: 280px; }
    .global-controls { max-width: 300px; }
}
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
    canvas { transition: none; }
}

