/* ==========================================
   小说阅读 - 番茄小说风格移动端UI
   ========================================== */

/* === Reset & Variables === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary: #ff6b35;
  --primary-dark: #e55a2b;
  --bg: #f5f5f5;
  --bg-card: #fff;
  --text: #1a1a1a;
  --text-secondary: #888;
  --text-muted: #bbb;
  --border: #eee;
  --shadow: 0 2px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 30px rgba(0,0,0,0.12);
  --radius: 12px;
  --radius-sm: 8px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --header-h: 48px;
  --reader-top-h: 44px;
  --reader-bottom-h: 44px;
  --page-padding: 20px;
}

html {
  height: 100%;
  overflow: hidden;
  -webkit-text-size-adjust: 100%;
  -ms-text-size-adjust: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  user-select: none;
  -webkit-user-select: none;
  overflow: hidden;
  height: 100vh;
  height: 100dvh;
  width: 100vw;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
}

/* 桌面端提示 */
#desktop-tip {
  position: fixed;
  top: 0; left: 0; right: 0;
  background: #ff6b35;
  color: #fff;
  text-align: center;
  padding: 10px 16px;
  font-size: 14px;
  z-index: 9999;
  animation: tipSlideDown 0.3s ease;
}
@keyframes tipSlideDown {
  from { transform: translateY(-100%); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

#app {
  height: 100vh;
  height: 100dvh;
  width: 100%;
  max-width: 1024px;
  margin: 0 auto;
  position: relative;
  overflow: hidden;
  padding-top: var(--safe-top);
  padding-left: var(--safe-left);
  padding-right: var(--safe-right);
}

/* === View Management === */
.view {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  display: none;
  flex-direction: column;
  -webkit-overflow-scrolling: touch;
}
.view.active { display: flex; }

/* === Home View === */
#view-home {
  background: linear-gradient(180deg, #fff5f0 0%, var(--bg) 30%);
}

.home-header {
  padding: calc(20px + var(--safe-top)) 20px 8px;
  text-align: center;
}
.home-header h1 {
  font-size: 28px;
  font-weight: 700;
  color: var(--primary);
  letter-spacing: 2px;
}
.home-subtitle {
  display: block;
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 4px;
}

.home-shelf {
  padding: 0 16px 16px;
}

/* 系列标题 */
.shelf-series-header {
  padding: 16px 4px 12px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}
.series-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.series-title {
  font-size: 22px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: 1px;
}
.series-badge {
  font-size: 11px;
  color: var(--primary);
  background: #fff5f0;
  padding: 2px 10px;
  border-radius: 10px;
  font-weight: 600;
}
.series-subtitle {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 6px;
  line-height: 1.5;
}
.series-meta {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* 书封面网格 */
.shelf-books-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}

/* 书封面卡片 */
.book-card {
  cursor: pointer;
  transition: transform 0.15s;
}
.book-card:active {
  transform: scale(0.96);
}
.book-cover {
  width: 100%;
  aspect-ratio: 3/4;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 12px rgba(0,0,0,0.1);
  position: relative;
  overflow: hidden;
  padding: 12px 8px;
  -webkit-transform: translateZ(0);
  transform: translateZ(0);
}
.book-cover::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 30px;
  background: linear-gradient(transparent, rgba(0,0,0,0.08));
}
.book-cover-emoji {
  font-size: 36px;
  position: relative;
  z-index: 1;
  margin-bottom: 8px;
}
.book-cover-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  position: relative;
  z-index: 1;
  text-align: center;
  line-height: 1.3;
}
.book-info {
  padding: 6px 2px 0;
}
.book-title {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.book-meta {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

.home-footer {
  text-align: center;
  padding: 24px 16px;
  padding-bottom: calc(24px + var(--safe-bottom));
  font-size: 11px;
  line-height: 2;
  color: var(--text-muted);
}
.footer-beian {
  text-align: center;
  color: #bbb;
  font-size: 12px;
  line-height: 2;
}
.footer-beian a {
  color: #bbb;
  text-decoration: none;
  transition: color 0.2s;
}
.footer-beian a:hover {
  color: var(--primary);
}
.footer-copyright {
  color: #666;
}
.footer-copyright a {
  color: #666;
}
.home-footer a {
  color: var(--text-secondary);
  text-decoration: none;
  transition: color 0.2s;
}
.home-footer a:hover {
  color: var(--primary);
}

/* === Share Section === */
.share-section {
  margin-bottom: 16px;
  padding: 16px 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  text-align: left;
}
.share-section h3 {
  font-size: 20px;
  font-weight: 600;
  color: #000;
  margin: 0 0 10px 0;
}
.share-links {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.share-link {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 14px;
  transition: color 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.share-link:hover {
  color: var(--primary);
}
.share-link::after {
  content: '🔗';
  font-size: 12px;
}

/* === Novel Detail View === */
.novel-header {
  height: var(--header-h);
  display: flex;
  align-items: center;
  padding: 0 12px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 10;
}
.novel-title-text {
  flex: 1;
  text-align: center;
  font-size: 17px;
  font-weight: 600;
}

.btn-back, .btn-share, .btn-chapter-list {
  width: 36px; height: 36px;
  border: none;
  background: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text);
  border-radius: 50%;
  transition: background 0.15s;
}
.btn-back:active, .btn-share:active, .btn-chapter-list:active {
  background: var(--border);
}

.novel-content {
  flex: 1;
  overflow-y: auto;
  padding-bottom: 70px;
}

.novel-cover-section {
  padding: 24px;
  text-align: center;
}
.novel-cover-big {
  width: 120px; height: 160px;
  margin: 0 auto 16px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 48px;
  box-shadow: var(--shadow-lg);
}
.novel-cover-section h2 {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 4px;
}
.novel-cover-section .author {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 12px;
}
.novel-cover-section .desc {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.6;
  padding: 0 16px;
}

.novel-chapter-list {
  padding: 0 16px;
}
.chapter-section-title {
  font-size: 15px;
  font-weight: 600;
  margin: 8px 0 12px;
  padding-left: 4px;
  border-left: 3px solid var(--primary);
}

.chapter-item {
  display: flex;
  align-items: center;
  padding: 14px 12px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.15s;
  border-radius: var(--radius-sm);
}
.chapter-item:active { background: #f9f9f9; }
.chapter-item .chapter-num {
  width: 24px; height: 24px;
  background: #f0f0f0;
  border-radius: 50%;
  font-size: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-right: 12px;
  color: var(--text-secondary);
  flex-shrink: 0;
}
.chapter-item .chapter-name {
  flex: 1;
  font-size: 14px;
}
.chapter-item .chapter-arrow {
  color: var(--text-muted);
}
.chapter-item.read .chapter-num { background: #e8f5e9; color: #4caf50; }

/* === Novel Detail — Chapter List === */

.novel-bottom-bar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  padding: 12px 20px calc(12px + var(--safe-bottom));
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  display: flex;
  gap: 12px;
  z-index: 10;
  max-width: 1024px;
  margin: 0 auto;
}

.btn-start-read {
  flex: 1;
  height: 44px;
  border: none;
  border-radius: 22px;
  background: var(--primary);
  color: #fff;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, transform 0.15s;
}
.btn-start-read:active {
  background: var(--primary-dark);
  transform: scale(0.97);
}

/* === Reader View === */
#view-reader {
  background: #f0ede4;
}

.reader-top-bar, .reader-bottom-bar {
  position: absolute;
  left: 0; right: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  padding: 0 12px;
  background: #fff;
  transition: transform 0.3s, opacity 0.3s;
}
.reader-top-bar {
  top: 0;
  height: var(--reader-top-h);
  border-bottom: 1px solid rgba(0,0,0,0.06);
  padding-top: var(--safe-top);
}
.reader-bottom-bar {
  bottom: 0;
  height: var(--reader-bottom-h);
  border-top: 1px solid rgba(0,0,0,0.06);
  padding-bottom: var(--safe-bottom);
}
.reader-top-bar.hidden {
  transform: translateY(-100%);
  opacity: 0;
  pointer-events: none;
}
.reader-bottom-bar.hidden {
  transform: translateY(100%);
  opacity: 0;
  pointer-events: none;
}

.reader-chapter-title {
  flex: 1;
  text-align: center;
  font-size: 14px;
  color: var(--text-secondary);
}

.reader-progress {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 40px;
}
.progress-bar {
  flex: 1;
  height: 3px;
  background: #e0e0e0;
  border-radius: 2px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 2px;
  transition: width 0.3s;
}
.progress-text {
  font-size: 11px;
  color: var(--text-secondary);
  white-space: nowrap;
  min-width: 40px;
  text-align: right;
}

/* ========================================
   3D 翻页舞台 (Turn.js 风格 — 页面卷曲)
   ======================================== */
.reader-stage {
  position: absolute;
  top: var(--reader-top-h);
  bottom: var(--reader-bottom-h);
  left: 0; right: 0;
  -webkit-perspective: 3000px;
  perspective: 3000px;
  -webkit-perspective-origin: 50% 50%;
  perspective-origin: 50% 50%;
  overflow: hidden;
  background: #ddd;
}

/* 底层页面 — 翻页后被露出的内容 */
.page-under {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  overflow-y: auto;
  padding: var(--page-padding);
  font-size: 16px;
  -webkit-overflow-scrolling: touch;
  background: inherit;
  z-index: 1;
}

/* 翻动页：静态部分（折痕左侧，保持不动） */
.page-curl-static {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  overflow-y: auto;
  padding: var(--page-padding);
  font-size: 16px;
  -webkit-overflow-scrolling: touch;
  background: inherit;
  z-index: 2;
  pointer-events: none;
  -webkit-clip-path: inset(0 0 0 0);
  clip-path: inset(0 0 0 0);
  will-change: clip-path;
}

/* 翻动页：卷曲部分容器 — 绕折痕线旋转 */
.page-curl-wrapper {
  position: absolute;
  top: 0;
  width: 100%; height: 100%;
  -webkit-transform-origin: left center;
  transform-origin: left center;
  -webkit-transform-style: preserve-3d;
  transform-style: preserve-3d;
  z-index: 5;
  will-change: transform, left, width;
}

/* 卷曲页正面（朝向读者的一面，翻动时可见） */
.page-curl-front {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  overflow-y: auto;
  padding: var(--page-padding);
  font-size: 16px;
  -webkit-overflow-scrolling: touch;
  background: inherit;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  z-index: 2;
}

/* 卷曲页背面（翻过去后看到的一面） */
.page-curl-back {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  overflow-y: auto;
  padding: var(--page-padding);
  font-size: 16px;
  -webkit-overflow-scrolling: touch;
  background: inherit;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  transform: rotateY(180deg);
  z-index: 1;
}

/* 折痕处的高光 — 模拟纸张弯曲处的光线反射 */
.curl-highlight {
  position: absolute;
  top: 0; bottom: 0;
  width: 0;
  pointer-events: none;
  z-index: 8;
  opacity: 0;
  background: linear-gradient(to right,
    rgba(255,255,255,0.3) 0%,
    rgba(255,255,255,0.1) 50%,
    transparent 100%
  );
  transition: opacity 0.15s;
}

/* 点击翻页区域 */
.tap-zone {
  position: absolute;
  top: 0; bottom: 0;
  z-index: 10;
}
.tap-left { left: 0; width: 25%; }
.tap-center { left: 25%; width: 50%; }
.tap-right { right: 0; width: 25%; }

/* === Reader Themes === */
#view-reader.theme-white { background: #f5f5f5; }
#view-reader.theme-white .reader-stage,
#view-reader.theme-white .page-under,
#view-reader.theme-white .page-curl-static,
#view-reader.theme-white .page-curl-front,
#view-reader.theme-white .page-curl-back { background: #fff; color: #1a1a1a; }

#view-reader.theme-warm { background: #e8dfc8; }
#view-reader.theme-warm .reader-stage,
#view-reader.theme-warm .page-under,
#view-reader.theme-warm .page-curl-static,
#view-reader.theme-warm .page-curl-front,
#view-reader.theme-warm .page-curl-back { background: #f5ecd7; color: #4a3728; }

#view-reader.theme-dark { background: #1a1a1a; }
#view-reader.theme-dark .reader-stage,
#view-reader.theme-dark .page-under,
#view-reader.theme-dark .page-curl-static,
#view-reader.theme-dark .page-curl-front,
#view-reader.theme-dark .page-curl-back { background: #222; color: #ccc; }
#view-reader.theme-dark .reader-top-bar,
#view-reader.theme-dark .reader-bottom-bar {
  background: #1e1e1e;
  border-color: rgba(255,255,255,0.06);
  color: #ccc;
}
#view-reader.theme-dark .btn-back,
#view-reader.theme-dark .btn-chapter-list { color: #ccc; }
#view-reader.theme-dark .reader-chapter-title { color: #999; }
#view-reader.theme-dark .reader-settings {
  background: #1e1e1e;
  border-color: rgba(255,255,255,0.1);
  color: #ccc;
}
#view-reader.theme-dark .curl-highlight {
  background: linear-gradient(to right,
    rgba(255,255,255,0.1) 0%,
    rgba(255,255,255,0.05) 50%,
    transparent 100%
  );
}

#view-reader.theme-warm .reader-top-bar,
#view-reader.theme-warm .reader-bottom-bar {
  background: #f0e6cf;
  border-color: rgba(0,0,0,0.06);
}
#view-reader.theme-warm .reader-settings {
  background: #f0e6cf;
}

#view-reader.theme-green .reader-top-bar,
#view-reader.theme-green .reader-bottom-bar {
  background: #d4e2cc;
  border-color: rgba(0,0,0,0.06);
}
#view-reader.theme-green .reader-settings {
  background: #d4e2cc;
}

#view-reader.theme-green { background: #c8d6c0; }
#view-reader.theme-green .reader-stage,
#view-reader.theme-green .page-under,
#view-reader.theme-green .page-curl-static,
#view-reader.theme-green .page-curl-front,
#view-reader.theme-green .page-curl-back { background: #dce8d4; color: #2c3e2c; }

/* === Page Content Styles === */
.page-content {
  line-height: 1.9;
  word-break: break-all;
  overflow-wrap: break-word;
}
.page-content h1 { font-size: 1.6em; margin: 0.5em 0; text-align: center; }
.page-content h2 { font-size: 1.25em; margin: 1em 0 0.5em; }
.page-content h3 { font-size: 1.1em; margin: 0.8em 0 0.4em; }
.page-content p { margin: 0.3em 0; text-indent: 2em; }
.page-content hr { border: none; border-top: 1px dashed #ccc; margin: 1em 0; }
.page-content em { color: var(--text-secondary); }
.page-content blockquote {
  border-left: 3px solid var(--primary);
  padding-left: 12px;
  margin: 0.6em 0;
  color: var(--text-secondary);
}

/* === Reader Settings === */
.reader-settings {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  background: #fff;
  border-top: 1px solid var(--border);
  padding: 16px 20px calc(16px + var(--safe-bottom));
  z-index: 25;
  transform: translateY(100%);
  visibility: hidden;
  pointer-events: none;
  transition: transform 0.3s, visibility 0s 0.3s;
}
.reader-settings.show {
  transform: translateY(0);
  visibility: visible;
  pointer-events: auto;
  transition: transform 0.3s, visibility 0s 0s;
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
}
.settings-row span { font-size: 14px; }

.font-size-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}
.btn-font {
  width: 36px; height: 36px;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--bg-card);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  color: var(--text);
  transition: background 0.15s;
}
.btn-font:active { background: var(--border); }

.theme-options {
  display: flex;
  gap: 10px;
}
.theme-dot {
  width: 32px; height: 32px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  transition: border-color 0.2s, transform 0.15s;
}
.theme-dot:active { transform: scale(0.9); }
.theme-dot.active { border-color: var(--primary); }
.theme-white { background: #f5f5f5; border: 1px solid #ddd; }
.theme-warm { background: #f5ecd7; }
.theme-dark { background: #333; }
.theme-green { background: #dce8d4; }

/* === Font Options === */
.font-options {
  display: flex;
  gap: 8px;
}
.font-dot {
  width: 36px; height: 36px;
  border-radius: 8px;
  border: 2px solid var(--border);
  background: var(--bg-card);
  cursor: pointer;
  transition: border-color 0.2s, transform 0.15s, background 0.15s;
  font-size: 15px;
  color: var(--text);
}
.font-dot:active { transform: scale(0.9); }
.font-dot.active {
  border-color: var(--primary);
  background: #fff5f0;
  color: var(--primary);
}
.font-songti { font-family: "Noto Serif SC", "Source Han Serif CN", "SimSun", "宋体", serif; }
.font-alibaba { font-family: "Alibaba PuHuiTi", "阿里巴巴普惠体", sans-serif; }
.font-wenkai { font-family: "LXGW WenKai", "霞鹜文楷", cursive; }
.font-wenkai-mono { font-family: "LXGW Marker Gothic", "霞鹜漫黑", sans-serif; }

/* === Font Families === */
#view-reader.font-songti .page-content,
#view-reader.font-songti .page-under,
#view-reader.font-songti .page-curl-static,
#view-reader.font-songti .page-curl-front,
#view-reader.font-songti .page-curl-back {
  font-family: "Noto Serif SC", "Source Han Serif CN", "SimSun", "宋体", "STSong", serif;
}
#view-reader.font-alibaba .page-content,
#view-reader.font-alibaba .page-under,
#view-reader.font-alibaba .page-curl-static,
#view-reader.font-alibaba .page-curl-front,
#view-reader.font-alibaba .page-curl-back {
  font-family: "Alibaba PuHuiTi", "阿里巴巴普惠体", "PingFang SC", "Microsoft YaHei", sans-serif;
}
#view-reader.font-wenkai .page-content,
#view-reader.font-wenkai .page-under,
#view-reader.font-wenkai .page-curl-static,
#view-reader.font-wenkai .page-curl-front,
#view-reader.font-wenkai .page-curl-back {
  font-family: "LXGW WenKai", "霞鹜文楷", cursive;
}
#view-reader.font-wenkai-mono .page-content,
#view-reader.font-wenkai-mono .page-under,
#view-reader.font-wenkai-mono .page-curl-static,
#view-reader.font-wenkai-mono .page-curl-front,
#view-reader.font-wenkai-mono .page-curl-back {
  font-family: "LXGW Marker Gothic", "霞鹜漫黑", sans-serif;
}

/* === Chapter Panel (Slide from right) === */
.overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.4);
  z-index: 30;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
}
.overlay.show {
  opacity: 1;
  pointer-events: auto;
}

.chapter-panel {
  position: fixed;
  top: 0; right: 0;
  width: 80%; max-width: 320px;
  height: 100vh;
  height: 100dvh;
  background: var(--bg-card);
  z-index: 35;
  transform: translateX(100%);
  transition: transform 0.3s cubic-bezier(0.25, 0.8, 0.25, 1.2);
  display: flex;
  flex-direction: column;
  padding-top: var(--safe-top);
}
.chapter-panel.show { transform: translateX(0); }

.chapter-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 16px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 16px;
  font-weight: 600;
}
.btn-close-panel {
  width: 32px; height: 32px;
  border: none; background: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  color: var(--text-secondary);
}
.btn-close-panel:active { background: var(--border); }

.chapter-panel-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
  -webkit-overflow-scrolling: touch;
}
.chapter-panel-item {
  padding: 14px 20px;
  font-size: 14px;
  cursor: pointer;
  border-bottom: 1px solid #f5f5f5;
  transition: background 0.15s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chapter-panel-item:active { background: #f9f9f9; }
.chapter-panel-item.active {
  color: var(--primary);
  font-weight: 600;
  background: #fff5f0;
}

/* === Toast === */
.toast {
  position: fixed;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%) scale(0.8);
  background: rgba(0,0,0,0.78);
  color: #fff;
  padding: 10px 20px;
  border-radius: 20px;
  font-size: 13px;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
}
.toast.show {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

/* === Scrollbar === */
::-webkit-scrollbar { width: 0; height: 0; }

/* === Animations === */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}
.book-card { animation: fadeInUp 0.4s ease backwards; }

/* ==========================================
   响应式适配 — 不同屏幕尺寸
   ========================================== */

/* 超小屏 (< 360px) — 如 iPhone SE 1st gen, 小屏 Android */
@media screen and (max-width: 359px) {
  .shelf-books-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }
  .home-header h1 { font-size: 22px; }
  .series-title { font-size: 18px; }
  .book-cover-emoji { font-size: 28px; }
  .book-cover-title { font-size: 11px; }
  .book-title { font-size: 12px; }
  .book-meta { font-size: 10px; }
  .novel-cover-big { width: 100px; height: 133px; font-size: 40px; }
  .novel-cover-section h2 { font-size: 18px; }
  .chapter-item { padding: 12px 10px; }
  .chapter-item .chapter-name { font-size: 13px; }
  .btn-start-read { font-size: 14px; height: 40px; }
  .reader-progress { padding: 0 20px; }
}

/* 小屏 (360px - 413px) — 如 iPhone SE 2nd, Galaxy S 系列 */
@media screen and (min-width: 360px) and (max-width: 413px) {
  .shelf-books-grid { gap: 12px; }
}

/* 中等屏幕 (414px - 767px) — 主流手机 */
@media screen and (min-width: 414px) and (max-width: 767px) {
  .book-cover-emoji { font-size: 40px; }
}

/* 平板 / 大屏 (>= 768px) */
@media screen and (min-width: 768px) {
  .shelf-books-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
  }
  .home-header h1 { font-size: 32px; }
  .series-title { font-size: 24px; }
  .book-cover-emoji { font-size: 44px; }
  .book-cover-title { font-size: 14px; }
  .book-title { font-size: 14px; }
  .novel-cover-big { width: 140px; height: 186px; font-size: 56px; }
  .novel-cover-section h2 { font-size: 24px; }
  .chapter-panel { max-width: 360px; }
  .reader-progress { padding: 0 60px; }
}

/* 横屏模式 */
@media screen and (orientation: landscape) and (max-height: 500px) {
  .home-header { padding: 12px 20px 4px; }
  .home-header h1 { font-size: 20px; }
  .home-subtitle { display: none; }
  .shelf-books-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
  }
  .book-cover-emoji { font-size: 24px; margin-bottom: 4px; }
  .book-cover-title { font-size: 11px; }
  .book-cover { padding: 8px 6px; }
  .book-cover::after { height: 16px; }
  .novel-cover-section { padding: 12px; }
  .novel-cover-big { width: 80px; height: 106px; font-size: 32px; margin-bottom: 8px; }
  .novel-cover-section h2 { font-size: 18px; }
  .novel-bottom-bar { padding: 8px 20px calc(8px + var(--safe-bottom)); }
  .btn-start-read { height: 36px; font-size: 14px; }
  .reader-top-bar { height: 36px; }
  .reader-bottom-bar { height: 36px; }
  .reader-stage {
    top: 36px;
    bottom: 36px;
  }
  .settings-row { padding: 4px 0; }
  .chapter-panel { max-width: 280px; }
}

/* ==========================================
   iPhone 安全区域特殊处理
   ========================================== */

/* iPhone X+ 底部 Home Indicator */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  .home-footer {
    padding-bottom: calc(24px + env(safe-area-inset-bottom));
  }
  .novel-bottom-bar {
    padding-bottom: calc(12px + env(safe-area-inset-bottom));
  }
  .reader-bottom-bar {
    padding-bottom: env(safe-area-inset-bottom);
  }
  .reader-settings {
    padding-bottom: calc(16px + env(safe-area-inset-bottom));
  }
  .reader-top-bar {
    padding-top: env(safe-area-inset-top);
  }
}

/* ==========================================
   Android 特殊兼容
   ========================================== */

/* Android Chrome 地址栏收缩时高度变化 */
@supports (height: 100dvh) {
  body { height: 100dvh; }
  #app { height: 100dvh; }
}

/* 修复 Android WebView 中 overflow-scrolling 不生效的问题 */
.page-under,
.page-curl-static,
.page-curl-front,
.page-curl-back,
.chapter-panel-list,
.novel-content {
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
}

/* 修复 Android 上 3D 变换闪烁 */
.page-curl-wrapper,
.page-curl-front,
.page-curl-back {
  -webkit-transform: translate3d(0, 0, 0);
  transform: translate3d(0, 0, 0);
}

/* ==========================================
   高 DPI / Retina 适配
   ========================================== */
@media screen and (-webkit-min-device-pixel-ratio: 2), screen and (min-resolution: 2dppx) {
  .progress-bar { height: 2px; }
  .chapter-item { border-bottom-width: 0.5px; }
  .chapter-panel-item { border-bottom-width: 0.5px; }
}

@media screen and (-webkit-min-device-pixel-ratio: 3), screen and (min-resolution: 3dppx) {
  .progress-bar { height: 1.5px; }
}

/* ==========================================
   暗色模式系统适配
   ========================================== */
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: light dark;
  }
}

/* ==========================================
   无障碍 & 减弱动画
   ========================================== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .page-curl-wrapper { will-change: auto; }
  .page-curl-static { will-change: auto; }
}

/* ==========================================
   触摸目标最小尺寸 (WCAG)
   ========================================== */
.btn-back, .btn-share, .btn-chapter-list,
.btn-font, .theme-dot, .font-dot,
.btn-close-panel,
.chapter-item,
.chapter-panel-item {
  min-width: 44px;
  min-height: 44px;
}

/* ==========================================
   aspect-ratio fallback
   ========================================== */
@supports not (aspect-ratio: 3/4) {
  .book-cover {
    height: 0;
    padding-top: 133.33%;
    position: relative;
  }
  .book-cover > * {
    position: absolute;
  }
  .book-cover-emoji {
    top: 30%;
    left: 50%;
    transform: translate(-50%, -50%);
  }
  .book-cover-title {
    bottom: 15%;
    left: 0;
    right: 0;
  }
}

/* ==========================================
   clip-path fallback
   ========================================== */
@supports not (clip-path: inset(0 0 0 0)) {
  .page-curl-static {
    visibility: visible;
  }
}

/* ==========================================
   iOS 橡皮筋效果修复
   ========================================== */
.view {
  overscroll-behavior-y: contain;
}

/* ==========================================
   输入框和可交互元素 iOS 圆角修复
   ========================================== */
input, textarea, select, button {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  border-radius: 0;
}
button {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
}

/* ==========================================
   修复 iOS Safari 100vh 问题
   ========================================== */
@supports (height: 100dvh) {
  .view { height: 100dvh; }
}