/* ==========================================================================
   格物斋 · 掌上卷 (Mobile Edition)
   --------------------------------------------------------------------------
   手机端重设计层：仅作用于窄屏 (max-width: 900px)，桌面端保持 1:1 复刻不变。
   设计语言延续国风科技感：宣纸底 / 朱砂红 / 松墨绿 / 描金 / 青碧。
   在 tokens.css + main.css 之后加载，只做「覆盖 + 移动端专属组件」。
   ========================================================================== */

/* ---------------------------------------------------------------------------
   0. 移动端设计变量
   --------------------------------------------------------------------------- */
@media (max-width: 900px) {
  :root {
    /* 间距节奏：手机上比桌面更紧凑 */
    --m-gutter: 18px;
    --m-bar-h: 56px;         /* 顶部栏 */
    --m-tab-h: 60px;         /* 底部标签栏 */
    --m-safe-b: env(safe-area-inset-bottom, 0px);
    --m-radius: 14px;
    --m-radius-sm: 10px;
    --m-shadow: 0 6px 24px rgba(23, 56, 61, 0.10);
    --m-shadow-soft: 0 2px 10px rgba(23, 56, 61, 0.06);
    --m-border: rgba(23, 56, 61, 0.12);
    --m-ink-mute: rgba(34, 34, 34, 0.56);
    /* 正文阅读字号（手机更舒适） */
    --m-reading-size: 17px;
    --m-reading-leading: 1.95;
  }

  html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    /* 通栏滑动区使用负边距，需裁剪水平溢出，避免布局视口被撑宽 */
    overflow-x: clip;
  }

  body {
    padding-top: var(--m-bar-h);
    /* 为底部标签栏 + 安全区留白 */
    padding-bottom: calc(var(--m-tab-h) + var(--m-safe-b) + 8px);
    font-size: 16px;
    line-height: 1.75;
    overflow-x: clip;
    -webkit-tap-highlight-color: transparent;
  }

  /* 承载通栏滑动区的区块同样裁剪 */
  .gw-section,
  .gw-section--band,
  .site-main {
    overflow-x: clip;
  }

  /* 不支持 clip 的老浏览器退回 hidden */
  @supports not (overflow-x: clip) {
    html, body, .gw-section, .gw-section--band, .site-main { overflow-x: hidden; }
  }

  .sci-container {
    padding-left: var(--m-gutter);
    padding-right: var(--m-gutter);
    max-width: 100%;
  }

  /* 触控友好：最小点击尺寸 */
  a, button, input, select, .gw-tag-filter-btn {
    touch-action: manipulation;
  }

  img { max-width: 100%; height: auto; }
}

/* ---------------------------------------------------------------------------
   1. 顶部栏：更紧凑，可滚动隐藏（阅读沉浸）
   --------------------------------------------------------------------------- */
@media (max-width: 900px) {
  .gw-navbar {
    background: rgba(255, 253, 248, 0.94);
    -webkit-backdrop-filter: saturate(1.4) blur(14px);
    backdrop-filter: saturate(1.4) blur(14px);
    border-bottom: 1px solid var(--m-border);
    transition: transform 0.32s var(--sci-ease-expo), box-shadow 0.3s ease;
  }
  .gw-nav-inner {
    height: var(--m-bar-h);
    padding: 0 var(--m-gutter);
    max-width: 100%;
  }
  .gw-brand { gap: 9px; }
  .gw-brand-mark {
    width: 32px; height: 32px;
    border-radius: 9px;
    box-shadow: 0 4px 12px rgba(178, 58, 48, 0.20);
  }
  .gw-brand-txt { font-size: 1.16rem; }
  .gw-brand-sub { font-size: 0.64rem; margin-top: 0; }

  .gw-search-btn, .gw-menu-btn {
    padding: 9px;
    border-radius: 10px;
    min-width: 40px; min-height: 40px;
    justify-content: center;
  }
  .gw-search-btn:active, .gw-menu-btn:active {
    background: rgba(178, 58, 48, 0.08);
    color: var(--sci-vernilion);
  }

  /* 搜索 / 菜单浮层：全宽卡纸风 */
  .gw-search-drop, .gw-mobile-menu {
    top: var(--m-bar-h);
    max-height: calc(100dvh - var(--m-bar-h));
    padding: 16px var(--m-gutter) 20px;
    background: rgba(255, 251, 248, 0.99);
    -webkit-backdrop-filter: blur(16px);
    backdrop-filter: blur(16px);
    box-shadow: 0 20px 44px rgba(23, 56, 61, 0.16);
  }
  .gw-search-drop input {
    font-size: 16px; /* ≥16px 防止 iOS 自动缩放 */
    padding: 14px 16px;
    border-radius: var(--m-radius-sm);
  }
  .gw-mobile-menu a {
    font-size: 1rem;
    padding: 15px 2px;
    letter-spacing: 0.01em;
  }
  .gw-mobile-menu .gw-mobile-primary-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 1.08rem;
  }
  .gw-mobile-menu .gw-mobile-primary-link::after {
    content: '›';
    color: var(--sci-ink-faint);
    font-size: 1.3rem;
    line-height: 1;
  }

  /* 滚动隐藏态：顶部栏上移，进度条/吸顶标题栏同步上移 */
  .gw-nav-hidden .gw-navbar { transform: translateY(-100%); }
  .gw-nav-hidden .gw-read-progress { transform: translateY(calc(-1 * var(--m-bar-h))); }
  .gw-nav-hidden .gw-readbar { transform: translateY(-130%); }
  .gw-nav-hidden .gw-readbar.is-visible { transform: translateY(calc(-1 * var(--m-bar-h))); }
}

/* ---------------------------------------------------------------------------
   2. 底部标签栏（移动端专属 · APP 式导航）
   --------------------------------------------------------------------------- */
/* 桌面端兜底：即使移动端元素已注入，也一律隐藏，保证 1:1 复刻不受影响 */
.gw-tabbar,
.gw-readbar,
.gw-read-progress,
.gw-mobile-backtop { display: none; }

@media (max-width: 900px) {
  .gw-tabbar {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 9990;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    height: calc(var(--m-tab-h) + var(--m-safe-b));
    padding-bottom: var(--m-safe-b);
    background: rgba(255, 253, 248, 0.96);
    -webkit-backdrop-filter: saturate(1.5) blur(18px);
    backdrop-filter: saturate(1.5) blur(18px);
    border-top: 1px solid var(--m-border);
    box-shadow: 0 -6px 24px rgba(23, 56, 61, 0.08);
  }
  .gw-tabbar-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    color: var(--m-ink-mute);
    font-size: 0.66rem;
    letter-spacing: 0.04em;
    text-decoration: none;
    position: relative;
    transition: color 0.2s ease;
  }
  .gw-tabbar-item svg {
    width: 22px; height: 22px;
    stroke-width: 1.6;
    transition: transform 0.24s var(--sci-ease-expo);
  }
  .gw-tabbar-item:active svg { transform: scale(0.9); }
  .gw-tabbar-item.is-active { color: var(--sci-vernilion); font-weight: 600; }
  .gw-tabbar-item.is-active svg { stroke-width: 2; }
  .gw-tabbar-item.is-active::before {
    content: '';
    position: absolute;
    top: 0;
    width: 22px; height: 2.5px;
    border-radius: 0 0 3px 3px;
    background: var(--sci-vernilion);
  }
}

/* ---------------------------------------------------------------------------
   3. 首页 Hero：压缩高度，统计改横向胶囊
   --------------------------------------------------------------------------- */
@media (max-width: 900px) {
  .gw-hero--editorial {
    padding: 34px 0 30px;
    min-height: auto;
  }
  .gw-hero-art {
    opacity: 0.5;
    object-position: 62% center;
  }
  .gw-hero--editorial .gw-hero-inner {
    padding: 0 var(--m-gutter);
    grid-template-columns: 1fr;
    gap: 22px;
  }
  .gw-hero--editorial .gw-hero-kicker {
    font-size: 0.68rem;
    letter-spacing: 0.22em;
    margin-bottom: 12px;
  }
  .gw-hero--editorial .gw-hero-title {
    font-size: clamp(3.1rem, 19vw, 4.4rem);
    line-height: 1.02;
    letter-spacing: 0.01em;
    margin: 0 0 16px;
  }
  .gw-hero--editorial .gw-hero-subtitle {
    font-size: 0.98rem;
    line-height: 1.8;
    margin-bottom: 22px;
    max-width: 34em;
  }
  .gw-hero--editorial .gw-hero-actions {
    flex-direction: column;
    align-items: stretch;
    gap: 11px;
  }
  .gw-hero--editorial .gw-hero-actions a {
    width: 100%;
    text-align: center;
    padding: 14px 20px;
    border-radius: var(--m-radius-sm);
    font-size: 0.95rem;
    min-height: 48px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
  /* 右侧 TODAY'S DESK 面板：卡纸 + 三宫格统计 */
  .gw-hero-panel {
    max-width: 100%;
    padding: 20px 18px;
    border-radius: var(--m-radius);
    border: 1px solid var(--m-border);
    background: rgba(255, 253, 248, 0.94);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
    box-shadow: var(--m-shadow-soft);
  }
  .gw-hero-panel h2 { font-size: 1.16rem; line-height: 1.5; }
  .gw-hero-panel p { font-size: 0.9rem; line-height: 1.7; }
  .gw-hero-stats {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    margin-top: 16px;
  }
  .gw-stat {
    padding: 12px 6px;
    border-radius: var(--m-radius-sm);
    background: rgba(255, 255, 255, 0.72);
    border: 1px solid var(--m-border);
    text-align: center;
  }
  .gw-stat strong { font-size: 1.5rem; display: block; line-height: 1.1; }
  .gw-stat span {
    font-size: 0.68rem;
    white-space: normal;
    margin-top: 4px;
    color: var(--m-ink-mute);
    display: block;
  }
}

/* ---------------------------------------------------------------------------
   4. 区块标题与节奏
   --------------------------------------------------------------------------- */
@media (max-width: 900px) {
  .gw-section { padding: 40px 0; }
  .gw-section--tight { padding-top: 30px; }
  .gw-section-head-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    margin-bottom: 20px;
  }
  .gw-section-title { font-size: 1.5rem; line-height: 1.3; }
  .gw-kicker { font-size: 0.7rem; letter-spacing: 0.2em; margin-bottom: 8px; }
  .gw-section-more {
    font-size: 0.86rem;
    padding: 7px 0;
    color: var(--sci-azure);
  }
  .gw-section-more:active { color: var(--sci-vernilion); }
}

/* ---------------------------------------------------------------------------
   5. 卡片与网格：单列、通栏封面、更大触控面
   --------------------------------------------------------------------------- */
@media (max-width: 900px) {
  /* 编辑精选 —— 头条卡通栏，其余改为「左图右文」紧凑行，显著缩短页面 */
  .gw-featured-grid--editorial { grid-template-columns: 1fr; gap: 14px; }
  .gw-featured-card {
    border-radius: var(--m-radius);
    overflow: hidden;
    border: 1px solid var(--m-border);
    background: var(--sci-paper-warm);
    box-shadow: var(--m-shadow-soft);
  }
  .gw-featured-card:active { transform: scale(0.988); }
  .gw-featured-card--lead .gw-featured-cover { height: 208px; }
  .gw-featured-card--lead .gw-featured-body { padding: 17px 16px 19px; }
  .gw-featured-card--lead .gw-featured-title { font-size: 1.32rem; }

  /* 非头条：左图右文 */
  .gw-featured-card:not(.gw-featured-card--lead) {
    display: grid;
    grid-template-columns: 116px minmax(0, 1fr);
    align-items: stretch;
  }
  .gw-featured-card:not(.gw-featured-card--lead) .gw-featured-cover,
  .gw-featured-card:not(.gw-featured-card--lead) .gw-featured-cover img {
    height: 100%;
    min-height: 116px;
    width: 116px;
  }
  .gw-featured-card:not(.gw-featured-card--lead) .gw-featured-cover img {
    object-fit: cover;
  }
  .gw-featured-card:not(.gw-featured-card--lead) .gw-featured-body {
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    justify-content: center;
  }
  .gw-featured-card:not(.gw-featured-card--lead) .gw-featured-title {
    font-size: 1rem;
    line-height: 1.48;
    margin: 4px 0 6px;
    -webkit-line-clamp: 3;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }
  .gw-featured-card:not(.gw-featured-card--lead) .gw-featured-excerpt { display: none; }
  .gw-featured-card:not(.gw-featured-card--lead) .gw-featured-date { font-size: 0.72rem; }
  .gw-featured-body { padding: 16px; }
  .gw-featured-title { font-size: 1.16rem; line-height: 1.5; }
  .gw-featured-excerpt {
    font-size: 0.9rem;
    line-height: 1.75;
    -webkit-line-clamp: 3;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }
  .gw-featured-date { font-size: 0.78rem; }

  /* 六大领域 */
  .gw-board-grid--visual { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .gw-board-grid--visual .gw-board-card {
    min-height: 168px;
    border-radius: var(--m-radius);
    padding: 16px 14px;
  }
  .gw-board-grid--visual .gw-board-name { font-size: 1.1rem; }
  .gw-board-grid--visual .gw-board-en { font-size: 0.62rem; }
  .gw-board-grid--visual .gw-board-desc { font-size: 0.78rem; line-height: 1.6; }
  .gw-board-grid--visual .gw-board-count { font-size: 0.68rem; }

  /* 阅读路径 */
  .gw-pathway-grid { grid-template-columns: 1fr; gap: 14px; }
  .gw-pathway-card {
    border-radius: var(--m-radius);
    padding: 22px 18px;
    min-height: auto;
  }
  .gw-pathway-card h3 { font-size: 1.2rem; }
  .gw-pathway-card p { font-size: 0.9rem; line-height: 1.72; }
  .gw-pathway-index { font-size: 2.6rem; opacity: 0.14; }

  /* 各板块最新：横向滑动卡片（每栏一屏宽） */
  .gw-board-articles-grid {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scroll-snap-type: x mandatory;
    margin: 0 calc(-1 * var(--m-gutter));
    padding: 2px var(--m-gutter) 8px;
    scrollbar-width: none;
  }
  .gw-board-articles-grid::-webkit-scrollbar { display: none; }
  .gw-board-article-card {
    flex: 0 0 84%;
    max-width: 340px;
    scroll-snap-align: start;
    border-radius: var(--m-radius);
    padding: 16px;
  }
  .gw-board-article-head { margin-bottom: 10px; }
  .gw-board-article-name { font-size: 1.06rem; }
  .gw-board-article-list li a {
    padding: 11px 0;
    min-height: 44px;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 8px;
  }

  /* 分类总览 */
  .gw-categories-grid { grid-template-columns: 1fr; gap: 12px; }
  .gw-category-strip {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scroll-snap-type: x mandatory;
    padding-bottom: 6px;
    margin: 0 calc(-1 * var(--m-gutter));
    padding-left: var(--m-gutter);
    padding-right: var(--m-gutter);
  }
  .gw-category-strip > * { scroll-snap-align: start; flex: 0 0 auto; }

  /* 顶部标签筛选：横向滚动药丸 */
  .gw-tag-filter {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    margin: 0 calc(-1 * var(--m-gutter));
    padding: 2px var(--m-gutter) 6px;
    scrollbar-width: none;
  }
  .gw-tag-filter::-webkit-scrollbar { display: none; }
  .gw-tag-filter-btn {
    flex: 0 0 auto;
    padding: 9px 16px;
    border-radius: 999px;
    min-height: 40px;
    font-size: 0.86rem;
  }
  .gw-archive-head { padding: 26px var(--m-gutter) 18px; }
  .gw-archive-title { font-size: 1.9rem; }
  .gw-archive-desc { font-size: 0.92rem; line-height: 1.72; }

  /* 归档列表卡（文章列表页 / 分类页 / 板块页）：紧凑「左图右文」 */
  .sci-card--list {
    grid-template-columns: 108px minmax(0, 1fr);
    border-radius: var(--m-radius);
    overflow: hidden;
    box-shadow: var(--m-shadow-soft);
  }
  .sci-card--list .sci-card-cover,
  .sci-card-cover {
    min-height: 0;
    height: 100%;
  }
  .sci-card--list .sci-card-cover img { height: 100%; }
  .sci-card-body { padding: 13px 14px; }
  .sci-card--list .sci-card-meta {
    margin-bottom: 7px;
    gap: 7px;
    font-size: 0.72rem;
  }
  .sci-card--list .entry-title {
    font-size: 1rem;
    line-height: 1.45;
    margin: 0 0 6px;
    -webkit-line-clamp: 3;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }
  .sci-card--list .entry-excerpt {
    font-size: 0.8rem;
    line-height: 1.6;
    -webkit-line-clamp: 2;
  }
  .sci-card--list .sci-card-meta time { font-size: 0.7rem; }
  .sci-card--list .sci-badge-tag { font-size: 0.7rem; padding: 2px 8px; }
  /* 附件式：无封面时正文占满 */
  .sci-card--list:not(:has(.sci-card-cover)) { grid-template-columns: 1fr; }
}

/* ---------------------------------------------------------------------------
   6. 文章阅读页：进度条 + 吸顶标题 + 目录抽屉 + 排版
   --------------------------------------------------------------------------- */
/* 阅读进度条 */
@media (max-width: 900px) {
  .gw-read-progress {
    position: fixed;
    top: var(--m-bar-h);
    left: 0;
    height: 3px;
    width: 0;
    z-index: 9995;
    display: block;
    background: linear-gradient(90deg, var(--sci-vernilion), var(--sci-gold));
    box-shadow: 0 0 8px rgba(178, 58, 48, 0.4);
    transition: width 0.1s linear;
    pointer-events: none;
  }

  /* 阅读页吸顶迷你标题栏（出现于正文滚动后） */
  .gw-readbar {
    position: fixed;
    top: var(--m-bar-h);
    left: 0; right: 0;
    z-index: 9980;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 var(--m-gutter);
    height: 48px;
    background: rgba(255, 253, 248, 0.96);
    -webkit-backdrop-filter: blur(14px);
    backdrop-filter: blur(14px);
    border-bottom: 1px solid var(--m-border);
    transform: translateY(-130%);
    transition: transform 0.3s var(--sci-ease-expo);
  }
  .gw-readbar.is-visible { transform: translateY(0); }
  .gw-readbar-title {
    flex: 1;
    min-width: 0;
    font-family: var(--sci-font-heading);
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--sci-ink-deep);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .gw-readbar-btn {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 7px 12px;
    border: 1px solid var(--m-border);
    border-radius: 999px;
    background: #fff;
    color: var(--sci-forest);
    font-size: 0.78rem;
    cursor: pointer;
    min-height: 34px;
  }
  .gw-readbar-btn:active { background: rgba(178, 58, 48, 0.07); }
  .gw-readbar-btn svg { width: 15px; height: 15px; }

  /* 正文排版 */
  .single .site-main { padding-top: 12px; }
  .single .sci-card {
    padding: 22px 18px 26px;
    border-radius: var(--m-radius);
    border: 1px solid var(--m-border);
    box-shadow: var(--m-shadow-soft);
  }
  .single .entry-title {
    font-size: 1.72rem;
    line-height: 1.32;
    letter-spacing: 0.005em;
    margin-bottom: 14px;
  }
  .single .sci-card-meta {
    flex-wrap: wrap;
    gap: 6px 12px;
    font-size: 0.8rem;
    margin-bottom: 18px;
  }
  .single .sci-featured img,
  .single .sci-featured {
    border-radius: var(--m-radius-sm);
    margin-bottom: 20px;
  }
  .single .entry-content {
    font-size: var(--m-reading-size);
    line-height: var(--m-reading-leading);
    color: #2c2c2c;
    letter-spacing: 0.008em;
  }
  .single .entry-content p { margin: 0 0 1.15em; }
  .single .entry-content h2 {
    font-size: 1.34rem;
    line-height: 1.42;
    margin: 2em 0 0.7em;
    padding-top: 0.5em;
    border-top: 1px solid var(--m-border);
  }
  .single .entry-content h3 {
    font-size: 1.13rem;
    line-height: 1.5;
    margin: 1.7em 0 0.6em;
  }
  .single .entry-content h4 { font-size: 1.02rem; margin: 1.4em 0 0.5em; }
  .single .entry-content blockquote {
    margin: 1.3em 0;
    padding: 12px 16px;
    border-left: 3px solid var(--sci-vernilion);
    background: rgba(178, 58, 48, 0.045);
    border-radius: 0 var(--m-radius-sm) var(--m-radius-sm) 0;
    font-size: 0.96rem;
  }
  .single .entry-content ul,
  .single .entry-content ol { padding-left: 1.25em; }
  .single .entry-content li+li { margin-top: 0.45em; }
  .single .entry-content a {
    color: var(--sci-azure);
    border-bottom: 1px solid rgba(47, 116, 128, 0.3);
  }
  /* 代码块通栏可横滑 */
  .single .entry-content pre {
    margin: 1.3em calc(-1 * var(--m-gutter));
    border-radius: 0;
    padding: 15px var(--m-gutter);
    font-size: 0.82rem;
    line-height: 1.62;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .single .entry-content code { font-size: 0.86em; }
  /* 表格横滑 */
  .single .entry-content table {
    display: block;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    font-size: 0.84rem;
    border-radius: var(--m-radius-sm);
  }
  .single .entry-content th,
  .single .entry-content td { padding: 9px 12px; white-space: nowrap; }
  /* 图片通栏 */
  .single .entry-content figure img,
  .single .entry-content .sci-zoomable {
    border-radius: var(--m-radius-sm);
  }
  /* KaTeX 公式横滑，避免溢出 */
  .single .entry-content .sci-katex-block,
  .single .entry-content .katex-display {
    overflow-x: auto;
    overflow-y: hidden;
    padding: 4px 0;
  }
  /* KaTeX 的无障碍 MathML 副本在窄屏会以「不可见但很宽」的形态撑大布局视口，
     导致部分移动浏览器 shrink-to-fit 缩小整页。用尺寸包含隔离，既消除溢出，
     又保留元素本身（不破坏屏幕阅读器语义）。*/
  .katex .katex-mathml,
  .katex-mathml {
    contain: strict !important;
    width: 0 !important;
    height: 0 !important;
    overflow: hidden !important;
  }

  /* 目录：改为吸底抽屉 */
  .gw-toc-panel {
    margin: 4px 0 20px;
    border-radius: var(--m-radius-sm);
  }
  .gw-toc-toggle-btn {
    width: 100%;
    justify-content: center;
    min-height: 46px;
    font-size: 0.9rem;
    border-radius: var(--m-radius-sm);
  }
  /* 当抽屉被打开时抬高 */
  body.gw-toc-open .gw-toc-mobile-nav {
    display: block !important;
  }
  .gw-toc-mobile-nav {
    margin-top: 10px;
    max-height: 46vh;
    overflow-y: auto;
    overscroll-behavior: contain;
  }
  .gw-toc-mobile-nav .gw-toc-item a {
    padding: 11px 4px;
    min-height: 44px;
    display: flex;
    align-items: center;
    font-size: 0.92rem;
  }

  /* 上一篇 / 下一篇 */
  .gw-post-nav { grid-template-columns: 1fr; gap: 10px; }
  .gw-post-nav a {
    padding: 15px 16px;
    border-radius: var(--m-radius-sm);
    min-height: 64px;
  }

  /* 相关阅读 */
  .gw-related-grid { grid-template-columns: 1fr; gap: 12px; }

  /* 返回顶部悬浮按钮让位于底部标签栏 */
  .gw-backtop, .sci-backtop, #back-top, .back-to-top {
    bottom: calc(var(--m-tab-h) + var(--m-safe-b) + 14px) !important;
  }
}

/* ---------------------------------------------------------------------------
   6b. 返回顶部悬浮按钮
   --------------------------------------------------------------------------- */
@media (max-width: 900px) {
  .gw-mobile-backtop {
    position: fixed;
    right: 14px;
    bottom: calc(var(--m-tab-h) + var(--m-safe-b) + 76px);
    z-index: 9400;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    border: 1px solid var(--m-border);
    border-radius: 50%;
    background: rgba(255, 253, 248, 0.96);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    color: var(--sci-forest);
    box-shadow: var(--m-shadow);
    opacity: 0;
    transform: translateY(10px) scale(0.9);
    pointer-events: none;
    transition: opacity 0.25s ease, transform 0.25s var(--sci-ease-expo);
    cursor: pointer;
  }
  .gw-mobile-backtop.is-visible {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
  }
  .gw-mobile-backtop:active {
    background: rgba(178, 58, 48, 0.08);
    color: var(--sci-vernilion);
  }
}

/* ---------------------------------------------------------------------------
   7. 仿真实验室 / 论文翻译 / 科技速览
   --------------------------------------------------------------------------- */
@media (max-width: 900px) {
  /* 实验室 */
  .gw-lab-workbench { border-radius: var(--m-radius); margin-bottom: 40px; }
  .gw-lab-head { padding: 20px 18px 14px; gap: 10px; }
  .gw-lab-title { font-size: 1.4rem; }
  .gw-lab-tabs {
    gap: 18px;
    padding: 0 18px;
    overflow-x: auto;
    scrollbar-width: none;
  }
  .gw-lab-tabs::-webkit-scrollbar { display: none; }
  .gw-lab-tab { flex: 0 0 auto; padding: 12px 0; }
  .gw-lab-workspace { display: flex; flex-direction: column; min-height: 0; }
  .gw-lab-controls {
    padding: 18px;
    border-right: 0;
    border-bottom: 1px solid var(--m-border);
  }
  .gw-lab-control-list { gap: 16px; }
  .gw-lab-control input[type=range] { height: 32px; }
  /* 画布固定比例，避免过高 */
  .gw-lab-stage, .gw-lab-canvas {
    height: auto;
    min-height: 0;
    aspect-ratio: 4 / 3;
  }
  .gw-lab-stage canvas, .gw-lab-canvas canvas { width: 100% !important; height: 100% !important; }
  .gw-lab-actions { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; margin-top: 16px; }
  .gw-lab-action { min-height: 44px; border-radius: var(--m-radius-sm); }
  .gw-lab-readout { display: block; padding: 18px; }
  .gw-lab-metrics { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
  .gw-lab-metrics > div,
  .gw-lab-metrics > div:first-child { padding: 0; border: 0; }
  .gw-lab-equation { margin-top: 16px; }
  .gw-lab-entry-grid { grid-template-columns: 1fr; gap: 14px; }
  .gw-lab-entry { border-radius: var(--m-radius); }
  .gw-experiments-head { padding-bottom: 22px; }
  .gw-project-grid { gap: 14px; }
  .gw-project-card-body { padding: 16px; }

  /* 翻译 */
  .gw-translate-shell { border-radius: var(--m-radius); margin-bottom: 44px; }
  .gw-translate-head { padding: 28px 18px 20px; }
  .gw-translate-head .gw-archive-title { font-size: 1.8rem; }
  .gw-translate-form { gap: 18px; padding: 20px 18px; }
  .gw-translate-fields { grid-template-columns: 1fr; gap: 14px; }
  .gw-translate-field input,
  .gw-translate-field select {
    font-size: 16px;
    min-height: 48px;
    border-radius: var(--m-radius-sm);
    width: 100%;
  }
  .gw-translate-actions { flex-direction: column; align-items: stretch; gap: 11px; }
  .gw-translate-submit { width: 100%; min-height: 48px; border-radius: var(--m-radius-sm); }
  .gw-translate-result, .gw-translate-restricted {
    flex-direction: column;
    align-items: stretch;
    padding: 18px;
    border-radius: var(--m-radius-sm);
  }
  .gw-translate-result-link { width: 100%; min-height: 46px; }
  .gw-pdf-picker { padding: 18px; border-radius: var(--m-radius-sm); }
  .gw-pdf-picker input { font-size: 16px; }

  /* 科技速览 */
  .sci-flash-strip--cards { grid-template-columns: 1fr; gap: 12px; }
  .sci-flash-item {
    border-radius: var(--m-radius);
    padding: 16px;
  }
  .sci-flash-item a { font-size: 0.98rem; line-height: 1.6; }

  /* 电子报 */
  .gw-newsletter--wide {
    grid-template-columns: 1fr;
    padding: 22px 18px;
    border-radius: var(--m-radius);
    gap: 16px;
  }
  .gw-newsletter-form { flex-direction: column; gap: 10px; }
  .gw-newsletter-form input {
    font-size: 16px;
    min-height: 48px;
    border-radius: var(--m-radius-sm);
    width: 100%;
  }
  .gw-newsletter-form button { width: 100%; min-height: 48px; border-radius: var(--m-radius-sm); }

  /* 页脚：紧凑双列，去掉大留白 */
  .gw-footer { padding: 34px 0 18px; }
  .gw-footer-inner { padding: 0 var(--m-gutter); }
  .gw-contact-section { padding-bottom: 22px; margin-bottom: 22px; }
  .gw-contact-section h3 { font-size: 1.08rem; }
  .gw-contact-section p { font-size: 0.88rem; }
  .gw-social-links { flex-direction: row; align-items: center; flex-wrap: wrap; gap: 10px; }
  .gw-social-link {
    min-height: 42px;
    padding: 9px 15px;
    border-radius: 999px;
    border: 1px solid var(--m-border);
  }
  .gw-footer-grid {
    grid-template-columns: 1fr 1fr;
    gap: 22px 16px;
  }
  .gw-footer-grid > div:first-child { grid-column: 1 / -1; }
  .gw-footer-grid h4 { font-size: 0.9rem; margin-bottom: 10px; }
  .gw-footer-grid ul { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 12px; }
  .gw-footer-grid ul a,
  .gw-footer-grid p a { font-size: 0.88rem; padding: 7px 0; display: inline-block; }
  .gw-footer-bar { font-size: 0.76rem; line-height: 1.7; padding-top: 16px; }

  /* Kimi 科学助手：抬到底部栏之上，缩小面板 */
  .gw-kimi-agent {
    right: 12px;
    bottom: calc(var(--m-tab-h) + var(--m-safe-b) + 12px) !important;
    z-index: 9500;
  }
  .gw-kimi-toggle { width: 46px; height: 46px; }
  .gw-kimi-panel {
    right: 12px;
    bottom: calc(var(--m-tab-h) + var(--m-safe-b) + 66px) !important;
    width: calc(100vw - 24px);
    max-width: 380px;
    max-height: calc(100dvh - var(--m-bar-h) - var(--m-tab-h) - 90px);
    border-radius: var(--m-radius);
  }
}

/* ---------------------------------------------------------------------------
   8. 超窄屏 (<400px) 微调
   --------------------------------------------------------------------------- */
@media (max-width: 400px) {
  :root { --m-gutter: 14px; }
  .gw-hero--editorial .gw-hero-title { font-size: clamp(2.8rem, 20vw, 3.6rem); }
  .gw-board-grid--visual { grid-template-columns: 1fr; }
  /* 页脚导航改为两列，8 个链接只占 4 行，避免纵向堆叠过长 */
  .gw-footer-grid { grid-template-columns: 1fr; }
  .gw-footer-grid ul { grid-template-columns: 1fr 1fr; }
  .gw-brand-sub { display: none; }
}

/* ---------------------------------------------------------------------------
   9. 横屏 / 平板竖屏的中间态（保持与桌面更接近）
   --------------------------------------------------------------------------- */
@media (min-width: 640px) and (max-width: 900px) {
  .gw-board-grid--visual { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .gw-featured-grid--editorial { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .gw-featured-card--lead { grid-column: 1 / -1; }
  .gw-categories-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .gw-board-articles-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .gw-footer-grid { grid-template-columns: repeat(3, 1fr); }
  .gw-footer-grid > div:first-child { grid-column: auto; }
  .gw-hero-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

/* ---------------------------------------------------------------------------
   10. 无障碍 / 偏好
   --------------------------------------------------------------------------- */
@media (max-width: 900px) and (prefers-reduced-motion: reduce) {
  .gw-navbar, .gw-tabbar-item svg, .gw-readbar, .gw-read-progress { transition: none !important; }
}
