:root { --sidebar-width: 320px; }

.layout { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

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

.logo { display: flex; align-items: center; gap: 10px; }
.logo-text { font-weight: 600; font-size: 15px; }

.status-dot {
    width: 8px; height: 8px; border-radius: 50;
    background: var(--text-muted);
}
.status-dot.online { background: var(--accent); box-shadow: 0 0 8px var(--accent); }
.status-dot.error { background: var(--error); box-shadow: 0 0 8px var(--error); }

.sidebar-content { flex: 1; overflow-y: auto; padding: 16px; }

.section { margin-bottom: 20px; }

.section-title { padding: 0 4px; }

.form-group { margin-bottom: 12px; }

label {
    display: block; font-size: 11px; font-weight: 500;
    color: var(--text-secondary); margin-bottom: 6px;
}

input[type="text"], input[type="number"], select, textarea {
    width: 100%; padding: 10px 12px;
    background: var(--bg-tertiary); border: 1px solid var(--border);
    border-radius: 6px; color: var(--text-primary);
    font-family: var(--mono); font-size: 12px; transition: border-color 0.2s;
}

input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); }
input::placeholder, textarea::placeholder { color: var(--text-muted); }
textarea { min-height: 80px; resize: vertical; }

select {
    cursor: pointer; 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='%23606065' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 10px center; padding-right: 32px;
}

.toggle-row {
    display: flex; align-items: center; justify-content: space-between;
    padding: 10px 12px; background: var(--bg-tertiary);
    border: 1px solid var(--border); border-radius: 6px;
    font-size: 12px; color: var(--text-secondary);
}

.toggle {
    position: relative; width: 36px; height: 20px;
    background: var(--bg-elevated); border-radius: 10px;
    cursor: pointer; transition: background 0.2s;
}
.toggle.active { background: var(--accent); }
.toggle::after {
    content: ''; position: absolute; top: 2px; left: 2px;
    width: 16px; height: 16px; background: var(--text-primary);
    border-radius: 50%; transition: transform 0.2s;
}
.toggle.active::after { transform: translateX(16px); }

.btn {
    display: flex; align-items: center; justify-content: center; gap: 6px;
    width: 100%; padding: 10px 16px; font-family: var(--sans);
    font-size: 13px; font-weight: 600; border: none; border-radius: 6px;
    cursor: pointer; transition: all 0.2s;
}
.btn-primary { background: var(--accent); color: var(--bg-primary); }
.btn-primary:hover { background: var(--accent-dim); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-secondary { background: var(--bg-tertiary); color: var(--text-primary); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--bg-elevated); }

.nodes-grid { display: flex; flex-wrap: wrap; gap: 6px; }
.node-tag {
    font-family: var(--mono); font-size: 10px; padding: 4px 8px;
    background: var(--bg-tertiary); border: 1px solid var(--border);
    border-radius: 4px; color: var(--text-secondary);
    cursor: pointer; transition: all 0.2s;
}
.node-tag:hover { border-color: var(--accent); color: var(--accent); }

/* Main Panel */
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }

.main-header {
    padding: 16px 24px; border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between;
    background: var(--bg-secondary);
}
.main-title { font-size: 14px; font-weight: 600; color: var(--text-primary); }
.main-meta { font-family: var(--mono); font-size: 11px; color: var(--text-muted); }

.main-content { flex: 1; overflow-y: auto; padding: 24px; background: var(--bg-primary); }

.empty-state {
    display: flex; flex-direction: column; align-items: center;
    justify-content: center; height: 100%; color: var(--text-muted); text-align: center;
}
.empty-icon {
    width: 64px; height: 64px; background: var(--bg-tertiary);
    border-radius: 12px; display: flex; align-items: center;
    justify-content: center; margin-bottom: 16px; font-size: 24px;
}
.empty-title { font-size: 14px; font-weight: 500; margin-bottom: 4px; color: var(--text-secondary); }
.empty-desc { font-size: 12px; }

/* Results */
.results { display: none; }
.results.active { display: block; }

.stats-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 12px; margin-bottom: 24px; }
.stat-box { background: var(--bg-secondary); border: 1px solid var(--border); border-radius: 8px; padding: 16px; text-align: center; }
.stat-value { font-family: var(--mono); font-size: 24px; font-weight: 500; color: var(--accent); margin-bottom: 4px; }
.stat-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); }

.result-section { margin-bottom: 24px; }
.result-section:last-child { margin-bottom: 0; }

.preview-image { width: 100%; max-width: 800px; border-radius: 8px; border: 1px solid var(--border); background: var(--bg-secondary); }

.render-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(400px, 1fr)); gap: 16px; }
.render-card { background: var(--bg-secondary); border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.render-card-header {
    padding: 12px 16px; border-bottom: 1px solid var(--border);
    font-size: 12px; font-weight: 600; color: var(--text-secondary);
    text-transform: uppercase; letter-spacing: 0.05em;
}
.render-card img { width: 100%; display: block; }

.viewer-card {
    background: var(--bg-secondary); border: 1px solid var(--border);
    border-radius: 8px; overflow: hidden;
}

.download-section { display: flex; gap: 12px; margin-bottom: 24px; }
.btn-download {
    display: inline-flex; align-items: center; gap: 8px; padding: 12px 20px;
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-dim) 100%);
    color: var(--bg-primary); font-weight: 600; font-size: 13px;
    border: none; border-radius: 8px; cursor: pointer; text-decoration: none; transition: all 0.2s;
}
.btn-download:hover { transform: translateY(-1px); box-shadow: 0 4px 12px var(--accent-glow); }
.btn-download:disabled { opacity: 0.5; cursor: not-allowed; transform: none; box-shadow: none; }
.btn-download svg { width: 16px; height: 16px; }

.json-output {
    background: var(--bg-secondary); border: 1px solid var(--border); border-radius: 8px;
    padding: 16px; font-family: var(--mono); font-size: 11px; line-height: 1.6;
    max-height: 500px; overflow-y: auto; white-space: pre-wrap; word-break: break-word;
}
.json-output::-webkit-scrollbar { width: 6px; }
.json-output::-webkit-scrollbar-track { background: var(--bg-tertiary); border-radius: 3px; }
.json-output::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

.error-message {
    background: rgba(239, 68, 68, 0.1); border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: 8px; padding: 16px; color: var(--error); font-size: 13px;
}

/* Pipeline Progress */
.pipeline-progress { margin-bottom: 24px; }
.progress-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.progress-title { font-size: 12px; font-weight: 600; color: var(--text-secondary); }
.progress-meta { font-family: var(--mono); font-size: 11px; color: var(--text-muted); }
.progress-nodes { display: flex; flex-direction: column; gap: 8px; }

.progress-node {
    display: flex; align-items: center; gap: 12px; padding: 10px 14px;
    background: var(--bg-secondary); border: 1px solid var(--border);
    border-radius: 6px; transition: all 0.2s;
}
.progress-node.active { border-color: var(--accent); background: var(--accent-glow); }
.progress-node.completed { opacity: 0.6; }
.progress-node.pending { opacity: 0.4; }
.progress-node.error { border-color: var(--error); background: rgba(239, 68, 68, 0.1); }
.progress-node.error .node-indicator { border-color: var(--error); background: var(--error); color: white; }

.node-indicator {
    width: 20px; height: 20px; border-radius: 50%;
    background: var(--bg-tertiary); border: 2px solid var(--border);
    display: flex; align-items: center; justify-content: center;
    font-size: 10px; flex-shrink: 0;
}
.progress-node.active .node-indicator { border-color: var(--accent); background: var(--accent); animation: pulse 1s infinite; }
.progress-node.completed .node-indicator { border-color: var(--accent); background: var(--accent); color: var(--bg-primary); }

@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }

.node-info { flex: 1; min-width: 0; }
.node-name { font-family: var(--mono); font-size: 12px; color: var(--text-primary); }
.node-time { font-family: var(--mono); font-size: 11px; color: var(--text-muted); }

.node-progress { display: flex; align-items: center; gap: 8px; margin-top: 4px; }
.progress-bar { flex: 1; height: 4px; background: var(--bg-tertiary); border-radius: 2px; overflow: hidden; }
.progress-bar-fill { height: 100%; background: var(--accent); transition: width 0.2s; }
.progress-text { font-family: var(--mono); font-size: 10px; color: var(--accent); min-width: 60px; text-align: right; }

.node-result {
    font-family: var(--mono); font-size: 11px; color: var(--text-secondary);
    margin: 8px 0 16px 32px; padding: 12px;
    background: var(--bg-tertiary); border: 1px solid var(--border);
    border-left: 3px solid var(--accent); border-radius: 0 6px 6px 0;
    max-height: 200px; overflow-y: auto; white-space: pre-wrap;
    word-break: break-word; line-height: 1.5; position: relative;
}
.node-result.error { border-left-color: var(--error); color: var(--error); }
.node-result.has-image { max-height: none; overflow: visible; padding: 0; background: transparent; border: none; }
.node-result::-webkit-scrollbar { width: 4px; }
.node-result::-webkit-scrollbar-track { background: transparent; }
.node-result::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
.node-preview-image { width: 100%; border-radius: 6px; border: 1px solid var(--border); }

.copy-btn {
    float: right; position: sticky; top: 8px;
    width: 28px; height: 28px; margin: 0 0 8px 8px;
    background: var(--bg-elevated); border: 1px solid var(--border);
    border-radius: 4px; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    opacity: 0; transition: opacity 0.2s, background 0.2s;
}
.node-result:hover .copy-btn { opacity: 1; }
.copy-btn:hover { background: var(--bg-tertiary); border-color: var(--accent); }
.copy-btn svg { width: 14px; height: 14px; stroke: var(--text-secondary); }
.copy-btn:hover svg { stroke: var(--accent); }
.copy-btn.copied { background: var(--accent); border-color: var(--accent); }
.copy-btn.copied svg { stroke: var(--bg-primary); }

.result-row { display: flex; margin-bottom: 4px; }
.result-row:last-child { margin-bottom: 0; }
.result-key { color: var(--accent); min-width: 140px; flex-shrink: 0; }
.result-value { color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; }

@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
.fade-in { animation: fadeIn 0.3s ease-out; }

.assets-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.asset-card { background: var(--bg-secondary); border: 1px solid var(--border); border-radius: 8px; padding: 12px; }
.asset-card-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 8px; }
.asset-uid { font-family: var(--mono); font-size: 11px; color: var(--accent); word-break: break-all; }
.asset-price { font-family: var(--mono); font-size: 13px; font-weight: 600; color: var(--text-primary); white-space: nowrap; margin-left: 8px; }
.asset-category { font-size: 10px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); margin-bottom: 4px; }
.asset-dims { font-family: var(--mono); font-size: 10px; color: var(--text-secondary); }
