/* ==========================================================================
   创金A — v19 移动端收口层（2026-11-23）
   背景：v6 → v14 → v18 → v19 四代移动端样式叠加后出现互相覆盖的冲突，
   典型如底栏容器 54px / 条目 60px、二级面板按 54px 定位、顶栏头像负 margin
   溢出右内边距、16px 防放大规则把占位文案撑爆、个股吸顶报价条遮挡图表等。
   本文件只在 ≤1023px 生效，作为移动端壳层的唯一最终口径；桌面端零影响。
   加载顺序：styles → fundflow-v8 → theme-v14 → theme-v18 → theme-v19 → 本文件 → auth-v20
   ========================================================================== */

/* 默认隐藏：仅在 ≤767px 的折叠块里显示展开按钮 */
.rank-fold-toggle { display: none; }

@media (max-width: 1023px) {
  /* ---------- 1. 顶栏：44px 头像保留触控面积，但不再冲出右内边距 ---------- */
  .topbar { height: var(--topbar-h); }
  .topbar-inner {
    padding: 0 12px;
    gap: 8px;
    min-height: 52px;
    flex-wrap: nowrap;
  }
  .brand { min-height: 44px; gap: 8px; }
  .brand-mark { width: 28px; height: 28px; }
  .brand-text strong { font-size: 14px; }
  .topbar-right { gap: 8px; margin-left: auto; flex: 0 0 auto; }
  .topbar-avatar {
    width: 44px;
    height: 44px;
    margin-right: 0;
    font-size: 12px;
    box-sizing: border-box;
  }
  .theme-toggle { width: 36px; height: 36px; }
  .theme-toggle svg { width: 15px; height: 15px; }
  .status-capsule {
    height: 30px;
    padding: 0 10px;
    max-width: 104px;
    font-size: 11px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .status-capsule .status-exp { display: none; }

  /* ---------- 2. 底部导航：容器 / 条目 / 二级面板统一 60px（+安全区） ---------- */
  .bottom-nav {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: 1fr;
    align-items: stretch;
    height: calc(60px + env(safe-area-inset-bottom, 0px));
    padding-bottom: env(safe-area-inset-bottom, 0px);
    z-index: 66;
  }
  .bottom-nav-item {
    height: 100%;
    min-height: 0;
    gap: 2px;
    font-size: 10.5px;
    font-weight: 500;
    justify-content: center;
  }
  .bottom-nav-item .bn-icon {
    display: inline-grid;
    place-items: center;
    width: 42px;
    height: 26px;
    border-radius: 13px;
    transition: background 0.16s ease, transform 0.12s ease;
  }
  .bottom-nav-item svg { width: 20px; height: 20px; }
  .bottom-nav-item.active { color: var(--accent); font-weight: 600; }
  /* 旧版顶部指示条与图标胶囊二选一：统一保留图标胶囊，去掉悬空的红条 */
  .bottom-nav-item.active::before { display: none; }
  .bottom-nav-item.active .bn-icon { background: var(--up-dim); }
  .bottom-nav-item:active .bn-icon { transform: scale(0.9); }

  .bottom-subnav {
    bottom: calc(60px + env(safe-area-inset-bottom, 0px));
    z-index: 65;
    border-radius: 14px 14px 0 0;
    max-height: calc(100dvh - 60px - env(safe-area-inset-bottom, 0px));
    overflow-y: auto;
    overscroll-behavior: contain;
  }
  .bottom-subnav-item { height: 44px; font-size: 13px; }

  /* ---------- 3. 输入框：保留 16px 防 iOS 聚焦放大，占位文案回到设计字号 ---------- */
  input::placeholder,
  textarea::placeholder {
    font-size: 13px;
    font-weight: 400;
    letter-spacing: 0;
  }
  .searchbox input::placeholder,
  .watch-add-search input::placeholder,
  .card-redeem input::placeholder { font-size: 13px; }

  /* ---------- 4. 首页指数脉搏条：右缘渐隐，明确「可横滑」 ---------- */
  .v19-pulse .vp-scroll {
    -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 26px), transparent);
    mask-image: linear-gradient(90deg, #000 calc(100% - 26px), transparent);
  }
  .v19-subidx .sub-idx { height: 30px; padding: 0 11px; }
  .v19-pulse .vp-idx { padding: 14px 16px 12px; }

  /* ---------- 5. 个股 / 板块详情：吸顶报价条改为固定条，仅在页头滚出后出现 ---------- */
  .sticky-quote-bar {
    position: fixed;
    left: 0;
    right: 0;
    top: var(--topbar-h);
    z-index: 50;
    margin: 0;
    padding: 6px 12px;
    min-height: 38px;
    border-top: 0;
    border-bottom: 1px solid var(--border);
    transform: translateY(-110%);
    opacity: 0;
    pointer-events: none;
    transition: transform 0.18s ease, opacity 0.18s ease;
  }
  .sticky-quote-bar.is-visible {
    transform: none;
    opacity: 1;
    pointer-events: auto;
  }
  .sticky-quote-bar .page-back { width: 32px; height: 32px; flex: 0 0 auto; }
  .sticky-quote-bar .sqb-name { font-size: 13px; max-width: 42%; overflow: hidden; text-overflow: ellipsis; }
  .sticky-quote-bar .sqb-price { font-size: 14px; }
  .sticky-quote-bar .sqb-pct { font-size: 12px; }

  /* ---------- 6. 通用触控与密度 ---------- */
  .v19-ends .end-chip,
  .hot-chip,
  .pano-row,
  .mood-chip { min-height: 32px; }
  .page-head { gap: 6px; }
  .panel-head { min-height: 42px; }
  .quote-more-toggle { min-height: 40px; }
  .search-pick, .search-row-main { min-height: 44px; }
  .v19-subidx { scrollbar-width: none; }

  /* 触控目标：低于 30px 的行内控件统一放大可点区域（不改变视觉密度） */
  .page-back { width: 36px; height: 36px; }
  .ffv8-rank-add { width: 32px; height: 32px; }
  .ffv8-fold-toggle { height: 32px; padding: 0 11px; font-size: 11.5px; }
  .ev-chip { min-height: 32px; }
  .profile-name-edit { min-height: 32px; padding: 3px 10px; font-size: 12px; }
  .block-more { padding: 8px 6px; margin: -8px -6px; }
  .rank-expand-btn { min-height: 40px; padding: 0 14px; font-size: 12px; }
  .chart-range .range-handle { width: 28px; }
  .chart-range .range-tip.left { left: 30px; }
  .chart-range .range-tip.right { right: 30px; }


  /* 二级面板打开时压暗背景，明确层级（点击穿透，交给既有外部点击收起逻辑） */
  body.has-bottom-subnav::after {
    content: '';
    position: fixed;
    left: 0;
    right: 0;
    top: 0;
    bottom: calc(60px + env(safe-area-inset-bottom, 0px));
    z-index: 64;
    background: rgba(8, 10, 14, 0.26);
    pointer-events: none;
    animation: subnav-fade 0.18s ease;
  }
}

@keyframes subnav-fade {
  from { opacity: 0; }
  to { opacity: 1; }
}


/* 三榜折叠只在手机（≤767px）生效；平板/桌面保持完整 10 条，避免出现「隐藏行但没有展开按钮」 */
@media (max-width: 767px) {
  .rank-fold-toggle {
    display: block;
    width: 100%;
    height: 40px;
    border: 0;
    border-top: 1px solid var(--hairline);
    background: var(--panel-2);
    color: var(--muted);
    font-family: inherit;
    font-size: 12px;
    font-weight: 500;
    letter-spacing: 0.02em;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }
  .rank-fold-toggle:active { background: var(--panel-3); }
  .rank-fold[data-folded] .data-table tbody tr:nth-child(n + 7) { display: none; }
}

/* 桌面端不渲染移动端吸顶条（旧实现会把它作为普通块级元素留在页尾） */
@media (min-width: 1024px) {
  .sticky-quote-bar { display: none; }
  .rank-fold-toggle { display: none; }
}
