* {
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  margin: 0;
  padding: 1.5rem;
  background: #fafafa;
  color: #1a1a1a;
}

header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 0.5rem;
}

header h1 {
  font-size: 1.25rem;
  margin: 0;
}

header label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
  color: #444;
}

.help-link {
  margin-left: auto;
  font-size: 0.85rem;
  color: #1a56db;
  text-decoration: none;
}

.help-link:hover {
  text-decoration: underline;
}

select, input, textarea, button {
  font: inherit;
  padding: 0.4rem 0.6rem;
  border: 1px solid #ccc;
  border-radius: 4px;
}

#status {
  min-height: 1.2em;
  color: #555;
  margin: 0.5rem 0 1rem;
}

#status.error {
  color: #b00020;
}

.panels {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}

.panels[hidden] {
  display: none;
}

.panel {
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  padding: 1rem;
}

.panel h2 {
  margin-top: 0;
  font-size: 1rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: #555;
}

.panel label {
  display: block;
  font-size: 0.85rem;
  color: #555;
  margin-bottom: 0.75rem;
}

.panel textarea,
.panel .prompt-editable {
  display: block;
  width: 100%;
  min-height: 160px;
  margin-top: 0.35rem;
  resize: vertical;
  font-family: inherit;
}

.prompt-editable {
  overflow-y: auto;
  white-space: pre-wrap;
  font-size: 1rem;
  line-height: 1.4;
  background: #fff;
}

.prompt-editable:focus {
  outline: 2px solid #8ab4f8;
  outline-offset: -1px;
}

.panel-prod textarea,
.panel-prod input {
  background: #f2f2f2;
  color: #444;
}

.controls {
  display: flex;
  gap: 1rem;
}

.controls label {
  flex: 1;
}

.controls input,
.controls select {
  width: 100%;
  margin-top: 0.35rem;
}

.actions {
  margin-top: 0.85rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.actions button {
  cursor: pointer;
  background: #fff;
}

.actions button:hover {
  background: #f2f2f2;
}

#diff-status,
#sanitize-status {
  font-size: 0.85rem;
  color: #777;
  font-style: italic;
}

.sanitize-findings {
  margin-top: 0.6rem;
  padding: 0.75rem;
  background: #fff8e6;
  border: 1px solid #f0dca0;
  border-radius: 6px;
}

.sanitize-findings-list {
  list-style: none;
  margin: 0 0 0.6rem;
  padding: 0;
  font-size: 0.85rem;
}

.sanitize-findings-list li {
  margin-bottom: 0.3rem;
  cursor: help;
}

.sanitize-findings-list li::before {
  content: attr(data-category);
  display: inline-block;
  min-width: 4.5rem;
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.7rem;
  letter-spacing: 0.03em;
  color: #7a5c00;
}

.sanitize-actions {
  display: flex;
  gap: 0.5rem;
}

.sanitize-actions button {
  cursor: pointer;
  background: #fff;
  padding: 0.3rem 0.75rem;
  font-size: 0.85rem;
}

.sanitize-actions button:hover {
  background: #f2f2f2;
}

.diff-same {
  color: #333;
}

.diff-added {
  background: #d4f5d4;
  color: #146214;
}

.diff-removed {
  background: #fbdcdc;
  color: #a30000;
  text-decoration: line-through;
}

.evals {
  margin-top: 1rem;
  padding-top: 0.85rem;
  border-top: 1px solid #eee;
}

.evals-label {
  display: block;
  font-size: 0.85rem;
  color: #555;
  margin-bottom: 0.5rem;
}

.evalset-info {
  margin: 0 0 0.75rem;
  font-size: 0.9rem;
  color: #333;
}

#run-eval-btn {
  cursor: pointer;
  background: #fff;
}

#run-eval-btn:hover {
  background: #f2f2f2;
}

#run-eval-btn:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

#run-eval-status {
  margin-left: 0.75rem;
  font-size: 0.85rem;
  color: #777;
  font-style: italic;
}

.view-results-link {
  display: block;
  width: fit-content;
  margin: 0.5rem auto 1.5rem;
  font-size: 0.85rem;
  color: #1a56db;
  text-decoration: none;
}

.view-results-link[hidden] {
  display: none;
}

.view-results-link:hover {
  text-decoration: underline;
}

.summary-compare {
  width: 100%;
  max-width: 500px;
  margin: 0 auto 1.5rem;
  border-collapse: collapse;
  background: #fff;
}

.summary-compare[hidden] {
  display: none;
}

.summary-compare th,
.summary-compare td {
  border: 1px solid #e0e0e0;
  padding: 0.5rem 0.85rem;
  text-align: left;
  font-size: 0.9rem;
}

.summary-compare th {
  background: #f7f7f7;
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 0.03em;
  color: #555;
}

.summary-compare td:first-child {
  color: #555;
  font-weight: 600;
}

.metric-better {
  color: #146214;
  font-weight: 600;
}

.metric-worse {
  color: #a30000;
  font-weight: 600;
}

.response-text {
  white-space: pre-wrap;
}

.response-score {
  margin-top: 0.5rem;
}

.score-badge {
  display: inline-block;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
}

.score-badge.score-pass {
  background: #d4f5d4;
  color: #146214;
}

.score-badge.score-fail {
  background: #fbdcdc;
  color: #a30000;
}

.score-badge.score-partial {
  background: #fff3cd;
  color: #7a5c00;
}

.criteria-list {
  list-style: none;
  margin: 0.4rem 0 0;
  padding: 0;
  font-size: 0.8rem;
}

.criteria-list li {
  cursor: help;
}

.criterion-pass {
  color: #146214;
}

.criterion-fail {
  color: #a30000;
}

.results-table {
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  border-collapse: collapse;
  background: #fff;
}

.results-table[hidden] {
  display: none;
}

.results-table th,
.results-table td {
  border: 1px solid #e0e0e0;
  padding: 0.6rem 0.75rem;
  text-align: left;
  vertical-align: top;
  font-size: 0.9rem;
}

.results-table th {
  background: #f7f7f7;
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 0.03em;
  color: #555;
}

.results-table .query-thumb {
  display: block;
  max-width: 160px;
  max-height: 120px;
  margin-bottom: 0.5rem;
  border-radius: 4px;
}

.recent-runs {
  max-width: 1100px;
  margin: 2rem auto 0;
}

.recent-runs h2 {
  font-size: 1rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: #555;
  margin-bottom: 0.5rem;
}

.recent-runs #recent-runs-status {
  font-size: 0.85rem;
  color: #777;
  font-style: italic;
}

.recent-runs .results-table {
  max-width: none;
  margin: 0;
}

.recent-runs .status-failed {
  color: #b00020;
}

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