/* Topic navigation buttons: the one definition. The viewer writes them
   as Bootstrap buttons, .btn.btn-secondary.topic-nav-prev and
   .btn.btn-primary.topic-nav-next (Prev / Next, Start Exam, Retake,
   Submit), so .topic-nav-btn only adds the icon size there. Markup
   without .btn (the SCORM export in api/export-scorm.php and the ECG
   tool's option buttons) gets the same two looks from the tokens. */
.topic-nav-btn i {
    font-size: 1.1em;
}

.topic-nav-btn:not(.btn) {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--gap-icon);
    min-height: var(--control-h);
    padding: 0.5rem 1.25rem;
    border: 1px solid var(--border-medium);
    border-radius: var(--r-sm);
    background: var(--neutral-tint);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 1rem;
    font-weight: 600;
    line-height: 1.4;
    text-decoration: none;
    cursor: pointer;
    transition: background-color var(--dur-fast) ease, border-color var(--dur-fast) ease;
}

.topic-nav-btn:not(.btn):hover {
    border-color: var(--primary-soft);
    color: var(--text-primary);
}

.topic-nav-next:not(.btn) {
    border-color: var(--primary-fill);
    background: var(--primary-fill);
    color: #fff;
}

.topic-nav-next:not(.btn):hover {
    border-color: var(--primary-fill-hover);
    background: var(--primary-fill-hover);
    color: #fff;
}

.topic-nav-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* The section hero is the shared .page-hero--compact (renderPageHero),
   hidden at 960px and below; its Present action is an .icon-btn--chrome.
   Breadcrumbs are gone: the .page-back link under the hero goes up one
   level, to the category (above 960px only; see below). */

/* Stand-in H1 (view.php): visually hidden at 960px and below, where the
   hero and its H1 are not rendered, and not rendered above 960px, where
   the hero's H1 is. One H1 at every width. */
.viewer-h1-narrow {
    display: none;
}
@media (max-width: 960px) {
    .viewer-h1-narrow {
        display: block;
    }
    /* Phones and tablets: no "Back to {category}" pill above the topic
       (owner, 2026-10-16); the navbar and the Topics bar get you around. */
    .section-page-container > .page-back {
        display: none;
    }
}

/* section.php page styles */

/* Prevent content overflow on mobile. overflow-wrap: break-word is
   the standard rule and only kicks in when a word would otherwise
   overflow the container. We deliberately don't use word-break:
   break-word here — that's more aggressive and was splitting normal
   multi-word inline tags (e.g. "Minute Volume") mid-character at
   narrow column widths. */
.section-content-inner {
    overflow-wrap: break-word;
    overflow-x: hidden;
    max-width: 100%;
}

/* Highlighted inline tags from Quill ("Minute Volume" etc.) — the
   real markup is <span class="term"> from a custom blot in
   admin/scripts.php, but bg-color inline-style spans get the same
   treatment for any Quill highlight format. white-space: nowrap
   keeps each tag whole so a phrase like "Minute Volume" wraps to
   the next line as a unit, instead of breaking mid-character via
   overflow-wrap when the tail of the line is too narrow. The span
   itself is still inline, so the line can break at the space
   BEFORE the span normally. */
.section-content-inner .term,
.section-content-inner span[style*="background-color"] {
    white-space: nowrap;
}

.section-content-inner img {
    max-width: 100%;
    height: auto;
}

.section-content-inner .styled-info-card,
.section-content-inner .info-card-embed,
.section-content-inner .callout-embed,
.section-content-inner .html-snippet-embed,
.section-content-inner .key-points-preview,
.section-content-inner table {
    max-width: 100%;
    overflow-x: auto;
}

.section-card {
    overflow: hidden;
    max-width: 100%;
}

/* Group label — small contextual tag inside each topic card showing which
   group it belongs to. Travels with the card's visibility (one-at-a-time UI). */
.topic-group-label {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.6rem 1rem;
    margin-bottom: 1rem;
    font-size: var(--fs-eyebrow);
    font-weight: 700;
    letter-spacing: var(--ls-eyebrow);
    text-transform: uppercase;
    color: var(--text-secondary);
    background: var(--surface-2);
    border-left: 3px solid var(--brand-red);
    border-radius: var(--r-xs);
}
.topic-group-label i {
    font-size: 0.95rem;
    color: var(--brand-red);
}
/* On paper the label is ink on white in every theme: the dark theme's
   --surface-2 would otherwise print as a solid band. */
@media print {
    .topic-group-label {
        background: none;
        color: #333;
    }
}

/* ── Reading typography for topic content ─────────────────────────────
   Topic bodies are read for minutes at a stretch, so they get book-like
   settings rather than the site's UI defaults: more air above a heading
   than below it, and lists with room between items. The sizes (the prose
   ladder: body, h2, h3, h4) and the reading line length live in ONE rule
   in learn-page-styles.css, shared with the SCORM export; this block only
   sets colour and rhythm. */
.section-content-inner {
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
}
.section-content-inner > p,
.section-content-inner > ol,
.section-content-inner > ul {
    font-size: inherit;
    line-height: inherit;
    color: inherit;
}
/* Off-white body text in dark mode: pure white on navy glares over a long
   read. Headings and bold stay at full brightness so they still stand out. */
[data-theme="dark"] .section-content-inner,
[data-theme="dark"] .section-content-inner p,
[data-theme="dark"] .section-content-inner li { color: #DCE3EE; }
[data-theme="dark"] .section-content-inner strong,
[data-theme="dark"] .section-content-inner h2,
[data-theme="dark"] .section-content-inner h3,
[data-theme="dark"] .section-content-inner h4 { color: #F5F8FB; }

.section-content-inner p {
    margin: 0 0 1.15em;
    text-wrap: pretty;      /* no one-word last lines where supported */
}
.section-content-inner > :last-child { margin-bottom: 0; }

/* Headings: air above, tight below (sizes: the prose ladder). */
.section-content-inner h2,
.section-content-inner h3,
.section-content-inner h4 {
    color: var(--text-primary);
    line-height: 1.25;
    letter-spacing: -0.012em;
    text-wrap: balance;
    margin: 0 0 0.5em;
}
.section-content-inner h2 {
    margin-top: 1.9em;
    padding-bottom: 0.3em;
    border-bottom: 1px solid color-mix(in srgb, var(--primary-soft, #3A6FA8) 35%, var(--border-soft, #d8dee6));
}
.section-content-inner h3 {
    margin-top: 1.7em;
}
.section-content-inner h4 {
    margin-top: 1.6em;
}
.section-content-inner > h2:first-child,
.section-content-inner > h3:first-child,
.section-content-inner > h4:first-child,
.section-content-inner > .image-card-embed:first-child + h2,
.section-content-inner > .image-card-embed:first-child + h3 { margin-top: 0; }
/* A heading right after a bigger heading is a subtitle, not a new section. */
.section-content-inner h2 + h3,
.section-content-inner h3 + h4 { margin-top: 0.6em; }

/* Lists: breathing room between items, accent-coloured markers. */
.section-content-inner > ul,
.section-content-inner > ol { padding-left: 2.2rem; }
.section-content-inner ul,
.section-content-inner ol { margin: 0.3em 0 1.3em; }
.section-content-inner li { margin: 0.45em 0; }
.section-content-inner li li { margin: 0.25em 0; }
.section-content-inner li::marker,
.section-content-inner ol li[data-list]::before {
    color: var(--primary-soft, #3A6FA8);
    font-weight: 700;
}

/* Inline: bold that actually reads bold, links that look like links. */
.section-content-inner strong { font-weight: 700; }

/* Blocks sit in the same vertical rhythm as paragraphs. */
.section-content-inner > .callout-embed,
.section-content-inner > .key-points-preview,
.section-content-inner > .info-card-embed,
.section-content-inner > .accordion-embed,
.section-content-inner > .html-snippet-embed,
.section-content-inner > .image-card-embed { margin: 1.5rem 0; }
.section-content-inner .sc-text,
.section-content-inner .key-points-preview li,
.section-content-inner .sacc-body,
.section-content-inner table { line-height: 1.6; }

/* Phones: lists indent less (the line-length cap never bites there). */
@media (max-width: 600px) {
    .section-content-inner > ul,
    .section-content-inner > ol { padding-left: 1.5rem; }
}

/* Inline content links — soft site-color tint at rest, full site color + underline on hover */
.section-content-inner p a,
.section-content-inner li a,
.section-content-inner > a {
    color: color-mix(in srgb, var(--site-color) 65%, var(--text-primary));
    text-decoration: underline;
    text-decoration-thickness: 1.5px;
    text-decoration-color: color-mix(in srgb, var(--site-color) 45%, transparent);
    text-underline-offset: 0.18em;
    transition: color 0.2s ease, text-decoration-color 0.2s ease;
}

.section-content-inner p a:hover,
.section-content-inner li a:hover,
.section-content-inner > a:hover {
    color: var(--site-color);
    text-decoration: underline;
    text-decoration-thickness: 2px;
    text-underline-offset: 3px;
}

/* HTML Snippet wrapper — let content fill width */
.section-content-inner .html-snippet-embed,
.section-content-inner .snippet-render {
    width: 100%;
    overflow-x: auto;
}

/* A content table wider than the reading panel (section-scripts.js adds
   .is-wide after measuring) scrolls sideways on its own instead of being
   clipped at the panel edge, with a one-line hint above it. */
.section-content-inner table.is-wide {
    display: block;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
}
/* Once it scrolls anyway, give each column room to read instead of
   squeezing every cell to its longest word. */
.section-content-inner table.is-wide :is(th, td) {
    min-width: 8rem;
}
.section-content-inner .table-scroll-hint {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    margin: 1rem 0 -0.75rem;
    font-size: var(--fs-sm, 0.85rem);
    color: var(--text-muted);
}

/* Content Tables — catch all tables inside content areas. Framed and
   banded so a table stands apart from the reading panel (owner,
   2026-10-16): a firmer frame, a tinted header row (or the first row of
   a table authored without <th> cells), and alternating row tints on
   every table. The --tbl-* hooks are reused by the dark snippet rules in
   learn-page-styles.css. */
.section-content-inner table {
    --tbl-line: var(--border-medium, #B8CDE0);
    --tbl-head: color-mix(in srgb, var(--primary-soft) 16%, var(--card-bg));
    --tbl-band: color-mix(in srgb, var(--primary-soft) 5%, var(--card-bg));
    width: 100%;
    border-collapse: collapse;
    margin: 1.25rem 0;
    font-size: 0.95rem;
    border-radius: 8px;
    overflow: hidden;
    border: 1.5px solid var(--tbl-line);
    background: var(--card-bg);
}
[data-theme="dark"] .section-content-inner table {
    --tbl-head: color-mix(in srgb, var(--primary-soft) 24%, var(--card-bg));
    --tbl-band: rgba(255, 255, 255, 0.04);
}

.section-content-inner table th,
.section-content-inner table td {
    padding: 0.65rem 0.85rem;
    border: 1px solid var(--tbl-line);
    text-align: left;
    color: var(--text-primary, #333);
}

.section-content-inner table th,
.section-content-inner table:not(:has(th)) tr:first-child > td {
    background: var(--tbl-head);
    font-weight: 700;
    font-size: 0.9rem;
}

.section-content-inner table tbody tr:nth-child(even) > td {
    background: var(--tbl-band);
}

/* Admin edit cog (creators): an .icon-btn.icon-btn--outlined; the class
   stays as admin-modal.php's click hook. */

/* Content images */
.section-content-inner img {
    max-width: 100%;
    height: auto;
    border-radius: 10px;
    border: 2px solid var(--border-soft);
    margin: 1.5rem 0;
    display: block;
    box-shadow: 0 2px 8px var(--shadow-soft);
    cursor: zoom-in;
    transition: opacity 0.2s ease;
}

.section-content-inner img:hover {
    opacity: 0.85;
}

/* Dark mode: content images render at full brightness (no dimming filter). */

/* Section-video wrapper now lives inside .content-video-dock (the dock
   provides chrome). The wrapper itself stays flat so the trigger button
   or stage inside is the only visible element. */
.section-video {
    width: 100%;
}

/* Embedded audio player. The .section-audio wrapper lives inside the
   .content-audio-dock card; the dock provides the card chrome so the
   audio bar itself stays flat (no its-own background/border/shadow). */
.section-audio {
    width: 100%;
}

.audio-player-ui {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
    background: transparent;
    border: none;
    border-radius: 0;
    padding: 0;
    box-shadow: none;
    box-sizing: border-box;
}

[data-theme="dark"] .audio-player-ui {
    background: transparent;
    border: none;
    box-shadow: none;
}

/* Audio dock — a .surface-panel sibling of .content-nav-bar with the
   same compact padding. Sits between .content-main and the prev/next bar
   inside .content-column so the layout reads as four stacked cards
   (TOC, content, audio, nav). The .content-column flex gap supplies
   the visible space above and below. */
.content-audio-dock {
    width: 100%;
    box-sizing: border-box;
    /* Match .content-nav-bar's compact padding so the audio dock is the
       same height as the prev/next bar, sitting between it and the
       content card as a same-size sibling. */
    padding: 0.85rem 1.25rem;
    flex-shrink: 0;
}
.content-audio-dock:empty,
.content-audio-dock.is-empty {
    display: none;
}

/* Video dock — a .surface-panel like .content-audio-dock and
   .content-nav-bar. Idle: a compact "Watch video" trigger button.
   Playing: the .video-stage replaces the trigger and the dock grows
   to a 16:9 stage capped at 50vh. .content-main (flex: 1) shrinks to
   make room because the dock is flex-shrink:0. */
.content-video-dock {
    width: 100%;
    box-sizing: border-box;
    padding: 0.85rem 1.25rem;
    flex-shrink: 0;
    transition: padding 0.25s ease;
}
.content-video-dock:empty,
.content-video-dock.is-empty {
    display: none;
}
.content-video-dock:has(.section-video.is-open) {
    padding: 0.85rem;
}

/* ── Video-only topic (no written content) ───────────────────────────────
   On desktop the right column is a fixed-height flex stack: content card
   (flex:1) on top, compact video dock (flex-shrink:0) below. When the topic
   has a video but no content, hand that height to the video instead of an
   empty card: hide the empty .content-main and let the dock grow to fill the
   column (same height the content window would have occupied). Topics WITH
   content are unaffected — this only triggers on .is-video-only.
   Scoped to the wide-desktop layout where the column has a fixed height;
   on mobile the natural stacked flow already does the right thing. */
@media (min-width: 961px) {
    /* Has to outrank ".content-main.surface-panel:not(.is-fs-content)
       { display: flex }" further down, which silently won the tie and kept
       the empty card on screen. */
    .content-column.is-video-only > .content-main,
    .content-column.is-video-only > .content-main.surface-panel:not(.is-fs-content) {
        display: none;
    }
    .content-column.is-video-only .content-video-dock {
        flex: 1;
        min-height: 0;
        display: flex;
        flex-direction: column;
        justify-content: center;
    }
    /* The open stage normally caps at 50vh; here let it fill the dock. */
    .content-column.is-video-only .content-video-dock .section-video {
        flex: 1;
        min-height: 0;
        display: flex;
        flex-direction: column;
        justify-content: center;
    }
    .content-column.is-video-only .content-video-dock .section-video.is-open .video-stage {
        max-height: none;
        flex: 1;
        min-height: 0;
        aspect-ratio: auto;   /* fill the reclaimed height instead of forcing 16:9 */
    }
}

/* In video-only mode the stage IS the card — there's nothing to collapse
   back to, so hide the collapse pill. */
.content-column.is-video-only .video-collapse-btn {
    display: none;
}

/* Compact trigger — shown when no video is playing. Full-width clickable
   bar shaped like a play CTA. */
.video-trigger {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    width: 100%;
    padding: 0.4rem 0.4rem;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    border-radius: 10px;
    text-align: left;
    transition: background 0.15s ease;
}
.video-trigger:hover {
    background: rgba(255, 255, 255, 0.08);
}
[data-theme="dark"] .video-trigger:hover {
    background: rgba(255, 255, 255, 0.05);
}
.video-trigger-icon {
    flex-shrink: 0;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: #1B5E20;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    box-shadow: 0 2px 10px rgba(27, 94, 32, 0.45);
}
[data-theme="dark"] .video-trigger-icon {
    background: #1B5E20;
    box-shadow: 0 2px 10px rgba(27, 94, 32, 0.55);
}
.video-trigger-label {
    flex: 1;
    min-width: 0;
    color: var(--text-primary);
}
/* "Expand" pill on the trigger — light-blue tinted to match the
   collapse pill so the two states read as a paired toggle. The down-
   chevron mirrors the up-chevron on the collapse pill for a consistent
   ↓ Expand / ↑ Collapse vocabulary. */
.video-trigger-hint {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.35rem 0.85rem;
    border-radius: 999px;
    border: 2px solid rgba(65, 132, 234, 0.55);
    background: rgba(65, 132, 234, 0.18);
    color: var(--primary-soft);
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}
.video-trigger-hint i {
    font-size: 0.95rem;
    line-height: 1;
}
[data-theme="dark"] .video-trigger-hint {
    border-color: rgba(141, 185, 232, 0.55);
    background: rgba(141, 185, 232, 0.18);
    color: #8DB9E8;
}
.video-trigger:hover .video-trigger-hint {
    background: rgba(65, 132, 234, 0.28);
}
[data-theme="dark"] .video-trigger:hover .video-trigger-hint {
    background: rgba(141, 185, 232, 0.28);
}
/* Trigger / stage swap is a max-height + opacity crossfade so the
   transition between "compact bar" and "playing video" is smooth.
   The .is-open class on .section-video drives both children. */
.video-trigger {
    overflow: hidden;
    max-height: 120px;
    transition: max-height 0.35s ease, opacity 0.2s ease, padding 0.3s ease, margin 0.3s ease;
}
.section-video.is-open .video-trigger {
    max-height: 0;
    opacity: 0;
    pointer-events: none;
    padding: 0;
    margin: 0;
}

/* Playing stage — 16:9 video with a collapse button overlaid. Capped at
   50vh so the content card always keeps some room. Hidden via
   max-height/opacity so the transition is animatable. */
.video-stage {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    max-height: 0;
    opacity: 0;
    pointer-events: none;
    border-radius: 10px;
    overflow: hidden;
    background: #000;
    transition: max-height 0.35s ease, opacity 0.25s ease 0.05s;
}
.section-video.is-open .video-stage {
    max-height: 50vh;
    opacity: 1;
    pointer-events: auto;
}
.video-stage iframe,
.video-stage video {
    width: 100%;
    height: 100%;
    border: none;
    display: block;
}
.video-stage video {
    object-fit: contain;
    background: #000;
}
/* Collapse pill — top-right, light-blue chrome matching the .video-
   trigger-hint "Expand" pill. Bumped contrast (solid fill on darker
   blue + drop-shadow) so it stands out over arbitrary video frames. */
.video-collapse-btn {
    position: absolute;
    top: 0.6rem;
    right: 0.6rem;
    z-index: 6;
    padding: 0.4rem 0.9rem;
    border-radius: 999px;
    border: 2px solid rgba(65, 132, 234, 0.85);
    background: rgba(65, 132, 234, 0.85);
    color: #fff;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.45);
    transition: background 0.15s ease, border-color 0.15s, transform 0.15s;
}
.video-collapse-btn i {
    font-size: 1rem;
    line-height: 1;
}
.video-collapse-btn:hover {
    background: rgba(65, 132, 234, 1);
    border-color: rgba(141, 185, 232, 1);
    transform: translateY(-1px);
}
[data-theme="dark"] .video-collapse-btn {
    background: rgba(90, 139, 196, 0.9);
    border-color: rgba(141, 185, 232, 0.85);
}
[data-theme="dark"] .video-collapse-btn:hover {
    background: rgba(141, 185, 232, 1);
    border-color: rgba(141, 185, 232, 1);
}

/* Custom video player bar — the .video-player-ui class is applied
   alongside .audio-player-ui so it inherits the audio bar's visual
   styling for free (rounded card, play button color, progress bar,
   speed pill, volume slider, CC button). The only video-specific
   tweak is to hide it until the stage is open. */
.section-video .video-player-ui {
    display: none;
    margin-top: 0.6rem;
}
.section-video.is-open .video-player-ui {
    display: flex;
}
/* The native HTML5 <video> element renders its OS-default control bar
   when the `controls` attribute is present. We omit that attribute
   and drive playback through .video-player-ui instead. Defensively
   hide any browser-default UI that might leak through (Safari shows
   inline playback chrome on focus even without `controls`). */
.section-video .video-stage video::-webkit-media-controls {
    display: none !important;
}

/* Click-shield over Vimeo iframes — always rendered so the
   platform's hover-revealed UI (center pause button, branding overlays)
   never reaches the user. Transparent + click-to-toggle; the play
   affordance lives on the bar below the video, not in the middle of
   the frame. */
.video-iframe-shield {
    position: absolute;
    inset: 0;
    z-index: 4;
    cursor: pointer;
    background: transparent;
}

/* Mobile: skip the expand/collapse interaction altogether — show the
   video stage permanently expanded and hide the trigger + collapse
   chrome. JS auto-loads the iframe src when mobile is active so
   Vimeo is immediately usable. */
@media (max-width: 960px) {
    .content-video-dock .video-trigger { display: none !important; }
    .content-video-dock .video-stage {
        max-height: 75vh !important;
        opacity: 1 !important;
        pointer-events: auto !important;
    }
    .video-collapse-btn { display: none !important; }
    /* The stage is always open at mobile widths; bake the padding
       tweak in unconditionally. */
    .content-video-dock { padding: 0.85rem; }
}


.ap-play-btn {
    flex-shrink: 0;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    background: #1B5E20;
    color: #fff;
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    box-shadow: 0 2px 10px rgba(27, 94, 32, 0.45);
}

.ap-play-btn:hover {
    filter: brightness(1.1);
    transform: scale(1.08);
    box-shadow: 0 4px 16px rgba(27, 94, 32, 0.6);
}

.ap-play-btn:active {
    transform: scale(0.95);
}

.ap-time-cur,
.ap-time-total {
    flex-shrink: 0;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-secondary);
    font-variant-numeric: tabular-nums;
    min-width: 2.6rem;
    text-align: center;
    line-height: 1;
}

.ap-progress {
    flex: 1;
    height: 6px;
    background: rgba(0, 0, 0, 0.12);
    border-radius: 4px;
    position: relative;
    cursor: pointer;
    user-select: none;
    transition: height 0.15s ease;
}

[data-theme="dark"] .ap-progress {
    background: rgba(255, 255, 255, 0.13);
}

.ap-progress:hover {
    height: 8px;
}

/* Light-green band showing the furthest the learner has watched
   (high-water mark). Sits behind the playhead fill, so a re-watch
   reads as: blue [played so far] → light green [previously watched
   but not yet replayed] → background [never reached]. */
.ap-progress-watched {
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    width: 0%;
    background: #a5d6a7;
    border-radius: 4px;
    pointer-events: none;
    transition: width 0.2s linear;
}
[data-theme="dark"] .ap-progress-watched { background: #2e6b33; }

.ap-progress-fill {
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    width: 0%;
    background: var(--primary-soft);
    border-radius: 4px;
    pointer-events: none;
}

.ap-progress-thumb {
    position: absolute;
    top: 50%;
    left: 0%;
    width: 12px;
    height: 12px;
    background: #fff;
    border: 2px solid var(--primary-soft);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
    transition: left 0.1s linear;
}

.video-speed-bar {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    justify-content: center;
    margin-top: 0.5rem;
}

.video-speed-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-right: 0.15rem;
}

.video-speed-btn {
    padding: 0.15rem 0.5rem;
    border-radius: 5px;
    border: 1.5px solid var(--border-soft);
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.7rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.15s ease;
}

.video-speed-btn:hover {
    border-color: var(--primary-soft);
    color: var(--primary-soft);
}

.video-speed-btn.active {
    /* White label on the fixed fill token (readable in both themes). */
    background: var(--primary-fill, #3A6FA8);
    border-color: var(--primary-fill, #3A6FA8);
    color: #fff;
}

.ap-speed-btn {
    flex-shrink: 0;
    padding: 0.2rem 0.5rem;
    border-radius: 6px;
    border: 2px solid var(--border-soft);
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.7rem;
    font-weight: 800;
    cursor: pointer;
    transition: all 0.2s ease;
    line-height: 1.5;
    min-width: 2.2rem;
    text-align: center;
}

.ap-speed-btn:hover {
    border-color: var(--primary-soft);
    color: var(--primary-soft);
}

.ap-volume-wrap {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    flex-shrink: 0;
}

.ap-vol-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.1rem;
    cursor: pointer;
    padding: 0.15rem;
    display: flex;
    align-items: center;
    transition: color 0.15s;
}

.ap-vol-btn:hover {
    color: var(--primary-soft);
}

.ap-vol-slider {
    width: 60px;
    height: 4px;
    -webkit-appearance: none;
    appearance: none;
    background: var(--border-soft);
    border-radius: 2px;
    cursor: pointer;
}
/* Inputs sit outside the global :focus-visible rule, so give the slider the
   same outline; the wider offset clears the 12px thumb. */
.ap-vol-slider:focus-visible {
    outline: var(--focus-outline, 2px solid var(--primary-soft));
    outline-offset: 6px;
}

.ap-vol-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--primary-soft);
    cursor: pointer;
}

.ap-vol-slider::-moz-range-thumb {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--primary-soft);
    border: none;
    cursor: pointer;
}

@media (max-width: 960px) {
    .ap-vol-slider {
        width: 40px;
    }
    .ap-volume-wrap {
        display: none;
    }
}

.ap-cc-btn {
    flex-shrink: 0;
    padding: 0.25rem 0.55rem;
    border-radius: 6px;
    border: 2px solid var(--border-soft);
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.7rem;
    font-weight: 800;
    letter-spacing: 0.04em;
    cursor: pointer;
    transition: all 0.2s ease;
    line-height: 1.5;
}

.ap-cc-btn:hover {
    border-color: var(--primary-soft);
    color: var(--primary-soft);
}

.ap-cc-btn.active {
    /* White label on the fixed fill token (readable in both themes). */
    background: var(--primary-fill, #3A6FA8);
    border-color: var(--primary-fill, #3A6FA8);
    color: #fff;
}

.audio-caption-display {
    display: none;
    margin-top: 0.75rem;
    padding: 0.65rem 1rem;
    background: rgba(0, 0, 0, 0.05);
    border-left: 3px solid var(--primary-soft);
    border-radius: 0 8px 8px 0;
    font-size: 0.95rem;
    line-height: 1.6;
    color: var(--text-primary);
    font-style: italic;
    min-height: 1.5rem;
}

[data-theme="dark"] .audio-caption-display {
    background: rgba(255, 255, 255, 0.07);
}

@media print {
    .audio-player-ui { display: none; }
    .audio-caption-display { display: none; }
}

/* Image Lightbox */
.lightbox-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    z-index: 10000;
    cursor: zoom-out;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.lightbox-overlay.active {
    display: flex;
}

.lightbox-overlay img {
    width: auto;
    height: auto;
    min-width: 60vw;
    max-width: 95vw;
    max-height: 92vh;
    border-radius: 12px;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.5);
    object-fit: contain;
}

/* The close button is a .modal-close.icon-btn--chrome (white glyph on the
   scrim) pinned to the corner, with a faint disc so it still reads over a
   bright image. The SCORM export styles its own .lightbox-close. */
.lightbox-overlay .lightbox-close {
    --icon-btn-size: 44px;
    position: fixed;
    top: 1.25rem;
    right: 1.5rem;
    z-index: 10001;
    border-radius: var(--r-pill);
    background: rgba(255, 255, 255, 0.15);
    font-size: 1.4rem;
}

.lightbox-overlay .lightbox-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* ===== Layout with TOC sticky sidebar =====
   Two .surface-panel columns: the TOC card and the content card
   (.content-main), plus the video / audio docks and the prev/next bar
   under the content card, all panels too. The topic cards inside
   .content-main are flat: the panel is the surface at every width. */
.content-layout {
    position: relative;
}

.content-main {
    width: 100%;
}

.content-main .section-card {
    background: none;
    border: none;
    border-radius: 0;
    box-shadow: none;
    padding: 0;
    margin-bottom: 0;
}

/* The column stacks its panels with one gap at every width. */
.content-column {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* Phones and tablets: the reading panel's padding steps down with the
   screen (desktop sets its own below, clear of the scrollbar; full
   screen sets its own in learn-page-styles.css). */
.content-main.surface-panel:not(.is-fs-content) {
    padding: 1.5rem;
}
@media (max-width: 600px) {
    .content-main.surface-panel:not(.is-fs-content) {
        padding: 1.25rem 1rem;
    }
}

/* Table of Contents Sidebar: fills the 280px track of the desktop grid
   below (phones set their own full-bleed width). */
.toc-sidebar {
    width: 280px;
}

/* Wide desktop: TOC as sticky sidebar in flex layout */
@media (min-width: 961px) {
    .content-layout {
        display: grid;
        grid-template-columns: 280px 1fr;
        grid-template-rows: auto 1fr;
        gap: 0 2rem;
    }
    /* Single-topic sections render no TOC sidebar. Without this the
       content column falls into the 280px sidebar track and the whole
       page reads as one narrow strip. */
    .content-layout.is-solo {
        grid-template-columns: 1fr;
    }
    /* 2rem under the panels, as before the page shell: the panels are
       viewport-height minus 6rem, so at the bottom of the page this
       leaves the small gap above them instead of pushing their top
       edge off screen (the shell's default is 3rem). */
    .page-shell.section-page-container {
        padding-bottom: 2rem;
    }
    /* Right column wrapper — content card on top, nav bar pinned at the
       bottom. Total height matches the TOC sidebar so their bottom
       edges align. Mobile (below 1025px) is left to natural page flow. */
    .content-column {
        min-width: 0;
        height: calc(var(--scroll-viewport-h, 100vh) - 6rem);
        align-self: flex-start;
        position: sticky;
        top: 2rem;
    }
    .content-main,
    .content-main.surface-panel:not(.is-fs-content) {
        min-width: 0;
        /* The panel (.surface-panel) lives HERE rather than on each
           .section-card child — so navigating between topics keeps the
           same visible card and the FL scrollbar stays inside the
           rounded clip. */
        flex: 1;
        min-height: 0;
        /* Padding applied to the OUTER card (instead of the inner
           .fl-scroll) so it's present on first paint. Otherwise the
           topic content sits flush-left until FLScrollbar runs at
           DOMContentLoaded and adds .fl-scrolled, causing a visible
           horizontal snap as the padding kicks in. The padding-right
           of 38px reserves the gutter the FL track sits over. */
        padding: 1.5rem 2.5rem;
        padding-right: 38px;
        display: flex;
        flex-direction: column;
        overflow: hidden;
    }
    /* FLScrollbar wraps the topic cards in .fl-scroll. Padding lives
       on .content-main itself (above) so it's present on first paint
       and doesn't snap when .fl-scrolled is added. */
    .content-main.fl-scrolled > .fl-scroll {
        flex: 1;
        min-height: 0;
    }
    .toc-sidebar {
        flex-shrink: 0;
        position: sticky;
        top: 2rem; /* overridden by JS */
        align-self: flex-start;
    }
    .toc-card {
        height: calc(var(--scroll-viewport-h, 100vh) - 6rem);
        max-height: calc(var(--scroll-viewport-h, 100vh) - 6rem);
        display: flex;
        flex-direction: column;
        overflow: hidden;
    }
    .toc-collapsible {
        flex: 1;
        min-height: 0;
        display: flex;
        flex-direction: column;
        overflow: hidden;
    }
    .toc-collapsible .toc-inner {
        display: flex;
        flex-direction: column;
        flex: 1;
        min-height: 0;
        overflow: hidden;
    }
    .toc-header {
        flex-shrink: 0;
    }
    .toc-list-scroll {
        flex: 1;
        min-height: 0;
        overflow-y: auto;
        overflow-x: hidden;
    }
    .toc-footer {
        flex-shrink: 0;
        border-top: 1px solid var(--border-soft);
        padding-top: 0.75rem;
        margin-top: 0.5rem;
    }
}

/* The TOC is its own .surface-panel (frame, fill and elevation come from
   the shared class); only the tighter padding is local. */
.toc-card {
    padding: 1.25rem;
}

/* Dark theme: the viewer's panels keep their original near-black glass
   (the owner prefers it to the shared --card-bg surface): the TOC, the
   content card, the prev/next bar and the video / audio docks. Full
   screen keeps its own opaque surfaces (below). */
[data-theme="dark"] .toc-card.surface-panel,
[data-theme="dark"] .content-main.surface-panel:not(.is-fs-content),
[data-theme="dark"] .content-nav-bar.surface-panel,
[data-theme="dark"] .content-video-dock.surface-panel,
[data-theme="dark"] .content-audio-dock.surface-panel {
    background: rgba(4, 8, 18, 0.85);
    border-color: rgba(140, 160, 200, 0.4);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
}
/* Text scrolls behind the full-screen prev/next bar, so it stays solid. */
[data-theme="dark"] .content-main.is-fs-content > .content-nav-bar.surface-panel {
    background: var(--card-bg);
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
}

.toc-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border-soft);
}

.toc-header > span:first-child {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.toc-header > span:first-child i {
    font-size: 1rem;
    color: var(--primary-soft);
}

.toc-header-actions {
    display: flex;
    align-items: center;
    gap: 0.15rem;
    margin: -0.5rem -0.5rem -0.5rem 0;
}

/* Glossary / Resources / Print: .icon-btn (named by aria-label). */
.toc-header .toc-header-icon-btn i {
    font-size: 1.3rem;
    color: inherit;
}

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

.toc-item {
    margin-bottom: 0.15rem;
}

/* TOC group — collapsible wrapper around a set of topic links.
   <li class="toc-group"> > <button class="toc-group-header"> + <ul class="toc-group-body"> */
.toc-group {
    list-style: none;
    margin: 0;
    padding: 0;
}
.toc-group-header {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    width: 100%;
    margin: 0.85rem 0 0.35rem;
    padding: 0.2rem 0.25rem 0.3rem;
    background: none;
    border: none;
    border-bottom: 1px solid color-mix(in srgb, var(--brand-red) 35%, transparent);
    font-size: var(--fs-eyebrow);
    font-weight: 700;
    letter-spacing: var(--ls-eyebrow);
    text-transform: uppercase;
    color: var(--text-secondary);
    cursor: pointer;
    text-align: left;
    transition: color 0.2s ease, border-color 0.2s ease;
}
.toc-group-header:hover {
    color: var(--text-primary);
    border-bottom-color: var(--brand-red);
}
.toc-group-header i:first-child {
    color: var(--brand-red);
}
.toc-group-header .toc-group-title {
    flex: 1;
}
.toc-group-header i:first-child {
    font-size: 0.9rem;
}
.toc-group-chevron {
    font-size: 0.95rem;
    transition: transform 0.2s ease;
}
.toc-group.collapsed .toc-group-chevron {
    transform: rotate(-90deg);
}
.toc-group:first-child .toc-group-header {
    margin-top: 0;
}
.toc-group-body {
    list-style: none;
    margin: 0;
    padding: 0;
    overflow: hidden;
    transition: max-height 0.25s ease, opacity 0.18s ease;
    max-height: 3000px;
}
.toc-group.collapsed .toc-group-body {
    max-height: 0;
    opacity: 0;
}

.toc-link {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.5rem 0.75rem;
    border-radius: 8px;
    text-decoration: none;
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 500;
    line-height: 1.4;
    transition: all 0.2s ease;
    position: relative;
    border-left: 3px solid transparent;
}

.toc-link:hover {
    color: var(--text-primary);
    background: var(--hover-bg);
    text-decoration: none;
}

.toc-link.active {
    color: var(--primary-text);
    background: var(--primary-tint);
    border-left-color: var(--primary-soft);
    font-weight: 600;
}

.toc-number {
    width: 22px;
    height: 22px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 700;
    flex-shrink: 0;
    background: var(--hover-bg);
    color: var(--text-secondary);
    transition: all 0.2s ease;
}

.toc-link.active .toc-number {
    background: var(--primary-fill, #3A6FA8);
    color: white;
}

.toc-link.toc-complete .toc-number {
    background: var(--success-tint);
    color: var(--success-text);
}

.toc-link.toc-complete.active .toc-number {
    background: var(--primary-fill, #3A6FA8);
    color: white;
}

/* Prior-enrollment marker — set on topics the user finished under a
   previous enrollment that no longer counts. Subtle dot to the right
   of the title; hover reveals the explanation. */
.toc-link.toc-prior-completed .toc-title::after {
    content: "•";
    margin-left: 0.4em;
    color: var(--warning-text);
    font-size: 1.1em;
}

.toc-title {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

/* Progress bar in TOC */
.toc-progress {
    margin-top: 1rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border-soft);
}

.toc-progress-label {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.4rem;
}

/* The bar is a .fl-progress.fl-progress--compact (styles.css). */

/* Thin progress bar shown in the fixed mobile TOC strip */
.toc-strip-progress {
    display: none;
}
@media (max-width: 960px) {
    .toc-strip-progress {
        display: block;
        height: 4px;
        background: rgba(255, 255, 255, 0.18);
    }
    .toc-strip-progress-fill {
        height: 100%;
        background: var(--brand-gold);
        transition: width 0.5s ease;
        width: 0%;
    }
    /* Hide the labeled progress inside the collapsible on mobile */
    .toc-progress {
        display: none;
    }
}

/* Reset Progress: a small .btn.btn-quiet-danger. */
.toc-reset-wrap {
    margin-top: 0.75rem;
    text-align: center;
}

/* Glossary button in TOC sidebar */
.toc-glossary-btn-wrap {
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border-soft);
}

.toc-glossary-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.55rem 0.85rem;
    border: 2px solid var(--border-soft);
    border-radius: 10px;
    background: var(--hover-bg);
    color: var(--text-secondary);
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.toc-glossary-btn:hover {
    border-color: var(--primary-soft);
    color: var(--primary-soft);
    background: linear-gradient(135deg, rgba(65, 132, 234, 0.06) 0%, rgba(65, 132, 234, 0.02) 100%);
}

.toc-glossary-btn i {
    font-size: 1.05rem;
}

.toc-glossary-count {
    margin-left: auto;
    background: var(--primary-fill, #3A6FA8);
    color: #fff;
    font-size: 0.7rem;
    font-weight: 700;
    padding: 0.1rem 0.45rem;
    border-radius: 50px;
    line-height: 1.4;
}

/* Glossary Modal */
.glossary-modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--scrim);
    z-index: 10000;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
}

.glossary-modal-overlay.active {
    display: flex;
}

.glossary-modal {
    background: var(--card-bg);
    border: 1px solid var(--border-soft);
    border-radius: var(--r-lg);
    width: 100%;
    max-width: 560px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: var(--elev-4);
    animation: glossarySlideIn 0.25s ease;
    overflow: hidden;
}

@keyframes glossarySlideIn {
    from { opacity: 0; transform: translateY(20px) scale(0.97); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.glossary-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.1rem 1.25rem;
    border-bottom: 1px solid var(--border-soft);
}

.glossary-modal-header h2,
.glossary-modal-header h3 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.glossary-modal-header h2 i,
.glossary-modal-header h3 i {
    color: var(--primary-soft);
    font-size: 1.25rem;
}

.glossary-modal-header .modal-close {
    margin: -0.5rem -0.5rem -0.5rem 0;
}

/* SCORM export only (the viewer's close button is a .modal-close). */
.glossary-modal-close {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: var(--hover-bg);
    color: var(--text-secondary);
    font-size: 1.1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
}

.glossary-modal-close:hover {
    background: var(--danger-tint);
    color: var(--danger-text);
}

.glossary-modal-search {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.75rem 1.25rem;
    border-bottom: 1px solid var(--border-soft);
}

.glossary-modal-search i {
    color: var(--text-secondary);
    font-size: 1.1rem;
    flex-shrink: 0;
}

.glossary-modal-search input {
    flex: 1;
    border: none;
    background: transparent;
    font-size: 0.95rem;
    color: var(--text-primary);
}
/* Borderless field, outside the global :focus-visible rule: same outline. */
.glossary-modal-search input:focus-visible {
    outline: var(--focus-outline, 2px solid var(--primary-soft));
    outline-offset: var(--focus-offset, 2px);
    border-radius: var(--r-xs, 4px);
}

.glossary-modal-search input::placeholder {
    color: var(--text-muted);
    opacity: 1;
}

.glossary-modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 0.75rem 1.25rem 1.25rem;
}

.glossary-modal-list {
    margin: 0;
    padding: 0;
}

.glossary-entry {
    padding: 0.65rem 0;
    border-bottom: 1px solid var(--border-soft);
}

.glossary-entry:last-child {
    border-bottom: none;
}

.glossary-entry dt {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--primary-text);
    margin: 0;
}

.glossary-entry dd {
    font-size: 0.88rem;
    color: var(--text-secondary);
    margin: 0.2rem 0 0 0;
    line-height: 1.5;
}

/* The viewer's no-match line is an .empty-state--compact; these rules
   are for the SCORM export's plain markup. */
.glossary-no-results:not(.empty-state) {
    text-align: center;
    padding: 2rem 1rem;
    color: var(--text-secondary);
}

.glossary-no-results:not(.empty-state) i {
    font-size: 2rem;
    margin-bottom: 0.5rem;
    display: block;
    opacity: 0.4;
}

.glossary-no-results:not(.empty-state) p {
    margin: 0;
    font-size: 0.9rem;
}

/* Resources modal: each citation is an inset row that is all link. */
.resource-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.resource-item {
    padding: 0;
}

.resource-card-link {
    display: flex;
    align-items: flex-start;
    gap: 0.6rem;
    padding: 0.85rem 1rem;
    color: inherit;
    text-decoration: none;
}

.resource-card-icon {
    flex-shrink: 0;
    margin-top: 0.1rem;
    font-size: 1.15rem;
    color: var(--primary-soft);
}

.resource-card-text {
    flex: 1;
    min-width: 0;
}

.resource-cite {
    font-size: 0.92rem;
    line-height: 1.55;
    color: var(--text-primary);
}

.resource-desc {
    margin-top: 0.3rem;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

/* Glossary modal scrollbar */
.glossary-modal-body::-webkit-scrollbar {
    width: 5px;
}

.glossary-modal-body::-webkit-scrollbar-track {
    background: transparent;
}

.glossary-modal-body::-webkit-scrollbar-thumb {
    background: var(--border-soft);
    border-radius: 3px;
}

/* Scrollbar styling for TOC — desktop */
@media (min-width: 961px) {
    .toc-list-scroll {
        scrollbar-width: thin;
        scrollbar-color: var(--border-strong) transparent;
    }
    .toc-list-scroll::-webkit-scrollbar { width: 6px; }
    .toc-list-scroll::-webkit-scrollbar-track { background: transparent; }
    .toc-list-scroll::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 3px; }
    .toc-list-scroll::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }
    /* When the custom overlay scrollbar is initialised, flip the
       .toc-list-scroll into a flex column so the inner .fl-scroll fills
       its height (which itself comes from flex: 1 in .toc-collapsible). */
    .toc-list-scroll.fl-scrolled {
        display: flex;
        flex-direction: column;
    }
    .toc-list-scroll.fl-scrolled > .fl-scroll {
        flex: 1 1 auto;
        min-height: 0;
        /* Reserve a gutter so topic labels don't sit under the
           overlay scrollbar track (track width 20px @ right: 6px =
           26px of the right edge — pad slightly past that). */
        padding-right: 30px;
    }
    .toc-collapse-btn { display: none; }
    .toc-collapsible {
        display: flex !important;
        flex-direction: column;
        max-height: none !important;
        border: none !important;
        background: transparent !important;
    }
    .toc-collapsible .toc-inner { padding: 0; }
}

/* TOC mobile — fixed strip below sticky header */
@media (max-width: 960px) {
    .page-shell.section-page-container {
        padding-top: 0;
    }

    .toc-sidebar {
        position: sticky;
        top: 0;
        z-index: 999;
        /* Span viewport edge-to-edge regardless of any nested .container
           or Bootstrap padding above us. */
        width: 100vw;
        margin-left: calc(50% - 50vw);
        margin-right: calc(50% - 50vw);
        margin-bottom: 0.75rem;
    }
    /* The panel opens up into a full-bleed strip: no frame or corners. */
    .toc-card { padding: 0; border: none; border-radius: 0; box-shadow: var(--elev-3); background: var(--card-bg); }
    /* The strip is navy chrome in both themes (the hero hides at this
       width, so the strip carries the section identity): the brand band
       with its red cap. Collapse button + action icons in a flex row. */
    .toc-strip-bar {
        display: flex;
        align-items: stretch;
        background: var(--brand-band);
        border-bottom: 3px solid var(--brand-red);
    }
    .toc-collapse-btn {
        display: flex;
        flex: 1;
        align-items: center;
        gap: 0.5rem;
        padding: 0.75rem 1.1rem;
        background: transparent;
        border: none;
        border-bottom: 2px solid transparent;
        font-size: 0.95rem;
        font-weight: 700;
        color: #fff;
        cursor: pointer;
        transition: border-color var(--dur-fast) ease;
        min-width: 0;
        min-height: var(--control-h);
        --focus-color: var(--focus-color-chrome);
        --focus-outline: 2px solid var(--focus-color-chrome);
    }
    .toc-collapse-btn:focus-visible { outline-offset: -4px; }
    .toc-collapse-btn i:first-child { color: var(--brand-gold); }
    .toc-collapse-btn i.chevron { margin-left: auto; transition: transform 0.3s ease; font-size: 1.1rem; }
    .toc-collapse-btn.expanded i.chevron { transform: rotate(180deg); }
    .toc-collapse-btn.expanded { border-bottom-color: rgba(255, 255, 255, 0.25); }
    /* Glossary / Resources / Print in the strip: .icon-btn--chrome. */
    .toc-strip-actions { display: flex; align-items: center; gap: 0.15rem; padding: 0 0.5rem; border-left: 1px solid rgba(255, 255, 255, 0.22); }
    /* Hide originals on mobile — they live in the strip now */
    .toc-glossary-btn-wrap { display: none; }
    .print-btn { display: none !important; }
    /* Collapsible */
    /* The list opens as a sheet under the strip (moved into <body> while
       open, so it carries its own card colour). */
    .toc-collapsible { display: none; background: var(--card-bg); border-top: 1px solid var(--border-soft); overflow-y: scroll; scrollbar-width: auto; scrollbar-color: var(--border-strong) var(--surface-2); }
    .toc-collapsible::-webkit-scrollbar { width: 14px; }
    .toc-collapsible::-webkit-scrollbar-track { background: var(--surface-2); }
    .toc-collapsible::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 7px; border: 2px solid var(--surface-2); }
    .toc-collapsible::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }
    .toc-collapsible.expanded { display: block; overflow-y: auto; -webkit-overflow-scrolling: touch; }
    .toc-collapsible .toc-inner { padding: 0.6rem 0.75rem; }
    .toc-header { display: none; }
    .toc-progress { margin-top: 0.5rem; padding: 0 0.75rem 0.75rem; }

    /* Expanded TOC overlays the content and stretches edge-to-edge.
       `top` is set inline by section-scripts.js to the bottom of the
       sticky strip-bar so the first list items aren't hidden behind
       it; `bottom: 0` anchors to the viewport edge. z=950 puts the
       panel above the footer (z=900) so a deep scroll-position at the
       moment of opening doesn't let the footer peek through; the
       strip-bar (z=999) still renders above the panel at the top. */
    .toc-collapsible.expanded {
        position: fixed;
        left: 0;
        right: 0;
        top: 0;
        bottom: 0;
        z-index: 950;
        max-height: none;
        box-sizing: border-box;
        /* The sheet is the only thing that scrolls while it is open: no
           sideways scrollbar of its own, a finger on it pans up/down only,
           and reaching its top or bottom never carries on into the page
           behind (the wheel/touch lock in section-scripts.js only covers
           gestures that START outside the sheet). */
        overflow-x: hidden;
        touch-action: pan-y;
        overscroll-behavior: contain;
    }
    /* Marker class — applied to html/body while the TOC overlay is
       open. Scroll lock itself is handled by wheel/touchmove event
       listeners in section-scripts.js (NOT overflow: hidden), because
       overflow: hidden breaks the sticky strip-bar — sticky needs a
       scrollable ancestor, and locking scroll via overflow drops the
       bar out of viewport-top position. The class is here in case
       other code wants to react to the open state. */
}

/* On desktop, strip bar is invisible (collapse btn is hidden; actions are hidden) */
@media (min-width: 961px) {
    .toc-strip-bar { display: block; }
    .toc-strip-actions { display: none; }
}

/* ===== Topic navigation fade transition ===== */
.section-card[data-topic-index] {
    transition: opacity 0.18s ease;
}
.section-card[data-topic-index].topic-fading {
    opacity: 0;
}


/* ===== Confetti Canvas ===== */
#confettiCanvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 9999;
}

/* Celebration banner: a .callout.is-success, shown once every topic is
   complete (section-scripts.js adds .visible). */
.celebration-banner {
    display: none;
    margin-bottom: 1.25rem;
    animation: bannerPop 0.5s ease;
}

.celebration-banner.visible {
    display: block;
}

.celebration-banner .callout-title {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin-bottom: 0.15rem;
    font-size: 1.1rem;
}

@keyframes bannerPop {
    0% { opacity: 0; transform: scale(0.9) translateY(-10px); }
    50% { transform: scale(1.02) translateY(0); }
    100% { opacity: 1; transform: scale(1) translateY(0); }
}

/* Inline knowledge check, exam and ECG tool: an inset tray inside the
   topic, question cards on the card colour, answers as .choice-tile rows
   (real radios, visually hidden but focusable, a ti-check when chosen).
   The .quiz-* rules without .choice-tile / .btn below keep the SCORM
   export's own markup (api/export-scorm.php) working. */
.inline-quiz,
.inline-tool {
    margin: 1.25rem 0 0;
    padding: 1.25rem 1.5rem;
    border: 1px solid var(--border-soft);
    border-radius: var(--r-lg);
    background: var(--surface-2);
}

/* Clinical simulators size themselves by width, so the embed escapes the
   text column and centres on it (nothing up to <body> clips overflow). */
.inline-clinical-tool {
    position: relative;
    left: 50%;
    width: min(92vw, 1500px);
    max-width: none;
    transform: translateX(-50%);
}

.inline-clinical-tool iframe {
    display: block;
    width: 100%;
    height: min(85vh, 1100px);
    border: none;
    background: transparent;
}

@media (max-width: 600px) {
    .inline-quiz,
    .inline-tool {
        padding: 1rem;
    }
}

.inline-quiz-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.25rem;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.inline-quiz-title {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.inline-quiz-title i {
    color: var(--primary-soft);
    font-size: 1.3rem;
}

.inline-quiz-title-note {
    color: var(--text-muted);
    font-size: 0.8em;
    font-weight: 500;
}

/* SCORM export: its info chip has no .status-pill. */
.inline-quiz-info:not(.status-pill) {
    padding: 0.3rem 0.75rem;
    border-radius: var(--r-pill);
    background: var(--primary-tint);
    color: var(--primary-text);
    font-size: 0.85rem;
    font-weight: 600;
}

.inline-quiz-start {
    padding: 1.5rem 1rem;
    text-align: center;
}

.inline-quiz-lead {
    margin: 0 0 1rem;
    color: var(--text-secondary);
}

.inline-quiz-alt {
    margin-top: 1rem;
}

.quiz-question-card {
    margin-bottom: 1rem;
    padding: 1.25rem;
    border: 1px solid var(--border-soft);
    border-radius: var(--r-md);
    background: var(--card-bg);
}

/* The answers are one radio group: <fieldset><legend>question</legend>. */
.quiz-fieldset {
    min-width: 0;
    margin: 0;
    padding: 0;
    border: 0;
}

.quiz-question-text {
    float: none;
    width: auto;
    margin-bottom: 0.85rem;
    padding: 0;
    color: var(--text-primary);
    font-size: 1.05rem;
    font-weight: 600;
    line-height: 1.55;
}

.quiz-q-num {
    color: var(--primary-text);
    font-weight: 700;
    margin-right: 0.35rem;
}

.quiz-q-progress {
    display: block;
    margin-bottom: 0.35rem;
    color: var(--text-muted);
    font-size: var(--fs-meta);
    font-weight: 600;
}

.quiz-answers-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.quiz-fitb-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
}

.quiz-fitb-row .form-control {
    flex: 1 1 12rem;
    min-width: 0;
}

/* Fill-in-the-blank, graded: a Correct / Incorrect pill under the field,
   plus the accepted answer when the typed one was wrong. */
.quiz-fitb-verdict {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem 0.75rem;
    margin: 0.75rem 0 0;
    color: var(--text-secondary);
    font-size: var(--fs-body-sm);
}

.quiz-fitb-verdict strong {
    color: var(--text-primary);
}

/* The radio stays in the page for keyboard and screen readers (arrow
   keys move through the group), visually hidden. .choice-tile hides its
   own input the same way; this covers the export's rows. */
.quiz-radio {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.quiz-answer-text {
    flex: 1;
    min-width: 0;
    color: var(--text-primary);
    font-size: 0.98rem;
}

.quiz-answer-icon {
    display: none;
    flex-shrink: 0;
    font-size: 1.15rem;
    line-height: 1;
}

/* SCORM export rows: the same tile look without the shared class. */
.quiz-answer-label:not(.choice-tile) {
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-height: var(--control-h);
    padding: var(--pad-inset);
    border: 1.5px solid var(--border-strong);
    border-radius: var(--r-md);
    background: var(--card-bg);
    cursor: pointer;
}

.quiz-answer-label:not(.choice-tile):hover {
    border-color: var(--primary-text);
    background: var(--primary-tint);
}

.quiz-answer-label:not(.choice-tile).selected {
    border-color: var(--primary-fill);
    background: var(--primary-tint);
}

/* Before submit: the chosen row (also from section-scripts.js's
   .selected, for engines without :has()). */
.choice-tile.quiz-answer-label.selected {
    border-color: var(--primary-fill);
    background: var(--primary-tint);
}

/* Graded: green on the right answer, red on a wrong pick, each with its
   own icon and words (.quiz-answer-icon); the selection check retires
   and the disabled rows keep full strength. Three classes out-rank the
   tile's checked state (.choice-tile:has(> input:checked)). */
.quiz-answer-label.correct-answer,
.choice-tile.quiz-answer-label.correct-answer {
    border-color: var(--success-text);
    background: var(--success-tint);
}

.quiz-answer-label.incorrect-answer,
.choice-tile.quiz-answer-label.incorrect-answer {
    border-color: var(--danger-text);
    background: var(--danger-tint);
}

.quiz-answer-label.correct-answer .quiz-answer-icon {
    display: inline-flex;
    color: var(--success-text);
}

.quiz-answer-label.incorrect-answer .quiz-answer-icon {
    display: inline-flex;
    color: var(--danger-text);
}

.choice-tile.quiz-answer-label.graded {
    opacity: 1;
    cursor: default;
    pointer-events: none;
}

.choice-tile.quiz-answer-label.graded::after {
    content: none;
}

.quiz-answer-label.graded {
    cursor: default;
    pointer-events: none;
}

/* Explanation after an answer: a .callout.is-info in the viewer. */
.quiz-explanation {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    margin: 0.85rem 0 0;
    font-size: 0.92rem;
    line-height: 1.55;
}

.quiz-explanation > i {
    flex-shrink: 0;
    margin-top: 0.15rem;
}

/* SCORM export: no .callout on its explanation. */
.quiz-explanation:not(.callout) {
    padding: 0.65rem 1rem;
    border-left: 3px solid var(--info-text);
    border-radius: 0 var(--r-sm) var(--r-sm) 0;
    background: var(--info-tint);
    color: var(--text-primary);
}

.quiz-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-top: 1rem;
}

/* SCORM export: a .btn-primary look for its Submit / Next buttons. */
.quiz-submit-btn:not(.btn) {
    display: inline-flex;
    flex: 1;
    align-items: center;
    justify-content: center;
    gap: var(--gap-icon);
    min-height: var(--control-h);
    padding: 0.6rem 2rem;
    border: none;
    border-radius: var(--r-sm);
    background: var(--primary-fill);
    color: #fff;
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
}

.quiz-submit-btn:not(.btn):hover {
    background: var(--primary-fill-hover);
}

/* Result card (knowledge check and exam): icon, verdict, score. */
.quiz-outcome {
    padding: 1.5rem 1rem;
    text-align: center;
}

.quiz-outcome-icon {
    display: block;
    margin-bottom: 0.4rem;
    font-size: 2.6rem;
    line-height: 1;
}

.quiz-outcome.is-passed .quiz-outcome-icon,
.quiz-outcome.is-passed .quiz-outcome-title {
    color: var(--success-text);
}

.quiz-outcome.is-failed .quiz-outcome-icon,
.quiz-outcome.is-failed .quiz-outcome-title {
    color: var(--danger-text);
}

.quiz-outcome-title {
    margin: 0 0 0.4rem;
    font-size: 1.35rem;
    font-weight: 700;
}

.quiz-outcome-score {
    margin: 0 0 0.25rem;
    color: var(--text-primary);
    font-size: 1.2rem;
    font-weight: 700;
}

.quiz-outcome-pass {
    margin: 0 0 1rem;
    color: var(--text-muted);
}

/* Learner banners above the topics. Each is a .callout (styles.css):
     .ce-enroll-banner     .callout.is-ce    invitation to enroll for CE
     .engaged-mode-banner  .callout.is-ce    CE assignment / self-enrolled
                           .callout.is-info  course assignment (locked
                                             playback for credit)
     .ce-earned-banner     .callout.is-ce    certificate issued
   CE has one look, the gold CE identity (--ce-text on --ce-tint). This
   only lays the icon, text and action out in a row. */
.learn-banner {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.75rem 1rem;
    margin-bottom: 1.25rem;
}

.learn-banner > .ti:first-child {
    flex-shrink: 0;
    font-size: 1.6rem;
    line-height: 1;
}

.learn-banner-body {
    flex: 1 1 16rem;
    min-width: 0;
}

.learn-banner .callout-title {
    display: block;
    margin-bottom: 0.1rem;
    font-size: 1rem;
}

.learn-banner-body > span {
    display: block;
    color: var(--text-secondary);
    font-size: var(--fs-meta);
    line-height: 1.45;
}

.learn-banner code {
    padding: 0.05rem 0.35rem;
    border-radius: var(--r-xs);
    background: var(--card-bg);
    color: var(--text-primary);
    font-size: 0.85em;
}

.learn-banner .btn {
    flex-shrink: 0;
}

/* Plain links in a banner's text (the earned banner's "profile
   transcript"): primary text, underlined, since the gold CE tint is too
   close to the default link colour in dark. */
.learn-banner a:not([class]) {
    color: var(--primary-text);
    text-decoration: underline;
    text-underline-offset: 2px;
}

/* Completion slide — synthetic final card shown when the user has an
   active engagement (CE or classroom). Lives at the end of the topic
   sequence; navigated to via the last topic's "Finish" button or the
   TOC's "Certificate" / "Submit" entry. Different visual states for
   pre-completion (progress prompt) vs post-completion (celebration). */
.section-card-completion .completion-card-inner {
    text-align: center;
    padding: 2.5rem 1.5rem 1rem;
}
.completion-icon {
    width: 88px;
    height: 88px;
    border-radius: 50%;
    margin: 0 auto 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5rem;
    background: var(--primary-tint);
    color: var(--primary-text);
}
/* CE: the gold identity, pending and earned alike. */
.completion-icon.is-ce,
.completion-icon-success {
    background: var(--ce-tint);
    color: var(--ce-text);
}
.completion-icon-success {
    animation: completionPulse 2s ease-out;
}
@keyframes completionPulse {
    0%   { transform: scale(0.8); box-shadow: 0 0 0 0 rgba(217, 179, 128, 0.45); }
    50%  { transform: scale(1.05); }
    100% { transform: scale(1); box-shadow: 0 0 0 18px rgba(217, 179, 128, 0); }
}
.completion-title {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0 0 0.5rem;
}
.completion-subtitle {
    color: var(--text-secondary);
    font-size: 1rem;
    max-width: 540px;
    margin: 0 auto 1.5rem;
    line-height: 1.5;
}
.completion-cert-info {
    max-width: 360px;
    margin: 0 auto 1.5rem;
    padding: 1rem 1.5rem;
}
.completion-cert-id {
    font-size: var(--fs-eyebrow);
    text-transform: uppercase;
    letter-spacing: var(--ls-eyebrow);
    font-weight: 700;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
}
.completion-cert-info code {
    display: block;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
    background: none;
    padding: 0;
    letter-spacing: 0.05em;
}
.completion-cert-date {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 0.5rem;
}
/* View / print (.btn-primary) and All my certificates (.btn-secondary). */
.completion-actions {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    justify-content: center;
    margin-bottom: 0.5rem;
}
.completion-progress-wrap { max-width: 360px; margin: 0 auto; }
.completion-progress-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.4rem;
}
/* The bar is a .fl-progress (styles.css). */

.completion-back-row {
    display: flex;
    justify-content: center;
    gap: 1rem;
    padding: 1.5rem;
    border-top: 1px solid var(--border-soft);
}

/* "Show what's missing" diagnostic — shown in engaged CE mode when the
   reqs check leaves any topic activity unsatisfied. Folded by default so
   it doesn't dominate a freshly-enrolled view; expand by click. An
   .surface-inset disclosure. */
.completion-missing-block {
    margin: 1.1rem auto 0;
    max-width: 560px;
    text-align: left;
    padding: 0.55rem 0.9rem;
}
.completion-missing-block summary {
    cursor: pointer;
    font-weight: 600;
    color: var(--text-secondary);
    list-style: none;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}
.completion-missing-block[open] summary { margin-bottom: 0.65rem; }
.completion-missing-list {
    margin: 0 0 0.55rem;
    padding-left: 1.15rem;
    color: var(--text-primary);
    font-size: 0.92rem;
    line-height: 1.55;
}
.completion-missing-reqs {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    color: var(--warning-text);
}
.completion-missing-hint {
    margin: 0;
    font-size: 0.82rem;
    color: var(--text-muted);
    line-height: 1.5;
}

/* Retry-issue block — shown when the server thinks the section is done
   but no cert row exists (auto-issue path missed it). A
   .callout.is-warning. */
.completion-retry-block {
    margin: 1.1rem auto 0;
    max-width: 560px;
    text-align: center;
}
.completion-retry-note {
    margin: 0 0 0.6rem;
    color: var(--text-primary);
    font-size: 0.9rem;
    line-height: 1.5;
}
.completion-retry-msg {
    margin: 0.6rem 0 0;
    color: var(--text-muted);
    font-size: 0.85rem;
    min-height: 1.2em;
}
.completion-retry-msg.is-error { color: var(--danger-text); }
.completion-retry-msg.is-success { color: var(--success-text); }

/* TOC entry for completion slide — distinct from numbered topics. */
.toc-item-completion {
    margin-top: 0.35rem;
    border-top: 1px dashed var(--border-soft);
    padding-top: 0.35rem;
}
.toc-link-completion .toc-number {
    background: var(--ce-tint);
    color: var(--ce-text);
    font-size: 0.95rem;
}
/* (The active number takes the shared white-on-fill look from
   .toc-link.active .toc-number; colouring it here hid the icon.) */
.toc-link-completion.active {
    color: var(--primary-text);
}

/* Nav-lock — TOC items beyond the user's current "frontier" in
   engaged mode. Muted text (full opacity, so the title still reads at
   AA) with a lock in the number tile; aria-disabled and a hidden
   "(locked)" carry the state for screen readers (section-scripts.js).
   Clicks shake the row instead of navigating. */
.toc-link.toc-locked {
    color: var(--text-muted);
    cursor: not-allowed;
    pointer-events: auto; /* keep clickable so the click handler can shake */
}
.toc-link.toc-locked:hover {
    background: transparent;
}
.toc-link.toc-locked .toc-number {
    background: color-mix(in srgb, var(--text-muted) 15%, transparent);
    color: var(--text-muted);
    position: relative;
}
.toc-link.toc-locked .toc-number::after {
    content: '\eae2'; /* ti-lock (Tabler 2.47.0) */
    font-family: 'tabler-icons';
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: inherit;
    border-radius: inherit;
    font-size: 0.85rem;
}
.toc-item.toc-shake {
    animation: tocShake 0.45s ease;
}
@keyframes tocShake {
    0%, 100% { transform: translateX(0); }
    20%      { transform: translateX(-4px); }
    40%      { transform: translateX(4px); }
    60%      { transform: translateX(-3px); }
    80%      { transform: translateX(2px); }
}

/* Global topic-navigation bar — a .surface-panel below .content-main
   inside .content-column on desktop; on mobile it just stacks below the
   topic content. Prev (.btn-secondary) / Next (.btn-primary), a
   "Topic X / Y" counter the JS updates as the user navigates, and the
   Finish button on the last topic in engaged mode. */
.content-nav-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.85rem 1.25rem;
    flex-shrink: 0;
}
.content-nav-counter {
    font-size: 0.92rem;
    font-weight: 600;
    color: var(--text-muted);
    letter-spacing: 0.02em;
    flex: 1;
    text-align: center;
}
/* Engaged-mode "what to do next" hint — replaces the Next button
   when the active topic's completion requirements are unmet. The
   warning tint doubles as a soft visual lock indicator. */
.content-nav-instructions {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.45rem 0.85rem;
    border-radius: var(--r-pill);
    background: var(--warning-tint);
    border: 1.5px solid var(--warning-border);
    color: var(--warning-text);
    font-size: 0.85rem;
    font-weight: 600;
    line-height: 1.3;
    max-width: 360px;
}
.content-nav-instructions i {
    font-size: 1rem;
    flex-shrink: 0;
    line-height: 1;
}
.content-nav-instructions-text {
    line-height: 1.3;
}
/* Hide the bar entirely when the learner is on the synthetic
   completion slide — that slide has its own "Back to last topic"
   action and the counter / next don't apply. JS adds .is-hidden. */
.content-nav-bar.is-hidden { display: none; }

/* Phone-sized screens — counter on its own line above the prev/next
   buttons so they have room to breathe and don't overlap. */
@media (max-width: 600px) {
    .content-nav-bar {
        flex-wrap: wrap;
        gap: 0.5rem 0.75rem;
        padding: 0.75rem 1rem;
    }
    .content-nav-bar .content-nav-counter {
        order: -1;
        flex: 1 0 100%;
        text-align: center;
        font-size: 0.85rem;
    }
    .content-nav-bar .topic-nav-btn {
        flex: 1;
        min-width: 0;
    }
    /* On topic 1 the JS hides Prev with visibility; with the counter on
       its own line there is no centring to keep, so drop the empty slot. */
    .content-nav-bar .topic-nav-prev[style*="visibility: hidden"] {
        display: none;
    }
}

/* =========================================================
   Editorial notes panel (creator+ only). Sits above the TOC
   + content layout on the topic viewer. One inner panel per
   topic; .is-active toggles visibility as the learner moves.
   ========================================================= */
.topic-notes {
    margin-bottom: 1.25rem;
    border: 1.5px solid color-mix(in srgb, var(--primary-soft) 28%, var(--border-soft));
    border-radius: 14px;
    background: color-mix(in srgb, var(--primary-soft) 4%, var(--card-bg));
    overflow: hidden;
}
[data-theme="dark"] .topic-notes {
    background: color-mix(in srgb, var(--primary-soft) 8%, var(--card-bg));
    border-color: color-mix(in srgb, var(--primary-soft) 38%, var(--border-soft));
}
.topic-notes-header {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    padding: 0.65rem 1rem;
    background: color-mix(in srgb, var(--primary-soft) 10%, var(--card-bg));
    border-bottom: 1px solid color-mix(in srgb, var(--primary-soft) 22%, var(--border-soft));
    font-size: 0.85rem;
    color: var(--text-secondary);
    cursor: pointer;
    user-select: none;
    transition: background 0.15s ease;
}
.topic-notes-header:hover { background: color-mix(in srgb, var(--primary-soft) 14%, var(--card-bg)); }
.topic-notes-header:focus-visible {
    outline: 2px solid var(--primary-soft);
    outline-offset: -2px;
}
.topic-notes-header > i:first-child { color: var(--primary-soft); font-size: 1.05rem; }
.topic-notes-header-title {
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: 0.02em;
    text-transform: uppercase;
    font-size: 0.78rem;
}
.topic-notes-header-meta { color: var(--text-muted); font-size: 0.78rem; }
.topic-notes-collapse-icon {
    margin-left: auto;
    color: var(--text-muted);
    font-size: 1.05rem;
    transition: transform 0.18s ease, color 0.15s ease;
}
.topic-notes-header:hover .topic-notes-collapse-icon { color: var(--text-primary); }
.topic-notes-body { padding: 0.85rem 1rem 1rem; }
.topic-notes.is-collapsed .topic-notes-body { display: none; }
.topic-notes.is-collapsed .topic-notes-header { border-bottom: none; }

.topic-notes-panel { display: none; }
.topic-notes-panel.is-active { display: block; }

.topic-notes-list {
    list-style: none;
    padding: 0;
    margin: 0 0 0.85rem;
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
}
.topic-notes-list:empty { display: none; }

.topic-note {
    padding: 0.65rem 0.85rem;
    background: var(--card-bg);
    border: 1px solid var(--border-soft);
    border-radius: 10px;
}
.topic-note-head {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    margin-bottom: 0.3rem;
    flex-wrap: wrap;
}
.topic-note-author {
    color: var(--text-primary);
    font-size: 0.88rem;
    font-weight: 700;
}
.topic-note-when { color: var(--text-muted); font-size: 0.78rem; }
.topic-note-actions { margin-left: auto; display: flex; gap: 0.25rem; }
.topic-note-action-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.15rem 0.35rem;
    border-radius: 6px;
    font-size: 0.9rem;
    line-height: 1;
    transition: background 0.15s ease, color 0.15s ease;
}
.topic-note-action-btn:hover { background: color-mix(in srgb, var(--primary-soft) 16%, transparent); color: var(--text-primary); }
.topic-note-action-btn.topic-note-action-del:hover { background: var(--danger-tint); color: var(--danger-text); }
.topic-note-body {
    color: var(--text-primary);
    font-size: 0.92rem;
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-word;
}
.topic-note-body.is-editing { display: none; }
.topic-note-edit-textarea {
    width: 100%;
    min-height: 80px;
    padding: 0.55rem 0.7rem;
    border-radius: 8px;
    border: 1.5px solid var(--border-soft);
    background: var(--input-bg);
    color: var(--text-primary);
    font: inherit;
    line-height: 1.5;
    resize: vertical;
}
.topic-note-edit-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.4rem;
    font-size: 0.85rem;
}

.topic-notes-empty {
    color: var(--text-muted);
    font-size: 0.85rem;
    font-style: italic;
    padding: 0.35rem 0 0.65rem;
}

.topic-notes-form { display: flex; flex-direction: column; gap: 0.5rem; }
/* The note field is a .form-control (the site field recipe). */
.topic-notes-textarea {
    min-height: 60px;
    line-height: 1.5;
    resize: vertical;
}
.topic-notes-form-row {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    flex-wrap: wrap;
}
/* Add note: a .btn.btn-primary.btn-sm. */
.topic-notes-form-msg { color: var(--text-muted); font-size: 0.8rem; }
.topic-notes-form-msg.is-error { color: var(--danger-text); }

/* TOC asterisk for topics with editorial notes (creator+ only). Small,
   amber, sits flush against the title without changing the line height. */
.toc-note-marker {
    display: inline-block;
    margin-left: 0.25rem;
    color: var(--warning-text);
    font-weight: 800;
    line-height: 1;
}

/* Text size, chosen by the reader with the "Text size" button (section-scripts.js). The topic's own text grows;
   headings and blocks inside it are sized from it, so they grow too. Screen only: paper keeps the normal size. */
@media screen {
    html[data-text-size="1"] .section-content-inner { font-size: 1.15em; }
    html[data-text-size="2"] .section-content-inner { font-size: 1.3em; }
    /* Headings are normally sized from the page, not from the topic's text, so they would stay as they are.
       These are their normal sizes (24, 20 and 17.6px beside 16px text) written as multiples of the text. */
    html[data-text-size] .section-content-inner h2 { font-size: 1.5em; }
    html[data-text-size] .section-content-inner h3 { font-size: 1.25em; }
    html[data-text-size] .section-content-inner h4 { font-size: 1.1em; }
}
