:root {
  --bg: #0f1117;
  --panel: #161922;
  --panel-border: #252a36;
  --text: #e5e7eb;
  --muted: #9ca3af;
  --accent: #60a5fa;
  --green: #34d399;
  --red: #f87171;
  --yellow: #fbbf24;
  --user: #60a5fa;
  --bot: #a78bfa;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

header {
  padding: 16px 24px;
  border-bottom: 1px solid var(--panel-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

header h1 {
  font-size: 18px;
  margin: 0;
  font-weight: 600;
  letter-spacing: 0.3px;
}

.meta {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  font-size: 13px;
}

.badge {
  padding: 4px 10px;
  border-radius: 99px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
}
.badge.online { background: rgba(52, 211, 153, 0.15); color: var(--green); }
.badge.offline { background: rgba(248, 113, 113, 0.15); color: var(--red); }

button {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--panel-border);
  border-radius: 6px;
  padding: 6px 14px;
  font-size: 13px;
  cursor: pointer;
}
button:hover { background: #1f2330; }

main {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  gap: 16px;
  padding: 16px;
  height: calc(100vh - 65px);
}

.panel {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  padding: 16px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.panel h2 {
  margin: 0 0 12px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--muted);
  font-weight: 600;
}

.scroll {
  flex: 1;
  overflow-y: auto;
  padding-right: 4px;
}

.scroll::-webkit-scrollbar { width: 6px; }
.scroll::-webkit-scrollbar-thumb { background: var(--panel-border); border-radius: 3px; }

/* Transkript */
.line {
  margin-bottom: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  background: #0d0f15;
  border-left: 3px solid var(--user);
}
.line.bot { border-left-color: var(--bot); }
.line.system { border-left-color: var(--yellow); background: rgba(251, 191, 36, 0.06); }
.line .who {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--user);
  font-weight: 600;
  margin-bottom: 4px;
}
.line.bot .who { color: var(--bot); }
.line.system .who { color: var(--yellow); }
.line .text {
  font-size: 14px;
}
.line .ts {
  font-size: 10px;
  color: var(--muted);
  float: right;
}

/* Tool-Calls */
.tool {
  margin-bottom: 10px;
  padding: 10px 12px;
  background: #0d0f15;
  border: 1px solid var(--panel-border);
  border-radius: 8px;
}
.tool .name {
  font-family: ui-monospace, "JetBrains Mono", "Courier New", monospace;
  font-size: 13px;
  color: var(--accent);
  margin-bottom: 4px;
}
.tool .args, .tool .result {
  font-family: ui-monospace, monospace;
  font-size: 11px;
  white-space: pre-wrap;
  margin-top: 4px;
  color: var(--muted);
}
.tool .result.ok { color: var(--green); }
.tool .result.err { color: var(--red); }

/* State */
#state {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
#state th {
  text-align: left;
  padding: 8px 4px;
  color: var(--muted);
  font-weight: 500;
  border-bottom: 1px solid var(--panel-border);
}
#state td {
  padding: 8px 4px;
  border-bottom: 1px solid var(--panel-border);
  font-family: ui-monospace, monospace;
  color: var(--text);
}

/* Flow */
#flow {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: auto;
}
#flow svg {
  max-width: 100%;
  max-height: 100%;
}

/* Mermaid active node highlighting */
.node.active rect, .node.active polygon {
  stroke: var(--accent) !important;
  stroke-width: 3px !important;
  filter: drop-shadow(0 0 6px var(--accent));
}
