:root {
  --bg: #f7f7f4;
  --panel: #ffffff;
  --ink: #171717;
  --muted: #626866;
  --line: #d9ded8;
  --accent: #0f766e;
  --accent-2: #9f2d20;
  --soft: #e7f3ef;
  --shadow: 0 14px 42px rgba(20, 28, 24, .08);
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--ink);
}
a { color: inherit; }
.page-shell, .index-shell, .detail-shell {
  width: min(1240px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 28px 0 56px;
}
.site-nav, .back-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
}
.page-header, .index-header, .detail-header {
  border-bottom: 1px solid var(--line);
  padding: 12px 0 22px;
}
.eyebrow {
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
}
h1 {
  margin: 8px 0 12px;
  font-size: clamp(32px, 5vw, 58px);
  letter-spacing: 0;
  line-height: 1.05;
}
.page-header p, .index-header p, .paper-meta, .meta {
  color: var(--muted);
  line-height: 1.65;
  max-width: 980px;
}
.search-row {
  display: flex;
  gap: 10px;
  margin: 22px 0 16px;
}
.search-row input {
  flex: 1;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
  font-size: 15px;
  background: #fff;
}
button,
.paper-actions a,
.card-actions a,
.resource-link,
.site-nav a,
.back-nav a,
.card-actions span {
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 8px;
  padding: 8px 11px;
  cursor: pointer;
  text-decoration: none;
  font-size: 13px;
}
.keyword-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 0 0;
}
.keyword-bar + .keyword-bar {
  margin-top: 14px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}
.keyword-bar[data-filter-group="source"] button {
  background: #f9fbfa;
  border-color: #c8d2cc;
  font-weight: 700;
}
.keyword-bar[data-filter-group="topic"] button {
  background: #fff;
}
.keyword-bar button.active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}
.keyword-bar span { opacity: .72; margin-left: 4px; }
.paper-grid, .library-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 18px;
  margin-top: 24px;
}
.paper-card, .library-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  min-height: 100%;
  text-decoration: none;
}
.thumb, .library-cover {
  display: block;
  aspect-ratio: 16 / 9;
  background: #eef1ef;
  overflow: hidden;
}
.library-cover {
  padding: 20px;
  display: grid;
  place-items: center;
  background: #fff;
  border-bottom: 1px solid var(--line);
}
.thumb img, .library-cover img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  background: #f1f3f1;
}
.thumb-missing, .figure-missing {
  min-height: 220px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  color: var(--muted);
  font-size: 14px;
  letter-spacing: .04em;
}
.card-body {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1;
}
.card-topline {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}
h2 {
  margin: 0;
  font-size: 19px;
  line-height: 1.25;
  letter-spacing: 0;
}
h2 a { text-decoration: none; }
.authors {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
  margin: 0;
}
.affiliations {
  color: #4a5551;
  font-size: 12px;
  line-height: 1.45;
  margin: -4px 0 0;
}
.paper-tags, .card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.paper-tags span, .card-tags span {
  background: var(--soft);
  color: #17554e;
  border: 1px solid #c6e0d8;
  padding: 4px 7px;
  border-radius: 999px;
  font-size: 12px;
}
.resource-links {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}
.resource-link {
  padding: 5px 8px;
  font-weight: 700;
  color: var(--accent-2);
}
.resource-link.code { color: #0c5f4d; }
.summary {
  line-height: 1.62;
  color: #303533;
  margin: 0;
  font-size: 14px;
}
.paper-actions, .card-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: auto;
  padding-top: 6px;
}
.paper-figure, .hero-figure {
  margin: 24px 0;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}
.viewer-action-bar {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 10px 12px;
  background: #f9fbfa;
  border-bottom: 1px solid var(--line);
}
.viewer-open-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  border: 1px solid #9a2036;
  border-radius: 8px;
  padding: 8px 12px;
  background: #9a2036;
  color: #fff;
  font-size: 14px;
  font-weight: 800;
  text-decoration: none;
}
.viewer-open-link:hover {
  background: #7f1a2d;
  border-color: #7f1a2d;
}
.paper-viewer-wrap {
  position: relative;
  min-height: 560px;
  background: #f1f3f1;
}
.alphaxiv-reader-crop {
  overflow: hidden;
}
.paper-viewer {
  position: relative;
  z-index: 1;
  width: 100%;
  height: min(78vh, 900px);
  min-height: 560px;
  display: block;
  border: 0;
  background: #f1f3f1;
}
.alphaxiv-reader-viewer {
  width: calc(100% + min(575px, 32vw));
  max-width: none;
}
.paper-viewer-fallback {
  position: absolute;
  inset: 0;
  z-index: 0;
  min-height: 560px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f1f3f1;
}
.paper-viewer-fallback img {
  max-height: 620px;
  object-fit: contain;
}
.paper-figure img, .hero-figure img {
  width: 100%;
  display: block;
  max-height: 620px;
  object-fit: contain;
  background: #f1f3f1;
}
.paper-figure .figure-missing, .hero-figure .figure-missing { min-height: 280px; }
.paper-figure figcaption, .hero-figure figcaption {
  color: var(--muted);
  font-size: 13px;
  padding: 8px 12px;
}
.note {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: clamp(18px, 3vw, 34px);
  line-height: 1.74;
  box-shadow: var(--shadow);
}
.note h1 { font-size: clamp(25px, 4vw, 40px); }
.note h2 {
  margin-top: 30px;
  font-size: 22px;
  border-top: 1px solid var(--line);
  padding-top: 20px;
}
.note p, .note li { color: #262b29; }
.note ul { padding-left: 1.2em; }
.hidden { display: none !important; }
@media (max-width: 760px) {
  .paper-grid, .library-grid { grid-template-columns: 1fr; }
  .search-row { flex-direction: column; }
  .page-shell, .index-shell, .detail-shell {
    width: min(100vw - 20px, 1240px);
    padding-top: 18px;
  }
  .paper-viewer-wrap, .paper-viewer, .paper-viewer-fallback { min-height: 440px; }
}
