html, body {
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

body {
    background-color: var(--bs-body-bg);
}

h1:focus {
    outline: none;
}

/* ---------------------------------------------------------------- template */

.valid.modified:not([type=checkbox]) {
    outline: 1px solid #26b050;
}

.invalid {
    outline: 1px solid red;
}

.validation-message {
    color: var(--bs-danger-text-emphasis);
}

#blazor-error-ui {
    color-scheme: light only;
    background: lightyellow;
    color: #212529;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    box-sizing: border-box;
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

    #blazor-error-ui .dismiss {
        cursor: pointer;
        position: absolute;
        right: 0.75rem;
        top: 0.5rem;
    }

.blazor-error-boundary {
    background: #b32121;
    padding: 1rem 1rem 1rem 1.5rem;
    color: white;
}

    .blazor-error-boundary::after {
        content: "An error has occurred."
    }

.loading-progress {
    position: absolute;
    display: block;
    width: 8rem;
    height: 8rem;
    inset: 20vh 0 auto 0;
    margin: 0 auto 0 auto;
}

    .loading-progress circle {
        fill: none;
        stroke: var(--bs-secondary-bg);
        stroke-width: 0.6rem;
        transform-origin: 50% 50%;
        transform: rotate(-90deg);
    }

        .loading-progress circle:last-child {
            stroke: #8b3a2b;
            stroke-dasharray: calc(3.141 * var(--blazor-load-percentage, 0%) * 0.8), 500%;
            transition: stroke-dasharray 0.05s ease-in-out;
        }

.loading-progress-text {
    position: absolute;
    text-align: center;
    font-weight: bold;
    inset: calc(20vh + 3.25rem) 0 auto 0.2rem;
}

    .loading-progress-text:after {
        content: var(--blazor-load-percentage-text, "Loading");
    }

.app-loading-caption {
    position: absolute;
    inset: calc(20vh + 9.5rem) 1rem auto 1rem;
    text-align: center;
    color: var(--bs-secondary-color);
}

code {
    color: var(--bs-code-color);
}

/* ---------------------------------------------------------------- layout */

.content {
    padding-top: 0.5rem;
    padding-bottom: 2rem;
}

.page-lead {
    color: var(--bs-secondary-color);
    max-width: 60rem;
}

.card-link-tile {
    color: inherit;
    text-decoration: none;
    transition: border-color 0.15s ease-in-out, transform 0.15s ease-in-out;
}

    .card-link-tile:hover, .card-link-tile:focus-visible {
        border-color: var(--bs-primary);
    }

.stat-value {
    font-size: 1.75rem;
    font-weight: 600;
    line-height: 1.1;
}

.stat-label {
    color: var(--bs-secondary-color);
    font-size: 0.85rem;
}

.hero-figure {
    font-size: 3.25rem;
    font-weight: 600;
    line-height: 1;
}

.weight-badge {
    font-weight: 500;
    color: var(--bs-body-color) !important;
    background-color: var(--bs-tertiary-bg) !important;
}

.theme-toggle {
    white-space: nowrap;
}

/* ---------------------------------------------------------------- content */

.source-citations {
    font-size: 0.85rem;
    color: var(--bs-secondary-color);
    margin-top: 0.75rem;
}

    .source-citations ul {
        margin: 0.25rem 0 0 0;
        padding-left: 1.25rem;
    }

    .source-citations.compact ul {
        margin-top: 0.1rem;
    }

    .source-citations .source-label {
        font-weight: 600;
    }

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

    .markdown-body table {
        display: block;
        overflow-x: auto;
        max-width: 100%;
    }

    .markdown-body h1 {
        font-size: 1.5rem;
    }

    .markdown-body h2 {
        font-size: 1.3rem;
        margin-top: 1.5rem;
    }

    .markdown-body h3 {
        font-size: 1.1rem;
        margin-top: 1.25rem;
    }

    .markdown-body blockquote {
        border-left: 4px solid var(--bs-border-color);
        padding-left: 1rem;
        color: var(--bs-secondary-color);
    }

.source-notes .markdown-body p {
    margin-bottom: 0;
    overflow-wrap: anywhere;
}

.key-points li::marker {
    color: #8b3a2b;
}

.note-text {
    white-space: pre-wrap;
    background: var(--bs-warning-bg-subtle);
    border-radius: 0.375rem;
    padding: 0.5rem 0.75rem;
    font-size: 0.9rem;
}

/* ---------------------------------------------------------------- questions */

.question-stem {
    font-size: 1.1rem;
    font-weight: 500;
    white-space: pre-line;
}

.question-options .list-group-item {
    padding: 0.75rem 1rem;
}

.option-letter {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.75rem;
    height: 1.75rem;
    border-radius: 50%;
    border: 1px solid currentColor;
    font-weight: 600;
    font-size: 0.85rem;
}

.question-options .list-group-item.active .option-letter {
    background: rgba(255, 255, 255, 0.2);
}

.question-feedback {
    border-left: 4px solid;
    padding: 0.75rem 1rem;
    background: var(--bs-tertiary-bg);
    border-radius: 0.375rem;
}

.question-navigator {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(2.6rem, 1fr));
    gap: 0.35rem;
}

    .question-navigator .btn {
        position: relative;
        padding: 0.3rem 0;
        font-variant-numeric: tabular-nums;
    }

    .question-navigator .btn.current {
        outline: 3px solid var(--bs-primary);
        outline-offset: 1px;
    }

    .question-navigator .nav-flag {
        position: absolute;
        top: -0.35rem;
        right: -0.25rem;
        font-size: 0.7rem;
        color: #d39e00;
    }

.legend-box {
    display: inline-block;
    width: 0.8rem;
    height: 0.8rem;
    border: 1px solid var(--bs-secondary);
    border-radius: 0.2rem;
    vertical-align: -0.1rem;
}

    .legend-box.answered {
        background: var(--bs-secondary);
    }

.exam-timer {
    font-size: 1.25rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

/* ---------------------------------------------------------------- flashcards */

.flashcard {
    min-height: 16rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
    border-width: 2px;
}

.flashcard-front {
    font-size: 1.25rem;
    font-weight: 500;
    white-space: pre-line;
}

.flashcard-back {
    font-size: 1.1rem;
    white-space: pre-line;
}

.grade-buttons .btn {
    min-width: 6.5rem;
}

.grade-buttons small {
    display: block;
    font-size: 0.75rem;
    opacity: 0.8;
}

/* ---------------------------------------------------------------- charts */

/* Chart colour roles (validated for colour-vision deficiency against both theme surfaces). */
:root {
    --viz-series-1: #2a78d6;
    --viz-track: #cde2fb;
    --viz-grid: #e1e0d9;
    --viz-axis: #c3c2b7;
    --viz-ref: #52514e;
    --viz-surface: var(--bs-body-bg);
    --viz-empty: #ecebe7;
    --viz-heat-1: #86b6ef;
    --viz-heat-2: #5598e7;
    --viz-heat-3: #2a78d6;
    --viz-heat-4: #1c5cab;
}

:root[data-bs-theme="dark"] {
    --viz-series-1: #3987e5;
    --viz-track: #104281;
    --viz-grid: #373b3e;
    --viz-axis: #495057;
    --viz-ref: #c3c2b7;
    --viz-empty: #2b3035;
    --viz-heat-1: #1c5cab;
    --viz-heat-2: #2a78d6;
    --viz-heat-3: #5598e7;
    --viz-heat-4: #9ec5f4;
}

.viz svg {
    display: block;
    width: 100%;
    height: auto;
    overflow: visible;
}

.viz text {
    fill: var(--bs-secondary-color);
    font-size: 13px;
}

.viz .viz-value {
    fill: var(--bs-body-color);
    font-weight: 600;
}

.viz .viz-mark {
    fill: var(--viz-series-1);
}

.viz .viz-hit:hover .viz-mark, .viz .viz-hit:focus .viz-mark {
    opacity: 0.8;
}

.viz .viz-hit:focus {
    outline: none;
}

.viz .viz-hit:focus-visible .viz-focus {
    stroke: var(--bs-body-color);
    stroke-width: 1.5;
}

.viz .viz-grid {
    stroke: var(--viz-grid);
    stroke-width: 1;
}

.viz .viz-axis {
    stroke: var(--viz-axis);
    stroke-width: 1;
}

.viz .viz-ref {
    stroke: var(--viz-ref);
    stroke-width: 1.5;
}

.viz .viz-line {
    fill: none;
    stroke: var(--viz-series-1);
    stroke-width: 2;
    stroke-linejoin: round;
    stroke-linecap: round;
}

.viz .viz-dot {
    fill: var(--viz-series-1);
    stroke: var(--viz-surface);
    stroke-width: 2;
}

.heat-swatch {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 2px;
}

.swatch-0 { background-color: var(--viz-empty); }
.swatch-1 { background-color: var(--viz-heat-1); }
.swatch-2 { background-color: var(--viz-heat-2); }
.swatch-3 { background-color: var(--viz-heat-3); }
.swatch-4 { background-color: var(--viz-heat-4); }

.viz .heat-0 { fill: var(--viz-empty); }
.viz .heat-1 { fill: var(--viz-heat-1); }
.viz .heat-2 { fill: var(--viz-heat-2); }
.viz .heat-3 { fill: var(--viz-heat-3); }
.viz .heat-4 { fill: var(--viz-heat-4); }

.meter {
    height: 0.5rem;
    border-radius: 0.25rem;
    background-color: var(--viz-track);
    overflow: hidden;
}

    .meter > span {
        display: block;
        height: 100%;
        border-radius: 0.25rem;
        background-color: var(--viz-series-1);
    }

/* ---------------------------------------------------------------- calculators */

.sheet-layout rect.sheet {
    fill: var(--bs-tertiary-bg);
    stroke: var(--bs-border-color);
}

.sheet-layout rect.part {
    fill: #d9b38c;
    stroke: #6b4423;
    stroke-width: 0.5;
}

[data-bs-theme="dark"] .sheet-layout rect.part {
    fill: #8a6a4a;
    stroke: #e0c4a4;
}

.sheet-layout text {
    font-size: 2.2px;
    fill: #2b1a0e;
}

[data-bs-theme="dark"] .sheet-layout text {
    fill: #fff;
}

/* ---------------------------------------------------------------- print */

@media print {
    .sidebar, .top-row, .app-footer, .no-print {
        display: none !important;
    }

    .page, main {
        display: block !important;
    }

    article.content {
        padding: 0 !important;
    }

    .card {
        break-inside: avoid;
        border-color: #999 !important;
    }

    a[href^="http"]::after {
        content: " (" attr(href) ")";
        font-size: 0.75em;
        word-break: break-all;
    }
}
