:root {
  --bg: #f5efe4;
  --bg-accent: #e8dac3;
  --surface: rgba(255, 252, 246, 0.84);
  --surface-strong: #fffaf1;
  --surface-muted: #f0e3ce;
  --text: #1d241c;
  --text-muted: #566052;
  --line: rgba(29, 36, 28, 0.14);
  --line-strong: rgba(29, 36, 28, 0.24);
  --brand: #8f3d2e;
  --brand-soft: #c16f4c;
  --chip: #e6efe2;
  --chip-active: #d9b66e;
  --shadow: 0 18px 44px rgba(70, 47, 22, 0.12);
  --radius-lg: 26px;
  --radius-md: 18px;
  --radius-sm: 12px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "IBM Plex Sans", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(193, 111, 76, 0.18), transparent 24rem),
    radial-gradient(circle at bottom right, rgba(143, 61, 46, 0.14), transparent 20rem),
    linear-gradient(180deg, #f8f2e8 0%, var(--bg) 100%);
}

.page-shell {
  width: min(1500px, calc(100vw - 32px));
  margin: 24px auto 32px;
}

.hero {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  padding: 28px 30px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: linear-gradient(135deg, rgba(255, 250, 241, 0.96), rgba(232, 218, 195, 0.88));
  box-shadow: var(--shadow);
}

.eyebrow {
  margin: 0 0 8px;
  font-size: 0.82rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--brand);
}

h1,
h2,
h3 {
  margin: 0;
  font-family: "IBM Plex Serif", serif;
  font-weight: 600;
}

h1 {
  font-size: clamp(2rem, 3vw, 3.5rem);
  line-height: 1;
}

.hero-copy,
.results-subheading,
.field-hint,
.meta-text {
  color: var(--text-muted);
}

.hero-copy {
  margin: 14px 0 0;
  max-width: 62ch;
  line-height: 1.55;
}

.hero-stats {
  min-width: 230px;
  display: grid;
  gap: 12px;
}

.stat-card,
.panel-card {
  border: 1px solid var(--line);
  background: var(--surface);
  backdrop-filter: blur(12px);
  box-shadow: var(--shadow);
}

.stat-card {
  border-radius: var(--radius-md);
  padding: 16px 18px;
}

.stat-label {
  margin: 0 0 6px;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

.stat-value {
  margin: 0;
  font-size: 1.7rem;
  font-weight: 600;
}

.results-panel {
  display: grid;
  gap: 20px;
  align-content: start;
  margin-top: 20px;
}

.panel-card {
  border-radius: var(--radius-md);
  padding: 18px;
}

.field-label {
  display: block;
  margin-bottom: 10px;
  font-weight: 600;
}

.text-input {
  width: 100%;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong);
  background: rgba(255, 255, 255, 0.8);
  color: var(--text);
  font: inherit;
}

.text-input:focus {
  outline: 2px solid rgba(143, 61, 46, 0.25);
  border-color: var(--brand);
}

.field-hint {
  margin: 10px 0 0;
  font-size: 0.9rem;
}

.search-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  align-items: start;
}

.search-controls {
  display: grid;
  gap: 12px;
  justify-items: start;
}

.clear-search-button {
  align-self: center;
}

.select-input {
  min-width: 240px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong);
  background: rgba(255, 255, 255, 0.8);
  color: var(--text);
  font: inherit;
}

.select-input:focus {
  outline: 2px solid rgba(143, 61, 46, 0.25);
  border-color: var(--brand);
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.secondary-button {
  border: 1px solid var(--line-strong);
  background: transparent;
  color: var(--text);
  border-radius: 999px;
  padding: 8px 12px;
  cursor: pointer;
  font: inherit;
}

.filter-options {
  display: grid;
  gap: 8px;
  max-height: 260px;
  overflow: auto;
  padding-right: 4px;
}

.checkbox-row {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.5);
  cursor: pointer;
}

.checkbox-row input {
  margin-top: 3px;
}

.checkbox-copy {
  display: grid;
  gap: 2px;
}

.checkbox-title-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.checkbox-title {
  font-weight: 600;
}

.checkbox-meta {
  font-size: 0.88rem;
}

.definition-trigger {
  width: 18px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: var(--surface-strong);
  color: var(--brand);
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1;
  padding: 0;
  cursor: help;
}

.definition-tooltip {
  position: fixed;
  z-index: 50;
  width: max-content;
  padding: 10px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: var(--surface-strong);
  color: var(--text-muted);
  box-shadow: 0 16px 32px rgba(70, 47, 22, 0.18);
  font-size: 0.85rem;
  line-height: 1.45;
  pointer-events: none;
  overflow-wrap: anywhere;
}

.tag-search {
  margin: 12px 0 14px;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  border: 0;
  border-radius: 999px;
  background: var(--chip);
  color: var(--text);
  padding: 8px 12px;
  font: inherit;
}

.chip.active {
  background: var(--chip-active);
}

.chip button {
  all: unset;
  cursor: pointer;
  margin-left: 8px;
  font-weight: 700;
}

.results-toolbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: end;
}

.table-card {
  padding: 0;
  overflow: hidden;
}

.table-wrap {
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 1100px;
}

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

thead th {
  position: sticky;
  top: 0;
  background: var(--surface-strong);
  z-index: 1;
  font-size: 0.84rem;
}

.sort-trigger {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.74);
  color: var(--text);
  cursor: pointer;
  font: inherit;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.sort-label {
  font-size: 0.84rem;
}

.sort-indicator {
  color: var(--brand);
  font-size: 0.95rem;
  line-height: 1;
}

tbody tr {
  cursor: pointer;
  transition: background 160ms ease;
}

tbody tr:hover {
  background: rgba(232, 218, 195, 0.46);
}

.paper-title {
  font-weight: 600;
  margin-bottom: 6px;
}

.paper-link {
  color: inherit;
  text-decoration: none;
}

.paper-link:hover {
  text-decoration: underline;
}

.badge-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: flex-start;
}

.badge {
  display: inline-flex;
  align-items: flex-start;
  padding: 5px 8px;
  border-radius: 999px;
  background: var(--surface-muted);
  font-size: 0.83rem;
  line-height: 1.2;
  max-width: 100%;
  white-space: normal;
  overflow-wrap: anywhere;
}

.filter-dropdown {
  position: relative;
}

.filter-dropdown[open] .filter-trigger {
  border-color: var(--brand);
  background: rgba(193, 111, 76, 0.12);
}

.filter-trigger {
  list-style: none;
  display: grid;
  gap: 2px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.74);
}

.filter-trigger::-webkit-details-marker {
  display: none;
}

.filter-trigger-label {
  display: block;
  font-size: 0.84rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.filter-trigger-meta {
  color: var(--text-muted);
  font-size: 0.82rem;
  text-transform: none;
  letter-spacing: normal;
}

.filter-menu {
  position: absolute;
  top: calc(100% + 10px);
  left: 0;
  width: min(360px, 42vw);
  max-height: 70vh;
  overflow: auto;
  padding: 14px;
  border-radius: 18px;
  border: 1px solid var(--line-strong);
  background: var(--surface-strong);
  box-shadow: 0 24px 48px rgba(70, 47, 22, 0.18);
  z-index: 5;
}

.filter-menu-content {
  display: grid;
  gap: 14px;
}

.menu-mode {
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
}

.filter-mode-select {
  min-width: 0;
  width: 100%;
}

.filter-menu-group + .filter-menu-group {
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.menu-label {
  margin: 0 0 10px;
  font-size: 0.77rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.dropdown-search {
  margin-bottom: 12px;
}

.empty-state {
  text-align: center;
  padding: 48px 20px;
}

.empty-state strong,
.empty-state span {
  display: block;
}

.empty-state span {
  margin-top: 8px;
  color: var(--text-muted);
}

@media (max-width: 1100px) {
  .hero {
    flex-direction: column;
  }

  .hero-stats {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  }

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

  .search-controls {
    justify-items: stretch;
  }

  .select-input {
    min-width: 0;
    width: 100%;
  }
}

@media (max-width: 640px) {
  .page-shell {
    width: min(100vw - 20px, 100%);
    margin-top: 10px;
  }

  .hero,
  .panel-card {
    padding: 16px;
  }

  th,
  td {
    padding: 12px;
  }

  .filter-menu {
    width: min(82vw, 360px);
  }
}
