:root {
  --ink: #1e293b;
  --muted: #64748b;
  --primary: #991b1b;
  --primary-light: #fef2f2;
  --border: #e2e8f0;
  --bg: #fcfaf2;
  --sidebar-bg: #eceae0;

  --header-h: 60px;
  --sidebar-w: 280px;

  --serif: "Source Serif 4", Georgia, serif;
  --sans: "Inter", system-ui, sans-serif;
  --mono: "Fira Code", monospace;
}

* {
  box-sizing: border-box;
}

/* Custom Selection Highlight */
::selection {
  background: #fee2e2;
  color: #991b1b;
}

body {
  margin: 0;
  font-family: var(--sans);
  color: var(--ink);
  background: var(--bg);
  line-height: 1.6;
  height: 100vh;
  overflow: hidden;
  /* Prevent body scroll */
}

/* --- LAYOUT STRUCTURE --- */
.app-container {
  display: flex;
  height: 100vh;
  padding-top: var(--header-h);
}

/* Fixed Header */
.header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-h);
  background: rgba(255, 255, 255, 0.95);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  z-index: 1000;
  backdrop-filter: blur(8px);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.last-updated {
  font-size: 12px;
  color: var(--muted);
}

.menu-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
  flex-direction: column;
  gap: 4px;
  z-index: 1001;
}

.hamburger {
  display: block;
  width: 24px;
  height: 2px;
  background: var(--ink);
  position: relative;
  transition: all 0.3s;
}

.hamburger::before,
.hamburger::after {
  content: '';
  position: absolute;
  width: 24px;
  height: 2px;
  background: var(--ink);
  left: 0;
  transition: all 0.3s;
}

.hamburger::before {
  top: -8px;
}

.hamburger::after {
  bottom: -8px;
}

.menu-open .hamburger {
  background: transparent;
}

.menu-open .hamburger::before {
  transform: rotate(45deg);
  top: 0;
}

.menu-open .hamburger::after {
  transform: rotate(-45deg);
  bottom: 0;
}

.brand {
  font-weight: 700;
  font-size: 18px;
  display: flex;
  gap: 12px;
  align-items: baseline;
  cursor: pointer;
}

.brand span {
  color: var(--muted);
  font-weight: 400;
  font-size: 14px;
}

/* Fixed Sidebar (Accordion Style) */
.sidebar {
  width: var(--sidebar-w);
  height: 100%;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 24px 0 100px 0;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
}

.nav-group {
  border-bottom: 1px solid transparent;
}

/* Accordion Header */
.nav-header {
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  padding: 12px 24px;
  font-family: var(--sans);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  font-weight: 700;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: background 0.1s;
}

.nav-header:hover {
  background: #f1f5f9;
  color: var(--ink);
}

.nav-header::after {
  content: '›';
  font-size: 14px;
  transform: rotate(90deg);
  transition: transform 0.2s;
  color: var(--primary);
}

.nav-group.collapsed .nav-header::after {
  transform: rotate(0deg);
}

/* Nested Navigation Styling */
.sub-nav-header {
  padding-left: 32px;
  background: rgba(0, 0, 0, 0.02);
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.sub-nav-header:hover {
  background: rgba(0, 0, 0, 0.05);
}

.nav-links-container .nav-links-container {
  background: rgba(0, 0, 0, 0.02);
  border-left: 2px solid var(--border);
  margin-left: 24px;
}

/* Mobile Sidebar State */
.sidebar.mobile-open {
  transform: translateX(0);
}

/* Accordion Content */
.nav-links-container {
  display: block;
  padding-bottom: 12px;
}

.nav-group.collapsed .nav-links-container {
  display: none;
}

.nav-item {
  display: block;
  padding: 10px 24px 10px 32px;
  /* Indented slightly */
  color: var(--ink);
  text-decoration: none;
  font-size: 14px;
  border-left: 3px solid transparent;
  cursor: pointer;
  min-height: 44px;
  /* Ensure accessible tap target */
  display: flex;
  align-items: center;
}

.nav-item:hover {
  background: #e2e8f0;
}

.nav-item.active {
  background: var(--primary-light);
  color: var(--primary);
  border-left-color: var(--primary);
  font-weight: 600;
}

/* Sub-items (further indented) */
.nav-sub {
  display: block;
  padding: 8px 24px 8px 48px;
  font-size: 13px;
  color: var(--muted);
  text-decoration: none;
  cursor: pointer;
  min-height: 44px;
  /* Ensure accessible tap target */
  display: flex;
  align-items: center;
}

.nav-sub:hover {
  color: var(--ink);
}

/* Main Content Area */
.main {
  flex: 1;
  padding: 0;
  /* Reset padding to allow full-width footer */
  max-width: 100%;
  overflow-y: auto;
  /* Scroll ONLY content */
  display: flex;
  flex-direction: column;
}

.content-container {
  max-width: 800px;
  margin: 0 auto;
  padding: 48px 64px 60px;
  /* Padding inside the text area */
  flex: 1;
  /* Pushes footer down */
}

/* Content Sections (SPA Behavior) */
.content-section {
  display: none;
  /* Hidden by default */
  animation: fadeIn 0.4s ease;
}

.content-section.active {
  display: block;
  /* Show active */
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(15px) scale(0.98);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* --- TYPOGRAPHY & ELEMENTS --- */
h1,
h2 {
  color: #0f172a;
  margin-top: 0;
}

h3 {
  color: var(--primary);
  margin-top: 0;
}

h1 {
  font-family: var(--serif);
  font-size: 32px;
  margin-bottom: 16px;
}

h2 {
  font-family: var(--serif);
  font-size: 28px;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 12px;
}

h3 {
  font-size: 18px;
  font-weight: 600;
  margin-top: 32px;
  margin-bottom: 12px;
}

p {
  margin-bottom: 16px;
  line-height: 1.7;
}

/* Custom HR */
hr.custom-hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 32px 0;
}

/* Title Page / Intro Styling */
.title-page {
  text-align: center;
  padding-top: 60px;
}

.tp-title {
  font-family: var(--serif);
  font-size: 48px;
  font-weight: 700;
  color: #0f172a;
  margin-bottom: 16px;
  line-height: 1.2;
}

.tp-subtitle {
  font-size: 20px;
  color: var(--muted);
  margin-bottom: 48px;
  font-weight: 400;
}

.tp-author {
  font-size: 16px;
  font-weight: 600;
  color: var(--ink);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.tp-divider {
  width: 60px;
  height: 4px;
  background: var(--primary);
  margin: 32px auto;
}

/* Prologue Styling */
.prologue {
  background: #fdfdfd;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 24px 32px;
  margin-bottom: 48px;
  font-family: var(--serif);
  font-size: 17px;
  color: #334155;
  line-height: 1.7;
}

.signature {
  margin-top: 16px;
  font-weight: 700;
  font-family: var(--sans);
  font-size: 14px;
  color: var(--ink);
}

/* Reference Boxes */
.ref-box {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  margin: 24px 0;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
  /* Lively shadow */
}

.ref-title {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 700;
  color: var(--muted);
  margin-bottom: 12px;
}

.ref-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
}

.ref-item strong {
  display: block;
  font-size: 13px;
  margin-bottom: 4px;
}

.ref-item span {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--primary);
}

/* Practice Problems */
.problem-list {
  list-style: none;
  padding: 0;
  counter-reset: prob;
}

.problem-item {
  margin-bottom: 24px;
  padding-left: 32px;
  position: relative;
}

.problem-item::before {
  counter-increment: prob;
  content: counter(prob) ".";
  position: absolute;
  left: 0;
  top: 0;
  font-weight: 600;
  color: var(--muted);
}

/* Reveal/Answer Mechanism */
.reveal-row {
  margin-top: 8px;
  display: flex;
  align-items: baseline;
  gap: 12px;
}

/* Quiz Button */
.quiz-button-container {
  display: flex;
  justify-content: center;
  margin-top: 48px;
  margin-bottom: 24px;
}

.quiz-btn {
  display: inline-block;
  background: var(--primary);
  color: white;
  padding: 16px 32px;
  border-radius: 50px;
  text-decoration: none;
  font-weight: 600;
  font-size: 16px;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  transition: all 0.2s;
  letter-spacing: 0.02em;
}

.quiz-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.2);
  background: #1e293b;
  /* fallback for primary-dark if not defined */
}

.btn-reveal {
  background: none;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 8px 16px;
  /* Increased for mobile-friendliness */
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
}

.btn-reveal:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.answer {
  display: none;
  font-family: var(--serif);
  font-size: 15px;
  color: #334155;
  background: #ecfdf5;
  padding: 4px 12px;
  border-radius: 4px;
}

/* Footer Styling */
.doc-footer {
  width: 100%;
  background: #ffffff;
  padding: 32px 64px;
  border-top: 1px solid var(--border);
  margin-top: auto;
  /* Pushes to bottom if content is short */
}

.footer-content {
  max-width: 800px;
  margin: 0 auto;
  font-family: var(--sans);
  font-size: 12px;
  color: var(--muted);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.footer-links a {
  color: var(--muted);
  text-decoration: none;
  margin-left: 16px;
  transition: color 0.1s;
}

.footer-links a:hover {
  color: var(--primary);
}

/* Print Styles */
@media print {
  body {
    height: auto;
    overflow: visible;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .header,
  .sidebar,
  .btn-reveal {
    display: none;
  }

  .app-container {
    padding: 0;
    display: block;
    height: auto;
  }

  .main {
    margin: 0;
    padding: 0;
    max-width: 100%;
    overflow: visible;
  }

  .content-section {
    display: block !important;
    margin-bottom: 40px;
    page-break-after: always;
  }

  .title-page {
    page-break-after: always;
  }

  .answer {
    display: block;
    background: none;
    color: #000;
    padding: 0;
    margin-top: 4px;
    font-weight: bold;
  }

  .doc-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    border: none;
  }
}

/* ==========================
   UNIT 1 ENHANCED LAYOUT
   ========================== */

/* Unit Introduction Box */
.unit-intro {
  background: linear-gradient(135deg, #fef2f2 0%, #fff7ed 100%);
  border-left: 4px solid var(--primary);
  padding: 20px 24px;
  border-radius: 0 8px 8px 0;
  margin-bottom: 32px;
}

.unit-intro p {
  margin: 0;
  font-size: 16px;
  line-height: 1.7;
  color: var(--ink);
}

/* Section Introduction Text */
.section-intro {
  font-size: 15px;
  color: #475569;
  margin-bottom: 24px;
  line-height: 1.7;
}

/* M.A.I.N. Cause Cards */
.cause-card {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px 24px;
  margin-bottom: 16px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
  transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.cause-card:hover {
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
  transform: translateY(-2px);
}

.cause-title {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 0 16px 0;
  font-size: 18px;
  color: var(--ink);
}

.cause-letter {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: var(--primary);
  color: #ffffff;
  font-weight: 700;
  font-size: 18px;
  border-radius: 8px;
  flex-shrink: 0;
}

.cause-card .problem-list {
  margin: 0;
}

.cause-card .problem-item {
  margin-bottom: 12px;
}

.cause-card .problem-item:last-child {
  margin-bottom: 0;
}

/* Technology Grid */
.tech-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  margin-bottom: 32px;
}

.tech-card {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  transition: all 0.2s ease;
}

.tech-card:hover {
  background: #ffffff;
  border-color: var(--primary);
  box-shadow: 0 4px 12px rgba(153, 27, 27, 0.1);
}

.tech-card h4 {
  margin: 0 0 8px 0;
  font-size: 15px;
  font-weight: 600;
  color: var(--primary);
}

.tech-card p {
  margin: 0;
  font-size: 14px;
  line-height: 1.6;
  color: #64748b;
}

/* History Data Table */
.history-table {
  width: 100%;
  border-collapse: collapse;
  margin: 24px 0 32px;
  background: #ffffff;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.history-table thead {
  background: linear-gradient(135deg, var(--primary) 0%, #7f1d1d 100%);
}

.history-table th {
  padding: 14px 20px;
  text-align: left;
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #ffffff;
}

.history-table td {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
  line-height: 1.6;
  color: var(--ink);
}

.history-table tbody tr:last-child td {
  border-bottom: none;
}

.history-table tbody tr:nth-child(even) {
  background: #fafafa;
}

.history-table tbody tr:hover {
  background: #fef2f2;
}

/* Quote Card for Historical Speeches */
.quote-card {
  background: #f1f5f9;
  border-left: 4px solid #475569;
  padding: 24px 32px;
  margin: 32px 0;
  border-radius: 4px;
  position: relative;
  font-style: italic;
  font-family: var(--serif);
}

.quote-card::before {
  content: '"';
  position: absolute;
  top: 10px;
  left: 10px;
  font-size: 60px;
  color: #cbd5e1;
  line-height: 1;
}

.quote-text {
  font-size: 18px;
  color: #1e293b;
  line-height: 1.6;
  position: relative;
  z-index: 1;
}

.quote-author {
  display: block;
  margin-top: 16px;
  font-style: normal;
  font-weight: 700;
  color: var(--primary);
  font-family: var(--sans);
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Tactical Grid for Blitzkrieg Stages */
.tactical-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin: 24px 0;
}

.tactical-step {
  background: #ffffff;
  border: 1px solid var(--border);
  padding: 16px;
  border-radius: 8px;
  text-align: center;
}

.step-num {
  display: block;
  font-family: var(--mono);
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 8px;
}

.step-name {
  display: block;
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 8px;
}

.step-desc {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.4;
}

/* Responsive adjustments */
@media (max-width: 768px) {

  .tech-grid,
  .tactical-grid {
    grid-template-columns: 1fr;
  }

  .history-table th,
  .history-table td {
    padding: 12px 16px;
  }

  .header {
    padding: 0 16px;
  }

  .brand span {
    display: none;
  }

  .last-updated {
    display: none;
  }

  .menu-toggle {
    display: flex;
  }

  .sidebar {
    position: fixed;
    top: var(--header-h);
    left: 0;
    bottom: 0;
    z-index: 999;
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.1);
  }

  .content-container {
    padding: 32px 20px;
  }

  .tp-title {
    font-size: 32px;
  }

  .tp-subtitle {
    font-size: 16px;
  }

  .doc-footer {
    padding: 24px 20px;
  }

  .footer-content {
    flex-direction: column;
    gap: 16px;
    text-align: center;
  }

  .footer-links {
    display: flex;
    justify-content: center;
  }
}

/* --- STUDY TIPS SECTION --- */
.study-tips-section {
  background: #fff;
  border: 1px solid var(--border);
  border-left: 6px solid var(--primary);
  border-radius: 12px;
  padding: 32px;
  margin: 64px 0 32px;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.05);
}

.tips-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
}

.tips-icon {
  font-size: 32px;
  background: var(--primary-light);
  width: 60px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  border: 2px solid var(--primary);
}

.tips-title {
  font-family: var(--serif);
  font-size: 20px;
  font-weight: 700;
  color: var(--ink);
}

.tips-content p {
  font-family: var(--serif);
  font-size: 16px;
  color: #334155;
  margin-bottom: 20px;
}

.tips-cta {
  background: var(--primary-light);
  color: var(--primary);
  padding: 16px 20px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 14px;
  border-left: 3px solid var(--primary);
  margin-top: 12px;
}

/* --- QUIZ RUNNER UI OVERHAUL --- */
.quiz-layout {
  display: flex;
  gap: 32px;
  max-width: 1200px;
  margin: 40px auto;
  padding: 0 24px;
  align-items: flex-start;
  min-height: 100%;
  /* Ensure it fills height for scrolling */
}

/* Allow scrolling on assessment page */
.quiz-page-body {
  overflow-y: auto !important;
  height: auto !important;
}

.quiz-page-body .app-container {
  height: auto !important;
  overflow: visible !important;
}

.quiz-main {
  flex: 1;
  min-width: 0;
}

.quiz-sidebar {
  width: 300px;
  background: white;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  position: sticky;
  top: 80px;
  /* Below fixed header */
  max-height: calc(100vh - 100px);
  overflow-y: auto;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
}

.timer-box {
  background: #1e293b;
  color: white;
  padding: 16px;
  border-radius: 8px;
  text-align: center;
  margin-bottom: 24px;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.timer-label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #94a3b8;
  margin-bottom: 4px;
}

.timer-display {
  font-family: var(--mono);
  font-size: 32px;
  font-weight: 700;
}

.timer-display.warning {
  color: #fca5a5;
  animation: pulse 1s infinite;
}

@keyframes pulse {
  0% {
    opacity: 1;
  }

  50% {
    opacity: 0.5;
  }

  100% {
    opacity: 1;
  }
}

.nav-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  margin-bottom: 24px;
}

.nav-btn {
  width: 100%;
  aspect-ratio: 1;
  border: 1px solid var(--border);
  background: #f8fafc;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.nav-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.nav-btn.answered {
  background: #ecfdf5;
  border-color: #6ee7b7;
  color: #047857;
}

.nav-btn.flagged {
  background: #fffbeb;
  border-color: #fcd34d;
  color: #b45309;
  position: relative;
}

.nav-btn.flagged::after {
  content: '';
  position: absolute;
  top: 2px;
  right: 2px;
  width: 6px;
  height: 6px;
  background: #f59e0b;
  border-radius: 50%;
}

.checklist-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* Overwrite Quiz Container for New Layout */
.quiz-container {
  max-width: 100%;
  margin: 0;
  padding: 32px;
  box-shadow: none;
  border: none;
}

/* Question Cards Refined */
.question-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0;
  margin-bottom: 32px;
  overflow: hidden;
  transition: transform 0.2s, box-shadow 0.2s;
}

.question-card:hover {
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.05);
}

.q-header {
  background: #f8fafc;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.q-number-label {
  font-weight: 700;
  color: var(--primary);
  font-size: 14px;
}

.q-body {
  padding: 24px;
}

.q-text {
  font-family: var(--serif);
  font-size: 18px;
  line-height: 1.6;
  color: #1e293b;
  margin-bottom: 24px;
  font-weight: 600;
}

.q-instruction {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 12px;
  font-style: italic;
  display: flex;
  align-items: center;
  gap: 6px;
}

.options-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.option-label {
  display: block;
  padding: 16px 20px;
  background: white;
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
  font-size: 15px;
  color: #334155;
}

.option-label:hover {
  border-color: var(--primary);
  background: var(--primary-light);
}

.option-label input[type="radio"] {
  margin-right: 12px;
  accent-color: var(--primary);
}

.option-label.selected {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary);
  font-weight: 600;
}

.mark-btn {
  background: white;
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 8px;
}

.mark-btn:hover {
  background: #fffbeb;
  border-color: #fcd34d;
  color: #b45309;
}

.mark-btn.active {
  background: #fffbeb;
  border-color: #fcd34d;
  color: #b45309;
}

/* Modal Styling */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.7);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  backdrop-filter: blur(4px);
}

.modal-content {
  background: white;
  width: 90%;
  max-width: 450px;
  padding: 32px;
  border-radius: 16px;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.2);
  text-align: center;
}

.modal-icon {
  font-size: 48px;
  margin-bottom: 16px;
}

.modal-title {
  font-size: 20px;
  font-weight: 800;
  color: #ef4444;
  margin-bottom: 12px;
}

.modal-text {
  color: var(--muted);
  line-height: 1.6;
  margin-bottom: 24px;
}

.modal-actions {
  display: flex;
  gap: 12px;
}

.btn-secondary {
  flex: 1;
  padding: 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: white;
  font-weight: 600;
  cursor: pointer;
}

.btn-danger {
  flex: 1;
  padding: 12px;
  border-radius: 8px;
  border: none;
  background: #ef4444;
  color: white;
  font-weight: 600;
  cursor: pointer;
}

/* --- QUIZ ACTION BAR BUTTONS --- */
.btn-submit {
  background: var(--primary);
  color: white;
  border: none;
  padding: 16px 32px;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  min-height: 48px;
  /* Mobile tap target */
}

.btn-submit:hover {
  background: #7f1d1d;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(153, 27, 27, 0.3);
}

.btn-home {
  background: white;
  color: var(--ink);
  border: 1px solid var(--border);
  padding: 16px 32px;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  min-height: 48px;
  /* Mobile tap target */
}

.btn-home:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.action-bar {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  margin-top: 32px;
}

/* --- QUIZ MOBILE RESPONSIVENESS --- */
@media (max-width: 768px) {
  .quiz-layout {
    flex-direction: column-reverse;
    /* Timer on top after submit */
    padding: 0 16px;
    margin: 20px auto;
    gap: 20px;
  }

  .quiz-sidebar {
    width: 100%;
    position: static;
    max-height: none;
    padding: 16px;
    margin-bottom: 0;
  }

  .quiz-container {
    padding: 16px;
  }

  .quiz-title {
    font-size: 24px !important;
  }

  .quiz-subtitle {
    font-size: 14px;
  }

  .q-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 16px;
  }

  .q-body {
    padding: 16px;
  }

  .q-text {
    font-size: 16px;
    margin-bottom: 16px;
  }

  .option-label {
    padding: 14px 16px;
    font-size: 14px;
  }

  .timer-box {
    padding: 12px;
    margin-bottom: 16px;
  }

  .timer-display {
    font-size: 24px;
  }

  .nav-grid {
    grid-template-columns: repeat(5, 1fr);
    gap: 6px;
  }

  .nav-btn {
    font-size: 11px;
  }

  .mark-btn {
    padding: 8px 12px;
    font-size: 11px;
  }

  .action-bar {
    flex-direction: column;
  }

  .btn-submit,
  .btn-home {
    width: 100%;
    text-align: center;
  }

  .modal-content {
    padding: 24px 16px;
    width: 95%;
  }

  .modal-actions {
    flex-direction: column;
    gap: 8px;
  }
}

/* --- DBQ ENHANCEMENTS --- */
.doc-card {
  background: #ffffff;
  border: 1px solid var(--border);
  border-left: 4px solid var(--muted);
  border-radius: 8px;
  padding: 20px 24px;
  margin-bottom: 24px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.02);
}

.doc-card h5 {
  margin: 0 0 12px 0;
  font-family: var(--mono);
  font-size: 13px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  display: flex;
  justify-content: space-between;
}

.doc-content {
  font-style: italic;
  color: var(--ink);
  font-size: 15px;
  margin-bottom: 12px;
  line-height: 1.7;
}

.doc-source {
  font-size: 12px;
  color: var(--muted);
  display: block;
  margin-top: 8px;
}

.doc-image {
  max-width: 100%;
  height: auto;
  border-radius: 4px;
  border: 1px solid var(--border);
  margin-top: 12px;
}

.dbq-tip {
  background: #f0f9ff;
  border: 1px dashed #0c4a6e;
  border-radius: 8px;
  padding: 16px;
  margin: 0 0 24px 0;
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.dbq-tip-icon {
  font-size: 18px;
}

.dbq-tip-content {
  font-size: 14px;
  color: #0c4a6e;
  line-height: 1.5;
}

.dbq-tip-content strong {
  color: #0c4a6e;
  font-weight: 600;
}

/* --- WIKIPEDIA SEARCH --- */
.header-search-shell {
  position: relative;
  width: min(520px, 46vw);
}

.header-search-input-wrap {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #ffffff;
  min-height: 42px;
  padding: 0 6px 0 12px;
  box-shadow: 0 2px 4px rgba(15, 23, 42, 0.03);
}

.header-search-input-wrap svg {
  width: 15px;
  height: 15px;
  fill: #64748b;
  flex-shrink: 0;
}

.header-search-input-wrap:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px #fee2e2;
}

#wikiSearchInput {
  border: none;
  outline: none;
  font-size: 14px;
  color: var(--ink);
  background: transparent;
  min-height: 38px;
  width: 100%;
}

#wikiSearchInput::-webkit-search-cancel-button {
  -webkit-appearance: none;
}

.assistant-search-results {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  max-height: min(62vh, 460px);
  overflow-y: auto;
  display: none;
  flex-direction: column;
  gap: 10px;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.14);
  padding: 12px;
  z-index: 1300;
}

.assistant-search-results.open {
  display: flex;
}

.assistant-result-btn {
  border: 1px solid var(--border);
  background: #ffffff;
  border-radius: 10px;
  padding: 12px;
  cursor: pointer;
  text-align: left;
  text-decoration: none;
  color: inherit;
  display: block;
}

.assistant-result-btn:hover {
  border-color: var(--primary);
  background: #fffbfb;
}

.assistant-result-title {
  display: block;
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 6px;
}

.assistant-result-snippet {
  display: block;
  font-size: 13px;
  color: #334155;
  line-height: 1.5;
}

.assistant-result-snippet mark {
  background: #fee2e2;
  color: var(--primary);
  border-radius: 3px;
  padding: 0 2px;
}

.assistant-empty {
  border: 1px dashed var(--border);
  border-radius: 10px;
  padding: 16px;
  font-size: 13px;
  color: var(--muted);
  background: #f8fafc;
  text-align: center;
}

@media (max-width: 1024px) {
  .print-btn {
    display: none;
  }

  .header-search-shell {
    width: min(52vw, 420px);
  }
}

@media (max-width: 768px) {
  .print-btn {
    display: none;
  }

  .header-search-shell {
    width: min(56vw, 300px);
  }

  .header-search-input-wrap {
    min-height: 40px;
  }

  #wikiSearchInput {
    font-size: 13px;
    min-height: 36px;
  }

  .assistant-search-results {
    max-height: 52vh;
  }
}

/* Interactive Games Styles */
.flashcard-wrapper {
  perspective: 1000px;
  width: 100%;
  max-width: 500px;
  height: 300px;
  margin: 0 auto;
  cursor: pointer;
}

.flashcard {
  width: 100%;
  height: 100%;
  position: relative;
  transition: transform 0.6s;
  transform-style: preserve-3d;
}

.flashcard.flipped {
  transform: rotateY(180deg);
}

.flashcard-front,
.flashcard-back {
  position: absolute;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  text-align: center;
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.flashcard-front {
  background: white;
  border: 2px solid var(--primary);
  color: var(--text);
}

.flashcard-back {
  background: var(--primary);
  color: white;
  transform: rotateY(180deg);
}

.flashcard-nav {
  display: flex;
  justify-content: center;
  gap: 16px;
  margin-top: 24px;
}

.timeline-event {
  padding: 12px 16px;
  background: white;
  border: 1px solid var(--border);
  border-radius: 6px;
  margin-bottom: 8px;
  cursor: grab;
  display: flex;
  align-items: center;
  gap: 12px;
}

.timeline-event:active {
  cursor: grabbing;
}

.timeline-event.dragging {
  opacity: 0.5;
  background: var(--bg-alt);
}

/* ===== Interactive Embedded Activities ===== */
.interactive-embed {
  margin: 32px 0;
  padding: 24px;
  border: 1px solid var(--border);
  border-left: 4px solid var(--primary);
  border-radius: 10px;
  background: linear-gradient(135deg, #fefefe 0%, #f8fafc 100%);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.interactive-embed .embed-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  font-weight: 700;
  font-size: 16px;
  color: var(--primary);
}

.interactive-embed .embed-header .embed-icon {
  font-size: 22px;
}

.interactive-embed .embed-desc {
  font-size: 14px;
  color: var(--muted);
  margin-bottom: 16px;
  line-height: 1.5;
}

/* Match columns layout */
.match-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

@media (max-width: 600px) {
  .match-columns {
    grid-template-columns: 1fr;
  }
}

.match-column h4 {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin-bottom: 10px;
  font-weight: 700;
}

.match-dropzone {
  min-height: 48px;
  border: 2px dashed var(--border);
  border-radius: 8px;
  padding: 8px;
  margin-bottom: 8px;
  transition: border-color 0.2s, background 0.2s;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.match-dropzone.drag-over {
  border-color: var(--primary);
  background: rgba(139, 0, 0, 0.04);
}

.drag-option {
  display: inline-block;
  padding: 8px 14px;
  background: white;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  cursor: grab;
  transition: box-shadow 0.15s, transform 0.15s;
  user-select: none;
}

.drag-option:hover {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  transform: translateY(-1px);
}

.drag-option:active {
  cursor: grabbing;
}

.drag-option.dragging {
  opacity: 0.4;
}

.drag-option.correct {
  background: #ecfdf5;
  border-color: #10b981;
  color: #065f46;
}

.drag-option.incorrect {
  background: #fef2f2;
  border-color: #ef4444;
  color: #991b1b;
}

/* Options pool */
.options-pool {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px;
  background: #f1f5f9;
  border-radius: 8px;
  min-height: 48px;
  margin-bottom: 16px;
}

/* Who Am I clues */
.who-am-i-clue {
  padding: 10px 16px;
  margin-bottom: 6px;
  border-radius: 6px;
  background: #f8fafc;
  border-left: 3px solid var(--border);
  font-size: 14px;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.4s, transform 0.4s;
}

.who-am-i-clue.revealed {
  opacity: 1;
  transform: translateY(0);
}

/* Vocab grid */
.vocab-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 10px;
}

.vocab-card {
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: white;
  cursor: pointer;
  text-align: center;
  font-size: 13px;
  font-weight: 500;
  transition: all 0.2s;
  user-select: none;
}

.vocab-card:hover {
  border-color: var(--primary);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.vocab-card.selected {
  border-color: var(--primary);
  background: rgba(139, 0, 0, 0.06);
  box-shadow: 0 0 0 2px rgba(139, 0, 0, 0.15);
}

.vocab-card.matched {
  background: #ecfdf5;
  border-color: #10b981;
  pointer-events: none;
  opacity: 0.7;
}

.vocab-card.wrong {
  animation: shake 0.4s;
  border-color: #ef4444;
}

@keyframes shake {

  0%,
  100% {
    transform: translateX(0);
  }

  25% {
    transform: translateX(-6px);
  }

  75% {
    transform: translateX(6px);
  }
}

/* Embed result feedback */
.embed-result {
  margin-top: 16px;
  padding: 12px 16px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 14px;
  display: none;
}

.embed-result.show {
  display: block;
}

.embed-result.success {
  background: #ecfdf5;
  color: #065f46;
  border: 1px solid #10b981;
}

.embed-result.error {
  background: #fef2f2;
  color: #991b1b;
  border: 1px solid #ef4444;
}

/* Embed check button */
.embed-check-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, transform 0.15s;
  margin-top: 12px;
}

.embed-check-btn:hover {
  filter: brightness(1.15);
  transform: translateY(-1px);
}

/* Strategy sim choice buttons */
.strategy-choices {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}

.strategy-choice {
  padding: 12px 20px;
  border: 2px solid var(--border);
  border-radius: 8px;
  background: white;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  flex: 1;
  min-width: 140px;
  text-align: center;
}

.strategy-choice:hover {
  border-color: var(--primary);
  background: rgba(139, 0, 0, 0.03);
}

.strategy-choice.chosen {
  border-color: var(--primary);
  background: rgba(139, 0, 0, 0.08);
  font-weight: 700;
}

@media print {
  .interactive-embed {
    display: none !important;
  }

  .header-search-shell {
    display: none !important;
  }
}
