/* ============================================================
   移动端适配（手机 / 平板）+ PWA 增强
   所有页面共用。页面规则一律以 body 类（page-index / page-notes /
   page-practice / page-speech / page-vnotes）为前缀隔离，避免串扰。
   桌面端（> 900px）不受影响。
   ============================================================ */

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
body {
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

/* ==================== 通用（所有页面） ==================== */
@media (max-width: 900px) {
  /* 顶部栏：小屏允许换行、按钮紧凑、适配刘海 */
  header {
    flex-wrap: wrap;
    gap: 6px;
    padding: calc(10px + env(safe-area-inset-top)) 10px 8px;
  }
  header .logo { width: 32px; height: 32px; font-size: 15px; }
  header .title { font-size: 14px; }
  header .title small { display: none; }
  header .btn { padding: 6px 9px; font-size: 12px; }
  header .stat { display: none; }

  /* 抽屉遮罩（index / video_notes 用） */
  #drawerBackdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .55);
    z-index: 19;
  }
  #drawerBackdrop.show { display: block; }
  body.drawer-open { overflow: hidden; }
}

/* ==================== index.html（视频课程） ==================== */
@media (max-width: 900px) {
  .page-index #menuToggle { display: inline-flex; }
  /* 头部精简：只留 logo + 标题 + ☰（控制条上已有练习/笔记入口） */
  .page-index header .btn:not(#menuToggle) { display: none; }
  .page-index header .title { font-size: 13.5px; }
  .page-index header .title small { display: none; }

  /* 侧栏抽屉：全高覆盖（不依赖头部高度），固定定位 */
  .page-index main aside {
    position: fixed !important;
    left: 0 !important;
    top: 0 !important;
    bottom: 0 !important;
    max-height: none !important;
    padding-top: env(safe-area-inset-top);
    -webkit-overflow-scrolling: touch;
  }

  /* 播放区：高度 ≈ 视频 16:9 + 控制条（约 33vh），上下无多余黑区 */
  .page-index .player-wrap {
    flex: 0 0 auto;
    height: 33vh;
    min-height: 170px;
    padding: 4px;
  }
  .page-index .vp-shell video { max-height: 100%; }

  /* 控制区紧凑 */
  .page-index .now-playing { padding: 8px 12px; flex-shrink: 0; }
  .page-index .np-title { font-size: 14px; }
  .page-index .np-controls .btn { padding: 7px 12px; flex: 1 1 auto; justify-content: center; }
  .page-index .switch { font-size: 12px; }
  .page-index .hint { display: none; }

  /* 底部面板：占剩余空间，内部滚动 */
  .page-index .panel {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
  }
  .page-index .panel-tabs { padding: 8px 12px 0; flex-shrink: 0; }
  .page-index .panel-tabs .tab { padding: 7px 12px; font-size: 12.5px; }
  .page-index .panel-body {
    flex: 1 1 auto;
    min-height: 0;
    max-height: none;
    padding: 12px;
    overflow-y: auto;
  }

  /* 题目选项整行可点 */
  .page-index .opts { display: flex; flex-direction: column; gap: 8px; }
  .page-index .opt { width: 100%; }
  /* 截图网格 2 列 */
  .page-index .shots { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
}

/* ==================== notes.html（学习笔记） ==================== */
@media (max-width: 900px) {
  .page-notes main { flex-direction: column; }
  .page-notes main aside {
    position: static !important;
    width: 100% !important;
    min-width: 0 !important;
    max-height: 40vh;
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding-top: 0 !important;
  }
  .page-notes .note-list {
    display: flex;
    flex-direction: row;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 10px;
    gap: 8px;
  }
  .page-notes .note-item {
    flex: 0 0 auto;
    min-width: 118px;
    margin-bottom: 0;
  }
  .page-notes .editor-head { padding: 10px 14px; gap: 8px; flex-wrap: wrap; }
  .page-notes .editor-head .save-state { font-size: 11px; }
  .page-notes textarea { font-size: 16px; padding: 16px 18px; }  /* ≥16px 防 iOS 聚焦缩放 */
}

/* ==================== practice.html（课后练习） ==================== */
@media (max-width: 900px) {
  .page-practice main { padding: 14px 12px 70px; }
  .page-practice .cat { padding: 9px 14px; font-size: 13px; }
  .page-practice .qcard { padding: 14px; }
  .page-practice .qcard .qtext { font-size: 15px; }
  .page-practice .opt { padding: 12px 14px; }
  .page-practice .actions .btn { flex: 1 1 auto; justify-content: center; }
}

/* ==================== speech.html（口语跟读） ==================== */
@media (max-width: 900px) {
  .page-speech main { padding: 14px 12px 70px; }
  .page-speech .scard { padding: 18px 14px; }
  .page-speech .s-es { font-size: 22px; }
  .page-speech .s-actions .btn { padding: 12px 18px; font-size: 14px; flex: 1 1 auto; justify-content: center; }
  .page-speech .nav-row .btn { padding: 10px 16px; }
}

/* ==================== video_notes.html（视频笔记） ==================== */
@media (max-width: 900px) {
  .page-vnotes .menu-btn { display: inline-flex; }
  /* 头部精简：只留 ☰ + 返回课程 */
  .page-vnotes header .btn:not(.menu-btn) { display: none; }
  .page-vnotes header .btn.primary { display: inline-flex; }
  .page-vnotes main aside {
    position: fixed !important;
    left: 0 !important;
    top: 0 !important;
    bottom: 0 !important;
    max-height: none !important;
    padding-top: env(safe-area-inset-top);
    -webkit-overflow-scrolling: touch;
  }
  /* 视频区固定高度，笔记区占剩余空间滚动 */
  .page-vnotes .video-area {
    flex: 0 0 auto;
    height: 34vh;
    min-height: 160px;
    padding: 6px;
  }
  .page-vnotes .video-area video { max-height: 100%; }
  .page-vnotes .video-bar { padding: 8px 12px; gap: 8px; flex-wrap: wrap; }
  .page-vnotes .vb-title { font-size: 13px; }
  .page-vnotes .notes { padding: 12px 12px 60px; }
  .page-vnotes .doc-head h2 { font-size: 17px; }
  .page-vnotes .sec-time { padding: 8px 10px; }
  .page-vnotes .imgwrap { min-width: 0; }
}

/* ==================== 平板横屏 / 中等宽度微调 ==================== */
@media (min-width: 901px) and (max-width: 1200px) {
  header .btn { padding: 7px 11px; font-size: 12.5px; }
  header .title { font-size: 15px; }
}
