:root {
  color-scheme: light;
  --ink: #17212b;
  --muted: #667085;
  --line: #d8e0e7;
  --paper: #f5f7f8;
  --panel: #ffffff;
  --green: #08796d;
  --green-soft: #e4f3f0;
  --red: #a63d40;
  --gold: #a66b13;
  --blue: #2457a7;
  --shadow: 0 14px 36px rgba(23, 33, 43, 0.09);
}

* { box-sizing: border-box; }

html {
  max-width: 100%;
  overflow-x: hidden;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
  background: var(--paper);
  color: var(--ink);
  font-family: "Inter", "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
  line-height: 1.65;
}

a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; }
button, select { cursor: pointer; }

.site-header {
  position: relative;
  min-height: 520px;
  overflow: hidden;
  background: #253c3c url("https://images.unsplash.com/photo-1449824913935-59a10b8d2000?auto=format&fit=crop&w=2000&q=85") center 58%/cover no-repeat;
  color: #fff;
}

.site-header::before {
  position: absolute;
  inset: 0;
  background: rgba(12, 30, 34, 0.7);
  content: "";
}

.nav, .hero { position: relative; z-index: 1; }

.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: min(1220px, calc(100% - 48px));
  margin: 0 auto;
  padding: 22px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.24);
}

.brand, .nav-actions { display: flex; align-items: center; gap: 14px; }
.brand { line-height: 1.25; }

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid rgba(255, 255, 255, 0.52);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.1);
  font-weight: 800;
}

.brand small, .metric-label, .hero .eyebrow {
  display: block;
  color: rgba(255, 255, 255, 0.72);
  font-size: 0.8rem;
}

.nav-actions a { color: rgba(255, 255, 255, 0.88); font-size: 0.92rem; }
.nav-actions a:hover { color: #fff; }

.icon-button {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid rgba(255, 255, 255, 0.48);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  font-size: 1.35rem;
}

.icon-button:disabled { cursor: progress; opacity: 0.65; }
.icon-button.is-refreshing span { animation: spin 0.8s linear infinite; }

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 310px;
  align-items: end;
  gap: 56px;
  width: min(1220px, calc(100% - 48px));
  margin: 0 auto;
  padding: 76px 0 72px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--green);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.hero-copy h1 {
  max-width: 820px;
  margin: 10px 0 20px;
  font-size: 4rem;
  line-height: 1.08;
  letter-spacing: 0;
  white-space: nowrap;
}

.lead {
  max-width: 760px;
  margin: 0;
  color: rgba(255, 255, 255, 0.84);
  font-size: 1.08rem;
  white-space: nowrap;
}

.hero-meta { display: flex; flex-wrap: wrap; gap: 18px; margin-top: 28px; }
.hero-meta span { color: rgba(255, 255, 255, 0.82); font-size: 0.88rem; }

.status-panel {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-column: 1 / -1;
  max-width: 100%;
  min-width: 0;
  gap: 1px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.25);
  overflow: hidden;
}

.status-panel > div { min-width: 0; padding: 15px 20px; background: rgba(18, 41, 43, 0.62); }
.metric { display: block; font-size: 2rem; font-weight: 800; line-height: 1.1; }

main { width: min(1220px, calc(100% - 48px)); max-width: 100%; margin: 0 auto; padding: 0 0 64px; }

.toolbar {
  display: grid;
  grid-template-columns: minmax(220px, 1.25fr) repeat(4, minmax(120px, 0.7fr)) auto;
  align-items: end;
  gap: 10px;
  max-width: 100%;
  min-width: 0;
  margin-top: 24px;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  position: relative;
  z-index: 2;
}
.filter-row {
  display: contents;
}

label { display: grid; gap: 5px; color: var(--muted); font-size: 0.8rem; font-weight: 700; }

input, select {
  width: 100%;
  min-width: 0;
  min-height: 43px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #fff;
  color: var(--ink);
  padding: 8px 10px;
}

input:focus, select:focus { border-color: var(--green); outline: 2px solid rgba(8, 121, 109, 0.14); }

.clear-button {
  min-height: 43px;
  white-space: nowrap;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #f8fafb;
  color: #344054;
  padding: 8px 13px;
  font-weight: 700;
}

.clear-button:disabled { cursor: default; opacity: 0.45; }

.layout { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 24px; margin-top: 38px; }
.digest { min-width: 0; scroll-margin-top: 20px; }

/* --- Collapsible sidebar --- */
.sidebar {
  position: relative;
  transition: all 0.25s ease;
  overflow: hidden;
}
.sidebar-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}
.sidebar-top-title {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--muted);
  white-space: nowrap;
}
.sidebar-collapse-btn {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s;
}
.sidebar-collapse-btn:hover {
  background: #e8ecef;
  color: var(--ink);
}
.sidebar-collapse-btn svg {
  width: 16px;
  height: 16px;
}
.sidebar-close-btn,
.sidebar-backdrop {
  display: none;
}

/* Collapsed state */
.sidebar.collapsed {
  width: 48px;
  min-width: 48px;
  padding: 12px 8px;
  background: #f8fafb;
  border: 1px solid var(--line);
  border-radius: 8px;
}
.sidebar.collapsed > *:not(.sidebar-top) {
  display: none;
}
.sidebar.collapsed .sidebar-top {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
  justify-content: center;
}
.sidebar.collapsed .sidebar-top-title {
  display: none;
}
.layout:has(.sidebar.collapsed) {
  grid-template-columns: 48px minmax(0, 1fr);
}

.section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

h2 { margin: 0; font-size: 1.45rem; line-height: 1.25; }
.result-count { margin: 0; color: var(--muted); font-size: 0.88rem; white-space: nowrap; }

.notice {
  margin-bottom: 14px;
  border-left: 3px solid var(--gold);
  background: #fff8e8;
  color: #72501d;
  padding: 10px 13px;
  font-size: 0.88rem;
}

.article-list { display: grid; max-width: 100%; min-width: 0; gap: 16px; }

.article-card, .loading-card, .empty-card {
  max-width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 24px;
}

.article-card { box-shadow: 0 6px 20px rgba(23, 33, 43, 0.04); }
.paper-topline { display: flex; justify-content: space-between; min-width: 0; gap: 18px; margin-bottom: 10px; color: var(--muted); font-size: 0.83rem; }
.journal-name { color: var(--red); font-weight: 750; }

.article-card h3 {
  max-width: 100%;
  margin: 0;
  overflow-wrap: anywhere;
  word-break: break-word;
  font-size: 1.32rem;
  line-height: 1.45;
}

.original-title {
  max-width: 100%;
  margin: 6px 0 12px;
  overflow-wrap: anywhere;
  word-break: break-word;
  color: #536170;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1rem;
  line-height: 1.45;
}

.tags { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 17px; }

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 25px;
  border-radius: 999px;
  background: var(--green-soft);
  color: #08665e;
  padding: 2px 9px;
  font-size: 0.76rem;
  font-weight: 750;
}

.summary-block { max-width: 100%; min-width: 0; border-left: 3px solid var(--green); background: #f7faf9; padding: 15px 17px; }
.summary-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 6px; }
.summary-heading h4 { margin: 0; font-size: 0.9rem; }
.summary-heading span { color: var(--muted); font-size: 0.74rem; }
.summary-block p { margin: 0; overflow-wrap: anywhere; word-break: break-word; color: #344054; }

.original-abstract { margin-top: 13px; border-bottom: 1px solid var(--line); padding-bottom: 13px; }
.original-abstract summary { color: var(--blue); font-size: 0.84rem; font-weight: 700; }
.original-abstract p { margin: 10px 0 0; overflow-wrap: anywhere; word-break: break-word; color: #596574; font-family: Georgia, "Times New Roman", serif; font-size: 0.9rem; }
.abstract-missing { margin: 10px 0 0; color: var(--gold); font-size: 0.8rem; }

.paper-details { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 22px; margin: 18px 0 0; }
.paper-details div { min-width: 0; }
.paper-details dt { color: var(--muted); font-size: 0.74rem; font-weight: 750; }
.paper-details dd { margin: 1px 0 0; overflow-wrap: anywhere; color: #344054; font-size: 0.86rem; }

.article-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 14px; margin-top: 18px; }

.primary-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 38px;
  border-radius: 5px;
  background: var(--ink);
  color: #fff;
  padding: 7px 12px;
  font-size: 0.86rem;
  font-weight: 750;
}

.primary-link:hover { background: var(--green); }
.doi-text { color: var(--muted); overflow-wrap: anywhere; font-size: 0.78rem; }
.empty-card p { margin: 4px 0 0; color: var(--muted); }

.pagination { display: flex; justify-content: center; align-items: center; gap: 14px; margin-top: 22px; color: var(--muted); font-size: 0.84rem; }
.pagination button { min-height: 38px; border: 1px solid var(--line); border-radius: 5px; background: #fff; padding: 7px 12px; color: var(--ink); }
.pagination button:disabled { cursor: default; opacity: 0.4; }

.sidebar { display: grid; align-content: start; gap: 16px; }

.side-section { border-top: 3px solid var(--ink); background: var(--panel); padding: 18px; }
.side-section h2 { margin-bottom: 14px; font-size: 1rem; }
.side-heading { display: flex; justify-content: space-between; align-items: center; }
.side-heading span { color: var(--muted); font-size: 0.8rem; }
.topic-list, .journal-list { display: grid; gap: 7px; }

.stat-row, .journal-row {
  display: grid;
  width: 100%;
  gap: 4px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: inherit;
  padding: 6px;
  text-align: left;
}

.stat-row:hover, .journal-row:hover, .stat-row.active, .journal-row.active { background: #edf5f3; }
.stat-row.active, .journal-row.active { outline: 1px solid #b5d9d4; }
.row-line { display: flex; justify-content: space-between; gap: 12px; color: #344054; font-size: 0.84rem; }
.row-line strong { min-width: 0; overflow-wrap: anywhere; }

.bar { display: block; height: 5px; overflow: hidden; border-radius: 999px; background: #e7ecef; }
.bar span { display: block; height: 100%; border-radius: inherit; background: var(--green); }

.journal-list { max-height: 650px; overflow-y: auto; padding-right: 3px; }
.journal-row small { display: block; color: var(--muted); font-size: 0.73rem; line-height: 1.35; overflow-wrap: anywhere; }
.source-note p { color: var(--muted); font-size: 0.84rem; }
.source-status { display: flex; justify-content: space-between; border-top: 1px solid var(--line); padding-top: 11px; font-size: 0.84rem; }
.muted { color: var(--muted); }

.footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 12px;
  width: min(1220px, calc(100% - 48px));
  margin: 0 auto;
  padding: 28px 0 38px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.8rem;
}

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 1040px) {
  .toolbar { grid-template-columns: 1.4fr 1fr 1fr; }
  .clear-button { grid-column: auto; }
  .layout { grid-template-columns: minmax(0, 1fr) 290px; }
}

@media (max-width: 820px) {
  .toolbar { grid-template-columns: 1fr; margin-top: 20px; }
  .filter-toggle { justify-self: start; }
  .filter-row.open { grid-column: 1 / -1; }
  .hero { grid-template-columns: 1fr; gap: 28px; padding-top: 58px; }
  .hero-copy h1 { font-size: 3rem; white-space: normal; }
  .lead { white-space: normal; }
  .status-panel { grid-column: auto; }
  .layout { grid-template-columns: 1fr; }
  .sidebar { grid-template-columns: 1fr 1fr; }
  .source-note { grid-column: 1 / -1; }
  .journal-list { max-height: 420px; }
}

@media (max-width: 640px) {
  .nav, .hero, main, .footer {
    width: auto;
    max-width: none;
    margin-right: 14px;
    margin-left: 14px;
  }
  .nav { align-items: flex-start; gap: 14px; }
  .nav-actions a { display: none; }
  .hero { padding: 46px 0 56px; }
  .hero-copy h1 { font-size: 2.35rem; white-space: normal; }
  .lead { font-size: 0.98rem; white-space: normal; }
  .status-panel { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .status-panel > div { padding: 12px 8px; }
  .metric { font-size: 1.42rem; }
  .metric-label { overflow-wrap: anywhere; font-size: 0.72rem; }
  .toolbar { margin-top: 18px; }
  .clear-button { grid-column: auto; }
  .section-heading { align-items: flex-start; flex-direction: column; gap: 5px; }
  .result-count { white-space: normal; }
  .digest, .article-list, .article-card, .loading-card, .empty-card { min-width: 0; }
  .article-card, .loading-card, .empty-card { padding: 17px; overflow-wrap: anywhere; }
  .paper-topline { flex-direction: column; gap: 2px; }
  .article-card h3 { font-size: 1.16rem; }
  .paper-details { grid-template-columns: 1fr; }
  .summary-heading { align-items: flex-start; }
  .sidebar { grid-template-columns: 1fr; }
  .source-note { grid-column: auto; }
  .pagination { justify-content: space-between; gap: 8px; }
  .footer { flex-direction: column; }
}

/* --- Abstract source tags --- */
.abstract-source-tag {
  display: inline-block;
  margin-top: 8px;
  border-radius: 4px;
  padding: 2px 8px;
  font-size: 0.74rem;
  font-weight: 700;
}
.source-crossref { background: #e8f0fe; color: #1a56a7; }
.source-openalex { background: #e4f3f0; color: #08665e; }
.source-publisher, .source-出版商数据库 { background: #fef3e4; color: #a66b13; }
.source-html, .source-html抓取 { background: #f3e8ff; color: #6b3fa0; }

/* --- Search result highlighting --- */
mark {
  background: #fff3bf;
  color: inherit;
  border-radius: 2px;
  padding: 0 1px;
}

/* --- Abstract sources breakdown sidebar --- */
.abstract-sources-breakdown {
  margin-top: 12px;
  border-top: 1px solid var(--line);
  padding-top: 10px;
}
.abstract-sources-breakdown h3 {
  margin: 0 0 8px;
  font-size: 0.84rem;
  color: var(--muted);
  font-weight: 700;
}
.source-rows { display: grid; gap: 5px; }
.source-row, .provider-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.8rem;
  gap: 10px;
}
.source-row span, .provider-row span { color: var(--muted); }
.source-row strong, .provider-row strong { color: var(--ink); white-space: nowrap; }

.provider-health {
  margin-top: 12px;
  border-top: 1px solid var(--line);
  padding-top: 10px;
}
.provider-health h3 {
  margin: 0 0 8px;
  font-size: 0.84rem;
  color: var(--muted);
  font-weight: 700;
}
.provider-rows { display: grid; gap: 5px; }
.provider-row span {
  display: inline-flex;
  align-items: center;
  min-width: 0;
}
.provider-row i {
  width: 7px;
  height: 7px;
  margin-right: 7px;
  border-radius: 999px;
  background: var(--muted);
  flex: 0 0 auto;
}
.provider-row.is-on i { background: var(--green); }
.provider-row.is-on strong { color: var(--green); }
.provider-row.is-off i { background: #c7cdd4; }
.provider-row.is-off strong { color: var(--muted); }

/* --- Keywords --- */
.keywords-block {
  margin-top: 14px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}
.keywords-block h4 {
  margin: 0 0 6px;
  font-size: 0.8rem;
  color: var(--muted);
  font-weight: 700;
}
.keyword-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.kw-tag {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 4px;
  background: #eef2ff;
  color: #3730a3;
  padding: 2px 8px;
  font-size: 0.78rem;
  font-weight: 600;
}
.kw-original {
  width: 100%;
  margin-top: 4px;
  font-size: 0.74rem;
}
.kw-original summary {
  color: var(--muted);
  cursor: pointer;
}
.kw-original p {
  margin: 4px 0 0;
  color: #596574;
  font-family: Georgia, "Times New Roman", serif;
}

/* --- WeChat mini-program button --- */
.wx-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 38px;
  border: 1px solid #07c160;
  border-radius: 5px;
  background: #fff;
  color: #07c160;
  padding: 7px 12px;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
}
.wx-btn:hover {
  background: #07c160;
  color: #fff;
}

/* --- Toast notification --- */
.toast {
  position: fixed;
  bottom: 32px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: #17212b;
  color: #fff;
  padding: 12px 24px;
  border-radius: 8px;
  font-size: 0.88rem;
  font-weight: 600;
  opacity: 0;
  transition: opacity 0.3s, transform 0.3s;
  z-index: 9999;
  pointer-events: none;
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
  max-width: 420px;
  text-align: center;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* --- Update banner --- */
.update-banner {
  text-align: center;
  padding: 10px;
  background: #fff8e8;
  border-bottom: 1px solid var(--gold);
  color: #72501d;
  font-size: 0.88rem;
  font-weight: 600;
}
.update-banner button {
  border: none;
  background: none;
  color: var(--blue);
  font-weight: 700;
  cursor: pointer;
  text-decoration: underline;
}

/* --- Paper detail collapse --- */
.paper-details-toggle {
  margin-top: 12px;
  border-top: 1px solid var(--line);
  padding-top: 10px;
}
.paper-details-toggle > summary {
  color: var(--blue);
  font-size: 0.84rem;
  font-weight: 700;
  cursor: pointer;
  list-style: none;
}
.paper-details-toggle > summary::-webkit-details-marker { display: none; }
.paper-details-toggle > summary::before { content: '▸ '; }
.paper-details-toggle[open] > summary::before { content: '▾ '; }

/* --- Citation badge --- */
.citation-badge {
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--muted);
}
.citation-badge.high { color: var(--red); }

/* --- Filter toggle (mobile) --- */
.filter-toggle, .sidebar-toggle {
  display: none;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #fff;
  color: var(--ink);
  padding: 8px 13px;
  font-weight: 700;
  font-size: 0.84rem;
  white-space: nowrap;
}

@media (max-width: 820px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .sidebar { display: none; }
  body.sidebar-open { overflow: hidden; }
  .sidebar-backdrop:not([hidden]) {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 99;
    border: 0;
    background: rgba(15, 23, 42, 0.42);
    cursor: default;
  }
  .sidebar.open {
    display: grid;
    position: fixed;
    top: 0;
    left: 0;
    width: min(86vw, 340px);
    height: 100dvh;
    z-index: 100;
    overflow-y: auto;
    background: var(--panel);
    box-shadow: 0 0 40px rgba(0,0,0,0.22);
    padding: 16px;
  }
  .sidebar-collapse-btn { display: none !important; }
  .sidebar-close-btn {
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fff;
    color: var(--ink);
    font-size: 1.25rem;
    line-height: 1;
    font-weight: 700;
  }
  .filter-toggle, .sidebar-toggle { display: inline-flex; align-items: center; }
  .filter-row { display: none; }
  .filter-row.open { display: grid; grid-template-columns: 1fr; gap: 8px; }
  .filter-row.open .clear-button { grid-column: 1 / -1; }
}
