html, body {
    height: 100%;
}

h1:focus {
    outline: none;
}

/* Introductions and running text keep a readable measure (docs/lab-design-standards.md, section 3). */
.intro {
    max-width: 760px;
}

/* Theory pages and lessons: the standard theory pattern, with callouts for the one thing to remember. */
.lesson {
    max-width: 860px;
}

.lesson p, .lesson li {
    line-height: 1.65;
    margin-bottom: 0.75rem;
}

.lesson ul {
    padding-left: 1.25rem;
}

.lesson .callout {
    border-left: 4px solid var(--mud-palette-primary);
    background: var(--mud-palette-background);
    padding: 0.75rem 1rem;
    margin: 1rem 0;
    border-radius: 4px;
}

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

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

/* Reconnect overlay. Blazor toggles the components-reconnect-* classes on #components-reconnect-modal. */
#components-reconnect-modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 2000;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(2px);
    font-family: Roboto, "Segoe UI", sans-serif;
}

#components-reconnect-modal.components-reconnect-show,
#components-reconnect-modal.components-reconnect-failed,
#components-reconnect-modal.components-reconnect-rejected {
    display: flex;
}

.reconnect-card {
    background: var(--mud-palette-surface);
    color: var(--mud-palette-text-primary);
    border-radius: 12px;
    padding: 2rem 2.25rem;
    max-width: 26rem;
    margin: 1rem;
    text-align: center;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.45);
}

.reconnect-title {
    font-size: 1.35rem;
    font-weight: 500;
    margin: 0.75rem 0 0.5rem;
}

.reconnect-text, .reconnect-failed-text {
    line-height: 1.55;
    margin: 0 0 1rem;
    color: var(--mud-palette-text-secondary);
}

.reconnect-spinner {
    width: 40px;
    height: 40px;
    margin: 0 auto;
    border: 4px solid var(--mud-palette-lines-default);
    border-top-color: var(--mud-palette-primary);
    border-radius: 50%;
    animation: reconnect-spin 0.9s linear infinite;
}

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

.reconnect-button {
    display: none;
    background: var(--mud-palette-primary);
    color: var(--mud-palette-primary-text);
    border: 0;
    border-radius: 6px;
    padding: 0.6rem 1.25rem;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
}

.reconnect-failed-text { display: none; }

#components-reconnect-modal.components-reconnect-failed .reconnect-text,
#components-reconnect-modal.components-reconnect-rejected .reconnect-text,
#components-reconnect-modal.components-reconnect-failed .reconnect-spinner,
#components-reconnect-modal.components-reconnect-rejected .reconnect-spinner {
    display: none;
}

#components-reconnect-modal.components-reconnect-failed .reconnect-failed-text,
#components-reconnect-modal.components-reconnect-rejected .reconnect-failed-text,
#components-reconnect-modal.components-reconnect-failed .reconnect-button,
#components-reconnect-modal.components-reconnect-rejected .reconnect-button {
    display: block;
    margin-left: auto;
    margin-right: auto;
}

/* Accessibility helpers. */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.skip-link {
    position: absolute;
    left: 8px;
    top: -60px;
    z-index: 3000;
    padding: 8px 14px;
    background: var(--mud-palette-primary);
    color: var(--mud-palette-primary-text);
    border-radius: 6px;
    font-weight: 500;
    text-decoration: none;
    transition: top 0.15s;
}

.skip-link:focus {
    top: 8px;
}

:focus-visible {
    outline: 2px solid var(--mud-palette-primary);
    outline-offset: 2px;
}

#main-content:focus {
    outline: none;
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Print: drop the chrome, widen the content, open collapsed panels. */
@media print {
    .mud-appbar, .mud-drawer, .mud-overlay, .no-print, #components-reconnect-modal,
    .mud-snackbar, .mud-popover, .skip-link, #blazor-error-ui {
        display: none !important;
    }

    .mud-main-content {
        padding-left: 0 !important;
        padding-top: 0 !important;
        margin-left: 0 !important;
    }

    .mud-container {
        max-width: none !important;
        padding: 0 !important;
    }

    .mud-paper {
        box-shadow: none !important;
        border: 1px solid #ccc;
        break-inside: avoid;
    }

    .mud-expand-panel .mud-collapse-container {
        height: auto !important;
        visibility: visible !important;
        overflow: visible !important;
    }

    html, body {
        background: #fff !important;
        color: #000 !important;
    }
}

/* Small screens: keep everything reachable on a phone without horizontal scrolling. */
.mud-table-container, .mud-simple-table {
    overflow-x: auto;
}

@media (max-width: 600px) {
    .appbar-github, .appbar-icon {
        display: none;
    }

    .appbar-title {
        font-size: 1rem;
    }

    #main-content {
        padding-left: 12px !important;
        padding-right: 12px !important;
    }

    .reconnect-card {
        padding: 1.25rem 1rem;
    }
}

/* Radio options stacked one per line, for answers that are full sentences. */
/* MudBlazor lays the group out as a row with a more specific rule, hence !important. */
.radio-stack .mud-radio-group, .mud-radio-group.radio-stack {
    flex-direction: column !important;
    align-items: flex-start !important;
}

/* The footer that ties the lab to the CloudWorrior blog. */
.lab-footer {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 2rem;
    padding: 1.25rem 1rem 1.75rem;
    border-top: 1px solid var(--mud-palette-lines-default);
    font-size: 0.85rem;
    color: var(--mud-palette-text-secondary);
}

.lab-footer a {
    color: var(--mud-palette-text-primary);
    text-decoration: underline;
}

/* Language menu: a flag beside each language's name. */
.language-option {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
}

.language-option .flag {
    width: 20px;
    height: 14px;
    object-fit: cover;
    border-radius: 2px;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.25);
}

/* The language button: the current language's flag before its code. */
.language-menu .mud-button-label::before {
    content: "";
    display: inline-block;
    width: 20px;
    height: 14px;
    margin-right: 8px;
    background-size: cover;
    background-position: center;
    border-radius: 2px;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.25);
}

.language-menu.flag-en .mud-button-label::before { background-image: url("images/flags/en.svg"); }
.language-menu.flag-nl .mud-button-label::before { background-image: url("images/flags/nl.svg"); }
.language-menu.flag-pl .mud-button-label::before { background-image: url("images/flags/pl.svg"); }
.language-menu.flag-de .mud-button-label::before { background-image: url("images/flags/de.svg"); }

/* ---- Animations (the shared player in js/animation-player.js, copied from the Probability Lab; its renderer in js/attention-animation.js) ---- */

.anim-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
}

.anim-speed {
    display: inline-flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 2px;
}

.anim-speed > span {
    margin-right: 4px;
    color: var(--mud-palette-text-secondary);
}

.anim-speed-button {
    min-width: 44px !important;
}

.anim-speed-button[aria-pressed="true"] {
    background: var(--mud-palette-primary-hover);
    font-weight: 700;
    text-decoration: underline;
    text-underline-offset: 3px;
}

.anim-chart {
    width: 100%;
    overflow: hidden;
}

.anim svg {
    display: block;
    max-width: 100%;
    font-family: inherit;
}

.anim-readout {
    margin: 0.5rem 0 0;
    font-variant-numeric: tabular-nums;
    min-height: 1.5em;
}

.anim .anim-tick, .anim .anim-label {
    font-size: 11px;
    fill: var(--mud-palette-text-secondary);
}

.anim .anim-label {
    fill: var(--mud-palette-text-primary);
    paint-order: stroke;
    stroke: var(--mud-palette-surface);
    stroke-width: 3px;
    stroke-linejoin: round;
}

.anim .anim-title {
    font-size: 12px;
    fill: var(--mud-palette-text-primary);
}

.anim .anim-grid line {
    stroke: var(--mud-palette-lines-default);
    stroke-width: 1;
}

.anim .anim-axis {
    stroke: var(--mud-palette-text-secondary);
    stroke-width: 1;
}

.anim .anim-line {
    fill: none;
    stroke: var(--mud-palette-primary);
    stroke-width: 2;
    stroke-linejoin: round;
}

.anim .anim-target {
    stroke: var(--mud-palette-warning);
    stroke-width: 2;
    stroke-dasharray: 6 4;
}

.anim .anim-dot {
    fill: var(--mud-palette-primary);
}


/* ---- A chapter's visuals: the first block of every chapter (the first rule) ---- */
.chapter-visual {
    margin: 0 0 1.5rem;
    max-width: 900px;
    scroll-margin-top: 80px;
}

.lesson .chapter-visual:not(:first-child) {
    margin-top: 1.5rem;
}

.visual-title {
    display: block;
    font-weight: 500;
    margin-bottom: 0.5rem;
}

.visual-description {
    margin: 0.5rem 0 0;
    line-height: 1.55;
}

.lesson h2[id] {
    scroll-margin-top: 80px;
}


/* ---- Transformers and Attention Lab ---- */

/* Links inside running text are underlined (WCAG: not by colour alone). */
.text-link, .outline-title a, .lesson a {
    color: var(--mud-palette-primary);
    text-decoration: underline;
}

/* The home page's clip sits where the other labs put their picture. */
.home-visual {
    margin: 0 0 1.25rem;
    max-width: 960px;
}

.home-visual figcaption {
    margin-top: 0.5rem;
}

.area-card {
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

/* The Course, Theory and Tools overviews: one line per chapter, section or tool, with its status. */
.outline-list {
    list-style: none;
    margin: 0;
    padding: 0;
    max-width: 860px;
}

.outline-item {
    display: grid;
    grid-template-columns: 3.5rem 1fr auto;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0;
    border-bottom: 1px solid var(--mud-palette-lines-default);
}

.outline-number {
    color: var(--mud-palette-text-secondary);
    font-variant-numeric: tabular-nums;
}

.outline-title {
    min-width: 0;
    overflow-wrap: anywhere;
}

.outline-note {
    display: block;
    font-size: 0.8rem;
}

[data-tool].outline-item {
    grid-template-columns: 1fr auto;
}

/* Chapter 9's clip (wwwroot/js/attention-animation.js): every colour from the theme, so light and dark both work. */
.clip-pickers {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem 1rem;
    margin-bottom: 0.75rem;
}

.clip-pickers > * {
    flex: 1 1 220px;
    max-width: 300px;
}

.clip-pickers > :first-child {
    flex: 2 1 280px;
    max-width: 420px;
}

/* Page titles shrink on a phone, so a chapter title is not four lines of display type. */
@media (max-width: 600px) {
    /* The beam's table keeps the translation and its score; the log-probability is in the text below it. */
    .hide-phone {
        display: none;
    }

    h1.mud-typography-h3 {
        font-size: 2rem;
        line-height: 1.2;
    }
}

.anim .ac-title {
    font-size: 15px;
    font-weight: 600;
    fill: var(--mud-palette-text-primary);
}

.anim .ac-head {
    font-size: 12px;
    font-weight: 600;
    fill: var(--mud-palette-text-secondary);
}

.anim .ac-label, .anim .ac-token {
    font-size: 14px;
    fill: var(--mud-palette-text-primary);
}

.anim .ac-token-q {
    font-weight: 700;
    fill: var(--mud-palette-primary);
}

.anim .ac-num, .anim .ac-small {
    font-size: 12px;
    fill: var(--mud-palette-text-primary);
    font-variant-numeric: tabular-nums;
}

.anim .ac-pos {
    fill: var(--mud-palette-primary);
}

.anim .ac-neg {
    fill: var(--mud-palette-info);
}

/* Negative entries also carry a dashed outline, so the sign is not told by colour alone. */
.anim .ac-cell.ac-neg {
    stroke: var(--mud-palette-info);
    stroke-width: 1;
    stroke-dasharray: 2 1.5;
}

.anim .ac-weight {
    fill: var(--mud-palette-secondary);
}

/* The translation playground. */
.example-button {
    text-transform: none !important;
}

.vocabulary {
    margin: 0;
    line-height: 1.8;
    overflow-wrap: anywhere;
}

.german {
    font-size: 1.6rem;
    font-weight: 500;
    margin: 0 0 0.5rem;
    color: var(--mud-palette-primary);
    overflow-wrap: anywhere;
}

.beam-table .num {
    text-align: right;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.beam-table tr.is-chosen td {
    font-weight: 500;
}

.table-scroll {
    overflow-x: auto;
    position: relative;
}

/* Inside a scrolling box (focusable, so the keyboard can scroll it), a table does not scroll on its own as well. */
.table-scroll .mud-table-container, .table-scroll.mud-simple-table, .table-scroll .mud-simple-table {
    overflow: visible !important;
}

.table-scroll:focus-visible {
    outline: 2px solid var(--mud-palette-primary);
    outline-offset: 2px;
}

.alignment-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem 1rem;
    margin-bottom: 0.5rem;
}

.alignment-controls > * {
    flex: 0 1 260px;
}

.alignment {
    margin: 0;
    max-width: 760px;
}

.alignment-svg {
    display: block;
    width: 100%;
    height: auto;
    font-family: Roboto, 'Segoe UI', Helvetica, Arial, sans-serif;
}

.alignment-cell {
    fill: var(--mud-palette-primary);
    stroke: var(--mud-palette-lines-default);
    stroke-width: 0.5;
}

.alignment-label {
    font-size: 13px;
    fill: var(--mud-palette-text-primary);
}

.alignment-value {
    font-size: 11px;
    fill: var(--mud-palette-text-primary);
    font-variant-numeric: tabular-nums;
}

.alignment-value.is-strong {
    fill: var(--mud-palette-primary-text);
}

.alignment-links {
    margin: 0;
    padding-left: 1.25rem;
    columns: 2 220px;
    font-size: 0.9rem;
}

@media print {
    .anim-controls, .clip-pickers, .alignment-controls {
        display: none !important;
    }
}

/* ---- The tools and simulations (M2) ---- */
.tool-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 380px), 1fr));
    gap: 1rem 2rem;
}

.tool-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem 2rem;
    margin-bottom: 0.75rem;
}

.tool-figure {
    font-variant-numeric: tabular-nums;
    margin: 0.5rem 0 0;
}

.formula {
    font-family: "Cambria Math", "STIX Two Math", "Latin Modern Math", serif;
    font-size: 1.05rem;
    overflow-wrap: anywhere;
}

.german-inline {
    font-weight: 500;
    color: var(--mud-palette-primary);
}

/* Sliders: a native range with its label (RangeInput.razor). */
.range-input {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    min-width: min(100%, 240px);
    flex: 1 1 240px;
    max-width: 420px;
    margin-bottom: 0.5rem;
}

.range-input label {
    font-size: 0.9rem;
}

.range-input .range-value {
    font-variant-numeric: tabular-nums;
}

.range-input input[type="range"] {
    width: 100%;
    accent-color: var(--mud-palette-primary);
}

.range-input input[type="range"]:focus-visible {
    outline: 2px solid var(--mud-palette-primary);
    outline-offset: 2px;
}

/* Charts (LabChart.razor): one y-axis, series told apart by dash as well as colour. */
.lab-chart {
    margin: 0;
    max-width: 760px;
}

.lab-chart-svg {
    display: block;
    width: 100%;
    height: auto;
    font-family: Roboto, 'Segoe UI', Helvetica, Arial, sans-serif;
}

.chart-grid {
    stroke: var(--mud-palette-lines-default);
    stroke-width: 1;
}

.chart-axis {
    stroke: var(--mud-palette-text-secondary);
    stroke-width: 1;
}

.chart-tick {
    font-size: 11px;
    fill: var(--mud-palette-text-secondary);
}

.chart-label {
    font-size: 12px;
    fill: var(--mud-palette-text-primary);
}

.chart-line {
    fill: none;
    stroke-width: 2.25;
    stroke-linejoin: round;
}

.chart-bar {
    stroke-width: 1;
    fill-opacity: 0.45;
}

.chart-dot {
    stroke: none;
}

.chart-s1 { stroke: var(--mud-palette-primary); fill: var(--mud-palette-primary); }
.chart-s2 { stroke: var(--mud-palette-secondary); fill: var(--mud-palette-secondary); stroke-dasharray: 7 4; }
.chart-s3 { stroke: var(--mud-palette-info); fill: var(--mud-palette-info); stroke-dasharray: 2 3; }
.chart-s4 { stroke: var(--mud-palette-warning); fill: var(--mud-palette-warning); stroke-dasharray: 10 3 2 3; }
.chart-line.chart-s1, .chart-line.chart-s2, .chart-line.chart-s3, .chart-line.chart-s4 { fill: none; }
.chart-dot.chart-s2, .chart-dot.chart-s3, .chart-dot.chart-s4, .chart-bar.chart-s1 { stroke-dasharray: none; }

.chart-marker {
    stroke: var(--mud-palette-text-secondary);
    stroke-width: 1.5;
    stroke-dasharray: 4 3;
}

.chart-marker-label {
    font-size: 11px;
    fill: var(--mud-palette-text-primary);
    paint-order: stroke;
    stroke: var(--mud-palette-surface);
    stroke-width: 3px;
}

.chart-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem 1rem;
    list-style: none;
    margin: 0.25rem 0 0;
    padding: 0;
    font-size: 0.85rem;
}

.chart-legend li {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

/* Tables of numbers: right-aligned, tabular figures; the chosen row bold. */
.number-table .num {
    text-align: right;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.number-table tr.is-chosen td, .number-table tr.is-chosen th {
    font-weight: 600;
}

.number-table caption {
    caption-side: top;
    text-align: left;
    font-size: 0.85rem;
    padding: 0 0 0.25rem;
    color: var(--mud-palette-text-secondary);
}

.table-one .formula {
    font-size: 0.95rem;
}

.table-one .value {
    font-variant-numeric: tabular-nums;
    color: var(--mud-palette-text-secondary);
}

/* Vectors (VectorTable.razor): the first eight entries, tinted by size; the minus sign says the sign. */
.vector-table table {
    border-collapse: collapse;
    font-size: 0.85rem;
    font-variant-numeric: tabular-nums;
}

.vector-table caption {
    caption-side: top;
    text-align: left;
    padding-bottom: 0.25rem;
    color: var(--mud-palette-text-secondary);
}

.vector-table th, .vector-table td {
    padding: 0.2rem 0.3rem;
    border-bottom: 1px solid var(--mud-palette-lines-default);
    white-space: nowrap;
}

.vector-table th[scope="row"] {
    text-align: left;
    font-weight: 500;
}

.vector-table td.num {
    text-align: right;
}

.vector-table td.pos {
    background: color-mix(in srgb, var(--mud-palette-primary) calc(var(--strength, 0) * 28%), transparent);
}

.vector-table td.neg {
    background: color-mix(in srgb, var(--mud-palette-info) calc(var(--strength, 0) * 28%), transparent);
}

.vector-table tr.is-highlighted th {
    color: var(--mud-palette-primary);
}

/* Probabilities as bars (ProbabilityBars.razor). */
.prob-bars {
    list-style: none;
    margin: 0;
    padding: 0;
    max-width: 560px;
}

.prob-row {
    display: grid;
    grid-template-columns: minmax(5rem, 8rem) 1fr 4.5rem;
    align-items: center;
    gap: 0.5rem;
    padding: 0.15rem 0;
}

.prob-word {
    font-weight: 500;
    overflow-wrap: anywhere;
}

.prob-row.is-highlighted .prob-word {
    color: var(--mud-palette-primary);
}

.prob-track {
    display: block;
    height: 0.8rem;
    border-radius: 3px;
    background: var(--mud-palette-lines-default);
    overflow: hidden;
}

.prob-fill {
    display: block;
    height: 100%;
    background: var(--mud-palette-primary);
}

.prob-value {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

/* The attention explorer: four heads side by side, two on a phone. */
.head-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 0.75rem 1rem;
}

@media (min-width: 700px) {
    .head-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        max-width: 1200px;
    }
}

.head-cell {
    border: 1px solid var(--mud-palette-lines-default);
    border-radius: 8px;
    padding: 0.25rem 0.5rem 0.5rem;
}

.head-cell.is-chosen {
    border-color: var(--mud-palette-primary);
    box-shadow: 0 0 0 1px var(--mud-palette-primary);
}

.token-button {
    text-transform: none !important;
    min-width: 0 !important;
}

/* The next-word playground. */
.next-blank {
    color: var(--mud-palette-primary);
    font-weight: 700;
}

.next-history {
    margin: 0;
    padding-left: 1.25rem;
    font-variant-numeric: tabular-nums;
}

.seed-field {
    max-width: 140px;
}

/* BLEU: the candidate's n-grams, the matches marked by an outline and a tint (and in text for screen readers). */
.bleu-score {
    font-size: 1.6rem;
    font-weight: 500;
    margin: 0 0 0.5rem;
    color: var(--mud-palette-primary);
    font-variant-numeric: tabular-nums;
}

.ngrams {
    line-height: 2;
}

.ngram {
    display: inline-block;
    margin: 0 0.25rem 0.25rem 0;
    padding: 0 0.35rem;
    border: 1px dashed var(--mud-palette-lines-default);
    border-radius: 4px;
    white-space: nowrap;
}

.ngram.is-match {
    border: 1px solid var(--mud-palette-primary);
    background: color-mix(in srgb, var(--mud-palette-primary) 16%, transparent);
    font-weight: 500;
}

/* Beam search's tree: kept beginnings as boxes, finished ones with a square, the chosen path marked. */
.beam-tree-scroll {
    max-width: 100%;
}

.beam-tree {
    display: block;
    font-family: Roboto, 'Segoe UI', Helvetica, Arial, sans-serif;
}

.beam-node rect {
    fill: var(--mud-palette-surface);
    stroke: var(--mud-palette-lines-default);
    stroke-width: 1.5;
}

.beam-node text {
    font-size: 13px;
    fill: var(--mud-palette-text-primary);
}

.beam-node.is-finished rect {
    stroke-dasharray: 4 2;
}

.beam-node.is-path rect {
    stroke: var(--mud-palette-primary);
    stroke-width: 2.5;
}

.beam-node.is-path text {
    font-weight: 700;
}

.beam-edge {
    stroke: var(--mud-palette-lines-default);
    stroke-width: 1.5;
}

.beam-edge.is-path {
    stroke: var(--mud-palette-primary);
    stroke-width: 2.5;
}

.beam-dropped {
    font-size: 11px;
    fill: var(--mud-palette-text-secondary);
}

/* The positional-encoding grid: a PNG, each value one pixel, scaled up without smoothing. */
.pe-grid {
    margin: 0;
}

.pe-grid-frame {
    display: flex;
    gap: 0.5rem;
    align-items: stretch;
}

.pe-axis-y {
    writing-mode: vertical-rl;
    transform: rotate(180deg);
    font-size: 0.8rem;
    color: var(--mud-palette-text-secondary);
}

.pe-grid img {
    display: block;
    width: 100%;
    max-width: 760px;
    height: 300px;
    image-rendering: pixelated;
    border-radius: 6px;
}

/* The embedding map: shapes tell English, German and shared words apart as well as colours. */
.map-frame {
    max-width: 900px;
}

.map-svg {
    display: block;
    width: 100%;
    height: auto;
    font-family: Roboto, 'Segoe UI', Helvetica, Arial, sans-serif;
}

.map-point text {
    font-size: 8px;
    fill: var(--mud-palette-text-secondary);
}

.map-point {
    cursor: pointer;
}

.map-en, .map-point.map-en circle { fill: var(--mud-palette-primary); }
.map-de, .map-point.map-de rect { fill: var(--mud-palette-secondary); }
.map-both, .map-point.map-both path { fill: var(--mud-palette-info); }

.map-point.is-chosen text, .map-point.is-near text {
    font-size: 12px;
    font-weight: 700;
    fill: var(--mud-palette-text-primary);
    paint-order: stroke;
    stroke: var(--mud-palette-surface);
    stroke-width: 3px;
}

.map-point.is-chosen circle, .map-point.is-chosen rect, .map-point.is-chosen path {
    stroke: var(--mud-palette-text-primary);
    stroke-width: 2;
}

.map-link {
    stroke: var(--mud-palette-text-primary);
    stroke-width: 1;
    stroke-dasharray: 3 2;
}

.map-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem 1.25rem;
    list-style: none;
    padding: 0;
    margin: 0 0 0.5rem;
    font-size: 0.85rem;
}

.map-legend li {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.map-search {
    max-width: 320px;
}

.map-neighbours {
    margin: 0;
    padding-left: 1.25rem;
}

/* The head gallery. */
.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr));
    gap: 0.75rem;
}

.gallery-card {
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.gallery-card.is-chosen {
    outline: 2px solid var(--mud-palette-primary);
}

.gallery-description {
    margin: 0.25rem 0;
}

.gallery-example-caption {
    font-size: 0.85rem;
    margin: 0 0 0.25rem;
}

.gallery-examples {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 360px), 1fr));
    gap: 1rem;
}

/* The matrix calculator. */
.matrix-inputs {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem 2rem;
}

.matrix-input {
    border: 1px solid var(--mud-palette-lines-default);
    border-radius: 8px;
    padding: 0.5rem 0.75rem;
}

.matrix-input legend {
    font-size: 0.9rem;
    padding: 0 0.25rem;
}

.matrix-input-row {
    display: flex;
    gap: 0.35rem;
    margin-bottom: 0.35rem;
}

.matrix-input input {
    width: 4.2rem;
    padding: 0.3rem;
    font: inherit;
    color: var(--mud-palette-text-primary);
    background: var(--mud-palette-surface);
    border: 1px solid var(--mud-palette-lines-inputs);
    border-radius: 4px;
}

.matrix-input input:focus-visible {
    outline: 2px solid var(--mud-palette-primary);
}

.matrix-chart svg {
    max-width: 560px;
}

.anim .mx-name, .anim .mx-op {
    font-size: 16px;
    font-weight: 600;
    fill: var(--mud-palette-text-primary);
}

.anim .mx-op {
    font-size: 22px;
}

.anim .mx-cell {
    fill: var(--mud-palette-surface);
    stroke: var(--mud-palette-lines-default);
    stroke-width: 1.5;
}

.anim .mx-on {
    fill: var(--mud-palette-primary);
    stroke: var(--mud-palette-primary);
}

.anim .mx-num {
    font-size: 15px;
    fill: var(--mud-palette-text-primary);
    font-variant-numeric: tabular-nums;
}

.anim .mx-num-on {
    fill: var(--mud-palette-primary-text);
    font-weight: 700;
}

/* The paper's Figure 1, redrawn on the diagram standard's dark card (the same in both themes). */
.figure-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

@media (min-width: 1100px) {
    .figure-layout {
        grid-template-columns: minmax(0, 620px) minmax(0, 1fr);
        align-items: start;
    }
}

.figure-one {
    margin: 0;
}

.figure-one-svg {
    display: block;
    width: 100%;
    max-width: 620px;
    height: auto;
    font-family: Roboto, 'Segoe UI', Helvetica, Arial, sans-serif;
}

.fig-canvas { fill: #0B0E1D; }
.fig-stack { fill: #10142A; stroke: #2A3052; stroke-width: 1.5; }
.fig-n { font-size: 22px; font-weight: 600; fill: #E6E8EE; }
.fig-note { font-size: 11px; fill: #A7AEC4; }
.fig-arrow, .fig-residual { stroke: #A7AEC4; stroke-width: 1.5; fill: none; }
.fig-residual { stroke-dasharray: 4 3; }
.fig-arrowhead { fill: #A7AEC4; }
.fig-box { cursor: pointer; }
.fig-box .fig-shape { fill: #151A33; stroke-width: 1.5; }
.fig-box .fig-label { font-size: 14px; font-weight: 600; fill: #E6E8EE; }
.fig-box .fig-plus { font-size: 20px; font-weight: 700; fill: #E6E8EE; }
.fig-amber .fig-shape { stroke: #F7B955; }
.fig-violet .fig-shape { stroke: #7C5CFF; }
.fig-teal .fig-shape { stroke: #19F7D1; }
.fig-green .fig-shape { stroke: #3DD68C; }
.fig-plain .fig-shape, .fig-shape.fig-plain { stroke: #A7AEC4; fill: #0B0E1D; }
.fig-box:hover .fig-shape { fill: #1E2547; }
.fig-box.is-chosen .fig-shape { fill: #232A52; stroke-width: 3.5; }
.fig-box:focus { outline: none; }
.fig-box:focus-visible .fig-shape { stroke: #FFFFFF; stroke-width: 3.5; }
.fig-box[data-lit="on"] .fig-shape { fill: #5A3A10; stroke: #F7B955; stroke-width: 3.5; }

.fig-credit {
    font-size: 0.8rem;
    color: var(--mud-palette-text-secondary);
    margin-top: 0.35rem;
}

.figure-explanation {
    max-width: 640px;
    line-height: 1.6;
}

/* Tool embeds (/embed/tools/{slug}): no app bar or drawer, 12 px of padding, the attribution at the end. */
.embed-main {
    padding: 12px;
    min-height: 100vh;
    background: var(--mud-palette-background);
    overflow-x: hidden;
}

.embed-main:focus {
    outline: none;
}

.embed-attribution {
    margin: 8px 0 0;
    font-size: 0.8125rem;
    text-align: right;
}

.embed-attribution a {
    color: var(--mud-palette-primary);
    text-decoration: underline;
}

@media print {
    .tool-controls, .range-input {
        display: none !important;
    }

}

/* ---- M3: the chapter framework (the Hypothesis Testing Lab's, adapted) ---- */
.lesson-paper {
    max-width: 920px;
}

.lesson .lesson-heading {
    margin: 1.75rem 0 0.5rem;
}

.lesson code, .exercise code, .glossary code {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.9em;
    background: var(--mud-palette-background);
    border: 1px solid var(--mud-palette-lines-default);
    border-radius: 4px;
    padding: 0 4px;
    overflow-wrap: anywhere;
}

.exercise a, .paper-note a, .glossary a {
    color: var(--mud-palette-primary);
    text-decoration: underline;
}

.formula {
    overflow-x: auto;
    overflow-y: hidden;
    padding: 0.25rem 0;
    margin: 0.5rem 0 1rem;
}

.math-inline .katex {
    font-size: 1.05em;
}

.callout-label {
    margin-right: 0.25rem;
}

.symbols {
    margin: 0 0 1rem;
    display: grid;
    gap: 0.35rem;
}

.symbol-row {
    display: grid;
    grid-template-columns: minmax(5rem, max-content) 1fr;
    gap: 0.75rem;
    align-items: baseline;
}

.symbol-row dt {
    font-weight: 500;
}

.symbol-row dd {
    margin: 0;
    line-height: 1.55;
}

.lesson .note-box {
    border: 1px solid var(--mud-palette-lines-default);
    border-left: 4px solid var(--mud-palette-secondary);
    padding: 0.75rem 1rem;
    margin: 1rem 0;
    border-radius: 4px;
}

.note-title {
    display: block;
    margin-bottom: 0.25rem;
}

.lesson .why-true {
    border: 1px dashed var(--mud-palette-lines-default);
    border-radius: 4px;
    padding: 0.5rem 1rem;
    margin: 1rem 0;
}

.why-true summary {
    cursor: pointer;
    font-weight: 500;
    padding: 0.25rem 0;
}

.why-true-label {
    color: var(--mud-palette-text-secondary);
}

.try-it {
    display: flex;
    gap: 0.75rem;
    align-items: flex-start;
    border-left: 4px solid var(--mud-palette-secondary);
    background: var(--mud-palette-background);
    padding: 0.75rem 1rem;
    margin: 1rem 0;
    border-radius: 4px;
}

.try-it-label {
    display: block;
}

.lesson-table caption {
    caption-side: bottom;
    text-align: left;
    padding-top: 0.35rem;
    font-size: 0.8rem;
    color: var(--mud-palette-text-secondary);
}

.chapter-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    max-width: 920px;
}

.chapter-nav .mud-button-label {
    text-transform: none;
    text-align: left;
}

.exercise-list {
    display: grid;
    gap: 1rem;
}

.exercise-input {
    max-width: 240px;
}

.exercise-hints li, .exercise-solution li {
    margin-bottom: 0.4rem;
    line-height: 1.6;
}

.exercise-solution {
    border-left: 4px solid var(--mud-palette-success);
    padding-left: 1rem;
}

.paper-note {
    border-left: 4px solid var(--mud-palette-primary) !important;
}

.visual-own {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
    flex: 2 1 280px;
    max-width: 460px;
}

.visual-own > .mud-input-control {
    flex: 1 1 200px;
}

/* A clip wider than a phone scrolls inside its own region, never the page (the region is focusable). */
.anim-chart.anim-scroll {
    overflow-x: auto;
}

.anim-chart.anim-scroll:focus-visible {
    outline: 2px solid var(--mud-palette-primary);
    outline-offset: 2px;
}

@media (max-width: 600px) {
    .anim-chart.anim-scroll svg {
        min-width: 560px;
    }

    .symbol-row {
        grid-template-columns: 1fr;
        gap: 0;
    }
}

/* The glossary. */
.glossary-filter {
    max-width: 420px;
}

.glossary {
    max-width: 860px;
    margin: 0;
}

.glossary-entry {
    padding: 10px 0;
    border-bottom: 1px solid var(--mud-palette-lines-default);
    scroll-margin-top: 80px;
}

.glossary-entry[hidden] {
    display: none;
}

.glossary-entry dt {
    font-weight: 500;
    font-size: 1.05rem;
}

.glossary-english {
    font-weight: 400;
    font-size: 0.85rem;
    margin-left: 8px;
}

.glossary-entry dd {
    margin: 4px 0 0 0;
}

.glossary-where {
    display: block;
    margin-top: 2px;
}

/* ---- M3: the chapters' clips (wwwroot/js/*-animation.js): every colour from the theme ---- */
.anim .cl-title {
    font-size: 15px;
    font-weight: 600;
    fill: var(--mud-palette-text-primary);
}

.anim .cl-head {
    font-size: 12px;
    font-weight: 600;
    fill: var(--mud-palette-text-secondary);
}

.anim .cl-text {
    font-size: 14px;
    fill: var(--mud-palette-text-primary);
}

.anim .cl-strong {
    font-weight: 700;
}

.anim .cl-num, .anim .cl-small {
    font-size: 12px;
    fill: var(--mud-palette-text-primary);
    font-variant-numeric: tabular-nums;
}

.anim .cl-warn {
    fill: var(--mud-palette-warning);
    font-weight: 600;
}

.anim .cl-op {
    font-size: 20px;
    fill: var(--mud-palette-text-secondary);
}

.anim .cl-word, .anim .cl-piece, .anim .cl-cell {
    fill: var(--mud-palette-surface);
    stroke: var(--mud-palette-lines-default);
    stroke-width: 1;
}

.anim .cl-word.is-new, .anim .cl-piece.is-new, .anim .cl-cell.is-on {
    stroke: var(--mud-palette-primary);
    stroke-width: 2.5;
}

.anim .cl-word.is-unknown {
    stroke: var(--mud-palette-warning);
    stroke-width: 2;
    stroke-dasharray: 4 2;
}

.anim .cl-track {
    fill: var(--mud-palette-lines-default);
    opacity: 0.35;
}

.anim .cl-bar {
    fill: var(--mud-palette-primary);
}

.anim .cl-bar-2 {
    fill: var(--mud-palette-secondary);
}

.anim .cl-bar-hi {
    fill: var(--mud-palette-secondary);
    stroke: var(--mud-palette-text-primary);
    stroke-width: 1.5;
}

.anim .cl-bar-neg {
    fill: var(--mud-palette-info);
}

.anim .cl-plane, .dot-svg .cl-plane {
    fill: none;
    stroke: var(--mud-palette-lines-default);
}

.anim .cl-gridline, .dot-svg .cl-gridline {
    stroke: var(--mud-palette-lines-default);
    stroke-width: 1;
}

.anim .cl-axis, .dot-svg .cl-axis {
    stroke: var(--mud-palette-text-secondary);
    stroke-width: 1.5;
}

.anim .cl-arrow-a, .dot-svg .cl-arrow-a {
    stroke: var(--mud-palette-primary);
    stroke-width: 3;
}

.anim .cl-arrow-a-head, .dot-svg .cl-arrow-a-head {
    fill: var(--mud-palette-primary);
}

.anim .cl-arrow-b, .dot-svg .cl-arrow-b {
    stroke: var(--mud-palette-secondary);
    stroke-width: 3;
    stroke-dasharray: 7 3;
}

.anim .cl-arrow-b-head, .dot-svg .cl-arrow-b-head {
    fill: var(--mud-palette-secondary);
}

.anim .cl-masked {
    fill: var(--mud-palette-lines-default);
    opacity: 0.6;
}

.anim .cl-link {
    stroke: var(--mud-palette-primary);
    fill: none;
    stroke-linecap: round;
}

.anim .cl-state {
    fill: var(--mud-palette-surface);
    stroke: var(--mud-palette-secondary);
    stroke-width: 2;
}

/* Chapter 3's figure: two arrows the reader drags. */
.dot-figure {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem 2rem;
    align-items: flex-start;
}

.dot-plane {
    flex: 0 1 320px;
    max-width: 320px;
    width: 100%;
}

.dot-svg {
    display: block;
    width: 100%;
    height: auto;
    touch-action: none;
}

.dot-svg text {
    fill: var(--mud-palette-text-primary);
    font-size: 13px;
}

.dot-handle {
    fill: var(--mud-palette-primary-hover);
    stroke: var(--mud-palette-text-primary);
    stroke-width: 1;
    cursor: grab;
}

.dot-arc {
    fill: var(--mud-palette-warning);
    opacity: 0.25;
}

.dot-side {
    flex: 1 1 260px;
    min-width: 0;
}

.dot-readout p {
    margin: 0.25rem 0;
    font-variant-numeric: tabular-nums;
}

.dot-sum {
    overflow-wrap: anywhere;
}

@media print {
    .clip-pickers, .visual-own, .anim-controls {
        display: none !important;
    }

    .lesson-paper, .lesson-paper.mud-paper {
        break-inside: auto !important;
    }

    .chapter-visual, .note-box, .callout, .try-it, .exercise {
        break-inside: avoid;
    }

    .lesson a, .exercise a, .paper-note a {
        color: #000 !important;
    }
}

@media (max-width: 600px) {
    .lesson-paper.pa-6 {
        padding: 14px !important;
    }
}

/* Numbers drawn on a coloured cell keep a halo of the surface colour, so they read on any fill. */
.anim .cl-cellnum {
    paint-order: stroke;
    stroke: var(--mud-palette-surface);
    stroke-width: 3px;
    stroke-linejoin: round;
}

.anim .cl-dot {
    fill: var(--mud-palette-primary);
}

.anim .cl-dashed {
    stroke: var(--mud-palette-secondary);
    stroke-dasharray: 6 3;
}

/* Chapter 11's heads side by side. */
.heads-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr));
    gap: 0.5rem 1rem;
}

.head-panel {
    min-width: 0;
}

.head-panel.is-off .alignment {
    opacity: 0.35;
}

.head-panel .alignment-svg {
    max-width: 100%;
}

.head-switches {
    display: flex;
    flex-wrap: wrap;
    gap: 0 1rem;
}

/* A long example (two sentences) in a picker is cut with an ellipsis rather than widening the page. */
.clip-pickers > * {
    min-width: 0;
}

.clip-picker .mud-input-slot, .clip-picker .mud-select-input {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ---- "Watch a translation, step by step" (Components/Pages/Tools/TranslationWalkthroughTool.razor, js/walkthrough-animation.js) ---- */
.walk-host > .anim-readout {
    display: none;
}

.walk-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 1.25rem;
}

@media (min-width: 1100px) {
    .walk-layout {
        grid-template-columns: minmax(0, 480px) minmax(0, 1fr);
        align-items: start;
    }

    .walk-diagram {
        position: sticky;
        top: 76px;
    }
}

.walk-diagram .figure-one-svg {
    max-width: 480px;
    margin: 0 auto;
}

.figure-one-svg.is-static .fig-box {
    cursor: default;
}

.figure-one-svg.is-static .fig-box:not([data-lit]):hover .fig-shape {
    fill: #151A33;
}

.fig-arrow[data-lit="on"], .fig-residual[data-lit="on"] {
    stroke: #F7B955;
    stroke-width: 3;
    stroke-dasharray: 7 5;
    animation: walk-flow 0.9s linear infinite;
}

@keyframes walk-flow {
    to { stroke-dashoffset: -24; }
}

@media (prefers-reduced-motion: reduce) {
    .fig-arrow[data-lit="on"], .fig-residual[data-lit="on"] {
        animation: none;
    }
}

.fig-walk-status { font-size: 18px; font-weight: 600; fill: #F7B955; }
.fig-walk-caption { font-size: 13px; fill: #A7AEC4; }
.fig-walk-german { font-size: 17px; font-weight: 600; fill: #E6E8EE; }
.fig-walk-layer { font-size: 11px; font-weight: 600; fill: #F7B955; }
.fig-walk-english { font-size: 12px; fill: #A7AEC4; }

.walk-panel {
    min-width: 0;
    background: var(--mud-palette-surface);
    border: 1px solid var(--mud-palette-lines-default);
    border-radius: 8px;
    padding: 0 16px 12px;
}

.walk-header {
    padding: 10px 0 8px;
    border-bottom: 1px solid var(--mud-palette-lines-default);
    background: var(--mud-palette-surface);
}

@media (max-width: 1099px) {
    .walk-header {
        position: sticky;
        top: 64px;
        z-index: 3;
    }
}

@media (max-width: 599px) {
    .walk-header {
        top: 56px;
    }

    .walk-panel {
        padding: 0 10px 10px;
    }
}

.walk-header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.walk-count {
    font-size: 0.8125rem;
    color: var(--mud-palette-text-secondary);
    font-variant-numeric: tabular-nums;
}

.walk-nav {
    display: inline-flex;
    gap: 6px;
}

.walk-icon {
    min-width: 40px;
    min-height: 36px;
    font-size: 1.4rem;
    line-height: 1;
    border-radius: 6px;
    border: 1px solid var(--mud-palette-primary);
    background: transparent;
    color: var(--mud-palette-primary);
    cursor: pointer;
}

.walk-icon:hover {
    background: var(--mud-palette-primary-hover);
}

.walk-icon:focus-visible, .walk-chip:focus-visible, .walk-jump:focus-visible {
    outline: 2px solid var(--mud-palette-primary);
    outline-offset: 2px;
}

.walk-headline {
    font-size: 1.2rem;
    font-weight: 500;
    line-height: 1.35;
    margin: 4px 0 0;
}

.walk-sofar {
    margin: 4px 0 0;
    font-size: 0.95rem;
}

.walk-sofar-words {
    font-weight: 600;
}

.walk-stat-label {
    color: var(--mud-palette-text-secondary);
}

.walk-body {
    padding-top: 8px;
}

.walk-text {
    line-height: 1.6;
    margin: 0 0 4px;
    max-width: 720px;
}

.walk-section {
    font-size: 0.8125rem;
    margin: 0 0 4px;
}

.walk-formula {
    margin: 4px 0 8px;
    overflow-x: auto;
    overflow-y: hidden;
}

/* KaTeX sets display maths at 1.21em; in the calculation panel that pushed the widest line (MultiHead … W^O) past the
   edge. At 1em it fits the panel at desktop widths; narrower panels still scroll. */
.walk-formula .katex {
    font-size: 1em;
}

.walk-note {
    font-size: 0.875rem;
    color: var(--mud-palette-text-secondary);
    margin: 6px 0;
}

.walk-picker {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 8px 0;
}

.walk-chip {
    min-height: 32px;
    padding: 2px 12px;
    border-radius: 16px;
    border: 1px solid var(--mud-palette-primary);
    background: transparent;
    color: var(--mud-palette-text-primary);
    font: inherit;
    font-size: 0.875rem;
    cursor: pointer;
}

.walk-chip[aria-pressed="true"] {
    background: var(--mud-palette-primary);
    color: var(--mud-palette-primary-text);
    font-weight: 600;
}

.walk-vectors {
    margin: 8px 0;
}

.walk-tokens {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    list-style: none;
    padding: 0;
    margin: 8px 0;
}

.walk-tokens li {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 4px 10px;
    border: 1px solid var(--mud-palette-lines-default);
    border-radius: 6px;
    min-width: 44px;
}

.walk-tokens li.is-newest {
    border: 2px solid var(--mud-palette-primary);
}

.walk-token {
    font-weight: 600;
}

.walk-token-id {
    font-size: 0.75rem;
    color: var(--mud-palette-text-secondary);
    font-variant-numeric: tabular-nums;
}

.walk-map {
    margin: 8px 0;
}

.walk-map-title {
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 4px;
}

.walk-map-svg {
    display: block;
    max-width: none;
    font-family: inherit;
}

.walk-map-label {
    font-size: 11px;
    fill: var(--mud-palette-text-primary);
}

.walk-map-label.is-focus {
    font-weight: 700;
}

.walk-map-value {
    font-size: 9.5px;
    fill: var(--mud-palette-text-primary);
    font-variant-numeric: tabular-nums;
}

.walk-map-value.is-strong {
    fill: var(--mud-palette-primary-text);
    font-weight: 600;
}

.walk-map-value.is-masked {
    fill: var(--mud-palette-text-secondary);
}

.walk-cell { fill: var(--mud-palette-primary); }
.walk-cell-neg { fill: var(--mud-palette-info); }
.walk-cell-masked { fill: var(--mud-palette-lines-default); opacity: 0.55; }
.walk-focus-row { fill: none; stroke: var(--mud-palette-text-primary); stroke-width: 1.5; }

.walk-strongest {
    margin: 4px 0 8px;
    font-weight: 500;
}

.walk-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1.5rem;
}

.walk-stat {
    margin: 4px 0;
    font-variant-numeric: tabular-nums;
}

.walk-zeros {
    margin: 8px 0;
    max-width: 420px;
}

.walk-zero-track, .walk-bar-track {
    display: block;
    height: 10px;
    border-radius: 5px;
    background: var(--mud-palette-lines-default);
    overflow: hidden;
}

.walk-zero-bar, .walk-bar {
    display: block;
    height: 100%;
    background: var(--mud-palette-primary);
}

.walk-bars {
    margin: 8px 0;
}

.walk-bar-list {
    list-style: none;
    padding: 0;
    margin: 0;
    max-width: 560px;
}

.walk-bar-list li {
    display: grid;
    grid-template-columns: minmax(4.5rem, 7rem) minmax(0, 1fr) minmax(5rem, auto);
    align-items: center;
    gap: 8px;
    padding: 3px 0;
    font-variant-numeric: tabular-nums;
}

.walk-bar-list li.is-chosen {
    font-weight: 700;
}

.walk-bar-list li.is-chosen .walk-bar-track {
    outline: 2px solid var(--mud-palette-text-primary);
    outline-offset: 1px;
}

.walk-bar-word {
    overflow-wrap: anywhere;
}

.walk-bar-value {
    text-align: right;
    white-space: nowrap;
}

.walk-chosen {
    margin: 8px 0;
}

.walk-chosen-word {
    font-size: 2rem;
    font-weight: 600;
    color: var(--mud-palette-primary);
}

.walk-done dt {
    font-weight: 500;
    color: var(--mud-palette-text-secondary);
    margin-top: 8px;
}

.walk-done dd {
    margin: 2px 0 0;
    font-size: 1.15rem;
    font-weight: 600;
}

.walk-timeline {
    margin-top: 12px;
    border-top: 1px solid var(--mud-palette-lines-default);
    padding-top: 8px;
}

.walk-timeline > summary, .walk-group > summary {
    cursor: pointer;
    padding: 6px 0;
    font-weight: 500;
}

.walk-steps {
    max-height: 420px;
    overflow-y: auto;
    padding-right: 4px;
}

.walk-group > ol {
    list-style: none;
    margin: 0 0 6px;
    padding: 0 0 0 12px;
}

.walk-jump {
    display: block;
    width: 100%;
    text-align: left;
    padding: 4px 8px;
    border: 0;
    border-radius: 4px;
    background: transparent;
    color: var(--mud-palette-text-primary);
    font: inherit;
    font-size: 0.875rem;
    cursor: pointer;
}

.walk-jump:hover {
    text-decoration: underline;
}

.walk-jump[aria-current="step"] {
    background: var(--mud-palette-primary);
    color: var(--mud-palette-primary-text);
    font-weight: 600;
}

/* The home page's featured walkthrough card. */
.walk-feature {
    margin: 0 0 1.5rem;
    max-width: 960px;
    border-left: 4px solid var(--mud-palette-primary);
}

@media print {
    .walk-header {
        position: static;
    }

    .walk-diagram {
        position: static;
    }
}

/* ---- M4: chapter 16's stack, built up in layers (Figure 1's diagram style) ---- */
.stack-stages {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin: 0.5rem 0 0.75rem;
}

.stack-svg {
    width: 100%;
    max-width: 640px;
    height: auto;
    display: block;
}

.stack-svg .stack-layer {
    cursor: pointer;
}

.stack-svg .stack-layer:focus {
    outline: none;
}

.stack-svg .stack-layer:focus-visible .fig-stack {
    stroke: #FFFFFF;
    stroke-width: 3;
}

.stack-svg .fig-stack[data-lit="on"] {
    stroke: #F7B955;
    stroke-width: 3;
}

@media print {
    .stack-svg .fig-stack[data-lit="on"] {
        stroke-width: 2;
    }
}

/* ---- M5: the Theory tab ---- */
.paper-quote {
    margin: 0 0 1.25rem;
    max-width: 860px;
}

.paper-quote blockquote {
    margin: 0;
    padding: 0.5rem 0 0.5rem 1rem;
    border-left: 3px solid var(--mud-palette-lines-default);
    font-size: 1.05rem;
    line-height: 1.6;
    font-style: italic;
}

.paper-quote blockquote p {
    margin: 0;
}

.paper-quote figcaption {
    margin: 0.35rem 0 0 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.paper-quote-where {
    color: var(--mud-palette-text-secondary);
}

.notation-table th[scope="row"] {
    white-space: nowrap;
}

.prepared-list {
    margin: 0;
    padding-left: 1.25rem;
    line-height: 1.8;
}

.embedded-tool {
    border-top: 1px solid var(--mud-palette-lines-default);
    padding-top: 0.75rem;
    min-width: 0;
}

/* The abstract's claims */
.claims-figure ul {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr));
    gap: 0.75rem;
}

.claims-blocks {
    margin-bottom: 1rem !important;
}

.claim-block, .claim-result {
    border: 1px solid var(--mud-palette-lines-default);
    border-radius: 10px;
    padding: 0.75rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.claim-block {
    flex-direction: row;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.claim-block.is-removed .claim-name {
    text-decoration: line-through;
    text-decoration-thickness: 2px;
}

.claim-block.is-kept {
    border: 2px solid var(--mud-palette-primary);
}

.claim-name {
    font-weight: 600;
}

.claim-verdict, .claim-what, .claim-where {
    font-size: 0.9rem;
    color: var(--mud-palette-text-secondary);
}

.claim-block.is-kept .claim-verdict {
    color: var(--mud-palette-text-primary);
}

.claim-number {
    font-size: 2rem;
    font-weight: 700;
    line-height: 1.1;
    color: var(--mud-palette-primary);
}

.claim-unit {
    font-weight: 600;
}

/* Section 2: path lengths */
.path-panels {
    display: grid;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.path-panel .path-title {
    margin: 0;
}

.path-svg {
    display: block;
    width: 100%;
    max-width: 560px;
    height: auto;
}

.path-dot { fill: var(--mud-palette-text-disabled); }
.path-dot.is-end { fill: var(--mud-palette-primary); }
.path-route { fill: none; stroke: var(--mud-palette-primary); stroke-width: 3; stroke-linejoin: round; stroke-linecap: round; }

/* Section 3.2: Figure 2 */
.figure-two {
    display: grid;
    grid-template-columns: minmax(0, 620px) minmax(0, 1fr);
    gap: 1rem 1.5rem;
    align-items: start;
}

@media (max-width: 960px) {
    .figure-two {
        grid-template-columns: minmax(0, 1fr);
    }
}

.figure-two-svg {
    max-width: 620px;
}

.fig-box.is-optional .fig-shape {
    stroke-dasharray: 6 4;
}

.figure-two-panel {
    border-left: 4px solid var(--mud-palette-primary);
    padding-left: 1rem;
}

.figure-two-panel p {
    margin: 0 0 0.5rem;
}

/* Section 3.2.2: the cost of h heads */
.head-cost-svg {
    display: block;
    width: 100%;
    max-width: 640px;
    height: auto;
    margin: 0.5rem 0;
}

.head-slice { stroke: var(--mud-palette-surface); stroke-width: 1; }
.head-slice-0 { fill: #F7B955; }
.head-slice-1 { fill: #7C5CFF; }
.head-slice-2 { fill: #19F7D1; }
.head-slice-3 { fill: #3DD68C; }
.head-slice-label { font-size: 11px; font-weight: 600; fill: #0B0E1D; }
.head-cost svg .fig-note { fill: var(--mud-palette-text-secondary); }

.head-cost-table td {
    font-variant-numeric: tabular-nums;
    text-align: right;
}

/* Section 3.2.3: three attentions */
.three-maps {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr));
    gap: 1rem;
}

.three-map-title {
    margin: 0 0 0.25rem;
}

@media print {
    .embedded-tool .mud-button-root, .paper-quote-plain strong {
        display: inline;
    }

    .figure-two {
        grid-template-columns: minmax(0, 1fr);
    }
}

/* "Read the paper": the PDF on arXiv and its arXiv page (Theory, Home, chapters). */
.paper-link {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem 1rem;
    margin: 0.5rem 0 1rem;
}

.paper-link-actions {
    display: inline-flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem 1rem;
}

/* ---- M5 Part 2: figures of sections 5 to 7 and the appendix ---- */
.batching-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.batch {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 4px;
    border: 1px solid var(--mud-palette-lines-default);
    border-radius: 6px;
}

.batch-row {
    display: flex;
    gap: 2px;
}

.batch-cell {
    width: 10px;
    height: 10px;
    border-radius: 2px;
    background: var(--mud-palette-primary);
}

.batch-cell.is-pad {
    background: transparent;
    outline: 1px dashed var(--mud-palette-text-disabled);
    outline-offset: -1px;
}

.compute-bars {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 0.75rem;
}

.compute-run {
    display: grid;
    gap: 0.2rem;
}

.compute-name {
    font-weight: 600;
}

.compute-track, .table-two-track {
    display: block;
    height: 12px;
    background: var(--mud-palette-background-gray);
    border-radius: 6px;
    overflow: hidden;
    max-width: 560px;
}

.compute-bar, .table-two-bar {
    display: block;
    height: 100%;
    background: var(--mud-palette-primary);
    border-radius: 6px;
}

.table-two-bar.is-cost {
    background: var(--mud-palette-secondary);
}

.compute-value {
    font-size: 0.9rem;
    color: var(--mud-palette-text-secondary);
}

.table-two-table td.table-two-cell {
    min-width: 140px;
}

.table-two-number {
    display: block;
    font-variant-numeric: tabular-nums;
}

.table-two-table tr.is-transformer th, .table-two-table tr.is-transformer .table-two-number {
    font-weight: 700;
    color: var(--mud-palette-primary);
}

.table-two-column {
    font: inherit;
    font-weight: 600;
    color: var(--mud-palette-primary);
    background: none;
    border: none;
    border-bottom: 2px dashed currentColor;
    padding: 0;
    cursor: pointer;
    text-align: left;
}

.table-two-column.is-chosen {
    border-bottom-style: solid;
}

.parse-svg {
    display: block;
    width: 100%;
    max-width: 640px;
    height: auto;
}

.parse-edge { stroke: var(--mud-palette-text-secondary); stroke-width: 1.5; }
.parse-label { font-size: 16px; font-weight: 700; fill: var(--mud-palette-primary); }
.parse-word { font-size: 16px; fill: var(--mud-palette-text-primary); }

.parse-sequence {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    font-family: 'Roboto Mono', Consolas, monospace;
}

.parse-token {
    padding: 2px 6px;
    border-radius: 4px;
    border: 1px solid var(--mud-palette-lines-default);
}

.parse-token.is-bracket {
    color: var(--mud-palette-primary);
    font-weight: 600;
}

.parse-legend {
    columns: 2 220px;
    padding-left: 1.25rem;
}

.timeline-list {
    list-style: none;
    margin: 0;
    padding: 0 0 0 1rem;
    border-left: 3px solid var(--mud-palette-primary);
    display: grid;
    gap: 0.9rem;
}

.timeline-entry {
    display: grid;
    gap: 0.15rem;
}

.timeline-year {
    font-weight: 700;
    color: var(--mud-palette-primary);
}

.timeline-plan, .timeline-source {
    font-size: 0.9rem;
}

.timeline-plan {
    color: var(--mud-palette-text-secondary);
}

.lines-svg {
    display: block;
    width: 100%;
    max-width: 760px;
    height: auto;
}

.lines-word { font-size: 14px; fill: var(--mud-palette-text-primary); }
.lines-word.is-from { font-weight: 700; fill: var(--mud-palette-primary); }
.attn-line { fill: none; stroke-linecap: round; }
.head-line-0 { stroke: #F7B955; }
.head-line-1 { stroke: #7C5CFF; }
.head-line-2 { stroke: #19F7D1; }
.head-line-3 { stroke: #3DD68C; }

.head-swatch {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 2px;
    margin-right: 6px;
}

.lines-strongest {
    padding-left: 1.25rem;
    columns: 2 240px;
}

/* Chapter 22: Figure 1 losing its encoder, step by step (data-stage), and the two models side by side. */
.stage-buttons { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 0.5rem; }
.stage-caption { min-height: 3em; }
.decoder-only-layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: 1rem; align-items: start; }
@media (min-width: 900px) { .decoder-only-layout { grid-template-columns: minmax(0, 520px) minmax(0, 1fr); } }
.decoder-only-diagram { min-width: 0; }
.decoder-only-diagram .figure-one-svg { width: 100%; height: auto; max-width: 520px; }
.decoder-only-figure .fig-box, .decoder-only-figure .fig-arrow, .decoder-only-figure .fig-residual, .decoder-only-figure .fig-stack { transition: opacity 0.6s ease; }
.decoder-only-figure:not([data-stage="1"]) :is(.fig-box[data-box="inputs"], .fig-box[data-box^="input-"], .fig-box[data-box^="encoder-"], [data-into="input-embedding"], [data-into="input-positions"], [data-into^="encoder-"], .fig-memory, [data-stack="encoder"]) { opacity: 0.08; }
.decoder-only-figure:is([data-stage="3"], [data-stage="4"]) :is(.fig-box[data-box="decoder-cross"], .fig-box[data-box="decoder-norm-2"], [data-into="decoder-cross"], [data-into="decoder-norm-2"]) { opacity: 0.08; }
.decoder-only-changes { margin: 0; padding-left: 1.5rem; line-height: 1.7; opacity: 0.75; }
.decoder-only-changes.is-current { opacity: 1; border-left: 4px solid var(--mud-palette-primary); padding-left: 2rem; }
.decoder-only-changes li strong { margin-right: 0.35rem; }
.compare-table { margin-top: 1rem; border-collapse: collapse; }
.compare-table th, .compare-table td { padding: 0.3rem 0.75rem 0.3rem 0; vertical-align: top; text-align: left; border-bottom: 1px solid var(--mud-palette-lines-default); }
.compare-table th[scope="row"] { text-align: left; }

/* Chapter 23: sizes on a log scale, the context's cost, the three families. */
.size-axis { position: relative; height: 1.4rem; margin-left: calc(10rem + 0.75rem); margin-right: 0; font-size: 0.75rem; color: var(--mud-palette-text-secondary); }
.size-axis span { position: absolute; transform: translateX(-50%); }
.size-list { list-style: none; margin: 0; padding: 0; }
.size-row { display: grid; grid-template-columns: 10rem minmax(0, 1fr); column-gap: 0.75rem; row-gap: 0.15rem; padding: 0.35rem 0; border-bottom: 1px solid var(--mud-palette-lines-default); }
.size-name { font-weight: 600; }
.size-track { background: var(--mud-palette-background-gray); height: 0.9rem; border-radius: 3px; align-self: center; }
.size-fill { display: block; height: 100%; background: var(--mud-palette-secondary); border-radius: 3px; }
.size-row.is-ours .size-fill { background: var(--mud-palette-primary); }
.size-value, .size-source { grid-column: 2; font-size: 0.85rem; overflow-wrap: anywhere; }
@media (max-width: 600px) {
    .size-axis { margin: 0 0.9rem; }
    .size-row { grid-template-columns: minmax(0, 1fr); }
    .size-value, .size-source { grid-column: 1; }
}
.cost-row { display: grid; grid-template-columns: minmax(0, 14rem) minmax(0, 1fr); gap: 0.25rem 0.75rem; margin: 0.5rem 0; align-items: center; }
.cost-track { background: var(--mud-palette-secondary); height: 0.9rem; border-radius: 3px; overflow: hidden; }
.cost-attention { display: block; height: 100%; background: var(--mud-palette-primary); }
.cost-value { grid-column: 2; font-size: 0.85rem; }
@media (max-width: 600px) { .cost-row { grid-template-columns: minmax(0, 1fr); } .cost-value { grid-column: 1; } }
.model-families { display: grid; grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); gap: 1rem; }
.family-card { border: 1px solid var(--mud-palette-lines-default); border-radius: 8px; padding: 0.75rem 1rem; }
.family-grids { display: flex; flex-wrap: wrap; gap: 0.75rem; }
.family-grid { margin: 0.5rem 0; max-width: 9rem; }
.family-grid svg { width: 6rem; height: 6rem; display: block; }
.family-grid .grid-on { fill: var(--mud-palette-primary); }
.family-grid .grid-off { fill: none; stroke: var(--mud-palette-lines-default); stroke-width: 1.5; }

/* Chapters 24 and 25: the full trace, grouped and collapsible, and the experiments, predicted first. */
.sentence-picker { margin-bottom: 0.5rem; }
.trace-summary { margin: 0.75rem 0; overflow-wrap: anywhere; }
.trace-groups { display: flex; flex-direction: column; gap: 0.4rem; }
.trace-group { border: 1px solid var(--mud-palette-lines-default); border-radius: 6px; padding: 0.4rem 0.75rem; }
.trace-group > summary { cursor: pointer; font-weight: 600; padding: 0.25rem 0; }
.trace-steps { margin: 0.25rem 0 0.5rem; padding-left: 1.5rem; }
.trace-step > summary { cursor: pointer; padding: 0.15rem 0; display: list-item; }
.trace-step-name { font-weight: 500; margin-right: 0.5rem; }
.trace-step-live { color: var(--mud-palette-text-secondary); overflow-wrap: anywhere; }
.trace-step-body { border-left: 3px solid var(--mud-palette-primary); margin: 0.25rem 0 0.5rem; padding: 0.1rem 0.75rem; }
.trace-step-body p { margin: 0.35rem 0; }
.trace-links { display: flex; flex-wrap: wrap; gap: 0.25rem 0.5rem; font-size: 0.9rem; }
.experiments { display: flex; flex-direction: column; gap: 1rem; }
.experiment-card { border: 1px solid var(--mud-palette-lines-default); border-radius: 8px; padding: 0.75rem 1rem; }
.experiment-card h3 { margin: 0 0 0.5rem; }
.experiment-result { margin-top: 0.75rem; overflow-wrap: anywhere; }
.experiment-columns { display: grid; grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); gap: 1rem; }
@media print {
    .trace-group, .trace-step { break-inside: avoid; }
}
.legend-swatch { display: inline-block; width: 0.9rem; height: 0.9rem; border-radius: 2px; vertical-align: middle; margin-right: 0.3rem; }
.legend-attention { background: var(--mud-palette-primary); }
.legend-rest { background: var(--mud-palette-secondary); }


/* The lab guide (/guide): annotated screenshots, a walkthrough of pictures, the five phases and suggested paths. */
.guide-intro {
    max-width: 760px;
}

.guide-toc ol {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 8px;
    list-style: none;
    padding: 0;
    margin: 0 0 1.5rem;
    counter-reset: toc;
}

.guide-toc li {
    counter-increment: toc;
}

.guide-toc a {
    display: inline-block;
    padding: 4px 12px;
    border: 1px solid var(--mud-palette-lines-default);
    border-radius: 16px;
    color: var(--mud-palette-text-primary);
    text-decoration: underline;
    text-underline-offset: 2px;
    font-size: 0.875rem;
}

.guide-toc a::before {
    content: counter(toc) ". ";
    color: var(--mud-palette-text-secondary);
}

.guide-section {
    max-width: 1000px;
    margin: 0 0 2.5rem;
    scroll-margin-top: 72px;
}

.guide-lead {
    font-size: 1.05rem;
    line-height: 1.6;
    margin: 0 0 1rem;
    max-width: 860px;
    color: var(--mud-palette-text-secondary);
}

.guide-text {
    margin-top: 1rem;
}

.guide-shot {
    margin: 0 0 1.5rem;
    break-inside: avoid;
}

/* The frame wraps the picture at its natural size (a close-up is not blown up), never wider than the column. */
.guide-shot-frame {
    position: relative;
    display: inline-block;
    max-width: 100%;
    vertical-align: top;
    border: 1px solid var(--mud-palette-lines-default);
    border-radius: 8px;
    overflow: hidden;
    line-height: 0;
}

.guide-shot-frame img {
    max-width: 100%;
    height: auto;
    display: block;
}

.guide-pin {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--mud-palette-warning);
    color: var(--mud-palette-warning-text);
    border: 2px solid var(--mud-palette-white);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.6);
    font-weight: 700;
    font-size: 0.85rem;
    line-height: 1;
}

.guide-shot-frame .guide-pin {
    position: absolute;
    transform: translate(-50%, -50%);
}

.guide-shot-caption {
    font-weight: 500;
    margin: 0.75rem 0 0.25rem;
    line-height: 1.5;
}

.guide-callouts {
    list-style: none;
    padding: 0;
    margin: 0.75rem 0 0;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 6px 20px;
}

.guide-callouts li {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    line-height: 1.45;
    font-size: 0.925rem;
}

.guide-pin-inline {
    flex: 0 0 auto;
    width: 24px;
    height: 24px;
    font-size: 0.8rem;
    box-shadow: none;
}

.guide-path-steps {
    padding-left: 1.25rem;
    margin: 0;
}

.guide-path-steps li {
    line-height: 1.5;
    margin-bottom: 0.4rem;
    font-size: 0.925rem;
}

.guide-hint {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px 10px;
    border: 1px solid var(--mud-palette-lines-default);
    border-left: 4px solid var(--mud-palette-primary);
    border-radius: 8px;
    padding: 4px 6px 4px 12px;
    margin: 0 0 1.25rem;
    font-size: 0.9rem;
}

.guide-hint-text {
    flex: 1 1 16rem;
}

@media (max-width: 600px) {
    .guide-pin {
        width: 22px;
        height: 22px;
        font-size: 0.75rem;
    }

    .guide-pin-inline {
        width: 22px;
        height: 22px;
    }
}

@media print {
    .guide-sequence-frame {
        display: block !important;
        break-inside: avoid;
    }

    .guide-pin {
        print-color-adjust: exact;
        -webkit-print-color-adjust: exact;
    }

}

/* The notation sheet (/notation): one table, on one A4 page in landscape when printed. */
.notation-sheet-table { border-collapse: collapse; width: 100%; }
.notation-sheet-table th, .notation-sheet-table td { padding: 0.3rem 0.6rem; border-bottom: 1px solid var(--mud-palette-lines-default); text-align: left; vertical-align: top; }
.notation-sheet-table thead th { font-weight: 600; }
.notation-sheet-table .formula-cell { white-space: nowrap; font-weight: 400; }
.notation-links { white-space: nowrap; }
@page notation-sheet { size: A4 landscape; margin: 10mm; }
@media print {
    .notation-page { page: notation-sheet; }
    .notation-page h1 { font-size: 16pt !important; margin-bottom: 2pt !important; }
    .notation-page .intro { font-size: 8pt !important; margin-bottom: 4pt !important; }
    .notation-sheet { overflow: visible !important; }
    .notation-page .mud-typography-overline { display: none !important; }
    .notation-page > .mud-typography-body2 { font-size: 7pt !important; margin-top: 3pt !important; }
    .notation-sheet-table { font-size: 7pt; line-height: 1.15; }
    .notation-sheet-table th, .notation-sheet-table td { padding: 0.8pt 3pt; }
    .notation-sheet-table .katex { font-size: 1em; }
    .notation-links a { text-decoration: none; }
}

/* The translation chat (/tools/chat): the reader's sentences on the right, the model's replies on the left. */
.chat-top {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.25rem 1rem;
}

.chat-log {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    max-height: min(60vh, 560px);
    min-height: 140px;
    overflow-y: auto;
    padding: 0.75rem;
    margin: 0.75rem 0 1rem;
    border: 1px solid var(--mud-palette-lines-default);
    border-radius: 8px;
    background: var(--mud-palette-background);
}

.chat-log:focus-visible {
    outline: 2px solid var(--mud-palette-primary);
    outline-offset: 2px;
}

.chat-row {
    display: flex;
}

.chat-from-reader {
    justify-content: flex-end;
}

.chat-bubble {
    max-width: min(85%, 640px);
    min-width: 0;
    padding: 0.55rem 0.85rem;
    border-radius: 14px;
    line-height: 1.5;
    overflow-wrap: anywhere;
}

.chat-from-reader .chat-bubble {
    background: var(--mud-palette-primary);
    color: var(--mud-palette-primary-text);
    border-bottom-right-radius: 4px;
}

.chat-from-model .chat-bubble {
    background: var(--mud-palette-surface);
    color: var(--mud-palette-text-primary);
    border: 1px solid var(--mud-palette-lines-default);
    border-bottom-left-radius: 4px;
}

.chat-bubble p {
    margin: 0;
}

.chat-bubble p + p, .chat-bubble p + details, .chat-bubble .chat-suggestions + p {
    margin-top: 0.4rem;
}

.chat-german {
    font-size: 1.25rem;
    font-weight: 500;
    color: var(--mud-palette-primary);
}

.chat-meta {
    font-size: 0.85rem;
    color: var(--mud-palette-text-secondary);
}

.chat-continuation {
    font-size: 1.1rem;
}

.chat-word {
    font-weight: 600;
    color: var(--mud-palette-primary);
}

.chat-word.is-new {
    animation: chat-word-in 0.3s ease-out both;
    animation-delay: calc(var(--i) * 0.35s);
}

@keyframes chat-word-in {
    from { opacity: 0; transform: translateY(0.3em); }
    to { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
    .chat-word.is-new { animation: none; }
}

mark.chat-unknown {
    background: #FFE08A;
    color: #1A1A1A;
    padding: 0 0.15em;
    border-radius: 3px;
    text-decoration: underline wavy #B3261E;
    text-underline-offset: 3px;
}

.chat-suggestions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.35rem;
    margin-top: 0.4rem;
}

.chat-instead {
    font-size: 0.9rem;
    margin-right: 0.15rem;
}

.chat-candidates summary {
    cursor: pointer;
    color: var(--mud-palette-primary);
    font-size: 0.9rem;
}

.chat-candidates .mud-simple-table {
    background: transparent;
}

.chat-chosen {
    color: var(--mud-palette-text-secondary);
    font-weight: 400;
}

.chat-input-row {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
}

.chat-input {
    flex: 1 1 auto;
    min-width: 0;
}

.chat-send {
    margin-top: 6px !important;
    flex: 0 0 auto;
}

.chat-hint {
    margin: 0.25rem 0 0;
    font-size: 0.9rem;
}

.chat-section {
    margin-top: 1.25rem;
}

.chat-filter {
    max-width: 320px;
}

.chat-group {
    margin-bottom: 0.6rem;
}

.chat-group-title {
    font-size: 0.85rem;
    font-weight: 600;
    margin: 0 0 0.3rem;
    color: var(--mud-palette-text-secondary);
}

.chat-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
}

.word-chip {
    font: inherit;
    font-size: 0.9rem;
    line-height: 1.2;
    min-height: 32px;
    min-width: 32px;
    padding: 0.3rem 0.7rem;
    border-radius: 16px;
    border: 1px solid var(--mud-palette-primary);
    background: transparent;
    color: var(--mud-palette-primary);
    cursor: pointer;
}

.word-chip:hover {
    background: var(--mud-palette-action-default-hover);
}

.word-chip:focus-visible {
    outline: 2px solid var(--mud-palette-primary);
    outline-offset: 2px;
}

@media (max-width: 600px) {
    .chat-log {
        max-height: 70vh;
        padding: 0.5rem;
    }

    .chat-bubble {
        max-width: 92%;
    }

    .chat-input-row {
        flex-direction: column;
        align-items: stretch;
        gap: 0.25rem;
    }

    .chat-send {
        margin-top: 0 !important;
        align-self: flex-end;
    }
}

@media print {
    .chat-log {
        max-height: none;
        overflow: visible;
        border: none;
        padding: 0;
    }

    .chat-input-row, .chat-hint {
        display: none !important;
    }

    .chat-bubble {
        break-inside: avoid;
        border: 1px solid #999 !important;
        background: #fff !important;
        color: #000 !important;
    }

    .chat-word.is-new {
        animation: none;
    }
}
