/**
 * OncoEdge – shared exam styles for the setter, dashboard, and exam-taking pages.
 * Consolidates what used to be duplicated inline <style> blocks in each page.
 */

/* ---- Layout ---- */
.grid-container {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
  width: 100%;
}

@media (min-width: 992px) {
  .grid-container { grid-template-columns: 1.2fr 0.8fr; }
  .grid-container--setter { grid-template-columns: 0.8fr 1.2fr; }
}

.analytics-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
}

@media (min-width: 768px) {
  .analytics-grid { grid-template-columns: 1fr 1fr; }
}

/* ---- Analytics KPI cards (admin dashboard) ---- */
.analytics-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 1rem;
}

.analytics-kpi-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 12px;
  padding: 1.25rem 1rem;
  text-align: center;
  transition: border-color 0.2s ease, transform 0.2s ease;
}

.analytics-kpi-card:hover { transform: translateY(-2px); border-color: var(--accent-color); }

.analytics-kpi-card i {
  font-size: 1.3rem;
  color: var(--accent-color);
  margin-bottom: 0.5rem;
  display: block;
}

.analytics-kpi-card__value {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--text-color);
  line-height: 1.2;
}

.analytics-kpi-card__label {
  font-size: 0.78rem;
  color: var(--muted-text);
  margin-top: 0.25rem;
}

.analytics-kpi-card--good i,
.analytics-kpi-card--good .analytics-kpi-card__value { color: #34d399; }

.analytics-kpi-card--bad i,
.analytics-kpi-card--bad .analytics-kpi-card__value { color: #f87171; }

@media (max-width: 768px) {
  .analytics-kpi-card__value { font-size: 1.35rem; }
}

.card-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
  font-size: 1.25rem;
  font-weight: 600;
}

.card-title i { color: var(--accent-color); }

/* ---- Exam / history cards ---- */
.exam-item, .history-item {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--card-border);
  border-radius: 8px;
  padding: 1rem;
  margin-bottom: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  transition: transform 0.2s ease, border-color 0.2s ease;
}

.exam-item:hover, .history-item:hover {
  transform: translateY(-2px);
  border-color: var(--accent-color);
}

.exam-item.selected {
  border-color: var(--accent-color);
  background: rgba(255, 255, 255, 0.05);
}

.exam-header, .history-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.exam-title, .history-title {
  font-weight: 600;
  font-size: 1.05rem;
  color: var(--text-color);
}

.exam-meta, .history-meta {
  display: flex;
  gap: 1rem;
  font-size: 0.85rem;
  color: var(--muted-text);
  flex-wrap: wrap;
}

.exam-actions, .history-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
  justify-content: flex-end;
  align-items: center;
  flex-wrap: wrap;
}

/* ---- Badges & small buttons ---- */
.badge-attempt {
  background: rgba(168, 85, 247, 0.15);
  color: #c084fc;
  border: 1px solid rgba(168, 85, 247, 0.3);
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 500;
}

.badge-limit {
  background: rgba(239, 68, 68, 0.15);
  color: #fca5a5;
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.btn-xs {
  padding: 0.35rem 0.65rem;
  font-size: 0.8rem;
  min-height: auto;
}

.btn-danger-xs {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #fca5a5;
  padding: 0.35rem 0.65rem;
  font-size: 0.8rem;
  min-height: auto;
  border-radius: 4px;
  cursor: pointer;
}

.btn-danger-xs:hover {
  background: #ef4444;
  color: #fff;
}

.toggle-public-btn {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  background: transparent;
  border: 1px solid var(--card-border);
  color: var(--muted-text);
  cursor: pointer;
  border-radius: 4px;
  padding: 0.35rem 0.65rem;
  font-size: 0.8rem;
  transition: all 0.2s;
}

.toggle-public-btn.is-public {
  background: rgba(16, 185, 129, 0.1);
  border-color: rgba(16, 185, 129, 0.3);
  color: #34d399;
}

/* ---- Charts ---- */
.chart-container {
  position: relative;
  width: 100%;
  height: 300px;
}

/* ---- Tabs ---- */
.tab-nav {
  display: flex;
  gap: 0.5rem;
  border-bottom: 1px solid var(--card-border);
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
}

.tab-btn {
  background: transparent;
  border: none;
  color: var(--muted-text);
  padding: 0.5rem 1rem;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  border-radius: 6px;
  transition: all 0.2s;
}

.tab-btn:hover { color: var(--text-color); background: rgba(255, 255, 255, 0.02); }
.tab-btn.active { color: var(--accent-color); background: rgba(168, 85, 247, 0.1); }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* ---- Modals ---- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 2000;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s;
}

.modal-overlay.visible { opacity: 1; visibility: visible; }

.modal-content {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 12px;
  padding: 1.5rem;
  width: 90%;
  max-width: 600px;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
}

.modal-content--wide { max-width: 800px; }

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--card-border);
  padding-bottom: 0.75rem;
  margin-bottom: 1rem;
}

.modal-close {
  background: transparent;
  border: none;
  font-size: 1.5rem;
  color: var(--muted-text);
  cursor: pointer;
}

/* ---- Forms ---- */
.form-group { margin-bottom: 1.25rem; }

.form-group label {
  display: block;
  margin-bottom: 0.5rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted-text);
}

.form-group input,
.form-group textarea,
.form-group select {
  width: 100%;
  padding: 0.75rem;
  border-radius: 8px;
  border: 1px solid var(--card-border);
  background: var(--input-bg);
  color: var(--text-color);
}

.form-group input[type="checkbox"] { width: auto; margin-right: 0.5rem; }

/* ---- Tables ---- */
.admin-table, .leaderboard-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.admin-table th, .admin-table td,
.leaderboard-table th, .leaderboard-table td {
  padding: 0.75rem;
  text-align: left;
  border-bottom: 1px solid var(--card-border);
}

.admin-table th, .leaderboard-table th {
  color: var(--accent-color);
  font-weight: 600;
}

.leaderboard-rank { font-weight: bold; width: 40px; }
.leaderboard-rank-1 { color: #f59e0b; }
.leaderboard-rank-2 { color: #94a3b8; }
.leaderboard-rank-3 { color: #b45309; }

/* ---- Question list (setter) ---- */
.question-list-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem;
  border-bottom: 1px solid var(--card-border);
  font-size: 0.9rem;
  background: rgba(255, 255, 255, 0.01);
}

.question-list-item:hover { background: rgba(255, 255, 255, 0.02); }

.builder-panel {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--card-border);
  border-radius: 8px;
  padding: 1rem;
  margin-bottom: 1.5rem;
}

.builder-panel__title {
  font-weight: 600;
  margin-bottom: 0.75rem;
  color: var(--accent-color);
  font-size: 0.95rem;
}

/* ---- Chunk builder rules ---- */
.chunk-rule-row {
  display: grid;
  grid-template-columns: 1fr 1fr 80px auto;
  gap: 0.5rem;
  align-items: end;
  margin-bottom: 0.75rem;
}

.availability-hint {
  font-size: 0.78rem;
  margin-top: 0.35rem;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.availability-hint--ok { color: #34d399; }
.availability-hint--warn { color: #f59e0b; }
.availability-hint--empty { color: #f87171; }

/* ---- Stats cards ---- */
.stats-summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stats-card {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--card-border);
  padding: 1rem;
  border-radius: 8px;
  text-align: center;
}

.stats-charts-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
}

@media (min-width: 992px) {
  .stats-charts-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (min-width: 769px) and (max-width: 991px) {
  .stats-charts-grid { grid-template-columns: repeat(2, 1fr); }
}

.stats-number {
  font-size: 1.5rem;
  font-weight: bold;
  color: var(--accent-color);
  margin-top: 0.25rem;
}

/* ---- Admin attempt review (QA / grading disputes — admin/editor only) ---- */
.review-item {
  border: 1px solid var(--card-border);
  border-radius: 8px;
  padding: 1rem;
  margin-bottom: 1rem;
  background: rgba(255, 255, 255, 0.01);
}

.review-item.correct { border-left: 4px solid #10b981; }
.review-item.incorrect { border-left: 4px solid #ef4444; }

.review-question { font-weight: 600; margin-bottom: 0.75rem; }

.review-options {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 0.75rem;
}

.review-option {
  padding: 0.5rem;
  border-radius: 4px;
  font-size: 0.9rem;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid transparent;
}

.review-option.selected {
  background: rgba(239, 68, 68, 0.1);
  border-color: rgba(239, 68, 68, 0.3);
  color: #ef4444;
}

.review-option.correct {
  background: rgba(16, 185, 129, 0.1);
  border-color: rgba(16, 185, 129, 0.3);
  color: #34d399;
}

/* ---- Exam-taking (proctored) ---- */
.exam-option {
  padding: 1rem;
  margin: 0.75rem 0;
  border-radius: 8px;
  cursor: pointer;
  background-color: var(--option-bg);
  border: 1px solid var(--card-border);
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 1rem;
  min-height: 60px;
}

.exam-option:hover {
  background-color: var(--option-hover-bg);
  transform: translateY(-1px);
}

.exam-option.selected {
  background-color: var(--option-selected-bg);
  border-color: var(--option-selected-border);
}

.exam-option__marker {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background-color: var(--option-marker-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: bold;
  transition: background-color 0.3s ease;
  flex-shrink: 0;
}

.exam-option.selected .exam-option__marker {
  background-color: var(--option-marker-selected-bg);
  color: #fff;
}

.exam-option__text { flex: 1; font-size: 0.95rem; line-height: 1.5; }

.question-image-container {
  max-width: 100%;
  margin: 1rem 0;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--card-border);
  text-align: center;
}

.question-image-container img { max-width: 100%; max-height: 350px; object-fit: contain; }

/* ---- Exam palette (paged) ---- */
.exam-palette {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  flex-wrap: wrap;
  justify-content: center;
}

.exam-palette__grid {
  display: flex;
  gap: 0.25rem;
  flex-wrap: wrap;
  justify-content: center;
}

.exam-palette__btn {
  min-width: 40px;
  min-height: 40px;
  padding: 0;
  border-radius: 6px;
  border: 1px solid var(--card-border);
  background: var(--option-bg);
  color: var(--text-color);
  cursor: pointer;
  transition: all 0.15s ease;
}

.exam-palette__btn:hover,
.oe-pagination__pages .oe-pagination__btn:hover:not(.oe-pagination__btn--active) { border-color: var(--accent-color); }
.exam-palette__btn.answered,
.oe-pagination__pages .oe-pagination__btn.answered { border-color: rgba(16, 185, 129, 0.6); color: #34d399; }
.exam-palette__btn.active { background: var(--accent-color); border-color: var(--accent-color); color: #fff; }

/* Flagged-for-review indicator: a small corner dot that layers on top of
   the answered/active states rather than replacing their color. */
.exam-palette__btn.flagged,
.oe-pagination__pages .oe-pagination__btn.flagged {
  position: relative;
}
.exam-palette__btn.flagged::after,
.oe-pagination__pages .oe-pagination__btn.flagged::after {
  content: '';
  position: absolute;
  top: -3px;
  right: -3px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #f59e0b;
  border: 1.5px solid var(--card-bg, #1a1a1a);
}

/* ---- Question info bar: flag toggle + answered-progress ---- */
.oe-question-info__row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}

.oe-flag-btn {
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: inherit;
  border-radius: 6px;
  width: 36px;
  height: 36px;
  min-width: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  touch-action: manipulation;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.oe-flag-btn:hover { background: rgba(255, 255, 255, 0.22); }

.oe-flag-btn.is-flagged {
  background: #f59e0b;
  border-color: #f59e0b;
  color: #1a1a1a;
}

.oe-question-info__progress {
  height: 4px;
  background: rgba(255, 255, 255, 0.25);
  border-radius: 2px;
  margin-top: 0.6rem;
  overflow: hidden;
}

.oe-question-info__progress-bar {
  height: 100%;
  background: #fff;
  border-radius: 2px;
  transition: width 0.3s ease;
}

.exam-jump {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.exam-jump input {
  width: 68px;
  padding: 0.4rem 0.5rem;
  border-radius: 6px;
  border: 1px solid var(--card-border);
  background: var(--input-bg);
  color: var(--text-color);
  font-size: 0.85rem;
}

.timer-badge {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.75rem;
  border-radius: 8px;
  background: rgba(168, 85, 247, 0.1);
  border: 1px solid rgba(168, 85, 247, 0.3);
  font-weight: 600;
  color: var(--text-color);
}

.timer-badge.warning {
  background: rgba(239, 68, 68, 0.12);
  border-color: rgba(239, 68, 68, 0.4);
  color: #fca5a5;
  animation: oe-exam-pulse 1.5s infinite;
}

@keyframes oe-exam-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

/* ---- Calculator (oe_exam_mode.html) ---- */
.icon-header-button.is-active {
  background: rgba(168, 85, 247, 0.18);
  border-color: var(--accent-color);
  color: var(--accent-color);
}

.oe-calculator {
  position: fixed;
  z-index: 3500;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Desktop/tablet: floating panel that never covers header/footer controls */
@media (min-width: 769px) {
  .oe-calculator {
    top: 84px;
    right: 1.5rem;
    width: 300px;
    border-radius: 14px;
  }
}

/* Mobile: bottom sheet, matching the audience's primary device */
@media (max-width: 768px) {
  .oe-calculator {
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    max-height: min(78dvh, 560px);
    border-radius: 16px 16px 0 0;
    overflow-y: auto;
    padding-bottom: env(safe-area-inset-bottom, 0);
  }
}

.oe-calculator__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--card-border);
  font-weight: 600;
  color: var(--text-color);
  flex-shrink: 0;
}

.oe-calculator__header i { color: var(--accent-color); margin-right: 0.35rem; }

.oe-calculator__close {
  background: transparent;
  border: none;
  color: var(--muted-text);
  font-size: 1.1rem;
  cursor: pointer;
  width: 32px;
  height: 32px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}
.oe-calculator__close:hover { background: rgba(255, 255, 255, 0.08); color: var(--text-color); }

.oe-calculator__display {
  padding: 0.75rem 1rem;
  text-align: right;
  background: var(--input-bg);
  border-bottom: 1px solid var(--card-border);
  flex-shrink: 0;
}

.oe-calculator__expression {
  font-size: 0.8rem;
  color: var(--muted-text);
  min-height: 1.1em;
  overflow-x: auto;
  white-space: nowrap;
}

.oe-calculator__value {
  font-size: clamp(1.5rem, 6vw, 1.9rem);
  font-weight: 700;
  color: var(--text-color);
  overflow-x: auto;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.oe-calculator__grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.4rem;
  padding: 0.75rem;
}

.oe-calc-btn {
  min-height: 46px;
  border-radius: 8px;
  border: 1px solid var(--card-border);
  background: var(--option-bg);
  color: var(--text-color);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  touch-action: manipulation;
  transition: background 0.12s ease, transform 0.08s ease;
}
.oe-calc-btn:hover { background: var(--option-hover-bg); }
.oe-calc-btn:active { transform: scale(0.94); }

.oe-calc-btn--func {
  font-size: 0.8rem;
  color: var(--accent-color);
  background: rgba(168, 85, 247, 0.08);
}

.oe-calc-btn--op {
  background: var(--accent-color);
  border-color: var(--accent-color);
  color: #fff;
}
.oe-calc-btn--op:hover { filter: brightness(1.12); }

.oe-calc-btn--equals {
  background: linear-gradient(135deg, var(--accent-color), #6366f1);
  border: none;
  color: #fff;
}

.oe-calc-btn--clear {
  color: #f87171;
  border-color: rgba(239, 68, 68, 0.4);
}

.oe-calc-btn--zero { grid-column: span 2; }

@media (max-width: 768px) {
  .oe-calc-btn { min-height: 50px; font-size: 1.05rem; }
  .oe-calc-btn--func { font-size: 0.82rem; }
}

/* ---- Proctored exam shell (oe_exam_mode.html) ---- */
body.oe-proctored {
  -webkit-user-select: none;
  user-select: none;
}

.oe-app--proctored .oe-main__scroll {
  padding: var(--oe-content-pad) 0;
}

.fullscreen-overlay,
.dialog-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 5000;
  padding: max(1rem, env(safe-area-inset-top)) max(1rem, env(safe-area-inset-right)) max(1rem, env(safe-area-inset-bottom)) max(1rem, env(safe-area-inset-left));
}

.fullscreen-overlay {
  background: var(--bg-gradient-start);
}

.dialog-overlay {
  background: rgba(0, 0, 0, 0.8);
  z-index: 4000;
}

.fullscreen-card,
.dialog-box {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 12px;
  padding: clamp(1.25rem, 4vw, 2.5rem);
  width: min(500px, 100%);
  max-width: 100%;
  max-height: min(90dvh, calc(100dvh - 2rem));
  overflow-y: auto;
  text-align: center;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  -webkit-overflow-scrolling: touch;
}

.dialog-box {
  border-color: #ef4444;
  box-shadow: 0 10px 30px rgba(239, 68, 68, 0.2);
}

.dialog-box--neutral {
  border-color: var(--card-border);
  box-shadow: none;
}

.dialog-box--accent {
  border-color: var(--accent-color);
  box-shadow: 0 10px 30px rgba(168, 85, 247, 0.2);
}

.dialog-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.dialog-actions .btn {
  flex: 1 1 8rem;
  min-height: 44px;
}

/* ---- Post-submit results screen ---- */
.oe-results-hero {
  text-align: center;
  padding: 2rem 1rem;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--card-border);
}

.oe-results-hero.pass { border-color: rgba(16, 185, 129, 0.4); }
.oe-results-hero.fail { border-color: rgba(239, 68, 68, 0.4); }

.oe-results-hero__score {
  font-size: clamp(2.5rem, 8vw, 3.5rem);
  font-weight: 800;
  line-height: 1;
  background: linear-gradient(135deg, var(--accent-color), #6366f1);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.oe-results-hero__grade {
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  margin-top: 0.25rem;
}

.oe-results-hero.pass .oe-results-hero__grade { color: #34d399; }
.oe-results-hero.fail .oe-results-hero__grade { color: #f87171; }

.oe-results-hero__meta {
  display: flex;
  justify-content: center;
  gap: 1.5rem;
  margin-top: 1rem;
  font-size: 0.9rem;
  color: var(--muted-text);
  flex-wrap: wrap;
}

.oe-results-hero__meta i { color: var(--accent-color); margin-right: 0.35rem; }

.oe-results-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
  margin-top: 1.5rem;
  flex-wrap: wrap;
}

.oe-results-actions .btn {
  margin: 0;
  min-height: 44px;
  flex: 1 1 200px;
  max-width: 260px;
}

@media (max-width: 768px) {
  .oe-results-hero { padding: 1.5rem 1rem; }
  .oe-results-hero__meta { gap: 1rem; font-size: 0.85rem; }
  .oe-results-actions .btn { flex: 1 1 100%; max-width: none; }
}

/* ---- Dashboard welcome / key entry ---- */
.exam-welcome-card {
  align-items: center;
}

.exam-key-row {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  width: 100%;
  max-width: 400px;
  justify-self: stretch;
}

.exam-key-row input {
  flex: 1;
  padding: 0.75rem;
  border-radius: 8px;
  border: 1px solid var(--card-border);
  background: var(--input-bg);
  color: var(--text-color);
  min-height: 44px;
}

.exam-key-row .btn {
  margin-top: 0;
  min-height: 44px;
  width: 100%;
}

@media (min-width: 480px) {
  .exam-key-row {
    flex-direction: row;
    justify-self: end;
  }

  .exam-key-row .btn {
    width: auto;
    flex-shrink: 0;
  }
}

/* ---- Responsive: phones & small tablets ---- */
@media (max-width: 768px) {
  .grid-container,
  .analytics-grid {
    gap: 1rem;
  }

  .card-title {
    font-size: 1.1rem;
    flex-wrap: wrap;
  }

  .exam-header,
  .history-header {
    flex-direction: column;
    gap: 0.35rem;
    align-items: flex-start;
  }

  .exam-actions,
  .history-actions {
    justify-content: flex-start;
    width: 100%;
  }

  .tab-nav {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
    scrollbar-width: none;
    gap: 0.35rem;
    padding-bottom: 0.25rem;
  }

  .tab-nav::-webkit-scrollbar {
    display: none;
  }

  .tab-btn {
    flex-shrink: 0;
    padding: 0.5rem 0.75rem;
    font-size: 0.85rem;
    white-space: nowrap;
  }

  .chunk-rule-row {
    grid-template-columns: 1fr;
    gap: 0.65rem;
  }

  .chart-container {
    height: min(260px, 45vw);
    min-height: 200px;
  }

  .modal-content {
    width: min(600px, calc(100vw - 1.5rem));
    max-height: min(88dvh, calc(100dvh - env(safe-area-inset-top) - env(safe-area-inset-bottom) - 1.5rem));
    padding: 1.15rem;
    margin: 0.75rem;
  }

  .modal-header h2 {
    font-size: 1.15rem !important;
  }

  .question-list-item {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }

  .stats-summary-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  /* Proctored exam footer: compact palette + nav */
  .oe-app--proctored .oe-footer {
    padding-top: 0.5rem;
    padding-bottom: calc(0.5rem + var(--oe-safe-bottom));
  }

  .oe-app--proctored .oe-footer__inner {
    gap: 0.5rem;
  }

  .exam-palette {
    flex-direction: column;
    align-items: stretch;
    gap: 0.4rem;
  }

  .exam-palette__grid {
    flex-wrap: nowrap;
    overflow-x: auto;
    justify-content: flex-start;
    max-width: 100%;
    padding: 0.15rem 0;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
    scrollbar-width: none;
  }

  .exam-palette__grid::-webkit-scrollbar {
    display: none;
  }

  .exam-palette__btn {
    min-width: 38px;
    min-height: 38px;
    flex-shrink: 0;
  }

  .exam-jump {
    justify-content: center;
    width: 100%;
  }

  .exam-option {
    padding: 0.85rem;
    min-height: 52px;
    gap: 0.75rem;
  }

  .exam-option__text {
    font-size: 0.9rem;
    word-break: break-word;
  }

  .question-image-container img {
    max-height: min(280px, 40vh);
  }

  .oe-app--proctored .oe-footer__copyright {
    font-size: 0.68rem;
    line-height: 1.3;
  }

  .timer-badge {
    font-size: 0.82rem;
    padding: 0.35rem 0.55rem;
    gap: 0.35rem;
  }
}

/* ---- iPad / tablet landscape ---- */
@media (min-width: 769px) and (max-width: 1024px) {
  .analytics-grid {
    grid-template-columns: 1fr;
  }

  .chart-container {
    height: 280px;
  }

  .chunk-rule-row {
    grid-template-columns: 1fr 1fr;
  }

  .chunk-rule-row > :nth-child(3),
  .chunk-rule-row > :nth-child(4) {
    grid-column: span 1;
  }
}

@media (max-width: 380px) {
  .exam-palette__btn {
    min-width: 34px;
    min-height: 34px;
    font-size: 0.78rem;
  }

  .stats-summary-grid {
    grid-template-columns: 1fr;
  }
}

/* ================================================================
 *  SETTER COLLAPSIBLE SIDEBAR
 *  All rules scoped to .grid-container--setter / .setter-sidebar
 *  so dashboard & exam-mode pages are unaffected.
 * ================================================================ */

/* --- Viewport-filling static card layout ---
 * Prevents page-level scrolling. The grid fills the available viewport
 * height and each panel scrolls independently (like question bank). */
.oe-main__scroll:has(.grid-container--setter) {
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.oe-main__scroll:has(.grid-container--setter) .oe-main__inner {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.grid-container--setter {
  flex: 1;
  min-height: 0;
  align-items: stretch;
}

/* Sidebar: internal scroll on the exam list */
.setter-sidebar .setter-sidebar__content {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.setter-sidebar #examsListContainer {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  scrollbar-width: none; /* Firefox */
  -ms-overflow-style: none; /* IE and Edge */
}
.setter-sidebar #examsListContainer::-webkit-scrollbar {
  display: none; /* Chrome, Safari, Opera */
}

/* Workspace: tab nav stays pinned, content scrolls */
.setter-workspace {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.setter-workspace #workspaceContent {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  scrollbar-width: none; /* Firefox */
  -ms-overflow-style: none; /* IE and Edge */
  padding-right: 0;
}
.setter-workspace #workspaceContent::-webkit-scrollbar {
  display: none; /* Chrome, Safari, Opera */
}

/* Remove the old fixed max-heights since we now flex-fill */
.setter-workspace #assignedQuestionsList {
  max-height: none;
  overflow-y: visible;
}

.setter-workspace #qbSearchResults {
  max-height: 220px;
}

/* --- Transition on the grid itself --- */
@media (min-width: 992px) {
  .grid-container--setter {
    transition: grid-template-columns 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  }
  .grid-container--setter.collapsed {
    grid-template-columns: 52px 1fr;
  }
}

/* --- Sidebar wrapper (left panel) --- */
.setter-sidebar {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;                     /* allow grid to shrink it */
  overflow: hidden;
}

/* --- Rail: slim strip visible when collapsed --- */
.setter-sidebar__rail {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0.75rem 0;
  gap: 1rem;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.25s ease, visibility 0.25s ease;
  z-index: 1;
}

.setter-sidebar__rail-btn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  border: 1px solid var(--card-border);
  background: rgba(255, 255, 255, 0.03);
  color: var(--accent-color);
  cursor: pointer;
  font-size: 1rem;
  transition: all 0.2s;
  flex-shrink: 0;
}
.setter-sidebar__rail-btn:hover {
  background: rgba(168, 85, 247, 0.15);
  border-color: var(--accent-color);
}

.setter-sidebar__rail-title {
  writing-mode: vertical-rl;
  text-orientation: mixed;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted-text);
  letter-spacing: 0.03em;
  max-height: calc(100% - 100px);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* --- Full content: hidden when collapsed --- */
.setter-sidebar__content {
  flex: 1;
  min-width: 0;
  opacity: 1;
  visibility: visible;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}

/* --- Collapsed state (desktop only via grid breakpoint) --- */
.grid-container--setter.collapsed .setter-sidebar__rail {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}
.grid-container--setter.collapsed .setter-sidebar__content {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

/* --- Workspace panel (right side) --- */
.setter-workspace {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* --- Expand toggle in header (visible in full/expanded sidebar) --- */
.setter-sidebar__collapse-btn {
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  border: 1px solid var(--card-border);
  background: transparent;
  color: var(--muted-text);
  cursor: pointer;
  font-size: 0.8rem;
  transition: all 0.2s;
  flex-shrink: 0;
}
.setter-sidebar__collapse-btn:hover {
  background: rgba(168, 85, 247, 0.1);
  color: var(--accent-color);
  border-color: var(--accent-color);
}

/* --- Mobile: overlay drawer approach (< 992px) --- */
@media (max-width: 991px) {
  .grid-container--setter {
    position: relative;
  }

  /* On mobile the sidebar is always full-width in normal flow */
  .setter-sidebar__rail { display: none; }

  /* Mobile collapsed: hide the entire sidebar panel */
  .grid-container--setter.collapsed .setter-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: min(380px, 85vw);
    height: 100dvh;
    z-index: 1500;
    background: var(--card-bg);
    border-right: 1px solid var(--card-border);
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.4);
    padding: 1rem;
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow-y: auto;
  }

  .grid-container--setter.collapsed .setter-sidebar.drawer-open {
    transform: translateX(0);
  }

  .grid-container--setter.collapsed .setter-sidebar__content {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
  }

  /* Backdrop overlay */
  .setter-sidebar__backdrop {
    display: none;
  }
  .grid-container--setter.collapsed .setter-sidebar__backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1499;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
  }
  .grid-container--setter.collapsed .setter-sidebar.drawer-open + .setter-sidebar__backdrop,
  .grid-container--setter.collapsed .setter-sidebar__backdrop.visible {
    opacity: 1;
    pointer-events: auto;
  }

  /* Mobile FAB to open the drawer */
  .setter-mobile-fab {
    display: none;
  }
  .grid-container--setter.collapsed .setter-mobile-fab {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    position: fixed;
    bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
    left: 1rem;
    z-index: 1498;
    padding: 0.6rem 1rem;
    border-radius: 12px;
    border: 1px solid rgba(168, 85, 247, 0.4);
    background: var(--card-bg);
    color: var(--accent-color);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    transition: all 0.2s;
  }
  .grid-container--setter.collapsed .setter-mobile-fab:hover {
    background: rgba(168, 85, 247, 0.15);
  }
}

/* Desktop: hide mobile-only elements */
@media (min-width: 992px) {
  .setter-mobile-fab { display: none !important; }
  .setter-sidebar__backdrop { display: none !important; }
}

/* --- Tablet tweaks (769px - 991px) --- */
@media (min-width: 769px) and (max-width: 991px) {
  .grid-container--setter.collapsed .setter-sidebar {
    width: min(340px, 75vw);
  }
}
