:root {
  --bg: #f6f6f3;
  --card: #ffffff;
  --text: #171717;
  --muted: #666666;
  --border: #e2e2dc;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.06);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}

.page {
  max-width: 1180px;
  margin: 0 auto;
  padding: 40px 24px;
}
.tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 0 0 18px;
  padding: 6px;
  background: #eeeeea;
  border: 1px solid var(--border);
  border-radius: 999px;
  width: fit-content;
}

.tab-button {
  background: transparent;
  color: var(--text);
  border-radius: 999px;
  padding: 10px 16px;
}

.tab-button.active {
  background: #171717;
  color: white;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}
.hero {
  margin-bottom: 24px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

h1 {
  margin: 0;
  font-size: 42px;
  letter-spacing: -0.04em;
}

h2 {
  margin: 0 0 16px;
  font-size: 18px;
}

.subhead {
  margin: 12px 0 0;
  max-width: 680px;
  color: var(--muted);
  line-height: 1.5;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 22px;
}

label {
  display: block;
  font-weight: 650;
  margin-bottom: 8px;
}

textarea,
.text-input {
  width: 100%;
  resize: vertical;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
  font: inherit;
  line-height: 1.45;
}

.text-input {
  margin-bottom: 16px;
}

.actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 14px;
}

button {
  border: 0;
  border-radius: 999px;
  padding: 11px 16px;
  background: #171717;
  color: white;
  font-weight: 650;
  cursor: pointer;
}

button.secondary {
  background: #eeeeea;
  color: #171717;
}

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

.status {
  min-height: 24px;
  margin: 14px 0 0;
  color: var(--muted);
}

.grid {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(320px, 0.85fr);
  gap: 18px;
  margin-top: 18px;
  align-items: start;
}

.hidden {
  display: none;
}

.answer-card pre {
  white-space: pre-wrap;
  word-wrap: break-word;
  margin: 0;
  line-height: 1.55;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 13px;
}

.side {
  display: grid;
  gap: 18px;
}

.metadata {
  display: grid;
  grid-template-columns: 100px 1fr;
  gap: 10px 14px;
  margin: 0;
}

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

.metadata dd {
  margin: 0;
  word-break: break-word;
}

.chunks {
  display: grid;
  gap: 10px;
}

.chunk {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px;
  background: #fafafa;
}

.chunk-title {
  font-weight: 700;
  margin-bottom: 6px;
}

.chunk-meta {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

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

  h1 {
    font-size: 34px;
  }
}

.history-card {
  margin-top: 18px;
}

.tab-panel > .history-card:first-child,
.tab-panel > .card:first-child {
  margin-top: 0;
}

.section-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.section-description {
  margin: -8px 0 0;
  color: var(--muted);
  line-height: 1.4;
}

.runs-list {
  display: grid;
  gap: 10px;
}

.run-item {
  width: 100%;
  text-align: left;
  border: 1px solid var(--border);
  background: #fafafa;
  color: var(--text);
  border-radius: 14px;
  padding: 14px;
  cursor: pointer;
}

.run-item:hover {
  background: #f0f0ec;
}

.run-question {
  font-weight: 700;
  margin-bottom: 6px;
}

.run-meta {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.empty-state {
  color: var(--muted);
}
.chunk {
  cursor: pointer;
}

.chunk:hover {
  background: #f0f0ec;
}

.chunk.active {
  border-color: #171717;
  background: #f3f3ef;
}

.chunk-text-heading {
  margin: 18px 0 8px;
  font-size: 14px;
}

.chunk-text {
  white-space: pre-wrap;
  word-wrap: break-word;
  margin: 0;
  max-height: 420px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #fafafa;
  padding: 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 12px;
  line-height: 1.5;
}

.controls-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 16px;
}

select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px;
  font: inherit;
  background: white;
}

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

.rebuild-action {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}
.source-library-grid {
  display: grid;
  grid-template-columns: 0.9fr 1.1fr;
  gap: 18px;
  align-items: start;
}

.subsection-title {
  margin: 0 0 10px;
  font-size: 15px;
}

.document-item {
  width: 100%;
  text-align: left;
  border: 1px solid var(--border);
  background: #fafafa;
  color: var(--text);
  border-radius: 14px;
  padding: 14px;
  cursor: pointer;
}

.document-item:hover {
  background: #f0f0ec;
}

.document-item.active {
  border-color: #171717;
  background: #f3f3ef;
}

.document-title {
  font-weight: 700;
  margin-bottom: 6px;
}

.document-meta {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.document-chunk-text {
  white-space: pre-wrap;
  word-wrap: break-word;
  margin-top: 8px;
  max-height: 260px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #ffffff;
  padding: 10px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 12px;
  line-height: 1.5;
}

@media (max-width: 900px) {
  .source-library-grid {
    grid-template-columns: 1fr;
  }
}
.subsection-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

button.danger {
  background: #7f1d1d;
  color: white;
}

button.danger:hover {
  background: #991b1b;
}