:root {
  --bg: #0f1116;
  --bg-soft: #161a23;
  --panel: #1c2230;
  --line: #2a3348;
  --text: #e8eefc;
  --muted: #8fa0bf;
  --accent: #3bb3ff;
  --ok: #35d28a;
  --warn: #ffb547;
  --err: #ff6f6f;
  --assistant: #1f2d45;
  --thought: #2e2642;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, Liberation Mono, monospace;
  background: radial-gradient(1200px 700px at 20% -10%, #1e2740, var(--bg));
  color: var(--text);
}

.page {
  max-width: 1300px;
  margin: 0 auto;
  padding: 16px;
  display: grid;
  gap: 12px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

h1,
h2 {
  margin: 0;
  font-weight: 700;
}

h1 {
  font-size: 22px;
}

h2 {
  font-size: 16px;
  margin-bottom: 8px;
}

.muted {
  color: var(--muted);
  margin: 4px 0 0;
}

.panel {
  background: color-mix(in srgb, var(--panel) 92%, #000 8%);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
}

.form-panel form {
  display: grid;
  gap: 8px;
}

label {
  display: grid;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
}

input,
textarea,
button {
  font: inherit;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  background: var(--bg-soft);
  color: var(--text);
}

textarea {
  resize: vertical;
  min-height: 78px;
}

button {
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 8px 12px;
  cursor: pointer;
  background: var(--accent);
  color: #04131d;
  font-weight: 700;
}

button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-secondary {
  background: var(--warn);
  color: #2a1a00;
}

.btn-ghost {
  background: transparent;
  border-color: var(--line);
  color: var(--text);
}

.actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.meta-row {
  margin-top: 8px;
  display: flex;
  gap: 16px;
  font-size: 12px;
  color: var(--muted);
  flex-wrap: wrap;
}

.status {
  display: flex;
  gap: 8px;
}

.badge {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
  color: var(--muted);
  text-transform: lowercase;
}

.badge-ok {
  border-color: color-mix(in srgb, var(--ok) 70%, var(--line));
  color: var(--ok);
}

.badge-warn {
  border-color: color-mix(in srgb, var(--warn) 70%, var(--line));
  color: var(--warn);
}

.badge-err {
  border-color: color-mix(in srgb, var(--err) 70%, var(--line));
  color: var(--err);
}

.grid-two {
  display: grid;
  gap: 12px;
  grid-template-columns: 1fr 1fr;
}

.feed {
  border: 1px solid var(--line);
  background: rgba(10, 12, 18, 0.55);
  border-radius: 10px;
  padding: 8px;
  min-height: 220px;
  max-height: 420px;
  overflow: auto;
}

.chat-item,
.activity-item,
.rpc-item,
.line-row {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 8px;
  margin-bottom: 6px;
}

.chat-item.assistant {
  background: color-mix(in srgb, var(--assistant) 75%, transparent);
}

.chat-item.thought {
  background: color-mix(in srgb, var(--thought) 75%, transparent);
}

.activity-item.thinking {
  background: color-mix(in srgb, #3a2d56 70%, transparent);
}

.activity-item.tool {
  background: color-mix(in srgb, #2e3e2f 70%, transparent);
}

.activity-item.permission {
  background: color-mix(in srgb, #4a3a1f 70%, transparent);
}

.activity-item.error {
  background: color-mix(in srgb, #4f2222 75%, transparent);
}

.item-head {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 4px;
}

.chat-text,
.activity-text,
.rpc-text,
.line-text {
  white-space: pre-wrap;
  word-break: break-word;
}

.activity-meta {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 4px;
}

.rpc-grid {
  display: grid;
  grid-template-columns: 70px 1fr;
  gap: 4px 8px;
  align-items: baseline;
  font-size: 12px;
}

.rpc-grid span {
  color: var(--muted);
}

.rpc-grid code {
  color: var(--text);
}

.line-row {
  display: grid;
  gap: 8px;
  grid-template-columns: 100px 56px 1fr;
  align-items: start;
  font-size: 12px;
}

.line-stream {
  text-transform: lowercase;
  color: var(--muted);
}

.line-stream.stderr {
  color: var(--warn);
}

.raw-feed {
  max-height: 340px;
}

.empty {
  color: var(--muted);
  padding: 8px;
  border: 1px dashed var(--line);
  border-radius: 8px;
}

@media (max-width: 980px) {
  .grid-two {
    grid-template-columns: 1fr;
  }

  .line-row {
    grid-template-columns: 90px 48px 1fr;
  }
}
