/* ============================================================
   SHARED CHAPTER READING-SHELL — single source of truth for the
   reading UI common to every chapter page (hero, tabs, sidebar,
   learning cards/sections, images, test-yourself, flashcard &
   list quizzes, chapter nav). Consumes tokens.css.
   Page-specific rules + the few drifted selectors stay inline.
   ============================================================ */
/* Reading-shell layout — fluid 3-column. The reading column holds at
   --content-width; the right spacer is the flex slack, so as the window
   narrows the empty right space collapses FIRST, then (≤1024px, below)
   the whole thing goes single-column and the sidebar hands off to the
   section compass. sidebar = fixed, content = hold-then-shrink, spacer = slack. */
.page-body { max-width: var(--max-width); margin: 0 auto; padding: var(--space-xl) var(--space-lg); display: flex; gap: 0; align-items: flex-start; }
.spacer-col { flex: 1 1 0; max-width: 180px; }
/* Anchor jumps (section list / compass) must land the section CARD top clear of
   the sticky nav+tab chrome so its rounded corners show as a "start of section"
   cue. The heading id sits one card-padding (--space-xl) below the card top, so
   clear the chrome + that padding + a small gap. Overrides each page's inline
   [id] rule, which cleared only the heading and tucked the card top behind. */
/* Static (no --tab-height): the tab bar is only present at the very top; once
   you've jumped to any section the nav has collapsed and only the 64px nav
   remains. Including the dynamic --tab-height made the FIRST jump (from the top,
   tab bar showing) land ~48px lower/centered while later jumps landed at the top.
   A fixed offset lands every jump the same — card top + rounded corners with a
   little background above. */
[id] { scroll-margin-top: calc(var(--nav-height) + 56px); }
.chapter-hero-bg { position: absolute; top: 0; left: 0; right: 0; bottom: -60px; background: linear-gradient(180deg, #0d2235 0%, var(--surface-base) 70%, transparent 100%); pointer-events: none; z-index: -2; }
.chapter-hero-bg::before { content: ''; position: absolute; inset: 0; background: repeating-linear-gradient(90deg, rgba(255,255,255,0.015) 0px, rgba(255,255,255,0.015) 1px, transparent 1px, transparent 80px), repeating-linear-gradient(0deg, rgba(255,255,255,0.01) 0px, rgba(255,255,255,0.01) 1px, transparent 1px, transparent 40px); mask-image: linear-gradient(180deg, white 60%, transparent 100%); -webkit-mask-image: linear-gradient(180deg, white 60%, transparent 100%); pointer-events: none; }
.chapter-hero-content { position: relative; display: inline-block; }
.chapter-hero-number { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); font-family: 'Montserrat', sans-serif; font-size: 12rem; font-weight: 800; color: var(--card-accent); opacity: 0.10; line-height: 1; pointer-events: none; z-index: 0; }
.chapter-hero-title { position: relative; z-index: 1; font-family: 'Montserrat', sans-serif; font-size: var(--text-4xl); font-weight: 200; letter-spacing: 2px; line-height: var(--leading-tight); color: var(--text-primary); margin-bottom: 0; text-transform: lowercase; }
.chapter-hero-title strong { font-weight: 700; }
.chapter-hero-desc { position: relative; z-index: 1; font-size: var(--text-lg); color: var(--text-secondary); line-height: var(--leading-relaxed); max-width: 560px; margin: 0 auto; }
.tab-bar { position: sticky; top: var(--nav-height); z-index: 500; background: rgba(10, 26, 40, 0.85); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); border-bottom: 1px solid var(--border-subtle); margin-top: var(--space-xl); transition: opacity 0.35s ease; }
.tab-bar-inner { max-width: var(--content-width); margin: 0 auto; display: flex; justify-content: center; gap: 0; height: var(--tab-height); }
.tab-btn { font-family: 'Inter', sans-serif; font-size: var(--text-sm); font-weight: 600; text-transform: lowercase; letter-spacing: 0.5px; padding: 0 32px; border: none; border-bottom: 2px solid transparent; cursor: pointer; transition: all 0.2s; background: transparent; color: var(--text-secondary); height: 100%; display: flex; align-items: center; }
.tab-btn.active { color: var(--text-primary); border-bottom-color: var(--accent); }
.tab-btn:not(.active):hover { color: var(--text-primary); }
.tab-btn:focus-visible, .tab-btn-inline:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.nav-tabs-inline { display: flex; gap: 0; align-items: center; height: 100%; position: absolute; left: 50%; transform: translateX(-50%) translateY(var(--tab-height)); opacity: 0; pointer-events: none; transition: opacity 0.45s ease, transform 0.45s cubic-bezier(0.25, 0.1, 0.25, 1); }
.tab-btn-inline { font-family: 'Inter', sans-serif; font-size: var(--text-sm); font-weight: 600; text-transform: lowercase; letter-spacing: 0.5px; padding: 0 24px; border: none; border-bottom: 2px solid transparent; cursor: pointer; background: transparent; color: var(--text-secondary); height: 100%; display: flex; align-items: center; transition: color 0.2s, border-color 0.2s; }
.tab-btn-inline.active { color: var(--text-primary); border-bottom-color: var(--accent); }
.tab-btn-inline:not(.active):hover { color: var(--text-primary); }
.sidebar { flex: 0 0 180px; position: sticky; top: calc(var(--nav-height) + var(--tab-height) + 24px); padding-right: var(--space-xl); }
.sidebar-nav { list-style: none; display: flex; flex-direction: column; gap: 4px; }
.sidebar-link { display: flex; align-items: center; gap: 10px; font-size: var(--text-xs); color: var(--text-muted); padding: 6px 0 6px 12px; border-left: 2px solid transparent; transition: all 0.2s; cursor: pointer; background: none; border: none; font-family: inherit; width: 100%; text-align: left; }
.sidebar-link:hover { color: var(--text-secondary); }
.sidebar-link.active { color: var(--accent); border-left-color: var(--accent); }
.sidebar-link.active-review { color: var(--card-accent); border-left-color: var(--card-accent); }
.sidebar-link:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sidebar-progress { margin-top: var(--space-xl); padding-top: var(--space-lg); border-top: 1px solid var(--border-subtle); }
.sidebar-progress-label { font-size: 10px; color: var(--text-muted); margin-bottom: var(--space-sm); transition: color 0.3s; }
.sidebar-progress-bar { height: 3px; background: var(--border-subtle); border-radius: 2px; overflow: hidden; }
.sidebar-progress-fill { height: 100%; width: 14%; background: var(--accent); border-radius: 2px; transition: all 0.3s; }
.sidebar-progress-fill.amber { background: var(--card-accent); }
.sidebar-progress-label.amber { color: var(--card-accent); }
.sidebar-link.done { color: var(--green-dim); border-left-color: transparent; }
.sidebar-link.wrong { color: rgba(234, 67, 53, 0.7); border-left-color: transparent; }
.sidebar-link-dot { width: 8px; height: 8px; border-radius: 50%; border: 1.5px solid var(--border-strong); flex-shrink: 0; transition: all 0.2s; }
.sidebar-link.active .sidebar-link-dot { border-color: var(--accent); background: var(--accent); }
.sidebar-link.done .sidebar-link-dot { border-color: var(--green); background: var(--green); }
.sidebar-link.wrong .sidebar-link-dot { border-color: var(--red); background: var(--red); }
.content { flex: 0 1 var(--content-width); min-width: 0; max-width: var(--content-width); padding: 0; }
.learning-card { background: rgba(255, 255, 255, 0.95); border-radius: var(--radius-lg); padding: var(--space-xl); box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12); }
.learning-card h2 { font-family: 'Montserrat', sans-serif; font-size: var(--text-2xl); font-weight: 700; color: var(--card-accent); margin-bottom: var(--space-lg); }
.learning-card h3 { font-family: 'Montserrat', sans-serif; font-size: var(--text-lg); font-weight: 700; color: var(--card-accent); margin-top: var(--space-xl); margin-bottom: var(--space-md); }
/* Tabular data inside a learning card. Shares the amber-accent idiom of
   .review-card / .criteria-list. Wrap in .data-table-wrap so narrow screens
   scroll the table rather than squeezing the columns. */
.data-table-wrap { overflow-x: auto; margin: 0 0 var(--space-lg); -webkit-overflow-scrolling: touch; }
.data-table { width: 100%; border-collapse: collapse; font-size: var(--text-base); }
.data-table th { font-family: 'Montserrat', sans-serif; font-size: var(--text-xs); font-weight: 700; letter-spacing: 1px; text-transform: uppercase; color: var(--card-accent); text-align: left; padding: 10px 14px; border-bottom: 2px solid rgba(212, 148, 58, 0.28); white-space: nowrap; }
.data-table td { padding: 11px 14px; color: #3a4a5a; line-height: var(--leading-normal); border-bottom: 1px solid rgba(212, 148, 58, 0.12); }
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: rgba(212, 148, 58, 0.05); }
.data-table td:first-child { font-weight: 600; color: #1a2a3a; }
.data-table .td-undefined { color: #8a94a6; font-style: italic; }
@media (max-width: 480px) { .data-table th, .data-table td { padding: 9px 10px; } }

.criteria-list { list-style: none; counter-reset: criteria-counter; margin: 0 0 var(--space-lg); }
.criteria-list li { counter-increment: criteria-counter; display: flex; align-items: center; gap: 12px; padding: 7px 0; font-size: var(--text-base); color: #3a4a5a; line-height: var(--leading-normal); }
.criteria-list li::before { content: counter(criteria-counter); font-family: 'Montserrat', sans-serif; font-size: var(--text-xs); font-weight: 700; color: var(--card-accent); background: rgba(212, 148, 58, 0.10); width: 24px; height: 24px; border-radius: 50%; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.learning-card p { font-size: var(--text-base); color: #3a4a5a; line-height: var(--leading-relaxed); margin-bottom: var(--space-lg); }
.learning-card p:last-child { margin-bottom: 0; }
.learning-card p.image-caption { font-size: 0.78rem; line-height: 1.4; color: #7c8694; background: #f0f1f4; margin: 0; padding: 8px 28px 10px; font-style: italic; }
.learning-card strong { color: #1a2a3a; font-weight: 600; }
.learning-card em { color: #4a5a6a; }
.eeg-image-container:hover { box-shadow: 0 2px 12px rgba(59, 164, 224, 0.15); }
.eeg-image { width: 100%; display: block; margin: 0; border-radius: var(--radius-sm); }
/* Tabbed image comparisons — the tabbed-specific look (rounded corners, clip,
   tab pills). Shared here so it can't drift per page (it did: the image corners
   fell out of sync). The full-bleed margin stays inline on each page, grouped
   with its .eeg-image-container / .react-stepper-wrap siblings. */
.tabbed-comparison { border-radius: var(--radius-sm); overflow: hidden; }
.comp-pane { cursor: pointer; transition: opacity 0.2s; }
.comp-pane:hover { opacity: 0.92; }
.comp-panes { padding: 0; }
.comp-pane img { width: 100%; display: block; margin: 0; border-radius: var(--radius-sm); }
.comp-tabs { display: flex; gap: 6px; justify-content: center; padding: 10px 8px; flex-wrap: wrap; }
.comp-tab { font-family: 'Montserrat', sans-serif; font-size: 11px; font-weight: 600; letter-spacing: 0.5px; padding: 7px 16px; border: 1px solid #d0d8e0; border-radius: 6px; cursor: pointer; background: transparent; color: #6b7a8d; transition: all 0.2s; }
.comp-tab.active { background: var(--accent); color: #fff; border-color: var(--accent); box-shadow: 0 2px 8px rgba(59, 164, 224, 0.2); }
.comp-tab:not(.active):hover { color: #3a4a5a; border-color: #b0b8c0; background: #f5f7fa; }
.test-yourself { margin-top: var(--space-xl); }
.test-yourself-collapsed { display: flex; align-items: center; gap: 14px; cursor: pointer; transition: all 0.25s; padding: var(--space-md) var(--space-lg); border-radius: var(--radius-md); background: linear-gradient(135deg, rgba(212, 148, 58, 0.08), rgba(212, 148, 58, 0.03)); border: 1px solid rgba(212, 148, 58, 0.18); }
.test-yourself-collapsed:hover { background: linear-gradient(135deg, rgba(212, 148, 58, 0.12), rgba(212, 148, 58, 0.05)); border-color: rgba(212, 148, 58, 0.28); }
.test-yourself-collapsed:hover .test-yourself-label { color: #e8a84a; }
.test-yourself-icon { width: 36px; height: 36px; border-radius: 50%; background: linear-gradient(135deg, rgba(212, 148, 58, 0.18), rgba(212, 148, 58, 0.08)); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.test-yourself-icon svg { width: 18px; height: 18px; color: var(--card-accent); }
.test-yourself-text { flex: 1; }
.test-yourself-label { font-family: 'Montserrat', sans-serif; font-size: var(--text-base); font-weight: 600; color: var(--card-accent); transition: color 0.2s; letter-spacing: 0.3px; }
.test-yourself-hint { font-size: var(--text-xs); color: var(--text-muted); margin-top: 2px; }
.test-yourself-chevron { width: 18px; height: 18px; color: var(--text-muted); transition: transform 0.3s; flex-shrink: 0; }
.test-yourself.open .test-yourself-chevron { transform: rotate(180deg); }
.test-yourself.open .test-yourself-collapsed { border-color: rgba(212, 148, 58, 0.30); background: linear-gradient(135deg, rgba(212, 148, 58, 0.12), rgba(212, 148, 58, 0.05)); border-radius: var(--radius-md) var(--radius-md) 0 0; }
.test-yourself-body { display: none; padding: var(--space-lg); background: rgba(10, 26, 40, 0.5); border: 1px solid rgba(212, 148, 58, 0.18); border-top: none; border-radius: 0 0 var(--radius-md) var(--radius-md); }
.test-yourself.open .test-yourself-body { display: block; }
.test-yourself-body .eeg-image-container { margin-left: -12px; margin-right: -12px; }
.test-yourself-question { font-size: var(--text-base); font-weight: 500; color: var(--text-primary); line-height: var(--leading-normal); margin-bottom: var(--space-md); }
.test-yourself-reveal { display: inline-flex; align-items: center; gap: 8px; margin-top: var(--space-md); padding: 10px 20px; border: 1px solid rgba(212, 148, 58, 0.35); border-radius: var(--radius-sm); background: rgba(212, 148, 58, 0.10); color: var(--card-accent); font-family: 'Montserrat', sans-serif; font-size: var(--text-sm); font-weight: 600; cursor: pointer; transition: all 0.2s; letter-spacing: 0.3px; }
.test-yourself-reveal:hover { background: rgba(212, 148, 58, 0.18); border-color: var(--card-accent); }
.test-yourself-reveal svg { width: 14px; height: 14px; }
.test-yourself-answer { display: none; margin: var(--space-lg) calc(-1 * var(--space-lg)) calc(-1 * var(--space-lg)); padding: var(--space-lg); border-radius: 0 0 var(--radius-md) var(--radius-md); background: rgba(52, 168, 83, 0.06); border-top: 1px solid rgba(52, 168, 83, 0.15); }
.test-yourself-answer.visible { display: block; }
.test-yourself-answer-title { font-family: 'Montserrat', sans-serif; font-size: var(--text-lg); font-weight: 700; color: #34a853; display: flex; align-items: center; gap: 8px; margin-bottom: var(--space-sm); }
.test-yourself-answer-title svg { width: 18px; height: 18px; }
.test-yourself-answer p { font-size: var(--text-base); color: var(--text-primary); line-height: var(--leading-relaxed); margin-bottom: var(--space-md); }
.test-yourself-answer p:last-child { margin-bottom: 0; }
.review-card { background: #fcf9f4; border-radius: var(--radius-lg); padding: var(--space-xl); border-left: 4px solid var(--card-accent); }
.review-card-title { font-family: 'Montserrat', sans-serif; font-size: var(--text-2xl); font-weight: 700; color: var(--card-accent); margin-bottom: 6px; }
.review-card-subtitle { font-size: var(--text-sm); color: #8a9ab0; margin-bottom: var(--space-xl); }
.review-card ol { list-style: none; display: flex; flex-direction: column; gap: 0; counter-reset: review-counter; }
.review-card li { counter-increment: review-counter; display: flex; align-items: flex-start; gap: 16px; padding: 14px 0; border-bottom: 1px solid rgba(212, 148, 58, 0.10); }
.review-card li:last-child { border-bottom: none; padding-bottom: 0; }
.review-card li::before { content: counter(review-counter); font-family: 'Montserrat', sans-serif; font-size: var(--text-xs); font-weight: 700; color: var(--card-accent); background: rgba(212, 148, 58, 0.10); width: 28px; height: 28px; border-radius: 50%; display: flex; align-items: center; justify-content: center; flex-shrink: 0; margin-top: 1px; }
.review-card li span { font-size: var(--text-base); color: #3a4a5a; line-height: var(--leading-normal); }
.flashcard-view { max-width: var(--content-width); margin: 0 auto; }
.flashcard-view.hidden { display: none; }
.flashcard { background: rgba(255, 255, 255, 0.95); border-radius: var(--radius-lg); box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12); overflow: hidden; display: none; }
.flashcard:first-of-type { display: block; }
.flashcard-top { padding: 16px var(--space-lg); display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid #edf1f5; }
.flashcard-qnum { font-family: 'Montserrat', sans-serif; font-size: var(--text-xs); font-weight: 700; letter-spacing: 1.5px; color: var(--accent); }
.flashcard-body { padding: var(--space-lg); }
.flashcard-question { font-size: var(--text-lg); font-weight: 500; color: #1a2a3a; line-height: var(--leading-normal); margin-bottom: var(--space-lg); }
.flashcard-options { display: flex; flex-direction: column; gap: 10px; }
.fc-option { display: flex; align-items: center; gap: 14px; padding: 14px 18px; border-radius: var(--radius-md); border: 1px solid #dde3ea; background: transparent; cursor: pointer; transition: all 0.2s; text-align: left; width: 100%; font-family: inherit; color: #3a4a5a; font-size: var(--text-sm); }
.fc-option:hover { border-color: rgba(59, 164, 224, 0.4); background: rgba(59, 164, 224, 0.04); }
.fc-option.selected { border-color: var(--accent); background: rgba(59, 164, 224, 0.08); }
.fc-option.correct { border-color: var(--green); background: rgba(52, 168, 83, 0.08); }
.fc-option.incorrect { border-color: var(--red); background: rgba(234, 67, 53, 0.06); opacity: 0.6; }
.fc-option:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.fc-option-letter { width: 28px; height: 28px; border-radius: 50%; background: #edf1f5; display: flex; align-items: center; justify-content: center; font-family: 'Montserrat', sans-serif; font-size: var(--text-xs); font-weight: 700; color: #8a9ab0; flex-shrink: 0; }
.fc-option.selected .fc-option-letter { background: var(--accent); color: white; }
.fc-option.correct .fc-option-letter { background: var(--green); color: white; }
.flashcard-body .eeg-image { margin: var(--space-lg) 0; }
.flashcard-footer { padding: var(--space-lg); border-top: 1px solid #edf1f5; display: flex; justify-content: space-between; align-items: center; }
.fc-skip { font-size: var(--text-sm); color: #8a9ab0; background: none; border: none; cursor: pointer; font-family: inherit; transition: color 0.2s; }
.fc-skip:hover { color: var(--text-secondary); }
.fc-submit { padding: 8px 24px; border-radius: var(--radius-sm); border: none; background: var(--accent); color: white; font-size: var(--text-sm); font-weight: 600; cursor: pointer; transition: all 0.2s; }
.fc-submit:hover { background: var(--accent-bright); }
.flashcard-answer { padding: var(--space-lg); border-top: 1px solid #edf1f5; display: none; }
.flashcard-answer.visible { display: flex; flex-direction: column; }
.fc-answer-result { display: flex; align-items: center; gap: 10px; margin-bottom: var(--space-md); }
.fc-answer-icon { width: 36px; height: 36px; border-radius: 50%; background: rgba(52, 168, 83, 0.12); display: flex; align-items: center; justify-content: center; }
.fc-answer-icon svg { width: 20px; height: 20px; color: var(--green); }
.fc-answer-label { font-family: 'Montserrat', sans-serif; font-size: var(--text-lg); font-weight: 700; color: var(--green); }
.flashcard-answer p { font-size: var(--text-sm); color: #5a6a7a; line-height: var(--leading-relaxed); margin-bottom: var(--space-lg); }
.flashcard-answer .eeg-image { margin-bottom: var(--space-lg); }
.fc-answer-nav { display: flex; justify-content: space-between; align-items: center; align-self: stretch; }
.fc-prev-btn, .fc-next-btn { display: inline-flex; align-items: center; gap: 8px; padding: 10px 24px; border-radius: var(--radius-sm); border: none; background: var(--accent); color: white; font-size: var(--text-sm); font-weight: 600; cursor: pointer; }
.fc-prev-btn svg, .fc-next-btn svg { width: 16px; height: 16px; }
.list-view { display: none; max-width: var(--content-width); margin: 0 auto; }
.list-view.active { display: block; }
.list-questions { display: flex; flex-direction: column; gap: var(--space-xl); }
.list-item { background: rgba(255, 255, 255, 0.95); border-radius: var(--radius-lg); padding: var(--space-lg); box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12); }
.list-item-num { font-family: 'Montserrat', sans-serif; font-size: var(--text-xs); font-weight: 700; letter-spacing: 1.5px; text-transform: uppercase; color: var(--accent); margin-bottom: var(--space-md); }
.list-item-question { font-size: var(--text-base); font-weight: 500; color: #1a2a3a; line-height: var(--leading-normal); margin-bottom: var(--space-lg); }
.list-item .eeg-image { margin: var(--space-lg) 0; }
.list-item-options { display: flex; flex-direction: column; gap: 8px; margin-bottom: var(--space-lg); }
.list-option { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-radius: var(--radius-sm); border: 1px solid #dde3ea; background: transparent; cursor: pointer; transition: all 0.2s; text-align: left; width: 100%; font-family: inherit; color: #3a4a5a; font-size: var(--text-sm); }
.list-option:hover { border-color: rgba(59, 164, 224, 0.4); background: rgba(59, 164, 224, 0.04); }
.list-option.selected { border-color: var(--accent); background: rgba(59, 164, 224, 0.08); }
.list-option-radio { width: 18px; height: 18px; border-radius: 50%; border: 2px solid #c5cdd6; flex-shrink: 0; transition: all 0.2s; position: relative; }
.list-option.selected .list-option-radio { border-color: var(--accent); }
.list-option.selected .list-option-radio::after { content: ''; position: absolute; top: 3px; left: 3px; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
.list-check { display: inline-flex; align-items: center; gap: 8px; padding: 8px 24px; border-radius: var(--radius-sm); border: none; background: var(--accent); color: white; font-size: var(--text-sm); font-weight: 600; cursor: pointer; font-family: inherit; transition: all 0.2s; }
.list-check:hover { background: var(--accent-bright); }
.list-check svg { width: 16px; height: 16px; display: none; }
.list-answer { margin-top: var(--space-lg); padding-top: var(--space-lg); border-top: 1px solid rgba(52, 168, 83, 0.20); display: none; }
.list-answer.visible { display: block; }
.list-answer-title svg { width: 16px; height: 16px; }
.list-answer p { font-size: var(--text-sm); color: #5a6a7a; line-height: var(--leading-relaxed); margin-bottom: var(--space-md); }
.sidebar-view-toggle { margin-top: var(--space-lg); padding-top: var(--space-lg); border-top: 1px solid var(--border-subtle); }
.view-toggle-btn { display: flex; align-items: center; gap: 8px; font-size: 11px; font-weight: 500; color: var(--text-muted); background: none; border: none; cursor: pointer; padding: 0; font-family: inherit; transition: color 0.2s; }
.view-toggle-btn:hover { color: var(--text-secondary); }
.view-toggle-btn svg { width: 14px; height: 14px; }

/* ── chapter prev/next nav (shared shell; markup generated per chapter by generate.js from chapters.js) ── */
.chapter-nav { max-width: var(--content-width); margin: 0 auto; padding: var(--space-2xl) var(--space-lg) var(--space-3xl); display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-lg); }
.chapter-nav-link { display: flex; flex-direction: column; gap: var(--space-xs); padding: var(--space-lg); border-radius: var(--radius-md); border: 1px solid var(--border-subtle); background: var(--surface-raised); transition: all 0.2s; }
.chapter-nav-link:hover { border-color: var(--card-accent); background: var(--card-accent-glow); }
.chapter-nav-link.next { text-align: right; }
.chapter-nav-label { font-size: var(--text-xs); font-weight: 600; letter-spacing: 1px; text-transform: uppercase; color: var(--text-muted); }
.chapter-nav-title { font-family: 'Montserrat', sans-serif; font-size: var(--text-lg); font-weight: 600; color: var(--text-primary); }
.chapter-nav-link:hover .chapter-nav-title { color: var(--card-accent-bright); }
@media (max-width: 768px) {
  .chapter-nav { grid-template-columns: 1fr; }
  .chapter-nav-link.next { text-align: left; }
}

/* ── responsive layout collapse (shared; lives here AFTER the base flex
      layout so it wins — chapter.css loads after each page's inline <style>).
      At ≤1024px the reading shell goes single-column and the learn Sections
      sidebar hands off to the floating compass; the practice sidebar stays
      as a wrapping strip above its content. ── */
@media (max-width: 1024px) {
  .page-body { display: block; }
  .sidebar { position: relative; top: auto; padding-right: 0; margin-bottom: var(--space-xl); display: flex; gap: var(--space-xl); flex-wrap: wrap; }
  .sidebar-label { flex-basis: 100%; }
  .sidebar-nav { flex-direction: row; gap: var(--space-lg); }
  .sidebar-progress { margin: 0; padding: 0; border: none; }
  .spacer-col { display: none; }
  .content { margin: 0 auto; width: 100%; max-width: var(--content-width); }
  body.has-section-nav #sidebar-learn,
  body.has-section-nav #sidebar-practice { display: none; }
  body.has-section-nav.tab-learn .section-compass[data-tab="learn"],
  body.has-section-nav.tab-practice .section-compass[data-tab="practice"] { display: block; }
}
@media (max-width: 768px) {
  .sidebar { flex-direction: column; gap: 0; }
  .sidebar-nav { flex-direction: column; gap: 4px; }
}

/* ── floating "compass" (built by sectionNav.js). At ≤1024px a tab's sidebar
      hands off to this frosted button, bottom-left. learn: one ring that
      fills with reading progress (blue, gold on review). practice: the ring
      splits into a green (correct) + red (wrong) arc, mirroring the question
      sidebar's segmented progress. Tap to reveal the section/question list. ── */
.section-compass { display: none; position: fixed; left: 16px; bottom: 16px; z-index: 60; touch-action: none; }
/* draggable: parked in the right lower corner (panel flips to right-align) */
.section-compass.dock-right { left: auto; right: 16px; }
.section-compass.dock-right .section-compass-panel { left: auto; right: 0; transform-origin: bottom right; }
.section-compass.dragging .section-compass-btn { cursor: grabbing; }
.section-compass-btn { position: relative; width: 52px; height: 52px; padding: 0; border-radius: 50%; border: 1px solid rgba(255, 255, 255, 0.14); background: rgba(13, 26, 40, 0.62); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); box-shadow: 0 4px 18px rgba(0, 0, 0, 0.35); cursor: pointer; display: grid; place-items: center; transition: transform 0.15s ease; }
.section-compass-btn:active { transform: scale(0.96); }
.section-compass-ring { position: absolute; inset: 0; width: 100%; height: 100%; transform: rotate(-90deg); }
.section-compass-ring .ring-bg { fill: none; stroke: rgba(255, 255, 255, 0.14); stroke-width: 3; }
.section-compass-ring .ring-fg { fill: none; stroke-width: 3; stroke-linecap: round; stroke-dasharray: 0 113.097; transition: stroke-dasharray 0.4s ease, stroke-dashoffset 0.4s ease, stroke 0.3s ease; }
.section-compass-ring .ring-a { stroke: var(--accent); }
.section-compass-ring .ring-b { stroke: transparent; }
.section-compass.is-review .section-compass-ring .ring-a { stroke: var(--card-accent); }
.section-compass[data-tab="practice"] .section-compass-ring .ring-a { stroke: var(--green); }
.section-compass[data-tab="practice"] .section-compass-ring .ring-b { stroke: var(--red); }
.section-compass-count { font-family: 'Montserrat', sans-serif; font-size: 12px; font-weight: 600; color: var(--text-secondary); }
.section-compass.is-review .section-compass-count { color: var(--card-accent-bright); }
.section-compass-panel { position: absolute; left: 0; bottom: 62px; min-width: 190px; padding: 8px; border-radius: 14px; border: 1px solid rgba(255, 255, 255, 0.12); background: rgba(10, 22, 34, 0.9); -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px); box-shadow: 0 10px 34px rgba(0, 0, 0, 0.45); opacity: 0; transform: translateY(8px) scale(0.96); transform-origin: bottom left; pointer-events: none; transition: opacity 0.2s ease, transform 0.2s ease; }
.section-compass.open .section-compass-panel { opacity: 1; transform: none; pointer-events: auto; }
.section-compass-panel-head { font-family: 'Montserrat', sans-serif; font-size: 10px; font-weight: 700; letter-spacing: 2px; text-transform: uppercase; color: var(--text-muted); padding: 6px 10px 8px; }
.section-compass-item { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: 8px; font-size: 13px; color: var(--text-secondary); text-decoration: none; transition: background 0.15s ease, color 0.15s ease; }
.section-compass-item:hover { background: rgba(255, 255, 255, 0.05); color: var(--text-primary); }
.section-compass-item.active { color: var(--accent); background: var(--accent-glow); }
.section-compass-item.active-review { color: var(--card-accent-bright); background: var(--card-accent-glow); }
.section-compass-item.done { color: var(--green-dim); }
.section-compass-item.wrong { color: rgba(234, 67, 53, 0.85); }
.section-compass-item.active .sidebar-link-dot { border-color: var(--accent); background: var(--accent); }
.section-compass-item.done .sidebar-link-dot { border-color: var(--green); background: var(--green); }
.section-compass-item.wrong .sidebar-link-dot { border-color: var(--red); background: var(--red); }

/* ── Chapter hero, responsive ──────────────────────────────────────────────
   These belong HERE, after the base .chapter-hero-number/-title/-desc sizes
   above. The identical rules also sit in every page's inline @media, but there
   they were DEAD: this file loads after the inline <style>, so the base sizes
   above overrode the inline mobile shrink. Defining the shrink here (last wins)
   revives it for every page. ─────────────────────────────────────────────── */
@media (max-width: 768px) {
  .chapter-hero-number { font-size: 7rem; }
  .chapter-hero-title { font-size: var(--text-3xl); }
}
@media (max-width: 480px) {
  .chapter-hero-title { font-size: var(--text-xl); }
  .chapter-hero-desc { font-size: var(--text-sm); }
}

.test-yourself-collapsed:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
