:root {
  --bg: #0b0d12;
  --bg-elev: #131722;
  --bg-elev-2: #1a2030;
  --border: #232a3a;
  --text: #e6e9f2;
  --text-dim: #8a93a6;
  --accent: #7c8cff;
  --accent-soft: rgba(124, 140, 255, 0.15);
  --user: #2a8cff;
  --tool: #d4a017;
  --ok: #3ddc97;
  --danger: #ff6b6b;
  --radius: 12px;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
}

body {
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Inter, sans-serif;
  color: var(--text);
  background: radial-gradient(1200px 600px at 70% -10%, rgba(124, 140, 255, 0.08), transparent),
    var(--bg);
  display: grid;
  grid-template-rows: 56px 1fr;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-elev);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  letter-spacing: 0.2px;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 0 4px rgba(61, 220, 151, 0.15);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--text-dim);
}

select,
button,
textarea {
  font: inherit;
  color: var(--text);
}

select,
button {
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 10px;
  cursor: pointer;
}

select:hover,
button:hover {
  border-color: var(--accent);
}

button#send-btn {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 10px 18px;
  border-radius: 10px;
  font-weight: 600;
}

button#send-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.layout {
  display: grid;
  grid-template-columns: 1fr 360px;
  min-height: 0;
}

@media (max-width: 900px) {
  .layout {
    grid-template-columns: 1fr;
  }
  .inspector {
    border-left: none !important;
    border-top: 1px solid var(--border);
  }
}

.chat {
  display: grid;
  grid-template-rows: 1fr auto;
  min-height: 0;
}

.messages {
  overflow-y: auto;
  padding: 24px 22px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.msg {
  max-width: 78%;
  padding: 10px 14px;
  border-radius: 14px;
  line-height: 1.45;
  white-space: pre-wrap;
  word-wrap: break-word;
  border: 1px solid var(--border);
  background: var(--bg-elev);
}

.msg.user {
  align-self: flex-end;
  background: var(--user);
  border-color: transparent;
  color: #fff;
}

.msg.assistant {
  align-self: flex-start;
  background: var(--bg-elev);
}

.msg.tool {
  align-self: flex-start;
  background: rgba(212, 160, 23, 0.08);
  border-color: rgba(212, 160, 23, 0.3);
  color: #ffd97a;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12.5px;
}

.msg.tool::before {
  content: attr(data-tool) " →";
  display: block;
  font-weight: 700;
  margin-bottom: 4px;
  color: var(--tool);
}

.msg.error {
  align-self: center;
  background: rgba(255, 107, 107, 0.08);
  border-color: rgba(255, 107, 107, 0.3);
  color: var(--danger);
}

.composer {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  padding: 12px 14px;
  border-top: 1px solid var(--border);
  background: var(--bg-elev);
}

textarea {
  width: 100%;
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  resize: vertical;
  min-height: 44px;
  max-height: 220px;
  outline: none;
}

textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}

.inspector {
  border-left: 1px solid var(--border);
  background: var(--bg-elev);
  padding: 18px 18px 24px;
  overflow-y: auto;
}

.inspector h2 {
  margin: 0 0 4px;
  font-size: 14px;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  color: var(--text-dim);
}

.inspector h3 {
  margin: 22px 0 8px;
  font-size: 12px;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  color: var(--text-dim);
}

.hint {
  margin: 0 0 14px;
  font-size: 12px;
  color: var(--text-dim);
}

.state-card {
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
}

.state-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 6px 0;
  border-bottom: 1px dashed var(--border);
  font-size: 13px;
}

.state-row:last-child {
  border-bottom: none;
}

.state-label {
  color: var(--text-dim);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
}

.state-value {
  font-weight: 600;
}

.state-value.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  font-weight: 500;
}

.tools-list,
.tools-available {
  list-style: none;
  padding: 0;
  margin: 0;
}

.tools-available li {
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 10px;
  margin-bottom: 6px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  color: var(--text);
}

.tools-available li::before {
  content: "🔧 ";
}

.trace {
  list-style: none;
  padding: 0;
  margin: 0;
  counter-reset: step;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.trace li {
  counter-increment: step;
  position: relative;
  padding: 6px 10px 6px 28px;
  background: var(--bg-elev-2);
  border-radius: 8px;
  font-size: 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  color: var(--text-dim);
}

.trace li::before {
  content: counter(step);
  position: absolute;
  left: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: 50%;
  font-size: 10px;
  display: grid;
  place-items: center;
  font-weight: 700;
}

.trace li.tool {
  color: var(--tool);
}

.tools-pill {
  display: inline-block;
  background: var(--accent-soft);
  color: var(--accent);
  padding: 1px 8px;
  border-radius: 999px;
  margin-right: 4px;
  font-size: 11px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  color: var(--accent);
}

.thinking {
  color: var(--text-dim);
  font-style: italic;
}
