@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

:root {
  --bg: #f8f7f4;
  --panel: #ffffff;
  --text: #0f0f0f;
  --muted: #4b4b4b;
  --border: rgba(0, 0, 0, 0.08);
  --accent: #f15a22;
  --accent-soft: rgba(241, 90, 34, 0.08);
  --accent-border: rgba(241, 90, 34, 0.35);
  --shadow: 0 14px 40px rgba(0,0,0,0.06);
  --radius: 14px;
  --radius-sm: 10px;
  --ui-font: "Inter", -apple-system, system-ui, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: var(--ui-font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--text); text-decoration: none; }
a:hover { color: var(--accent); }

code, .mono { font-family: var(--mono); font-size: 0.9em; }

h1, h2, h3 {
  font-weight: 800;
  letter-spacing: 0.01em;
  margin: 0 0 0.6rem;
}
h1 { font-size: clamp(1.5rem, 2.2vw, 2rem); line-height: 1.15; }
h2 { font-size: 1.35rem; line-height: 1.2; }
h3 { font-size: 1.1rem; line-height: 1.25; }

/* Layout */
.container { max-width: 1320px; margin: 0 auto; padding: 0 1.25rem; }
.page-shell { padding-top: 0.75rem; padding-bottom: 2rem; }

/* Topbar */
.topbar {
  position: sticky; top: 0; z-index: 10;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  padding: 0.5rem 0;
}
.topbar .container {
  display: flex; align-items: center; justify-content: space-between;
}
.topbar .left { display: flex; align-items: center; gap: 1.5rem; }
.brand { font-weight: 800; font-size: 1.15rem; }
.brand a { display: flex; align-items: center; gap: 0.5rem; }
.nav { display: flex; gap: 0.25rem; }
.nav a {
  padding: 0.35rem 0.75rem; border-radius: 8px;
  font-weight: 600; font-size: 0.92rem; color: var(--muted);
  transition: background 0.15s;
}
.nav a:hover { background: var(--accent-soft); color: var(--text); }
.nav a.active { background: var(--accent-soft); color: var(--accent); }

/* Cards */
.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
}

/* Stat cards */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin: 1.25rem 0;
}
.stat-card {
  text-align: center;
  padding: 1.5rem 1rem;
}
.stat-card .stat-value {
  font-size: 2.5rem; font-weight: 800; color: var(--accent);
  line-height: 1;
}
.stat-card .stat-label {
  font-size: 0.88rem; color: var(--muted); margin-top: 0.4rem;
  font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em;
}

/* Tables */
table {
  width: 100%; border-collapse: collapse;
  font-size: 0.92rem;
}
th, td {
  padding: 0.6rem 0.75rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
th {
  font-weight: 700; font-size: 0.82rem;
  text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--muted); background: rgba(0,0,0,0.02);
  position: sticky; top: 0;
}
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr:hover td { background: rgba(241, 90, 34, 0.03); }
.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--panel);
  box-shadow: var(--shadow);
}
.table-wrap table { margin: 0; }
.table-wrap th { top: 0; z-index: 1; }

/* Score colors */
.score-high { color: #16a34a; font-weight: 700; }
.score-mid { color: #ca8a04; font-weight: 600; }
.score-low { color: #dc2626; font-weight: 600; }

.score-badge {
  display: inline-block;
  min-width: 2.5rem;
  padding: 0.15rem 0.5rem;
  border-radius: 6px;
  text-align: center;
  font-weight: 700;
  font-size: 0.88rem;
  font-variant-numeric: tabular-nums;
}
.score-badge.score-high { background: rgba(22, 163, 74, 0.1); }
.score-badge.score-mid { background: rgba(202, 138, 4, 0.1); }
.score-badge.score-low { background: rgba(220, 38, 38, 0.1); }

/* Pills */
.pill {
  display: inline-block;
  padding: 0.15rem 0.6rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  border: 1px solid var(--accent-border);
  background: var(--accent-soft);
}
.pill--ok { border-color: rgba(22,163,74,0.3); background: rgba(22,163,74,0.08); color: #16a34a; }
.pill--bad { border-color: rgba(220,38,38,0.3); background: rgba(220,38,38,0.08); color: #dc2626; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; gap: 0.4rem;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--panel);
  font-weight: 600; font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.15s;
}
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn--primary {
  background: var(--accent); color: #fff; border-color: var(--accent);
}
.btn--primary:hover { background: #d94d1a; color: #fff; }

/* Prompt header */
.prompt-header {
  margin-bottom: 1.5rem;
}
.prompt-text {
  font-size: 1.2rem;
  color: var(--muted);
  margin: 0.5rem 0;
  font-style: italic;
}
.prompt-meta {
  display: flex; gap: 1rem; align-items: center;
  font-size: 0.88rem; color: var(--muted);
  margin-top: 0.5rem;
}

/* Article expand */
.article-preview {
  color: var(--muted);
  font-size: 0.88rem;
  max-width: 50ch;
}
.article-expand {
  cursor: pointer;
  color: var(--accent);
  font-size: 0.82rem;
  font-weight: 600;
}
.article-full {
  display: none;
  margin-top: 0.75rem;
  padding: 1rem;
  background: rgba(0,0,0,0.02);
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  line-height: 1.6;
  max-height: 400px;
  overflow-y: auto;
  white-space: pre-wrap;
}
.article-full.open { display: block; }

/* Response display */
.response-card {
  margin-bottom: 1.25rem;
}
.response-card .response-header {
  display: flex; align-items: center; gap: 1rem;
  margin-bottom: 0.5rem;
}
.response-body {
  padding: 1rem;
  background: rgba(0,0,0,0.02);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  line-height: 1.6;
  max-height: 300px;
  overflow-y: auto;
  white-space: pre-wrap;
}
.response-body.collapsed {
  max-height: 120px;
  overflow: hidden;
  position: relative;
}
.response-body.collapsed::after {
  content: "";
  position: absolute; bottom: 0; left: 0; right: 0;
  height: 50px;
  background: linear-gradient(transparent, rgba(248,247,244,0.95));
}

/* Embedding matrix */
.embed-matrix {
  font-variant-numeric: tabular-nums;
}
.embed-matrix td.best {
  background: rgba(22, 163, 74, 0.08);
  font-weight: 800;
}

/* Breadcrumb */
.breadcrumb {
  display: flex; align-items: center; gap: 0.35rem;
  font-size: 0.88rem; color: var(--muted);
  margin-bottom: 0.75rem;
}
.breadcrumb a { color: var(--accent); }
.breadcrumb .sep { color: var(--border); }

/* Live run */
.run-log {
  background: #1a1a2e;
  color: #e0e0e0;
  padding: 1rem;
  border-radius: var(--radius);
  font-family: var(--mono);
  font-size: 0.82rem;
  line-height: 1.5;
  max-height: 500px;
  overflow-y: auto;
  white-space: pre-wrap;
}
.run-log .log-line { margin: 0; }
.run-log .log-result { color: #4ade80; }
.run-log .log-error { color: #f87171; }

/* Section spacing */
.section { margin: 1.5rem 0; }
.section-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 1rem;
}

/* Utility */
.muted { color: var(--muted); }
.small { font-size: 0.88rem; }
.row { display: flex; gap: 0.75rem; align-items: center; }
.flex-1 { flex: 1; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mb-1 { margin-bottom: 0.5rem; }

/* Footer */
.footer {
  border-top: 1px solid var(--border);
  padding: 1.25rem 0;
  margin-top: 2rem;
  color: var(--muted);
  font-size: 0.82rem;
}

/* Config grid */
.config-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: 1rem;
}
.config-grid .card { margin: 0; }

/* Responsive */
@media (max-width: 768px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .table-wrap { font-size: 0.85rem; }
  th, td { padding: 0.4rem 0.5rem; }
}
