h1:focus {
    outline: none;
}

.valid.modified:not([type=checkbox]) {
    outline: 1px solid #26b050;
}

.invalid {
    outline: 1px solid #e50000;
}

.validation-message {
    color: #e50000;
}

.blazor-error-boundary {
    background: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTYiIGhlaWdodD0iNDkiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIG92ZXJmbG93PSJoaWRkZW4iPjxkZWZzPjxjbGlwUGF0aCBpZD0iY2xpcDAiPjxyZWN0IHg9IjIzNSIgeT0iNTEiIHdpZHRoPSI1NiIgaGVpZ2h0PSI0OSIvPjwvY2xpcFBhdGg+PC9kZWZzPjxnIGNsaXAtcGF0aD0idXJsKCNjbGlwMCkiIHRyYW5zZm9ybT0idHJhbnNsYXRlKC0yMzUgLTUxKSI+PHBhdGggZD0iTTI2My41MDYgNTFDMjY0LjcxNyA1MSAyNjUuODEzIDUxLjQ4MzcgMjY2LjYwNiA1Mi4yNjU4TDI2Ny4wNTIgNTIuNzk4NyAyNjcuNTM5IDUzLjYyODMgMjkwLjE4NSA5Mi4xODMxIDI5MC41NDUgOTIuNzk1IDI5MC42NTYgOTIuOTk2QzI5MC44NzcgOTMuNTEzIDI5MSA5NC4wODE1IDI5MSA5NC42NzgyIDI5MSA5Ny4wNjUxIDI4OS4wMzggOTkgMjg2LjYxNyA5OUwyNDAuMzgzIDk5QzIzNy45NjMgOTkgMjM2IDk3LjA2NTEgMjM2IDk0LjY3ODIgMjM2IDk0LjM3OTkgMjM2LjAzMSA5NC4wODg2IDIzNi4wODkgOTMuODA3MkwyMzYuMzM4IDkzLjAxNjIgMjM2Ljg1OCA5Mi4xMzE0IDI1OS40NzMgNTMuNjI5NCAyNTkuOTYxIDUyLjc5ODUgMjYwLjQwNyA1Mi4yNjU4QzI2MS4yIDUxLjQ4MzcgMjYyLjI5NiA1MSAyNjMuNTA2IDUxWk0yNjMuNTg2IDY2LjAxODNDMjYwLjczNyA2Ni4wMTgzIDI1OS4zMTMgNjcuMTI0NSAyNTkuMzEzIDY5LjMzNyAyNTkuMzEzIDY5LjYxMDIgMjU5LjMzMiA2OS44NjA4IDI1OS4zNzEgNzAuMDg4N0wyNjEuNzk1IDg0LjAxNjEgMjY1LjM4IDg0LjAxNjEgMjY3LjgyMSA2OS43NDc1QzI2Ny44NiA2OS43MzA5IDI2Ny44NzkgNjkuNTg3NyAyNjcuODc5IDY5LjMxNzkgMjY3Ljg3OSA2Ny4xMTgyIDI2Ni40NDggNjYuMDE4MyAyNjMuNTg2IDY2LjAxODNaTTI2My41NzYgODYuMDU0N0MyNjEuMDQ5IDg2LjA1NDcgMjU5Ljc4NiA4Ny4zMDA1IDI1OS43ODYgODkuNzkyMSAyNTkuNzg2IDkyLjI4MzcgMjYxLjA0OSA5My41Mjk1IDI2My41NzYgOTMuNTI5NSAyNjYuMTE2IDkzLjUyOTUgMjY3LjM4NyA5Mi4yODM3IDI2Ny4zODcgODkuNzkyMSAyNjcuMzg3IDg3LjMwMDUgMjY2LjExNiA4Ni4wNTQ3IDI2My41NzYgODYuMDU0N1oiIGZpbGw9IiNGRkU1MDAiIGZpbGwtcnVsZT0iZXZlbm9kZCIvPjwvZz48L3N2Zz4=) no-repeat 1rem/1.8rem, #b32121;
    padding: 1rem 1rem 1rem 3.7rem;
    color: white;
}

    .blazor-error-boundary::after {
        content: "An error has occurred."
    }

.darker-border-checkbox.form-check-input {
    border-color: #929292;
}

.form-floating > .form-control-plaintext::placeholder, .form-floating > .form-control::placeholder {
    color: var(--bs-secondary-color);
    text-align: end;
}

.form-floating > .form-control-plaintext:focus::placeholder, .form-floating > .form-control:focus::placeholder {
    text-align: start;
}

/* ── MWS passage rendering (Phase 2 Milestone A) ─────────────────────────── */

.mws-location-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    margin-bottom: 1rem;
    font-weight: 600;
}

.mws-passage {
    padding: 1rem;
    margin: 0.5em;
}

/* hub: a calmer, card-like frame for home-base passages */
.mws-passage.layout-hub {
    border: 1px solid #ccc;
    border-radius: 0.5rem;
    background: #fafafa;
}

/* Extractor-hoisted title/subtitle (hub/narration passages only — see CradleExtractor's
   TryHoistHeadingTitleSubtitle) get their own header region ahead of the node-driven body. */
.mws-passage-header {
    margin-bottom: 0.75rem;
}

.mws-passage-title {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 700;
}

.mws-passage-subtitle {
    margin: 0.15rem 0 0;
    font-size: 1.05rem;
    font-weight: 400;
    opacity: 0.8;
}

/* Module-authored layout chrome (layouts/{id}.yaml, matched by a passage's or popup's own layout
   name — see LoadedModule.LayoutChrome/RenderedLayoutChrome). Bare structural hooks only, same
   treatment as .mws-location-header — a module's own CSS is entirely responsible for how these
   look; the app never branches on what layout they belong to or what they contain. */
.mws-layout-header,
.mws-layout-footer,
.mws-layout-before-content,
.mws-layout-after-content {
    display: block;
}

/* text/link default to inline flow — a passage's own explicit 'break' nodes are what create line
   separation (see .mws-break below), not the node's own display box. This mirrors how the format
   is actually authored: the extractor emits an explicit break between every line/paragraph of
   text rather than relying on block-level text nodes to self-separate. */
.mws-text {
    display: inline;
}

/* text-align only has an effect on a block formatting context, so an explicitly aligned text node
   is the one deliberate override to the inline default above — it needs its own line to align
   within. Unaligned text stays inline and flows with its neighbors. */
.mws-text.align-left,
.mws-text.align-center,
.mws-text.align-right,
.mws-text.align-justified {
    display: block;
}

.mws-text.align-left { text-align: left; }
.mws-text.align-center { text-align: center; }
.mws-text.align-right { text-align: right; }
.mws-text.align-justified { text-align: justify; }

/* Bare break = <br>-equivalent: a line break only, no added vertical spacing (the element's a
   <div>, so this is just the do-nothing default — no rule needed here). */
.mws-break{
    display: block;
}

/* style="paragraph" = a paragraph boundary: vertical spacing on top of the line break, roughly
   what two adjacent <p> margins would collapse to. */
.mws-break.style-paragraph {
    margin-top: 0.75rem;
}

.mws-section {
    margin: 1rem 0;
    padding: 0.5rem 1rem;
    border-left: 3px solid #ddd;
}

/* Links default to inline text-link styling, not button chrome — a <button> element is used for
   click/keyboard semantics, but visually it should read as a hyperlink within flowing text.
   Modules that want a prominent button-style choice opt in via style="button" (see e.g.
   .mws-link.style-button in a module's own stylesheet). */
.mws-link {
    display: inline;
    background: none;
    border: none;
    margin: 0;
    padding: 0;
    font: inherit;
    color: #1a56db;
    text-decoration: underline;
    cursor: pointer;
}

.mws-link:hover:not(:disabled) {
    color: #123f9e;
}

.mws-link:disabled {
    color: #888;
    text-decoration: none;
    cursor: default;
}

.mws-link.state-affecting {
    font-weight: 600;
}

.mws-image {
    padding: 0.5rem;
    margin: 0.5rem 0;
    font-style: italic;
}

/* An <img>'s UA-default display is inline, which only respects horizontal margins as part of the
   surrounding line box — centering/right-aligning it needs its own line first, same reasoning as
   .mws-text.align-* above. left/justified get the block treatment too (for the "own line, doesn't
   flow with neighboring inline content" behavior an explicit align implies) but no margin override
   — an image has no text-align-justify equivalent, and block-level default margins already read as
   left-aligned. */
.mws-image.align-left,
.mws-image.align-center,
.mws-image.align-right,
.mws-image.align-justified {
    display: block;
}

.mws-image.align-center { margin-left: auto; margin-right: auto; }
.mws-image.align-right { margin-left: auto; margin-right: 0; }

.mws-audio-track {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    padding: 0.5rem;
    margin: 0.5rem 0;
}

.mws-audio-track-title {
    font-style: italic;
}

.mws-audio-track-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.mws-audio-track-play,
.mws-audio-track-pause {
    width: 2rem;
    height: 2rem;
    flex: none;
    border: none;
    border-radius: 50%;
    background: #1a56db;
    cursor: pointer;
}

.mws-audio-track-play:disabled,
.mws-audio-track-pause:disabled {
    background: #888;
    cursor: default;
}

.mws-audio-track-scrubber {
    flex: 1 1 auto;
}

.mws-audio-track-time {
    flex: none;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.mws-input {
    padding: 0.5rem;
    margin: 0.5rem 0;
    background: #f0f0f0;
}

.mws-input-options {
    padding: 0.5rem;
    margin: 0.5rem 0;
    background: #f0f0f0;
    border: none;
}

.mws-input-option {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.15rem 0;
}

.mws-popup-trigger {
    margin: 0.25rem 0.5rem 0.25rem 0;
    padding: 0.4rem 0.9rem;
}

.mws-popup-overlay {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background: rgba(0, 0, 0, 0.6);
    z-index: 1000;
}

.mws-popup-overlay > * {
    background: #fff;
    padding: 1.5rem;
    border-radius: 0.5rem;
    max-width: 30rem;
}

/* .mws-popup-container wraps the header/content/footer regions (see RenderedPopupView.razor). */
.mws-popup-container {
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 2rem);
}

.mws-popup-content {
    overflow-y: auto;
    /* Without an explicit overflow-x, the spec computes it as auto (not visible) once overflow-y
       is non-visible — so any 1px rounding overflow (fractional vw widths, mask pseudo-elements)
       triggers a spurious horizontal scrollbar even though text is wrapping correctly. Content
       here is only ever meant to scroll vertically. */
    overflow-x: hidden;
}

.mws-popup-footer {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
    flex-shrink: 0;
}

/* ── Pause bar (Play.razor's pause mode) ─────────────────────────────────────
   A full-width panel fixed to the bottom of the screen — not a modal, so its own
   z-index sits below .mws-dialog-overlay (1100, see below) so the resume-confirm
   and quit dialogs it can open still stack above it, but above ordinary passage
   content. Always mounted now (see Play.razor) rather than added/removed via @if, so it can slide
   in/out — the transform/transition below is a generic default (translate fully off-screen when
   closed); a module can override the visual specifics (border art, exact offset) on the same
   .mws-pause-bar/.mws-pause-bar--open selectors, which win by cascade order (its <style> tag is
   appended to <head> after this file's <link>). */
.mws-pause-bar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1050;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem calc(0.5rem + env(safe-area-inset-bottom));
    background: #1c1c1c;
    color: #fff;
    box-shadow: 0 -0.25rem 0.75rem rgba(0, 0, 0, 0.35);
    transform: translateY(100%);
    transition: transform 0.25s ease;
    pointer-events: none;
}

.mws-pause-bar.mws-pause-bar--open {
    transform: translateY(0);
    pointer-events: auto;
}

.mws-pause-scrubber-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.mws-pause-nav-button {
    flex: none;
    min-width: 2.25rem;
    padding: 0.35rem 0.5rem;
    font-size: 1rem;
    line-height: 1;
    background: rgba(255, 255, 255, 0.12);
    color: inherit;
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 0.35rem;
}

.mws-pause-nav-button:disabled {
    opacity: 0.35;
}

.mws-pause-forward-group {
    display: flex;
    flex: none;
    gap: 0.35rem;
}

.mws-pause-actions-row {
    display: flex;
    justify-content: center;
    gap: 0.75rem;
}

/* The scrubber itself — every entry always renders (no paging), but the row never wraps, so with
   many entries most of it sits off to either side; centerElement (timelineScrubber.js) scrolls the
   highlighted entry into view instead of relying on the player to drag/scroll manually. The
   scrollbar itself is hidden since dragging it isn't a supported interaction, just a side effect of
   needing a real scroll container for that to work. */
.mws-timeline-list {
    display: flex;
    align-items: center;
    flex: 1;
    min-width: 0;
    gap: 0.25rem;
    list-style: none;
    padding: 0.15rem 0.35rem;
    margin: 0;
    overflow-x: auto;
    scrollbar-width: none;
    border-left: 1px solid rgba(255, 255, 255, 0.2);
    border-right: 1px solid rgba(255, 255, 255, 0.2);
}

.mws-timeline-list::-webkit-scrollbar {
    display: none;
}

.mws-timeline-entry {
    flex: none;
    max-width: 6rem;
    padding: 0.25rem 0.5rem;
    background: rgba(255, 255, 255, 0.12);
    border-radius: 0.25rem;
    font-size: 0.8rem;
}

.mws-timeline-label {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.mws-timeline-entry.current {
    background: #7c3aed;
    color: #fff;
    font-weight: 600;
}

.mws-timeline-entry.checkpoint {
    border: 1px dashed #7c3aed;
}

.mws-timeline-current-marker {
    font-style: italic;
}

.mws-inline-icon {
    height: 1.1em;
    width: 1.1em;
    vertical-align: text-bottom;
}

.mws-image-missing {
    padding: 0.5rem;
    margin: 0.5rem 0;
    background: #f0f0f0;
    font-style: italic;
}

.mws-audio-test {
    margin-top: 1rem;
    padding: 0.5rem 1rem;
    background: #f5f5f5;
    border-radius: 0.5rem;
}

/* ── App shell (Phase 3 Milestone A) ─────────────────────────────────────── */

:root {
    --mws-text-scale: 1;
}

body {
    font-size: calc(1rem * var(--mws-text-scale));
}

.mws-back-button,
.mws-options-button,
.mws-pause-button {
    padding: 0.4rem 0.9rem;
}

.mws-play-chrome {
    display: flex;
    align-items: flex-start;
    justify-content: flex-end;
    gap: 0.5rem;
    margin-bottom: 1rem;
    /* Stays above every overlay (popup backdrop, options dialog) and above scrolled passage
       content — the pause and options buttons must stay reachable no matter what's showing on top
       of the passage itself. Hidden entirely while paused (Play.razor) — .mws-pause-bar takes over
       at the bottom of the screen instead. */
    position: sticky;
    top: 0;
    z-index: 1200;
    background: transparent;
    padding: 0.5rem 0;
}

.mws-options-button,
.mws-pause-button {
    font-size: 1.2rem;
    line-height: 1;
}

.mws-main-menu-buttons,
.mws-tabs,
.mws-help-topics {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.mws-tabs,
.mws-help-topics {
    flex-direction: row;
    flex-wrap: wrap;
}

.mws-tabs button.selected,
.mws-help-topics button.selected {
    background: #7c3aed;
    color: #fff;
}

.mws-help {
    display: flex;
    gap: 1.5rem;
    align-items: flex-start;
}

.mws-help-topics {
    flex-direction: column;
    flex: 0 0 auto;
}

.mws-help-content {
    flex: 1;
}

.mws-empty-state {
    font-style: italic;
    color: #666;
}

.mws-continue-empty {
    text-align: center;
    font-style: italic;
    color: #666;
    padding: 2rem 1rem;
}

.mws-achievement-module {
    margin: 1rem 0;
    padding: 0.5rem 1rem;
    background: #f5f5f5;
    border-radius: 0.5rem;
}

.mws-module-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    margin: 0.5rem 0;
    background: #f5f5f5;
    border-radius: 0.5rem;
}

.mws-delete-confirm {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.mws-badge {
    display: inline-block;
    padding: 0.1rem 0.5rem;
    margin-left: 0.5rem;
    font-size: 0.75rem;
    background: #7c3aed;
    color: #fff;
    border-radius: 1rem;
}

.mws-module-toolbar {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.mws-upload-button {
    display: inline-flex;
    align-items: center;
    padding: 0.35rem 0.75rem;
    border: 1px solid ButtonBorder;
    border-radius: 0.25rem;
    background: ButtonFace;
    color: ButtonText;
    font: inherit;
    cursor: pointer;
}

/* Visually hidden but still focusable/clickable-via-label — unlike display:none, this pattern is
   reliably triggerable by a <label for="..."> across browsers/WebViews for file inputs. */
.mws-visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.mws-module-carousel {
    display: flex;
    gap: 1rem;
    overflow-x: auto;
    padding-bottom: 0.5rem;
}

.mws-module-tile {
    position: relative;
    flex: 0 0 auto;
    width: 12rem;
    padding: 1rem;
    background: #f5f5f5;
    border: 2px solid transparent;
    border-radius: 0.5rem;
    cursor: pointer;
}

.mws-module-tile.selected {
    border-color: #7c3aed;
}

.mws-tile-version {
    position: absolute;
    bottom: 0.35rem;
    right: 0.5rem;
    font-size: 0.7rem;
    color: #666;
}

.mws-module-detail {
    position: relative;
    margin-top: 1rem;
    padding: 1rem;
    padding-bottom: 2.5rem;
    background: #f5f5f5;
    border-radius: 0.5rem;
}

.mws-module-language {
    position: absolute;
    bottom: 0.75rem;
    right: 1rem;
}

.mws-save-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.75rem 1rem;
    margin: 0.5rem 0;
    background: #f5f5f5;
    border-radius: 0.5rem;
}

.mws-save-info {
    display: flex;
    flex-direction: column;
    gap: 0.5em;
}

.mws-save-actions {
    display: flex;
    align-items: center;
    gap: 0.5em;
    flex-wrap: wrap;
}

.mws-module-row-info {
    display: flex;
    flex-direction: column;
    gap: 0.5em;
}

.mws-save-timestamp {
    font-size: 0.85em;
    color: #666;
}

.mws-save-language {
    font-size: 0.75em;
    color: #999;
}

.mws-version-warning {
    font-size: 0.85em;
    color: #b32121;
}

.mws-dialog-overlay {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background: rgba(0, 0, 0, 0.6);
    z-index: 1100;
}

.mws-dialog {
    background: #fff;
    padding: 1.5rem;
    border-radius: 0.5rem;
    max-width: 26em;
    width: 100%;
}

/* Label stacked above its controls (not inline) — flex-direction: column here is the structural
   default; a module's own CSS skins the input/value/checkbox pieces on top (see .mws-options-input
   etc. below). The controls themselves (slider, value, mute checkbox+label) stay in their own
   horizontal row via .mws-options-controls, nested inside. */
.mws-options-row {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0.25rem;
    margin: 0.5rem 0;
}

.mws-options-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.mws-options-controls input[type="range"] {
    flex: 1;
}

.mws-options-controls select {
    flex: 1;
}

.mws-options-hint {
    cursor: help;
    opacity: 0.7;
}

.mws-dialog-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
}

.mws-dialog-footer {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid #ddd;
}

.mws-quit-button {
    color: #b32121;
}

.mws-save-name-input {
    width: 100%;
    padding: 0.4rem;
    margin-top: 0.5rem;
}

.mws-nav-error-detail {
    font-family: monospace;
    font-size: 0.85rem;
    opacity: 0.75;
    word-break: break-word;
}

/* ── Responsive / platform layout (Phase 2 Milestone C) ──────────────────────
   Mobile-first base styles above (see .mws-passage etc.); widen up for
   tablet/desktop below. iOS/MacCatalyst can't be built or tested here yet (no
   Mac build host) — this is CSS-only, so it applies to those targets too
   whenever that changes. */

/* Respect notches/rounded corners/home indicators on phones and tablets
   (Android/iOS status bars, the "status-bar-safe-area" div already present
   in the MAUI head's wwwroot/index.html). */
body {
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
    margin: 0;
}

@media (max-width: 47.99rem) {
    .mws-popup-overlay > * {
        max-width: none;
        width: 100%;
        height: 100%;
        border-radius: 0;
        overflow-y: auto;
    }
}

/* Web-only: shown in Components/App.razor while the WASM bundle downloads and boots (prerendering
   is off), removed once Blazor.start() resolves. Structural only —
   same split as .mws-main-menu: colors/logo/tagline art come from the theme's own theme.css
   (.mws-splash / .mws-splash-logo / .mws-splash-tagline), not from here. */
.mws-splash {
    position: fixed;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    z-index: 9999;
}

.mws-splash-tagline {
    margin: 0;
    max-width: 26rem;
    text-align: center;
}

.mws-spinner {
    width: 2rem;
    height: 2rem;
    border-width: 0.25rem;
    border-style: solid;
    border-radius: 50%;
    animation: mws-spin 0.8s linear infinite;
}

.mws-loading-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    color: #fff;
}

.mws-loading-progress-track {
    width: 14rem;
    max-width: 80vw;
    height: 0.5rem;
    background: rgba(255, 255, 255, 0.25);
    border-radius: 999px;
    overflow: hidden;
}

.mws-loading-progress-fill {
    height: 100%;
    background: #fff;
}

@keyframes mws-spin {
    to {
        transform: rotate(360deg);
    }
}
