:root {
  --bg: #f8f9fa;
  --card-bg: #ffffff;
  --border: #dee2e6;
  --text: #212529;
  --text-muted: #6c757d;
  --accent: #4361ee;
  --accent-light: #eef0ff;
  --tag-bg: #e9ecef;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  padding: 2rem 1rem;
}

.container { margin: 0 auto; }

/* Header */
.header {
  text-align: center;
  margin-bottom: 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 2px solid var(--border);
}
.header h1 {
  font-size: 1.75rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}
.header .stats {
  display: flex;
  justify-content: center;
  gap: 2rem;
  margin-top: 0.75rem;
  flex-wrap: wrap;
  font-size: 0.9rem;
  color: var(--text-muted);
}
.header .stats strong {
  color: var(--text);
  font-size: 1.1rem;
}
.back-link {
  margin-top: 0.5rem;
  font-size: 0.85rem;
}
.back-link a {
  color: var(--accent);
  text-decoration: none;
}
.back-link a:hover { text-decoration: underline; }

/* Filter bar */
.filter-bar {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}
.filter-bar input,
.filter-bar select {
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.875rem;
  background: var(--card-bg);
  flex: 1;
  min-width: 180px;
}
.filter-bar input:focus,
.filter-bar select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}

/* Filter Panel */
.filter-panel {
  margin-bottom: 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--card-bg);
  box-shadow: var(--shadow);
}
.filter-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.6rem 1rem;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.9rem;
  user-select: none;
}
.filter-panel-header:hover {
  background: var(--accent-light);
  border-radius: 8px;
}
.filter-panel-toggle {
  font-size: 0.7rem;
  color: var(--text-muted);
  transition: transform 0.2s;
}
.filter-panel-toggle.open { transform: rotate(180deg); }
.filter-panel-content { padding: 0 1rem 1rem; }
.filter-panel-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}
.clear-filters-btn {
  padding: 0.3rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--card-bg);
  font-size: 0.8rem;
  cursor: pointer;
  color: var(--text-muted);
}
.clear-filters-btn:hover {
  background: var(--accent-light);
  color: var(--accent);
}
.filter-groups-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 1rem;
}
.filter-group {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.5rem;
}
.filter-group-title {
  font-weight: 600;
  font-size: 0.8rem;
  margin-bottom: 0.4rem;
  padding-bottom: 0.3rem;
  border-bottom: 1px solid var(--border);
}
.filter-group-count {
  font-weight: 400;
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-left: 0.3rem;
}
.filter-group-tags {
  max-height: 300px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.filter-tag {
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
  padding: 0.2rem 0.3rem;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.8rem;
  flex-wrap: wrap;
}
.filter-tag:hover { background: var(--accent-light); }
.filter-tag input[type="checkbox"] {
  margin: 0;
  cursor: pointer;
}
.filter-tag .tag {
  white-space: nowrap;
  word-break: normal;
  flex-shrink: 0;
}
.tag-count {
  margin-left: auto;
  font-size: 0.7rem;
  color: var(--text-muted);
  min-width: 1.5rem;
  text-align: right;
}

/* Table */
.table-wrap {
  overflow-x: auto;
  border-radius: 8px;
  box-shadow: var(--shadow);
  background: var(--card-bg);
}
table {
  border-collapse: collapse;
  font-size: 0.85rem;
  table-layout: fixed; /* honor <colgroup> widths */
}
thead {
  position: sticky;
  top: 0;
  z-index: 10;
}
thead th {
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  text-align: left;
  padding: 0.55rem 0.65rem;
  white-space: normal;
  word-break: break-word;
  cursor: pointer;
  user-select: none;
  font-size: 0.8rem;
  line-height: 1.25;
}
thead th:hover { opacity: 0.9; }
thead th.sort-asc::after { content: ' ▲'; font-size: 0.7em; }
thead th.sort-desc::after { content: ' ▼'; font-size: 0.7em; }

tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background 0.15s;
}
tbody tr:hover { background: var(--accent-light); }
tbody tr.hidden { display: none; }
td {
  padding: 0.5rem 0.65rem;
  vertical-align: top;
  word-break: break-word;
  overflow-wrap: anywhere;
  white-space: normal;
}
td.idx-cell { text-align: right; color: var(--text-muted); }
td.title-cell {
  font-weight: 600;
}
td.title-cell a {
  color: var(--accent);
  text-decoration: none;
}
td.title-cell a:hover { text-decoration: underline; }
.deep-dive-link {
  display: inline-block;
  margin-top: 0.25rem;
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  background: var(--accent-light);
  color: var(--accent);
  font-size: 0.7rem;
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
}
.deep-dive-link:hover { background: var(--accent); color: #fff; }

.not-specified {
  color: #adb5bd;
  font-style: italic;
}

/* Subtle marker when a bilingual field falls back to the other language. */
.lang-fallback {
  display: inline-block;
  margin-left: 0.3rem;
  padding: 0 0.35rem;
  border-radius: 4px;
  font-size: 0.65rem;
  font-weight: 600;
  background: #fef3c7;
  color: #92400e;
  vertical-align: middle;
  cursor: help;
}

/* Arxiv id link */
.arxiv-link {
  color: var(--accent);
  text-decoration: none;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.8rem;
  white-space: nowrap;
}
.arxiv-link:hover { text-decoration: underline; }

/* Open-source verdict + link */
.link-cell .link-verdict {
  display: inline-block;
  padding: 0.1rem 0.45rem;
  border-radius: 12px;
  font-size: 0.72rem;
  font-weight: 600;
  margin-right: 0.3rem;
}
.link-cell .link-verdict.yes { background: #d1fae5; color: #065f46; }
.link-cell .link-verdict.partial { background: #fef3c7; color: #92400e; }
.link-cell .link-verdict.no { background: #fee2e2; color: #991b1b; }
.link-cell .link-verdict.other { background: var(--tag-bg); color: var(--text-muted); }
.link-cell .repo-link {
  display: inline-block;
  padding: 0.1rem 0.45rem;
  margin-right: 0.3rem;
  border-radius: 12px;
  background: #d1fae5;
  color: #065f46;
  text-decoration: none;
  font-size: 0.72rem;
  font-weight: 600;
  white-space: nowrap;
}
.link-cell .repo-link:hover { text-decoration: underline; }

/* Subtable tabs */
.subtable-tabs {
  display: flex;
  gap: 0.4rem;
  margin-bottom: 1rem;
  border-bottom: 2px solid var(--border);
  flex-wrap: wrap;
}
.subtable-tab {
  padding: 0.45rem 1rem;
  border: 1px solid var(--border);
  border-bottom: none;
  border-radius: 6px 6px 0 0;
  background: var(--bg);
  color: var(--text-muted);
  font-size: 0.9rem;
  cursor: pointer;
  font-weight: 500;
  position: relative;
  bottom: -2px;
  transition: background 0.15s, color 0.15s;
}
.subtable-tab:hover {
  background: var(--accent-light);
  color: var(--accent);
}
.subtable-tab.active {
  background: var(--card-bg);
  color: var(--text);
  font-weight: 700;
  border-bottom: 2px solid var(--card-bg);
  box-shadow: 0 -1px 3px rgba(0, 0, 0, 0.04);
}

/* Language switcher */
.lang-switch {
  position: absolute;
  top: 0.6rem;
  right: 0.8rem;
  display: flex;
  gap: 0.35rem;
  font-size: 0.85rem;
}
.lang-switch a {
  cursor: pointer;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  color: var(--text-muted);
  user-select: none;
}
.lang-switch a:hover { background: var(--accent-light); color: var(--accent); }
.lang-switch a.active {
  background: var(--accent);
  color: #fff;
}
.header { position: relative; }

/* Tags */
td.tag-cell .tag-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 3px 4px;
}
.tag {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 12px;
  font-size: 0.72rem;
  font-weight: 500;
  white-space: normal;
  word-break: break-word;
  line-height: 1.4;
}

/* Footer */
.footer {
  text-align: center;
  margin-top: 1.5rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* Responsive */
@media (max-width: 768px) {
  body { padding: 1rem 0.5rem; }
  .header h1 { font-size: 1.3rem; }
  td { font-size: 0.8rem; padding: 0.4rem; }
}

@media print {
  body { padding: 0; background: #fff; }
  .filter-bar, .filter-panel { display: none; }
  .table-wrap { box-shadow: none; }
  thead th { background: #333 !important; -webkit-print-color-adjust: exact; }
}
