:root {
  --bg: #ffffff;
  --bg-alt: #f8fafc;
  --border-subtle: #e2e8f0;
  --border-strong: #cbd5e1;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --accent: #2563eb;
  --accent-soft: #dbeafe;
  --row-alt: #f9fafb;
  --row-hover: #eff6ff;
  --radius-lg: 12px;
  --font-sans: system-ui, -apple-system, BlinkMacSystemFont, "SF Pro Text", sans-serif;
  --accent-add: #059669;
  --accent-add-soft: #d1fae5;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  background: var(--bg-alt);
  color: var(--text-main);
}

.page {
  max-width: 1400px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 2.5rem;
}

/* ===== Paper-style hero (stacked, centered) ===== */
.hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  margin-bottom: 1.5rem;
}

.paper-title {
  font-size: clamp(1.6rem, 3.5vw, 2.4rem);
  font-weight: 700;
  line-height: 1.25;
  margin: 0 0 1rem;
}

.authors-list {
  font-size: 0.95rem;
  line-height: 1.7;
  margin-bottom: 0.5rem;
  max-width: 800px;
}

.authors-list .author a {
  color: var(--accent);
  text-decoration: none;
}

.authors-list .author a:hover {
  color: var(--accent);
  text-decoration: underline;
}

.authors-affiliations {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
}

.authors-equal {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-style: italic;
  margin-bottom: 1rem;
}

/* Publication link buttons */
.publication-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin-bottom: 1.2rem;
}

.pub-link-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  font-size: 0.9rem;
  font-weight: 500;
  font-family: var(--font-sans);
  text-decoration: none;
  color: #333;
  background: #fafafa;
  border: 1px solid #ddd;
  border-radius: 8px;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
  transition: all 0.2s ease-in-out;
}

.pub-link-btn:hover {
  background: #f0f0f0;
  border-color: #ccc;
  box-shadow: 0 2px 5px rgba(0,0,0,0.1);
  transform: translateY(-1px);
}

.pub-link-btn.bibtex-copied {
  background: #16a34a;
  color: #fff;
  border-color: #16a34a;
}

.pub-link-btn svg {
  flex-shrink: 0;
}

/* Teaser figure */
.teaser {
  max-width: 960px;
  margin: 0 auto 1rem;
}

.teaser img {
  width: 100%;
  height: auto;
  display: block;
}

.teaser figcaption {
  font-size: 0.82rem;
  line-height: 1.55;
  color: var(--text-main);
  text-align: justify;
  margin-top: 0.6rem;
}

/* Abstract */
.abstract-section {
  max-width: 960px;
  margin: 0 auto 1.2rem;
  text-align: justify;
  background: var(--bg-alt);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 1rem 1.25rem;
}

.abstract-section h2 {
  font-size: 1rem;
  font-weight: 700;
  margin: 0 0 0.4rem;
  text-align: left;
}

.abstract-section p {
  font-size: 0.88rem;
  line-height: 1.6;
  color: var(--text-main);
  margin: 0;
  font-style: italic;
}

/* Tabs */
.table-tabs {
  display: inline-flex;
  flex-wrap: wrap;
  border: 1px solid var(--border-subtle);
  border-radius: 999px;
  padding: 3px;
  background: #ffffff;
  margin-bottom: 1rem;
}

.tab-button {
  border: none;
  background: transparent;
  padding: 0.35rem 0.9rem;
  border-radius: 999px;
  font-size: 0.9rem;
  cursor: pointer;
  color: var(--text-muted);
  white-space: nowrap;
}

.tab-button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.tab-button.is-active {
  background: var(--accent);
  color: #ffffff;
}

/* Table container */
.table-section {
  background: #ffffff;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-subtle);
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.05);
  padding: 0.9rem 1.0rem 0.8rem;
  margin-bottom: 1.2rem;
}

.table-container {
  min-height: 120px;
}

.table-wrapper {
  width: 100%;
  overflow-x: auto;
}

.loading-message,
.error-message {
  font-size: 0.9rem;
  color: var(--text-muted);
  padding: 0.5rem;
}

.error-message {
  color: #b91c1c;
}

@media (max-width: 768px) {
  .page {
    padding-inline: 0.75rem;
  }
}

/* Responsive hero */
@media (max-width: 768px) {
  .paper-title {
    font-size: 1.4rem;
  }
  .teaser {
    max-width: 100%;
  }
}


/* === LaTeX-like table styling ===================================== */
.latex-table-wrapper {
  max-width: min(1400px, 100%);
  margin: 1.5rem auto;
  overflow-x: auto;
  background: #ffffff;
  border-radius: 4px;
  box-shadow: 0 0 0 1px var(--border-strong);
}

.latex-table {
  border-collapse: collapse;
  font-family: var(--font-sans);
  font-size: 0.7rem;
  width: 100%;
  table-layout: fixed;
}

.latex-table th,
.latex-table td {
  padding: 2px 4px;
  border-right: 0.5px solid var(--border-subtle);
  vertical-align: middle;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.latex-table tbody tr:nth-child(odd) {
  background: #f8f5ff;
}

.latex-table tbody tr:nth-child(even) {
  background: #ffffff;
}

.latex-table tbody tr:hover {
  background: #f1ecff;
}

/* group header row */
.latex-table thead .th-group {
  text-align: center;
  font-weight: 600;
  font-size: 0.72rem;
}

.latex-table thead .th-metadata {
  background: #f0f4f8;
}

.latex-table thead .th-prior {
  background: #e5f4ea;
}

.latex-table thead .th-creation {
  background: #e3efff;
}

.latex-table thead .th-animation {
  background: #ffe9d8;
}

.latex-table thead .th-sub {
  background: #f7f7f7;
  text-align: center;
  font-weight: 500;
}

.taxonomy-table.latex-table th:first-child,
.taxonomy-table.latex-table td:first-child {
  text-align: left;
  width: 12%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.icon-cell img,
.legend-table .legend-icon-cell img {
  max-height: 18px;
  width: auto;
  vertical-align: middle;
}

/* Colored badge (crbox) matching LaTeX \crboxbold / \crboxreg */
.crbox {
  display: inline-block;
  padding: 1px 3px;
  border-radius: 3px;
  font-family: system-ui, sans-serif;
  font-size: 0.6rem;
  line-height: 1.2;
  vertical-align: middle;
  text-align: center;
  min-width: 16px;
  cursor: default;
}

/* Floating tooltip for crbox badges (appended to body via JS) */
.crbox-tip {
  position: fixed;
  background: #1e293b;
  color: #fff;
  font-size: 0.75rem;
  font-weight: 500;
  font-family: system-ui, sans-serif;
  padding: 4px 8px;
  border-radius: 5px;
  white-space: nowrap;
  pointer-events: none;
  z-index: 9999;
  line-height: 1.3;
  opacity: 0;
  transition: opacity 0.12s;
}
.crbox-tip.is-visible {
  opacity: 1;
}

/* Legend table: two columns — Category | Icons */
.legend-table.latex-table {
  font-size: 0.82rem;
  border-collapse: separate;
  border-spacing: 0;
}

.legend-table.latex-table tbody tr {
  position: relative;
}

.legend-table.latex-table tbody tr:hover {
  z-index: 5;
}

.legend-table.latex-table th {
  padding: 6px 8px;
  font-size: 1.1rem;
}

.legend-table.latex-table td {
  padding: 3px 6px;
}

.legend-table.latex-table th:first-child,
.legend-table.latex-table td:first-child {
  width: 130px;
  text-align: left;
  white-space: normal;
  font-weight: 600;
}

.legend-table.latex-table td:last-child {
  white-space: normal;
  padding-left: 10px;
  overflow: visible;
}

.legend-table .icon-cell img {
  max-height: 28px;
}

.legend-icons-cell {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  align-items: center;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.legend-filter-btn {
  cursor: pointer;
  border-radius: 4px;
  padding: 2px 4px;
  transition: background 0.15s, box-shadow 0.15s;
}

.legend-filter-btn:hover {
  background: var(--accent-soft);
  box-shadow: 0 0 0 2px var(--accent);
  transform: scale(1.12);
  position: relative;
  z-index: 10;
}

.legend-filter-btn.is-active {
  background: var(--accent);
  box-shadow: 0 0 0 2px var(--accent);
}

.legend-filter-btn.is-active .legend-label {
  color: #ffffff;
}

.legend-filter-btn.is-active .crbox {
  outline: 2px solid #ffffff;
}

.legend-label {
  font-size: 0.82rem;
  color: var(--text-main);
}

/* Legend filter pills container */
.legend-filter-pills {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 0.5rem;
}

.legend-filter-pills:empty {
  display: none;
}

.legend-filter-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.25rem 0.6rem;
  background: var(--accent-soft);
  border: 1px solid var(--accent);
  border-radius: 999px;
  font-size: 0.78rem;
  color: var(--accent);
  font-weight: 600;
}

.legend-filter-pill button {
  border: none;
  background: none;
  color: var(--accent);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  padding: 0 2px;
  font-weight: 700;
}

.legend-filter-pill button:hover {
  color: #1d4ed8;
}

.legend-filter-clear-all {
  border: 1px solid var(--border-subtle);
  background: #ffffff;
  color: var(--text-muted);
  font-size: 0.75rem;
  font-family: var(--font-sans);
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.15s;
}

.legend-filter-clear-all:hover {
  background: #fee2e2;
  border-color: #fca5a5;
  color: #b91c1c;
}

/* Embedded legend in publications tab */
.pub-legend-section {
  margin-bottom: 0.75rem;
}

.pub-legend-section .latex-table-wrapper {
  margin: 0.5rem auto;
}

.pub-legend-heading {
  font-size: 0.95rem;
  font-weight: 600;
  margin: 0 0 1rem;
}

.pub-legend-hint {
  font-weight: 500;
  font-size: 0.82rem;
  color: #b45309;
  background: #fffbeb;
  padding: 2px 8px;
  border-radius: 4px;
  border: 1px solid #fde68a;
}

/* Datasets table: first column wider for name + badge */
.datasets-table.latex-table th:first-child,
.datasets-table.latex-table td:first-child {
  text-align: left;
  width: 16%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.datasets-table.latex-table td:first-child .bib-btn {
  display: inline;
}

/* section label rows (Faces / Full-body / Hands etc.) */
.taxonomy-table.latex-table tr.section-row td,
.assets-table.latex-table tr.section-row td,
.datasets-table.latex-table tr.section-row td {
  background: #edf2ff;
  font-weight: 600;
  text-align: center;
}

/* === Cell overflow tooltip ================================= */
.cell-tooltip {
  position: fixed;
  z-index: 1000;
  background: #1e293b;
  color: #f1f5f9;
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 0.78rem;
  line-height: 1.5;
  padding: 6px 10px;
  border-radius: 6px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.25);
  max-width: 320px;
  white-space: normal;
  word-break: break-word;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.cell-tooltip.is-visible {
  opacity: 1;
}

.cell-tooltip img {
  max-height: 20px;
  vertical-align: middle;
  background: rgba(255,255,255,0.9);
  border-radius: 3px;
  padding: 1px;
}

.cell-tooltip .crbox {
  font-size: 0.7rem;
}

.cell-tooltip .icon-cell,
.cell-tooltip .crbox {
  margin-right: 4px;
}

/* === BibTeX popup ========================================== */
.bib-btn {
  border: none;
  background: none;
  color: #2563eb;
  cursor: pointer;
  padding: 0;
  font: inherit;
  text-decoration: underline;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: block;
}

.bib-overlay {
  position: fixed;
  top: 0; right: 0; bottom: 0; left: 0;
  background: rgba(15, 23, 42, 0.5);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.bib-popup {
  background: #ffffff;
  border-radius: 12px;
  padding: 1.25rem 1.5rem;
  max-width: 700px;
  width: 90%;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  animation: bib-popup-in 0.15s ease-out;
}

@keyframes bib-popup-in {
  from { opacity: 0; transform: scale(0.95) translateY(8px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

.bib-popup-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.bib-popup-title {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text-main);
}

.bib-popup-close {
  border: none;
  background: none;
  font-size: 1.4rem;
  cursor: pointer;
  color: var(--text-muted);
  line-height: 1;
  padding: 4px;
  border-radius: 4px;
  transition: all 0.15s;
}

.bib-popup-close:hover {
  background: #f1f5f9;
  color: var(--text-main);
}

.bib-popup-body {
  max-height: 400px;
  overflow: auto;
  background: var(--bg-alt);
  color: var(--text-main);
  border: 1px solid var(--border-subtle);
  padding: 1rem 1.25rem;
  font-family: "SF Mono", "Fira Code", "Cascadia Code", "Consolas", monospace;
  font-size: 0.8rem;
  line-height: 1.6;
  border-radius: 8px;
  white-space: pre-wrap;
  word-break: break-word;
  tab-size: 2;
}

/* BibTeX syntax highlighting */
.bib-popup-body .bib-type   { color: #7c3aed; font-weight: 600; }
.bib-popup-body .bib-key    { color: #b45309; }
.bib-popup-body .bib-field  { color: #2563eb; }
.bib-popup-body .bib-eq     { color: var(--text-muted); }
.bib-popup-body .bib-value  { color: #16a34a; }
.bib-popup-body .bib-brace  { color: var(--text-muted); }

.bib-popup-copy {
  align-self: flex-end;
  padding: 0.4rem 1rem;
  font-size: 0.8rem;
  font-family: var(--font-sans);
  font-weight: 500;
  border-radius: 6px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: white;
  cursor: pointer;
  transition: all 0.15s;
}

.bib-popup-copy:hover {
  background: #1d4ed8;
  border-color: #1d4ed8;
}

.bib-popup-copy.copied {
  background: #16a34a;
  border-color: #16a34a;
}

/* Publication card inside popup overlay */
.pub-card-popup {
  max-width: 1400px;
  width: 92%;
  max-height: 90vh;
  position: relative;
  padding: 0.75rem;
}

.pub-card-popup > .bib-popup-close {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  z-index: 1;
}

.pub-card-popup-body {
  overflow-y: auto;
  max-height: calc(90vh - 2rem);
}

.pub-card-popup-body .pub-card,
.pub-card-popup-body .pub-card-in-popup {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 1.25rem;
  padding: 1rem 1.25rem;
}

.pub-card-popup-body .pub-abstract {
  display: block;
}

.latex-table thead .th-sub {
  font-size: 0.64rem;
  line-height: 1.2;
  white-space: normal;
}

/* --- Refinements to reduce clutter without breaking icons --- */
.latex-table {
  font-size: 0.68rem;
}

.latex-table thead .th-sub {
  font-size: 0.75rem;
  white-space: normal;
}

.icon-cell img,
.legend-table .legend-icon-cell img {
  max-height: 16px;
}


/* === Publications cards ===================================== */

.publications-list {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  margin-top: 0.75rem;
}

.pub-card {
  position: relative;
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 1.25rem;
  padding: 1rem 1.25rem;
  border-radius: 16px;
  border: 1px solid var(--border-subtle);
  background: #ffffff;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.04);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.pub-card:hover {
  transform: translateY(-4px) scale(1.008);
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.12);
  border-color: var(--accent);
}

.pub-card-popup-body .pub-card,
.pub-card-popup-body .pub-card-in-popup {
  transition: none;
  border: none;
  box-shadow: none;
}

.pub-card-popup-body .pub-card:hover,
.pub-card-popup-body .pub-card-in-popup:hover {
  transform: none;
  box-shadow: none;
  border: none;
}

.pub-rank {
  position: absolute;
  left: -0.75rem;
  top: 1rem;
  width: 1.6rem;
  height: 1.6rem;
  border-radius: 999px;
  background: #f49191;
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 600;
}

.pub-thumb {
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.pub-thumb-linked {
  cursor: pointer;
  position: relative;
}

.pub-thumb-linked:hover {
  transform: scale(1.05);
  box-shadow: 0 6px 16px rgba(15, 23, 42, 0.10);
  border-radius: 12px;
}

.pub-thumb-linked::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 12px;
  border: 2px solid transparent;
  transition: border-color 0.25s ease;
  pointer-events: none;
}

.pub-thumb-linked:hover::after {
  border-color: var(--accent-soft);
}

.pub-thumb-link {
  display: block;
  width: 100%;
  text-decoration: none;
}

.pub-thumb img {
  width: 100%;
  height: auto;
  display: block;
  transition: filter 0.25s ease;
}

.pub-thumb-linked:hover img {
  filter: brightness(1.05);
}

.pub-thumb img.no-thumb {
  opacity: 0;
  position: absolute;
}

.pub-thumb.has-placeholder {
  background: #f1f5f9;
  position: relative;
}

.pub-thumb .thumb-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  aspect-ratio: 4 / 3;
  color: #94a3b8;
}

.pub-main {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.pub-title {
  font-size: 1rem;
  margin: 0;
}

.pub-authors {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.pub-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}

.pub-tag {
  font-size: 0.72rem;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  background: #e5f0ff;
}

.pub-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.4rem;
}

.pub-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.4rem 1rem;
  border-radius: 999px;
  border: 1px solid var(--border-subtle);
  font-size: 0.85rem;
  font-weight: 500;
  text-decoration: none;
  background: #f8fafc;
  color: var(--text-main);
  cursor: pointer;
  transition: all 0.15s ease;
}

.pub-link:hover {
  background: var(--accent);
  color: #ffffff;
  border-color: var(--accent);
  transform: translateY(-1px);
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.25);
}

.pub-bib-copy {
  font-family: inherit;
}

.pub-bib-copied {
  background: #16a34a;
  color: #fff;
  border-color: #16a34a;
}

.pub-abstract {
  margin-top: 0.4rem;
  font-size: 0.8rem;
  color: var(--text-main);
  background: #f9fafb;
  border-radius: 8px;
  padding: 0.6rem 0.75rem;
  text-align: justify;
}

/* Assets table: first column wider for name */
.assets-table.latex-table th:first-child,
.assets-table.latex-table td:first-child {
  text-align: left;
  width: 14%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.assets-table.latex-table td .icon-cell,
.assets-table.latex-table td .crbox {
  margin-right: 4px;
}

/* Taxonomy tags on pub cards */
.pub-taxonomy-tag {
  font-size: 0.72rem;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-weight: 600;
}

.pub-taxonomy-avatar {
  background: #e5f4ea;
  color: #166534;
}

.pub-taxonomy-assets {
  background: #ffe9d8;
  color: #9a3412;
}

.pub-taxonomy-skipped {
  background: #f1f5f9;
  color: #64748b;
}

/* Skip reason on pub cards (hidden by default) */
.pub-skip-reason {
  margin-top: 0.3rem;
  font-size: 0.78rem;
  font-style: italic;
  color: var(--text-muted);
  background: #f9fafb;
  border-radius: 6px;
  padding: 0.4rem 0.6rem;
  display: none;
}

/* Validation notes on pub cards (hidden by default) */
.pub-note {
  margin-top: 0.3rem;
  font-size: 0.78rem;
  font-style: italic;
  color: #92400e;
  background: #fffbeb;
  border-left: 3px solid #f59e0b;
  border-radius: 6px;
  padding: 0.4rem 0.6rem;
  display: none;
}

/* Show notes/skip-reasons when toggled */
.show-notes .pub-note,
.show-notes .pub-skip-reason {
  display: block;
}

/* --- Filter controls --- */
.pub-controls {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
  padding: 0.6rem 0.75rem;
  background: #ffffff;
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.04);
}

.pub-search-wrap {
  position: relative;
  flex: 1;
  min-width: 200px;
}

.pub-search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

.pub-search {
  width: 100%;
  padding: 0.5rem 0.7rem 0.5rem 2rem;
  font-size: 0.88rem;
  font-family: var(--font-sans);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  background: var(--bg-alt);
  color: var(--text-main);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.pub-search:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
  background: #ffffff;
}

.pub-filter-select {
  padding: 0.5rem 0.7rem;
  font-size: 0.85rem;
  font-family: var(--font-sans);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  background: var(--bg-alt);
  color: var(--text-main);
  cursor: pointer;
  outline: none;
  transition: border-color 0.15s;
}

.pub-filter-select:focus {
  border-color: var(--accent);
}

/* Custom multi-select dropdown */
.pub-multiselect {
  position: relative;
  display: inline-block;
}
.pub-multiselect-btn {
  text-align: left;
  min-width: 120px;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23666'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.6rem center;
  padding-right: 1.6rem;
}
.pub-multiselect-menu {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  margin-top: 4px;
  background: #fff;
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  z-index: 100;
  min-width: 160px;
  padding: 0.3rem 0;
}
.pub-multiselect.is-open .pub-multiselect-menu {
  display: block;
}
.pub-multiselect-item {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.7rem;
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--text-main);
  white-space: nowrap;
  transition: background 0.1s;
}
.pub-multiselect-item:hover {
  background: var(--bg-alt);
}
.pub-multiselect-item input[type="checkbox"] {
  accent-color: var(--accent);
  margin: 0;
}

.pub-result-count {
  font-size: 0.82rem;
  color: var(--text-muted);
  white-space: nowrap;
  margin-left: auto;
}

.table-find-bar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 0.75rem;
  margin: 0 auto 0;
  max-width: min(1400px, 100%);
  background: #ffffff;
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.04);
}
.table-find-bar + .latex-table-wrapper {
  margin-top: 0.5rem;
}
.table-find-input-wrap {
  position: relative;
  width: 380px;
}
.table-find-input-wrap .pub-search {
  padding-right: 7rem;
}
.table-find-count {
  position: absolute;
  right: 52px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
  pointer-events: none;
}
.table-find-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.table-find-nav:hover {
  background: var(--border-subtle);
  color: var(--text-main);
}
#taxonomy-search-prev, #assets-search-prev { right: 26px; }
#taxonomy-search-next, #assets-search-next { right: 4px; }
.find-match {
  background: rgba(255, 220, 80, 0.25);
}
.find-current {
  background: rgba(255, 180, 0, 0.45);
  outline: 2px solid rgba(255, 160, 0, 0.6);
  outline-offset: -1px;
}

.pub-show-notes-toggle {
  font-size: 0.82rem;
  color: var(--text-muted);
  white-space: nowrap;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.3rem;
  user-select: none;
}

/* Filter toggle button — hidden on desktop, shown on mobile */
.pub-filter-toggle {
  display: none;
  align-items: center;
  gap: 0.3rem;
  padding: 0.5rem 0.7rem;
  font-size: 0.85rem;
  font-family: var(--font-sans);
  font-weight: 500;
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  background: var(--bg-alt);
  color: var(--text-muted);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s;
}

.pub-filter-toggle:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.pub-controls.filters-open .pub-filter-toggle {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}

/* --- Pagination --- */
.pub-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  margin-top: 1.5rem;
  padding: 0.75rem 0;
}

.pub-page-btn {
  padding: 0.4rem 1rem;
  font-size: 0.85rem;
  font-family: var(--font-sans);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  background: #ffffff;
  cursor: pointer;
  transition: all 0.15s;
}

.pub-page-btn:hover:not(:disabled) {
  background: var(--accent);
  color: #ffffff;
  border-color: var(--accent);
}

.pub-page-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.pub-page-info {
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* Responsive layout */
@media (max-width: 900px) {
  .table-tabs {
    border-radius: 12px;
  }
  .tab-button {
    padding: 0.3rem 0.6rem;
    font-size: 0.8rem;
  }
  .tab-button--add {
    margin-left: 0;
  }
  .pub-card {
    grid-template-columns: minmax(0, 1fr);
  }
  .pub-rank {
    left: 0.5rem;
    top: 0.5rem;
    z-index: 2;
  }
  .pub-controls {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
  }
  .pub-search-wrap {
    min-width: 0;
    flex: 1;
  }
  .pub-result-count {
    margin-left: 0;
    text-align: center;
    order: 10;
    width: 100%;
  }
  /* Show toggle button on mobile */
  .pub-filter-toggle {
    display: inline-flex;
  }
  /* Hide filter controls by default on mobile */
  .pub-filter-collapsible {
    display: none;
  }
  /* Show filter controls when toggled open */
  .pub-controls.filters-open .pub-filter-collapsible {
    display: flex;
  }
  .pub-controls.filters-open {
    flex-direction: column;
    align-items: stretch;
  }
  .pub-controls.filters-open .pub-search-wrap {
    order: -1;
  }
}

/* === Add Entry tab + form ======================================= */
.tab-button--add {
  background: var(--accent-add);
  color: #ffffff;
  font-weight: 600;
  border: 2px solid var(--accent-add);
  box-shadow: 0 0 0 2px var(--accent-add-soft);
  margin-left: 0.5rem;
}

.tab-button--add:hover {
  background: #047857;
  border-color: #047857;
}

.tab-button--add.is-active {
  background: var(--accent-add);
  color: #ffffff;
  border-color: var(--accent-add);
}

/* Form layout */
.add-form {
  max-width: 800px;
  margin: 0 auto;
}

.add-form-section {
  margin-bottom: 1.5rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--border-subtle);
}

.add-form-section:last-of-type {
  border-bottom: none;
}

.add-form-section h3 {
  font-size: 1rem;
  font-weight: 600;
  margin: 0 0 0.75rem;
  color: var(--text-main);
}

.add-field {
  margin-bottom: 0.75rem;
}

.add-field label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-main);
  margin-bottom: 0.25rem;
}

.add-field label .required {
  color: #dc2626;
  margin-left: 2px;
}

.add-field input[type="text"],
.add-field input[type="number"],
.add-field input[type="url"],
.add-field select,
.add-field textarea {
  width: 100%;
  padding: 0.5rem 0.7rem;
  font-size: 0.88rem;
  font-family: var(--font-sans);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  background: var(--bg-alt);
  color: var(--text-main);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.add-field input:focus,
.add-field select:focus,
.add-field textarea:focus {
  border-color: var(--accent-add);
  box-shadow: 0 0 0 3px var(--accent-add-soft);
  background: #ffffff;
}

.add-field textarea {
  min-height: 80px;
  resize: vertical;
}

.add-field .add-field-hint {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 0.2rem;
}

/* Radio group for table type */
.add-radio-group {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  margin-top: 0.25rem;
}

.add-radio-group label {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-weight: 400;
  cursor: pointer;
}

.add-radio-group input[type="radio"] {
  accent-color: var(--accent-add);
}

/* Classification sub-fields (shown/hidden by JS) */
.add-cls-fields {
  display: none;
  margin-top: 0.75rem;
  padding: 0.75rem;
  background: var(--bg-alt);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
}

.add-cls-fields.is-visible {
  display: block;
}

.add-cls-fields .add-field {
  margin-bottom: 0.5rem;
}

/* Inline field pair */
.add-field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

/* Action buttons */
.add-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 1.25rem 0;
}

.add-btn {
  padding: 0.5rem 1.1rem;
  font-size: 0.88rem;
  font-family: var(--font-sans);
  font-weight: 500;
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  background: #ffffff;
  color: var(--text-main);
  cursor: pointer;
  transition: all 0.15s;
}

.add-btn:hover {
  background: var(--bg-alt);
  border-color: var(--border-strong);
}

.add-btn-primary {
  background: var(--accent-add);
  color: #ffffff;
  border-color: var(--accent-add);
}

.add-btn-primary:hover {
  background: #047857;
  border-color: #047857;
}

.add-download-btn {
  background: var(--accent-add);
  color: #ffffff;
  border-color: var(--accent-add);
}

.add-download-btn:hover {
  background: #047857;
  border-color: #047857;
}

/* Preview / diff viewer */
.add-preview {
  margin-top: 1rem;
}

.add-preview h4 {
  font-size: 0.9rem;
  font-weight: 600;
  margin: 0 0 0.5rem;
  cursor: pointer;
  user-select: none;
}

.add-preview-content {
  background: var(--bg-alt);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  font-family: "SF Mono", "Fira Code", "Cascadia Code", "Consolas", monospace;
  font-size: 0.8rem;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 500px;
  overflow: auto;
}

.diff-viewer {
  background: #ffffff;
  color: var(--text-main);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  font-family: "SF Mono", "Fira Code", "Cascadia Code", "Consolas", monospace;
  font-size: 0.78rem;
  line-height: 1.55;
  white-space: pre;
  overflow: auto;
  max-height: 500px;
  tab-size: 2;
}

.diff-viewer .diff-add {
  background: #dcfce7;
  color: #166534;
  display: block;
}

.diff-viewer .diff-del {
  background: #fee2e2;
  color: #991b1b;
  display: block;
}

.diff-viewer .diff-hdr {
  color: #2563eb;
  font-weight: 600;
  display: block;
}

/* Instructions panel */
.add-instructions {
  margin-top: 1.25rem;
  padding: 0.85rem 1rem;
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: 8px;
  font-size: 0.82rem;
  line-height: 1.6;
  color: var(--text-main);
}

.add-instructions h4 {
  margin: 0 0 0.4rem;
  font-size: 0.88rem;
  font-weight: 600;
}

.add-instructions ol {
  margin: 0;
  padding-left: 1.2rem;
}

.add-instructions li {
  margin-bottom: 0.3rem;
}

.add-instructions code {
  background: #fef3c7;
  padding: 1px 4px;
  border-radius: 3px;
  font-size: 0.8rem;
}

/* Validation error */
.add-field.has-error input,
.add-field.has-error select,
.add-field.has-error textarea {
  border-color: #dc2626;
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.15);
}

.add-field .add-error-msg {
  font-size: 0.78rem;
  color: #dc2626;
  margin-top: 0.2rem;
  display: none;
}

.add-field.has-error .add-error-msg {
  display: block;
}

/* Responsive */
@media (max-width: 600px) {
  .add-field-row {
    grid-template-columns: 1fr;
  }
  .add-actions {
    flex-direction: column;
  }
  .add-actions .add-btn {
    width: 100%;
    text-align: center;
  }
}

/* ===== Tabs row (tabs + last-updated) ===== */
.table-tabs-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.table-tabs-row .table-tabs {
  margin-bottom: 0;
}

.last-updated {
  color: var(--text-muted);
  font-size: 0.82rem;
  white-space: nowrap;
  align-self: flex-end;
}

/* ===== Site footer ===== */
.site-footer {
  text-align: left;
  padding: 0;
  margin-top: -0.5rem;
}

/* ===== Cookie consent banner ===== */
.cookie-banner {
  display: none;
  position: fixed;
  bottom: 24px;
  right: 24px;
  max-width: 400px;
  background: #fafafa;
  border: 1px solid #ddd;
  border-radius: 4px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
  padding: 20px;
  z-index: 9999;
  font-size: 13px;
  line-height: 1.7;
}

.cookie-banner.is-visible {
  display: block;
}

.cookie-banner-title {
  font-weight: 600;
  font-size: 14px;
  color: #1a1a1a;
  margin-bottom: 8px;
}

.cookie-banner-text {
  color: #666;
  font-size: 12px;
  margin-bottom: 16px;
}

.cookie-banner-actions {
  display: flex;
  gap: 8px;
}

.cookie-btn {
  flex: 1;
  padding: 8px 0;
  border-radius: 2px;
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s;
  background: transparent;
}

.cookie-btn-accept {
  border: 1px solid #333;
  color: #333;
}

.cookie-btn-accept:hover {
  background: #333;
  color: #fff;
}

.cookie-btn-decline {
  border: 1px solid #ccc;
  color: #999;
}

.cookie-btn-decline:hover {
  background: #eee;
  color: #555;
  border-color: #aaa;
}
