:root {
  color-scheme: light;
  --ink: #24211f;
  --muted: #8d8782;
  --line: #eee9e5;
  --surface: #ffffff;
  --surface-soft: #faf8f6;
  --accent: #ff6b3d;
  --accent-dark: #e94e25;
  --accent-soft: #fff0e9;
  --shadow: 0 18px 60px rgb(65 38 24 / 9%);
  --container: 1180px;
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--surface);
  -webkit-font-smoothing: antialiased;
}

button,
input {
  font: inherit;
}

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

button {
  color: inherit;
}

a {
  color: inherit;
  text-decoration: none;
}

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

.skip-link {
  position: fixed;
  z-index: 100;
  left: 16px;
  top: -60px;
  padding: 10px 16px;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  transition: top 0.2s;
}

.skip-link:focus {
  top: 12px;
}

.site-header {
  position: sticky;
  z-index: 20;
  top: 0;
  border-bottom: 1px solid rgb(38 31 27 / 4%);
  background: rgb(250 248 246 / 92%);
  backdrop-filter: blur(18px);
}

.header-inner {
  width: min(var(--container), calc(100% - 40px));
  height: 78px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 34px;
}

.brand {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: Georgia, "Songti SC", serif;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.brand b {
  color: var(--accent);
  font-weight: inherit;
}

.brand-mark {
  width: 35px;
  height: 35px;
  display: grid;
  place-items: center;
  border-radius: 11px;
  background: linear-gradient(145deg, #ff8953, #ff5436);
  box-shadow: 0 8px 18px rgb(255 95 50 / 23%);
}

.brand-mark svg {
  width: 29px;
  fill: #fff;
}

.brand-mark-line {
  fill: none;
  stroke: #ff6840;
  stroke-width: 2;
}

.main-nav {
  display: flex;
  align-items: center;
  gap: 30px;
  margin-left: auto;
  font-size: 14px;
}

.main-nav a {
  position: relative;
  padding: 28px 0;
  white-space: nowrap;
}

.main-nav a::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 18px;
  width: 0;
  height: 2px;
  border-radius: 10px;
  background: var(--accent);
  transform: translateX(-50%);
  transition: width 0.2s;
}

.main-nav a:hover,
.main-nav a.active {
  color: var(--accent-dark);
}

.main-nav a.active::after,
.main-nav a:hover::after {
  width: 18px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.search-box {
  width: 220px;
  height: 40px;
  display: flex;
  align-items: center;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: #fff;
  box-shadow: 0 4px 18px rgb(48 35 28 / 4%);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.search-box:focus-within {
  border-color: #ffb49a;
  box-shadow: 0 0 0 4px rgb(255 107 61 / 10%);
}

.search-box input {
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  font-size: 13px;
}

.search-box input::placeholder {
  color: #bbb5b1;
}

.search-box svg {
  width: 18px;
  fill: none;
  stroke: #99918c;
  stroke-width: 1.8;
  stroke-linecap: round;
}

.text-action,
.signup-button,
.menu-toggle {
  border: 0;
  background: transparent;
  cursor: pointer;
}

.text-action {
  padding: 8px 4px;
  font-size: 13px;
}

.signup-button {
  padding: 9px 16px;
  border: 1px solid #ffbda7;
  border-radius: 999px;
  color: var(--accent-dark);
  background: #fff;
  font-size: 13px;
}

.menu-toggle {
  display: none;
}

main {
  min-height: 70vh;
}

.library-shell {
  width: min(var(--container), calc(100% - 40px));
  margin: 0 auto;
  padding: 60px 0 76px;
}

.section-heading {
  display: flex;
  justify-content: space-between;
  align-items: end;
  padding: 0 0 34px;
}

.section-heading .eyebrow {
  margin: 0 0 10px;
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 2.4px;
}

.section-heading h1 {
  margin: 0;
  font-family: Georgia, "Songti SC", serif;
  font-size: clamp(27px, 3vw, 38px);
  font-weight: 600;
  letter-spacing: -1px;
}

.section-heading > p {
  max-width: 320px;
  margin: 0 0 5px;
  color: var(--muted);
  font-size: 14px;
  text-align: right;
}

.filter-panel {
  position: relative;
  padding: 25px 30px;
  overflow: hidden;
  border: 1px solid #f0ebe8;
  border-radius: 18px;
  background: linear-gradient(115deg, #fff 0%, #fff 70%, #fff9f5 100%);
  box-shadow: 0 14px 45px rgb(53 34 24 / 5%);
}

.filter-panel::after {
  content: "";
  position: absolute;
  right: -70px;
  top: -85px;
  width: 190px;
  height: 190px;
  border: 1px solid rgb(255 107 61 / 12%);
  border-radius: 50%;
}

.filter-row {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 70px 1fr;
  align-items: start;
  min-height: 42px;
}

.filter-label {
  padding: 8px 0;
  color: #a39d98;
  font-size: 13px;
}

.filter-options {
  display: flex;
  flex-wrap: wrap;
  gap: 5px 23px;
}

.filter-options button {
  padding: 7px 10px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  cursor: pointer;
  font-size: 13px;
  transition: color 0.2s, background 0.2s, transform 0.2s;
}

.filter-options button:hover {
  color: var(--accent-dark);
  transform: translateY(-1px);
}

.filter-options button.selected {
  color: var(--accent-dark);
  background: var(--accent-soft);
}

.results-section {
  padding-top: 42px;
}

.sort-bar {
  min-height: 47px;
  display: flex;
  align-items: start;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
}

.sort-tabs {
  display: flex;
  gap: 32px;
}

.sort-tabs button {
  position: relative;
  padding: 0 0 16px;
  border: 0;
  background: transparent;
  cursor: pointer;
  font-size: 14px;
}

.sort-tabs button::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 2px;
  border-radius: 8px;
  background: var(--accent);
  opacity: 0;
  transform: scaleX(0.3);
  transition: opacity 0.2s, transform 0.2s;
}

.sort-tabs button.selected {
  color: var(--accent-dark);
  font-weight: 600;
}

.sort-tabs button.selected::after {
  opacity: 1;
  transform: scaleX(1);
}

#result-count {
  margin: 2px 0 0;
  color: #aaa39e;
  font-size: 12px;
}

.book-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 38px 40px;
  padding: 40px 0 28px;
  outline: 0;
}

.book-card {
  min-width: 0;
  display: grid;
  grid-template-columns: 106px minmax(0, 1fr);
  gap: 19px;
  align-items: center;
  cursor: pointer;
}

.book-cover {
  position: relative;
  width: 106px;
  aspect-ratio: 3 / 4;
  overflow: hidden;
  border-radius: 7px;
  color: #fff;
  background: var(--cover, linear-gradient(145deg, #667eea, #764ba2));
  box-shadow: 0 12px 25px rgb(37 29 25 / 15%);
  transition: transform 0.25s, box-shadow 0.25s;
}

.book-card:hover .book-cover {
  transform: translateY(-4px);
  box-shadow: 0 17px 30px rgb(37 29 25 / 20%);
}

.book-cover::before,
.book-cover::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  background: rgb(255 255 255 / 14%);
}

.book-cover::before {
  width: 120px;
  height: 120px;
  right: -58px;
  top: -43px;
}

.book-cover::after {
  width: 62px;
  height: 62px;
  left: -28px;
  bottom: 15px;
  border: 1px solid rgb(255 255 255 / 20%);
  background: transparent;
}

.cover-number {
  position: absolute;
  top: 10px;
  left: 11px;
  color: rgb(255 255 255 / 60%);
  font-family: Georgia, serif;
  font-size: 10px;
  letter-spacing: 1px;
}

.cover-title {
  position: absolute;
  z-index: 1;
  inset: auto 11px 16px;
  font-family: Georgia, "Songti SC", serif;
  font-size: 16px;
  font-weight: 700;
  line-height: 1.45;
  text-shadow: 0 2px 8px rgb(0 0 0 / 22%);
}

.book-info {
  min-width: 0;
}

.book-title {
  display: block;
  width: 100%;
  padding: 0;
  overflow: hidden;
  border: 0;
  background: transparent;
  cursor: pointer;
  font-size: 17px;
  font-weight: 600;
  line-height: 1.5;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.book-meta,
.book-stats,
.book-update {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.book-description {
  display: -webkit-box;
  margin: 7px 0 0;
  overflow: hidden;
  color: #6f6965;
  font-size: 12px;
  line-height: 1.65;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.book-update {
  color: #aaa39e;
}

.empty-state {
  padding: 86px 20px;
  color: var(--muted);
  text-align: center;
}

.empty-state > span {
  display: block;
  color: #ffc0a9;
  font-size: 52px;
  transform: rotate(-20deg);
}

.empty-state h3 {
  margin: 6px 0;
  color: var(--ink);
  font-size: 18px;
}

.empty-state p {
  margin: 0 0 18px;
  font-size: 13px;
}

.empty-state button {
  padding: 9px 18px;
  border: 0;
  border-radius: 999px;
  color: #fff;
  background: var(--accent);
  cursor: pointer;
}

.pagination {
  display: flex;
  justify-content: center;
  gap: 8px;
  padding-top: 24px;
}

.pagination button {
  min-width: 36px;
  height: 36px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
}

.pagination button:hover:not(:disabled),
.pagination button.active {
  border-color: var(--accent);
  color: #fff;
  background: var(--accent);
}

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

.quick-tools {
  position: fixed;
  z-index: 12;
  right: 20px;
  bottom: 80px;
  display: grid;
  overflow: hidden;
  border: 1px solid #eeeae7;
  border-radius: 12px;
  background: rgb(255 255 255 / 94%);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.quick-tools button {
  width: 61px;
  min-height: 61px;
  display: grid;
  place-items: center;
  gap: 2px;
  padding: 8px 4px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  cursor: pointer;
  font-size: 10px;
}

.quick-tools button:last-child {
  border-bottom: 0;
}

.quick-tools button:hover {
  color: var(--accent-dark);
  background: var(--accent-soft);
}

.quick-tools svg {
  width: 21px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.site-footer {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 24px 50px;
  padding: 46px max(32px, calc((100% - var(--container)) / 2));
  color: #968f8a;
  background: #292624;
  font-size: 12px;
}

.footer-brand {
  color: #fff;
  font-family: Georgia, "Songti SC", serif;
  font-size: 19px;
  font-weight: 700;
}

.site-footer p {
  margin: 9px 0 0;
}

.footer-links {
  display: flex;
  align-items: start;
  gap: 24px;
  color: #d0cbc8;
}

.footer-links a:hover {
  color: #fff;
}

.copyright {
  grid-column: 1 / -1;
  padding-top: 20px;
  border-top: 1px solid rgb(255 255 255 / 8%);
}

.book-dialog {
  width: min(560px, calc(100% - 32px));
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: 20px;
  box-shadow: 0 28px 90px rgb(0 0 0 / 24%);
}

.book-dialog::backdrop {
  background: rgb(24 18 15 / 42%);
  backdrop-filter: blur(4px);
}

.dialog-close {
  position: absolute;
  z-index: 2;
  top: 14px;
  right: 14px;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 50%;
  background: rgb(255 255 255 / 83%);
  cursor: pointer;
  font-size: 22px;
}

.dialog-layout {
  display: grid;
  grid-template-columns: 170px 1fr;
  gap: 28px;
  padding: 42px;
  background: linear-gradient(130deg, #fff9f5, #fff);
}

.dialog-cover {
  min-height: 226px;
  display: grid;
  place-items: end start;
  padding: 22px;
  border-radius: 12px;
  color: #fff;
  background: var(--cover);
  box-shadow: 0 18px 35px rgb(40 27 21 / 18%);
  font-family: Georgia, "Songti SC", serif;
  font-size: 24px;
  font-weight: 700;
  line-height: 1.4;
}

.dialog-details h2 {
  margin: 4px 0 8px;
  font-family: Georgia, "Songti SC", serif;
  font-size: 25px;
}

.dialog-details p {
  color: #746d68;
  font-size: 13px;
  line-height: 1.8;
}

.dialog-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin: 16px 0;
}

.dialog-tags span {
  padding: 5px 9px;
  border-radius: 999px;
  color: var(--accent-dark);
  background: var(--accent-soft);
  font-size: 11px;
}

.read-button {
  padding: 10px 20px;
  border: 0;
  border-radius: 999px;
  color: #fff;
  background: linear-gradient(135deg, #ff8051, #f34c2d);
  box-shadow: 0 8px 20px rgb(255 91 48 / 23%);
  cursor: pointer;
}

.toast {
  position: fixed;
  z-index: 50;
  left: 50%;
  bottom: 30px;
  max-width: calc(100% - 32px);
  padding: 11px 18px;
  border-radius: 999px;
  color: #fff;
  background: rgb(37 33 30 / 92%);
  box-shadow: 0 10px 32px rgb(0 0 0 / 20%);
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 12px);
  transition: opacity 0.2s, transform 0.2s;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

@media (max-width: 1120px) {
  .header-inner {
    gap: 22px;
  }

  .main-nav {
    gap: 20px;
  }

  .main-nav a:nth-last-child(-n + 2) {
    display: none;
  }

  .search-box {
    width: 190px;
  }

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

@media (max-width: 780px) {
  .header-inner {
    width: calc(100% - 30px);
    height: 64px;
    justify-content: space-between;
  }

  .menu-toggle {
    width: 36px;
    height: 36px;
    display: grid;
    place-content: center;
    gap: 4px;
    padding: 0;
  }

  .menu-toggle span {
    width: 19px;
    height: 1.5px;
    border-radius: 2px;
    background: var(--ink);
    transition: transform 0.2s, opacity 0.2s;
  }

  .menu-toggle[aria-expanded="true"] span:first-child {
    transform: translateY(5.5px) rotate(45deg);
  }

  .menu-toggle[aria-expanded="true"] span:nth-child(2) {
    opacity: 0;
  }

  .menu-toggle[aria-expanded="true"] span:last-child {
    transform: translateY(-5.5px) rotate(-45deg);
  }

  .brand {
    font-size: 17px;
  }

  .brand-mark {
    width: 31px;
    height: 31px;
  }

  .header-actions {
    gap: 4px;
  }

  .search-box {
    width: 38px;
    padding: 0 10px;
    box-shadow: none;
    background: transparent;
  }

  .search-box:focus-within {
    position: absolute;
    z-index: 4;
    left: 12px;
    right: 12px;
    width: auto;
    background: #fff;
  }

  .search-box input {
    width: 0;
  }

  .search-box:focus-within input {
    width: 100%;
  }

  .text-action,
  .signup-button {
    display: none;
  }

  .main-nav {
    position: absolute;
    left: 15px;
    right: 15px;
    top: 70px;
    display: none;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: #fff;
    box-shadow: var(--shadow);
  }

  .main-nav.open {
    display: flex;
  }

  .main-nav a,
  .main-nav a:nth-last-child(-n + 2) {
    display: block;
    padding: 12px 14px;
    border-radius: 9px;
  }

  .main-nav a::after {
    display: none;
  }

  .main-nav a.active {
    background: var(--accent-soft);
  }

  .library-shell {
    width: calc(100% - 30px);
    padding: 35px 0 55px;
  }

  .section-heading {
    display: block;
    padding-bottom: 24px;
  }

  .section-heading > p {
    margin-top: 10px;
    text-align: left;
  }

  .filter-panel {
    padding: 19px 17px;
    border-radius: 14px;
  }

  .filter-row {
    grid-template-columns: 48px 1fr;
  }

  .filter-options {
    flex-wrap: nowrap;
    gap: 3px;
    padding-bottom: 6px;
    overflow-x: auto;
    scrollbar-width: none;
  }

  .filter-options::-webkit-scrollbar {
    display: none;
  }

  .filter-options button {
    flex: 0 0 auto;
  }

  .results-section {
    padding-top: 30px;
  }

  .book-grid {
    grid-template-columns: 1fr;
    gap: 27px;
    padding-top: 28px;
  }

  .book-card {
    grid-template-columns: 94px minmax(0, 1fr);
    gap: 16px;
  }

  .book-cover {
    width: 94px;
  }

  .quick-tools {
    right: 12px;
    bottom: 18px;
  }

  .quick-tools button:not(#back-to-top) {
    display: none;
  }

  .quick-tools button {
    width: 45px;
    min-height: 45px;
  }

  .quick-tools span {
    display: none;
  }

  .site-footer {
    grid-template-columns: 1fr;
    padding: 38px 22px;
  }

  .footer-links {
    flex-wrap: wrap;
    gap: 13px 20px;
  }

  .copyright {
    grid-column: auto;
  }

  .dialog-layout {
    grid-template-columns: 110px 1fr;
    gap: 20px;
    padding: 42px 24px 30px;
  }

  .dialog-cover {
    min-height: 150px;
    padding: 14px;
    font-size: 18px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}

