/* ExamCracker AI — V5 exam entitlement, active-exam scope and phone UX */
#examLibraryCategoryRow { display:none !important; }
.exam-library-shell,
.exam-library-shell .card,
.exam-library-hero,
.exam-library-actions,
.library-section-head,
.exam-library-search-wrap,
.exam-library-exams,
.library-series-grid,
.library-subject-grid,
.library-test-list,
.library-test-card,
.dynamic-test-modal-box,
.exam-access-modal-box { min-width:0; max-width:100%; }

.exam-library-hero { align-items:stretch; }
.exam-library-hero > div:first-child { min-width:0; flex:1 1 auto; }
.exam-library-actions { flex:0 1 44%; justify-content:flex-end; align-items:flex-end; }
.exam-library-actions select { min-width:0; max-width:100%; }

.library-selected-exams-search { grid-template-columns:minmax(0,1fr) !important; }
.library-chip-row { overflow-x:auto; scrollbar-width:none; }
.library-chip-row::-webkit-scrollbar { display:none; }
.library-chip { flex:0 0 auto; }

.library-exam-card,
.library-series-card,
.library-subject-card,
.library-test-card { min-width:0; }
.library-exam-copy,
.library-series-copy,
.library-test-main { min-width:0; overflow:hidden; }
.library-exam-copy strong,
.library-series-copy strong,
.library-test-card h4,
.library-test-card p { overflow-wrap:anywhere; white-space:normal; }

/* Mobile: every exam-library control stacks or fills the phone width. */
@media (max-width: 767px) {
  .exam-library-shell { gap:12px; }
  .exam-library-hero { padding:14px; gap:12px; }
  .exam-library-hero h2 { font-size:1.25rem; line-height:1.2; overflow-wrap:anywhere; }
  .exam-library-hero p { font-size:.76rem; line-height:1.45; }
  .exam-library-actions { width:100%; display:grid; grid-template-columns:minmax(0,1fr) minmax(0,1fr); gap:8px; }
  .exam-library-actions select { grid-column:1 / -1; width:100%; min-height:44px; }
  .exam-library-actions .btn { width:100%; min-height:42px; }

  .exam-library-search-wrap { grid-template-columns:minmax(0,1fr) !important; }
  .library-section-head { display:flex; flex-direction:column; align-items:flex-start; gap:5px; }
  .library-section-head h3 { font-size:1rem; }
  .library-section-head p { line-height:1.45; }
  .exam-library-exams { grid-template-columns:minmax(0,1fr); }
  .library-series-grid { grid-template-columns:minmax(0,1fr); }
  .library-subject-grid { grid-template-columns:minmax(0,1fr); }
  .library-tabs { max-width:100%; overflow-x:auto; }
  .library-tab { flex:0 0 auto; }
  .library-test-card { flex-direction:column; align-items:stretch; padding:12px; }
  .library-test-card .btn { width:100%; }
  .library-test-meta { gap:5px; }
  .library-test-meta span { max-width:100%; }
}

/* Dynamic AI question bank modal — no horizontal clipping on phones. */
.dynamic-test-modal-box {
  width:min(720px, calc(100vw - 20px)) !important;
  max-width:calc(100vw - 20px) !important;
  box-sizing:border-box;
  overflow-x:hidden;
}
.dynamic-test-modal-box .dynamic-test-header,
.dynamic-test-modal-box .dynamic-field,
.dynamic-test-modal-box .dynamic-test-grid,
.dynamic-test-modal-box .dynamic-test-footer { min-width:0; max-width:100%; }
.dynamic-test-modal-box .dynamic-test-header > div { min-width:0; }
.dynamic-test-modal-box .dynamic-test-header h3,
.dynamic-test-modal-box .dynamic-test-header p,
.dynamic-test-modal-box .dynamic-test-footer { overflow-wrap:anywhere; }
.dynamic-test-modal-box .search-select,
.dynamic-test-modal-box .search-select input,
.dynamic-test-modal-box .dynamic-field > select,
.dynamic-test-modal-box .dynamic-field > input { width:100%; max-width:100%; box-sizing:border-box; min-width:0; }
.dynamic-test-modal-box .search-select-menu { max-width:100%; overflow-x:hidden; }

/* Exam access manager */
.exam-access-modal-box { width:min(560px, calc(100vw - 20px)) !important; max-width:calc(100vw - 20px) !important; }
.exam-access-head h3 { margin:8px 0 2px; color:#fff; font-family:var(--font-heading); font-size:1.3rem; }
.exam-access-head p { margin:0 0 14px; color:var(--text-muted); font-size:.78rem; }
.exam-access-search { width:100%; min-height:44px; box-sizing:border-box; border-radius:12px; border:1px solid var(--border-subtle); background:var(--surface-2,#111827); color:#fff; padding:10px 12px; margin-bottom:10px; }
.exam-access-list { max-height:min(58vh,520px); overflow:auto; display:grid; gap:7px; }
.exam-access-row { display:flex; align-items:center; gap:10px; width:100%; min-width:0; box-sizing:border-box; text-align:left; padding:11px 12px; border-radius:12px; border:1px solid var(--border-subtle); background:rgba(255,255,255,.03); color:#fff; cursor:pointer; }
.exam-access-row.accessible { border-color:rgba(99,102,241,.35); }
.exam-access-main { display:grid; gap:2px; min-width:0; flex:1 1 auto; }
.exam-access-main strong { font-size:.82rem; overflow-wrap:anywhere; }
.exam-access-main small { color:var(--text-dim); font-size:.68rem; }
.exam-access-status { flex:0 0 auto; font-size:.68rem; padding:5px 7px; border-radius:999px; white-space:nowrap; }
.exam-access-status.selected { background:rgba(16,185,129,.12); color:#86efac; border:1px solid rgba(16,185,129,.3); }
.exam-access-status.available { background:rgba(99,102,241,.12); color:#a5b4fc; border:1px solid rgba(99,102,241,.3); }
.exam-access-status.locked { background:rgba(245,158,11,.1); color:#fbbf24; border:1px solid rgba(245,158,11,.3); }
.exam-access-note { margin-top:10px; color:var(--text-dim); font-size:.68rem; line-height:1.45; }
body.light-mode .exam-access-head h3 { color:#0f172a; }
body.light-mode .exam-access-search { background:#fff; color:#0f172a; border-color:#dbe3ee; }
body.light-mode .exam-access-row { background:#fff; color:#0f172a; border-color:#dbe3ee; }
body.light-mode .exam-access-main small,
body.light-mode .exam-access-note { color:#64748b; }

@media (max-width: 767px) {
  .exam-access-modal-box { padding:14px !important; }
  .exam-access-list { max-height:52vh; }
  .exam-access-row { align-items:flex-start; }
  .exam-access-status { margin-top:2px; }
}

/* V16: exam names are identity-bearing labels; never truncate/clip them or key switching by display text. */
.library-exam-card { min-width:0; cursor:pointer; }
.library-exam-copy { min-width:0; flex:1 1 auto; }
.library-exam-copy strong, .library-exam-copy small { display:block; overflow-wrap:anywhere; white-space:normal; text-overflow:clip; overflow:visible; }
#examSelector, #examLibraryExamSelect { min-width:0; max-width:100%; }


/* V18: multi-target exam chips. One active exam, multiple reversible target exams. */
.target-exam-chips{display:flex;gap:6px;align-items:center;flex-wrap:wrap;margin-top:7px;max-width:100%;}
.target-exam-chip{appearance:none;border:1px solid rgba(99,102,241,.35);background:rgba(99,102,241,.08);color:#cbd5e1;border-radius:999px;padding:5px 9px;font-size:.68rem;font-weight:700;cursor:pointer;max-width:100%;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;}
.target-exam-chip span{margin-left:4px;color:#94a3b8;}
.target-exam-chip.active{border-color:rgba(34,211,238,.55);background:rgba(34,211,238,.08);color:#fff;box-shadow:0 0 0 1px rgba(34,211,238,.06);}
.target-exam-chip:hover{border-color:#22d3ee;color:#fff;}
@media(max-width:767px){.target-exam-chips{overflow-x:auto;flex-wrap:nowrap;padding-bottom:2px;scrollbar-width:none}.target-exam-chips::-webkit-scrollbar{display:none}.target-exam-chip{flex:0 0 auto;min-height:34px;max-width:78vw}.exam-picker-wrap{min-width:0;width:100%;}}
