:root {
  color-scheme: light;
  --bg: #f5f7fb;
  --panel: #ffffff;
  --ink: #152033;
  --muted: #65758b;
  --line: #dce3ee;
  --accent: #2563eb;
  --accent-soft: #e8f0ff;
  --good: #15803d;
}

* {
  box-sizing: border-box;
}

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

.layout {
  display: grid;
  grid-template-columns: minmax(320px, 420px) 1fr;
  min-height: 100vh;
}

.control-panel {
  background: var(--panel);
  border-right: 1px solid var(--line);
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 32px;
  line-height: 1.05;
  letter-spacing: 0;
}

h2 {
  font-size: 24px;
}

.eyebrow {
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
  margin-bottom: 8px;
}

.lede {
  color: var(--muted);
  margin-top: 12px;
  line-height: 1.5;
}

label {
  display: grid;
  gap: 8px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
}

select,
textarea,
input[type="number"] {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px 12px;
  font: inherit;
  background: #fff;
  color: var(--ink);
}

textarea {
  resize: vertical;
  line-height: 1.45;
}

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

.strategy {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  display: flex;
  gap: 8px;
  align-items: center;
  font-weight: 700;
  font-size: 13px;
}

.row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
}

.inline {
  display: flex;
  grid-template-columns: none;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-weight: 700;
}

.topk {
  width: 92px;
}

button {
  border: 0;
  border-radius: 8px;
  padding: 13px 16px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

button:disabled {
  cursor: wait;
  opacity: .65;
}

.status {
  min-height: 20px;
  color: var(--muted);
  font-size: 13px;
}

.results {
  padding: 28px;
  min-width: 0;
}

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

.meta {
  color: var(--muted);
  font-size: 13px;
  text-align: right;
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 16px;
}

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

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.card-header {
  padding: 16px;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.badge {
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border-bottom: 1px solid var(--line);
}

.metric {
  padding: 12px;
  border-right: 1px solid var(--line);
}

.metric:last-child {
  border-right: 0;
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.metric strong {
  display: block;
  margin-top: 4px;
  font-size: 18px;
}

.answer {
  padding: 16px;
  white-space: pre-wrap;
  line-height: 1.5;
}

.chunk {
  border-top: 1px solid var(--line);
  padding: 14px 16px;
}

.chunk-title {
  display: flex;
  justify-content: space-between;
  color: var(--good);
  font-size: 12px;
  font-weight: 800;
  margin-bottom: 8px;
}

.chunk-text {
  color: #26364d;
  line-height: 1.45;
  font-size: 13px;
}

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

  .control-panel {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
}

@media (max-width: 520px) {
  .strategy-grid,
  .metrics {
    grid-template-columns: 1fr;
  }

  .row,
  .results-header {
    flex-direction: column;
    align-items: stretch;
  }

  .meta {
    text-align: left;
  }
}
