/* ---- Library grid ---- */
.lib-wrap { padding-top: 32px; }
.lib-title { text-align: center; }

.lib-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 18px;
  margin-top: 28px;
}
@media (min-width: 560px) {
  .lib-grid { grid-template-columns: repeat(3, 1fr); }
}

.lib-banner-placeholder {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 110px;
  border: 1.5px dashed var(--card-border);
  border-radius: 14px;
  background: var(--card);
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  text-align: center;
}

.lib-card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 14px;
  overflow: hidden;
  cursor: pointer;
  transition: border-color .15s ease, transform .15s ease, box-shadow .15s ease;
}
.lib-card:hover {
  border-color: #3a4070;
  transform: translateY(-2px);
  box-shadow: 0 12px 24px -8px rgba(0, 0, 0, .4);
}
.lib-cover { position: relative; width: 100%; aspect-ratio: 3/4; background: #000; }
.lib-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.lib-cover::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(0,0,0,0) 55%, rgba(0,0,0,.75) 100%);
}
.lib-read-pill {
  position: absolute;
  left: 10px;
  bottom: 10px;
  right: 10px;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(28, 202, 91, .92);
  color: #ffffff;
  font-weight: 700;
  font-size: 12px;
  padding: 6px 10px;
  border-radius: 999px;
  justify-content: center;
}
.lib-stack-card { cursor: default; }
.lib-stack-card:hover {
  border-color: var(--card-border);
  transform: none;
  box-shadow: none;
}
.lib-stack-cover { background: transparent; overflow: visible; }
.lib-stack-cover::after { content: none; }
.lib-stack-layer {
  position: absolute;
  inset: 0;
  border-radius: 12px;
  border: 1px solid var(--card-border);
  background: var(--card);
}
.lib-stack-layer-3 { transform: rotate(-7deg) translate(-6%, 4%); opacity: .5; }
.lib-stack-layer-2 { transform: rotate(5deg) translate(5%, -3%); opacity: .8; }
.lib-stack-layer-1 {
  background: linear-gradient(160deg, var(--card) 0%, rgba(28, 202, 91, .16) 100%);
  border-color: rgba(28, 202, 91, .45);
  display: flex;
  align-items: center;
  justify-content: center;
}
.lib-stack-count {
  font-size: 1.8rem;
  font-weight: 900;
  color: var(--green);
}

.lib-info { padding: 10px 12px 14px; }
.lib-book-title {
  font-size: 13px;
  font-weight: 600;
  line-height: 1.3;
  margin: 0;
  color: var(--text);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ---- Reader ---- */
.reader-view {
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 100;
  display: none;
  flex-direction: column;
}
.reader-view.active { display: flex; }

.reader-topbar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--card-border);
  background: var(--card);
}
.reader-icon-btn {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: rgb(19, 23, 52);
  border: 1px solid var(--card-border);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 18px;
  font-weight: 700;
  line-height: 1;
  padding: 0;
}
.reader-icon-btn:hover { border-color: var(--green); }
.reader-title {
  flex: 1;
  min-width: 0;
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: center;
}
.reader-zoom-group { display: flex; gap: 6px; flex-shrink: 0; }

.reader-canvas-wrap {
  flex: 1;
  overflow: auto;
  display: flex;
  align-items: flex-start;
  padding: 16px 10px;
  position: relative;
}
.reader-canvas-wrap canvas {
  margin: auto;
  background: #fff;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .5);
  border-radius: 2px;
}

.reader-loading {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  color: var(--muted-2);
  font-size: 14px;
}
.reader-loading.hidden { display: none; }
.reader-spinner {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 3px solid var(--track);
  border-top-color: var(--green);
  animation: reader-spin .8s linear infinite;
}
@keyframes reader-spin { to { transform: rotate(360deg); } }

.reader-audio-bar {
  flex-shrink: 0;
  padding: 12px 14px;
  border-top: 1px solid var(--card-border);
  background: var(--card);
}
.reader-audio-label {
  margin: 0 0 10px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted-2);
}
.reader-audio-player {
  display: flex;
  align-items: center;
  gap: 12px;
}
.reader-audio-play {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--green);
  border: none;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.reader-audio-play svg { margin-left: 2px; }
.reader-audio-play:hover { background: var(--green-dark); }
.reader-audio-scrub { flex: 1; min-width: 0; }
.reader-audio-track {
  position: relative;
  height: 4px;
  background: var(--track);
  border-radius: 999px;
  margin-bottom: 6px;
}
.reader-audio-track-fill {
  width: 0%;
  height: 100%;
  background: var(--green);
  border-radius: 999px;
}
.reader-audio-track-handle {
  position: absolute;
  left: 0%;
  top: 50%;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--green);
  border: 2px solid var(--card);
  transform: translate(-50%, -50%);
}
.reader-audio-time {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--muted);
}
.reader-audio-wave { flex-shrink: 0; color: var(--muted); }

.reader-bottombar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-top: 1px solid var(--card-border);
  background: var(--card);
}
.reader-nav-btn {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--green);
  border: none;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.reader-nav-btn:hover { background: var(--green-dark); }
.reader-nav-btn:disabled { background: #888a98; cursor: not-allowed; }
.reader-progress-col { flex: 1; min-width: 0; }
.reader-progress-track {
  height: 6px;
  background: var(--track);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 6px;
}
.reader-progress-fill {
  height: 100%;
  width: 0%;
  background: var(--green);
  border-radius: 999px;
  transition: width .2s ease;
}
.reader-page-indicator {
  text-align: center;
  font-size: 12px;
  color: var(--muted);
}
