/* Theme variables live in shared/variables.css — loaded before this file. */

* { box-sizing: border-box; margin: 0; padding: 0; }
html { height: 100%; }

body {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  background: var(--bg, #0f1117);
  color: var(--text, #e2e8f0);
  min-height: 100%;
}

/* ── Theme Toggle ─────────────────────────────── */
.theme-toggle {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 100;
  background: var(--surface-2, #22253a);
  border: 1px solid var(--border, #2d3148);
  border-radius: 50%;
  width: 2.2rem;
  height: 2.2rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  color: var(--text, #e2e8f0);
  transition: background 0.15s;
}
.theme-toggle:hover { background: var(--highlight); }

/* ── Header ───────────────────────────────────── */
.page-header {
  text-align: center;
  padding: 2rem 1.5rem 1.5rem;
  border-bottom: 1px solid var(--border, #2d3148);
}

.page-header h1 {
  font-size: 1.75rem;
  font-weight: 700;
  margin-bottom: 0.35rem;
}

.page-header h1 .accent { color: var(--accent, #5ba300); }
.page-header h1 .accent-2 { color: var(--accent-2); }

.page-header p {
  color: var(--muted, #8892a4);
  font-size: 0.875rem;
  max-width: 650px;
  margin: 0 auto;
}

.page-header .back-link {
  display: inline-block;
  margin-bottom: 0.75rem;
  color: var(--muted, #8892a4);
  text-decoration: none;
  font-size: 0.8rem;
}

.page-header .back-link:hover { color: var(--accent-2); }

/* ── Main Layout ──────────────────────────────── */
.challenge-layout {
  display: grid;
  grid-template-columns: 300px 1fr 340px;
  max-width: 1600px;
  margin: 0 auto;
  min-height: calc(100vh - 120px);
}

/* ── Left Panel: Challenge Selector ───────────── */
.left-panel {
  border-right: 1px solid var(--border, #2d3148);
  overflow-y: auto;
  background: var(--surface, #1a1d27);
}

.panel-header {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted, #8892a4);
  padding: 0.75rem 1rem 0.5rem;
  border-bottom: 1px solid var(--border, #2d3148);
  position: sticky;
  top: 0;
  background: var(--surface, #1a1d27);
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* ── Repo group headers ───────────────────────── */
.repo-group-header {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent-2);
  padding: 0.6rem 1rem 0.4rem;
  background: var(--surface-2, #22253a);
  border-bottom: 1px solid var(--border, #2d3148);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.repo-group-count {
  font-weight: 400;
  color: var(--muted, #8892a4);
  font-size: 0.65rem;
  text-transform: none;
  letter-spacing: 0;
}

.challenge-card {
  padding: 1rem;
  border-bottom: 1px solid var(--border, #2d3148);
  cursor: pointer;
  transition: background 0.1s;
}

.challenge-card:hover { background: var(--highlight); }
.challenge-card.active { background: var(--highlight); border-left: 3px solid var(--accent, #5ba300); }

.challenge-card-title {
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.challenge-card-desc {
  font-size: 0.75rem;
  color: var(--muted, #8892a4);
  line-height: 1.4;
}

.challenge-card-meta {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 0.5rem;
  font-size: 0.7rem;
}

.difficulty-badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 9999px;
  font-weight: 600;
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.difficulty-easy { color: var(--token-agents); background: rgba(91,163,0,0.15); }
.difficulty-medium { color: var(--token-skills); background: rgba(201,122,46,0.15); }
.difficulty-hard { color: var(--token-tools); background: rgba(199,62,62,0.15); }

.par-badge {
  color: var(--muted, #8892a4);
  font-weight: 500;
}

.best-score-badge {
  color: var(--accent-2);
  font-weight: 600;
}

/* ── Center Panel: Editor ─────────────────────── */
.center-panel {
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  background: var(--bg, #0f1117);
}

.editor-section {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border, #2d3148);
}

.editor-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.5rem;
}

.editor-section-title {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted, #8892a4);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.token-count-badge {
  font-size: 0.65rem;
  font-weight: 500;
  color: var(--accent-2);
  background: rgba(0,158,176,0.1);
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  text-transform: none;
  letter-spacing: 0;
}

.editor-textarea {
  width: 100%;
  min-height: 80px;
  padding: 0.75rem;
  background: var(--code-bg, #151820);
  color: var(--code-text, #c9d1d9);
  border: 1px solid var(--border, #2d3148);
  border-radius: 6px;
  font-family: "SF Mono", "Fira Code", "Cascadia Code", monospace;
  font-size: 0.8rem;
  line-height: 1.5;
  resize: vertical;
}

.editor-textarea:focus {
  outline: none;
  border-color: var(--accent-2);
}

.editor-textarea.prompt-textarea {
  min-height: 60px;
}

/* ── File Selector ────────────────────────────── */
.file-selector {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  max-height: 200px;
  overflow-y: auto;
  padding: 0.25rem 0;
}

.file-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.25rem 0.6rem;
  border-radius: 4px;
  font-size: 0.72rem;
  font-family: "SF Mono", "Fira Code", monospace;
  cursor: pointer;
  border: 1px solid var(--border, #2d3148);
  background: var(--surface, #1a1d27);
  color: var(--muted, #8892a4);
  transition: all 0.1s;
  white-space: nowrap;
}

.file-chip:hover { border-color: var(--accent-2); color: var(--text, #e2e8f0); }

.file-chip.selected {
  background: rgba(0,158,176,0.12);
  border-color: var(--accent-2);
  color: var(--accent-2);
  font-weight: 500;
}

.file-chip .chip-tokens {
  font-size: 0.6rem;
  opacity: 0.7;
}

/* ── File Preview Pane ───────────────────────── */
.file-preview {
  margin-top: 0.5rem;
  border: 1px solid var(--border, #2d3148);
  border-radius: 6px;
  background: var(--code-bg, #151820);
  overflow: hidden;
}

.file-preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.4rem 0.75rem;
  background: var(--surface-2, #22253a);
  border-bottom: 1px solid var(--border, #2d3148);
}

.file-preview-name {
  font-family: "SF Mono", "Fira Code", monospace;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--accent-2);
}

.file-preview-close {
  background: none;
  border: none;
  color: var(--muted, #8892a4);
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
  padding: 0 0.25rem;
}
.file-preview-close:hover { color: var(--accent-5); }

.file-preview-content {
  padding: 0.75rem;
  margin: 0;
  max-height: 300px;
  overflow-y: auto;
  font-family: "SF Mono", "Fira Code", monospace;
  font-size: 0.75rem;
  line-height: 1.5;
  color: var(--code-text, #c9d1d9);
  white-space: pre-wrap;
  word-break: break-word;
}

/* ── Skills/Tools Editor ──────────────────────── */
.skills-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.skill-item {
  background: var(--surface, #1a1d27);
  border: 1px solid var(--border, #2d3148);
  border-radius: 6px;
  padding: 0.5rem 0.75rem;
}

.skill-item-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
}

.skill-name-input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text, #e2e8f0);
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.2rem 0;
  font-family: "SF Mono", "Fira Code", monospace;
}

.skill-name-input:focus { outline: none; }

.skill-remove-btn {
  background: none;
  border: none;
  color: var(--muted, #8892a4);
  cursor: pointer;
  font-size: 1rem;
  padding: 0 0.25rem;
  line-height: 1;
}
.skill-remove-btn:hover { color: var(--accent-5); }

.skill-content-input {
  width: 100%;
  min-height: 50px;
  padding: 0.5rem;
  background: var(--code-bg, #151820);
  color: var(--code-text, #c9d1d9);
  border: 1px solid var(--border, #2d3148);
  border-radius: 4px;
  font-family: "SF Mono", "Fira Code", monospace;
  font-size: 0.75rem;
  line-height: 1.4;
  resize: vertical;
}
.skill-content-input:focus { outline: none; border-color: var(--accent-4); }

.add-skill-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.4rem 0.8rem;
  background: var(--surface, #1a1d27);
  border: 1px dashed var(--border, #2d3148);
  border-radius: 6px;
  color: var(--muted, #8892a4);
  cursor: pointer;
  font-size: 0.75rem;
  transition: all 0.1s;
}
.add-skill-btn:hover { border-color: var(--accent-4); color: var(--accent-4); }

.example-tools-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-top: 0.5rem;
  flex-wrap: wrap;
}
.example-tools-label {
  font-size: 0.65rem;
  color: var(--muted, #8892a4);
  white-space: nowrap;
}
.example-tools-chips {
  display: flex;
  gap: 0.3rem;
  flex-wrap: wrap;
}
.example-tool-chip {
  padding: 0.2rem 0.55rem;
  background: transparent;
  border: 1px solid var(--border, #2d3148);
  border-radius: 12px;
  color: var(--muted, #8892a4);
  cursor: pointer;
  font-size: 0.65rem;
  transition: all 0.1s;
}
.example-tool-chip:hover { border-color: var(--accent-4); color: var(--accent-4); background: color-mix(in srgb, var(--accent-4) 8%, transparent); }

/* ── Run Button ───────────────────────────────── */
.run-section {
  padding: 1rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  border-bottom: 1px solid var(--border, #2d3148);
}

.run-btn {
  padding: 0.6rem 1.5rem;
  background: var(--accent, #5ba300);
  color: #fff;
  border: none;
  border-radius: 6px;
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  transition: opacity 0.15s;
  white-space: nowrap;
}

.run-btn:hover { opacity: 0.9; }
.run-btn:disabled { opacity: 0.4; cursor: not-allowed; }

.clear-btn {
  padding: 0.4rem 0.8rem;
  background: var(--surface-2, #22253a);
  color: var(--muted, #8892a4);
  border: 1px solid var(--border, #2d3148);
  border-radius: 6px;
  font-size: 0.75rem;
  cursor: pointer;
  transition: all 0.1s;
  white-space: nowrap;
}
.clear-btn:hover { border-color: var(--accent, #5ba300); color: var(--accent, #5ba300); }
.clear-btn:disabled { opacity: 0.4; cursor: not-allowed; }

.total-tokens-display {
  font-size: 0.8rem;
  color: var(--muted, #8892a4);
}

.total-tokens-display strong {
  color: var(--accent-2);
  font-variant-numeric: tabular-nums;
}

/* ── Output Section ───────────────────────────── */
.output-section {
  padding: 1rem 1.25rem;
  flex: 1;
}

.output-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.5rem;
}

.output-area {
  background: var(--code-bg, #151820);
  border: 1px solid var(--border, #2d3148);
  border-radius: 6px;
  padding: 0.75rem;
  min-height: 120px;
  max-height: 400px;
  overflow-y: auto;
  font-family: "SF Mono", "Fira Code", monospace;
  font-size: 0.8rem;
  line-height: 1.5;
  color: var(--code-text, #c9d1d9);
  white-space: pre-wrap;
  word-break: break-word;
}

.output-text {
  white-space: pre-wrap;
  word-break: break-word;
}

.response-code-block {
  margin: 0.4rem 0;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid var(--border, #2d3148);
  white-space: normal;
}

.code-lang-label {
  display: block;
  padding: 0.15rem 0.6rem;
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted, #8892a4);
  background: var(--surface, #1a1d27);
  border-bottom: 1px solid var(--border, #2d3148);
}

.response-code-block pre {
  margin: 0;
  padding: 0.5rem 0.6rem;
  overflow-x: auto;
  background: var(--code-bg, #151820);
}

.response-code-block pre code {
  font-family: "SF Mono", "Fira Code", "Cascadia Code", monospace;
  font-size: 0.72rem;
  line-height: 1.55;
}

.output-placeholder {
  color: var(--muted, #8892a4);
  font-style: italic;
}

/* ── Right Panel: Scorecard ───────────────────── */
.right-panel {
  border-left: 1px solid var(--border, #2d3148);
  overflow-y: auto;
  background: var(--surface, #1a1d27);
}

/* LLM Mode controls */
.llm-controls {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border, #2d3148);
}

.control-group {
  margin-bottom: 0.5rem;
}

.control-group:last-child { margin-bottom: 0; }

.control-label {
  display: block;
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted, #8892a4);
  margin-bottom: 0.25rem;
}

.control-select {
  width: 100%;
  padding: 0.4rem 0.5rem;
  background: var(--surface-2, #22253a);
  color: var(--text, #e2e8f0);
  border: 1px solid var(--border, #2d3148);
  border-radius: 4px;
  font-size: 0.75rem;
}

.api-config, .webllm-config {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border, #2d3148);
}

.api-input {
  width: 100%;
  padding: 0.4rem 0.5rem;
  background: var(--surface-2, #22253a);
  color: var(--text, #e2e8f0);
  border: 1px solid var(--border, #2d3148);
  border-radius: 4px;
  font-size: 0.75rem;
  margin-bottom: 0.4rem;
}

.api-input:focus { outline: none; border-color: var(--accent-2); }

.api-hint {
  font-size: 0.65rem;
  color: var(--muted, #8892a4);
  line-height: 1.4;
}

.load-btn {
  width: 100%;
  padding: 0.5rem;
  background: var(--accent-2);
  color: #fff;
  border: none;
  border-radius: 4px;
  font-weight: 600;
  font-size: 0.75rem;
  cursor: pointer;
  margin-bottom: 0.4rem;
}
.load-btn:disabled { opacity: 0.4; cursor: not-allowed; }

.webllm-progress {
  margin-top: 0.4rem;
}

.webllm-progress-bar-wrap {
  position: relative;
  height: 8px;
  background: var(--surface-2, #22253a);
  border-radius: 4px;
  overflow: hidden;
}

.webllm-progress-bar {
  height: 100%;
  background: var(--accent-2);
  transition: width 0.3s;
  width: 0;
}

.webllm-progress-text {
  display: block;
  margin-top: 0.3rem;
  font-size: 0.65rem;
  color: var(--muted, #8892a4);
  text-align: center;
}

/* ── Sampler / model settings panel ──────────── */
/* Shared rules in shared/sampler.css            */
.sampler-panel {
  padding: 0.6rem 1rem;
  border-bottom: 1px solid var(--border, #2d3148);
}

/* ── Token Budget Bar ─────────────────────────── */
.token-budget {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border, #2d3148);
}

.token-budget-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.5rem;
  font-size: 0.7rem;
  color: var(--muted, #8892a4);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.token-budget-bar {
  height: 12px;
  background: var(--surface-2, #22253a);
  border-radius: 6px;
  overflow: hidden;
  display: flex;
}

.token-budget-bar .segment {
  height: 100%;
  transition: width 0.3s;
}

.segment-system { background: var(--token-system); }
.segment-files { background: var(--token-files); }
.segment-skills { background: var(--token-skills); }
.segment-prompt { background: var(--token-prompt); opacity: 0.6; }

.token-budget-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.5rem;
  font-size: 0.65rem;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  color: var(--muted, #8892a4);
}

.legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 2px;
}

.legend-dot.system { background: var(--token-system); }
.legend-dot.files { background: var(--token-files); }
.legend-dot.skills { background: var(--token-skills); }
.legend-dot.prompt { background: var(--token-prompt); opacity: 0.6; }

/* ── Scorecard ────────────────────────────────── */
.scorecard {
  padding: 1rem;
  border-bottom: 1px solid var(--border, #2d3148);
}

.scorecard-title {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted, #8892a4);
  margin-bottom: 0.75rem;
}

.score-display {
  text-align: center;
  padding: 1rem 0;
}

.score-rating {
  font-size: 1.8rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
}

.score-rating.ace { color: var(--gold); }
.score-rating.eagle { color: var(--gold); }
.score-rating.birdie { color: var(--accent, #5ba300); }
.score-rating.par { color: var(--accent-2); }
.score-rating.bogey { color: var(--accent-4); }
.score-rating.double-bogey { color: var(--accent-5); }
.score-rating.dnf { color: var(--muted, #8892a4); }

.score-tokens {
  font-size: 0.85rem;
  color: var(--muted, #8892a4);
  font-variant-numeric: tabular-nums;
}

.score-par-diff {
  font-size: 0.75rem;
  margin-top: 0.25rem;
}

.score-par-diff.under { color: var(--accent, #5ba300); }
.score-par-diff.over { color: var(--accent-4); }

/* ── Validation Results ───────────────────────── */
.validation-results {
  padding: 0 1rem 1rem;
}

.validation-item {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.75rem;
  padding: 0.25rem 0;
}

.validation-pass { color: var(--accent, #5ba300); }
.validation-fail { color: var(--accent-5); }

/* ── Hints ────────────────────────────────────── */
.hints-section {
  padding: 1rem;
  border-bottom: 1px solid var(--border, #2d3148);
}

.hints-title {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted, #8892a4);
  margin-bottom: 0.5rem;
  cursor: pointer;
}

.hints-title:hover { color: var(--accent-4); }

.hints-list {
  list-style: none;
  font-size: 0.75rem;
  color: var(--muted, #8892a4);
}

.hints-list li {
  padding: 0.3rem 0;
  padding-left: 1rem;
  position: relative;
}

.hints-list li::before {
  content: "\1F4A1";
  position: absolute;
  left: 0;
  font-size: 0.7rem;
}

.hint-hidden { display: none; }

/* ── Leaderboard ──────────────────────────────── */
.leaderboard-section {
  padding: 1rem;
}

.leaderboard-title {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted, #8892a4);
  margin-bottom: 0.5rem;
}

.leaderboard-table {
  width: 100%;
  font-size: 0.72rem;
  border-collapse: collapse;
}

.leaderboard-table th {
  text-align: left;
  font-weight: 600;
  color: var(--muted, #8892a4);
  padding: 0.3rem 0.5rem;
  border-bottom: 1px solid var(--border, #2d3148);
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.leaderboard-table td {
  padding: 0.3rem 0.5rem;
  border-bottom: 1px solid var(--border, #2d3148);
  color: var(--text, #e2e8f0);
}

.leaderboard-table tr:first-child td { color: var(--gold); font-weight: 600; }
.leaderboard-table tr:nth-child(2) td { color: var(--silver); }
.leaderboard-table tr:nth-child(3) td { color: var(--bronze); }

.leaderboard-empty {
  text-align: center;
  color: var(--muted, #8892a4);
  font-size: 0.75rem;
  padding: 1rem 0;
  font-style: italic;
}

/* ── Scoring Explainer ────────────────────────── */
.scoring-explainer {
  border-top: 1px solid var(--border, #2d3148);
  padding: 0.75rem 1rem;
}

.scoring-explainer-title {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted, #8892a4);
  cursor: pointer;
  list-style: none;
  user-select: none;
}

.scoring-explainer-title::-webkit-details-marker { display: none; }

.scoring-explainer-title::before {
  content: "\25B6\00A0";
  font-size: 0.55rem;
  vertical-align: middle;
}

.scoring-explainer[open] .scoring-explainer-title::before { content: "\25BC\00A0"; }

.scoring-explainer-title:hover { color: var(--accent-4); }

.scoring-explainer-body {
  margin-top: 0.75rem;
}

.scoring-formula {
  font-size: 0.7rem;
  font-family: monospace;
  background: var(--surface-2, var(--surface, #1a1d27));
  border: 1px solid var(--border, #2d3148);
  border-radius: 4px;
  padding: 0.5rem 0.75rem;
  color: var(--accent, #5ba300);
  margin-bottom: 0.75rem;
}

.scoring-terms {
  font-size: 0.72rem;
  margin: 0 0 0.75rem;
}

.scoring-terms dt {
  font-weight: 600;
  color: var(--fg, var(--text, #e2e8f0));
  margin-top: 0.5rem;
}

.scoring-terms dd {
  margin: 0.15rem 0 0 0.75rem;
  color: var(--muted, #8892a4);
  line-height: 1.5;
}

.scoring-range {
  font-weight: 400;
  color: var(--muted, #8892a4);
}

.scoring-tip {
  font-size: 0.7rem;
  color: var(--muted, #8892a4);
  font-style: italic;
  border-left: 2px solid var(--accent-2);
  padding-left: 0.5rem;
  margin: 0;
  line-height: 1.5;
}

/* ── Status Bar ───────────────────────────────── */
.status-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.4rem 1rem;
  font-size: 0.7rem;
  color: var(--muted, #8892a4);
  background: var(--surface, #1a1d27);
  border-top: 1px solid var(--border, #2d3148);
}

.status-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  margin-right: 0.4rem;
}
.status-dot.ready { background: var(--accent, #5ba300); }
.status-dot.running { background: var(--accent-4); animation: pulse 1s infinite; }
.status-dot.error { background: var(--accent-5); }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* ── Celebrations ────────────────────────────── */
@keyframes scoreGlowGold {
  0% { box-shadow: 0 0 0 0 rgba(245,200,66,0.5); }
  40% { box-shadow: 0 0 24px 6px rgba(245,200,66,0.35); }
  100% { box-shadow: 0 0 0 0 rgba(245,200,66,0); }
}

@keyframes scoreGlowGreen {
  0% { box-shadow: 0 0 0 0 rgba(91,163,0,0.5); }
  40% { box-shadow: 0 0 18px 4px rgba(91,163,0,0.3); }
  100% { box-shadow: 0 0 0 0 rgba(91,163,0,0); }
}

@keyframes scoreGlowTeal {
  0% { box-shadow: 0 0 0 0 rgba(0,158,176,0.4); }
  40% { box-shadow: 0 0 12px 3px rgba(0,158,176,0.25); }
  100% { box-shadow: 0 0 0 0 rgba(0,158,176,0); }
}

.scorecard.celebrate-gold { animation: scoreGlowGold 1.6s ease-out; }
.scorecard.celebrate-green { animation: scoreGlowGreen 1.3s ease-out; }
.scorecard.celebrate-teal { animation: scoreGlowTeal 1s ease-out; }

.score-display { position: relative; }

.score-rating {
  transition: transform 0.3s ease-out;
}

.score-rating.pop-in {
  animation: ratingPopIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes ratingPopIn {
  0% { transform: scale(0.3); opacity: 0; }
  60% { transform: scale(1.15); opacity: 1; }
  100% { transform: scale(1); }
}

#score-final {
  font-variant-numeric: tabular-nums;
}

.celebration-badge {
  position: absolute;
  top: -0.5rem;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.2rem 0.7rem;
  border-radius: 9999px;
  white-space: nowrap;
  animation: badgeSlideIn 0.4s ease-out, badgeFadeOut 0.5s ease-in 2.5s forwards;
  z-index: 10;
  pointer-events: none;
}

.celebration-badge.first-completion {
  background: var(--accent-3);
  color: #fff;
}

.celebration-badge.new-best {
  background: var(--gold);
  color: #1a1d27;
}

@keyframes badgeSlideIn {
  from { opacity: 0; transform: translateX(-50%) translateY(0.5rem); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

@keyframes badgeFadeOut {
  to { opacity: 0; transform: translateX(-50%) translateY(-0.3rem); }
}

@media (prefers-reduced-motion: reduce) {
  .scorecard.celebrate-gold,
  .scorecard.celebrate-green,
  .scorecard.celebrate-teal { animation: none; }
  .celebration-badge { animation: none; opacity: 1; }
  .score-rating.pop-in { animation: none; }
}

/* ── Mobile Tab Bar ───────────────────────────── */
.mobile-tab-bar {
  display: none;
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--surface, #1a1d27);
  border-bottom: 1px solid var(--border, #2d3148);
}

.mobile-tab {
  flex: 1;
  padding: 0.75rem 0.5rem;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--muted, #8892a4);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
  text-align: center;
}

.mobile-tab:hover { color: var(--text, #e2e8f0); }

.mobile-tab.active {
  color: var(--accent-2);
  border-bottom-color: var(--accent-2);
}

/* ── Responsive: Tablet ──────────────────────── */
@media (max-width: 1200px) {
  .challenge-layout {
    grid-template-columns: 1fr;
    min-height: auto;
  }

  .left-panel {
    border-right: none;
    border-bottom: 1px solid var(--border, #2d3148);
    max-height: 300px;
  }

  .right-panel {
    border-left: none;
    border-top: 1px solid var(--border, #2d3148);
  }
}

/* ── Responsive: Mobile ──────────────────────── */
@media (max-width: 768px) {
  /* Show tab bar */
  .mobile-tab-bar {
    display: flex;
  }

  /* Header compact */
  .page-header {
    padding: 1rem 1rem 0.75rem;
  }

  .page-header h1 {
    font-size: 1.3rem;
  }

  .page-header p {
    font-size: 0.8rem;
    line-height: 1.4;
  }

  /* Theme toggle avoid overlap with content */
  .theme-toggle {
    top: 0.6rem;
    right: 0.6rem;
    width: 2rem;
    height: 2rem;
    font-size: 1rem;
  }

  /* Layout: single column, panels toggle via JS */
  .challenge-layout {
    grid-template-columns: 1fr;
    min-height: auto;
  }

  .left-panel {
    border-right: none;
    border-bottom: 1px solid var(--border, #2d3148);
    max-height: none;
    overflow-y: auto;
  }

  .right-panel {
    border-left: none;
    border-top: 1px solid var(--border, #2d3148);
  }

  /* Hidden panel (toggled by JS) */
  .mobile-hidden {
    display: none !important;
  }

  /* Challenge cards: bigger touch targets */
  .challenge-card {
    padding: 1rem 1rem;
    min-height: 3.5rem;
  }

  .challenge-card-title {
    font-size: 0.95rem;
  }

  .challenge-card-desc {
    font-size: 0.8rem;
    line-height: 1.5;
  }

  .challenge-card-meta {
    font-size: 0.75rem;
    gap: 0.5rem;
    flex-wrap: wrap;
  }

  .difficulty-badge {
    font-size: 0.7rem;
    padding: 0.2rem 0.6rem;
  }

  /* Editor sections: tighter padding */
  .editor-section {
    padding: 0.75rem 1rem;
  }

  .editor-textarea {
    font-size: 0.85rem;
    min-height: 70px;
  }

  /* File chips: bigger touch targets, constrain width */
  .file-chip {
    padding: 0.4rem 0.7rem;
    font-size: 0.78rem;
    min-height: 2.2rem;
    align-items: center;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .file-selector {
    gap: 0.5rem;
    max-height: 250px;
  }

  /* Context file hint: mobile-friendly */
  .editor-section-header span[style*="font-size:0.65rem"] {
    display: none;
  }

  /* Skill items: better touch */
  .skill-item {
    padding: 0.6rem 0.75rem;
  }

  .skill-remove-btn {
    font-size: 1.3rem;
    padding: 0.25rem 0.5rem;
    min-width: 2rem;
    min-height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .add-skill-btn {
    padding: 0.5rem 1rem;
    font-size: 0.8rem;
    min-height: 2.5rem;
  }

  /* Run section: sticky at bottom of editor */
  .run-section {
    position: sticky;
    bottom: 0;
    z-index: 10;
    background: var(--surface, #1a1d27);
    border-top: 1px solid var(--border, #2d3148);
    padding: 0.75rem 1rem;
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  .run-btn {
    flex: 1;
    min-width: 0;
    padding: 0.75rem 1rem;
    font-size: 0.9rem;
    min-height: 2.75rem;
  }

  .total-tokens-display {
    font-size: 0.75rem;
    text-align: center;
    flex-basis: 100%;
  }

  /* Output area */
  .output-area {
    min-height: 100px;
    max-height: 300px;
    font-size: 0.78rem;
  }

  /* Sampler grid: single column on mobile */
  .sampler-grid {
    grid-template-columns: 1fr 1fr;
    gap: 0.4rem 0.5rem;
  }

  .sampler-header {
    font-size: 0.72rem;
    margin-bottom: 0.5rem;
  }

  .sampler-input {
    font-size: 0.8rem;
    padding: 0.35rem 0.5rem;
    min-height: 2.2rem;
  }

  .sampler-label {
    font-size: 0.78rem;
  }

  /* LLM controls: bigger select */
  .control-select {
    font-size: 0.8rem;
    padding: 0.5rem;
    min-height: 2.5rem;
  }

  /* API inputs: bigger touch targets */
  .api-input {
    font-size: 0.8rem;
    padding: 0.5rem;
    min-height: 2.5rem;
  }

  .load-btn {
    font-size: 0.8rem;
    padding: 0.65rem;
    min-height: 2.5rem;
  }

  /* Token budget: compact */
  .token-budget {
    padding: 0.6rem 1rem;
  }

  .token-budget-legend {
    gap: 0.4rem;
    font-size: 0.7rem;
  }

  /* Scorecard: centered display */
  .scorecard {
    padding: 0.75rem 1rem;
  }

  .score-rating {
    font-size: 1.5rem;
  }

  /* Leaderboard: horizontal scroll on narrow */
  .leaderboard-section {
    padding: 0.75rem 1rem;
    overflow-x: auto;
  }

  .leaderboard-table {
    font-size: 0.7rem;
    min-width: 320px;
  }

  /* Validation */
  .validation-results {
    padding: 0 0.75rem 0.75rem;
  }

  .validation-item {
    font-size: 0.78rem;
    padding: 0.3rem 0;
    word-break: break-word;
  }

  .validation-item code {
    word-break: break-all;
  }

  /* Status bar */
  .status-bar {
    font-size: 0.68rem;
    padding: 0.35rem 0.75rem;
  }

  /* WebLLM model select */
  .webllm-config .control-select {
    font-size: 0.75rem;
  }

  /* Panel headers */
  .panel-header {
    padding: 0.6rem 1rem 0.5rem;
    font-size: 0.72rem;
  }

  /* File preview */
  .file-preview-content {
    max-height: 200px;
    font-size: 0.72rem;
  }
}

/* ── Prism syntax highlighting tokens ─────────── */
/* Dark theme (default) */
.token.comment,
.token.prolog,
.token.doctype,
.token.cdata            { color: #6a737d; font-style: italic; }
.token.keyword,
.token.operator,
.token.boolean          { color: #79c0ff; }
.token.string,
.token.char,
.token.template-string  { color: #a5d6ff; }
.token.number           { color: #ffa657; }
.token.function         { color: #d2a8ff; }
.token.class-name       { color: #ffa657; }
.token.builtin          { color: #79c0ff; }
.token.punctuation      { color: #8b949e; }
.token.property         { color: #7ee787; }
.token.attr-name        { color: #7ee787; }
.token.attr-value       { color: #a5d6ff; }
.token.tag              { color: #7ee787; }
.token.selector         { color: #7dd3a8; }
.token.annotation       { color: #ffa657; }
.token.regex            { color: #7dd3a8; }
.token.important,
.token.bold             { font-weight: bold; }
.token.italic           { font-style: italic; }

/* Light theme overrides */
[data-theme="light"] .token.comment,
[data-theme="light"] .token.prolog,
[data-theme="light"] .token.doctype,
[data-theme="light"] .token.cdata            { color: #6e7781; }
[data-theme="light"] .token.keyword,
[data-theme="light"] .token.operator,
[data-theme="light"] .token.boolean          { color: #0550ae; }
[data-theme="light"] .token.string,
[data-theme="light"] .token.char,
[data-theme="light"] .token.template-string  { color: #0a3069; }
[data-theme="light"] .token.number           { color: #953800; }
[data-theme="light"] .token.function         { color: #8250df; }
[data-theme="light"] .token.class-name       { color: #953800; }
[data-theme="light"] .token.builtin          { color: #0550ae; }
[data-theme="light"] .token.punctuation      { color: #24292f; }
[data-theme="light"] .token.property         { color: #116329; }
[data-theme="light"] .token.attr-name        { color: #116329; }
[data-theme="light"] .token.attr-value       { color: #0a3069; }
[data-theme="light"] .token.tag              { color: #116329; }
[data-theme="light"] .token.selector         { color: #0550ae; }
[data-theme="light"] .token.annotation       { color: #953800; }
[data-theme="light"] .token.regex            { color: #116329; }
