:root {
  --bg: #0d0f14;
  --surface: #161a22;
  --surface-2: #1e2330;
  --border: #2a2f3d;
  --text: #e2e8f0;
  --text-muted: #64748b;
  --accent: #7c6af7;
  --accent-2: #22d3ee;
  --arm-a: #f59e0b;
  --arm-b: #ec4899;
  --arm-c: #22c55e;
  --arm-d: #3b82f6;
  --radius: 8px;
  --font: 'Inter', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
  /* hero colors used by quest-chat.js via var(--hero-*-color) */
  --hero-wizard-color: #a78bfa;
  --hero-ranger-color: #34d399;
  --hero-rogue-color:  #f87171;
  --hero-healer-color: #60a5fa;
  --hero-user-color:   var(--accent);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.6;
}

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

/* Layout */
.container { max-width: 1200px; margin: 0 auto; padding: 0 24px; }

header {
  border-bottom: 1px solid var(--border);
  padding: 20px 0;
  margin-bottom: 40px;
}

header .inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

header h1 {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

header h1 span { color: var(--accent); }

.subtitle {
  color: var(--text-muted);
  font-size: 13px;
  margin-top: 4px;
}

/* Arm badges */
.arm-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.arm-badge.A { background: color-mix(in srgb, var(--arm-a) 15%, transparent); color: var(--arm-a); border: 1px solid color-mix(in srgb, var(--arm-a) 30%, transparent); }
.arm-badge.B { background: color-mix(in srgb, var(--arm-b) 15%, transparent); color: var(--arm-b); border: 1px solid color-mix(in srgb, var(--arm-b) 30%, transparent); }
.arm-badge.C { background: color-mix(in srgb, var(--arm-c) 15%, transparent); color: var(--arm-c); border: 1px solid color-mix(in srgb, var(--arm-c) 30%, transparent); }
.arm-badge.D { background: color-mix(in srgb, var(--arm-d) 15%, transparent); color: var(--arm-d); border: 1px solid color-mix(in srgb, var(--arm-d) 30%, transparent); }

/* Comparison table */
.comparison-grid {
  display: grid;
  grid-template-columns: 180px repeat(4, 1fr);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 48px;
}

.grid-header, .grid-cell {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  border-right: 1px solid var(--border);
}

.grid-header:last-child, .grid-cell:last-child { border-right: none; }

.grid-header {
  background: var(--surface);
  font-weight: 600;
  font-size: 13px;
}

.grid-header.arm-col {
  text-align: center;
}

.grid-label {
  background: var(--surface);
  color: var(--text-muted);
  font-size: 12px;
}

.grid-cell {
  background: var(--bg);
  font-variant-numeric: tabular-nums;
  text-align: center;
}

.grid-cell.winner {
  background: color-mix(in srgb, var(--accent) 6%, var(--bg));
}

.metric-value {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.metric-spread {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Trial grid */
.section-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.trials-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
  margin-bottom: 48px;
}

.trial-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color 0.15s;
}

.trial-card:hover { border-color: var(--accent); }

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

.trial-card .card-body {
  padding: 12px 16px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.stat-item .stat-label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.stat-item .stat-value {
  font-size: 16px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.trial-card .card-footer {
  padding: 10px 16px;
  background: var(--surface-2);
  display: flex;
  gap: 8px;
}

.btn {
  flex: 1;
  padding: 6px 12px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  text-align: center;
  transition: background 0.15s, border-color 0.15s;
}

.btn:hover { background: var(--border); text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: white; }
.btn.primary:hover { background: color-mix(in srgb, var(--accent) 85%, white); }

/* Quest chat renderer */
.quest-chat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 24px;
}

.quest-chat .chat-header {
  padding: 12px 16px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  font-weight: 600;
}

.chat-icon {
  width: 20px;
  height: 20px;
  background: var(--accent);
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
}

.chat-messages {
  max-height: 500px;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.chat-msg {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.chat-msg.from-user { flex-direction: row-reverse; }

.msg-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
  text-transform: uppercase;
}

.msg-bubble {
  max-width: 72%;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 13px;
  line-height: 1.5;
}

.chat-msg.from-user .msg-bubble {
  background: color-mix(in srgb, var(--accent) 20%, var(--surface-2));
  border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
}

.msg-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
}

.msg-sender {
  font-size: 11px;
  font-weight: 600;
  text-transform: capitalize;
}

.msg-time {
  font-size: 10px;
  color: var(--text-muted);
}

.msg-target {
  font-size: 10px;
  color: var(--text-muted);
  font-style: italic;
}

/* Hero colors */
.hero-wizard { background: color-mix(in srgb, #a78bfa 25%, var(--surface-2)); color: #a78bfa; }
.hero-ranger { background: color-mix(in srgb, #34d399 25%, var(--surface-2)); color: #34d399; }
.hero-rogue  { background: color-mix(in srgb, #f87171 25%, var(--surface-2)); color: #f87171; }
.hero-healer { background: color-mix(in srgb, #60a5fa 25%, var(--surface-2)); color: #60a5fa; }
.hero-user   { background: color-mix(in srgb, var(--accent) 25%, var(--surface-2)); color: var(--accent); }

.bubble-wizard { background: color-mix(in srgb, #a78bfa 10%, var(--surface-2)); border: 1px solid color-mix(in srgb, #a78bfa 20%, transparent); }
.bubble-ranger { background: color-mix(in srgb, #34d399 10%, var(--surface-2)); border: 1px solid color-mix(in srgb, #34d399 20%, transparent); }
.bubble-rogue  { background: color-mix(in srgb, #f87171 10%, var(--surface-2)); border: 1px solid color-mix(in srgb, #f87171 20%, transparent); }
.bubble-healer { background: color-mix(in srgb, #60a5fa 10%, var(--surface-2)); border: 1px solid color-mix(in srgb, #60a5fa 20%, transparent); }
.bubble-user   { background: color-mix(in srgb, var(--accent) 12%, var(--surface-2)); border: 1px solid color-mix(in srgb, var(--accent) 25%, transparent); }

/* Detail page */
.detail-layout {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 24px;
  margin-bottom: 40px;
}

.iframe-container {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  aspect-ratio: 16/10;
}

.iframe-container iframe {
  width: 100%;
  height: 100%;
  border: none;
  display: block;
}

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

.metric-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
}

.metric-card .mc-label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 4px;
}

.metric-card .mc-value {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}

.metric-card .mc-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Transcript accordion */
.transcript {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 24px;
}

.transcript summary {
  padding: 12px 16px;
  cursor: pointer;
  background: var(--surface-2);
  font-size: 13px;
  font-weight: 600;
  user-select: none;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.transcript summary::-webkit-details-marker { display: none; }

.transcript summary::after {
  content: '▼';
  font-size: 10px;
  color: var(--text-muted);
  transition: transform 0.2s;
}

.transcript[open] summary::after { transform: rotate(180deg); }

.transcript-body {
  padding: 16px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-muted);
  max-height: 400px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-all;
}

/* Responsive */
@media (max-width: 900px) {
  .detail-layout { grid-template-columns: 1fr; }
  .comparison-grid { grid-template-columns: 120px repeat(4, 1fr); }
}

@media (max-width: 640px) {
  .comparison-grid { overflow-x: auto; }
  .trials-grid { grid-template-columns: 1fr; }
}

/* Loading / empty state */
.empty-state {
  text-align: center;
  padding: 60px 24px;
  color: var(--text-muted);
}

.empty-state h3 { font-size: 16px; margin-bottom: 8px; color: var(--text); }
