/* mEMA UI Kit 0.6.1 (11 Nov 2026: base defaults that only undid mEMA's old heading, select and table-cell styles are gone; 0.6, 11 Nov 2026: module pages no longer load mEMA's classic styles, so the cascade layers, the reset layer and section 14 are gone; the stylesheets moved to css/ and the script to js/; 0.5.4: table rows highlight on hover only with table-hover; 0.5.3: editable text works in Safari again; 0.5.2: white icons on solid buttons, icon-off for toggles that are off; 0.5.1: anything you can click has a light blue border, --ui-click-line; 0.5, 10 Nov 2026: cascade layers kept mEMA's stylesheets out of the box (replaced in 0.6); 0.4.1: .prose uses the full width, .prose-narrow keeps a reading width; 0.4, Nov 2026: icons (Mark's PNGs), sidebar layout, side menu, cards, pagination, breadcrumb, prose and callouts, sections 15-22; 0.3.3, 6 Nov 2026: the page div follows the window on module pages, so the breakpoints fire; 0.3.2 let greyed-out tabs show a tooltip; 0.3.1 undid mEMA's page-wide .row and .dialog rules; 0.2 was the 23 Oct proposal)
   A small responsive layer for mEMA module pages: columns, tables, buttons, inputs and a few components.
   Everything is scoped to .mema-ui, the content box between mEMA's header and footer,
   so mEMA's header, menu, footer and other pages don't change.
   Breakpoints follow that box's own width (container queries): sm 576px, md 768px, lg 1024px.

   What a module page loads (0.6): css/mema/base.css (mEMA's page frame: header, menus, footer, dialogs), the toasts'
   css/toastify.css and css/notify.css, this file and the module's assets/module.css. mEMA's classic styles
   (css/mema/classic.css and the old page stylesheets) never load on module pages, so nothing old reaches the box and
   no reset is needed: what this file and the module say is what you see, and where they say nothing you get the
   browser's default. The root below still sets every inherited text property, as the base styles <body>. */

/* Tokens */
.mema-ui {
  --ui-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Tahoma, Arial, sans-serif;
  --ui-mono: ui-monospace, Menlo, Consolas, monospace;
  --ui-fg: #1F2933;
  --ui-muted: #5B6673;
  --ui-line: #D8DEE6;
  --ui-click-line: #B3C5E6;     /* the border of anything you can click (0.5.1); --ui-line is for things you read */
  --ui-bg: #FFFFFF;
  --ui-subtle: #F3F5F8;
  --ui-primary: #355394;
  --ui-primary-hover: #2A4378;
  --ui-primary-soft: #E7EDF7;
  --ui-ok: #1E6B43;
  --ui-ok-soft: #E1F1E7;
  --ui-warn: #8A5300;
  --ui-warn-soft: #FBEFD8;
  --ui-danger: #B02318;
  --ui-danger-hover: #8E1C13;
  --ui-danger-soft: #FBE5E3;
  --ui-shadow: 0 6px 20px rgba(15, 23, 42, .14);
  --ui-radius: 6px;
  --ui-gap: 16px;
  container-type: inline-size;
  display: block;
  /* Every inherited text property, so nothing comes in from mEMA's page (its body is font-stretch: condensed) */
  font: normal normal 400 normal 15px/1.45 var(--ui-font);
  color: var(--ui-fg);
  text-align: left;
  text-indent: 0;
  text-transform: none;
  text-shadow: none;
  letter-spacing: normal;
  word-spacing: normal;
  white-space: normal;
  word-break: normal;
  overflow-wrap: normal;
  font-kerning: auto;
  list-style: disc outside none;
  visibility: visible;
  cursor: auto;
  caret-color: auto;
  border-collapse: separate;
}

/* 1. Base: the kit's own defaults for plain elements */
.mema-ui *, .mema-ui *::before, .mema-ui *::after { box-sizing: border-box; }
.mema-ui :where(h1, h2, h3, h4) { margin: 0; font-weight: 700; line-height: 1.25; color: var(--ui-fg); }
.mema-ui :where(h1) { font-size: 1.6em; }
.mema-ui :where(h2) { font-size: 1.3em; }
.mema-ui :where(h3) { font-size: 1.1em; }
.mema-ui :where(h4) { font-size: 1em; }
.mema-ui :where(p, ul, ol, dl) { margin: 0; }
.mema-ui :where(ul, ol) { padding-left: 1.25em; }
.mema-ui :where(table) { border-collapse: collapse; }
.mema-ui :where(td, th) { vertical-align: middle; text-align: left; }
.mema-ui :where(input, select, textarea, button) { font: inherit; color: inherit; }
.mema-ui :where(fieldset) { min-width: 0; margin: 0; padding: 0; border: 0; }
.mema-ui :where(legend) { padding: 0; }
/* Links: no underline (as mEMA's pages have them); underlined on hover. Underlined in .prose (post text). */
.mema-ui :where(a) { color: var(--ui-primary); text-decoration: none; }
.mema-ui :where(a:hover) { color: var(--ui-primary-hover); text-decoration: underline; }
.mema-ui :where(code) { font-family: var(--ui-mono); font-size: .92em; }
.mema-ui :focus-visible { outline: 2px solid var(--ui-primary); outline-offset: 2px; }

/* 2. Layout helpers */
.mema-ui .stack { display: grid; gap: var(--ui-gap); align-content: start; }
.mema-ui .stack-sm { display: grid; gap: 8px; align-content: start; }
.mema-ui .cluster { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.mema-ui .spread { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; }
.mema-ui :is(.stack, .stack-sm, .row, .grid-auto) > * { min-width: 0; }

/* 3. Columns: a 12-column grid. Every child is full width until a class gives it a span. */
.mema-ui .row { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: var(--ui-gap); }
.mema-ui .row > * { grid-column: span 12; }
.mema-ui .row > .col-1 { grid-column: span 1; }   .mema-ui .row > .col-2 { grid-column: span 2; }   .mema-ui .row > .col-3 { grid-column: span 3; }
.mema-ui .row > .col-4 { grid-column: span 4; }   .mema-ui .row > .col-5 { grid-column: span 5; }   .mema-ui .row > .col-6 { grid-column: span 6; }
.mema-ui .row > .col-7 { grid-column: span 7; }   .mema-ui .row > .col-8 { grid-column: span 8; }   .mema-ui .row > .col-9 { grid-column: span 9; }
.mema-ui .row > .col-10 { grid-column: span 10; } .mema-ui .row > .col-11 { grid-column: span 11; } .mema-ui .row > .col-12 { grid-column: span 12; }
@container (min-width: 576px) {
  .mema-ui .row > .col-sm-1 { grid-column: span 1; }   .mema-ui .row > .col-sm-2 { grid-column: span 2; }   .mema-ui .row > .col-sm-3 { grid-column: span 3; }
  .mema-ui .row > .col-sm-4 { grid-column: span 4; }   .mema-ui .row > .col-sm-5 { grid-column: span 5; }   .mema-ui .row > .col-sm-6 { grid-column: span 6; }
  .mema-ui .row > .col-sm-7 { grid-column: span 7; }   .mema-ui .row > .col-sm-8 { grid-column: span 8; }   .mema-ui .row > .col-sm-9 { grid-column: span 9; }
  .mema-ui .row > .col-sm-10 { grid-column: span 10; } .mema-ui .row > .col-sm-11 { grid-column: span 11; } .mema-ui .row > .col-sm-12 { grid-column: span 12; }
}
@container (min-width: 768px) {
  .mema-ui .row > .col-md-1 { grid-column: span 1; }   .mema-ui .row > .col-md-2 { grid-column: span 2; }   .mema-ui .row > .col-md-3 { grid-column: span 3; }
  .mema-ui .row > .col-md-4 { grid-column: span 4; }   .mema-ui .row > .col-md-5 { grid-column: span 5; }   .mema-ui .row > .col-md-6 { grid-column: span 6; }
  .mema-ui .row > .col-md-7 { grid-column: span 7; }   .mema-ui .row > .col-md-8 { grid-column: span 8; }   .mema-ui .row > .col-md-9 { grid-column: span 9; }
  .mema-ui .row > .col-md-10 { grid-column: span 10; } .mema-ui .row > .col-md-11 { grid-column: span 11; } .mema-ui .row > .col-md-12 { grid-column: span 12; }
}
@container (min-width: 1024px) {
  .mema-ui .row > .col-lg-1 { grid-column: span 1; }   .mema-ui .row > .col-lg-2 { grid-column: span 2; }   .mema-ui .row > .col-lg-3 { grid-column: span 3; }
  .mema-ui .row > .col-lg-4 { grid-column: span 4; }   .mema-ui .row > .col-lg-5 { grid-column: span 5; }   .mema-ui .row > .col-lg-6 { grid-column: span 6; }
  .mema-ui .row > .col-lg-7 { grid-column: span 7; }   .mema-ui .row > .col-lg-8 { grid-column: span 8; }   .mema-ui .row > .col-lg-9 { grid-column: span 9; }
  .mema-ui .row > .col-lg-10 { grid-column: span 10; } .mema-ui .row > .col-lg-11 { grid-column: span 11; } .mema-ui .row > .col-lg-12 { grid-column: span 12; }
}
/* As many columns as fit, each at least --min wide. No breakpoints needed. */
.mema-ui .grid-auto { display: grid; gap: var(--ui-gap); grid-template-columns: repeat(auto-fill, minmax(min(var(--min, 220px), 100%), 1fr)); }

/* 4. Tables */
.mema-ui .table { width: 100%; border-collapse: collapse; font-size: .95em; }
.mema-ui .table th, .mema-ui .table td { padding: 8px 10px; border: 0; border-bottom: 1px solid var(--ui-line); text-align: left; vertical-align: middle; }
.mema-ui .table thead th { background: var(--ui-subtle); color: var(--ui-muted); font-size: .78em; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; white-space: nowrap; }
.mema-ui .table thead th a { color: inherit; text-decoration: none; }
.mema-ui .table thead th[aria-sort="ascending"]::after { content: " \2191"; }
.mema-ui .table thead th[aria-sort="descending"]::after { content: " \2193"; }
/* Row highlight on hover, opt-in: a wide data table where it helps to follow a row, or one whose whole row is a link.
   Not on by default, as a hover means "you can click this" (0.5.4). */
.mema-ui .table-hover tbody tr:hover { background: var(--ui-subtle); }
.mema-ui .table tr.group td { padding-top: 14px; background: var(--ui-bg); color: var(--ui-muted); font-size: .78em; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; }
.mema-ui .table .cell-head { font-weight: 600; }
.mema-ui .table .num { text-align: right; font-variant-numeric: tabular-nums; }
.mema-ui .table-nowrap :is(th, td) { white-space: nowrap; }
/* .table-box: a bordered box for tables that fit. Row menus and pickers inside it can open past its edges. */
.mema-ui .table-box { border: 1px solid var(--ui-line); border-radius: var(--ui-radius); background: var(--ui-bg); }
.mema-ui .table-box .table thead th:first-child { border-top-left-radius: calc(var(--ui-radius) - 1px); }
.mema-ui .table-box .table thead th:last-child { border-top-right-radius: calc(var(--ui-radius) - 1px); }
/* .table-scroll: a bordered box that scrolls sideways when its table is wider. For wide data. */
.mema-ui .table-scroll { overflow-x: auto; border: 1px solid var(--ui-line); border-radius: var(--ui-radius); background: var(--ui-bg); }
.mema-ui :is(.table-box, .table-scroll) .table tr:last-child td { border-bottom: 0; }
/* Stacked tables: below 576px each row becomes a card, and each cell shows its data-label. */
@container (max-width: 575.98px) {
  .mema-ui .table-stack thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .mema-ui .table-stack, .mema-ui .table-stack tbody, .mema-ui .table-stack tr { display: block; width: 100%; }
  .mema-ui .table-stack tr { padding: 10px 12px; border-bottom: 1px solid var(--ui-line); }
  .mema-ui .table-stack tr:last-child { border-bottom: 0; }
  .mema-ui .table-stack td { display: grid; grid-template-columns: 7.5em minmax(0, 1fr); align-items: center; gap: 2px 10px; padding: 3px 0; border: 0; }
  .mema-ui .table-stack td::before { content: attr(data-label); color: var(--ui-muted); font-size: .85em; font-weight: 600; }
  .mema-ui .table-stack td:not([data-label]) { display: block; }
  .mema-ui .table-stack td:not([data-label])::before { content: none; }
  .mema-ui .table-stack .cell-head { font-size: 1.05em; font-weight: 700; }
  .mema-ui .table-stack .num { text-align: left; }
  .mema-ui .table-stack tr.group { padding: 12px 12px 4px; background: var(--ui-subtle); }
  .mema-ui .table-stack tr.group td { padding: 0; background: none; }
}

/* 5. Buttons */
.mema-ui .btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 34px; padding: 6px 14px; border: 1px solid var(--ui-click-line); border-radius: var(--ui-radius); background: var(--ui-bg); color: var(--ui-fg); font: inherit; font-size: .93em; font-weight: 600; line-height: 1.2; text-decoration: none; white-space: nowrap; cursor: pointer; }
.mema-ui .btn:hover { border-color: var(--ui-primary); background: var(--ui-primary-soft); }
.mema-ui .btn-primary { background: var(--ui-primary); border-color: var(--ui-primary); color: #FFFFFF; }
.mema-ui .btn-primary:hover { background: var(--ui-primary-hover); border-color: var(--ui-primary-hover); }
.mema-ui .btn-danger { background: var(--ui-danger); border-color: var(--ui-danger); color: #FFFFFF; }
.mema-ui .btn-danger:hover { background: var(--ui-danger-hover); border-color: var(--ui-danger-hover); }
.mema-ui .btn-link { background: none; border-color: transparent; color: var(--ui-primary); padding-inline: 6px; }
.mema-ui .btn-link:hover { border-color: transparent; background: var(--ui-primary-soft); }
.mema-ui .btn-sm { min-height: 28px; padding: 3px 10px; font-size: .85em; }
.mema-ui .btn:disabled, .mema-ui .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; }
.mema-ui .btn-group { display: inline-flex; flex-wrap: wrap; }
.mema-ui .btn-group > .btn { border-radius: 0; }
.mema-ui .btn-group > .btn + .btn { margin-left: -1px; }
.mema-ui .btn-group > .btn:first-child { border-radius: var(--ui-radius) 0 0 var(--ui-radius); }
.mema-ui .btn-group > .btn:last-child { border-radius: 0 var(--ui-radius) var(--ui-radius) 0; }
.mema-ui .btn-group > .btn[aria-pressed="true"] { background: var(--ui-primary-soft); color: var(--ui-fg); }
@media (pointer: coarse) {
  .mema-ui .btn { min-height: 44px; }
  .mema-ui .btn-sm { min-height: 36px; }
}

/* 6. Badges and counts */
.mema-ui .badge { display: inline-flex; align-items: center; padding: 2px 9px; border-radius: 999px; background: var(--ui-subtle); color: var(--ui-muted); font-size: .8em; font-weight: 700; line-height: 1.5; white-space: nowrap; }
.mema-ui .badge-ok { background: var(--ui-ok-soft); color: var(--ui-ok); }
.mema-ui .badge-warn { background: var(--ui-warn-soft); color: var(--ui-warn); }
.mema-ui .badge-danger { background: var(--ui-danger-soft); color: var(--ui-danger); }
.mema-ui .badge-primary { background: var(--ui-primary-soft); color: var(--ui-primary); }
/* .count: a number on a tab, a view switch or a button. Add hidden words for screen readers. */
.mema-ui .count { display: inline-flex; align-items: center; justify-content: center; min-width: 1.7em; height: 1.7em; padding: 0 .5em; border-radius: 999px; background: var(--ui-subtle); color: var(--ui-muted); font-family: var(--ui-mono); font-size: .76em; font-weight: 600; line-height: 1; font-variant-numeric: tabular-nums; }
.mema-ui .count-primary { background: var(--ui-primary); color: #FFFFFF; }
.mema-ui .count-warn { background: var(--ui-warn-soft); color: var(--ui-warn); box-shadow: inset 0 0 0 1px rgba(138, 83, 0, .25); }
.mema-ui .count-danger { background: var(--ui-danger); color: #FFFFFF; }

/* 7. Alerts */
.mema-ui .alert { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; padding: 10px 14px; border-radius: var(--ui-radius); background: var(--ui-primary-soft); color: var(--ui-fg); }
.mema-ui .alert-ok { background: var(--ui-ok-soft); }
.mema-ui .alert-warn { background: var(--ui-warn-soft); }
.mema-ui .alert-danger { background: var(--ui-danger-soft); }
.mema-ui .alert-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-left: auto; }

/* 8. Tabs and view switch. Mark the current one with aria-current="page". */
/* position: relative keeps a count's hidden words inside the scrolling bar, not widening the page. */
.mema-ui .nav-tabs { position: relative; display: flex; gap: 2px; overflow-x: auto; box-shadow: inset 0 -1px 0 var(--ui-line); scrollbar-width: thin; }
.mema-ui .nav-tabs a { display: inline-flex; align-items: center; gap: 7px; padding: 9px 12px; border-bottom: 2px solid transparent; color: var(--ui-muted); font-weight: 600; text-decoration: none; white-space: nowrap; }
.mema-ui .nav-tabs a:hover { color: var(--ui-fg); }
.mema-ui .nav-tabs a[aria-current="page"] { color: var(--ui-fg); border-bottom-color: var(--ui-primary); }
/* A greyed-out tab has no href, so it can't be clicked but can still show its title as a tooltip. */
.mema-ui .nav-tabs a[aria-disabled="true"], .mema-ui .nav-tabs a[aria-disabled="true"]:hover { opacity: .45; color: var(--ui-muted); cursor: not-allowed; }
@container (max-width: 575.98px) {
  /* Narrow boxes: the tab bar scrolls sideways and fades at the right edge to show there's more. */
  .mema-ui .nav-tabs { padding-right: 28px; -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent); mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent); }
}
.mema-ui .nav-seg { display: inline-flex; flex-wrap: wrap; border: 1px solid var(--ui-click-line); border-radius: var(--ui-radius); overflow: hidden; background: var(--ui-bg); }
.mema-ui .nav-seg a { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-right: 1px solid var(--ui-click-line); color: var(--ui-muted); font-size: .93em; font-weight: 600; text-decoration: none; white-space: nowrap; }
.mema-ui .nav-seg a:last-child { border-right: 0; }
.mema-ui .nav-seg a:hover { background: var(--ui-primary-soft); color: var(--ui-fg); }
.mema-ui .nav-seg a[aria-current="page"] { background: var(--ui-primary-soft); color: var(--ui-fg); }

/* 9. Forms */
.mema-ui .field { display: grid; gap: 4px; align-content: start; }
.mema-ui .field > label, .mema-ui .field > legend, .mema-ui .label { font-size: .9em; font-weight: 700; }
.mema-ui .field > legend { margin-bottom: 4px; }
.mema-ui .help { color: var(--ui-muted); font-size: .85em; }
.mema-ui .error { color: var(--ui-danger); font-size: .85em; font-weight: 600; }
.mema-ui .input, .mema-ui .select { width: 100%; min-height: 36px; padding: 6px 10px; border: 1px solid var(--ui-line); border-radius: var(--ui-radius); background: var(--ui-bg); color: var(--ui-fg); }
.mema-ui textarea.input { min-height: 5.5em; resize: vertical; }
.mema-ui .input:focus, .mema-ui .select:focus { border-color: var(--ui-primary); }
.mema-ui .input[aria-invalid="true"], .mema-ui .select[aria-invalid="true"] { border-color: var(--ui-danger); }
.mema-ui .input:disabled, .mema-ui .select:disabled, .mema-ui .input[readonly] { background: var(--ui-subtle); color: var(--ui-muted); }
.mema-ui .input:disabled, .mema-ui .select:disabled { cursor: not-allowed; }
.mema-ui .input[type="file"] { padding: 4px; }
.mema-ui .input[type="file"]::file-selector-button { margin-right: 10px; padding: 4px 12px; border: 1px solid var(--ui-click-line); border-radius: calc(var(--ui-radius) - 2px); background: var(--ui-subtle); color: var(--ui-fg); font: inherit; font-weight: 600; cursor: pointer; }
/* Checkboxes and radios: <label class="check"><input type="checkbox"> Text</label>; .checks lines them up. */
.mema-ui .check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.mema-ui .check input { width: 1.05em; height: 1.05em; margin: 0; accent-color: var(--ui-primary); }
.mema-ui .checks { display: flex; flex-wrap: wrap; gap: 6px 18px; }
/* An input joined to a button, such as a Patient ID with Look up. */
.mema-ui .input-group { display: flex; }
.mema-ui .input-group > .input { flex: 1 1 auto; min-width: 0; border-radius: var(--ui-radius) 0 0 var(--ui-radius); }
.mema-ui .input-group > .btn { margin-left: -1px; border-radius: 0 var(--ui-radius) var(--ui-radius) 0; }

/* 10. Panels and data display */
.mema-ui .panel { display: grid; gap: 10px; align-content: start; padding: 14px; border: 1px solid var(--ui-line); border-radius: var(--ui-radius); background: var(--ui-bg); }
.mema-ui .panel-muted { background: var(--ui-subtle); }
.mema-ui .stat { font-size: 1.45em; font-weight: 700; line-height: 1.2; font-variant-numeric: tabular-nums; }
/* .kv: label and value pairs, such as a connection's details. One column in narrow boxes. */
.mema-ui .kv { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 6px 16px; }
.mema-ui .kv dt { color: var(--ui-muted); }
.mema-ui .kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
@container (max-width: 575.98px) {
  .mema-ui .kv { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .mema-ui .kv dd { margin-bottom: 8px; }
}
.mema-ui .empty { display: grid; justify-items: center; gap: 8px; padding: 28px 16px; border: 1px dashed var(--ui-line); border-radius: var(--ui-radius); color: var(--ui-muted); text-align: center; }
.mema-ui .spinner { display: inline-block; width: 1em; height: 1em; border: 2px solid var(--ui-line); border-top-color: var(--ui-primary); border-radius: 50%; vertical-align: -2px; animation: mema-ui-spin .8s linear infinite; }
@keyframes mema-ui-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .mema-ui .spinner { animation-duration: 2.4s; } }

/* 11. Menus, dialogs and type-ahead */
/* Row menu: <details class="menu"><summary class="btn btn-link btn-sm">⋯</summary><div class="menu-list">…</div></details> */
.mema-ui .menu { position: relative; display: inline-block; }
.mema-ui .menu > summary { list-style: none; }
.mema-ui .menu > summary::-webkit-details-marker { display: none; }
.mema-ui .menu-list { position: absolute; top: calc(100% + 4px); right: 0; z-index: 20; display: grid; min-width: 180px; padding: 4px; border: 1px solid var(--ui-line); border-radius: var(--ui-radius); background: var(--ui-bg); box-shadow: var(--ui-shadow); }
.mema-ui .menu-list > form { display: contents; }
.mema-ui .menu-list > a, .mema-ui .menu-list > button, .mema-ui .menu-list > form > button { display: block; width: 100%; padding: 7px 10px; border: 0; border-radius: 4px; background: none; color: var(--ui-fg); font: inherit; font-size: .93em; text-align: left; text-decoration: none; white-space: nowrap; cursor: pointer; }
.mema-ui .menu-list > :hover, .mema-ui .menu-list > form > button:hover { background: var(--ui-subtle); }
.mema-ui .menu-list > .danger { color: var(--ui-danger); }
/* Dialog: a native <dialog class="dialog"> inside .mema-ui, opened by a button with data-dialog="its id". */
.mema-ui .dialog { width: min(440px, calc(100vw - 32px)); padding: 0; border: 1px solid var(--ui-line); border-radius: 10px; background: var(--ui-bg); color: var(--ui-fg); box-shadow: 0 20px 50px rgba(15, 23, 42, .25); }
.mema-ui .dialog::backdrop { background: rgba(15, 23, 42, .45); }
.mema-ui .dialog-body { display: grid; gap: 10px; padding: 18px 18px 6px; }
.mema-ui .dialog-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; padding: 12px 18px 16px; }
/* Type-ahead: an input with a list of options under it. The module's script fills and filters the list. */
.mema-ui .combo { position: relative; }
.mema-ui .combo-list { position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 20; max-height: 240px; overflow-y: auto; margin: 0; padding: 4px; list-style: none; border: 1px solid var(--ui-line); border-radius: var(--ui-radius); background: var(--ui-bg); box-shadow: var(--ui-shadow); }
.mema-ui .combo-list [role="option"] { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 2px 10px; padding: 7px 10px; border-radius: 4px; cursor: pointer; }
.mema-ui .combo-list [role="option"]:hover, .mema-ui .combo-list [aria-selected="true"] { background: var(--ui-primary-soft); }

/* 12. Helpers */
.mema-ui .text-muted { color: var(--ui-muted); }
.mema-ui .small { font-size: .85em; }
.mema-ui .mono { font-family: var(--ui-mono); }
.mema-ui .num { font-variant-numeric: tabular-nums; }
.mema-ui .w-auto { width: auto; }
.mema-ui .visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
@container (max-width: 767.98px) { .mema-ui .hide-md { display: none !important; } }
@container (max-width: 575.98px) { .mema-ui .hide-sm { display: none !important; } }

/* 13. Module pages (Module Kit section 11): the title row's heading is mEMA blue. */
.mema-ui .mod-title { color: var(--ui-primary); }

/* 14. The page divs around the box (has-module) moved to css/mema/base.css in 0.6, with the rest of the page frame. */


/* 15. Icons: Mark's icon set (icons/mema/*.png, mostly 96 or 256 px, so sharp at these sizes on any screen).
   MemaModules::icon('toolbox') writes <img class="icon" src="icons/mema/toolbox.png" alt="" width="20" height="20">. */
.mema-ui .icon { display: inline-block; width: 1.25em; height: 1.25em; flex: none; object-fit: contain; vertical-align: -0.28em; }
.mema-ui .icon-sm { width: 1em; height: 1em; }
.mema-ui .icon-lg { width: 2em; height: 2em; }
/* Greyed out, for something disabled (WCAG doesn't ask disabled controls for contrast) */
.mema-ui .icon-muted { filter: grayscale(1); opacity: .5; }
/* Grey at full strength, for a toggle that's off but can be clicked (Save for later before it's saved) */
.mema-ui .icon-off { filter: grayscale(1); }
/* On a solid button Mark's colours vanish into the blue or red, so the icon is drawn white (his shape, a filter) */
.mema-ui :is(.btn-primary, .btn-danger) .icon { filter: brightness(0) invert(1); }
/* An input with an icon inside it, such as search */
.mema-ui .input-icon { position: relative; }
.mema-ui .input-icon > .icon { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--ui-muted); pointer-events: none; }
.mema-ui .input-icon > .input { padding-left: 34px; }

/* 16. Sidebar layout: a side menu and a main column from md up; stacked below. */
.mema-ui .layout-sidebar { display: grid; gap: 20px; }
.mema-ui .layout-sidebar > * { min-width: 0; }
@container (min-width: 768px) {
  .mema-ui .layout-sidebar { grid-template-columns: 210px minmax(0, 1fr); gap: 28px; align-items: start; }
  .mema-ui .layout-sidebar > :first-child { position: sticky; top: 12px; }
}

/* 17. Side menu: a vertical list of links with icons and counts. Below md it becomes a row of pills. */
.mema-ui .side-nav { display: grid; gap: 2px; }
.mema-ui .side-nav-label { padding: 14px 10px 4px; color: var(--ui-muted); font-size: .74em; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.mema-ui .side-nav a { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: var(--ui-radius); color: var(--ui-fg); font-weight: 500; text-decoration: none; }
.mema-ui .side-nav a:hover { background: var(--ui-subtle); }
.mema-ui .side-nav a > .icon { color: var(--ui-muted); }
.mema-ui .side-nav a[aria-current="page"] { background: var(--ui-primary-soft); color: var(--ui-primary); font-weight: 700; }
.mema-ui .side-nav a[aria-current="page"] > .icon { color: var(--ui-primary); }
.mema-ui .side-nav a > .count { margin-left: auto; }
@container (max-width: 767.98px) {
  .mema-ui .side-nav { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: thin; }
  .mema-ui .side-nav a { flex: none; padding: 5px 12px; border: 1px solid var(--ui-click-line); border-radius: 999px; }
  .mema-ui .side-nav .side-nav-label, .mema-ui .side-nav .side-nav-extra { display: none; }
}

/* 18. Cards: one item in a list, such as a post. The title link covers the whole card, so it has the
   clickable border; .card-static is a card that isn't a link (gray, no hover). */
.mema-ui .card { position: relative; display: grid; gap: 14px; padding: 16px 18px; border: 1px solid var(--ui-click-line); border-radius: 8px; background: var(--ui-bg); }
.mema-ui .card:hover { border-color: var(--ui-primary); background: #F7F9FD; box-shadow: 0 2px 10px rgba(53, 83, 148, .10); }
.mema-ui .card-static, .mema-ui .card-static:hover { border-color: var(--ui-line); background: var(--ui-bg); box-shadow: none; }
.mema-ui .card:focus-within { outline: 2px solid var(--ui-primary); outline-offset: 2px; }
.mema-ui .card-warn, .mema-ui .card-warn.card-static:hover { border-color: #E2B65F; background: #FFFCF4; }
.mema-ui .card-body { display: grid; gap: 6px; align-content: start; min-width: 0; }
.mema-ui .card-kicker { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; color: var(--ui-muted); font-size: .85em; }
.mema-ui .card-title { font-size: 1.12em; line-height: 1.3; }
.mema-ui .card-title a { color: var(--ui-fg); text-decoration: none; }
.mema-ui .card-title a::after { content: ""; position: absolute; inset: 0; border-radius: inherit; }
.mema-ui .card-title a:focus-visible { outline: none; }
/* A small button in the card's top line, such as Save. It sits above the title link that covers the card. */
.mema-ui .card-action { position: relative; z-index: 1; margin-left: auto; display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; padding: 0; border: 0; border-radius: var(--ui-radius); background: none; color: var(--ui-muted); cursor: pointer; }
.mema-ui .card-action:hover { background: var(--ui-subtle); color: var(--ui-fg); }
.mema-ui .card-action[aria-pressed="true"] { color: var(--ui-primary); }
.mema-ui .card-action[aria-pressed="false"] .icon { filter: grayscale(1); }
@media (pointer: coarse) { .mema-ui .card-action { width: 44px; height: 44px; } }
.mema-ui .card-text { color: var(--ui-muted); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.mema-ui .card-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; font-size: .88em; }
.mema-ui .card-more { margin-left: auto; display: inline-flex; align-items: center; gap: 4px; color: var(--ui-primary); font-weight: 600; }
.mema-ui .card-media { aspect-ratio: 16 / 10; overflow: hidden; border-radius: 6px; background: var(--ui-subtle); }
.mema-ui .card-media :is(img, svg) { display: block; width: 100%; height: 100%; object-fit: cover; }
@container (min-width: 576px) {
  .mema-ui .card-row { grid-template-columns: minmax(0, 1fr) 168px; align-items: start; }
}

/* 19. Pagination: page links with Previous and Next. Under 576px only Previous, "Page 2 of 5" and Next show. */
.mema-ui .pagination { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px; }
.mema-ui .pagination-info { color: var(--ui-muted); font-size: .88em; }
.mema-ui .pagination-pages { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
.mema-ui .pagination-pages > a, .mema-ui .pagination-pages > span { display: inline-flex; align-items: center; justify-content: center; gap: 4px; min-width: 34px; height: 34px; padding: 0 10px; border: 1px solid var(--ui-line); border-radius: var(--ui-radius); background: var(--ui-bg); color: var(--ui-fg); font-size: .92em; font-weight: 600; text-decoration: none; font-variant-numeric: tabular-nums; }
.mema-ui .pagination-pages > a { border-color: var(--ui-click-line); }
.mema-ui .pagination-pages > a:hover { border-color: var(--ui-primary); background: var(--ui-primary-soft); }
.mema-ui .pagination-pages > [aria-current="page"] { background: var(--ui-primary); border-color: var(--ui-primary); color: #FFFFFF; }
.mema-ui .pagination-pages > [aria-disabled="true"] { opacity: .45; cursor: not-allowed; }
.mema-ui .pagination-pages > .gap { min-width: 18px; padding: 0; border: 0; background: none; color: var(--ui-muted); }
.mema-ui .pagination-pages > .pagination-now { display: none; border: 0; background: none; color: var(--ui-muted); font-weight: 500; }
@container (max-width: 575.98px) {
  .mema-ui .pagination-pages > .page-num, .mema-ui .pagination-pages > .gap { display: none; }
  .mema-ui .pagination-pages > .pagination-now { display: inline-flex; }
  .mema-ui .pagination-info { display: none; }
  .mema-ui .pagination-pages { width: 100%; justify-content: space-between; }
}

/* 20. Breadcrumb */
.mema-ui .breadcrumb { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 0; padding: 0; list-style: none; color: var(--ui-muted); font-size: .88em; }
.mema-ui .breadcrumb li { display: inline-flex; align-items: center; gap: 6px; }
.mema-ui .breadcrumb li + li::before { content: "\203A"; color: var(--ui-muted); }
.mema-ui .breadcrumb [aria-current="page"] { color: var(--ui-fg); }

/* 21. Prose: long-form content from the Content module (posts, pages, terms). */
.mema-ui .prose { font-size: 1.03em; line-height: 1.65; }
.mema-ui .prose-narrow { max-width: 70ch; }        /* opt-in reading width, about 70 characters a line */
.mema-ui .prose > * + * { margin-top: 1em; }
.mema-ui .prose > :first-child { margin-top: 0; }
.mema-ui .prose > :where(h2) { margin-top: 1.7em; font-size: 1.32em; }
.mema-ui .prose > :where(h3) { margin-top: 1.4em; font-size: 1.12em; }
.mema-ui .prose > :where(h2, h3, h4) + * { margin-top: .45em; }
.mema-ui .prose :where(li + li) { margin-top: .3em; }
.mema-ui .prose :where(a) { text-decoration: underline; text-underline-offset: 2px; }
.mema-ui .prose :where(blockquote) { margin: 0; padding: 2px 0 2px 16px; border-left: 3px solid var(--ui-line); color: var(--ui-muted); }
.mema-ui .prose :where(hr) { margin: 2em 0; border: 0; border-top: 1px solid var(--ui-line); }
.mema-ui .prose :where(figure) { margin: 1.4em 0; }
.mema-ui .prose figure > :where(img, svg) { display: block; max-width: 100%; height: auto; border: 1px solid var(--ui-line); border-radius: 6px; }
.mema-ui .prose :where(figcaption) { margin-top: 6px; color: var(--ui-muted); font-size: .86em; }
.mema-ui .prose :where(table) { width: 100%; font-size: .94em; }
.mema-ui .prose :where(th, td) { padding: 7px 10px; border-bottom: 1px solid var(--ui-line); }
.mema-ui .prose :where(th) { background: var(--ui-subtle); font-size: .85em; }
.mema-ui .prose .embed { max-width: 800px; aspect-ratio: 16 / 9; overflow: hidden; border-radius: 6px; background: #0F172A; }
.mema-ui .prose .embed iframe { width: 100%; height: 100%; border: 0; }
.mema-ui .prose .lead { color: var(--ui-muted); font-size: 1.1em; }

/* 22. Callout: a highlighted note inside content. Tones match the alerts. */
.mema-ui .callout { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 2px 12px; align-items: start; padding: 12px 14px; border-radius: var(--ui-radius); background: var(--ui-primary-soft); }
.mema-ui .callout > .icon { margin-top: .2em; color: var(--ui-primary); }
.mema-ui .callout-title { font-weight: 700; }
.mema-ui .callout-ok { background: var(--ui-ok-soft); }      .mema-ui .callout-ok > .icon { color: var(--ui-ok); }
.mema-ui .callout-warn { background: var(--ui-warn-soft); }  .mema-ui .callout-warn > .icon { color: var(--ui-warn); }
.mema-ui .callout-danger { background: var(--ui-danger-soft); } .mema-ui .callout-danger > .icon { color: var(--ui-danger); }
/* Icon list: rows of an icon and a line of text, the modern take on the old [icn ...] feature lists */
.mema-ui .icon-list { display: grid; gap: 10px; padding: 0; list-style: none; }
.mema-ui .icon-list li { display: grid; grid-template-columns: 32px minmax(0, 1fr); gap: 12px; align-items: start; }
.mema-ui .icon-list li > .icon { width: 32px; height: 32px; padding: 7px; border-radius: 8px; background: var(--ui-primary-soft); color: var(--ui-primary); }
/* Thumbnails: a grid of images with a caption, such as the media library */
.mema-ui .thumb { display: grid; gap: 6px; padding: 8px; border: 1px solid var(--ui-line); border-radius: 8px; background: var(--ui-bg); font-size: .85em; }
.mema-ui .thumb-img { aspect-ratio: 4 / 3; overflow: hidden; border-radius: 5px; background: var(--ui-subtle); }
.mema-ui .thumb-img :is(img, svg) { display: block; width: 100%; height: 100%; object-fit: cover; }
.mema-ui .thumb[aria-selected="true"] { border-color: var(--ui-primary); box-shadow: 0 0 0 2px var(--ui-primary-soft); }
