:root {
  color-scheme: dark;
  --bg: #0b1020;
  --panel: rgba(255, 255, 255, 0.06);
  --panel-2: rgba(255, 255, 255, 0.09);
  --border: rgba(255, 255, 255, 0.14);
  --text: rgba(255, 255, 255, 0.92);
  --muted: rgba(255, 255, 255, 0.68);
  --muted-2: rgba(255, 255, 255, 0.52);
  --link: #7aa2ff;
  --accent: #8b5cf6;
  --accent-2: #22c55e;
  --danger: #fb7185;
  --shadow: rgba(0, 0, 0, 0.35);
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono",
    "Courier New", monospace;
  --sans: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    Roboto, "Noto Sans SC", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei",
    Arial, "Apple Color Emoji", "Segoe UI Emoji";
}

[data-theme="light"] {
  color-scheme: light;
  --bg: #f7f8fc;
  --panel: rgba(17, 24, 39, 0.05);
  --panel-2: rgba(17, 24, 39, 0.08);
  --border: rgba(17, 24, 39, 0.12);
  --text: rgba(17, 24, 39, 0.92);
  --muted: rgba(17, 24, 39, 0.68);
  --muted-2: rgba(17, 24, 39, 0.55);
  --link: #2563eb;
  --shadow: rgba(17, 24, 39, 0.18);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  font-family: var(--sans);
  background-color: var(--bg);
  background-image: radial-gradient(1200px 600px at 20% -10%, rgba(139, 92, 246, 0.35), transparent 60%),
    radial-gradient(900px 500px at 80% 0%, rgba(34, 197, 94, 0.18), transparent 60%);
  background-repeat: no-repeat;
  background-attachment: fixed;
  color: var(--text);
  line-height: 1.55;
}

[data-theme="light"] body {
  background-image: radial-gradient(1200px 600px at 20% -10%, rgba(139, 92, 246, 0.22), transparent 60%),
    radial-gradient(900px 500px at 80% 0%, rgba(34, 197, 94, 0.14), transparent 60%);
}

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

a:hover {
  text-decoration: underline;
}

.container {
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
  padding: 48px 0 80px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.brand {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.brand-title {
  font-weight: 750;
  font-size: 22px;
  letter-spacing: 0.2px;
}

.brand-subtitle {
  color: var(--muted);
  font-size: 13px;
}

.intro-banner {
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.15) 0%, rgba(34, 197, 94, 0.1) 100%);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px 24px;
  margin-bottom: 20px;
}

.intro-text {
  margin: 0;
  font-size: 15px;
  line-height: 1.7;
  color: var(--text);
}

[data-theme="light"] .intro-banner {
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.1) 0%, rgba(34, 197, 94, 0.08) 100%);
}

.toolbar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 9px 12px;
  border-radius: 12px;
  box-shadow: 0 10px 30px var(--shadow);
}

.chip button,
.chip select {
  appearance: none;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  cursor: pointer;
  outline: none;
}

.chip select {
  padding-right: 18px;
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%),
    linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: right 10px top 55%, right 5px top 55%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}

.hero {
  display: grid;
  grid-template-columns: 1.25fr 0.75fr;
  gap: 16px;
  margin-top: 18px;
}

.hero[data-page="index"] {
  grid-template-columns: 1fr;
}

@media (max-width: 940px) {
  .hero {
    grid-template-columns: 1fr;
  }
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: 0 20px 60px var(--shadow);
}

.panel-inner {
  padding: 18px;
}

.panel h2 {
  margin: 0 0 8px;
  font-size: 16px;
  font-weight: 720;
}

.panel p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.searchbar {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-top: 12px;
}

.searchbar input {
  flex: 1;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px 14px;
  color: var(--text);
  font-size: 14px;
  outline: none;
}

.searchbar input::placeholder {
  color: var(--muted-2);
}

.searchbar .btn {
  border: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(139, 92, 246, 0.35), rgba(139, 92, 246, 0.12));
  color: var(--text);
  border-radius: 14px;
  padding: 11px 14px;
  font-size: 14px;
  cursor: pointer;
  font-weight: 650;
}

.searchbar .btn:active {
  transform: translateY(1px);
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}

.filters label {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 10px 12px;
  color: var(--muted);
  font-size: 13px;
}

.filters select {
  border: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  outline: none;
  cursor: pointer;
}

.meta {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 10px;
  color: var(--muted);
  font-size: 12px;
}

.meta code {
  font-family: var(--mono);
  font-size: 11px;
  background: rgba(0, 0, 0, 0.18);
  padding: 2px 6px;
  border-radius: 8px;
  border: 1px solid var(--border);
}

[data-theme="light"] .meta code {
  background: rgba(17, 24, 39, 0.06);
}

.table-wrap {
  margin-top: 14px;
  overflow: auto;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.12);
}

[data-theme="light"] .table-wrap {
  background: rgba(17, 24, 39, 0.03);
}

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

thead th {
  position: sticky;
  top: 0;
  background: rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(12px);
  text-align: left;
  font-size: 12px;
  color: var(--muted);
  padding: 10px 10px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  z-index: 2;
}

[data-theme="light"] thead th {
  background: rgba(255, 255, 255, 0.75);
}

.th-wrap {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.info {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.12);
  color: var(--muted-2);
  font-size: 11px;
  font-weight: 750;
  line-height: 1;
  user-select: none;
  cursor: help;
}

[data-theme="light"] .info {
  background: rgba(17, 24, 39, 0.03);
}

.info:hover {
  background: var(--panel-2);
  color: var(--text);
}

.info:focus {
  outline: 2px solid var(--link);
  outline-offset: 2px;
}

.tooltip {
  position: fixed;
  z-index: 9999;
  left: 0;
  top: 0;
  max-width: min(520px, calc(100vw - 24px));
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(17, 24, 39, 0.94);
  color: var(--text);
  font-size: 12px;
  line-height: 1.45;
  box-shadow: 0 20px 60px var(--shadow);
  backdrop-filter: blur(12px);
  pointer-events: none;
  white-space: normal;
}

[data-theme="light"] .tooltip {
  background: rgba(255, 255, 255, 0.94);
}

tbody td {
  padding: 10px 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  vertical-align: top;
  font-size: 13px;
}

[data-theme="light"] tbody td {
  border-bottom: 1px solid rgba(17, 24, 39, 0.08);
}

tbody tr {
  transition: background 0.15s ease;
}

tbody tr:hover td {
  background: rgba(139, 92, 246, 0.12);
}

tbody tr:hover td:first-child {
  box-shadow: inset 3px 0 0 var(--accent);
}

.food-name {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 320px;
}

.food-name .primary,
.food-name .zh {
  font-weight: 700;
}

.food-name .secondary,
.food-name .en {
  color: var(--muted);
  font-size: 12px;
}

.pill {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.16);
  color: var(--muted);
  font-size: 12px;
  font-family: var(--mono);
}

[data-theme="light"] .pill {
  background: rgba(17, 24, 39, 0.06);
}

.score {
  font-family: var(--mono);
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 4px;
}

.score-high {
  background: rgba(139, 92, 246, 0.25);
  color: #a78bfa;
}

.score-mid {
  background: rgba(99, 102, 241, 0.2);
  color: #818cf8;
}

.score-low {
  background: rgba(96, 165, 250, 0.15);
  color: #93c5fd;
}

.score-poor {
  background: rgba(148, 163, 184, 0.15);
  color: var(--muted);
}

[data-theme="light"] .score-high {
  background: rgba(139, 92, 246, 0.15);
  color: #7c3aed;
}

[data-theme="light"] .score-mid {
  background: rgba(99, 102, 241, 0.12);
  color: #4f46e5;
}

[data-theme="light"] .score-low {
  background: rgba(59, 130, 246, 0.1);
  color: #2563eb;
}

[data-theme="light"] .score-poor {
  background: rgba(100, 116, 139, 0.1);
  color: #64748b;
}

.delta.pos {
  color: var(--accent-2);
  font-weight: 700;
}

.delta.neg {
  color: var(--danger);
  font-weight: 700;
}

.pagination {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  margin-top: 12px;
  color: var(--muted);
  font-size: 12px;
}

.pagination .btn {
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  border-radius: 12px;
  padding: 8px 10px;
  cursor: pointer;
  font-weight: 650;
}

.pagination .btn[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
}

.to-top {
  position: fixed;
  right: 18px;
  bottom: 18px;
  width: 44px;
  height: 44px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  box-shadow: 0 20px 60px var(--shadow);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 850;
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
  transition:
    opacity 160ms ease,
    transform 160ms ease,
    background 160ms ease;
  z-index: 50;
}

.to-top.show {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.to-top:active {
  transform: translateY(1px);
}

.modal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(0, 0, 0, 0.6);
  z-index: 999;
}

.modal[aria-hidden="false"] {
  display: flex;
}

.modal-card {
  width: min(860px, 100%);
  max-height: min(78vh, 720px);
  overflow: auto;
  background: rgba(10, 14, 28, 0.96);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: 0 30px 100px rgba(0, 0, 0, 0.55);
}

[data-theme="light"] .modal-card {
  background: rgba(255, 255, 255, 0.96);
}

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 16px 10px;
  border-bottom: 1px solid var(--border);
}

.modal-title {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.modal-title h3 {
  margin: 0;
  font-size: 16px;
}

.modal-title .sub {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.modal-close {
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  border-radius: 12px;
  padding: 8px 10px;
  cursor: pointer;
  font-weight: 700;
}

.modal-body {
  padding: 12px 16px 18px;
  color: var(--muted);
  font-size: 14px;
}

.kv {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 10px 14px;
  margin-top: 10px;
}

@media (max-width: 620px) {
  .kv {
    grid-template-columns: 1fr;
  }
}

.kv .k {
  color: var(--muted-2);
  font-family: var(--mono);
  font-size: 12px;
}

.kv .v {
  color: var(--text);
}

.section {
  margin-top: 44px;
}

.section h2 {
  font-size: 18px;
  margin: 0 0 10px;
}

.paper {
  background: rgba(0, 0, 0, 0.12);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 18px;
}

[data-theme="light"] .paper {
  background: rgba(17, 24, 39, 0.03);
}

.paper h3 {
  margin: 18px 0 8px;
  font-size: 15px;
}

.paper p {
  margin: 8px 0;
  color: var(--text);
}

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

.figure {
  margin: 14px 0 16px;
}

.figure img {
  width: 100%;
  height: auto;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.15);
}

.figure figcaption {
  margin-top: 10px;
  color: var(--muted);
  font-size: 13px;
}

.footer {
  margin-top: 60px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 12px;
}

.footer code {
  font-family: var(--mono);
  font-size: 11px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Skeleton loading */
.skeleton-row td {
  padding: 16px 12px;
}

.skeleton {
  height: 18px;
  background: linear-gradient(90deg, var(--panel) 25%, var(--panel-2) 50%, var(--panel) 75%);
  background-size: 200% 100%;
  border-radius: 4px;
  animation: skeleton-shimmer 1.5s infinite;
}

@keyframes skeleton-shimmer {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}
