:root {
  color-scheme: light;
  --bg: #f5f6f7;
  --panel: #ffffff;
  --panel-2: #f0f4f4;
  --text: #182022;
  --muted: #6b7478;
  --line: #d8dedf;
  --accent: #d95d67;
  --accent-2: #0f8b8d;
  --warn: #b56b16;
  --bad: #ba3a46;
  --good: #0f7f58;
  --shadow: 0 1px 2px rgba(10, 20, 24, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  font-size: 14px;
  letter-spacing: 0;
  overflow-x: hidden;
}

button,
input,
textarea,
select {
  font: inherit;
}

.topbar {
  height: 58px;
  display: grid;
  grid-template-columns: minmax(190px, auto) minmax(220px, 340px) auto auto auto auto;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  position: sticky;
  top: 0;
  z-index: 2;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  white-space: nowrap;
}

.mark {
  width: 14px;
  height: 14px;
  border: 2px solid var(--accent);
  border-radius: 50%;
  box-shadow: 0 0 0 3px rgba(217, 93, 103, 0.14);
}

.field {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 8px;
  color: var(--muted);
}

.field input,
.stack-field input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  border-radius: 6px;
  outline: none;
}

.field input,
.stack-field input,
select {
  height: 34px;
  padding: 0 10px;
}

textarea {
  resize: vertical;
  min-height: 76px;
  padding: 10px;
  line-height: 1.4;
}

.field input:focus,
.stack-field input:focus,
textarea:focus,
select:focus {
  border-color: var(--accent-2);
  box-shadow: 0 0 0 3px rgba(15, 139, 141, 0.12);
}

.check {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  white-space: nowrap;
}

button {
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  cursor: pointer;
}

button:hover {
  border-color: #b9c3c5;
}

.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
  padding: 0 12px;
}

.primary:hover {
  border-color: #c84653;
  background: #c84653;
}

.icon-button {
  width: 34px;
  padding: 0;
  display: inline-grid;
  place-items: center;
}

.status {
  min-width: 88px;
  color: var(--muted);
  white-space: nowrap;
}

.layout {
  display: grid;
  grid-template-columns: minmax(250px, 320px) minmax(360px, 1fr) minmax(340px, 520px);
  gap: 14px;
  height: calc(100vh - 58px);
  padding: 14px;
}

.runs-panel,
.timeline-panel,
.detail-panel {
  min-width: 0;
  min-height: 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.query-box {
  display: grid;
  gap: 10px;
  padding: 12px;
  border-bottom: 1px solid var(--line);
  background: var(--panel-2);
}

.query-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 92px;
  gap: 8px;
}

.stack-field {
  display: grid;
  gap: 5px;
  min-width: 0;
  color: var(--muted);
  font-size: 12px;
}

.panel-title {
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 0 12px;
  border-bottom: 1px solid var(--line);
  font-weight: 700;
}

.muted {
  color: var(--muted);
  font-weight: 500;
}

.runs-list,
.timeline,
.detail-view {
  overflow: auto;
}

.runs-list {
  padding: 8px;
}

.run-item,
.event-item {
  width: 100%;
  text-align: left;
  height: auto;
  border: 1px solid transparent;
  background: #fff;
  border-radius: 6px;
}

.run-item {
  display: grid;
  gap: 6px;
  padding: 10px;
  margin-bottom: 7px;
}

.run-item.active,
.event-item.active {
  border-color: var(--accent);
  background: #fff7f8;
}

.run-top,
.event-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.run-goal,
.event-message {
  color: var(--muted);
  overflow-wrap: anywhere;
  line-height: 1.35;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 12px;
  border: 1px solid var(--line);
  color: var(--muted);
  background: #fff;
}

.pill.running {
  color: var(--warn);
  border-color: rgba(181, 107, 22, 0.28);
  background: rgba(181, 107, 22, 0.08);
}

.pill.succeeded,
.pill.ok {
  color: var(--good);
  border-color: rgba(15, 127, 88, 0.26);
  background: rgba(15, 127, 88, 0.08);
}

.pill.failed,
.pill.bad {
  color: var(--bad);
  border-color: rgba(186, 58, 70, 0.25);
  background: rgba(186, 58, 70, 0.08);
}

.timeline {
  padding: 10px 12px;
}

.event-item {
  display: grid;
  grid-template-columns: 10px 1fr;
  gap: 10px;
  padding: 10px;
  margin-bottom: 8px;
}

.event-dot {
  width: 10px;
  height: 10px;
  margin-top: 5px;
  border-radius: 50%;
  background: var(--accent-2);
}

.event-dot.result {
  background: var(--good);
}

.event-dot.command_queued {
  background: var(--accent);
}

.event-dot.planner_started,
.event-dot.display_selected {
  background: var(--accent-2);
}

.event-dot.tool_started,
.event-dot.tool_finished,
.event-dot.finish_called {
  background: #64748b;
}

.event-dot.visual_context_updated,
.event-dot.visual_context_injected {
  background: #8f5bb8;
}

.event-dot.run_failed {
  background: var(--bad);
}

.event-body {
  min-width: 0;
}

.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.detail-view {
  flex: 1;
  margin: 0;
  padding: 12px;
  background: #11181b;
  color: #e8eeee;
  line-height: 1.45;
  font-size: 12px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.image-strip {
  display: grid;
  gap: 10px;
  padding: 12px;
  border-bottom: 1px solid var(--line);
  max-height: 46vh;
  overflow: auto;
  background: #fbfcfc;
}

.image-preview {
  display: grid;
  gap: 6px;
}

.image-preview img {
  width: 100%;
  max-height: 38vh;
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

.empty {
  color: var(--muted);
  padding: 18px;
}

@media (max-width: 1100px) {
  .topbar {
    grid-template-columns: 1fr auto;
    height: auto;
  }

  .brand,
  .session-field {
    grid-column: 1 / -1;
  }

  #streamButton {
    grid-column: 1 / -1;
    width: 100%;
  }

  .status {
    grid-column: 1 / -1;
  }

  .layout {
    grid-template-columns: 1fr;
    height: auto;
  }

  .runs-panel,
  .timeline-panel,
  .detail-panel {
    min-height: 360px;
  }
}

@media (max-width: 520px) {
  .layout {
    padding: 14px 8px;
  }

  .run-top {
    align-items: flex-start;
    flex-direction: column;
  }

  .run-item {
    padding: 10px 9px;
  }
}
