:root {
  color-scheme: light;
  --background: #f7f7f8;
  --surface: #ffffff;
  --surface-soft: #f0f0f2;
  --surface-strong: #e7e7ea;
  --text: #17171a;
  --text-muted: #5c5c65;
  --text-soft: #74747d;
  --border: #d9d9de;
  --border-strong: #b9b9c1;
  --accent: #b51f58;
  --accent-soft: #f9dce7;
  --accent-contrast: #ffffff;
  --success: #17653c;
  --success-soft: #dff3e7;
  --warning: #8a5000;
  --warning-soft: #fff0cf;
  --danger: #a92525;
  --danger-soft: #f9dddd;
  --focus: #2864dc;
  --shadow: 0 12px 36px rgba(28, 24, 31, 0.08);
  --radius: 14px;
  --radius-small: 9px;
  --shell: 1480px;
}

html[data-theme="dark"] {
  color-scheme: dark;
  --background: #151518;
  --surface: #1e1e22;
  --surface-soft: #27272c;
  --surface-strong: #303036;
  --text: #f2f2f4;
  --text-muted: #b8b8c0;
  --text-soft: #96969f;
  --border: #3a3a41;
  --border-strong: #595962;
  --accent: #f0719e;
  --accent-soft: #4b2333;
  --accent-contrast: #201018;
  --success: #85d7a8;
  --success-soft: #183c2a;
  --warning: #f4bd62;
  --warning-soft: #493316;
  --danger: #ff9494;
  --danger-soft: #4d2022;
  --focus: #8bb1ff;
  --shadow: 0 16px 44px rgba(0, 0, 0, 0.26);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--background);
  color: var(--text);
  font-family: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 16px;
  line-height: 1.55;
  text-rendering: optimizeLegibility;
}

button,
input,
select {
  font: inherit;
}

button,
select {
  cursor: pointer;
}

button,
input,
select,
a,
summary {
  -webkit-tap-highlight-color: transparent;
}

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

a {
  color: inherit;
}

.shell {
  width: min(calc(100% - 48px), var(--shell));
  margin-inline: auto;
}

.skip-link {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 100;
  padding: 10px 14px;
  border-radius: var(--radius-small);
  background: var(--text);
  color: var(--background);
  transform: translateY(-160%);
}

.skip-link:focus {
  transform: translateY(0);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  border-bottom: 1px solid color-mix(in srgb, var(--border) 84%, transparent);
  background: color-mix(in srgb, var(--background) 90%, transparent);
  backdrop-filter: blur(16px);
}

.topbar-inner {
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
}

.brand img {
  width: 40px;
  height: 40px;
  border: 1px solid var(--border);
  border-radius: 10px;
}

.brand span {
  display: grid;
  line-height: 1.25;
}

.brand strong {
  font-size: 16px;
  letter-spacing: 0.01em;
}

.brand small {
  margin-top: 3px;
  color: var(--text-muted);
  font-size: 12px;
}

.quiet-button,
.secondary-button,
.primary-button,
.site-tab {
  min-height: 44px;
  border: 1px solid var(--border);
  border-radius: var(--radius-small);
  padding: 9px 15px;
  background: var(--surface);
  color: var(--text);
  font-weight: 650;
  transition: background-color 180ms ease, border-color 180ms ease, color 180ms ease,
    transform 120ms ease;
}

.quiet-button {
  width: 44px;
  min-width: 44px;
  padding: 0;
  display: inline-grid;
  place-items: center;
}

.quiet-button::before {
  content: "☾";
  font-size: 19px;
  line-height: 1;
}

html[data-theme="dark"] .quiet-button::before {
  content: "☀";
}

.quiet-button:hover,
.secondary-button:hover,
.site-tab:hover {
  border-color: var(--border-strong);
  background: var(--surface-soft);
}

.primary-button {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-contrast);
}

.primary-button:hover {
  filter: brightness(1.07);
}

.quiet-button:active,
.secondary-button:active,
.primary-button:active,
.site-tab:active {
  transform: scale(0.98);
}

.intro {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(240px, 340px);
  align-items: end;
  gap: 48px;
  padding: 56px 0 34px;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.14em;
}

.intro h1 {
  max-width: 720px;
  margin: 0;
  font-size: clamp(36px, 5vw, 66px);
  line-height: 1.06;
  letter-spacing: -0.045em;
}

.intro-copy {
  max-width: 670px;
  margin: 18px 0 0;
  color: var(--text-muted);
  font-size: clamp(16px, 2vw, 19px);
}

.freshness {
  padding-left: 20px;
  border-left: 3px solid var(--accent);
  display: grid;
  gap: 4px;
}

.freshness span,
.freshness small {
  color: var(--text-muted);
  font-size: 13px;
}

.freshness strong {
  font-variant-numeric: tabular-nums;
  font-size: 17px;
}

.summary-row {
  display: grid;
  grid-template-columns: minmax(420px, 1.35fr) minmax(420px, 1fr);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
}

.site-strip {
  min-width: 0;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.site-status-item {
  min-width: 0;
  padding: 18px 20px;
}

.site-status-item + .site-status-item {
  border-left: 1px solid var(--border);
}

.metric-grid {
  display: grid;
  min-width: 0;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border-left: 1px solid var(--border);
}

.metric {
  padding: 18px 20px;
}

.metric + .metric {
  border-left: 1px solid var(--border);
}

.site-status-item span,
.site-status-item small,
.metric span,
.metric small {
  display: block;
  color: var(--text-muted);
  font-size: 13px;
}

.site-status-item strong,
.metric strong {
  display: block;
  margin: 4px 0 2px;
  font-size: clamp(26px, 3vw, 38px);
  color: var(--text);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.035em;
}

.workspace,
.results {
  margin-top: 44px;
}

.workspace-heading,
.results-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
}

.workspace-heading h2,
.results-heading h2 {
  margin: 0;
  font-size: 24px;
  letter-spacing: -0.02em;
}

.workspace-heading p,
.results-heading p {
  margin: 6px 0 0;
  color: var(--text-muted);
}

.result-count {
  flex: none;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}

.site-tabs {
  display: flex;
  gap: 8px;
  margin-top: 22px;
  overflow-x: auto;
  padding-bottom: 2px;
  scrollbar-width: thin;
}

.site-tab {
  min-width: 74px;
  flex: 0 0 auto;
}

.site-tab.is-active {
  border-color: var(--text);
  background: var(--text);
  color: var(--background);
}

.filters {
  display: grid;
  grid-template-columns: minmax(240px, 1.7fr) repeat(6, minmax(128px, 1fr)) minmax(116px, 0.7fr);
  gap: 12px;
  margin-top: 14px;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.field {
  min-width: 0;
  display: grid;
  align-content: end;
  gap: 7px;
}

.field label,
.field-label {
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 750;
}

.field input,
.field select {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--border);
  border-radius: var(--radius-small);
  padding: 9px 11px;
  background: var(--background);
  color: var(--text);
}

.field input::placeholder {
  color: var(--text-soft);
  opacity: 1;
}

.field input:hover,
.field select:hover {
  border-color: var(--border-strong);
}

.field-action button {
  width: 100%;
}

.results {
  padding-bottom: 64px;
}

.results-heading {
  margin-bottom: 14px;
}

.loading-state,
.message-state {
  min-height: 260px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 12px;
  padding: 32px;
  text-align: center;
}

.loading-state p,
.message-state p {
  max-width: 520px;
  margin: 0;
  color: var(--text-muted);
}

.message-state strong {
  font-size: 20px;
}

.skeleton {
  width: min(420px, 70vw);
  height: 14px;
  border-radius: 999px;
  background: var(--surface-strong);
  animation: pulse 1.3s ease-in-out infinite alternate;
}

.skeleton-wide {
  width: min(560px, 78vw);
}

.skeleton-mid {
  width: min(300px, 60vw);
}

@keyframes pulse {
  from {
    opacity: 0.5;
  }
  to {
    opacity: 1;
  }
}

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

table {
  width: 100%;
  min-width: 1120px;
  border-collapse: collapse;
  font-size: 14px;
}

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

th {
  z-index: 5;
  background: var(--surface-soft);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.04em;
}

tbody tr:last-child td {
  border-bottom: 0;
}

tbody tr:hover {
  background: color-mix(in srgb, var(--accent-soft) 32%, transparent);
}

.site-badge,
.level-badge,
.rank-badge,
.tag {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border-radius: 999px;
  padding: 3px 9px;
  font-size: 12px;
  font-weight: 750;
}

.site-badge {
  border: 1px solid var(--border-strong);
  background: var(--surface-soft);
}

.level-badge {
  min-width: 30px;
  justify-content: center;
}

.level-S,
.level-A {
  background: var(--success-soft);
  color: var(--success);
}

.level-B {
  background: var(--warning-soft);
  color: var(--warning);
}

.level-C {
  background: var(--danger-soft);
  color: var(--danger);
}

.book-cell {
  min-width: 280px;
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  gap: 12px;
}

.cover {
  width: 48px;
  height: 64px;
  border: 1px solid var(--border);
  border-radius: 7px;
  object-fit: cover;
  background: var(--surface-strong);
}

.cover-fallback {
  display: grid;
  place-items: center;
  color: var(--text-muted);
  font-size: 20px;
  font-weight: 800;
}

.book-link {
  color: var(--text);
  font-size: 15px;
  font-weight: 760;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

.book-link:hover {
  color: var(--accent);
}

.book-meta,
.book-description,
.subtle {
  color: var(--text-muted);
  font-size: 12px;
}

.book-meta {
  margin-top: 3px;
}

.book-description {
  max-width: 42ch;
  margin-top: 7px;
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.tag-list,
.rank-list,
.metric-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag,
.rank-badge {
  background: var(--surface-soft);
  color: var(--text-muted);
  font-weight: 620;
}

.tag-list {
  margin-top: 8px;
}

.metric-item {
  display: grid;
  gap: 1px;
  min-width: 74px;
}

.metric-item span {
  color: var(--text-muted);
  font-size: 11px;
}

.metric-item strong {
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.score-block {
  min-width: 154px;
}

.score-line {
  display: flex;
  align-items: center;
  gap: 8px;
}

.score-value {
  font-size: 24px;
  font-weight: 780;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.04em;
}

.score-strategy {
  display: block;
  margin-top: 3px;
  color: var(--text-muted);
  font-size: 11px;
}

.score-details {
  margin-top: 9px;
}

.score-details summary {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  color: var(--accent);
  cursor: pointer;
  font-size: 12px;
  font-weight: 750;
}

.score-details-content {
  margin-top: 7px;
  padding: 10px;
  border-radius: var(--radius-small);
  background: var(--surface-soft);
}

.source-score-summary {
  margin: 0 0 10px;
  color: var(--text-muted);
  font-size: 13px;
}

.source-score-summary strong {
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.score-component-list {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 12px;
  margin: 0;
  font-size: 12px;
}

.score-component-list dt {
  color: var(--text-muted);
}

.score-component-list dd {
  margin: 0;
  font-variant-numeric: tabular-nums;
  font-weight: 720;
}

.score-notes {
  margin: 9px 0 0;
  padding-left: 18px;
  color: var(--text-muted);
  font-size: 12px;
}

.book-cards {
  display: grid;
  gap: 12px;
}

.book-card {
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.book-card-top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.book-card .book-cell {
  min-width: 0;
  flex: 1;
}

.book-card .score-block {
  flex: none;
  min-width: auto;
  text-align: right;
}

.book-card-section {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.book-card-section > strong {
  display: block;
  margin-bottom: 7px;
  color: var(--text-muted);
  font-size: 12px;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-top: 20px;
}

.pagination span {
  min-width: 124px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.pagination button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.footer {
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.footer-inner {
  min-height: 108px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

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

.is-hidden {
  display: none !important;
}

.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: 1240px) {
  .filters {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .field-search {
    grid-column: span 2;
  }
}

@media (max-width: 899px) {
  .shell {
    width: min(calc(100% - 32px), var(--shell));
  }

  .intro {
    grid-template-columns: 1fr;
    gap: 24px;
    padding-top: 40px;
  }

  .freshness {
    max-width: 420px;
  }

  .summary-row {
    grid-template-columns: 1fr;
  }

  .site-strip {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .metric-grid {
    border-top: 1px solid var(--border);
    border-left: 0;
  }

  .site-status-item {
    padding: 14px 16px;
  }

  .metric-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .metric + .metric {
    border-left: 1px solid var(--border);
  }

  .workspace-heading,
  .results-heading {
    align-items: start;
    flex-direction: column;
    gap: 8px;
  }

  .table-wrap {
    display: none !important;
  }

  .book-cards:not(.is-hidden) {
    display: grid;
  }
}

@media (min-width: 900px) {
  .book-cards {
    display: none !important;
  }
}

@media (max-width: 680px) {
  .shell {
    width: min(calc(100% - 24px), var(--shell));
  }

  .topbar-inner {
    min-height: 64px;
  }

  .brand img {
    width: 36px;
    height: 36px;
  }

  .brand small {
    display: none;
  }

  .intro h1 {
    font-size: clamp(34px, 12vw, 48px);
  }

  .site-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .metric-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .site-status-item + .site-status-item {
    border-left: 0;
  }

  .site-status-item:nth-child(even) {
    border-left: 1px solid var(--border);
  }

  .site-status-item:nth-child(n + 3) {
    border-top: 1px solid var(--border);
  }

  .filters {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    padding: 14px;
  }

  .field-search {
    grid-column: 1 / -1;
  }

  .book-card-top {
    display: grid;
    grid-template-columns: 1fr;
  }

  .book-card .score-block {
    text-align: left;
  }

  .footer-inner {
    align-items: start;
    flex-direction: column;
    justify-content: center;
    padding-block: 26px;
  }
}

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

  .metric + .metric {
    border-top: 1px solid var(--border);
    border-left: 0;
  }

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

  .field-search {
    grid-column: auto;
  }

  .book-cell {
    grid-template-columns: 42px minmax(0, 1fr);
  }

  .cover {
    width: 42px;
    height: 58px;
  }

  .pagination {
    gap: 8px;
  }

  .pagination span {
    min-width: 92px;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
