/* 题库（历年试卷 + 在线答题）专用样式 */
.qb-hero { padding: 40px 0 26px; display: grid; grid-template-columns: 1fr auto; gap: 28px; align-items: end; }
.qb-hero h1 { margin: 10px 0 12px; font-size: clamp(2rem, 4vw, 2.875rem); letter-spacing: -.05em; }
.qb-hero p { margin: 0; max-width: 640px; color: var(--text-2); font-size: 1.0312rem; line-height: 1.8; }
.qb-stats { display: flex; gap: 26px; }
.qb-stats div { text-align: right; }
.qb-stats strong { display: block; font-size: 1.7188rem; letter-spacing: -.04em; color: var(--primary); }
.qb-stats span { font-size: 0.875rem; color: var(--muted); }

.qb-filters { padding: 18px 20px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); }
.qb-filter-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; flex-wrap: wrap; }
.qb-filter-row + .qb-filter-row { border-top: 1px dashed var(--line); }
.qb-filter-row > b { flex: none; width: 62px; color: var(--muted); font-size: 0.9375rem; font-weight: 700; }
.qb-chip { padding: 6px 12px; border: 1px solid var(--line); border-radius: 999px; background: var(--bg-soft); color: var(--text-2); font-size: 0.9375rem; font-weight: 650; transition: .16s; }
.qb-chip:hover { border-color: var(--primary); color: var(--primary); }
.qb-chip.active { border-color: transparent; background: var(--primary); color: #fff; }
.qb-select, .qb-input { height: 36px; padding: 0 10px; border: 1px solid var(--line); border-radius: 9px; background: var(--bg-soft); font-size: 0.9375rem; }
.qb-input { width: 240px; padding-left: 12px; }
.qb-search { display: flex; align-items: center; gap: 8px; margin-left: auto; }

.qb-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 18px 2px 10px; }
.qb-toolbar strong { font-size: 1.0312rem; }
.qb-toolbar span { margin-left: 8px; color: var(--muted); font-size: 0.9375rem; }

.qb-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; padding-bottom: 18px; }
.qb-card { display: flex; gap: 14px; padding: 16px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); color: inherit; text-decoration: none; transition: .18s; }
.qb-card:hover { transform: translateY(-2px); border-color: var(--primary); box-shadow: var(--shadow); }
.qb-card-year { flex: none; display: grid; place-content: center; width: 62px; height: 62px; border-radius: 14px; background: var(--primary-soft); color: var(--primary); font-size: 1.3125rem; font-weight: 850; }
.qb-card-year small { font-size: 0.8125rem; font-weight: 650; }
.qb-card h3 { margin: 0 0 6px; font-size: 1rem; line-height: 1.5; font-weight: 750; }
.qb-card-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.qb-card-meta em { padding: 2px 7px; border-radius: 6px; background: var(--bg-soft); color: var(--muted); font-size: 0.8125rem; font-style: normal; }
.qb-card div.qb-card-go { margin-top: auto; display: flex; gap: 8px; }
.qb-card-go button { padding: 7px 12px; border: 1px solid var(--line-strong); border-radius: 9px; background: var(--bg-soft); font-size: 0.875rem; font-weight: 700; }
.qb-card-go button.primary { border-color: transparent; background: var(--primary); color: #fff; }
.qb-card-open { display: inline-flex; align-items: center; min-height: 34px; padding: 7px 12px; border-radius: 9px; background: var(--primary); color: #fff; font-size: 0.875rem; font-weight: 750; }

.qb-special-setup { margin-bottom: 0; }
.qb-special-landing .qb-practice { display: block; padding-top: 0; }
.qb-special-setup-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.qb-special-setup-head strong { display: block; font-size: 1.0312rem; }
.qb-special-setup-head span { display: block; margin-top: 4px; color: var(--muted); font-size: 0.875rem; }
.qb-special-form { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.qb-special-actions { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.qb-special-actions p { margin: 0; color: var(--muted); font-size: 0.875rem; }
.qb-special-actions a { color: var(--primary); font-weight: 700; }
.essay-filter-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.essay-search-row { flex: 1; }
.essay-search-row .qb-input { flex: 1; min-width: 220px; }
.essay-grid-v2 .essay-card-copy { min-width: 0; display: flex; flex: 1; flex-direction: column; }
.essay-grid-v2 .essay-card-copy h3 { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.essay-grid-v2 .essay-card-copy > p { margin: 0 0 10px; color: var(--text-2); font-size: 0.875rem; line-height: 1.6; }

.qb-pagination { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 10px 2px 48px; }
.qb-pagination[hidden] { display: none; }
.qb-pagination-summary { color: var(--muted); font-size: 0.875rem; font-variant-numeric: tabular-nums; }
.qb-pagination-pages { display: flex; align-items: center; justify-content: center; gap: 6px; }
.qb-pagination button { min-width: 38px; height: 38px; padding: 0 11px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--text-2); font-size: 0.875rem; font-weight: 750; transition: border-color .16s, color .16s, background .16s, transform .16s; }
.qb-pagination button:hover:not(:disabled) { border-color: var(--primary); color: var(--primary); transform: translateY(-1px); }
.qb-pagination button.active { border-color: var(--primary); background: var(--primary); color: #fff; box-shadow: 0 6px 16px color-mix(in srgb, var(--primary) 24%, transparent); }
.qb-pagination button:disabled { cursor: not-allowed; opacity: .42; }
.qb-pagination .qb-page-arrow { padding: 0 14px; }
.qb-pagination-pages i { width: 24px; color: var(--muted); font-style: normal; text-align: center; }

/* 答题页 */
.qb-practice { display: grid; grid-template-columns: minmax(0, 1fr) 268px; gap: 22px; padding: 22px 0 60px; align-items: start; }
.qb-bar { position: sticky; top: var(--header); z-index: 40; display: flex; align-items: center; gap: 14px; padding: 12px 16px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); box-shadow: var(--shadow); }
.qb-bar h2 { margin: 0; font-size: 1.0312rem; font-weight: 800; }
.qb-bar .qb-bar-sub { color: var(--muted); font-size: 0.875rem; }
.qb-bar-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.qb-timer { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 10px; background: var(--bg-soft); font-variant-numeric: tabular-nums; font-weight: 800; font-size: 1rem; }
.qb-btn { padding: 8px 14px; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--surface); font-size: 0.9375rem; font-weight: 700; transition: .16s; }
.qb-btn:hover { border-color: var(--primary); color: var(--primary); }
.qb-btn.primary { border-color: transparent; background: var(--primary); color: #fff; }
.qb-btn.ghost { border-color: transparent; background: var(--bg-soft); }
.qb-btn[disabled] { opacity: .5; cursor: not-allowed; }

.qb-question { padding: 22px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); }
.qb-qhead { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.qb-qno { display: grid; place-content: center; min-width: 34px; height: 34px; border-radius: 10px; background: var(--primary); color: #fff; font-weight: 850; font-size: 1rem; }
.qb-qtags { display: flex; flex-wrap: wrap; gap: 6px; }
.qb-qtags em { padding: 3px 8px; border-radius: 6px; background: var(--primary-soft); color: var(--primary); font-size: 0.8125rem; font-style: normal; font-weight: 700; }
.qb-material { margin-bottom: 16px; padding: 14px 16px; border: 1px dashed var(--line-strong); border-radius: 12px; background: var(--bg-soft); color: var(--text-2); font-size: 1rem; line-height: 1.85; }
.qb-material img { max-width: 100%; border-radius: 8px; cursor: zoom-in; }
.qb-stem { font-size: 1.0938rem; line-height: 1.9; font-weight: 600; }
.qb-stem img { max-width: 100%; margin: 10px 0; border-radius: 8px; cursor: zoom-in; }
.qb-options { margin-top: 18px; display: grid; gap: 10px; }
.qb-option { display: flex; gap: 12px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--bg-soft); text-align: left; transition: .16s; }
.qb-option:hover { border-color: var(--primary); }
.qb-option i { flex: none; display: grid; place-content: center; width: 26px; height: 26px; border-radius: 8px; background: var(--surface); border: 1px solid var(--line-strong); font-style: normal; font-weight: 800; font-size: 0.9375rem; }
.qb-option span { flex: 1; font-size: 1.0312rem; line-height: 1.75; }
.qb-option img { max-width: 100%; max-height: 240px; border-radius: 6px; object-fit: contain; cursor: zoom-in; }
.qb-image-error { min-height: 72px; padding: 12px; display: grid; place-items: center; border: 1px dashed var(--line-strong); border-radius: 8px; color: var(--muted); font-size: .8125rem; font-weight: 600; }
.qb-image-viewer { position: fixed; inset: 0; z-index: 1300; display: grid; place-items: center; padding: 28px; }
.qb-image-viewer-backdrop { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; background: rgba(8, 15, 27, .8); backdrop-filter: blur(5px); }
.qb-image-viewer section { position: relative; z-index: 1; max-width: min(1180px, 94vw); max-height: 92vh; padding: 18px; overflow: auto; border-radius: 16px; background: var(--surface); box-shadow: 0 24px 80px rgba(0, 0, 0, .4); }
.qb-image-viewer section img { display: block; max-width: 100%; max-height: calc(92vh - 36px); object-fit: contain; }
.qb-image-viewer-close { position: sticky; top: 0; float: right; z-index: 2; width: 36px; height: 36px; margin: 0 0 -36px; border: 0; border-radius: 50%; background: rgba(17, 24, 39, .8); color: #fff; font-size: 1.5rem; line-height: 1; }
.qb-option.selected { border-color: var(--primary); background: var(--primary-soft); }
.qb-option.selected i { background: var(--primary); color: #fff; border-color: transparent; }
.qb-option.correct { border-color: var(--green); background: var(--green-soft); }
.qb-option.correct i { background: var(--green); color: #fff; border-color: transparent; }
.qb-option.wrong { border-color: #e14b5a; background: #fdeef0; }
.qb-option.wrong i { background: #e14b5a; color: #fff; border-color: transparent; }
.qb-answer { margin-top: 18px; padding: 16px; border: 1px solid var(--line); border-radius: 12px; background: var(--bg-soft); }
.qb-answer-head { display: flex; flex-wrap: wrap; gap: 14px; align-items: center; font-weight: 800; }
.qb-answer-head b { color: var(--green); }
.qb-answer-head s { color: #e14b5a; }
.qb-analysis { margin-top: 10px; color: var(--text-2); font-size: 1rem; line-height: 1.9; white-space: pre-wrap; }
.qb-foot { display: flex; align-items: center; gap: 10px; margin-top: 18px; flex-wrap: wrap; }

.qb-side { display: grid; gap: 14px; position: sticky; top: calc(var(--header) + 96px); min-width: 0; }
.qb-panel { padding: 16px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); min-width: 0; }
.qb-panel h4 { margin: 0 0 12px; font-size: 0.9375rem; letter-spacing: .04em; color: var(--muted); }
/* ⚠️ 别省 min-width:0：答题卡是 6 列网格，列里数字按钮的 min-content 会把
   268px 的侧栏列撑到 300px+，宽屏下整页多出 10px 横向滚动条。 */
.qb-sheet { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 6px; min-width: 0; }
.qb-sheet button { height: 30px; min-width: 0; padding: 0; border: 1px solid var(--line); border-radius: 7px; background: var(--bg-soft); font-size: 0.875rem; font-weight: 700; }
.qb-sheet button.done { background: var(--primary-soft); border-color: var(--primary); color: var(--primary); }
.qb-sheet button.mark { background: var(--orange-soft); border-color: var(--orange); color: var(--orange); }
.qb-sheet button.right { background: var(--green-soft); border-color: var(--green); color: var(--green); }
.qb-sheet button.bad { background: #fdeef0; border-color: #e14b5a; color: #e14b5a; }
.qb-sheet button.current { outline: 2px solid var(--primary); outline-offset: 1px; }
.qb-legend { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; color: var(--muted); font-size: 0.8125rem; }
.qb-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 4px; }

.qb-dialog { position: fixed; inset: 0; z-index: 200; display: grid; place-items: center; padding: 20px; }
.qb-dialog-backdrop { position: absolute; inset: 0; background: rgba(12, 20, 32, .45); backdrop-filter: blur(2px); }
.qb-dialog-card { position: relative; width: min(620px, 100%); max-height: 86vh; overflow: auto; padding: 24px; border-radius: 18px; background: var(--surface); box-shadow: var(--shadow); }
.qb-dialog-card h3 { margin: 0 0 6px; font-size: 1.375rem; }
.qb-dialog-card p { margin: 0 0 16px; color: var(--text-2); font-size: 1rem; line-height: 1.8; }
.qb-modes { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 16px; }
.qb-modes label { padding: 14px; border: 1px solid var(--line); border-radius: 12px; cursor: pointer; }
.qb-modes label.sel { border-color: var(--primary); background: var(--primary-soft); }
.qb-modes b { display: block; font-size: 1rem; }
.qb-modes small { color: var(--muted); font-size: 0.875rem; }
.qb-form { display: grid; gap: 12px; margin-bottom: 18px; }
.qb-form label { display: grid; gap: 6px; font-size: 0.9375rem; font-weight: 700; }
.qb-report { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 16px; }
.qb-report div { padding: 12px; border-radius: 12px; background: var(--bg-soft); text-align: center; }
.qb-report strong { display: block; font-size: 1.375rem; color: var(--primary); }
.qb-report span { font-size: 0.875rem; color: var(--muted); }
.qb-report-list { display: grid; gap: 8px; max-height: 260px; overflow: auto; }
.qb-report-list button { display: flex; gap: 10px; align-items: center; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg-soft); text-align: left; font-size: 0.9375rem; }
.qb-report-list button b { color: #e14b5a; }
.qb-dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }

.qb-empty { padding: 60px 0; text-align: center; color: var(--muted); }
.qb-resume { display: flex; align-items: center; gap: 12px; margin: 18px 0; padding: 12px 16px; border: 1px solid var(--primary); border-radius: 12px; background: var(--primary-soft); font-size: 1rem; }
.qb-resume button { margin-left: auto; }

@media (max-width: 900px) {
  .qb-practice { grid-template-columns: 1fr; }
  .qb-side { position: static; }
  .qb-hero { grid-template-columns: 1fr; }
  .qb-report { grid-template-columns: repeat(2, 1fr); }
  .qb-special-form { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
/* ---------- 窄屏答题条 ----------------------------------------------------
   现场：手机端 qb-bar 里那段二三十字的试卷全名和「提交试卷」等按钮抢同一行宽度，
   flex 挤压后中文被逐字断行，整条高度冲到 800px+，首屏连第一道题都看不到。
   处理：窄屏不展示试卷全名（选卷时已经知道），答题条压成「计时 + 操作」两行；
   同时答题进行中收起顶部栏目导航，把可视高度全让给题干。
------------------------------------------------------------------------- */
@media (max-width: 820px) {
  body.qb-active { --header: 64px; }
  body.qb-active .site-header { height: var(--header); }
  body.qb-active .mobile-nav { display: none !important; }

  .qb-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    padding: 10px 12px;
    border-radius: 12px;
  }
  .qb-bar > div:first-child { display: none; }   /* 试卷全名 + 模式副标题，窄屏不展示 */
  .qb-bar h2 { font-size: 0.9375rem; }
  .qb-bar .qb-bar-sub { font-size: 0.8125rem; }
  .qb-bar-actions {
    margin-left: 0;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
    align-items: center;
  }
  .qb-timer {
    grid-column: 1 / -1;
    justify-self: start;
    padding: 4px 12px;
    font-size: 0.9375rem;
  }
  .qb-bar-actions .qb-btn {
    width: 100%;
    min-width: 0;
    padding: 8px 2px;
    font-size: 0.875rem;
    white-space: nowrap;
    overflow: hidden;
  }

  .qb-practice { padding: 12px 0 48px; gap: 14px; }
  .qb-question { padding: 16px; border-radius: 14px; }
  .qb-stem { font-size: 1.0312rem; line-height: 1.85; }
  .qb-option { padding: 11px 12px; }
  .qb-option span { font-size: 1rem; line-height: 1.7; }
  .qb-qhead { margin-bottom: 12px; }
  .qb-foot { gap: 8px; }
  .qb-foot .qb-btn { flex: 1 1 auto; min-width: 0; padding: 8px 10px; font-size: 0.875rem; }
  .qb-foot [data-qb-progress] { flex: 1 1 100%; margin-left: 0 !important; text-align: left; }
  .qb-side { top: auto; }
}

@media (max-width: 640px) {
  .qb-hero { padding-top: 28px; }
  .qb-stats { width: 100%; justify-content: space-between; gap: 12px; }
  .qb-stats div { text-align: left; }
  .qb-filters { padding: 14px; border-radius: 14px; }
  .qb-filter-row { align-items: flex-start; }
  .qb-filter-row > b { width: 100%; }
  .qb-search, .essay-search-row { width: 100%; margin-left: 0; flex-wrap: wrap; }
  .qb-input, .essay-search-row .qb-input { width: 100%; min-width: 0; }
  .qb-grid { min-width: 0; grid-template-columns: minmax(0, 1fr); }
  .qb-grid > *,
  .qb-card,
  .essay-grid-v2 .essay-card-copy { min-width: 0; max-width: 100%; }
  .qb-card { width: 100%; box-sizing: border-box; }
  .essay-grid-v2 .essay-card-copy h3 {
    display: -webkit-box;
    overflow: hidden;
    white-space: normal;
    overflow-wrap: anywhere;
    text-overflow: ellipsis;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    line-clamp: 2;
  }
  .essay-grid-v2 .qb-card-year { width: 56px; height: 56px; font-size: 1.125rem; }
  .essay-grid-v2 .qb-card-meta { min-width: 0; }
  .qb-special-form { grid-template-columns: 1fr; }
  .qb-special-actions { align-items: stretch; flex-direction: column; }
  .qb-special-actions .qb-btn { width: 100%; }
  .qb-pagination { flex-direction: column; align-items: stretch; padding-bottom: 36px; }
  .qb-pagination-summary { text-align: center; }
  .qb-pagination-pages { gap: 4px; }
  .qb-pagination button { min-width: 34px; height: 36px; padding: 0 9px; }
  .qb-pagination .qb-page-arrow span { display: none; }
}
@media print {
  .site-header, .qb-side, .qb-bar-actions, .qb-foot, .qb-dialog { display: none !important; }
}
