:root {
  --ink: #23302f;
  --ink-soft: #53615f;
  --paper: #f5efe4;
  --paper-light: #fbf7ef;
  --surface: rgba(255, 252, 246, 0.78);
  --surface-strong: rgba(255, 253, 249, 0.94);
  --line: rgba(50, 69, 65, 0.18);
  --line-strong: rgba(50, 69, 65, 0.32);
  --accent: #8a5a38;
  --sage: #6d8278;
  --shadow-soft: 0 14px 40px rgba(63, 48, 32, 0.055);
  --shadow-hover: 0 20px 48px rgba(63, 48, 32, 0.085);
  --serif: "Songti SC", "STSong", "Noto Serif CJK SC", "Source Han Serif SC", Georgia, serif;
  --sans: "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--paper);
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 78% 12%, rgba(226, 183, 125, 0.22), transparent 24rem),
    radial-gradient(circle at 10% 84%, rgba(109, 130, 120, 0.14), transparent 28rem),
    linear-gradient(180deg, var(--paper-light) 0%, #f4eee3 58%, #f2ebdf 100%);
  background-attachment: fixed;
  font-family: var(--sans);
  text-rendering: optimizeLegibility;
}

body::before {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  content: "";
  opacity: 0.45;
  background-image:
    linear-gradient(rgba(81, 65, 48, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(81, 65, 48, 0.025) 1px, transparent 1px);
  background-size: 36px 36px;
  mask-image: linear-gradient(to bottom, black, transparent 82%);
  -webkit-mask-image: linear-gradient(to bottom, black, transparent 82%);
}

body::after {
  position: fixed;
  inset: clamp(16px, 2.6vw, 32px);
  z-index: 2;
  pointer-events: none;
  content: "";
  border: 1px solid rgba(138, 90, 56, 0.1);
}

a {
  color: inherit;
}

button,
input {
  font: inherit;
}

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

.site-title {
  position: relative;
  display: flex;
  justify-content: center;
  padding: clamp(36px, 4vw, 46px) 24px 0;
}

.site-title h1 {
  margin: 0;
  font: 500 clamp(22px, 3vw, 28px)/1.2 var(--serif);
  letter-spacing: 0.16em;
}

.site-title h1::after {
  display: block;
  width: 52px;
  height: 1px;
  margin: 18px auto 0;
  content: "";
  background: linear-gradient(90deg, transparent, var(--accent) 23%, var(--accent) 77%, transparent);
}

.language-toggle {
  position: absolute;
  top: 35px;
  right: max(24px, calc((100vw - 1120px) / 2));
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 48px;
  height: 30px;
  padding: 0 10px;
  color: var(--ink-soft);
  font: 600 12px/1 var(--sans);
  letter-spacing: 0.06em;
  background: rgba(255, 252, 246, 0.7);
  border: 1px solid var(--line);
  border-radius: 999px;
  box-shadow: 0 4px 14px rgba(63, 48, 32, 0.025);
  cursor: pointer;
  transition: color 160ms ease, background-color 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}

.language-toggle:hover {
  color: var(--ink);
  background: var(--surface-strong);
  border-color: var(--line-strong);
  box-shadow: 0 6px 18px rgba(63, 48, 32, 0.055);
}

.language-toggle:focus-visible {
  outline: 3px solid rgba(138, 90, 56, 0.22);
  outline-offset: 3px;
}

.home-main {
  position: relative;
  width: min(800px, calc(100% - 40px));
  margin: 0 auto;
  padding: clamp(96px, 16vh, 170px) 0 108px;
}

.welcome {
  max-width: 680px;
  margin: 0 auto 56px;
  font: 400 clamp(29px, 5vw, 44px)/1.45 var(--serif);
  letter-spacing: 0.035em;
  text-align: center;
  text-wrap: balance;
}

.title-search {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
  height: 62px;
  margin-bottom: 28px;
  background: linear-gradient(135deg, rgba(255, 253, 249, 0.86), rgba(255, 250, 242, 0.66));
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.7),
    var(--shadow-soft);
  transition: border-color 160ms ease, box-shadow 160ms ease, background-color 160ms ease;
}

.title-search:focus-within {
  background: var(--surface-strong);
  border-color: rgba(138, 90, 56, 0.34);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.8),
    0 18px 44px rgba(63, 48, 32, 0.075);
}

.search-icon {
  position: absolute;
  left: 22px;
  width: 20px;
  height: 20px;
  color: var(--sage);
  pointer-events: none;
}

.title-search input {
  width: 100%;
  height: 100%;
  padding: 0 22px 0 55px;
  color: var(--ink);
  font-size: 16px;
  background: transparent;
  border: 0;
  border-radius: inherit;
  outline: none;
  appearance: none;
}

.title-search input::-webkit-search-cancel-button {
  opacity: 0.48;
}

.library-list {
  display: grid;
  margin: 0;
  padding: 0;
  gap: 14px;
  list-style: none;
}

.library-list li[hidden] {
  display: none;
}

.library-item {
  position: relative;
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) 34px;
  align-items: center;
  min-height: 96px;
  padding: 19px 21px;
  gap: 19px;
  overflow: hidden;
  color: var(--ink);
  text-decoration: none;
  background: linear-gradient(112deg, rgba(255, 253, 249, 0.84), rgba(255, 250, 243, 0.68));
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.65),
    0 6px 22px rgba(63, 48, 32, 0.025);
  transition: background-color 170ms ease, border-color 170ms ease, transform 170ms ease, box-shadow 170ms ease;
}

.library-item::before {
  position: absolute;
  inset: 16px auto 16px 0;
  width: 3px;
  content: "";
  background: linear-gradient(180deg, rgba(138, 90, 56, 0.15), var(--accent), rgba(109, 130, 120, 0.4));
  border-radius: 0 3px 3px 0;
  opacity: 0;
  transform: scaleY(0.55);
  transition: opacity 170ms ease, transform 170ms ease;
}

.library-item:hover {
  background: var(--surface-strong);
  border-color: rgba(138, 90, 56, 0.34);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.8),
    var(--shadow-hover);
  transform: translateY(-3px);
}

.library-item:hover::before {
  opacity: 1;
  transform: scaleY(1);
}

.library-item:active {
  transform: translateY(-1px);
}

.library-item:focus-visible {
  outline: 3px solid rgba(138, 90, 56, 0.23);
  outline-offset: 3px;
}

.book-mark {
  position: relative;
  z-index: 1;
  display: grid;
  width: 48px;
  height: 48px;
  place-items: center;
  color: var(--accent);
  background: linear-gradient(145deg, rgba(138, 90, 56, 0.1), rgba(109, 130, 120, 0.055));
  border: 1px solid rgba(138, 90, 56, 0.13);
  border-radius: 13px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.5);
  transition: background-color 170ms ease, transform 170ms ease;
}

.book-mark svg {
  width: 27px;
  height: 27px;
}

.library-item:hover .book-mark {
  background-color: rgba(255, 253, 249, 0.72);
  transform: rotate(-2deg) translateY(-1px);
}

.book-title {
  display: block;
  font: 500 clamp(18px, 2.4vw, 22px)/1.45 var(--serif);
  letter-spacing: 0.005em;
  overflow-wrap: anywhere;
}

.book-details {
  position: relative;
  z-index: 1;
  min-width: 0;
}

.book-meta {
  display: flex;
  flex-wrap: wrap;
  margin-top: 9px;
  gap: 5px 20px;
  color: var(--ink-soft);
  font: 12px/1.55 var(--sans);
}

.book-meta strong {
  color: var(--ink);
}

.book-meta span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.item-arrow {
  position: relative;
  z-index: 1;
  width: 34px;
  height: 34px;
  padding: 8px;
  color: var(--sage);
  background: rgba(109, 130, 120, 0.055);
  border: 1px solid rgba(109, 130, 120, 0.12);
  border-radius: 50%;
  transition: color 170ms ease, background-color 170ms ease, border-color 170ms ease, transform 170ms ease;
}

.library-item:hover .item-arrow {
  color: var(--accent);
  background: rgba(138, 90, 56, 0.07);
  border-color: rgba(138, 90, 56, 0.16);
  transform: translateX(3px);
}

@media (max-width: 560px) {
  body {
    background-attachment: scroll;
  }

  .site-title {
    padding-top: 30px;
  }

  .site-title h1 {
    font-size: 21px;
  }

  .language-toggle {
    top: 24px;
    right: 16px;
  }

  .home-main {
    width: calc(100% - 32px);
    padding: 78px 0 70px;
  }

  .welcome {
    margin-bottom: 40px;
    font-size: clamp(27px, 8.5vw, 36px);
    line-height: 1.5;
  }

  .title-search {
    height: 56px;
    border-radius: 12px;
  }

  .library-item {
    grid-template-columns: 42px minmax(0, 1fr) 30px;
    min-height: 84px;
    padding: 15px;
    gap: 13px;
  }

  .book-mark {
    width: 42px;
    height: 42px;
  }

  .book-title {
    font-size: 17px;
  }

  .item-arrow {
    width: 30px;
    height: 30px;
    padding: 7px;
  }
}

@media (max-width: 639px) {
  body::after {
    display: none;
  }
}

@media (max-width: 430px) {
  .welcome {
    font-size: clamp(24px, 6.8vw, 29px);
    letter-spacing: 0.025em;
  }
}

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