/* 物理题库样式 */
:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --bg: #f5f7fb;
  --card: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --border: #e5e7eb;
  --radius: 10px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
}
.container { max-width: 1100px; margin: 0 auto; padding: 0 20px; }

.site-header {
  background: linear-gradient(135deg, #1d4ed8 0%, #2563eb 45%, #4f46e5 100%);
  color: #fff; padding: 32px 0 26px; margin-bottom: 24px; border-radius: 0 0 16px 16px;
  box-shadow: 0 4px 18px rgba(37, 99, 235, .25);
}
.site-header h1 { font-size: 1.75rem; font-weight: 800; letter-spacing: .5px; }
.crumb { margin: 0 0 6px; font-size: .86rem; opacity: .9; }
.crumb a { color: #fff; text-decoration: none; border-bottom: 1px dashed rgba(255,255,255,.6); }
.crumb a:hover { color: #fff; border-bottom-color: #fff; }
.subtitle { opacity: .92; margin-top: 6px; font-size: .98rem; }

.card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px 20px;
  box-shadow: 0 1px 3px rgba(0,0,0,.05);
}

/* 筛选栏 */
.filter-bar { margin-bottom: 18px; }
.filter-row { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.filter-row select {
  padding: 6px 10px; border: 1px solid var(--border); border-radius: 6px;
  font-size: .9rem; background: #fff; color: var(--text);
}
.filter-row2 { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.filter-row2 input[type="search"] {
  flex: 1; min-width: 200px; padding: 7px 12px;
  border: 1px solid var(--border); border-radius: 6px; font-size: .9rem;
}
.filter-row2 button {
  padding: 7px 16px; border: none; border-radius: 6px;
  background: var(--primary); color: #fff; cursor: pointer; font-size: .9rem;
}
.filter-row2 button:hover { background: var(--primary-dark); }
.filter-row2 .counter { color: var(--muted); font-size: .85rem; margin-left: auto; }

/* 考卷搜索框（比题干搜索窄一些，辅助快速定位卷） */
#fPaperSearch {
  flex: 0 1 240px; min-width: 160px; padding: 7px 12px;
  border: 1px solid var(--border); border-radius: 6px; font-size: .9rem;
}
#fPaper optgroup { font-style: normal; color: var(--muted); }
#fPaper optgroup option { color: var(--text); }

/* 题目卡片 */
.question { margin-bottom: 16px; }
.question:hover { box-shadow: 0 2px 8px rgba(0,0,0,.08); }
.q-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.q-num { font-weight: 700; font-size: 1.05rem; color: var(--primary-dark); }
.badge {
  display: inline-block; padding: 1px 10px; border-radius: 20px;
  font-size: .75rem; background: #eef2ff; color: var(--primary-dark);
}
.badge.src { background: #ecfdf5; color: #059669; }
.badge.diff-易 { background: #ecfdf5; color: #059669; }
.badge.diff-中 { background: #fef3c7; color: #b45309; }
.badge.diff-难 { background: #fee2e2; color: #b91c1c; }
.badge.kp { background: #f3f4f6; color: #374151; }

.q-stem { font-size: 1rem; }
.fig img { max-width: 100%; max-height: 320px; display: block; margin: 10px 0; border-radius: 6px; }
.fig-formula { display: inline-block; vertical-align: -0.35em; margin: 0 2px; }
.fig-formula img { height: 1.5em; width: auto; max-width: 98%; vertical-align: baseline; }

.options { list-style: none; margin: 10px 0 0 8px; }
.opt { padding: 3px 0; }

.q-actions { margin-top: 10px; }
.btn-answer {
  padding: 7px 20px; border: 1px solid var(--primary); border-radius: 6px;
  background: #fff; color: var(--primary); cursor: pointer; font-size: .9rem;
}
.btn-answer:hover { background: #eff6ff; }
.qa-wrap { margin-top: 12px; border-top: 1px dashed var(--border); padding-top: 12px; }
.qa-block { margin-bottom: 12px; }
.qa-block summary { font-weight: 700; margin-bottom: 6px; color: var(--primary-dark); }
.qa-body { font-size: .95rem; }

/* 分页 */
.pager { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; justify-content: center; padding: 14px 0; }
.pager .pg {
  min-width: 34px; padding: 6px 10px; border: 1px solid var(--border);
  border-radius: 6px; background: #fff; cursor: pointer; font-size: .85rem;
}
.pager .pg:hover { background: #eff6ff; }
.pager .pg.cur { background: var(--primary); color: #fff; border-color: var(--primary); }
.pager span { color: var(--muted); font-size: .85rem; margin-left: 8px; }

.empty { text-align: center; color: var(--muted); padding: 40px 0; }
.site-footer { text-align: center; color: var(--muted); font-size: .82rem; padding: 30px 0 40px; }

/* 试卷下载条 */
.dl-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 14px; margin-bottom: 14px; }
.dl-label { font-weight: 600; color: #444; }
.dl-select { padding: 6px 8px; border: 1px solid #ccc; border-radius: 6px; min-width: 220px; }
.dl-btn { display: none; padding: 6px 16px; background: #2563eb; color: #fff; border-radius: 6px; text-decoration: none; font-weight: 600; }
.dl-btn.show { display: inline-block; }
.dl-btn:hover { background: #1d4ed8; }
.dl-hint { color: #888; font-size: 0.85em; }

/* ===== 头部操作区 ===== */
.header-actions { margin-top: 12px; display: flex; align-items: center; gap: 10px; }
.basket-count { background: rgba(255,255,255,.2); padding: 4px 12px; border-radius: 20px; font-size: .9rem; }
.btn {
  padding: 7px 16px; border: none; border-radius: 6px; cursor: pointer;
  font-size: .9rem; background: #fff; color: #2563eb; font-weight: 600;
}
.btn:hover { background: #eff6ff; }
.btn-primary { background: #2563eb; color: #fff; }
.btn-primary:hover { background: #1d4ed8; color: #fff; }
.btn-sm { padding: 4px 10px; font-size: .82rem; }
.btn.danger { color: #dc2626; background: #fff; border: 1px solid #fca5a5; }
.btn.danger:hover { background: #fef2f2; }

/* ===== 试题篮侧栏 ===== */
.basket-overlay {
  position: fixed; inset: 0; background: rgba(15,23,42,.35);
  z-index: 999; backdrop-filter: blur(2px);
}
.basket[hidden] { display: none !important; }
.basket {
  position: fixed; top: 0; right: 0; bottom: 0; width: 400px; max-width: 92vw;
  background: #fff; box-shadow: -6px 0 24px rgba(0,0,0,.18);
  z-index: 1000; display: flex; flex-direction: column;
  border-radius: 12px 0 0 12px;
}
.basket-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 18px; border-bottom: 1px solid var(--border); background: #f8fafc;
  border-radius: 12px 0 0 0;
}
.basket-head h2 { font-size: 1.15rem; }
.basket-n { color: #2563eb; }
.basket-tools { display: flex; gap: 6px; padding: 10px 18px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.basket-meta { padding: 10px 18px; border-bottom: 1px solid var(--border); }
.basket-meta label { font-size: .88rem; color: #444; }
.basket-meta input {
  width: 100%; padding: 6px 10px; margin-top: 4px; border: 1px solid var(--border);
  border-radius: 6px; font-size: .9rem;
}
.basket-list {
  flex: 1; overflow-y: auto; padding: 12px 16px;
}
.basket-empty { color: var(--muted); text-align: center; padding: 40px 10px; }
.basket-item {
  display: flex; gap: 8px; align-items: flex-start; padding: 9px 8px;
  border: 1px solid var(--border); border-radius: 8px; margin-bottom: 8px;
  background: #fafbfc;
}
.basket-item .bi-num {
  font-weight: 700; color: #2563eb; font-size: .85rem; min-width: 18px;
  padding-top: 1px;
}
.basket-item .bi-src { font-size: .7rem; color: #059669; background: #ecfdf5; padding: 0 6px; border-radius: 10px; }
.basket-item .bi-stem {
  flex: 1; font-size: .82rem; line-height: 1.5; color: #374151;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.basket-item .bi-tools { display: flex; flex-direction: column; gap: 2px; }
.basket-item .bi-tools button {
  border: none; background: none; cursor: pointer; font-size: .8rem; color: #6b7280;
  padding: 1px 4px; border-radius: 4px;
}
.basket-item .bi-tools button:hover { background: #eef2ff; color: #2563eb; }
.basket-item .bi-tools button.del:hover { background: #fef2f2; color: #dc2626; }
.basket-foot {
  padding: 14px 18px; border-top: 1px solid var(--border); background: #f8fafc;
  border-radius: 0 0 0 12px;
}
.mode-row { display: flex; gap: 16px; font-size: .88rem; margin-bottom: 12px; color: #333; }
.mode-row label { display: flex; align-items: center; gap: 5px; cursor: pointer; }
.basket-foot .btn-primary { width: 100%; padding: 11px; font-size: 1rem; }
.gen-status { margin-top: 8px; font-size: .84rem; color: #2563eb; min-height: 1.2em; }
.gen-status.error { color: #dc2626; }
.gen-status.ok { color: #059669; }

/* 加入试题篮按钮 */
.q-actions { display: flex; gap: 8px; }
.btn-basket-add {
  padding: 7px 16px; border: 1px solid #059669; border-radius: 6px;
  background: #fff; color: #059669; cursor: pointer; font-size: .9rem;
}
.btn-basket-add:hover { background: #ecfdf5; }
.btn-basket-add.added {
  background: #059669; color: #fff;
}

/* 返回顶端按钮 */
.back-top {
  position: fixed; right: 24px; bottom: 32px; z-index: 999;
  width: 46px; height: 46px; border-radius: 50%; border: none;
  background: var(--primary); color: #fff; font-size: 1.3rem; font-weight: 700;
  cursor: pointer; box-shadow: 0 4px 14px rgba(37, 99, 235, .4);
  transition: transform .18s, opacity .18s, background .2s;
}
.back-top:hover { background: var(--primary-dark); transform: translateY(-3px); }
.back-top[hidden] { display: none; }

/* ===== 响应式断点 =====
   大屏(≥1280)：已由 1100px 容器承载，双栏可选
   平板(641-1024px)：保持单栏，但容器自适应、字体略调
   手机(≤640px)：窄屏优化，筛选可折行、试题篮全屏
*/
@media (max-width: 1024px) {
  .container { padding: 0 16px; }
  .site-header h1 { font-size: 1.45rem; }
}
@media (max-width: 768px) {
  .container { max-width: 100%; }
  .question { padding: 16px; }
  .q-stem { font-size: .98rem; }
}
@media (max-width: 640px) {
  .basket {
    top: auto;             /* 底部抽屉：不再从顶部全屏 */
    bottom: 0; left: 0; right: 0;
    width: 100%; max-width: 100%;
    height: auto;
    max-height: 75vh;      /* 最多 3/4 屏高，上方保留主界面内容 */
    border-radius: 16px 16px 0 0;
    box-shadow: 0 -8px 30px rgba(0,0,0,.22);
  }
  .basket-head { border-radius: 16px 16px 0 0; }
  .basket-list { max-height: calc(75vh - 200px); overflow-y: auto; }
  .filter-row { flex-direction: column; }
  .filter-row select { width: 100%; }
  .filter-row2 { flex-direction: column; align-items: stretch; }
  .filter-row2 input[type="search"], #fPaperSearch { width: 100%; min-width: 0; }
  .filter-row2 .counter { margin-left: 0; }
  .site-header { padding: 22px 0 18px; }
  .header-actions { flex-wrap: wrap; }
  .back-top { right: 14px; bottom: 20px; width: 42px; height: 42px; }
  .mode-row { flex-direction: column; gap: 8px; }
}
