:root {
  color-scheme: light dark;
  --bg: #f4f1ea;
  --surface: #fffdf8;
  --surface-strong: #ffffff;
  --text: #20231f;
  --muted: #6a6e67;
  --line: #dcd8cf;
  --accent: #17765a;
  --accent-soft: #dcece5;
  --shadow: 0 12px 34px rgb(45 48 42 / 10%);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, "Noto Sans SC", "Microsoft YaHei", system-ui, sans-serif;
  line-height: 1.5;
}

.hero {
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.hero__inner,
footer {
  width: min(1180px, calc(100% - 32px));
  margin-inline: auto;
}

.page {
  width: min(1180px, calc(100% - 32px));
  margin-inline: auto;
}

.hero__inner { padding: 64px 0 52px; }

.eyebrow {
  margin: 0 0 14px;
  color: var(--accent);
  font-size: .75rem;
  font-weight: 800;
  letter-spacing: .18em;
}

h1 {
  margin: 0;
  font-family: Georgia, "Noto Serif SC", "Songti SC", serif;
  font-size: clamp(2.2rem, 6vw, 4.8rem);
  font-weight: 700;
  letter-spacing: -.035em;
  line-height: 1.06;
}

.intro {
  max-width: 650px;
  margin: 20px 0;
  color: var(--muted);
  font-size: 1.05rem;
}

.formula {
  display: inline-block;
  padding: 9px 14px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--accent-soft);
  font-family: "Cascadia Code", Consolas, monospace;
  font-size: .9rem;
}

.formula span { color: var(--accent); font-weight: 700; }

.page { padding: 30px 0 48px; }

.workspace {
  display: grid;
  grid-template-columns: minmax(290px, 340px) minmax(0, 1fr);
  align-items: start;
  gap: 24px;
}

.ranking-panel {
  min-width: 0;
  font-size: .9rem;
}

.catalog {
  position: relative;
  overflow: clip;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-strong);
  box-shadow: var(--shadow);
  font-size: .86rem;
}

.section-tabs,
.value-buttons {
  display: flex;
  gap: 8px;
}

.section-tabs {
  position: sticky;
  z-index: 3;
  top: 18px;
  gap: 0;
  padding: 0 8px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.category-tabs {
  padding: 8px 0;
}

.category-item + .category-item {
  border-top: 1px solid color-mix(in srgb, var(--line) 65%, transparent);
}

.accordion-values {
  padding: 6px 10px 10px;
  background: color-mix(in srgb, var(--accent-soft) 20%, var(--surface));
}
.value-group + .value-group { margin-top: 12px; }
.value-group__title {
  margin: 5px 8px 4px;
  color: var(--muted);
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: .04em;
}

.value-buttons {
  flex-direction: column;
  gap: 2px;
}

.section-button,
.category-button,
.value-button {
  min-height: 36px;
  border-color: transparent;
  background: transparent;
  font-size: .82rem;
}

.section-button {
  flex: 1;
  min-height: 52px;
  border: 0;
  border-bottom: 3px solid transparent;
  border-radius: 0;
  padding-inline: 6px;
  font-size: .9rem;
  font-weight: 700;
  white-space: nowrap;
}

.category-button {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  border: 0;
  border-radius: 0;
  padding-inline: 14px;
  text-align: left;
  font-size: .86rem;
  font-weight: 600;
}
.category-button::after {
  content: "›";
  color: var(--muted);
  font-size: 1rem;
  transform: rotate(0deg);
  transition: transform .15s ease;
}
.category-button[aria-expanded="true"]::after { transform: rotate(90deg); }
.value-button {
  display: flex;
  width: 100%;
  min-width: 0;
  align-items: center;
  justify-content: space-between;
  gap: 7px;
  min-height: 34px;
  padding: 5px 9px 5px 18px;
  border-color: transparent;
  background: transparent;
  text-align: left;
  font-size: .8rem;
  font-weight: 400;
}
.button-label { min-width: 0; }
.value-button.is-truncated .button-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.value-button small {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: .68rem;
  font-weight: 500;
}
.section-button.is-active {
  border-bottom-color: var(--accent);
  color: var(--accent);
}
.category-button.is-active {
  background: color-mix(in srgb, var(--accent-soft) 45%, transparent);
  color: var(--accent);
  font-weight: 650;
}
.value-button.is-active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}
.selection {
  margin: 13px 12px 16px;
  color: var(--muted);
  font-size: .82rem;
}

.toolbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 18px;
}

.status { margin: 0; font-size: .94rem; font-weight: 650; }
.updated { margin: 4px 0 0; color: var(--muted); font-size: .76rem; }
.controls { display: flex; align-items: center; gap: 10px; }

input,
select,
button {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-strong);
  color: var(--text);
  font: inherit;
}

input { width: min(310px, 48vw); padding: 0 13px; }
select { padding: 0 9px; }
button { padding: 0 15px; cursor: pointer; font-weight: 700; }
button:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
button:disabled { cursor: not-allowed; opacity: .45; }
input:focus-visible, select:focus-visible, button:focus-visible, a:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent) 30%, transparent);
  outline-offset: 2px;
}

.page-size { display: flex; align-items: center; gap: 7px; color: var(--muted); white-space: nowrap; }

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-strong);
  box-shadow: var(--shadow);
}

table { width: 100%; border-collapse: collapse; font-size: .88rem; font-variant-numeric: tabular-nums; }
th, td { padding: 14px 16px; border-bottom: 1px solid var(--line); text-align: left; }
th { background: var(--surface); color: var(--muted); font-size: .76rem; letter-spacing: .05em; text-transform: uppercase; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr[data-url] { cursor: pointer; }
tbody tr[data-url]:hover { background: color-mix(in srgb, var(--accent-soft) 48%, transparent); }
tbody tr[data-url]:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: -3px;
  background: color-mix(in srgb, var(--accent-soft) 48%, transparent);
}
.rank { width: 74px; color: var(--muted); }
.number { text-align: right; white-space: nowrap; }
.title { min-width: 240px; font-weight: 550; }
.id { color: var(--muted); font-family: "Cascadia Code", Consolas, monospace; font-size: .85rem; }
.rating { color: var(--accent); font-weight: 800; }
.message { padding: 48px 16px; color: var(--muted); text-align: center; }

.pagination {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 22px;
}
.page-jump-label,
.page-total { color: var(--muted); white-space: nowrap; }
.page-number {
  width: 78px;
  padding-inline: 10px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

footer {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  padding: 28px 0 42px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: .84rem;
}
footer p { margin: 0; }
footer a { color: var(--accent); }

.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;
}

@media (max-width: 720px) {
  .hero__inner { padding: 44px 0 38px; }
  .page { width: min(100% - 20px, 1180px); }
  .section-tabs { padding-inline: 8px; }
  .section-button { flex: 1; padding-inline: 8px; font-size: .9rem; }
  .category-tabs { padding-block: 6px; }
  .toolbar { align-items: stretch; flex-direction: column; }
  .controls { align-items: stretch; }
  .search { flex: 1; }
  input { width: 100%; }
  th, td { padding: 12px; }
  footer { flex-direction: column; }
}

@media (max-width: 960px) {
  .workspace { grid-template-columns: minmax(0, 1fr); }
  .catalog {
    margin-bottom: 28px;
  }
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #171a17;
    --surface: #1d211e;
    --surface-strong: #232824;
    --text: #edf1ec;
    --muted: #a9b0a8;
    --line: #3b423c;
    --accent: #72d3ad;
    --accent-soft: #223d33;
    --shadow: none;
  }
}
