:root {
  color-scheme: light;
  --bg: #f4f2ed;
  --surface: #fbfaf7;
  --surface-strong: #ffffff;
  --ink: #1d1d1f;
  --muted: #6e6b66;
  --line: #dedbd4;
  --line-strong: #c9c4ba;
  --accent: #8a2f2a;
  --accent-soft: #f3e8e5;
  --gold: #9b7a43;
  --focus: #2563eb;
  --max-width: 1540px;
  --ease-out: cubic-bezier(.16, 1, .3, 1);
  --spring: cubic-bezier(.2, .85, .24, 1);
}

* { box-sizing: border-box; }

html { background: var(--bg); }

body {
  margin: 0;
  color: var(--ink);
  background: var(--bg);
  font-family: "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  letter-spacing: 0;
}

button, input, select { font: inherit; letter-spacing: 0; }

a { color: inherit; }

button:focus-visible,
input:focus-visible,
select:focus-visible,
a:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--focus) 34%, transparent);
  outline-offset: 2px;
}

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

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  min-height: 62px;
  padding: 0 max(24px, calc((100vw - var(--max-width)) / 2));
  display: flex;
  align-items: center;
  gap: 14px;
  border-bottom: 1px solid rgba(125, 119, 108, 0.18);
  background: rgba(250, 249, 246, 0.9);
  backdrop-filter: blur(18px);
}

.brand {
  color: #161616;
  font-family: "Songti SC", "SimSun", serif;
  font-size: 22px;
  font-weight: 700;
  text-decoration: none;
}

.sample-label {
  padding-left: 14px;
  border-left: 1px solid var(--line-strong);
  color: var(--muted);
  font-size: 13px;
}

.home-link {
  margin-left: auto;
  color: #4c4944;
  font-size: 14px;
  text-decoration: none;
}

.catalog-app {
  width: min(var(--max-width), calc(100% - 48px));
  margin: 0 auto;
  padding: 40px 0 70px;
}

.category-panel {
  padding: 20px 0 24px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.panel-heading {
  padding: 0 0 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.panel-heading span {
  color: #3d3934;
  font-family: "Songti SC", "SimSun", serif;
  font-size: 20px;
  font-weight: 650;
}

.panel-heading strong {
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

.category-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.category-button {
  position: relative;
  width: auto;
  min-height: 34px;
  padding: 0 11px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #47433e;
  border: 1px solid var(--line);
  border-radius: 9px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, .94), rgba(255, 255, 255, .72)),
    var(--surface-strong);
  box-shadow: 0 8px 22px rgba(62, 50, 37, 0.045);
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  overflow: hidden;
  transform: translateY(0) scale(1);
  transition:
    transform 180ms var(--ease-out),
    box-shadow 180ms var(--ease-out),
    border-color 180ms var(--ease-out),
    background 180ms var(--ease-out);
}

.category-button::after {
  content: "";
  position: absolute;
  inset: auto 16% 0 16%;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(138, 47, 42, .62), transparent);
  opacity: 0;
  transform: scaleX(.45);
  transition: opacity 180ms var(--ease-out), transform 180ms var(--ease-out);
}

@media (hover: hover) and (pointer: fine) {
  .category-button:hover {
    transform: translateY(-2px);
    border-color: rgba(138, 47, 42, .24);
    box-shadow: 0 18px 44px rgba(61, 47, 34, .13), inset 0 1px 0 rgba(255, 255, 255, .84);
  }

  .category-button:hover::after {
    opacity: 1;
    transform: scaleX(1);
  }
}

.category-button.is-active {
  color: #fff;
  background: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 10px 24px rgba(112, 35, 31, 0.18);
}

.category-button.is-active::after {
  background: linear-gradient(90deg, transparent, rgba(232, 196, 128, .78), transparent);
}

.category-title {
  font-family: "Songti SC", "SimSun", serif;
  font-size: 15px;
  line-height: 1;
  font-weight: 650;
  white-space: nowrap;
}

.catalog-content { min-width: 0; }

.catalog-heading {
  min-height: 128px;
  padding-bottom: 26px;
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 32px;
  border-bottom: 1px solid var(--line);
}

.catalog-heading > div:first-child { min-width: 0; }

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
}

h1 {
  margin: 0;
  font-family: "Songti SC", "SimSun", serif;
  font-size: 44px;
  line-height: 1.15;
  font-weight: 650;
  letter-spacing: 0;
}

.section-summary {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 14px;
  overflow-wrap: anywhere;
}

.scope-switch {
  max-width: 100%;
  padding: 4px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.7);
}

.scope-button {
  min-width: 0;
  min-height: 36px;
  padding: 0 13px;
  color: #5e5a54;
  border: 0;
  border-radius: 6px;
  background: transparent;
  cursor: pointer;
  white-space: nowrap;
}

.scope-button.is-active {
  color: var(--ink);
  background: var(--surface-strong);
  box-shadow: 0 1px 4px rgba(38, 31, 24, 0.12);
}

.toolbar {
  padding: 22px 0 18px;
  display: grid;
  grid-template-columns: minmax(260px, 1fr) 112px;
  gap: 10px;
}

.toolbar > * { min-width: 0; }

.search-field input,
.select-field select {
  width: 100%;
  height: 46px;
  color: var(--ink);
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: var(--surface-strong);
}

.search-field input { padding: 0 15px; font-size: 15px; }

.select-field { position: relative; }

.select-field span {
  position: absolute;
  left: 11px;
  top: 7px;
  z-index: 1;
  color: var(--muted);
  font-size: 10px;
  pointer-events: none;
}

.select-field select {
  padding: 15px 28px 1px 10px;
  font-size: 13px;
}

.result-bar {
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  color: var(--muted);
  font-size: 13px;
}

.result-bar p { margin: 0; }

.clear-button {
  padding: 6px 0;
  color: var(--accent);
  border: 0;
  background: transparent;
  cursor: pointer;
}

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

.book-row {
  min-width: 0;
  min-height: 116px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, .94), rgba(255, 255, 255, .74)),
    var(--surface-strong);
  box-shadow: 0 8px 22px rgba(62, 50, 37, 0.045);
  overflow: hidden;
  transform: translateY(0) scale(1);
  transition:
    transform 180ms var(--ease-out),
    box-shadow 180ms var(--ease-out),
    border-color 180ms var(--ease-out);
}

.book-link {
  height: 100%;
  min-height: 116px;
  padding: 12px 15px 13px;
  display: flex;
  flex-direction: column;
  text-decoration: none;
}

@media (hover: hover) and (pointer: fine) {
  .book-row:hover {
    transform: translateY(-2px);
    border-color: rgba(138, 47, 42, .22);
    box-shadow: 0 17px 40px rgba(61, 47, 34, .12), inset 0 1px 0 rgba(255, 255, 255, .84);
  }
}

.book-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.book-number {
  color: var(--accent);
  font-family: ui-monospace, "Cascadia Mono", monospace;
  font-size: 12px;
  font-weight: 700;
}

.book-main {
  min-width: 0;
  margin-top: 8px;
}

.book-title,
.book-credit {
  display: block;
  overflow: hidden;
}

.book-title {
  display: -webkit-box;
  font-family: "Songti SC", "SimSun", serif;
  font-size: 18px;
  line-height: 1.34;
  font-weight: 650;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.book-credit {
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.book-meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  min-width: 0;
}

.source-badge,
.scope-badge {
  color: #65605a;
  font-size: 10px;
  white-space: nowrap;
}

.source-badge { color: var(--gold); font-weight: 700; }
.scope-badge { color: var(--muted); }

.pagination {
  min-height: 76px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
}

.pagination button {
  min-width: 76px;
  height: 36px;
  color: var(--ink);
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: var(--surface-strong);
  cursor: pointer;
}

.pagination button:disabled { opacity: 0.38; cursor: default; }
.pagination span { color: var(--muted); font-size: 13px; }

.empty-state {
  grid-column: 1 / -1;
  padding: 70px 20px;
  color: var(--muted);
  text-align: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
}

@media (max-width: 1120px) {
  .toolbar { grid-template-columns: minmax(260px, 1fr) 110px; }
}

@media (max-width: 760px) {
  .topbar { padding: 0 16px; }
  .sample-label { display: none; }
  .catalog-app { width: min(100% - 28px, var(--max-width)); padding-top: 24px; }
  .catalog-heading { min-height: 0; align-items: stretch; flex-direction: column; gap: 20px; }
  h1 { font-size: 36px; }
  .scope-switch { align-self: stretch; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .scope-switch { width: 100%; }
  .scope-button { padding: 0 6px; font-size: 12px; }
  .toolbar { grid-template-columns: minmax(0, 1fr); }
  .search-field { grid-column: 1; }
  .page-size-field { grid-column: 1; width: 106px; justify-self: end; }
  .category-nav { gap: 6px; }
  .category-button { min-height: 34px; padding: 0 10px; }
  .category-title { font-size: 15px; }
  .book-grid { grid-template-columns: 1fr; }
  .book-row,
  .book-link { min-height: 118px; }
  .book-credit {
    color: #514b44;
    font-size: 14px;
    line-height: 1.55;
    white-space: normal;
    text-overflow: clip;
    overflow-wrap: anywhere;
  }
  .result-bar { align-items: flex-start; flex-wrap: wrap; gap: 8px; padding: 4px 0; }
  .pagination { min-height: 64px; gap: 8px; }
  .pagination button {
    width: 44px;
    min-width: 44px;
    height: 42px;
    padding: 0;
    flex: 0 0 44px;
    font-size: 0;
  }
  .pagination [data-prev]::before,
  .pagination [data-next]::before { display: block; font-size: 22px; line-height: 1; }
  .pagination [data-prev]::before { content: "\2190"; }
  .pagination [data-next]::before { content: "\2192"; }
  .pagination span { min-width: 74px; text-align: center; white-space: nowrap; }
}

@media (max-width: 430px) {
  .page-size-field { width: 102px; }
  .category-nav { gap: 6px; }
  .category-button { min-height: 32px; padding: 0 9px; }
  .category-title { font-size: 14px; }
  .book-title { font-size: 17px; }
  .book-meta { gap: 6px; }
  .scope-badge { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .category-button,
  .category-button::after,
  .book-row {
    transition-duration: .001ms !important;
  }
}

@media (prefers-reduced-transparency: reduce) {
  .topbar,
  .scope-switch { background: var(--surface); backdrop-filter: none; }
}

@media (prefers-contrast: more) {
  :root { --muted: #4d4943; --line: #999188; --line-strong: #736c63; }
}
