/* 知序 · 题库页 (#bank)。完全复用 ui.css token 与组件。 */

.library {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
}

.library-head {
  margin-bottom: 4px;
}

.library-exam-link {
  color: var(--brand-ink);
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}
.library-exam-link:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.library-paper-btn {
  gap: 8px;
}
.library-picked-pill {
  display: inline-grid;
  place-items: center;
  min-width: 22px;
  height: 22px;
  padding: 0 7px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.22);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
}

/* 紧凑筛选栏 */
.library-toolbar {
  padding: 12px 14px;
  display: grid;
  gap: 12px;
}
.library-core-filters {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}
.library-core-filters label {
  display: grid;
  gap: 5px;
  min-width: 0;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--ink-2);
}
.library-core-filters select {
  width: 100%;
  min-width: 0;
  min-height: 44px;
}

.library-filter-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.library-search-wrap {
  position: relative;
  flex: 1 1 240px;
  min-width: 0;
}
.library-search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--ink-3);
  display: inline-flex;
  pointer-events: none;
}
.library-search-wrap input[type="search"] {
  width: 100%;
  padding-left: 36px;
  background: var(--surface-2);
}
.library-search-wrap input[type="search"]:focus {
  background: var(--surface);
}

.library-filter-selects {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.library-filter-selects select {
  min-width: 120px;
  max-width: 176px;
  background-color: var(--surface);
  font-size: var(--t-sm);
}

.library-filter-toggle {
  flex: none;
  min-height: 44px;
}
.library-filter-badge {
  display: inline-grid;
  place-items: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--brand-soft);
  color: var(--brand-ink);
  font-size: 12px;
  font-weight: 700;
}
.library-label-mobile,
.library-badge-mobile {
  display: none;
}

.library-advanced-row {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  flex-wrap: wrap;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}
.library-adv-field {
  display: grid;
  gap: 6px;
  flex: 1 1 200px;
  min-width: 0;
}
.library-adv-field > span {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-2);
}
.library-adv-field select {
  width: 100%;
}
.library-adv-actions {
  display: flex;
  align-items: center;
  margin-left: auto;
}

/* 待核对档案提示（仅非默认筛选时展示） */
.library-archive-note {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 10px 14px;
  margin-bottom: 12px;
  border-radius: var(--r-md);
  background: var(--warn-soft);
  border: 1px solid var(--warn-line);
  color: var(--warn);
  font-size: 13.5px;
  line-height: 1.55;
}
.library-archive-note svg {
  flex: none;
  margin-top: 2px;
}

/* 结果统计栏 */
.library-results {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
}
.library-results-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px 16px;
  flex-wrap: wrap;
  padding: 2px 2px 4px;
  scroll-margin-top: 16px;
}
.library-results-meta {
  display: flex;
  align-items: center;
  gap: 8px 12px;
  flex-wrap: wrap;
}
.library-count {
  font-size: 14px;
  color: var(--ink-2);
}
.library-count b {
  color: var(--ink);
  font-weight: 700;
}
.library-active-chips {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.library-filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  background: var(--brand-soft);
  border: 1px solid var(--brand-line);
  color: var(--brand-ink);
  font-size: 12.5px;
  font-weight: 600;
}
.library-filter-chip:hover {
  background: var(--surface);
}

/* 题目卡片 */
.library-list {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 14px;
}
.library-card {
  padding: clamp(18px, 2.2vw, 24px);
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 14px;
  transition: border-color 0.15s var(--ease), box-shadow 0.15s var(--ease);
}
.library-card:hover {
  border-color: var(--line-strong);
}
.library-card-head {
  display: grid;
  gap: 8px;
}
.library-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.library-badge-source {
  max-width: 28ch;
  overflow: hidden;
  text-overflow: ellipsis;
  display: inline-block;
  line-height: 22px;
}
.library-card h2 {
  font-size: 17px;
  font-weight: 700;
  line-height: 1.4;
  color: var(--ink);
}

.library-stem {
  font-size: 15.5px;
  line-height: 1.78;
  color: var(--ink);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.library-stem .katex,
.library-opt-text .katex {
  display: inline-block;
  max-width: 100%;
  overflow-x: auto;
  vertical-align: middle;
}

.library-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px 20px;
  padding: 10px 14px;
  border-radius: var(--r-sm);
  background: var(--surface-2);
}
.library-options.is-stacked {
  grid-template-columns: minmax(0, 1fr);
}
.library-option {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 4px 0;
  border-radius: 0;
  background: transparent;
  border: 0;
  font-size: var(--t-base);
  line-height: 1.62;
  color: var(--ink);
  cursor: text;
}
.library-opt-key {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  min-width: 18px;
  height: auto;
  border-radius: 0;
  background: transparent;
  color: var(--ink-3);
  font-family: var(--font-mono);
  font-size: var(--t-xs);
  font-weight: 700;
}
.library-opt-key::after {
  content: ".";
}
.library-opt-text {
  min-width: 0;
  overflow-wrap: anywhere;
}

/* 卡片底部操作与次级折叠 */
.library-card-foot {
  display: grid;
  gap: 10px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}
.library-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.library-pick-btn.is-picked,
.library-pick-btn[aria-pressed="true"] {
  background: var(--brand-soft);
  border-color: var(--brand-line);
  color: var(--brand-ink);
}
.library-paper-link {
  margin-left: auto;
  color: var(--ink-2);
}
.library-paper-link:hover {
  color: var(--brand-ink);
}

.library-provenance {
  font-size: 12.5px;
  color: var(--ink-3);
}
.library-provenance summary {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 28px;
  color: var(--ink-3);
  font-size: 12.5px;
  user-select: none;
}
.library-provenance summary::before {
  content: "▸";
  font-size: 11px;
  transition: transform 0.15s var(--ease);
}
.library-provenance[open] summary::before {
  transform: rotate(90deg);
}
.library-provenance summary:hover {
  color: var(--ink-2);
}
.library-provenance-body {
  margin-top: 6px;
  padding: 10px 12px;
  border-radius: var(--r-sm);
  background: var(--surface-2);
  border: 1px solid var(--line);
  display: grid;
  gap: 4px;
  line-height: 1.55;
}
.library-provenance-body a {
  color: var(--brand-ink);
  text-decoration: none;
}
.library-provenance-body a:hover {
  text-decoration: underline;
}

/* 底部分页 */
.library-pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  padding: 8px 0 4px;
}
.library-page-indicator {
  font-size: 14px;
  color: var(--ink-2);
  padding: 0 6px;
}

/* 手机端自适应 */
@media (max-width: 700px) {
  .library {
    gap: 12px;
  }
  .library-head {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    align-items: start;
    gap: 8px;
    margin-bottom: 2px;
  }
  .library-head-main {
    display: grid;
    gap: 4px;
    min-width: 0;
  }
  .library-head-main h1 {
    grid-column: auto;
    grid-row: auto;
    min-width: 0;
  }
  .library-head-actions {
    grid-column: 1 / -1;
    grid-row: auto;
    width: 100%;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
  }
  .library-head-main p {
    grid-column: auto;
    grid-row: auto;
    margin-top: 0;
    font-size: 12.5px;
    line-height: 1.5;
  }
  .library-paper-btn {
    min-height: 40px;
    padding: 0 14px;
    font-size: 14px;
  }
  .library-toolbar {
    padding: 10px 12px;
  }
  .library-core-filters {
    gap: 6px;
  }
  .library-core-filters select {
    padding-inline-start: 7px;
    padding-inline-end: 24px;
    background-position: right 7px center;
    font-size: 1rem;
  }
  .library-search-wrap {
    flex: 1 1 0;
  }
  .library-label-desktop,
  .library-badge-desktop {
    display: none;
  }
  .library-label-mobile {
    display: inline;
  }
  .library-badge-mobile {
    display: inline-grid;
  }
  .library-toolbar:not(.is-open) .library-filter-selects {
    display: none;
  }
  .library-toolbar.is-open .library-filter-selects {
    width: 100%;
    order: 3;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    padding-top: 10px;
    border-top: 1px solid var(--line);
  }
  .library-toolbar.is-open .library-filter-selects select {
    max-width: none;
    min-width: 0;
    width: 100%;
  }
  .library-toolbar.is-open .library-filter-selects select:first-child {
    grid-column: 1 / -1;
  }
  .library-toolbar.is-open .library-advanced-row {
    padding-top: 8px;
    border-top: 0;
    gap: 8px;
  }
  .library-adv-field {
    flex: 1 1 100%;
  }
  .library-adv-actions {
    width: 100%;
    justify-content: flex-end;
  }

  .library-options {
    grid-template-columns: minmax(0, 1fr);
  }
  .library-actions {
    gap: 8px;
  }
  .library-actions > button {
    flex: 1 1 calc(50% - 4px);
    min-height: 42px;
  }
  .library-actions > [data-action="buddy"] {
    flex: 0 1 auto;
  }
  .library-paper-link {
    margin-left: auto;
  }
}

/* 文理先选，再按卷种和年份缩小范围。 */
.library-stream-group { border: 0; padding: 0; margin: 0; min-width: 0; }
.library-stream-group legend { font-weight: 700; font-size: .9rem; margin-bottom: 8px; }
.library-stream-options { display: flex; flex-wrap: wrap; gap: 8px; }
.library-stream-options label { display: flex; align-items: center; gap: 8px; min-height: 48px; padding: 0 12px; border: 1px solid var(--line-strong); border-radius: var(--r-sm); cursor: pointer; }
.library-stream-options label:has(input:checked) { background: var(--brand-soft); border-color: var(--brand-ink); color: var(--brand-ink); font-weight: 700; }
.library-stream-options input { accent-color: var(--brand-ink); margin: 0; }
.library-stream-options label:focus-within { outline: 2px solid var(--brand-ink); outline-offset: 2px; }
.library-stream-group p, .library-scope-note { font-size: 13px; line-height: 1.6; color: var(--ink-2); margin: 8px 0 0; }
.library-scope-note a { color: var(--brand-ink); }
.library-core-filters select { min-height: 48px; font-size: 1rem; }
.library-advanced-row[hidden] { display: none; }
@media (max-width: 700px) {
  .library-stream-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .library-stream-options label { padding-inline: 10px; }
  .library-core-filters { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .library-core-filters label:last-child { grid-column: 1 / -1; }
}

/* ---------- 题库双视图：按试卷浏览 + A4 首页缩略图预览 + 打印 ---------- */
.library-head-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
.bp-mode-tabs > :not(.seg-thumb) {
  min-height: 32px;
  padding: 0 11px;
  font-size: 12.5px;
  gap: 5px;
}
.bp-pane { display: grid; gap: 12px; }
.bp-pane[hidden] { display: none; }
.bp-toolbar {
  display: grid;
  gap: 10px;
  padding: 13px 15px;
  border-radius: var(--r-xl);
}
.bp-filter-top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 12px;
}
.bp-kind-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.bp-pdf-check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  color: var(--ink-2);
  cursor: pointer;
  user-select: none;
}
.bp-pdf-check input { accent-color: var(--brand); margin: 0; }
.bp-filter-row {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(130px, 0.7fr) minmax(110px, 0.55fr) auto;
  gap: 8px;
  align-items: center;
}
@media (max-width: 780px) {
  .bp-filter-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .bp-search-wrap { grid-column: 1 / -1; }
}
.bp-search-wrap { position: relative; display: flex; align-items: center; }
.bp-search-ico {
  position: absolute;
  left: 10px;
  color: var(--ink-4);
  pointer-events: none;
  display: inline-grid;
  place-items: center;
}
.bp-search-wrap input {
  width: 100%;
  padding-left: 32px;
}
.bp-summary-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 6px 12px;
  font-size: 12.5px;
  color: var(--ink-3);
  padding: 0 2px;
}
.bp-summary-bar b { color: var(--ink); font-weight: 700; }
.bp-comp-legend { display: inline-flex; align-items: center; gap: 10px; font-size: 11.5px; }
.bp-comp-legend > span { display: inline-flex; align-items: center; gap: 4px; }
.bp-comp-legend i { width: 8px; height: 4px; border-radius: 2px; display: inline-block; }
.bp-comp-legend i.is-c, .bp-comp-bar i.is-c { background: #3b5bdb; }
.bp-comp-legend i.is-f, .bp-comp-bar i.is-f { background: #0f8a5f; }
.bp-comp-legend i.is-s, .bp-comp-bar i.is-s { background: #d99226; }

/* A4 试卷小图网格 */
.bp-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 13px;
}
@media (max-width: 1040px) {
  .bp-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 720px) {
  .bp-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
}
@media (max-width: 400px) {
  .bp-grid { grid-template-columns: minmax(0, 1fr); }
}
.bp-card {
  display: flex;
  flex-direction: column;
  border-radius: var(--r-xl);
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: border-color 0.16s var(--ease), box-shadow 0.2s var(--ease), transform 0.2s var(--ease);
}
.bp-card:hover {
  border-color: var(--line-hover);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}
.bp-thumb-stage {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px 18px 12px;
  background: linear-gradient(180deg, #f2f3f5 0%, #e9ebef 100%);
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  overflow: hidden;
  text-align: left;
}
.bp-sheet {
  position: relative;
  width: 100%;
  max-width: 168px;
  aspect-ratio: 210 / 285;
  background: #ffffff;
  border-radius: 3px 3px 3px 3px;
  border: 1px solid rgba(17, 19, 24, 0.09);
  box-shadow:
    0 2px 4px rgba(17, 19, 24, 0.07),
    0 8px 18px -6px rgba(17, 19, 24, 0.14);
  overflow: hidden;
  transition: transform 0.28s cubic-bezier(0.22, 1.12, 0.36, 1);
}
.bp-card:hover .bp-sheet { transform: translateY(-2px) scale(1.025); }
.bp-sheet-mock {
  position: absolute;
  inset: 0;
  padding: 12px 11px 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  color: var(--ink);
}
.bp-mock-secret {
  font-size: 6.5px;
  letter-spacing: 0.08em;
  color: #c94a38;
  font-weight: 700;
}
.bp-mock-title {
  font-size: 9px;
  line-height: 1.3;
  font-weight: 700;
  color: var(--ink);
  text-align: center;
  margin-top: 2px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.bp-mock-sub {
  font-size: 6.5px;
  color: var(--ink-3);
  text-align: center;
  font-family: var(--font-mono);
}
.bp-mock-rule {
  display: block;
  height: 1px;
  background: rgba(17, 19, 24, 0.16);
  margin: 3px 0 2px;
}
.bp-mock-sec {
  font-size: 6.5px;
  font-weight: 700;
  color: var(--ink-2);
  margin-top: 3px;
}
.bp-mock-ln {
  display: block;
  height: 3px;
  border-radius: 1.5px;
  background: #e5e7ec;
}
.bp-mock-ln.w92 { width: 92%; }
.bp-mock-ln.w90 { width: 90%; }
.bp-mock-ln.w86 { width: 86%; }
.bp-mock-ln.w78 { width: 78%; }
.bp-mock-ln.w74 { width: 74%; }
.bp-mock-ln.w64 { width: 64%; }
.bp-mock-ln.w55 { width: 55%; }
.bp-mock-opts {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 3px 6px;
  margin: 1px 0 3px;
}
.bp-mock-opts i {
  display: block;
  height: 2.5px;
  border-radius: 1px;
  background: #eceef2;
}
.bp-sheet-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top center;
  background: #ffffff;
  opacity: 0;
  transition: opacity 0.28s var(--ease);
}
.bp-sheet-img.is-loaded { opacity: 1; }
.bp-sheet-fold {
  position: absolute;
  top: 0;
  right: 0;
  width: 14px;
  height: 14px;
  background: linear-gradient(225deg, #e5e7ec 50%, #f5f6f8 51%, #ffffff 100%);
  box-shadow: -1px 1px 2px rgba(17, 19, 24, 0.08);
  pointer-events: none;
}
.bp-page-pill {
  position: absolute;
  right: 9px;
  bottom: 8px;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  color: var(--ink-2);
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(17, 19, 24, 0.09);
  padding: 1px 6px;
  border-radius: 999px;
  backdrop-filter: blur(4px);
}
.bp-hover-pill {
  position: absolute;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 11px;
  border-radius: 999px;
  background: rgba(22, 24, 29, 0.88);
  color: #ffffff;
  font-size: 11.5px;
  font-weight: 600;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.16s var(--ease), transform 0.16s var(--ease);
  pointer-events: none;
}
.bp-thumb-stage:hover .bp-hover-pill,
.bp-thumb-stage:focus-visible .bp-hover-pill {
  opacity: 1;
  transform: translateY(0);
}

.bp-card-body {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 11px 12px 11px;
}
.bp-badges { display: flex; flex-wrap: wrap; gap: 4px; }
.bp-tag {
  font-size: 10.5px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 4px;
  background: var(--surface-2);
  color: var(--ink-3);
}
.bp-tag.is-year { font-family: var(--font-mono); color: var(--ink); font-weight: 700; }
.bp-tag.is-gk { background: var(--brand-soft); color: var(--brand-ink); }
.bp-tag.is-mock { background: var(--warn-soft); color: #9a5d07; }
.bp-tag.is-ans { background: var(--ok-soft); color: #0b6e4b; }
.bp-title {
  font-size: 13px;
  font-weight: 700;
  line-height: 1.38;
  color: var(--ink);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 2.75em;
}
.bp-meta-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  font-size: 11px;
  color: var(--ink-3);
}
.bp-comp-bar {
  display: flex;
  height: 3.5px;
  border-radius: 999px;
  background: #e8eaef;
  overflow: hidden;
  gap: 1px;
}
.bp-comp-bar i { display: block; height: 100%; }
.bp-actions {
  margin-top: auto;
  padding-top: 6px;
  display: flex;
  align-items: center;
  gap: 5px;
}
.bp-print-btn { flex: 1 1 auto; justify-content: center; gap: 4px; font-size: 12px; min-height: 30px; padding: 0 8px; }
.bp-prev-btn, .bp-ans-btn { font-size: 11.5px; min-height: 30px; padding: 0 7px; }
.bp-pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 6px 0 12px;
  font-size: 13px;
  color: var(--ink-3);
}
.bp-pager b { color: var(--ink); }
.bp-loading, .bp-empty {
  text-align: center;
  padding: 36px 16px;
  color: var(--ink-3);
  display: grid;
  justify-items: center;
  gap: 8px;
}

/* 原卷预览与打印弹窗 */
.bp-modal {
  width: min(1060px, calc(100vw - 28px));
  height: min(88vh, 860px);
  max-width: none;
  max-height: none;
  margin: auto;
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-xl);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}
.bp-modal[open] {
  display: flex;
  flex-direction: column;
}
.bp-modal::backdrop {
  background: rgba(17, 19, 24, 0.48);
  backdrop-filter: blur(3px);
}
.bp-modal-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 14px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.bp-modal-title-wrap { min-width: 0; display: grid; gap: 2px; }
.bp-modal-title-wrap h2 {
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.bp-modal-title-wrap small { font-size: 11.5px; color: var(--ink-3); }
.bp-modal-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.bp-doc-tabs > :not(.seg-thumb) { min-height: 28px; padding: 0 10px; font-size: 12px; }
.bp-doc-tabs button:disabled { opacity: 0.42; cursor: not-allowed; }
.bp-modal-body { flex: 1 1 auto; display: flex; background: #e6e8ec; min-height: 0; }
#bp-modal-frame { width: 100%; height: 100%; border: 0; display: block; background: #ffffff; }
.bp-modal-empty {
  margin: auto;
  text-align: center;
  display: grid;
  gap: 10px;
  justify-items: center;
  padding: 24px;
  color: var(--ink-2);
}
@media (max-width: 700px) {
  .bp-mode-tabs { flex: 1 1 200px; width: auto; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .bp-mode-tabs > :not(.seg-thumb) { justify-content: center; padding: 0 8px; }
  .library-paper-btn { flex: 0 0 auto; white-space: nowrap; min-height: 36px; padding: 0 12px; font-size: 13px; }
  .bp-thumb-stage { padding: 10px 12px 9px; }
  .bp-modal { width: calc(100vw - 12px); height: 92vh; }
}

/* =====================================================================
   Unified 3-Tier Scope Bar & Lazy Full Archive Browser (.ba-*) — v4.5
   ===================================================================== */
.ba-scope-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.ba-scope-tabs {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.ba-scope-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 36px;
  padding: 0 13px;
  border-radius: 10px;
  border: 1px solid var(--line, rgba(17, 19, 24, 0.085));
  background: var(--surface, #fff);
  color: var(--ink-2, #343840);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 1px 1.5px rgba(17, 19, 24, 0.03);
  transition: border-color 140ms ease, background 140ms ease, color 140ms ease, box-shadow 140ms ease;
}

.ba-scope-btn em {
  font-style: normal;
  font-size: 11.5px;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--surface-2, #f4f4f3);
  color: var(--ink-3, #52565e);
}

.ba-scope-btn:hover {
  border-color: rgba(59, 91, 219, 0.36);
  color: var(--brand-ink, #2b44ad);
}

.ba-scope-btn.is-on {
  background: var(--brand, #3b5bdb);
  border-color: var(--brand, #3b5bdb);
  color: #fff;
  box-shadow: 0 2px 6px rgba(59, 91, 219, 0.22);
}

.ba-scope-btn.is-on em {
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
}

.ba-scope-hint {
  margin: 0;
  font-size: 12px;
  color: var(--ink-4, #6b707a);
}

.ba-pane {
  display: grid;
  gap: 12px;
}

.ba-stream-opts label span em {
  font-style: normal;
  font-size: 11px;
  color: var(--ink-4, #6b707a);
  margin-left: 2px;
}
.ba-stream-opts label:has(input:checked) span em {
  color: var(--brand-ink, #2b44ad);
  font-weight: 700;
}

.ba-filter-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.ba-search-wrap {
  flex: 1 1 260px;
  min-width: 0;
}

.ba-filter-row > select {
  min-height: 36px;
  padding: 0 28px 0 10px;
  border-radius: 9px;
  border: 1px solid var(--line-strong, rgba(17, 19, 24, 0.14));
  background: var(--surface, #fff);
  color: var(--ink, #111318);
  font-size: 13px;
}

.ba-fig-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  padding: 0 10px;
  border-radius: 9px;
  border: 1px solid var(--line, rgba(17, 19, 24, 0.085));
  background: var(--surface-2, #f4f4f3);
  color: var(--ink-2, #343840);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.ba-fig-toggle input {
  accent-color: var(--brand, #3b5bdb);
  margin: 0;
}

.ba-fig-toggle em {
  font-style: normal;
  font-size: 11px;
  color: var(--ink-4, #6b707a);
}

.ba-summary {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px 16px;
  flex-wrap: wrap;
  padding: 4px 2px 8px;
  font-size: 13px;
  color: var(--ink-2, #343840);
}

.ba-summary-l {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
}

.ba-summary-l b {
  font-size: 14.5px;
  color: var(--ink, #111318);
}

.ba-summary-sub,
.ba-summary-r {
  font-size: 12px;
  color: var(--ink-4, #6b707a);
}

/* Progressive scan bar */
.ba-scan-bar {
  margin-bottom: 10px;
  padding: 9px 13px;
  border-radius: 10px;
  background: rgba(59, 91, 219, 0.055);
  border: 1px solid rgba(59, 91, 219, 0.2);
  display: grid;
  gap: 6px;
}

.ba-scan-copy {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--ink-2, #343840);
}

.ba-scan-track {
  height: 4px;
  border-radius: 999px;
  background: rgba(59, 91, 219, 0.14);
  overflow: hidden;
}

.ba-scan-track i {
  display: block;
  height: 100%;
  background: var(--brand, #3b5bdb);
  border-radius: 999px;
  transition: width 180ms ease;
}

/* Question cards */
.ba-list {
  display: grid;
  gap: 12px;
}

.ba-card {
  padding: 16px 20px 14px;
  display: grid;
  gap: 10px;
  background: var(--surface, #fff);
  border: 1px solid var(--line, rgba(17, 19, 24, 0.085));
  border-radius: var(--r-lg, 14px);
  box-shadow: var(--shadow-sm);
  transition: border-color 140ms ease;
}

.ba-card:hover {
  border-color: rgba(17, 19, 24, 0.17);
}

.ba-card-badges {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.ba-badge-paper {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ba-qual {
  display: inline-flex;
  align-items: center;
  padding: 1.5px 7px;
  border-radius: 5px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

.ba-qual.is-rev {
  background: rgba(15, 138, 95, 0.10);
  color: #0b6e4b;
  border: 1px solid rgba(15, 138, 95, 0.24);
}

.ba-qual.is-ext {
  background: var(--surface-2, #f4f4f3);
  color: var(--ink-4, #6b707a);
  border: 1px solid rgba(17, 19, 24, 0.07);
}

.ba-qual.is-fig {
  background: rgba(217, 146, 38, 0.12);
  color: #8c5204;
  border: 1px solid rgba(217, 146, 38, 0.28);
}

.ba-card-title {
  margin: 0;
  font-size: 15.5px;
  font-weight: 700;
  color: var(--ink, #111318);
  line-height: 1.35;
  letter-spacing: -0.012em;
}

.ba-stem {
  font-size: 14.5px;
  line-height: 1.75;
  color: var(--ink-2, #343840);
  overflow-x: auto;
}

.ba-fig-note {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 8px;
  background: rgba(217, 146, 38, 0.085);
  border: 1px solid rgba(217, 146, 38, 0.22);
  color: #7c4a04;
  font-size: 12px;
}

.ba-options {
  list-style: none;
  margin: 0;
  padding: 12px 14px;
  border-radius: 10px;
  background: var(--surface-2, #f4f4f3);
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 20px;
  font-size: 14px;
  line-height: 1.6;
  color: var(--ink, #111318);
}

.ba-options li {
  display: flex;
  align-items: baseline;
  gap: 7px;
  min-width: 0;
  overflow-x: auto;
}

.ba-opt-k {
  font-family: var(--font-mono);
  font-size: 12.5px;
  font-weight: 700;
  color: var(--ink-3, #52565e);
  flex-shrink: 0;
}

/* Inline solution drawer */
.ba-sol {
  padding: 12px 14px;
  border-radius: 10px;
  background: #fafaf9;
  border: 1px solid rgba(15, 138, 95, 0.22);
  border-left: 3px solid var(--ok, #0f8a5f);
  display: grid;
  gap: 8px;
}

.ba-sol-ans {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 13.5px;
}

.ba-sol-ans > span {
  font-size: 11px;
  font-weight: 700;
  padding: 1.5px 7px;
  border-radius: 5px;
  background: rgba(15, 138, 95, 0.12);
  color: #0b6e4b;
}

.ba-sol-ans > strong {
  color: var(--ink, #111318);
  font-weight: 700;
}

.ba-sol-body {
  font-size: 13.5px;
  line-height: 1.75;
  color: var(--ink-2, #343840);
  overflow-x: auto;
}

.ba-sol-empty {
  margin: 0;
  font-size: 12.5px;
  color: var(--ink-4, #6b707a);
}

.ba-card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px 14px;
  flex-wrap: wrap;
  padding-top: 4px;
  border-top: 1px solid rgba(17, 19, 24, 0.055);
}

.ba-card-acts {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.ba-sol-btn.is-open {
  background: rgba(15, 138, 95, 0.08);
  color: #0b6e4b;
}

.ba-pdf-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--ink-3, #52565e);
  font-size: 12.5px;
  text-decoration: none;
}

.ba-pdf-btn:hover {
  color: var(--brand-ink, #2b44ad);
}

.ba-src-detail {
  font-size: 11.5px;
  color: var(--ink-4, #6b707a);
}

.ba-src-detail summary {
  cursor: pointer;
  user-select: none;
  display: inline-block;
}

.ba-src-detail p {
  margin: 6px 0 0;
  line-height: 1.55;
  color: var(--ink-3, #52565e);
}

.ba-src-detail code {
  font-size: 11px;
  background: var(--surface-2, #f4f4f3);
  padding: 0 4px;
  border-radius: 3px;
}

/* Numbered pagination + jump */
.ba-pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 16px;
  padding: 6px 0;
}

.ba-pager-nums {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.ba-pnum {
  min-width: 32px;
  height: 32px;
  padding: 0 8px;
  border-radius: 8px;
  border: 1px solid var(--line, rgba(17, 19, 24, 0.085));
  background: var(--surface, #fff);
  color: var(--ink-2, #343840);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
}

.ba-pnum:hover { border-color: rgba(59, 91, 219, 0.4); color: var(--brand-ink, #2b44ad); }
.ba-pnum.is-on {
  background: var(--brand, #3b5bdb);
  border-color: var(--brand, #3b5bdb);
  color: #fff;
}

.ba-pager-dots {
  padding: 0 3px;
  color: var(--ink-4, #6b707a);
}

.ba-jump {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-left: 6px;
  font-size: 12px;
  color: var(--ink-3, #52565e);
}

.ba-jump label {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.ba-jump input {
  width: 64px;
  height: 30px;
  padding: 0 7px;
  border-radius: 7px;
  border: 1px solid var(--line-strong, rgba(17, 19, 24, 0.14));
  background: var(--surface, #fff);
  font-size: 12.5px;
  text-align: center;
}

.ba-license {
  margin-top: 10px;
  padding: 10px 4px 2px;
  border-top: 1px solid var(--line, rgba(17, 19, 24, 0.085));
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px 8px;
  font-size: 11.5px;
  color: var(--ink-4, #6b707a);
}

.ba-license a {
  color: var(--ink-3, #52565e);
  text-decoration: underline;
  text-underline-offset: 2px;
}

@media (max-width: 700px) {
  .ba-scope-tabs { width: 100%; }
  .ba-scope-btn { flex: 1 1 auto; justify-content: center; padding: 0 10px; font-size: 12px; }
  .ba-card { padding: 14px 14px 12px; }
  .ba-options { grid-template-columns: minmax(0, 1fr); gap: 6px; padding: 10px 12px; }
  .ba-filter-row > select,
  .ba-fig-toggle { flex: 1 1 calc(50% - 4px); }
  .ba-jump { margin-left: 0; width: 100%; justify-content: center; }
}

/* Keep search and the first question visible on small screens. */
@media (max-width: 640px) {
  .library-toolbar:not(.is-open) .library-stream-group,
  .library-toolbar:not(.is-open) .library-core-filters { display: none; }
  .library-toolbar { padding: 12px; }
  .library-toolbar .library-filter-row { margin-top: 0; }
}
