/* ==========================================================================
   爆款内容工作台 · 手机端视觉重塑 Nova Mobile
   ----------------------------------------------------------------
   配合 nova.css 的「余烬 Ember」语言，重做手机端底部导航为悬浮「Dock」。
   加载于 mobile.css 之后，仅覆盖 ≤760px 移动端，删除本引入即可回退。
   版本：v1 ｜ 2026-08-20
   ========================================================================== */

@media (max-width: 760px) {
  html,
  body {
    max-width: 100%;
    overflow-x: clip;
  }
  /* ---------- 底部导航：全宽顶条 → 悬浮圆角 Dock ---------- */
  .sidebar {
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: calc(10px + env(safe-area-inset-bottom));
    top: auto;
    width: auto;
    height: auto;
    flex-direction: row;
    align-items: stretch;
    padding: 6px;
    border: 1px solid var(--line);
    border-top: 1px solid var(--line);
    border-right: 1px solid var(--line);
    border-radius: 20px;
    background: color-mix(in srgb, var(--sidebar) 90%, transparent);
    backdrop-filter: blur(22px) saturate(150%);
    -webkit-backdrop-filter: blur(22px) saturate(150%);
    box-shadow: var(--shadow-lg);
    z-index: 30;
  }

  nav {
    display: flex;
    width: 100%;
    gap: 4px;
    padding: 0;
  }

  /* 每个 tab：图标 + 标签，等宽，柔和的选中态 */
  .sidebar .nav-item {
    flex: 1 1 0;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 4px;
    min-height: 58px;
    padding: 8px 2px 6px;
    border: 1px solid transparent;
    border-radius: 15px;
    background: transparent;
    font-size: 11px !important;
    font-weight: 650;
    line-height: 1.1;
    letter-spacing: .01em;
    text-align: center;
    color: var(--t2);
    box-shadow: none;
  }

  .sidebar .nav-item .nav-icon {
    width: 26px;
    height: 26px;
    display: grid;
    place-items: center;
    color: var(--t3);
    transition: color .18s ease, transform .18s ease;
  }
  .sidebar .nav-item .nav-icon svg.icon {
    width: 22px;
    height: 22px;
    stroke-width: 1.8;
  }

  /* 选中态：熔岩橙柔和底 + 橙色 icon/label */
  .sidebar .nav-item.active {
    background: var(--orange-soft);
    border-color: color-mix(in srgb, var(--orange) 26%, var(--line));
    box-shadow: none;
    color: var(--t1);
  }
  .sidebar .nav-item.active .nav-icon {
    color: var(--orange);
  }
  .sidebar .nav-item.active::after {
    display: none; /* 移除桌面端左侧圆点，移动端不使用 */
  }

  .sidebar .nav-item:active {
    transform: scale(.96);
  }

  /* 主题切换按钮上移，避免与悬浮 Dock 重叠 */
  .theme-toggle {
    right: 18px;
    bottom: calc(88px + env(safe-area-inset-bottom));
  }
}

/* 2026-08-23：移动端驾驶舱收紧、榜单卡片化与 AI 对话抽屉。放在最后以覆盖历史主题规则。 */
@media (max-width: 760px) {
  .topbar {
    gap: 12px;
    padding: 14px 0 12px;
  }

  .topbar-brand .brand-mark {
    flex-basis: 38px;
    width: 38px;
    height: 38px;
    border-radius: 12px;
  }
  .topbar-brand .brand-mark .icon {
    width: 36px;
    height: 36px;
  }
  .topbar-brand strong { font-size: 17px; }
  .topbar-brand small { font-size: 10px; }

  .top-actions {
    display: grid !important;
    grid-template-columns: 48px minmax(0, 220px) minmax(0, 1fr) !important;
    gap: 8px;
    align-items: center;
    width: 100%;
  }
  .top-actions > #refreshBtn {
    grid-column: 1 !important;
    grid-row: 1 !important;
  }
  .top-actions > .cockpit-range-slot,
  .top-actions > .cockpit-range-slot.is-single-day,
  .top-actions > .cockpit-range-slot.is-multi-day {
    grid-column: 2 !important;
    grid-row: 1 !important;
    width: min(220px, 100%) !important;
    min-width: 0 !important;
    max-width: 220px !important;
    flex-basis: auto !important;
  }
  .top-actions .range-picker-toggle {
    min-height: 48px;
    padding: 8px 11px;
    gap: 8px;
  }
  .top-actions .range-picker-caption { display: none; }
  .top-actions .range-picker-toggle strong {
    min-width: 0;
    font-size: 12px;
    white-space: nowrap;
  }
  .top-actions > #runProgressCard {
    grid-column: 3 !important;
    grid-row: 1 !important;
    justify-self: end;
    min-width: 0;
  }
  .top-actions #runBtn {
    width: auto !important;
    min-width: 48px;
    padding-inline: 13px;
  }

  .hero-pipeline-card > .hero-card {
    display: block !important;
    height: auto !important;
    min-height: 0 !important;
    padding: 18px 20px 16px !important;
  }
  .hero-pipeline-card .hero-copy h2 {
    margin: 14px 0 8px !important;
    line-height: 1.38;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
    overflow: hidden;
  }
  .hero-pipeline-card .hero-copy p {
    font-size: 11px;
    line-height: 1.45;
  }

  .pipeline-attachment {
    gap: 0 !important;
    padding: 8px 12px !important;
  }
  .pipeline-attachment-head {
    display: flex !important;
    align-items: center;
    gap: 8px;
    min-height: 28px;
  }
  .pipeline-attachment-head > .hero-status-strip {
    flex: 1 1 auto;
    min-width: 0;
    min-height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: hidden;
  }
  .pipeline-attachment-head > .panel-title { display: none !important; }
  .pipeline-mobile-toggle {
    display: inline-flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    min-height: 30px;
    padding: 5px 9px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--panel);
    color: var(--t2);
    font: inherit;
    font-size: 11px;
  }
  .pipeline-attachment.pipeline-collapsed > .pipeline-compact {
    display: none !important;
  }
  .pipeline-attachment:not(.pipeline-collapsed) > .pipeline-compact {
    display: block !important;
    margin-top: 8px;
  }

  #view-dashboard .leaderboard-panel {
    padding: 8px !important;
    overflow: visible;
  }
  #view-dashboard .leaderboard-panel .table-wrap {
    width: 100%;
    overflow: visible !important;
  }
  #view-dashboard .leaderboard-panel table,
  #view-dashboard .leaderboard-panel tbody {
    display: block !important;
    width: 100% !important;
    min-width: 0 !important;
    table-layout: auto !important;
  }
  #leaderboard tr[data-id] {
    width: 100%;
    max-width: 100%;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    grid-template-areas:
      "video video"
      "stats1 stats2"
      "stats3 stats4"
      "status status" !important;
  }
  #leaderboard tr[data-id] td:nth-child(2) {
    min-width: 0;
    padding-left: 40px;
    padding-right: 0;
  }
  #leaderboard tr[data-id] td:nth-child(7) {
    justify-self: start;
    width: 100%;
  }
  #leaderboard .video-cell {
    width: 100%;
    max-width: none !important;
    min-width: 0;
  }

  .aichat-wrap {
    display: block !important;
    position: relative;
    height: calc(100dvh - 190px) !important;
    min-height: 500px;
  }
  .aichat-main {
    height: 100% !important;
    min-height: 0 !important;
  }
  .aichat-side {
    position: fixed;
    top: 12px;
    left: 12px;
    bottom: calc(88px + env(safe-area-inset-bottom));
    z-index: 52;
    width: min(310px, calc(100vw - 40px));
    max-height: none !important;
    visibility: hidden;
    pointer-events: none;
    transform: translateX(calc(-100% - 24px));
    transition: transform .22s ease, visibility .22s ease;
  }
  .aichat-wrap.side-open .aichat-side {
    visibility: visible;
    pointer-events: auto;
    transform: translateX(0);
  }
  .aichat-mobile-menu {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    min-height: 34px;
    padding: 7px 10px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--panel);
    color: var(--t2);
    font: inherit;
    font-size: 12px;
  }
  .aichat-mobile-menu .icon { width: 16px; height: 16px; }
  .aichat-side-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 51;
    border: 0;
    background: rgba(25, 22, 18, .34);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
  }
  .aichat-side-backdrop[hidden] { display: none; }

  .course-selector-projects {
    bottom: calc(88px + env(safe-area-inset-bottom));
  }
  .course-selector-form-grid,
  .course-selector-simple-options,
  .course-selector-source-summary,
  .course-selector-filters,
  .course-selector-review-layout {
    grid-template-columns: 1fr;
  }
  .course-selector-risk-filter { min-height: 44px; }
  .history-sidebar-mobile-trigger { min-height: 44px; }
}

@media (max-width: 390px) {
  .top-actions {
    grid-template-columns: 48px minmax(0, 1fr) auto !important;
  }
  .top-actions > .cockpit-range-slot,
  .top-actions > .cockpit-range-slot.is-single-day,
  .top-actions > .cockpit-range-slot.is-multi-day {
    width: 100% !important;
    max-width: none !important;
  }
  .top-actions #runBtn span { display: none; }
}

/* 榜单手机卡片：仅重排移动端，桌面八列表格保持原样。 */
@media (max-width: 760px) {
  #view-dashboard .leaderboard-panel {
    padding: 8px !important;
    background: transparent;
    border: 0;
    box-shadow: none;
  }

  #leaderboard tr[data-id] {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    grid-template-areas:
      "video video"
      "stats1 stats2"
      "stats3 stats4"
      "status status" !important;
    gap: 12px !important;
    padding: 16px 16px 0 !important;
    border-radius: 20px !important;
    box-shadow: 0 8px 26px color-mix(in srgb, var(--t1) 6%, transparent) !important;
    overflow: hidden;
  }

  #leaderboard tr[data-id] td:nth-child(1) {
    top: 16px !important;
    right: 16px !important;
    left: auto !important;
    width: 44px !important;
    height: 44px !important;
    border-radius: 13px !important;
    background: color-mix(in srgb, var(--elevated) 94%, var(--orange) 6%) !important;
  }

  #leaderboard tr[data-id] td:nth-child(1) .rank-num {
    font-size: 17px !important;
    font-weight: 850 !important;
  }

  #leaderboard tr[data-id] td:nth-child(2) {
    padding: 0 52px 0 0 !important;
  }

  #leaderboard .video-cell {
    display: flex !important;
    align-items: flex-start !important;
    gap: 12px !important;
  }

  #leaderboard .cover-thumb {
    width: 54px !important;
    height: 82px !important;
    flex: 0 0 54px !important;
    border-radius: 10px !important;
    object-fit: cover;
  }

  #leaderboard .video-meta {
    display: grid;
    gap: 7px;
    align-content: start;
    min-width: 0;
  }

  #leaderboard .video-meta > strong {
    font-size: 15px !important;
    line-height: 1.45 !important;
    font-weight: 800 !important;
    letter-spacing: -.01em;
  }

  #leaderboard .account-teacher-line {
    display: flex !important;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    min-width: 0;
    color: var(--t2);
    font-size: 12px !important;
  }

  #leaderboard .account-profile-trigger {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  #leaderboard .teacher-assignment-pill {
    min-height: 24px;
    padding: 3px 9px;
    border-radius: 8px;
    font-size: 11px;
  }

  #leaderboard .operator-line {
    display: block;
    max-width: 100%;
    margin-top: 0 !important;
    color: var(--t2);
    font-size: 11px !important;
    line-height: 1.45;
  }

  #leaderboard tr[data-id] td:nth-child(3),
  #leaderboard tr[data-id] td:nth-child(4),
  #leaderboard tr[data-id] td:nth-child(5),
  #leaderboard tr[data-id] td:nth-child(6) {
    min-height: 72px;
    padding: 11px 12px 12px !important;
    border-radius: 13px !important;
    background: var(--elevated) !important;
    font-size: 15px !important;
    font-weight: 800 !important;
    line-height: 1.35;
    white-space: normal !important;
  }

  #leaderboard tr[data-id] td:nth-child(3)::before,
  #leaderboard tr[data-id] td:nth-child(4)::before,
  #leaderboard tr[data-id] td:nth-child(5)::before,
  #leaderboard tr[data-id] td:nth-child(6)::before {
    margin-bottom: 5px !important;
    font-size: 10px !important;
    font-weight: 700 !important;
    letter-spacing: .06em !important;
  }

  #leaderboard tr[data-id] td:nth-child(4) {
    color: var(--amber);
  }

  #leaderboard .number-strong {
    font-size: 18px !important;
  }

  #leaderboard .trend-line {
    margin-top: 4px !important;
    font-size: 11px !important;
    line-height: 1.35;
    white-space: normal;
  }

  #leaderboard tr[data-id] td:nth-child(7) {
    display: flex !important;
    align-items: center;
    min-height: 58px;
    width: auto !important;
    margin: 2px -16px 0;
    padding: 12px 50px 12px 16px !important;
    border-top: 1px solid var(--line) !important;
  }

  #leaderboard .status-pill {
    padding: 5px 9px !important;
    border-radius: 9px !important;
    font-size: 11px !important;
  }

  #leaderboard tr[data-id] td:nth-child(8) {
    display: grid !important;
    place-items: center;
    position: absolute;
    right: 18px;
    bottom: 18px;
    width: 22px;
    height: 22px;
    color: var(--t1);
    font-size: 24px;
    line-height: 1;
  }
}

/* 2026-08-30：榜单手机卡片密度与字号统一。
   同时清除桌面固定列宽，避免标题、状态和指标块在窄屏溢出。 */
@media (max-width: 760px) {
  html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
  }

  main {
    padding-right: 12px;
    padding-left: 12px;
    padding-bottom: calc(84px + env(safe-area-inset-bottom));
  }

  #view-dashboard > .section-head {
    margin-top: 20px;
    padding: 12px 12px 9px;
    border-radius: 16px 16px 0 0;
  }

  #view-dashboard > .section-head h2 {
    font-size: 20px;
    line-height: 1.3;
  }

  #view-dashboard > .section-head .ranking-title-line {
    display: grid;
    gap: 6px;
  }

  #view-dashboard > .section-head .ranking-confirmations {
    gap: 5px 10px;
  }

  #view-dashboard > .section-head .ranking-confirmations span,
  #view-dashboard > .section-head .legend {
    font-size: 10.5px;
    line-height: 1.45;
  }

  #view-dashboard > .section-head .ranking-confirmations span {
    gap: 5px;
  }

  #view-dashboard > .section-head .ranking-confirmations span i {
    width: 6px;
    height: 6px;
    flex-basis: 6px;
  }

  #view-dashboard > .section-head .row-actions {
    gap: 6px;
    margin-top: 7px;
  }

  #view-dashboard .leaderboard-panel {
    padding: 4px !important;
  }

  #view-dashboard .leaderboard-panel table,
  #view-dashboard .leaderboard-panel tbody {
    display: block !important;
    width: 100% !important;
    min-width: 0 !important;
    table-layout: auto !important;
  }

  #view-dashboard .leaderboard-panel thead {
    display: none !important;
  }

  #leaderboard tr[data-id] {
    display: grid !important;
    width: 100% !important;
    max-width: 100% !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    grid-template-areas:
      "video video"
      "stats1 stats2"
      "stats3 stats4"
      "status status" !important;
    gap: 8px !important;
    margin: 0 0 10px !important;
    padding: 12px 12px 0 !important;
    border-radius: 16px !important;
    overflow: hidden;
  }

  #leaderboard tr[data-id] > td {
    display: block;
    width: auto !important;
    min-width: 0 !important;
    max-width: 100% !important;
    border: 0;
  }

  #leaderboard tr[data-id] td:nth-child(1) {
    top: 12px !important;
    right: 12px !important;
    left: auto !important;
    width: 36px !important;
    height: 36px !important;
    border-radius: 11px !important;
  }

  #leaderboard tr[data-id] td:nth-child(1) .rank-num {
    font-size: 14px !important;
    line-height: 1;
  }

  #leaderboard tr[data-id] td:nth-child(2) {
    grid-area: video;
    padding: 0 42px 0 0 !important;
  }

  #leaderboard .video-cell {
    display: flex !important;
    align-items: flex-start !important;
    gap: 10px !important;
  }

  #leaderboard .cover-thumb {
    width: 48px !important;
    height: 72px !important;
    flex: 0 0 48px !important;
    border-radius: 8px !important;
  }

  #leaderboard .video-meta {
    gap: 4px;
  }

  #leaderboard .video-meta > strong {
    display: -webkit-box !important;
    margin: 0 !important;
    overflow: hidden;
    font-size: 14px !important;
    font-weight: 800 !important;
    line-height: 1.4 !important;
    white-space: normal !important;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
  }

  #leaderboard .account-teacher-line {
    gap: 5px;
    font-size: 11px !important;
    line-height: 1.4;
  }

  #leaderboard .account-profile-trigger {
    font-size: inherit !important;
    line-height: inherit;
  }

  #leaderboard .teacher-assignment-pill {
    min-height: 22px;
    padding: 2px 7px;
    border-radius: 7px;
    font-size: 10px;
  }

  #leaderboard .operator-line {
    font-size: 10.5px !important;
    line-height: 1.4;
  }

  #leaderboard tr[data-id] td:nth-child(3),
  #leaderboard tr[data-id] td:nth-child(4),
  #leaderboard tr[data-id] td:nth-child(5),
  #leaderboard tr[data-id] td:nth-child(6) {
    min-height: 60px;
    padding: 8px 10px 9px !important;
    border-radius: 11px !important;
    font-size: 14px !important;
    line-height: 1.3;
  }

  #leaderboard tr[data-id] td:nth-child(3) { grid-area: stats1; }
  #leaderboard tr[data-id] td:nth-child(4) { grid-area: stats2; }
  #leaderboard tr[data-id] td:nth-child(5) { grid-area: stats3; }
  #leaderboard tr[data-id] td:nth-child(6) { grid-area: stats4; }

  #leaderboard tr[data-id] td:nth-child(3)::before,
  #leaderboard tr[data-id] td:nth-child(4)::before,
  #leaderboard tr[data-id] td:nth-child(5)::before,
  #leaderboard tr[data-id] td:nth-child(6)::before {
    margin-bottom: 3px !important;
    font-size: 9.5px !important;
    line-height: 1.3;
    letter-spacing: .04em !important;
  }

  #leaderboard .number-strong {
    font-size: 16px !important;
  }

  #leaderboard .trend-line,
  #leaderboard .appearance-days {
    margin-top: 2px !important;
    font-size: 10px !important;
    line-height: 1.3;
  }

  #leaderboard tr[data-id] td:nth-child(7) {
    grid-area: status;
    display: flex !important;
    align-items: center;
    justify-self: stretch;
    min-height: 44px;
    margin: 0 -12px;
    padding: 9px 42px 9px 12px !important;
    border-top: 1px solid var(--line) !important;
  }

  #leaderboard .status-pill {
    max-width: calc(100% - 4px);
    padding: 4px 8px !important;
    border-radius: 8px !important;
    font-size: 10px !important;
    line-height: 1.35;
    white-space: normal;
  }

  #leaderboard tr[data-id] td:nth-child(8) {
    right: 14px;
    bottom: 12px;
    width: 20px;
    height: 20px;
    font-size: 20px;
  }

  .sidebar {
    left: 10px;
    right: 10px;
    bottom: calc(8px + env(safe-area-inset-bottom));
    padding: 4px;
    border-radius: 18px;
  }

  .sidebar .nav-item {
    gap: 3px;
    min-height: 52px;
    padding: 6px 2px 5px;
    border-radius: 13px;
    font-size: 10.5px !important;
  }

  .sidebar .nav-item .nav-icon {
    width: 23px;
    height: 23px;
  }

  .sidebar .nav-item .nav-icon svg.icon {
    width: 20px;
    height: 20px;
  }

  .theme-toggle {
    bottom: calc(76px + env(safe-area-inset-bottom));
  }
}

/* 2026-08-31：手机端改为左侧抽屉导航，并精简榜单与详情操作。 */
.mobile-menu-button,
.mobile-nav-backdrop {
  display: none;
}
.shortcut-label-mobile {
  display: none;
}

@media (max-width: 760px) {
  body.mobile-nav-open {
    overflow: hidden;
  }

  main {
    padding: 0 12px calc(30px + env(safe-area-inset-bottom)) !important;
  }

  .mobile-menu-button {
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    padding: 0;
    border: 1px solid var(--line);
    border-radius: 50%;
    background: var(--card);
    color: var(--t1);
    box-shadow: var(--shadow-sm);
    cursor: pointer;
    z-index: 2;
  }
  .mobile-menu-button svg {
    width: 20px;
    height: 20px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
  }

  .mobile-nav-backdrop,
  .mobile-nav-backdrop:hover,
  .mobile-nav-backdrop:focus-visible,
  .mobile-nav-backdrop:active {
    display: block;
    position: fixed !important;
    inset: 0 !important;
    z-index: 74 !important;
    padding: 0;
    border: 0;
    background: rgba(20, 18, 14, .38);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    transform: none !important;
    filter: none !important;
    animation: none !important;
    will-change: auto !important;
    transition: opacity .2s ease, visibility .2s ease;
  }
  body.mobile-nav-open .mobile-nav-backdrop {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
  }

  .sidebar,
  body.auth-locked .sidebar {
    display: flex;
    position: fixed;
    inset: 0 auto 0 0;
    width: min(82vw, 310px);
    height: 100dvh;
    padding: calc(18px + env(safe-area-inset-top)) 14px calc(18px + env(safe-area-inset-bottom));
    flex-direction: column;
    align-items: stretch;
    border: 0;
    border-right: 1px solid var(--line);
    border-radius: 0 22px 22px 0;
    background: color-mix(in srgb, var(--sidebar) 97%, transparent);
    box-shadow: 24px 0 60px rgba(20, 18, 14, .18);
    overflow-y: auto;
    transform: translateX(calc(-100% - 24px));
    visibility: hidden;
    pointer-events: none;
    transition: transform .22s cubic-bezier(.32, .72, .28, 1), visibility .22s ease;
    z-index: 75;
  }
  body.mobile-nav-open .sidebar {
    transform: translateX(0);
    visibility: visible;
    pointer-events: auto;
  }
  .sidebar .brand,
  body.auth-locked .sidebar .brand {
    display: flex !important;
    padding: 2px 8px 20px;
  }
  .sidebar .brand div {
    display: block;
    font-size: inherit;
  }
  .sidebar nav {
    display: grid;
    width: 100%;
    gap: 6px;
    padding: 0;
  }
  .sidebar .nav-item,
  .sidebar .nav-item:nth-child(n+6),
  .sidebar .nav-item[data-view="settings"] {
    display: flex !important;
    width: 100%;
    min-height: 48px;
    padding: 10px 12px;
    flex: 0 0 auto;
    flex-direction: row;
    justify-content: flex-start;
    align-items: center;
    gap: 12px;
    border-radius: 13px;
    font-size: 14px !important;
    line-height: 1.25;
    text-align: left;
  }
  .sidebar .nav-item[hidden] {
    display: none !important;
  }
  .sidebar .nav-item .nav-icon {
    flex: 0 0 24px;
    width: 24px;
    height: 24px;
  }
  .sidebar .nav-item .nav-icon svg.icon {
    width: 20px;
    height: 20px;
  }
  .sidebar .sidebar-foot,
  body.auth-locked .sidebar .sidebar-foot {
    display: block !important;
    width: 100%;
    margin-top: auto;
    padding-top: 16px;
  }
  .sidebar .sidebar-account {
    display: block;
    margin-bottom: 6px;
  }

  .topbar,
  body.view-hides-topbar .topbar {
    display: grid !important;
    grid-template-columns: 42px minmax(0, 1fr) auto;
    align-items: center;
    gap: 8px;
    min-height: 66px;
    height: auto;
    margin: 0 0 14px;
    padding: 11px 0;
    position: sticky;
    top: 0;
    z-index: 60;
    border-bottom: 1px solid var(--line);
    background: color-mix(in srgb, var(--bg) 94%, transparent);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
  }
  body.view-hides-topbar main {
    padding-top: 0 !important;
  }
  .topbar-page-title {
    position: absolute;
    left: 50%;
    width: min(42vw, 190px);
    transform: translateX(-50%);
    text-align: center;
    pointer-events: none;
  }
  .topbar h1,
  .topbar-page-title h1 {
    margin: 0;
    overflow: hidden;
    font-size: 17px !important;
    font-weight: 800;
    line-height: 1.25;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .top-actions {
    grid-column: 3;
    display: flex !important;
    align-items: center;
    justify-content: flex-end;
    gap: 5px;
    width: auto;
  }
  body.view-hides-topbar .top-actions {
    display: none !important;
  }
  #topLastCapture,
  .top-actions > .date-field {
    display: none !important;
  }
  .top-actions > #refreshBtn,
  .top-actions > .cockpit-range-slot,
  .top-actions > .cockpit-range-slot.is-single-day,
  .top-actions > .cockpit-range-slot.is-multi-day,
  .top-actions > #runProgressCard,
  .top-actions #runBtn,
  .top-actions .range-picker,
  .top-actions .range-picker-toggle {
    flex: 0 0 42px !important;
    width: 42px !important;
    min-width: 42px !important;
    max-width: 42px !important;
    height: 42px !important;
    min-height: 42px !important;
    margin: 0 !important;
    padding: 0 !important;
    border-radius: 50% !important;
  }
  .top-actions > #refreshBtn {
    display: none !important;
  }
  .top-actions #runBtn,
  .top-actions .range-picker-toggle {
    display: grid !important;
    place-items: center;
    transform: none !important;
    transition: color .16s ease, border-color .16s ease, background .16s ease !important;
  }
  .top-actions > .cockpit-range-slot,
  .top-actions > .cockpit-range-slot.is-single-day,
  .top-actions > .cockpit-range-slot.is-multi-day,
  .top-actions > #runProgressCard {
    grid-column: auto !important;
    grid-row: auto !important;
    justify-self: auto !important;
  }
  .top-actions .range-picker-caption,
  .top-actions .range-picker-toggle strong,
  .top-actions .range-picker-chevron,
  .top-actions #runButtonLabel,
  .top-actions #runProgressPercent,
  .top-actions #runBtn > span:not(.run-progress-fill),
  .top-actions #refreshBtn > span {
    display: none !important;
  }
  .top-actions .range-picker-icon,
  .top-actions #runButtonIcon {
    display: block !important;
    width: 19px;
    height: 19px;
    margin: 0;
  }
  .top-actions #refreshBtn i {
    margin: 0;
  }
  .top-actions .run-progress-fill {
    border-radius: 50% !important;
  }
  .range-popover {
    position: fixed !important;
    z-index: 160;
    top: calc(68px + env(safe-area-inset-top));
    right: max(10px, env(safe-area-inset-right)) !important;
    left: max(10px, env(safe-area-inset-left)) !important;
    width: auto !important;
    min-width: 0 !important;
    max-width: none !important;
    max-height: calc(100dvh - 82px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
    box-sizing: border-box;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
  }

  #view-dashboard .cockpit-right {
    display: grid !important;
    grid-template-columns: 1fr;
    gap: 10px;
  }
  #view-dashboard .cockpit-metrics {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 10px;
  }
  #view-dashboard .cockpit-right .metric-card {
    aspect-ratio: 1 / 1;
    min-height: 0 !important;
    padding: 13px !important;
    justify-content: center;
    border-radius: 17px;
  }
  #view-dashboard .cockpit-right .metric-card .metric-label {
    margin: 0 0 10px;
    gap: 7px;
    font-size: 11px;
    line-height: 1.3;
  }
  #view-dashboard .cockpit-right .metric-card .metric-icon {
    width: 25px;
    height: 25px;
    border-radius: 8px;
  }
  #view-dashboard .cockpit-right .metric-card strong,
  #view-dashboard .cockpit-right .metric-card.accent-cyan strong {
    margin: 0 0 6px;
    font-size: clamp(20px, 7vw, 29px) !important;
    line-height: 1.08;
  }
  #view-dashboard .cockpit-right .metric-card small {
    font-size: 9.5px;
    line-height: 1.35;
  }
  #view-dashboard .cockpit-right .capture-shortcuts,
  #view-dashboard .cockpit-right .capture-shortcut-grid {
    width: 100%;
  }
  #view-dashboard .cockpit-right .capture-shortcut-grid {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 8px;
  }
  #view-dashboard .cockpit-right .capture-shortcut {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    min-height: 50px !important;
    height: 50px !important;
    padding: 8px 12px !important;
    border-radius: 999px !important;
    transform: none !important;
    transition: color .16s ease, border-color .16s ease, background .16s ease !important;
  }
  #view-dashboard .cockpit-right .capture-shortcut .shortcut-logo {
    flex: 0 0 28px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
  }
  #view-dashboard .cockpit-right .capture-shortcut .shortcut-copy {
    flex: 0 1 auto;
  }
  #view-dashboard .cockpit-right .capture-shortcut .shortcut-copy strong {
    font-size: 12px;
    white-space: nowrap;
  }
  #view-dashboard .shortcut-label-desktop {
    display: none;
  }
  #view-dashboard .shortcut-label-mobile {
    display: inline;
  }
  #view-dashboard .cockpit-right .capture-shortcut .shortcut-copy small,
  #view-dashboard .cockpit-right .capture-shortcut .shortcut-arrow {
    display: none !important;
  }

  #view-dashboard > .section-head .row-actions,
  #view-dashboard > .section-head .ranking-confirmations,
  #pendingVideosBtn,
  #view-dashboard > .section-head .legend,
  #view-dashboard > .section-head .ranking-copy-status {
    display: none !important;
  }
  #view-dashboard > .section-head {
    margin-top: 16px;
    padding-bottom: 8px;
  }
  #leaderboard tr[data-id] {
    grid-template-areas:
      "video video"
      "stats1 stats2"
      "stats3 stats4" !important;
    padding-bottom: 12px !important;
  }
  #leaderboard tr[data-id] td:nth-child(7),
  #leaderboard tr[data-id] td:nth-child(8) {
    display: none !important;
  }

  #detailModal .detail-video-wrap,
  #detailModal .detail-video-placeholder,
  #detailModal footer {
    display: none !important;
  }
  #detailModal .drawer-content {
    padding-bottom: calc(18px + env(safe-area-inset-bottom));
  }

  .theme-toggle {
    bottom: calc(18px + env(safe-area-inset-bottom)) !important;
  }
}

/* 2026-08-31：移动端编辑与记录抽屉稳定性。 */
@media (max-width: 760px) {
  /* 固定手机顶栏占用首行，历史记录抽屉从顶栏下方开始。 */
  #view-aichat .aichat-side,
  #view-course-selector .course-selector-projects {
    top: calc(78px + env(safe-area-inset-top));
    bottom: max(12px, env(safe-area-inset-bottom));
  }

  /* 文案库六个子页完整显示，激活末项时不会把前面的标签推离屏幕。 */
  #copywriterTabs {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 4px;
    width: 100%;
    max-width: 100%;
    overflow: visible;
    padding: 4px;
  }
  #copywriterTabs button {
    width: 100%;
    min-width: 0;
    min-height: 38px;
    padding: 8px 4px;
    font-size: 11px;
    white-space: nowrap;
  }

  /* 老师建档五阶段固定为完整五列，短标签允许自然换行。 */
  .teacher-interview-stages {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 4px;
    width: 100%;
    max-width: 100%;
    overflow: visible;
  }
  .teacher-interview-stages span {
    display: grid;
    place-items: center;
    min-width: 0;
    min-height: 44px;
    padding: 6px 2px;
    font-size: 10px;
    line-height: 1.25;
    white-space: normal;
  }
}

/* 2026-08-31：AI 选片精修弹窗在手机端完全收进视口。 */
@media (max-width: 760px) {
  #courseSelectorEditorModal {
    overflow: hidden;
  }
  #courseSelectorEditorModal .course-selector-editor-modal,
  #courseSelectorEditorModal .course-selector-editor-body,
  #courseSelectorEditorModal .course-selector-editor-toolbar,
  #courseSelectorEditorModal .course-selector-editor-grid {
    width: 100%;
    max-width: 100%;
    min-width: 0;
  }
  #courseSelectorEditorModal .course-selector-editor-body {
    padding: 12px;
    overflow-x: hidden;
  }
  #courseSelectorEditorModal .course-selector-editor-toolbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    align-items: stretch;
    gap: 8px;
  }
  #courseSelectorEditorModal .course-selector-editor-tools {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 8px;
    min-width: 0;
  }
  #courseSelectorEditorModal .course-selector-granularity,
  #courseSelectorEditorModal .course-selector-structure-legend {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
    min-width: 0;
  }
  #courseSelectorEditorModal .course-selector-structure-legend {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 4px;
  }
  #courseSelectorEditorModal .course-selector-structure-legend span {
    min-width: 0;
    padding: 4px 2px;
    overflow: hidden;
    text-align: center;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  #courseSelectorEditorModal .course-selector-editor-toolbar > .row-actions {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
    width: 100%;
    min-width: 0;
  }
  #courseSelectorEditorModal .course-selector-editor-toolbar > .row-actions .button {
    width: 100%;
    min-width: 0;
    padding: 0 4px;
    font-size: 10px;
    white-space: nowrap;
  }
  #courseSelectorEditorModal .course-selector-editor-grid {
    grid-template-columns: minmax(0, 1fr);
    gap: 10px;
    min-height: 0;
  }
  #courseSelectorEditorModal .course-selector-editor-grid > section,
  #courseSelectorEditorModal .course-selector-editor-grid > aside {
    min-width: 0;
    padding: 10px;
  }
  #courseSelectorEditorModal .course-selector-editor-label {
    min-width: 0;
  }
  #courseSelectorEditorModal .course-selector-editor-label small {
    overflow-wrap: anywhere;
  }
  #courseSelectorEditorModal .course-selector-editor-blocks {
    min-height: 320px;
    padding: 18px 16px;
  }
  #courseSelectorEditorModal .course-selector-segment-text {
    font-size: 16px;
    line-height: 1.9;
  }
}

/* 2026-08-31：手机实机第二轮收紧——抽屉、顶栏与榜单摘要。 */
@media (max-width: 760px) {
  .sidebar,
  body.auth-locked .sidebar {
    width: min(72vw, 272px);
    padding-right: 12px;
    padding-left: 12px;
  }
  .mobile-nav-backdrop,
  .mobile-nav-backdrop:hover,
  .mobile-nav-backdrop:focus-visible,
  .mobile-nav-backdrop:active {
    left: min(72vw, 272px) !important;
  }
  #workspaceSidebar #nav {
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    justify-content: flex-start !important;
    width: 100% !important;
  }
  #workspaceSidebar #nav > .nav-item,
  #workspaceSidebar #nav > .nav-item:nth-child(n+6),
  #workspaceSidebar #nav > .nav-item[data-view="settings"] {
    align-self: stretch !important;
    flex: 0 0 auto !important;
    width: 100% !important;
    max-width: none !important;
    margin-right: 0 !important;
    margin-left: 0 !important;
    padding-right: 14px !important;
    padding-left: 14px !important;
  }
  .sidebar .sidebar-account-trigger {
    width: 100% !important;
    max-width: none !important;
  }

  .topbar,
  body.view-hides-topbar .topbar {
    width: calc(100% + 24px);
    margin-right: -12px;
    margin-left: -12px;
    padding-right: 12px;
    padding-left: 12px;
  }

  .hero-pipeline-card > .hero-card {
    padding: 13px 16px 12px !important;
  }
  .hero-pipeline-card .chip.hot {
    padding: 4px 8px;
    font-size: 0;
    letter-spacing: .08em;
  }
  .hero-pipeline-card .chip.hot::after {
    content: "TOP 1";
    font-size: 9px;
  }
  .hero-pipeline-card .hero-kicker,
  .hero-pipeline-card .hero-history-strip {
    display: none !important;
  }
  .hero-pipeline-card .hero-copy h2 {
    margin: 8px 0 5px !important;
    font-size: 17px !important;
    line-height: 1.34 !important;
    -webkit-line-clamp: 2;
  }
  .hero-pipeline-card .hero-copy p:not(.hero-kicker) {
    margin: 0 !important;
    overflow: hidden;
    font-size: 10.5px !important;
    line-height: 1.35 !important;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  #view-dashboard .cockpit-right {
    gap: 8px;
  }
  #view-dashboard .cockpit-metrics {
    gap: 8px;
  }
  #view-dashboard .cockpit-right .metric-card {
    aspect-ratio: auto;
    min-height: 84px !important;
    padding: 11px 13px !important;
    justify-content: center;
  }
  #view-dashboard .cockpit-right .metric-card .metric-label {
    margin: 0 0 7px;
    font-size: 10px;
  }
  #view-dashboard .cockpit-right .metric-card .metric-icon {
    width: 22px;
    height: 22px;
    border-radius: 7px;
  }
  #view-dashboard .cockpit-right .metric-card strong,
  #view-dashboard .cockpit-right .metric-card.accent-cyan strong {
    margin: 0;
    font-size: clamp(20px, 6.3vw, 25px) !important;
  }
  #ordersDelta,
  #ordersDate,
  #gmvRoi,
  #gmvDate {
    display: none !important;
  }
}

/* 2026-09-04：手机端全页连接修复——稳定遮罩、抽屉和全局浮动控件。 */
@media (max-width: 760px) {
  /* 遮罩本身也是 button，必须彻底隔离普通按钮的 hover 位移与动画。 */
  .aichat-side-backdrop,
  .aichat-side-backdrop:hover,
  .aichat-side-backdrop:focus-visible,
  .aichat-side-backdrop:active,
  .course-selector-side-backdrop,
  .course-selector-side-backdrop:hover,
  .course-selector-side-backdrop:focus-visible,
  .course-selector-side-backdrop:active {
    position: fixed !important;
    z-index: 51 !important;
    inset: 0 !important;
    width: auto !important;
    height: auto !important;
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    transform: none !important;
    filter: none !important;
    animation: none !important;
    transition: none !important;
    will-change: auto !important;
  }

  /* fixed 抽屉不能继承桌面 sticky 卡片的 align-self，否则上下 inset 不会撑满。 */
  #view-course-selector .course-selector-projects {
    align-self: stretch !important;
    height: auto !important;
    max-height: none !important;
  }

  /* 嵌入投流页的负边距必须与手机主区 12px 内边距一致。 */
  #view-sph-monitor.sph-monitor-view {
    margin: -16px -12px -90px;
  }

  /* 主题入口收进手机菜单顶部，避免持续盖住卡片、表单、弹窗和抽屉。 */
  .theme-toggle,
  .theme-toggle:hover,
  .theme-toggle:focus-visible,
  .theme-toggle:active {
    position: fixed !important;
    z-index: 76 !important;
    top: calc(14px + env(safe-area-inset-top)) !important;
    right: auto !important;
    bottom: auto !important;
    left: calc(min(72vw, 272px) - 54px) !important;
    width: 40px !important;
    height: 40px !important;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: none !important;
    filter: none !important;
    animation: none !important;
    transition: opacity .16s ease, visibility .16s ease !important;
    will-change: auto !important;
  }
  body.mobile-nav-open .theme-toggle {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
  }
}
