@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=Outfit:wght@500;600;700;800&display=swap");

:root {
  --font-body: "Inter", "SF Pro Text", "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --font-display: "Outfit", "Inter", "SF Pro Display", "PingFang SC", sans-serif;
  --font-mono: "JetBrains Mono", "SFMono-Regular", "IBM Plex Mono", monospace;
  --color-bg: #f4f7fb;
  --page-gradient:
    radial-gradient(circle at 12% 10%, rgba(88, 116, 171, 0.12), transparent 32%),
    radial-gradient(circle at 88% 8%, rgba(159, 174, 200, 0.16), transparent 26%),
    linear-gradient(180deg, #f7f9fc 0%, #f3f6fb 48%, #eef2f8 100%);
  --color-panel: rgba(255, 255, 255, 0.78);
  --color-panel-strong: rgba(255, 255, 255, 0.92);
  --color-panel-soft: rgba(240, 244, 251, 0.84);
  --color-border: rgba(148, 163, 184, 0.22);
  --color-border-strong: rgba(100, 116, 139, 0.28);
  --color-border-soft: rgba(255, 255, 255, 0.58);
  --color-input: rgba(255, 255, 255, 0.94);
  --color-btn: rgba(255, 255, 255, 0.92);
  --color-btn-secondary: rgba(247, 250, 255, 0.92);
  --color-btn-secondary-border: rgba(148, 163, 184, 0.24);
  --color-text: #132033;
  --color-text-soft: #4a5c74;
  --color-text-muted: #6a7b92;
  --color-text-faint: #8ea0b5;
  --color-accent: #5b7ce2;
  --color-accent-strong: #4264c8;
  --color-accent-soft: rgba(90, 124, 226, 0.14);
  --color-accent-alt: #8aa2ec;
  --color-tag-text: #3152aa;
  --color-tag-bg: rgba(88, 116, 171, 0.12);
  --color-ok: #16a34a;
  --color-warn: #ca8a04;
  --color-danger: #dc2626;
  --color-danger-border: #fca5a5;
  --shadow-panel: 0 22px 48px rgba(15, 23, 42, 0.07), inset 0 1px 0 rgba(255, 255, 255, 0.52);
  --shadow-card: 0 26px 58px rgba(15, 23, 42, 0.09), inset 0 1px 0 rgba(255, 255, 255, 0.42);
  --shadow-hover: 0 30px 70px rgba(15, 23, 42, 0.14);
  --shadow-modal: 0 42px 96px rgba(15, 23, 42, 0.18);
  --overlay: rgba(0, 0, 0, 0.4);
  --dialog-overlay: rgba(0, 0, 0, 0.4);
  --pdf-bg: #edf2f8;
  --summary-box-bg: rgba(246, 249, 255, 0.92);
  --summary-box-border: rgba(115, 138, 196, 0.18);
  --pill-gradient: linear-gradient(135deg, #5c7ce4 0%, #4767cd 100%);
  --header-bg: rgba(244, 247, 251, 0.76);
  --header-shadow: 0 16px 42px rgba(15, 23, 42, 0.08);
  --noise-opacity: 0.04;
}
body[data-theme="pearl"] {
  --color-bg: #fbf7fd;
  --page-gradient:
    radial-gradient(circle at 10% 10%, rgba(167, 139, 250, 0.16), transparent 30%),
    radial-gradient(circle at 88% 4%, rgba(221, 214, 254, 0.22), transparent 28%),
    linear-gradient(180deg, #fcf9ff 0%, #f8f4ff 50%, #f4efff 100%);
  --color-panel: rgba(255, 255, 255, 0.8);
  --color-panel-strong: rgba(255, 255, 255, 0.93);
  --color-panel-soft: rgba(246, 240, 255, 0.86);
  --color-border: rgba(167, 139, 250, 0.2);
  --color-border-strong: rgba(124, 58, 237, 0.24);
  --color-border-soft: rgba(255, 255, 255, 0.62);
  --color-btn-secondary: rgba(252, 247, 255, 0.92);
  --color-btn-secondary-border: rgba(167, 139, 250, 0.2);
  --color-accent: #8b6be8;
  --color-accent-strong: #744bd8;
  --color-accent-soft: rgba(139, 107, 232, 0.14);
  --summary-box-bg: rgba(251, 246, 255, 0.94);
  --summary-box-border: rgba(139, 107, 232, 0.18);
  --pill-gradient: linear-gradient(135deg, #8c6dea 0%, #7248d2 100%);
  --color-tag-text: #6338c2;
  --color-tag-bg: rgba(139, 107, 232, 0.14);
  --header-bg: rgba(251, 247, 253, 0.78);
}
body[data-theme="sage"] {
  --color-bg: #f3f6f2;
  --page-gradient:
    radial-gradient(circle at 12% 10%, rgba(45, 114, 83, 0.13), transparent 30%),
    radial-gradient(circle at 84% 8%, rgba(209, 234, 225, 0.22), transparent 28%),
    linear-gradient(180deg, #f7faf6 0%, #f2f6f2 48%, #edf2ed 100%);
  --color-panel: rgba(255, 255, 255, 0.8);
  --color-panel-strong: rgba(255, 255, 255, 0.92);
  --color-panel-soft: rgba(236, 244, 239, 0.86);
  --color-border: rgba(91, 138, 114, 0.18);
  --color-border-strong: rgba(74, 115, 93, 0.24);
  --color-border-soft: rgba(255, 255, 255, 0.6);
  --color-btn-secondary: rgba(245, 249, 245, 0.94);
  --color-btn-secondary-border: rgba(91, 138, 114, 0.18);
  --color-text: #1d2b22;
  --color-text-soft: #4a5c50;
  --color-text-muted: #6b7d71;
  --color-text-faint: #98a69d;
  --color-accent: #4d8d6f;
  --color-accent-strong: #3b7458;
  --color-accent-soft: rgba(77, 141, 111, 0.14);
  --color-accent-alt: #73a98e;
  --summary-box-bg: rgba(240, 249, 244, 0.92);
  --summary-box-border: rgba(77, 141, 111, 0.16);
  --pill-gradient: linear-gradient(135deg, #4c8b6d 0%, #3a7255 100%);
  --color-tag-text: #2f6d50;
  --color-tag-bg: rgba(77, 141, 111, 0.14);
  --header-bg: rgba(243, 246, 242, 0.78);
}
body[data-theme="graphite"] {
  --color-bg: #0d1117;
  --page-gradient:
    radial-gradient(circle at 14% 8%, rgba(59, 130, 246, 0.16), transparent 28%),
    radial-gradient(circle at 88% 12%, rgba(41, 84, 140, 0.22), transparent 28%),
    linear-gradient(180deg, #111722 0%, #0d121b 48%, #090e15 100%);
  --color-panel: rgba(19, 26, 39, 0.82);
  --color-panel-strong: rgba(16, 22, 34, 0.94);
  --color-panel-soft: rgba(26, 35, 50, 0.9);
  --color-border: rgba(115, 130, 156, 0.16);
  --color-border-strong: rgba(148, 163, 184, 0.22);
  --color-border-soft: rgba(255, 255, 255, 0.04);
  --color-input: rgba(16, 22, 34, 0.92);
  --color-btn: rgba(16, 22, 34, 0.9);
  --color-btn-secondary: rgba(31, 41, 55, 0.92);
  --color-btn-secondary-border: rgba(115, 130, 156, 0.18);
  --color-text: #f4f4f5;
  --color-text-soft: #a5b4c9;
  --color-text-muted: #7f8ca1;
  --color-text-faint: #5c687a;
  --color-accent: #7ca8ea;
  --color-accent-strong: #5f8fda;
  --color-accent-soft: rgba(95, 143, 218, 0.18);
  --color-accent-alt: #9ec0f0;
  --color-tag-text: #dbeafe;
  --color-tag-bg: rgba(59, 130, 246, 0.18);
  --shadow-panel: 0 28px 64px rgba(0, 0, 0, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.04);
  --shadow-card: 0 28px 68px rgba(0, 0, 0, 0.34), inset 0 1px 0 rgba(255, 255, 255, 0.04);
  --shadow-hover: 0 32px 76px rgba(0, 0, 0, 0.42);
  --shadow-modal: 0 44px 98px rgba(0, 0, 0, 0.54);
  --overlay: rgba(0, 0, 0, 0.7);
  --dialog-overlay: rgba(0, 0, 0, 0.7);
  --pdf-bg: #090c12;
  --summary-box-bg: rgba(24, 34, 48, 0.94);
  --summary-box-border: rgba(115, 130, 156, 0.2);
  --pill-gradient: linear-gradient(135deg, #7ca8ea 0%, #5f8fda 100%);
  --header-bg: rgba(13, 17, 23, 0.8);
  --header-shadow: 0 18px 48px rgba(0, 0, 0, 0.36);
  --noise-opacity: 0.055;
}
html { scroll-behavior: smooth; }
* { box-sizing: border-box; }
body {
  position: relative;
  margin: 0;
  font-family: var(--font-body);
  background-color: var(--color-bg);
  background-image: var(--page-gradient);
  color: var(--color-text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background-color 0.22s ease, background-image 0.22s ease, color 0.22s ease;
}
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: var(--noise-opacity);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140' viewBox='0 0 140 140'%3E%3Cg fill='%23111827' fill-opacity='.16'%3E%3Ccircle cx='12' cy='18' r='1'/%3E%3Ccircle cx='62' cy='44' r='1'/%3E%3Ccircle cx='112' cy='20' r='1'/%3E%3Ccircle cx='34' cy='96' r='1'/%3E%3Ccircle cx='96' cy='86' r='1'/%3E%3Ccircle cx='126' cy='116' r='1'/%3E%3Ccircle cx='82' cy='128' r='1'/%3E%3Ccircle cx='16' cy='122' r='1'/%3E%3C/g%3E%3C/svg%3E");
}
body.modal-open { overflow: hidden; }
button { font: inherit; }
.page-shell {
  position: relative;
  z-index: 1;
  min-height: 100dvh;
}
.container { max-width: 1480px; margin: 0 auto; padding: 0 28px; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.skip-link {
  position: fixed;
  top: 14px;
  left: 18px;
  z-index: 1200;
  padding: 10px 14px;
  border-radius: 999px;
  background: var(--color-panel-strong);
  color: var(--color-text);
  border: 1px solid var(--color-border-strong);
  box-shadow: var(--shadow-panel);
  text-decoration: none;
  transform: translateY(-64px);
}
.skip-link:focus-visible {
  transform: translateY(0);
  outline: none;
}
body, select, input, textarea, button, .panel, .paper-card, .paper-modal-content, .answer, .resource-chip, .theme-option, .filter-chip, .icon-pill, .header-icon-btn, .mode-toggle-btn, .keyword-item {
  transition: background-color 0.22s ease, border-color 0.22s ease, color 0.22s ease, box-shadow 0.22s ease, transform 0.18s ease;
}
h1, h2, h3, h4 {
  font-family: var(--font-display);
  text-wrap: balance;
  letter-spacing: -0.03em;
}
p, li, label, small, .sub, .hint, .mini-hint, .dialog-lead { text-wrap: pretty; }
.repo-stat-pill,
.paper-position,
.filter-chip-count,
.meta-pill,
.keyword-count,
.keyword-rank,
.paper-card-order {
  font-variant-numeric: tabular-nums;
}
.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  background: var(--header-bg);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--color-border);
  box-shadow: var(--header-shadow);
}
.site-header::after {
  content: "";
  position: absolute;
  inset: auto 0 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--color-accent) 36%, white 64%), transparent);
  opacity: 0.72;
}
.header-main { display: grid; grid-template-columns: 1fr auto 1fr; gap: 22px; align-items: center; padding-top: 18px; padding-bottom: 18px; }
.header-left-stack {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0;
  justify-self: start;
  min-width: 0;
}
.header-left-row {
  display: inline-flex;
  align-items: flex-start;
  gap: 0;
  flex-wrap: nowrap;
  min-width: 0;
}
.repo-link-group {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  width: min(100%, 372px);
}
.repo-link-card {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 13px 16px;
  border-radius: 22px;
  border: 1px solid rgba(148, 163, 184, 0.14);
  background:
    radial-gradient(circle at top left, rgba(124, 161, 244, 0.18), transparent 36%),
    linear-gradient(135deg, rgba(17, 24, 39, 0.94), rgba(30, 41, 59, 0.96));
  color: white;
  text-decoration: none;
  box-shadow: 0 22px 44px rgba(15, 23, 42, 0.16), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  min-width: 0;
}
.repo-link-card:hover {
  text-decoration: none;
  transform: translateY(-2px);
  color: white;
  box-shadow: 0 28px 56px rgba(15, 23, 42, 0.22), inset 0 1px 0 rgba(255, 255, 255, 0.1);
}
.repo-link-icon { width: 18px; height: 18px; display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto; }
.repo-link-icon svg { width: 18px; height: 18px; display: block; }
.repo-link-copy { display: inline-flex; flex-direction: column; align-items: flex-start; min-width: 0; gap: 2px; }
.repo-link-title {
  font-size: 11px;
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.72);
}
.repo-link-subtitle {
  display: block;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: -0.02em;
  max-width: 100%;
}
.repo-link-stats { display: inline-flex; align-items: center; gap: 6px; justify-self: end; }
.repo-stat-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 9px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  font-size: 12px;
  font-weight: 700;
  backdrop-filter: blur(6px);
}
.repo-stat-pill svg { width: 13px; height: 13px; display: block; }
.repo-reference-link {
  align-self: center;
  color: var(--color-text-muted);
  font-size: 11px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  line-height: 1.1;
  text-align: center;
  padding-left: 0;
}
.repo-reference-link:hover { color: var(--color-accent-strong); text-decoration: none; }
.brand-lockup {
  display: inline-flex;
  align-items: center;
  gap: 16px;
  justify-self: center;
  color: inherit;
  text-decoration: none;
}
.brand-lockup:hover { text-decoration: none; }
.brand-mark {
  width: 58px;
  height: 58px;
  border-radius: 18px;
  display: grid;
  place-items: center;
  padding: 5px;
  background:
    radial-gradient(circle at 24% 24%, rgba(255, 255, 255, 0.96), rgba(255, 255, 255, 0.72)),
    linear-gradient(180deg, rgba(255, 255, 255, 0.92), rgba(244, 247, 252, 0.86));
  border: 1px solid var(--color-border);
  box-shadow: 0 16px 36px rgba(15, 23, 42, 0.1), inset 0 1px 0 rgba(255, 255, 255, 0.7);
  overflow: hidden;
}
.brand-lockup:hover .brand-mark {
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.13), inset 0 1px 0 rgba(255, 255, 255, 0.78);
}
.brand-mark-logo { width: 100%; height: 100%; display: block; object-fit: contain; border-radius: 12px; }
.brand-copy h1 {
  margin: 0;
  font-size: 21px;
  font-weight: 700;
  line-height: 1.06;
  color: var(--color-text);
  letter-spacing: -0.04em;
}
.sub {
  margin: 6px 0 0;
  color: var(--color-text-muted);
  font-size: 13px;
  line-height: 1.55;
  max-width: 34ch;
}
.brand-lockup:hover .brand-copy h1 { color: var(--color-accent-strong); }
.header-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; }
.date-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 6px 4px 14px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--color-panel-strong) 88%, transparent);
  border: 1px solid var(--color-border);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.58);
}
.header-date-text {
  white-space: nowrap;
  color: var(--color-text);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.03em;
}
@media (max-width: 1120px) {
  .header-main { grid-template-columns: 1fr; justify-items: start; }
  .brand-lockup { justify-self: start; }
  .header-actions { justify-content: flex-start; flex-wrap: wrap; }
  .header-left-row { width: 100%; flex-wrap: wrap; align-items: flex-start; }
  .repo-link-group { width: min(100%, 420px); }
}
@media (max-width: 820px) {
  .container { padding: 0 16px; }
}
@media (max-width: 640px) {
  .header-main {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "left actions"
      "brand brand";
    justify-items: stretch;
    align-items: center;
    gap: 10px 8px;
    padding-top: 12px;
    padding-bottom: 10px;
  }
  .header-left-stack {
    grid-area: left;
    min-width: 0;
    width: 100%;
  }
  .header-actions {
    grid-area: actions;
    justify-self: end;
    justify-content: flex-end;
    align-self: start;
    gap: 4px;
    flex-wrap: nowrap;
  }
  .brand-lockup {
    grid-area: brand;
    justify-self: start;
    gap: 12px;
    width: 100%;
  }
  .brand-mark {
    width: 44px;
    height: 44px;
    border-radius: 14px;
  }
  .brand-copy h1 { font-size: 18px; }
  .sub { display: none; }
  .header-left-row {
    flex-wrap: nowrap;
    align-items: center;
    min-width: 0;
  }
  .repo-link-group {
    min-width: 0;
    align-items: center;
    width: auto;
  }
  .repo-link-card {
    min-width: 0;
    width: auto;
    padding: 8px 11px;
    gap: 8px;
    border-radius: 14px;
    flex-wrap: nowrap;
    align-items: center;
  }
  .repo-link-copy { min-width: 0; }
  .repo-link-title { font-size: 12px; }
  .repo-link-subtitle,
  .repo-link-stats,
  .repo-reference-link,
  .header-date-text {
    display: none;
  }
  .date-chip { gap: 0; }
  .header-icon-btn {
    width: 36px;
    height: 36px;
  }
  .skip-link { left: 12px; }
}

@media (max-width: 420px) {
  .header-main { gap: 8px 6px; }
  .header-actions { gap: 3px; }
  .header-icon-btn {
    width: 34px;
    height: 34px;
  }
  .repo-link-card { padding: 7px 8px; }
  .brand-copy h1 { font-size: 15px; }
}
