:root {
  --bg: #f6f4ee;
  --surface: #fffefb;
  --ink: #1d1c1a;
  --ink-2: #55524c;
  --ink-3: #8a867e;
  --rule: #e4e0d6;
  --rule-strong: #cfc9bc;
  --accent: #a4332b;
  --accent-soft: #f4e4df;
  --strip: #c9c3b6;
  --strip-on: #a4332b;
  --shadow: 0 1px 0 rgba(0,0,0,.02), 0 12px 40px -12px rgba(40,30,20,.28);
  --d-rct: #2d6a9f; --d-ma: #7a4fa0; --d-sr: #9567b0; --d-trial: #4f84b0;
  --d-cons: #a8741b; --d-obs: #2e7a68; --d-rev: #8a7962; --d-other: #7d7a74;
  --serif: "Newsreader", "Iowan Old Style", Georgia, serif;
  --sans: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121110; --surface: #1b1a18; --ink: #ece8e1; --ink-2: #b3aea5; --ink-3: #7f7a72;
    --rule: #2b2926; --rule-strong: #3a3733; --accent: #e0705f; --accent-soft: #3a211d;
    --strip: #3d3a35; --strip-on: #e0705f; --shadow: 0 12px 40px -12px rgba(0,0,0,.7);
    --d-rct: #6ea6d8; --d-ma: #b493d6; --d-sr: #c4a6de; --d-trial: #8cb6db;
    --d-cons: #d9a54b; --d-obs: #63b39f; --d-rev: #b8a68d; --d-other: #a39f97;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #121110; --surface: #1b1a18; --ink: #ece8e1; --ink-2: #b3aea5; --ink-3: #7f7a72;
  --rule: #2b2926; --rule-strong: #3a3733; --accent: #e0705f; --accent-soft: #3a211d;
  --strip: #3d3a35; --strip-on: #e0705f; --shadow: 0 12px 40px -12px rgba(0,0,0,.7);
  --d-rct: #6ea6d8; --d-ma: #b493d6; --d-sr: #c4a6de; --d-trial: #8cb6db;
  --d-cons: #d9a54b; --d-obs: #63b39f; --d-rev: #b8a68d; --d-other: #a39f97;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.5 var(--sans); font-feature-settings: "tnum" 0;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
button, input, select { font: inherit; color: inherit; }
.wrap { max-width: 880px; margin: 0 auto; padding: 0 16px; }
[hidden] { display: none !important; }

/* Masthead */
.masthead { border-bottom: 1px solid var(--rule); }
.masthead-inner { display: flex; align-items: baseline; gap: 18px; flex-wrap: wrap; padding-top: 22px; padding-bottom: 14px; }
.wordmark { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; }
.wordmark span { font: 600 26px/1 var(--serif); letter-spacing: -.01em; }
.mark { width: 24px; height: 24px; fill: var(--accent); transform: translateY(2px); }
.tagline { margin: 0; color: var(--ink-2); font: italic 400 17px/1.3 var(--serif); }

/* Controls */
.controls { position: sticky; top: 0; z-index: 5; background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: saturate(1.4) blur(10px); -webkit-backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--rule); }
.tabs { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; margin: 0 -16px; padding: 8px 16px 0; }
.tabs::-webkit-scrollbar { display: none; }
.tabs a { flex: none; padding: 8px 12px 10px; text-decoration: none; color: var(--ink-2); font-weight: 500;
  border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs a:hover { color: var(--ink); }
.tabs a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--accent); }
.count { color: var(--ink-3); font-weight: 400; font-variant-numeric: tabular-nums; }
.filters { display: grid; grid-template-columns: 1fr auto auto; gap: 8px; padding: 10px 0 8px; }
.search { position: relative; display: block; }
.search svg { position: absolute; left: 11px; top: 50%; width: 16px; height: 16px; transform: translateY(-50%);
  fill: none; stroke: var(--ink-3); stroke-width: 1.8; stroke-linecap: round; }
input[type="search"], select {
  width: 100%; height: 38px; border: 1px solid var(--rule-strong); border-radius: 8px;
  background: var(--surface); padding: 0 12px; outline: none; }
input[type="search"] { padding-left: 34px; }
select { padding-right: 28px; appearance: none; -webkit-appearance: none; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--ink-3) 50%), linear-gradient(135deg, var(--ink-3) 50%, transparent 50%);
  background-position: calc(100% - 15px) 16px, calc(100% - 10px) 16px; background-size: 5px 5px; background-repeat: no-repeat; }
input:focus-visible, select:focus-visible, button:focus-visible, a:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px; }
.areas { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; margin: 0 -16px; padding: 2px 16px 12px; }
.areas::-webkit-scrollbar { display: none; }
.chip { flex: none; border: 1px solid var(--rule-strong); background: transparent; border-radius: 999px;
  padding: 5px 12px; font-size: 13.5px; color: var(--ink-2); cursor: pointer; white-space: nowrap; }
.chip:hover { color: var(--ink); border-color: var(--ink-3); }
.chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--bg); }

/* List */
.summary { color: var(--ink-3); font-size: 13.5px; margin: 16px 0 4px; }
.papers { list-style: none; margin: 0; padding: 0; }
.paper { display: grid; grid-template-columns: 44px 1fr auto; gap: 4px 14px; padding: 16px 0;
  border-bottom: 1px solid var(--rule); cursor: pointer; }
.paper:hover .title { color: var(--accent); }
.rank { font: 500 19px/1.35 var(--serif); color: var(--ink-3); text-align: right; font-variant-numeric: tabular-nums; }
.body { min-width: 0; }
.title { font: 500 18.5px/1.32 var(--serif); margin: 0 0 5px; letter-spacing: -.003em; transition: color .12s; }
.title a { text-decoration: none; }
.meta { color: var(--ink-2); font-size: 13.5px; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; }
.meta .journal { font-style: italic; }
.dot { width: 3px; height: 3px; border-radius: 50%; background: var(--ink-3); }
.badge { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 500; color: var(--ink-2); }
.badge::before { content: ""; width: 8px; height: 8px; border-radius: 2px; background: var(--c, var(--d-other)); }
.area-tag { font-size: 12.5px; color: var(--ink-3); }
.stats { text-align: right; display: flex; flex-direction: column; align-items: flex-end; gap: 6px; min-width: 104px; }
.cites { font: 600 22px/1 var(--serif); font-variant-numeric: tabular-nums; }
.cites small { display: block; font: 400 11.5px/1.3 var(--sans); color: var(--ink-3); margin-top: 3px; letter-spacing: .01em; }
.strip { display: grid; grid-template-columns: repeat(16, 1fr); gap: 2px; align-items: end; width: 96px; height: 18px; }
.strip i { display: block; background: var(--strip); border-radius: 1px; min-height: 2px; }
.strip i.on { background: var(--strip-on); }
.row-actions { display: flex; gap: 2px; }
.icon-btn { border: 0; background: transparent; padding: 4px; border-radius: 6px; cursor: pointer; color: var(--ink-3); line-height: 0; }
.icon-btn:hover { color: var(--ink); background: var(--rule); }
.icon-btn svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linejoin: round; }
.icon-btn[aria-pressed="true"] { color: var(--accent); }
.icon-btn[aria-pressed="true"] svg { fill: currentColor; }
.empty { padding: 48px 0; color: var(--ink-2); text-align: center; font: italic 18px/1.5 var(--serif); }
.empty a, .linklike { color: var(--accent); }
#sentinel { height: 1px; }

/* Footer */
.footer { padding-top: 28px; padding-bottom: 40px; color: var(--ink-3); font-size: 13px; }
.footer p { margin: 0 0 6px; }
.footer-links { display: flex; gap: 18px; flex-wrap: wrap; }
.footer a, .linklike { color: var(--ink-2); }
.linklike { border: 0; background: none; padding: 0; text-decoration: underline; cursor: pointer; font-size: inherit; }

/* Detail sheet */
.sheet { border: 0; padding: 0; background: var(--surface); color: var(--ink); box-shadow: var(--shadow);
  width: min(760px, 100%); max-height: min(92vh, 1000px); border-radius: 14px; overflow: auto; overscroll-behavior: contain; }
.sheet::backdrop { background: rgba(20, 16, 12, .42); }
.sheet-inner { padding: 26px 30px 30px; position: relative; }
.close { position: sticky; top: 0; float: right; margin: -10px -14px 0 8px; width: 36px; height: 36px; border: 0;
  border-radius: 50%; background: var(--surface); font-size: 24px; line-height: 1; color: var(--ink-2); cursor: pointer; z-index: 1; }
.close:hover { background: var(--rule); color: var(--ink); }
.d-kicker { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; margin-bottom: 10px; }
.d-title { font: 500 27px/1.22 var(--serif); margin: 0 0 10px; letter-spacing: -.01em; }
.d-meta { color: var(--ink-2); margin: 0 0 16px; }
.d-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 22px; }
.btn { display: inline-flex; align-items: center; gap: 7px; height: 36px; padding: 0 14px; border-radius: 8px;
  border: 1px solid var(--rule-strong); background: transparent; text-decoration: none; cursor: pointer; font-size: 14px; font-weight: 500; }
.btn:hover { border-color: var(--ink-3); }
.btn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linejoin: round; stroke-linecap: round; }
.btn[aria-pressed="true"] { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }
.btn[aria-pressed="true"] svg { fill: currentColor; }
.d-why { border-top: 1px solid var(--rule); padding-top: 18px; }
.d-why p.lead { font: 400 19px/1.45 var(--serif); margin: 0 0 14px; }
.d-why p.lead strong { font-weight: 600; }
.big-strip { display: grid; grid-template-columns: repeat(16, 1fr); gap: 3px; align-items: end; height: 54px; margin-bottom: 4px; }
.big-strip i { background: var(--strip); border-radius: 2px; min-height: 3px; }
.big-strip i.on { background: var(--strip-on); }
.strip-axis { display: flex; justify-content: space-between; color: var(--ink-3); font-size: 11.5px; font-variant-numeric: tabular-nums; margin-bottom: 22px; }
h3.section { font: 600 12px/1 var(--sans); text-transform: uppercase; letter-spacing: .08em; color: var(--ink-3); margin: 26px 0 8px; }
.glist { list-style: none; margin: 0; padding: 0; }
.glist li { display: grid; grid-template-columns: 46px 1fr; gap: 2px 12px; padding: 10px 0; border-bottom: 1px solid var(--rule); }
.glist .gy { font-variant-numeric: tabular-nums; color: var(--ink-3); font-size: 13.5px; padding-top: 1px; }
.glist .gb { font-size: 12.5px; font-weight: 600; color: var(--ink-2); letter-spacing: .01em; }
.glist .gt { font-size: 14px; line-height: 1.4; }
.glist .gt a { text-decoration: none; }
.glist .gt a:hover { text-decoration: underline; color: var(--accent); }
.glist .gv { font-size: 12.5px; color: var(--ink-3); }
.more { margin-top: 10px; }
.nlist { list-style: none; margin: 0; padding: 0; }
.nlist li { padding: 10px 0; border-bottom: 1px solid var(--rule); cursor: pointer; }
.nlist li:hover .nt { color: var(--accent); }
.nt { font: 500 16px/1.35 var(--serif); }
.nm { font-size: 12.5px; color: var(--ink-2); margin-top: 3px; display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.about h2 { font: 600 26px/1.2 var(--serif); margin: 0 0 12px; }
.about p, .about li { font-size: 15px; }
.about ul { padding-left: 18px; }
.about li { margin-bottom: 8px; }
.muted { color: var(--ink-3); }

@media (max-width: 640px) {
  body { font-size: 14.5px; }
  .masthead-inner { padding-top: 16px; padding-bottom: 10px; gap: 4px 14px; }
  .wordmark span { font-size: 23px; }
  .tagline { font-size: 15.5px; }
  .filters { grid-template-columns: 1fr 1fr; }
  .search { grid-column: 1 / -1; }
  .paper { grid-template-columns: 30px 1fr; gap: 6px 10px; padding: 14px 0; }
  .rank { font-size: 16px; }
  .title { font-size: 17px; }
  .stats { grid-column: 2; flex-direction: row; align-items: center; justify-content: space-between; text-align: left; min-width: 0; }
  .cites { font-size: 17px; display: flex; align-items: baseline; gap: 6px; }
  .cites small { display: inline; margin: 0; }
  .sheet { width: 100%; max-width: 100%; max-height: 94vh; margin: auto 0 0; border-radius: 16px 16px 0 0; }
  .sheet-inner { padding: 20px 18px 28px; }
  .d-title { font-size: 23px; }
}
@media (prefers-reduced-motion: no-preference) {
  .sheet[open] { animation: rise .18s ease-out; }
  @keyframes rise { from { transform: translateY(14px); opacity: 0; } to { transform: none; opacity: 1; } }
}
