/* 数问阑珊 手机版 —— 沿用桌面版暖色系配色 */
:root {
  --bg: #FFF5E1;
  --btn: #FFA07A;
  --btn-fg: #2F4F4F;
  --correct: #98FB98;
  --incorrect: #FF6347;
  --label: #FFE4B5;
  --text: #2F4F4F;
  --stats: #FFDEAD;
  --default: #F5DEB3;
  --line: rgba(47, 79, 79, .18);
}
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  overscroll-behavior: none;
}
img { user-select: none; -webkit-user-drag: none; }

/* ---------- 页面切换 ---------- */
.page { display: none; min-height: 100vh; min-height: 100dvh; flex-direction: column; }
.page.active { display: flex; }

/* ---------- 按钮 ---------- */
.btn {
  font: 600 15px/1 -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--btn-fg);
  background: var(--btn);
  border: none;
  border-radius: 12px;
  padding: 13px 10px;
  box-shadow: 0 2px 0 rgba(47,79,79,.15);
}
.btn:active { transform: translateY(1px); box-shadow: none; opacity: .92; }
.btn.locked { opacity: .35; }
.btn-primary { background: #ff8c5a; color: #fff; }
.btn-danger { background: var(--incorrect); color: #fff; }
.btn-big { padding: 15px; font-size: 17px; }
.btn-small { padding: 8px 14px; font-size: 13px; border-radius: 9px; }
.btn.ok { background: var(--correct); }
.btn.bad { background: var(--incorrect); color: #fff; }

/* ---------- 登录页 ---------- */
#page-login { align-items: center; justify-content: center; }
.login-wrap { width: 86%; max-width: 360px; text-align: center; }
.login-logo { border-radius: 22px; margin-bottom: 10px; }
.login-title { font-size: 30px; letter-spacing: 8px; margin-bottom: 4px; }
.login-sub { font-size: 13px; opacity: .65; margin-bottom: 26px; }
.login-form { text-align: left; display: flex; flex-direction: column; gap: 8px; }
.form-label { font-size: 13px; opacity: .8; }
.login-form input[type=text], .login-form input[type=password] {
  font-size: 17px; padding: 12px 14px; border: 1.5px solid var(--line);
  border-radius: 12px; background: #fffdf7; color: var(--text); outline: none;
}
.login-form input:focus { border-color: var(--btn); }
.form-check { font-size: 14px; display: flex; align-items: center; gap: 7px; margin: 4px 0 10px; }
.form-check input { width: 18px; height: 18px; accent-color: var(--btn); }
.login-tip { text-align: center; font-size: 12px; opacity: .55; margin-top: 10px; }
.login-error { text-align: center; color: var(--incorrect); font-size: 13px; min-height: 18px; margin-top: 6px; }

/* ---------- 顶栏 ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: calc(env(safe-area-inset-top) + 12px) 14px 12px;
  background: var(--label);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 5;
}
.topbar-title { font-size: 17px; font-weight: 700; }
.topbar-user { font-size: 13px; opacity: .75; min-width: 52px; text-align: right; }

/* ---------- 主页 ---------- */
.bank-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px;
  padding: 20px 16px 8px;
}
.bank-grid .btn { font-size: 19px; padding: 20px 0; }
.func-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px;
  padding: 14px 16px;
}
.clock-bar {
  display: flex; justify-content: space-between;
  padding: 12px 18px; font-size: 13px; opacity: .8;
  border-top: 1px solid var(--line); margin-top: 6px;
}
.main-footer { margin-top: auto; padding: 14px 16px calc(env(safe-area-inset-bottom) + 14px); text-align: center; }

/* ---------- 答题页 ---------- */
.quiz-body { flex: 1; overflow-y: auto; padding: 14px 16px; }
.quiz-qtext { font-size: 17px; font-weight: 600; margin-bottom: 12px; }
.quiz-qtext:empty { display: none; }
.quiz-img-wrap { text-align: center; margin-bottom: 14px; }
.quiz-img-wrap img {
  max-width: 100%; border-radius: 10px; background: #fff;
  border: 1px solid var(--line); cursor: zoom-in;
}
.quiz-options { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; padding-bottom: 10px; }
.opt {
  display: flex; align-items: center; gap: 8px;
  background: #fffdf7; border: 1.5px solid var(--line); border-radius: 12px;
  padding: 12px 18px; font-size: 17px; font-weight: 600;
}
.opt.sel { background: var(--btn); color: #fff; border-color: var(--btn); }
.quiz-bar {
  display: flex; gap: 10px; padding: 10px 14px calc(env(safe-area-inset-bottom) + 12px);
  background: var(--label); border-top: 1px solid var(--line);
}
.quiz-bar .btn { flex: 1; }

/* ---------- 查看页 ---------- */
.bank-tabs {
  display: flex; gap: 6px; overflow-x: auto; padding: 10px 14px 4px;
  scrollbar-width: none;
}
.bank-tabs::-webkit-scrollbar { display: none; }
.bank-tabs .tab {
  flex: 0 0 auto; padding: 8px 16px; border-radius: 999px; font-size: 14px; font-weight: 600;
  background: #fffdf7; border: 1.5px solid var(--line); color: var(--text);
}
.bank-tabs .tab.on { background: var(--btn); color: #fff; border-color: var(--btn); }
.review-list { max-height: 34vh; overflow-y: auto; padding: 8px 14px; }
.review-item {
  display: flex; justify-content: space-between; align-items: center;
  background: #fffdf7; border: 1px solid var(--line); border-radius: 10px;
  padding: 11px 14px; margin-bottom: 8px; font-size: 14px;
}
.review-item.on { border-color: var(--btn); background: var(--label); }
.review-empty { text-align: center; opacity: .55; padding: 18px; font-size: 14px; }
.review-view {
  flex: 1; overflow-y: auto; border-top: 1px solid var(--line);
  padding: 12px 14px calc(env(safe-area-inset-bottom) + 12px); text-align: center;
}
.review-hint { opacity: .5; font-size: 14px; padding: 20px 0; }
#review-img { max-width: 100%; border-radius: 10px; border: 1px solid var(--line); background: #fff; cursor: zoom-in; }
#review-delete { margin-top: 12px; }

/* ---------- 统计页 ---------- */
.stats-body { flex: 1; overflow-y: auto; padding: 12px 14px calc(env(safe-area-inset-bottom) + 14px); }
.stats-sec { margin-bottom: 18px; }
.stats-sec h3 { font-size: 15px; margin-bottom: 8px; }
.stats-table { width: 100%; border-collapse: collapse; font-size: 13px; background: #fffdf7; border-radius: 10px; overflow: hidden; }
.stats-table th, .stats-table td { border: 1px solid var(--line); padding: 8px 6px; text-align: center; }
.stats-table th { background: var(--stats); font-weight: 700; }
.stats-empty { text-align: center; opacity: .55; padding: 30px 0; }

/* ---------- 遮罩 ---------- */
.overlay {
  display: none; position: fixed; inset: 0; z-index: 50;
  background: rgba(30, 25, 15, .55); flex-direction: column;
}
.overlay.show { display: flex; }
.overlay-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: calc(env(safe-area-inset-top) + 10px) 14px 10px;
  color: #fff; font-size: 16px; font-weight: 700;
}
.overlay-head .btn-small { background: rgba(255,255,255,.9); }
.overlay-body { flex: 1; overflow: auto; display: flex; align-items: flex-start; justify-content: center; padding: 6px 12px 20px; }
.overlay-body img { max-width: 100%; border-radius: 10px; background: #fff; }
.help-body {
  display: block; background: var(--bg); margin: 4px 12px calc(env(safe-area-inset-bottom) + 12px);
  border-radius: 14px; padding: 18px; font-size: 14px; line-height: 1.8;
}
.help-body h3 { font-size: 15px; margin: 12px 0 4px; }
.help-body h3:first-child { margin-top: 0; }

/* 放大查看 */
.overlay-zoom { align-items: center; }
.overlay-zoom img { transition: transform .18s ease; transform-origin: center; }
.zoom-tip { position: absolute; bottom: calc(env(safe-area-inset-bottom) + 14px); width: 100%; text-align: center; color: rgba(255,255,255,.8); font-size: 12px; }

/* ---------- Toast ---------- */
#toast {
  position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%) translateY(20px);
  background: rgba(47, 79, 79, .92); color: #fff; font-size: 14px;
  padding: 11px 20px; border-radius: 999px; opacity: 0; pointer-events: none;
  transition: opacity .25s, transform .25s; z-index: 99; max-width: 84vw; text-align: center;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }


/* ---------- 批注按钮条 ---------- */
.ann-bar { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 10px; }
.ann-btn { background: var(--btn); color: #fff; border-color: var(--btn); }
.img-col { display: flex; flex-direction: column; align-items: center; max-width: 100%; }

/* 批注媒体 */
.media-video { max-width: 100%; max-height: 70vh; border-radius: 10px; background: #000; }
.media-img { max-width: 100%; border-radius: 10px; background: #fff; cursor: zoom-in; }

/* 图片缩放旋转控制条 */
.zoom-ctrl {
  position: absolute; bottom: calc(env(safe-area-inset-bottom) + 44px); width: 100%;
  display: flex; justify-content: center; gap: 10px; z-index: 60;
}
.zoom-ctrl .btn-small { background: rgba(255,255,255,.92); }

/* 批注音频播放器 */
.media-audio { width: 86vw; max-width: 420px; margin-top: 30px; }

/* 批注音频悬浮播放条 */
#audio-bar {
  position: fixed; left: 10px; right: 10px; bottom: calc(env(safe-area-inset-bottom) + 10px);
  z-index: 80; display: flex; align-items: center; gap: 8px;
  background: rgba(47, 79, 79, .95); border-radius: 999px; padding: 6px 8px 6px 12px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, .25);
}
#audio-el { flex: 1; height: 38px; min-width: 0; }
#audio-bar-close { background: rgba(255, 255, 255, .92); flex: none; }

/* 图片放大页打开时，音频播放条上移避开缩放工具条 */
#audio-bar.up { bottom: calc(env(safe-area-inset-bottom) + 104px); }

/* 通用输入对话框 */
.input-dialog {
  background: var(--bg); border-radius: 14px; padding: 20px 18px;
  margin-top: 8vh; width: min(84vw, 340px);
  display: flex; flex-direction: column; gap: 14px;
}
.input-dialog input {
  font-size: 20px; padding: 11px 12px; text-align: center;
  border: 1px solid var(--line); border-radius: 10px; background: #fffdf7;
}

/* ---------- 功能按钮九宫格（3×3，尺寸向题库按钮看齐） ---------- */
.func-grid .btn { font-size: 17px; padding: 16px 0; }

/* 播放条紧凑化：居中胶囊，横屏时也不再横贯屏幕 */
#audio-bar {
  left: 50%; right: auto; transform: translateX(-50%);
  width: max-content; min-width: 260px; max-width: 92vw;
}
#audio-el { width: 210px; flex: none; }
#audio-bar.up { bottom: calc(env(safe-area-inset-bottom) + 88px); }

/* 页面工具条（统计/错题本页顶部按钮） */
.page-toolbar { display: flex; justify-content: flex-end; gap: 10px; padding: 10px 14px 2px; }

/* 统计总览卡片 */
.stat-cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 16px; }
.stat-card { background: #fffdf7; border: 1px solid var(--line); border-radius: 10px; padding: 10px 4px; text-align: center; }
.stat-card-val { font-size: 17px; font-weight: 700; color: var(--btn); }
.stat-card-label { font-size: 12px; opacity: .6; margin-top: 2px; }
.advice { font-size: 14px; line-height: 1.7; margin: 4px 0; }

/* 错题本 */
.wrong-list { max-height: 34vh; overflow-y: auto; padding: 8px 14px; }
#wrong-img { max-width: 100%; border-radius: 10px; border: 1px solid var(--line); background: #fff; cursor: zoom-in; }

/* PDF 报告离屏容器与排版 */
#pdf-holder { position: fixed; left: -10000px; top: 0; z-index: -1; }
.pdf-report {
  width: 760px; background: #FFF5E1; padding: 32px;
  font-family: "Microsoft YaHei", "PingFang SC", sans-serif; color: #2f4f4f;
}
.pdf-report h1 { font-size: 26px; margin: 0 0 6px; }
.pdf-report h2 { font-size: 18px; margin: 18px 0 8px; }
.pdf-sub { font-size: 13px; opacity: .7; margin: 0 0 14px; }
.pdf-line { font-size: 14px; line-height: 1.8; margin: 4px 0; }
.pdf-img { max-width: 100%; border: 1px solid #d8cdbb; border-radius: 8px; background: #fff; margin-top: 6px; }
.pdf-foot { font-size: 12px; opacity: .6; margin-top: 24px; text-align: center; }
.pdf-wrong { margin-bottom: 14px; }

/* 批注遮罩在上时，放大页仍要盖过它（批注图点开直接缩放旋转） */
#zoom-overlay { z-index: 55; }

/* 播放条拖动手柄与自由悬浮模式 */
.audio-grip { cursor: grab; color: rgba(255, 255, 255, .85); padding: 0 4px; touch-action: none; user-select: none; font-size: 15px; }
#audio-bar.floating { left: 0; right: auto; bottom: auto; top: 100px; transform: none; }

/* AI 分析结果框 */
.ai-box {
  margin: 8px 14px 0; padding: 12px 14px;
  background: #fffdf7; border: 1px solid var(--line); border-radius: 10px;
  font-size: 14px; line-height: 1.8; white-space: pre-wrap;
}

/* PDF 生成后的悬浮下载条（浏览器里自动下载会被拦截，改为用户亲手点） */
.pdf-dl-bar {
  position: fixed; left: 50%; bottom: 150px; transform: translateX(-50%);
  display: flex; align-items: center; gap: 8px; z-index: 100;
  background: #fffdf7; border: 1px solid var(--line); border-radius: 14px;
  padding: 10px 12px; box-shadow: 0 6px 20px rgba(47,79,79,.25);
  max-width: 92vw;
}
.pdf-dl-btn {
  display: inline-block; text-decoration: none; border: none; cursor: pointer;
  font: 600 14px/1 -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  color: #fff; background: #ff8c5a; border-radius: 10px; padding: 12px 14px;
}
.pdf-dl-share { background: var(--btn); color: var(--btn-fg); }
.pdf-dl-close {
  border: none; background: none; font-size: 20px; cursor: pointer;
  color: var(--btn-fg); opacity: .6; padding: 4px 6px;
}
