/* ============================================================
   七猫在线阅读 · 简约风格全局样式
   适配 PC 与手机浏览器，支持暗色模式
   ============================================================ */

:root {
  --bg: #f7f7f8;
  --surface: #ffffff;
  --surface-2: #f0f0f2;
  --text: #1a1a1a;
  --text-2: #7a7a80;
  --text-3: #a5a5ac;
  --line: #e8e8ec;
  --accent: #e8543d;
  --accent-soft: rgba(232, 84, 61, 0.09);
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 4px 20px rgba(0, 0, 0, 0.06);
  --max-w: 1080px;
  --header-h: 56px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101014;
    --surface: #17171c;
    --surface-2: #202027;
    --text: #ececf1;
    --text-2: #9a9aa3;
    --text-3: #6b6b74;
    --line: #2a2a33;
    --accent: #ff6a4d;
    --accent-soft: rgba(255, 106, 77, 0.14);
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; }
img { -webkit-user-drag: none; }

/* ------------------------------------------------ 头部导航 ---- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  height: var(--header-h);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.header-inner {
  max-width: var(--max-w); margin: 0 auto; height: 100%;
  display: flex; align-items: center; gap: 14px; padding: 0 18px;
}
.logo {
  display: flex; align-items: center; gap: 8px;
  font-weight: 800; font-size: 17px; letter-spacing: 0.5px; flex: 0 0 auto;
}
.logo .dot {
  width: 26px; height: 26px; border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), #ff9a62);
  display: inline-flex; align-items: center; justify-content: center;
  color: #fff; font-size: 13px; font-weight: 800;
}
.header-search {
  flex: 1; display: flex; align-items: center; max-width: 480px;
  background: var(--surface-2); border-radius: 99px; padding: 0 14px;
  height: 38px; gap: 8px;
}
.header-search input {
  flex: 1; border: none; outline: none; background: transparent;
  font-size: 14px; color: var(--text); min-width: 0;
}
.header-search .s-btn {
  border: none; background: var(--accent); color: #fff;
  border-radius: 99px; height: 28px; padding: 0 16px;
  font-size: 13px; cursor: pointer; flex: 0 0 auto;
}
.header-search .s-btn:active { transform: scale(0.96); }
.header-actions { flex: 0 0 auto; display: flex; gap: 6px; }
.h-icon {
  width: 36px; height: 36px; border-radius: 50%; border: none;
  background: transparent; color: var(--text-2); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; font-size: 17px;
}
.h-icon:hover { background: var(--surface-2); }

/* ------------------------------------------------ 类型切换 ---- */
.type-tabs {
  display: flex; gap: 6px; padding: 14px 18px 2px;
  max-width: var(--max-w); margin: 0 auto;
}
.type-tab {
  border: 1px solid var(--line); background: var(--surface);
  color: var(--text-2); border-radius: 99px; padding: 6px 18px;
  font-size: 14px; cursor: pointer; transition: 0.15s;
}
.type-tab.on {
  background: var(--text); border-color: var(--text); color: var(--bg);
  font-weight: 600;
}

/* ------------------------------------------------ 主布局 ---- */
.container { max-width: var(--max-w); margin: 0 auto; padding: 14px 18px 60px; }
.section { margin-top: 22px; }
.section-head {
  display: flex; align-items: baseline; justify-content: space-between;
  margin-bottom: 12px;
}
.section-title { font-size: 17px; font-weight: 800; letter-spacing: 0.3px; }
.section-sub { font-size: 12px; color: var(--text-3); }

/* ------------------------------------------------ 发现入口 ---- */
/* 分组筛选条：分组名居左，入口换行平铺；长分组可折叠（PC 无横向滚动） */
.fgroup {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 6px 0;
}
.fgroup + .fgroup { border-top: 1px dashed var(--line); }
.fgroup-name {
  flex: 0 0 92px; padding-top: 6px;
  font-size: 12.5px; font-weight: 600; color: var(--text-3);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.fchips {
  flex: 1; min-width: 0;
  display: flex; flex-wrap: wrap; gap: 8px;
}
.fmore {
  flex: 0 0 auto; align-self: flex-start;
  border: none; background: none; cursor: pointer;
  color: var(--accent); font-size: 12.5px; padding: 6px 4px;
  white-space: nowrap;
}
.fmore:hover { text-decoration: underline; }
.chip {
  flex: 0 0 auto; padding: 7px 15px; border-radius: 99px;
  background: var(--surface); border: 1px solid var(--line);
  color: var(--text-2); font-size: 13px; cursor: pointer; white-space: nowrap;
  transition: 0.15s;
}
.chip.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 600; }

/* ------------------------------------------------ 卡片网格 ---- */
.grid {
  display: grid; gap: 16px 14px;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
}
@media (min-width: 640px) {
  .grid { grid-template-columns: repeat(auto-fill, minmax(128px, 1fr)); }
}
.card { cursor: pointer; }
.card .cover {
  position: relative; aspect-ratio: 3/4; border-radius: var(--radius-sm);
  overflow: hidden; background: var(--surface-2);
  box-shadow: 0 2px 10px rgba(0,0,0,0.07);
}
.card .cover img {
  width: 100%; height: 100%; object-fit: cover; display: block;
  transition: transform 0.25s ease;
}
.card:hover .cover img { transform: scale(1.05); }
.card .cover .badge {
  position: absolute; left: 6px; bottom: 6px; z-index: 2;
  font-size: 10px; padding: 2px 7px; border-radius: 6px;
  background: rgba(0,0,0,0.55); color: #fff; backdrop-filter: blur(4px);
}
.card .t {
  margin-top: 7px; font-size: 13px; font-weight: 600; line-height: 1.35;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden; word-break: break-all;
}
.card .s { margin-top: 2px; font-size: 11px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* 列表行样式（搜索结果） */
.rows { display: flex; flex-direction: column; gap: 14px; }
.row-card {
  display: flex; gap: 12px; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px; cursor: pointer; transition: 0.15s;
}
.row-card:hover { box-shadow: var(--shadow); transform: translateY(-1px); }
.row-card .cover {
  flex: 0 0 72px; width: 72px; aspect-ratio: 3/4; border-radius: 8px;
  overflow: hidden; background: var(--surface-2);
}
.row-card .cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.row-card .info { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.row-card .t { font-size: 15px; font-weight: 700; }
.row-card .meta { font-size: 12px; color: var(--text-3); margin-top: 3px; display: flex; gap: 8px; flex-wrap: wrap; }
.row-card .desc {
  font-size: 12.5px; color: var(--text-2); margin-top: 6px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.tag-mini {
  font-size: 10.5px; padding: 1px 7px; border-radius: 5px;
  background: var(--accent-soft); color: var(--accent);
}

/* ------------------------------------------------ 加载/空态 ---- */
.loading { text-align: center; padding: 40px 0; color: var(--text-3); font-size: 13px; }
.spinner {
  width: 26px; height: 26px; margin: 0 auto 10px;
  border: 3px solid var(--line); border-top-color: var(--accent);
  border-radius: 50%; animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.empty { text-align: center; padding: 60px 20px; color: var(--text-3); font-size: 14px; }
.empty .big { font-size: 40px; margin-bottom: 10px; }
.load-more {
  display: block; margin: 22px auto 0; padding: 9px 34px;
  border: 1px solid var(--line); background: var(--surface); color: var(--text-2);
  border-radius: 99px; font-size: 13px; cursor: pointer;
}
.load-more:hover { border-color: var(--accent); color: var(--accent); }

/* ------------------------------------------------ 详情页 ---- */
.detail-hero { display: flex; gap: 18px; margin-top: 10px; }
.detail-cover {
  flex: 0 0 130px; width: 130px; aspect-ratio: 3/4; border-radius: var(--radius);
  overflow: hidden; background: var(--surface-2); box-shadow: var(--shadow);
}
.detail-cover img { width: 100%; height: 100%; object-fit: cover; }
.detail-info { flex: 1; min-width: 0; }
.detail-title { font-size: 21px; font-weight: 800; line-height: 1.3; margin: 2px 0 0; }
.detail-author { color: var(--accent); font-size: 13px; margin-top: 6px; font-weight: 600; }
.detail-stats { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.stat-pill {
  font-size: 11.5px; color: var(--text-2); background: var(--surface-2);
  border-radius: 6px; padding: 2px 9px;
}
.detail-actions { display: flex; gap: 10px; margin-top: 16px; }
.btn-primary {
  flex: 1; height: 42px; border: none; border-radius: 12px;
  background: var(--accent); color: #fff; font-size: 15px; font-weight: 700;
  cursor: pointer; transition: 0.15s;
}
.btn-primary:active { transform: scale(0.98); }
.btn-ghost {
  flex: 0 0 auto; height: 42px; padding: 0 20px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--surface); color: var(--text-2);
  font-size: 14px; cursor: pointer;
}
.intro-block { white-space: pre-wrap; font-size: 14px; color: var(--text-2); line-height: 1.9; }
.intro-block.clamp {
  display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden;
  white-space: normal;
}
.intro-toggle { color: var(--accent); font-size: 13px; background: none; border: none; cursor: pointer; padding: 6px 0 0; }

/* 章节列表 */
.toc-panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.toc-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px; border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.toc-toolbar .count { font-size: 12px; color: var(--text-3); }
.toc-toolbar .ops { display: flex; gap: 4px; }
.toc-toolbar button {
  border: none; background: transparent; color: var(--text-2);
  font-size: 12.5px; padding: 5px 10px; border-radius: 7px; cursor: pointer;
}
.toc-toolbar button:hover { background: var(--surface-2); }
.toc-list { max-height: 420px; overflow-y: auto; }
.toc-item {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 11px 14px; border-bottom: 1px solid var(--line);
  font-size: 13.5px; cursor: pointer; transition: background 0.12s;
}
.toc-item:last-child { border-bottom: none; }
.toc-item:hover { background: var(--surface-2); }
.toc-item.cur { color: var(--accent); font-weight: 700; }
.toc-item .idx { color: var(--text-3); font-size: 11px; flex: 0 0 auto; }
.toc-item .name { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.toc-item .dur { color: var(--text-3); font-size: 11.5px; flex: 0 0 auto; }

/* ------------------------------------------------ 阅读器 ---- */
.reader-body { background: var(--bg); }
.reader-wrap { max-width: 720px; margin: 0 auto; padding: 24px 20px 40px; }
.reader-head { text-align: center; color: var(--text-3); font-size: 12px; }
.reader-title { font-size: 20px; font-weight: 800; margin: 14px 0 22px; text-align: center; }
.reader-content { font-size: var(--reader-fs, 18px); line-height: 1.95; letter-spacing: 0.4px; }
.reader-content p { margin: 0 0 1.1em; text-indent: 2em; text-align: justify; }
.reader-nav { display: flex; gap: 12px; margin: 34px 0 10px; }
.reader-nav button {
  flex: 1; height: 44px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--surface); color: var(--text); font-size: 14px; cursor: pointer;
}
.reader-nav button:disabled { opacity: 0.4; cursor: default; }
.reader-nav .go-back { flex: 0 0 88px; }
.reader-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(12px); border-top: 1px solid var(--line);
  transform: translateY(110%); transition: transform 0.25s;
}
.reader-bar.show { transform: translateY(0); }
.reader-bar button {
  border: none; background: transparent; color: var(--text-2); font-size: 13px;
  padding: 6px 12px; border-radius: 8px; cursor: pointer;
}
.reader-bar button:hover { background: var(--surface-2); }
.reader-bar .fs-ctrl { display: flex; align-items: center; gap: 2px; }
.reader-bar .fs-ctrl span { font-size: 12px; color: var(--text-3); padding: 0 2px; }

/* ------------------------------------------------ 通用抽屉 ---- */
.drawer-mask {
  position: fixed; inset: 0; z-index: 90; background: rgba(0,0,0,0.45);
  opacity: 0; pointer-events: none; transition: opacity 0.22s;
}
.drawer-mask.show { opacity: 1; pointer-events: auto; }
.drawer {
  position: fixed; z-index: 91; background: var(--surface);
  transition: transform 0.26s cubic-bezier(0.22, 0.8, 0.3, 1);
  display: flex; flex-direction: column;
}
.drawer.right {
  top: 0; right: 0; bottom: 0; width: min(360px, 88vw);
  border-radius: 18px 0 0 18px; transform: translateX(105%);
}
.drawer.bottom {
  left: 0; right: 0; bottom: 0; max-height: 72vh;
  border-radius: 18px 18px 0 0; transform: translateY(105%);
}
.drawer.show { transform: translate(0, 0); }
.drawer-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px 10px; border-bottom: 1px solid var(--line); flex: 0 0 auto;
}
.drawer-head .tt { font-weight: 800; font-size: 15px; }
.drawer-head .x {
  border: none; background: var(--surface-2); color: var(--text-2);
  width: 28px; height: 28px; border-radius: 50%; cursor: pointer; font-size: 13px;
}
.drawer-body { flex: 1; overflow-y: auto; padding: 6px 0 calc(14px + env(safe-area-inset-bottom)); }

/* ------------------------------------------------ toast ---- */
#toast {
  position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%) translateY(20px);
  background: rgba(20,20,24,0.9); color: #fff; font-size: 13px;
  padding: 9px 18px; border-radius: 99px; z-index: 999;
  opacity: 0; pointer-events: none; transition: 0.25s; max-width: 80vw;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ------------------------------------------------ 页脚 ---- */
.site-footer {
  text-align: center; color: var(--text-3); font-size: 12px;
  padding: 26px 18px calc(26px + env(safe-area-inset-bottom));
}
.site-footer a { color: var(--text-2); }

/* ------------------------------------------------ PC 端优化 ---- */
@media (min-width: 900px) {
  :root { --header-h: 62px; }
  .container { padding-top: 20px; }
  .type-tabs { padding-top: 18px; }
  .type-tab { padding: 8px 22px; font-size: 15px; }
  .section-title { font-size: 19px; }
  .card .t { font-size: 14px; }

  /* 详情页：简介 + 目录双栏 */
  .detail-cols {
    display: grid; grid-template-columns: minmax(260px, 2fr) 3fr;
    gap: 30px; align-items: start;
  }
  .detail-cols .section { margin-top: 6px; }
  .detail-cover { flex: 0 0 176px; width: 176px; border-radius: 16px; }
  .detail-title { font-size: 26px; }
  .detail-actions { max-width: 460px; }
  .toc-panel { position: sticky; top: calc(var(--header-h) + 14px); }
  .toc-list { max-height: 560px; }

  /* 首页行卡片与加载更多 */
  .row-card { padding: 14px 16px; }
  .load-more { padding: 10px 44px; font-size: 14px; }
}

/* ------------------------------------------------ 移动端适配 ---- */
@media (max-width: 640px) {
  .header-inner { padding: 0 12px; gap: 8px; }
  .logo span.txt { display: none; }
  /* 分组筛选条：移动端分组名上置，入口换行 */
  .fgroup { flex-direction: column; gap: 6px; padding: 8px 0; }
  .fgroup-name { flex: none; padding-top: 0; }
  .container { padding: 10px 14px 50px; }
  .detail-hero { gap: 14px; }
  .detail-cover { flex: 0 0 104px; width: 104px; }
  .detail-title { font-size: 18px; }
  .type-tabs { padding: 12px 14px 0; }
}
