:root {
  --serif: 'Source Serif 4', Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --mono: 'JetBrains Mono', 'SFMono-Regular', Menlo, monospace;

  --bg: #fdfcf9;
  --paper: #ffffff;
  --text: #2f2a22;
  --muted: #6e665b;
  --border: #e2d8c6;
  --accent: #2c6fb7;
  --accent-hover: #1e528a;
  --warm: #d9622b;
  --warm-soft: #fad9c8;
  --cool-soft: #e2eaf5;
  --extreme: #d9622b;
  --extreme-soft: rgba(217, 98, 43, 0.1);
}

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

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: var(--serif);
  color: var(--text);
  background: var(--bg);
  line-height: 1.65;
}

.article {
  max-width: 980px;
  margin: 0 auto;
  padding: 2.5rem 1.5rem 5rem;
}

.back-link {
  display: inline-block;
  margin-bottom: 1.5rem;
  color: var(--muted);
  text-decoration: none;
  font-family: var(--sans);
  font-size: 0.9rem;
  transition: color 0.2s;
}
.back-link:hover {
  color: var(--text);
}

.article-header {
  margin-bottom: 3rem;
  text-align: center;
}

.kicker {
  margin: 0 0 0.75rem;
  font-family: var(--sans);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--muted);
}

h1 {
  margin: 0 auto 1rem;
  font-size: clamp(2.4rem, 5vw, 3.5rem);
  line-height: 1.1;
  letter-spacing: -0.02em;
  max-width: 15ch;
  color: #1a1815;
}

.abstract {
  margin: 0 auto;
  max-width: 62ch;
  font-size: 1.15rem;
  color: #4d463d;
}

.byline {
  display: flex;
  gap: 1rem;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 1.4rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-family: var(--sans);
  font-size: 0.92rem;
}

.step-section {
  position: relative;
  margin-top: 4rem;
  padding: 3rem 2.5rem;
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: 24px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.03);
}

.step-badge {
  position: absolute;
  top: -16px;
  left: 32px;
  background: var(--accent);
  color: white;
  font-family: var(--sans);
  font-weight: 700;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 0.4rem 1.2rem;
  border-radius: 999px;
  box-shadow: 0 4px 12px rgba(44, 111, 183, 0.25);
}

h2 {
  margin: 0 0 1rem;
  font-size: clamp(1.6rem, 3.5vw, 2.2rem);
  line-height: 1.15;
  color: #1a1815;
}

p {
  max-width: 68ch;
  font-size: 1.1rem;
}

code {
  font-family: var(--mono);
  font-size: 0.92em;
  background: rgba(0, 0, 0, 0.05);
  padding: 0.2em 0.4em;
  border-radius: 6px;
}

.button-row {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin: 1.5rem 0 0.5rem;
}

.scenario-desc {
  font-family: var(--sans);
  color: var(--muted);
  font-size: 0.95rem;
  margin-top: 0;
  margin-bottom: 2rem;
  font-style: italic;
}

.mode-button {
  border: 1px solid var(--border);
  background: white;
  color: var(--text);
  padding: 0.7rem 1.2rem;
  border-radius: 999px;
  font: 600 0.95rem var(--sans);
  cursor: pointer;
  transition: all 150ms ease;
  box-shadow: 0 2px 8px rgba(0,0,0,0.02);
}

.mode-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.06);
  border-color: var(--accent);
}

.mode-button.is-active {
  background: var(--text);
  color: white;
  border-color: var(--text);
}

.action-btn {
  border: none;
  background: var(--text);
  color: white;
  padding: 0.8rem 1.4rem;
  border-radius: 12px;
  font: 600 1rem var(--sans);
  cursor: pointer;
  transition: all 150ms ease;
  box-shadow: 0 4px 14px rgba(0,0,0,0.1);
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
}

.action-btn:hover {
  transform: translateY(-2px);
  background: #1a1815;
  box-shadow: 0 6px 20px rgba(0,0,0,0.15);
}

.action-btn:active {
  transform: translateY(1px);
}

.action-btn--primary {
  background: var(--accent);
  font-size: 1.15rem;
  padding: 1rem 2.5rem;
  border-radius: 16px;
}
.action-btn--primary:hover {
  background: var(--accent-hover);
}

.sample-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1.5rem;
  margin-top: 1rem;
}

.sample-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 1.5rem;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.03);
}

.sample-card--accent {
  background: linear-gradient(150deg, rgba(217, 98, 43, 0.05), white);
  border-color: rgba(217, 98, 43, 0.25);
}

.sample-card h3 {
  margin: 0 0 1rem;
  font-size: 1.05rem;
  font-family: var(--sans);
  color: #554e44;
}

.number-bubbles {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  min-height: 4rem;
  margin-bottom: 1.2rem;
}

.bubble {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border-radius: 10px;
  background: var(--cool-soft);
  color: var(--accent-hover);
  font-family: var(--mono);
  font-weight: 600;
  font-size: 1.05rem;
  box-shadow: 0 2px 5px rgba(0,0,0,0.06);
  animation: popIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

@keyframes popIn {
  0% { transform: scale(0.6) translateY(10px); opacity: 0; }
  100% { transform: scale(1) translateY(0); opacity: 1; }
}

.bubble.group-b {
  background: var(--warm-soft);
  color: #9c3f15;
}

.bubble.neutral {
  background: #f0ebe1;
  color: var(--text);
  margin: 4px;
  border-radius: 50%;
}

.sample-metric {
  margin: 0;
  color: var(--muted);
  font-family: var(--sans);
  font-size: 0.95rem;
}

.big-number {
  margin: 0.25rem 0 0.5rem;
  font: 700 clamp(2.5rem, 5vw, 3.2rem) var(--sans);
  color: var(--warm);
  line-height: 1;
}

.unit {
  font-size: 0.45em;
  color: var(--muted);
  font-weight: 500;
  vertical-align: middle;
}

.bucket-container {
  margin: 2.5rem 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
}

.bucket {
  width: 100%;
  max-width: 500px;
  min-height: 140px;
  border: 3px dashed #d1c8b8;
  border-radius: 24px;
  background: rgba(255,255,255,0.4);
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-content: center;
  padding: 1.5rem;
  transition: all 0.4s ease;
}

.bucket.filled {
  border-style: solid;
  border-color: #d1c8b8;
  background: white;
  box-shadow: inset 0 4px 15px rgba(0,0,0,0.04);
}

.bucket-empty-text {
  color: #9a917f;
  font-family: var(--sans);
  margin: 0;
}

.reshuffle-controls {
  display: flex;
  align-items: stretch;
  gap: 1rem;
  margin: 2rem 0;
  flex-wrap: wrap;
}

.reshuffle-result {
  flex: 1;
  background: white;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem 1.5rem;
  font-family: var(--sans);
  display: flex;
  align-items: center;
  box-shadow: inset 0 2px 6px rgba(0,0,0,0.02);
}

.reshuffle-result p {
  margin: 0;
  font-size: 0.95rem;
  color: var(--muted);
}

.flex-cols {
  display: flex;
  width: 100%;
  gap: 1rem;
  justify-content: space-between;
  align-items: center;
}

.flex-cols div {
  font-size: 0.95rem;
}

.stat-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1.2rem;
  margin: 2rem 0;
  transition: opacity 0.4s ease, transform 0.4s ease;
}

.stat-strip.hidden {
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
}

.stat-pill {
  background: white;
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 1.2rem;
  text-align: center;
  box-shadow: 0 4px 15px rgba(0,0,0,0.02);
}

.stat-pill.highlight-pill {
  border-color: var(--extreme);
  background: var(--extreme-soft);
}

.stat-label {
  display: block;
  margin-bottom: 0.5rem;
  font-family: var(--sans);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
}

.stat-value {
  font: 700 2rem var(--sans);
  color: var(--text);
  line-height: 1;
}
.highlight-pill .stat-value {
  color: var(--extreme);
}

.interactive-figure {
  margin: 2.5rem 0;
  padding: 1.5rem 2rem;
  background: white;
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.04);
}

canvas {
  width: 100%;
  height: auto;
  display: block;
}

figcaption {
  margin-bottom: 1.5rem;
  color: var(--muted);
  font-size: 0.95rem;
  text-align: center;
  font-family: var(--sans);
}

.p-value-card {
  background: #1a1815;
  color: white;
  border-radius: 24px;
  padding: 3rem 2rem;
  text-align: center;
  margin: 2.5rem 0;
  box-shadow: 0 20px 50px rgba(0,0,0,0.12);
}

.p-value-title {
  margin: 0 0 1rem;
  font-size: 2rem;
  font-weight: 400;
  color: #e2d8c6;
}

.p-val-number {
  font-weight: 700;
  color: #ffc266;
  font-size: 2.8rem;
}

.p-value-math {
  font-family: var(--mono);
  font-size: 1.15rem;
  color: #a39c8e;
  margin-bottom: 2rem;
  background: rgba(255,255,255,0.05);
  display: inline-block;
  padding: 0.5rem 1.5rem;
  border-radius: 8px;
}

.p-value-explanation {
  font-size: 1.15rem;
  max-width: 60ch;
  margin: 0 auto;
  line-height: 1.6;
}

/* ─── Callout variants ─── */
.callout {
  margin: 1.5rem 0;
  padding: 1rem 1.2rem;
  border-radius: 0 12px 12px 0;
  font-size: 1rem;
}
.callout strong {
  font-family: var(--sans);
  font-size: 0.9rem;
}
.callout--think {
  border-left: 3px solid var(--accent);
  background: rgba(44, 111, 183, 0.04);
}
.callout--null {
  border-left: 3px solid var(--extreme);
  background: rgba(217, 98, 43, 0.04);
}

/* ─── Extreme tag ─── */
.extreme-tag {
  display: inline-block;
  font-family: var(--sans);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--extreme);
  background: var(--extreme-soft);
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  margin-left: 0.3rem;
}

/* ─── Math blocks ─── */
.math-block {
  margin: 1.2rem 0;
  text-align: center;
  overflow-x: auto;
}

/* ─── Misconception cards ─── */
.misconception-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1rem;
  margin: 1.5rem 0;
}
.misconception-card {
  padding: 1.2rem;
  border: 1px solid rgba(200, 50, 50, 0.15);
  border-radius: 14px;
  background: rgba(200, 50, 50, 0.03);
}
.misconception-card p {
  margin: 0;
  font-size: 0.95rem;
  line-height: 1.55;
}
.misconception-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.2rem 0.8rem;
  border-radius: 16px;
  background: rgba(200, 50, 50, 0.1);
  color: #c03030;
  font-family: var(--sans);
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.5rem;
}

/* ─── Shortcut cards & Viz ─── */
.shortcut-viz {
  margin: 3rem 0;
  padding: 2rem;
  background: white;
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.02);
}

.shortcut-viz h4 {
  margin: 0 0 0.5rem;
  font-family: var(--sans);
  font-size: 1.25rem;
  color: #1a1815;
}

.shortcut-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin: 1.5rem 0;
}
.shortcut-card {
  padding: 1.2rem;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: white;
  box-shadow: 0 4px 15px rgba(0,0,0,0.02);
}
.shortcut-card h4 {
  margin: 0 0 0.5rem;
  font-family: var(--sans);
  font-size: 1rem;
  color: var(--text);
}
.shortcut-card p {
  margin: 0;
  font-size: 0.95rem;
  color: var(--muted);
  line-height: 1.55;
}

/* ─── Explanation list ─── */
.explanation-list {
  max-width: 68ch;
  font-size: 1.1rem;
  padding-left: 1.5rem;
}

.explanation-list li {
  margin-bottom: 0.8rem;
}

h3 {
  margin-top: 2rem;
  margin-bottom: 0.8rem;
  font-size: 1.25rem;
  color: #1a1815;
}

@media (max-width: 880px) {
  .sample-grid,
  .stat-strip {
    grid-template-columns: 1fr;
  }
  .reshuffle-controls {
    flex-direction: column;
  }
  .shortcut-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .article {
    padding-inline: 1rem;
  }
  .step-section {
    padding: 2rem 1.5rem;
  }
  .interactive-figure {
    padding: 1rem;
  }
  .action-btn {
    width: 100%;
    justify-content: center;
  }
}
