/* ==========================================================================
   CSLM — Computer Science of Language Models
   Shares the palette and type of https://rainwangphy.github.io/
   ========================================================================== */

:root {
  --bg: #faf9f5;
  --bg-soft: #f0eee6;
  --text: #1a1915;
  --text-muted: #6b6660;
  --text-faint: #7d776c;
  --border: #e3ded1;
  --border-strong: #d6cfbe;
  --link: #9c4221;
  --link-hover: #7a3318;
  --accent: #b3542f;
  --accent-soft: #f2e5db;
  --highlight: #8a3324;
  --highlight-soft: #efe2ce;
  --figure-bg: #ffffff;
  --grain: .05;
  --shadow: 0 1px 2px rgba(60, 47, 33, .06), 0 6px 20px rgba(60, 47, 33, .05);
  --radius: 8px;
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue",
          "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --serif: "Source Serif 4", "Iowan Old Style", "Palatino Linotype", Palatino,
           Georgia, "Songti SC", "Noto Serif CJK SC", serif;
}

html[data-theme="dark"] {
  --bg: #1f1e1c;
  --bg-soft: #282623;
  --text: #ece9e0;
  --text-muted: #a8a299;
  --text-faint: #8a8479;
  --border: #3a3733;
  --border-strong: #4a4640;
  --link: #e08d6a;
  --link-hover: #efb094;
  --accent: #d97757;
  --accent-soft: #3a2a22;
  --highlight: #e5876a;
  --highlight-soft: #3a2520;
  --figure-bg: #f4f2ec;
  --grain: .045;
  --shadow: 0 1px 2px rgba(0, 0, 0, .35), 0 6px 20px rgba(0, 0, 0, .28);
}

* { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: 70px;
}

body {
  margin: 0;
  font-family: var(--serif);
  font-size: 17px;
  line-height: 1.72;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* Faint paper grain over the page background. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: var(--grain);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

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

.content p a, .content li a, .content td a {
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
  text-decoration-color: color-mix(in srgb, var(--link) 35%, transparent);
}
.content p a:hover, .content li a:hover { text-decoration-color: currentColor; }
.content a.card { text-decoration: none; }

img { max-width: 100%; height: auto; }

/* --------------------------------------------------------------- masthead */

.masthead {
  position: sticky;
  top: 0;
  z-index: 100;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: saturate(150%) blur(12px);
  -webkit-backdrop-filter: saturate(150%) blur(12px);
  border-bottom: 1px solid var(--border-strong);
}

.masthead__inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 56px;
}

.site-title {
  font-family: var(--sans);
  font-weight: 650;
  font-size: .95rem;
  letter-spacing: .02em;
  color: var(--text);
  white-space: nowrap;
}
.site-title:hover { color: var(--accent); text-decoration: none; }

.nav-links {
  list-style: none;
  display: flex;
  align-items: center;
  gap: .25rem;
  margin: 0;
  padding: 0;
}

.nav-links a {
  display: block;
  font-family: var(--sans);
  padding: .4rem .7rem;
  border-radius: 6px;
  font-size: .9rem;
  font-weight: 500;
  color: var(--text-muted);
}
.nav-links a:hover { background: var(--bg-soft); color: var(--text); text-decoration: none; }

.theme-toggle, .nav-toggle {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  border-radius: 6px;
  width: 32px;
  height: 32px;
  font-size: .95rem;
  cursor: pointer;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.theme-toggle:hover, .nav-toggle:hover { color: var(--text); border-color: var(--text-faint); }
.nav-toggle { display: none; }

/* ------------------------------------------------------------------ layout */

.layout {
  max-width: 860px;
  margin: 0 auto;
  padding: 3rem 1.5rem 3rem;
}

.content { min-width: 0; }

.content h1 {
  font-family: var(--serif);
  font-size: 2.3rem;
  font-weight: 600;
  letter-spacing: -.015em;
  line-height: 1.2;
  margin: 0 0 .6rem;
}

.content h2 {
  font-family: var(--serif);
  font-size: 1.4rem;
  font-weight: 600;
  letter-spacing: -.008em;
  margin: 3.2rem 0 1rem;
  padding-bottom: .45rem;
  border-bottom: 1px solid var(--border-strong);
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: .9rem;
  align-items: baseline;
}
.content h2 .no {
  font-family: var(--sans);
  font-size: .8rem;
  font-weight: 700;
  letter-spacing: .1em;
  color: var(--accent);
  transform: translateY(-.12em);
}

.content h3 {
  font-family: var(--serif);
  font-size: 1.08rem;
  font-weight: 600;
  margin: 1.8rem 0 .6rem;
}

.content p { margin: 0 0 1rem; }
.content ul, .content ol { padding-left: 1.3rem; margin: 0 0 1rem; }
.content li { margin-bottom: .35rem; }

.muted { color: var(--text-muted); }
.small { font-size: .86rem; }
var, .m { font-style: italic; font-family: var(--serif); }

/* -------------------------------------------------------------------- hero */

.hero { padding-bottom: 1.4rem; }

.eyebrow {
  display: flex;
  align-items: center;
  gap: .9rem;
  margin: 0 0 1.1rem;
  font-family: var(--sans);
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--accent);
}
.eyebrow::after { content: ""; flex: 1; height: 1px; background: var(--border-strong); }

.subtitle {
  margin: 0 0 1.6rem;
  font-size: 1.16rem;
  font-style: italic;
  line-height: 1.55;
  color: var(--text-muted);
  max-width: 38rem;
}

.lede {
  font-size: 1.06rem;
  line-height: 1.75;
}
.lede::first-letter {
  float: left;
  font-size: 3.3em;
  line-height: .82;
  padding: .06em .12em 0 0;
  font-weight: 600;
  color: var(--accent);
}

.chips { display: flex; flex-wrap: wrap; gap: .45rem; margin: 1.4rem 0 0 !important; padding: 0 !important; list-style: none; }
.chips li { margin: 0; }
.chip {
  display: inline-block;
  font-family: var(--sans);
  font-size: .8rem;
  font-weight: 500;
  color: var(--text-muted);
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: .15rem .75rem;
}
.content a.chip { text-decoration: none; }
a.chip:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }

/* ----------------------------------------------------------- claim & defs */

.claim {
  margin: 1.8rem 0;
  padding: 1.1rem 1.3rem;
  background: var(--accent-soft);
  border-left: 3px solid var(--accent);
  border-radius: 0 var(--radius) var(--radius) 0;
  font-size: 1.04rem;
  line-height: 1.6;
}
.claim p { margin: 0; }
.claim p + p { margin-top: .7rem; }
.claim strong { color: var(--accent); font-weight: 600; }
html[data-theme="dark"] .claim strong { color: var(--link-hover); }

.def {
  margin: 1.2rem 0;
  padding: .95rem 1.2rem;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: .97rem;
}
.def p { margin: 0; }
.def p + p { margin-top: .5rem; }
.def__label {
  display: block;
  margin-bottom: .25rem;
  font-family: var(--sans);
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.eq {
  display: block;
  font-family: var(--serif);
  font-style: italic;
  text-align: center;
  margin: .6rem 0 .2rem;
  font-size: 1.02rem;
}

.def-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: .8rem;
  margin: 1rem 0;
}
.def-grid .def { margin: 0; font-size: .92rem; line-height: 1.6; }

/* ----------------------------------------------------------------- figures */

.figure { margin: 1.8rem 0; }
.figure__frame {
  background: var(--figure-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  text-align: center;
}
.figure img { display: block; margin: 0 auto; }
.figure figcaption {
  margin-top: .6rem;
  font-family: var(--sans);
  font-size: .8rem;
  color: var(--text-faint);
  text-align: center;
}


/* ---------------------------------------------------- seven differences */

.diffs { counter-reset: diff; list-style: none; margin: 0 !important; padding: 0 !important; }
.diffs > li {
  counter-increment: diff;
  position: relative;
  padding: .15rem 0 .85rem 2.3rem;
  margin: 0;
  font-size: .95rem;
  line-height: 1.6;
  color: var(--text-muted);
}
.diffs > li::before {
  content: counter(diff, decimal-leading-zero);
  position: absolute;
  left: 0;
  top: .38rem;
  font-family: var(--sans);
  font-size: .72rem;
  font-weight: 700;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}
.diffs b { display: block; color: var(--text); font-weight: 600; }

/* ------------------------------------------------------------------ table */

.table-wrap { overflow-x: auto; margin: 1.4rem 0; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: .9rem;
  line-height: 1.5;
}
th, td {
  padding: .6rem .8rem;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--border);
}
thead th {
  font-family: var(--sans);
  font-size: .76rem;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--text-faint);
  border-bottom: 1px solid var(--border-strong);
}
tbody th { font-weight: 600; white-space: nowrap; }
td:last-child { color: var(--text); }
td:nth-child(2) { color: var(--text-muted); }

/* ------------------------------------------------------------------- cards */

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1rem;
  margin: 1rem 0;
}

.card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-soft);
  padding: 1rem 1.1rem;
}
.card h3 { margin: 0 0 .35rem; font-size: 1rem; font-weight: 600; }
.card p { margin: 0; font-size: .9rem; color: var(--text-muted); line-height: 1.6; }
.card__tag {
  display: block;
  margin-bottom: .3rem;
  font-family: var(--sans);
  font-size: .7rem;
  font-weight: 600;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--accent);
}

a.card { color: inherit; display: block; transition: border-color .15s, transform .15s; }
a.card:hover {
  text-decoration: none;
  border-color: var(--accent);
  background: var(--accent-soft);
  transform: translateY(-1px);
}
a.card:hover h3 { color: var(--accent); }

/* ---------------------------------------------------------------- timeline */

.timeline {
  list-style: none;
  margin: 1.4rem 0 !important;
  padding: 0 !important;
  position: relative;
}
.timeline::before {
  content: "";
  position: absolute;
  left: 94px;
  top: .6rem;
  bottom: .6rem;
  width: 1px;
  background: var(--border-strong);
}
.timeline > li {
  display: grid;
  grid-template-columns: 80px minmax(0, 1fr);
  gap: 2rem;
  position: relative;
  margin: 0;
  padding: .55rem 0;
}
.timeline > li::before {
  content: "";
  position: absolute;
  left: 90px;
  top: 1.05rem;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--bg);
  border: 2px solid var(--border-strong);
}
.timeline .when {
  font-family: var(--sans);
  font-size: .82rem;
  font-weight: 600;
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
  text-align: right;
  white-space: nowrap;
  padding-top: .15rem;
}
.timeline .what { font-size: .94rem; color: var(--text-muted); line-height: 1.6; }
.timeline .what b { color: var(--text); font-weight: 600; }
.timeline .what p { margin: .2rem 0 0; }

.timeline > li.is-future::before { background: var(--accent); border-color: var(--accent); }
.timeline > li.is-future .when { color: var(--accent); }
.timeline > li.divider { padding: .9rem 0; }
.timeline > li.divider::before { display: none; }
.timeline > li.divider .what {
  font-family: var(--sans);
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--text-faint);
}

/* ------------------------------------------------------------- read list */

.reading section { margin-bottom: 1.6rem; }
.reading h3 {
  margin: 0 0 .4rem;
  font-family: var(--sans);
  font-size: .76rem;
  font-weight: 600;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--text-faint);
}
.reading ul { list-style: none; padding: 0 !important; margin: 0 !important; }
.reading li {
  padding: .4rem 0;
  border-bottom: 1px dashed var(--border);
  font-size: .9rem;
  line-height: 1.5;
  margin: 0;
}
.reading li:last-child { border-bottom: 0; }
.content .reading a { color: var(--text); text-decoration: none; }
.content .reading a:hover { color: var(--accent); }

/* ------------------------------------------------------------------ footer */

.site-footer { border-top: 1px solid var(--border); margin-top: 2rem; }
.site-footer__inner {
  font-family: var(--sans);
  max-width: 1180px;
  margin: 0 auto;
  padding: 1.4rem 1.5rem 2.2rem;
  font-size: .82rem;
  color: var(--text-faint);
  display: flex;
  flex-wrap: wrap;
  gap: .8rem;
  justify-content: space-between;
}

/* ------------------------------------------------------------- responsive */

@media (max-width: 760px) {
  .def-grid { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 680px) {
  body { font-size: 16.5px; }
  .nav-toggle { display: inline-flex; }
  .masthead__inner { flex-wrap: wrap; padding: .5rem 1rem; }
  .nav-links {
    order: 3;
    flex-basis: 100%;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    display: none;
    padding-bottom: .5rem;
  }
  .nav-links.is-open { display: flex; }
  .nav-links a { padding: .55rem .6rem; }
  .layout { padding: 2rem 1rem 2rem; }
  .content h1 { font-size: 1.7rem; }
  .timeline::before { left: 72px; }
  .timeline > li { grid-template-columns: 58px minmax(0, 1fr); gap: 1.9rem; }
  .timeline > li::before { left: 68px; }
  .timeline .when { font-size: .76rem; }
}
