:root {
  --paper: #f6f2ea;
  --paper-2: #eee9df;
  --ink: #171717;
  --muted: #6c6a64;
  --line: #ded8cc;
  --blue: #1647ff;
  --blue-soft: #e8ecff;
  --green: #287a5d;
  --amber: #aa7424;
  --red: #b45d61;
  --surface: #fffdfa;
  --shadow: 0 18px 50px rgba(42, 38, 30, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    linear-gradient(var(--line) 1px, transparent 1px),
    linear-gradient(90deg, var(--line) 1px, transparent 1px),
    var(--paper);
  background-size: 30px 30px;
  color: var(--ink);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
}

a {
  color: inherit;
  text-decoration: none;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  height: 68px;
  padding: 0 56px;
  border-bottom: 1px solid var(--line);
  background: rgba(246, 242, 234, 0.92);
  backdrop-filter: blur(10px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  font-size: 18px;
  font-weight: 700;
}

.brand span {
  color: var(--ink);
}

.brand strong {
  color: var(--blue);
}

.brand-logo {
  width: 48px;
  height: 48px;
  margin-left: 8px;
  object-fit: contain;
  display: block;
}

.site-header nav {
  display: flex;
  align-items: center;
  gap: 24px;
  color: #292723;
  font-size: 13px;
  text-transform: uppercase;
}

main {
  padding: 54px 56px 64px;
}

.hero {
  max-width: 1180px;
  margin: 0 auto 28px;
}

.kicker {
  margin: 0 0 12px;
  color: var(--muted);
  font-family: Inter, ui-sans-serif, system-ui, sans-serif;
  font-size: 14px;
}

.hero h1 {
  max-width: 980px;
  margin: 0;
  font-size: clamp(34px, 5vw, 58px);
  line-height: 1.05;
  letter-spacing: 0;
}

.hero h1 span {
  color: var(--blue);
}

.hero-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px;
  max-width: 980px;
  margin: 28px 0;
}

.hero-stats div,
.quick-charts article,
.matrix-panel,
.dataset-card,
.filters,
.toolbar {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 250, 0.9);
  box-shadow: var(--shadow);
}

.hero-stats div {
  padding: 14px;
}

.hero-stats strong {
  display: block;
  color: var(--blue);
  font-size: 28px;
}

.hero-stats span,
.toolbar span,
.panel-title span,
.meta,
.evidence {
  color: var(--muted);
  font-family: Inter, ui-sans-serif, system-ui, sans-serif;
}

.search-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 110px;
  gap: 10px;
  max-width: 760px;
}

input,
select {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  padding: 13px 14px;
}

button {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
}

.search-row button {
  border-color: var(--blue);
  background: var(--blue);
  color: #fff;
  font-weight: 800;
  text-transform: uppercase;
}

.layout {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  gap: 56px;
  max-width: 1180px;
  margin: 0 auto;
}

.filters {
  align-self: start;
  position: sticky;
  top: 88px;
  padding: 0;
  max-height: calc(100vh - 104px);
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}

.filter-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 12px;
  border-bottom: 1px solid var(--line);
  text-transform: uppercase;
  font-size: 13px;
  font-weight: 800;
}

.filter-head button {
  padding: 6px 9px;
  color: var(--blue);
  font-size: 12px;
}

.filter-group {
  border-bottom: 1px solid var(--line);
}

.accordion {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border: 0;
  border-radius: 0;
  padding: 13px 12px;
  background: transparent;
  font-size: 12px;
  font-weight: 800;
  text-align: left;
  text-transform: uppercase;
}

.accordion::after {
  content: ">";
  color: var(--muted);
}

.accordion[aria-expanded="false"]::after {
  transform: rotate(90deg);
}

.accordion-body {
  display: grid;
  gap: 8px;
  padding: 0 12px 13px;
}

.accordion[aria-expanded="false"] + .accordion-body {
  display: none;
}

.check {
  display: grid;
  grid-template-columns: 16px minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  color: #35332f;
  font-size: 12px;
}

.check input {
  width: 15px;
  height: 15px;
  accent-color: var(--blue);
}

.check b {
  color: var(--muted);
  font-weight: 500;
}

.results {
  min-width: 0;
}

.toolbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  padding: 12px;
  margin-bottom: 16px;
}

.toolbar strong {
  color: var(--blue);
  font-size: 18px;
}

.toolbar label {
  display: flex;
  align-items: center;
  gap: 8px;
}

.toolbar select {
  padding: 8px 10px;
}

.quick-charts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 14px;
}

.quick-charts article,
.matrix-panel {
  padding: 14px;
}

h2 {
  margin: 0 0 12px;
  font-size: 15px;
}

.bar-chart {
  display: grid;
  gap: 8px;
}

.bar-row {
  display: grid;
  grid-template-columns: minmax(130px, 190px) minmax(0, 1fr) 34px;
  gap: 10px;
  align-items: center;
  font-size: 12px;
}

.bar-track {
  height: 10px;
  border-radius: 999px;
  background: #ece6dc;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  border-radius: inherit;
  background: var(--blue);
}

.panel-title {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: baseline;
}

.panel-title > div:first-child {
  min-width: 0;
}

.matrix-controls {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.matrix-controls label {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-family: Inter, ui-sans-serif, system-ui, sans-serif;
  font-size: 11px;
}

.matrix-controls select {
  min-height: 34px;
  padding: 7px 9px;
  font-size: 12px;
}

.matrix {
  overflow: auto;
}

.matrix-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 4px 0 12px;
}

.matrix-summary span {
  display: inline-flex;
  gap: 5px;
  align-items: baseline;
  padding: 7px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--muted);
  font-family: Inter, ui-sans-serif, system-ui, sans-serif;
  font-size: 12px;
}

.matrix-summary strong {
  color: var(--blue);
}

.matrix table {
  width: 100%;
  min-width: 780px;
  border-collapse: collapse;
  font-size: 12px;
}

.matrix th,
.matrix td {
  border: 1px solid var(--line);
  padding: 8px;
  text-align: center;
}

.matrix th {
  background: #f1eadf;
}

.matrix th:first-child,
.matrix td:first-child {
  position: sticky;
  left: 0;
  background: #faf7f0;
  text-align: left;
}

.cell-filled {
  background: #e3f0e8;
  color: var(--green);
  font-weight: 800;
}

.cell-sparse {
  background: #fff3d8;
  color: var(--amber);
  font-weight: 800;
}

.cell-empty {
  background: #f4e4e2;
  color: var(--red);
}

.gap-list {
  margin-top: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdfa;
}

.gap-list h3 {
  margin: 0 0 8px;
  font-size: 13px;
  text-transform: uppercase;
}

.gap-list ul {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 7px 12px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.gap-list li {
  color: #35332f;
  font-family: Inter, ui-sans-serif, system-ui, sans-serif;
  font-size: 12px;
  line-height: 1.35;
}

.gap-list li span {
  color: var(--muted);
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(276px, 1fr));
  gap: 16px;
  margin-top: 14px;
}

.dataset-card {
  overflow: hidden;
}

.thumb {
  position: relative;
  display: block;
  height: 156px;
  background:
    radial-gradient(circle at 24% 30%, rgba(255, 255, 255, 0.85), transparent 24%),
    linear-gradient(135deg, var(--thumb-a), var(--thumb-b));
  overflow: hidden;
}

.thumb::before,
.thumb::after {
  content: "";
  position: absolute;
  inset: 22px;
  border: 1px solid rgba(255, 255, 255, 0.58);
  border-radius: 8px;
}

.thumb::after {
  inset: auto 24px 24px auto;
  width: 74px;
  height: 74px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.18);
}

.thumb img {
  position: absolute;
  inset: 0;
  z-index: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top center;
  filter: saturate(1.04) contrast(1.02);
}

.thumb:not(.fallback)::before,
.thumb:not(.fallback)::after {
  display: none;
}

.thumb.fallback::before,
.thumb.fallback::after {
  z-index: 0;
}

.thumb.fallback::before {
  content: attr(data-label);
  display: grid;
  place-items: center;
  inset: 20px;
  color: rgba(255, 255, 255, 0.88);
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 0;
}

.star {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 2;
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.86);
  color: var(--blue);
  font-weight: 800;
}

.source-badge {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 2;
  max-width: calc(100% - 58px);
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  padding: 7px 8px;
  border: 1px solid rgba(222, 216, 204, 0.9);
  border-radius: 7px;
  background: rgba(255, 253, 250, 0.9);
  color: #171717;
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.source-professor {
  color: var(--blue);
}

.source-dongyu {
  color: var(--green);
}

.source-datasets-bot {
  color: var(--amber);
}

.card-body {
  display: grid;
  gap: 10px;
  padding: 14px;
}

.dataset-card h3 {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.25;
}

.meta {
  font-size: 12px;
}

.language-tags {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px;
  margin-top: 8px;
}

.language-label,
.language-tag {
  border-radius: 5px;
  font-size: 10px;
  line-height: 1;
  white-space: nowrap;
}

.language-label {
  border: 1px solid #cbd5ff;
  background: var(--blue-soft);
  color: var(--blue);
  padding: 4px 5px;
  font-weight: 700;
  text-transform: uppercase;
}

.language-tag {
  border: 1px solid #d7ddff;
  background: #ffffff;
  color: #2442b8;
  padding: 4px 6px;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip {
  border: 1px solid #dad4ca;
  border-radius: 5px;
  background: #f7f3eb;
  color: #374151;
  padding: 4px 6px;
  font-size: 11px;
  line-height: 1;
  white-space: nowrap;
}

.chip.blue {
  border-color: #cbd5ff;
  background: var(--blue-soft);
  color: var(--blue);
}

.chip.green {
  border-color: #c8e6d7;
  background: #e9f7ef;
  color: var(--green);
}

.chip.red {
  border-color: #ecd0d2;
  background: #f8e8e9;
  color: var(--red);
}

.chip.language-chip {
  border-color: #d7ddff;
  background: #f8f9ff;
  color: #2442b8;
}

.evidence {
  min-height: 54px;
  margin: 0;
  font-size: 13px;
  line-height: 1.4;
}

.card-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-start;
  align-items: center;
  gap: 8px;
}

.details-button,
.summary-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 9px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--blue);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.details-button:hover,
.summary-link:hover,
.back-link:hover,
.online-actions a:hover {
  border-color: var(--blue);
  background: var(--blue-soft);
}

.detail-page {
  max-width: 1180px;
  margin: 0 auto;
}

.back-link {
  display: inline-flex;
  align-items: center;
  margin-bottom: 18px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(255, 253, 250, 0.92);
  color: var(--blue);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.detail-hero {
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(320px, 0.92fr);
  gap: 24px;
  align-items: stretch;
  margin-bottom: 22px;
}

.detail-media {
  position: relative;
  min-height: 430px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    radial-gradient(circle at 26% 25%, rgba(255, 255, 255, 0.72), transparent 24%),
    linear-gradient(135deg, #5f646b, #d9d5ca);
  box-shadow: var(--shadow);
}

.detail-media::before {
  content: attr(data-label);
  position: absolute;
  inset: 26px;
  display: none;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.58);
  border-radius: 8px;
  color: rgba(255, 255, 255, 0.9);
  font-size: 28px;
  font-weight: 800;
}

.detail-media.fallback::before {
  display: grid;
}

.detail-media img {
  width: 100%;
  height: 100%;
  min-height: inherit;
  object-fit: cover;
  object-position: top center;
  display: block;
}

.detail-summary,
.detail-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 250, 0.94);
  box-shadow: var(--shadow);
}

.detail-summary {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 430px;
  padding: 28px;
}

.detail-summary h1 {
  margin: 14px 0 12px;
  font-size: clamp(28px, 4vw, 50px);
  line-height: 1.02;
  letter-spacing: 0;
}

.detail-summary p {
  margin: 0 0 16px;
  color: #2f2d29;
  font-family: Inter, ui-sans-serif, system-ui, sans-serif;
  line-height: 1.55;
}

.detail-summary .detail-meta {
  color: var(--muted);
  font-size: 13px;
}

.online-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}

.online-actions a {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--blue);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.detail-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 16px;
}

.detail-panel {
  padding: 18px;
}

.detail-panel:nth-child(3) {
  grid-column: 1 / -1;
}

.detail-panel h2 {
  font-size: 13px;
  text-transform: uppercase;
}

.detail-panel p {
  margin: 0;
  color: #35332f;
  font-family: Inter, ui-sans-serif, system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.55;
}

#detailDialog {
  width: min(840px, calc(100vw - 28px));
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  padding: 20px;
  box-shadow: 0 20px 70px rgba(0, 0, 0, 0.24);
}

#detailDialog::backdrop {
  background: rgba(25, 24, 22, 0.42);
}

.close-button {
  float: right;
  width: 32px;
  height: 32px;
}

.detail-grid {
  display: grid;
  grid-template-columns: 170px minmax(0, 1fr);
  gap: 10px 16px;
  font-family: Inter, ui-sans-serif, system-ui, sans-serif;
  font-size: 14px;
}

.detail-grid dt {
  color: var(--muted);
}

.detail-grid dd {
  margin: 0;
}

.detail-evidence {
  padding: 10px;
  border-radius: 6px;
  background: #f5f1e9;
  line-height: 1.45;
}

@media (max-width: 980px) {
  .site-header,
  main {
    padding-left: 18px;
    padding-right: 18px;
  }

  .layout {
    grid-template-columns: 1fr;
    gap: 18px;
  }

  .filters {
    position: static;
  }

  .quick-charts,
  .hero-stats {
    grid-template-columns: 1fr;
  }

  .detail-hero,
  .detail-layout {
    grid-template-columns: 1fr;
  }

  .detail-media,
  .detail-summary {
    min-height: 320px;
  }

  .detail-panel:nth-child(3) {
    grid-column: auto;
  }
}

@media (max-width: 640px) {
  .site-header nav {
    display: none;
  }

  .search-row,
  .toolbar {
    grid-template-columns: 1fr;
    display: grid;
  }

  .bar-row {
    grid-template-columns: minmax(96px, 130px) minmax(0, 1fr) 30px;
  }

  .detail-summary {
    padding: 18px;
  }

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