:root {
    /* Dark Theme (Default) */
    --bg-base: #0F1E1F;
    --bg-surface: #1D3234;
    --bg-panel: #243D3F;
    --text-main: #FFFFFF;
    --text-muted: #A5A5A5;
    
    --accent-primary: #E0FF45;
    --accent-glow: rgba(224,255,69,0.35);
    --accent-secondary: #22D3EE;
    
    --status-active: #22c55e;
    --status-idle: #eab308;
    --status-error: #ef4444;

    --border-dim: rgba(255, 255, 255, 0.1);
    --shadow-intense: rgba(0, 0, 0, 0.5);

    --font-sans: 'Montserrat', system-ui, sans-serif;
    --font-mono: 'Montserrat', system-ui, sans-serif;
    --activity-entry-height: 64px;
    --activity-stream-height: 628px;
}

[data-theme="light"] {
    --bg-base: #f8fafc;
    --bg-surface: #ffffff;
    --bg-panel: #f1f5f9;
    --text-main: #0f172a;
    --text-muted: #64748b;
    
    --accent-primary: #6d28d9;
    --accent-glow: rgba(109, 40, 217, 0.3);
    --accent-secondary: #0284c7;
    
    --status-active: #16a34a;
    --status-idle: #d97706;
    
    --border-dim: rgba(0, 0, 0, 0.1);
    --shadow-intense: rgba(0, 0, 0, 0.1);
}

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

body {
    background-color: var(--bg-base);
    color: var(--text-main);
    font-family: var(--font-sans);
    min-height: 100vh;
    overflow-x: hidden;
    overflow-y: auto;
    transition: background-color 0.3s, color 0.3s;
    background-image: 
        radial-gradient(circle at 50% 0%, var(--accent-glow) 0%, transparent 50%),
        linear-gradient(var(--border-dim) 1px, transparent 1px),
        linear-gradient(90deg, var(--border-dim) 1px, transparent 1px);
    background-size: 100% 100%, 40px 40px, 40px 40px;
}

.app-container {
    display: flex;
    flex-direction: column;
    min-height: calc(100vh - 64px);
    padding: 1.5rem;
    max-width: 1800px;
    margin: 0 auto;
}

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

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

.brand h1 {
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: -0.02em;
}

.brand span {
    color: var(--accent-primary);
    font-weight: 400;
}

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

.btn {
    background: transparent;
    border: 1px solid var(--border-dim);
    color: var(--text-main);
    padding: 0.4rem 0.8rem;
    border-radius: 6px;
    font-family: var(--font-sans);
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s;
}

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

.pulse-indicator {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background-color: var(--status-active);
    box-shadow: 0 0 10px var(--status-active);
}

.core-pulse {
    animation: pulse-active 2s infinite ease-in-out;
}

@keyframes pulse-active {
    0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.7); }
    70% { transform: scale(1); box-shadow: 0 0 0 10px rgba(34, 197, 94, 0); }
    100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); }
}

.status-badge {
    background: rgba(34, 197, 94, 0.1);
    color: var(--status-active);
    padding: 0.4rem 0.8rem;
    border-radius: 99px;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    border: 1px solid rgba(34, 197, 94, 0.2);
}

.architecture-banner {
    background: var(--bg-surface);
    border: 1px solid var(--border-dim);
    border-left: 4px solid var(--accent-secondary);
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1rem;
    display: flex;
    gap: 1rem;
    align-items: flex-start;
    font-size: 0.85rem;
    line-height: 1.5;
    box-shadow: 0 4px 6px var(--shadow-intense);
}

.banner-icon {
    width: 32px;
    height: 32px;
    color: var(--status-idle);
    flex: 0 0 auto;
}

.banner-icon svg {
    width: 100%;
    height: 100%;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.arch-flow {
    margin-top: 0.5rem;
    padding-top: 0.5rem;
    border-top: 1px dashed var(--border-dim);
    color: var(--text-muted);
    font-family: var(--font-mono);
    font-size: 0.75rem;
}

.arch-flow span {
    color: var(--accent-primary);
    font-weight: bold;
}

.dashboard {
    display: flex;
    gap: 1.5rem;
    flex: 1;
    min-height: 0;
    align-items: stretch;
}

.visualization-panel {
    flex: 2;
    background: var(--bg-surface);
    border: 1px solid var(--border-dim);
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    box-shadow: inset 0 0 40px var(--shadow-intense);
    min-height: 0;
}

.log-panel {
    flex: 0 0 520px;
    background: var(--bg-surface);
    border: 1px solid var(--border-dim);
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
}

.panel-header {
    padding: 1.25rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-dim);
    background: rgba(0,0,0,0.05);
}

.panel-header h2 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-main);
}

.view-mode, .stream-controls span {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.stream-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.canvas-container {
    flex: 0 0 auto;
    position: relative;
    overflow: hidden;
    height: clamp(620px, 68vh, 760px);
}

#connections-svg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
}

.connection-line {
    stroke: var(--border-dim);
    stroke-width: 2;
    fill: none;
    transition: stroke 0.3s, stroke-width 0.3s;
}

.connection-line.active {
    stroke: var(--accent-primary);
    stroke-width: 3;
    filter: drop-shadow(0 0 8px var(--accent-glow));
    animation: flow 2s linear infinite;
    stroke-dasharray: 10 5;
}

@keyframes flow {
    to { stroke-dashoffset: -15; }
}

.agent-node {
    position: absolute;
    background: var(--bg-panel);
    border: 1px solid var(--border-dim);
    border-radius: 12px;
    padding: 1rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    min-width: 200px;
    z-index: 10;
    cursor: default;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), border-color 0.3s, box-shadow 0.3s;
}

.agent-node.orchestrator {
    min-width: 240px;
    border-color: var(--accent-primary);
    box-shadow: 0 0 20px var(--accent-glow);
    padding: 1.2rem;
    z-index: 20;
}

.agent-node:hover {
    transform: translate(-50%, -50%) scale(1.05) !important;
    border-color: var(--accent-primary);
    box-shadow: 0 10px 30px var(--shadow-intense);
    z-index: 30;
}

.node-glow {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 120%;
    height: 120%;
    background: radial-gradient(circle, var(--accent-glow) 0%, transparent 70%);
    opacity: 0;
    transition: opacity 0.3s;
    z-index: -1;
    pointer-events: none;
}

.agent-node.processing .node-glow {
    opacity: 1;
}

.agent-icon {
    width: 44px;
    height: 44px;
    background: var(--border-dim);
    border-radius: 8px;
    display: flex;
    justify-content: center;
    align-items: center;
    color: var(--accent-primary);
}

.agent-icon svg {
    width: 24px;
    height: 24px;
    stroke: currentColor;
    fill: none;
}

.agent-info h3 {
    font-size: 0.9rem;
    margin-bottom: 0.2rem;
}

.agent-info p {
    font-size: 0.7rem;
    color: var(--text-muted);
}

.node-status {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-left: auto;
}

.node-status.active { background: var(--status-active); box-shadow: 0 0 8px var(--status-active); }
.node-status.idle { background: var(--status-idle); }
.node-status.working { background: var(--accent-secondary); box-shadow: 0 0 8px var(--accent-secondary); animation: pulse-active 1s infinite; }

.log-container {
    flex: 0 0 auto;
    height: var(--activity-stream-height);
    padding: 1rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    font-family: var(--font-mono);
    min-height: 0;
    overscroll-behavior: contain;
}

.log-container::-webkit-scrollbar {
    width: 6px;
}
.log-container::-webkit-scrollbar-thumb {
    background: var(--border-dim);
    border-radius: 10px;
}

.log-entry {
    background: rgba(0,0,0,0.05);
    border: 1px solid var(--border-dim);
    border-left: 3px solid var(--text-muted);
    padding: 0.75rem 1rem;
    border-radius: 0 6px 6px 0;
    font-size: 0.8rem;
    min-height: var(--activity-entry-height);
    animation: slideIn 0.3s ease-out forwards;
    opacity: 0;
    transform: translateX(20px);
    flex-shrink: 0;
}

[data-theme="dark"] .log-entry {
    background: rgba(0,0,0,0.3);
}

@keyframes slideIn {
    to { opacity: 1; transform: translateX(0); }
}

.log-entry.info { border-left-color: var(--accent-secondary); }
.log-entry.success { border-left-color: var(--status-active); }
.log-entry.action { border-left-color: var(--accent-primary); }
.log-entry.warning { border-left-color: var(--status-idle); }

.log-time {
    color: var(--text-muted);
    font-size: 0.7rem;
    margin-bottom: 0.3rem;
    display: block;
}

.log-agent {
    color: var(--text-main);
    font-weight: 700;
    margin-right: 0.5rem;
}

.log-msg {
    color: var(--text-muted);
    line-height: 1.4;
}

.orchestration-cta {
    width: min(1800px, calc(100% - 48px));
    margin: 0 auto 3rem;
}

.site-footer {
    padding: 34px 24px 42px;
    border-top: 1px solid var(--border-dim);
    text-align: center;
}

.footer-text {
    margin: 0;
    color: var(--text-muted);
    font-size: 0.9rem;
}

@media (max-width: 1200px) {
    .agent-node { min-width: 180px; padding: 0.8rem; }
    .agent-icon { width: 32px; height: 32px; font-size: 0.9rem; }
}

@media (max-width: 1024px) {
    body {
        overflow: auto;
    }

    .app-container {
        height: auto;
        min-height: 100vh;
    }

    .dashboard {
        flex-direction: column;
    }
    .visualization-panel {
        min-height: 500px;
    }

    .log-panel {
        flex: 0 0 auto;
        height: auto;
        max-height: none;
    }

    .log-container {
        height: var(--activity-stream-height);
    }

    .canvas-container {
        height: 520px;
    }
}

@media (max-width: 900px) {
    .agent-node {
        min-width: 140px;
        padding: 0.55rem;
        gap: 0.5rem;
    }

    .agent-node.orchestrator {
        min-width: 180px;
        padding: 0.75rem;
    }

    .agent-icon {
        width: 32px;
        height: 32px;
    }

    .agent-icon svg {
        width: 18px;
        height: 18px;
    }

    .agent-info h3 {
        font-size: 0.75rem;
    }

    .agent-info p {
        display: none;
    }
}

@media (max-width: 520px) {
    .app-container {
        padding: 1rem;
    }

    .visualization-panel {
        min-height: 620px;
    }

    .canvas-container {
        height: 560px;
    }

    .agent-node {
        min-width: 120px;
        padding: 0.5rem;
        gap: 0.4rem;
    }

    .agent-node.orchestrator {
        min-width: 170px;
    }

    .agent-icon {
        width: 28px;
        height: 28px;
    }

    .agent-info h3 {
        font-size: 0.68rem;
    }

    #node-orchestrator { top: 10% !important; left: 50% !important; }
    #node-oracle { top: 27% !important; left: 28% !important; }
    #node-councillor { top: 27% !important; left: 72% !important; }
    #node-council { top: 44% !important; left: 50% !important; }
    #node-explorer { top: 61% !important; left: 28% !important; }
    #node-librarian { top: 61% !important; left: 72% !important; }
    #node-designer { top: 80% !important; left: 28% !important; }
    #node-fixer { top: 80% !important; left: 72% !important; }
}
