:root {
  color-scheme: light;
  --paper: #f7f5ef;
  --ink: #282720;
  --muted: #747067;
  --line: rgba(40, 39, 32, 0.14);
  --wash: #ebe7dc;
  --white: #fffdf8;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans SC", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-width: 320px;
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(255,255,255,0.68), rgba(247,245,239,0.86)),
    var(--paper);
}

a {
  color: inherit;
  text-decoration: none;
  -webkit-tap-highlight-color: rgba(40, 39, 32, 0.08);
}

.site {
  width: min(1100px, 100%);
  min-height: 100svh;
  margin: 0 auto;
  padding: max(22px, env(safe-area-inset-top)) 18px max(34px, env(safe-area-inset-bottom));
}

.logo {
  display: flex;
  width: 376px;
  height: 376px;
  margin: 0 auto 23px;
  align-items: center;
  justify-content: center;
}

.logo img {
  display: block;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.category-list {
  display: grid;
  gap: 14px;
  width: min(560px, 100%);
  margin: 0 auto;
}

.category-link {
  display: flex;
  min-height: 72px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.72);
  box-shadow: 0 10px 30px rgba(51, 47, 38, 0.05);
  font-size: clamp(20px, 5.2vw, 30px);
  line-height: 1.25;
  text-align: center;
}

.category-link:active,
.back:active {
  transform: translateY(1px);
}

.category-head {
  display: grid;
  grid-template-columns: 44px 1fr 44px;
  align-items: center;
  gap: 8px;
  margin: 0 auto 22px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 14px;
}

.category-head h1 {
  min-width: 0;
  margin: 0;
  font-size: clamp(21px, 5.4vw, 34px);
  font-weight: 500;
  line-height: 1.22;
  text-align: center;
  overflow-wrap: anywhere;
}

.back {
  display: flex;
  width: 44px;
  height: 44px;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-size: 36px;
  line-height: 1;
}

.book-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
  gap: 20px 16px;
}

.book-card {
  position: relative;
  min-width: 0;
}

.cover-button {
  display: block;
  overflow: hidden;
  width: 100%;
  aspect-ratio: 0.707 / 1;
  padding: 0;
  border: 1px solid rgba(40, 39, 32, 0.12);
  border-radius: 6px;
  background: var(--wash);
  box-shadow: 0 16px 38px rgba(48, 43, 34, 0.12);
  cursor: pointer;
  touch-action: manipulation;
}

.cover-button:focus-visible {
  outline: 2px solid rgba(40, 39, 32, 0.42);
  outline-offset: 3px;
}

.cover {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.book-card h2 {
  min-height: 1.5em;
  margin: 14px 0 8px;
  font-size: 20px;
  font-weight: 500;
  line-height: 1.5;
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.doc-menu {
  position: absolute;
  z-index: 10;
  right: 10px;
  bottom: 44px;
  display: grid;
  min-width: 132px;
  overflow: hidden;
  border: 1px solid rgba(40, 39, 32, 0.12);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.96);
  box-shadow: 0 18px 42px rgba(48, 43, 34, 0.18);
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity 150ms ease, transform 150ms ease;
  backdrop-filter: blur(10px);
}

.book-card.is-menu-open .doc-menu {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.doc-menu a {
  display: flex;
  min-height: 46px;
  padding: 0 22px;
  align-items: center;
  justify-content: center;
  border-bottom: 1px solid rgba(40, 39, 32, 0.08);
  font-size: 15px;
  letter-spacing: 0.04em;
}

.doc-menu a:last-child {
  border-bottom: 0;
}

.doc-menu a:active {
  background: rgba(235, 231, 220, 0.82);
}

@media (max-width: 520px) {
  .site {
    padding-right: 14px;
    padding-left: 14px;
  }

  .logo {
    width: min(304px, 76vw);
    height: min(304px, 76vw);
    margin-bottom: 17px;
  }

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

  .book-card h2 {
    font-size: 18px;
  }
}
