:root {
  --serif: 'Source Serif 4', Georgia, serif;
  --sans: 'Manrope', -apple-system, BlinkMacSystemFont, sans-serif;
  --mono: 'IBM Plex Mono', monospace;

  --bg: #fdfcf9;
  --paper: #ffffff;
  --text: #2f2a22;
  --muted: #6e665b;
  --border: #e2d8c6;
  --accent: #2c6fb7;
  --accent-hover: #1e528a;
}

*, *::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; }
.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; color: #1a1815; max-width: 16ch; }
.abstract { margin: 0 auto 1rem; max-width: 64ch; 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, ul { max-width: 68ch; font-size: 1.1rem; }
li { margin-bottom: 0.5rem; }
.explanation-list { padding-left: 1.5rem; margin: 1rem 0; }

.math-block { margin: 1.5rem 0; padding: 0.6rem 0.8rem; overflow-x: auto; background: rgba(0,0,0,0.02); border-radius: 12px; text-align: center; }

.action-btn {
  border: 1px solid var(--accent);
  background: var(--accent); color: white;
  padding: 0.55rem 1rem; border-radius: 999px;
  font: 600 0.88rem var(--sans); cursor: pointer;
}
.action-btn:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.action-btn--ghost { background: white; color: var(--text); border-color: var(--border); }
.action-btn--ghost:hover { border-color: var(--accent); }

.train-controls {
  display: flex; align-items: center; gap: 0.9rem; flex-wrap: wrap;
  margin: 0.8rem 0 1.2rem;
  font-family: var(--sans); color: var(--text);
}
.train-controls label { display: flex; align-items: center; gap: 0.5rem; font-size: 0.92rem; }
.train-controls input[type=range] { width: 200px; accent-color: var(--accent); }

.ssl-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem;
  margin: 1rem 0;
}
@media (max-width: 880px) { .ssl-grid { grid-template-columns: 1fr; } }
.ssl-panel {
  background: white;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 0.8rem 0.9rem 1rem;
  display: flex; flex-direction: column; gap: 0.4rem; align-items: center;
}
.ssl-panel canvas {
  width: 224px; height: 224px;
  border-radius: 8px;
  image-rendering: pixelated;
}
.panel-label { font-family: var(--sans); font-weight: 600; font-size: 0.86rem; color: var(--text); text-align: center; }
.panel-meta { font-family: var(--mono); font-size: 0.82rem; color: var(--muted); margin-top: 0.4rem; }

.ssl-figure {
  margin: 1.4rem 0;
  padding: 1.1rem;
  background: white;
  border: 1px solid var(--border);
  border-radius: 16px;
}
.ssl-figure canvas { width: 100%; height: auto; display: block; border-radius: 8px; background: #fdfcf9; }
.ssl-figure figcaption { margin-top: 0.7rem; text-align: center; font-family: var(--sans); font-size: 0.92rem; color: var(--muted); }

.examples-table-wrap { overflow-x: auto; margin: 1.5rem 0; }
.examples-table { width: 100%; border-collapse: collapse; font-family: var(--sans); font-size: 0.95rem; }
.examples-table th, .examples-table td { padding: 0.7rem 0.9rem; text-align: left; border-bottom: 1px solid var(--border); vertical-align: top; }
.examples-table th { background: rgba(0,0,0,0.02); color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; font-size: 0.78rem; }

.callout {
  margin: 1.6rem 0; padding: 1.1rem 1.3rem;
  border-left: 4px solid var(--accent);
  background: rgba(44, 111, 183, 0.04);
  border-radius: 0 12px 12px 0; font-size: 1rem;
}
.callout strong { font-family: var(--sans); font-size: 0.9rem; }
.callout--think { border-left-color: #d9622b; background: rgba(217,98,43,0.04); }
.callout--key   { border-left-color: #1e7770; background: rgba(30,119,112,0.05); }

/* ---------- contrastive / SimCLR lab ---------- */
.lab {
  margin: 1.6rem 0 0.5rem;
  padding: 1.4rem 1.4rem 1.2rem;
  background: #fbfaf6;
  border: 1px solid var(--border);
  border-radius: 18px;
}
.lab-controls {
  display: flex; flex-wrap: wrap; align-items: flex-end;
  gap: 1.1rem 1.6rem; margin-bottom: 1.4rem;
}
.ctrl { display: flex; flex-direction: column; gap: 0.4rem; min-width: 190px; flex: 1 1 190px; }
.ctrl label {
  display: flex; justify-content: space-between; align-items: baseline;
  font-family: var(--sans); font-size: 0.86rem; font-weight: 600; color: var(--text);
}
.ctrl-val { font-family: var(--mono); color: #d9622b; font-weight: 500; }
.lab input[type=range] {
  -webkit-appearance: none; width: 100%; height: 4px;
  background: var(--border); border-radius: 2px; outline: none;
}
.lab input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 17px; height: 17px; border-radius: 50%;
  background: var(--accent); border: 3px solid #fff; cursor: pointer;
  box-shadow: 0 2px 5px rgba(44,111,183,0.4);
}
.lab input[type=range]::-moz-range-thumb {
  width: 17px; height: 17px; border-radius: 50%;
  background: var(--accent); border: 3px solid #fff; cursor: pointer;
}
.lab-controls .action-btn { flex: 0 0 auto; align-self: flex-end; }

.lab-top {
  display: grid; grid-template-columns: 1.1fr 1fr; gap: 1.4rem;
  align-items: start; margin-bottom: 1.2rem;
}
@media (max-width: 780px) { .lab-top { grid-template-columns: 1fr; } }

.lab-views {
  display: flex; flex-wrap: wrap; align-items: center; gap: 0.8rem;
}
.lab-view { display: flex; flex-direction: column; align-items: center; gap: 0.4rem; }
.lab-view canvas {
  width: 112px; height: 112px; border-radius: 8px; background: #fff;
  image-rendering: auto;
}
.lab-arrow { font-family: var(--sans); font-size: 0.8rem; color: var(--muted); font-weight: 600; }
.lab-arrow span { display: block; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em; }

.lab-scatter, .lab-matrix { margin: 0; }
.lab-scatter canvas { width: 100%; max-width: 300px; height: auto; display: block; margin: 0 auto; border-radius: 10px; }
.lab-matrix { margin-top: 0.4rem; text-align: center; }
.lab-matrix canvas { width: 100%; max-width: 366px; height: auto; display: inline-block; border-radius: 10px; }
.lab-scatter figcaption, .lab-matrix figcaption {
  margin-top: 0.5rem; font-family: var(--sans); font-size: 0.82rem;
  color: var(--muted); line-height: 1.45; text-align: center;
}

.stat-strip { display: flex; gap: 0.8rem; flex-wrap: wrap; margin: 1.2rem 0 0.4rem; }
.stat-pill {
  flex: 1 1 130px; min-width: 130px;
  background: #fff; border: 1.5px solid var(--border); border-radius: 12px;
  padding: 0.7rem 0.9rem; display: flex; flex-direction: column; gap: 0.15rem;
}
.stat-pill .stat-label { font-family: var(--sans); font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); font-weight: 600; }
.stat-pill .stat-value { font-family: var(--mono); font-size: 1.35rem; font-weight: 600; color: var(--text); }
.stat-pill--accent { border-color: var(--accent); }
.stat-pill--accent .stat-value { color: var(--accent); }
.stat-pill--warm { border-color: #d9622b; }
.stat-pill--warm .stat-value { color: #d9622b; }

.article-footer { margin-top: 4rem; text-align: center; font-family: var(--sans); font-size: 0.85rem; color: var(--muted); }

@media (max-width: 640px) {
  .article { padding-inline: 1rem; }
  .step-section { padding: 2rem 1.5rem; }
  .lab-controls .action-btn { align-self: stretch; width: 100%; }
}
