:root {
  --bg: #ffffff;
  --fg: #1a1a1a;
  --muted: #6b7280;
  --border: #e5e7eb;
  --card: #f9fafb;
  --accent: #2563eb;
  --user-bubble: #eef2ff;
  --assistant-bubble: #f3f4f6;
  --positive: #059669;
  --negative: #dc2626;
  --pass: #059669;
  --fail: #dc2626;
  --pass-bg: #ecfdf5;
  --fail-bg: #fef2f2;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115;
    --fg: #e5e7eb;
    --muted: #9ca3af;
    --border: #262b36;
    --card: #171a21;
    --accent: #60a5fa;
    --user-bubble: #1e2749;
    --assistant-bubble: #1a1d24;
    --positive: #34d399;
    --negative: #f87171;
    --pass: #34d399;
    --fail: #f87171;
    --pass-bg: #052e21;
    --fail-bg: #2c1414;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  line-height: 1.5;
}

#app {
  max-width: 860px;
  margin: 0 auto;
  padding: 24px 20px 80px;
}
#app.scenario-layout {
  max-width: 1400px;
}

h1 { font-size: 1.4rem; margin: 0 0 4px; }
h2 { font-size: 1.1rem; margin: 32px 0 8px; }
.sub { color: var(--muted); margin: 0 0 24px; font-size: 0.9rem; }

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

section { margin-bottom: 28px; }
section ul { list-style: none; padding: 0; margin: 8px 0 0; }
section li {
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
  display: flex;
  gap: 8px;
  align-items: baseline;
  flex-wrap: wrap;
}
.count { color: var(--muted); font-weight: normal; font-size: 0.85em; }
.metric-name { color: var(--muted); font-size: 0.9em; }
.target-name { color: var(--muted); font-size: 0.85em; font-weight: normal; }

.tag {
  font-size: 0.72rem;
  padding: 1px 7px;
  border-radius: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}
.tag.positive { color: var(--positive); background: color-mix(in srgb, var(--positive) 15%, transparent); }
.tag.negative { color: var(--negative); background: color-mix(in srgb, var(--negative) 15%, transparent); }

.crumb {
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 16px;
}

.meta-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px 18px;
  margin-bottom: 20px;
}
.meta-card + .meta-card { margin-top: -8px; }
.meta-row { margin-bottom: 10px; }
.meta-row:last-child { margin-bottom: 0; }
.meta-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  font-weight: 600;
  margin-bottom: 3px;
}
.meta-value { font-size: 0.92rem; }

.landmarks { margin: 4px 0 0; padding-left: 18px; font-size: 0.88rem; }
.landmarks li { margin-bottom: 4px; }
.landmarks .turn-tag { color: var(--accent); font-weight: 600; }

.score-card {
  border-radius: 10px;
  padding: 14px 18px;
  margin-bottom: 20px;
  border: 1px solid var(--border);
}
.score-card.pass { background: var(--pass-bg); border-color: color-mix(in srgb, var(--pass) 35%, var(--border)); }
.score-card.fail { background: var(--fail-bg); border-color: color-mix(in srgb, var(--fail) 35%, var(--border)); }
.score-verdict { font-weight: 700; font-size: 0.95rem; margin-bottom: 6px; }
.score-verdict.pass { color: var(--pass); }
.score-verdict.fail { color: var(--fail); }
.score-justification { font-size: 0.9rem; }

.scenario-grid {
  display: grid;
  grid-template-columns: minmax(320px, 420px) 1fr;
  gap: 28px;
  align-items: start;
}
.scenario-meta-col {
  position: sticky;
  top: 24px;
  max-height: calc(100vh - 48px);
  overflow-y: auto;
}
.scenario-convo-col { min-width: 0; }

@media (max-width: 900px) {
  .scenario-grid { grid-template-columns: 1fr; }
  .scenario-meta-col {
    position: static;
    max-height: none;
  }
}

.scenario-tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
}
.scenario-tab {
  background: none;
  border: none;
  font: inherit;
  color: var(--muted);
  padding: 8px 14px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.scenario-tab:hover { color: var(--fg); }
.scenario-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  font-weight: 600;
}

.transcript { display: flex; flex-direction: column; gap: 12px; }
.msg {
  padding: 10px 14px;
  border-radius: 12px;
  max-width: 85%;
  font-size: 0.92rem;
}
.msg.user {
  background: var(--user-bubble);
  align-self: flex-end;
  border-bottom-right-radius: 3px;
  white-space: pre-wrap;
}
.msg.assistant {
  background: var(--assistant-bubble);
  align-self: flex-start;
  border-bottom-left-radius: 3px;
  max-width: 92%;
}
.msg-role {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin-bottom: 4px;
  font-weight: 600;
}
.msg-turn-marker {
  align-self: center;
  color: var(--muted);
  font-size: 0.72rem;
  margin: 6px 0 -2px;
}

/* Markdown rendered inside assistant messages */
.msg-md > *:first-child { margin-top: 0; }
.msg-md > *:last-child { margin-bottom: 0; }
.msg-md p { margin: 0 0 0.7em; }
.msg-md ul, .msg-md ol { margin: 0 0 0.7em; padding-left: 1.4em; }
.msg-md li { margin-bottom: 0.25em; }
.msg-md h1, .msg-md h2, .msg-md h3 { font-size: 1em; margin: 0.8em 0 0.4em; }
.msg-md strong { font-weight: 700; }
.msg-md em { font-style: italic; }
.msg-md code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.88em;
  background: color-mix(in srgb, var(--fg) 8%, transparent);
  padding: 0.1em 0.35em;
  border-radius: 4px;
}
.msg-md pre {
  background: color-mix(in srgb, var(--fg) 8%, transparent);
  padding: 10px 12px;
  border-radius: 8px;
  overflow-x: auto;
  margin: 0 0 0.7em;
}
.msg-md pre code { background: none; padding: 0; }
.msg-md blockquote {
  margin: 0 0 0.7em;
  padding-left: 0.8em;
  border-left: 3px solid var(--border);
  color: var(--muted);
}
.msg-md a { text-decoration: underline; }

.error { color: var(--negative); padding: 40px 0; text-align: center; }
