/* ============================================================================
   MODULE READER — Layout & Reader-Specific Styles
   ============================================================================
   Block component styles (.module-body, .chapter-block, callouts, etc.) live in:
   shared/css/content-blocks.css  ← update THAT file to change card styles.
   ============================================================================ */

/* --- Reader Layout (3-column grid: content | divider | tool) --- */
.reader-layout {
  display: grid;
  grid-template-columns: 1fr 0 0;
  min-height: 100vh;
  transition: grid-template-columns 0.3s ease;
}

.reader-layout.split-open {
  grid-template-columns: 1fr 8px minmax(300px, 1fr);
}

.reader-layout.tool-expanded {
  grid-template-columns: 0 0 1fr;
}

/* --- Split view: two independent scrollers --------------------------------
   While a tool is open the page itself stops scrolling and each pane scrolls
   on its own, so a student can scroll inside the tool without dragging the
   chapter text along with it. Reading with no tool open keeps normal document
   scrolling. `min-height: 0` is what lets the grid shrink below its content. */
body.reader-split-active {
  height: 100dvh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

body.reader-split-active .reader-layout {
  flex: 1 1 auto;
  min-height: 0;
}

/* --- Reader Content Panel --- */
.reader-content {
  padding: clamp(1rem, 4vw, 3rem);
  max-width: 900px;
  margin: 0 auto;
  width: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  position: relative;
}

.reader-layout.split-open .reader-content {
  max-width: 100%;
  padding-right: 1.5rem;
  height: 100%;
  min-height: 0;
}

.reader-layout.tool-expanded .reader-content {
  display: none;
}

/* --- Breadcrumb --- */
.reader-breadcrumb {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: var(--app-muted);
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.reader-breadcrumb a {
  color: var(--app-accent);
  text-decoration: none;
}

.reader-breadcrumb a:hover {
  text-decoration: underline;
}

.breadcrumb-sep {
  color: var(--app-border);
}

/* --- Module Header --- */
.module-header {
  margin-bottom: 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 2px solid var(--app-border);
}

.module-header h1 {
  font-size: 2rem;
  color: #1e40af;
  margin: 0 0 0.5rem;
  line-height: 1.2;
}

.module-description {
  font-size: 1.05rem;
  color: var(--app-muted);
  margin: 0 0 1rem;
  line-height: 1.6;
}

.module-meta {
  display: flex;
  gap: 1.5rem;
  flex-wrap: wrap;
}

.module-meta-item {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
  color: var(--app-muted);
}

/* --- Progress Bar --- */
.reader-progress-bar {
  position: sticky;
  top: 0;
  z-index: 100;
  height: 4px;
  background: var(--app-border);
  border-radius: 2px;
  margin-bottom: 1.5rem;
  overflow: hidden;
}

.reader-progress-fill {
  height: 100%;
  background: var(--app-accent);
  border-radius: 2px;
  transition: width 0.3s ease;
  width: 0%;
}

/* --- Page mode (lightweight instructor Page) --- */
/* Pages drop the academic progress bar and reading-time chrome */
body.page-mode-reader .reader-progress-bar {
  display: none !important;
}
body.page-mode-reader .module-meta:empty {
  display: none;
}

/* --- Table of Contents Sidebar --- */
.reader-toc {
  position: fixed;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 260px;
  max-height: 70vh;
  overflow-y: auto;
  background: var(--app-card-bg);
  border-right: 1px solid var(--app-border);
  border-radius: 0 12px 12px 0;
  box-shadow: 4px 0 12px rgba(15, 23, 42, 0.06);
  padding: 1rem;
  z-index: 50;
  transition: transform 0.3s ease;
}

.reader-toc.collapsed {
  transform: translateY(-50%) translateX(-100%);
}

/* Collapsed TOC tab — small button visible at left edge */
.toc-collapsed-tab {
  position: fixed;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  z-index: 49;
  background: var(--app-card-bg, #fff);
  border: 1px solid var(--app-border, #e2e8f0);
  border-left: none;
  border-radius: 0 8px 8px 0;
  padding: 0.5rem 0.6rem;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--app-muted, #64748b);
  cursor: pointer;
  box-shadow: 2px 0 8px rgba(15, 23, 42, 0.06);
  transition: background 0.15s ease, color 0.15s ease;
  writing-mode: horizontal-tb;
}

.toc-collapsed-tab:hover {
  background: var(--app-bg, #f1f5f9);
  color: var(--app-text, #1e293b);
}

.toc-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--app-border);
}

.toc-header h3 {
  margin: 0;
  font-size: 0.9rem;
  color: var(--app-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.toc-collapse-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--app-muted);
  padding: 2px;
  border-radius: 4px;
}

.toc-collapse-btn:hover {
  background: var(--app-bg);
}

.toc-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.toc-list li {
  margin-bottom: 2px;
}

.toc-list a {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.6rem;
  border-radius: 6px;
  color: var(--app-text);
  text-decoration: none;
  font-size: 0.85rem;
  line-height: 1.3;
  transition: background 0.15s ease;
}

.toc-list a:hover {
  background: var(--app-bg);
}

.toc-list a.active {
  background: #e0f2fe;
  color: var(--app-accent);
  font-weight: 600;
}

/* Section completion indicators */
.toc-completion {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid var(--app-border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
}

.toc-completion.completed {
  background: var(--app-success);
  border-color: var(--app-success);
  color: white;
}

.toc-completion.partial {
  border-color: var(--app-accent);
  background: #e0f2fe;
}

/* --- TOC Resources Link --- */
.toc-resources-link {
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--app-border);
}

.toc-resources-link .toc-link {
  font-weight: 600;
  color: var(--app-accent, #2563eb);
}

.toc-resources-link .toc-link:hover {
  background: #e0f2fe;
}

.toc-res-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--app-accent, #2563eb);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  margin-left: 0.35rem;
}

/* --- TOC "Save as PDF" export button (bottom of TOC) --- */
.toc-pdf-export {
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--app-border);
}

.toc-pdf-btn {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  width: 100%;
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--app-border, #e2e8f0);
  border-radius: 6px;
  background: var(--app-card-bg, #fff);
  color: var(--app-text, #1e293b);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.toc-pdf-btn:hover {
  background: var(--app-bg, #f1f5f9);
  border-color: var(--app-accent, #2563eb);
  color: var(--app-accent, #2563eb);
}

.toc-pdf-btn svg {
  flex-shrink: 0;
}

/* --- "Save as PDF" confirmation modal --- */
.pdf-export-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(15, 23, 42, 0.55);
}

.pdf-export-modal {
  background: var(--app-card-bg, #fff);
  color: var(--app-text, #1e293b);
  border-radius: 12px;
  max-width: 480px;
  width: 100%;
  padding: 1.5rem 1.6rem;
  box-shadow: 0 20px 50px rgba(15, 23, 42, 0.3);
}

.pdf-export-modal-title {
  margin: 0 0 0.5rem;
  font-size: 1.15rem;
}

.pdf-export-modal-lead {
  margin: 0 0 0.75rem;
  color: var(--app-muted, #64748b);
  font-size: 0.9rem;
}

.pdf-export-modal-list {
  margin: 0 0 0.9rem;
  padding-left: 1.1rem;
  font-size: 0.87rem;
  line-height: 1.5;
}

.pdf-export-modal-list li {
  margin-bottom: 0.4rem;
}

.pdf-export-modal-tip {
  margin: 0 0 1.1rem;
  font-size: 0.82rem;
  color: var(--app-muted, #64748b);
  background: var(--app-bg, #f1f5f9);
  border-radius: 6px;
  padding: 0.5rem 0.65rem;
}

.pdf-export-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.6rem;
}

.pdf-export-cancel-btn,
.pdf-export-confirm-btn {
  padding: 0.55rem 1rem;
  border-radius: 8px;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--app-border, #e2e8f0);
}

.pdf-export-cancel-btn {
  background: var(--app-card-bg, #fff);
  color: var(--app-text, #1e293b);
}

.pdf-export-cancel-btn:hover {
  background: var(--app-bg, #f1f5f9);
}

.pdf-export-confirm-btn {
  background: var(--app-accent, #2563eb);
  border-color: var(--app-accent, #2563eb);
  color: #fff;
}

.pdf-export-confirm-btn:hover {
  filter: brightness(0.95);
}

/* --- Module Body / Content Area --- */
.module-body {
  line-height: 1.75;
  font-size: 1.05rem;
  color: var(--app-text);
}

.module-body h1 {
  font-size: 1.8rem;
  color: #1e40af;
  margin: 2.5rem 0 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--app-border);
}

.module-body h2 {
  font-size: 1.4rem;
  color: #1e40af;
  margin: 2rem 0 0.75rem;
}

.module-body h3 {
  font-size: 1.15rem;
  color: var(--app-text);
  margin: 1.5rem 0 0.5rem;
}

.module-body p {
  margin: 0.75rem 0;
}

.module-body ul, .module-body ol {
  padding-left: 1.5rem;
  margin: 0.75rem 0;
}

.module-body li {
  margin-bottom: 0.4rem;
}

.module-body img {
  max-width: 100%;
  border-radius: 8px;
  margin: 1rem 0;
}

/* MathJax SVG containment — prevent SVGs from overflowing */
.module-body mjx-container {
  overflow-x: auto;
  overflow-y: hidden;
  max-width: 100%;
}

.module-body mjx-container[display="true"] {
  display: block !important;
  text-align: center;
  margin: 1.5rem 0;
  overflow-x: auto;
}

.module-body mjx-container svg {
  max-width: 100%;
}

.module-body .MathJax {
  overflow-x: auto;
  overflow-y: hidden;
}

.module-body code {
  background: #f1f5f9;
  padding: 0.15em 0.4em;
  border-radius: 4px;
  font-size: 0.9em;
  color: #d64747;
}

.module-body blockquote {
  margin: 1rem 0;
  padding: 0.75rem 1.25rem;
  border-left: 4px solid var(--app-accent);
  background: #f8fafc;
  border-radius: 0 8px 8px 0;
  color: var(--app-muted);
}

/* --- Table House Style --- */
.module-body .table-wrapper {
  overflow-x: auto;
  margin: 1.5rem 0;
  border-radius: 12px;
  border: 1px solid var(--app-border);
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.04);
}

.module-body table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
  line-height: 1.55;
}

.module-body thead {
  background: linear-gradient(135deg, #1e3a5f 0%, #1e40af 100%);
}

.module-body thead th {
  padding: 0.7rem 1rem;
  text-align: left;
  font-weight: 600;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #ffffff;
  border-bottom: 2px solid #1e40af;
  white-space: nowrap;
}

.module-body thead th:first-child {
  border-radius: 11px 0 0 0;
}

.module-body thead th:last-child {
  border-radius: 0 11px 0 0;
}

.module-body tbody td {
  padding: 0.65rem 1rem;
  border-bottom: 1px solid #e2e8f0;
  color: var(--app-text);
  vertical-align: top;
}

.module-body tbody tr:nth-child(even) {
  background: #f8fafc;
}

.module-body tbody tr:nth-child(odd) {
  background: #ffffff;
}

.module-body tbody tr:hover {
  background: #e0f2fe;
  transition: background 0.15s ease;
}

.module-body tbody tr:last-child td {
  border-bottom: none;
}

.module-body tbody tr:last-child td:first-child {
  border-radius: 0 0 0 11px;
}

.module-body tbody tr:last-child td:last-child {
  border-radius: 0 0 11px 0;
}

.module-body tbody td strong {
  color: #1e40af;
  font-weight: 600;
}

/* Compact variant for small tables (add .compact to .table-wrapper) */
.module-body .table-wrapper.compact table {
  font-size: 0.85rem;
}

.module-body .table-wrapper.compact th,
.module-body .table-wrapper.compact td {
  padding: 0.45rem 0.75rem;
}

/* --- Section wrapper (for IntersectionObserver tracking) --- */
.module-section {
  scroll-margin-top: 2rem;
  padding-bottom: 1rem;
}

/* --- Loading --- */
.module-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4rem;
  color: var(--app-muted);
}

.loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--app-border);
  border-top-color: var(--app-accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-bottom: 1rem;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}


/* ============================================================================
   CONTENT BLOCKS — Repeatable Design Components
   ============================================================================ */

/* --- Block Header (shared layout for blocks with titles) --- */
.block-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
}

/* --- Code-Snippet Collapse / Expand --- */
.block-collapse-btn {
  background: none;
  border: none;
  font-size: 1rem;
  line-height: 1;
  padding: 0.15rem 0.35rem;
  cursor: pointer;
  color: #64748b;
  border-radius: 4px;
  transition: color 0.15s ease, background 0.15s ease;
  flex-shrink: 0;
}

.block-collapse-btn:hover {
  color: #e2e8f0;
  background: rgba(255, 255, 255, 0.08);
}

.block-body {
  transition: opacity 0.2s ease;
}

.block-collapsed .block-body {
  opacity: 0;
}

.chapter-block.code-snippet.block-collapsed .code-snippet-header {
  border-bottom: none;
}

/* Comparison: add ⚖️ icon via CSS like other blocks */
.chapter-block.comparison .block-title::before {
  content: '⚖️';
  font-size: 1.1rem;
}

/* --- Concept Block --- */
.chapter-block.concept {
  background: var(--app-card-bg);
  border: 1px solid var(--app-border);
  border-left: 5px solid var(--app-accent);
  border-radius: 12px;
  padding: 1.5rem;
  margin: 1.5rem 0;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.05);
}

.chapter-block.concept .block-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: #1e40af;
  margin: 0 0 0.75rem 0;
}

.chapter-block.concept .block-title::before {
  content: '💡';
  font-size: 1.2rem;
}

.chapter-block.concept .block-content {
  line-height: 1.7;
}

/* --- Guided Task Block --- */
.chapter-block.guided-task {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-left: 5px solid var(--app-success);
  border-radius: 12px;
  padding: 1.5rem;
  margin: 1.5rem 0;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.05);
  position: relative;
}

/* --- Guided Task Focus Effect (when tool panel is open) --- */
.reader-focus-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(255, 255, 255, 0.65);
  z-index: 50;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.35s ease;
  border-radius: 0;
}

.reader-focus-overlay.active {
  opacity: 1;
}

.reader-task-focused {
  position: relative !important;
  z-index: 51 !important;
  box-shadow:
    0 0 0 4px var(--app-success, #22c55e),
    0 0 30px rgba(34, 197, 94, 0.35),
    0 8px 24px rgba(0, 0, 0, 0.1) !important;
  transition: box-shadow 0.3s ease, transform 0.3s ease !important;
  animation: guidedTaskPulse 2.5s ease-in-out infinite;
}

@keyframes guidedTaskPulse {
  0%, 100% {
    box-shadow:
      0 0 0 4px var(--app-success, #22c55e),
      0 0 30px rgba(34, 197, 94, 0.35),
      0 8px 24px rgba(0, 0, 0, 0.1);
  }
  50% {
    box-shadow:
      0 0 0 6px var(--app-success, #22c55e),
      0 0 40px rgba(34, 197, 94, 0.5),
      0 8px 24px rgba(0, 0, 0, 0.1);
  }
}

.chapter-block.guided-task .block-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: #166534;
  margin: 0 0 0.75rem 0;
}

.chapter-block.guided-task .block-title::before {
  content: '🔬';
  font-size: 1.2rem;
}

.guided-task-steps {
  padding-left: 1.25rem;
  margin: 0.75rem 0;
}

.guided-task-steps li {
  margin-bottom: 0.5rem;
  line-height: 1.6;
}

.open-tool-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 1rem;
  padding: 0.6rem 1.2rem;
  background: var(--app-success);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.1s ease;
}

.open-tool-btn:hover {
  background: #22863a;
  transform: translateY(-1px);
}

.open-tool-btn::after {
  content: '→';
  font-size: 1.1rem;
}

/* --- Video Block --- */
.chapter-block.video {
  margin: 1.5rem 0;
}

.video-wrapper {
  position: relative;
  width: 100%;
  padding-bottom: 56.25%; /* 16:9 aspect ratio */
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.1);
}

.video-wrapper iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: none;
}

.video-caption {
  text-align: center;
  font-size: 0.85rem;
  color: var(--app-muted);
  margin-top: 0.5rem;
  font-style: italic;
}

/* --- Assessment Block --- */
.chapter-block.assessment {
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-left: 5px solid var(--app-warning);
  border-radius: 12px;
  padding: 1.5rem;
  margin: 1.5rem 0;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.05);
}

.chapter-block.assessment .block-title {
  font-size: 1rem;
  font-weight: 700;
  color: #92400e;
  margin: 0 0 0.75rem 0;
}

.chapter-block.assessment .block-title::before {
  content: '✏️';
  font-size: 1.1rem;
}

.assessment-question {
  font-weight: 600;
  margin-bottom: 0.75rem;
}

.assessment-options {
  list-style: none;
  padding: 0;
}

.assessment-options li {
  padding: 0.5rem 0.75rem;
  margin-bottom: 0.4rem;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s ease;
  border: 1px solid transparent;
}

.assessment-options li:hover {
  background: #fef3c7;
  border-color: #fde68a;
}

.assessment-options li.selected {
  background: #fde68a;
  border-color: var(--app-warning);
}

.assessment-options li.correct {
  background: #d1fae5;
  border-color: var(--app-success);
}

.assessment-options li.incorrect {
  background: #fee2e2;
  border-color: var(--app-danger);
}

.assessment-feedback {
  margin-top: 0.75rem;
  padding: 0.75rem;
  border-radius: 8px;
  font-size: 0.9rem;
  display: none;
}

.assessment-feedback.correct {
  display: block;
  background: #d1fae5;
  color: #166534;
}

.assessment-feedback.incorrect {
  display: block;
  background: #fee2e2;
  color: #991b1b;
}

.assessment-feedback.partial {
  display: block;
  background: #fef3c7;
  color: #92400e;
}

.assessment-submit-btn {
  margin-top: 0.75rem;
  padding: 0.5rem 1rem;
  background: var(--app-warning);
  color: #1f2a37;
  border: none;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s ease;
}

.assessment-submit-btn:hover {
  background: #f59e0b;
}

/* --- Unavailable check-in: authoring gap (staff only) or transient failure --- */
.chapter-block.assessment.assessment-unavailable {
  background: #f8fafc;
  border-color: #e2e8f0;
  border-left-color: #94a3b8;
}

.assessment-unavailable-title {
  margin: 0 0 0.35rem;
  font-size: 0.9rem;
  font-weight: 700;
  color: #b45309;
}

.assessment-unavailable-body {
  margin: 0;
  font-size: 0.85rem;
  color: #64748b;
}

.assessment-unavailable-body code {
  padding: 0.1rem 0.3rem;
  border-radius: 4px;
  background: #e2e8f0;
  font-size: 0.82rem;
}

.assessment-retry-btn {
  margin-top: 0.6rem;
  padding: 0.4rem 0.9rem;
  background: transparent;
  color: #475569;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  transition: background 0.2s ease;
}

.assessment-retry-btn:hover {
  background: #e2e8f0;
}

/* --- Inline self-check (reader-inline-questions.js) --- */
.assessment-instruction {
  font-size: 0.85rem;
  font-weight: 600;
  color: #92400e;
  margin: 0 0 0.6rem 0;
}

.assessment-options li.assessment-option {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
}

.assessment-option-marker {
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  margin-top: 2px;
  border: 2px solid #cbd5e1;
  background: #fff;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.assessment-option-marker.radio {
  border-radius: 50%;
}

.assessment-option-marker.checkbox {
  border-radius: 4px;
}

.assessment-option.selected .assessment-option-marker {
  border-color: var(--app-warning);
  background: var(--app-warning);
  box-shadow: inset 0 0 0 3px #fffbeb;
}

.assessment-option.correct .assessment-option-marker {
  border-color: var(--app-success);
  background: var(--app-success);
  box-shadow: inset 0 0 0 3px #d1fae5;
}

.assessment-option.incorrect .assessment-option-marker {
  border-color: var(--app-danger);
  background: var(--app-danger);
  box-shadow: inset 0 0 0 3px #fee2e2;
}

/* Glyphs, so correct/incorrect never depends on colour alone. */
.assessment-option.correct .assessment-option-marker::after,
.assessment-option.incorrect .assessment-option-marker::after {
  display: block;
  text-align: center;
  font-size: 13px;
  line-height: 18px;
  font-weight: 700;
}

.assessment-option.correct .assessment-option-marker::after {
  content: '\2713';
  color: #065f46;
}

.assessment-option.incorrect .assessment-option-marker::after {
  content: '\00d7';
  color: #991b1b;
}

.assessment-option-text {
  flex: 1 1 auto;
}

.assessment-option.locked {
  cursor: default;
}

.assessment-option:focus-visible {
  outline: 2px solid var(--app-accent);
  outline-offset: 2px;
}

.assessment-actions {
  margin-top: 0.25rem;
}

.assessment-submit-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.assessment-explanation {
  margin-top: 0.5rem;
  padding-top: 0.5rem;
  border-top: 1px solid rgba(22, 101, 52, 0.2);
  font-weight: 400;
  color: #14532d;
}


/* --- Deep-Dive Block --- */
.chapter-block.deep-dive {
  margin: 1.5rem 0;
  border: 1px solid var(--app-border);
  border-radius: 12px;
  overflow: hidden;
}

.deep-dive-summary {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 1rem 1.25rem;
  background: #f8fafc;
  cursor: pointer;
  font-weight: 600;
  color: var(--app-accent);
  user-select: none;
  transition: background 0.15s ease;
}

.deep-dive-summary:hover {
  background: #e0f2fe;
}

.deep-dive-summary::before {
  content: '▶';
  font-size: 0.75rem;
  transition: transform 0.2s ease;
}

.chapter-block.deep-dive[open] .deep-dive-summary::before {
  transform: rotate(90deg);
}

.deep-dive-content {
  padding: 1.25rem;
  background: var(--app-card-bg);
  border-top: 1px solid var(--app-border);
  line-height: 1.7;
}

/* --- Callout Block --- */
.chapter-block.callout {
  padding: 1.25rem 1.5rem;
  border-radius: 12px;
  margin: 1.5rem 0;
}

.callout-header {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.15rem;
  margin-bottom: 0.5rem;
}

.callout-header .block-icon {
  font-size: 1.4rem;
  line-height: 1;
}

.callout-label {
  font-weight: 700;
  font-size: 0.9rem;
}

.callout-body {
  line-height: 1.6;
}

/* Callout type variants */
.chapter-block.callout.key-takeaway {
  background: #f0fdfa;
  border: 1px solid #99f6e4;
  border-left: 5px solid #14b8a6;
}

.chapter-block.callout.warning {
  background: #fff7ed;
  border: 1px solid #fed7aa;
  border-left: 5px solid #ea580c;
}

.chapter-block.callout.definition {
  background: #e0f2fe;
  border: 1px solid #7dd3fc;
  border-left: 5px solid var(--app-accent);
}

.chapter-block.callout.formula {
  background: #f5f3ff;
  border: 1px solid #c4b5fd;
  border-left: 5px solid #7c3aed;
}

/* --- Mini-Interactive Block --- */
.chapter-block.mini-interactive {
  background: var(--app-card-bg);
  border: 1px solid var(--app-border);
  border-radius: 12px;
  padding: 1.5rem;
  margin: 1.5rem 0;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.05);
}

.chapter-block.mini-interactive .block-title {
  font-size: 1rem;
  font-weight: 700;
  color: #7c3aed;
  margin: 0 0 0.75rem 0;
}

.chapter-block.mini-interactive .block-title::before {
  content: '🎮';
  font-size: 1.1rem;
}

.mini-tool-container {
  min-height: 300px;
  position: relative;
}

.mini-tool-instructions {
  font-size: 0.9rem;
  color: var(--app-muted);
  margin-top: 0.5rem;
  font-style: italic;
}


/* --- Code Snippet Block --- */
.chapter-block.code-snippet {
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 12px;
  margin: 1.5rem 0;
  overflow: hidden;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.12);
}

.code-snippet-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 1rem;
  background: #0f172a;
  border-bottom: 1px solid #334155;
}

.chapter-block.code-snippet.block-collapsed .code-snippet-header {
  border-bottom: none;
}

.code-snippet-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
  color: #94a3b8;
  flex: 1;
}

.code-snippet-icon {
  font-size: 1rem;
}

.code-snippet-title {
  font-weight: 600;
  color: #e2e8f0;
}

.code-snippet-lang {
  background: #334155;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #94a3b8;
}

.code-copy-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: transparent;
  border: 1px solid #475569;
  color: #94a3b8;
  padding: 0.25rem 0.6rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 500;
  transition: all 0.15s ease;
}

.code-copy-btn:hover {
  background: #334155;
  color: #e2e8f0;
  border-color: #64748b;
}

.code-copy-btn.copied {
  border-color: var(--app-success);
  color: var(--app-success);
}

.code-snippet-body {
  margin: 0;
  padding: 1.25rem 1.5rem;
  overflow-x: auto;
  font-size: 0.88rem;
  line-height: 1.65;
}

.code-snippet-body code {
  background: transparent !important;
  color: #e2e8f0;
  padding: 0 !important;
  font-family: 'Fira Code', 'Cascadia Code', 'JetBrains Mono', 'SF Mono', 'Consolas', monospace;
  font-size: inherit;
  border-radius: 0;
}

/* --- Example Block --- */
.chapter-block.example {
  background: #fefce8;
  border: 1px solid #fde68a;
  border-left: 5px solid #f59e0b;
  border-radius: 12px;
  padding: 1.5rem;
  margin: 1.5rem 0;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.05);
}

.chapter-block.example .block-header {
  margin-bottom: 0.75rem;
}

.chapter-block.example .block-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: #92400e;
  margin: 0;
}

.example-context {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: #f59e0b;
  color: white;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  margin-left: 0.25rem;
}

.chapter-block.example .example-content {
  line-height: 1.7;
}

/* --- Comparison Block --- */
.chapter-block.comparison {
  background: var(--app-card-bg);
  border: 1px solid var(--app-border);
  border-radius: 12px;
  padding: 1.5rem;
  margin: 1.5rem 0;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.05);
}

.chapter-block.comparison .block-header {
  margin-bottom: 1rem;
}

.chapter-block.comparison .block-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: #1e40af;
  margin: 0;
}

.comparison-grid {
  display: flex;
  gap: 0;
  align-items: stretch;
}

.comparison-panel {
  flex: 1;
  padding: 1rem;
  line-height: 1.65;
}

.comparison-panel h3 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--app-accent);
  margin: 0 0 0.5rem 0;
  padding-bottom: 0.4rem;
  border-bottom: 2px solid var(--app-accent);
}

.comparison-divider {
  width: 1px;
  background: var(--app-border);
  flex-shrink: 0;
  margin: 0 0.25rem;
}

/* --- Figure Block --- */
.chapter-block.figure {
  margin: 1.5rem 0;
  text-align: center;
}

.figure-container {
  display: inline-block;
  margin: 0 auto;
  text-align: center;
}

.figure-img {
  width: 100%;
  border-radius: 10px;
  box-shadow: 0 4px 16px rgba(15, 23, 42, 0.1);
}

/* Line diagrams read better flat — the drop shadow suits photographs, not schematics. */
.figure-img[src$=".svg"] {
  background: var(--app-card-bg);
  border: 1px solid var(--app-border);
  box-shadow: none;
}

.figure-annotation {
  text-align: left;
  font-size: 0.9rem;
  line-height: 1.6;
  margin-top: 0.75rem;
  color: var(--app-text);
}

.figure-caption {
  font-size: 0.85rem;
  color: var(--app-muted);
  font-style: italic;
  margin-top: 0.5rem;
  padding-top: 0.4rem;
  border-top: 1px solid var(--app-border);
  text-align: left;
}

.figure-number {
  font-style: normal;
  font-weight: 700;
  color: var(--app-text);
}

.figure-number::after {
  content: " — ";
}

.figure-label {
  font-style: normal;
  font-weight: 600;
  color: var(--app-text);
}

.figure-label:not(:empty)::after {
  content: ". ";
}

.figure-ref {
  color: var(--app-accent);
  text-decoration: none;
  font-weight: 600;
  white-space: nowrap;
}

.figure-ref:hover,
.figure-ref:focus-visible {
  text-decoration: underline;
}

/* Brief highlight so a jump from a cross-reference lands somewhere obvious. */
.chapter-block.figure:target .figure-container {
  outline: 2px solid var(--app-accent);
  outline-offset: 6px;
  border-radius: 12px;
}


/* ============================================================================
   DIVIDER & TOOL PANEL
   ============================================================================ */

.reader-divider {
  width: 8px;
  background: var(--app-border);
  cursor: col-resize;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease;
  position: relative;
}

.reader-divider:hover {
  background: var(--app-accent);
}

.divider-handle {
  width: 4px;
  height: 40px;
  background: var(--app-muted);
  border-radius: 2px;
  opacity: 0.5;
}

.reader-divider:hover .divider-handle {
  opacity: 1;
  background: white;
}

.reader-tool-panel {
  display: flex;
  flex-direction: column;
  background: var(--app-bg);
  overflow: hidden;
  isolation: isolate;
  position: relative;
  z-index: 10;
}

.reader-layout.split-open .reader-tool-panel,
.reader-layout.tool-expanded .reader-tool-panel {
  height: 100%;
  min-height: 0;
}

.tool-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 1rem;
  background: var(--app-card-bg);
  border-bottom: 1px solid var(--app-border);
  min-height: 44px;
}

.tool-panel-title {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--app-text);
}

.tool-panel-controls {
  display: flex;
  gap: 0.5rem;
}

.tool-panel-btn {
  background: none;
  border: 1px solid var(--app-border);
  border-radius: 6px;
  padding: 4px 8px;
  cursor: pointer;
  color: var(--app-muted);
  transition: all 0.15s ease;
}

.tool-panel-btn:hover {
  background: var(--app-bg);
  color: var(--app-text);
  border-color: var(--app-muted);
}

/* Bounded height is what gives the tool its OWN scrollbar inside the panel. */
.tool-panel-iframe {
  flex: 1 1 auto;
  border: none;
  width: 100%;
  height: 100%;
  min-height: 0;
}

/* Floating close button — positioned near the iframe content area */
.tool-panel-floating-close {
  position: absolute;
  right: 12px;
  top: 52px; /* default; JS updates this to match iframe offset */
  z-index: 20;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--app-border);
  background: rgba(255, 255, 255, 0.95);
  color: var(--app-muted);
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
  transition: all 0.15s ease;
}

.tool-panel-floating-close:hover {
  background: var(--app-danger, #ef4444);
  color: white;
  border-color: var(--app-danger, #ef4444);
  transform: scale(1.1);
}


/* ============================================================================
   FOOTNOTE SUPERSCRIPTS
   ---------------------------------------------------------------------------
   Owned entirely by citations.css. Do not redeclare .footnote-ref here.
   ============================================================================ */


/* ============================================================================
   CACHED COPY NOTICE — backend unreachable, chapter served from static files
   ============================================================================ */

.reader-cached-notice {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  margin: 0 0 1.75rem;
  padding: 0.9rem 1.1rem;
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-left: 5px solid var(--app-warning);
  border-radius: 10px;
}

.reader-cached-notice-text {
  flex: 1 1 20rem;
  margin: 0;
  font-size: 0.88rem;
  line-height: 1.5;
  color: #92400e;
}

.reader-cached-notice-btn {
  flex: 0 0 auto;
  padding: 0.4rem 1rem;
  background: var(--app-warning);
  color: #1f2a37;
  border: none;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  transition: background 0.2s ease;
}

.reader-cached-notice-btn:hover {
  background: #f59e0b;
}


/* ============================================================================
   ACCESS ERROR (401 / 403) — friendly full-page card
   ============================================================================ */

.reader-access-error {
  max-width: 480px;
  margin: 4rem auto;
  text-align: center;
  padding: 2.5rem 2rem;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
}

.reader-access-error-icon {
  font-size: 2.4rem;
  margin-bottom: 0.75rem;
}

.reader-access-error-heading {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--app-text, #1e293b);
  margin: 0 0 0.75rem;
}

.reader-access-error p {
  font-size: 0.95rem;
  color: var(--app-text, #334155);
  line-height: 1.55;
  margin: 0 0 0.5rem;
}

.reader-error-btn {
  display: inline-block;
  margin-top: 1.25rem;
  padding: 0.6rem 1.5rem;
  background: var(--app-primary, #3b82f6);
  color: #fff;
  font-size: 0.92rem;
  font-weight: 500;
  border-radius: 8px;
  text-decoration: none;
  transition: background 0.15s;
}

.reader-error-btn:hover {
  background: var(--app-primary-dark, #2563eb);
}


/* ============================================================================
   DOWNLOADABLE RESOURCES SECTION
   ============================================================================ */

.module-resources-section {
  margin-top: 3rem;
  padding: 1.5rem;
  background: linear-gradient(135deg, #eff6ff 0%, #f0fdf4 100%);
  border: 1px solid #bfdbfe;
  border-radius: 12px;
}

.module-resources-section h2 {
  font-size: 1.2rem;
  color: #1e40af;
  margin: 0 0 1rem 0;
}

.resource-cards {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.resource-card {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 0.75rem 1rem;
  min-width: 260px;
  flex: 1 1 260px;
  max-width: 400px;
  transition: box-shadow 0.15s ease;
}

.resource-card:hover {
  box-shadow: 0 2px 8px rgba(30, 64, 175, 0.1);
}

.resource-icon {
  font-size: 1.6rem;
  line-height: 1;
  flex-shrink: 0;
}

.resource-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.resource-label {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--app-heading, #1e293b);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.resource-meta {
  font-size: 0.78rem;
  color: var(--app-muted, #64748b);
}

.resource-btn {
  flex-shrink: 0;
  padding: 0.4rem 0.9rem;
  border: none;
  border-radius: 6px;
  background: #1e40af;
  color: #fff;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.15s ease;
}

.resource-btn:hover {
  background: #1e3a8a;
}

.resource-btn:disabled {
  opacity: 0.6;
  cursor: wait;
}

@media (max-width: 640px) {
  .resource-cards {
    flex-direction: column;
  }
  .resource-card {
    max-width: 100%;
  }
}


/* ============================================================================
   REFERENCES / CITATIONS SECTION
   ---------------------------------------------------------------------------
   Owned entirely by citations.css. Do not redeclare .module-references or
   .references-list here — the two files fought and produced a broken layout.
   ============================================================================ */

/* ============================================================================
   VIDEO PLACEHOLDER (when no URL provided)
   ============================================================================ */

.video-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem;
  background: #f1f5f9;
  border-radius: 12px;
  color: var(--app-muted);
}

.video-placeholder span {
  font-size: 2.5rem;
  margin-bottom: 0.5rem;
}

.video-placeholder p {
  font-size: 0.9rem;
}


/* ============================================================================
   RESPONSIVE
   ============================================================================ */

/* Split-screen / half-width laptop windows (e.g. a MacBook browser taking half
   the monitor while the student takes notes in the other half). Side-by-side
   reading + tool no longer fits, so stack the tool panel below the content. */
@media (min-width: 769px) and (max-width: 1024px) {
  .reader-layout.split-open {
    grid-template-columns: 1fr !important;
    grid-template-rows: minmax(0, 1fr) 60vh;
  }

  .reader-layout.split-open .reader-divider {
    display: none !important;
  }

  .reader-layout.split-open .reader-tool-panel {
    max-height: 60vh;
    min-height: 0;
    border-top: 2px solid var(--app-border);
  }

  .reader-layout.split-open .reader-content {
    max-width: 100%;
    padding-right: clamp(1rem, 4vw, 3rem);
    min-height: 0;
  }

  /* Resource cards wrap comfortably instead of overflowing the narrow column. */
  .resource-card {
    flex: 1 1 100%;
    min-width: 0;
    max-width: 100%;
  }
}

@media (max-width: 1100px) {
  .reader-toc {
    display: none;
  }
}

@media (max-width: 768px) {
  .reader-layout {
    grid-template-columns: 1fr !important;
  }

  .reader-layout.split-open {
    grid-template-columns: 1fr !important;
    grid-template-rows: minmax(0, 1fr) 60vh;
  }

  .reader-divider {
    display: none !important;
  }

  .reader-tool-panel {
    max-height: 60vh;
    min-height: 0;
    border-top: 2px solid var(--app-border);
  }

  .reader-layout.split-open .reader-content {
    min-height: 0;
  }

  .reader-content {
    padding: 1rem;
  }

  .module-header h1 {
    font-size: 1.5rem;
  }

  .chapter-block {
    padding: 1rem !important;
  }
}


/* ============================================================================
   CHAPTER CHECK-UP QUIZ
   ============================================================================ */

.chapter-quiz-section {
  margin-top: 3rem;
  padding-top: 2rem;
  border-top: 2px solid #e2e8f0;
}

.chapter-quiz-card {
  text-align: center;
  padding: 2.5rem 2rem;
  background: linear-gradient(135deg, #f0f9ff 0%, #f8fafc 100%);
  border: 1px solid #e0e7ff;
  border-radius: 12px;
  max-width: 600px;
  margin: 0 auto;
}

.chapter-quiz-icon {
  font-size: 2rem;
  width: 56px;
  height: 56px;
  line-height: 56px;
  margin: 0 auto 1rem;
  background: var(--app-primary, #3b82f6);
  color: #fff;
  border-radius: 50%;
  font-weight: 700;
}

.chapter-quiz-title {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--app-text, #1e293b);
  margin: 0 0 0.5rem;
}

.chapter-quiz-desc {
  font-size: 0.92rem;
  color: var(--app-muted, #64748b);
  line-height: 1.5;
  margin: 0 0 1.5rem;
}

.chapter-quiz-start-btn {
  display: inline-block;
  padding: 0.65rem 2rem;
  background: var(--app-primary, #3b82f6);
  color: #fff;
  font-size: 0.95rem;
  font-weight: 600;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}

.chapter-quiz-start-btn:hover {
  background: var(--app-primary-dark, #2563eb);
  transform: translateY(-1px);
}

.chapter-quiz-start-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.chapter-quiz-error {
  background: #fef2f2;
  border-color: #fecaca;
}

/* ---- Questions list ---- */

.chapter-quiz-questions {
  max-width: 720px;
  margin: 0 auto;
}

.chapter-quiz-questions .chapter-quiz-title {
  text-align: center;
  margin-bottom: 1.5rem;
}

.cq-question {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.25rem;
  transition: border-color 0.2s;
}

.cq-question-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.6rem;
}

.cq-question-number {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--app-primary, #3b82f6);
  background: #eff6ff;
  padding: 0.15rem 0.55rem;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.cq-instruction {
  font-size: 0.82rem;
  color: var(--app-muted, #64748b);
  font-style: italic;
}

.cq-question-text {
  font-size: 0.95rem;
  line-height: 1.55;
  color: var(--app-text, #1e293b);
  margin-bottom: 1rem;
}

.cq-select-hint {
  font-size: 0.82rem;
  color: var(--app-muted, #64748b);
  margin: 0 0 0.5rem;
  font-style: italic;
}

/* ---- Options ---- */

.cq-options {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.cq-option {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  padding: 0.7rem 1rem;
  background: #f8fafc;
  border: 1.5px solid #e2e8f0;
  border-radius: 8px;
  cursor: pointer;
  text-align: left;
  font-size: 0.9rem;
  line-height: 1.45;
  color: var(--app-text, #1e293b);
  transition: border-color 0.15s, background 0.15s;
}

.cq-option:hover {
  border-color: var(--app-primary, #3b82f6);
  background: #f0f9ff;
}

.cq-option.selected {
  border-color: var(--app-primary, #3b82f6);
  background: #eff6ff;
}

.cq-option-marker {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  border: 2px solid #cbd5e1;
  border-radius: 50%;
  margin-top: 2px;
  transition: border-color 0.15s, background 0.15s;
}

.cq-checkbox {
  border-radius: 4px;
}

.cq-option.selected .cq-option-marker {
  border-color: var(--app-primary, #3b82f6);
  background: var(--app-primary, #3b82f6);
  box-shadow: inset 0 0 0 3px #fff;
}

.cq-option-text {
  flex: 1;
}

/* ---- Post-submit option states ---- */

.cq-option-correct {
  border-color: #22c55e !important;
  background: #f0fdf4 !important;
}

.cq-option-correct .cq-option-marker {
  border-color: #22c55e;
  background: #22c55e;
}

.cq-option-wrong {
  border-color: #ef4444 !important;
  background: #fef2f2 !important;
}

.cq-option-wrong .cq-option-marker {
  border-color: #ef4444;
  background: #ef4444;
}

/* ---- Feedback ---- */

.cq-feedback {
  display: none;
  margin-top: 0.75rem;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  font-size: 0.88rem;
  line-height: 1.5;
}

.cq-feedback.cq-correct {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  color: #166534;
}

.cq-feedback.cq-incorrect {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #991b1b;
}

.cq-fb-icon {
  font-weight: 700;
  font-size: 1rem;
}

.cq-fb-explanation {
  margin-top: 0.4rem;
  font-size: 0.85rem;
  color: var(--app-text, #334155);
}

/* ---- Score card ---- */

.chapter-quiz-score {
  text-align: center;
  padding: 1.5rem;
  border-radius: 10px;
  margin-bottom: 1rem;
}

.chapter-quiz-score.passed {
  background: linear-gradient(135deg, #f0fdf4, #dcfce7);
  border: 1px solid #bbf7d0;
}

.chapter-quiz-score.not-passed {
  background: linear-gradient(135deg, #fffbeb, #fef3c7);
  border: 1px solid #fde68a;
}

.cq-score-number {
  font-size: 2.5rem;
  font-weight: 800;
  color: var(--app-text, #1e293b);
  line-height: 1;
  margin-bottom: 0.25rem;
}

.cq-score-detail {
  font-size: 0.92rem;
  color: var(--app-muted, #64748b);
}

.chapter-quiz-actions {
  text-align: center;
  margin-top: 1.5rem;
}

.chapter-quiz-submit-btn {
  display: inline-block;
  padding: 0.7rem 2.5rem;
  background: var(--app-primary, #3b82f6);
  color: #fff;
  font-size: 1rem;
  font-weight: 600;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}

.chapter-quiz-submit-btn:hover {
  background: var(--app-primary-dark, #2563eb);
  transform: translateY(-1px);
}

.chapter-quiz-submit-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.chapter-quiz-retry-btn {
  margin-top: 1rem;
  background: var(--app-secondary, #64748b);
}

.chapter-quiz-retry-btn:hover {
  background: #475569;
}
