:root {
    /* Blender-inspired Dark Theme Compositor Palette */
    --bg-app: #151515;
    --bg-panel: #242424;
    --bg-panel-header: #1e1e1e;
    --bg-node: #333333;
    --bg-node-header: #424242;
    --bg-node-active: #3e3e3e;
    --bg-input: #1b1b1b;
    
    --border-color: #3f3f3f;
    --border-light: #555555;
    --border-active: #568af2;
    
    --text-main: #e0e0e0;
    --text-muted: #9e9e9e;
    --text-faint: #6e6e6e;
    
    --accent-blue: #568af2;
    --accent-blue-hover: #6a9cf5;
    --accent-green: #6da25b;
    --accent-orange: #d1873e;
    --accent-purple: #9066cc;
    --accent-pink: #cc668e;
    --accent-red: #c94f4f;

    --shadow-sm: 0 2px 4px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 8px rgba(0,0,0,0.4);
    --shadow-lg: 0 8px 16px rgba(0,0,0,0.5);
    
    --radius-sm: 4px;
    --radius-md: 6px;
    --radius-lg: 8px;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: var(--bg-app);
    color: var(--text-main);
    line-height: 1.5;
    height: 100vh;
    overflow: hidden;
    font-size: 14px;
}

.hidden-svg {
    position: absolute;
    width: 0;
    height: 0;
    pointer-events: none;
}

/* Layout */
.app-layout {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

/* Top Nav */
.top-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1.5rem;
    background-color: var(--bg-panel-header);
    border-bottom: 1px solid var(--border-color);
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
    z-index: 10;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-weight: 600;
    font-size: 1rem;
    color: #fff;
    letter-spacing: -0.01em;
}

.logo svg {
    color: var(--accent-orange);
}

.nav-controls {
    display: flex;
    align-items: center;
    gap: 1rem;
}

/* Forms & Inputs */
.select-input {
    background-color: var(--bg-input);
    color: var(--text-main);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    padding: 0.5rem 2rem 0.5rem 0.75rem;
    font-family: inherit;
    font-size: 0.875rem;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%239e9e9e' 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 0.75rem center;
    cursor: pointer;
    transition: border-color 0.2s;
}

.select-input:hover, .select-input:focus {
    border-color: var(--accent-blue);
    outline: none;
}

.select-input.small {
    padding: 0.25rem 1.5rem 0.25rem 0.5rem;
    font-size: 0.75rem;
    height: auto;
}

.primary-btn {
    background-color: var(--accent-blue);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    padding: 0.5rem 1rem;
    font-family: inherit;
    font-size: 0.875rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    transition: background-color 0.2s;
    box-shadow: var(--shadow-sm);
}

.primary-btn:hover {
    background-color: var(--accent-blue-hover);
}

.icon-btn {
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-muted);
    border-radius: var(--radius-sm);
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}

.icon-btn:hover {
    background-color: var(--bg-input);
    color: var(--text-main);
}

.icon-btn.active {
    background-color: var(--bg-input);
    color: var(--accent-blue);
    border-color: var(--border-color);
}

/* Workspace Panels */
.workspace {
    display: flex;
    flex: 1;
    overflow: hidden;
}

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

.panel:last-child {
    border-right: none;
}

.panel-header {
    background-color: var(--bg-panel-header);
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.panel-header h2 {
    font-size: 0.8125rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

.split {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Node Editor Canvas */
.node-editor-panel {
    flex: 1.25;
    background-color: #202020;
    background-image: 
        linear-gradient(rgba(255,255,255,0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255,255,255,0.03) 1px, transparent 1px);
    background-size: 20px 20px;
    background-position: center center;
    position: relative;
}

.node-canvas {
    flex: 1;
    overflow: auto;
    position: relative;
    padding: 2rem;
}

.node-chain {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
    position: relative;
    z-index: 2;
    min-height: 100%;
    padding-bottom: 4rem;
}

/* Node Component */
.node {
    width: 260px;
    background-color: var(--bg-node);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    cursor: grab;
    user-select: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    position: relative;
}

.node.active {
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 1px var(--accent-blue), var(--shadow-md);
}

.node.dragging {
    opacity: 0.8;
    cursor: grabbing;
    box-shadow: var(--shadow-lg);
}

.node-header {
    padding: 0.5rem 0.75rem;
    background-color: var(--bg-node-header);
    border-top-left-radius: var(--radius-md);
    border-top-right-radius: var(--radius-md);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Node Type Colors */
.node[data-type="feGaussianBlur"] .node-header { border-top: 3px solid var(--accent-blue); }
.node[data-type="feColorMatrix"] .node-header { border-top: 3px solid var(--accent-purple); }
.node[data-type="feTurbulence"] .node-header { border-top: 3px solid var(--accent-orange); }
.node[data-type="feDisplacementMap"] .node-header { border-top: 3px solid var(--accent-red); }
.node[data-type="feOffset"] .node-header { border-top: 3px solid var(--accent-green); }
.node[data-type="feMerge"] .node-header { border-top: 3px solid #ced4da; }
.node[data-type="feComponentTransfer"] .node-header { border-top: 3px solid var(--accent-pink); }
.node[data-type="SourceGraphic"] .node-header { border-top: 3px solid var(--text-muted); }

.node-title {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-main);
}

.node-actions {
    display: flex;
    gap: 0.25rem;
}

.node-action-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.125rem;
    border-radius: 2px;
}

.node-action-btn:hover {
    color: var(--text-main);
    background-color: rgba(255,255,255,0.1);
}

.node-action-btn.delete:hover {
    color: var(--accent-red);
}

.node-body {
    padding: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.node-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-family: 'Fira Code', monospace;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Connector Pins */
.node-ports {
    display: flex;
    justify-content: space-between;
    position: absolute;
    width: 100%;
    left: 0;
}

.node-port {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background-color: var(--bg-node);
    border: 2px solid var(--text-muted);
    position: absolute;
    transform: translateX(-50%);
}

.port-in { top: -5px; left: 50%; }
.port-in.secondary { left: 25%; }
.port-out { bottom: -5px; left: 50%; border-color: var(--accent-blue); }

.node[data-type="SourceGraphic"] .port-in { display: none; }
.node-chain .node:last-child .port-out { border-color: var(--accent-green); }

/* Node connection lines visually */
.node-link-visual {
    width: 2px;
    height: 1.5rem;
    background-color: var(--text-muted);
    margin: -1.5rem auto 0;
    z-index: 1;
}

.node:first-child .node-link-visual {
    display: none;
}

/* Preview Panel */
.preview-panel {
    flex: 1;
    background-color: var(--bg-panel);
    display: flex;
    flex-direction: column;
}

.preview-controls {
    display: flex;
    gap: 0.5rem;
    background-color: var(--bg-input);
    padding: 0.25rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
}

.preview-area {
    flex: 1;
    position: relative;
    overflow: hidden;
    background-color: #000;
    background-image: 
        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;
    background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.target-container {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    isolation: isolate; /* Create new stacking context for filter */
}

.target-view {
    display: none;
    width: 100%;
    height: 100%;
    align-items: center;
    justify-content: center;
}

.target-view.active {
    display: flex;
}

/* Specific Demo Content */
.shapes-demo {
    position: relative;
    width: 200px;
    height: 200px;
}

.shape {
    position: absolute;
    box-shadow: 0 4px 12px rgba(0,0,0,0.5);
}

.shape.circle {
    border-radius: 50%;
}

.shape.c1 {
    width: 120px;
    height: 120px;
    background: #ff5e5e;
    top: 20px;
    left: 20px;
    animation: drift1 4s infinite alternate ease-in-out;
}

.shape.c2 {
    width: 100px;
    height: 100px;
    background: #5e8cff;
    bottom: 20px;
    right: 20px;
    animation: drift2 5s infinite alternate ease-in-out;
}

.shape.rect {
    width: 80px;
    height: 80px;
    background: #4ade80;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    border-radius: 12px;
    animation: spin 6s infinite linear;
}

.demo-image {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
}

.demo-text {
    font-size: 5rem;
    font-weight: 800;
    color: #fff;
    text-align: center;
    letter-spacing: -0.02em;
    line-height: 1;
}

/* Animations for shapes */
@keyframes drift1 {
    0% { transform: translate(0, 0); }
    100% { transform: translate(30px, 30px); }
}
@keyframes drift2 {
    0% { transform: translate(0, 0); }
    100% { transform: translate(-40px, -20px); }
}
@keyframes spin {
    0% { transform: translate(-50%, -50%) rotate(0deg); }
    100% { transform: translate(-50%, -50%) rotate(360deg); }
}

/* Properties Editor */
.properties-editor {
    height: 250px;
    background-color: var(--bg-panel);
    border-top: 1px solid var(--border-color);
    overflow-y: auto;
    padding: 1rem;
}

.empty-state {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-muted);
    font-size: 0.875rem;
}

/* Control Groups */
.control-group {
    margin-bottom: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.control-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
}

.control-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.control-value {
    font-family: 'Fira Code', monospace;
    font-size: 0.75rem;
    color: var(--accent-blue);
    background: var(--bg-input);
    padding: 0.125rem 0.25rem;
    border-radius: 2px;
    border: 1px solid var(--border-color);
    width: 60px;
    text-align: right;
}

.slider-container {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

input[type="range"] {
    -webkit-appearance: none;
    width: 100%;
    height: 4px;
    background: var(--bg-input);
    border-radius: 2px;
    outline: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--accent-blue);
    cursor: grab;
}

input[type="range"]::-moz-range-thumb {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--accent-blue);
    cursor: grab;
    border: none;
}

input[type="text"], input[type="color"] {
    width: 100%;
    background-color: var(--bg-input);
    color: var(--text-main);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    padding: 0.5rem;
    font-family: 'Fira Code', monospace;
    font-size: 0.8125rem;
}

input[type="text"]:focus {
    outline: none;
    border-color: var(--accent-blue);
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8125rem;
    color: var(--text-main);
    cursor: pointer;
}

/* Modal */
.modal {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background-color: rgba(0,0,0,0.7);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s;
}

.modal.active {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background-color: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-lg);
    transform: translateY(20px);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.modal.active .modal-content {
    transform: translateY(0);
}

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

.modal-header h3 {
    font-size: 1.125rem;
    font-weight: 600;
}

.modal-body {
    padding: 1.5rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.code-section h4 {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.code-block-wrapper {
    position: relative;
    background-color: #0d0d0d;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1rem;
    overflow-x: auto;
}

.code-block-wrapper pre {
    margin: 0;
    font-family: 'Fira Code', monospace;
    font-size: 0.8125rem;
    color: #e2e8f0;
    line-height: 1.5;
}

.code-block-wrapper .copy-btn {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    background-color: var(--bg-panel);
    border: 1px solid var(--border-light);
    color: var(--text-main);
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    cursor: pointer;
    transition: background-color 0.2s;
}

.code-block-wrapper .copy-btn:hover {
    background-color: var(--accent-blue);
    border-color: var(--accent-blue);
    color: #fff;
}
