body[data-desk="books"] .books-scroll {
  flex: 1;
  min-width: 0;
  min-height: 0;
  overflow: auto;
}

body[data-desk="books"] #viz-zoom {
  min-height: 100%;
}

.shelf {
  padding: 28px 28px 72px;
}

.shelf-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 28px 18px;
}
.book-tile {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  min-width: 0;
}
.book-tile .book-card { width: 100%; }

.book-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 14px;
  margin: 0;
  padding: 6px;
  border: 0;
  border-radius: 16px;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.book-card:hover,
.book-card:focus-visible {
  background: var(--wash);
  outline: none;
}

.book-cover {
  width: 168px;
  height: 236px;
  border-radius: 3px 10px 10px 3px;
  box-shadow: 10px 16px 28px var(--shadow);
  color: #f7f2ea;
  display: flex;
  align-items: flex-end;
  padding: 18px 16px 18px 26px;
  background-color: var(--cloth, #6b5344);
  background-image:
    linear-gradient(90deg, rgba(0, 0, 0, 0.38), rgba(0, 0, 0, 0.38) 13px, rgba(255, 255, 255, 0.2) 13px, rgba(255, 255, 255, 0.2) 15px, transparent 15px),
    linear-gradient(180deg, transparent 42%, rgba(0, 0, 0, 0.42));
}

.book-cover strong {
  position: relative;
  font-family: "Iowan Old Style", Palatino, Georgia, serif;
  font-size: 26px;
  font-weight: 500;
  letter-spacing: -0.03em;
  line-height: 1.05;
}

.book-card h3 {
  margin: 0;
  font-family: "Iowan Old Style", Palatino, Georgia, serif;
  font-size: 22px;
  font-weight: 500;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.book-card p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

body[data-need-app="1"][data-wheel="fog"] .book-card h3,
body[data-need-app="1"][data-wheel="fog"] .leaf-heading h2 {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", sans-serif;
  font-weight: 600;
}

.reader {
  display: flex;
  height: calc(100vh - 84px);
  min-height: calc(100vh - 84px);
}

.reader[hidden],
#shelf[hidden],
#leaf-canvas[hidden],
#leaf-img[hidden],
#leaf-note[hidden],
#shelf-empty[hidden] {
  display: none;
}

.toc {
  width: min(300px, 34vw);
  flex: none;
  overflow: auto;
  padding: 12px 10px 28px;
  border-right: 1px solid var(--line);
  background: var(--sheet);
}

.toc button {
  display: block;
  width: 100%;
  margin: 0 0 2px;
  padding: 8px 10px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: inherit;
  font: inherit;
  font-size: 14px;
  line-height: 1.35;
  text-align: left;
  cursor: pointer;
}

.toc button:hover,
.toc button:focus-visible,
.toc button[aria-current="true"] {
  background: var(--wash);
  outline: none;
}

.leaf {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: var(--paper);
}

.leaf-bar {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-shrink: 0;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
}

.leaf-heading {
  min-width: 0;
  flex: 1;
}

.leaf-heading h2 {
  margin: 0;
  font-family: "Iowan Old Style", Palatino, Georgia, serif;
  font-size: 20px;
  font-weight: 500;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.leaf-heading p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.3;
}

.pager {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.leaf-bar button {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--field);
  color: var(--ink);
  border-radius: 999px;
  padding: 6px 12px;
  font: inherit;
  font-size: 14px;
  cursor: pointer;
}

.leaf-bar button:hover,
.leaf-bar button:focus-visible {
  background: var(--wash);
  outline: none;
}

.leaf-bar button:disabled {
  opacity: 0.4;
  cursor: default;
}

#page-label {
  min-width: 9rem;
  text-align: center;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}

.leaf-frame {
  flex: 1;
  min-height: 0;
  display: grid;
  place-items: center;
  overflow: auto;
  padding: 16px;
}

.leaf-frame canvas,
.leaf-frame img {
  max-width: 100%;
  background: #fff;
  box-shadow: 0 12px 32px var(--shadow);
}

.leaf-frame img {
  width: auto;
  height: auto;
  max-height: calc(100vh - 150px);
  object-fit: contain;
}

.notice-page {
  max-width: 38rem;
  margin: 0;
  padding: 36px 12px;
  font-family: "Iowan Old Style", Palatino, Georgia, serif;
  font-size: 26px;
  line-height: 1.4;
}

@media (max-width: 800px) {
  .reader {
    flex-direction: column;
    height: auto;
    min-height: calc(100vh - 84px);
  }

  .toc {
    width: auto;
    max-height: 34vh;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .leaf-frame {
    min-height: 72vh;
  }

  .leaf-bar {
    flex-wrap: wrap;
  }

  .pager {
    width: 100%;
    justify-content: space-between;
  }
}

@media (prefers-reduced-motion: reduce) {
  .book-cover { transition: none; }
}
