:root {
  color-scheme: dark;
  --bg: #0f172a;
  --panel: #1e293b;
  --border: #334155;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --accent: #38bdf8;
  --good: #4ade80;
  --warn: #fb923c;
  --bad: #f87171;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
html, body, #root { margin: 0; height: 100%; background: var(--bg); color: var(--text); }

.app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  max-width: 720px;
  margin: 0 auto;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
}
.topbar h1 { margin: 0; font-size: 16px; }
.topbar .meta { font-size: 12px; color: var(--muted); }

.page { padding: 16px; flex: 1; }

.login-card, .card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 12px;
}
label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
input, textarea {
  width: 100%;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  font-size: 14px;
  margin-bottom: 12px;
}
button {
  background: var(--accent);
  color: var(--bg);
  border: 0;
  border-radius: 8px;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
button.secondary { background: transparent; color: var(--text); border: 1px solid var(--border); }
button:disabled { opacity: 0.5; cursor: not-allowed; }
.error { color: var(--bad); font-size: 13px; margin: 8px 0; }
.muted { color: var(--muted); font-size: 12px; }

.node-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 8px;
  background: var(--panel);
  cursor: pointer;
}
.node-row:hover { border-color: var(--accent); }
.node-row .name { font-weight: 600; }
.node-row .runtime { font-size: 11px; color: var(--muted); }

.status-dot {
  width: 10px; height: 10px; border-radius: 50%;
  display: inline-block; margin-right: 6px;
}
.status-dot.idle { background: var(--good); }
.status-dot.working { background: var(--warn); }
.status-dot.offline { background: var(--muted); }
.status-dot.error, .status-dot.blocked { background: var(--bad); }

.chat-stream {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
}
.msg {
  border-radius: 10px;
  padding: 10px 12px;
  max-width: 88%;
  white-space: pre-wrap;
  font-size: 14px;
}
.msg.me { align-self: flex-end; background: #1e3a8a; }
.msg.agent { align-self: flex-start; background: var(--panel); border: 1px solid var(--border); }
.msg .meta { font-size: 10px; color: var(--muted); margin-top: 4px; }

.composer {
  display: flex;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid var(--border);
  background: var(--panel);
  position: sticky;
  bottom: 0;
}
.composer textarea { margin-bottom: 0; min-height: 44px; resize: vertical; }
.composer button { flex-shrink: 0; }

.live-log {
  background: #000;
  color: #4ade80;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  padding: 12px;
  border-radius: 8px;
  white-space: pre-wrap;
  max-height: 240px;
  overflow: auto;
  border: 1px solid var(--border);
  margin-top: 12px;
}
.live-log-toggle { background: transparent; color: var(--accent); border: 1px solid var(--border); margin-top: 8px; }
