/* ============================================================
   移动端适配（手机 / 平板）+ PWA 增强 — De finale
   所有页面共用。页面规则一律以 body 类（page-index / page-thema /
   page-vocab / page-notes / page-practice / page-profile）为前缀隔离。
   桌面端（> 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: 10px 10px 8px;   /* 顶部安全区统一交给 safe-area.css 的 body padding */
  }
  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; }

  /* 抽屉遮罩 */
  #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（首页：thema 网格） ==================== */
@media (max-width: 900px) {
  .page-index #menuToggle { display: inline-flex; }
  .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;
  }

  .page-index .thema-grid { grid-template-columns: 1fr; gap: 10px; }
  .page-index .thema-card { padding: 14px 16px; }
  .page-index .thema-card .num { width: 44px; height: 44px; font-size: 16px; }
  .page-index .thema-card .title-zh { font-size: 15px; }
  .page-index .hero { padding: 18px 14px; }
  .page-index .hero h1 { font-size: 22px; }
}

/* ==================== thema.html（thema 详情） ==================== */
@media (max-width: 900px) {
  .page-thema main { flex-direction: column; padding: 12px; }
  .page-thema .thema-main { padding: 14px; }
  .page-thema .pdf-toolbar { flex-wrap: wrap; gap: 6px; }
  .page-thema .pdf-toolbar .pdf-page-input { width: 56px; }
  .page-thema .audio-list { gap: 8px; }
  .page-thema .audio-item { padding: 10px 12px; }
  .page-thema .transcript-page { padding: 12px 14px; }
  .page-thema .transcript-page .page-text { font-size: 14.5px; }
  .page-thema .vocab-mini .vw { font-size: 14px; padding: 9px 11px; }
}

/* ==================== vocab.html（闪卡） ==================== */
@media (max-width: 900px) {
  .page-vocab main { padding: 14px 12px 70px; }
  .page-vocab .chip { padding: 9px 14px; font-size: 13px; }
  .page-vocab .card-wrap { min-height: 250px; }
  .page-vocab .card3d { height: 280px; }
  .page-vocab .face { padding: 24px 16px; }
  .page-vocab .face .word { font-size: 32px; }
  .page-vocab .face .sub { font-size: 18px; }
  .page-vocab .grade-row .btn { min-width: 0; padding: 12px 8px; font-size: 13.5px; flex: 1 1 30%; }
  .page-vocab .kbd-hint { display: none; }
  .page-vocab .start-row .btn { flex: 1 1 auto; justify-content: center; }
  .page-vocab .switch { font-size: 12px; }
  .page-vocab .done-stats .stat-chip { font-size: 12px; }
}

/* ==================== 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; }
}

/* ==================== practice.html（oefening 速览） ==================== */
@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; }
}

/* ==================== profile.html ==================== */
@media (max-width: 900px) {
  .page-profile main { padding: 14px 12px 70px; }
  .page-profile .stat-chip { font-size: 12px; padding: 6px 10px; }
}

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