/* ===== Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  color: var(--ink);
  background: var(--surface);
  line-height: 1.65;
  font-size: 16px;
}

.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 28px;
}

/* ===== Hero ===== */
.hero {
  background: linear-gradient(160deg, #bfdbfe 0%, #dbeafe 30%, #eff6ff 70%, var(--wash) 100%);
  padding: 60px 0 52px;
  text-align: center;
}

.venue-badge {
  display: inline-block;
  background: var(--accent);
  color: var(--surface);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 4px 14px;
  border-radius: 20px;
  margin-bottom: 20px;
}

.paper-title {
  font-size: 1.9rem;
  font-weight: 700;
  line-height: 1.3;
  color: var(--ink);
  max-width: 820px;
  margin: 0 auto 24px;
}

/* Hero Buttons */
.hero-buttons {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 12px;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 20px;
  border: 1.5px solid var(--accent);
  border-radius: 6px;
  color: var(--accent);
  font-size: 0.9rem;
  font-weight: 500;
  text-decoration: none;
  background: var(--surface);
  transition: background 0.18s, color 0.18s;
  cursor: pointer;
  font-family: inherit;
}

.btn:not(:disabled):hover {
  background: var(--accent);
  color: var(--surface);
}

.btn:disabled {
  border-color: var(--muted);
  color: var(--muted);
  cursor: default;
}

.hero-link-note {
  margin-top: 12px;
  color: var(--muted);
  font-size: 0.85rem;
}

.btn svg { width: 16px; height: 16px; flex-shrink: 0; }

/* ===== Sections ===== */
.section { padding: 64px 0; }
.section-alt { background: var(--wash); }

.section h2 {
  font-size: 1.55rem;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 24px;
  padding-bottom: 10px;
  border-bottom: 2px solid var(--line);
}

/* ===== Abstract ===== */
.abstract-row {
  display: flex;
  gap: 32px;
  align-items: stretch;
}

.abstract-text {
  font-size: 0.97rem;
  color: var(--muted);
  line-height: 1.8;
  flex: 1;
  min-width: 0;
}

.wordcloud-container {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.wordcloud-note {
  font-size: 0.8rem;
  color: var(--muted);
  text-align: center;
  font-style: italic;
  margin-top: 4px;
}

.wordcloud-wrap {
  width: 100%;
  height: 310px;
  position: relative;
  overflow: hidden;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--wash) 0%, var(--wash) 100%);
  border: 1px solid var(--line);
}

.wc-word {
  position: absolute;
  white-space: nowrap;
  font-family: 'Inter', sans-serif;
  font-weight: 600;
  cursor: default;
  transition: transform 0.3s, opacity 0.3s;
  opacity: 0.85;
}
.wc-word:hover {
  transform: scale(1.15);
  opacity: 1;
}

@keyframes wcFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

@media (max-width: 768px) {
  .abstract-row { flex-direction: column; }
  .wordcloud-container { width: 100%; }
  .wordcloud-wrap { width: 100%; height: 260px; }
}

/* ===== Stats Grid ===== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 28px 20px;
  text-align: center;
  box-shadow: 0 1px 4px rgba(0,0,0,0.05);
}

.stat-number {
  font-size: 2.2rem;
  font-weight: 700;
  color: var(--accent);
  line-height: 1;
  margin-bottom: 8px;
}

.stat-label {
  font-size: 0.85rem;
  color: var(--muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* ===== Domain Table ===== */
.table-wrapper {
  overflow-x: auto;
  border-radius: 8px;
  border: 1px solid var(--line);
  margin-bottom: 32px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

thead th {
  background: var(--ink);
  color: var(--surface);
  padding: 11px 14px;
  text-align: left;
  font-weight: 600;
  font-size: 0.82rem;
  white-space: nowrap;
}

tbody td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--wash);
  color: var(--muted);
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--wash); }

/* ===== Pipeline ===== */
.pipe-slider { text-align: center; }

.pipe-tabs {
  display: inline-flex;
  background: var(--wash);
  border-radius: 8px;
  padding: 3px;
  gap: 2px;
  margin-bottom: 16px;
}

.pipe-tab {
  padding: 6px 16px;
  border: none;
  border-radius: 6px;
  background: transparent;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s, box-shadow 0.15s;
}
.pipe-tab:hover { color: var(--muted); }
.pipe-tab.active {
  background: var(--surface);
  color: var(--accent);
  box-shadow: 0 1px 4px rgba(0,0,0,0.12);
  font-weight: 600;
}

.pipe-img {
  width: 100%;
  border-radius: 8px;
}

/* ===== Injection Demo ===== */
/* Inline stats & legend inside card */
.inj-stats-inline {
  display: flex;
  gap: 20px;
  padding: 10px 16px;
  background: #f8fafc;
  border-top: 1px solid var(--line);
  font-size: 0.84rem;
  color: var(--muted);
  flex-shrink: 0;
}

.inj-legend-inline {
  display: flex;
  gap: 20px;
  padding: 8px 16px;
  font-size: 0.8rem;
  color: #64748b;
  flex-shrink: 0;
  align-items: center;
}

.inj-legend-note {
  margin-left: auto;
  font-size: 0.75rem;
  color: var(--muted);
  font-style: italic;
}

.inj-controls {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.inj-round-tabs {
  display: inline-flex;
  background: var(--wash);
  border-radius: 8px;
  padding: 3px;
  gap: 2px;
}

.inj-viewer-card {
  display: flex;
  height: 68vh;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  background: var(--surface);
  box-shadow: 0 2px 12px rgba(0,0,0,0.07);
}

.inj-panel {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.inj-panel + .inj-panel {
  border-left: 1px solid var(--line);
}

.inj-right {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  border-left: 1px solid var(--line);
}

.inj-texts {
  display: flex;
  flex: 1;
  min-height: 0;
}

.inj-panel-img {
  flex: none;
  width: 40%;
  background: var(--wash);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.inj-panel-img img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.inj-panel-title {
  padding: 10px 16px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
  background: #f8fafc;
  flex-shrink: 0;
}

.inj-panel-body {
  padding: 14px 16px;
  font-size: 0.85rem;
  line-height: 1.8;
  color: var(--muted);
  overflow-y: auto;
  flex: 1;
}

.inj-legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.inj-legend-item mark {
  padding: 1px 7px;
  border-radius: 3px;
  font-size: 0.8rem;
  font-weight: 500;
}

.inj-stat strong {
  font-weight: 700;
}

.inj-stat-detected strong { color: #ca8a04; }
.inj-stat-survived strong { color: #dc2626; }

mark.hal-detected {
  background: #fef9c3;
  color: #92400e;
  border-radius: 3px;
  padding: 1px 2px;
  font-style: normal;
  cursor: help;
}

@media (max-width: 768px) {
  .inj-viewer-card { flex-direction: column; height: auto; }
  .inj-panel + .inj-panel { border-left: none; border-top: 1px solid var(--line); }
  .inj-panel-img { height: 200px; }
}

/* ===== Detection Visualization ===== */
.det-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

/* Model multi-select dropdown */
.det-model-dropdown {
  position: relative;
}

.det-model-btn {
  cursor: pointer;
  text-align: left;
  min-width: 180px;
}

.det-model-menu {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  z-index: 100;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
  max-height: 320px;
  overflow-y: auto;
  min-width: 220px;
  margin-top: 4px;
}

.det-model-menu.open { display: block; }

.det-model-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px;
  cursor: pointer;
  font-size: 0.84rem;
  color: var(--muted);
  transition: background 0.1s;
}

.det-model-option:hover { background: var(--wash); }
.det-model-option.selected { background: #eff6ff; }

.det-model-swatch {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  flex-shrink: 0;
}

.det-model-check {
  margin-left: auto;
  font-size: 0.8rem;
  color: var(--accent);
  font-weight: 700;
}

.det-viewer-card {
  display: flex;
  height: 68vh;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  background: var(--surface);
  box-shadow: 0 2px 12px rgba(0,0,0,0.07);
}

.det-panel-img {
  width: 50%;
  flex-shrink: 0;
  background: var(--wash);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.det-panel-img img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.det-panel-text {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 20px 24px;
  color: var(--muted);
  overflow-y: auto;
}

.det-text-body {
  flex: 1;
  font-size: 0.88rem;
  line-height: 1.85;
}

.det-gt {
  background: #fee2e2;
  color: #b91c1c;
  border-radius: 3px;
  padding: 1px 2px;
}

.det-bracket {
  font-weight: 800;
  font-size: 1.15em;
}

.det-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--muted);
  align-items: center;
  flex-shrink: 0;
}

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

.det-legend-swatch {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  display: inline-block;
}

@media (max-width: 768px) {
  .det-viewer-card { flex-direction: column; height: auto; }
  .det-panel-img { width: 100%; height: 220px; }
}

/* ===== Leaderboard ===== */
.lb-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 14px;
  margin-bottom: 20px;
}

.lb-left { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }

.lb-tabs {
  display: flex;
  gap: 0;
  border: 1.5px solid var(--accent);
  border-radius: 6px;
  overflow: hidden;
}

.lb-tab {
  padding: 8px 18px;
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  background: var(--surface);
  color: var(--accent);
  border: none;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
  font-family: inherit;
}

.lb-tab.active {
  background: var(--accent);
  color: var(--surface);
}

.lb-filter {
  display: flex;
  gap: 6px;
  align-items: center;
}

.lb-filter-label {
  font-size: 0.83rem;
  color: var(--muted);
  margin-right: 2px;
}

.filter-btn {
  padding: 5px 12px;
  border: 1px solid var(--line);
  border-radius: 20px;
  font-size: 0.8rem;
  cursor: pointer;
  background: var(--surface);
  color: var(--muted);
  transition: all 0.15s;
  font-family: inherit;
}

.filter-btn.active {
  background: var(--ink);
  color: var(--surface);
  border-color: var(--ink);
}

.filter-btn:hover:not(.active) { background: var(--wash); }

.download-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  background: var(--wash);
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 0.82rem;
  color: var(--muted);
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s;
  white-space: nowrap;
}

.download-btn:hover { background: var(--line); }
.download-btn svg { width: 14px; height: 14px; }

.lb-note {
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 10px;
}

/* Leaderboard Table */
.lb-table-wrap {
  overflow-x: auto;
  border-radius: 8px;
  border: 1px solid var(--line);
}

#lb-table {
  min-width: 800px;
  border-collapse: collapse;
  font-size: 0.81rem;
  width: 100%;
  background: var(--surface);
}

#lb-table thead tr:first-child th {
  background: var(--ink);
  color: var(--surface);
  padding: 9px 10px;
  text-align: center;
  font-weight: 600;
  font-size: 0.78rem;
  white-space: nowrap;
}

#lb-table thead tr:last-child th {
  background: #2d3f55;
  color: #cbd5e1;
  padding: 7px 8px;
  text-align: center;
  font-size: 0.73rem;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
}

#lb-table thead tr:last-child th:hover { background: #3d5068; color: var(--surface); }
#lb-table thead tr:last-child th.sort-asc::after { content: " ▲"; font-size: 0.65em; }
#lb-table thead tr:last-child th.sort-desc::after { content: " ▼"; font-size: 0.65em; }

/* Sticky columns */
#lb-table th.sticky-1, #lb-table td.sticky-1 {
  position: sticky; left: 0; z-index: 2; min-width: 40px;
}
#lb-table th.sticky-2, #lb-table td.sticky-2 {
  position: sticky; left: 40px; z-index: 2; min-width: 160px;
}
#lb-table th.sticky-3, #lb-table td.sticky-3 {
  position: sticky; left: 200px; z-index: 2; min-width: 76px;
}

#lb-table thead tr:first-child th.sticky-1,
#lb-table thead tr:first-child th.sticky-2,
#lb-table thead tr:first-child th.sticky-3 { z-index: 4; }

#lb-table thead tr:last-child th.sticky-1,
#lb-table thead tr:last-child th.sticky-2,
#lb-table thead tr:last-child th.sticky-3 { z-index: 3; }

#lb-table tbody td {
  padding: 8px 10px;
  text-align: center;
  border-bottom: 1px solid var(--wash);
  white-space: nowrap;
  color: var(--muted);
  background: var(--surface);
}

#lb-table tbody td.sticky-1,
#lb-table tbody td.sticky-2,
#lb-table tbody td.sticky-3 { background: var(--surface); }

#lb-table tbody tr:nth-child(even) td { background: var(--wash); }
#lb-table tbody tr:nth-child(even) td.sticky-1,
#lb-table tbody tr:nth-child(even) td.sticky-2,
#lb-table tbody tr:nth-child(even) td.sticky-3 { background: var(--wash); }

#lb-table tbody tr:nth-child(1) td { background: #fefce8; }
#lb-table tbody tr:nth-child(1) td.sticky-1,
#lb-table tbody tr:nth-child(1) td.sticky-2,
#lb-table tbody tr:nth-child(1) td.sticky-3 { background: #fefce8; }

#lb-table tbody tr:hover td { background: #eff6ff !important; }
#lb-table tbody tr:hover td.sticky-1,
#lb-table tbody tr:hover td.sticky-2,
#lb-table tbody tr:hover td.sticky-3 { background: #eff6ff !important; }

#lb-table td.align-left { text-align: left; }

/* Best value highlight */
#lb-table td.best { color: #16a34a; font-weight: 700; }

/* Column group separator */
.col-sep { border-left: 2px solid var(--muted) !important; }
.col-sep-body { border-left: 2px solid var(--line) !important; }

/* Type badge */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 0.7rem;
  font-weight: 600;
}
.badge-open { background: #dbeafe; color: #1d4ed8; }
.badge-closed { background: #fef3c7; color: #92400e; }

/* Rank */
.rank-medal { font-weight: 700; }
.rank-1 { color: #b45309; }
.rank-2 { color: var(--muted); }
.rank-3 { color: #92400e; }
.dash-val { color: #cbd5e1; }

/* ===== Citation ===== */
.citation-block {
  background: var(--ink);
  border-radius: 8px;
  padding: 24px;
  overflow-x: auto;
}

.citation-block pre {
  color: var(--line);
  font-family: 'JetBrains Mono', 'Fira Code', 'Courier New', monospace;
  font-size: 0.85rem;
  line-height: 1.6;
  white-space: pre;
}

/* ===== Examples Viewer ===== */
.ex-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 20px;
}

.ex-selects {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

.ex-right-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Unhighlight btn — same height as mode toggle */
#btn-highlight {
  align-self: auto;
  padding: 7px 14px;
}

.ex-select {
  padding: 7px 32px 7px 12px;
  border: 1.5px solid var(--line);
  border-radius: 8px;
  font-size: 0.85rem;
  font-family: inherit;
  color: var(--muted);
  background: var(--surface);
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%236b7280' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  cursor: pointer;
  min-width: 140px;
  transition: border-color 0.15s;
}
.ex-select:focus { outline: none; border-color: var(--accent); }

.ex-mode-toggle {
  display: flex;
  border: 1.5px solid var(--accent);
  border-radius: 6px;
  overflow: hidden;
}

.ex-mode {
  padding: 7px 16px;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  background: var(--surface);
  color: var(--accent);
  border: none;
  font-family: inherit;
  transition: background 0.15s, color 0.15s;
}

.ex-mode.active {
  background: var(--accent);
  color: var(--surface);
}

/* Single-image viewer */
.ex-viewer-outer {
  padding: 0 28px 48px;
}

#ex-viewer { width: 100%; }

.ex-viewer-card {
  display: flex;
  height: 68vh;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  background: var(--surface);
  box-shadow: 0 2px 12px rgba(0,0,0,0.07);
}

.ex-viewer-img {
  width: 50%;
  flex-shrink: 0;
  background: var(--wash);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.ex-viewer-img img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.ex-viewer-body {
  flex: 1;
  padding: 24px 28px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow-y: auto;
}

.ex-viewer-header {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.ex-domain-badge {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 10px;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  flex-shrink: 0;
}

.ex-filename {
  font-size: 0.78rem;
  color: var(--muted);
  font-family: 'JetBrains Mono', monospace;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  min-width: 0;
}

.ex-gt-btn {
  align-self: flex-start;
  padding: 5px 14px;
  border: 1.5px solid var(--accent);
  border-radius: 6px;
  background: var(--surface);
  color: var(--accent);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s, color 0.15s;
}
.ex-gt-btn:hover { background: #eff6ff; }
.ex-gt-btn.active { background: var(--accent); color: var(--surface); }

/* Method slider (synthetic mode) — top-right of card header */
.ex-method-slider {
  margin-left: auto;
  flex-shrink: 0;
  display: flex;
  background: var(--wash);
  border-radius: 8px;
  padding: 3px;
  gap: 2px;
}

.ex-method-slider button {
  padding: 4px 10px;
  border: none;
  border-radius: 6px;
  background: transparent;
  font-size: 0.74rem;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s, box-shadow 0.15s;
}

.ex-method-slider button:hover { color: var(--muted); }

.ex-method-slider button.active {
  background: var(--surface);
  color: #7c3aed;
  box-shadow: 0 1px 4px rgba(0,0,0,0.12);
  font-weight: 600;
}

.ex-caption {
  font-size: 0.9rem;
  line-height: 1.8;
  color: var(--muted);
  flex: 1;
  overflow-y: auto;
}

/* Hallucination highlight + tooltip */
mark { background: transparent; }

mark.hal {
  background: #fee2e2;
  color: #b91c1c;
  border-radius: 3px;
  padding: 1px 2px;
  font-style: normal;
  cursor: help;
}

.hal-tooltip {
  position: fixed;
  background: var(--ink);
  color: var(--surface);
  font-size: 0.72rem;
  font-weight: 500;
  padding: 4px 9px;
  border-radius: 5px;
  white-space: nowrap;
  pointer-events: none;
  z-index: 9999;
  transition: opacity 0.15s;
  opacity: 0;
}

/* GT correction highlight */
mark.gt-cor {
  background: #bbf7d0;
  color: #14532d;
  border-radius: 3px;
  padding: 1px 2px;
  font-style: normal;
}

/* ===== Footer ===== */
footer {
  background: var(--ink);
  color: var(--muted);
  text-align: center;
  padding: 28px;
  font-size: 0.85rem;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
  .paper-title { font-size: 1.35rem; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .lb-controls { flex-direction: column; align-items: flex-start; }
  .hero-buttons { gap: 8px; }
  .btn { padding: 8px 14px; font-size: 0.85rem; }
}
