:root {
  --paper: #faf9f6;
  --card: #ffffff;
  --ink: #1c1b1f;
  --muted: #6f6a6e;
  --line: #e5e1db;
  --accent: #ae2b34;
  --accent-ink: #8c2129;
  --wash: #f7efec;
  --serif: "STIX Two Text", "Times New Roman", Georgia, serif;
  --sans: "IBM Plex Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #141317;
    --card: #1d1c21;
    --ink: #eae8e4;
    --muted: #a29ca0;
    --line: #2d2b31;
    --accent: #e37d84;
    --accent-ink: #ee9aa0;
    --wash: #251a1c;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}
body {
  margin: 0 auto;
  max-width: 66rem;
  padding: 0 1.1rem 3rem;
  background: var(--paper);
  color: var(--ink);
  font: 16px/1.55 var(--sans);
}
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-ink); text-decoration: underline; }
a:focus-visible, summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 2px;
}

/* Site chrome */
.site-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 1.4rem 0 0.9rem;
  border-bottom: 1px solid var(--line);
}
.site-title {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 1.25rem;
  color: var(--ink);
  letter-spacing: 0.01em;
}
.site-title:hover { color: var(--accent); text-decoration: none; }
.site-header nav a {
  margin-left: 1.1rem;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 500;
}
.site-header nav a:hover { color: var(--accent); }

.site-footer {
  margin-top: 3.5rem;
  padding-top: 1.1rem;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.8rem;
  max-width: 60ch;
}

/* Masthead: date and stats left, activity calendar right, one aligned band */
.masthead {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 1.2rem 2.5rem;
  padding: 1.8rem 0 0.9rem;
}
/* Fixed slot sized for the longest date ("Wednesday, September 30, 2026")
   so the calendar sits in the same spot on every page. */
.masthead-info { flex: 0 0 35rem; max-width: 100%; }
.masthead h1 {
  font-family: var(--serif);
  font-weight: 600;
  font-size: clamp(1.7rem, 4vw, 2.3rem);
  line-height: 1.15;
  margin: 0 0 0.5rem;
  text-wrap: balance;
}
.day-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1.4rem;
  margin: 0;
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.day-meta a.stat { color: var(--accent); }

/* Contribution-style calendar */
.cal { margin: 0 auto 0.2rem; max-width: 100%; }
@media (max-width: 56rem) {
  /* Narrow screens scroll the grid; no hover there, so no clipped tooltips. */
  .cal { overflow-x: auto; }
}
.cal-months, .cal-grid {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 12px;
  gap: 3px;
  width: max-content;
  padding: 0 4px;
}
.cal-months span {
  height: 0.95rem;
  font-size: 0.62rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: visible;
}
/* The 4px frame keeps the current-day ring inside the scroll container. */
.cal-grid { grid-template-rows: repeat(7, 12px); padding: 4px; }
.cal-cell {
  position: relative;
  width: 12px;
  height: 12px;
  border-radius: 2.5px;
  background: color-mix(in srgb, var(--line) 55%, var(--card));
}
.cal-cell::after {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 7px);
  left: 50%;
  translate: -50%;
  z-index: 20;
  white-space: nowrap;
  padding: 0.22rem 0.55rem;
  border-radius: 4px;
  background: var(--ink);
  color: var(--paper);
  font: 500 0.72rem/1.4 var(--sans);
  font-variant-numeric: tabular-nums;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.12s;
  pointer-events: none;
}
.cal-cell:hover::after,
a.cal-cell:focus-visible::after { opacity: 1; visibility: visible; }
.cal-cell.future::after { content: none; }
@media (prefers-reduced-motion: reduce) {
  .cal-cell::after { transition: none; }
}
.cal-cell.future { visibility: hidden; }
a.cal-cell:hover { outline: 1px solid var(--accent); }
.cal-cell.current { outline: 2px solid var(--accent); outline-offset: 1px; }
.cal-cell.l1 { background: color-mix(in srgb, var(--accent) 22%, var(--card)); }
.cal-cell.l2 { background: color-mix(in srgb, var(--accent) 45%, var(--card)); }
.cal-cell.l3 { background: color-mix(in srgb, var(--accent) 70%, var(--card)); }
.cal-cell.l4 { background: var(--accent); }

/* Sticky section nav */
.topic-nav {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  padding: 0.6rem 0;
  margin: 0.6rem 0 0.4rem;
  border-bottom: 1px solid var(--line);
  background: var(--paper);
  background: color-mix(in srgb, var(--paper) 92%, transparent);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  scrollbar-width: none;
}
.topic-nav::-webkit-scrollbar { display: none; }
@media (max-width: 48rem) {
  /* Single scrolling row on narrow screens, with a fade hinting at more. */
  .topic-nav {
    flex-wrap: nowrap;
    overflow-x: auto;
    mask-image: linear-gradient(90deg, #000 calc(100% - 1.5rem), transparent);
    -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 1.5rem), transparent);
  }
}
.topic-nav a {
  flex: none;
  padding: 0.28rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--card);
  color: var(--ink);
  font-size: 0.78rem;
  font-weight: 500;
  white-space: nowrap;
}
.topic-nav a:hover {
  border-color: var(--accent);
  color: var(--accent);
  text-decoration: none;
}
.topic-nav .n {
  font-family: var(--mono);
  font-size: 0.7rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* Sections */
section { scroll-margin-top: 3.6rem; }
section h2 {
  margin: 2.2rem 0 0.8rem;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--muted);
}
section h2 .count {
  font-family: var(--mono);
  font-weight: 400;
  letter-spacing: 0;
  margin-left: 0.3rem;
  font-variant-numeric: tabular-nums;
}
.highlights h2 { color: var(--accent); }

.highlight-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 27rem), 1fr));
  gap: 0.7rem;
  align-items: start;
}
.topic-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 21rem), 1fr));
  gap: 0.7rem;
  align-items: start;
}

/* Paper cards */
.paper {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 5px;
  transition: border-color 0.15s;
}
.paper:hover { border-color: color-mix(in srgb, var(--accent) 35%, var(--line)); }
.paper[open] { border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }

.paper summary {
  display: block;
  list-style: none;
  position: relative;
  padding: 0.8rem 2.4rem 0.85rem 1rem;
  cursor: pointer;
}
.paper summary::-webkit-details-marker { display: none; }
.paper summary::marker { content: ""; }
.paper summary::after {
  content: "+";
  position: absolute;
  top: 0.62rem;
  right: 0.85rem;
  font-family: var(--mono);
  font-size: 1.1rem;
  color: var(--muted);
  transition: transform 0.15s, color 0.15s;
}
.paper[open] summary::after { transform: rotate(45deg); color: var(--accent); }
@media (prefers-reduced-motion: reduce) {
  .paper, .paper summary::after { transition: none; }
}

.paper h3 {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 1rem;
  line-height: 1.35;
  margin: 0 0 0.35rem;
  text-wrap: balance;
}
.paper-meta {
  display: block;
  font-size: 0.75rem;
  line-height: 1.6;
  color: var(--muted);
}
.paper-meta .authors { margin-right: 0.4rem; }
.tag {
  display: inline-block;
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 0 0.4rem;
  margin-right: 0.35rem;
  font-size: 0.68rem;
  font-weight: 500;
  letter-spacing: 0.03em;
  vertical-align: 1px;
}
.tag-accent { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 55%, var(--line)); }

.paper-summary {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  margin-top: 0.45rem;
  font-family: var(--serif);
  font-size: 0.92rem;
  line-height: 1.55;
}
.paper[open] .paper-summary { display: block; }
.no-summary { color: var(--muted); font-style: italic; }

.paper-more { padding: 0 1rem 0.9rem; }
.paper-more p {
  margin: 0 0 0.7rem;
  max-width: 65ch;
  font-family: var(--serif);
  font-size: 0.92rem;
  line-height: 1.6;
}
.paper-more ul {
  margin: 0 0 0.7rem;
  padding-left: 1.05rem;
  max-width: 65ch;
  font-family: var(--serif);
  font-size: 0.92rem;
  line-height: 1.55;
}
.paper-more li { margin: 0 0 0.45rem; }
.paper-more li::marker { color: var(--accent); }

/* Inline markdown inside summaries */
.paper strong { font-weight: 600; }
.paper code {
  font-family: var(--mono);
  font-size: 0.82em;
  background: color-mix(in srgb, var(--line) 55%, transparent);
  border-radius: 3px;
  padding: 0.04em 0.28em;
}
.paper-links {
  display: flex;
  gap: 1.2rem;
  font-family: var(--mono);
  font-size: 0.78rem;
}
.paper-links a { color: var(--accent); }

/* Highlights get the full treatment */
.highlight {
  background: var(--wash);
  border-color: color-mix(in srgb, var(--accent) 22%, var(--line));
}
.highlight summary { padding: 1rem 2.6rem 1rem 1.2rem; }
.highlight summary::after { top: 0.8rem; right: 1rem; }
.highlight h3 { font-size: 1.12rem; }
.highlight .paper-summary { -webkit-line-clamp: 2; }
.highlight .paper-more { padding: 0 1.2rem 1.1rem; }

/* Folded low-interest papers */
.folded { margin-top: 0.7rem; }
.folded > summary {
  display: inline-block;
  list-style: none;
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 999px;
  padding: 0.28rem 0.85rem;
}
.folded > summary::-webkit-details-marker { display: none; }
.folded > summary::marker { content: ""; }
.folded > summary:hover { color: var(--accent); border-color: var(--accent); }
.folded[open] > summary { color: var(--accent); border-style: solid; }
.folded-list { list-style: none; margin: 0.6rem 0 0; padding: 0; }
.folded-list li {
  padding: 0.35rem 0;
  border-bottom: 1px solid var(--line);
  font-size: 0.85rem;
  line-height: 1.45;
}
.folded-list li:last-child { border-bottom: none; }
.folded-list a { font-family: var(--serif); color: var(--ink); }
.folded-list a:hover { color: var(--accent); }
.folded-list .who { color: var(--muted); font-size: 0.75rem; margin-left: 0.4rem; }

/* Archive */
.archive-list { list-style: none; padding: 0; margin: 1.2rem 0; }
.archive-list li {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--line);
}
.archive-list a {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 1rem;
  color: var(--ink);
}
.archive-list a:hover { color: var(--accent); }
.archive-list .count {
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

main > h1 {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 1.7rem;
  margin: 1.8rem 0 0.5rem;
}
