/* =====================================================================
   腾讯动漫自建阅读客户端 —— 样式
   设计约束：
     · 移动优先，暗色底（漫画阅读场景）
     · 不引入任何第三方字体/图标库/埋点脚本
     · 所有可见文案都不含广告位、购买引导、APP 下载引导
   ===================================================================== */

:root {
  --bg: #0f1115;
  --bg-2: #171a21;
  --bg-3: #1f232c;
  --line: #2a2f3a;
  --fg: #e8eaed;
  --fg-2: #a6adba;
  --fg-3: #6d7480;
  --accent: #ff7a45;
  --accent-2: #ffb26b;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

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

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--fg);
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
        "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  overscroll-behavior-y: none;
}

button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
img { display: block; }

.view { min-height: 100vh; }
[hidden] { display: none !important; }

/* ------------------------------------------------------------ 顶栏 */

.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 10px;
  height: calc(50px + var(--safe-top));
  padding: var(--safe-top) 12px 0;
  background: rgba(15, 17, 21, .92);
  backdrop-filter: saturate(160%) blur(12px);
  -webkit-backdrop-filter: saturate(160%) blur(12px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; letter-spacing: .5px; }
.brand-mark {
  width: 20px; height: 20px; border-radius: 5px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 0 0 3px rgba(255, 122, 69, .15);
}
.topbar-title { flex: 1; text-align: center; font-weight: 600; font-size: 15px; }
.topbar-right { min-width: 32px; display: flex; justify-content: flex-end; }
.icon-btn {
  width: 32px; height: 32px; border-radius: 8px;
  font-size: 20px; line-height: 1; color: var(--fg-2);
  display: inline-flex; align-items: center; justify-content: center;
}
.icon-btn:active { background: var(--bg-3); color: var(--fg); }

/* ------------------------------------------------------------ 搜索 */

.searchbar {
  position: sticky; top: calc(50px + var(--safe-top)); z-index: 29;
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px;
  background: var(--bg-2);
  border-bottom: 1px solid var(--line);
}
.searchbar input {
  flex: 1; height: 36px; padding: 0 12px;
  background: var(--bg-3); color: var(--fg);
  border: 1px solid var(--line); border-radius: 10px;
  font-size: 14px; outline: none;
}
.searchbar input:focus { border-color: var(--accent); }

/* ------------------------------------------------------------ 分类 */

.chips {
  display: flex; gap: 8px; overflow-x: auto;
  padding: 12px; scrollbar-width: none;
  position: sticky; top: calc(50px + var(--safe-top)); z-index: 20;
  background: linear-gradient(var(--bg) 70%, rgba(15, 17, 21, 0));
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto; padding: 6px 14px; border-radius: 999px;
  background: var(--bg-2); border: 1px solid var(--line);
  color: var(--fg-2); font-size: 13px; white-space: nowrap;
}
.chip.active { background: var(--accent); border-color: var(--accent); color: #1a1208; font-weight: 600; }

/* ------------------------------------------------------------ 列表 */

.grid {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 10px; padding: 4px 12px 24px;
}
@media (min-width: 520px) { .grid { grid-template-columns: repeat(4, 1fr); } }
@media (min-width: 820px) { .grid { grid-template-columns: repeat(6, 1fr); } }

.card { position: relative; cursor: pointer; }
.card-cover {
  position: relative; width: 100%; aspect-ratio: 3 / 4;
  border-radius: 8px; overflow: hidden; background: var(--bg-3);
}
.card-cover img { width: 100%; height: 100%; object-fit: cover; }
.card-title {
  margin-top: 6px; font-size: 12.5px; line-height: 1.35; color: var(--fg);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.sentinel { height: 4px; }
.list-status { text-align: center; color: var(--fg-3); font-size: 13px; padding: 10px 0 28px; }

/* ------------------------------------------------------------ 详情 */

.detail-hero { padding: 16px 12px 0; }
.detail-hero img {
  width: 100%; max-height: 46vh; object-fit: cover;
  border-radius: 12px; background: var(--bg-3);
}
.detail-meta { padding: 12px 16px 4px; }
.detail-title { font-size: 20px; font-weight: 700; margin: 0 0 6px; }
.detail-row { color: var(--fg-2); font-size: 13px; margin: 3px 0; }
.detail-desc {
  color: var(--fg-2); font-size: 13px; line-height: 1.7; margin: 10px 0 0;
  white-space: pre-wrap;
}
.chapter-head {
  display: flex; justify-content: space-between; align-items: baseline;
  padding: 18px 16px 8px; font-weight: 600; font-size: 15px;
  border-bottom: 1px solid var(--line);
}
.muted { color: var(--fg-3); font-weight: 400; font-size: 12.5px; }
.chapter-list { list-style: none; margin: 0; padding: 0 0 40px; }
.chapter-list li {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 13px 16px; border-bottom: 1px solid rgba(42, 47, 58, .55);
  cursor: pointer;
}
.chapter-list li:active { background: var(--bg-2); }
.chapter-name { font-size: 14px; }
.chapter-tag {
  flex: 0 0 auto; font-size: 10.5px; padding: 2px 6px; border-radius: 4px;
  color: var(--fg-3); border: 1px solid var(--line);
}

/* ------------------------------------------------------------ 阅读器 */

.reader { background: #05070a; }
.reader-chrome {
  position: fixed; left: 0; right: 0; z-index: 40;
  background: rgba(8, 10, 14, .94);
  backdrop-filter: blur(10px);
  transition: transform .18s ease, opacity .18s ease;
}
.reader-chrome-top {
  top: 0; display: flex; align-items: center; gap: 10px;
  height: calc(46px + var(--safe-top)); padding: var(--safe-top) 12px 0;
  border-bottom: 1px solid var(--line);
}
.reader-title {
  flex: 1; text-align: center; font-size: 14px; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.reader-chrome-bottom {
  bottom: 0; display: flex; align-items: center; justify-content: space-between;
  gap: 10px; padding: 10px 14px calc(10px + var(--safe-bottom));
  border-top: 1px solid var(--line);
}
.reader.chrome-hidden .reader-chrome-top { transform: translateY(-100%); opacity: 0; }
.reader.chrome-hidden .reader-chrome-bottom { transform: translateY(100%); opacity: 0; }
.chap-btn {
  padding: 7px 14px; border-radius: 8px; font-size: 13px;
  background: var(--bg-3); border: 1px solid var(--line); color: var(--fg-2);
}
.chap-btn:disabled { opacity: .35; }
.reader-progress { font-size: 12px; color: var(--fg-3); }

.reader-pages { padding: 0 0 20px; }
.reader-pages img { width: 100%; display: block; background: #14161c; }
.reader-notice {
  position: fixed; left: 50%; bottom: calc(74px + var(--safe-bottom));
  transform: translateX(-50%);
  max-width: 88vw; padding: 10px 14px; border-radius: 10px;
  background: rgba(31, 35, 44, .96); border: 1px solid var(--line);
  color: var(--fg-2); font-size: 12.5px; text-align: center; z-index: 41;
}

/* ------------------------------------------------------------ 其它 */

.toast {
  position: fixed; left: 50%; bottom: calc(30px + var(--safe-bottom));
  transform: translateX(-50%);
  padding: 9px 16px; border-radius: 10px; z-index: 60;
  background: rgba(31, 35, 44, .97); border: 1px solid var(--line);
  color: var(--fg); font-size: 13px; max-width: 80vw; text-align: center;
}
.skeleton {
  background: linear-gradient(90deg, var(--bg-2) 25%, var(--bg-3) 37%, var(--bg-2) 63%);
  background-size: 400% 100%; animation: sk 1.4s ease infinite;
  border-radius: 8px;
}
@keyframes sk { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }
