/* ═══════════════════════════════════════════
   三国阁 · 移动端沉浸式阅读样式
   仅在 max-width: 768px 生效
   ═══════════════════════════════════════════ */
@media (max-width: 768px) {
  /* ── CSS 变量 ── */
  :root {
    --topbar-h: 0px;
    --mobile-bottom-h: 56px;
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --reading-font-size: 17px;
    --reading-line-height: 2;
    --reading-bg: #faf7f0;
    --reading-text: #2b2622;
    --reading-width: 100%;
  }

  /* ── 暗色模式变量 ── */
  body.dark-mode {
    --bg: #1a1a1a;
    --card: #242424;
    --primary: #d45c4a;
    --primary-dark: #b84535;
    --ink: #ddd;
    --muted: #999;
    --border: #333;
    --reading-bg: #1e1e1e;
    --reading-text: #ccc;
  }
  body.dark-mode .mobile-header,
  body.dark-mode .mobile-tabbar {
    background: rgba(30,30,30,.97);
  }
  body.dark-mode .search-btn {
    background: #333;
    color: #ddd;
  }
  body.dark-mode pre.classical {
    background: #2a2a2a;
    color: #ccc;
    border-left-color: var(--primary);
  }
  body.dark-mode .detail-section p,
  body.dark-mode .md {
    color: var(--reading-text);
  }
  body.dark-mode .detail-card-page {
    background: var(--reading-bg);
  }
  body.dark-mode .comments {
    background: var(--bg);
  }
  body.dark-mode .comment {
    background: var(--card);
  }
  body.dark-mode .audio-bar {
    background: var(--card);
    border-top-color: var(--border);
  }

  /* ── 全局重置 ── */
  html { font-size: 15px; }
  body { padding-bottom: calc(var(--mobile-bottom-h) + var(--safe-bottom) + 8px); }

  /* ── 隐藏桌面顶栏 ── */
  header.topbar { display: none !important; }

  /* ═══ 沉浸阅读进度条 ═══ */
  .reading-progress {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: 3px;
    z-index: 999;
    background: transparent;
  }
  .reading-progress-bar {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--primary), #e67e22);
    border-radius: 0 2px 2px 0;
    transition: width .1s linear;
  }

  /* ═══ 移动端顶栏 ═══ */
  .mobile-header {
    display: flex !important;
    align-items: center;
    gap: 6px;
    padding: 10px 12px;
    background: rgba(255,255,255,.97);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 40;
    transition: transform .3s ease;
  }
  .mobile-header.hidden { transform: translateY(-100%); }
  .mobile-header .brand {
    font-family: var(--serif);
    font-weight: 700;
    font-size: 17px;
    color: var(--primary);
    text-decoration: none;
    letter-spacing: 1px;
    white-space: nowrap;
  }
  .mobile-header .spacer { flex: 1; }
  .mobile-header .header-btn {
    width: 34px; height: 34px;
    border: 0; background: #f1ece1;
    border-radius: 50%;
    font-size: 15px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex: none;
    transition: background .15s;
    -webkit-tap-highlight-color: transparent;
  }
  .mobile-header .header-btn:active { background: #ddd; }
  .mobile-header .back-btn {
    width: 34px; height: 34px;
    border: 0; background: transparent;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--ink);
    text-decoration: none;
    flex: none;
  }

  /* ═══ 阅读模式控制按钮组 ═══ */
  .reading-controls {
    display: flex;
    gap: 4px;
  }
  .reading-controls .header-btn {
    width: 30px; height: 30px;
    font-size: 13px;
  }

  /* ═══ 底部导航栏（带自动隐藏） ═══ */
  .mobile-tabbar {
    display: flex !important;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    z-index: 100;
    background: rgba(255,255,255,.97);
    backdrop-filter: blur(12px);
    border-top: 1px solid var(--border);
    padding: 6px 0 calc(6px + var(--safe-bottom));
    justify-content: space-around;
    transition: transform .3s ease;
  }
  .mobile-tabbar.hidden { transform: translateY(100%); }
  .mobile-tabbar a {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 6px 0;
    text-decoration: none;
    color: var(--muted);
    font-size: 10px;
    -webkit-tap-highlight-color: transparent;
    transition: color .15s;
  }
  .mobile-tabbar a.active { color: var(--primary); }
  .mobile-tabbar a .tab-icon { font-size: 20px; line-height: 1; }

  /* ── 首页瀑布流 → 单列 ── */
  .feed {
    column-count: 1 !important;
    column-gap: 0 !important;
    padding: 0 12px 12px;
    margin-top: 0;
  }
  .card { margin-bottom: 12px; }
  .card .cover.placeholder { height: 120px; font-size: 36px; }
  .card .body { padding: 10px 12px; }
  .card .title { font-size: 15px; }
  .card .excerpt { font-size: 13px; -webkit-line-clamp: 2; }

  /* ── 分类标签横向滚动 ── */
  .tabs {
    overflow-x: auto;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding: 0 12px;
    margin: 8px 0;
    display: block;
  }
  .tabs::-webkit-scrollbar { display: none; }
  .tab {
    display: inline-block;
    font-size: 13px;
    padding: 6px 16px;
    margin-right: 6px;
    white-space: nowrap;
  }

  /* ── 首页"继续阅读"横滑模块 ── */
  .read-more-wrap { margin: 8px 12px; }
  .read-more-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
  }
  .read-more-head h3 {
    font-family: var(--serif);
    font-size: 15px;
    margin: 0;
    color: var(--ink);
  }
  .read-more-head a {
    font-size: 12px;
    color: var(--primary);
    text-decoration: none;
  }
  .read-more-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    display: flex;
    gap: 10px;
  }
  .read-more-scroll::-webkit-scrollbar { display: none; }
  .read-more-card {
    flex: none;
    width: 140px;
    background: var(--card);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,.06);
  }
  .read-more-card .rm-cover {
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-family: var(--serif);
    font-size: 26px;
    font-weight: 700;
  }
  .read-more-card .rm-body { padding: 8px 10px; }
  .read-more-card .rm-title {
    font-size: 12px;
    font-weight: 600;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }
  .read-more-card .rm-meta {
    font-size: 10px;
    color: var(--muted);
    margin-top: 2px;
  }

  /* ── 书籍目录页 ── */
  .book-page { flex-direction: column; padding: 0 0 16px; }
  .book-sidebar { display: none !important; }
  .book-content { width: 100%; }
  .book-head {
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 16px;
    margin: 0 12px 12px;
    border-radius: 14px;
  }
  .book-cover { width: 72px; height: 100px; font-size: 32px; }
  .book-title { font-size: 22px; }
  .book-sub { justify-content: center; }
  .book-intro { text-align: left; }
  .book-search { font-size: 14px; padding: 8px 12px; }
  .toc-section { scroll-margin-top: 12px; }
  .toc-sec-title { font-size: 16px; }

  /* 移动端分卷导航标签 */
  .mobile-toc-tabs {
    display: flex;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    gap: 6px;
    padding: 8px 12px;
    background: #fff;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 30;
  }
  .mobile-toc-tabs::-webkit-scrollbar { display: none; }
  .mobile-toc-tab {
    flex: none;
    font-size: 12px;
    padding: 5px 14px;
    border-radius: 20px;
    background: #f1ece1;
    color: var(--muted);
    text-decoration: none;
    white-space: nowrap;
    font-weight: 600;
    transition: all .15s;
  }
  .mobile-toc-tab.active {
    background: var(--primary);
    color: #fff;
  }

  /* ═══ 详情页 — 沉浸阅读 ═══ */
  .detail-page { padding: 0; margin: 0; }
  .detail-card-page {
    border-radius: 0;
    padding: 20px 18px;
    box-shadow: none;
    border-bottom: 1px solid var(--border);
    background: var(--reading-bg);
    max-width: var(--reading-width);
    margin: 0 auto;
    transition: background .3s;
  }
  .detail-head {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 10px;
  }
  .detail-title {
    font-size: 22px;
    line-height: 1.4;
    margin: 0;
    flex: 1;
    font-family: var(--serif);
    color: var(--ink);
  }
  .btn-share {
    align-self: flex-start;
    font-size: 12px;
    padding: 4px 10px;
    white-space: nowrap;
    flex: none;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--card);
    color: var(--primary);
    cursor: pointer;
  }
  .detail-meta {
    font-size: 12px;
    flex-wrap: wrap;
    gap: 6px;
    color: var(--muted);
    margin-bottom: 14px;
  }
  .detail-tags { margin: 12px 0 4px; display: flex; flex-wrap: wrap; gap: 6px; }
  .tag { font-size: 12px; color: var(--primary); background: rgba(192,57,43,.08); padding: 3px 10px; border-radius: 16px; }

  /* 详情页原文+译文 — 沉浸阅读字体 */
  pre.classical {
    font-size: calc(var(--reading-font-size) * 0.95);
    line-height: var(--reading-line-height);
    padding: 14px 16px;
    margin: 0;
    font-family: var(--serif);
    background: rgba(0,0,0,.03);
    border-left: 4px solid var(--primary);
    border-radius: 8px;
    color: var(--reading-text);
    white-space: pre-wrap;
    word-wrap: break-word;
  }
  .detail-section {
    margin-top: 20px;
  }
  .detail-section p {
    font-size: var(--reading-font-size);
    line-height: var(--reading-line-height);
    margin: 0 0 .8em;
    white-space: pre-wrap;
    color: var(--reading-text);
  }
  .sec-label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    font-weight: 700;
    color: #fff;
    background: var(--primary);
    padding: 2px 10px;
    border-radius: 14px;
    margin-bottom: 8px;
  }
  .read-btn {
    font-family: var(--sans);
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    background: rgba(255,255,255,.92);
    color: var(--primary);
    border: none;
    padding: 2px 8px;
    border-radius: 12px;
    white-space: nowrap;
    -webkit-tap-highlight-color: transparent;
  }
  .read-btn:active { opacity: .7; }

  /* 内容区块间隔 */
  .detail-section + .detail-section {
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
  }

  /* 图片画廊 */
  .detail-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 6px;
    margin: 14px 0;
  }
  .detail-gallery img {
    width: 100%;
    border-radius: 10px;
    object-fit: cover;
    max-height: 280px;
  }

  /* 评论 */
  .comments { padding: 18px 16px; }
  .comments-title { font-size: 16px; font-family: var(--serif); }
  .comment-form {
    background: var(--card);
    border-radius: 14px;
    padding: 14px;
    box-shadow: 0 1px 3px rgba(0,0,0,.05);
  }
  .comment-form .cmt-author {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 8px 12px;
    font-size: 14px;
    font-family: inherit;
    outline: none;
    background: #fcfbf8;
  }
  .comment-form .cmt-content {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 10px;
    margin-top: 8px;
    padding: 8px 12px;
    font-size: 14px;
    font-family: inherit;
    outline: none;
    resize: vertical;
    background: #fcfbf8;
  }
  .cmt-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 8px;
  }
  .cmt-actions .form-msg { margin: 0; margin-right: auto; font-size: 12px; }
  .comment-list { list-style: none; padding: 0; margin: 14px 0 0; }
  .comment {
    background: var(--card);
    border-radius: 12px;
    padding: 12px 14px;
    margin-bottom: 10px;
    box-shadow: 0 1px 2px rgba(0,0,0,.04);
  }
  .cmt-head { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
  .cmt-name { color: var(--ink); font-weight: 600; }
  .cmt-body { font-size: 14px; line-height: 1.7; }
  .cmt-empty { color: var(--muted); text-align: center; padding: 20px; font-size: 13px; }

  /* 弹窗 */
  .modal-card {
    margin: 2vh auto;
    max-width: calc(100% - 16px);
    padding: 20px 18px;
    border-radius: 14px;
  }

  /* ═══ 底部音频播放条 ═══ */
  .audio-bar {
    display: flex !important;
    position: fixed;
    bottom: calc(var(--mobile-bottom-h) + var(--safe-bottom));
    left: 0; right: 0;
    z-index: 90;
    background: var(--card);
    border-top: 1px solid var(--border);
    padding: 8px 14px;
    align-items: center;
    gap: 10px;
    transform: translateY(100%);
    transition: transform .3s ease;
    box-shadow: 0 -2px 10px rgba(0,0,0,.06);
  }
  .audio-bar.active { transform: translateY(0); }
  .audio-bar .ab-title {
    flex: 1;
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .audio-bar .ab-status {
    font-size: 11px;
    color: var(--muted);
    white-space: nowrap;
  }
  .audio-bar .ab-ctrl {
    width: 40px; height: 40px;
    border: 0; background: var(--primary);
    color: #fff; border-radius: 50%;
    font-size: 18px; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    flex: none;
    transition: transform .12s;
  }
  .audio-bar .ab-ctrl:active { transform: scale(.92); }

  /* 发帖表单 */
  .compose-title { font-size: 17px; }
  .field input, .field textarea, .field select { font-size: 15px; padding: 10px; }

  /* 通用工具类 */
  .hide-mobile { display: none !important; }
}
