:root {
  --bg: #faf8f4;
  --card: #ffffff;
  --bg-subtle: #f2efe8;
  --ink: #1a1814;
  --ink-soft: #5a554c;
  --ink-faint: #8e8678;
  --hairline: #e4dfd4;
  --hairline-strong: #c8c2b3;
  --accent: #c26e12;
  --accent-text: #8a4e0a;
  --accent-soft: #ffddc3;
  --accent-bg: #fff3e9;
  --note-bg: #eef6fb;
  --note-border: #4a90c2;
  --note-text: #1c4a66;
  --shadow: 0 1px 2px rgba(26,24,20,.05), 0 1px 3px rgba(26,24,20,.04);
  --serif: "Newsreader", Georgia, "Times New Roman", serif;
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font-family: var(--sans); color: var(--ink); background: var(--bg);
  line-height: 1.5; font-size: 15px; -webkit-font-smoothing: antialiased;
  text-rendering: optimizeSpeed;
}
a { color: var(--accent-text); text-decoration: none; }
a:hover { text-decoration: underline; }
.wrap { max-width: 1320px; margin: 0 auto; padding: 0 32px; }

/* sticky top bar: title + search stay pinned while everything below scrolls away */
.topbar {
  position: sticky; top: 0; z-index: 20; background: var(--card);
  border-bottom: 1px solid var(--hairline); padding: 16px 0;
}
header { background: var(--card); border-bottom: 1px solid var(--hairline); padding: 14px 0 22px; }
.titlebar { display: flex; align-items: center; gap: 24px; flex-wrap: wrap; }
h1 {
  margin: 0; font-family: var(--serif); font-weight: 500; font-size: 32px; line-height: 1;
  letter-spacing: -.025em; display: flex; align-items: center; gap: 13px; flex: 0 0 auto;
}
h1 a { color: var(--ink); display: inline-flex; align-items: center; gap: 13px; }
h1 a:hover { text-decoration: none; }
h1 .with { font-style: italic; margin-left: -0.25em; margin-right: -0.08em; }
/* logo optically centered against the serif cap-height (nudged up a touch),
   and pulled 2px left to tighten the gap after "With" */
h1 .leanlogo { height: 30px; width: auto; display: block; position: relative; top: -5px; margin-left: -2px; }
.search {
  flex: 1 1 auto; min-width: 200px;
  height: 38px; padding: 0 15px; box-sizing: border-box; position: relative; top: -3px;
  font-size: 15px; font-family: var(--sans); border: 1px solid var(--hairline-strong);
  border-radius: 10px; background: var(--card); box-shadow: var(--shadow); outline: none; color: var(--ink);
}
.titlebar .segmented { flex: 0 0 auto; }
.search:focus { border-color: var(--accent); }
.meta-line { color: var(--ink-faint); font-size: 13px; margin-top: 10px; }

.controls { margin-top: 16px; }
/* rounded-full pill group, matching paperswithcode.co time/order filters */
.segmented {
  display: inline-flex; gap: 2px; background: var(--bg-subtle);
  border-radius: 9999px; padding: 4px;
}
.seg {
  border: none; background: transparent; cursor: pointer; font-family: var(--sans);
  font-size: 13px; font-weight: 500; color: var(--ink-soft); padding: 6px 16px;
  border-radius: 9999px; white-space: nowrap;
  transition: color .15s, background-color .15s, box-shadow .15s;
}
.seg:hover { color: var(--ink); }
.seg.active {
  background: var(--card); color: var(--ink); font-weight: 600;
  box-shadow: 0 1px 2px 0 rgba(0,0,0,.05);
}

.chips { display: flex; flex-wrap: wrap; gap: 7px; margin: 14px 0 2px; }
.chip {
  font-size: 12.5px; padding: 4px 11px; border-radius: 999px; border: 1px solid transparent;
  background: var(--bg-subtle); color: var(--ink-soft); cursor: pointer; user-select: none;
  white-space: nowrap; font-family: var(--sans);
}
.chip:hover { filter: brightness(.97); }
.chip.active { outline: 2px solid var(--ink); outline-offset: 1px; }
.chip .n { opacity: .6; margin-left: 4px; }
/* colored chips share the pastel tag palette */
.chip.c-amber  { background:#fdf2d6; color:#a06a1e; }
.chip.c-blue   { background:#e6f0fb; color:#3f72b5; }
.chip.c-green  { background:#e4f3e6; color:#4a8a5c; }
.chip.c-purple { background:#f0e9fa; color:#8061ac; }
.chip.c-pink   { background:#fbe9f1; color:#b06088; }
.chip.c-orange { background:#fcebdc; color:#b06a3c; }
.chip.c-teal   { background:#ddf3ef; color:#43927f; }
.chip.c-rose   { background:#fbe7e7; color:#b06163; }
.chip.c-cyan   { background:#e0f2f5; color:#3f8597; }
.chip.c-indigo { background:#e8e9fa; color:#6062ac; }
.chip.c-lime   { background:#eef5da; color:#6d8a3c; }
.chip.c-slate  { background:#eaeef2; color:#5a6b7e; }

main { margin-top: 4px; margin-bottom: 60px; }

.month-sep {
  position: sticky; top: 64px; z-index: 5; margin: 12px 0 4px; padding: 18px 0 16px;
  font-family: var(--serif); font-size: 17px; font-weight: 600; color: var(--ink-soft);
  background: linear-gradient(var(--bg) 86%, rgba(250,248,244,0));
  display: flex; align-items: center; gap: 12px;
}
.month-sep:first-child { margin-top: 0; }
.month-sep::after { content: ""; flex: 1 1 auto; height: 1px; background: var(--hairline); }
.month-sep .mn { opacity: .6; font-family: var(--sans); font-size: 12.5px; font-weight: 500; }

.card {
  display: flex; gap: 20px; background: var(--card); border: 1px solid var(--hairline);
  border-radius: 14px; padding: 18px 20px; margin-bottom: 16px; box-shadow: var(--shadow);
}
.thumb-link { flex: 0 0 200px; display: block; align-self: flex-start; }
.thumb {
  width: 200px; height: 254px; border-radius: 9px; border: 1px solid var(--hairline);
  object-fit: cover; object-position: top center; background: #fff;
  display: block; transition: box-shadow .12s, transform .12s;
}
.thumb-link:hover .thumb { box-shadow: 0 4px 14px rgba(26,24,20,.16); transform: translateY(-1px); }
.thumb-ph {
  width: 200px; height: 254px; border-radius: 9px; border: 1px solid var(--hairline);
  display: flex; align-items: center; justify-content: center; text-align: center; padding: 8px;
  background: #fff; color: var(--ink-faint);
  font-family: var(--mono); font-size: 12px; font-weight: 500;
}
.body { flex: 1 1 auto; min-width: 0; }
.title {
  font-family: var(--serif); font-size: 22px; font-weight: 500; line-height: 1.2;
  margin: 0 0 6px; letter-spacing: -.015em; text-wrap: balance;
}
.title a { color: var(--ink); }
.title a:hover { color: var(--accent-text); text-decoration: none; }
.authors { font-family: var(--serif); color: var(--ink-soft); font-size: 15px; margin: 0 0 10px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lean-note {
  background: var(--note-bg); border-left: 3px solid var(--note-border); padding: 9px 14px;
  border-radius: 0 8px 8px 0; font-size: 15.5px; margin: 0 0 10px; color: var(--note-text);
}
.abs { font-family: var(--serif); font-size: 15px; color: var(--ink-soft); margin: 0 0 10px; line-height: 1.6; }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: 9px; font-size: 12.5px; }
.badge {
  font-family: var(--mono); background: var(--bg-subtle); color: var(--ink-soft);
  border-radius: 6px; padding: 2px 8px; font-size: 12px;
}
.date { color: var(--ink-faint); font-weight: 500; }
.tag { border-radius: 6px; padding: 2px 9px; cursor: pointer; font-weight: 600;
  background: var(--accent-bg); color: var(--accent-text); }
.tag:hover { text-decoration: underline; }
/* pastel tag color families: soft tinted bg + gently muted text, per tag name */
.tag.c-amber  { background:#fdf2d6; color:#a06a1e; }
.tag.c-blue   { background:#e6f0fb; color:#3f72b5; }
.tag.c-green  { background:#e4f3e6; color:#4a8a5c; }
.tag.c-purple { background:#f0e9fa; color:#8061ac; }
.tag.c-pink   { background:#fbe9f1; color:#b06088; }
.tag.c-orange { background:#fcebdc; color:#b06a3c; }
.tag.c-teal   { background:#ddf3ef; color:#43927f; }
.tag.c-rose   { background:#fbe7e7; color:#b06163; }
.tag.c-cyan   { background:#e0f2f5; color:#3f8597; }
.tag.c-indigo { background:#e8e9fa; color:#6062ac; }
.tag.c-lime   { background:#eef5da; color:#6d8a3c; }
.tag.c-slate  { background:#eaeef2; color:#5a6b7e; }
.links { margin-left: auto; display: flex; gap: 14px; }
.links a { font-weight: 600; color: #1d4ed8; }
.links .repo { color: #1d4ed8; }
.repo-btn { font-family: var(--mono); font-size: 13px; }
.empty { text-align: center; color: var(--ink-faint); padding: 60px 0; }
footer { padding: 26px 0 60px; color: var(--ink-faint); font-size: 12.5px; }
footer a { color: var(--ink-soft); }

/* ---- detail page ---- */
.backlink { display: inline-block; margin: 18px 0 4px; font-size: 13.5px; font-weight: 600; }
.detail { display: flex; gap: 30px; align-items: flex-start; margin-top: 10px; }
.detail-thumb { flex: 0 0 300px; }
.detail-thumb img, .detail-thumb .thumb-ph {
  width: 300px; height: 388px; border-radius: 11px; border: 1px solid var(--hairline);
  object-fit: cover; object-position: top center; background: #fff; display: block;
}
.detail-thumb .thumb-ph { display: flex; align-items: center; justify-content: center;
  font-family: var(--mono); color: var(--ink-faint); }
.detail-main { flex: 1 1 auto; min-width: 0; }
.detail h1.ptitle {
  display: block; font-family: var(--serif); font-size: 30px; font-weight: 500;
  line-height: 1.15; letter-spacing: -.02em; margin: 0 0 10px; color: var(--ink); text-wrap: balance;
}
.detail .authors { font-family: var(--serif); font-size: 16.5px; white-space: normal; margin-bottom: 12px; }
.detail .lean-note { font-size: 16.5px; padding: 12px 16px; margin: 14px 0; }
.detail .abs-full { font-family: var(--serif); font-size: 16.5px; color: #2e2a24; line-height: 1.7; margin: 14px 0 18px; }
.detail .row { font-size: 13px; gap: 10px; margin-bottom: 16px; }

/* TL;DR box (paperswithcode-style): serif text, amber left rule */
.tldr-box {
  position: relative; padding: 16px 20px 16px 22px; background: var(--card);
  border: 1px solid var(--hairline); border-left: 3px solid var(--accent);
  border-radius: 5px; margin: 6px 0 8px; font-family: var(--serif);
  font-size: 16px; line-height: 1.6; color: var(--ink);
}

/* section delimiters: small uppercase mono label with a top hairline */
.section-label {
  font-family: var(--mono); font-size: 10.5px; letter-spacing: .12em; text-transform: uppercase;
  color: var(--ink-faint); margin: 0 0 12px; padding-top: 22px; border-top: 1px solid var(--hairline);
}
.section-label .ai { color: var(--note-border); }
.section-label.first { border-top: none; padding-top: 6px; }

/* summary sections */
.summary { margin: 4px 0 0; }
.sum-block { margin: 0 0 4px; }
.sum-text { font-family: var(--serif); font-size: 16.5px; line-height: 1.7; color: #2e2a24; margin: 0 0 14px; }
.sum-figs { display: flex; flex-wrap: wrap; gap: 16px; margin: 10px 0 18px; }
figure.sum-fig { margin: 0; flex: 1 1 280px; max-width: 100%; }
figure.sum-fig img {
  width: 100%; height: auto; border: 1px solid var(--hairline); border-radius: 8px;
  background: #fff; display: block;
}
figure.sum-fig figcaption { font-size: 12.5px; color: var(--ink-faint); margin-top: 6px; line-height: 1.45; }
.sum-table { overflow-x: auto; margin: 12px 0; }
.sum-table table { border-collapse: collapse; font-size: 13.5px; font-family: var(--sans); width: auto; }
.sum-table th, .sum-table td { border: 1px solid var(--hairline); padding: 5px 11px; text-align: left; }
.sum-table th { background: var(--bg-subtle); font-weight: 600; }
.sum-table .tbl-cap { font-size: 12.5px; color: var(--ink-faint); margin-top: 5px; }
.btns { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 8px; }
.btn {
  display: inline-block; padding: 9px 16px; border-radius: 9px; font-weight: 600; font-size: 14px;
  border: 1px solid var(--hairline-strong); background: var(--card); color: var(--ink);
}
.btn:hover { border-color: var(--accent); color: var(--accent-text); text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { color: #fff; filter: brightness(1.05); }

@media (max-width: 720px) {
  .wrap { padding: 0 16px; }
  .card .thumb-link, .card .thumb, .card .thumb-ph { display: none; }
  .links { margin-left: 0; }
  h1 { font-size: 28px; }
  .title { font-size: 19px; }
  .detail { flex-direction: column; }
  .detail-thumb { flex: 0 0 auto; align-self: center; }
  .detail h1.ptitle { font-size: 25px; }
}
