:root {
  --bg: #0f1419;
  --panel: #1a2332;
  --border: #2d3a4f;
  --text: #e7ecf3;
  --muted: #8b9cb3;
  --accent: #3b82f6;
  --ok: #22c55e;
  --bad: #ef4444;
  --warn: #f59e0b;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  grid-template-rows: auto 1fr;
  gap: 1rem;
  max-width: 1200px;
  margin: 0 auto;
  padding: 1rem;
  min-height: 100vh;
}

header {
  grid-column: 1 / -1;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  padding: 1rem 1.25rem;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
}

h1 { margin: 0 0 0.25rem; font-size: 1.35rem; }
.sub { margin: 0; color: var(--muted); font-size: 0.9rem; }
.api-box code {
  display: block;
  font-size: 0.75rem;
  background: #0d1117;
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
  color: #7dd3fc;
  word-break: break-all;
}

.nodes-panel, .chat-panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem;
}

.nodes-panel h2 { margin: 0 0 0.75rem; font-size: 1rem; }
.summary { font-size: 0.85rem; margin-bottom: 1rem; color: var(--muted); }

.node-card {
  padding: 0.65rem 0.75rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  margin-bottom: 0.5rem;
  font-size: 0.85rem;
}
.node-card.ok { border-color: #166534; background: rgba(34,197,94,0.08); }
.node-card.bad { border-color: #7f1d1d; background: rgba(239,68,68,0.08); }
.node-card .name { font-weight: 600; }
.node-card .detail { color: var(--muted); font-size: 0.78rem; margin-top: 0.2rem; }

.node-select {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-top: 1rem;
  font-size: 0.85rem;
}
.node-select select {
  background: #0d1117;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.5rem;
}

.chat-panel {
  display: flex;
  flex-direction: column;
  min-height: 70vh;
}

.messages {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 1rem;
  padding-right: 0.25rem;
}

.msg {
  max-width: 85%;
  padding: 0.75rem 1rem;
  border-radius: 12px;
  line-height: 1.5;
  font-size: 0.95rem;
  white-space: pre-wrap;
}
.msg.user {
  align-self: flex-end;
  background: var(--accent);
  color: #fff;
}
.msg.assistant {
  align-self: flex-start;
  background: #0d1117;
  border: 1px solid var(--border);
}
.msg.system {
  align-self: center;
  font-size: 0.8rem;
  color: var(--muted);
  background: transparent;
}

.chat-form {
  display: flex;
  gap: 0.5rem;
  align-items: flex-end;
}
.chat-form textarea {
  flex: 1;
  resize: vertical;
  min-height: 48px;
  background: #0d1117;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.65rem 0.85rem;
  font: inherit;
}
.chat-form button {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 0.75rem 1.25rem;
  font-weight: 600;
  cursor: pointer;
}
.chat-form button:disabled { opacity: 0.5; cursor: not-allowed; }

.meta {
  margin-top: 0.5rem;
  font-size: 0.78rem;
  color: var(--muted);
}

@media (max-width: 800px) {
  .layout { grid-template-columns: 1fr; }
  header { flex-direction: column; }
}
