@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

html {
  font-size: 15px;
  position: relative;
  min-height: 100%;
}

@media (min-width: 768px) {
  html { font-size: 16px; }
}

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: #f0f2f8;
  color: #1a1a2e;
}

.app-navbar {
  background: linear-gradient(135deg, #1e3a5f 0%, #0f2744 100%) !important;
}

.page-header h1,
.hero-title {
  font-weight: 800;
  color: #16213e;
}

/* Hero */
.hero-banner {
  background: linear-gradient(135deg, #1e3a5f 0%, #2563eb 100%);
  color: #fff;
  border-radius: 1rem;
  padding: 2rem 2.25rem;
  box-shadow: 0 8px 32px rgba(30, 58, 95, 0.25);
}

.hero-title {
  color: #fff;
  font-size: 1.85rem;
  margin-bottom: 0.35rem;
}

.hero-sub {
  color: rgba(255,255,255,0.85);
  font-size: 1rem;
}

.section-title {
  font-weight: 700;
  font-size: 1.1rem;
  color: #334155;
}

/* Stats */
.stat-card {
  background: #fff;
  border-radius: 0.85rem;
  padding: 1.35rem 1rem;
  text-align: center;
  box-shadow: 0 2px 12px rgba(0,0,0,0.06);
  border: 1px solid #e8ecf4;
  height: 100%;
  position: relative;
}

.stat-icon {
  font-size: 1.25rem;
  color: #94a3b8;
  margin-bottom: 0.35rem;
  display: block;
}

.stat-value {
  font-size: 1.65rem;
  font-weight: 800;
  color: #1e3a5f;
  line-height: 1.2;
}

.stat-label {
  font-size: 0.72rem;
  color: #6c757d;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 0.3rem;
  font-weight: 600;
}

.stat-success .stat-value { color: #198754; }
.stat-success .stat-icon { color: #198754; }
.stat-info .stat-value { color: #0d6efd; }
.stat-info .stat-icon { color: #0d6efd; }
.stat-danger .stat-value { color: #dc3545; }
.stat-danger .stat-icon { color: #dc3545; }
.stat-muted .stat-value { color: #6c757d; }

/* Subject tiles */
.subject-tile {
  display: block;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 0.85rem;
  padding: 1.5rem 1.25rem;
  color: inherit;
  transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
  height: 100%;
  position: relative;
  overflow: hidden;
}

.subject-tile::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 4px;
  background: var(--tile-color, #0d6efd);
}

.subject-tile:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 28px rgba(30, 58, 95, 0.14);
  border-color: var(--tile-color, #0d6efd);
  color: inherit;
}

.subject-tile-icon {
  width: 3rem;
  height: 3rem;
  border-radius: 0.75rem;
  background: color-mix(in srgb, var(--tile-color, #0d6efd) 12%, white);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 0.85rem;
}

.subject-tile-icon i {
  font-size: 1.5rem;
  color: var(--tile-color, #0d6efd);
}

.subject-tile-title {
  font-weight: 700;
  font-size: 1.1rem;
  color: #1e293b;
  margin-bottom: 0.2rem;
}

.subject-tile-count {
  font-size: 0.85rem;
  color: #64748b;
}

.subject-tile-arrow {
  position: absolute;
  right: 1rem;
  top: 50%;
  transform: translateY(-50%);
  color: #cbd5e1;
  font-size: 1.25rem;
  transition: color 0.2s, transform 0.2s;
}

.subject-tile:hover .subject-tile-arrow {
  color: var(--tile-color, #0d6efd);
  transform: translateY(-50%) translateX(3px);
}

.test-promo-card {
  background: linear-gradient(145deg, #fff 0%, #eef4ff 100%);
  border: 1px solid #c7d9f5 !important;
}

/* Chapter cards */
.chapter-card {
  display: block;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 0.65rem;
  padding: 1rem 1.15rem;
  color: inherit;
  transition: border-color 0.15s, box-shadow 0.15s;
  height: 100%;
}

.chapter-card:hover {
  border-color: #0d6efd;
  box-shadow: 0 4px 12px rgba(13, 110, 253, 0.1);
  color: inherit;
}

.chapter-title {
  font-weight: 600;
  color: #1e3a5f;
  margin-bottom: 0.35rem;
}

.chapter-meta {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  color: #6c757d;
}

/* Questions */
.paper-card {
  border: none;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.paper-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 0.5rem 1.25rem rgba(0, 0, 0, 0.1) !important;
}

.paper-meta {
  border: none;
  background: linear-gradient(135deg, #ffffff 0%, #f0f4ff 100%);
}

.question-card {
  border: none;
  overflow: hidden;
}

.question-header {
  background: #fff;
  border-bottom: 1px solid #e9ecef;
  padding: 0.75rem 1.25rem;
}

.question-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.5rem;
  height: 2rem;
  padding: 0 0.6rem;
  background: #1e3a5f;
  color: #fff;
  font-weight: 700;
  font-size: 0.85rem;
  border-radius: 0.375rem;
}

.source-badge {
  background: #fff3cd;
  color: #856404;
  font-size: 0.75rem;
  padding: 0.25rem 0.5rem;
  border-radius: 0.25rem;
}

.question-text {
  font-size: 1.05rem;
  line-height: 1.7;
  color: #212529;
  white-space: pre-wrap;
}

.options-grid {
  display: grid;
  gap: 0.75rem;
}

@media (min-width: 768px) {
  .options-grid {
    grid-template-columns: 1fr 1fr;
  }
}

.option-item {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  background: #f8f9fb;
  border: 1px solid #e2e6ea;
  border-radius: 0.5rem;
  transition: background 0.15s;
}

.option-item:hover {
  background: #eef2ff;
  border-color: #c7d2fe;
}

.option-correct {
  background: #d1e7dd !important;
  border-color: #a3cfbb !important;
}

.option-wrong {
  background: #f8d7da !important;
  border-color: #f1aeb5 !important;
}

.option-label {
  flex-shrink: 0;
  width: 1.75rem;
  height: 1.75rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #fff;
  border: 2px solid #6c757d;
  border-radius: 50%;
  font-weight: 700;
  font-size: 0.8rem;
  color: #495057;
}

.option-label-correct {
  background: #198754;
  border-color: #198754;
  color: #fff;
}

.option-label-wrong {
  background: #dc3545;
  border-color: #dc3545;
  color: #fff;
}

.option-text {
  flex: 1;
  line-height: 1.6;
  padding-top: 0.1rem;
  white-space: pre-wrap;
}

.answer-block {
  padding: 0.75rem 1rem;
  background: #f8f9fa;
  border-radius: 0.5rem;
  border-left: 4px solid #198754;
}

.answer-pill {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  border-radius: 2rem;
  font-weight: 600;
  font-size: 0.9rem;
}

.answer-pill.correct {
  background: #d1e7dd;
  color: #0f5132;
}

.explanation-box {
  margin-top: 0.5rem;
  padding-top: 0.5rem;
  border-top: 1px dashed #dee2e6;
  color: #495057;
}

/* Image vs auto-SVG compare panels */
.diagram-compare {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin: 1rem 0;
  padding: 0.75rem;
  border: 1px solid #d8dee9;
  border-radius: 0.5rem;
  background: #fafbfc;
}

@media (max-width: 768px) {
  .diagram-compare {
    grid-template-columns: 1fr;
  }
}

.diagram-compare-col {
  min-width: 0;
  background: #fff;
  border: 1px solid #e9ecef;
  border-radius: 0.375rem;
  padding: 0.65rem;
}

.diagram-compare-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #6c757d;
  margin-bottom: 0.5rem;
}

.diagram-compare-status {
  font-size: 0.72rem;
  margin-bottom: 0.5rem;
  padding: 0.25rem 0.5rem;
  border-radius: 0.25rem;
  background: #f1f3f5;
  color: #495057;
}

.diagram-compare-ok .diagram-compare-status {
  background: #d1e7dd;
  color: #0f5132;
}

.diagram-compare-approx .diagram-compare-status {
  background: #cff4fc;
  color: #055160;
}

.diagram-compare-approx {
  border-color: #9eeaf9;
}

.diagram-compare-fail .diagram-compare-status {
  background: #fff3cd;
  color: #664d03;
}

.diagram-original-body img,
.diagram-original-body picture img {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 0 auto;
  max-height: 42vh;
}

.diagram-svg-canvas {
  display: block;
  margin: 0 auto;
  max-height: 42vh;
  background: #fff;
}

.diagram-svg-placeholder {
  min-height: 120px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 1rem;
  border: 1px dashed #ced4da;
  border-radius: 0.375rem;
  background: #f8f9fa;
}

.tex-content mjx-container {
  font-size: 108% !important;
}

.footer {
  background: #fff;
}

/* ── Mock Test Setup ── */
.setup-form .setup-label {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #64748b;
  margin-bottom: 0.4rem;
}

.setup-hint {
  font-size: 0.78rem;
  color: #94a3b8;
}

.setup-section {
  margin-top: 1.75rem;
  padding-top: 1.75rem;
  border-top: 1px solid #e8ecf4;
}

.setup-section:first-of-type {
  border-top: none;
  padding-top: 0;
}

.setup-top-row {
  display: grid;
  grid-template-columns: 1fr 10rem;
  gap: 1.25rem;
  align-items: start;
}

@media (max-width: 576px) {
  .setup-top-row {
    grid-template-columns: 1fr;
  }
}

.setup-field .setup-hint {
  display: block;
  margin-top: 0.35rem;
}

.filter-section-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.filter-actions {
  display: flex;
  gap: 0.4rem;
  flex-shrink: 0;
}

/* Year grid — fixed equal columns */
.year-chip-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 0.5rem;
  padding: 1rem;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 0.75rem;
}

@media (max-width: 992px) {
  .year-chip-grid { grid-template-columns: repeat(5, 1fr); }
}
@media (max-width: 768px) {
  .year-chip-grid { grid-template-columns: repeat(4, 1fr); }
}
@media (max-width: 480px) {
  .year-chip-grid { grid-template-columns: repeat(3, 1fr); }
}

.source-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 1rem;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 0.75rem;
}

/* Chapter grid — uniform rows */
.chapter-chip-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
  max-height: 320px;
  overflow-y: auto;
  padding: 0.25rem 0.35rem 0.25rem 0;
  scrollbar-width: thin;
  scrollbar-color: #cbd5e1 transparent;
}

.chapter-chip-grid::-webkit-scrollbar {
  width: 6px;
}

.chapter-chip-grid::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 3px;
}

@media (max-width: 1200px) {
  .chapter-chip-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 576px) {
  .chapter-chip-grid { grid-template-columns: 1fr; }
}

/* Checkbox chips */
.checkbox-chip {
  position: relative;
  display: inline-flex;
  margin: 0;
  cursor: pointer;
  user-select: none;
  vertical-align: top;
}

.checkbox-chip-block {
  display: block;
  width: 100%;
  min-width: 0;
}

.checkbox-chip-input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}

.checkbox-chip-text {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  min-height: 2.6rem;
  padding: 0.5rem 0.8rem;
  font-size: 0.84rem;
  font-weight: 600;
  color: #334155;
  background: #fff;
  border: 1.5px solid #d6deea;
  border-radius: 0.55rem;
  transition: border-color 0.15s, background 0.15s, color 0.15s, box-shadow 0.15s;
  line-height: 1.25;
  box-sizing: border-box;
}

/* Tick box — the clear "this is selectable" indicator */
.chip-check {
  flex-shrink: 0;
  width: 1.15rem;
  height: 1.15rem;
  border: 2px solid #c2ccdb;
  border-radius: 0.3rem;
  background: #fff;
  position: relative;
  transition: all 0.15s ease;
}

.chip-check::after {
  content: "";
  position: absolute;
  left: 0.32rem;
  top: 0.12rem;
  width: 0.3rem;
  height: 0.6rem;
  border: solid #fff;
  border-width: 0 2.5px 2.5px 0;
  transform: rotate(45deg) scale(0);
  transition: transform 0.15s ease;
}

.checkbox-chip-chapter .checkbox-chip-text {
  min-height: 2.85rem;
  padding: 0.55rem 0.75rem;
  font-size: 0.8rem;
  font-weight: 500;
  text-align: left;
}

.checkbox-chip-subject .checkbox-chip-text {
  font-size: 0.92rem;
  font-weight: 700;
  padding: 0.6rem 1.1rem;
  min-height: 2.7rem;
  white-space: nowrap;
}

.chip-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Years are centered numbers — keep tick + number tight */
.year-chip-grid .chip-label {
  flex: 0 1 auto;
}
.year-chip-grid .checkbox-chip-text {
  justify-content: center;
}

.chip-count {
  flex-shrink: 0;
  min-width: 1.75rem;
  text-align: center;
  font-size: 0.68rem;
  font-weight: 700;
  padding: 0.15rem 0.45rem;
  background: #eef2f7;
  color: #64748b;
  border-radius: 1rem;
  line-height: 1.2;
}

/* Hover — clearly interactive */
.checkbox-chip:hover .checkbox-chip-text {
  border-color: #93c5fd;
  background: #f5f9ff;
}
.checkbox-chip:hover .chip-check {
  border-color: #60a5fa;
}

/* Selected — soft blue fill + filled tick (NOT a heavy solid block) */
.checkbox-chip:has(.checkbox-chip-input:checked) .checkbox-chip-text {
  background: #eff5ff;
  border-color: #2563eb;
  color: #1e40af;
  box-shadow: inset 0 0 0 1px #2563eb;
}

.checkbox-chip:has(.checkbox-chip-input:checked) .chip-check {
  background: #2563eb;
  border-color: #2563eb;
}

.checkbox-chip:has(.checkbox-chip-input:checked) .chip-check::after {
  transform: rotate(45deg) scale(1);
}

.checkbox-chip:has(.checkbox-chip-input:checked) .chip-count {
  background: #dbe7fe;
  color: #1e40af;
}

.checkbox-chip:has(.checkbox-chip-input:focus-visible) .checkbox-chip-text {
  outline: 2px solid #60a5fa;
  outline-offset: 2px;
}

/* Subject cards */
.subject-setup-card {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 0.75rem;
  margin-bottom: 0.85rem;
  overflow: hidden;
}

.subject-setup-card:last-child {
  margin-bottom: 0;
}

.subject-toolbar {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 1rem 1.25rem;
  padding: 0.9rem 1.1rem;
  background: #fafbfc;
}

@media (max-width: 992px) {
  .subject-toolbar {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }
}

.subject-stats {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
  justify-content: center;
}

@media (max-width: 992px) {
  .subject-stats { justify-content: flex-start; }
}

.subject-controls {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-shrink: 0;
  justify-content: flex-end;
}

@media (max-width: 992px) {
  .subject-controls { justify-content: flex-start; }
}

.stat-pill {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.25rem 0.6rem;
  background: #fff;
  color: #64748b;
  border-radius: 1rem;
  border: 1px solid #e2e8f0;
  white-space: nowrap;
}

.numerical-pct-wrap {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin: 0;
}

.numerical-pct-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: #64748b;
  white-space: nowrap;
}

.numerical-pct-wrap .num-pct-input {
  width: 3.25rem;
  text-align: center;
  font-weight: 700;
  padding: 0.25rem 0.35rem;
}

.chapter-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  white-space: nowrap;
}

.chapter-toggle.active {
  background: #2563eb;
  border-color: #2563eb;
  color: #fff;
}

.chapter-pick-panel {
  padding: 1rem 1.1rem 1.1rem;
  background: #fff;
  border-top: 1px solid #e8ecf4;
}

/* Test */
.filter-grid {
  max-height: 200px;
  overflow-y: auto;
  padding: 0.5rem;
  background: #f8f9fb;
  border-radius: 0.5rem;
  border: 1px solid #e9ecef;
}

.test-toolbar {
  z-index: 1020;
  top: 0.5rem;
}

.question-palette .palette-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  font-size: 0.75rem;
  font-weight: 600;
  border: 1px solid #dee2e6;
  border-radius: 0.35rem;
  background: #fff;
  color: #495057;
  text-decoration: none;
}

.question-palette .palette-btn.answered {
  background: #cfe2ff;
  border-color: #0d6efd;
  color: #0d6efd;
}

.subject-heading {
  color: #1e3a5f;
  border-bottom: 2px solid #0d6efd;
  padding-bottom: 0.35rem;
  margin-bottom: 1rem;
}

.test-options {
  display: grid;
  gap: 0.5rem;
}

.test-option {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background: #f8f9fb;
  border: 2px solid #e2e6ea;
  border-radius: 0.5rem;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  margin: 0;
}

.test-option:has(input:checked) {
  border-color: #0d6efd;
  background: #eef4ff;
}

.test-option input {
  margin-top: 0.35rem;
  flex-shrink: 0;
}

.score-ring {
  background: #fff;
  border-radius: 1rem;
  box-shadow: 0 4px 20px rgba(0,0,0,0.08);
}

.score-main {
  font-size: 3rem;
  font-weight: 800;
  line-height: 1;
}

.score-denom {
  font-size: 1.5rem;
  font-weight: 500;
  color: #6c757d;
}

.review-correct { border-left: 4px solid #198754; }
.review-wrong { border-left: 4px solid #dc3545; }
.review-skip { border-left: 4px solid #adb5bd; }

.exam-timer {
  font-weight: 700;
  font-size: 1.1rem;
  color: #1e3a5f;
  background: #e8f0fe;
  padding: 0.35rem 0.85rem;
  border-radius: 0.5rem;
  border: 1px solid #c7d8f7;
}

.exam-timer-warning {
  color: #dc3545 !important;
  background: #fde8e8 !important;
  border-color: #f5c2c7 !important;
  animation: timer-pulse 1s ease-in-out infinite;
}

@keyframes timer-pulse {
  50% { opacity: 0.75; }
}

.elapsed-timer {
  color: #64748b;
  font-weight: 600;
}

.bookmark-btn {
  line-height: 1;
  padding: 0.2rem 0.45rem;
}

.bookmark-form {
  vertical-align: middle;
}

.trend-chart {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.trend-row {
  display: grid;
  grid-template-columns: 72px 1fr 48px 36px;
  align-items: center;
  gap: 0.5rem;
}

.trend-label {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.trend-bar-wrap {
  background: #eef1f6;
  border-radius: 4px;
  height: 10px;
  overflow: hidden;
}

.trend-bar {
  height: 100%;
  border-radius: 4px;
  min-width: 2px;
  transition: width 0.3s ease;
}

.trend-bar-good { background: #198754; }
.trend-bar-mid { background: #ffc107; }
.trend-bar-low { background: #dc3545; }

.trend-value {
  font-weight: 700;
  font-size: 0.85rem;
  text-align: right;
}

.trend-link {
  font-size: 0.75rem;
}

.mini-bar {
  border-radius: 3px 3px 0 0;
}

/* Dashboard guide */
.guide-card .guide-item {
  padding: 0.75rem 0;
}

.guide-item-highlight {
  background: #f8f9fc;
  border-radius: 0.75rem;
  padding: 1rem 1.15rem !important;
  height: 100%;
}

.guide-item h3 {
  font-weight: 600;
  margin-bottom: 0.5rem;
}
