* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: system-ui, sans-serif; background: #0a0a0a; color: #e0e0e0; height: 100vh; display: flex; flex-direction: column; }

/* Top bar */
#top-bar { display: flex; align-items: center; gap: 1rem; padding: 0.4rem 1rem; background: #111; border-bottom: 1px solid #222; }
#top-bar h1 { font-size: 0.85rem; font-weight: 600; color: #888; }
#status { font-size: 0.75rem; color: #666; }

/* Node metrics bar */
#node-metrics { display: flex; gap: 1px; padding: 0; background: #111; border-bottom: 1px solid #222; }
.node-meter { flex: 1; display: flex; align-items: center; gap: 0.4rem; padding: 0.25rem 0.6rem; background: #0a0a0a; }
.nm-label { font-size: 0.65rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em; min-width: 4.5rem; }
#meter-input .nm-label { color: #f59e0b; }
#meter-output .nm-label { color: #34d399; }
#meter-memorizer .nm-label { color: #c084fc; }
#meter-sensor .nm-label { color: #60a5fa; }
.nm-bar { flex: 1; height: 6px; background: #1a1a1a; border-radius: 3px; overflow: hidden; }
.nm-fill { height: 100%; width: 0%; border-radius: 3px; transition: width 0.3s, background-color 0.3s; background: #333; }
.nm-text { font-size: 0.6rem; color: #555; min-width: 5rem; text-align: right; font-family: monospace; }

/* Two-column layout: chat 1/3 | trace 2/3 */
#main { flex: 1; display: grid; grid-template-columns: 1fr 2fr; gap: 1px; background: #222; overflow: hidden; min-height: 0; }

.panel { background: #0a0a0a; display: flex; flex-direction: column; overflow: hidden; }
.panel-header { padding: 0.5rem 0.75rem; font-size: 0.75rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; border-bottom: 1px solid #222; flex-shrink: 0; }
.panel-header.chat-h { color: #60a5fa; background: #0a1628; }
.panel-header.trace-h { color: #a78bfa; background: #120a1e; }

/* Chat panel */
.chat-panel { display: flex; flex-direction: column; }
#messages { flex: 1; overflow-y: auto; padding: 0.5rem; display: flex; flex-direction: column; gap: 0.4rem; }
.msg { max-width: 90%; padding: 0.5rem 0.75rem; border-radius: 0.6rem; line-height: 1.4; white-space: pre-wrap; font-size: 0.9rem; }
.msg.user { align-self: flex-end; background: #2563eb; color: white; }
.msg.assistant { align-self: flex-start; background: #1e1e1e; border: 1px solid #333; }
.msg.assistant.streaming { border-color: #2563eb; }

/* Input bar */
#input-bar { display: flex; gap: 0.5rem; padding: 0.75rem; background: #111; border-top: 1px solid #222; }
#input { flex: 1; padding: 0.5rem 0.75rem; background: #1a1a1a; color: #e0e0e0; border: 1px solid #333; border-radius: 0.4rem; font-size: 0.9rem; outline: none; }
#input:focus { border-color: #2563eb; }
button { padding: 0.5rem 1rem; background: #2563eb; color: white; border: none; border-radius: 0.4rem; cursor: pointer; font-size: 0.9rem; }
button:hover { background: #1d4ed8; }

/* Trace panel */
#trace { flex: 1; overflow-y: auto; padding: 0.5rem; font-family: 'JetBrains Mono', 'Cascadia Code', 'Fira Code', monospace; font-size: 0.72rem; line-height: 1.5; }

.trace-line { padding: 0.15rem 0.4rem; border-bottom: 1px solid #111; display: flex; gap: 0.5rem; align-items: baseline; }
.trace-line:hover { background: #1a1a2e; }

.trace-ts { color: #555; flex-shrink: 0; min-width: 5rem; }
.trace-node { font-weight: 700; flex-shrink: 0; min-width: 6rem; }
.trace-node.input { color: #f59e0b; }
.trace-node.output { color: #34d399; }
.trace-node.memorizer { color: #c084fc; }
.trace-node.runtime { color: #60a5fa; }

.trace-event { color: #888; flex-shrink: 0; min-width: 6rem; }

.trace-data { color: #ccc; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.trace-data.instruction { color: #22c55e; }
.trace-data.error { color: #ef4444; }
.trace-data.state { color: #c084fc; }
.trace-data.context { color: #666; }

/* Expandable trace detail */
.trace-line.expandable { cursor: pointer; }
.trace-detail { display: none; padding: 0.3rem 0.4rem 0.3rem 12rem; font-size: 0.65rem; color: #777; white-space: pre-wrap; word-break: break-all; max-height: 10rem; overflow-y: auto; background: #0d0d14; border-bottom: 1px solid #1a1a2e; }
.trace-detail.open { display: block; }
