:root {
  color-scheme: dark;
  --bg: #0b1020;
  --panel: #131a2d;
  --card: #19233d;
  --line: #2b395f;
  --text: #f4f7fb;
  --muted: #9eb0d0;
  --accent: #6ea8fe;
  --accent-2: #8ee3cf;
  --danger: #ff7b7b;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: linear-gradient(180deg, #0b1020 0%, #0d1326 100%);
  color: var(--text);
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
  padding: 24px 28px 12px;
}

.topbar h1 {
  margin: 0 0 6px;
  font-size: 28px;
}

.topbar p {
  margin: 0;
  color: var(--muted);
}

.pill {
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(110, 168, 254, 0.16);
  color: var(--accent);
  border: 1px solid rgba(110, 168, 254, 0.28);
}

.layout {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 20px;
  padding: 12px 28px 28px;
}

.panel {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.card {
  background: rgba(25, 35, 61, 0.92);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 18px;
  box-shadow: 0 14px 32px rgba(3, 7, 18, 0.28);
}

.card.full-height {
  min-height: calc(100vh - 120px);
}

.card h2 {
  margin-top: 0;
  margin-bottom: 12px;
  font-size: 18px;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.inline-controls,
.search-row,
.chat-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.form-grid label,
.search-row,
.chat-form {
  width: 100%;
}

label span {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  color: var(--muted);
}

.full-width {
  grid-column: 1 / -1;
}

input,
select,
textarea,
button {
  width: 100%;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #0f1730;
  color: var(--text);
  padding: 12px 14px;
  font: inherit;
}

textarea {
  resize: vertical;
}

button {
  background: linear-gradient(135deg, rgba(110, 168, 254, 0.18), rgba(142, 227, 207, 0.18));
  border-color: rgba(110, 168, 254, 0.32);
  cursor: pointer;
  font-weight: 600;
}

button.secondary {
  background: transparent;
}

.output {
  margin: 12px 0 0;
  padding: 12px;
  border-radius: 14px;
  background: #0f1730;
  border: 1px solid var(--line);
  overflow: auto;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 12px;
}

.result-item,
.chat-bubble,
.chunk-event {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
  background: rgba(15, 23, 48, 0.8);
}

.result-item h3,
.chat-bubble h3 {
  margin: 0 0 6px;
  font-size: 15px;
}

.result-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 8px 0;
}

.result-meta span,
.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(142, 227, 207, 0.12);
  border: 1px solid rgba(142, 227, 207, 0.22);
  color: var(--accent-2);
  font-size: 12px;
}

.chat-transcript {
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1;
  min-height: 420px;
  max-height: calc(100vh - 320px);
  overflow: auto;
  padding-right: 4px;
}

.chat-bubble.user {
  border-color: rgba(110, 168, 254, 0.34);
}

.chat-bubble.assistant {
  border-color: rgba(142, 227, 207, 0.34);
}

.chat-bubble pre,
.result-item pre,
.chunk-event pre {
  white-space: pre-wrap;
  margin: 0;
}

.chat-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

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

  .card.full-height {
    min-height: auto;
  }
}
