/* ═══════════════════════════════════════════════
   25-Day Exam Prep — Style
   Public: #3b82f6 | Mechanical: #f59e0b | Done: #10b981
   ═══════════════════════════════════════════════ */

:root {
  --blue: #3b82f6;
  --blue-bg: #eff6ff;
  --blue-light: #bfdbfe;
  --amber: #f59e0b;
  --amber-bg: #fffbeb;
  --amber-light: #fde68a;
  --green: #10b981;
  --green-bg: #ecfdf5;
  --green-light: #a7f3d0;
  --red: #ef4444;
  --red-bg: #fef2f2;
  --red-light: #fecaca;
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --gray-900: #111827;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md: 0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
  --transition: 0.2s ease;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: "PingFang SC", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  font-size: 15px; line-height: 1.65; color: var(--gray-800);
  background: var(--gray-50); min-height: 100vh;
}

a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Nav ─────────────────────── */
nav {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 20px; background: #fff; border-bottom: 1px solid var(--gray-200);
  position: sticky; top: 0; z-index: 200;
}
nav a { font-weight: 600; font-size: 16px; }
nav span { color: var(--gray-500); font-size: 14px; margin-left: auto; }

/* ── Main ────────────────────── */
main { max-width: 1100px; margin: 0 auto; padding: 24px 20px 60px; }

/* For chapter pages with sidebar, main expands full-width */
body:has(.chapter-layout) main { max-width: none; margin: 0; padding: 24px 0 60px 0; }

/* ═══════════ HOMEPAGE ═══════════ */

.hero { text-align: center; padding: 32px 0 20px; }
.hero h1 { font-size: 28px; font-weight: 700; color: var(--gray-900); }
.hero .subtitle { font-size: 15px; color: var(--gray-500); margin-top: 6px; }

.overall-progress { max-width: 400px; margin: 20px auto 0; }
.overall-progress .progress-bar { height: 10px; border-radius: 5px; background: var(--gray-200); overflow: hidden; }
.overall-progress .fill { height: 100%; border-radius: 5px; background: linear-gradient(90deg, var(--blue), var(--green)); transition: width 0.5s ease; }
.overall-progress .progress-text { display: block; text-align: center; font-size: 13px; color: var(--gray-500); margin-top: 6px; }

.subject-summary { display: flex; gap: 16px; margin: 24px 0; flex-wrap: wrap; }
.subject-card { flex: 1; min-width: 220px; padding: 18px 20px; border-radius: var(--radius); box-shadow: var(--shadow); display: block; text-decoration: none; transition: all var(--transition); }
.subject-card:hover { transform: translateY(-2px); box-shadow: 0 6px 16px rgba(0,0,0,.1); }
.subject-card.public { border-left: 4px solid var(--blue); }
.subject-card.mechanical { border-left: 4px solid var(--amber); }
.subject-card h3 { font-size: 17px; margin-bottom: 4px; color: var(--gray-800); }
.subject-card p { font-size: 13px; color: var(--gray-500); margin-bottom: 6px; }
.card-hint { font-size: 12px; color: var(--blue); }
.mini-progress { height: 6px; border-radius: 3px; background: var(--gray-200); overflow: hidden; }
.mini-progress .fill { height: 100%; border-radius: 3px; transition: width 0.5s ease; }
.public .mini-progress .fill { background: var(--blue); }
.mechanical .mini-progress .fill { background: var(--amber); }

.day-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(185px, 1fr)); gap: 14px; margin: 24px 0; }

.day-card {
  display: flex; flex-direction: column; gap: 6px; position: relative;
  padding: 16px; border-radius: var(--radius); border: 2px solid var(--gray-200);
  background: #fff; transition: all var(--transition); overflow: hidden;
}
.day-card:hover { border-color: var(--blue); box-shadow: var(--shadow-md); transform: translateY(-2px); }
.day-card.checked { border-color: var(--green); background: var(--green-bg); }
.day-card.weekend::after {
  content: ''; position: absolute; top: 0; right: 0; width: 0; height: 0;
  border-style: solid; border-width: 0 24px 24px 0;
  border-color: transparent var(--gray-200) transparent transparent;
}
.day-card.weekend.checked::after { border-color: transparent var(--green-light) transparent transparent; }

.day-num { font-size: 22px; font-weight: 700; color: var(--gray-800); }
.day-date { font-size: 12px; color: var(--gray-400); }
.day-subjects { display: flex; gap: 6px; flex-wrap: wrap; }
.tag { font-size: 11px; padding: 2px 8px; border-radius: 10px; font-weight: 500; }
.tag.public { background: var(--blue-bg); color: var(--blue); }
.tag.mechanical { background: var(--amber-bg); color: #b45309; }
.day-focus { font-size: 12px; color: var(--gray-500); line-height: 1.5; }
.check-mark {
  position: absolute; bottom: 8px; right: 10px; font-size: 18px;
  opacity: 0; transition: opacity var(--transition);
}
.day-card.checked .check-mark { opacity: 1; }

.key-numbers { margin: 32px 0; }
.key-numbers h2 { font-size: 20px; margin-bottom: 14px; }
.key-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 12px; }
.key-block h3 { font-size: 15px; margin-bottom: 8px; color: var(--gray-700); }
.key-item { display: flex; justify-content: space-between; align-items: center; padding: 8px 12px; background: #fff; border-radius: 6px; box-shadow: var(--shadow); font-size: 13px; }
.key-item .value { font-weight: 700; color: var(--blue); white-space: nowrap; }

/* ═══════════ DAY PAGE ═══════════ */

.day-header { margin-bottom: 20px; }
.day-header h1 { font-size: 26px; font-weight: 700; }
.back-link { font-size: 14px; color: var(--gray-500); display: inline-block; margin-bottom: 8px; }
.back-link:hover { color: var(--blue); text-decoration: none; }

.exam-info { display: flex; gap: 20px; flex-wrap: wrap; font-size: 13px; color: var(--gray-600); margin-bottom: 16px; }
.ticket-pending { color: var(--gray-500); }
.ticket-ready { color: #059669; font-weight: 600; }
.ticket-ended { color: #991b1b; }

.chapter-meta { font-size: 13px; color: var(--gray-500); margin-bottom: 16px; }
.chapter-section { margin-bottom: 32px; padding-bottom: 24px; border-bottom: 1px solid var(--gray-150); }
.chapter-section .section-header h2 { font-size: 20px; color: var(--gray-800); font-weight: 700; }

/* Chapter TOC sidebar */
.chapter-layout { position: relative; }
.chapter-toc {
  position: fixed; left: 0; top: 55px; bottom: 0; z-index: 100;
  width: 220px; overflow-y: auto;
  padding: 16px 12px; border-right: 1px solid var(--gray-200);
  background: var(--gray-50);
}
.chapter-toc h3 { font-size: 15px; margin-bottom: 10px; color: var(--gray-800); }
.chapter-toc ul { list-style: none; padding: 0; margin: 0; }
.chapter-toc li { margin-bottom: 8px; }
.chapter-toc a {
  font-size: 13px; color: var(--gray-600); text-decoration: none;
  display: block; padding: 4px 8px; border-radius: 4px;
  transition: all var(--transition);
  word-break: break-all; line-height: 1.4;
}
.chapter-toc a:hover, .chapter-toc a.active { color: var(--blue); background: var(--blue-bg); }
.toc-stat { display: block; font-size: 11px; margin-top: 2px; padding: 0 8px; }
.toc-c { color: #059669; }
.toc-w { color: #991b1b; margin-left: 4px; }
.toc-u { color: var(--gray-400); margin-left: 4px; }
.toc-bar-fill { height: 3px; border-radius: 2px; background: var(--blue); transition: width .3s; margin: 2px 8px 0; }
.chapter-main { margin: 0 auto; padding: 0 24px 0 256px; max-width: 1200px; min-width: 0; }

@media (max-width: 900px) {
  .chapter-toc { position: static; width: 100%; max-height: 200px; border-right: none; border-bottom: 1px solid var(--gray-200); }
  .chapter-toc ul { display: flex; flex-wrap: wrap; gap: 4px; }
  .chapter-toc li { margin-bottom: 0; }
  .chapter-main { margin: 0; padding: 0 16px; }
}

.review-section { margin-bottom: 32px; border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.section-header { padding: 16px 20px; color: #fff; }
.section-header.public { background: var(--blue); }
.section-header.mechanical { background: #92400e; }
.section-header h2 { font-size: 18px; display: flex; align-items: center; gap: 8px; }
.time-badge { font-size: 12px; font-weight: 400; background: rgba(255,255,255,.2); padding: 2px 10px; border-radius: 10px; }
.chapter-tags { font-size: 13px; margin-top: 4px; opacity: .85; }
.review-body { padding: 20px; background: #fff; font-size: 14px; line-height: 1.8; }
.review-body h1, .review-body h2, .review-body h3, .review-body h4 { color: var(--gray-800); margin: 16px 0 10px; }
.review-body h1 { font-size: 20px; } .review-body h2 { font-size: 17px; } .review-body h3 { font-size: 15px; }
.review-body p { margin: 6px 0; }
.review-body ul, .review-body ol { padding-left: 20px; margin: 8px 0; }
.review-body li { margin: 4px 0; }
.review-body blockquote { border-left: 3px solid var(--blue); margin: 12px 0; padding: 8px 14px; background: var(--blue-bg); border-radius: 0 6px 6px 0; }
.review-body code { background: var(--gray-100); padding: 1px 5px; border-radius: 3px; font-size: 13px; }
.review-body strong { color: var(--blue); }
.review-body img { max-width: 100%; border-radius: 6px; margin: 8px 0; }

/* ── Quiz Container ──────────── */
.quiz-container { padding: 0 20px 20px; background: #fff; }
.quiz-header { padding: 14px 0; border-top: 1px solid var(--gray-200); }
.quiz-header h3 { font-size: 16px; margin-bottom: 10px; }
.quiz-controls { display: flex; gap: 8px; margin-bottom: 10px; }
.mode-btn {
  font-size: 13px; padding: 6px 14px; border: 1.5px solid var(--gray-300);
  border-radius: 16px; background: #fff; cursor: pointer; color: var(--gray-600);
  transition: all var(--transition); font-family: inherit;
}
.mode-btn:hover { border-color: var(--blue); color: var(--blue); }
.mode-btn.active { background: var(--blue); color: #fff; border-color: var(--blue); }
.quiz-progress { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.quiz-progress .progress-bar { flex: 1; height: 8px; border-radius: 4px; background: var(--gray-200); overflow: hidden; }
.quiz-progress .fill { height: 100%; border-radius: 4px; background: var(--green); transition: width 0.3s ease; }
.quiz-progress .count { font-size: 13px; color: var(--gray-500); white-space: nowrap; }

/* ── Question ────────────────── */
.question { padding: 16px 0; border-bottom: 1px solid var(--gray-100); }
.question:last-child { border-bottom: none; }
.q-header { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.q-num { font-weight: 700; color: var(--gray-800); font-size: 14px; }
.q-type { font-size: 11px; padding: 1px 7px; border-radius: 8px; font-weight: 500; }
.q-type.single { background: var(--blue-bg); color: var(--blue); }
.q-type.multi { background: #fef3c7; color: #b45309; }
.q-type.judgment { background: var(--green-bg); color: #059669; }
.q-section { font-size: 11px; color: var(--gray-400); }
.q-stem { font-size: 14px; line-height: 1.7; margin-bottom: 10px; color: var(--gray-800); }
.q-stem p { margin: 4px 0; }
.q-options { display: flex; flex-direction: column; gap: 6px; }

.option {
  display: block; text-align: left; padding: 10px 14px; border: 1.5px solid var(--gray-200);
  border-radius: 8px; background: #fff; cursor: pointer; font-size: 14px; line-height: 1.6;
  font-family: inherit; color: var(--gray-700); transition: all var(--transition);
}
.option:hover { border-color: var(--blue); background: var(--blue-bg); }
.option.selected { border-color: var(--blue); background: var(--blue-bg); outline: 2px solid var(--blue); outline-offset: -2px; }
.option.correct { border-color: var(--green); background: var(--green-bg); color: #065f46; }
.option.wrong { border-color: var(--red); background: var(--red-bg); color: #991b1b; }
.question.answered .option { pointer-events: none; cursor: default; }
.question.answered .option:not(.correct):not(.wrong):hover { background: #fff; border-color: var(--gray-200); }

/* Reset buttons */
.reset-bar {
  display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap;
}
.reset-btn {
  font-size: 12px; padding: 5px 14px;
  border: 1.5px solid var(--gray-300); border-radius: 6px;
  background: #fff; cursor: pointer; font-family: inherit;
  color: var(--gray-600); transition: all var(--transition);
}
.reset-btn:hover { border-color: var(--red); color: var(--red); background: var(--red-bg); }

.q-result { display: none; align-items: center; gap: 6px; margin-top: 10px; font-size: 14px; font-weight: 600; }
.q-result.visible { display: flex; }
.result-icon { font-size: 18px; }
.q-analysis {
  display: none;
  margin-top: 8px; padding: 10px 14px; background: var(--gray-50);
  border-radius: 6px; font-size: 13px; line-height: 1.7; color: var(--gray-600);
  border-left: 3px solid var(--blue);
}

.submit-multi {
  margin-top: 0.5rem;
  padding: 0.25rem 1rem;
  border: 1px solid var(--gray-300);
  border-radius: 4px;
  background: var(--color-bg, #fff);
  cursor: pointer;
}
.submit-multi:hover {
  background: var(--blue);
  color: white;
}

/* Single mode navigation */
.single-nav { display: none; justify-content: center; align-items: center; gap: 12px; margin: 16px 0; }
.single-nav.visible { display: flex; }
.single-nav button {
  font-size: 13px; padding: 7px 18px; border: 1.5px solid var(--gray-300);
  border-radius: 6px; background: #fff; cursor: pointer; font-family: inherit;
  transition: all var(--transition);
}
.single-nav button:hover { border-color: var(--blue); color: var(--blue); }
.single-nav button:disabled { opacity: .4; cursor: not-allowed; }
.single-nav .qn-indicator { font-size: 13px; color: var(--gray-500); }

/* ── Check-in ────────────────── */
.checkin-section { text-align: center; padding: 32px 0; }
.checkin-btn {
  font-size: 17px; padding: 14px 48px; border: none; border-radius: 30px;
  background: linear-gradient(135deg, var(--blue), #6366f1); color: #fff;
  cursor: pointer; font-weight: 600; font-family: inherit; box-shadow: var(--shadow-md);
  transition: all var(--transition);
}
.checkin-btn:hover { transform: translateY(-1px); box-shadow: 0 6px 12px rgba(59,130,246,.3); }
.checkin-btn:active { transform: scale(0.97); }
.checkin-btn.done { background: var(--green); cursor: default; }
.checkin-btn.done:active { transform: none; }
.checkin-status { margin-top: 10px; font-size: 13px; color: var(--gray-500); }

/* ── Figure grid ──────────────── */
.figure-heading {
  font-size: 15px; font-weight: 600; color: var(--gray-700);
  margin: 24px 0 12px; padding-bottom: 6px;
  border-bottom: 1.5px solid var(--gray-200);
}
.figure-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin: 8px 0 16px;
}
.figure-grid figure {
  margin: 0; text-align: center;
}
.figure-grid figure img {
  max-width: 100%; height: auto;
  border: 1px solid var(--gray-200);
  border-radius: 6px;
}
.figure-grid figcaption {
  margin-top: 6px;
  font-size: 13px; color: var(--gray-500);
  line-height: 1.5;
}

/* ── Responsive ──────────────── */
@media (max-width: 768px) {
  main { padding: 16px 12px 40px; }
  .hero h1 { font-size: 22px; }
  .day-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
  .subject-summary { flex-direction: column; }
  .review-body { padding: 14px; font-size: 13px; }
  .day-card { padding: 12px; }
  .key-grid { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
  .day-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
  .day-num { font-size: 18px; }
  .checkin-btn { padding: 12px 32px; font-size: 15px; }
}

@media print {
  nav, .checkin-section, .quiz-controls, .quiz-progress, .single-nav { display: none; }
  .question.answered .q-result, .question.answered .q-analysis { display: block !important; }
}
