/* ============================================================
   手机端适配
   ------------------------------------------------------------
   只在窄屏生效，桌面端的排版一点都不动。
   断点： 820px（平板竖屏 / 大屏手机）  480px（普通手机）
   ============================================================ */

/* 手机上表格要能横向滑：renderTable 会套一层 .tblwrap */
.tblwrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.tblwrap::after { content: ""; display: block; height: 1px; }

/* 手机上才出现的「文章 / 题目」切换（阅读用），桌面端隐藏 */
.mob-switch { display: none; }

@media (max-width: 820px) {

  /* ---------------------------------------------------- 基础 */
  body { font-size: 16px; }
  .btn { min-height: 40px; }
  .btn.sm, .btn.tiny { min-height: 34px; }

  /* ------------------------------------------------ 顶栏 */
  .hdr {
    height: auto;
    min-height: 56px;
    flex-wrap: wrap;
    padding: 8px 12px;
    gap: 8px 10px;
    align-items: center;
  }
  .hdr-left { min-width: 0; flex: 1 1 auto; flex-direction: row; align-items: baseline; gap: 8px; }
  .cand { display: none; }                      /* 考号在手机上没意义，省地方 */
  .time { font-size: 14px; white-space: nowrap; }
  .hdr-mid { order: 3; width: 100%; flex: 1 1 100%; gap: 6px; font-size: 12px; }
  .hdr-mid .bar { flex: 1; min-width: 60px; }
  .hdr-right { margin-left: auto; gap: 6px; }
  .hdr-right .btn { padding: 6px 10px; font-size: 13px; }
  .ic-btn { width: 34px; height: 34px; }
  .ic-btn.sm { width: 30px; height: 30px; }
  #btn-volume { display: none; }                /* 音量用手机侧键，藏掉这个按钮省地方 */
  .audio-note, .audio-hint { display: none; }

  /* ------------------------------------------- 指令面板 */
  .instr { padding: 14px 16px; margin: 10px 12px 0; border-radius: 6px; }
  .instr h1 { font-size: 20px; margin: 0 0 8px; }
  .instr p { font-size: 14.5px; margin: 6px 0 0; }

  /* ------------------------------------ 两栏 → 上下堆叠 */
  .cols, .cols.one, .cols.wide-left { display: block; }
  .col-left {
    padding: 12px 12px 0;
    border-right: 0;
    border-bottom: 1px solid var(--rule);
  }
  .col-right { padding: 12px 12px 0; min-height: 0; }
  .wrap, .examwrap { padding: 0; }

  /* ------------------------------------ 阅读：文章/题目 切换 */
  .mob-switch {
    display: flex; position: sticky; top: 0; z-index: 6;
    background: #fff; border-bottom: 1px solid var(--rule);
    margin: 0 0 12px; padding: 6px 12px; gap: 6px;
  }
  .mob-switch button {
    flex: 1; border: 1px solid var(--panel-line); background: #fff;
    font: inherit; font-size: 14px; padding: 9px 0; border-radius: 7px; cursor: pointer;
    color: var(--ink-2);
  }
  .mob-switch button.on { background: var(--teal); border-color: var(--teal); color: #fff; font-weight: 600; }

  /* 只看一边 */
  body[data-mobview="passage"] .mob-hide-passage,
  body[data-mobview="questions"] .mob-hide-questions { display: none !important; }

  /* --------------------------------------------- 表格 */
  /* 不用负外边距"出血"——那会把整页撑宽 12px。就让它在本栏内横向滚动。 */
  .tblwrap { margin: 0; padding: 0 0 4px; }
  .gaptable { font-size: 13.5px; min-width: 520px; }
  .gaptable th, .gaptable td { padding: 7px 9px; }
  .gaptable caption { font-size: 14px; }

  /* ----------------------------------------- 笔记 / 选项框 */
  .notes.boxed { padding: 12px 14px; }
  .notes-title { font-size: 15.5px; margin-bottom: 10px; }
  .notes .line.two { display: block; }
  .notes .line.two .l { width: auto; margin-bottom: 2px; }
  .notes .line.two .r { padding-left: 0; }
  .optbox { padding: 10px 12px; font-size: 14px; }

  /* ------------------------------------------- 题干/选项 */
  .qgroup { margin-bottom: 20px; }
  .qgroup-head .r { font-size: 14.5px; }
  .qgroup-head .ins { font-size: 14px; }
  .qitem { gap: 8px; }
  .qnum { flex-basis: 34px; min-width: 34px; height: 26px; line-height: 26px; font-size: 13px; }
  .qstem { font-size: 15px; }
  .opt { padding: 9px 4px; font-size: 15px; }
  input.gap, select.sel {
    min-height: 34px; font-size: 15px; padding: 4px 8px;
    max-width: 100%;
  }
  .optbox .opt, label.opt { line-height: 1.5; }

  /* --------------------------------------------- 底部栏 */
  .botbar {
    height: auto; min-height: 52px; padding: 6px 8px;
    overflow-x: auto; -webkit-overflow-scrolling: touch;
    flex-wrap: nowrap; gap: 12px; font-size: 13px;
  }
  .botbar .qbox { min-width: 30px; height: 30px; line-height: 30px; font-size: 13px; }
  .partnav { flex: 0 1 auto; gap: 8px; }
  .qboxes { flex: 0 1 auto; max-width: 44vw; }
  .partnav-title { font-size: 13px; }
  .partmeta { font-size: 13px; white-space: nowrap; flex: 0 0 auto; }
  .partmeta .cnt { display: none; }             /* 「0 of 10」手机上省略，腾地方 */
  .botbar::-webkit-scrollbar { height: 3px; }

  /* ------------------------------------------- 上下题按钮 */
  .navbtns { right: 10px; bottom: 68px; }
  .navbtns .btn { width: 46px; height: 46px; }

  /* -------------------------------------------- 对话弹窗 */
  .dlg { width: 94vw; max-width: 94vw; padding: 20px 18px; max-height: 86vh; overflow: auto; }
  .dlg h3 { font-size: 17px; }
  .dlg .acts { flex-wrap: wrap; gap: 8px; }
  .dlg .acts .btn { flex: 1 1 auto; min-width: 120px; }

  /* ---------------------------------------------- 笔记面板 */
  .notepanel {
    position: fixed; inset: 0; width: 100%; max-width: 100%;
    transform: translateX(100%); z-index: 60;
  }
  .notepanel.on { transform: none; }
  .notepanel textarea { font-size: 15px; }

  /* ------------------------------------------------ 首页 */
  .home { padding: 20px 16px 40px; }
  .home-top { flex-direction: column; align-items: stretch; gap: 12px; }
  .home-top h1 { font-size: 21px; }
  .home-right { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  .home-right .btn { width: 100%; }
  .home-right .home-user { grid-column: 1 / -1; text-align: left; }
  .tiles { grid-template-columns: 1fr; }
  .tile { padding: 14px 16px; }
  .home-actions { flex-direction: column; }
  .home-actions .btn { width: 100%; }

  /* ------------------------------------------ 音频设备面板 */
  .av-panel { margin: 0 0 16px; padding: 14px; }
  .av-head { flex-wrap: wrap; gap: 8px; }
  .av-row { flex-wrap: wrap; gap: 8px; }
  .av-row select, .av-row input[type=range] { min-width: 0; flex: 1 1 140px; }
  .av-label { min-width: 60px; }

  /* ---------------------------------------------- 选题页 */
  .picker { padding: 24px 16px 40px; }
  .pick-list { grid-template-columns: 1fr; }
  .pick-card { padding: 16px 18px; }

  /* ---------------------------------------------- 设置页 */
  .settings { padding: 20px 16px 50px; }
  .settings-head h1 { font-size: 21px; }
  .settings h2 { font-size: 16px; }
  .grid2 { grid-template-columns: 1fr; }
  .kv { flex-wrap: wrap; gap: 4px; }
  .kv code { word-break: break-all; }
  .card2 { padding: 14px 16px; }

  /* ---------------------------------------------- 结果页 */
  .result { padding: 20px 14px 50px; }
  .result h1 { font-size: 22px; }
  .res-h { font-size: 15px; }
  .ai-card { padding: 14px 16px; }
  .ai-bands { grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); }
  .ai-band .v, .ai-band .big { font-size: 20px; }
  .band-summary { flex-wrap: wrap; }
  .ov-sec { padding: 12px 14px; }

  /* ---------------------------------------------- 口语 */
  .sp-wrap { max-width: 100%; }
  .sp-rec { gap: 8px; }
  .sp-rec .btn.sm { padding: 7px 14px; font-size: 14px; }
  .sp-play audio { width: 100%; max-width: 100%; }
  .sp-cue { padding: 12px 14px; }

  /* ---------------------------------------------- 写作 */
  .answerbox { min-height: 260px; font-size: 15px; }
  .wtask { font-size: 14.5px; }
  .figwrap img, img.figure { width: 100%; height: auto; }

  /* ------------------------------------------------- 其他 */
  .hist-item { padding: 12px 14px; }
  .hist-item .row { flex-wrap: wrap; gap: 6px; }
  table.hist-table, table.res-table, table.ov-table { font-size: 12.5px; }
  .made-by { font-size: 17px; margin: 28px 0 12px; }
  .made-by b { font-size: 19px; }
}

/* ============================================================
   小屏手机再收一档
   ============================================================ */
@media (max-width: 480px) {
  body { font-size: 15.5px; }

  .hdr { padding: 7px 10px; }
  .time { font-size: 13px; }
  .hdr-right .btn { padding: 5px 8px; font-size: 12px; }
  .btn.finish { padding: 5px 10px; }

  .instr { margin: 8px 10px 0; padding: 12px 13px; }
  .instr h1 { font-size: 18px; }

  .col-left, .col-right { padding-left: 10px; padding-right: 10px; }
  .mob-switch { margin-left: 0; margin-right: 0; padding: 6px 10px; }

  .qnum { flex-basis: 30px; min-width: 30px; font-size: 12px; }
  .qstem { font-size: 14.5px; }
  .opt { font-size: 14.5px; }

  .notes.boxed { padding: 10px 12px; }
  .notes .line { font-size: 14.5px; }

  .home-right { grid-template-columns: 1fr; }
  .ai-bands { grid-template-columns: 1fr 1fr; }

  .made-by { font-size: 15px; }
  .made-by b { font-size: 17px; }
}

/* ============================================================
   横屏手机 / 小平板：顶栏还是一条，但收紧一点
   ============================================================ */
@media (max-width: 820px) and (orientation: landscape) {
  .hdr { flex-wrap: nowrap; }
  .hdr-mid { order: 0; width: auto; flex: 0 1 auto; }
  .cand { display: block; font-size: 11px; }
  .hdr-left { flex: 0 0 auto; }
}

/* ============================================================
   触屏：去掉 hover 造成的粘滞
   ============================================================ */
@media (hover: none) {
  .tile:hover, .pick-card:hover, .btn:hover { transform: none; }
  .btn:active { opacity: .82; }
  .opt:active { background: #f2f5f7; }
}

/* ============================================================
   管理后台的手机端
   ============================================================ */
@media (max-width: 820px) {
  .mgr-hdr { flex-wrap: wrap; height: auto; padding: 10px 12px; gap: 8px 12px; }
  .mgr-hdr-left { font-size: 14px; }
  .mgr-logo { display: none; }                 /* 手机上省掉英文品牌名 */
  .mgr-sep { display: none; }
  .mgr-tabs { order: 3; width: 100%; flex: 1 1 100%; gap: 6px; overflow-x: auto; }
  .mgr-tab { padding: 8px 14px; font-size: 14px; white-space: nowrap; }
  .mgr-hdr-right { margin-left: auto; gap: 8px; }
  .mgr-who { display: none; }

  .mgr-pane { padding: 14px 12px 40px; }
  .mgr-cards { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
  .mgr-card { padding: 13px 14px; }
  .mgr-card .v { font-size: 24px; }
  .mgr-box { padding: 14px; }
  .mgr-bar { gap: 8px; }
  .mgr-search { flex: 1 1 140px; min-width: 0; }

  /* 表格改成卡片式：手机上横着拖表格太难用 */
  .mgr-table thead { display: none; }
  .mgr-table, .mgr-table tbody, .mgr-table tr, .mgr-table td { display: block; width: 100%; }
  .mgr-table tr {
    border: 1px solid #e3e7ea; border-radius: 10px;
    padding: 12px 14px; margin-bottom: 10px; background: #fff;
  }
  .mgr-table td { border: 0; padding: 4px 0; display: flex; justify-content: space-between; gap: 12px; }
  .mgr-table td::before {
    content: attr(data-l); color: #8b9299; font-size: 12.5px; flex: 0 0 auto;
  }
  .mgr-table td:first-child { display: block; font-size: 15px; margin-bottom: 6px; }
  .mgr-table td:first-child::before { display: none; }
  .mgr-table .w { display: none; }             /* 进度条手机上省掉 */
  .mgr-table .acts { flex-wrap: wrap; justify-content: flex-start; gap: 6px; margin-top: 8px; border-top: 1px solid #f1f3f5; padding-top: 10px; }
  .mgr-table .acts::before { display: none; }
  .mgr-table .acts .btn { flex: 0 0 auto; }

  .mgr-dlg { max-width: 94vw; padding: 20px 18px; }
  .mgr-dlg-acts { flex-wrap: wrap; }
  .mgr-dlg-acts .btn { flex: 1 1 auto; }
  .mgr-bar-row .nm { width: 80px; }
}
/* ============================================================
   手机上：顶部音频条可收起
   ============================================================ */
.audio-expand { display: none; }

@media (max-width: 820px) {
  /* 默认只留 播放键 + 时间 + 展开箭头。
     注意要显式写 display —— cbt.css 在 900px 以下把 .hdr-mid 整个藏了。 */
  .hdr-mid { display: flex; flex-wrap: nowrap; align-items: center; }
  .hdr-mid .seek, .hdr-mid .wave, .hdr-mid #audioText { display: none; }
  .hdr-mid .tcode { font-size: 12.5px; white-space: nowrap; margin-left: auto; }
  .audio-expand { display: inline-flex; flex: 0 0 auto; }

  /* 展开后：进度条单独占一行 */
  body.audio-open .hdr-mid { flex-wrap: wrap; }
  body.audio-open .hdr-mid .seek {
    display: block; order: 9; flex: 1 1 100%;
    width: 100%; margin: 2px 0 0;
  }
  body.audio-open .hdr-mid .wave { display: none; }
  body.audio-open .hdr-mid #audioText {
    display: block; order: 10; flex: 1 1 100%;
    font-size: 11.5px; color: var(--ink-3);
  }
}

/* ============================================================
   手机上：全屏写作
   ============================================================ */
.wfull-bar { display: none; }

@media (max-width: 820px) {
  .wfull-bar {
    display: none;
    align-items: center; gap: 10px; margin-bottom: 8px;
  }
  .wfull-count { display: none; font-size: 13px; color: var(--ink-3); }

  /* 平时显示「全屏写作」 */
  body:not(.writing-full) .wfull-bar { display: flex; }
  body:not(.writing-full) #btn-exitfull { display: none; }

  /* 全屏状态：藏掉题目、说明、底栏、导航按钮和其他栏目 */
  body.writing-full { overflow: hidden; }
  body.writing-full .hdr,
  body.writing-full .instr,
  body.writing-full .botbar,
  body.writing-full .navbtns,
  body.writing-full .col-left,
  body.writing-full .wordcount,
  body.writing-full #ai-out,
  body.writing-full #ai-write,
  body.writing-full #ai-msg,
  body.writing-full .hint2,
  body.writing-full .made-by { display: none !important; }

  body.writing-full .wfull-bar {
    display: flex; position: fixed; top: 0; left: 0; right: 0; z-index: 50;
    background: #fff; border-bottom: 1px solid var(--rule);
    padding: 8px 12px; margin: 0;
  }
  body.writing-full .wfull-bar #btn-fullwrite { display: none; }
  body.writing-full .wfull-bar .wfull-count { display: inline; margin-left: auto; }
  body.writing-full .wfull-bar #btn-exitfull { display: inline-flex; }

  body.writing-full .col-right { padding: 0; }
  body.writing-full .cols { display: block; }
  body.writing-full .answerbox {
    display: block; position: fixed; z-index: 40;
    top: 54px; left: 0; right: 0; bottom: 0;
    width: 100%; max-width: 100%; height: auto; min-height: 0;
    border: 0; border-radius: 0; padding: 14px 16px;
    font-size: 16px; line-height: 1.7;
    resize: none; outline: none;
  }
  body.writing-full #wrap { padding: 0; margin: 0; }
  body.writing-full .exam, body.writing-full #scr-exam { overflow: hidden; }
}