* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

/* 页面根容器 */
html, body { width: 100vw; height: 100vh; overflow: hidden; background-color: #f7f7f9; }
body { font-family: -apple-system, BlinkMacSystemFont, sans-serif; color: #333; margin: 0 auto; max-width: 600px; position: relative; box-shadow: 0 0 20px rgba(0,0,0,0.05); }

/* 单页架构 */
.view-layer { position: absolute; top: 0; left: 0; width: 100%; height: 100%; display: none; background: #f7f7f9; flex-direction: column; z-index: 100;}
.view-layer.active { display: flex; }

/* 头部导航 */
.top-header { flex-shrink: 0; padding: 10px 15px 0; background: #fff; z-index: 50; }
.search-bar { background: #f5f6f8; border-radius: 20px; padding: 8px 15px; border: 1px solid #ebebeb; color: #999; font-size: 14px; margin-bottom: 12px; }
.nav-tabs { display: flex; overflow-x: auto; font-size: 16px; color: #888; padding-bottom: 5px; overscroll-behavior-x: contain; -webkit-overflow-scrolling: touch; }
.nav-tabs::-webkit-scrollbar { display: none; }
.nav-tab { margin-right: 22px; white-space: nowrap; transition: 0.2s; cursor: pointer; flex-shrink: 0; }
.nav-tab.active { font-size: 18px; color: #222; font-weight: 800; position: relative; }
.nav-tab.active::after { content: ''; position: absolute; bottom: -6px; left: 50%; transform: translateX(-50%); width: 14px; height: 3px; background: #222; border-radius: 2px; }

/* 内容滚动区 */
.main-content { flex: 1; overflow-y: auto; padding: 15px 15px 20px; -webkit-overflow-scrolling: touch; }
.card-module { background: #fff; border-radius: 16px; padding: 18px; margin-bottom: 15px; box-shadow: 0 4px 12px rgba(0,0,0,0.03); }
.card-title { font-size: 18px; font-weight: 900; margin-bottom: 16px; display: flex; align-items: center; color: #111; }
.card-title .sub-title { font-size: 13px; color: #bbb; font-weight: normal; margin-left: 10px; }
.card-title .arrow { margin-left: auto; color: #ccc; font-size: 20px; font-weight: bold; }

/* ✨ 修复排版 1：绝对锁死行列宽高，严防溢出！ */
.book-grid-horizontal { 
  display: grid; 
  grid-template-rows: repeat(4, 74px); 
  grid-auto-flow: column; 
  grid-auto-columns: min(calc(50vw - 25px), 270px); 
  gap: 14px 12px; 
  overflow-x: auto; 
  overscroll-behavior-x: contain; 
  -webkit-overflow-scrolling: touch; 
  padding-bottom: 10px;
}
.book-grid-horizontal::-webkit-scrollbar { display: none; }

.book-item { display: flex; gap: 10px; align-items: center; cursor: pointer; width: 100%; height: 74px; overflow: hidden; min-width: 0;}

/* ✨ 修复排版 2：图层叠加法封面容器，彻底解决 DOM 乱码崩坏！ */
.cover-wrapper { width: 52px; height: 72px; position: relative; border-radius: 4px; overflow: hidden; flex-shrink: 0; border: 1px solid #f0f0f0; }
.book-cover { position: absolute; top: 0; left: 0; width: 100%; height: 100%; object-fit: cover; z-index: 2; transition: opacity 0.3s ease; }
.book-cover-fallback { position: absolute; top: 0; left: 0; width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; z-index: 1; padding: 4px; }
.book-cover-fallback span { writing-mode: vertical-rl; font-size: 13px; font-weight: bold; color: #444; letter-spacing: 2px; max-height: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-family: "STZhongsong", "SimSun", serif; }

/* 文本信息流区 */
.book-info { flex: 1 1 0%; min-width: 0; display: flex; flex-direction: column; justify-content: center; gap: 6px; }
.book-name-row { display: flex; align-items: center; width: 100%; min-width: 0; }

/* ✨ 修复排版 3：强制锁定数字宽度，让后面的书名绝对垂直对齐！ */
.book-rank { width: 20px; font-size: 16px; font-weight: 800; color: #c4c4c4; font-family: Arial, sans-serif; flex-shrink: 0; text-align: left; }
.book-rank.top3 { color: #ff5a5f; }

/* 书名和标签强制截断 */
.book-name { font-size: 15px; font-weight: bold; color: #222; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1 1 0%; min-width: 0; display: block; }
.book-tags { display: flex; gap: 6px; overflow: hidden; white-space: nowrap; width: 100%; flex-wrap: nowrap;}
.tag { font-size: 10px; background: #f5f5f5; color: #999; padding: 2px 6px; border-radius: 4px; flex-shrink: 0; max-width: 70px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;}

/* 完结推荐垂直布局 */
.book-grid-vertical { display: flex; flex-direction: column; gap: 20px; }
.book-item-large { display: flex; gap: 15px; cursor: pointer; border-bottom: 1px solid #fafafa; padding-bottom: 15px; width: 100%; overflow: hidden;}
.book-item-large:last-child { border-bottom: none; padding-bottom: 0; }
.book-item-large .cover-wrapper { width: 75px; height: 100px; border-radius: 6px; box-shadow: 0 2px 8px rgba(0,0,0,0.08); flex-shrink: 0;}
.book-item-large .book-cover-fallback span { font-size: 16px; letter-spacing: 3px; }
.book-item-large .book-info { flex: 1 1 0%; min-width: 0; display: flex; flex-direction: column; justify-content: flex-start; gap: 6px; padding-top: 2px;}
.book-item-large .book-name-row { display: flex; justify-content: space-between; align-items: baseline; width: 100%; }
.book-item-large .book-name-large { font-size: 16px; font-weight: bold; color: #222; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1 1 0%; min-width: 0; }
.book-item-large .book-score { color: #ff5a5f; font-size: 15px; font-weight: bold; flex-shrink: 0; margin-left: 10px; }
.book-item-large .book-score small { font-size: 11px; font-weight: normal; }
.book-item-large .book-desc { font-size: 13px; color: #999; line-height: 1.5; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* 底部导航 */
.bottom-nav { flex-shrink: 0; background: rgba(255,255,255,0.95); backdrop-filter: blur(10px); display: flex; justify-content: space-around; padding: 8px 0 25px; border-top: 1px solid #f0f0f0; z-index: 90; }
.bottom-nav-item { display: flex; flex-direction: column; align-items: center; color: #999; font-size: 10px; gap: 4px; cursor: pointer; }
.bottom-nav-item.active { color: #222; font-weight: 800; }
.bottom-nav-item .icon { font-size: 22px; }