/* ==========================================================================
 * 「我的故事」手机端头部收口
 * --------------------------------------------------------------------------
 * 用户定版（2026-11-22）：
 *   1. 左下时钟按钮、右下音乐按钮挪到顶部，排在汉堡按钮左边；
 *   2. 中英切换器紧跟标题右边（不贴汉堡）。
 * 只在本页 body.story-mobile-header（由 myStory.html 的 IIFE 添加）生效，
 * 用 html body 前缀 + !important 压过后注入的 i18n.css 与 myStory.css。
 * ========================================================================== */
html body.story-mobile-header .tom-r-header__actions {
  flex: 1 1 auto !important;
  min-width: 0 !important;
  /* 中文 / 时钟 / 音乐 / 汉堡 四等分剩余空间，别让两个圆钮挤成一坨 */
  justify-content: space-between !important;
  gap: 6px !important;
}

html body.story-mobile-header .tom-r-header__brand {
  flex: 0 0 auto !important;
  max-width: 168px !important;
}

/* 语言切换器排在 actions 最左，视觉上紧跟标题；dockHeaderLanguage()
   把它插进 actions 的 DOM 顺序不影响这里的 order。 */
html.tom-r-header-active body.story-mobile-header .tom-r-header__actions .tom-i18n-switch {
  order: -1 !important;
  margin-left: 0 !important;
  margin-right: 0 !important;
  flex: 0 0 auto !important;
  height: 32px !important;
  min-height: 32px !important;
  line-height: 30px !important;
}

/* 时钟 + 音乐：从底部浮钮改成头部行内按钮 */
html body.story-mobile-header .clock-button,
html body.story-mobile-header .music-player {
  position: relative !important;
  display: block !important;
  left: auto !important;
  right: auto !important;
  top: auto !important;
  bottom: auto !important;
  width: 32px !important;
  height: 32px !important;
  min-width: 32px !important;
  min-height: 32px !important;
  margin: 0 !important;
  padding: 0 !important;
  transform: none !important;
  transform-origin: center !important;
  z-index: auto !important;
  flex: 0 0 auto !important;
}

html body.story-mobile-header .clock-button { order: 0 !important; }
html body.story-mobile-header .music-player { order: 1 !important; }
html body.story-mobile-header .tom-r-header__actions > button,
html body.story-mobile-header .tom-r-header__actions > #tomRFab {
  order: 2 !important;
  margin-left: 0 !important;
  margin-right: 0 !important;
}

html body.story-mobile-header .clock-disc,
html body.story-mobile-header .music-disc {
  width: 32px !important;
  height: 32px !important;
  margin: 0 !important;
  border-radius: 10px !important;
}

html body.story-mobile-header .clock-disc svg {
  width: 18px !important;
  height: 18px !important;
}

/* 音乐控制条原来浮在唱片上方（底部按钮用），进头部后改到按钮下方 */
html body.story-mobile-header .music-controls {
  /* 头部高 60px，唱片顶边约 13px：+20px 才能让控制条整条落在头部下方 */
  top: calc(100% + 20px) !important;
  bottom: auto !important;
  z-index: 20 !important;
}

/* 极窄手机：优先保住「标题 + 中文 + 时钟 + 音乐 + 汉堡」全部同行 */
@media (max-width: 380px) {
  html body.story-mobile-header .tom-r-header__brand {
    max-width: 82px !important;
    font-size: 13px !important;
  }
  html.tom-r-header-active body.story-mobile-header .tom-r-header__actions .tom-i18n-switch {
    padding: 0 7px !important;
    font-size: 12px !important;
  }
  html body.story-mobile-header .tom-r-header__actions {
    gap: 4px !important;
  }
  html body.story-mobile-header .clock-button,
  html body.story-mobile-header .music-player,
  html body.story-mobile-header .clock-disc,
  html body.story-mobile-header .music-disc {
    width: 28px !important;
    height: 28px !important;
    min-width: 28px !important;
    min-height: 28px !important;
  }
}

/* ==========================================================================
 * 2026-11-30：断点切换「一次成型」
 * --------------------------------------------------------------------------
 * 从宽屏缩到窄屏时，全站脚本可能先把 #tomRFab 当成右下悬浮按钮放进 DOM。
 * 本页绝不允许它露出那一帧：悬浮态一律隐藏，只有被搬进顶部栏后
 * （className 换成 tom-r-header-toggle）才显示。
 * ========================================================================== */
html body.story-page #tomRFab.tom-r-fab {
  display: none !important;
}

html body.story-mobile-header .tom-r-header__actions > #tomRFab {
  position: relative !important;
  left: auto !important;
  right: auto !important;
  top: auto !important;
  bottom: auto !important;
  transform: none !important;
  margin: 0 !important;
  z-index: auto !important;
}
