/* ================================================================
   PPE Results Explorer — Black Chalkboard
   Educational-yet-scrappy. White chalk, blue, red accents.
   ================================================================ */

:root {
  --bg: #1a1a1e;
  --bg-card: #222228;
  --chalk: #e8e5dc;
  --chalk-dim: #9a978e;
  --chalk-faint: #5e5c56;
  --blue: #5b9bf5;
  --red: #e8614d;
  --gold: #f0c75e;
  --font-chalk: 'Caveat', cursive;
  --font-chalk-sm: 'Caveat', cursive;
  --font-display: 'Fredericka the Great', cursive;
  --font-body: 'Inter', system-ui, sans-serif;
}

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

/* SVG filter for rough/hand-drawn edges */
svg.chalk-filters { position: absolute; width: 0; height: 0; }

body {
  background: var(--bg);
  color: rgba(232,229,220,0.92);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.6;
  min-height: 100vh;
  background-image:
    radial-gradient(ellipse at 20% 50%, rgba(40,40,42,0.5) 0%, transparent 70%),
    radial-gradient(ellipse at 80% 30%, rgba(38,38,42,0.4) 0%, transparent 70%);
  box-shadow: inset 0 0 120px rgba(0,0,0,0.6);
}

/* chalk-dust noise — two layers for grain + smudge */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9999;
  opacity: 0.045;
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23n)' opacity='1'/%3E%3C/svg%3E"),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='400' height='400'%3E%3Cfilter id='s'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.25' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='400' height='400' filter='url(%23s)' opacity='0.5'/%3E%3C/svg%3E");
  background-size: 200px 200px, 400px 400px;
}

/* ── Nav ───────────────────────────────────────────────────── */

.top-nav {
  border-bottom: 1px solid rgba(232,229,220,0.06);
  padding: 0 24px;
  position: sticky;
  top: 0;
  background: var(--bg);
  backdrop-filter: blur(8px);
  z-index: 100;
}

.nav-inner {
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 52px;
}

.nav-title {
  font-family: var(--font-chalk);
  font-size: 24px;
  font-weight: 700;
  color: var(--chalk);
  text-decoration: none;
  white-space: nowrap;
}

.nav-links { display: flex; gap: 24px; }

.nav-link {
  color: var(--chalk-dim);
  text-decoration: none;
  font-family: var(--font-chalk-sm);
  font-size: 20px;
  font-weight: 600;
  padding: 2px 0;
  border-bottom: 2px solid transparent;
  transition: color 0.15s;
}

.nav-link:hover { color: var(--chalk); }
.nav-link.active { color: var(--chalk); border-bottom-color: var(--blue); }

/* ── Page titles ──────────────────────────────────────────── */

.page-title {
  font-family: var(--font-chalk);
  font-size: 2.8rem;
  font-weight: 700;
  margin-bottom: 8px;
  text-shadow:
    0 0 8px rgba(232,229,220,0.08),
    1px 1px 0 rgba(232,229,220,0.03);
}

.page-intro {
  color: var(--chalk-dim);
  font-size: 16px;
  margin-bottom: 32px;
}

/* ── Landing ───────────────────────────────────────────────── */

.landing {
  max-width: 1100px;
  margin: 0 auto;
  padding: 60px 24px 48px;
}

.landing-inner {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 48px;
  align-items: center;
}

@media (max-width: 768px) {
  .landing-inner { grid-template-columns: 1fr; gap: 32px; }
}

.landing-text h1 {
  font-family: var(--font-display);
  font-size: 3rem;
  font-weight: 400;
  line-height: 1.2;
  margin-bottom: 16px;
  text-shadow: 0 0 10px rgba(232,229,220,0.1);
  color: var(--chalk);
}

.landing-sub {
  color: var(--chalk-dim);
  font-size: 16px;
  margin-bottom: 28px;
  max-width: 400px;
}

.landing-actions {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
}

.landing-or {
  color: var(--chalk-faint);
  font-family: var(--font-chalk);
  font-size: 18px;
  text-decoration: none;
  transition: color 0.15s;
}

.landing-or:hover {
  color: var(--chalk-dim);
}

.landing-caveat {
  color: var(--chalk-faint);
  font-family: var(--font-chalk);
  font-size: 17px;
  font-style: italic;
}

/* stat boxes */
.stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.stat-box {
  background: transparent;
  border: none;
  border-radius: 6px;
  padding: 16px;
  text-align: center;
  position: relative;
}

.stat-box::before {
  content: '';
  position: absolute;
  inset: -2px;
  border: 2.5px solid rgba(232,229,220,0.2);
  border-radius: 6px;
  filter: url(#chalk-rough);
  pointer-events: none;
}

.stat-number {
  font-family: var(--font-chalk);
  font-size: 2.2rem;
  font-weight: 700;
  color: var(--chalk);
  line-height: 1.2;
}

.stat-label {
  font-size: 12px;
  color: var(--chalk-dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* hero chart */
.hero-chart {
  background: transparent;
  border: none;
  border-radius: 6px;
  margin-bottom: 16px;
  position: relative;
  overflow: visible;
  height: 180px;
}

.hero-chart::before {
  content: '';
  position: absolute;
  inset: -2px;
  border: 2.5px solid rgba(232,229,220,0.2);
  border-radius: 6px;
  filter: url(#chalk-rough);
  pointer-events: none;
}

.hero-chart canvas {
  display: block;
  position: absolute;
  top: -24px;
  left: 50%;
  transform: translateX(-50%);
  cursor: none;
}

/* ── Layout ────────────────────────────────────────────────── */

.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 32px 24px 80px;
}

/* ── Steps ─────────────────────────────────────────────────── */

.steps {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  margin-bottom: 32px;
}

.step {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  padding: 8px 16px;
  border-radius: 20px;
  transition: background 0.15s;
}

.step:hover { background: rgba(232,229,220,0.04); }

.step-num {
  width: 30px; height: 30px;
  border-radius: 50%;
  border: 2px solid var(--chalk-faint);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-chalk);
  font-size: 18px; font-weight: 700;
  color: var(--chalk-faint);
  transition: all 0.15s;
}

.step.active .step-num { background: var(--blue); border-color: var(--blue); color: #fff; }
.step.completed .step-num { background: var(--blue); border-color: var(--blue); color: #fff; opacity: 0.7; }

.step-label {
  font-family: var(--font-chalk);
  font-size: 20px; font-weight: 600;
  color: var(--chalk-faint);
}

.step.active .step-label,
.step.completed .step-label { color: var(--chalk); }

.step-line {
  width: 40px; height: 0;
  border-top: 2px dashed var(--chalk-faint);
  opacity: 0.25;
}

/* ── Cards ─────────────────────────────────────────────────── */

.card {
  background: transparent;
  border: none;
  border-radius: 4px;
  padding: 28px;
  margin-bottom: 24px;
  position: relative;
}

.card::before {
  content: '';
  position: absolute;
  inset: -2px;
  border: 2.5px solid rgba(232,229,220,0.22);
  border-radius: 5px;
  filter: url(#chalk-rough);
  pointer-events: none;
}

.card h2 {
  font-family: var(--font-chalk);
  font-size: 2rem; font-weight: 700;
  margin-bottom: 16px;
  text-shadow: 0 0 6px rgba(232,229,220,0.06);
}

.section-note {
  color: var(--chalk-dim);
  font-size: 14px;
  margin-bottom: 20px;
}

/* ── Step sections ─────────────────────────────────────────── */

.step-section { display: none; }
.step-section.active-section { display: block; }

/* ── Paper picker ──────────────────────────────────────────── */

.picker-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.picker-header h2 { margin-bottom: 4px; }

.picker-header-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-shrink: 0;
}

.btn-sm {
  font-size: 16px;
  padding: 7px 14px;
}

.selected-summary {
  margin-bottom: 16px;
}

.selected-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.selected-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 12px;
  background: rgba(91,155,245,0.08);
  border: 1px solid rgba(91,155,245,0.15);
  font-size: 12px;
  color: var(--chalk);
}

.subject-selected-count {
  font-size: 16px;
  color: var(--blue);
  font-weight: 400;
}

.picker-controls {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
}

.search-input {
  flex: 1;
  background: rgba(232,229,220,0.05);
  border: 1px solid rgba(232,229,220,0.12);
  border-radius: 6px;
  padding: 10px 14px;
  color: var(--chalk);
  font-family: var(--font-body);
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s;
}

.search-input::placeholder { color: var(--chalk-faint); }
.search-input:focus { border-color: var(--blue); }

.paper-count {
  color: var(--chalk-dim);
  font-family: var(--font-chalk);
  font-size: 22px; font-weight: 700;
  white-space: nowrap;
}

.paper-lists {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 20px;
}

@media (max-width: 768px) {
  .paper-lists { grid-template-columns: 1fr; }
}

.subject-group h3 {
  font-family: var(--font-chalk);
  font-size: 22px; font-weight: 700;
  margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 1px dashed rgba(232,229,220,0.12);
}

.subject-group[data-subject="Philosophy"] h3 { color: var(--blue); }
.subject-group[data-subject="Politics"] h3 { color: var(--red); }
.subject-group[data-subject="Economics"] h3 { color: var(--gold); }

.paper-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 5px 8px;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.1s;
  font-size: 13px;
}

.paper-item:hover { background: rgba(232,229,220,0.04); }
.paper-item.selected { background: rgba(91,155,245,0.1); }
.paper-item.hidden { display: none; }

.paper-item input[type="checkbox"] {
  margin-top: 2px;
  accent-color: var(--blue);
}

.paper-name { flex: 1; }

.paper-badge {
  font-family: var(--font-chalk-sm);
  font-size: 13px;
  padding: 1px 7px;
  border-radius: 8px;
  font-weight: 700;
  white-space: nowrap;
}

.badge-predictable { background: rgba(91,155,245,0.12); color: var(--blue); }
.badge-moderate { background: rgba(240,199,94,0.12); color: var(--gold); }
.badge-volatile { background: rgba(232,97,77,0.12); color: var(--red); }
.badge-kingmaker { background: rgba(232,97,77,0.2); color: var(--red); border: 1px solid rgba(232,97,77,0.3); }
.badge-trend-up { background: rgba(91,155,245,0.15); color: var(--blue); font-size: 11px; }
.badge-trend-down { background: rgba(232,97,77,0.15); color: var(--red); font-size: 11px; }

.paper-limited {
  color: var(--chalk-faint);
  font-size: 11px;
  font-style: italic;
  white-space: nowrap;
}

.paper-stats {
  color: var(--chalk-faint);
  font-size: 11px;
  white-space: nowrap;
}

/* ── Buttons ───────────────────────────────────────────────── */

.step-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  margin-top: 24px;
}

.btn {
  display: inline-block;
  padding: 10px 24px;
  border-radius: 4px 6px 5px 7px;
  font-family: var(--font-chalk);
  font-size: 20px; font-weight: 700;
  cursor: pointer;
  border: none;
  text-decoration: none;
  text-align: center;
  transition: background 0.15s, opacity 0.15s;
}

.btn:disabled { opacity: 0.35; cursor: not-allowed; }

.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:hover:not(:disabled) { background: #4a8de8; }

.btn-secondary {
  background: rgba(232,229,220,0.06);
  color: var(--chalk);
  border: 1px solid rgba(232,229,220,0.12);
}

.btn-secondary:hover { background: rgba(232,229,220,0.1); }

/* ── Ability slider ────────────────────────────────────────── */

.ability-widget { max-width: 500px; margin: 0 auto; }

.ability-presets {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-bottom: 20px;
}

.preset-btn {
  padding: 8px 16px;
  border-radius: 16px;
  border: 1px solid rgba(232,229,220,0.12);
  background: transparent;
  color: var(--chalk-dim);
  font-family: var(--font-chalk-sm);
  font-size: 18px; font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.preset-btn:hover { border-color: var(--chalk); color: var(--chalk); }

.preset-btn.active {
  background: rgba(91,155,245,0.12);
  border-color: var(--blue);
  color: var(--blue);
}

.slider-container { margin-bottom: 16px; }

.chalk-slider {
  width: 100%; height: 6px;
  -webkit-appearance: none; appearance: none;
  background: rgba(232,229,220,0.15);
  border-radius: 3px;
  outline: none;
}

.chalk-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--blue);
  cursor: pointer;
  border: 2px solid var(--bg);
  box-shadow: 0 2px 6px rgba(0,0,0,0.4);
}

.chalk-slider::-moz-range-thumb {
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--blue);
  cursor: pointer;
  border: 2px solid var(--bg);
}

.slider-labels {
  display: flex;
  justify-content: space-between;
  margin-top: 6px;
  font-family: var(--font-chalk-sm);
  font-size: 16px;
  color: var(--chalk-faint);
}

.ability-readout {
  text-align: center;
  color: var(--chalk-dim);
  font-size: 14px;
}

/* ── Results ───────────────────────────────────────────────── */

.result-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 28px;
  align-items: center;
  margin-bottom: 28px;
}

@media (max-width: 700px) {
  .result-row { grid-template-columns: 1fr; }
}

.result-headline {
  padding: 20px;
  background: rgba(91,155,245,0.05);
  border-radius: 6px;
  border: 1px dashed rgba(91,155,245,0.2);
}

.result-headline .big-number {
  font-family: var(--font-chalk);
  font-size: 2.4rem; font-weight: 700;
  color: var(--chalk);
  line-height: 1.3;
}

.headline-breakdown {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin: 12px 0 8px;
}

.headline-class {
  font-family: var(--font-chalk);
  font-size: 20px;
  font-weight: 600;
}

.result-headline .range-text {
  font-size: 13px;
  color: var(--chalk-dim);
  margin-top: 4px;
}

.result-chart-container { display: flex; justify-content: center; }

/* ── Paper breakdown ───────────────────────────────────────── */

.paper-breakdown { margin-bottom: 24px; }

.paper-breakdown h3 {
  font-family: var(--font-chalk);
  font-size: 1.6rem; font-weight: 700;
  margin-bottom: 8px;
}

.breakdown-note {
  color: var(--chalk-faint);
  font-size: 13px;
  margin-bottom: 16px;
}

.breakdown-table { width: 100%; border-collapse: collapse; }

.breakdown-table th {
  color: var(--chalk-faint);
  font-family: var(--font-chalk);
  font-weight: 700; font-size: 15px;
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid rgba(232,229,220,0.08);
}

.breakdown-table td {
  padding: 7px 10px;
  font-size: 13px;
  border-bottom: 1px solid rgba(232,229,220,0.04);
  vertical-align: middle;
}

.subject-dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: middle;
}

.subject-dot--phil { background: var(--blue); }
.subject-dot--pol { background: var(--red); }
.subject-dot--econ { background: var(--gold); }

.breakdown-mark {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
}

.mark-bar-wrap {
  width: 80px; height: 8px;
  background: rgba(232,229,220,0.06);
  border-radius: 4px;
  position: relative;
  overflow: hidden;
}

.mark-bar {
  height: 100%;
  background: var(--chalk-dim);
  border-radius: 4px;
  opacity: 0.4;
}

.mark-threshold {
  position: absolute; top: 0;
  width: 1.5px; height: 100%;
  background: var(--red);
  opacity: 0.5;
}

.mark-threshold--first { background: var(--blue); }

.risk-badge {
  font-family: var(--font-chalk);
  font-size: 14px; font-weight: 600;
  padding: 1px 6px;
  border-radius: 6px;
}

.risk-high { color: var(--red); background: rgba(232,97,77,0.12); }
.risk-some { color: var(--gold); background: rgba(240,199,94,0.1); }

.breakdown-sigma {
  color: var(--chalk-faint);
  font-size: 12px;
}

/* ── Context panels ────────────────────────────────────────── */

.context-panels {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}

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

.context-card {
  background: rgba(232,229,220,0.03);
  border: 1px solid rgba(232,229,220,0.06);
  border-radius: 6px;
  padding: 16px 20px;
}

.context-card h3 {
  font-family: var(--font-chalk);
  font-size: 20px; font-weight: 700;
  margin-bottom: 8px;
  color: var(--chalk-dim);
}

.context-card .context-value {
  font-family: var(--font-chalk);
  font-size: 22px; font-weight: 700;
}

.context-card .context-note {
  font-size: 12px;
  color: var(--chalk-faint);
  margin-top: 4px;
}

.swap-arrow { color: var(--blue); font-weight: 700; }

/* ── Classification colors (shared) ───────────────────────── */

.class-first { color: var(--blue); font-weight: 600; }
.class-21 { color: var(--chalk); font-weight: 600; }
.class-22 { color: var(--gold); }
.class-low { color: var(--chalk-faint); }

/* ── Methodology modal ────────────────────────────────────── */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.modal-content {
  max-width: 600px;
  width: 100%;
  max-height: 80vh;
  overflow: hidden;
  position: relative;
  animation: modal-in 0.15s ease-out;
  background: var(--bg-card);
}

.modal-content::before {
  display: none;
}

@keyframes modal-in {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

.modal-close {
  position: absolute;
  top: 12px; right: 16px;
  background: none;
  border: none;
  color: var(--chalk-dim);
  font-size: 28px;
  cursor: pointer;
  line-height: 1;
  padding: 4px;
}

.modal-close:hover { color: var(--chalk); }

.methodology-brief {
  list-style: none;
  padding: 0;
}

.methodology-brief li {
  padding: 8px 0;
  border-bottom: 1px solid rgba(232,229,220,0.06);
  font-size: 14px;
  color: var(--chalk-dim);
  line-height: 1.6;
}

.methodology-brief li:last-child { border-bottom: none; }

.modal-actions {
  margin-top: 20px;
  text-align: center;
}

/* ── Methodology full page ────────────────────────────────── */

.methodology-full {
  max-width: 700px;
  margin: 0 auto;
  padding-bottom: 60px;
}

.methodology-full > p:first-of-type {
  font-size: 14px;
  color: var(--chalk-dim);
  line-height: 1.8;
  margin-bottom: 32px;
  padding-bottom: 20px;
  border-bottom: 1px solid rgba(232,229,220,0.08);
  font-style: italic;
}

.methodology-full h2 {
  font-family: var(--font-chalk);
  font-size: 1.8rem;
  font-weight: 700;
  margin-top: 36px;
  margin-bottom: 14px;
  padding-bottom: 6px;
  border-bottom: 1px dashed rgba(232,229,220,0.1);
}

.methodology-full p,
.methodology-full li {
  font-size: 14px;
  color: var(--chalk-dim);
  margin-bottom: 10px;
  line-height: 1.8;
}

.methodology-full ul,
.methodology-full ol {
  padding-left: 20px;
  margin-bottom: 14px;
}

.methodology-full ol {
  list-style: decimal;
}

.methodology-rules-table {
  width: 100%;
  border-collapse: collapse;
  margin: 16px 0;
}

.methodology-rules-table th,
.methodology-rules-table td {
  padding: 8px 12px;
  text-align: left;
  border-bottom: 1px solid rgba(232,229,220,0.06);
  font-size: 14px;
}

.methodology-rules-table th {
  color: var(--chalk-faint);
  font-family: var(--font-chalk);
  font-weight: 700;
  font-size: 16px;
}


/* KaTeX overrides for dark theme */
.methodology-full .katex {
  color: var(--chalk);
  font-size: 1.05em;
}

/* ── Charts ───────────────────────────────────────────────── */

.chart-wrap {
  height: 360px;
  position: relative;
}


.chart-wrap--short {
  height: 200px;
}

.chart-wrap--tall {
  height: 480px;
}

/* ── Explorer ─────────────────────────────────────────────── */

.explorer-controls {
  display: flex;
  gap: 16px;
  align-items: center;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.match-count {
  font-family: var(--font-chalk-sm);
  font-size: 14px;
  color: var(--chalk-dim);
}

.explorer-list-controls {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid rgba(232,229,220,0.06);
}

.explorer-list-controls .search-input {
  max-width: 260px;
}

.explorer-filters {
  display: flex;
  gap: 6px;
}

.filter-btn {
  padding: 6px 14px;
  border-radius: 14px;
  border: 1px solid rgba(232,229,220,0.12);
  background: transparent;
  color: var(--chalk-dim);
  font-family: var(--font-chalk);
  font-size: 17px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.filter-btn:hover { border-color: var(--chalk); color: var(--chalk); }

.filter-btn.active {
  background: rgba(91,155,245,0.12);
  border-color: var(--blue);
  color: var(--blue);
}

.explorer-sort {
  display: flex;
  align-items: center;
  gap: 8px;
}

.sort-label {
  color: var(--chalk-faint);
  font-size: 13px;
}

.sort-btn {
  padding: 4px 10px;
  border-radius: 10px;
  border: 1px solid rgba(232,229,220,0.08);
  background: transparent;
  color: var(--chalk-dim);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s;
}

.sort-btn:hover { color: var(--chalk); }
.sort-btn.active { background: rgba(91,155,245,0.1); border-color: var(--blue); color: var(--blue); }

.explorer-paper-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 10px;
}

.explorer-paper-card {
  background: transparent;
  border: none;
  border-radius: 6px;
  padding: 12px 16px;
  cursor: pointer;
  transition: background 0.15s;
  position: relative;
}

.explorer-paper-card::before {
  content: '';
  position: absolute;
  inset: -2px;
  border: 2.5px solid rgba(232,229,220,0.16);
  border-radius: 6px;
  filter: url(#chalk-rough);
  pointer-events: none;
  transition: border-color 0.15s;
}

.explorer-paper-card:hover {
  background: rgba(91,155,245,0.06);
}

.explorer-paper-card:hover::before {
  border-color: rgba(91,155,245,0.25);
}

/* ── Trends section ───────────────────────────────────────── */


/* ── Explorer card items ─────────────────────────────────── */

.explorer-card-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.explorer-card-name {
  flex: 1;
  font-weight: 500;
  font-size: 14px;
}

.explorer-card-stats {
  display: flex;
  gap: 16px;
  font-size: 12px;
  color: var(--chalk-dim);
}

/* ── Paper profile ────────────────────────────────────────── */

.paper-profile { min-height: 60px; }

.profile-placeholder {
  color: var(--chalk-faint);
  font-style: italic;
  padding: 16px 0;
}

.profile-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}

.profile-header h3 {
  font-family: var(--font-chalk);
  font-size: 1.8rem;
  font-weight: 700;
  flex: 1;
}

.profile-stats {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.profile-stat {
  text-align: center;
  min-width: 70px;
  padding: 10px 14px;
  background: rgba(232,229,220,0.04);
  border-radius: 6px;
}

.profile-stat-value {
  font-family: var(--font-chalk);
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--chalk);
}

.profile-stat-label {
  font-size: 11px;
  color: var(--chalk-dim);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.profile-trend {
  font-size: 13px;
  color: var(--chalk-dim);
  padding: 8px 0;
  border-top: 1px solid rgba(232,229,220,0.06);
  margin-bottom: 12px;
}

.profile-pop h4 {
  font-family: var(--font-chalk);
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--chalk-dim);
}

.sparkline {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 80px;
  padding-bottom: 16px;
}

.spark-bar-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
  min-width: 0;
}

.spark-bar {
  width: 100%;
  max-width: 20px;
  background: var(--chalk-faint);
  border-radius: 2px 2px 0 0;
  transition: height 0.2s;
}

.spark-bar.spark-recent {
  background: var(--blue);
  opacity: 0.7;
}

.spark-year {
  font-size: 9px;
  color: var(--chalk-faint);
  margin-top: 3px;
}

/* ── Overview ─────────────────────────────────────────────── */

.sticky-toc {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  margin: 0 -24px 32px;
  padding: 12px 24px;
  border: 0px;
  position: sticky;
  top: 53px;
  backdrop-filter: blur(10px);
  z-index: 50;
}

.sticky-toc a {
  font-family: var(--font-chalk);
  font-size: 18px;
  font-weight: 600;
  color: var(--chalk-dim);
  text-decoration: none;
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s;
  padding-bottom: 4px;
  border-bottom: 2.5px solid transparent;
}

.sticky-toc a:hover {
  color: var(--chalk);
}

.sticky-toc a.active {
  color: var(--chalk);
  border-bottom-color: var(--blue);
}

.chart-detail {
  margin-top: 24px;
  border: 1px solid rgba(232,229,220,0.08);
  border-radius: 8px;
  padding: 0;
}

.chart-detail summary {
  padding: 12px 14px;
  font-family: var(--font-chalk);
  font-size: 17px;
  font-weight: 600;
  color: var(--chalk);
  cursor: pointer;
  list-style: none;
}

.chart-detail summary::before {
  content: '▸ ';
  color: var(--chalk-faint);
}

.chart-detail[open] summary::before {
  content: '▾ ';
}

.chart-detail-body {
  padding: 0 14px 14px;
  font-size: 14px;
  color: var(--chalk);
  line-height: 1.55;
}

.kingmaker-note {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid rgba(232,229,220,0.06);
  font-size: 14px;
  color: var(--chalk-dim);
}

.kingmaker-note .kingmaker-label {
  font-family: var(--font-chalk);
  font-size: 15px;
  font-weight: 600;
  color: var(--chalk);
  margin-right: 6px;
}

.overview-callouts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

@media (max-width: 700px) {
  .overview-callouts { grid-template-columns: 1fr; }
}

/* ── Kingmaker items ──────────────────────────────────────── */

.kingmaker-defn {
  margin-bottom: 10px;
}

.kingmaker-value {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.kingmaker-item {
  font-size: 14px;
  color: var(--chalk);
}

.kingmaker-sigma {
  color: var(--chalk-faint);
  font-size: 12px;
  margin-left: 4px;
}

/* ── Footer ────────────────────────────────────────────────── */

.site-footer {
  border-top: 1px solid rgba(232,229,220,0.06);
  padding: 20px 24px;
  text-align: center;
  font-size: 12px;
  color: var(--chalk-faint);
  max-width: 800px;
  margin: 0 auto;
}

.site-footer a { color: var(--chalk-dim); }

.footer-caveat {
  margin-top: 4px;
  font-family: var(--font-chalk);
  font-size: 16px;
  font-style: italic;
}

/* ── What-if: conditional marks ──────────────────────────── */


.whatif-papers {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 20px;
  margin-bottom: 20px;
}

.whatif-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: 6px;
  background: rgba(232,229,220,0.02);
  border: 1px solid rgba(232,229,220,0.06);
  transition: background 0.15s, border-color 0.15s;
}

.whatif-row.fixed {
  background: rgba(91,155,245,0.05);
  border-color: rgba(91,155,245,0.2);
}

.whatif-paper-name {
  flex: 1;
  font-size: 14px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.whatif-input-group {
  display: flex;
  align-items: center;
  gap: 4px;
}

.whatif-mark-input {
  width: 64px;
  padding: 6px 10px;
  border-radius: 6px;
  border: 1px solid rgba(232,229,220,0.12);
  background: rgba(232,229,220,0.04);
  color: var(--chalk);
  font-family: var(--font-body);
  font-size: 15px;
  font-weight: 600;
  text-align: center;
  transition: border-color 0.15s;
  -moz-appearance: textfield;
}

.whatif-mark-input::-webkit-outer-spin-button,
.whatif-mark-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.whatif-mark-input::placeholder {
  color: var(--chalk-faint);
  font-weight: 400;
}

.whatif-mark-input:focus {
  outline: none;
  border-color: var(--blue);
}

.whatif-clear-btn {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: none;
  background: rgba(232,229,220,0.06);
  color: var(--chalk-dim);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
  visibility: hidden;
}

.whatif-row.fixed .whatif-clear-btn {
  visibility: visible;
}

.whatif-clear-btn:hover {
  background: rgba(232,97,77,0.15);
  color: var(--red);
}

.whatif-lock-icon {
  font-size: 14px;
  width: 18px;
  text-align: center;
  flex-shrink: 0;
}

.whatif-status {
  font-size: 12px;
  color: var(--chalk-faint);
  width: 140px;
  text-align: right;
  flex-shrink: 0;
  line-height: 1.4;
}

.whatif-status-sim {
  font-style: italic;
  opacity: 0.6;
}

.whatif-status-pctile {
  color: var(--chalk-dim);
}

.whatif-status-label {
  font-size: 11px;
}

.whatif-status--well-below-average { color: var(--red); }
.whatif-status--below-average { color: var(--gold); }
.whatif-status--around-average { color: var(--chalk-dim); }
.whatif-status--above-average { color: var(--blue); }
.whatif-status--strong { color: #7dd3a0; }

.whatif-actions {
  margin-bottom: 20px;
}

.whatif-results {
  margin-bottom: 24px;
  margin-top: 16px;
}

.whatif-headline {
  background: rgba(232,229,220,0.03);
  border: 1px solid rgba(232,229,220,0.08);
  border-radius: 8px;
  padding: 20px 24px;
  margin-bottom: 16px;
}


.whatif-hint {
  font-size: 14px;
  color: var(--chalk-dim);
  font-style: italic;
  padding: 12px 0;
}

.whatif-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 16px;
  font-size: 14px;
}

.whatif-table th {
  text-align: left;
  padding: 8px 12px;
  border-bottom: 1px solid rgba(232,229,220,0.1);
  color: var(--chalk-faint);
  font-family: var(--font-chalk);
  font-size: 15px;
  font-weight: 600;
}

.whatif-table td {
  padding: 6px 12px;
  border-bottom: 1px solid rgba(232,229,220,0.04);
}

.whatif-table-mark {
  font-weight: 600;
  font-family: var(--font-body);
}

.whatif-table-fixed {
  opacity: 0.6;
}

.whatif-table-fixed .whatif-table-mark {
  color: var(--chalk-faint);
}

.whatif-subheader {
  display: flex;
  align-items: baseline;
  gap: 16px;
  flex-wrap: wrap;
  justify-content: space-between;
  margin-top: 4px;
}

.whatif-subheader .step-actions {
  margin-top: 0;
}

.whatif-subheader .section-note {
  flex: 1 1 300px;
  margin-bottom: 0;
}

.whatif-explanation {
  font-size: 14px;
  color: var(--chalk-dim);
  line-height: 1.6;
  flex: 1 1 300px;
}

.whatif-secondary {
  background: rgba(232,229,220,0.03);
  border: 1px solid rgba(232,229,220,0.08);
  border-radius: 8px;
  padding: 14px 20px;
  margin-top: 16px;
  margin-bottom: 16px;
}

.whatif-secondary h3 {
  font-family: var(--font-chalk);
  font-size: 17px;
  font-weight: 600;
  color: var(--chalk-dim);
  margin-bottom: 6px;
}

.whatif-secondary-note {
  font-size: 13px;
  color: var(--chalk-faint);
  margin-bottom: 10px;
  line-height: 1.5;
}

.whatif-table-note {
  font-size: 11px;
  font-weight: 400;
  color: var(--chalk-faint);
}

/* ── Mobile responsive ────────────────────────────────────── */

@media (max-width: 600px) {
  /* Nav: show/hide on scroll direction */
  .top-nav {
    position: sticky;
    transition: transform 0.25s ease;
  }

  .top-nav.nav-hidden {
    transform: translateY(-100%);
  }

  .nav-title {
    font-size: 16px;
  }

  .nav-links {
    gap: 10px;
  }

  .nav-link {
    font-size: 15px;
  }

  .nav-inner {
    padding: 0;
    height: 44px;
  }

  /* Steps: allow wrapping to two rows */
  .steps {
    flex-wrap: wrap;
    gap: 4px 0;
  }

  .step {
    padding: 6px 8px;
    gap: 5px;
  }

  .step-label {
    font-size: 15px;
  }

  .step-num {
    width: 24px;
    height: 24px;
    font-size: 14px;
  }

  .step-line {
    width: 16px;
  }

  /* Paper breakdown table: horizontal scroll */
  .paper-breakdown {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .breakdown-table {
    min-width: 560px;
  }

  /* What-if rows: stack vertically */
  .whatif-row {
    flex-wrap: wrap;
    gap: 6px 10px;
    padding: 10px 12px;
  }

  .whatif-paper-name {
    flex: 1 1 100%;
    min-width: 0;
    font-size: 13px;
  }

  .whatif-input-group {
    flex: 0 0 auto;
  }

  .whatif-status {
    width: auto;
    text-align: left;
    flex: 1 1 auto;
    font-size: 11px;
  }

  .whatif-lock-icon {
    font-size: 12px;
    width: 14px;
  }

  /* What-if results table: horizontal scroll */
  .whatif-results {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .whatif-table {
    min-width: 480px;
  }

  /* Explorer paper cards: narrower grid */
  .explorer-paper-list {
    grid-template-columns: 1fr;
  }

  .explorer-paper-card {
    padding: 10px 12px;
  }

  /* Overview popularity chart: taller on mobile to give rows space */
  .chart-wrap--tall {
    height: 560px;
  }

  /* Hide desktop-only line breaks */
  .desktop-only {
    display: none;
  }

/* Sticky TOC: match mobile padding */
  .sticky-toc {
    margin: 0 -14px 24px;
    padding: 10px 14px;
    top: 44px;
    transition: top 0.25s ease;
  }

  body.nav-hidden .sticky-toc {
    top: 0;
  }

/* Slider: prevent touch drag from scrolling page */
  .chalk-slider {
    touch-action: none;
  }

  /* Containers: tighter padding */
  .container {
    padding: 24px 14px 60px;
  }

  .top-nav {
    padding: 0 14px;
  }

  .landing {
    padding: 32px 14px 32px;
  }

  .card {
    padding: 18px 14px;
  }
}
