/* ============================================================================
 * TomApp 全站响应式基础层  ·  tom-responsive.css
 * ----------------------------------------------------------------------------
 * 设计约定（后续维护请遵守）：
 * 1. 这是「框架层」，不是某个页面的皮肤。页面内容以后怎么改，都不需要动本文件。
 * 2. 桌面端（宽 > 1024px 且为鼠标设备）完全不介入，原有版式、配色保持不变。
 * 3. 只做兜底：不溢出、能点到、导航可达。不重设计任何页面。
 * 4. 新页面只需在 </head> 前引本文件、</body> 前引 js/tom-responsive.js 即可。
 * 5. 断点分三档：平板(<=1024) / 手机(<=768) / 小屏(<=480)；
 *    另用 (hover:none) and (pointer:coarse) 识别触屏，
 *    保证 iPad Pro 横屏(1366px) 这类「宽度像桌面、其实是平板」的设备也被覆盖。
 * 6. 运行时体检由 tom-responsive.js 打 class，样式统一定义在这里，方便撤销/排查。
 *
 * 缓存提示：静态托管下 /css/* 被 _headers 设了 immutable，
 * 本文件已在 _headers 中单独设为 no-store；若新增其它同名资源请同步处理。
 * ========================================================================== */

:root {
  --tom-r-version: "1";
  --tom-r-z: 2147483000;
  --tom-r-bg: rgba(12, 17, 26, 0.98);
  --tom-r-bg-2: rgba(20, 28, 41, 0.96);
  --tom-r-line: rgba(255, 255, 255, 0.12);
  --tom-r-soft: rgba(255, 255, 255, 0.07);
  --tom-r-text: #f1f5fb;
  --tom-r-muted: #9aa7ba;
  --tom-r-accent: #0fb89b;
  --tom-r-shadow: 0 24px 64px rgba(0, 0, 0, 0.55);
  --tom-r-safe-b: env(safe-area-inset-bottom, 0px);
  --tom-r-safe-r: env(safe-area-inset-right, 0px);
  --tom-r-safe-l: env(safe-area-inset-left, 0px);
  --tom-r-safe-t: env(safe-area-inset-top, 0px);
}

/* 首页等支持浅色主题的页面 */
html[data-theme="light"] {
  --tom-r-bg: rgba(255, 255, 255, 0.98);
  --tom-r-bg-2: rgba(244, 247, 252, 0.97);
  --tom-r-line: rgba(16, 24, 40, 0.12);
  --tom-r-soft: rgba(16, 24, 40, 0.05);
  --tom-r-text: #16202e;
  --tom-r-muted: #63718a;
  --tom-r-shadow: 0 24px 64px rgba(16, 24, 40, 0.18);
}

/* ---------------------------------------------------------------------------
 * 0. 全站通用移动导航组件（默认隐藏，仅平板/手机/触屏显示）
 * ------------------------------------------------------------------------- */
.tom-r-fab,
.tom-r-scrim,
.tom-r-panel,
.tom-r-scroll,
.tom-r-skip {
  box-sizing: border-box;
}

.tom-r-fab,
.tom-r-scrim,
.tom-r-panel {
  display: none;
}

/* 页面自带导航时可显式关闭通用悬浮导航，避免页脚下方多出一个空方块 */
body[data-tom-no-fab] #tomRFab,
body[data-tom-no-fab] #tomRPanel,
body[data-tom-no-fab] #tomRScrim,
body[data-tom-no-fab] .tom-r-fab,
body[data-tom-no-fab] .tom-r-panel,
body[data-tom-no-fab] .tom-r-scrim,
body[data-tom-no-fab] .tom-r-header {
  display: none !important;
}

/* ---------------------------------------------------------------------------
 * 1. 平板 + 手机 + 触屏设备（含 iPad Pro 横屏）
 * ------------------------------------------------------------------------- */
@media (max-width: 1024px), (hover: none) and (pointer: coarse) {

  /* 触屏基础：去掉点击高亮、避免双击缩放与 300ms 点击延迟 */
  html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
  }

  /* 关键：移动端若只用 body{overflow-x:hidden}，Chrome/Safari 会把
     layout viewport 撑宽到内容宽度（390 视口变成 497），fixed 元素随之跑偏、
     整页被缩小。clip 不创建滚动容器（不影响 position:sticky），
     老浏览器自动回退到 hidden。 */
  html,
  body {
    overflow-x: hidden;
    overflow-x: clip;
    max-width: 100%;
  }

  a,
  button,
  input,
  select,
  textarea,
  label,
  summary,
  [role="button"],
  [onclick] {
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
  }

  /* 媒体元素不撑破容器（仅在这些设备生效，不影响桌面既有版式） */
  img,
  video,
  canvas,
  svg,
  picture {
    max-width: 100% !important;
  }

  img[width],
  video[width] {
    height: auto;
  }

  /* 长串文本 / 代码块不产生横向滚动 */
  pre,
  code,
  kbd,
  samp {
    overflow-wrap: anywhere;
    word-break: break-word;
  }

  pre {
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* 写死 px 宽的容器兜底；JS 体检会为个别元素补 tom-r-fit */
  iframe,
  table,
  .tom-r-fit {
    max-width: 100% !important;
  }

  .tom-r-fit {
    overflow-wrap: anywhere !important;
    word-break: break-word !important;
  }

  /* JS 体检：可横向滚动的表格容器 */
  .tom-r-scroll {
    display: block;
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
  }

  .tom-r-scroll > table {
    max-width: none;
    min-width: 100%;
  }

  /* JS 体检：过窄的多列网格降为自适应列 */
  .tom-r-fluid-grid {
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)) !important;
  }

  /* JS 体检：并排的固定宽侧栏在手机上改为上下堆叠 */
  .tom-r-stack {
    flex-direction: column !important;
    flex-wrap: wrap !important;
  }

  .tom-r-stack > .tom-r-stack-item {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    flex: 0 0 auto !important;
  }

  /* 横向导航条：允许滑动，不撑破页面 */
  .sticky-nav-inner,
  .tom-r-hscroll {
    max-width: 100% !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
    scrollbar-width: none;
  }

  .sticky-nav-inner::-webkit-scrollbar,
  .tom-r-hscroll::-webkit-scrollbar {
    display: none;
  }

  /* 触控目标：只对 JS 标记过的导航类元素放大，避免撑坏正文里的行内链接 */
  .tom-r-tap {
    min-height: 44px !important;
    min-width: 44px !important;
  }

  /* display:inline 的元素上 min-height/min-width 完全无效，
     必须先切成 inline-flex（JS 会按原 display 分流标记） */
  .tom-r-tap-inline {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    vertical-align: middle;
    min-height: 44px !important;
    min-width: 44px !important;
    padding-top: 6px !important;
    padding-bottom: 6px !important;
  }

  /* hover 才显示的内容，在触屏上强制可见 */
  .tom-r-reveal,
  .side-nav a span {
    opacity: 1 !important;
    visibility: visible !important;
    transform: none !important;
    pointer-events: auto !important;
  }

  /* 横向菜单按钮（AI 工具页等）：保持可滑动，同时保证点击区域。
     !important 是因为部分页面在 body 里还有更晚的内联 <style> */
  .btn-menu {
    min-height: 44px !important;
    display: inline-flex !important;
    align-items: center !important;
    white-space: nowrap !important;
    flex: 0 0 auto !important;
  }

  /* ---------- 通用移动导航：悬浮按钮 ---------- */
  .tom-r-fab {
    display: inline-flex;
    position: fixed;
    right: calc(16px + var(--tom-r-safe-r));
    bottom: calc(18px + var(--tom-r-safe-b));
    z-index: calc(var(--tom-r-z) + 2);
    align-items: center;
    gap: 9px;
    min-width: 56px;
    min-height: 52px;
    padding: 0 16px;
    border: 1px solid var(--tom-r-line);
    border-radius: 999px;
    background: var(--tom-r-bg-2);
    color: var(--tom-r-text);
    box-shadow: var(--tom-r-shadow);
    font-size: 14px;
    font-weight: 700;
    line-height: 1;
    cursor: pointer;
    -webkit-backdrop-filter: blur(16px);
    backdrop-filter: blur(16px);
  }

  /* 右下角已有浮动按钮（首页「我的故事」等）时自动让位到左下 */
  .tom-r-fab.tom-r-fab--avoid {
    right: auto;
    left: calc(16px + var(--tom-r-safe-l));
  }

  .tom-r-fab__bars {
    display: inline-flex;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
    width: 18px;
    height: 14px;
    flex: 0 0 auto;
  }

  .tom-r-fab__bars i {
    display: block;
    width: 100%;
    height: 2px;
    border-radius: 2px;
    background: currentColor;
    transition: transform 0.2s ease, opacity 0.2s ease;
  }

  .tom-r-fab[aria-expanded="true"] .tom-r-fab__bars i:nth-child(1) {
    transform: translateY(6px) rotate(45deg);
  }

  .tom-r-fab[aria-expanded="true"] .tom-r-fab__bars i:nth-child(2) {
    opacity: 0;
  }

  .tom-r-fab[aria-expanded="true"] .tom-r-fab__bars i:nth-child(3) {
    transform: translateY(-6px) rotate(-45deg);
  }

  /* ---------- 通用移动导航：遮罩 ---------- */
  .tom-r-scrim {
    display: block;
    position: fixed;
    inset: 0;
    z-index: calc(var(--tom-r-z) + 1);
    background: rgba(0, 0, 0, 0.55);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.24s ease, visibility 0.24s ease;
  }

  html.tom-r-nav-open .tom-r-scrim {
    opacity: 1;
    visibility: visible;
  }

  /* ---------- 通用移动导航：抽屉 ---------- */
  .tom-r-panel {
    display: flex;
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    z-index: calc(var(--tom-r-z) + 3);
    flex-direction: column;
    width: min(340px, calc(100vw - 48px));
    max-width: 100%;
    padding-top: var(--tom-r-safe-t);
    padding-bottom: var(--tom-r-safe-b);
    border-left: 1px solid var(--tom-r-line);
    background: var(--tom-r-bg);
    color: var(--tom-r-text);
    box-shadow: var(--tom-r-shadow);
    transform: translateX(102%);
    visibility: hidden;
    transition: transform 0.26s cubic-bezier(0.22, 0.8, 0.3, 1), visibility 0.26s ease;
    -webkit-backdrop-filter: blur(20px);
    backdrop-filter: blur(20px);
    font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", -apple-system, sans-serif;
  }

  html.tom-r-nav-open .tom-r-panel {
    transform: translateX(0);
    visibility: visible;
  }

  html.tom-r-nav-open,
  html.tom-r-nav-open body {
    overflow: hidden;
  }

  .tom-r-panel__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 18px 18px 14px;
    border-bottom: 1px solid var(--tom-r-line);
    flex: 0 0 auto;
  }

  .tom-r-panel__head strong {
    font-size: 16px;
    letter-spacing: 0.02em;
  }

  .tom-r-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border: 0;
    border-radius: 12px;
    background: var(--tom-r-soft);
    color: var(--tom-r-text);
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
  }

  .tom-r-panel__body {
    flex: 1 1 auto;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    padding: 14px 14px calc(24px + var(--tom-r-safe-b));
  }

  .tom-r-group {
    margin: 14px 8px 8px;
    color: var(--tom-r-muted);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.08em;
  }

  .tom-r-group:first-child {
    margin-top: 2px;
  }

  .tom-r-link {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 48px;
    padding: 10px 14px;
    margin: 4px 0;
    border-radius: 12px;
    color: var(--tom-r-text);
    font-size: 15px;
    line-height: 1.45;
    text-decoration: none;
    word-break: break-word;
  }

  .tom-r-link:hover,
  .tom-r-link:focus-visible,
  .tom-r-link.tom-r-link--current {
    background: var(--tom-r-soft);
    color: var(--tom-r-accent);
    outline: none;
  }

  .tom-r-link__dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--tom-r-accent);
    flex: 0 0 auto;
    opacity: 0.75;
  }

  .tom-r-link--sub {
    font-size: 14px;
    color: var(--tom-r-muted);
    padding-left: 20px;
  }

  .tom-r-panel__foot {
    padding: 10px 18px calc(14px + var(--tom-r-safe-b));
    border-top: 1px solid var(--tom-r-line);
    color: var(--tom-r-muted);
    font-size: 11px;
    flex: 0 0 auto;
  }
}

/* ---------------------------------------------------------------------------
 * 2. 平板专属（769 ~ 1024，以及触屏的大屏 iPad）
 *    两栏内容保持，但收敛留白与固定宽度
 * ------------------------------------------------------------------------- */
@media (min-width: 769px) and (max-width: 1024px),
       (min-width: 1025px) and (hover: none) and (pointer: coarse) {

  /* 固定像素宽度的主容器：改为不超过视口 */
  [style*="width:"][class*="container"],
  .container[style*="width"],
  .nav-in,
  .nav-container,
  .header-inner,
  .wrap,
  .tomblog-nav-inner,
  .nav-contents {
    max-width: 100%;
  }

  .tom-r-fab {
    min-height: 54px;
  }

  .tom-r-panel {
    width: min(360px, 88vw);
  }
}

/* ---------------------------------------------------------------------------
 * 3. 手机小屏
 * ------------------------------------------------------------------------- */
@media (max-width: 768px) {

  /* 主容器左右留白收敛为 0：小屏尽量占满整宽，让正文文字更大更清晰。
     仍保留刘海屏 safe-area，避免横屏时内容钻进圆角/刘海区。 */
  .wrap,
  .container,
  .content,
  .nav-in,
  .nav-container,
  .header-inner,
  .tomblog-nav-inner,
  .nav-contents,
  .nav-contents-wrapper {
    padding-left: var(--tom-r-safe-l) !important;
    padding-right: var(--tom-r-safe-r) !important;
    max-width: 100% !important;
  }

  /* 装饰性绝对定位光晕不参与布局，避免撑宽 */
  .tech-orb,
  .orb-a,
  .orb-b,
  .light-effect,
  .background-layer,
  .floating-card {
    max-width: 100vw;
    pointer-events: none;
  }

  .tom-r-panel {
    width: min(340px, calc(100vw - 40px));
  }
}

@media (max-width: 480px) {
  .tom-r-fab {
    min-width: 52px;
    min-height: 48px;
    padding: 0 13px;
    font-size: 13px;
  }

  .tom-r-fab__label {
    display: none;
  }

  .tom-r-panel {
    width: calc(100vw - 32px);
  }
}

/* 尊重系统的「减少动态效果」 */
@media (prefers-reduced-motion: reduce) {
  .tom-r-panel,
  .tom-r-scrim,
  .tom-r-fab__bars i {
    transition: none !important;
  }
}

/* 打印时不带导航控件 */
@media print {
  .tom-r-fab,
  .tom-r-scrim,
  .tom-r-panel {
    display: none !important;
  }
}

/* ==========================================================================
 * 5. 小屏「菜单贴按钮 + 内容贴边 + 按钮对齐」专项（2026-11-22）
 * --------------------------------------------------------------------------
 * 背景：i18n.css 由 js 动态注入、在 head 末尾加载，且大量使用 !important，
 * 早期为了规避「220px 包含块把菜单推出屏幕」把 TomAi 菜单钉死在 left:16px，
 * 导致展开菜单与右上角触发按钮（300px 开外）严重分离；各页面包裹层还留有
 * 14~24px 左右内边距，小屏正文被挤窄。本段统一在框架层收口：
 *   a) 所有展开菜单右对齐到触发按钮所在的右边缘（Preview 按钮在左则左对齐）；
 *   b) 主内容容器左右贴边（留 safe-area），占满屏宽；
 *   c) TomAi 三个 CTA 按钮等宽对称排列，不再出现「2+1」错位与溢出。
 * 选择器均带 body/html 前缀 + !important，确保压过动态注入的皮肤规则。
 * ========================================================================== */
@media (max-width: 1200px) {
  /* ---- a1. TomAi：菜单从右上角按钮正下方展开，右边缘与按钮对齐 ----
     i18n.css 旧规则是 .tomai-page .nav.mobile-nav-open .nav-list（3 个类）；
     这里加 body 前缀提高优先级，覆盖它的 left:16px !important。 */
  body.tomai-page .nav.mobile-nav-open .nav-list {
    left: auto !important;
    right: 0 !important;
    transform-origin: top right;
  }

  /* ---- a2. 通用 nav-container / preview / books / tombBlog：菜单右边缘统一贴右 ---- */
  body .nav-container.mobile-nav-open .nav-menu,
  body .books-page .nav-container.mobile-nav-open .nav-menu,
  body .tomblog-nav-inner.mobile-nav-open .tomblog-menu {
    left: auto !important;
    right: 0 !important;
  }

  /* Preview 触发按钮与展开菜单统一靠右（2026-11-22 用户定版）。
     旧规则把小屏菜单钉在左侧按钮下方，与「菜单一律在右」冲突，已废弃。 */
  @media (max-width: 560px) {
    body .preview-nav-container.mobile-nav-open .nav-menu {
      left: auto !important;
      right: 0 !important;
      transform-origin: top right;
    }
  }
}

@media (max-width: 768px) {
  /* ---- b. 主内容容器贴边（含 i18n 皮肤里常见的正文包裹层） ---- */
  body .hero-content-grid,
  body .hero-right,
  body .cta,
  body .tomai-page .hero .header,
  body .tomai-page .hero .section-description {
    padding-left: 0 !important;
    padding-right: 0 !important;
    max-width: 100% !important;
    width: 100% !important;
  }

  /* TomAi hero 标题/描述此前用 95% 宽度居中，小屏改贴边铺满、两端对齐 */
  body.tomai-page .hero .header,
  body.tomai-page .hero .section-description {
    width: 100% !important;
    max-width: 100% !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
    text-align: center !important;
  }

  /* ---- c. TomAi 三个 CTA 按钮：等宽、三列、对称铺满，取消「2+1」错位 ----
     压过 ai-tech.css 的 grid-template-columns: repeat(2,...) !important
     与 mobile-nav.css 的 repeat(3,...)（后者无 !important）。 */
  body.tomai-page .sticky-buttons-container {
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    gap: 8px !important;
    width: 100% !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
  }
  body.tomai-page .sticky-buttons-container .tomai-gateway-btn,
  body.tomai-page .sticky-buttons-container .tomai-gateway-btn2,
  body.tomai-page .sticky-buttons-container .tomai-gateway-btn3,
  body.tomai-page .sticky-buttons-container #tomai-portal-btn {
    grid-column: auto !important;
    grid-row: auto !important;
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
    padding-left: 6px !important;
    padding-right: 6px !important;
  }
}

/* 极窄屏（<=374px）：三个按钮一行放不下文字，改等高两行布局：
   第一行「线上 TomAi传送门」独占整行，第二行另两个等宽并排，整体仍对称。 */
@media (max-width: 374px) {
  body.tomai-page .sticky-buttons-container {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }
  body.tomai-page .sticky-buttons-container #tomai-portal-btn {
    grid-column: 1 / -1 !important;
    grid-row: 1 !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
  }
  body.tomai-page .sticky-buttons-container .tomai-gateway-btn3 {
    grid-column: 1 !important;
    grid-row: 2 !important;
  }
  body.tomai-page .sticky-buttons-container .tomai-gateway-btn2 {
    grid-column: 2 !important;
    grid-row: 2 !important;
  }
}

/* ==========================================================================
 * 6. Footer 链接「一行排满再换行」（2026-11-22）
 * --------------------------------------------------------------------------
 * 原版 .footer-links li 是块级列表项、一项占一整行，文字只占左侧窄窄一条，
 * 右边大片留白（截图红框所示）。按「一行空间先用满、排不下才换行」的原则：
 *   a) 每个分类块（一列一个块）占满整行宽度；
 *   b) 块内链接改 flex-wrap 横排，一行排满才自动换到第二行；
 *   c) footer 左右贴边，延续 0 留白策略。
 * ========================================================================== */
@media (max-width: 768px) {
  /* a. 一列一个块：每个分类占满整行（压过 auto-fit minmax(200px) 在小屏塌成的单窄列） */
  body .footer-content {
    grid-template-columns: 1fr !important;
    column-gap: 0 !important;
    row-gap: 22px !important;
    padding-left: var(--tom-r-safe-l) !important;
    padding-right: var(--tom-r-safe-r) !important;
  }
  body .footer-bottom {
    padding-left: var(--tom-r-safe-l) !important;
    padding-right: var(--tom-r-safe-r) !important;
  }
  body .footer-content .footer-section {
    width: 100% !important;
    min-width: 0 !important;
  }

  /* b. 块内链接横排铺满：一行排满才换行，不再一项一行 */
  body .footer-content .footer-links {
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 10px 18px !important;
  }
  body .footer-content .footer-links li {
    margin-bottom: 0 !important;
    flex: 0 0 auto !important;
  }
  body .footer-content .footer-links a {
    white-space: nowrap;
  }
}

/* ==========================================================================
 * 6. 菜单按钮 / 展开面板一律靠右，其余头部信息靠左（2026-11-22 用户定版）
 * --------------------------------------------------------------------------
 * 全站 6 套 header 共用：品牌 + PRO会员/用户名/语言等控件在左，菜单按钮在右，
 * 展开面板右对齐。控件统一压到 32px 高、同行居中，杜绝 52px 大色块和下方留白。
 * 本表由 tom-responsive.js 注入，在页面 CSS 之后、i18n.css 之前加载；
 * 统一用 html body 前缀 + !important 压住后面的动态皮肤规则。
 * ========================================================================== */
@media (max-width: 1200px) {
  /* ---- 6.1 菜单触发按钮：全部靠右 ---- */
  html body .mobile-menu-toggle,
  html body .nav-toggle,
  html body .tab-nav-menu-toggle,
  html body .tomai-menu-toggle,
  html body .tomblog-menu-toggle,
  html body .hero-menu-toggle,
  html body .tom-r-header-toggle {
    margin-left: auto !important;
    justify-self: end !important;
    order: 99 !important;
  }

  /* ---- 6.2 头部信息控件：紧凑、同高、水平对齐 ---- */
  html body .nav-actions,
  html body .nav-right-controls,
  html body .tomblog-actions {
    height: 36px !important;
    min-height: 0 !important;
    align-items: center !important;
    gap: 6px !important;
    padding: 0 !important;
  }
  html body .nav-actions > a,
  html body .nav-actions > button,
  html body .header-actions > a,
  html body .header-actions > button,
  html body .nav-actions > span.user-role-badge,
  html body .nav-right-controls > a,
  html body .nav-right-controls > button,
  html body .nav-right-controls > span.user-role-badge,
  html body .tomblog-actions > a,
  html body .tomblog-actions > button,
  html body .tomblog-actions > span.user-role-badge {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    height: 32px !important;
    min-height: 0 !important;
    padding: 0 10px !important;
    line-height: 1 !important;
    font-size: 12px !important;
    white-space: nowrap !important;
    box-sizing: border-box !important;
  }
  html body .user-role-badge.role-badge-pro::after {
    top: -5px !important;
    right: -5px !important;
    font-size: 14px !important;
  }

  /* ---- 6.3 通用 .nav-container：≤560 两行（品牌 / 控件+按钮），更宽一行 ---- */
  html body .nav-container:not(.preview-nav-container) {
    grid-template-columns: auto auto minmax(0, 1fr) !important;
  }
  html body .nav-container:not(.preview-nav-container) > .logo {
    grid-column: 1 !important;
    grid-row: 1 !important;
    justify-self: start !important;
    max-width: calc(100vw - 260px) !important;
    min-width: 0 !important;
  }
  html body .nav-container:not(.preview-nav-container) > .nav-actions {
    grid-column: 2 !important;
    grid-row: 1 !important;
    justify-self: start !important;
    width: auto !important;
    max-width: none !important;
  }
  html body .nav-container:not(.preview-nav-container) > .mobile-menu-toggle {
    grid-column: 3 !important;
    grid-row: 1 !important;
  }
  html body .nav-container.mobile-nav-open:not(.preview-nav-container) > .nav-actions {
    grid-column: 2 !important;
    grid-row: 1 !important;
    width: auto !important;
  }

  /* ---- 6.4 Preview：与成长社群同构——品牌 / 控件 / 汉堡同一行 ---- */
  html body .preview-nav-container {
    grid-template-columns: auto auto minmax(0, 1fr) !important;
  }
  html body .preview-nav-container > .logo {
    grid-column: 1 !important;
    grid-row: 1 !important;
    justify-self: start !important;
    max-width: calc(100vw - 260px) !important;
    min-width: 0 !important;
    overflow: hidden !important;
    white-space: nowrap !important;
    text-overflow: ellipsis !important;
  }
  html body .preview-nav-container > .nav-actions {
    grid-column: 2 !important;
    grid-row: 1 !important;
    justify-self: start !important;
    width: auto !important;
    max-width: none !important;
  }
  html body .preview-nav-container > .mobile-menu-toggle {
    grid-column: 3 !important;
    grid-row: 1 !important;
    justify-self: end !important;
  }
  html body .preview-nav-container.mobile-nav-open > .nav-actions {
    grid-column: 2 !important;
    grid-row: 1 !important;
    width: auto !important;
  }

  /* ---- 6.5 新版首页：主题 / 旧版首页 / 语言跟随品牌靠左 ---- */
  html body .site-header .wrap {
    justify-content: flex-start !important;
    gap: 12px !important;
  }
  html body .site-header .header-actions {
    margin-left: 0 !important;
    margin-right: auto !important;
    justify-content: flex-start !important;
  }

  /* ---- 6.5 TomAi / tomBlog：菜单按钮右端，用户控件在其左侧 ---- */
  html body .tomai-page .nav-contents {
    grid-template-columns: auto auto minmax(0, 1fr) !important;
  }
  html body .tomai-page .nav-contents > .logo {
    grid-column: 1 !important;
    grid-row: 1 !important;
    justify-self: start !important;
    max-width: calc(100vw - 240px) !important;
  }
  html body .tomai-page .nav-contents > .nav-actions {
    grid-column: 2 !important;
    grid-row: 1 !important;
    justify-self: start !important;
    width: auto !important;
  }
  html body .tomai-page .nav-contents > .tomai-menu-toggle {
    grid-column: 3 !important;
    grid-row: 1 !important;
    justify-self: end !important;
  }
  html body .tomblog-nav-inner {
    grid-template-columns: auto auto minmax(0, 1fr) !important;
  }
  html body .tomblog-nav-inner > .tomblog-brand {
    grid-column: 1 !important;
    grid-row: 1 !important;
    justify-self: start !important;
  }
  html body .tomblog-nav-inner > .tomblog-actions {
    grid-column: 2 !important;
    grid-row: 1 !important;
    justify-self: start !important;
    position: static !important;
    width: auto !important;
    max-width: none !important;
  }
  html body .tomblog-nav-inner > .tomblog-menu-toggle {
    grid-column: 3 !important;
    grid-row: 1 !important;
    justify-self: end !important;
  }

  /* ---- 6.6 展开面板：一律右对齐，不再居中或靠左 ---- */
  html body .nav-container.mobile-nav-open .nav-menu,
  html body .tomblog-nav-inner.mobile-nav-open .tomblog-menu,
  html body .tab-nav.mobile-nav-open .tab-nav-center,
  html body .tomai-page .nav.mobile-nav-open .nav-list,
  html body .hero-menu-group.hero-menu-collapsible.mobile-nav-open {
    left: auto !important;
    right: 0 !important;
    transform: none !important;
    max-width: calc(100vw - 16px) !important;
  }

  /* ---- 6.7 通用悬浮菜单按钮：部分老页面用 button:not(...) 把 FAB 改回
         position:relative + display:inline-block，导致按钮跑到几万像素长的
         文档底部；这里用 html body button 前缀收口，强制回右下角。 ---- */
  html body button.tom-r-fab {
    display: inline-flex !important;
    position: fixed !important;
    left: auto !important;
    right: calc(16px + var(--tom-r-safe-r, 0px)) !important;
    bottom: calc(18px + var(--tom-r-safe-b, 0px)) !important;
    z-index: calc(var(--tom-r-z, 2147482000) + 2) !important;
    min-width: 56px !important;
    min-height: 44px !important;
  }
  html body button.tom-r-fab.tom-r-fab--avoid {
    bottom: calc(96px + var(--tom-r-safe-b, 0px)) !important;
  }
}

@media (min-width: 561px) and (max-width: 1200px) {
  /* 宽度够：品牌 / 控件 / 菜单按钮同行，不再把控件甩到第二行 */
  html body .preview-nav-container {
    grid-template-columns: auto auto minmax(0, 1fr) !important;
  }
  html body .preview-nav-container > .logo {
    grid-column: 1 !important;
    grid-row: 1 !important;
    max-width: calc(100vw - 260px) !important;
  }
  html body .preview-nav-container > .nav-actions {
    grid-column: 2 !important;
    grid-row: 1 !important;
  }
  html body .preview-nav-container > .mobile-menu-toggle {
    grid-column: 3 !important;
    grid-row: 1 !important;
  }
}

/* ==========================================================================
 * 7. 菜单按钮全站统一定版（2026-11-22 用户定版）
 * --------------------------------------------------------------------------
 * 6 套 header 触发按钮 + 无原生导航页的悬浮按钮，一律 44×44 深色圆角方块、
 * 三条白杠；不再出现 TomAi/TomBlog 的点阵、Preview 的黄色裸杠、
 * 工作台的文字胶囊、悬浮按钮的「菜单」文字。
 * 本节由 tom-responsive.js 注入，加载在页面 CSS 之后、i18n.css 之前；
 * 使用 html body 前缀 + !important 压住各页内联覆盖。
 * ========================================================================== */
html body .mobile-menu-toggle,
html body .nav-toggle,
html body .tab-nav-menu-toggle,
html body .tomai-menu-toggle,
html body .tomblog-menu-toggle,
html body .hero-menu-toggle,
html body .tab-nav.tab-nav-collapsible .tab-nav-menu-toggle,
html body .menu-toggle.immersive-target,
html body .tom-r-header-toggle,
html body button.tom-r-fab {
  width: 44px !important;
  height: 44px !important;
  min-width: 44px !important;
  min-height: 44px !important;
  padding: 0 !important;
  gap: 0 !important;
  border: 1px solid rgba(255, 255, 255, 0.16) !important;
  border-radius: 12px !important;
  background: rgba(12, 18, 30, 0.9) !important;
  color: #fff !important;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.22) !important;
  align-items: center !important;
  justify-content: center !important;
  flex-direction: column !important;
  text-align: center !important;
  margin-right: 0 !important;
  flex: 0 0 auto !important;
  -webkit-backdrop-filter: none !important;
  backdrop-filter: none !important;
}

/* 2026-11-25 修正：删除原先这条「无条件 display:flex!important」。
   它压过了各页自己的 display:none，导致一级菜单已全部显示的宽屏下
   汉堡按钮仍在（两套菜单同时出现），也把 i18n 语言切换器挤到第二行。
   显隐现在完全交回各页 CSS（mobile-nav.css / tomBlog.css / Guide.css 等），
   天然互斥：窄屏只有汉堡、宽屏只有一级菜单。
   三道杠居中由各页媒体查询里的 display:inline-flex 保证（见 mobile-nav.css:21
   / tomBlog.css:981），无需在此顶层强制 display。 */

/* 独立沉浸页的 ☰ 按钮也纳入同一尺寸/配色，固定在同一右上位置 */
html body .menu-toggle.immersive-target {
  position: fixed !important;
  top: 12px !important;
  right: 12px !important;
  left: auto !important;
}

/* 三条杠：统一 18×2px 白线、2px 间距；原 DOM 里的 span 全部复原 */
html body .mobile-menu-toggle span,
html body .nav-toggle span,
html body .tab-nav-menu-toggle span,
html body .tomai-menu-toggle span,
html body .tomblog-menu-toggle span,
html body .hero-menu-toggle span,
html body .navbar .mobile-menu-toggle span,
html body .menu-toggle.immersive-target span,
html body .tom-r-header-toggle span,
html body .tab-nav.tab-nav-collapsible .tab-nav-menu-toggle span {
  display: block !important;
  width: 18px !important;
  height: 2px !important;
  min-height: 2px !important;
  /* 横向 auto margin 兜底：即使某个页面把按钮改回 block/grid，
     三条杠也不会贴左边。 */
  margin: 2px auto !important;
  align-self: center !important;
  padding: 0 !important;
  border: 0 !important;
  border-radius: 999px !important;
  background: #fff !important;
  opacity: 1 !important;
}

/* 全局注入的 #tomRFab 再兜一层：任何页面脚本/内联样式都不能把三条杠推到左侧 */
html body #tomRFab {
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  text-align: center !important;
}
/* 2026-11-30 修复：宽屏桌面页面已有一级导航，通用悬浮按钮不该出现。
   原 display:flex!important 无视断点强制显示，而 position:fixed 只在窄屏定义，
   按钮因此掉进文档流，在备案栏后面多出 44px 黑块 + 等高灰色留白。 */
@media (min-width: 1025px) and (hover: hover) and (pointer: fine) {
  html body #tomRFab { display: none !important; }
}
html body #tomRFab > span {
  margin-left: auto !important;
  margin-right: auto !important;
  align-self: center !important;
}

/* 点阵/文字标签一律作废 */
html body .tomai-menu-toggle::before,
html body .tomblog-menu-toggle::before,
html body .tab-nav.tab-nav-collapsible .tab-nav-menu-toggle::after,
html body .tab-nav.tab-nav-collapsible.mobile-nav-open .tab-nav-menu-toggle::after {
  content: none !important;
}

/* 悬浮入口：只留图标，不再显示「菜单」文字 */
html body .tom-r-fab__label {
  display: none !important;
}
html body .tom-r-fab__bars {
  width: 18px !important;
  height: 14px !important;
  gap: 4px !important;
}
html body .tom-r-fab__bars i {
  width: 18px !important;
  height: 2px !important;
  border-radius: 999px !important;
  background: #fff !important;
}

/* 头部按钮统一离右边缘 12px（原来 390px 贴边、1024px 留 24px） */
@media (max-width: 1200px) {
  html body .nav-container,
  html body .nav-contents,
  html body .tomblog-nav-inner,
  html body .tab-nav {
    padding-right: 12px !important;
  }
  /* TomAi 的 nav 外层额外留了 24px，收掉才能保证按钮离右边缘也是 12px */
  html body .nav-contents-wrapper {
    padding-right: 0 !important;
  }
  /* 新版首页的 .site-header .wrap 同样留 12px 右间距；品牌/控件不换行 */
  html body .site-header .wrap {
    padding-right: 12px !important;
  }
  html body .site-header .wrap .brand {
    display: inline-flex !important;
    align-items: center !important;
    max-width: 120px !important;
    overflow: hidden !important;
    white-space: nowrap !important;
  }
  html body .site-header .wrap .brand-text {
    display: inline-block !important;
    max-width: 72px !important;
    overflow: hidden !important;
    white-space: nowrap !important;
    text-overflow: ellipsis !important;
  }
}

/* 没有原生头部条的页面：补一条与成长社群同构的顶部栏 */
.tom-r-header {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 60px;
  padding: 0 12px;
  box-sizing: border-box;
  z-index: calc(var(--tom-r-z, 2147482000) + 4);
  background: rgba(12, 18, 30, 0.96);
  border-bottom: 1px solid rgba(255, 255, 255, 0.14);
}
.tom-r-header__inner {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 100%;
}
.tom-r-header__brand {
  min-width: 0;
  max-width: calc(100vw - 180px);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-size: 17px;
  font-weight: 700;
  color: #e0b33c;
}
.tom-r-header__actions {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
}
/* 语言切换器进头部栏后回到普通文档流，不再用各页的 fixed/absolute 定位 */
html.tom-r-header-active .tom-r-header__actions .tom-i18n-switch,
html.tom-r-header-active .tom-r-header__actions .menu-toggle.immersive-target {
  position: relative !important;
  top: auto !important;
  right: auto !important;
  left: auto !important;
  margin: 0 !important;
}
@media (max-width: 1024px), (hover: none) and (pointer: coarse) {
  html.tom-r-header-active .tom-r-header { display: block; }
  html.tom-r-header-active body { padding-top: 60px !important; }
}

/* ==========================================================================
 * 8. 窄屏隐藏页面内重复的一级菜单条（2026-11-22 用户定版）
 * 顶部已有汉堡按钮展开全站导航，hero 里的两行一级菜单按钮（.hero-cta-group）
 * 属重复入口：窄屏隐藏，宽度够了、顶部汉堡消失后再恢复显示。
 * 触发条件与 tom-responsive.js 的 NAV_MQ 保持一致。
 * ========================================================================== */
@media (max-width: 1024px), (hover: none) and (pointer: coarse) {
  html body .hero-cta-group {
    display: none !important;
  }
}

/* ==========================================================================
 * 9. 中文孤字换行抑制（2026-11-30）
 * 段落/列表/标题在 1152~1440 等宽度下，末行只剩一个汉字（最多加一个句号），
 * 极难看。text-wrap: pretty 让浏览器自动把孤字提前，保证末行至少两个字；
 * 比逐条改文案可靠——换窗口宽度也不会重新出现。
 * ========================================================================== */
p, li, h1, h2, h3, h4, h5, h6, td, th, figcaption, blockquote, div, span {
  text-wrap: pretty;
}
