/* ─── RESET & TOKENS ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --navy:       #0284c7;
  --navy-mid:   #0ea5e9;
  --navy-light: #38bdf8;
  --gold:       #38bdf8;
  --gold-dark:  #0ea5e9;
  --gold-light: #7dd3fc;
  --bg:         #f0f9ff;
  --white:      #ffffff;
  --card-sh:    0 2px 12px rgba(0,0,0,.08);
  --card-sh-h:  0 6px 24px rgba(0,0,0,.14);
  --red:        #dc3545;
  --green:      #28a745;
  --purple:     #6f42c1;
  --orange:     #fd7e14;
  --txt:        #1a1a2e;
  --txt-muted:  #666;
  --border:     #e2e4ea;
  --radius:     10px;
  --radius-sm:  6px;
  --transition: .2s ease;
}

html { scroll-behavior: smooth; zoom: 1.25; }
body {
  font-family: 'Montserrat', system-ui, sans-serif;
  background: var(--bg);
  color: var(--txt);
  min-height: 100vh;
  line-height: 1.6;
}

a { text-decoration: none; color: inherit; }
ul { list-style: none; }
button { cursor: pointer; font-family: inherit; border: none; outline: none; }
img { display: block; max-width: 100%; }

/* ─── SCROLLBAR ──────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: #ccc; border-radius: 3px; }

/* ─── NAVBAR ──────────────────────────────────────────────────────────── */
.navbar {
  position: sticky; top: 0; z-index: 100;
  background: var(--white);
  box-shadow: 0 1px 12px rgba(0,0,0,.05);
  border-bottom: 1px solid var(--border);
}
.nav-inner {
  max-width: 1200px; margin: 0 auto;
  padding: 0 24px;
  height: 56px;
  display: flex; align-items: center; gap: 32px;
}
.logo {
  display: flex; align-items: center; gap: 8px;
  flex-shrink: 0;
}
.logo-icon { width: 28px; height: 28px; }
.logo-text {
  font-size: 1.4rem; font-weight: 700; color: var(--gold);
  letter-spacing: -.5px;
}
.logo-text em { font-style: normal; }

.nav-links {
  display: flex; align-items: center; gap: 6px; margin-left: auto;
}
.nav-link {
  padding: 6px 14px; border-radius: 20px;
  font-size: .875rem; font-weight: 500; color: var(--txt);
  transition: var(--transition);
}
.nav-link:hover { color: var(--navy); }
.nav-link.active {
  background: var(--navy); color: var(--white);
}
.nav-right {
  display: flex; align-items: center; gap: 10px; margin-left: 16px;
}
.nav-variate {
  font-size: .875rem; font-weight: 600; color: var(--txt); cursor: pointer;
}
.nav-hamburger {
  display: none; background: none; font-size: 1.4rem; color: var(--navy);
}

/* ─── PAGE WRAPPER ───────────────────────────────────────────────────── */
.page { max-width: 1200px; margin: 0 auto; padding: 32px 24px 64px; }
.page-sm { max-width: 860px; margin: 0 auto; padding: 32px 24px 64px; }

/* ─── LOADING ────────────────────────────────────────────────────────── */
.loading-screen {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; min-height: 60vh; gap: 16px; color: var(--txt-muted);
}
.spinner {
  width: 40px; height: 40px; border: 3px solid var(--border);
  border-top-color: var(--gold); border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── HOME – SUBJECTS GRID ───────────────────────────────────────────── */
.subjects-header {
  margin-bottom: 28px;
}
.subjects-header h1 {
  font-size: 1.6rem; font-weight: 700; color: var(--navy); margin-bottom: 8px;
}
.subjects-header p { font-size: .9rem; color: var(--txt-muted); max-width: 540px; }
.subjects-header p a { color: var(--gold); }

.subjects-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 24px; flex-wrap: wrap; gap: 12px;
}
.authority-select {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 16px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); background: var(--white);
  font-size: .875rem; color: var(--txt-muted);
  cursor: pointer;
}
.authority-select select {
  border: none; background: none; font-family: inherit;
  font-size: .875rem; color: var(--txt); cursor: pointer;
  appearance: none; outline: none;
}
.filter-icon { font-size: .85rem; }

.subjects-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(185px, 1fr));
  gap: 20px;
}
.subject-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.05);
  overflow: hidden;
  display: flex; flex-direction: column;
  transition: box-shadow var(--transition), transform var(--transition);
  cursor: pointer;
}
.subject-card:hover {
  box-shadow: var(--card-sh-h); transform: translateY(-3px);
}
.subject-card-img {
  width: 100%; height: 130px; object-fit: cover;
}
.subject-card-img-placeholder {
  width: 100%; height: 130px;
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-light) 100%);
  display: flex; align-items: center; justify-content: center;
  font-size: 2rem;
}
.subject-card-body {
  padding: 12px 14px 16px; flex: 1; display: flex; flex-direction: column;
}
.subject-card-title {
  font-size: .95rem; font-weight: 700; color: var(--navy); margin-bottom: 4px;
}
.subject-card-cat {
  font-size: .78rem; color: var(--gold); font-weight: 500; margin-bottom: 14px;
}
.subject-card-btn {
  display: block; width: 100%;
  padding: 8px; text-align: center;
  background: var(--gold); color: var(--white);
  border-radius: var(--radius-sm); font-size: .85rem; font-weight: 600;
  transition: background var(--transition);
  margin-top: auto;
}
.subject-card-btn:hover { background: var(--gold-dark); }

/* ─── BACK LINK ──────────────────────────────────────────────────────── */
.back-link {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: .9rem; color: var(--txt); margin-bottom: 24px;
  font-weight: 500;
}
.back-link:hover { color: var(--navy); }
.breadcrumb {
  font-size: .9rem; color: var(--txt); margin-bottom: 24px;
  font-weight: 500; display: flex; align-items: center; gap: 6px;
}
.breadcrumb a { color: var(--txt); }
.breadcrumb a:hover { color: var(--navy); }
.breadcrumb .sep { color: var(--txt-muted); }
.breadcrumb .cur { color: var(--navy); }

/* ─── BOOK TABS ──────────────────────────────────────────────────────── */
.book-tabs {
  display: flex; border-radius: var(--radius-sm); overflow: hidden;
  border: 1px solid var(--navy); margin-bottom: 28px; background: var(--navy);
}
.book-tab {
  flex: 1; padding: 12px 8px; text-align: center;
  font-size: .78rem; font-weight: 600; letter-spacing: .5px;
  text-transform: uppercase; cursor: pointer;
  color: rgba(255,255,255,.65);
  transition: var(--transition);
  background: var(--navy);
  border-right: 1px solid rgba(255,255,255,.12);
}
.book-tab:last-child { border-right: none; }
.book-tab.active {
  background: var(--white); color: var(--gold);
}
.book-tab:hover:not(.active) { color: var(--white); }

/* ─── CHAPTERS PAGE ──────────────────────────────────────────────────── */
.page-title {
  font-size: 1.4rem; font-weight: 700; color: var(--navy); margin-bottom: 24px;
}
.chapter-list { display: flex; flex-direction: column; gap: 10px; }
.chapter-btn {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px; background: var(--navy); color: var(--white);
  border-radius: var(--radius-sm); font-size: .9rem; font-weight: 500;
  cursor: pointer; text-align: left;
  transition: background var(--transition);
  border: none; width: 100%;
}
.chapter-btn:hover { background: var(--navy-mid); }
.chapter-btn .chap-count {
  font-size: .78rem; color: rgba(255,255,255,.55); white-space: nowrap; margin-left: 12px;
}
.chapter-btn .chap-arrow { color: rgba(255,255,255,.4); font-size: .8rem; margin-left: 8px; }

/* ─── TRAINING MODE QUESTIONS ────────────────────────────────────────── */
.chapter-heading {
  text-align: center; font-size: 1.1rem; font-weight: 700;
  color: var(--gold); letter-spacing: 1px; text-transform: uppercase;
  margin-bottom: 28px;
}
.question-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--card-sh);
  margin-bottom: 16px; overflow: hidden;
}
.question-header {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 14px 18px; background: var(--navy); color: var(--white);
}
.question-num {
  min-width: 26px; height: 26px; border-radius: 50%;
  background: var(--gold); color: var(--navy);
  display: flex; align-items: center; justify-content: center;
  font-size: .78rem; font-weight: 700; flex-shrink: 0; margin-top: 1px;
}
.question-text { font-size: .9rem; font-weight: 500; line-height: 1.5; }
.question-body { padding: 14px 18px; }
.option-label {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 8px 10px; border-radius: var(--radius-sm);
  cursor: pointer; font-size: .875rem; line-height: 1.5;
  transition: background var(--transition);
  margin-bottom: 4px;
}
.option-label:hover { background: var(--bg); }
.option-label input[type="radio"] {
  margin-top: 3px; accent-color: var(--navy); flex-shrink: 0;
}
.option-label.correct { color: var(--gold); font-weight: 500; }
.option-label.correct input { accent-color: var(--gold); }
.option-label.selected-wrong { color: var(--red); }
.option-label.selected-correct { color: var(--green); font-weight: 600; }
.explanation-box {
  margin: 12px 0 0; padding: 10px 14px;
  background: #f0f7ff; border-left: 3px solid var(--navy);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: .83rem; color: #334; line-height: 1.55;
  display: none;
}
.explanation-box.visible { display: block; }

/* ─── TEST RULES ─────────────────────────────────────────────────────── */
.rules-section { margin-bottom: 24px; }
.rules-section h2 {
  font-size: 1rem; font-weight: 700; color: var(--navy); margin-bottom: 10px;
}
.rules-info-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 6px;
  font-size: .875rem; margin-bottom: 8px;
}
.rules-info-row { display: flex; gap: 6px; }
.rules-info-row .label { color: var(--txt); font-weight: 500; }
.rules-info-row .value { color: var(--txt-muted); }
.rules-info-row .value a { color: var(--gold); }
.rules-list { list-style: disc; padding-left: 20px; font-size: .875rem; color: var(--txt); }
.rules-list li { margin-bottom: 4px; }
.rules-num-title {
  color: var(--gold); font-weight: 600; font-size: .875rem; margin: 10px 0 4px;
}
.rules-confirm {
  font-weight: 600; font-size: .875rem; margin: 20px 0 20px;
  border-top: 1px solid var(--border); padding-top: 18px;
}
.btn-start {
  display: block; margin: 0 auto;
  padding: 12px 36px; background: var(--navy);
  color: var(--gold); font-size: 1rem; font-weight: 700;
  border-radius: var(--radius-sm); border: 2px solid var(--gold);
  transition: var(--transition);
}
.btn-start:hover { background: var(--navy-mid); }

/* ─── TEST MODE ──────────────────────────────────────────────────────── */
.test-header {
  margin-bottom: 20px;
}
.test-title {
  font-size: 1.1rem; font-weight: 700; color: var(--navy); margin-bottom: 16px;
}
.question-palette {
  display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px;
}
.palette-btn {
  width: 34px; height: 34px; border-radius: var(--radius-sm);
  font-size: .78rem; font-weight: 600;
  background: var(--white); color: var(--txt);
  border: 1px solid var(--border);
  transition: var(--transition);
  cursor: pointer;
}
.palette-btn.current { background: var(--navy); color: var(--white); border-color: var(--navy); }
.palette-btn.answered { background: #d4edda; color: #155724; border-color: #c3e6cb; }
.palette-btn.flagged { background: #fff3cd; color: #856404; border-color: #ffc107; }
.palette-btn.skipped { background: #f8d7da; color: #721c24; border-color: #f5c6cb; }
.palette-btn.answered.flagged { background: #ffeeba; color: #856404; border-color: #ffc107; }

.timer-bar {
  display: flex; align-items: center; gap: 8px;
  font-size: .95rem; font-weight: 600; margin-bottom: 20px;
}
.timer-label { color: var(--txt); }
.timer-value { color: var(--gold); font-size: 1rem; }
.timer-value.warning { color: var(--red); }

.test-question-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--card-sh);
  overflow: hidden; margin-bottom: 20px;
}
.test-question-header {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 14px 18px; background: var(--white);
  border-bottom: 1px solid var(--border);
}
.test-question-num {
  min-width: 28px; height: 28px; border-radius: 50%;
  background: var(--navy); color: var(--white);
  display: flex; align-items: center; justify-content: center;
  font-size: .78rem; font-weight: 700; flex-shrink: 0;
}
.test-question-text { font-size: .9rem; font-weight: 500; line-height: 1.55; }
.test-question-body { padding: 14px 18px; }
.test-option {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 10px 12px; border-radius: var(--radius-sm);
  cursor: pointer; font-size: .875rem; line-height: 1.5;
  margin-bottom: 6px; border: 1px solid var(--border);
  transition: border-color var(--transition), background var(--transition);
}
.test-option:hover { border-color: var(--navy); background: #f9faff; }
.test-option.selected { border-color: var(--navy); background: #eef1fa; }
.test-option input[type="radio"] { margin-top: 3px; accent-color: var(--navy); flex-shrink: 0; }

.test-nav-bar {
  display: flex; gap: 10px; flex-wrap: wrap; align-items: center;
  padding: 16px 0;
}
.btn { padding: 9px 22px; border-radius: var(--radius-sm); font-size: .875rem; font-weight: 600; transition: var(--transition); }
.btn-prev { background: #e9ecef; color: var(--txt); }
.btn-prev:hover:not(:disabled) { background: #dde1e7; }
.btn-prev:disabled { opacity: .45; cursor: not-allowed; }
.btn-next { background: var(--navy); color: var(--white); }
.btn-next:hover { background: var(--navy-mid); }
.btn-reset { background: var(--red); color: var(--white); }
.btn-reset:hover { background: #c82333; }
.btn-skip { background: var(--white); color: var(--txt); border: 1px solid var(--border); }
.btn-skip:hover { border-color: var(--navy); }
.btn-flag { background: #856404; color: var(--white); }
.btn-flag:hover { background: #6d5203; }
.btn-flag.flagged-active { background: #ffc107; color: #333; }
.btn-submit { background: var(--green); color: var(--white); margin-left: auto; }
.btn-submit:hover { background: #218838; }

/* ─── RESULTS ────────────────────────────────────────────────────────── */
.results-card {
  border-radius: var(--radius); padding: 24px;
  margin-bottom: 20px; border: 1px solid transparent;
}
.results-card.pass { background: #d4edda; border-color: #c3e6cb; }
.results-card.fail { background: #f8d7da; border-color: #f5c6cb; }
.results-badge {
  display: flex; align-items: center; gap: 12px; margin-bottom: 16px;
}
.badge-icon {
  width: 40px; height: 40px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem;
}
.badge-icon.pass { background: var(--green); color: var(--white); }
.badge-icon.fail { background: var(--red); color: var(--white); }
.badge-title { font-size: 1.2rem; font-weight: 700; }
.badge-score { font-size: .85rem; color: var(--txt-muted); }
.results-stats {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px;
  margin-bottom: 16px;
}
.stat-box {
  background: var(--white); border-radius: var(--radius-sm);
  padding: 12px; text-align: center;
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
}
.stat-icon { font-size: .8rem; color: var(--txt-muted); margin-bottom: 4px; }
.stat-label { font-size: .75rem; color: var(--txt-muted); margin-bottom: 4px; }
.stat-value { font-size: 1.4rem; font-weight: 700; color: var(--navy); }
.stat-sub { font-size: .75rem; color: var(--txt-muted); }
.perf-bar-row {
  display: flex; align-items: center; gap: 12px;
}
.perf-label { font-size: .875rem; font-weight: 600; }
.perf-pct { font-size: .875rem; font-weight: 700; margin-left: auto; }
.perf-bar-track {
  flex: 1; height: 8px; background: rgba(0,0,0,.1); border-radius: 4px; overflow: hidden;
}
.perf-bar-fill { height: 100%; border-radius: 4px; background: var(--green); transition: width .8s ease; }

.accordion {
  background: var(--navy); border-radius: var(--radius-sm);
  margin-bottom: 10px; overflow: hidden;
}
.accordion-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px; color: var(--white); cursor: pointer;
  font-size: .9rem; font-weight: 600;
}
.accordion-toggle { font-size: 1.1rem; }
.accordion-body {
  background: var(--white); padding: 20px;
  display: none; font-size: .875rem; line-height: 1.7;
}
.accordion-body.open { display: block; }
.accordion-body p { margin-bottom: 6px; }
.accordion-body .highlight { color: var(--gold); font-weight: 600; }
.accordion-body .fail-text { color: var(--red); font-weight: 600; }

.answer-review-item {
  padding: 12px 0; border-bottom: 1px solid var(--border);
}
.answer-review-item:last-child { border-bottom: none; }
.answer-q { font-weight: 600; margin-bottom: 6px; color: var(--navy); font-size: .875rem; }
.answer-row { display: flex; gap: 8px; font-size: .83rem; margin-bottom: 3px; }
.answer-row .lbl { color: var(--txt-muted); min-width: 90px; }
.answer-row .val-correct { color: var(--green); font-weight: 500; }
.answer-row .val-wrong { color: var(--red); font-weight: 500; }
.answer-row .val-skip { color: var(--txt-muted); font-style: italic; }

/* ─── UTILITY ────────────────────────────────────────────────────────── */
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.text-center { text-align: center; }
.text-muted { color: var(--txt-muted); font-size: .875rem; }
.divider { height: 1px; background: var(--border); margin: 20px 0; }
.tag-coming-soon {
  display: inline-block; padding: 2px 8px;
  background: #fff3cd; color: #856404; font-size: .7rem; font-weight: 600;
  border-radius: 20px; margin-left: 6px; vertical-align: middle;
}

/* ─── RESPONSIVE ─────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .nav-links { display: none; }
  .nav-links.open {
    display: flex; flex-direction: column; position: absolute;
    top: 56px; left: 0; right: 0; background: var(--white);
    padding: 16px 24px; box-shadow: 0 4px 12px rgba(0,0,0,.1);
    z-index: 99;
  }
  .nav-hamburger { display: block; }
  .subjects-grid { grid-template-columns: repeat(auto-fill, minmax(155px, 1fr)); }
  .results-stats { grid-template-columns: repeat(2, 1fr); }
  .test-nav-bar { gap: 7px; }
  .btn { padding: 8px 14px; font-size: .8rem; }
  .btn-submit { margin-left: 0; }
}
@media (max-width: 480px) {
  .page, .page-sm { padding: 20px 14px 48px; }
  .subjects-grid { grid-template-columns: repeat(2, 1fr); }
  .results-stats { grid-template-columns: 1fr 1fr; }
  .book-tab { font-size: .68rem; padding: 10px 4px; }
}
