/* ============ 基础 ============ */
* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --primary: #2a5caa;
  --blue: #2f6fd6;
  --blue-light: #eaf2ff;
  --green: #18a058;
  --orange: #f97316;
  --red: #e5484d;
  --bg: #eef1f6;
  --card: #ffffff;
  --border: #e3e8f0;
  --text: #2c3a4b;
  --muted: #8a94a6;
}
html, body { height: 100%; }
body {
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", "微软雅黑", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
}
.hidden { display: none !important; }
button { font-family: inherit; }

/* ============ 顶部栏 ============ */
.app-header {
  height: 60px;
  background: linear-gradient(90deg, #1c4a8f 0%, #2a5caa 100%);
  color: #fff;
  display: flex;
  align-items: center;
  padding: 0 24px;
  position: sticky; top: 0; z-index: 100;
  box-shadow: 0 2px 10px rgba(20, 50, 100, .25);
}
.logo { display: flex; align-items: center; gap: 10px; font-size: 17px; font-weight: 700; letter-spacing: 1px; white-space: nowrap; }
.logo .mark { width: 34px; height: 34px; border-radius: 8px; background: rgba(255,255,255,.16); display: grid; place-items: center; font-size: 16px; font-weight: 900; }
.header-right { margin-left: auto; display: flex; align-items: center; gap: 20px; font-size: 13.5px; white-space: nowrap; }
.header-right .timer { font-weight: 700; font-size: 14.5px; color: #ffd666; font-variant-numeric: tabular-nums; letter-spacing: .5px; }
.header-right .timer.low { color: #ff9d9d; animation: blink 1s step-end infinite; }
.sync-status { color: #dbeafe; font-size: 12px; }
.sync-status.local { color: #ffe0a3; }
.sync-status.ok { color: #b7f7d4; }
@keyframes blink { 50% { opacity: .45; } }
.btn-lock { background: rgba(255,255,255,.14); border: 1px solid rgba(255,255,255,.4); color: #fff; padding: 5px 14px; border-radius: 6px; font-size: 13px; cursor: pointer; transition: background .15s; }
.btn-lock:hover { background: rgba(255,255,255,.28); }
.seat b { font-size: 15px; }

/* ============ 布局 ============ */
.layout { display: flex; gap: 14px; padding: 14px; max-width: 1440px; margin: 0 auto; align-items: flex-start; }
.sidebar { width: 272px; flex-shrink: 0; display: flex; flex-direction: column; gap: 14px; position: sticky; top: 74px; max-height: calc(100vh - 88px); }
.card { background: var(--card); border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 1px 3px rgba(20,40,80,.06); }

/* 考生卡片 */
.user-card { padding: 18px 16px 14px; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.avatar { width: 54px; height: 54px; border-radius: 50%; background: #dbe7f7; color: var(--primary); display: grid; place-items: center; font-size: 26px; }
.user-name { font-weight: 700; font-size: 15px; }
.user-seat { font-size: 12px; color: var(--muted); }
.exam-title { font-size: 12.5px; color: var(--muted); text-align: center; line-height: 1.6; padding: 6px 8px 0; border-top: 1px dashed var(--border); margin-top: 8px; }

/* 答题卡 */
.sheet-card { flex: 1; min-height: 0; overflow-y: auto; padding: 14px 14px 16px; }
.sheet-card-title { font-weight: 700; font-size: 14px; padding-bottom: 8px; border-bottom: 1px solid var(--border); margin-bottom: 10px; }
.sheet-group { margin-bottom: 14px; }
.sheet-group-title { display: flex; justify-content: space-between; font-size: 12.5px; font-weight: 600; color: #4a5568; margin-bottom: 7px; }
.sheet-group-title .range { color: var(--muted); font-weight: 400; }
.sheet-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.q-num { height: 30px; border-radius: 5px; border: 1px solid #d5dbe6; background: #fff; color: #5a6a7e; font-size: 12px; cursor: pointer; transition: all .12s; }
.q-num:hover { border-color: var(--blue); color: var(--blue); transform: translateY(-1px); }
.q-num.done { background: var(--green); border-color: var(--green); color: #fff; }
.q-num.marked { background: var(--orange); border-color: var(--orange); color: #fff; }
.q-num.cur { outline: 2px solid var(--blue); outline-offset: 1px; font-weight: 700; color: var(--blue); }
.q-num.cur.done { color: #fff; }
.q-num.cur.marked { color: #fff; }

/* ============ 主内容 ============ */
.main { flex: 1; min-width: 0; }
.paper { background: var(--card); border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 1px 3px rgba(20,40,80,.06); padding: 26px 32px 20px; min-height: calc(100vh - 88px); display: flex; flex-direction: column; }
.q-header { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.q-badge { padding: 3px 12px; border-radius: 4px; font-size: 12.5px; color: #fff; font-weight: 600; }
.badge-judge { background: #0e9f6e; }
.badge-single { background: #2f6fd6; }
.badge-multi { background: #8b5cf6; }
.q-no { font-size: 16px; font-weight: 700; color: var(--primary); }
.mark-btn { margin-left: auto; border: 1px solid #fbd7b0; background: #fff7ec; color: var(--orange); padding: 5px 14px; border-radius: 6px; cursor: pointer; font-size: 12.5px; transition: all .15s; }
.mark-btn.on { background: var(--orange); color: #fff; border-color: var(--orange); }
.note-btn { border: 1px solid #c4cddb; background: #fff; color: #4a5568; padding: 5px 14px; border-radius: 6px; cursor: pointer; font-size: 12.5px; transition: all .15s; }
.note-btn:hover { border-color: var(--blue); color: var(--blue); }
.q-stem { font-size: 15.5px; line-height: 1.9; margin-bottom: 22px; white-space: pre-wrap; word-break: break-word; }
.q-img { display: block; max-width: 100%; margin: 10px auto 0; border: 1px solid var(--border); border-radius: 6px; background: #fff; }
.opts { display: flex; flex-direction: column; gap: 12px; }
.opt { display: flex; align-items: center; gap: 12px; border: 1.5px solid var(--border); border-radius: 8px; padding: 11px 14px; cursor: pointer; transition: all .15s; user-select: none; background: #fff; }
.opt:hover { border-color: #b9cdf0; background: #f7faff; }
.opt.selected { border-color: var(--blue); background: var(--blue-light); }
.opt .letter { width: 26px; height: 26px; border-radius: 50%; border: 1.5px solid #b6c2d4; display: grid; place-items: center; font-size: 13px; font-weight: 600; color: #5a6a7e; flex-shrink: 0; transition: all .15s; background: #fff; }
.opt.selected .letter { background: var(--blue); border-color: var(--blue); color: #fff; }
.opt.multi .letter { border-radius: 6px; }
.opt .opt-text { flex: 1; font-size: 14.5px; line-height: 1.7; }
.opt .opt-check { color: var(--blue); font-weight: 700; display: none; }
.opt.multi.selected .opt-check { display: inline; }
.q-tip { margin-top: 22px; font-size: 12.5px; color: var(--muted); }

/* 底部工具条 */
.q-footer { margin-top: auto; padding-top: 18px; display: flex; align-items: center; gap: 14px; border-top: 1px dashed var(--border); flex-wrap: wrap; }
.legend { display: flex; gap: 16px; font-size: 12px; color: #5a6a7e; flex-wrap: wrap; }
.legend i { width: 13px; height: 13px; border-radius: 3px; display: inline-block; margin-right: 5px; vertical-align: -2px; }
.legend .l-cur { background: #fff; border: 2px solid var(--blue); }
.legend .l-todo { background: #fff; border: 1px solid #c4cddb; }
.legend .l-done { background: var(--green); }
.legend .l-mark { background: var(--orange); }
.kbd-hint { color: #a5aebe; }
.backup-ok { color: #2e9e5b; }
.backup-warn { color: #e07c1f; }
.footer-btns { margin-left: auto; display: flex; gap: 10px; }
.btn { padding: 9px 24px; border-radius: 6px; border: none; font-size: 14px; cursor: pointer; font-weight: 600; transition: all .15s; }
.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:hover { background: #245ec4; box-shadow: 0 3px 10px rgba(47,111,214,.35); }
.btn-orange { background: var(--orange); color: #fff; }
.btn-orange:hover { background: #e05f00; box-shadow: 0 3px 10px rgba(249,115,22,.35); }
.btn-ghost { background: #fff; border: 1px solid #c4cddb; color: #4a5568; }
.btn-ghost:hover { border-color: var(--blue); color: var(--blue); }
.btn-light { background: #fff; color: var(--primary); font-size: 15px; padding: 10px 30px; }
.btn-light:hover { background: #f0f5ff; }

/* ============ 锁屏 ============ */
.lock-mask { position: fixed; inset: 0; background: linear-gradient(135deg, #123a75, #1e5aa8 60%, #2a5caa); z-index: 2000; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; color: #fff; }
.lock-icon { font-size: 64px; }
.lock-title { font-size: 24px; font-weight: 700; letter-spacing: 4px; }
.lock-tip { color: rgba(255,255,255,.75); font-size: 13.5px; }

/* ============ 弹窗 ============ */
.modal-mask { position: fixed; inset: 0; background: rgba(15, 30, 60, .55); display: flex; align-items: center; justify-content: center; z-index: 1500; padding: 20px; }
.modal { background: #fff; border-radius: 12px; width: 460px; max-width: 94vw; max-height: 86vh; overflow-y: auto; padding: 28px; box-shadow: 0 12px 48px rgba(0,0,0,.3); animation: pop .18s ease; }
@keyframes pop { from { transform: scale(.94); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.modal-title { font-size: 17px; font-weight: 700; text-align: center; margin-bottom: 18px; }
.notice-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 22px; }
.notice-item { display: flex; gap: 12px; font-size: 13.5px; line-height: 1.7; }
.notice-item .n-label { width: 70px; flex-shrink: 0; color: var(--muted); text-align: right; }
.modal-actions { display: flex; justify-content: center; gap: 12px; margin-top: 4px; }
.submit-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 16px; }
.s-item { background: #f6f8fb; border: 1px solid var(--border); border-radius: 8px; padding: 12px 6px; text-align: center; }
.s-num { display: block; font-size: 22px; font-weight: 700; color: var(--text); }
.s-num.ok { color: var(--green); } .s-num.bad { color: var(--red); } .s-num.warn { color: var(--orange); }
.s-label { font-size: 12px; color: var(--muted); }
.warn-line { background: #fff4e5; color: #b45309; border: 1px solid #fbd7b0; border-radius: 6px; padding: 10px 12px; font-size: 13px; margin-bottom: 20px; line-height: 1.7; }
.warn-line.good { background: #ecf9f1; color: #0e7a4b; border-color: #b8e6cf; }
.center-text { text-align: center; color: var(--muted); margin-bottom: 20px; }

/* ============ 成绩页 ============ */
.result-head { display: flex; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.score-card { flex: 1; min-width: 260px; background: linear-gradient(135deg, #1c4a8f, #2a5caa); color: #fff; border-radius: 10px; padding: 22px 26px; }
.score-main { display: flex; align-items: baseline; gap: 8px; }
.score-num { font-size: 42px; font-weight: 800; }
.score-total { font-size: 16px; opacity: .8; }
.score-pct { font-size: 14px; margin-top: 2px; }
.score-bar { height: 8px; border-radius: 4px; background: rgba(255,255,255,.22); margin: 12px 0 10px; overflow: hidden; }
.score-bar i { display: block; height: 100%; background: #ffd666; border-radius: 4px; }
.score-meta { font-size: 12px; opacity: .75; }
.type-cards { flex: 1; min-width: 260px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.type-card { background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 14px; text-align: center; display: flex; flex-direction: column; justify-content: center; gap: 2px; }
.type-card .t-name { font-size: 12.5px; color: var(--muted); }
.type-card .t-num { font-size: 24px; font-weight: 700; color: var(--primary); }
.type-card .t-num span { font-size: 13px; color: var(--muted); font-weight: 400; }
.result-toolbar { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.filter-tabs { display: flex; gap: 8px; flex-wrap: wrap; }
.f-tab { border: 1px solid #d5dbe6; background: #fff; color: #5a6a7e; padding: 6px 16px; border-radius: 20px; font-size: 13px; cursor: pointer; transition: all .15s; }
.f-tab.on { background: var(--blue); border-color: var(--blue); color: #fff; }
.result-toolbar .btn { margin-left: auto; }
.review-list { display: flex; flex-direction: column; gap: 10px; padding-bottom: 30px; }
.review-item { border: 1px solid var(--border); border-radius: 8px; background: #fff; overflow: hidden; }
.review-head { display: flex; align-items: center; gap: 10px; padding: 10px 14px; cursor: pointer; background: #fafbfd; }
.review-head:hover { background: #f2f6fc; }
.r-badge { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-size: 13px; flex-shrink: 0; }
.r-badge.r-ok { background: var(--green); }
.r-badge.r-bad { background: var(--red); }
.r-badge.r-empty { background: #a5aebe; }
.r-type { font-size: 12px; padding: 2px 8px; border-radius: 4px; background: #eef2f8; color: #5a6a7e; flex-shrink: 0; }
.r-no { font-size: 13px; font-weight: 600; color: var(--text); flex-shrink: 0; }
.r-stem-preview { flex: 1; font-size: 13px; color: #5a6a7e; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.r-arrow { color: var(--muted); transition: transform .15s; flex-shrink: 0; }
.review-head.open .r-arrow { transform: rotate(180deg); }
.review-body { padding: 14px 18px; border-top: 1px solid var(--border); font-size: 13.5px; line-height: 1.9; background: #fff; }
.r-full-stem { font-size: 14px; line-height: 1.9; margin-bottom: 8px; white-space: pre-wrap; word-break: break-word; }
.r-opt { padding: 2px 0; color: #4a5568; }
.r-opt.correct { color: #0e7a4b; font-weight: 600; }
.r-opt.wrong { color: var(--red); font-weight: 600; }
.tag { font-size: 11px; padding: 1px 7px; border-radius: 4px; margin-left: 8px; font-weight: 400; vertical-align: 1px; }
.tag-right { background: #ecf9f1; color: #0e7a4b; }
.tag-wrong { background: #fdeaea; color: var(--red); }
.r-answer-line { margin: 10px 0 6px; padding: 8px 12px; background: #f6f8fb; border-radius: 6px; }
.green { color: #0e7a4b; } .red { color: var(--red); }
.r-explain { color: #5a6a7e; white-space: pre-wrap; word-break: break-word; }
.ex-label { color: var(--primary); font-weight: 700; margin-right: 4px; }
.empty-tip { text-align: center; color: var(--muted); padding: 40px 0; }

/* ============ 响应式 ============ */
@media (max-width: 1100px) {
  .layout { flex-direction: column; }
  .sidebar { width: 100%; position: static; max-height: none; }
  .sheet-grid { grid-template-columns: repeat(auto-fill, minmax(34px, 1fr)); }
  .header-right { gap: 12px; }
  .app-header { flex-wrap: wrap; height: auto; padding: 10px 16px; row-gap: 8px; }
  .logo { width: 100%; }
  .type-cards { grid-template-columns: 1fr 1fr 1fr; }
}

/* ============ 首页 ============ */
.home-title { font-size: 17px; font-weight: 700; margin: 4px 0 14px; }
.home-title:not(:first-child) { margin-top: 24px; }
.bank-card { display: flex; align-items: center; gap: 14px; border: 1px solid var(--border); border-radius: 10px; padding: 16px 18px; margin-bottom: 12px; background: #fff; transition: all .15s; }
.bank-card:hover { border-color: #b9cdf0; box-shadow: 0 2px 10px rgba(47,111,214,.10); }
.bank-emoji { font-size: 26px; }
.bank-info { flex: 1; min-width: 0; }
.bank-title { font-size: 15px; font-weight: 700; }
.bank-meta { font-size: 12.5px; color: var(--muted); margin-top: 3px; }
.inprogress-banner { display: flex; align-items: center; gap: 12px; background: #fff7ec; border: 1px solid #fbd7b0; border-radius: 10px; padding: 14px 18px; margin-bottom: 16px; flex-wrap: wrap; }
.inprogress-banner .ip-info { flex: 1; min-width: 240px; }
.inprogress-banner .ip-title { font-weight: 700; font-size: 14px; color: #b45309; }
.inprogress-banner .ip-meta { font-size: 12.5px; color: #b45309; opacity: .85; margin-top: 2px; }
.rec-summary-card { display: flex; align-items: center; gap: 12px; border: 1px solid var(--border); border-radius: 10px; padding: 14px 18px; background: #fff; flex-wrap: wrap; }
.rs-info { flex: 1; min-width: 240px; }
.rs-info .rs-main { font-size: 14px; font-weight: 600; }
.rs-info .rs-sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; }

/* ============ 作答记录页 ============ */
.stats-row { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; margin-bottom: 16px; }
.stat-tile { background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 14px; text-align: center; }
.stat-tile .st-num { font-size: 20px; font-weight: 700; color: var(--primary); }
.stat-tile .st-label { font-size: 12px; color: var(--muted); margin-top: 2px; }
.toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.toolbar .right { margin-left: auto; display: flex; gap: 10px; flex-wrap: wrap; }
.identity-card { display: flex; align-items: flex-end; gap: 14px; margin-bottom: 18px; padding: 14px 16px; border: 1px solid var(--border); border-radius: 8px; background: #fff; }
.identity-main { flex: 1; min-width: 180px; }
.identity-card .home-title { margin: 0 0 8px; }
.identity-select { width: 100%; max-width: 360px; box-sizing: border-box; border: 1px solid #c4cddb; border-radius: 6px; padding: 8px 10px; color: #344054; background: #fff; font: inherit; }
.identity-select:focus { outline: none; border-color: var(--blue); }
.identity-list { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.identity-item { display: inline-flex; align-items: center; gap: 6px; padding: 3px 6px 3px 9px; border: 1px solid var(--border); border-radius: 14px; color: #5a6a7e; font-size: 12px; }
.identity-item .btn-xs { padding: 2px 6px; }
.identity-item .btn-xs.danger { color: #b42318; }
.rr-author { color: var(--muted); font-weight: 400; }
.record-row { display: flex; align-items: center; gap: 14px; border: 1px solid var(--border); border-radius: 10px; padding: 13px 16px; margin-bottom: 10px; background: #fff; flex-wrap: wrap; }
.record-row:hover { border-color: #b9cdf0; }
.record-row .rr-date { font-size: 12.5px; color: var(--muted); width: 150px; flex-shrink: 0; }
.record-row .auto-tag { display: inline-block; font-size: 11px; background: #fdeaea; color: var(--red); border-radius: 4px; padding: 0 5px; }
.record-row .rr-title { flex: 1; min-width: 240px; font-weight: 600; font-size: 14px; }
.record-row .rr-score { font-size: 20px; font-weight: 800; color: var(--primary); white-space: nowrap; }
.record-row .rr-score small { font-size: 12px; color: var(--muted); font-weight: 400; }
.record-row .rr-time { font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.record-row .rr-btns { display: flex; gap: 8px; }
.btn-sm { padding: 5px 14px; font-size: 12.5px; border-radius: 6px; border: none; cursor: pointer; font-weight: 600; transition: all .15s; }
.btn-sm.primary { background: var(--blue); color: #fff; }
.btn-sm.primary:hover { background: #245ec4; }
.btn-sm.danger { background: #fff; border: 1px solid #f3c1c3; color: var(--red); }
.btn-sm.danger:hover { background: #fdeaea; }

/* 成绩页按钮组 */
.result-btns { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
#examOnly { display: flex; align-items: center; gap: 20px; }

@media (max-width: 1100px) {
  .stats-row { grid-template-columns: repeat(2, 1fr); }
}

/* ============ 首页题库搜题 ============ */
.search-card { border: 1px solid var(--border); border-radius: 10px; padding: 16px 18px 14px; background: #fff; margin-bottom: 6px; }
.search-box { display: flex; gap: 10px; }
.search-input { flex: 1; padding: 9px 14px; border: 1.5px solid #d5dbe6; border-radius: 8px; font-size: 14px; outline: none; font-family: inherit; color: var(--text); transition: border-color .15s; }
.search-input:focus { border-color: var(--blue); }
.search-hint { font-size: 12px; color: var(--muted); margin-top: 6px; }
.search-results { margin-top: 14px; border-top: 1px dashed var(--border); padding-top: 12px; }
.sr-count { font-size: 12.5px; color: var(--muted); margin-bottom: 8px; }
.sr-item { border: 1px solid var(--border); border-radius: 8px; padding: 10px 14px; margin-bottom: 8px; background: #fafbfd; }
.sr-top { display: flex; align-items: center; gap: 10px; font-size: 12px; color: var(--muted); }
.sr-bank { color: var(--primary); font-weight: 600; max-width: 60%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sr-stem { font-size: 13.5px; line-height: 1.7; margin: 6px 0 4px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.sr-opts { font-size: 12.5px; color: #5a6a7e; line-height: 1.7; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.sr-btns { margin-top: 6px; }
.btn-xs { padding: 3px 12px; font-size: 12px; border-radius: 5px; border: 1px solid #c4cddb; background: #fff; color: #4a5568; cursor: pointer; transition: all .15s; }
.btn-xs:hover { border-color: var(--blue); color: var(--blue); }

/* 成绩页试卷内搜题 */
.result-search { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.result-search .search-input { max-width: 520px; }

/* ============ 搜题详情弹窗 ============ */
.modal.wide { width: 680px; }
.q-view-meta { font-size: 12px; color: var(--muted); text-align: center; margin: -8px 0 14px; }
.q-view-stem { font-size: 14.5px; line-height: 1.9; margin-bottom: 14px; white-space: pre-wrap; word-break: break-word; }
.q-view-opt { padding: 3px 0; color: #4a5568; line-height: 1.8; }
.q-view-opt.correct { color: #0e7a4b; font-weight: 600; }
.q-view-explain { margin-top: 12px; padding: 10px 12px; background: #f6f8fb; border-radius: 6px; color: #5a6a7e; line-height: 1.8; }

/* ============ 答题记录标记 ============ */
.r-mark { border: none; background: transparent; cursor: pointer; font-size: 16px; line-height: 1; padding: 2px 4px; color: #c4cddb; transition: color .15s; flex-shrink: 0; }
.r-mark:hover { color: var(--orange); }
.r-mark.on { color: var(--orange); }
.review-item.marked .review-head { background: #fff7ec; }
.r-note { border: none; background: transparent; cursor: pointer; font-size: 12.5px; line-height: 1; padding: 2px 6px; color: #c4cddb; transition: color .15s; flex-shrink: 0; }
.r-note:hover { color: var(--blue); }
.r-note.has { color: var(--blue); }

/* ============ 笔记弹窗 ============ */
.note-session-tag { font-size: 11px; background: #fff7ec; color: var(--orange); border-radius: 4px; padding: 1px 6px; vertical-align: middle; }
.note-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; max-height: 32vh; overflow-y: auto; }
.note-item { border: 1px solid var(--border); border-radius: 8px; padding: 8px 12px; background: #fafbfe; display: flex; align-items: flex-start; gap: 10px; }
.note-item.note-reply { margin-left: 24px; background: #f4f8ff; }
.note-main { flex: 1; min-width: 0; }
.note-text { font-size: 13px; line-height: 1.7; white-space: pre-wrap; word-break: break-word; }
.note-meta { font-size: 11.5px; color: var(--muted); margin-top: 4px; }
.note-empty { font-size: 12.5px; color: var(--muted); text-align: center; padding: 10px 0; }
.note-input { width: 100%; box-sizing: border-box; border: 1px solid #c4cddb; border-radius: 8px; padding: 10px 12px; font-size: 13.5px; line-height: 1.7; resize: vertical; font-family: inherit; }
.note-input:focus { outline: none; border-color: var(--blue); }

/* ============================================================
   手机端适配(竖屏为主)
   全部规则集中在 max-width:768px 内,PC 端(>768px)不加载任何一条,
   因此桌面布局、桌面端点行为与改造前完全一致。
   答题卡从「侧栏」改为「底部抽屉」:点底部浮标滑出,选中题号自动收起。
   ============================================================ */

/* ---------- 抽屉遮罩:仅手机端可见 ---------- */
.drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 30, 60, .42);
  z-index: 1200;
  opacity: 0;
  visibility: hidden;
  transition: opacity .22s ease, visibility .22s ease;
}
body.drawer-open .drawer-overlay { opacity: 1; visibility: visible; }

/* ---------- 吸底操作条:仅手机端可见 ---------- */
.exam-action-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1100;
  display: flex;
  align-items: center;
  gap: 8px;
  height: calc(56px + env(safe-area-inset-bottom, 0px));
  padding: 0 10px env(safe-area-inset-bottom, 0px);
  background: #fff;
  border-top: 1px solid var(--border);
  box-shadow: 0 -3px 14px rgba(20, 40, 80, .10);
}
.exam-action-bar .ab-btn {
  flex: 1;
  min-width: 0;
  height: 40px;
  border: 1px solid #d5dbe6;
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  font-size: 13.5px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  padding: 0 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: all .15s;
}
/* 答题卡按钮承载进度文案("答题卡 12/239"),比翻页按钮多分一些宽度,
   否则在 360px 窄屏上会被截断成"答题卡 12/2…" */
#abSheet { flex: 1.6; }
.exam-action-bar .ab-btn:active { background: #f2f6fc; border-color: var(--blue); color: var(--blue); }
.exam-action-bar .ab-btn:disabled { opacity: .4; cursor: default; }
.exam-action-bar .ab-btn.has-progress { border-color: var(--blue); color: var(--blue); background: var(--blue-light); }

/* 桌面端一律隐藏,只在手机断点内显示。
   注意:吸底条与顶部栏是兄弟节点(都在 body 下),不在 #examOnly 内,
   所以这里用 body.in-exam 这个状态开关配合 JS 一起控制,
   不要写成 #examOnly .exam-action-bar —— 那个选择器永远匹配不到。 */
.drawer-overlay, .exam-action-bar { display: none; }

/* ============================================================
   手机断点
   取 900px 而不是 768px:横屏手机宽度可达 844px,
   若用 768px 会漏掉横屏场景,导致侧栏退回竖排压在题目前面。
   900px 以上(桌面/大平板)仍走 PC 布局,不受影响。
   ============================================================ */
@media (max-width: 900px) {
  .drawer-overlay { display: block; }
  /* 0,2,0 优先于下面那条 0,1,0 的默认 display:none,无需 !important */
  body.in-exam .exam-action-bar { display: flex; }

  /* 顶栏瘦身:隐藏冗余项,只留系统名、题目进度、倒计时与返回 */
  .app-header { padding: 8px 12px; row-gap: 4px; }
  .logo { font-size: 15px; }
  .logo .mark { width: 28px; height: 28px; font-size: 14px; }
  .header-right { gap: 10px; font-size: 12.5px; }
  .header-right .timer { font-size: 13px; }
  #btnLock, #btnFs, .seat { display: none; }

  /* 布局:答题卡抽离为抽屉,主内容占满整宽 */
  .layout { display: block; padding: 8px; }
  .main { width: 100%; }
  .paper {
    min-height: 0;
    padding: 16px 14px 14px;
    border-radius: 10px;
  }
  /* 为吸底操作条留出空间,避免最后一行被挡住 */
  .layout { padding-bottom: calc(68px + env(safe-area-inset-bottom, 0px)); }

  /* 抽屉本体:默认收起(下沉到屏幕外),body.drawer-open 时滑入 */
  .sidebar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    top: auto;
    width: 100%;
    max-height: 68vh;
    z-index: 1300;
    gap: 0;
    padding: 0;
    background: #fff;
    border-radius: 14px 14px 0 0;
    box-shadow: 0 -8px 32px rgba(15, 30, 60, .22);
    overflow: hidden;
    transform: translateY(105%);
    transition: transform .26s cubic-bezier(.22, .61, .36, 1);
    display: flex;
    flex-direction: column;
  }
  body.drawer-open .sidebar { transform: translateY(0); }

  /* 考试元信息不随抽屉一起滑出,常驻抽屉顶部便于核对身份 */
  .sidebar .user-card {
    padding: 12px 14px;
    border: none;
    border-bottom: 1px solid var(--border);
    border-radius: 0;
    box-shadow: none;
    flex-direction: row;
    justify-content: flex-start;
    gap: 10px;
    flex-shrink: 0;
  }
  .sidebar .avatar { width: 34px; height: 34px; font-size: 17px; }
  .sidebar .user-card .user-name { font-size: 14px; }
  .sidebar .user-card .user-seat { font-size: 11.5px; }
  .sidebar .exam-title { display: none; }

  /* 抽屉内答题卡:可滚动,格子加大到适合手指点按 */
  /* min-height:0 是关键:flex 子项默认 min-height:auto,
     不加这句 91 题的答题卡会把抽屉撑破而不是内部滚动 */
  .sheet-card {
    flex: 1;
    min-height: 0;
    padding: 12px 14px calc(16px + env(safe-area-inset-bottom, 0px));
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    border: none;
    border-radius: 0;
    box-shadow: none;
  }
  .sheet-grid { grid-template-columns: repeat(6, 1fr); gap: 8px; }
  .q-num { height: 40px; font-size: 14px; border-radius: 7px; }
  .q-num:hover { transform: none; } /* 触摸设备无 hover,取消位移避免误触发 */

  /* 题干与选项:加大触摸目标 */
  .q-header { gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
  .q-no { font-size: 15px; }
  .mark-btn, .note-btn { padding: 6px 12px; }
  .q-stem { font-size: 15px; line-height: 1.85; margin-bottom: 16px; }
  .opt { padding: 13px 12px; gap: 10px; }
  .opt .opt-text { font-size: 14.5px; }
  .opt .letter { width: 28px; height: 28px; font-size: 14px; }

  /* 卡片内的翻页条在手机端冗余(已有吸底条),隐藏以免重复 */
  .q-footer { display: none; }

  /* 滑动切题的配套设置:
     pan-y        —— 横向手势交给 JS 处理,纵向仍可正常滚动页面
     user-select  —— 防止滑动时误选中题干文字,长按也不弹系统菜单
     #paper 之外的区域(抽屉、弹窗)不受影响 */
  .paper {
    touch-action: pan-y;
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
  }

  /* 弹窗:手机上改为底部对齐的宽弹层,便于单手操作 */
  .modal-mask { padding: 12px; align-items: flex-end; }
  .modal {
    width: 100%;
    max-width: 100%;
    max-height: 88vh;
    border-radius: 14px;
    padding: 20px 16px calc(18px + env(safe-area-inset-bottom, 0px));
  }
  .modal.wide { width: 100%; }
  .submit-stats { gap: 8px; }
  .s-num { font-size: 19px; }
  .notice-item .n-label { width: 58px; font-size: 12.5px; }
  .modal-actions { gap: 10px; }
  .modal-actions .btn { flex: 1; padding: 9px 12px; }
  .note-list { max-height: 42vh; }
  .note-item.note-reply { margin-left: 12px; }

  /* 首页/记录页在手机上收紧留白 */
  .home-title { font-size: 16px; }
  .bank-card { padding: 14px; gap: 10px; }
  .record-row { padding: 12px 13px; gap: 8px; }
  .record-row .rr-date { width: auto; }
  .record-row .rr-title { min-width: 0; flex-basis: 100%; order: -1; }
  .stats-row { grid-template-columns: repeat(2, 1fr); }
  .type-cards { grid-template-columns: 1fr 1fr 1fr; }
  .score-card { min-width: 0; padding: 18px; }
  .score-num { font-size: 34px; }
  .review-head { padding: 10px 12px; gap: 8px; }
  .r-stem-preview { display: none; } /* 空间有限,题干预览让位给状态标记 */
  .review-body { padding: 12px 14px; }
  .toolbar .right { margin-left: 0; width: 100%; }
  .toolbar .right .btn, .toolbar .right .btn-sm { flex: 1; }
  .search-box { gap: 8px; }
  .identity-card { flex-direction: column; align-items: stretch; gap: 10px; }
  .identity-select { max-width: 100%; }
  .keyboard-hint, .kbd-hint { display: none; } /* 手机无方向键,隐藏键盘提示 */
}

/* 横屏手机:纵向空间紧张,抽屉压低避免遮住整屏题目。
   注意横屏手机宽度约 844px,已在上面 900px 断点内,
   所以这里只做增强,不再重复声明抽屉的基础定位。 */
@media (max-width: 900px) and (max-height: 500px) {
  .sidebar { max-height: 88vh; }
  .sheet-grid { grid-template-columns: repeat(8, 1fr); }
  .q-num { height: 34px; }
  .app-header { padding: 6px 12px; }
  .exam-action-bar { height: calc(48px + env(safe-area-inset-bottom, 0px)); }
  .layout { padding-bottom: calc(60px + env(safe-area-inset-bottom, 0px)); }
}
