/* Page-level styles: 首页 / 分类 / 搜索 / 详情 / 目录 / Reader / 书架 / 我的 / 设置 / 安装. */

/* ---------- 首页 ---------- */

.home-header {
  position: sticky;
  top: 0;
  z-index: 15;
  background: var(--bg);
  padding-top: var(--safe-top);
}

.banner {
  position: relative;
  padding: 8px 12px 0;
}

.banner__track {
  display: flex;
  gap: 0;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
  border-radius: 10px;
}

.banner__track::-webkit-scrollbar {
  display: none;
}

.banner__slide {
  position: relative;
  flex: 0 0 100%;
  scroll-snap-align: start;
  height: 150px;
  overflow: hidden;
  border-radius: 10px;
}

.banner__image {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.banner__image--empty {
  background: var(--cover-empty);
}

.banner__scrim {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 56px;
  background: linear-gradient(to bottom, transparent, rgba(0, 0, 0, 0.54));
}

.banner__title {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 8px;
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  text-align: left;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.banner__dots {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 0 4px;
}

.banner__dot {
  width: 6px;
  height: 6px;
  border-radius: 99px;
  background: rgba(0, 0, 0, 0.26);
  transition: width 0.2s ease;
}

.banner__dot--active {
  width: 14px;
  background: var(--accent);
}

.source-notice {
  margin: 4px 16px 0;
  font-size: 12px;
  color: var(--fg-tertiary);
}

/* ---------- 分类 ---------- */

.category-head {
  position: sticky;
  top: 0;
  z-index: 15;
  display: grid;
  grid-template-columns: 1fr 48px;
  align-items: center;
  height: calc(var(--app-bar-h) + var(--safe-top));
  padding: var(--safe-top) 4px 0 16px;
  background: var(--bg);
}

.category-head__title {
  font-size: 22px;
  font-weight: 700;
}

.icon-btn--search::before {
  content: '';
  width: 16px;
  height: 16px;
  border: 2px solid currentColor;
  border-radius: 50%;
  box-shadow: 5px 5px 0 -1px currentColor;
  transform: translate(-2px, -2px);
}

.category-filters {
  position: sticky;
  top: calc(var(--app-bar-h) + var(--safe-top));
  z-index: 14;
  background: var(--bg);
  padding-bottom: 4px;
}

.category-footer {
  min-height: 8px;
}

/* ---------- 搜索 ---------- */

.app-bar--search {
  grid-template-columns: 48px 1fr auto;
  gap: 4px;
  padding-right: 8px;
}

.search-input {
  width: 100%;
  height: 40px;
  padding: 0 8px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--fg);
  font-size: 16px;
  outline: none;
}

.search-input::placeholder {
  color: var(--fg-tertiary);
}

.search-list {
  padding-bottom: 16px;
}

.search-row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 10px 16px;
  text-align: left;
  border-bottom: 1px solid var(--divider);
}

.search-row__cover {
  flex: 0 0 auto;
  width: 56px;
  height: 78px;
  border-radius: 6px;
}

.search-row__body {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.search-row__title {
  font-size: 15px;
  font-weight: 600;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.search-row__subtitle {
  font-size: 12px;
  color: var(--fg-tertiary);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

/* ---------- 详情 ---------- */

.page--detail {
  padding-bottom: calc(64px + var(--safe-bottom));
}

.app-bar--shadow {
  box-shadow: 0 1px 0 var(--divider);
}

.detail-head {
  display: flex;
  gap: 12px;
  padding: 12px 16px 4px;
}

.detail-head__cover {
  flex: 0 0 auto;
  width: 110px;
  height: 150px;
  border-radius: 8px;
}

.detail-head__meta {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.detail-head__title {
  font-size: 18px;
  font-weight: 700;
  line-height: 1.25;
}

.detail-head__author {
  font-size: 13px;
  color: var(--fg-secondary);
}

/* Neutral pill exactly like the APK detail header (#F0F0F0 / #424242). */
.detail-head__source {
  align-self: flex-start;
  padding: 3px 8px;
  border-radius: 4px;
  background: var(--chip-bg);
  color: #424242;
  font-size: 12px;
}

.detail-desc-wrap {
  padding-top: 2px;
}

.detail-desc {
  font-size: 13px;
  line-height: 1.5;
  color: var(--fg-secondary);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.detail-desc--expanded {
  -webkit-line-clamp: unset;
  overflow: visible;
}

.detail-desc__toggle {
  padding: 0;
  min-height: 26px;
  font-size: 13px;
}

.detail-actions {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 25;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 16px calc(8px + var(--safe-bottom));
  background: var(--bg);
  box-shadow: 0 -1px 0 var(--divider);
}

/* _BookshelfAction parity: 90x46, bookmark glyph, #616161 → accent when saved. */
.shelf-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  width: 90px;
  height: 46px;
  border-radius: 8px;
  color: #616161;
  font-size: 13px;
  font-weight: 600;
}

.shelf-btn__icon {
  width: 22px;
  height: 22px;
  background: currentColor;
  -webkit-mask: var(--icon-bookmark-outline) center / contain no-repeat;
  mask: var(--icon-bookmark-outline) center / contain no-repeat;
}

.shelf-btn--on {
  color: var(--accent);
}

.shelf-btn--on .shelf-btn__icon {
  -webkit-mask-image: var(--icon-bookmark-filled);
  mask-image: var(--icon-bookmark-filled);
}

.detail-actions__read {
  flex: 1 1 auto;
  height: 46px;
  border-radius: 23px;
  font-size: 16px;
}

/* ---------- 目录 ---------- */

.chapters-page__title {
  padding: 12px 16px 0;
  font-size: 16px;
  font-weight: 700;
}

.chapter-directory {
  padding-bottom: 8px;
}

.chapter-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 8px 4px 16px;
}

.chapter-head__title {
  font-size: 16px;
  font-weight: 700;
}

.chapter-head__count {
  font-size: 13px;
  font-weight: 400;
  color: var(--fg-tertiary);
}

.chapter-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding: 4px 16px 16px;
}

.chapter-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 2.6;
  padding: 0 6px;
  border-radius: 6px;
  background: var(--chip-bg);
  color: var(--fg);
  font-size: 12px;
  text-align: center;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.chapter-cell--read {
  color: var(--fg-tertiary);
  opacity: 0.65;
}

/* ---------- Reader ---------- */

.page--reader {
  background: #000;
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  min-height: 100vh;
  min-height: 100dvh;
  overflow: hidden;
  padding-top: var(--safe-top);
}

.page--reader.page {
  min-height: 0;
}

.page--reader > .ad-slot {
  flex: 0 0 auto;
}

.reader-bar {
  position: relative;
  z-index: 40;
  flex: 0 0 auto;
  background: rgba(0, 0, 0, 0.92);
  color: #fff;
}

.reader-bar--top {
  display: grid;
  grid-template-columns: 48px 1fr auto;
  align-items: center;
  height: var(--app-bar-h);
  padding-top: 0;
}

.reader-bar__actions {
  display: flex;
  align-items: center;
  gap: 2px;
  padding-right: 4px;
}

/* Mirrors BookmarkButton: 收藏 / 已收藏 with the Material red when active. */
.reader-bookmark {
  display: grid;
  grid-template-rows: 22px auto;
  justify-items: center;
  gap: 2px;
  min-width: 56px;
  padding: 4px 6px;
  background: none;
  color: rgba(255, 255, 255, 0.86);
  font-size: 12px;
  font-weight: 600;
}

.reader-bookmark::before {
  content: '';
  width: 22px;
  height: 22px;
  background: currentColor;
  -webkit-mask: var(--icon-heart-outline) center / contain no-repeat;
  mask: var(--icon-heart-outline) center / contain no-repeat;
}

.reader-bookmark--on {
  color: #e53935;
}

.reader-bookmark--on::before {
  -webkit-mask-image: var(--icon-heart-filled);
  mask-image: var(--icon-heart-filled);
}

.reader-bar--top.reader-bar--hidden {
  transform: translateY(-110%);
  opacity: 0;
}

.reader-bar--bottom {
  padding-bottom: var(--safe-bottom);
}

.reader-bar--bottom.reader-bar--hidden {
  transform: translateY(110%);
  opacity: 0;
}

.reader-bar__title {
  font-size: 16px;
  font-weight: 500;
  text-align: center;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.reader-bar__row {
  display: flex;
  align-items: center;
  justify-content: space-evenly;
  gap: 8px;
  height: 52px;
  padding: 0 12px;
}

/* TextButton.icon parity: flat label with a leading skip glyph. */
.reader-nav-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 36px;
  padding: 0 8px;
  background: none;
  color: var(--accent);
  font-size: 14px;
  font-weight: 500;
}

.reader-nav-btn::before {
  content: '';
  width: 18px;
  height: 18px;
  background: currentColor;
  -webkit-mask: var(--icon-skip-previous) center / contain no-repeat;
  mask: var(--icon-skip-previous) center / contain no-repeat;
}

.reader-nav-btn--next {
  flex-direction: row-reverse;
}

.reader-nav-btn--next::before {
  -webkit-mask-image: var(--icon-skip-next);
  mask-image: var(--icon-skip-next);
}

.reader-nav-btn[disabled] {
  color: rgba(255, 255, 255, 0.38);
}

.reader-counter {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.78);
}

.reader-stream {
  display: block;
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 0;
  background: #000;
}

.reader-page {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 180px;
  background: #000;
}

.reader-page--ready {
  min-height: 0;
}

.reader-image {
  display: block;
  width: 100%;
  height: auto;
}

.reader-page__spinner {
  display: block;
  width: 28px;
  height: 28px;
  border: 2px solid rgba(255, 255, 255, 0.25);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}

.reader-page--failed {
  min-height: 200px;
}

.reader-retry {
  display: grid;
  place-items: center;
  gap: 6px;
  width: 100%;
  min-height: 200px;
  color: rgba(255, 255, 255, 0.7);
  font-size: 13px;
}

.reader-retry::before {
  content: '重新加载';
}

/* ---------- 书架 / 最近阅读 ---------- */

.shelf-header {
  position: sticky;
  top: 0;
  z-index: 15;
  background: var(--bg);
  padding-top: var(--safe-top);
}

.shelf-header__title {
  height: var(--app-bar-h);
  display: flex;
  align-items: center;
  padding: 0 16px;
  font-size: 22px;
  font-weight: 700;
}

.shelf-clear-row {
  display: flex;
  justify-content: flex-end;
  padding: 6px 12px 0;
}

.recent-list {
  padding-bottom: 16px;
}

.recent-row {
  position: relative;
  overflow: hidden;
}

.recent-row__action {
  position: absolute;
  inset: 0;
  display: block;
  background: #f44336;
}

.recent-tile {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px 10px 16px;
  background: var(--bg);
  border-bottom: 1px solid var(--divider);
}

.recent-tile__main {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: left;
}

.recent-tile__cover {
  flex: 0 0 auto;
  width: 60px;
  height: 84px;
  border-radius: 6px;
}

.recent-tile__body {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.recent-tile__title {
  font-size: 15px;
  font-weight: 600;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.recent-tile__progress {
  font-size: 12px;
  color: var(--fg-secondary);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.recent-tile__time {
  font-size: 11px;
  color: var(--fg-tertiary);
}

.recent-tile__side {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
}

.recent-tile__continue {
  min-height: 30px;
  padding: 0 14px;
  border-radius: 15px;
  font-size: 13px;
}

.recent-tile__delete {
  width: 28px;
  height: 24px;
  display: grid;
  place-items: center;
  color: var(--fg-tertiary);
}

.recent-tile__delete::before {
  content: '';
  width: 18px;
  height: 18px;
  background: currentColor;
  -webkit-mask: var(--icon-delete) center / contain no-repeat;
  mask: var(--icon-delete) center / contain no-repeat;
}

/* ---------- 我的 ---------- */

/* ProfilePage parity: white page, 56px #42A5F5 avatar, theme switch top-right. */
.me-theme {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  height: calc(48px + var(--safe-top));
  padding: var(--safe-top) 16px 0;
}

.me-theme__icon {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #ffc107;
  box-shadow: 0 0 0 2px rgba(255, 193, 7, 0.28);
}

.me-theme__icon--moon {
  background: #3f51b5;
  box-shadow: inset -5px 0 0 0 var(--bg);
}

.me-hero {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 4px 16px 20px;
}

.me-hero__avatar {
  width: 56px;
  height: 56px;
  border-radius: 12px;
  object-fit: contain;
  background: #000;
}

.me-hero__title {
  font-size: 18px;
  font-weight: 700;
}

.me-hero__subtitle {
  margin-top: 4px;
  font-size: 12px;
  color: var(--fg-secondary);
}

.me-anon {
  padding: 18px 16px 24px;
  font-size: 11px;
  color: var(--fg-tertiary);
}

.me-logout {
  display: block;
  margin: 20px auto 0;
}

/* ---------- 登录（仅 iOS Web Clip 模式） ---------- */

.page--login {
  min-height: 100vh;
  background: var(--bg-page);
}

.login-body {
  padding: 24px 24px calc(24px + env(safe-area-inset-bottom));
}

.login-logo {
  width: 72px;
  height: 72px;
  margin: 16px auto 8px;
  border-radius: 16px;
  background: var(--accent);
  background-image: url('../../assets/icons/about.svg');
  background-size: 40px 40px;
  background-position: center;
  background-repeat: no-repeat;
  box-shadow: 0 6px 18px rgba(38, 166, 154, 0.28);
}

.login-form {
  display: block;
  padding-top: 16px;
}

.login-title {
  font-size: 28px;
  font-weight: 700;
  color: var(--fg-primary);
}

.login-subtitle {
  margin-top: 8px;
  font-size: 14px;
  color: var(--fg-secondary);
}

.login-field {
  display: block;
  margin-top: 20px;
}

.login-label {
  display: block;
  font-size: 12px;
  color: var(--fg-secondary);
}

.login-input {
  width: 100%;
  height: 44px;
  margin-top: 4px;
  padding: 0 2px;
  border: none;
  border-bottom: 1px solid var(--divider);
  border-radius: 0;
  background: transparent;
  font-size: 16px;
  color: var(--fg-primary);
  outline: none;
}

.login-input:focus {
  border-bottom-color: var(--accent);
}

.login-error {
  min-height: 18px;
  margin-top: 12px;
  font-size: 13px;
  color: #E53935;
  opacity: 0;
}

.login-error--visible {
  opacity: 1;
}

.login-submit {
  width: 100%;
  height: 48px;
  margin-top: 12px;
  font-size: 16px;
  letter-spacing: 2px;
}

.login-submit:disabled {
  opacity: 0.6;
}

.login-note {
  margin-top: 18px;
  font-size: 12px;
  line-height: 1.6;
  color: var(--fg-tertiary);
}

/* ---------- 设置 ---------- */

.settings-body {
  padding-bottom: 24px;
}

.settings-row {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 56px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--divider);
}

.settings-row--stack {
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
}

.settings-row__body {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.settings-row__title {
  font-size: 15px;
}

.settings-row__subtitle {
  font-size: 12px;
  color: var(--fg-tertiary);
}

.settings-row__control {
  display: flex;
  align-items: center;
  gap: 12px;
}

.settings-row__value {
  min-width: 44px;
  font-size: 13px;
  color: var(--fg-secondary);
  text-align: right;
}

/* Material slider look: accent active track, #E0E0E0 remainder, round thumb. */
.settings-slider {
  flex: 1 1 auto;
  height: 20px;
  margin: 0;
  appearance: none;
  background: transparent;
  accent-color: var(--accent);
}

.settings-slider::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 2px;
  background: linear-gradient(
    to right,
    var(--accent) 0 calc(var(--fill, 40%)),
    #e0e0e0 calc(var(--fill, 40%)) 100%
  );
}

.settings-slider::-webkit-slider-thumb {
  appearance: none;
  width: 18px;
  height: 18px;
  margin-top: -7px;
  border-radius: 50%;
  background: var(--accent);
}

.settings-slider::-moz-range-track {
  height: 4px;
  border-radius: 2px;
  background: #e0e0e0;
}

.settings-slider::-moz-range-progress {
  height: 4px;
  border-radius: 2px;
  background: var(--accent);
}

.settings-slider::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border: none;
  border-radius: 50%;
  background: var(--accent);
}

.settings-version {
  padding: 20px 16px;
  font-size: 12px;
  color: var(--fg-tertiary);
  text-align: center;
}

.switch {
  position: relative;
  flex: 0 0 auto;
  width: 48px;
  height: 28px;
}

.switch__input {
  position: absolute;
  inset: 0;
  margin: 0;
  opacity: 0;
  z-index: 2;
}

.switch__track {
  position: absolute;
  inset: 4px 0;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.22);
  transition: background 0.18s ease;
}

.switch__track::after {
  content: '';
  position: absolute;
  left: 2px;
  top: -2px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  transition: transform 0.18s ease;
}

.switch__input:checked + .switch__track {
  background: rgba(38, 166, 154, 0.5);
}

.switch__input:checked + .switch__track::after {
  transform: translateX(20px);
  background: var(--accent);
}

/* ---------- 关于 / 安装 ---------- */

.about-body,
.install-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 24px 24px calc(32px + var(--safe-bottom));
  text-align: center;
}

.about-logo {
  width: 72px;
  height: 72px;
  border-radius: 18px;
  object-fit: contain;
  background: #000;
}

.about-title {
  font-size: 18px;
  font-weight: 700;
}

.about-line {
  font-size: 13px;
  color: var(--fg-secondary);
}

.about-note {
  font-size: 12px;
  line-height: 1.6;
  color: var(--fg-tertiary);
}

.install-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 8px 0 4px;
}

.install-hero__icon {
  width: 76px;
  height: 76px;
  border-radius: 18px;
  object-fit: contain;
  background: #000;
}

.install-hero__title {
  font-size: 16px;
  font-weight: 700;
}

.install-hero__sub {
  font-size: 12px;
  color: var(--fg-tertiary);
}

.install-cta {
  width: 100%;
  max-width: 340px;
  height: 46px;
  border-radius: 23px;
  font-size: 16px;
}

.install-cta--ghost {
  border: 1px solid var(--accent);
  background: transparent;
  color: var(--accent);
}

.install-steps {
  align-self: stretch;
  margin: 8px 0 0;
  padding-left: 24px;
  text-align: left;
  font-size: 14px;
  line-height: 2;
  color: var(--fg-secondary);
}

.install-note {
  font-size: 12px;
  color: var(--fg-tertiary);
  line-height: 1.6;
  word-break: break-all;
}

/* ---------- ad slot variants ---------- */

.ad-slot--bleed {
  width: 100%;
}

.ad-slot__link {
  display: block;
  width: 100%;
  height: auto;
}
