/* MRAT stylesheet (#115): the component CSS of the approved design system (#112, components/bundle.css),
   in cascade layers. tokens.css (generated) holds the tokens and the type classes. Rules and values are the
   design system's; additions are marked "MRAT:". No inline style anywhere: the CSP has no 'unsafe-inline'. */
@layer reset, tokens, base, components, utilities, print;

@layer reset {
  *,
  *::before,
  *::after {
    box-sizing: border-box;
  }
}

@layer base {
  /* MRAT: the full upstream variable fonts (vendor.json). The weight and width ranges let
     font-variation-settings and font-stretch reach every width. */
  @font-face {
    font-family: "Mona Sans";
    src: url("/static/fonts/MonaSans-Variable.875ad1fab0c1.woff2") format("woff2");
    font-weight: 200 900;
    font-stretch: 75% 125%;
    font-style: normal;
    font-display: swap;
  }

  @font-face {
    font-family: "Martian Mono";
    src: url("/static/fonts/MartianMono-Variable.7cdf8e985a48.woff2") format("woff2");
    font-weight: 100 800;
    font-stretch: 75% 112.5%;
    font-style: normal;
    font-display: swap;
  }

  /* MRAT: upstream Mona Sans 2.027 has an optical-size axis that the approved design (drawn with a font
     without it) does not use; "none" keeps the default optical size, so the glyphs match the design. */
  :root {
    font-optical-sizing: none;
  }

  body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: var(--font-sans);
    font-size: 15px;
    line-height: 22px;
    letter-spacing: -0.003em;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
  }

  h1,
  h2,
  h3,
  h4 {
    text-wrap: balance;
  }

  .display,
  .title,
  .m-pagehead h1 {
    font-variation-settings: "wdth" 112;
  }

  :focus-visible {
    outline: var(--focus-width) solid var(--focus);
    outline-offset: var(--focus-offset);
  }

  .m-data {
    font-family: var(--font-mono);
    font-variation-settings: "wdth" 87.5;
    font-size: 0.9em;
    letter-spacing: 0;
    font-variant-numeric: tabular-nums slashed-zero;
  }

  .m-muted {
    color: var(--ink-muted);
  }

  .m-visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }

  .m-icon {
    width: 18px;
    height: 18px;
    flex: none;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
  }

  .m-row {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-3);
    align-items: center;
  }

  .m-stack {
    display: grid;
    gap: var(--space-3);
  }

  /* MRAT (#339): a child is as wide as the stack. Without this, a scrolling child (a table, the print sheet) made the
     stack as wide as its content, and the page scrolled sideways on a phone. */
  .m-stack > * {
    min-width: 0;
  }
}

@layer components {
  /* MRAT (#219): the top stop of the primary gradient, registered so that it transitions. css-cascade-5 allows
     @property in a layer, so it stays with the button. Without @property the top changes at once, still opaque. */
  @property --m-btn-top {
    syntax: "<color>";
    inherits: false;
    initial-value: transparent;
  }

  /* Button: tactile, with a light top edge and a short shadow */
  .m-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    min-height: var(--control-h);
    padding: 0 var(--space-4);
    border: var(--border-hairline) solid var(--line);
    border-radius: var(--radius-md);
    background: var(--surface);
    color: var(--ink);
    font: inherit;
    font-weight: 600;
    letter-spacing: -0.01em;
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
    box-shadow: var(--shadow-xs);
    transition:
      background-color 120ms,
      --m-btn-top 120ms,
      box-shadow 120ms,
      transform 80ms;
  }

  .m-btn:hover {
    background: var(--surface-sunken);
  }

  .m-btn:active {
    transform: translateY(1px);
    box-shadow: none;
  }

  /* MRAT (#219): an opaque background-color under the gradient in every state, and a hover that fades the top stop.
     The shorthand with only a gradient sets background-color to transparent, and an image does not transition:
     the hover faded the colour in from transparent, a flash. */
  .m-btn--primary {
    --m-btn-top: var(--accent-top);

    color: var(--on-accent);
    background: linear-gradient(to bottom, var(--m-btn-top), var(--accent)) var(--accent);
    border-color: var(--accent-strong);
    box-shadow: var(--shadow-primary);
  }

  .m-btn--primary:hover {
    --m-btn-top: var(--accent);

    background: linear-gradient(to bottom, var(--m-btn-top), var(--accent)) var(--accent);
  }

  .m-btn--quiet {
    background: transparent;
    border-color: transparent;
    box-shadow: none;
    color: var(--ink-muted);
  }

  .m-btn--quiet:hover {
    background: var(--surface-sunken);
    color: var(--ink);
  }

  .m-btn--danger {
    color: var(--on-danger);
    background: var(--danger);
    border-color: var(--danger);
  }

  .m-btn--danger:hover {
    background: var(--danger);
    box-shadow: var(--shadow-sm);
  }

  .m-btn--sm {
    min-height: var(--control-h-sm);
    padding: 0 var(--space-3);
    border-radius: var(--radius-sm);
    font-size: 13px;
  }

  .m-btn--icon {
    padding: 0;
    width: var(--control-h);
  }

  .m-btn--sm.m-btn--icon {
    width: var(--control-h-sm);
  }

  .m-btn[disabled],
  .m-btn[aria-disabled="true"] {
    cursor: not-allowed;
    background: var(--surface-sunken);
    border-color: var(--line);
    color: var(--ink-muted);
    box-shadow: none;
  }

  .m-link {
    color: var(--accent);
    font-weight: 500;
    text-decoration: underline;
    text-decoration-color: var(--focus-halo);
    text-decoration-thickness: 2px;
    text-underline-offset: 0.22em;
  }

  .m-link:hover {
    color: var(--accent-strong);
    text-decoration-color: currentColor;
  }

  /* Form fields */
  .m-field {
    display: grid;
    gap: 6px;
    min-width: 0;
    align-content: start;
  }

  .m-field__label {
    font-size: 13px;
    font-weight: 600;
    line-height: 18px;
  }

  .m-field__unit {
    font-weight: 500;
    color: var(--ink-muted);
  }

  .m-field__hint {
    margin: 0;
    font-size: 13px;
    line-height: 18px;
    color: var(--ink-muted);
  }

  .m-field__error {
    display: flex;
    gap: 6px;
    align-items: flex-start;
    margin: 0;
    font-size: 13px;
    line-height: 18px;
    font-weight: 600;
    color: var(--danger);
  }

  .m-field__error .m-icon {
    width: 16px;
    height: 16px;
    margin-top: 1px;
  }

  .m-input {
    width: 100%;
    min-height: var(--control-h);
    padding: 0 var(--space-3);
    border: var(--border-hairline) solid var(--line-control);
    border-radius: var(--radius-md);
    background: var(--surface);
    color: var(--ink);
    font: inherit;
    box-shadow: var(--shadow-inset);
    transition:
      border-color 120ms,
      box-shadow 120ms;
  }

  .m-input:hover {
    border-color: var(--line-strong);
  }

  .m-input:focus-visible {
    outline: var(--focus-width) solid var(--focus);
    outline-offset: 0;
    border-color: var(--focus);
    box-shadow: 0 0 0 5px var(--focus-halo);
  }

  textarea.m-input {
    min-height: 6rem;
    padding: 10px var(--space-3);
    resize: vertical;
  }

  .m-input.m-data,
  .m-input--data {
    font-family: var(--font-mono);
    font-variation-settings: "wdth" 87.5;
    font-variant-numeric: tabular-nums slashed-zero;
  }

  input.m-input:read-only,
  textarea.m-input:read-only,
  .m-input[aria-readonly="true"] {
    background: var(--surface-sunken);
    border-style: dashed;
    box-shadow: none;
  }

  .m-field--error .m-input {
    border-color: var(--danger);
    box-shadow: 0 0 0 3px var(--danger-soft);
  }

  .m-select {
    position: relative;
  }

  .m-select select {
    appearance: none;
    padding-right: var(--space-7);
  }

  .m-select .m-icon {
    position: absolute;
    right: var(--space-3);
    top: 50%;
    translate: 0 -50%;
    pointer-events: none;
    color: var(--ink-muted);
  }

  .m-fields {
    display: grid;
    gap: var(--space-4);
    grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr));
  }

  /* MRAT: the airport search (#718). A grid, so the input is a block and the page does not move; the list has the
     width of the field. 4ch: 3-letter ids keep the names in line. */
  .m-combo {
    position: relative;
    display: grid;
  }

  .m-combo ul {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 30;
    max-height: 22rem;
    margin: 0;
    padding: 4px;
    overflow-y: auto;
    list-style: none;
    background: var(--surface-raised);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
  }

  .m-combo li {
    display: grid;
    grid-template-columns: minmax(4ch, auto) minmax(0, 1fr);
    gap: 0 8px;
    min-height: var(--target-min);
    padding: 8px 12px;
    border-radius: var(--radius-md);
    cursor: pointer;
  }

  .m-combo li:hover,
  .m-combo [aria-selected="true"] {
    background: var(--accent-soft);
  }

  .m-combo .m-field__hint {
    grid-column: 2;
  }

  /* Checkbox */
  .m-check {
    display: flex;
    gap: var(--space-3);
    align-items: flex-start;
    min-height: var(--target-min);
    padding-block: 11px;
    cursor: pointer;
  }

  .m-check input {
    width: 20px;
    height: 20px;
    margin: 1px 0 0;
    flex: none;
    accent-color: var(--accent);
  }

  .m-check input:disabled + span {
    color: var(--ink-muted);
  }

  .m-checklist {
    display: grid;
    margin: 0;
    padding: 0;
    border: 0;
  }

  .m-checklist legend {
    font-weight: 650;
    margin-bottom: var(--space-1);
  }

  /* Segmented controls: Yes/No answer and theme switch */
  .m-answer,
  .m-theme {
    display: inline-grid;
    grid-auto-flow: column;
    gap: 3px;
    margin: 0;
    padding: 3px;
    border: 0;
    border-radius: calc(var(--radius-md) + 3px);
    background: var(--surface-sunken);
    box-shadow: inset 0 0 0 1px var(--line);
  }

  .m-answer input,
  .m-theme input {
    position: absolute;
    opacity: 0;
    width: 1px;
    height: 1px;
  }

  .m-answer label {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    min-width: 5.5rem;
    min-height: calc(var(--target-min) - 6px);
    padding: 0 var(--space-4);
    border-radius: var(--radius-md);
    font-weight: 650;
    color: var(--ink-muted);
    cursor: pointer;
    transition:
      background var(--dur-1) var(--ease-out),
      color var(--dur-1) var(--ease-out),
      transform var(--dur-1) var(--ease-out);
  }

  .m-answer label:hover {
    color: var(--ink);
  }

  .m-answer input:checked + label {
    background: var(--surface);
    color: var(--ink);
    box-shadow:
      var(--shadow-xs),
      inset 0 0 0 1px var(--line);
  }

  .m-answer input[value="yes"]:checked + label {
    background: var(--ink);
    color: var(--bg);
    box-shadow: var(--shadow-xs);
  }

  .m-answer input:focus-visible + label,
  .m-theme input:focus-visible + label {
    outline: var(--focus-width) solid var(--focus);
    outline-offset: 1px;
  }

  .m-answer__points {
    font-family: var(--font-mono);
    font-variation-settings: "wdth" 87.5;
    font-weight: 500;
    font-size: 13px;
  }

  .m-theme label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 34px;
    padding: 0 var(--space-3);
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    color: var(--ink-muted);
    cursor: pointer;
  }

  .m-theme input:checked + label {
    background: var(--surface);
    color: var(--ink);
    box-shadow:
      var(--shadow-xs),
      inset 0 0 0 1px var(--line);
  }

  .m-theme .m-icon {
    width: 16px;
    height: 16px;
  }

  /* Reduction picker: a bounded whole-number choice, 0 to the question's points. MRAT (#339): a flex row that wraps,
     not a grid column flow: the 0 to 5 choices of a 5-point question are wider than a 360 px phone. */
  .m-reduce {
    justify-self: start;
    display: inline-flex;
    flex-wrap: wrap;
    gap: 3px;
    margin: 0;
    padding: 3px;
    border: 0;
    border-radius: calc(var(--radius-md) + 3px);
    background: var(--surface-sunken);
    box-shadow: inset 0 0 0 1px var(--line);
  }

  .m-reduce input {
    position: absolute;
    opacity: 0;
    width: 1px;
    height: 1px;
  }

  .m-reduce label {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    min-height: 34px;
    padding: 0 10px;
    border-radius: var(--radius-md);
    font-family: var(--font-mono);
    font-variation-settings: "wdth" 87.5;
    font-weight: 600;
    color: var(--ink-muted);
    cursor: pointer;
  }

  .m-reduce label:hover {
    color: var(--ink);
  }

  .m-reduce input:checked + label {
    background: var(--surface);
    color: var(--ink);
    box-shadow:
      var(--shadow-xs),
      inset 0 0 0 1px var(--line);
  }

  .m-reduce input:focus-visible + label {
    outline: var(--focus-width) solid var(--focus);
    outline-offset: 1px;
  }

  .m-reduce input:disabled + label {
    cursor: not-allowed;
  }

  fieldset.m-field {
    margin: 0;
    padding: 0;
    border: 0;
  }

  fieldset.m-field > legend {
    padding: 0;
    margin-bottom: 6px;
  }

  @media (max-width: 1023px) {
    .m-reduce label {
      min-height: calc(var(--target-min) - 6px);
    }
  }

  /* Risk badge: tinted for Low/Moderate/High, solid for Stop and for the --solid variant */
  .m-risk {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 24px;
    padding: 0 9px 0 7px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 650;
    line-height: 1;
    white-space: nowrap;
  }

  .m-risk__glyph {
    width: 14px;
    height: 14px;
    flex: none;
    fill: currentColor;
  }

  .m-risk--low {
    background: var(--risk-low-soft);
    color: var(--risk-low-ink);
    box-shadow: inset 0 0 0 1px var(--risk-low-edge);
  }

  .m-risk--moderate {
    background: var(--risk-moderate-soft);
    color: var(--risk-moderate-ink);
    box-shadow: inset 0 0 0 1px var(--risk-moderate-edge);
  }

  .m-risk--high {
    background: var(--risk-high-soft);
    color: var(--risk-high-ink);
    box-shadow: inset 0 0 0 1px var(--risk-high-edge);
  }

  .m-risk--stop {
    background: var(--risk-stop);
    color: var(--on-risk-stop);
  }

  .m-risk--none {
    background: transparent;
    color: var(--ink-muted);
    box-shadow: inset 0 0 0 1px var(--line-control);
  }

  .m-risk--solid.m-risk--low {
    background: var(--risk-low);
    color: var(--on-risk-low);
    box-shadow: none;
  }

  .m-risk--solid.m-risk--moderate {
    background: var(--risk-moderate);
    color: var(--on-risk-moderate);
    box-shadow: inset 0 0 0 1px var(--risk-moderate-ink);
  }

  .m-risk--solid.m-risk--high {
    background: var(--risk-high);
    color: var(--on-risk-high);
    box-shadow: none;
  }

  .m-risk--lg {
    height: 36px;
    padding: 0 14px 0 11px;
    gap: 8px;
    border-radius: var(--radius-md);
    font-size: 16px;
    letter-spacing: -0.01em;
  }

  .m-risk--lg .m-risk__glyph {
    width: 18px;
    height: 18px;
  }

  .m-risk-text {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-weight: 650;
  }

  .m-risk-text .m-risk__glyph {
    width: 14px;
    height: 14px;
  }

  .m-risk-text--low {
    color: var(--risk-low-ink);
  }

  .m-risk-text--moderate {
    color: var(--risk-moderate-ink);
  }

  .m-risk-text--high {
    color: var(--risk-high-ink);
  }

  .m-risk-text--stop {
    color: var(--risk-stop-ink);
  }

  /* Score bar: translucent, sticky */
  .m-score {
    position: sticky;
    top: 0;
    z-index: 5;
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-3) var(--space-5);
    align-items: center;
    padding: var(--space-3) var(--space-4);
    background: color-mix(in oklch, var(--surface-raised) 86%, transparent);
    backdrop-filter: blur(14px) saturate(1.4);
    border: var(--border-hairline) solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
  }

  .m-score__num {
    display: flex;
    align-items: baseline;
    gap: 6px;
  }

  .m-score__value {
    font-family: var(--font-mono);
    font-variation-settings: "wdth" 87.5;
    font-size: 36px;
    line-height: 40px;
    font-weight: 700;
    letter-spacing: -0.02em;
    font-variant-numeric: tabular-nums slashed-zero;
  }

  .m-score__unit {
    color: var(--ink-muted);
    font-size: 13px;
  }

  .m-score__parts {
    display: flex;
    gap: var(--space-5);
    margin: 0;
  }

  .m-score__parts div {
    display: grid;
    gap: 2px;
  }

  .m-score__parts dt {
    font-size: 12px;
    line-height: 16px;
    font-weight: 600;
    color: var(--ink-muted);
  }

  .m-score__parts dd {
    margin: 0;
    font-family: var(--font-mono);
    font-variation-settings: "wdth" 87.5;
    font-weight: 600;
  }

  .m-scale {
    width: 100%;
    max-width: 22rem;
    height: auto;
    flex: 1 1 14rem;
  }

  .m-scale__band--low {
    fill: var(--risk-low-soft);
  }

  .m-scale__band--moderate {
    fill: var(--risk-moderate-soft);
  }

  .m-scale__band--high {
    fill: var(--risk-high-soft);
  }

  .m-scale__band--stop {
    fill: var(--risk-stop-soft);
  }

  .m-scale__edge {
    stroke: var(--line-control);
    stroke-width: 1;
  }

  .m-scale__tick {
    fill: var(--ink-muted);
    font-family: var(--font-mono);
    font-size: 10px;
  }

  .m-scale__marker {
    fill: var(--ink);

    /* MRAT (v2.3 Motion): the marker slides to the new score; a browser that cannot animate a path moves it
       at once. */
    transition: d var(--dur-4) var(--ease-out);
  }

  /* Stop item flag */
  .m-stopflag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--risk-stop-ink);
    font-size: 13px;
    font-weight: 650;
    line-height: 18px;
  }

  .m-stopflag .m-risk__glyph {
    width: 15px;
    height: 15px;
  }

  /* Status: a dot and a word, never a risk colour */
  .m-status {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    font-size: 13px;
    font-weight: 600;
    line-height: 18px;
    white-space: nowrap;
    color: var(--ink);
  }

  .m-status::before {
    content: "";
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex: none;
    background: var(--ink-muted);
  }

  .m-status--draft::before {
    background: transparent;
    box-shadow: inset 0 0 0 1.5px var(--ink-muted);
  }

  .m-status--under-review::before {
    background: var(--accent);
    box-shadow: 0 0 0 3px var(--focus-halo);
  }

  .m-status--approved::before {
    background: var(--ink);
  }

  .m-status--archived {
    color: var(--ink-muted);
  }

  .m-status--archived::before {
    background: var(--line-control);
  }

  /* After Approved (#228): Work done has the Approved dot with a ring; Closed out a ringed, filled dot */
  .m-status--work-done::before {
    background: var(--ink);
    box-shadow: 0 0 0 3px var(--line);
  }

  .m-status--closed-out::before {
    background: var(--ink);
    box-shadow:
      0 0 0 2px var(--surface),
      0 0 0 3.5px var(--ink);
  }

  /* Alert: a surface card with a coloured icon tile */
  .m-alert {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 2px var(--space-3);
    align-items: start;
    padding: var(--space-3);
    background: var(--surface);
    border: var(--border-hairline) solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);

    /* MRAT (v2.3 Motion): an alert drops in (dur-2). */
    animation: m-drop var(--dur-2) var(--ease-out) backwards;
  }

  .m-alert > .m-tile {
    grid-row: span 2;
  }

  .m-alert__title {
    margin: 5px 0 0;
    font-weight: 650;
    letter-spacing: -0.01em;
  }

  .m-alert__body {
    margin: 0;
    grid-column: 2;
    color: var(--ink-muted);
  }

  .m-alert__action {
    grid-row: 1 / span 2;
    grid-column: 3;
    align-self: center;
  }

  /* Tile: a small coloured square that carries an icon (alerts, dialogs, empty states) */
  .m-tile {
    display: grid;
    place-items: center;
    width: 32px;
    height: 32px;
    flex: none;
    border-radius: 9px;
    background: var(--surface);
    color: var(--ink-muted);
    box-shadow:
      var(--shadow-xs),
      inset 0 0 0 1px var(--line);
  }

  .m-tile .m-icon {
    width: 18px;
    height: 18px;
    stroke-width: 2.2;
  }

  .m-tile--lg {
    width: 40px;
    height: 40px;
    border-radius: 11px;
  }

  .m-tile--lg .m-icon {
    width: 20px;
    height: 20px;
  }

  .m-tile--info {
    background: var(--accent);
    color: var(--on-accent);
    box-shadow: none;
  }

  .m-tile--success {
    background: var(--success);
    color: var(--on-success);
    box-shadow: none;
  }

  .m-tile--warning {
    background: var(--warning);
    color: var(--on-warning);
    box-shadow: none;
  }

  .m-tile--danger {
    background: var(--danger);
    color: var(--on-danger);
    box-shadow: none;
  }

  /* Toast: inverse, floating */
  .m-toasts {
    display: grid;
    gap: var(--space-2);
    justify-items: end;
  }

  .m-toast {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    max-width: 30rem;
    padding: 10px 10px 10px 14px;
    background: var(--inverse);
    color: var(--on-inverse);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    font-weight: 500;
  }

  .m-toast .m-icon {
    width: 18px;
    height: 18px;
  }

  .m-toast .m-btn {
    min-height: 30px;
    border-radius: var(--radius-sm);
    font-size: 13px;
  }

  /* Panel */
  .m-panel {
    background: var(--surface);
    border: var(--border-hairline) solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xs);
  }

  .m-panel__head {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-3);
    align-items: center;
    justify-content: space-between;
    padding: var(--space-3) var(--space-4) 0;
  }

  .m-panel__title {
    margin: 0;
    font-size: 16px;
    line-height: 24px;
    font-weight: 650;
    letter-spacing: -0.012em;
  }

  .m-panel__body {
    padding: var(--space-4);
  }

  /* Key-value list */
  .m-kv {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(10rem, 1fr));
    gap: var(--space-4) var(--space-5);
    margin: 0;
  }

  .m-kv div {
    display: grid;
    gap: 2px;
    min-width: 0;
  }

  .m-kv dt {
    font-size: 12px;
    line-height: 16px;
    font-weight: 600;
    color: var(--ink-muted);
  }

  .m-kv dd {
    margin: 0;
    font-weight: 500;
    overflow-wrap: anywhere;
  }

  /* Table */
  .m-table-wrap {
    /* MRAT (#339): the containing block of the visually hidden texts in the cells, so the scroll clips them too.
       Without it they were placed past the right edge of a wide table and the page scrolled sideways. */
    position: relative;
    overflow-x: auto;
    background: var(--surface);
    border: var(--border-hairline) solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xs);
  }

  .m-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 14px;
  }

  .m-table caption,
  .m-table__head {
    text-align: left;
    padding: var(--space-3) var(--space-4);
    font-weight: 650;
    letter-spacing: -0.01em;
  }

  /* #191: the title row of a table with a link beside the title; it looks like the caption it replaces. */
  .m-table__head {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
    justify-content: space-between;
    align-items: center;
    font-size: 14px;
  }

  .m-table__head .m-link {
    font-size: 13px;
  }

  .m-table th,
  .m-table td {
    padding: 10px var(--space-4);
    text-align: left;
    vertical-align: middle;
    border-bottom: var(--border-hairline) solid var(--line);
  }

  .m-table tbody tr:last-child td {
    border-bottom: 0;
  }

  .m-table thead th {
    background: var(--surface-sunken);
    font-size: 12px;
    line-height: 16px;
    font-weight: 600;
    color: var(--ink-muted);
    white-space: nowrap;
  }

  .m-table tbody tr:hover td {
    background: var(--surface-sunken);
  }

  .m-table .m-num {
    text-align: right;
    font-family: var(--font-mono);
    font-variation-settings: "wdth" 87.5;
    font-variant-numeric: tabular-nums slashed-zero;
  }

  .m-sort {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 0;
    border: 0;
    background: none;
    color: inherit;
    font: inherit;
    cursor: pointer;
    text-decoration: none;
  }

  .m-sort .m-icon {
    width: 14px;
    height: 14px;
  }

  th[aria-sort] .m-sort {
    color: var(--ink);
  }

  /* #199: the work order is the record link of a list row. A table cell would break it after each hyphen, so it
     stays on one line; a very long one ends with an ellipsis (the link text, its accessible name, stays whole). */
  .m-record-link {
    display: inline-block;
    max-width: 22ch;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    vertical-align: bottom;

    /* Room for the underline, which the hidden overflow would cut. */
    padding-bottom: 4px;
    margin-bottom: -4px;
  }

  .m-record-link--none {
    color: var(--ink-muted);
    font-weight: 400;
  }

  @media (max-width: 639px) {
    .m-table--stack thead {
      position: absolute;
      width: 1px;
      height: 1px;
      overflow: hidden;
      clip-path: inset(50%);
    }

    .m-table--stack tr {
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: var(--space-2) var(--space-3);
      padding: var(--space-3) var(--space-4);
      border-bottom: var(--border-hairline) solid var(--line);
    }

    .m-table--stack td {
      display: grid;
      gap: 2px;
      padding: 0;
      border: 0;
      text-align: left;
    }

    .m-table--stack td::before {
      content: attr(data-label);
      font-size: 12px;
      font-weight: 600;
      color: var(--ink-muted);
    }

    /* #199: the work order link is the title of a row card. */
    .m-table--stack td:has(> .m-record-link) {
      grid-column: 1 / -1;
      font-size: 15px;
    }

    .m-table--stack td:has(> .m-record-link)::before {
      content: none;
    }

    /* The title of a card has the whole width: a long work order wraps, and breaks anywhere, so it cannot make the
       card wider than the screen. */
    .m-table--stack .m-record-link {
      display: inline;
      max-width: none;
      white-space: normal;
      overflow-wrap: anywhere;
    }
  }

  /* Pagination */
  .m-pages {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
    align-items: center;
    justify-content: space-between;
  }

  .m-pages__list {
    display: flex;
    gap: 2px;
    margin: 0;
    padding: 0;
    list-style: none;
  }

  .m-pages__list a,
  .m-pages__list span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: var(--control-h-sm);
    min-height: var(--control-h-sm);
    border-radius: var(--radius-sm);
    color: var(--ink-muted);
    text-decoration: none;
    font-family: var(--font-mono);
    font-variation-settings: "wdth" 87.5;
    font-size: 13px;
  }

  .m-pages__list a:hover {
    background: var(--surface-sunken);
    color: var(--ink);
  }

  .m-pages__list [aria-current="page"] {
    background: var(--surface);
    color: var(--ink);
    font-weight: 700;
    box-shadow:
      var(--shadow-xs),
      inset 0 0 0 1px var(--line);
  }

  /* Empty state */
  .m-empty {
    display: grid;
    justify-items: start;
    gap: var(--space-2);
    padding: var(--space-6) var(--space-5);
    border: 1.5px dashed var(--line-control);
    border-radius: var(--radius-lg);
  }

  .m-empty > .m-tile {
    margin-bottom: var(--space-1);
  }

  .m-empty__title {
    margin: 0;
    font-size: 16px;
    line-height: 24px;
    font-weight: 650;
    letter-spacing: -0.012em;
  }

  .m-empty__text {
    margin: 0 0 var(--space-2);
    color: var(--ink-muted);
    max-width: var(--measure);
  }

  /* Chart */
  .m-chart {
    margin: 0;
    display: grid;
    gap: var(--space-2);
    max-width: 46rem;
  }

  /* Only the drawing: the data table under it holds risk glyphs, which are svg too (#198). */
  .m-chart > svg {
    width: 100%;
    height: auto;
  }

  .m-chart figcaption {
    font-weight: 650;
    letter-spacing: -0.01em;
  }

  .m-chart__band--low {
    fill: var(--risk-low-soft);
  }

  .m-chart__band--moderate {
    fill: var(--risk-moderate-soft);
  }

  .m-chart__band--high {
    fill: var(--risk-high-soft);
  }

  .m-chart__band--stop {
    fill: var(--risk-stop-soft);
  }

  .m-chart__axis {
    fill: var(--ink-muted);
    font-family: var(--font-mono);
    font-size: 10px;
  }

  .m-chart__label {
    fill: var(--ink-muted);
    font-family: var(--font-sans);
    font-size: 11px;
    font-weight: 650;
  }

  .m-chart__line {
    fill: none;
    stroke: var(--accent);
    stroke-width: 2.5;
    stroke-linejoin: round;
  }

  .m-chart__point {
    stroke: var(--surface);
    stroke-width: 2;
  }

  .m-chart__point--low {
    fill: var(--risk-low);
  }

  .m-chart__point--moderate {
    fill: var(--risk-moderate-ink);
  }

  .m-chart__point--high {
    fill: var(--risk-high);
  }

  .m-chart__point--stop {
    fill: var(--risk-stop);
  }

  .m-chart details {
    /* MRAT (#339): the data table scrolls inside the chart; it does not make the chart wider. */
    min-width: 0;
    font-size: 13px;
  }

  /* App shell */
  .m-shell {
    display: grid;
    grid-template-columns: var(--nav-width) minmax(0, 1fr);
    grid-template-rows: auto 1fr;
    min-height: 100%;
    background: var(--bg);
  }

  .m-top {
    grid-column: 1 / -1;
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    gap: var(--space-4);
    padding: 0 var(--space-4);
    min-height: 56px;
    background: color-mix(in oklch, var(--bg) 82%, transparent);
    backdrop-filter: blur(14px) saturate(1.4);
    border-bottom: var(--border-hairline) solid var(--line);
  }

  .m-wordmark {
    display: flex;
    align-items: baseline;
    gap: var(--space-2);
    color: var(--ink);
    text-decoration: none;
  }

  .m-wordmark__name {
    font-size: 18px;
    font-weight: 800;
    font-variation-settings: "wdth" 125;
    letter-spacing: 0.02em;
  }

  .m-wordmark__org {
    font-size: 13px;
    font-weight: 500;
    color: var(--ink-muted);
  }

  .m-top__end {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: var(--space-2);
  }

  .m-nav {
    padding: var(--space-3);
  }

  .m-nav ul {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 2px;
  }

  .m-nav__group {
    margin: var(--space-4) 0 var(--space-1);
    padding: 0 var(--space-3);
    font-size: 12px;
    font-weight: 600;
    color: var(--ink-muted);
  }

  .m-nav a {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    min-height: 40px;
    padding: 0 var(--space-3);
    border-radius: var(--radius-md);
    color: var(--ink-muted);
    text-decoration: none;
    font-weight: 600;
    letter-spacing: -0.01em;
  }

  .m-nav a:hover {
    color: var(--ink);
    background: var(--surface-sunken);
  }

  .m-nav a[aria-current="page"] {
    color: var(--ink);
    background: var(--surface);
    box-shadow:
      var(--shadow-xs),
      inset 0 0 0 1px var(--line);
  }

  .m-nav a[aria-current="page"] .m-icon {
    color: var(--accent);
  }

  /* The count of overdue close-outs beside Open risk items (#228) */
  .m-navbadge {
    display: inline-grid;
    place-items: center;
    min-width: 20px;
    height: 20px;
    margin-left: auto;
    padding: 0 6px;
    border-radius: var(--radius-pill);
    background: var(--danger-soft);
    color: var(--danger);
    font-size: 12px;
    font-weight: 700;
    line-height: 1;
    font-variant-numeric: tabular-nums;
  }

  .m-tabbar__ic .m-navbadge {
    position: absolute;
    top: -4px;
    right: 6px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    font-size: 11px;
  }

  .m-main {
    padding: var(--space-5) var(--space-6);
    min-width: 0;
  }

  .m-menu {
    display: none;
  }

  @media (max-width: 1023px) {
    .m-shell {
      grid-template-columns: minmax(0, 1fr);
    }

    .m-shell > .m-nav {
      display: none;
    }

    .m-menu {
      display: block;
    }

    .m-menu > summary {
      list-style: none;
      display: inline-flex;
      align-items: center;
      gap: var(--space-2);
      min-height: var(--target-min);
      padding: 0 var(--space-3);
      border-radius: var(--radius-md);
      font-weight: 600;
      cursor: pointer;
    }

    .m-menu > summary::-webkit-details-marker {
      display: none;
    }

    .m-menu > summary:hover {
      background: var(--surface-sunken);
    }

    .m-menu[open] > .m-nav {
      position: absolute;
      left: var(--space-3);
      right: var(--space-3);
      top: 60px;
      z-index: 20;
      background: var(--surface-raised);
      border: var(--border-hairline) solid var(--line);
      border-radius: var(--radius-lg);
      box-shadow: var(--shadow-lg);
    }

    .m-menu .m-nav a {
      min-height: var(--target-min);
    }

    .m-main {
      padding: var(--space-4);
    }

    body,
    .m-input,
    .m-btn {
      font-size: 16px;
    }

    .m-btn,
    .m-input {
      min-height: var(--target-min);
    }
  }

  /* Page header */
  .m-pagehead {
    display: grid;
    gap: var(--space-2);
    margin-bottom: var(--space-5);
  }

  .m-crumbs ol {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
    margin: 0;
    padding: 0;
    list-style: none;
    font-size: 13px;
    font-weight: 500;
  }

  .m-crumbs li + li::before {
    content: "/";
    margin-right: var(--space-2);
    color: var(--line-control);
  }

  .m-crumbs a {
    color: var(--ink-muted);
    text-decoration: none;
  }

  .m-crumbs a:hover {
    color: var(--accent);
  }

  .m-pagehead__row {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-3);
    align-items: center;
    justify-content: space-between;
  }

  .m-pagehead h1 {
    margin: 0;
    font-size: 32px;
    line-height: 36px;
    font-weight: 680;
    letter-spacing: -0.028em;
  }

  .m-pagehead__meta {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2) var(--space-4);
    align-items: center;
    color: var(--ink-muted);
    font-size: 14px;
  }

  /* Tabs */
  .m-tabs {
    display: flex;
    gap: var(--space-5);
    border-bottom: var(--border-hairline) solid var(--line);
    overflow-x: auto;
    scrollbar-width: none;
  }

  .m-tabs::-webkit-scrollbar {
    display: none;
  }

  @media (max-width: 639px) {
    .m-tabs {
      gap: var(--space-4);
    }
  }

  .m-tabs a {
    display: inline-flex;
    align-items: center;
    min-height: 40px;
    color: var(--ink-muted);
    font-weight: 600;
    letter-spacing: -0.01em;
    text-decoration: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    white-space: nowrap;
  }

  .m-tabs a:hover {
    color: var(--ink);
  }

  .m-tabs a[aria-current="page"] {
    color: var(--ink);
    border-bottom-color: var(--ink);
  }

  /* Filter bar: a GET form whose fields wrap */
  .m-filters {
    display: grid;
    gap: var(--space-3);
    grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr));
    align-items: end;
  }

  .m-filters__wide {
    grid-column: span 2;
  }

  /* A date input does not shrink below its value (172 px in Chromium), so a column of 10rem was too narrow (#331). */
  .m-filters--dates {
    grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
  }

  @media (max-width: 639px) {
    .m-filters {
      grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .m-filters--dates {
      grid-template-columns: minmax(0, 1fr);
    }

    .m-filters__wide,
    .m-filters > .m-btn {
      grid-column: 1 / -1;
    }
  }

  /* Stat tiles: a few counts that link to a filtered list */
  .m-stats {
    display: grid;
    gap: var(--space-3);
    grid-template-columns: repeat(auto-fit, minmax(9.5rem, 1fr));
  }

  .m-stat {
    display: grid;
    gap: 2px;
    min-width: 0;
    padding: 14px 16px;
    background: var(--surface);
    border: var(--border-hairline) solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xs);
    color: var(--ink);
    text-decoration: none;
  }

  a.m-stat:hover {
    background: var(--surface-sunken);
  }

  .m-stat__label {
    font-size: 12px;
    line-height: 16px;
    font-weight: 600;
    color: var(--ink-muted);
    overflow-wrap: anywhere;
  }

  .m-stat__value {
    font-family: var(--font-mono);
    font-variation-settings: "wdth" 87.5;
    font-size: 26px;
    line-height: 32px;
    font-weight: 700;
    font-variant-numeric: tabular-nums slashed-zero;
  }

  /* AI draft: a suggestion the user must read before it counts */
  .m-ai {
    display: grid;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    background: var(--surface);
    border: 1.5px dashed var(--accent);
    border-radius: var(--radius-md);
  }

  .m-ai__head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-2);
    font-size: 13px;
    font-weight: 650;
    color: var(--accent);
  }

  .m-ai__head .m-icon {
    width: 16px;
    height: 16px;
  }

  .m-ai__title {
    margin: 0;
    font-weight: 650;
    letter-spacing: -0.01em;
  }

  .m-ai__body {
    margin: 0;
  }

  .m-ai__meta {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-1) var(--space-4);
    font-size: 13px;
    color: var(--ink-muted);
  }

  .m-ai__meta strong {
    color: var(--ink);
    font-weight: 600;
  }

  .m-ai__actions {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
    align-items: center;
  }

  .m-ai__note {
    margin: 0;
    font-size: 12px;
    line-height: 16px;
    color: var(--ink-muted);
  }

  .m-ai[aria-busy="true"] {
    border-style: dotted;
    color: var(--ink-muted);
  }

  .m-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 30px;
    padding: 0 12px;
    border: var(--border-hairline) solid var(--line-control);
    border-radius: var(--radius-pill);
    background: var(--surface);
    color: var(--ink);
    font: inherit;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
  }

  .m-chip:hover {
    background: var(--surface-sunken);
  }

  .m-chip[disabled] {
    cursor: not-allowed;
    color: var(--ink-muted);
  }

  /* #220: an AI button while its htmx request runs (htmx-request): a spinner and "Drafting…" in place of its label.
     The label spans have no box, so the button at rest lays out as before. Reduced motion: the clock, no spinner. */
  .m-ai-go {
    display: contents;
  }

  .m-ai-going,
  .m-ai-going .m-icon {
    display: none;
  }

  .htmx-request > .m-ai-go {
    display: none;
  }

  .htmx-request > .m-ai-going {
    display: contents;
  }

  .m-ai-spin {
    flex: none;
    width: 14px;
    height: 14px;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: m-spin 800ms linear infinite;
  }

  @keyframes m-spin {
    to {
      transform: rotate(1turn);
    }
  }

  /* The live line of an AI block: out of the layout and empty at rest, but in the accessibility tree, so its text
     is announced when it appears. */
  .m-ai-wait {
    position: absolute;
  }

  .m-ai-wait > span {
    display: none;
  }

  .m-ai-wait.htmx-request {
    position: static;
    font-size: 13px;
    color: var(--ink-muted);
  }

  .m-ai-wait.htmx-request > span {
    display: inline;
  }

  @media (prefers-reduced-motion: reduce) {
    .m-ai-spin {
      display: none;
    }

    .htmx-request > .m-ai-going .m-icon {
      display: block;
    }
  }

  @media (max-width: 1023px) {
    .m-chip {
      min-height: var(--target-min);
    }
  }

  /* Dialog */
  .m-dialog {
    width: min(30rem, calc(100% - 2 * var(--space-4)));
    padding: 0;
    border: var(--border-hairline) solid var(--line);
    border-radius: var(--radius-xl);
    background: var(--surface-raised);
    color: var(--ink);
    box-shadow: var(--shadow-lg);
  }

  .m-dialog::backdrop {
    background: var(--scrim);
    backdrop-filter: blur(3px);
  }

  .m-dialog__head {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: var(--space-3);
    align-items: center;
    padding: var(--space-5) var(--space-5) var(--space-2);
  }

  .m-dialog__title {
    margin: 0;
    font-size: 18px;
    line-height: 24px;
    font-weight: 650;
    letter-spacing: -0.015em;
  }

  .m-dialog__body {
    padding: 0 var(--space-5) var(--space-4);
    color: var(--ink-muted);
  }

  .m-dialog__body .m-field {
    color: var(--ink);
  }

  .m-dialog__foot {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-5) var(--space-4);
  }

  /* Question card */
  .m-q {
    display: grid;
    gap: var(--space-3);
    padding: var(--space-4);
    background: var(--surface);
    border: var(--border-hairline) solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xs);
  }

  .m-q--yes {
    border-color: var(--line-control);
    box-shadow: var(--shadow-sm);
  }

  .m-q__meta {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2) var(--space-3);
    align-items: center;
    font-size: 12px;
    line-height: 16px;
    font-weight: 600;
    color: var(--ink-muted);
  }

  .m-q__num {
    display: grid;
    place-items: center;
    min-width: 24px;
    height: 24px;
    padding: 0 6px;
    border-radius: var(--radius-sm);
    background: var(--surface-sunken);
    color: var(--ink);
    font-family: var(--font-mono);
    font-variation-settings: "wdth" 87.5;
    font-weight: 700;
  }

  .m-q__text {
    margin: 0;
    font-size: 16px;
    line-height: 24px;
    font-weight: 600;
    letter-spacing: -0.012em;
  }

  .m-q__answer {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-3);
    align-items: center;
    justify-content: space-between;
  }

  .m-q__mitigation {
    display: grid;
    gap: var(--space-3);
    padding: var(--space-4);
    background: var(--surface-sunken);
    border-radius: var(--radius-md);
  }

  .m-q__mitigation h4 {
    margin: 0;
    font-size: 13px;
    font-weight: 650;
  }

  /* #197: the mitigation status, a one-tap choice beside the Mitigation heading, and its chip in the meta line. */
  .m-answer--choice label {
    min-width: 0;
    padding: 0 var(--space-3);
    font-size: 13px;
    text-align: center;
  }

  .m-q__chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-left: auto;
    padding: 2px var(--space-2);
    border-radius: var(--radius-pill);
    background: var(--surface);
    box-shadow: inset 0 0 0 1px var(--line-control);
    color: var(--ink);
  }

  .m-q__chip .m-icon {
    width: 14px;
    height: 14px;
  }

  .m-q__chip--done {
    background: var(--success-soft);
    box-shadow: none;
  }

  .m-q__chip--done .m-icon {
    color: var(--success);
  }

  /* A phone: the three options share the width of the card. */
  @media (max-width: 639px) {
    .m-q__status,
    .m-q__status .m-answer--choice {
      width: 100%;
    }

    /* Each option as wide as its words, on one line; the free width goes to all three. */
    .m-answer--choice label {
      padding: 0 var(--space-1);
      white-space: nowrap;
    }
  }

  /* Signature block */
  .m-sign {
    display: grid;
    gap: var(--space-2);
    align-content: start;
    padding: var(--space-4);
    border: var(--border-hairline) solid var(--line);
    border-radius: var(--radius-lg);
    background: var(--surface);
    box-shadow: var(--shadow-xs);
    break-inside: avoid;
  }

  .m-sign__role {
    margin: 0;
    font-size: 15px;
    font-weight: 650;
    letter-spacing: -0.01em;
  }

  .m-sign__statement {
    margin: 0;
    font-size: 13px;
    line-height: 18px;
    color: var(--ink-muted);
  }

  .m-sign__stamp {
    display: flex;
    gap: var(--space-3);
    align-items: center;
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-md);
    background: var(--surface-sunken);
  }

  .m-sign__stamp .m-icon {
    width: 20px;
    height: 20px;
    color: var(--accent);
  }

  .m-sign__who {
    display: grid;
    font-size: 13px;
    line-height: 18px;
  }

  .m-sign__emp {
    color: var(--ink-muted);
  }

  .m-sign__who strong {
    font-family: var(--font-mono);
    font-variation-settings: "wdth" 87.5;
    font-weight: 600;
  }

  .m-sign__lock {
    display: flex;
    gap: 6px;
    align-items: flex-start;
    margin: 0;
    font-size: 13px;
    line-height: 18px;
    color: var(--ink-muted);
  }

  .m-sign__lock .m-icon {
    width: 16px;
    height: 16px;
    margin-top: 1px;
  }

  .m-signs {
    display: grid;
    gap: var(--space-3);
    grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
  }

  /* v2.3 (M9, #165): motion, colour and app feel. The design system's bundle.css v2.3 section; MRAT
     changes are marked "MRAT:". */

  /* Band: the top bar of every page, and the Home masthead */
  .m-top--band {
    background: var(--band);
    color: var(--on-band);
    border-bottom: 0;
    backdrop-filter: none;
    box-shadow: 0 1px 0 var(--band-line);

    /* MRAT: the band is the same on every page: it stays still while the page under it changes. */
    view-transition-name: m-band;
  }

  .m-top--band .m-wordmark {
    color: var(--on-band);
  }

  .m-top--band .m-wordmark__org {
    color: var(--on-band-muted);
  }

  .m-top--band .m-btn--quiet,
  .m-top--band .m-menu > summary {
    color: var(--on-band-muted);
  }

  .m-top--band .m-btn--quiet:hover,
  .m-top--band .m-menu > summary:hover {
    background: var(--band-raised);
    color: var(--on-band);
  }

  /* MRAT: the user line and the focus ring of the bar's own controls are on the band too (the open menu is not). */
  .m-top--band > .m-top__end .m-muted {
    color: var(--on-band-muted);
  }

  .m-top--band > .m-wordmark:focus-visible,
  .m-top--band > .m-menu > summary:focus-visible,
  .m-top--band > .m-top__end .m-btn:focus-visible {
    outline-color: var(--on-band);
  }

  .m-mast {
    position: relative;
    display: grid;
    gap: var(--space-3);
    padding: 28px 32px 26px;
    border-radius: var(--radius-xl);
    background: var(--band);
    color: var(--on-band);
    overflow: hidden;
  }

  .m-mast__eyebrow {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2) var(--space-4);
    margin: 0;
    font-size: 13px;
    font-weight: 600;
    color: var(--on-band-muted);
  }

  /* MRAT: a class, not `.m-mast h1`, so the gallery can show the masthead with an h2 (one h1 per page). */
  .m-mast__title {
    margin: 0;
    font-size: 40px;
    line-height: 44px;
    font-weight: 700;
    letter-spacing: -0.03em;
    font-variation-settings: "wdth" 112;
    text-wrap: balance;
    max-width: 22ch;
  }

  .m-mast__sub {
    margin: 0;
    font-size: 15px;
    line-height: 22px;
    color: var(--on-band-muted);
    max-width: 60ch;
  }

  .m-mast__actions {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
    margin-top: var(--space-2);
  }

  .m-btn--onband {
    color: var(--band);
    background: var(--on-band);
    border-color: transparent;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
    font-weight: 650;
  }

  .m-btn--onband:hover {
    background: var(--on-band-muted);
  }

  .m-btn--ghostband {
    color: var(--on-band);
    background: transparent;
    border-color: var(--band-line);
  }

  .m-btn--ghostband:hover {
    background: var(--band-raised);
  }

  .m-btn--onband:focus-visible,
  .m-btn--ghostband:focus-visible {
    outline-color: var(--on-band);
  }

  /* Workflow route: the statuses as stations in workflow order, each joined to the next by an arrow */
  .m-route {
    position: relative;
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    row-gap: var(--space-3);
    margin: var(--space-4) 0 0;
    padding: var(--space-4) 0 0;
    list-style: none;
    border-top: 1px solid var(--band-line);
  }

  .m-route li {
    position: relative;
    min-width: 0;
  }

  .m-route li:not(:last-child)::after {
    content: "";
    position: absolute;
    top: 9px;
    left: 36px;
    right: 11px;
    height: 2px;
    border-radius: 1px;
    background: var(--route-line);
  }

  .m-route li:not(:last-child)::before {
    content: "";
    position: absolute;
    top: 10px;
    right: 10px;
    width: 9px;
    height: 9px;
    border-top: 2px solid var(--route-line);
    border-right: 2px solid var(--route-line);
    transform-origin: 100% 0;
    transform: rotate(45deg);
  }

  .m-route a {
    position: relative;
    display: grid;
    gap: 4px;
    justify-items: start;
    padding: 0 8px 4px 4px;
    margin-left: 4px;
    border-radius: var(--radius-md);
    color: var(--on-band);
    text-decoration: none;
    transition: background var(--dur-1) var(--ease-out);
  }

  .m-route a:hover {
    background: var(--band-raised);
  }

  .m-route a:focus-visible {
    outline: var(--focus-width) solid var(--on-band);
    outline-offset: 2px;
  }

  .m-route__node {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--band);
    border: 3px solid var(--on-band-muted);
  }

  .m-route__node--complete {
    background: var(--on-band);
    border-color: var(--on-band);
  }

  .m-route__node--review {
    background: var(--route-review);
    border-color: var(--route-review);
    box-shadow: 0 0 0 4px color-mix(in oklch, var(--route-review) 30%, transparent);
  }

  .m-route__node--approved {
    background: var(--route-approved);
    border-color: var(--route-approved);
  }

  .m-route__node--workdone {
    background: var(--band);
    border-color: var(--route-approved);
  }

  .m-route__node--closedout {
    background: var(--route-approved);
    border-color: var(--on-band);
  }

  .m-route__count {
    font-family: var(--font-mono);
    font-variation-settings: "wdth" 87.5;
    font-size: 30px;
    line-height: 34px;
    font-weight: 700;
    font-variant-numeric: tabular-nums slashed-zero;
  }

  .m-route__label {
    font-size: 13px;
    line-height: 16px;
    font-weight: 600;
    color: var(--on-band-muted);
  }

  /* Tinted count tiles (Analytics and other summaries; Home uses the route) */
  .m-stat--tint {
    gap: 6px;
    padding: 14px 16px 12px;
    box-shadow: var(--shadow-sm);
    transition:
      transform var(--dur-2) var(--ease-out),
      box-shadow var(--dur-2) var(--ease-out);
  }

  /* MRAT: touch screens have no hover motion (README, Motion). */
  @media (hover: hover) {
    a.m-stat--tint:hover {
      transform: translateY(-2px);
      box-shadow: var(--shadow-md);
    }
  }

  .m-stat--complete .m-stat__value {
    color: var(--accent);
  }

  .m-stat--review {
    background: var(--stat-review);
    border-color: transparent;
  }

  .m-stat--review .m-stat__value {
    color: var(--stat-review-ink);
  }

  .m-stat--approved {
    background: var(--success-soft);
    border-color: transparent;
  }

  .m-stat--approved .m-stat__value {
    color: var(--stat-approved-ink);
  }

  /* MRAT: a tinted link tile keeps its tint on hover (a.m-stat:hover is surface-sunken). */
  a.m-stat--review:hover {
    background: var(--stat-review);
  }

  a.m-stat--approved:hover {
    background: var(--success-soft);
  }

  /* Risk tile: the level as a solid square with its glyph, in lists */
  .m-risktile {
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    flex: none;
    border-radius: 11px;
  }

  .m-risktile svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
  }

  .m-risktile--low {
    background: var(--risk-low);
    color: var(--on-risk-low);
  }

  .m-risktile--moderate {
    background: var(--risk-moderate);
    color: var(--on-risk-moderate);
  }

  .m-risktile--high {
    background: var(--risk-high);
    color: var(--on-risk-high);
  }

  .m-risktile--stop {
    background: var(--risk-stop);
    color: var(--on-risk-stop);
  }

  /* MRAT: a Yes answer that is not a stop item has no level: its tile is neutral and shows the question number. */
  .m-risktile--plain {
    background: var(--surface-sunken);
    color: var(--ink-muted);
    box-shadow: inset 0 0 0 1px var(--line);
    font-family: var(--font-mono);
    font-variation-settings: "wdth" 87.5;
    font-size: 13px;
    font-weight: 650;
  }

  /* Action row: one record in a list, with its level, what it is, and what to do. MRAT: the rows are list
     items (.m-acts), so the first row has no top edge by the list rule below, and only a link row has hover. */
  .m-act {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 4px 16px;
    align-items: center;
    padding: 14px 16px;
    border-top: 1px solid var(--line);
    color: var(--ink);
    text-decoration: none;
    transition: background var(--dur-1) var(--ease-out);
  }

  a.m-act:hover {
    background: var(--surface-sunken);
  }

  .m-act__title {
    font-weight: 650;
    letter-spacing: -0.01em;
  }

  .m-act__meta {
    font-size: 13px;
    color: var(--ink-muted);
  }

  @media (max-width: 639px) {
    .m-act {
      grid-template-columns: auto minmax(0, 1fr);
    }

    .m-act > .m-btn {
      grid-column: 1 / -1;
      justify-self: start;
    }
  }

  .m-acts {
    margin: 0;
    padding: var(--space-2) 0 var(--space-1);
    list-style: none;
  }

  .m-acts li:first-child .m-act {
    border-top: 0;
  }

  /* Record header: tinted by the risk level, carries the score */
  .m-record {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: var(--space-4) var(--space-6);
    align-items: center;
    padding: 22px 24px;
    border-radius: var(--radius-xl);
    border: 1px solid;
    transition:
      background var(--dur-3) var(--ease-out),
      border-color var(--dur-3) var(--ease-out);
  }

  .m-record--low {
    --rec-ink: var(--risk-low-ink);

    background: var(--risk-low-soft);
    border-color: var(--risk-low-edge);
  }

  .m-record--moderate {
    --rec-ink: var(--risk-moderate-ink);

    background: var(--risk-moderate-soft);
    border-color: var(--risk-moderate-edge);
  }

  .m-record--high {
    --rec-ink: var(--risk-high-ink);

    background: var(--risk-high-soft);
    border-color: var(--risk-high-edge);
  }

  .m-record--stop {
    --rec-ink: var(--risk-stop-ink);

    background: var(--risk-stop-soft);
    border-color: var(--risk-stop);
  }

  /* MRAT: "Not scored" has no tint (README): the plain surface. */
  .m-record--none {
    background: var(--surface);
    border-color: var(--line);
  }

  .m-record__id {
    display: grid;
    gap: 6px;
    min-width: 0;
  }

  /* MRAT: the view transition name is on .m-vt (below), from an attribute, not from a custom property that an
     inline style would set (CSP). A long name wraps. */
  .m-record__tail {
    margin: 0;
    font-family: var(--font-mono);
    font-variation-settings: "wdth" 87.5;
    font-size: 34px;
    line-height: 38px;
    font-weight: 700;
    letter-spacing: -0.02em;
    overflow-wrap: anywhere;
  }

  .m-record__line {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2) var(--space-3);
    align-items: center;
    margin: 0;
    font-size: 14px;
    color: var(--ink-muted);
  }

  .m-record__score {
    display: flex;
    align-items: center;
    gap: var(--space-4);
  }

  .m-record__num {
    display: grid;
    justify-items: end;
  }

  .m-record__value {
    font-family: var(--font-mono);
    font-variation-settings: "wdth" 87.5;
    font-size: 56px;
    line-height: 56px;
    font-weight: 750;
    letter-spacing: -0.03em;
    color: var(--rec-ink, var(--ink));
    font-variant-numeric: tabular-nums;
  }

  .m-record__unit {
    font-size: 12px;
    font-weight: 650;
    color: var(--ink-muted);

    /* MRAT: "points · 6 − 3" stays on one line under a narrow number on a phone. */
    white-space: nowrap;
  }

  /* MRAT: the badge and the scale stack beside the number (the artboard's inline grid). */
  .m-record__level {
    display: grid;
    gap: var(--space-2);
    justify-items: start;
  }

  .m-record__level .m-scale {
    width: 240px;
    max-width: 100%;
    flex: none;
  }

  @media (max-width: 639px) {
    .m-record {
      grid-template-columns: minmax(0, 1fr);
      padding: 18px 16px;
    }

    .m-record__tail {
      font-size: 28px;
      line-height: 32px;
    }

    .m-record__num {
      justify-items: start;
    }
  }

  /* Score strip: the compact sticky score on phones */
  .m-strip {
    position: sticky;
    top: 0;
    z-index: 6;
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: 10px 14px;
    border-radius: var(--radius-lg);
    border: 1px solid;
    box-shadow: var(--shadow-md);
    backdrop-filter: blur(14px) saturate(1.4);
    transition:
      background var(--dur-3) var(--ease-out),
      border-color var(--dur-3) var(--ease-out);
  }

  .m-strip--low {
    --rec-ink: var(--risk-low-ink);

    background: color-mix(in oklch, var(--risk-low-soft) 92%, transparent);
    border-color: var(--risk-low-edge);
  }

  .m-strip--moderate {
    --rec-ink: var(--risk-moderate-ink);

    background: color-mix(in oklch, var(--risk-moderate-soft) 92%, transparent);
    border-color: var(--risk-moderate-edge);
  }

  .m-strip--high {
    --rec-ink: var(--risk-high-ink);

    background: color-mix(in oklch, var(--risk-high-soft) 92%, transparent);
    border-color: var(--risk-high-edge);
  }

  .m-strip--stop {
    --rec-ink: var(--risk-stop-ink);

    background: color-mix(in oklch, var(--risk-stop-soft) 92%, transparent);
    border-color: var(--risk-stop);
  }

  .m-strip--none {
    background: color-mix(in oklch, var(--surface-raised) 92%, transparent);
    border-color: var(--line);
  }

  .m-strip__value {
    font-family: var(--font-mono);
    font-variation-settings: "wdth" 87.5;
    font-size: 28px;
    line-height: 30px;
    font-weight: 750;
    color: var(--rec-ink, var(--ink));
    font-variant-numeric: tabular-nums;
  }

  .m-strip__meta {
    display: grid;
    gap: 2px;
    min-width: 0;
    font-size: 12px;
    font-weight: 600;
    color: var(--ink-muted);
  }

  .m-strip .m-scale {
    width: 112px;
    margin-left: auto;
    flex: none;
  }

  /* Motion: arrivals, the answer, page transitions. MRAT: fill mode backwards, not both: after the arrival no
     transform stays on the element, so a fixed dialog or a sticky bar inside it keeps the viewport as its
     containing block. */
  .m-arrive {
    animation: m-rise var(--dur-3) var(--ease-out) backwards;
  }

  .m-arrive--2 {
    animation-delay: 40ms;
  }

  .m-arrive--3 {
    animation-delay: 80ms;
  }


  .m-answer label:active {
    transform: scale(0.96);
  }

  .m-answer input[value="yes"]:checked + label .m-answer__points {
    display: inline-block;
    animation: m-pop var(--dur-2) var(--ease-pop) both;
  }

  @keyframes m-rise {
    from {
      opacity: 0;
      transform: translateY(8px);
    }

    to {
      opacity: 1;
      transform: none;
    }
  }

  @keyframes m-pop {
    from {
      opacity: 0;
      transform: scale(0.6);
    }

    to {
      opacity: 1;
      transform: none;
    }
  }

  @keyframes m-fade {
    from {
      opacity: 0;
    }

    to {
      opacity: 1;
    }
  }

  @view-transition {
    navigation: auto;
  }

  ::view-transition-old(root) {
    animation: m-fade var(--dur-2) var(--ease-in-out) reverse both;
  }

  ::view-transition-new(root) {
    animation: m-rise var(--dur-3) var(--ease-out) both;
  }

  @media (max-width: 639px) {
    .m-mast {
      padding: 20px 16px 18px;
      border-radius: 0 0 var(--radius-xl) var(--radius-xl);
    }

    .m-mast__title {
      font-size: 30px;
      line-height: 34px;
    }

    /* Six stations (#228): two rows of three on a phone, with no arrow from the end of the first row. */
    .m-route {
      grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .m-route li:nth-child(3)::after,
    .m-route li:nth-child(3)::before {
      display: none;
    }

    .m-route a {
      padding-right: 2px;
    }

    .m-route__count {
      font-size: 24px;
      line-height: 28px;
    }

    .m-route__label {
      font-size: 12px;
    }
  }

  /* MRAT: motion of #166 and #167 that the bundle names in its Motion section but leaves to the product. */

  /* The main content arrives on page load and after an htmx swap into <main> (a new child each time). */
  .m-main > * {
    animation: m-rise var(--dur-3) var(--ease-out) backwards;
  }

  /* The tail number carries over from a list row to the record header (README, Motion). Each element names
     itself from its data-vt attribute (`tail-<id>`, written by the server), so no inline style is needed (CSP)
     and only the row of the record that opens shares the header's name. A browser without typed attr() gives no
     name and keeps the page cross-fade. */
  .m-vt {
    view-transition-name: attr(data-vt type(<custom-ident>), none);
  }

  ::view-transition-group(*) {
    animation-duration: var(--dur-3);
    animation-timing-function: var(--ease-out);
  }

  /* The band (named on .m-top--band above) does not fade or rise. */
  ::view-transition-old(m-band) {
    display: none;
  }

  ::view-transition-new(m-band) {
    animation: none;
  }

  /* A new risk level: the badge pops (one keyframe name per level, so a change of level starts it again and
     an update with the same level does not). The record tint cross-fades by its transition above. */
  .m-record__score .m-risk--low,
  .m-strip .m-risk--low,
  .m-score .m-risk--low {
    animation: m-pop-low var(--dur-2) var(--ease-pop) backwards;
  }

  .m-record__score .m-risk--moderate,
  .m-strip .m-risk--moderate,
  .m-score .m-risk--moderate {
    animation: m-pop-moderate var(--dur-2) var(--ease-pop) backwards;
  }

  .m-record__score .m-risk--high,
  .m-strip .m-risk--high,
  .m-score .m-risk--high {
    animation: m-pop-high var(--dur-2) var(--ease-pop) backwards;
  }

  .m-record__score .m-risk--stop,
  .m-strip .m-risk--stop,
  .m-score .m-risk--stop {
    animation: m-pop-stop var(--dur-2) var(--ease-pop) backwards;
  }

  @keyframes m-pop-low {
    0% {
      opacity: 0.4;
      transform: scale(0.9);
    }

    60% {
      transform: scale(1.06);
    }

    100% {
      opacity: 1;
      transform: none;
    }
  }

  @keyframes m-pop-moderate {
    0% {
      opacity: 0.4;
      transform: scale(0.9);
    }

    60% {
      transform: scale(1.06);
    }

    100% {
      opacity: 1;
      transform: none;
    }
  }

  @keyframes m-pop-high {
    0% {
      opacity: 0.4;
      transform: scale(0.9);
    }

    60% {
      transform: scale(1.06);
    }

    100% {
      opacity: 1;
      transform: none;
    }
  }

  @keyframes m-pop-stop {
    0% {
      opacity: 0.4;
      transform: scale(0.9);
    }

    60% {
      transform: scale(1.06);
    }

    100% {
      opacity: 1;
      transform: none;
    }
  }

  /* An alert drops in (the animation is on .m-alert above). */
  @keyframes m-drop {
    from {
      opacity: 0;
      transform: translateY(-8px);
    }

    to {
      opacity: 1;
      transform: none;
    }
  }

  /* A table row steps to surface-sunken on hover. */
  .m-table tbody td {
    transition: background-color var(--dur-1) var(--ease-out);
  }

  /* Contrast and forced colours */
  @media (prefers-contrast: more) {
    .m-panel,
    .m-q,
    .m-table-wrap,
    .m-alert,
    .m-sign,
    .m-table th,
    .m-table td {
      border-color: var(--line-strong);
    }

    .m-muted,
    .m-field__hint,
    .m-kv dt,
    .m-alert__body {
      color: var(--ink);
    }

    .m-input {
      border-color: var(--line-strong);
    }
  }

  @media (forced-colors: active) {
    .m-risk,
    .m-alert,
    .m-btn,
    .m-answer,
    .m-theme,
    .m-reduce,
    .m-sign,
    .m-panel,
    .m-q,
    .m-tile,
    .m-stat,
    .m-chip,
    .m-record,
    .m-strip,
    .m-mast,
    .m-risktile {
      border: 1px solid CanvasText;
    }

    .m-risk__glyph {
      fill: CanvasText;
    }

    .m-status::before {
      background: CanvasText;
    }

    .m-answer input:checked + label,
    .m-theme input:checked + label,
    .m-reduce input:checked + label,
    .m-nav a[aria-current="page"],
    .m-tabs a[aria-current="page"] {
      forced-color-adjust: none;
      background: Highlight;
      color: HighlightText;
    }

    .m-chart__point {
      fill: CanvasText;
    }
  }

  /* MRAT: page frames of #114: the sign-in frame, the form stack and the top bar on a phone. */
  .m-auth {
    min-height: 100vh;
    min-height: 100dvh;
    display: grid;
    place-items: center;
    padding: var(--space-5) var(--space-4);
  }

  .m-auth__card {
    display: grid;
    gap: var(--space-4);
    width: 100%;
    max-width: 26rem;
    padding: var(--space-5);
    background: var(--surface);
    border: var(--border-hairline) solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
  }

  .m-auth .m-pagehead {
    margin-bottom: 0;
  }

  .m-auth .m-pagehead h1 {
    font-size: 24px;
    line-height: 30px;
    letter-spacing: -0.022em;
  }

  .m-form {
    display: grid;
    gap: var(--space-4);
  }

  .m-top__end form {
    margin: 0;
  }

  @media (max-width: 639px) {
    .m-top {
      gap: var(--space-2);
      padding: 0 var(--space-2);
    }

    .m-top__who,
    .m-wordmark__org {
      display: none;
    }
  }

  /* MRAT (#339): below the 390 px phone of the design, Menu, MRAT, Account and Sign out were 4 to 8 px wider than
     the screen. Less space between them; the 390 px bar does not change. */
  @media (max-width: 389px) {
    .m-top,
    .m-top__end {
      gap: var(--space-1);
    }

    .m-menu > summary {
      padding: 0 var(--space-2);
    }
  }

  .m-main p,
  .m-auth p {
    margin: 0;
  }

  /* MRAT: a checkbox row inside a line of other content (the AI-assisted check); the design system's
     preview sets these two values inline, which the CSP forbids. */
  .m-check--inline {
    min-height: 0;
    padding: 0;
  }

  /* MRAT: the component gallery shows open dialogs in the page flow, not over it. */
  .m-gallery .m-dialog[open] {
    position: static;
    margin: 0;
  }

  /* MRAT: and the score strips one under the other, not stuck at the top. */
  .m-gallery .m-strip {
    position: static;
  }

  /* --- #120 admin --- */

  /* The Admin and Account pages: one column of panels, as wide as the designs. */
  .m-adminpage {
    display: grid;
    gap: var(--space-5);
    max-width: 1040px;
    min-width: 0;
  }

  .m-adminpage > .m-pagehead {
    margin-bottom: 0;
  }

  .m-kv--2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .m-fields--3 {
    grid-template-columns: repeat(3, minmax(0, 12rem));
  }

  /* A date-time input does not shrink below its full value (date, time and AM/PM): a column of 13rem was too narrow
     (Chromium at 1280 px, Firefox at 640 px), so the input ran past its field or the card (#331). */
  .m-fields--datetime {
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 19rem), 1fr));
  }

  /* Fields without a hint whose labels can wrap: the inputs of a row stay on one line (#765, "Last flight: <type>
     (UTC)" on the crew record). */
  .m-fields--end {
    align-items: end;
  }

  /* With an error under one input, the end of the field is the end of the error: the label, the input and the error
     of each field take one track of a subgrid, so the inputs stay on one line and the error is below its own input
     (#788). The row gap is the gap of a field: Firefox adds a difference of the two gaps to the input track, and the
     inputs then grow. A phone has one column and keeps the stack. */
  @media (min-width: 640px) {
    .m-fields--end:has(.m-field--error) {
      row-gap: 6px;
    }

    .m-fields--end:has(.m-field--error) > .m-field {
      grid-row: span 3;
      grid-template-rows: subgrid;
    }

    .m-fields--end:has(.m-field--error) .m-field__label {
      align-self: end;
    }
  }

  @media (max-width: 639px) {
    .m-kv--2,
    .m-fields--3 {
      grid-template-columns: minmax(0, 1fr);
    }
  }

  .m-form--narrow {
    max-width: 26rem;
  }

  .m-row--between {
    justify-content: space-between;
  }

  .m-bands {
    gap: var(--space-2);
  }

  /* A disclosure whose summary is a button (Reset password…); the form inside works without JavaScript. */
  .m-disclose > summary {
    list-style: none;
    width: fit-content;
  }

  .m-disclose > summary::-webkit-details-marker {
    display: none;
  }

  .m-disclose[open] {
    flex-basis: 100%;
  }

  .m-disclose[open] > summary {
    margin-bottom: var(--space-4);
  }

  .m-adminpage .m-table time {
    white-space: nowrap;
  }

  /* The changes of a scoring method version (#227): one line each. */
  .m-changes {
    margin: 0;
    padding-inline-start: 1.1em;
  }

  /* One field and its button on a line (Account, default aircraft). */
  .m-inlineform {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-3);
    align-items: flex-end;
  }

  .m-inlineform > .m-field {
    flex: 1 1 18rem;
  }

  /* --- #116 home --- */
  .m-home,
  .m-analytics,
  .m-analytics__body {
    display: grid;
    gap: var(--space-5);
    max-width: 1040px;
  }

  /* MRAT (#339): as .m-stack > *: the trend data table scrolls, it does not widen the page. */
  .m-analytics > *,
  .m-analytics__body > * {
    min-width: 0;
  }

  .m-home .m-pagehead,
  .m-analytics .m-pagehead {
    margin-bottom: 0;
  }

  .m-home__count {
    font-weight: 500;
  }

  /* On a phone the table rows are cards: a pill keeps its own width, and a cell's label is not mono. */
  .m-home .m-table--stack td > .m-risk,
  .m-home .m-table--stack td > .m-status {
    justify-self: start;
  }

  .m-home .m-table--stack td::before {
    font-family: var(--font-sans);
  }

  .m-home__note {
    max-width: 68ch;
    font-size: 13px;
  }

  .m-home__more {
    padding-top: var(--space-2);
  }

  /* #310: the flight readiness check of Admin Home. */
  .m-ready p {
    margin: 0;
  }

  .m-ready__items {
    display: grid;
    gap: var(--space-3);
    margin: var(--space-3) 0 0;
    padding-left: var(--space-5);
  }

  .m-ready__title {
    font-weight: 650;
  }

  .m-ready__links {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-1) var(--space-4);
  }

  /* v2.3: on a phone the masthead runs to the edges, right under the band (the M9 phone artboard). With the
     bottom tab bar (#169) the masthead buttons are in the bar. */
  @media (max-width: 639px) {
    .m-home > .m-mast {
      margin: calc(-1 * var(--space-4)) calc(-1 * var(--space-4)) 0;
    }

    .m-shell:has(.m-tabbar) .m-mast__actions {
      display: none;
    }
  }

  .m-period {
    align-items: end;
  }

  .m-analytics__grid {
    display: grid;
    gap: 20px;

    /* MRAT (#339): at most the full width; 22rem is wider than a 360 px phone. */
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 22rem), 1fr));
  }

  .m-analytics__grid > :last-child {
    grid-column: 1 / -1;
  }

  /* A bar chart as a table: label, bar, count. */
  .m-bars {
    width: 100%;
    border-collapse: collapse;
  }

  .m-bars th,
  .m-bars td {
    padding: 5px 0;
    vertical-align: middle;
  }

  .m-bars tbody th {
    width: 9rem;
    padding-right: var(--space-3);
    font-size: 13px;
    font-weight: 600;
    text-align: left;
    overflow-wrap: anywhere;
  }

  .m-bars__bar svg {
    display: block;
    width: 100%;
    height: 12px;
  }

  .m-bars .m-num {
    width: 3rem;
    text-align: right;
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums slashed-zero;
  }

  .m-bars__fill--low {
    fill: var(--risk-low);
  }

  .m-bars__fill--moderate {
    fill: var(--risk-moderate-ink);
  }

  .m-bars__fill--high {
    fill: var(--risk-high);
  }

  .m-bars__fill--stop {
    fill: var(--risk-stop);
  }

  .m-bars__fill--status,
  .m-bars__fill--category {
    fill: var(--accent);
  }

  @media (forced-colors: active) {
    .m-bars__fill {
      fill: CanvasText;
    }
  }

  /* --- #317 flight records list: several facts in one cell, one per line; the CSV form under the table. --- */
  .m-records__line {
    display: block;
  }

  .m-records time {
    white-space: nowrap;
  }

  .m-records__export {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-3);
    margin-top: var(--space-4);
  }

  /* --- #118 assessment log --- */
  .m-log {
    display: grid;
    gap: var(--space-5);
    max-width: 1040px;
  }

  .m-log > .m-pagehead {
    margin-bottom: 0;
  }

  /* A grid item is as wide as its longest <option> unless it may shrink: on a phone the filter selects
     would overlap (owner feedback on #118). */
  .m-filters > .m-field {
    min-width: 0;
  }

  .m-log .m-table caption .m-muted {
    font-weight: 500;
  }

  .m-log__detail {
    display: block;
    color: var(--ink-muted);
    font-size: 13px;
  }

  .m-result {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-5);
    align-items: center;
  }

  .m-result > .m-kv {
    flex: 1 1 32rem;
  }

  .m-scope .m-kv {
    grid-template-columns: minmax(0, 1fr);
  }

  .m-history {
    display: grid;
    gap: 10px;
    margin: 0;
    padding: 0;
    list-style: none;
  }

  .m-history .m-row {
    gap: var(--space-3);
  }

  .m-log ins,
  .m-log del {
    text-decoration-thickness: 1px;
  }

  /* --- #119 library --- */
  .m-library,
  .m-library__panels {
    display: grid;
    gap: var(--space-5);
    max-width: 1040px;
  }

  .m-library .m-pagehead {
    margin-bottom: 0;
  }

  /* #698: the flight library, one section per category. The summary keeps its list-item display, so the browser
     draws the open or closed marker with no icon of ours. */
  .m-libgroups {
    display: grid;
    gap: var(--space-3);
  }

  .m-libgroup {
    background: var(--surface);
    border: var(--border-hairline) solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xs);
  }

  .m-libgroup > summary {
    min-height: var(--target-min);
    padding: var(--space-3) var(--space-4);
    cursor: pointer;
  }

  .m-libgroup[open] > summary {
    border-bottom: var(--border-hairline) solid var(--line);
  }

  .m-libgroup__name {
    font-weight: 600;
  }

  .m-libgroup > .m-table-wrap {
    border: 0;
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
    box-shadow: none;
  }

  .m-library__note {
    font-size: 13px;
  }

  .m-library__quote {
    font-weight: 600;
  }

  .m-library__choices {
    display: grid;
    gap: var(--space-1);
    min-width: 0;
    margin: 0;
    padding: 0;
    border: 0;
  }

  .m-tq {
    margin: var(--space-3) 0 0;
    padding: 0;
    list-style: none;
  }

  .m-tq__row {
    display: grid;
    grid-template-columns: 2rem minmax(0, 1fr) 10rem 4rem auto;
    gap: var(--space-3);
    align-items: center;
    padding: 10px var(--space-4);
    border-top: var(--border-hairline) solid var(--line);
  }

  .m-tq__text {
    font-weight: 600;
  }

  .m-tq__text .m-stopflag {
    margin-left: 6px;
  }

  .m-tq__category {
    font-size: 13px;
  }

  .m-tq__points {
    text-align: right;
  }

  .m-tq__actions {
    gap: var(--space-1);
  }

  @media (max-width: 639px) {
    .m-tq__row {
      grid-template-columns: 2rem minmax(0, 1fr) auto;
    }

    .m-tq__text {
      grid-column: 2 / -1;
    }

    .m-tq__category {
      grid-column: 2;
    }

    .m-tq__actions {
      grid-column: 2 / -1;
    }
  }

  /* --- #117 assessment --- */
  .m-assess {
    max-width: 920px;
    gap: var(--space-5);
  }

  .m-assess > .m-pagehead {
    margin-bottom: 0;
  }

  /* Owner feedback: the record tabs wrap on a phone; no tab hides behind a scroll. */
  .m-assess .m-tabs {
    flex-wrap: wrap;
    overflow-x: visible;
    row-gap: 0;
  }

  .m-assess__body {
    min-width: 0;
    margin: 0;
    padding: 0;
    border: 0;
  }

  .m-assess__between {
    justify-content: space-between;
    flex-wrap: wrap;
  }

  /* #196: a slot that htmx swaps (flash, unsaved-changes banner) has no box, so an empty one adds no gap. */
  .m-assess__slot {
    display: contents;
  }

  /* #195: the pre-save checks at Save. The page opens at their heading (#save-check): the warning stops below the
     sticky top bar and the sticky score, not behind them. */
  #save-check {
    scroll-margin-top: calc(56px + 8rem + var(--space-3));
  }

  .m-savecheck > :not(.m-tile) {
    grid-column: 2;
  }

  /* The title is a heading here (the focus target), at the size of the alert title. */
  .m-savecheck > .m-alert__title {
    font-size: inherit;
    line-height: inherit;
  }

  .m-savecheck__list {
    padding-left: var(--space-4);
  }

  .m-savecheck__actions {
    margin-top: var(--space-2);
  }

  /* The score bar stays sticky: its slot has no box, so the bar sticks within the whole form. */
  .m-score-slot {
    display: contents;
  }

  /* The sticky score stops under the sticky top bar (min-height 56px), not behind it. */
  .m-score-slot > .m-score,
  .m-score-slot > .m-strip {
    top: calc(56px + var(--space-2));
  }

  /* v2.3: the slot holds the ScoreBar and the ScoreStrip; a phone shows the strip, a wider screen the bar. */
  @media (max-width: 639px) {
    .m-score-slot > .m-score {
      display: none;
    }
  }

  @media (min-width: 640px) {
    .m-score-slot > .m-strip {
      display: none;
    }
  }

  /* #192: on a stored record the RecordHeader shows the score at the top of the page, so the ScoreBar shows only
     after the header leaves the screen (web-ts/src/scorebar.ts sets data-score-head on the form). The slot is a
     sticky line of no height: the bar takes no space in the page, so it shows and hides without moving the layout.
     Hidden, it is only transparent: its live region still announces the score. Without JavaScript, both show. */
  @media (min-width: 640px) and (scripting: enabled) {
    .m-score-slot--follow {
      display: block;
      position: sticky;
      top: calc(56px + var(--space-2));
      z-index: 5;
      height: 0;
    }

    .m-score-slot--follow > .m-score {
      position: relative;
      top: 0;
      opacity: 0;
      transform: translateY(-8px);
      pointer-events: none;
      transition:
        opacity var(--dur-2) var(--ease-out),
        transform var(--dur-2) var(--ease-out);
    }

    [data-score-head="gone"] > .m-score-slot--follow > .m-score {
      opacity: 1;
      transform: none;
      pointer-events: auto;
    }
  }

  /* v2.3: the crumbs and the record's actions on one line above the RecordHeader. */
  .m-recbar {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-3);
    align-items: center;
    justify-content: space-between;
  }

  .m-assess__thresholds {
    grid-template-columns: repeat(auto-fit, minmax(10rem, 12rem));
  }

  .m-assess__save {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-4);
    align-items: flex-end;
    justify-content: space-between;
  }

  .m-assess__status {
    flex: 1 1 16rem;
    max-width: 24rem;
  }

  .m-assess__actions {
    justify-items: end;
  }

  .m-assess__draft {
    margin: 0;
    font-size: 13px;
  }

  .m-assess__draft .m-icon {
    width: 14px;
    height: 14px;
    vertical-align: -2px;
  }

  .m-q__notes summary {
    width: max-content;
    min-height: var(--target-min);
    display: flex;
    align-items: center;
    gap: var(--space-1);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
  }

  .m-q__notes[open] summary {
    margin-bottom: var(--space-2);
  }

  .m-assess__ai {
    padding-top: var(--space-3);
    border-top: var(--border-hairline) solid var(--line);
  }

  .m-assess__choice > span {
    display: grid;
    gap: 2px;
  }

  /* The Return to Draft and Delete dialogs that htmx puts over the form (no script opens them modal). */
  #record-dialog .m-dialog[open] {
    position: fixed;
    inset: 0;
    z-index: 20;
    margin: auto;
    height: max-content;
  }

  #record-dialog:has(.m-dialog[open])::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: 19;
    background: var(--scrim);
  }

  /* --- #169 bottom tab bar and Save bar (design system v2.3, BottomTabBar) ---
     Phones only: below 640 px they are fixed at the bottom with the safe-area inset; wider screens use the side
     navigation or the Menu. Read-only has three tabs, so the columns follow the links. `aria-current` is `page` on
     the page itself and `true` on a page of one assessment (in the Assessments tab). The --dur-3 and --ease-out
     fallbacks are the values of the v2.3 motion tokens until tokens.css has them (#166). */
  .m-tabbar,
  .m-savebar {
    display: none;
    background: color-mix(in oklch, var(--surface-raised) 90%, transparent);
    backdrop-filter: blur(16px) saturate(1.4);
    border-top: 1px solid var(--line);
  }

  @media (max-width: 639px) {
    .m-tabbar,
    .m-savebar {
      position: fixed;
      left: 0;
      right: 0;
      bottom: 0;
      z-index: 12;
      display: grid;
    }

    .m-shell:has(> .m-tabbar, > .m-savebar) > .m-main {
      padding-bottom: calc(96px + env(safe-area-inset-bottom, 0px));
    }
  }

  .m-tabbar {
    grid-auto-flow: column;
    grid-auto-columns: minmax(0, 1fr);
    padding: 6px 8px calc(8px + env(safe-area-inset-bottom, 0px));
  }

  .m-tabbar a {
    display: grid;
    justify-items: center;
    align-content: center;
    gap: 4px;
    min-height: 56px;
    border-radius: var(--radius-md);
    color: var(--ink-muted);
    text-decoration: none;
    font-size: 11px;
    font-weight: 650;
    letter-spacing: 0.01em;
  }

  .m-tabbar__ic {
    position: relative;
    display: grid;
    place-items: center;
    width: 56px;
    height: 30px;
    border-radius: var(--radius-pill);
    transition:
      background var(--dur-3) var(--ease-out),
      color var(--dur-3) var(--ease-out);
  }

  .m-tabbar__ic .m-icon {
    width: 22px;
    height: 22px;
  }

  .m-tabbar a[aria-current] {
    color: var(--ink);
  }

  .m-tabbar a[aria-current] .m-tabbar__ic {
    background: var(--accent-soft);
    color: var(--accent-strong);
  }

  .m-tabbar__new {
    color: var(--ink);
  }

  .m-tabbar__new .m-tabbar__ic {
    width: 48px;
    height: 34px;
    border-radius: 12px;
    color: var(--on-accent);
    background: linear-gradient(to bottom, var(--accent-top), var(--accent));
    box-shadow: var(--shadow-primary);
  }

  .m-savebar {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: var(--space-2);
    align-items: center;
    padding: 8px 12px calc(8px + env(safe-area-inset-bottom, 0px));
  }

  .m-savebar__draft {
    margin: 0;
    color: var(--ink-muted);
    font-size: 12px;
    line-height: 16px;
    font-weight: 600;
  }

  /* MRAT (#229): the mitigation progress panel, one block per mitigation. */
  .m-progress + .m-progress {
    padding-top: var(--space-4);
    border-top: var(--border-hairline) solid var(--line);
  }

  .m-progress__title {
    margin: 0;
    font-size: 15px;
    line-height: 20px;
    font-weight: 650;
  }

  .m-progress__form {
    align-items: end;
  }

  /* MRAT (#228): the close-out of a record, the work-done form and the Open risk items board. */
  .m-closeout__title {
    margin: 0;
    font-size: 15px;
    line-height: 20px;
    font-weight: 650;
  }

  .m-closeout__items {
    display: grid;
    gap: var(--space-2);
    margin: 0;
    padding-left: var(--space-5);
  }

  .m-closeout p,
  .m-closeout__items p {
    margin: 0;
  }

  .m-closeout__warn,
  .m-board__late {
    color: var(--danger);
    font-weight: 650;
  }

  .m-workitem + .m-workitem {
    padding-top: var(--space-4);
    border-top: var(--border-hairline) solid var(--line);
  }

  .m-choice {
    margin: 0;
    padding: 0;
    border: 0;
  }

  /* MRAT (#299): the flight record pages. Each answer is a list of choices, each a row of at least 44 px; the
     planned change under a Yes shows only while the Yes is checked, by CSS, so the screen needs no JavaScript. */
  .m-fr-step {
    margin: 0;
  }

  /* Running text with an inline icon: on a phone the echo wraps as a sentence. */
  .m-fr-echo {
    margin: 0;
    font-weight: 600;
  }

  .m-fr-echo .m-icon {
    margin-right: var(--space-2);
    vertical-align: -3px;
    color: var(--ink-muted);
  }

  .m-fr-list {
    display: grid;
    gap: var(--space-1);
    margin: var(--space-1) 0;
    padding-left: var(--space-5);
  }

  .m-fr-items {
    display: grid;
    gap: var(--space-5);
  }

  .m-fr-q {
    display: grid;
    gap: var(--space-2);
    min-width: 0;
  }

  .m-fr-q + .m-fr-q,
  .m-fr-none {
    padding-top: var(--space-5);
    border-top: var(--border-hairline) solid var(--line);
  }

  .m-fr-q__text {
    margin: 0 0 var(--space-2);
    padding: 0;
    font-weight: 600;
    line-height: 22px;
  }

  .m-fr-choices {
    display: grid;
    gap: var(--space-2);
    min-width: 0;
    margin: 0;
    padding: 0;
    border: 0;
  }

  .m-fr-choices--row {
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 8rem), 1fr));
  }

  .m-fr-choices > input {
    position: absolute;
    opacity: 0;
    width: 1px;
    height: 1px;
  }

  .m-fr-choices > label {
    position: relative;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-1) var(--space-3);
    min-width: 0;
    min-height: var(--target-min);
    padding: var(--space-2) var(--space-3) var(--space-2) 40px;
    border-radius: var(--radius-md);
    background: var(--surface-sunken);
    box-shadow: inset 0 0 0 1px var(--line);
    cursor: pointer;
  }

  .m-fr-choices > label::before {
    content: "";
    position: absolute;
    left: var(--space-3);
    top: 50%;
    translate: 0 -50%;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--surface);
    box-shadow: inset 0 0 0 2px var(--line-control);
  }

  .m-fr-choices > label > span:first-child {
    flex: 1 1 10rem;
    min-width: 0;
    overflow-wrap: anywhere;
  }

  .m-fr-choices > input:checked + label {
    background: var(--surface);
    box-shadow: inset 0 0 0 2px var(--ink);
    font-weight: 600;
  }

  .m-fr-choices > input:checked + label::before {
    box-shadow: inset 0 0 0 5px var(--ink);
  }

  .m-fr-choices > input:focus-visible + label {
    outline: var(--focus-width) solid var(--focus);
    outline-offset: 2px;
  }

  .m-fr-q--error .m-fr-choices > label {
    box-shadow: inset 0 0 0 1px var(--danger);
  }

  .m-fr-plan {
    display: none;
    gap: var(--space-3);
    margin-left: var(--space-5);
    padding: var(--space-4);
    border-radius: var(--radius-md);
    background: var(--surface-sunken);
  }

  .m-fr-choices > input:checked + label + .m-fr-plan {
    display: grid;
  }

  .m-fr-plan__head {
    margin: 0;
    font-size: 13px;
    font-weight: 650;
  }

  .m-fr-plan__stop,
  .m-fr-stop {
    margin: 0;
    font-weight: 650;
    color: var(--danger);
  }

  .m-fr-stop {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
  }

  .m-fr-stop .m-risk__glyph {
    width: 14px;
    height: 14px;
  }

  .m-fr-none {
    display: grid;
    gap: var(--space-2);
    justify-items: start;
  }

  .m-fr-when {
    align-items: start;
  }

  /* The re-planning suggestions of a Yes (#313) */
  .m-fr-ai__list {
    display: grid;
    gap: var(--space-3);
    margin: 0;
    padding: 0;
    list-style: none;
  }

  .m-fr-ai__item {
    display: grid;
    gap: var(--space-2);
  }

  /* A block, not a flex box: a flex box drops the space between "Now" and the time. */
  .m-fr-now {
    margin: 0;
    padding-top: 22px;
    line-height: var(--target-min);
  }

  .m-fr-actions {
    justify-content: flex-end;
  }

  .m-fr-meta {
    align-items: center;
  }

  .m-fr-rows {
    display: grid;
    margin: 0;
    padding: 0;
    list-style: none;
  }

  .m-fr-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 16rem);
    gap: var(--space-1) var(--space-4);
    padding: var(--space-3) 0;
    border-top: var(--border-hairline) solid var(--line);
  }

  .m-fr-row:first-child {
    padding-top: 0;
    border-top: 0;
  }

  .m-fr-row__q,
  .m-fr-row__a {
    min-width: 0;
    overflow-wrap: anywhere;
  }

  .m-fr-row__a {
    font-weight: 600;
  }

  .m-fr-row__plan {
    grid-column: 1 / -1;
    font-size: 13px;
    color: var(--ink-muted);
    overflow-wrap: anywhere;
  }

  .m-fr-stamp {
    margin: var(--space-3) 0 0;
    font-size: 13px;
  }

  /* MRAT (#301): the username of a password form is for the password manager only (decision 12). A class, not
     style="", under the CSP. */
  .m-fr-user {
    display: none;
  }

  .m-fr-late {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    font-size: 13px;
    color: var(--ink-muted);
  }

  /* #305 (S7): the one status line of a Go row, under its status word. */
  .m-fr-line {
    display: block;
    font-size: 13px;
    color: var(--ink-muted);
  }

  /* #304: an A5b maintenance line with the PIC's tick. */
  .m-fr-tick {
    display: grid;
    gap: var(--space-2);
    min-width: 0;
    margin: 0;
    padding: 0;
    border: 0;
  }

  /* No-go is never next to Go (decision 8): at the end of the page, under a line. */
  .m-fr-end {
    padding-top: var(--space-4);
    border-top: var(--border-hairline) solid var(--line);
  }

  .m-fr-end > p {
    margin: 0;
  }

  /* MRAT (#303): the risk decision page. A line under each decision says what it leads to (SMS S2). */
  .m-fa-what {
    flex-basis: 100%;
    font-size: 13px;
    font-weight: 400;
    color: var(--ink-muted);
  }

  /* The Accept parts only while an Accept decision may be chosen (SMS S3), the conditions only for "Accept with
     conditions". A browser without :has() shows them, and the step ignores them for another decision. */
  .m-fa:has(#d-stop:checked, #d-defer:checked) .m-fa-accepting,
  .m-fa:not(:has(#d-conditions:checked)) .m-fa-cond,
  .m-fa:not(:has(#d-conditions:checked)) .m-fa-conditions:not(:has(.m-field--error)) {
    display: none;
  }

  /* A time of a risk decision ("23 Oct 0721Z", 12 characters of the mono face): a box of a fixed width, so that the
     masked time of a quality run never changes the wrap around it. */
  .m-when {
    display: inline-block;
    width: 12ch;
    white-space: nowrap;
  }

  /* #304: a date without a clock ("09 Oct"). */
  .m-when--day {
    width: 6ch;
  }

  .m-fa-note {
    display: flex;
    gap: var(--space-2);
    margin: 0;
  }

  .m-fa-entry + .m-fa-entry {
    padding-top: var(--space-4);
    border-top: var(--border-hairline) solid var(--line);
  }

  .m-fa-entry__head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-2);
    margin: 0;
  }

  .m-fa-intent {
    margin: 0;
    font-weight: 600;
  }

  .m-fa-basis {
    margin: 0;
    white-space: pre-line;
    overflow-wrap: anywhere;
  }

  @media (max-width: 639px) {
    .m-fr-row {
      grid-template-columns: minmax(0, 1fr);
    }

    /* A choice that scrolls into view (focus, a tap after a scroll) stops above the fixed tab bar, not under it. */
    .m-fr-choices > input,
    .m-fr-choices > label,
    .m-fr-plan .m-input {
      scroll-margin-bottom: 96px;
    }

    .m-fr-plan {
      margin-left: 0;
    }
  }
}

@layer utilities {
  /* MRAT: htmx's indicator rules, here because includeIndicatorCSS is off (ADR 0002, rule 2). */
  .htmx-indicator {
    opacity: 0;
    visibility: hidden;
  }

  .htmx-request .htmx-indicator,
  .htmx-request.htmx-indicator {
    opacity: 1;
    visibility: visible;
    transition: opacity 200ms ease-in;
  }

  /* Reduced motion: nothing moves (design system v2.3, Motion). !important beats every animation and transition,
     the view transition pseudo-elements included; no page starts a view transition at all. */
  @media (prefers-reduced-motion: reduce) {
    @view-transition {
      navigation: none;
    }

    *,
    *::before,
    *::after,
    ::view-transition-group(*),
    ::view-transition-old(*),
    ::view-transition-new(*) {
      transition: none !important;
      animation: none !important;
      scroll-behavior: auto;
    }

    .m-btn:active,
    .m-answer label:active,
    .m-stat--tint:hover {
      transform: none;
    }
  }
}

/* The paper: black on white in every theme. m-paper draws the sheet on screen (the gallery's print
   preview); @media print styles the page itself. */
@layer print {
  .m-paper {
    background: var(--print-paper);
    color: var(--print-ink);
    font-family: var(--font-sans);
    padding: 15mm;
    max-width: 186mm;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-md);
  }

  .m-paper * {
    color: var(--print-ink);
  }

  @media (max-width: 639px) {
    .m-paper {
      padding: var(--space-4);
      overflow-x: auto;
    }
  }

  .m-paper__head {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 2px var(--space-4);
    padding-bottom: var(--space-2);
    border-bottom: 2px solid var(--print-ink);
    font-size: 11px;
  }

  .m-paper__title {
    font-size: 17px;
    font-weight: 750;
    font-variation-settings: "wdth" 112;
    letter-spacing: -0.02em;
  }

  .m-paper h2 {
    font-size: 13px;
    margin: var(--space-4) 0 var(--space-2);
    font-weight: 700;
  }

  .m-paper table {
    width: 100%;
    border-collapse: collapse;
    font-size: 10.5px;
  }

  .m-paper th,
  .m-paper td {
    border: 1px solid var(--print-ink);
    padding: 3px 5px;
    text-align: left;
  }

  .m-paper .m-risk,
  .m-paper .m-sign__stamp {
    background: var(--print-paper);
    box-shadow: inset 0 0 0 1px var(--print-ink);
  }

  .m-paper .m-sign {
    background: var(--print-paper);
    box-shadow: none;
    border-color: var(--print-ink);
    border-radius: var(--radius-sm);
  }

  .m-paper__foot {
    margin-top: var(--space-4);
    padding-top: var(--space-2);
    border-top: 1px solid var(--print-ink);
    display: flex;
    justify-content: space-between;
    gap: var(--space-4);
    font-size: 9.5px;
  }

  /* --- #118 assessment log ---
     The print preview: the sheet at its paper width and margins, narrower on a small screen. */
  .m-sheet {
    max-width: none;
    padding: 14mm 14mm 16mm;
  }

  .m-sheet--letter {
    width: min(100%, 8.5in);
    min-height: 11in;
  }

  .m-sheet--a4 {
    width: min(100%, 210mm);
    min-height: 297mm;
  }

  /* #317: the print of the flight records list is a landscape sheet. */
  .m-sheet--letter-wide {
    width: min(100%, 11in);
    min-height: 8.5in;
  }

  .m-sheet--a4-wide {
    width: min(100%, 297mm);
    min-height: 210mm;
  }

  .m-records-sheet table {
    font-size: 9.5px;
  }

  /* #308: the one-page print of a flight record, and the blank paper FRAT (two pages a template). */
  .m-fprint,
  .m-fprint table {
    font-size: 9px;
    line-height: 1.2;
  }

  .m-fprint__two {
    columns: 2;
  }

  /* A server-made record id: one width at any length, so that it never moves the wrap of its line. */
  .m-fprint__id {
    display: inline-block;
    width: 23ch;
    white-space: nowrap;
  }

  /* `.m-fprint table` above would win over the class alone (#529). */
  .m-fprint .m-fprint__yes,
  .m-fprint .m-fprint__mrat {
    font-size: 8px;
  }

  .m-fprint__yes td:nth-child(2) {
    width: 34%;
  }

  .m-fprint th,
  .m-fprint td {
    padding: 1px 4px;
  }

  .m-fprint ul {
    margin: 0;
    padding-left: 1.2em;
  }

  /* 3 px, not --space-1: a half-hour limit in an item text (#527) wraps one line more, and the large leg stays one page. */
  .m-fprint h2 {
    font-size: 11px;
    margin: 3px 0 1px;
  }

  .m-fprint__cols {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(60mm, 1fr));
    gap: var(--space-3);
  }

  .m-blank,
  .m-blank table {
    font-size: 8px;
    line-height: 1.2;
  }

  .m-blank h2 {
    font-size: 10px;
    margin: var(--space-2) 0 2px;
  }

  .m-blank p {
    margin: 2px 0;
  }

  .m-blank th,
  .m-blank td {
    padding: 1px 3px;
  }

  .m-blank + .m-blank {
    margin-top: var(--space-6);
  }

  .m-blank__head td {
    min-width: 22mm;
    height: 5mm;
  }

  /* #717: an empty row of the planned changes has no text, so without a height it has no room to write in. */
  .m-blank__lines td {
    height: 5mm;
  }

  .m-blank__box {
    display: inline-block;
    width: 8px;
    height: 8px;
    border: 1px solid var(--print-ink);
    vertical-align: -1px;
  }

  /* #717: the Print button needs the page script (web-ts/src/print.ts). */
  @media (scripting: none) {
    [data-print] {
      display: none;
    }
  }

  .m-blank__ver {
    font-size: 20px;
    font-weight: 750;
    text-align: right;
  }

  .m-sheet__result {
    font-size: 12px;
  }

  .m-sheet .m-signs {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .m-sheet .m-sign__stamp .m-icon {
    display: none;
  }

  .m-sheet .m-paper__foot > .m-data {
    white-space: nowrap;
  }

  @media (max-width: 639px) {
    .m-sheet {
      padding: var(--space-4);
    }

    .m-sheet .m-signs {
      grid-template-columns: minmax(0, 1fr);
    }
  }

  @media print {
    @page {
      margin: 14mm 14mm 16mm;
    }

    html,
    body {
      background: var(--print-paper);
      color: var(--print-ink);
    }

    .m-top,
    .m-nav,
    .m-menu,
    .m-score,
    .m-strip,
    .m-toasts,
    .m-btn,
    .m-tabs,
    .m-tabbar,
    .m-savebar {
      display: none;
    }

    /* v2.3: the tinted record header and the risk tile print in ink on paper. */
    .m-record,
    .m-risktile {
      background: var(--print-paper);
      color: var(--print-ink);
      border-color: var(--print-ink);
      box-shadow: inset 0 0 0 1px var(--print-ink);
    }

    .m-shell {
      display: block;
    }

    .m-risk {
      background: var(--print-paper);
      color: var(--print-ink);
      box-shadow: inset 0 0 0 1px var(--print-ink);
    }

    .m-sign,
    .m-q,
    .m-panel,
    .m-table-wrap {
      break-inside: avoid;
      border-color: var(--print-ink);
      background: var(--print-paper);
      box-shadow: none;
    }

    /* #118: the paper size of the print page (owner decision #111): a named page per sheet class, so the
       choice needs no inline style (CSP). */
    @page letter {
      size: letter;
    }

    @page a4 {
      size: a4;
    }

    .m-sheet--letter {
      page: letter;
    }

    .m-sheet--a4 {
      page: a4;
    }

    @page letter-wide {
      size: letter landscape;
    }

    @page a4-wide {
      size: a4 landscape;
    }

    .m-sheet--letter-wide {
      page: letter-wide;
    }

    .m-sheet--a4-wide {
      page: a4-wide;
    }

    /* #318: each later page of a print says so (Firefox has no page-margin boxes). */
    @page {
      @bottom-center {
        content: "Continued: page " counter(page) " of " counter(pages);
        font-size: 9px;
      }
    }

    @page :first {
      @bottom-center {
        content: none;
      }
    }

    .m-main:has(> .m-printview) {
      padding: 0;
    }

    .m-printview > :not(.m-sheet) {
      display: none;
    }

    /* #308 (M7): each template of the blank starts a page, and its version is large on every page. */
    .m-blank + .m-blank {
      break-before: page;
      margin-top: 0;
    }

    /* #717: the version is the header group of the sheet, so each page repeats it in its own band, in the top
       margin of the blank's pages (a fixed element overlaps the heads; the page margin clips it). */
    @page blank-letter {
      size: letter;
      margin-top: 7mm;
    }

    @page blank-a4 {
      size: a4;
      margin-top: 7mm;
    }

    .m-blank {
      display: table;
      width: 100%;
    }

    .m-blank.m-sheet--letter {
      page: blank-letter;
    }

    .m-blank.m-sheet--a4 {
      page: blank-a4;
    }

    .m-blank__ver {
      display: table-header-group;
      line-height: 7mm;
    }

    /* #717: no row, field or part splits at a page break. */
    .m-blank tr,
    .m-blank p,
    .m-blank__part {
      break-inside: avoid;
    }

    .m-blank h2,
    .m-blank__cat {
      break-after: avoid;
    }

    .m-sheet {
      width: auto;
      min-height: 0;
      max-width: none;
      padding: 0;
      border-radius: 0;
      box-shadow: none;
    }

  }
}
