:root {
  --bg: #ffffff;
  --surface: #ffffff;
  --text: #1f2328;
  --muted: #5f6b76;
  --line: #e7edf4;
  --line-soft: #f1f5f9;
  --link: #0a66c2;
  --link-hover: #004b94;
  --accent: #2f7cd6;
  --highlight: #f2e5a6;
  --open: #2ea44f;
  --radius-sm: 6px;
  --radius-md: 8px;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --content-max: 1340px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Source Sans 3", "PingFang SC", "Noto Sans SC", sans-serif;
  line-height: 1.45;
}

.topbar {
  width: min(var(--content-max), calc(100% - 48px));
  margin: 0 auto;
  padding: 18px 0 14px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--space-4);
  border-bottom: 1px solid var(--line);
}

.title-block h1 {
  margin: 0;
  font-family: "Source Sans 3", "PingFang SC", "Noto Sans SC", sans-serif;
  font-size: clamp(25px, 2.2vw, 31px);
  font-weight: 700;
  letter-spacing: 0;
}

.title-block p {
  margin: 6px 0 0;
  font-size: 14px;
  color: var(--muted);
}

.stats {
  font-size: 13px;
  color: var(--muted);
}

.layout {
  width: min(var(--content-max), calc(100% - 48px));
  margin: 0 auto;
  padding: 18px 0 28px;
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 28px;
}

.controls {
  position: sticky;
  top: 12px;
  align-self: start;
  display: grid;
  gap: 10px;
}

.controls-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.controls h2 {
  margin: 0 0 4px;
  font-size: 20px;
  font-weight: 600;
  font-family: "Source Sans 3", "PingFang SC", "Noto Sans SC", sans-serif;
}

.facet-group {
  display: grid;
  gap: 6px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line-soft);
}

.facet-group summary {
  list-style: none;
  margin: 0;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  color: #384454;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.facet-group summary::-webkit-details-marker {
  display: none;
}

.facet-group summary::after {
  content: "▾";
  font-size: 12px;
  color: #6a7683;
}

.facet-group:not([open]) summary::after {
  content: "▸";
}

.facet-body {
  margin-top: 4px;
}

.facet-actions {
  display: flex;
  gap: 6px;
  margin-bottom: 6px;
}

.search-field-actions {
  margin-top: 6px;
}

.facet-actions button {
  min-width: 56px;
  min-height: 34px;
  padding: 5px 10px;
  font-size: 13px;
  border-color: #d7e3f2;
  color: #476183;
}

.facet-actions button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.search-field-summary {
  margin: 0 0 6px;
  font-size: 13px;
  color: #617086;
}

.search-field-warning {
  margin: 0 0 6px;
  font-size: 12px;
  color: #8a5a1f;
}

.facet-check-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px 10px;
}

.facet-check-item {
  display: grid;
  grid-template-columns: 16px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  padding: 4px 0;
}

.facet-check-item input[type="checkbox"] {
  width: 16px;
  height: 16px;
}

.facet-check-item .name {
  font-size: 13px;
  line-height: 1.4;
  color: #394757;
}

.facet-check-item.active .name {
  color: #173f74;
  font-weight: 400;
}

.facet-group h3 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  color: #384454;
}

.facet-list {
  display: grid;
  gap: 3px;
}

.facet-item {
  width: 100%;
  min-width: 0;
  border: none;
  border-radius: 0;
  background: transparent;
  color: #394757;
  display: grid;
  grid-template-columns: 16px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  padding: 5px 0;
  font-size: 13px;
  line-height: 1.4;
  text-align: left;
}

.facet-item .box {
  width: 16px;
  height: 16px;
  border: 1px solid #9eb2c7;
  background: #fff;
}

.facet-item.active {
  color: #183f72;
  font-weight: 600;
}

.facet-item.active .box {
  border-color: #3b78c9;
  background: #eaf2fc;
}

.controls label {
  display: grid;
  gap: 6px;
  font-size: 14px;
  font-weight: 500;
  color: #2a3643;
}

.search-field {
  margin-bottom: 2px;
}

.controls .inline {
  grid-auto-flow: column;
  justify-content: start;
  align-items: center;
  gap: var(--space-2);
  font-size: 14px;
  font-weight: 400;
}

input[type="text"],
select,
button {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  line-height: 1.3;
  padding: 8px 10px;
}

input[type="text"]:focus,
select:focus,
button:focus-visible {
  outline: none;
  border-color: var(--accent);
}

input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

button {
  cursor: pointer;
  width: fit-content;
  min-width: 94px;
}

#resetBtn {
  color: var(--link);
  background: #fff;
  border-color: #cfe0f2;
}

#facetToggleBtn {
  min-width: 72px;
  min-height: 34px;
  padding: 5px 10px;
  font-size: 13px;
  color: #4d627a;
  border-color: #d9e4f0;
}

main {
  min-width: 0;
}

.project-list {
  display: grid;
}

.project-card {
  padding: 2px 0 22px;
  margin-bottom: 28px;
  border-bottom: 1px solid var(--line-soft);
}

.card-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: start;
}

.project-title {
  color: #1f2c3a;
  text-decoration: none;
  font-family: "Source Sans 3", "PingFang SC", "Noto Sans SC", sans-serif;
  font-size: 19px;
  line-height: 1.38;
  font-weight: 500;
}

.project-title:hover {
  color: var(--link-hover);
  text-decoration: underline;
}

.header-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.fav-btn {
  min-width: 40px;
  width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: #fff;
  padding: 0;
  font-size: 19px;
  line-height: 1;
}

.fav-btn.active {
  color: var(--accent);
  border-color: #cde0f5;
  background: #f5f9ff;
}

.chip {
  display: inline;
  padding: 0;
  border-radius: 0;
  font-size: 12px;
  background: transparent;
  color: #5f6b76;
}

.primary-meta {
  margin-top: 3px;
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 10px;
  font-size: 12px;
  color: var(--muted);
}

.primary-meta strong {
  margin-right: 2px;
  font-weight: 400;
  color: #647384;
}

.badge {
  display: inline;
  font-size: 12px;
  padding: 1px 7px;
  border-radius: 10px;
  background: #f4f8fd;
  color: #4a647f;
}

.ratify-wrap strong {
  margin-right: 2px;
  font-weight: 500;
}

.meta-grid {
  margin-top: 6px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 12px;
  font-size: 13px;
}

.meta-grid > div {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
}

.meta-grid .leader,
.meta-grid .org,
.meta-grid .period {
  color: #2e3b4a;
}

.meta-grid strong {
  font-size: 12px;
  font-weight: 400;
  color: #556273;
}

.keywords {
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.keywords-row {
  width: 100%;
  margin-top: 1px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.abstracts {
  margin-top: 6px;
}

.abstracts summary {
  cursor: pointer;
  color: var(--link);
  font-size: 13px;
  font-weight: 400;
}

.abstracts summary:hover {
  color: var(--link-hover);
}

.abstracts p {
  margin: 4px 0 0;
  font-size: 13px;
  color: #2c3a4a;
  font-weight: 400;
  line-height: 1.5;
}

.abstracts strong {
  font-weight: 500;
  color: #556273;
}

.search-hit {
  background: #e6f1ff;
  color: #0a57a7;
  border-radius: 2px;
  padding: 0 1px;
}

.empty-state {
  padding: 20px 0;
  font-size: 16px;
  color: var(--muted);
}

.loading-state,
.error-state {
  padding: 30px 0;
  font-size: 15px;
  color: var(--muted);
}

.loading-state::before {
  content: "";
  display: inline-block;
  width: 12px;
  height: 12px;
  margin-right: 8px;
  border: 2px solid #c9d8e8;
  border-top-color: var(--accent);
  border-radius: 50%;
  vertical-align: -2px;
  animation: nsfc-spin 0.8s linear infinite;
}

.error-state {
  color: #8a3f3f;
}

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

@media (prefers-reduced-motion: reduce) {
  .loading-state::before {
    animation: none;
  }
}

.pager {
  margin-top: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

#pageInfo {
  min-width: 180px;
  text-align: center;
  font-size: 13px;
  color: var(--muted);
}

.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;
}

@media (max-width: 1200px) {
  .layout {
    grid-template-columns: 1fr;
    gap: var(--space-4);
  }

  .controls {
    position: static;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--line);
  }

  .controls h2 {
    grid-column: 1 / -1;
    font-size: 22px;
  }

  .controls-head {
    grid-column: 1 / -1;
  }

  .search-field {
    grid-column: 1 / -1;
  }

  .project-title {
    font-size: 18px;
  }

  .primary-meta {
    font-size: 13px;
  }

  .meta-grid {
    font-size: 14px;
  }

  .meta-grid strong {
    font-size: 12px;
  }

  .abstracts summary,
  .abstracts p {
    font-size: 13px;
  }
}

@media (max-width: 760px) {
  .topbar,
  .layout {
    width: calc(100% - 24px);
  }

  .topbar {
    flex-direction: column;
    align-items: flex-start;
  }

  .controls {
    grid-template-columns: 1fr;
  }

  .project-title {
    font-size: 17px;
  }

  .meta-grid {
    gap: 4px 10px;
  }

  .keywords-row {
    width: 100%;
  }
}
