/* library 组（library、library-doc）專屬樣式。
 * 全部用 app.css 的 token；class 用 lib- 前綴。兼容 iOS Safari 14：不用 inset / flex gap / aspect-ratio / :is() / dvh / color-mix。
 */

/* ---------------------------------------------------------------- 列表 */
.lib-search { display: flex; align-items: center; gap: var(--sp-2); margin: var(--sp-3) var(--gutter); }
.lib-search .input { flex: 1 1 auto; min-width: 0; }
.lib-search .btn { flex: 0 0 auto; }
.lib-list {
  padding: var(--sp-3) var(--gutter) var(--sp-5);
}
.lib-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-gap: var(--sp-4) var(--sp-3);
}
.lib-card {
  display: block;
  min-width: 0;
  color: var(--label);
  text-decoration: none;
  background: var(--bg-elevated);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-small);
  -webkit-tap-highlight-color: transparent;
}
.lib-card:active {
  opacity: 0.7;
}
.lib-card:focus-visible {
  outline: 2px solid var(--tint);
  outline-offset: 2px;
}
.lib-cover {
  position: relative;
  width: 100%;
  height: 0;
  padding-top: 135%;
  background: var(--fill);
  overflow: hidden;
}
.lib-cover__ph {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 34px;
  font-weight: 700;
  color: var(--label-3);
  background: var(--tint-soft);
}
.lib-cover__img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}
.lib-card__body {
  padding: var(--sp-2) var(--sp-3) var(--sp-3);
}
.lib-card__title {
  font-size: 15px;
  font-weight: 600;
  line-height: 1.35;
  overflow-wrap: break-word;
  word-break: break-word;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.lib-card__issue {
  margin-top: 2px;
  font-size: 13px;
  color: var(--label-2);
  overflow-wrap: break-word;
  word-break: break-word;
}
.lib-card__meta {
  margin-top: var(--sp-1);
  font-size: 12px;
  color: var(--label-3);
}
.lib-card__progress {
  margin-top: 2px;
  font-size: 12px;
  font-weight: 600;
  color: var(--tint);
}

/* ---------------------------------------------------------------- 閱讀器 */
.lib-reader {
  padding-bottom: calc(76px + env(safe-area-inset-bottom));
}
.lib-head {
  padding: var(--sp-3) var(--gutter) var(--sp-2);
}
.lib-head__issue {
  font-size: 13px;
  color: var(--tint);
  font-weight: 600;
  overflow-wrap: break-word;
  word-break: break-word;
}
.lib-head__summary {
  margin-top: var(--sp-1);
  font-size: 14px;
  color: var(--label-2);
  line-height: 1.5;
  overflow-wrap: break-word;
  word-break: break-word;
}
.lib-stage {
  position: relative;
  min-height: 60vh;
  padding: 0 var(--sp-2);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  touch-action: pan-y;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}
.lib-img {
  display: block;
  width: 100%;
  height: auto;
  background: var(--bg-elevated);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-small);
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-user-drag: none;
}
.lib-stage__msg {
  width: 100%;
  min-height: 60vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: var(--sp-4);
  font-size: 15px;
  color: var(--label-2);
  background: var(--bg-elevated);
  border: 0;
  border-radius: var(--radius-sm);
  font-family: inherit;
  overflow-wrap: break-word;
  word-break: break-word;
}
button.lib-stage__msg {
  color: var(--tint);
  cursor: pointer;
}
.lib-stage__spin {
  color: var(--label-3);
}
.lib-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 90;
  max-width: var(--col);
  margin: 0 auto;
  display: flex;
  align-items: center;
  padding: var(--sp-2) var(--gutter) calc(var(--sp-2) + env(safe-area-inset-bottom));
  background: var(--material-solid);
  box-shadow: 0 -0.5px 0 var(--separator);
}
.lib-bar__btn {
  flex: 0 0 auto;
  min-width: 88px;
  min-height: var(--tap);
  padding: 0 var(--sp-3);
  font-family: inherit;
  font-size: 16px;
  font-weight: 600;
  color: var(--on-tint);
  background: var(--tint);
  border: 0;
  border-radius: var(--radius);
  cursor: pointer;
}
.lib-bar__btn:disabled {
  opacity: 0.35;
  cursor: default;
}
.lib-bar__btn:focus-visible,
.lib-bar__page:focus-visible,
.lib-stage__msg:focus-visible {
  outline: 2px solid var(--tint);
  outline-offset: 2px;
}
.lib-bar__page {
  flex: 1 1 auto;
  min-width: 0;
  min-height: var(--tap);
  margin: 0 var(--sp-2);
  font-family: inherit;
  font-size: 16px;
  font-weight: 600;
  color: var(--label);
  background: var(--fill);
  border: 0;
  border-radius: var(--radius);
  cursor: pointer;
}
.lib-jump__hint {
  margin-top: var(--sp-2);
  font-size: 13px;
  color: var(--label-2);
}

@media (prefers-reduced-motion: reduce) {
  .lib-card,
  .lib-bar__btn,
  .lib-bar__page {
    transition: none;
  }
}
