:root {
  color-scheme: light;
  --bg: #f7f5f1;
  --surface: #ffffff;
  --surface-soft: #fbfaf7;
  --ink: #1e2522;
  --muted: #69736f;
  --line: #d8d5cd;
  --line-strong: #9b968a;
  --accent: #486a63;
  --accent-soft: #e5efec;
  --blue-soft: #e8edf5;
  --violet-soft: #eee9f4;
  --warning-soft: #f3ecdd;
  --radius: 8px;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.45;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.app-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  padding: 32px clamp(20px, 4vw, 56px) 22px;
  border-bottom: 1px solid var(--line);
  background: #fdfcf9;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2,
h3 {
  margin: 0;
  line-height: 1.15;
}

h1 {
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(32px, 4vw, 52px);
  font-weight: 500;
}

.collection-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
}

.paper-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fdfcf9;
  color: var(--ink);
  font-size: 13px;
  font-weight: 800;
  padding: 8px 12px;
}

.paper-link:hover {
  border-color: var(--line-strong);
  text-decoration: none;
}

.paper-link-icon {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: var(--accent);
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

h2 {
  font-size: 18px;
}

main {
  padding: 22px clamp(20px, 4vw, 56px) 56px;
}

.collection-tabs {
  display: inline-flex;
  gap: 4px;
  margin-bottom: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fdfcf9;
  padding: 4px;
}

.collection-tabs button {
  min-height: 34px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  font-weight: 800;
  padding: 6px 12px;
}

.collection-tabs button.is-active {
  background: var(--accent);
  color: #fff;
}

.collection-tabs button[hidden] {
  display: none;
}

.controls,
.results-shell {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.controls {
  padding: 16px;
}

.search-row,
.filter-row {
  display: grid;
  grid-template-columns: 2fr 1fr 140px;
  gap: 14px;
  align-items: end;
}

.filter-row {
  grid-template-columns: 1fr 1fr;
  margin-top: 14px;
}

.class-help {
  margin-top: 12px;
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

.class-help summary {
  cursor: pointer;
  color: var(--ink);
  font-weight: 700;
}

.class-help-intro {
  max-width: 980px;
  margin: 8px 0 12px;
  color: var(--muted);
  font-size: 13px;
}

.class-help-intro strong {
  color: var(--ink);
}

.class-card-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.class-card {
  min-height: 74px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 13px;
  padding: 10px 12px;
}

.class-card span {
  display: block;
  margin-bottom: 4px;
  color: var(--ink);
  font-weight: 800;
}

.class-card-full {
  background: var(--accent-soft);
}

.class-card-counterexamples {
  background: var(--warning-soft);
}

.class-card-literature_implied_answers,
.class-card-literature_already_answered {
  background: var(--blue-soft);
}

.class-card-partial,
.class-card-conditional {
  background: var(--violet-soft);
}

.field {
  display: grid;
  gap: 6px;
}

.field > span,
.field > label,
.toggle span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.author-combobox,
.filter-select {
  position: relative;
}

.author-options,
.filter-select-options {
  position: absolute;
  z-index: 20;
  top: calc(100% + 6px);
  right: 0;
  left: 0;
  max-height: min(280px, 40vh);
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  box-shadow: 0 12px 28px rgb(31 38 36 / 14%);
  padding: 4px;
}

.author-option,
.filter-select-option {
  display: flex;
  width: 100%;
  min-height: 36px;
  align-items: center;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  font: inherit;
  padding: 7px 9px;
  text-align: left;
}

.author-option:hover,
.author-option:focus-visible,
.author-option[aria-selected="true"],
.filter-select-option:hover,
.filter-select-option:focus-visible,
.filter-select-option[aria-selected="true"] {
  background: var(--accent-soft);
}

.author-options-empty {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  padding: 9px;
}

.filter-select-native {
  position: absolute;
  width: 1px;
  min-height: 0;
  height: 1px;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
}

.filter-select-trigger {
  display: flex;
  width: 100%;
  min-height: 40px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  font: inherit;
  padding: 8px 34px 8px 10px;
  position: relative;
  text-align: left;
}

.filter-select-trigger::after {
  position: absolute;
  top: 50%;
  right: 13px;
  width: 7px;
  height: 7px;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  content: "";
  transform: translateY(-70%) rotate(45deg);
}

.filter-select-trigger[aria-expanded="true"]::after {
  transform: translateY(-30%) rotate(225deg);
}

input,
select {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  padding: 8px 10px;
}

input:focus,
select:focus,
button:focus {
  outline: 2px solid #89a9a2;
  outline-offset: 2px;
}

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 8px;
}

.results-shell {
  margin-top: 18px;
  overflow: hidden;
}

.selected-shell {
  margin-top: 0;
}

.selected-intro {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.selected-intro {
  padding: 18px 20px;
}

.selected-intro p:last-child {
  max-width: 920px;
  margin-bottom: 0;
  color: var(--muted);
}

.selected-layout {
  display: grid;
  grid-template-columns: minmax(300px, 380px) minmax(0, 1fr);
  gap: 22px;
  align-items: stretch;
  margin-top: 18px;
}

.selected-proof-list {
  display: grid;
  gap: 10px;
}

.selected-proof-card {
  display: block;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  padding: 14px;
  text-align: left;
}

.selected-proof-card:hover,
.selected-proof-card:focus-visible {
  border-color: var(--line-strong);
  background: #fdfcf9;
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.selected-proof-card.is-active {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: inset 3px 0 0 var(--accent);
}

.selected-proof-kicker {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.selected-proof-title {
  display: block;
  margin-top: 6px;
  font-weight: 800;
  line-height: 1.25;
}

.selected-proof-claim {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
}

.selected-proof-meta {
  display: block;
  margin-top: 10px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
}

.selected-proof-reader {
  display: flex;
  min-width: 0;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  overflow: hidden;
}

.selected-card-doc-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.document-tab {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--muted);
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  font-weight: 800;
  padding: 7px 12px;
}

.document-tab.is-active {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.selected-pdf-frame {
  display: block;
  flex: 1 1 auto;
  width: 100%;
  height: auto;
  min-height: 0;
  border: 0;
  border-radius: 0;
  background: #fff;
}

.selected-empty {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
  color: var(--muted);
  padding: 28px;
  text-align: center;
}

.results-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
  background: #fdfcf9;
}

.results-head p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.table-wrap {
  overflow-x: auto;
}

.results-table {
  width: 100%;
  min-width: 900px;
  border-collapse: collapse;
}

.results-table th,
.results-table td {
  border-bottom: 1px solid var(--line);
  padding: 12px 14px;
  vertical-align: top;
  text-align: left;
}

.results-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f4f1eb;
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.sort-header {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  letter-spacing: inherit;
  padding: 0;
  text-align: left;
  text-transform: inherit;
}

.sort-header::after {
  content: "";
  width: 0;
  height: 0;
  border-right: 4px solid transparent;
  border-left: 4px solid transparent;
  opacity: 0.25;
}

.sort-header[data-direction="asc"]::after {
  border-bottom: 6px solid currentColor;
  opacity: 0.95;
}

.sort-header[data-direction="desc"]::after {
  border-top: 6px solid currentColor;
  opacity: 0.95;
}

.sort-header:not(.is-active)::after {
  border-top: 4px solid currentColor;
  border-bottom: 4px solid currentColor;
}

.result-row {
  cursor: pointer;
}

.results-table tr:hover td {
  background: #fbfaf7;
}

.result-row:focus {
  outline: none;
}

.result-row:focus td {
  background: var(--accent-soft);
}

.result-row:hover .paper-title,
.result-row:focus .paper-title {
  color: var(--accent);
}

.paper-cell {
  min-width: 240px;
  max-width: 330px;
}

.paper-title {
  display: block;
  font-weight: 700;
}

.arxiv-id {
  display: inline-block;
  margin-top: 5px;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
}

.katex {
  font-size: 1.04em;
}

.results-table .katex,
.selected-proof-card .katex {
  font-size: 1em;
}

#detailContent .katex-display,
.markdown-body .katex-display {
  margin: 10px 0;
  overflow-x: auto;
  overflow-y: hidden;
  padding-bottom: 2px;
  text-align: left;
}

#detailContent .katex-display > .katex,
.markdown-body .katex-display > .katex {
  text-align: left;
}

.authors-cell {
  max-width: 230px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px 8px;
  background: #fff;
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.badge-full,
.badge-verified {
  background: var(--accent-soft);
}

.badge-counterexamples,
.badge-warning,
.badge-needs_review {
  background: var(--warning-soft);
}

.badge-rejected {
  background: #f4dddd;
}

.badge-literature_implied_answers,
.badge-literature_already_answered {
  background: var(--blue-soft);
}

.badge-partial,
.badge-conditional {
  background: var(--violet-soft);
}

.badge-unverified,
.badge-superseded,
.badge-reviewed,
.badge-reviewed_packet,
.badge-human_verified,
.badge-selected_proof,
.badge-selected_model_proof {
  background: #ecebea;
}

.empty-state {
  padding: 44px !important;
  color: var(--muted);
  text-align: center !important;
}

.detail-panel {
  position: fixed;
  inset: 0 0 0 auto;
  z-index: 20;
  width: min(680px, 96vw);
  overflow-y: auto;
  border-left: 1px solid var(--line);
  background: var(--surface);
  box-shadow: -18px 0 40px rgba(35, 35, 35, 0.18);
  transform: translateX(100%);
  transition: transform 160ms ease;
}

.detail-panel[aria-hidden="false"] {
  transform: translateX(0);
}

.panel-backdrop {
  position: fixed;
  inset: 0;
  z-index: 10;
  background: rgba(30, 37, 34, 0.22);
}

.close-button {
  position: sticky;
  top: 12px;
  float: right;
  margin: 12px;
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: #fff;
  cursor: pointer;
  font-size: 24px;
  line-height: 1;
}

#detailContent {
  padding: 56px 28px 32px;
}

#detailContent h3 {
  margin-top: 24px;
}

#detailContent p {
  margin: 10px 0;
}

.detail-meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 16px 0;
}

.detail-meta div {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
  padding: 10px;
}

.detail-meta span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.detail-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 18px 0 22px;
}

.detail-action {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
  color: var(--ink);
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  padding: 10px 12px;
  text-decoration: none;
  text-align: left;
}

.detail-action:hover {
  border-color: var(--line-strong);
  background: #fff;
  text-decoration: none;
}

.detail-action:disabled {
  cursor: progress;
  opacity: 0.62;
}

.action-icon {
  flex: none;
  width: 18px;
  height: 18px;
  fill: none;
  stroke: var(--accent);
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.readme-block {
  max-height: 340px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
  color: var(--ink);
  padding: 14px 16px;
}

.markdown-body {
  font-size: 14px;
  line-height: 1.55;
}

.markdown-body h1,
.markdown-body h2,
.markdown-body h3 {
  margin: 16px 0 8px;
  font-family: inherit;
  line-height: 1.25;
}

.markdown-body h1:first-child,
.markdown-body h2:first-child,
.markdown-body h3:first-child,
.markdown-body p:first-child {
  margin-top: 0;
}

.markdown-body h1 {
  font-size: 18px;
}

.markdown-body h2 {
  font-size: 16px;
}

.markdown-body h3 {
  font-size: 15px;
}

.markdown-body p {
  margin: 8px 0;
}

.markdown-body ul {
  margin: 8px 0 8px 20px;
  padding: 0;
}

.markdown-body li + li {
  margin-top: 4px;
}

.markdown-body code {
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fff;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.92em;
  padding: 1px 4px;
}

.markdown-body pre {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  padding: 10px;
}

.markdown-body pre code {
  border: 0;
  background: transparent;
  padding: 0;
}

.crop-grid {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.crop-grid img {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.muted {
  color: var(--muted);
}

.contact-link {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 44px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  padding: 8px 10px;
}

.contact-link:hover {
  color: var(--accent);
  text-decoration: none;
}

.contact-link svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.contact-link:focus-visible {
  border-radius: 4px;
  outline: 2px solid #89a9a2;
  outline-offset: 3px;
}

@media (max-width: 900px) {
  .app-header {
    align-items: flex-start;
    flex-direction: column;
  }

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

  .class-card-grid {
    grid-template-columns: 1fr;
  }

  .selected-layout {
    grid-template-columns: 1fr;
  }

  .selected-pdf-frame {
    flex: none;
    height: 70vh;
    min-height: 460px;
  }

  .results-table {
    min-width: 860px;
  }

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

@media (max-width: 500px) {
  .collection-toolbar {
    gap: 6px;
  }

  .collection-tabs button {
    font-size: 12px;
    padding: 6px 8px;
    white-space: nowrap;
  }

  .paper-link,
  .contact-link {
    width: 34px;
    justify-content: center;
    padding: 8px;
  }

  .paper-link span,
  .contact-link span {
    display: none;
  }
}
