/* TBi3 clinic platform: design tokens, v1.
   Written by _build/tokens_build.py from one table. Do not edit by hand: change the table and run it.
   The build stops when a pair of colours that must be readable is not.

   One brand, two themes, three tunings.
   Themes    day and night. The device decides; data-theme="light" or "dark" on <html> overrides it.
             Day is the TBI3 Screening app: ink #241B3D and action blue #1F56CF on a tinted plate.
             Night is tbi3.com and the attorney portal: the void, bone words, the cyan signal.
   Tunings   the default (staff), data-role="tech" and data-role="patient" on <body>. See section 4.

   Every colour of the platform is named here, on :root, and no other file names a colour.
   A colour means one thing:
     primary and link (blue)     something that can be pressed next
     the trace (sky to violet)   how far along a visit is, and nothing else
     the four status pairs       the status of a test value, and nothing else
     danger (red)                STOP, an error, what cannot be undone
     ok (green)                  stored: the tick the procedure tells the technician to look for
*/

/* ---- 1. The same in both themes ---------------------------------------------------------------- */

:root {
  /* The logo's own colours, from brand sheet v12. Listed as the source; screens use the roles below. */
  --brand-sky: #00A6EE;
  --brand-bright: #1279E6;
  --brand-royal: #2A5AE0;
  --brand-indigo: #4F2FDB;
  --brand-violet: #6F00DA;
  --brand-deep: #3D0078;
  --brand-ink: #241B3D;
  --brand-bone: #ECE9E1;
  --brand-void: #050609;

  /* Type. System fonts only: the policy lets nothing be loaded from another site.
     --font-title is the slot for a licensed brand face served from the platform's own address.
     --font-record is for the words of the record: what the patient said, what the neurologist writes. */
  --font-ui: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-title: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-record: Charter, "Bitstream Charter", "Sitka Text", Cambria, "Noto Serif", Georgia, serif;
  --font-mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;

  /* The type scale. Sizes are rem, so a larger text size set in the browser is kept. */
  --t-micro: 0.8125rem;    /* 13  column heads, figures under a trace. The smallest size there is */
  --t-small: 0.875rem;     /* 14  a hint, a second line */
  --t-body: 1rem;          /* 16  words */
  --t-lead: 1.125rem;      /* 18  an instruction, a lede */
  --t-h3: 1.0625rem;       /* 17  a group inside a section */
  --t-h2: 1.375rem;        /* 22  a section */
  --t-h1: 1.875rem;        /* 30  one on a page (26 on a phone) */
  --t-display: 3rem;       /* 48  the sign-in title only (36 on a phone) */
  --t-reading: 1.75rem;    /* 28  a number typed by hand */
  --t-count: 2.5rem;       /* 40  a count the page reports */
  --t-clock: 3.5rem;       /* 56  a running timer */
  --leading: 1.5;
  --measure: 72ch;         /* the longest line of running text: 70 to 90 characters */

  /* Space: a 4px grid. --s1 to --s6 are the steps of interface kit v0.2, unchanged. */
  --s1: 4px;
  --s2: 8px;
  --s3: 12px;
  --s4: 16px;
  --s5: 24px;
  --s6: 32px;
  --s7: 48px;
  --s8: 64px;
  --gutter: 16px;          /* the page's side margin: 12 under 360px, 24 from 768px, 32 from 1200px */

  /* Corners. Nothing is a pill. */
  --r-xs: 2px;             /* a segment of a trace, a status mark */
  --r-sm: 6px;             /* a cell, a tick box */
  --r: 10px;               /* every control */
  --r-lg: 16px;            /* a region, a dialog */

  /* Sizes of things a hand touches. */
  --target: 48px;          /* the smallest thing a finger is asked to hit, in every tuning */
  --control: 48px;         /* the height of a control in this tuning */
  --control-lg: 56px;      /* the height of the main action in this tuning */
  --page-max: 77rem;

  /* What is pinned to the top and the bottom of the screen. A page sets these when it pins a bar,
     and the browser then keeps a focused control clear of it (scroll-padding in components.css). */
  --pin-top: 0px;
  --pin-bottom: 0px;

  /* Motion: a change of colour, and one busy mark. Nothing else moves. */
  --quick: 120ms;
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);

  /* Layers, lowest first. A dialog is in the browser's own top layer and needs no number. */
  --z-raised: 1;
  --z-actionbar: 10;
  --z-frame: 40;
  --z-toast: 60;
  --z-skip: 70;
}

/* ---- 2. Day ------------------------------------------------------------------------------------ */

:root {
  color-scheme: light;

  /* Surfaces. One plate. The lightest surface (key) is only for what a hand can press or type into. A number the page reports sits in a well. */
  --page: #ECEAF4;  /* the plate: the page itself. Words, lists and tables sit straight on it */
  --page-deep: #ECEAF4;  /* the sign-in page: the plate by day, the void of tbi3.com by night */
  --panel: #F5F4FA;  /* a grouped region: a form, a notice. One step lighter than the plate */
  --key: #FFFFFF;  /* fields, options, plain buttons: what a hand can press or type into */
  --key-hover: #F1EFF8;  /* a key under the pointer; a row under the pointer */
  --key-press: #E3E1EE;  /* a key held down; the current page in the menu */
  --well: #DFDDEA;  /* sunken: a count, a timer, a switched-off control */
  --bar: #FFFFFF;  /* the top bar and the visit bar. By night it is the void of tbi3.com */
  --float: #FFFFFF;  /* dialog and sheet: the only layers that float */
  --line: #D5D3E0;  /* hairline: dividers and the outline of a region. Never the edge of a control */
  --rule: #241B3D;  /* the 2px rule that opens a section */
  --edge: #7B7890;  /* the edge of anything that can be pressed: 3 to 1 or more on every surface */

  /* Words. */
  --text: #1A172C;  /* words. By night the bone of tbi3.com */
  --text-2: #54516A;  /* second-rank words: 4.5 to 1 or more on every surface */
  --title: #241B3D;  /* titles and readings: the brand ink by day, bone by night */

  /* The main action: the one thing to press next. Blue with a white label in both themes, as in the TBI3 Screening app. */
  --primary: #1F56CF;  /* fill of the one main action */
  --primary-hover: #1A49B0;
  --primary-press: #153B8F;
  --on-primary: #FFFFFF;  /* words on the main action */
  --link: #1F56CF;  /* action as words or as a line: a link, a quiet button, the open step. By night the cyan of tbi3.com */
  --tint: #E2E8FA;  /* the tint behind the open step, and behind a chosen answer on a patient page */
  --ring: #1F56CF;  /* the focus ring */

  /* A chosen answer on a staff page is filled with ink, so that blue stays the colour of the next action. */
  --chosen: #241B3D;  /* fill of a chosen answer (staff and technician) */
  --on-chosen: #FFFFFF;

  /* Danger: STOP, an error, what cannot be undone. A solid danger fill is for a control or the STOP sheet only. */
  --danger: #B42318;  /* fill */
  --danger-hover: #9A1C12;
  --danger-press: #7F160D;
  --on-danger: #FFFFFF;
  --danger-text: #B42318;  /* an error said in words, and its edge */

  /* Stored: the green tick the procedure tells the technician to look for. */
  --ok: #215B24;  /* the tick on a stored file */
  --on-ok: #FFFFFF;

  /* The report's four status pairs. The status of a test value and nothing else. Day: the printed values, unchanged. */
  --green-fill: #D9EAD3;
  --green-text: #215B24;
  --green-edge: #9DC193;  /* the edge of the cell, in its own hue */
  --green-key: #215B24;  /* the shape mark. By night it is the printed fill, so the page's own colour is on screen */
  --yellow-fill: #FFF2CC;
  --yellow-text: #6C4B00;
  --yellow-edge: #D4B65C;
  --yellow-key: #6C4B00;
  --red-fill: #F4CCCC;
  --red-text: #9C1C1C;
  --red-edge: #D38C8C;
  --red-key: #9C1C1C;
  --gray-fill: #E7E7E7;
  --gray-text: #404040;
  --gray-edge: #A9A9A9;
  --gray-key: #404040;

  /* The trace: how far along a visit is, and nothing else. Ten flat colours along the logo's run. No gradient is drawn anywhere. */
  --trace-0: #0080CC;
  --trace-1: #077DD8;
  --trace-2: #107AE3;
  --trace-3: #1D6FE4;
  --trace-4: #2661E1;
  --trace-5: #3652DF;
  --trace-6: #4640DD;
  --trace-7: #532CDB;
  --trace-8: #621EDA;
  --trace-9: #6F00DA;
  --track: #86839A;  /* the part of a trace not reached yet (drawn thinner, so it never depends on colour) */
  --on-trace: #FFFFFF;  /* the tick inside a bead of the trace */

  /* Fixed pieces. */
  --demo: #3D0078;  /* the demonstration strip: the logo's deep purple by day, the site's violet by night */
  --on-demo: #FFFFFF;
  --inverse: #241B3D;  /* a toast */
  --on-inverse: #ECE9E1;
  --inverse-edge: #241B3D;
  --inverse-danger: #FF9285;  /* the edge of a toast that reports an error */
  --scrim: rgba(16, 12, 30, 0.62);  /* behind a dialog */
  --paper: #FFFFFF;  /* white in both themes: behind a QR picture, so a phone can read it */
  --on-paper: #111111;

  /* Not colours: which logo file shows. The colour logo by day, the white one by night, as the logo package directs. */
  --logo-day: block;
  --logo-night: none;
  --logo-alone: none;  /* a colour logo shipped alone is shown in white by night */

  /* The calm key: a patient page. Nothing is pure white or pure black, no fill is bright, and the action is softened by night. */
  --calm-page: #E7E6F0;
  --calm-panel: #EEEDF5;
  --calm-key: #F4F3F9;
  --calm-key-hover: #E9E8F2;
  --calm-key-press: #DEDDE9;
  --calm-well: #DCDBE7;
  --calm-line: #D0CEDC;
  --calm-rule: #2B2742;
  --calm-edge: #74718A;
  --calm-text: #2B2742;
  --calm-text-2: #524F66;
  --calm-primary: #1F56CF;
  --calm-primary-hover: #1A49B0;
  --calm-primary-press: #153B8F;
  --calm-link: #1F56CF;
  --calm-tint: #DCE3F7;
  --calm-danger: #B42318;
  --calm-danger-text: #B42318;
  --calm-demo: #3D0078;
  --calm-track: #7F7C94;

  /* Names of interface kit v0.2 whose value differs by theme. Day: the v0.2 values. Night: light, so that var(--white) words on them stay readable. New work does not use them. */
  --action: #1F56CF;
  --action-hover: #1A49B0;
  --action-active: #153B8F;
  --action-soft: #DFE8F8;
  --error: #B42318;
  --error-hover: #912018;
  --error-active: #7A1A13;
}

/* ---- 3. Night ---------------------------------------------------------------------------------- */
/* Written twice: once for the device setting, once for data-theme="dark". Both come from the one
   table and are identical. They are inside "screen", so a page always prints with the day values. */

@media screen and (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;

    /* Surfaces. One plate. The lightest surface (key) is only for what a hand can press or type into. A number the page reports sits in a well. */
    --page: #0A0910;
    --page-deep: #050609;
    --panel: #12111B;
    --key: #1B1926;
    --key-hover: #242231;
    --key-press: #2D2B3B;
    --well: #050609;
    --bar: #050609;
    --float: #1E1C2A;
    --line: #2A2837;
    --rule: #8E8AA3;
    --edge: #77738D;

    /* Words. */
    --text: #ECE9E1;
    --text-2: #B7B4AE;
    --title: #ECE9E1;

    /* The main action: the one thing to press next. Blue with a white label in both themes, as in the TBI3 Screening app. */
    --primary: #2F62E8;
    --primary-hover: #3B6DF0;
    --primary-press: #2A58D6;
    --on-primary: #FFFFFF;
    --link: #16B8F3;
    --tint: #14203F;
    --ring: #16B8F3;

    /* A chosen answer on a staff page is filled with ink, so that blue stays the colour of the next action. */
    --chosen: #D8D5CC;
    --on-chosen: #14121C;

    /* Danger: STOP, an error, what cannot be undone. A solid danger fill is for a control or the STOP sheet only. */
    --danger: #C8372B;
    --danger-hover: #BC3227;
    --danger-press: #B02D23;
    --on-danger: #FFFFFF;
    --danger-text: #FF9285;

    /* Stored: the green tick the procedure tells the technician to look for. */
    --ok: #8BD08F;
    --on-ok: #0A0910;

    /* The report's four status pairs. The status of a test value and nothing else. Day: the printed values, unchanged. */
    --green-fill: #17301A;
    --green-text: #BFE5B5;
    --green-edge: #35603A;
    --green-key: #D9EAD3;
    --yellow-fill: #352B0B;
    --yellow-text: #F5DC8C;
    --yellow-edge: #6B5A1D;
    --yellow-key: #FFF2CC;
    --red-fill: #3A1618;
    --red-text: #F6B9B9;
    --red-edge: #7A3432;
    --red-key: #F4CCCC;
    --gray-fill: #28262F;
    --gray-text: #D3D1DA;
    --gray-edge: #57546A;
    --gray-key: #E7E7E7;

    /* The trace: how far along a visit is, and nothing else. Ten flat colours along the logo's run. No gradient is drawn anywhere. */
    --trace-0: #16B8F3;
    --trace-1: #2EABF5;
    --trace-2: #3B9EF7;
    --trace-3: #4A94F8;
    --trace-4: #578BF9;
    --trace-5: #6483FB;
    --trace-6: #727DFC;
    --trace-7: #7D76FC;
    --trace-8: #846DF6;
    --trace-9: #8A63F0;
    --track: #686582;
    --on-trace: #0A0910;

    /* Fixed pieces. */
    --demo: #6A35E8;
    --on-demo: #FFFFFF;
    --inverse: #2A2838;
    --on-inverse: #ECE9E1;
    --inverse-edge: #77738D;
    --inverse-danger: #FF9285;
    --scrim: rgba(0, 0, 0, 0.72);
    --paper: #FFFFFF;
    --on-paper: #111111;

    /* Not colours: which logo file shows. The colour logo by day, the white one by night, as the logo package directs. */
    --logo-day: none;
    --logo-night: block;
    --logo-alone: brightness(0) invert(1);

    /* The calm key: a patient page. Nothing is pure white or pure black, no fill is bright, and the action is softened by night. */
    --calm-page: #100F18;
    --calm-panel: #171620;
    --calm-key: #1F1E2A;
    --calm-key-hover: #282735;
    --calm-key-press: #312F3F;
    --calm-well: #0A0911;
    --calm-line: #2E2D3B;
    --calm-rule: #8B8899;
    --calm-edge: #7B7892;
    --calm-text: #D4D1C8;
    --calm-text-2: #A8A59E;
    --calm-primary: #4063C0;
    --calm-primary-hover: #4A6DC9;
    --calm-primary-press: #3757AE;
    --calm-link: #8FC3E3;
    --calm-tint: #1D2942;
    --calm-danger: #B5382E;
    --calm-danger-text: #F0958A;
    --calm-demo: #4B3BA6;
    --calm-track: #6B6884;

    /* Names of interface kit v0.2 whose value differs by theme. Day: the v0.2 values. Night: light, so that var(--white) words on them stay readable. New work does not use them. */
    --action: #16B8F3;
    --action-hover: #5CCBF7;
    --action-active: #8AD9F9;
    --action-soft: #14203F;
    --error: #FF9285;
    --error-hover: #FFA79C;
    --error-active: #FFBBB2;
  }
}

@media screen {
  :root[data-theme="dark"] {
    color-scheme: dark;

    /* Surfaces. One plate. The lightest surface (key) is only for what a hand can press or type into. A number the page reports sits in a well. */
    --page: #0A0910;
    --page-deep: #050609;
    --panel: #12111B;
    --key: #1B1926;
    --key-hover: #242231;
    --key-press: #2D2B3B;
    --well: #050609;
    --bar: #050609;
    --float: #1E1C2A;
    --line: #2A2837;
    --rule: #8E8AA3;
    --edge: #77738D;

    /* Words. */
    --text: #ECE9E1;
    --text-2: #B7B4AE;
    --title: #ECE9E1;

    /* The main action: the one thing to press next. Blue with a white label in both themes, as in the TBI3 Screening app. */
    --primary: #2F62E8;
    --primary-hover: #3B6DF0;
    --primary-press: #2A58D6;
    --on-primary: #FFFFFF;
    --link: #16B8F3;
    --tint: #14203F;
    --ring: #16B8F3;

    /* A chosen answer on a staff page is filled with ink, so that blue stays the colour of the next action. */
    --chosen: #D8D5CC;
    --on-chosen: #14121C;

    /* Danger: STOP, an error, what cannot be undone. A solid danger fill is for a control or the STOP sheet only. */
    --danger: #C8372B;
    --danger-hover: #BC3227;
    --danger-press: #B02D23;
    --on-danger: #FFFFFF;
    --danger-text: #FF9285;

    /* Stored: the green tick the procedure tells the technician to look for. */
    --ok: #8BD08F;
    --on-ok: #0A0910;

    /* The report's four status pairs. The status of a test value and nothing else. Day: the printed values, unchanged. */
    --green-fill: #17301A;
    --green-text: #BFE5B5;
    --green-edge: #35603A;
    --green-key: #D9EAD3;
    --yellow-fill: #352B0B;
    --yellow-text: #F5DC8C;
    --yellow-edge: #6B5A1D;
    --yellow-key: #FFF2CC;
    --red-fill: #3A1618;
    --red-text: #F6B9B9;
    --red-edge: #7A3432;
    --red-key: #F4CCCC;
    --gray-fill: #28262F;
    --gray-text: #D3D1DA;
    --gray-edge: #57546A;
    --gray-key: #E7E7E7;

    /* The trace: how far along a visit is, and nothing else. Ten flat colours along the logo's run. No gradient is drawn anywhere. */
    --trace-0: #16B8F3;
    --trace-1: #2EABF5;
    --trace-2: #3B9EF7;
    --trace-3: #4A94F8;
    --trace-4: #578BF9;
    --trace-5: #6483FB;
    --trace-6: #727DFC;
    --trace-7: #7D76FC;
    --trace-8: #846DF6;
    --trace-9: #8A63F0;
    --track: #686582;
    --on-trace: #0A0910;

    /* Fixed pieces. */
    --demo: #6A35E8;
    --on-demo: #FFFFFF;
    --inverse: #2A2838;
    --on-inverse: #ECE9E1;
    --inverse-edge: #77738D;
    --inverse-danger: #FF9285;
    --scrim: rgba(0, 0, 0, 0.72);
    --paper: #FFFFFF;
    --on-paper: #111111;

    /* Not colours: which logo file shows. The colour logo by day, the white one by night, as the logo package directs. */
    --logo-day: none;
    --logo-night: block;
    --logo-alone: brightness(0) invert(1);

    /* The calm key: a patient page. Nothing is pure white or pure black, no fill is bright, and the action is softened by night. */
    --calm-page: #100F18;
    --calm-panel: #171620;
    --calm-key: #1F1E2A;
    --calm-key-hover: #282735;
    --calm-key-press: #312F3F;
    --calm-well: #0A0911;
    --calm-line: #2E2D3B;
    --calm-rule: #8B8899;
    --calm-edge: #7B7892;
    --calm-text: #D4D1C8;
    --calm-text-2: #A8A59E;
    --calm-primary: #4063C0;
    --calm-primary-hover: #4A6DC9;
    --calm-primary-press: #3757AE;
    --calm-link: #8FC3E3;
    --calm-tint: #1D2942;
    --calm-danger: #B5382E;
    --calm-danger-text: #F0958A;
    --calm-demo: #4B3BA6;
    --calm-track: #6B6884;

    /* Names of interface kit v0.2 whose value differs by theme. Day: the v0.2 values. Night: light, so that var(--white) words on them stay readable. New work does not use them. */
    --action: #16B8F3;
    --action-hover: #5CCBF7;
    --action-active: #8AD9F9;
    --action-soft: #14203F;
    --error: #FF9285;
    --error-hover: #FFA79C;
    --error-active: #FFBBB2;
  }
}

/* ---- 4. Tunings -------------------------------------------------------------------------------- */
/* A tuning changes the size of words and of controls, and (for a patient) the key. It never changes
   the logo, the trace, the meaning of a colour, the shape of a control or the name of a class.

              words   hints   control   main action   key     who
   default    16      14      48        56            crisp   front desk, administrator, neurologist, sign-in
   tech       17      15      56        64            crisp   one hand on a tablet, eyes on the patient
   patient    18      16      60        60            calm    an injured adult on their own phone

   Set it on <body>: data-role="tech" or data-role="patient". A patient page also carries the class
   "patient" on <html> (ui.js sets it), which makes its root size 17px as in interface kit v0.2. */

[data-role="tech"] {
  --t-small: 0.9375rem;    /* 15: limits and targets are read at arm's length */
  --t-body: 1.0625rem;     /* 17 */
  --t-lead: 1.1875rem;     /* 19 */
  --t-h3: 1.125rem;        /* 18 */
  --t-h2: 1.5rem;          /* 24 */
  --t-h1: 2rem;            /* 32 (28 on a phone) */
  --t-reading: 2.4375rem;  /* 39 */
  --t-count: 2.75rem;      /* 44 */
  --t-clock: 3.5rem;       /* 56 on a phone; 72 from 768px (set in components.css) */
  --leading: 1.4;
  --control: 56px;
  --control-lg: 64px;
}

:root.patient,
[data-role="patient"] {
  --t-micro: 0.8125rem;    /* 14 at the 17px root */
  --t-small: 0.9375rem;    /* 16 */
  --t-body: 1.0625rem;     /* 18 */
  --t-lead: 1.1875rem;     /* 20 */
  --t-h3: 1.125rem;        /* 19 */
  --t-h2: 1.375rem;        /* 23 */
  --t-h1: 2rem;            /* 34 (30 on a phone) */
  --leading: 1.6;
  --measure: 34rem;
  --control: 3.5rem;       /* 60 at the 17px root */
  --control-lg: 3.5rem;

  /* the calm key */
  --page: var(--calm-page);
  --panel: var(--calm-panel);
  --key: var(--calm-key);
  --key-hover: var(--calm-key-hover);
  --key-press: var(--calm-key-press);
  --well: var(--calm-well);
  --bar: var(--calm-panel);
  --float: var(--calm-key);
  --line: var(--calm-line);
  --rule: var(--calm-rule);
  --edge: var(--calm-edge);
  --text: var(--calm-text);
  --text-2: var(--calm-text-2);
  --title: var(--calm-text);
  --primary: var(--calm-primary);
  --primary-hover: var(--calm-primary-hover);
  --primary-press: var(--calm-primary-press);
  --link: var(--calm-link);
  --tint: var(--calm-tint);
  --ring: var(--calm-link);
  --danger: var(--calm-danger);
  --danger-text: var(--calm-danger-text);
  --demo: var(--calm-demo);
  --track: var(--calm-track);
  /* a chosen answer is a tint with a doubled edge and heavier words, never a bright block */
  --chosen: var(--calm-tint);
  --on-chosen: var(--calm-text);
  /* the v0.2 names that differ by theme follow the calm key too */
  --action: var(--calm-link);
  --action-hover: var(--calm-link);
  --action-active: var(--calm-link);
  --action-soft: var(--calm-tint);
  --error: var(--calm-danger-text);
  --error-hover: var(--calm-danger-text);
  --error-active: var(--calm-danger-text);
}

/* ---- 5. Worked out from the roles, and the other names of interface kit v0.2 -------------------- */
/* Declared again in every tuning, so that each name follows the roles of the place it is used in.
   The v0.2 names are kept so that a page stylesheet written against app.css keeps its layout, its
   colours and its focus ring in both themes on the day this file replaces the old tokens.
   --s1 to --s6, --r-sm, --r, --r-lg, --target, --page-max, --text, --line, --action and the eight
   status names keep their names; --focus is still a whole outline. New work uses the names of
   sections 2 to 4. */

:root,
[data-role] {
  --focus: 3px solid var(--ring);       /* outline: var(--focus) */
  --ink: var(--title);
  --surface: var(--page);
  --white: var(--key);                  /* v0.2 used it for a panel and for words on a fill */
  --muted: var(--text-2);
  --backdrop: var(--scrim);
  --font: var(--font-ui);
  --mono: var(--font-mono);
}
/* TBi3 clinic platform: components, v1.
   One stylesheet for every page: patient, technician, neurologist, front desk, administrator.
   It is put together from _build/css/*.css by _build/build.py. Change the parts, not this file.

   Rules that hold everywhere. Follow them when you add a part.
   1. No colour is named here. Every colour is a token of tokens.css.
   2. Words sit on --page, --panel, --key or --well, in --text, --text-2 or --title. On a fill
      (primary, danger, chosen, a status pair, the demonstration strip) use that fill's own "on" colour.
   3. --line is for dividers. The edge of anything that can be pressed is --edge (3 to 1 or more).
   4. The lightest surface (--key) is only for what a hand can press or type into.
   5. A status pair is the status of a test value. Where a visit stands is .standing, never a pair.
   6. No shadow, no gradient, no blur. Depth is a step of tone and an edge.
   7. Hover styles sit inside @media (hover: hover). Every target is 48px in both directions.
   8. The policy forbids style attributes: a size or a state is a class or an attribute.

   Breakpoints (min-width, written in em so that they follow the text size a person has set in
   the browser; at the usual 16px they are): 30em = 480px a large phone, 37.5em = 600px a table
   unfolds, 48em = 768px a tablet, 56.25em = 900px the menu sits in the bar and a working screen
   takes two columns, 75em = 1200px three columns.
*/

/* ---- 1. Base ---------------------------------------------------------------------------------- */

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

/* Staff pages read at 16px. A patient page (class "patient" on <html>) has a 17px root.
   Percentages keep a larger text size the person has set in the browser.
   The scroll padding keeps a focused control and a link target clear of what is pinned. */
html {
  font-size: 100%;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-padding-top: calc(var(--pin-top) + 12px);
  scroll-padding-bottom: calc(var(--pin-bottom) + 12px);
}

html.patient {
  font-size: 106.25%;
}

:root:has(.demo-banner:not([hidden])) {
  --pin-top: 44px;
}

:root:has(.frame) {
  --pin-top: 100px;
}

:root:has(.action-bar) {
  --pin-bottom: 92px;
}

body {
  margin: 0;
  background: var(--page);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: var(--t-body);
  line-height: var(--leading);
  overflow-wrap: break-word;
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3,
h4,
p,
ul,
ol,
dl,
dd,
figure,
fieldset,
pre {
  margin: 0;
}

fieldset {
  min-width: 0;
  padding: 0;
  border: 0;
}

h1,
h2,
h3,
h4 {
  color: var(--title);
  font-family: var(--font-title);
  line-height: 1.2;
  letter-spacing: -0.015em;
  text-wrap: balance;
}

h1 {
  font-size: calc(var(--t-h1) * 0.875);
  font-weight: 700;
  letter-spacing: -0.02em;
}

h2 {
  font-size: var(--t-h2);
  font-weight: 700;
}

h3,
h4 {
  font-size: var(--t-h3);
  font-weight: 600;
  letter-spacing: -0.005em;
}

@media (min-width: 48em) {
  h1 {
    font-size: var(--t-h1);
  }
}

a {
  color: var(--link);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

@media (hover: hover) {
  a:hover {
    text-decoration-thickness: 2px;
  }
}

img,
svg {
  max-width: 100%;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

[hidden] {
  display: none !important;
}

:focus-visible {
  outline: var(--focus);
  outline-offset: 2px;
}

/* ---- 2. Words --------------------------------------------------------------------------------- */

.lede {
  max-width: 44rem;
  font-size: var(--t-lead);
}

.hint,
.muted {
  color: var(--text-2);
}

.hint {
  font-size: var(--t-small);
}

.strong {
  font-weight: 600;
}

/* Figures line up in columns: every reading, clock and count takes this. */
.num {
  font-variant-numeric: tabular-nums;
}

/* A record number, a file name, a code, a fingerprint: things where 0 and O must not be mixed up.
   Never a label, never a sentence. */
code,
kbd,
samp {
  font-family: var(--font-mono);
  font-size: inherit;
}

.mono {
  font-family: var(--font-mono);
  font-size: 0.9375em;
  font-variant-numeric: tabular-nums;
}

.nowrap {
  white-space: nowrap;
}

/* The words of the record: what the patient said, what the neurologist wrote. Set in the record
   face, so nobody takes them for the tool talking. Never a title, a label or a control. */
.record {
  font-family: var(--font-record);
  font-size: 1.0625em;
  line-height: 1.6;
}

/* Running text: paragraphs and lists written one after another. */
.prose {
  max-width: var(--measure);
}

.prose > * + * {
  margin-top: 0.75em;
}

.prose ul,
.prose ol,
.plain-list {
  padding-left: 1.25rem;
}

.prose li + li,
.plain-list li + li {
  margin-top: 0.35em;
}

/* An icon drawn in the page as an inline <svg class="i">: 20px, one stroke, the colour of the words. */
.i {
  display: inline-block;
  flex: 0 0 auto;
  width: 1.25em;
  height: 1.25em;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: butt;
  stroke-linejoin: miter;
  vertical-align: -0.25em;
}

/* ---- 3. Page frame ---------------------------------------------------------------------------- */

.skip {
  position: absolute;
  left: var(--s2);
  top: -200px;
  z-index: var(--z-skip);
  display: inline-flex;
  align-items: center;
  min-height: var(--target);
  padding: 0 var(--s4);
  border-radius: var(--r);
  background: var(--inverse);
  color: var(--on-inverse);
  font-weight: 600;
}

.skip:focus {
  top: var(--s2);
  outline-color: var(--on-inverse);
  outline-offset: -5px;
}

/* The demonstration strip. Shown on every page of a demonstration server, and it stays in view
   while the page scrolls. It is violet in both themes and nothing else on the platform is, so it
   cannot be taken for a status, a warning or part of the record.
   The second sentence sits in <span class="demo-more">: a small phone shows one line, and a screen
   reader still says both. */
.demo-banner {
  position: sticky;
  top: 0;
  z-index: var(--z-frame);
  padding: 3px var(--gutter);
  background: var(--demo);
  color: var(--on-demo);
  font-size: var(--t-micro);
  font-weight: 600;
  line-height: 1.4;
  text-align: center;
  print-color-adjust: exact;
  -webkit-print-color-adjust: exact;
}

@media (max-width: 29.99em) {
  .demo-more {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }
}

/* The top bar: the logo, the menu for the person's roles, who is signed in, My account, Sign out.
   This is the structure ui.js builds; nothing in it is restyled by a page. */
.topbar-bar {
  border-bottom: 1px solid var(--line);
  background: var(--bar);
}

.topbar-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0 var(--s3);
  min-height: 56px;
  max-width: var(--page-max);
  margin: 0 auto;
  padding: var(--s1) var(--gutter);
}

/* The logo. Two files, the colour one for day and the white one for night; the tokens show one.
   Never on a tile, never redrawn, never followed by a registered or trademark sign. Clear space
   around it is at least the height of the dot of the i. */
.brand {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 10px;
  min-height: var(--target);
  margin-right: var(--s2);
  border-radius: var(--r-sm);
  color: var(--text-2);
  font-size: var(--t-small);
  font-weight: 500;
  text-decoration: none;
}

.brand img,
.logo {
  display: block;
  width: auto;
  height: 28px;
}

img.logo-day {
  display: var(--logo-day);
}

img.logo-night {
  display: var(--logo-night);
}

/* Until a page ships both files: one colour logo alone is shown in white by night. The white file
   holds the same six shapes in white, so the picture is the same as logo-white.svg. */
.brand img:only-of-type,
img.signin-logo:only-of-type {
  filter: var(--logo-alone);
}

/* The right end of the bar while the menu is folded: who is signed in, and the Menu button. */
.topbar-end {
  display: flex;
  flex: 1 1 0;
  align-items: center;
  justify-content: flex-end;
  gap: var(--s3);
  min-width: 0;
  margin-left: auto;
}

.topbar-end > .btn {
  flex: 0 0 auto;
}

/* The Menu button: three bars and the word. */
.menu-toggle::before {
  content: "";
  flex: 0 0 auto;
  width: 18px;
  height: 14px;
  padding: 4px 0;
  border-top: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  background: currentColor;
  background-clip: content-box;
}

/* The name and the role take one line each, whatever their length: a long name is cut with an
   ellipsis (its title holds it whole), so the bar keeps its height. */
.who-brief {
  display: none;
  flex: 0 1 auto;
  min-width: 0;
  line-height: 1.3;
  text-align: right;
}

.who-brief .who-name,
.who-brief .who-role {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar-menu {
  display: none;
  flex: 1 0 100%;
  gap: var(--s2);
  margin-top: var(--s1);
  padding: var(--s2) 0 var(--s3);
  border-top: 1px solid var(--line);
}

.topbar-menu.is-open {
  display: grid;
}

.nav {
  display: grid;
}

/* A menu link. The current page is a key held down: heavier words on the pressed surface.
   No dot, no caret and no underline is added under it. */
.nav a,
.who-link {
  display: flex;
  align-items: center;
  min-height: var(--target);
  padding: 0 var(--s3);
  border-radius: var(--r);
  color: var(--text);
  font-weight: 500;
  text-decoration: none;
  transition: background-color var(--quick) var(--ease), color var(--quick) var(--ease);
}

.who-link {
  flex: 0 0 auto;
  margin-left: calc(var(--s3) * -1);
  white-space: nowrap;
}

.nav a[aria-current="page"],
.who-link[aria-current="page"] {
  background: var(--key-press);
  color: var(--title);
  font-weight: 700;
}

@media (hover: hover) {
  .nav a:hover,
  .who-link:hover {
    background: var(--key-hover);
    color: var(--title);
  }

  .nav a[aria-current="page"]:hover,
  .who-link[aria-current="page"]:hover {
    background: var(--key-press);
  }
}

.nav a.is-hover,
.nav a:active,
.who-link:active {
  background: var(--key-press);
  color: var(--title);
}

.who {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s3);
  padding: var(--s3) 0 0 var(--s3);
  border-top: 1px solid var(--line);
}

.who-text {
  display: grid;
  min-width: 0;
  line-height: 1.3;
}

.who-name {
  display: block;
  color: var(--title);
  font-size: var(--t-small);
  font-weight: 600;
}

.who-role {
  display: block;
  color: var(--text-2);
  font-size: var(--t-micro);
}

.who .btn {
  flex: 0 0 auto;
  white-space: nowrap;
}

/* The location a Neurologist of several locations works in (ui.js, locationSwitch): one select in the bar. */
.who-place {
  flex: 0 1 auto;
  min-width: 9rem;
  max-width: 24rem;
}

.who-place .input {
  width: auto;
  max-width: 100%;
  min-height: var(--target);
  padding-top: 0;
  padding-bottom: 0;
}

/* A person with a first step waiting has no links: the open menu then starts with the person,
   under one line and not two. */
.topbar .nav:empty {
  display: none;
}

.topbar .nav:empty + .who {
  padding-top: 0;
  border-top: 0;
}

/* On a small phone the open menu shows the name on its own line, then My account and Sign out. */
@media (max-width: 29.99em) {
  .who {
    flex-wrap: wrap;
  }

  .who-text {
    flex: 1 0 100%;
  }
}

/* From a large phone up, the bar itself says who is signed in, so the open menu does not repeat it. */
@media (min-width: 30em) {
  .who-brief {
    display: block;
  }

  .topbar-menu .who-text {
    display: none;
  }
}

/* The open menu on a tablet uses the width: the links run in columns. */
@media (min-width: 37.5em) and (max-width: 56.24em) {
  .topbar .nav {
    grid-template-columns: repeat(auto-fill, minmax(13rem, 1fr));
  }
}

/* The bar of a signed-in person keeps one width on every page, so the menu looks the same on a
   narrow form page and on a wide record (body.wide) as on any other. */
.topbar.has-person .topbar-row {
  max-width: 77rem;
}

/* On a wide screen the menu, the person and Sign out sit in the bar and the Menu button goes.
   ui.js measures the bar and sets is-stacked or is-folded on it: one row when the links fit beside
   the logo and the person; a row of their own when they do not; the Menu button, as on a phone,
   when even that row is too short. A link is never cut or wrapped. */
@media (min-width: 56.25em) {
  .topbar-end {
    display: none;
  }

  .topbar-menu,
  .topbar-menu.is-open {
    display: flex;
    flex: 1 1 0;
    align-items: center;
    gap: var(--s4);
    min-width: 0;
    margin: 0;
    padding: 0;
    border: 0;
  }

  .nav {
    display: flex;
    flex: 1 1 auto;
    flex-wrap: nowrap;
    gap: 0 2px;
    min-width: 0;
  }

  /* In the bar a link is still a 48px target, and its surface is a 36px key inside it. */
  .topbar .nav a,
  .topbar .who-link {
    position: relative;
    z-index: 0;
    flex: 0 0 auto;
    background: none;
    white-space: nowrap;
  }

  .topbar .nav a::before,
  .topbar .who-link::before {
    content: "";
    position: absolute;
    inset: 6px 0;
    z-index: -1;
    border-radius: var(--r-sm);
    transition: background-color var(--quick) var(--ease);
  }

  .topbar .nav a[aria-current="page"]::before,
  .topbar .who-link[aria-current="page"]::before,
  .topbar .nav a:active::before,
  .topbar .who-link:active::before,
  .topbar .nav a.is-hover::before {
    background: var(--key-press);
  }

  .who {
    flex: 0 0 auto;
    margin-left: auto;
    padding: 0;
    border: 0;
  }

  .topbar .who-link {
    margin-left: 0;
  }

  .topbar-menu .who-text {
    display: grid;
    text-align: right;
  }

  .topbar .who-name {
    justify-self: end;
    max-width: 16rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .topbar.is-stacked .topbar-menu,
  .topbar.is-stacked .topbar-menu.is-open {
    display: contents;
  }

  .topbar.is-stacked .who {
    order: 1;
  }

  .topbar.is-stacked .nav {
    flex: 1 0 100%;
    order: 2;
    margin-top: var(--s1);
    border-top: 1px solid var(--line);
  }

  /* the first link's words stand in line with the logo above and the page title below */
  .topbar.is-stacked .nav a:first-child {
    margin-left: calc(var(--s3) * -1);
  }

  .topbar.is-folded .topbar-end {
    display: flex;
  }

  .topbar.is-folded .topbar-menu {
    display: none;
    flex: 1 0 100%;
    gap: var(--s2);
    margin-top: var(--s1);
    padding: var(--s2) 0 var(--s3);
    border-top: 1px solid var(--line);
  }

  .topbar.is-folded .topbar-menu.is-open {
    display: grid;
  }

  .topbar.is-folded .nav {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(13rem, 1fr));
  }

  .topbar.is-folded .nav a::before {
    inset: 0;
    border-radius: var(--r);
  }

  .topbar.is-folded .who {
    justify-content: space-between;
    margin-left: 0;
    padding: var(--s3) 0 0 var(--s3);
    border-top: 1px solid var(--line);
  }

  .topbar.is-folded .topbar-menu .who-text {
    display: none;
  }

  .topbar.is-folded .who-link {
    margin-left: calc(var(--s3) * -1);
  }
}

@media (min-width: 56.25em) and (hover: hover) {
  .topbar .nav a:hover,
  .topbar .who-link:hover {
    background: none;
  }

  .topbar .nav a:hover::before,
  .topbar .who-link:hover::before {
    background: var(--key-hover);
  }

  .topbar .nav a[aria-current="page"]:hover::before,
  .topbar .who-link[aria-current="page"]:hover::before {
    background: var(--key-press);
  }
}

@media (min-width: 56.25em) {
  .topbar .nav a[aria-current="page"],
  .topbar .who-link[aria-current="page"],
  .topbar .nav a:active,
  .topbar .who-link:active,
  .topbar .nav a.is-hover {
    background: none;
  }
}

/* The page title, with the way back above it. One <h1> on a page. */
.page-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  max-width: var(--page-max);
  margin: 0 auto;
  padding: var(--s5) var(--gutter) 0;
}

.back {
  display: inline-flex;
  align-items: center;
  justify-self: start;
  gap: var(--s2);
  min-height: var(--target);
  margin-top: calc(var(--s3) * -1);
  padding-right: var(--s3);
  border-radius: var(--r);
  font-weight: 600;
  text-decoration: none;
}

.back::before {
  content: "";
  width: 9px;
  height: 9px;
  margin-left: 3px;
  border-bottom: 2px solid currentColor;
  border-left: 2px solid currentColor;
  transform: rotate(45deg);
}

@media (hover: hover) {
  .back:hover {
    text-decoration: underline;
    text-decoration-thickness: 2px;
  }
}

main {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-content: start;
  gap: var(--s4);
  max-width: var(--page-max);
  margin: 0 auto;
  padding: var(--s4) var(--gutter) var(--s7);
}

main:focus {
  outline: none;
}

/* Page widths. Put the class on <body>, or pass width to shell(). */
body.narrow {
  --page-max: 40rem;
}

body.wide {
  --page-max: 100rem;
}

/* The page's side margin: 12 on a very narrow phone or a zoomed display, 24 on a tablet, 32 on a
   wide screen. */
@media (max-width: 22.49em) {
  :root {
    --gutter: 12px;
  }
}

@media (min-width: 48em) {
  :root {
    --gutter: 24px;
  }
}

@media (min-width: 75em) {
  :root {
    --gutter: 32px;
  }
}

/* The main action of a long page stays in reach at the bottom of the screen. Put it straight
   inside <main>, after the content it acts on. One primary button; a second action is words
   (.btn-quiet), never a second box of the same weight. The bar is one row and holds nothing else:
   the reason a button is locked (.lock-why) stands in the page just above it. A confirmation that
   must be read first (the read-back) is never put in this bar.
   On a screen under 480px tall (a phone on its side) the bar is not pinned: it would leave too
   little room for the work. */
.action-bar {
  position: sticky;
  bottom: 0;
  z-index: var(--z-actionbar);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s3);
  margin: 0 calc(var(--gutter) * -1);
  padding: 6px var(--gutter) calc(6px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--line);
  background: var(--page);
}

.action-bar > .btn {
  flex: 1 1 auto;
  min-width: min-content;
}

/* the second action is words: it gives the room to the main one, and may take two lines */
.action-bar > .btn-quiet {
  flex: 0 1 auto;
  padding: 6px var(--s2);
  font-size: var(--t-body);
  text-align: left;
}

@media (min-width: 48em) {
  .action-bar > .btn {
    flex: 0 0 auto;
    min-width: 14rem;
  }

  .action-bar > .btn-quiet {
    min-width: 0;
  }
}

@media (max-height: 479.98px) {
  .action-bar {
    position: static;
  }

  :root:has(.action-bar) {
    --pin-bottom: 0px;
  }
}

/* The visit bar. Inside a visit the bar is the visit, not the menu: who, the one figure that
   matters, and (for the technician) STOP. With the demonstration strip above it and the trace as
   its lower edge it is one piece (.frame) that stays at the top of the screen at every width.
   The name and the record number are never cut: they wrap, and the bar grows. */
.frame {
  position: sticky;
  top: 0;
  z-index: var(--z-frame);
  background: var(--bar);
}

.frame > .demo-banner {
  position: static;
}

.visitbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0 var(--s3);
  min-height: 52px;
  max-width: var(--page-max);
  margin: 0 auto;
  padding: 2px var(--gutter);
}

.visit-home {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  gap: var(--s2);
  min-width: var(--target);
  min-height: var(--target);
  border-radius: var(--r-sm);
  color: var(--link);
  font-weight: 600;
  text-decoration: none;
}

.visit-home img {
  width: auto;
  height: 30px;
}

.visit-id {
  display: grid;
  flex: 1 1 5.5rem;
  min-width: 0;
  line-height: 1.25;
}

.visit-who {
  color: var(--title);
  font-weight: 700;
  overflow-wrap: anywhere;
}

.visit-rec {
  color: var(--text-2);
  font-family: var(--font-mono);
  font-size: var(--t-micro);
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

.visit-meta {
  display: none;
  flex: 0 1 auto;
  min-width: 0;
  color: var(--text-2);
  font-size: var(--t-small);
}

/* The visit clock: minutes since the first step, against the target of the whole visit. */
.visit-clock {
  display: grid;
  flex: 0 0 auto;
  justify-items: end;
  line-height: 1.15;
  text-align: right;
}

.clock-now {
  color: var(--title);
  font-size: 1.375rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}

.clock-of {
  color: var(--text-2);
  font-size: var(--t-micro);
  white-space: nowrap;
}

.frame > .trace {
  max-width: none;
}

/* a very narrow phone: closer together, so that the bar keeps to one row */
@media (max-width: 22.49em) {
  .visitbar {
    column-gap: var(--s2);
  }

  .visit-id {
    flex-basis: 5rem;
  }

  .visit-home img {
    height: 26px;
  }
}

@media (min-width: 48em) {
  .visitbar {
    min-height: 64px;
    gap: var(--s2) var(--s5);
    padding-top: var(--s1);
    padding-bottom: var(--s1);
  }

  .visit-meta {
    display: block;
  }

  .clock-now {
    font-size: 1.625rem;
  }
}

/* ---- 4. Buttons ------------------------------------------------------------------------------- */

/* Four kinds. One primary on a screen.
     .btn              a plain key: a real second choice
     .btn-primary      the one main action of the screen
     .btn-quiet        words only: a way back or out, or a lesser action beside the primary
     .btn-danger       what cannot be undone
   .btn-lg is the main action of a phone, tablet or patient screen. .btn-block fills its row.
   .btn-stop is the STOP of a visit and nothing else. */
.btn {
  appearance: none;
  -webkit-appearance: none;
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s2);
  min-width: var(--target);
  min-height: var(--control);
  margin: 0;
  padding: 10px 18px;
  border: 1px solid var(--edge);
  border-radius: var(--r);
  background: var(--key);
  color: var(--title);
  font: inherit;
  font-weight: 600;
  line-height: 1.25;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: background-color var(--quick) var(--ease), border-color var(--quick) var(--ease), color var(--quick) var(--ease);
}

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

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

.btn-quiet {
  border-color: transparent;
  background: none;
  color: var(--link);
  padding-right: var(--s3);
  padding-left: var(--s3);
}

.btn-lg {
  width: 100%;
  min-height: var(--control-lg);
  padding: 14px 22px;
  font-size: var(--t-lead);
  font-weight: 700;
}

.btn-quiet.btn-lg {
  width: auto;
  font-weight: 600;
}

.btn-block {
  width: 100%;
}

@media (min-width: 48em) {
  .btn-lg:not(.btn-block) {
    width: auto;
    min-width: 16rem;
  }

  .btn-quiet.btn-lg:not(.btn-block) {
    min-width: 0;
  }
}

@media (hover: hover) {
  .btn:hover {
    border-color: var(--title);
    background: var(--key-hover);
  }

  .btn-primary:hover {
    border-color: var(--primary-hover);
    background: var(--primary-hover);
    color: var(--on-primary);
  }

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

  .btn-quiet:hover {
    border-color: transparent;
    background: var(--key-hover);
    color: var(--link);
  }
}

.btn.is-hover {
  border-color: var(--title);
  background: var(--key-hover);
}

.btn-primary.is-hover {
  border-color: var(--primary-hover);
  background: var(--primary-hover);
}

.btn-danger.is-hover {
  border-color: var(--danger-hover);
  background: var(--danger-hover);
}

.btn-quiet.is-hover {
  border-color: transparent;
  background: var(--key-hover);
}

.btn:active,
.btn.is-active {
  border-color: var(--title);
  background: var(--key-press);
}

.btn-primary:active,
.btn-primary.is-active {
  border-color: var(--primary-press);
  background: var(--primary-press);
}

.btn-danger:active,
.btn-danger.is-active {
  border-color: var(--danger-press);
  background: var(--danger-press);
}

.btn-quiet:active,
.btn-quiet.is-active {
  border-color: transparent;
  background: var(--key-press);
}

.btn:focus-visible,
.btn.is-focus {
  outline: var(--focus);
  outline-offset: 2px;
}

/* Not available: sunk into the plate, flat, its words still readable (4.5 to 1). A button that is
   locked says why in words beside it (.lock-why). A busy button (aria-busy="true") looks the same,
   its label says what it is doing, and a mark runs along its lower edge. */
.btn:disabled,
.btn[aria-disabled="true"],
.btn[aria-busy="true"] {
  border-color: var(--line);
  background: var(--well);
  color: var(--text-2);
  cursor: not-allowed;
}

.btn-quiet:disabled,
.btn-quiet[aria-disabled="true"] {
  border-color: transparent;
  background: none;
}

.btn[aria-busy="true"] {
  overflow: hidden;
  cursor: progress;
}

.btn[aria-busy="true"]::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 0;
  width: 34%;
  height: 3px;
  background: var(--link);
}

.lock-why {
  color: var(--text-2);
  font-size: var(--t-small);
}

/* A button that reads as a link, for a small action inside a row. The target is still 48px tall. */
.link-btn {
  appearance: none;
  -webkit-appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: var(--target);
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: var(--r-sm);
  background: none;
  color: var(--link);
  font: inherit;
  font-weight: 600;
  text-align: left;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  cursor: pointer;
}

@media (hover: hover) {
  .link-btn:hover {
    text-decoration-thickness: 2px;
  }
}

.link-btn:disabled {
  color: var(--text-2);
  text-decoration: none;
  cursor: not-allowed;
}

/* A row of actions. On a phone the buttons share the row; on a wide screen they keep their width. */
.actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s3);
}

.actions > .btn {
  flex: 1 1 8rem;
}

.actions > .btn-quiet {
  flex: 0 1 auto;
}

@media (min-width: 48em) {
  .actions > .btn {
    flex: 0 0 auto;
  }

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

/* A row of actions whose main button has a long label: on a phone each button takes the whole row,
   so that no label breaks in two. */
@media (max-width: 47.99em) {
  .actions-stack > .btn {
    flex-basis: 100%;
  }
}

/* STOP. The one octagon on the platform, and the one place besides the STOP sheet where a solid
   danger fill is used. It is always in the visit bar, at every width. The button keeps a square
   outline for the focus ring; the octagon is drawn behind the word, which sits clear of the cuts. */
.btn-stop {
  appearance: none;
  -webkit-appearance: none;
  position: relative;
  z-index: 0;
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  min-width: 76px;
  min-height: var(--target);
  margin: 0;
  padding: 0 var(--s4);
  border: 0;
  border-radius: var(--r-sm);
  background: none;
  color: var(--on-danger);
  font: inherit;
  font-size: var(--t-body);
  font-weight: 800;
  letter-spacing: 0.08em;
  line-height: 1;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.btn-stop::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: var(--danger);
  clip-path: polygon(14px 0, calc(100% - 14px) 0, 100% 14px, 100% calc(100% - 14px), calc(100% - 14px) 100%, 14px 100%, 0 calc(100% - 14px), 0 14px);
  transition: background-color var(--quick) var(--ease);
}

@media (hover: hover) {
  .btn-stop:hover::before {
    background: var(--danger-hover);
  }
}

.btn-stop:active::before,
.btn-stop.is-active::before {
  background: var(--danger-press);
}

.btn-stop.is-hover::before {
  background: var(--danger-hover);
}

.btn-stop:focus-visible,
.btn-stop.is-focus {
  outline: var(--focus);
  outline-offset: 3px;
}

/* a very narrow phone: STOP gives a little room to the record number beside it */
@media (max-width: 22.49em) {
  .btn-stop {
    min-width: 66px;
    padding: 0 var(--s2);
    letter-spacing: 0.06em;
  }
}

@media (min-width: 48em) {
  .btn-stop {
    min-width: 96px;
    min-height: 52px;
    font-size: var(--t-lead);
  }

  .btn-stop::before {
    clip-path: polygon(15px 0, calc(100% - 15px) 0, 100% 15px, 100% calc(100% - 15px), calc(100% - 15px) 100%, 15px 100%, 0 calc(100% - 15px), 0 15px);
  }
}

/* ---- 5. Fields -------------------------------------------------------------------------------- */

/* Label above, hint under the label, error under the hint in words, then the control. */
.form {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--s4);
}

.field {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-content: start;
  gap: 6px;
  min-width: 0;
}

.label {
  color: var(--text);
  font-weight: 600;
}

.optional {
  color: var(--text-2);
  font-weight: 400;
}

.field-error {
  color: var(--danger-text);
  font-size: var(--t-small);
  font-weight: 600;
}

.input {
  appearance: none;
  -webkit-appearance: none;
  display: block;
  width: 100%;
  min-width: 0;
  min-height: var(--control);
  margin: 0;
  padding: 10px 12px;
  border: 1px solid var(--edge);
  border-radius: var(--r);
  background: var(--key);
  color: var(--text);
  font: inherit;
  font-size: max(1em, 16px); /* under 16px an iPhone zooms the page when the field is entered */
  line-height: 1.4;
  text-align: left;
  transition: border-color var(--quick) var(--ease);
}

textarea.input {
  min-height: 6.5rem;
  resize: vertical;
}

.input::placeholder {
  color: var(--text-2);
  opacity: 1;
}

.input::-webkit-date-and-time-value {
  text-align: left;
}

input[type="number"].input {
  -moz-appearance: textfield;
}

input[type="number"].input::-webkit-outer-spin-button,
input[type="number"].input::-webkit-inner-spin-button {
  margin: 0;
  -webkit-appearance: none;
}

@media (hover: hover) {
  .input:hover {
    border-color: var(--title);
  }
}

.input.is-hover {
  border-color: var(--title);
}

.input:focus-visible,
.input.is-focus {
  border-color: var(--ring);
  outline: var(--focus);
  outline-offset: 1px;
}

/* An error is said in words above the control, and the control's edge is doubled. */
.input[aria-invalid="true"] {
  padding: 9px 11px;
  border: 2px solid var(--danger-text);
}

/* Switched off: sunk into the plate. Read-only: a stored value, with no key under it. */
.input:disabled {
  border-color: var(--line);
  background: var(--well);
  color: var(--text-2);
  cursor: not-allowed;
  opacity: 1;
  -webkit-text-fill-color: var(--text-2);
}

.input[readonly] {
  border-color: var(--line);
  background: none;
}

/* A select keeps its own arrow off and gets one drawn here, so every browser shows the same control. */
.select {
  position: relative;
  display: block;
}

.select > .input {
  padding-right: 44px;
  cursor: pointer;
}

.select::after {
  content: "";
  position: absolute;
  top: 50%;
  right: 18px;
  width: 9px;
  height: 9px;
  margin-top: -7px;
  border-right: 2px solid var(--title);
  border-bottom: 2px solid var(--title);
  transform: rotate(45deg);
  pointer-events: none;
}

/* A value with its unit in one box, for example a pulse per minute. The unit is in the label colour. */
.input-group {
  display: flex;
  align-items: stretch;
  min-height: var(--control);
  border: 1px solid var(--edge);
  border-radius: var(--r);
  background: var(--key);
  transition: border-color var(--quick) var(--ease);
}

.input-group > .input {
  flex: 1 1 auto;
  min-height: calc(var(--control) - 2px);
  border: 0;
  background: transparent;
}

.input-group > .input:focus-visible {
  outline: none;
}

.input-group > .unit,
.input-group > .sep {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  padding: 0 12px 0 2px;
  color: var(--text-2);
  white-space: nowrap;
}

.input-group:focus-within {
  border-color: var(--ring);
  outline: var(--focus);
  outline-offset: 1px;
}

.field.has-error .input-group {
  border: 2px solid var(--danger-text);
}

.field.has-error .input-group > .input {
  min-height: calc(var(--control) - 4px);
  padding: 9px 11px;
  border: 0;
}

.input-group.is-disabled {
  border-color: var(--line);
  background: var(--well);
}

/* A reading typed by hand: large tabular figures set against the unit, so the number and its unit
   read as one quantity. Use with a number keypad (inputmode numeric or decimal). */
.input-reading {
  padding-right: 6px;
  color: var(--title);
  font-size: var(--t-reading);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
  line-height: 1.1;
  text-align: right;
}

.input-group > .input-reading,
input.input-reading {
  min-height: calc(var(--control) + 14px);
}

/* The figures never outgrow their box: in a narrow box, or with a large text size set in the
   browser, they are sized by the width of the box itself. */
.input-group:has(> .input-reading) {
  container: reading / inline-size;
}

@container reading (min-width: 0) {
  .input-group > .input-reading {
    font-size: min(var(--t-reading), 24cqi);
  }

  .input-pair > .input-reading {
    font-size: min(var(--t-reading), 12cqi);
  }
}

/* a reading that stands alone, with its unit said in the heading above: the figure in the middle */
input.input-reading:not(.input-group > *) {
  padding-right: 12px;
  text-align: center;
}

.input-group > .input-reading ~ .unit {
  padding-right: 12px;
  font-size: var(--t-small);
  font-weight: 600;
}

/* Two readings that are one measurement: blood pressure. One box, a slash between, one unit. */
.input-pair > .input-reading {
  flex: 1 1 0;
  width: 0;
  min-width: 2.5ch;
  padding-right: 4px;
  padding-left: 4px;
}

.input-pair > .unit {
  min-width: 3.5rem;
}

.input-pair > .input-reading:first-child {
  text-align: right;
}

.input-pair > .sep + .input-reading {
  text-align: left;
}

.input-pair > .sep {
  padding: 0 2px;
  color: var(--text-2);
  font-size: var(--t-reading);
  font-weight: 400;
  line-height: 1;
}

/* A reading outside its limit is not an error: the reading may be right. The box keeps a doubled
   dark edge, and the sentence under it says what to check and what happens next. */
.field.has-check .input-group,
.field.has-check > .input {
  border: 2px solid var(--title);
}

.field.has-check .input-group > .input {
  min-height: calc(var(--control) - 4px + 14px);
}

.field-check {
  color: var(--text);
  font-size: var(--t-small);
  font-weight: 600;
}

/* The six-digit sign-in code. */
.input-code {
  max-width: 13rem;
  font-family: var(--font-mono);
  font-size: 1.375rem;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.3em;
}

/* A short answer in the person's own words: one line that grows with what is typed, so a long
   answer is never cut by its box. (A <textarea rows="1">; where the browser cannot size a field
   by its content, the text wraps and the box scrolls.) */
textarea.input-grow {
  min-height: var(--control);
  resize: none;
  field-sizing: content;
}

/* A drafted section: words drafted from this patient's record, waiting for the neurologist. It sits
   on the tint, as everything that waits for someone does, under the word Draft (a .badge in the
   label). It does not print and does not count as written until it is accepted. The screen says
   Draft and nothing else about where the words came from. */
.field.is-draft {
  padding: var(--s3) var(--s4) var(--s4);
  border-radius: var(--r-lg);
  background: var(--tint);
}

.field.is-draft > .label > .badge {
  margin-left: var(--s2);
  vertical-align: 0.1em;
}

.field.is-draft > .actions {
  margin-top: var(--s2);
}

/* Where a person writes the record's own words (a narrative section, a long answer of the history):
   the record face, and a line of 70 to 90 characters at every window width. */
.input-record {
  max-width: var(--measure);
  padding: 12px 14px;
  font-family: var(--font-record);
  font-size: max(1.0625em, 17px);
  line-height: 1.6;
}

/* Layouts for several fields. */
.grid-2,
.grid-3,
.grid-auto {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: end;
  gap: var(--s4);
}

.grid-auto {
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 8.5rem), 1fr));
}

@media (min-width: 37.5em) {
  .grid-2,
  .grid-3 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 56.25em) {
  .grid-3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

/* ---- 6. Choices ------------------------------------------------------------------------------- */

/* One option. The real radio or checkbox covers the whole target, so touch, keyboard and screen
   readers all work as they do for a plain control.
   A chosen answer on a staff page is filled with ink: blue stays the colour of the next action.
   On a patient page it is a tint with a doubled edge and heavier words, never a bright block. */
.opts {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s2);
}

.opt {
  position: relative;
  display: flex;
  flex: 1 1 auto;
  min-width: 0;
}

.opt > input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.opt > span {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: var(--control);
  padding: 10px 14px;
  border: 1px solid var(--edge);
  border-radius: var(--r);
  background: var(--key);
  color: var(--title);
  font-weight: 500;
  line-height: 1.25;
  text-align: center;
  transition: background-color var(--quick) var(--ease), border-color var(--quick) var(--ease), color var(--quick) var(--ease);
}

@media (hover: hover) {
  .opt:hover > input:not(:checked):not(:disabled) + span {
    border-color: var(--title);
    background: var(--key-hover);
  }
}

.opt.is-hover > input:not(:checked):not(:disabled) + span {
  border-color: var(--title);
  background: var(--key-hover);
}

.opt > input:checked + span {
  border-color: var(--chosen);
  background: var(--chosen);
  color: var(--on-chosen);
  font-weight: 700;
}

.opt > input:focus-visible + span,
.opt.is-focus > span {
  outline: var(--focus);
  outline-offset: 2px;
}

.opt > input:disabled {
  cursor: not-allowed;
}

.opt > input:disabled + span {
  border-color: var(--line);
  background: var(--well);
  color: var(--text-2);
}

.opt > input:disabled:checked + span {
  border: 2px solid var(--text-2);
  font-weight: 700;
}

.field.has-error .opt > input:not(:checked) + span {
  border-color: var(--danger-text);
}

/* The calm key: a chosen answer is the tint, its edge doubled in the link colour. */
:root.patient .opt > input:checked + span,
[data-role="patient"] .opt > input:checked + span {
  padding: 9px 13px;
  border: 2px solid var(--link);
}

/* Segmented: two to four short answers that share one row in equal parts. A word is never cut:
   when the answers cannot share the row, the last one moves to the next line. */
.opts-row .opt {
  flex: 1 1 0;
  min-width: min-content;
}

.opts-row .opt > span {
  padding: 10px 6px;
}

/* Stacked: one answer per line, for longer lists. A circle means pick one, a square means pick any. */
.opts-stack {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
}

.opts-stack .opt > span {
  justify-content: flex-start;
  padding-left: 50px;
  text-align: left;
}

:root.patient .opts-stack .opt > input:checked + span,
[data-role="patient"] .opts-stack .opt > input:checked + span {
  padding-left: 49px;
}

.opts-stack .opt > span::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 14px;
  width: 24px;
  height: 24px;
  margin-top: -12px;
  border: 2px solid var(--edge);
  border-radius: 50%;
  background: var(--key);
}

.opts-stack .opt > input[type="checkbox"] + span::before {
  border-radius: var(--r-sm);
}

.opts-stack .opt > input:checked + span::before {
  border-color: var(--on-chosen);
  background: var(--on-chosen);
}

/* The mark of a chosen answer: a filled centre for pick one, a tick for pick any. Both are cut
   from a square that sits dead centre on the ring or the box. */
.opts-stack .opt > input:checked + span::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 14px;
  width: 24px;
  height: 24px;
  margin-top: -12px;
  background: var(--chosen);
  clip-path: circle(6px at 50% 50%);
}

.opts-stack .opt > input[type="checkbox"]:checked + span::after {
  clip-path: polygon(20% 52%, 30% 42%, 43% 55%, 70% 26%, 80% 36%, 43% 76%);
}

:root.patient .opts-stack .opt > input:checked + span::before,
[data-role="patient"] .opts-stack .opt > input:checked + span::before {
  left: 13px;
  border-color: var(--link);
  background: var(--key);
}

:root.patient .opts-stack .opt > input:checked + span::after,
[data-role="patient"] .opts-stack .opt > input:checked + span::after {
  left: 13px;
  background: var(--link);
}

.opts-stack .opt > input:disabled + span::before {
  border-color: var(--line);
  background: var(--well);
}

.opts-stack .opt > input:disabled:checked + span::before {
  border-color: var(--text-2);
  background: var(--well);
}

.opts-stack .opt > input:disabled:checked + span::after {
  left: 15px;
  background: var(--text-2);
}

@media (min-width: 37.5em) {
  .opts-cols {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* The rating row: a scale of joined keys, its two ends named under it (.rating-ends).
   0 to 6 always shares one line, so the scale is never broken in two: seven keys of 48px need
   336px, which a phone 375 wide has. In a narrower place (a phone 320 wide, which is a zoomed
   display) the keys are 42px wide and 56px tall: narrower than 48px, but no smaller in area.
   0 to 10 (class "rating-fold") shares one line from 34rem, and folds below that into two lines,
   0 to 5 over 6 to 10. */
.rating-wrap {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--s1);
  container: rating / inline-size;
}

.rating {
  display: grid;
  grid-auto-columns: minmax(0, 1fr);
  grid-auto-flow: column;
  gap: 0;
}

.rating .opt > span {
  min-height: max(52px, var(--control));
  padding: 10px 0;
  border-radius: 0;
  font-size: var(--t-lead);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.rating .opt + .opt > span {
  margin-left: -1px;
  width: calc(100% + 1px);
}

.rating .opt:first-child > span {
  border-top-left-radius: var(--r);
  border-bottom-left-radius: var(--r);
}

.rating .opt:last-child > span {
  border-top-right-radius: var(--r);
  border-bottom-right-radius: var(--r);
}

.rating .opt > input:checked + span,
.rating .opt > input:focus-visible + span,
.rating .opt.is-focus > span {
  z-index: var(--z-raised);
}

:root.patient .rating .opt > input:checked + span,
[data-role="patient"] .rating .opt > input:checked + span {
  padding: 9px 0;
}

@container rating (max-width: 335.98px) {
  .rating:not(.rating-fold) .opt > span {
    min-height: 56px;
  }
}

.rating-fold {
  grid-template-columns: repeat(6, minmax(0, 1fr));
  grid-auto-flow: row;
  row-gap: 6px;
}

.rating-fold .opt:nth-child(6) > span {
  border-top-right-radius: var(--r);
  border-bottom-right-radius: var(--r);
}

.rating-fold .opt:nth-child(7) > span {
  margin-left: 0;
  width: 100%;
  border-top-left-radius: var(--r);
  border-bottom-left-radius: var(--r);
}

@container rating (min-width: 34rem) {
  .rating-fold {
    grid-template-columns: none;
    grid-auto-flow: column;
  }

  .rating-fold .opt:nth-child(6) > span {
    border-radius: 0;
  }

  .rating-fold .opt:nth-child(7) > span {
    margin-left: -1px;
    width: calc(100% + 1px);
    border-radius: 0;
  }
}

/* Under 288px of room (a 0 to 10 row inside a panel on a 320px phone) six keys would be under
   48px: the row folds to three lines of four, each key on its own. */
@container rating (max-width: 287.98px) {
  .rating-fold {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    column-gap: 6px;
  }

  .rating-fold .opt > span,
  .rating-fold .opt + .opt > span,
  .rating-fold .opt:nth-child(6) > span,
  .rating-fold .opt:nth-child(7) > span {
    margin-left: 0;
    width: 100%;
    border-radius: var(--r);
  }
}

.rating-ends {
  display: flex;
  justify-content: space-between;
  gap: var(--s3);
  color: var(--text-2);
  font-size: var(--t-small);
}

/* Checkbox, and the larger consent row. A ticked box is blue, as in the iPhone app.
   Keep links out of the label: the control covers it. */
.check {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: var(--s3);
  min-height: var(--target);
  padding: 11px 0;
  line-height: 1.4;
  cursor: pointer;
}

.check > input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.check-box {
  position: relative;
  flex: 0 0 26px;
  width: 26px;
  height: 26px;
  border: 2px solid var(--edge);
  border-radius: var(--r-sm);
  background: var(--key);
  transition: background-color var(--quick) var(--ease), border-color var(--quick) var(--ease);
}

.check-label {
  min-width: 0;
  padding-top: 1px;
}

@media (hover: hover) {
  .check:hover > input:not(:disabled) + .check-box {
    border-color: var(--title);
  }
}

.check > input:checked + .check-box {
  border-color: var(--primary);
  background: var(--primary);
}

.check > input:checked + .check-box::after {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--on-primary);
  clip-path: polygon(18% 52%, 29% 41%, 42% 54%, 71% 23%, 82% 34%, 42% 77%);
}

.check > input:focus-visible + .check-box,
.check.is-focus > .check-box {
  outline: var(--focus);
  outline-offset: 2px;
}

.check > input:disabled {
  cursor: not-allowed;
}

.check > input:disabled + .check-box {
  border-color: var(--line);
  background: var(--well);
}

.check > input:disabled:checked + .check-box {
  border-color: var(--text-2);
  background: var(--text-2);
}

.check > input:disabled:checked + .check-box::after {
  background: var(--well);
}

.check > input:disabled ~ .check-label {
  color: var(--text-2);
}

.check-consent {
  padding: 14px var(--s4);
  border: 1px solid var(--edge);
  border-radius: var(--r);
  background: var(--key);
}

.check-consent:has(> input:checked) {
  padding: 13px 15px;
  border: 2px solid var(--link);
  background: var(--tint);
}

.check-consent > input:checked + .check-box {
  border-color: var(--link);
}

.field.has-error .check-consent,
.field.has-error .check > .check-box {
  border-color: var(--danger-text);
}

/* field({ type: 'password', reveal: true }): the "Show password" box sits inside the field. When
   the password is refused, the box keeps its own edge: it is not what is wrong. */
.field.has-error .check-reveal > .check-box {
  border-color: var(--edge);
}

.field.has-error .check-reveal > input:checked + .check-box {
  border-color: var(--primary);
}

/* ---- 7. Sections, panels, lists, readouts ------------------------------------------------------ */

.stack {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-content: start;
  gap: var(--s4);
}

.stack-sm {
  gap: var(--s2);
}

.stack-lg {
  gap: var(--s5);
}

.cluster {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s2) var(--s3);
}

.split {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--s1) var(--s4);
}

/* A section of a page. Its content sits straight on the plate under one 2px rule: no card is
   drawn around it. .sec-head holds the heading and, at the right, one short note. Inside a
   section a list or a table opens with a hairline, so two heavy rules never stack. */
.sec {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-content: start;
  gap: var(--s3);
  padding-top: var(--s3);
  border-top: 2px solid var(--rule);
}

.sec + .sec {
  margin-top: var(--s3);
}

.sec-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--s1) var(--s4);
}

.sec-note {
  color: var(--text-2);
  font-size: var(--t-small);
}

/* A panel groups what belongs to one act: a form with its Save button, the parts of a dialog.
   One step lighter than the plate, inside an edge of its own tone. Do not put a panel in a panel,
   and do not use one to hold plain reading. */
.panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-content: start;
  gap: var(--s3);
  padding: var(--s4);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--panel);
}

@media (min-width: 48em) {
  .panel {
    padding: var(--s5);
  }
}

@media (max-width: 22.49em) {
  .panel {
    padding: var(--s3);
  }
}

/* A list of rows: a worklist, a schedule, a set of files. The rows sit on the plate between
   hairlines. A row that opens something is a link over its whole width, with a mark at its end. */
.list {
  margin: 0;
  padding: 0;
  border-top: 1px solid var(--line);
  list-style: none;
}

.list > li {
  border-bottom: 1px solid var(--line);
}

.row {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-content: center;
  align-items: center;
  gap: 4px var(--s3);
  min-height: 64px;
  padding: var(--s3) 0;
  color: inherit;
  text-decoration: none;
}

a.row,
button.row {
  width: 100%;
  padding-right: 36px;
  padding-left: var(--s2);
  margin: 0;
  border: 0;
  border-radius: var(--r-sm);
  background: none;
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: background-color var(--quick) var(--ease);
}

a.row::after,
button.row::after {
  content: "";
  position: absolute;
  top: 50%;
  right: 14px;
  width: 9px;
  height: 9px;
  margin-top: -5px;
  border-top: 2px solid var(--text-2);
  border-right: 2px solid var(--text-2);
  transform: rotate(45deg);
}

@media (hover: hover) {
  a.row:hover,
  button.row:hover {
    background: var(--key-hover);
    color: inherit;
  }
}

a.row.is-hover,
a.row:active,
button.row:active {
  background: var(--key-press);
}

a.row:focus-visible,
button.row:focus-visible,
a.row.is-focus {
  outline: var(--focus);
  outline-offset: -3px;
}

.row-main {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.row-title {
  color: var(--title);
  font-weight: 600;
}

.row-sub {
  color: var(--text-2);
  font-size: var(--t-small);
}

.row-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 2px var(--s3);
  min-width: 0;
}

.row-meta .row-time {
  margin-left: auto;
}

@media (min-width: 37.5em) {
  .row {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .row-meta {
    display: grid;
    justify-items: end;
    max-width: 20rem;
    text-align: right;
  }

  .row-meta .row-time {
    margin-left: 0;
  }
}

.row-status {
  color: var(--title);
  font-weight: 600;
}

.row-time {
  color: var(--text-2);
  font-size: var(--t-small);
  font-variant-numeric: tabular-nums;
}

/* The one filled tag. It marks a read that cannot wait. */
.tag-stat {
  display: inline-block;
  padding: 1px var(--s2);
  border-radius: 4px;
  background: var(--danger);
  color: var(--on-danger);
  font-size: var(--t-micro);
  font-weight: 700;
  letter-spacing: 0.06em;
  print-color-adjust: exact;
  -webkit-print-color-adjust: exact;
}

/* A readout: the counts a page reports ("what needs you now"). One well, one cell for each count,
   a hairline between the cells. A cell that leads somewhere is a link and shows a mark; a count
   whose page does not exist yet is a plain cell, so nothing looks pressable that cannot be pressed. */
.cards {
  display: flex;
  flex-wrap: wrap;
  margin: 0;
  padding: 0;
  overflow: hidden;
  border-radius: var(--r-lg);
  background: var(--well);
  list-style: none;
}

/* The cells of a row share its width, and the cells of the last row fill it: whatever the number
   of counts a role has, the well has no empty cell. Two to a row on a phone, three on a tablet,
   all of them in one row on a laptop. */
.cards > li {
  display: grid;
  flex: 1 1 9.5rem;
  min-width: min(100%, 9.5rem);
  margin: 0 -1px -1px 0;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

@media (min-width: 48em) {
  .cards > li {
    flex-basis: 12rem;
  }

  /* exactly four counts stand in one row on a tablet (three and one would leave one stretched) */
  .cards > li:first-child:nth-last-child(4),
  .cards > li:first-child:nth-last-child(4) ~ li {
    flex-basis: 10rem;
  }
}

.card {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-content: start;
  gap: 2px;
  min-height: 96px;
  padding: var(--s3) var(--s4) var(--s4);
  color: inherit;
  text-decoration: none;
  transition: background-color var(--quick) var(--ease);
}

@media (min-width: 48em) {
  .card {
    min-height: 112px;
    padding: var(--s4);
  }
}

a.card {
  padding-right: 36px;
}

a.card::after {
  content: "";
  position: absolute;
  top: 22px;
  right: 18px;
  width: 9px;
  height: 9px;
  border-top: 2px solid var(--text-2);
  border-right: 2px solid var(--text-2);
  transform: rotate(45deg);
}

@media (hover: hover) {
  a.card:hover {
    background: var(--key-hover);
    color: inherit;
  }
}

a.card.is-hover,
a.card:active {
  background: var(--key-press);
}

a.card:focus-visible {
  outline: var(--focus);
  outline-offset: -3px;
}

.card-count {
  color: var(--title);
  font-size: calc(var(--t-count) * 0.8);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  line-height: 1.1;
}

@media (min-width: 48em) {
  .card-count {
    font-size: var(--t-count);
  }
}

.card-count.is-zero {
  color: var(--text-2);
  font-weight: 500;
}

.card-title {
  color: var(--title);
  font-weight: 600;
}

.card-detail {
  color: var(--text-2);
  font-size: var(--t-small);
}

/* Label and value pairs: the head of a record. */
.dl {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0;
}

.dl dt {
  color: var(--text-2);
  font-size: var(--t-small);
}

.dl dd {
  margin: 0 0 var(--s2);
  font-weight: 500;
}

.dl dd:last-child {
  margin-bottom: 0;
}

@media (min-width: 30em) {
  .dl {
    grid-template-columns: minmax(8rem, max-content) minmax(0, 1fr);
    gap: 6px var(--s4);
  }

  .dl dt {
    padding-top: 0.1em;
  }

  .dl dd {
    margin: 0;
  }
}

/* Facts in a line: the head of a visit (born, injury, assessment). Each fact is a small label over
   its value; they wrap as the room allows. */
.facts {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s2) var(--s5);
  margin: 0;
}

.facts > div {
  display: grid;
  gap: 1px;
  min-width: 0;
}

.facts dt {
  color: var(--text-2);
  font-size: var(--t-micro);
  font-weight: 600;
}

.facts dd {
  margin: 0;
  font-weight: 500;
}

/* A worklist: visits in rows, each a link over its whole width.
       <ul class="list worklist"><li><a class="row" href>
         <span class="wl-time">09:15</span>
         <span class="wl-who"><span class="row-title">name</span><span class="row-sub mono">record</span></span>
         <span class="wl-stand"> .standing </span>
         <span class="wl-detail"><span class="wl-next">where it stands</span>
           <span class="wl-waits"><span class="wl-label">Waits on </span>role<span class="wl-label">.</span></span></span>
       </a></li></ul>
   From 900px the rows line up in columns under one line of column names (.worklist-head).
   Below that each row is a short block: time and name, the standing, then one line of detail.
   On a phone the record number is left to the visit's own page. */
.worklist-head {
  display: none;
}

.worklist .row {
  grid-template-columns: minmax(0, max-content) minmax(0, 1fr);
  gap: 4px var(--s2);
  align-items: start;
  min-height: 72px;
}

.wl-time {
  min-width: 3rem;
  padding-top: 2px;
  color: var(--text-2);
  font-family: var(--font-mono);
  font-size: var(--t-small);
  font-variant-numeric: tabular-nums;
}

.wl-who {
  display: grid;
  gap: 1px;
  min-width: 0;
}

.wl-who .row-title {
  overflow-wrap: anywhere;
}

.wl-who .row-sub {
  display: none;
}

.wl-stand,
.wl-detail {
  grid-column: 2;
  min-width: 0;
}

.wl-detail {
  color: var(--text-2);
  font-size: var(--t-small);
}

.wl-waits {
  color: var(--text);
  font-weight: 600;
}

.wl-label {
  font-weight: 400;
}

/* A row the person cannot open keeps the columns of the rows that open (no mark at its end). */
.worklist div.row {
  padding-right: 36px;
  padding-left: var(--s2);
}

/* The standing and the STAT tag keep a gap between them. */
.wl-stand {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s1) var(--s2);
}

/* "Waits on Nobody" is said only in the table's column, never as a sentence on a phone. */
.wl-waits.wl-none {
  display: none;
}

@media (min-width: 37.5em) {
  .wl-who .row-sub {
    display: block;
  }
}

@media (min-width: 56.25em) {
  .worklist-head,
  .worklist .row {
    display: grid;
    grid-template-columns: 4rem minmax(10rem, 1fr) 14.5rem minmax(0, 2fr) 7rem;
    gap: 0 var(--s4);
    align-items: center;
  }

  .worklist-head {
    padding: 0 36px 6px var(--s2);
    color: var(--text-2);
    font-size: var(--t-micro);
    font-weight: 600;
  }

  .wl-time {
    padding-top: 0;
  }

  .wl-stand {
    grid-column: 3;
  }

  .wl-detail {
    display: contents;
    font-size: var(--t-body);
  }

  .wl-next {
    grid-column: 4;
    color: var(--text);
  }

  .wl-waits {
    grid-column: 5;
    color: var(--title);
    font-size: var(--t-small);
  }

  .wl-waits.wl-none {
    display: inline;
  }

  /* the line of column names says it; the words stay for a screen reader */
  .wl-label {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }
}

/* ---- 8. The status of a test value ------------------------------------------------------------- */

/* The report's four colours, for the status of a test value and for nothing else.
   A cell always shows its word (.status-word) and a mark whose shape says the same thing as the
   colour: a full disc (green), a half disc (yellow), a square (red), an empty ring (gray).
   By day the cell is the printed cell: the report's own fill and words. By night the fill is the
   same hue taken deep and the words the same hue taken pale, and the mark keeps the exact fill
   the report prints, so the page's colour is still on the screen.
   Works on a table cell, a div or a span. Only the pair's own text colour goes on a fill. */
.status {
  --st-fill: var(--gray-fill);
  --st-text: var(--gray-text);
  --st-edge: var(--gray-edge);
  --st-key: var(--gray-key);
  background: var(--st-fill);
  color: var(--st-text);
  outline: 1px solid var(--st-edge);
  outline-offset: -1px;
  print-color-adjust: exact;
  -webkit-print-color-adjust: exact;
}

.status-green {
  --st-fill: var(--green-fill);
  --st-text: var(--green-text);
  --st-edge: var(--green-edge);
  --st-key: var(--green-key);
}

.status-yellow {
  --st-fill: var(--yellow-fill);
  --st-text: var(--yellow-text);
  --st-edge: var(--yellow-edge);
  --st-key: var(--yellow-key);
}

.status-red {
  --st-fill: var(--red-fill);
  --st-text: var(--red-text);
  --st-edge: var(--red-edge);
  --st-key: var(--red-key);
}

.status-gray {
  --st-fill: var(--gray-fill);
  --st-text: var(--gray-text);
  --st-edge: var(--gray-edge);
  --st-key: var(--gray-key);
}

.status-word {
  position: relative;
  display: block;
  padding-left: 20px;
  font-size: var(--t-small);
  font-weight: 700;
}

.status-text {
  display: block;
}

/* The mark: 12px, at the start of the word's line. */
.status-word::before,
.status-word::after {
  content: "";
  position: absolute;
  top: 0.75em;
  left: 0;
  width: 12px;
  height: 12px;
  margin-top: -6px;
}

.status-word::before {
  border: 2px solid var(--st-key);
  border-radius: 50%;
}

.status-word::after {
  content: none;
}

.status-green .status-word::before {
  background: var(--st-key);
}

.status-yellow .status-word::after {
  content: "";
  width: 6px;
  border-radius: 6px 0 0 6px;
  background: var(--st-key);
}

.status-red .status-word::before {
  border-radius: 1px;
  background: var(--st-key);
}

div.status,
span.status {
  padding: var(--s2) 10px;
  border-radius: var(--r-sm);
}

span.status {
  display: inline-block;
}

/* The key to the four: a line of the four words with their marks, under a table of values. */
.status-key {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s2);
  margin: 0;
  padding: 0;
  list-style: none;
}

.status-key .status {
  padding: 4px 10px;
}

/* ---- 9. Where a visit stands ------------------------------------------------------------------- */

/* The trace. The logo's own run of colour, sky to violet, used for one thing: how far along a
   visit is. A row of plain segments (<i>), any number of them. No gradient is drawn: a segment is
   one flat colour, the stretch of the run it stands on (.s0 to .s9; a trace of 7, 9 or 10 segments
   takes them by place and needs no class on a segment).
     reached       thick, in its colour
     .off          not reached yet, or (in the neurologist's trace) not written: a thin line.
                   Thick against thin, so the state never depends on colour.
     .now          where the visit is now: taller than the rest, with the pointer over it
   Always beside words that say the same ("Step 3 of 10", "In review", "62 of 79 written"); the
   trace itself is hidden from a screen reader, or carries role="img" with a label. */
.trace {
  display: flex;
  align-items: center;
  gap: 3px;
  min-width: 0;
  height: 12px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.trace > i,
.trace > li {
  position: relative;
  flex: 1 1 0;
  min-width: 2px;
  height: 6px;
  border-radius: var(--r-xs);
  background: var(--trace-9);
  print-color-adjust: exact;
  -webkit-print-color-adjust: exact;
}

.trace-10 > :nth-child(1), .trace > .s0 { background: var(--trace-0); }
.trace-10 > :nth-child(2), .trace > .s1 { background: var(--trace-1); }
.trace-10 > :nth-child(3), .trace > .s2 { background: var(--trace-2); }
.trace-10 > :nth-child(4), .trace > .s3 { background: var(--trace-3); }
.trace-10 > :nth-child(5), .trace > .s4 { background: var(--trace-4); }
.trace-10 > :nth-child(6), .trace > .s5 { background: var(--trace-5); }
.trace-10 > :nth-child(7), .trace > .s6 { background: var(--trace-6); }
.trace-10 > :nth-child(8), .trace > .s7 { background: var(--trace-7); }
.trace-10 > :nth-child(9), .trace > .s8 { background: var(--trace-8); }
.trace-10 > :nth-child(10), .trace > .s9 { background: var(--trace-9); }

.trace-9 > :nth-child(1) { background: var(--trace-0); }
.trace-9 > :nth-child(2) { background: var(--trace-1); }
.trace-9 > :nth-child(3) { background: var(--trace-2); }
.trace-9 > :nth-child(4) { background: var(--trace-3); }
.trace-9 > :nth-child(5) { background: var(--trace-5); }
.trace-9 > :nth-child(6) { background: var(--trace-6); }
.trace-9 > :nth-child(7) { background: var(--trace-7); }
.trace-9 > :nth-child(8) { background: var(--trace-8); }
.trace-9 > :nth-child(9) { background: var(--trace-9); }

.trace-7 > :nth-child(1) { background: var(--trace-0); }
.trace-7 > :nth-child(2) { background: var(--trace-2); }
.trace-7 > :nth-child(3) { background: var(--trace-3); }
.trace-7 > :nth-child(4) { background: var(--trace-5); }
.trace-7 > :nth-child(5) { background: var(--trace-6); }
.trace-7 > :nth-child(6) { background: var(--trace-8); }
.trace-7 > :nth-child(7) { background: var(--trace-9); }

.trace > .off {
  height: 2px;
  border-radius: 1px;
  background: var(--track);
}

.trace > .now {
  height: 12px;
}

/* The pointer: the one "you are here" mark of the platform. A small triangle over the open step. */
.trace-point {
  height: 22px;
  padding-top: 10px;
}

.trace-point > .now::before {
  content: "";
  position: absolute;
  top: -10px;
  left: 50%;
  margin-left: -5px;
  border: 5px solid transparent;
  border-top: 6px solid var(--link);
  border-bottom: 0;
}

/* Figures under a trace: one for each segment, in line with it. Hidden from a screen reader; the
   words beside the trace say which step is open. */
.trace-figures {
  display: flex;
  gap: 3px;
  margin-top: 2px;
  color: var(--text-2);
  font-size: var(--t-micro);
  font-variant-numeric: tabular-nums;
  line-height: 1.3;
  text-align: center;
}

.trace-figures > span {
  flex: 1 1 0;
  min-width: 0;
}

.trace-figures > .now {
  color: var(--title);
  font-weight: 700;
}

/* A fine trace: many segments (the 79 sections of the report). Narrow gaps; no pointer. */
.trace-fine {
  gap: 1px;
}

.trace-fine > i,
.trace-fine > li {
  min-width: 1px;
  border-radius: 1px;
}

/* The trace as the lower edge of a visit bar: it sits on the bar's bottom line. */
.trace-edge {
  align-items: flex-end;
  gap: 2px;
  height: 7px;
  padding: 0;
  border-bottom: 1px solid var(--line);
}

.trace-edge > i,
.trace-edge > li {
  height: 4px;
  border-radius: 0;
}

.trace-edge > .off {
  height: 1px;
}

.trace-edge > .now {
  height: 6px;
}

/* Where a visit stands: the trace of its seven standings and the word from tbi3/status.py.
   Never one of the status pairs, so "In testing" can never be read as "Borderline".
       <span class="standing" data-state="review">
         <span class="trace trace-7" aria-hidden="true"><i></i><i></i><i></i><i></i><i></i><i></i><i></i></span>
         <span class="standing-word">In review</span>
       </span>
   data-state is the key of the state: scheduled, intake_started, ready, testing, tested, review,
   signed, stopped, cancelled. The stylesheet draws the segments from it. */
.standing {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px var(--s2);
  min-width: 0;
  vertical-align: middle;
}

.standing .trace {
  flex: 0 0 auto;
  gap: 2px;
  width: 75px;
  height: 8px;
}

.standing .trace > i {
  height: 4px;
  border-radius: 1px;
}

.standing-word {
  color: var(--title);
  font-weight: 600;
}

.standing[data-state="scheduled"] .trace > :nth-child(n+2),
.standing[data-state="intake_started"] .trace > :nth-child(n+3),
.standing[data-state="ready"] .trace > :nth-child(n+4),
.standing[data-state="testing"] .trace > :nth-child(n+5),
.standing[data-state="tested"] .trace > :nth-child(n+6),
.standing[data-state="review"] .trace > :nth-child(n+7),
.standing[data-state="cancelled"] .trace > i,
.standing .trace > .off {
  height: 2px;
  background: var(--track);
}

.standing[data-state="scheduled"] .trace > :nth-child(1),
.standing[data-state="intake_started"] .trace > :nth-child(2),
.standing[data-state="ready"] .trace > :nth-child(3),
.standing[data-state="testing"] .trace > :nth-child(4),
.standing[data-state="tested"] .trace > :nth-child(5),
.standing[data-state="review"] .trace > :nth-child(6),
.standing .trace > .now {
  height: 8px;
}

/* Stopped on a red flag: the trace is cut. What was reached is drawn in the neutral of the track,
   the rest is absent, and the word carries the octagon of STOP. */
.standing[data-state="stopped"] .trace > i {
  background: var(--track);
}

.standing[data-state="stopped"] .trace > .off {
  height: 2px;
}

.standing[data-state="stopped"] .standing-word,
.standing.is-stopped .standing-word {
  position: relative;
  padding-left: 20px;
  color: var(--danger-text);
}

.standing[data-state="stopped"] .standing-word::before,
.standing.is-stopped .standing-word::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 0;
  width: 14px;
  height: 14px;
  margin-top: -7px;
  background: var(--danger-text);
  clip-path: polygon(29% 0, 71% 0, 100% 29%, 100% 71%, 71% 100%, 29% 100%, 0 71%, 0 29%);
}

.standing[data-state="cancelled"] .standing-word {
  color: var(--text-2);
}

/* badge('Signed', tone), as ui.js draws it today: a plain word in an edge. The tone is not drawn
   as a status pair any more; only "red" (stopped) changes the colour of the word. New work shows
   where a visit stands with .standing, and keeps .badge for a small fact about a record. */
.badge {
  display: inline-block;
  padding: 1px var(--s2);
  border: 1px solid var(--edge);
  border-radius: 4px;
  background: none;
  color: var(--title);
  font-size: var(--t-micro);
  font-weight: 600;
  line-height: 1.5;
  white-space: nowrap;
  vertical-align: baseline;
}

/* the tone that tbi3/status.py gives a standing is no longer drawn as a colour */
.badge-green,
.badge-yellow,
.badge-gray {
  border-color: var(--edge);
  background: none;
  color: var(--title);
}

.badge-red {
  border-color: var(--danger-text);
  color: var(--danger-text);
}

/* ---- 10. Tables -------------------------------------------------------------------------------- */

/* A table sits on the plate: no box, no upright lines. The column names are small and quiet over
   a line in the edge colour; rows are divided by hairlines. */
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--t-body);
}

.table caption {
  padding-bottom: var(--s2);
  color: var(--title);
  font-size: var(--t-h3);
  font-weight: 600;
  text-align: left;
}

.table th,
.table td {
  padding: 12px 12px 12px 0;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.table th:last-child,
.table td:last-child {
  padding-right: 0;
}

.table thead th {
  padding-top: var(--s2);
  padding-bottom: var(--s2);
  border-bottom: 1px solid var(--edge);
  color: var(--text-2);
  font-size: var(--t-micro);
  font-weight: 600;
  vertical-align: bottom;
}

.table tbody th {
  color: var(--title);
  font-weight: 600;
}

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

.table td.status {
  padding-left: 12px;
  padding-right: 12px;
}

.table .mono {
  overflow-wrap: anywhere;
}

/* A second line inside a cell: the measure under the name of a task. */
.cell-sub {
  display: block;
  color: var(--text-2);
  font-size: var(--t-small);
  font-weight: 400;
}

/* A unit after a figure, in the label colour: 322 ms. */
.u {
  color: var(--text-2);
  font-weight: 400;
}

/* Where a value came from, under its row: the source file, who typed it, who checked it. */
.prov {
  display: flex;
  flex-wrap: wrap;
  gap: 2px var(--s4);
  color: var(--text-2);
  font-size: var(--t-small);
}

.prov b {
  color: var(--text);
  font-weight: 600;
}

.table tr.has-prov > th,
.table tr.has-prov > td {
  border-bottom: 0;
  padding-bottom: 4px;
}

.table tr.prov-row > td {
  padding-top: 0;
}

/* A value that waits for someone: the row is on the tint, and the pointer is not used here. */
.table tbody.is-waiting > tr > th,
.table tbody.is-waiting > tr > td:not(.status) {
  background: var(--tint);
}

.table tbody.is-waiting > tr > :first-child {
  padding-left: 12px;
}

.table tbody.is-waiting > tr > :last-child {
  padding-right: 12px;
}

.table td.table-empty {
  padding: var(--s4) 0;
  color: var(--text-2);
}

/* A table with three or more columns folds where it has no room: each row becomes a block and
   each cell shows its column name, taken from data-label (ui.js fills it from the header row).
   It folds under 600px of screen with no wrapper, and inside .table-box it folds by the width of
   the box, so a table in a narrow column folds on a wide screen too. */
.table-box {
  container: table / inline-size;
  min-width: 0;
}

@media (max-width: 37.49em) {
  .table-stack thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }

  .table-stack,
  .table-stack caption,
  .table-stack tbody,
  .table-stack tr,
  .table-stack th,
  .table-stack td {
    display: block;
    width: 100%;
  }

  /* flow-root: the row holds the margins of its cells, so a row on the tint has no gap in it */
  .table-stack tr {
    display: flow-root;
    padding: var(--s3) 0;
    border-bottom: 1px solid var(--line);
  }

  .table-stack tbody:first-of-type > tr:first-child {
    border-top: 1px solid var(--edge);
  }

  .table-stack th,
  .table-stack td {
    padding: 4px 0;
    border: 0;
  }

  .table-stack tbody th {
    font-size: var(--t-h3);
  }

  .table-stack td.num {
    text-align: left;
    white-space: normal;
  }

  /* A number sits on the line of its column name, at the right. */
  .table-stack td.num[data-label] {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: var(--s3);
  }

  .table-stack td[data-label]::before {
    content: attr(data-label);
    display: block;
    color: var(--text-2);
    font-size: var(--t-micro);
    font-weight: 600;
  }

  .table-stack td[data-label=""]::before {
    content: none;
  }

  /* A status cell keeps its column name, in its own colour, on the line of its word. */
  .table-stack td.status {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 0 var(--s3);
    margin: 4px 0;
    padding: var(--s2) 12px;
    border-radius: var(--r-sm);
  }

  .table-stack td.status[data-label]::before {
    grid-row: 1;
    grid-column: 2;
    color: inherit;
    text-align: right;
  }

  .table-stack td.status .status-word {
    grid-row: 1;
    grid-column: 1;
  }

  .table-stack td.status .status-text {
    grid-row: 2;
    grid-column: 1 / -1;
  }

  .table-stack tr.has-prov {
    padding-bottom: 0;
    border-bottom: 0;
  }

  .table-stack tr.prov-row {
    padding-top: 0;
  }

  .table-stack tbody.is-waiting > tr {
    padding-right: 12px;
    padding-left: 12px;
    background: var(--tint);
  }

  .table-stack tbody.is-waiting > tr > th,
  .table-stack tbody.is-waiting > tr > td:not(.status) {
    background: none;
  }

  .table-stack tbody.is-waiting > tr > :first-child,
  .table-stack tbody.is-waiting > tr > :last-child {
    padding-right: 0;
    padding-left: 0;
  }

  .table-stack tbody.is-waiting > tr > td.status {
    padding-right: 12px;
    padding-left: 12px;
  }
}

@container table (max-width: 31.98rem) {
  .table-stack thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }

  .table-stack,
  .table-stack caption,
  .table-stack tbody,
  .table-stack tr,
  .table-stack th,
  .table-stack td {
    display: block;
    width: 100%;
  }

  /* flow-root: the row holds the margins of its cells, so a row on the tint has no gap in it */
  .table-stack tr {
    display: flow-root;
    padding: var(--s3) 0;
    border-bottom: 1px solid var(--line);
  }

  .table-stack tbody:first-of-type > tr:first-child {
    border-top: 1px solid var(--edge);
  }

  .table-stack th,
  .table-stack td {
    padding: 4px 0;
    border: 0;
  }

  .table-stack tbody th {
    font-size: var(--t-h3);
  }

  .table-stack td.num {
    text-align: left;
    white-space: normal;
  }

  .table-stack td.num[data-label] {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: var(--s3);
  }

  .table-stack td[data-label]::before {
    content: attr(data-label);
    display: block;
    color: var(--text-2);
    font-size: var(--t-micro);
    font-weight: 600;
  }

  .table-stack td[data-label=""]::before {
    content: none;
  }

  .table-stack td.status {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 0 var(--s3);
    margin: 4px 0;
    padding: var(--s2) 12px;
    border-radius: var(--r-sm);
  }

  .table-stack td.status[data-label]::before {
    grid-row: 1;
    grid-column: 2;
    color: inherit;
    text-align: right;
  }

  .table-stack td.status .status-word {
    grid-row: 1;
    grid-column: 1;
  }

  .table-stack td.status .status-text {
    grid-row: 2;
    grid-column: 1 / -1;
  }

  .table-stack tr.has-prov {
    padding-bottom: 0;
    border-bottom: 0;
  }

  .table-stack tr.prov-row {
    padding-top: 0;
  }

  .table-stack tbody.is-waiting > tr {
    padding-right: 12px;
    padding-left: 12px;
    background: var(--tint);
  }

  .table-stack tbody.is-waiting > tr > th,
  .table-stack tbody.is-waiting > tr > td:not(.status) {
    background: none;
  }

  .table-stack tbody.is-waiting > tr > :first-child,
  .table-stack tbody.is-waiting > tr > :last-child {
    padding-right: 0;
    padding-left: 0;
  }

  .table-stack tbody.is-waiting > tr > td.status {
    padding-right: 12px;
    padding-left: 12px;
  }
}

/* For the rare table that cannot fold: it scrolls inside its own frame, never the page. */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--r-sm);
}

.table-wrap:focus-visible {
  outline: var(--focus);
  outline-offset: 2px;
}

/* dataTable(): a column head that sorts is a button filling its cell. The mark shows which way. */
.data-table {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--s3);
  container: table / inline-size;
}

.th-sort {
  appearance: none;
  -webkit-appearance: none;
  display: flex;
  align-items: center;
  gap: var(--s2);
  width: calc(100% + 12px);
  min-height: var(--target);
  margin: -8px -12px -8px 0;
  padding: 8px 12px 8px 0;
  border: 0;
  border-radius: var(--r-sm);
  background: none;
  color: inherit;
  font: inherit;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  touch-action: manipulation;
}

.table th.num .th-sort {
  justify-content: flex-end;
}

.th-sort:focus-visible {
  outline: var(--focus);
  outline-offset: -3px;
}

@media (hover: hover) {
  .th-sort:hover {
    color: var(--title);
  }

  .th-sort:hover .th-sort-label {
    text-decoration: underline;
    text-underline-offset: 3px;
  }
}

.th-sort-mark {
  display: inline-grid;
  flex: 0 0 auto;
  gap: 3px;
}

.th-sort-mark::before,
.th-sort-mark::after {
  content: "";
  width: 0;
  height: 0;
  border: 4px solid transparent;
  opacity: 0.55;
}

.th-sort-mark::before {
  border-top-width: 0;
  border-bottom: 5px solid currentColor;
}

.th-sort-mark::after {
  border-top: 5px solid currentColor;
  border-bottom-width: 0;
}

th[aria-sort="ascending"],
th[aria-sort="descending"] {
  color: var(--title);
}

th[aria-sort="ascending"] .th-sort-mark::before,
th[aria-sort="descending"] .th-sort-mark::after {
  opacity: 1;
}

th[aria-sort="ascending"] .th-sort-mark::after,
th[aria-sort="descending"] .th-sort-mark::before {
  opacity: 0.25;
}

.data-table thead th {
  vertical-align: middle;
}

/* On a phone a folded table shows no column heads, so "Sort by" takes their place. */
.table-sortbar {
  display: none;
  max-width: 24rem;
}

@media (max-width: 37.49em) {
  .table-sortbar {
    display: grid;
  }

  .table-stack .th-sort {
    visibility: hidden;
  }
}

/* ---- 11. A guided procedure: steps, stopwatch, progress ----------------------------------------- */

/* The list of steps: the trace, running down. A step reached is a filled bead in its own stretch
   of the run, with a tick; the open step is a ring in the link colour on the tint; a step to come
   is an empty ring. This is the markup stepper() builds. */
.steps {
  margin: 0;
  padding: 0;
  list-style: none;
}

.step {
  position: relative;
}

.step-row {
  position: relative;
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) auto;
  align-items: start;
  gap: 2px var(--s3);
  min-height: 52px;
  padding: 12px var(--s2);
  border-radius: var(--r-sm);
  color: inherit;
  text-decoration: none;
}

a.step-row:focus-visible,
a.step-row.is-focus {
  outline: var(--focus);
  outline-offset: -3px;
}

@media (hover: hover) {
  a.step-row:hover {
    background: var(--key-hover);
    color: inherit;
  }
}

/* The line between two beads: from the foot of this bead to the head of the next, whatever the
   height of the row. */
.step:not(:last-child)::after {
  content: "";
  position: absolute;
  top: 40px;
  bottom: -12px;
  left: calc(var(--s2) + 13px);
  width: 2px;
  background: var(--track);
}

.step-mark {
  position: relative;
  z-index: var(--z-raised);
  display: grid;
  grid-row: 1 / span 2;
  place-items: center;
  width: 28px;
  height: 28px;
  border: 2px solid var(--track);
  border-radius: 50%;
  color: var(--text-2);
  font-size: var(--t-micro);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  print-color-adjust: exact;
  -webkit-print-color-adjust: exact;
}

.step-title {
  padding-top: 2px;
  color: var(--text);
  font-weight: 500;
}

.step-sub {
  grid-column: 2 / -1;
  color: var(--text-2);
  font-size: var(--t-small);
}

.step-state {
  grid-row: 1;
  grid-column: 3;
  padding-top: 3px;
  color: var(--text-2);
  font-size: var(--t-small);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* Done. The number stays in the page for screen readers and is drawn at no size, so the tick
   stands in its place. The tick is cut from a square that fills the bead, so it is dead centre. */
.step.is-done .step-mark {
  --bead: var(--trace-9);
  border-color: var(--bead);
  background: var(--bead);
  font-size: 0;
}

.step.is-done:nth-child(1) .step-mark { --bead: var(--trace-0); }
.step.is-done:nth-child(2) .step-mark { --bead: var(--trace-1); }
.step.is-done:nth-child(3) .step-mark { --bead: var(--trace-2); }
.step.is-done:nth-child(4) .step-mark { --bead: var(--trace-3); }
.step.is-done:nth-child(5) .step-mark { --bead: var(--trace-4); }
.step.is-done:nth-child(6) .step-mark { --bead: var(--trace-5); }
.step.is-done:nth-child(7) .step-mark { --bead: var(--trace-6); }
.step.is-done:nth-child(8) .step-mark { --bead: var(--trace-7); }
.step.is-done:nth-child(9) .step-mark { --bead: var(--trace-8); }

.step.is-done .step-mark::after {
  content: "";
  position: absolute;
  inset: -2px;
  background: var(--on-trace);
  clip-path: polygon(27% 52%, 35% 44%, 45% 54%, 65% 32%, 73% 40%, 45% 70%);
}

.step.is-done::after {
  background: var(--trace-9);
}

.step.is-done:nth-child(1)::after { background: var(--trace-0); }
.step.is-done:nth-child(2)::after { background: var(--trace-1); }
.step.is-done:nth-child(3)::after { background: var(--trace-2); }
.step.is-done:nth-child(4)::after { background: var(--trace-3); }
.step.is-done:nth-child(5)::after { background: var(--trace-4); }
.step.is-done:nth-child(6)::after { background: var(--trace-5); }
.step.is-done:nth-child(7)::after { background: var(--trace-6); }
.step.is-done:nth-child(8)::after { background: var(--trace-7); }
.step.is-done:nth-child(9)::after { background: var(--trace-8); }

.step.is-done .step-state {
  color: var(--text);
}

/* Current: the one step that is open now. */
.step.is-current .step-row {
  background: var(--tint);
}

.step.is-current .step-mark {
  border-color: var(--link);
  background: var(--tint);
  color: var(--title);
}

.step.is-current .step-title {
  color: var(--title);
  font-weight: 700;
}

.step.is-current .step-sub,
.step.is-current .step-state {
  color: var(--text);
}

@media (hover: hover) {
  .step.is-current a.step-row:hover {
    background: var(--tint);
  }
}

/* Skipped: a dashed ring with a bar, and the reason underneath. */
.step.is-skipped .step-mark {
  border-style: dashed;
  border-color: var(--edge);
  font-size: 0;
}

.step.is-skipped .step-mark::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 12px;
  height: 2px;
  margin: -1px 0 0 -6px;
  background: var(--edge);
}

.step.is-skipped .step-state {
  color: var(--text);
}

/* Where a section of the neurologist's list still wants words: the count is heavy. */
.step.is-short .step-state {
  color: var(--title);
  font-weight: 700;
}

/* A stopwatch. It only shows time. It never stops or blocks the work, and passing the target
   only changes the words. This is what stopwatch() builds: the time and the target. A reading the
   page reports sits in a well. */
.stopwatch {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 2px var(--s3);
  padding: 6px var(--s3);
  border-radius: var(--r);
  background: var(--well);
}

.stopwatch-time {
  color: var(--title);
  font-size: var(--t-reading);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  line-height: 1.1;
}

.stopwatch-target {
  color: var(--text-2);
  font-size: var(--t-small);
}

.stopwatch.is-over .stopwatch-target {
  color: var(--title);
  font-weight: 600;
}

/* The timer of a step: the stopwatch at the size a technician reads at arm's length, with a bar
   of the time against its target under it (a native <progress class="progress">). */
.timer {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0 var(--s4);
  width: 100%;
  padding: var(--s3) var(--s4) var(--s4);
  border-radius: var(--r-lg);
}

.stopwatch-time,
.stopwatch-target {
  white-space: nowrap;
}

.stopwatch.is-over .stopwatch-target {
  white-space: normal;
}

.timer .stopwatch-time {
  font-size: var(--t-clock);
  letter-spacing: -0.03em;
  line-height: 1;
}

.timer .stopwatch-target {
  font-size: var(--t-body);
}

.timer .progress {
  flex: 1 0 100%;
  margin-top: var(--s3);
}

@media (min-width: 48em) {
  [data-role="tech"] .timer {
    --t-clock: 4.5rem;
  }
}

/* Progress: a native <progress class="progress">. Give it a text label next to it. */
.progress {
  appearance: none;
  -webkit-appearance: none;
  display: block;
  width: 100%;
  height: 8px;
  overflow: hidden;
  border: 0;
  border-radius: 4px;
  /* The element's own two colours are a pair that reads: they are what a browser without
     <progress> shows the text inside it in. The track and the bar are drawn by the parts below. */
  background: none;
  color: var(--text);
}

.progress::-webkit-progress-bar {
  background: var(--track);
}

/* Firefox has no part for the track: the element itself is the track. */
@supports (-moz-appearance: none) {
  .progress {
    background: var(--track);
  }
}

.progress::-webkit-progress-value {
  background: var(--title);
}

.progress::-moz-progress-bar {
  background: var(--title);
}

.file-row .progress::-webkit-progress-value {
  background: var(--link);
}

.file-row .progress::-moz-progress-bar {
  background: var(--link);
}

/* ---- 12. Notices ------------------------------------------------------------------------------- */

/* Four kinds, said in words and told apart by their edge. None of them borrows a status colour.
     .notice                 information: a panel inside a hairline
     .notice-attention       something to check: a doubled dark edge
     .notice-error           something failed: a doubled danger edge, the title in the danger colour
     .notice-stop            a visit stopped on a red flag: the octagon of STOP, a doubled danger
                             edge, and a real button to open the visit. Never a solid red block:
                             the solid danger fill is for the STOP control and the STOP sheet.
     .notice-offline         no connection: a trace with a gap in it, and what happens to what was typed
   Put the one action of a notice in <div class="actions"> inside it. */
.notice {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--s1);
  padding: 14px var(--s4);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--panel);
  color: var(--text);
}

.notice-title {
  color: var(--title);
  font-weight: 700;
}

.notice a:not(.btn) {
  color: var(--link);
}

.notice > .actions {
  margin-top: var(--s2);
}

/* A notice may take focus from a script so that it scrolls into view and is read out. */
.notice:focus {
  outline: none;
}

.notice-attention {
  padding: 13px 15px;
  border: 2px solid var(--title);
}

.notice-error {
  padding: 13px 15px;
  border: 2px solid var(--danger-text);
}

.notice-error .notice-title {
  color: var(--danger-text);
}

.notice-stop {
  padding: 13px 15px 13px 51px;
  border: 2px solid var(--danger-text);
  font-weight: 600;
}

.notice-stop::before {
  content: "";
  position: absolute;
  top: 15px;
  left: 15px;
  width: 24px;
  height: 24px;
  background: var(--danger-text);
  clip-path: polygon(29% 0, 71% 0, 100% 29%, 100% 71%, 71% 100%, 29% 100%, 0 71%, 0 29%);
}

.notice-stop .notice-title {
  color: var(--danger-text);
}

.notice-stop > p:not(.notice-title) + p,
.notice-stop .notice-title + p {
  font-weight: 400;
}

/* A notice with its action at the side, from a tablet up. */
@media (min-width: 48em) {
  .notice-row {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    column-gap: var(--s5);
  }

  .notice-row > :not(.actions) {
    grid-column: 1;
  }

  .notice-row > .actions {
    grid-row: 1 / span 3;
    grid-column: 2;
    margin-top: 0;
  }
}

/* No connection. The mark is a trace with a gap. Say what happens to what was typed. */
.notice-offline {
  padding: 13px 15px 13px 63px;
  border: 2px solid var(--title);
}

.notice-offline::before,
.notice-offline::after {
  content: "";
  position: absolute;
  top: 24px;
  left: 15px;
  width: 12px;
  height: 6px;
  border-radius: var(--r-xs);
  background: var(--title);
}

.notice-offline::after {
  left: 39px;
}

/* ---- 13. Toast --------------------------------------------------------------------------------- */

/* A short confirmation at the top of the screen, clear of the action at the bottom of a phone. */
.toasts {
  position: fixed;
  top: var(--s3);
  right: var(--s3);
  left: var(--s3);
  z-index: var(--z-toast);
  display: grid;
  justify-items: center;
  gap: var(--s2);
  pointer-events: none;
}

body.has-demo .toasts {
  top: 48px;
}

/* Under the demonstration strip wherever it is, so the two never cover each other. */
body .demo-banner > .toasts {
  position: absolute;
  top: calc(100% + var(--s3));
  font-size: var(--t-body);
  font-weight: 400;
  text-align: left;
}

/* Without a strip the toasts hang from a slot under the top bar: clear of the bar while it is in
   view, and at the top of the screen once the page has scrolled past it. */
.toast-slot {
  position: sticky;
  top: 0;
  z-index: var(--z-toast);
  height: 0;
}

.toast-slot > .toasts {
  position: absolute;
  top: var(--s3);
}

.toast {
  display: flex;
  align-items: center;
  gap: var(--s2);
  max-width: min(32rem, 100%);
  min-height: var(--target);
  padding: var(--s1) var(--s4);
  border: 1px solid var(--inverse-edge);
  border-radius: var(--r);
  background: var(--inverse);
  color: var(--on-inverse);
  font-weight: 600;
  pointer-events: auto;
}

/* A toast that reports a failure stays until it is closed. It is told apart by a doubled edge. */
.toast-error {
  padding-right: var(--s1);
  border: 2px solid var(--inverse-danger);
}

.toast-text {
  min-width: 0;
  padding: var(--s2) 0;
}

.toast-close {
  appearance: none;
  -webkit-appearance: none;
  flex: 0 0 auto;
  min-width: var(--target);
  min-height: var(--target);
  padding: 0 var(--s3);
  border: 1px solid var(--on-inverse);
  border-radius: var(--r-sm);
  background: none;
  color: var(--on-inverse);
  font: inherit;
  font-size: var(--t-small);
  font-weight: 600;
  cursor: pointer;
}

.toast-close:focus-visible {
  outline-color: var(--on-inverse);
}

/* ---- 14. Dialog and sheet ---------------------------------------------------------------------- */

/* A dialog asks before something that matters. It floats over a dimmed page inside an edge; it
   casts no shadow. On a phone its buttons stack and the confirming one is nearest the thumb. */
.dialog {
  width: min(32rem, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  max-height: calc(100dvh - 32px);
  padding: var(--s5);
  overflow: auto;
  border: 1px solid var(--edge);
  border-radius: var(--r-lg);
  background: var(--float);
  color: var(--text);
}

.dialog::backdrop {
  background: var(--scrim);
}

.dialog-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--s3);
}

.dialog-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: var(--s3);
  margin-top: var(--s2);
}

@media (max-width: 29.99em) {
  .dialog {
    padding: var(--s4);
  }

  .dialog-actions {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
  }
}

/* A sheet is a dialog that rises from the foot of a phone: STOP, "Could not do this".
   From 600px it is an ordinary dialog in the middle of the screen. */
@media (max-width: 37.49em) {
  .dialog.sheet {
    width: 100%;
    max-width: none;
    max-height: calc(100dvh - 48px);
    margin: auto 0 0;
    padding-bottom: calc(var(--s4) + env(safe-area-inset-bottom, 0px));
    border-width: 1px 0 0;
    border-radius: var(--r-lg) var(--r-lg) 0 0;
  }
}

/* A sheet on a small phone holds its whole content on a 320 by 568 screen: the note starts two
   lines tall and grows with what is typed, and the two actions share one row, the way back as
   words and the action as the button, as in the action bar. */
@media (max-width: 29.99em) {
  .dialog.sheet .dialog-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
  }

  .dialog.sheet .dialog-actions > .btn-quiet {
    flex: 0 0 auto;
    max-width: 6.25em;
    padding: 6px var(--s2);
    line-height: 1.25;
    text-align: left;
    text-wrap: balance;
  }

  .dialog.sheet .dialog-actions > .btn:not(.btn-quiet) {
    flex: 1 1 auto;
    width: auto;
    padding-right: var(--s3);
    padding-left: var(--s3);
  }

  .dialog.sheet textarea.input {
    min-height: 4.75rem;
    field-sizing: content;
  }
}

/* The STOP sheet. The emergency instruction comes first, on the one solid danger field of the
   platform; then the note that is needed, the button that stops the visit, and the way back. */
.stop-head {
  position: relative;
  display: grid;
  gap: 6px;
  padding: var(--s4) var(--s4) var(--s4) 60px;
  border-radius: var(--r);
  background: var(--danger);
  color: var(--on-danger);
  font-size: var(--t-lead);
  font-weight: 600;
  line-height: 1.35;
  print-color-adjust: exact;
  -webkit-print-color-adjust: exact;
}

.stop-head::before {
  content: "";
  position: absolute;
  top: var(--s4);
  left: var(--s4);
  width: 30px;
  height: 30px;
  background: var(--on-danger);
  clip-path: polygon(29% 0, 71% 0, 100% 29%, 100% 71%, 71% 100%, 29% 100%, 0 71%, 0 29%);
}

.stop-head::after {
  content: "";
  position: absolute;
  top: calc(var(--s4) + 13px);
  left: calc(var(--s4) + 7px);
  width: 16px;
  height: 4px;
  background: var(--danger);
}

.stop-head h2 {
  color: var(--on-danger);
  font-size: var(--t-h2);
  font-weight: 800;
}

/* ---- 15. File rows ----------------------------------------------------------------------------- */

/* One expected file: waiting, sending, stored or failed. The word is always shown.
   Stored carries the green tick the procedure tells the technician to look for. */
.file-row {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) auto;
  align-items: center;
  gap: 2px var(--s3);
  min-height: 64px;
  padding: var(--s3) var(--s4);
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--panel);
}

.list > li > .file-row {
  padding-right: 0;
  padding-left: 0;
  border: 0;
  border-radius: 0;
  background: none;
}

.file-mark {
  position: relative;
  width: 28px;
  height: 28px;
  border: 2px dashed var(--edge);
  border-radius: 50%;
  print-color-adjust: exact;
  -webkit-print-color-adjust: exact;
}

/* A file name is one long word: it breaks where it must, so it never runs under the state word. */
.file-main {
  display: grid;
  gap: 2px;
  min-width: 0;
  overflow-wrap: anywhere;
}

.file-name {
  color: var(--title);
  font-weight: 600;
}

.file-sub {
  color: var(--text-2);
  font-size: var(--t-small);
}

.file-state {
  color: var(--text);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.file-row .progress,
.file-row .file-actions {
  grid-column: 2 / -1;
}

/* A row under 288px of room (a 320px phone): the name takes the whole line, and the state word
   stands at the right of the line under it. The row is its own container, so this follows the
   room the row has, not the screen. */
.file-row {
  container: file / inline-size;
}

@container file (max-width: 17.99rem) {
  .file-main {
    display: contents;
  }

  .file-name,
  .file-sub {
    min-width: 0;
    overflow-wrap: anywhere;
  }

  .file-name {
    grid-row: 1;
    grid-column: 2 / -1;
  }

  .file-sub {
    grid-row: 2;
    grid-column: 2;
  }

  .file-state {
    grid-row: 2;
    grid-column: 3;
    align-self: start;
  }

  .file-mark {
    grid-row: 1;
    grid-column: 1;
  }
}

.file-row.is-sending .file-mark {
  border-style: solid;
  border-color: var(--link);
}

.file-row.is-stored .file-mark {
  border: 2px solid var(--ok);
  background: var(--ok);
}

.file-row.is-stored .file-mark::after {
  content: "";
  position: absolute;
  inset: -2px;
  background: var(--on-ok);
  clip-path: polygon(27% 52%, 35% 44%, 45% 54%, 65% 32%, 73% 40%, 45% 70%);
}

.file-row.is-stored .file-state {
  color: var(--ok);
}

.file-row.is-failed {
  padding: 11px 15px;
  border: 2px solid var(--danger-text);
}

.list > li > .file-row.is-failed {
  padding: 11px 12px;
  border-radius: var(--r);
}

.file-row.is-failed .file-mark {
  border: 2px solid var(--danger-text);
  background: var(--danger-text);
}

.file-row.is-failed .file-mark::before,
.file-row.is-failed .file-mark::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 14px;
  height: 2.5px;
  margin: -1.25px 0 0 -7px;
  background: var(--panel);
  transform: rotate(45deg);
}

.file-row.is-failed .file-mark::after {
  transform: rotate(-45deg);
}

.file-row.is-failed .file-state,
.file-row.is-failed .file-sub {
  color: var(--danger-text);
}

.file-row.is-failed .file-sub {
  font-weight: 600;
}

/* uploadRow(): a file row a person can send a file from. */
.upload-row .file-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0 var(--s4);
}

.upload-row.is-drop {
  border-color: var(--link);
  background: var(--tint);
}

.upload-row.is-drop .file-sub {
  color: var(--text);
}

/* "Take a photo" is offered only where there is a camera in the hand. */
.upload-camera {
  display: none;
}

@media (pointer: coarse) {
  .upload-camera {
    display: inline-flex;
  }
}

/* ---- 16. Nothing here, loading, saving ---------------------------------------------------------- */

/* Nothing to show. Said plainly, with why and what to do next. The mark is the trace's empty ring:
   a place not reached yet. It sits on the plate; no box is drawn. */
.empty {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  justify-items: start;
  gap: 4px;
  padding: var(--s4) 0 var(--s4) 36px;
}

.empty::before {
  content: "";
  position: absolute;
  top: calc(var(--s4) + 2px);
  left: 2px;
  width: 20px;
  height: 20px;
  border: 2px solid var(--track);
  border-radius: 50%;
}

.empty-title {
  color: var(--title);
  font-weight: 600;
}

.empty-text {
  max-width: 44rem;
  color: var(--text-2);
}

.empty > .btn {
  margin-top: var(--s2);
}

/* The busy mark: a short run moving along a track. It is the one thing on the platform that moves
   by itself. It is still on a patient page and under reduced motion. */
.loading {
  position: relative;
  padding-left: 40px;
}

.loading::before,
.loading::after,
.save-state[data-state="saving"]::before,
.save-state[data-state="saving"]::after {
  content: "";
  position: absolute;
  top: 0.75em;
  left: 0;
  width: 28px;
  height: 4px;
  margin-top: -2px;
  border-radius: var(--r-xs);
  background: var(--track);
}

.loading::after,
.save-state[data-state="saving"]::after {
  width: 10px;
  background: var(--link);
}

/* saveState(): whether what was typed is stored. Always said in words. */
.save-state {
  position: relative;
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0 var(--s3);
  color: var(--text-2);
  font-size: var(--t-small);
}

.save-state[data-state="saving"] {
  padding-left: 40px;
}

.save-state[data-state="saved"] {
  padding-left: 22px;
  color: var(--text);
}

.save-state[data-state="saved"]::before {
  content: "";
  position: absolute;
  top: 0.75em;
  left: 0;
  width: 16px;
  height: 16px;
  margin-top: -8px;
  background: var(--text);
  clip-path: polygon(8% 52%, 21% 39%, 38% 56%, 79% 14%, 92% 27%, 38% 82%);
}

.save-state[data-state="failed"] {
  color: var(--danger-text);
  font-weight: 600;
}

.form-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s2) var(--s4);
}

/* ---- 17. The read-back -------------------------------------------------------------------------- */

/* The patient's own answers, shown back exactly as stored, for the patient to confirm. The stored
   text arrives whole in <pre class="readback">: its lines are kept. It is the record's words, so
   it is set in the record face. A page may show the same text in parts (.readback-part), one for
   each section with a way to change it; it never changes a word of it. */
/* The half em at the right holds the space that hangs at the end of a full line of kept text, so
   that no text reaches past the box. */
.readback {
  max-width: var(--measure);
  padding: var(--s4) 0.5em var(--s4) 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  color: var(--text);
  font-family: var(--font-record);
  font-size: 1.0625em;
  line-height: 1.6;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.readback h2,
.readback h3 {
  margin-top: var(--s4);
  white-space: normal;
}

.readback > :first-child {
  margin-top: 0;
}

.readback-part {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0 var(--s4);
  padding-top: var(--s2);
  border-top: 2px solid var(--rule);
}

/* The title of a part is the stored line. It is stored in capitals and shown in sentence case;
   the words are not changed. */
.readback-title {
  font-size: var(--t-h2);
  text-transform: lowercase;
}

.readback-title::first-letter {
  text-transform: uppercase;
}

.readback-part > .qa-list,
.readback-part > .scores,
.readback-part > .hint {
  flex: 1 0 100%;
}

/* A question and its answer. The question is the tool's (sans, second rank); the answer is the
   patient's (the record face). */
.qa-list {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--s3);
  margin: var(--s2) 0 var(--s4);
}

.qa {
  display: grid;
  gap: 1px;
}

.qa-q {
  color: var(--text-2);
  font-size: var(--t-small);
}

.qa-a {
  margin: 0;
  font-family: var(--font-record);
  font-size: 1.0625em;
  line-height: 1.5;
}

@media (min-width: 37.5em) {
  .qa-cols {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    column-gap: var(--s6);
  }
}

/* The 22 symptom scores: name at the left, score at the right, two columns when there is room. */
.scores {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  margin: var(--s2) 0 var(--s4);
  padding: 0;
  list-style: none;
}

.scores > li {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--s3);
  padding: 6px 0;
  border-bottom: 1px solid var(--line);
  color: var(--text-2);
}

.scores > li > b {
  color: var(--text);
  font-family: var(--font-record);
  font-size: 1.0625em;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}

@media (min-width: 37.5em) {
  .scores {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    column-gap: var(--s6);
  }
}

/* ---- 18. Small helpers --------------------------------------------------------------------------- */

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  border: 0;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* A table caption kept for screen readers only stays one pixel. */
.table caption.sr-only {
  width: 1px;
  padding: 0;
}

.print-only {
  display: none;
}

/* svgImage(): a picture the server sent as text. */
.svg-image {
  display: block;
  height: auto;
}

/* ---- 19. Tabs ------------------------------------------------------------------------------------ */

/* The sections of one page. The chosen tab is heavy over a line in the title colour. Each tab
   keeps the width of its heavy form, so choosing one moves nothing. The tabs wrap; none is hidden. */
.tabs {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--s4);
}

.tabs-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0 var(--s1);
  border-bottom: 1px solid var(--line);
}

.tab {
  appearance: none;
  -webkit-appearance: none;
  display: inline-grid;
  align-content: center;
  justify-items: center;
  min-width: var(--target);
  min-height: var(--target);
  margin: 0 0 -1px;
  padding: 3px var(--s3) 0;
  border: 0;
  border-bottom: 3px solid transparent;
  border-radius: var(--r-sm) var(--r-sm) 0 0;
  background: none;
  color: var(--text-2);
  font: inherit;
  font-weight: 500;
  line-height: 1.25;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.tab::after {
  content: attr(data-label);
  height: 0;
  overflow: hidden;
  font-weight: 700;
  visibility: hidden;
}

.tab[aria-selected="true"] {
  border-bottom-color: var(--title);
  color: var(--title);
  font-weight: 700;
}

@media (hover: hover) {
  .tab:hover {
    background: var(--key-hover);
    color: var(--title);
  }
}

.tab:active,
.tab.is-hover {
  background: var(--key-press);
  color: var(--title);
}

.tab:focus-visible,
.tab.is-focus {
  outline: var(--focus);
  outline-offset: -3px;
}

.tab-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-content: start;
  gap: var(--s4);
}

.tab-panel:focus-visible {
  border-radius: var(--r-sm);
  outline: var(--focus);
  outline-offset: 4px;
}

/* ---- 20. The account page ------------------------------------------------------------------------ */

/* The secret of a sign-in code in groups for typing, its QR picture, and the recovery codes. */
.secret {
  display: flex;
  flex-wrap: wrap;
  gap: 6px var(--s4);
  margin: 0;
  padding: 0;
  list-style: none;
  color: var(--title);
  font-family: var(--font-mono);
  font-size: 1.125rem;
  font-weight: 600;
  letter-spacing: 0.08em;
}

/* A QR picture is always on white, in both themes, so a phone can read it. */
.qr {
  width: 13rem;
  max-width: 100%;
  padding: var(--s2);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--paper);
  image-rendering: pixelated;
}

.codes {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 12.5rem), 1fr));
  gap: var(--s2) var(--s5);
  margin: 0;
  padding: var(--s4);
  border-radius: var(--r);
  background: var(--well);
  color: var(--title);
  font-family: var(--font-mono);
  font-size: var(--t-h3);
  font-weight: 600;
  list-style: none;
}

/* ---- 21. Sign-in ---------------------------------------------------------------------------------- */

/* Three doors: patients, staff, attorneys. This is the markup of signin.html. From 900px the doors
   stand side by side, the staff door in the middle and the widest. Each door hangs from its own
   stretch of the trace by a tap with a ring end, the way a run ends in the logo. */
.signin-main {
  --page-max: 27rem;
  padding-top: var(--s5);
  gap: var(--s4);
}

.signin-brand {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s2) var(--s4);
  color: var(--text-2);
  font-size: var(--t-lead);
  font-weight: 500;
}

.signin-logo {
  width: auto;
  height: 44px;
}

.signin-main h1 {
  font-size: calc(var(--t-display) * 0.75);
  letter-spacing: -0.03em;
  line-height: 1.05;
}

.doors {
  display: grid;
  gap: var(--s2);
  padding: 0;
  list-style: none;
}

.doors a {
  display: inline-flex;
  align-items: center;
  min-height: var(--target);
  font-weight: 600;
}

.doors p + p {
  margin-top: 2px;
}

.door {
  --door: var(--trace-0);
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-content: start;
  gap: var(--s2);
  padding-top: 36px;
  border-top: 3px solid var(--door);
}

.door:nth-of-type(2) {
  --door: var(--trace-4);
}

.door:nth-of-type(3) {
  --door: var(--trace-9);
}

/* the tap: a short run at 45 degrees, ending in a ring */
.door::before {
  content: "";
  position: absolute;
  top: -1px;
  left: 27px;
  width: 3px;
  height: 22px;
  background: var(--door);
  transform: rotate(45deg);
  transform-origin: 0 0;
}

.door::after {
  content: "";
  position: absolute;
  top: 12px;
  left: 0;
  width: 16px;
  height: 16px;
  border: 3px solid var(--door);
  border-radius: 50%;
}

.door + .door {
  margin-top: var(--s4);
}

.door-link {
  display: inline-flex;
  align-items: center;
  justify-self: start;
  gap: 6px;
  min-height: var(--target);
  font-weight: 600;
}

@media (min-width: 56.25em) {
  .signin-main {
    --page-max: 68rem;
    grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.25fr) minmax(0, 0.8fr);
    column-gap: 0;
    padding-top: var(--s7);
    row-gap: var(--s5);
  }

  .signin-main > * {
    grid-column: 1 / -1;
  }

  .signin-main > .door {
    grid-column: auto;
    margin-top: var(--s4);
    padding-right: var(--s6);
  }

  .signin-main > .door:nth-of-type(3) {
    padding-right: 0;
  }

  .signin-logo {
    height: 64px;
  }

  .signin-main h1 {
    font-size: var(--t-display);
  }
}

/* ---- 22. Page layouts ---------------------------------------------------------------------------- */

/* The parts below lay out whole screens. They are here, and not in a page stylesheet, where two
   screens share them. Phone first: one column at 375. A working screen takes two columns from
   900px and three from 1200px: where you are in the whole, the work, what it still needs. */

/* Sign-in by night stands on the void of tbi3.com itself. */
body.signin {
  --page: var(--page-deep);
}

/* The small line over a title that says where the page is in a sequence: "Step 3 of 10". */
.step-count {
  color: var(--text-2);
  font-size: var(--t-small);
  font-weight: 600;
}

/* The visit in the room: who, where it stands, and the one button. */
.room {
  gap: var(--s4);
}

.room-where {
  display: grid;
  gap: var(--s2);
}

@media (min-width: 48em) {
  .room {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr) auto;
    align-items: center;
    gap: var(--s5);
  }
}

/* A working screen: where you are in the whole (.work-rail), the work (.work-main), what it still
   needs (.work-side). One column on a phone: the work first, the rest after it, and the list of
   steps folded away under the work. The technician's visit and the neurologist's case both use it. */
.work {
  gap: var(--s5);
  padding-top: var(--s4);
}

.work-rail {
  display: none;
}

.work-main,
.work-side {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-content: start;
  gap: var(--s4);
  min-width: 0;
}

.work-side {
  gap: var(--s5);
}

/* The pinned bar is a child of the page itself (<main class="work">), after the columns, so that
   it stays at the foot of the screen to the very end of the page. */
.work > .action-bar {
  grid-row: 3;
}

.work-head {
  display: grid;
  gap: var(--s2);
}

.work-head .step-count {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0 var(--s4);
}

.rail-head {
  display: flex;
  justify-content: space-between;
  gap: var(--s3);
  padding: 0 var(--s2) var(--s2);
  color: var(--text-2);
  font-size: var(--t-micro);
  font-weight: 600;
}

@media (min-width: 56.25em) {
  .work {
    grid-template-columns: 15rem minmax(0, 1fr);
    column-gap: var(--s6);
  }

  /* the pinned bar keeps to the column of the work */
  .work > .action-bar {
    grid-column: 2;
    margin-right: 0;
    margin-left: 0;
    padding-right: 0;
    padding-left: 0;
  }

  .work-rail {
    display: block;
    position: sticky;
    top: 112px;
    align-self: start;
    max-height: calc(100vh - 128px - var(--pin-bottom));
    max-height: calc(100dvh - 128px - var(--pin-bottom));
    overflow-y: auto;
  }

  .work-main,
  .work-side {
    grid-column: 2;
  }

  .work-trace,
  .fold-steps {
    display: none;
  }
}

@media (min-width: 75em) {
  .work {
    grid-template-columns: 15rem minmax(0, 1fr) 18rem;
  }

  .work-side {
    grid-row: 1;
    grid-column: 3;
    position: sticky;
    top: 112px;
    align-self: start;
    max-height: calc(100vh - 128px - var(--pin-bottom));
    max-height: calc(100dvh - 128px - var(--pin-bottom));
    overflow-y: auto;
  }
}

/* What to do, in the procedure's own words: read at arm's length. The mark is the ring end of a
   run in the logo. */
.do-list {
  display: grid;
  gap: var(--s2);
  margin: 0;
  padding: 0;
  font-size: var(--t-lead);
  line-height: 1.35;
  list-style: none;
}

.do-list > li {
  position: relative;
  padding-left: 22px;
}

.do-list > li::before {
  content: "";
  position: absolute;
  top: 0.675em;
  left: 0;
  width: 10px;
  height: 10px;
  margin-top: -5px;
  border: 2px solid var(--track);
  border-radius: 50%;
}

/* The readings of a step: blood pressure across the row, the rest two to a line. */
.readings {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--s4);
  max-width: 34rem;
  container: readings / inline-size;
}

.readings-2,
.readings-3 {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: start;
  gap: var(--s4) var(--s3);
}

.readings-3 {
  container: readings / inline-size;
}

@container readings (min-width: 17rem) {
  .readings-2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .readings-3 > .field {
    min-width: 0;
  }
}

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

@container readings (min-width: 0) {
  .readings-3 > .field > .input-reading {
    font-size: min(var(--t-reading), 13cqi);
  }
}

/* A checklist of yes or no items: the words at the left, the two keys at the right from 600px. */
.flags {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  container: flags / inline-size;
}

.flags > .field {
  padding: var(--s3) 0;
  border-bottom: 1px solid var(--line);
}

.flags > .field:first-child {
  border-top: 1px solid var(--line);
}

.flags > p {
  padding-top: var(--s3);
}

@container flags (min-width: 34rem) {
  .flags > .field {
    grid-template-columns: minmax(0, 1fr) 13rem;
    align-items: center;
    column-gap: var(--s4);
  }

  .flags > .field > .label {
    grid-column: 1;
  }

  .flags > .field > .opts {
    grid-row: 1 / span 2;
    grid-column: 2;
  }
}

/* A fold: a part of the page a person opens when they want it (a native <details>). */
.fold {
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.fold > summary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0 var(--s3);
  min-height: var(--target);
  padding: var(--s2) 28px var(--s2) 0;
  position: relative;
  border-radius: var(--r-sm);
  list-style: none;
  cursor: pointer;
}

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

.fold > summary::after {
  content: "";
  position: absolute;
  top: 50%;
  right: 6px;
  width: 9px;
  height: 9px;
  margin-top: -7px;
  border-right: 2px solid var(--text-2);
  border-bottom: 2px solid var(--text-2);
  transform: rotate(45deg);
}

.fold[open] > summary::after {
  margin-top: -2px;
  transform: rotate(-135deg);
}

.fold-title {
  color: var(--title);
  font-weight: 600;
}

.fold-note {
  color: var(--text-2);
  font-size: var(--t-small);
}

.fold > :not(summary) {
  margin-bottom: var(--s3);
}

/* Whether a station is reachable: a word with a mark. Online is the stored green; offline is a
   ring, and the words beside it say since when. */
.conn {
  position: relative;
  padding-left: 18px;
  font-weight: 600;
}

.conn::before {
  content: "";
  position: absolute;
  top: 0.75em;
  left: 0;
  width: 10px;
  height: 10px;
  margin-top: -5px;
  border: 2px solid var(--track);
  border-radius: 50%;
}

.conn.is-online::before {
  border-color: var(--ok);
  background: var(--ok);
}

/* A value that is not entered yet says so in words. */
.not-yet {
  color: var(--text-2);
  font-size: var(--t-small);
}

.table tr.is-now > th,
.table tr.is-now > td {
  background: var(--tint);
}

.table tr.is-now > :first-child {
  padding-left: 12px;
}

/* A table of short figures (the VOMS grid) keeps its cells side by side when it folds: each task
   is a block with its four figures in one line, each under its full name. */
@media (max-width: 37.49em) {
  .table-stack.is-figures tr {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 2px var(--s3);
  }

  .table-stack.is-figures td[data-label]::before {
    white-space: nowrap;
  }

  .table-stack.is-figures tr > th {
    flex: 1 0 100%;
  }

  .table-stack.is-figures tr > td {
    flex: 0 1 auto;
    width: auto;
  }

  .table-stack.is-figures tr.is-now {
    padding-right: 12px;
    padding-left: 12px;
  }

  .table-stack.is-figures tr.is-now > :first-child {
    padding-left: 0;
  }

  .table-stack.is-figures tr.is-now > th,
  .table-stack.is-figures tr.is-now > td {
    background: none;
  }

  .table-stack.is-figures tr.is-now {
    background: var(--tint);
  }
}

@container table (max-width: 31.98rem) {
  .table-stack.is-figures tr {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 2px var(--s3);
  }

  .table-stack.is-figures td[data-label]::before {
    white-space: nowrap;
  }

  .table-stack.is-figures tr > th {
    flex: 1 0 100%;
  }

  .table-stack.is-figures tr > td {
    flex: 0 1 auto;
    width: auto;
  }

  .table-stack.is-figures tr.is-now {
    padding-right: 12px;
    padding-left: 12px;
    background: var(--tint);
  }

  .table-stack.is-figures tr.is-now > :first-child {
    padding-left: 0;
  }

  .table-stack.is-figures tr.is-now > th,
  .table-stack.is-figures tr.is-now > td {
    background: none;
  }
}

/* The visit bar of a case: the patient by name, the facts of the visit, where it stands, and how
   much of the report is written. Under it the trace has one tick for each of the 79 sections,
   thin where a section is not written; on a phone it has one segment for each page of the report. */
.visit-back {
  display: none;
}

.visitbar-case .visit-standing {
  display: none;
  flex: 0 0 auto;
}

.visitbar-case .visit-meta {
  flex: 1 1 auto;
}

.visitbar-case .visit-id {
  flex: 1 1 8rem;
}

.trace-pages {
  gap: 3px;
}

.trace-sections {
  display: none;
}

@media (min-width: 30em) {
  .trace-sections {
    display: flex;
  }

  .trace-pages {
    display: none;
  }
}

@media (min-width: 37.5em) {
  .visitbar-case .visit-standing {
    display: block;
  }
}

@media (min-width: 75em) {
  .visit-back {
    display: inline;
  }

  .visitbar-case .visit-home {
    padding-right: var(--s2);
  }

  .visitbar-case .visit-id {
    flex: 0 1 auto;
  }
}

.visitbar-case .visit-meta {
  display: none;
}

@media (min-width: 75em) {
  .visitbar-case .visit-meta {
    display: flex;
    flex-wrap: nowrap;
    gap: var(--s5);
    white-space: nowrap;
  }
}

/* The pages of the report as a list: the number of the page, its title, and how much of it is
   written. The open page is a key held down. A page that still wants words has a heavy count
   behind an empty ring. */
.index {
  margin: 0;
  padding: 0;
  list-style: none;
}

.index-row {
  display: grid;
  grid-template-columns: 2.75rem minmax(0, 1fr) auto;
  align-items: center;
  gap: 0 var(--s2);
  min-height: var(--target);
  padding: 6px var(--s2);
  border-radius: var(--r-sm);
  color: var(--text);
  line-height: 1.3;
  text-decoration: none;
  transition: background-color var(--quick) var(--ease);
}

.index-n {
  color: var(--text-2);
  font-size: var(--t-small);
  font-variant-numeric: tabular-nums;
}

.index-count {
  color: var(--text-2);
  font-size: var(--t-small);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.index-count.is-short {
  position: relative;
  padding-left: 16px;
  color: var(--title);
  font-weight: 700;
}

.index-count.is-short::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 0;
  width: 10px;
  height: 10px;
  margin-top: -5px;
  border: 2px solid var(--title);
  border-radius: 50%;
}

.index-row[aria-current="true"] {
  background: var(--key-press);
  color: var(--title);
  font-weight: 700;
}

@media (hover: hover) {
  .index-row:hover {
    background: var(--key-hover);
  }

  .index-row[aria-current="true"]:hover {
    background: var(--key-press);
  }
}

.index-row:focus-visible {
  outline: var(--focus);
  outline-offset: -3px;
}

/* A count said as a figure in a ring: how many things. The ring is the logo's ring end. */
.count {
  display: inline-grid;
  place-items: center;
  min-width: 1.75em;
  height: 1.75em;
  padding: 0 0.4em;
  border: 2px solid var(--title);
  border-radius: 999px;
  color: var(--title);
  font-size: var(--t-micro);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

/* What is missing: each thing is a sentence with a link to the place to fix it. */
.missing-list {
  display: grid;
  margin: 0;
  padding: 0;
  border-top: 1px solid var(--line);
  list-style: none;
}

.missing-list > li {
  display: grid;
  gap: 0;
  padding: var(--s3) 0 var(--s1);
  border-bottom: 1px solid var(--line);
}

.missing-list a {
  display: inline-flex;
  align-items: center;
  justify-self: start;
  gap: 6px;
  min-height: var(--target);
  font-weight: 600;
}

.missing-pages {
  display: flex;
  flex-wrap: wrap;
  gap: 0 var(--s4);
}

.missing-pages .count {
  min-width: 1.6em;
  height: 1.6em;
}

/* The values that wait for a second person, each named, each with its own full-size button. */
.check-list {
  display: grid;
  gap: var(--s3);
  margin: var(--s2) 0 0;
  padding: 0;
  list-style: none;
}

.check-list > li {
  display: grid;
  gap: var(--s2);
  padding-top: var(--s3);
  border-top: 1px solid var(--line);
}

@media (min-width: 37.5em) {
  .check-list > li {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: var(--s4);
  }
}

/* The page before and the page after. */
.pager {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--s3);
  padding-top: var(--s3);
  border-top: 1px solid var(--line);
}

.pager-link {
  display: grid;
  align-content: center;
  gap: 1px;
  min-height: var(--target);
  padding: var(--s2) var(--s2);
  border-radius: var(--r-sm);
  text-decoration: none;
}

.pager-link.is-next {
  justify-items: end;
  text-align: right;
}

.pager-way {
  color: var(--text-2);
  font-size: var(--t-small);
}

.pager-title {
  font-weight: 600;
}

@media (hover: hover) {
  .pager-link:hover {
    background: var(--key-hover);
  }
}

/* a part only a phone needs: from 600px the visit bar says it */
@media (min-width: 37.5em) {
  .until-600 {
    display: none !important;
  }
}

/* A bar or a part that a wide screen does not need, because its content stands in the side column. */
@media (min-width: 75em) {
  .until-wide {
    display: none;
  }
}

/* a plain list of documents: no line above the first when it follows a heading */
.doc-list .row {
  min-height: 56px;
}

/* A patient page. One part of the questions to a screen, large type, the calm key. The bar holds
   the logo and whether the answers are saved; its lower edge is the trace of the nine steps. */
.patientbar {
  justify-content: space-between;
  min-height: 52px;
}

.patientbar .brand {
  min-height: 44px;
  margin: 0;
}

.form-patient {
  gap: var(--s5);
}

/* a short answer: a number of hours, a count */
.input-short {
  max-width: 9rem;
}

.readback-total {
  padding-top: var(--s3);
  border-top: 2px solid var(--rule);
  font-weight: 700;
}

/* The question at the end of the read-back. Its buttons are never pinned: the text is read first. */
.confirm {
  margin-top: var(--s4);
}

/* The pipeline: every visit by stage, in the order of a case's life. First the ruler: one cell
   for each stage with its count and its oldest visit; then, under it, the stages that hold visits,
   each with its visits as a worklist, oldest first.
   A stage that is a visit's standing is named with the standing mark, as on every other screen.
   From 1200px the nine stages stand in one row and each carries its own stretch of the trace as
   the bar over it, so the row reads as one trace. Referred and Billed stand before and after a
   visit: they have the neutral bar. An empty stage is a true state: a count of 0 and a word. */
.pipeline {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  margin: 0;
  padding: 0;
  border-top: 1px solid var(--line);
  list-style: none;
}

.stage {
  --stage: var(--track);
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 0 var(--s3);
  min-height: 56px;
  padding: var(--s2) 0;
  border-bottom: 1px solid var(--line);
}

.stage.s0 { --stage: var(--trace-0); }
.stage.s2 { --stage: var(--trace-2); }
.stage.s3 { --stage: var(--trace-3); }
.stage.s5 { --stage: var(--trace-5); }
.stage.s6 { --stage: var(--trace-6); }
.stage.s8 { --stage: var(--trace-8); }
.stage.s9 { --stage: var(--trace-9); }

.stage-name {
  min-width: 0;
}

.stage-count {
  grid-row: 1 / span 2;
  grid-column: 2;
  color: var(--title);
  font-size: var(--t-reading);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  line-height: 1;
}

.stage-count.is-zero {
  color: var(--text-2);
  font-weight: 500;
}

.stage-note {
  grid-column: 1;
  color: var(--text-2);
  font-size: var(--t-small);
}

.stage.is-outside .standing-word {
  color: var(--text);
}

.stage-group {
  display: grid;
  gap: var(--s2);
  margin-top: var(--s4);
}

@media (min-width: 48em) {
  .pipeline {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    column-gap: var(--s5);
  }
}

/* In three columns a long standing word has no room beside its trace. Every stage puts the trace
   above its word, and the two stages that have no trace keep its line empty, so the nine names
   stand on three common lines. */
@media (min-width: 48em) and (max-width: 74.99em) {
  .stage {
    align-content: start;
    align-items: start;
    padding: var(--s3) 0;
  }

  .stage .standing {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }

  .stage.is-outside .stage-name {
    padding-top: 14px;
  }

  /* the count stands beside the name and the first line of the note, in every cell at one height */
  .stage-count {
    align-self: start;
    margin-top: 22px;
  }
}

@media (min-width: 75em) {
  .pipeline {
    grid-template-columns: repeat(9, minmax(0, 1fr));
    column-gap: var(--s2);
    border-top: 0;
  }

  .stage {
    grid-template-columns: minmax(0, 1fr);
    align-content: start;
    align-items: start;
    gap: var(--s1);
    min-height: 9.5rem;
    padding: var(--s3) 0 var(--s3);
    border-top: 4px solid var(--stage);
    border-bottom: 0;
  }

  .stage.is-empty {
    padding-top: calc(var(--s3) + 2px);
    border-top-width: 2px;
  }

  .stage .trace {
    display: none;
  }

  .stage .standing-word {
    font-size: var(--t-small);
    white-space: normal;
  }

  .stage-name {
    min-height: 2.75rem;
  }

  .stage-count {
    grid-row: auto;
    grid-column: 1;
    font-size: var(--t-count);
  }
}

/* The visits of one stage: patient, how long in the stage, the next action, who it waits on. */
@media (max-width: 56.24em) {
  .worklist-stage .row {
    grid-template-columns: minmax(0, 1fr);
  }

  .worklist-stage .wl-stand,
  .worklist-stage .wl-detail {
    grid-column: 1;
  }

  .worklist-stage .wl-stand {
    color: var(--text-2);
    font-size: var(--t-small);
  }
}

@media (min-width: 56.25em) {
  .worklist-head.worklist-stage,
  .worklist-stage .row {
    grid-template-columns: minmax(10rem, 1fr) 9rem minmax(0, 2.2fr) 7rem;
  }

  .worklist-stage .wl-stand {
    grid-column: 2;
  }

  .worklist-stage .wl-next {
    grid-column: 3;
  }

  .worklist-stage .wl-waits {
    grid-column: 4;
  }
}

/* Three short sections side by side from 900px. */
.trio {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--s4);
  margin-top: var(--s3);
}

@media (min-width: 56.25em) {
  .trio {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: var(--s6);
  }

  .trio > .sec + .sec {
    margin-top: 0;
  }
}

/* The stations: the three office machines, one beside the other from 1000px. */
.stations {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--s6);
  margin: 0;
  padding: 0;
  list-style: none;
}

.station {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-content: start;
  gap: var(--s3);
  padding-top: var(--s3);
  border-top: 2px solid var(--rule);
}

.station-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--s3);
}

.station-head .conn {
  flex: 0 0 auto;
}

.station h3 {
  margin-top: var(--s2);
}

.station-upload {
  display: grid;
  gap: var(--s2);
  margin-top: var(--s2);
}

@media (min-width: 62.5em) {
  .stations {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: var(--s6);
  }
}

/* The schedule's bar: the day, the way to the days beside it, the search, and New visit.
   One column on a phone; one line from 900px. */
.daybar {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: end;
  gap: var(--s3) var(--s4);
}

.daybar-move > .btn {
  flex: 1 1 0;
  padding-right: var(--s2);
  padding-left: var(--s2);
}

@media (min-width: 56.25em) {
  .daybar {
    grid-template-columns: 11rem auto minmax(12rem, 1fr) auto;
  }

  .daybar-move > .btn {
    flex: 0 0 auto;
    padding-right: var(--s4);
    padding-left: var(--s4);
  }
}

/* an icon in the place of a unit, at the end of a search field */
.input-group > .unit > .i {
  width: 20px;
  height: 20px;
}

/* ---- 30. Motion ---------------------------------------------------------------------------------- */

/* Everything on the platform is there without motion. Two things change over time: a colour, when
   a control changes state (the transitions above, 120ms), and the busy mark below. Nothing flashes,
   lifts, slides in or pulses. The busy mark is still on a patient page and under reduced motion. */
@keyframes tbi3-busy {
  from { transform: translateX(0); }
  to { transform: translateX(18px); }
}

@keyframes tbi3-busy-wide {
  from { transform: translateX(0); }
  to { transform: translateX(194%); }
}

@media (prefers-reduced-motion: no-preference) {
  .loading::after,
  .save-state[data-state="saving"]::after {
    animation: tbi3-busy 0.9s var(--ease) infinite alternate;
  }

  .btn[aria-busy="true"]::after {
    animation: tbi3-busy-wide 1.1s var(--ease) infinite alternate;
  }

  :root.patient .loading::after,
  :root.patient .save-state[data-state="saving"]::after,
  :root.patient .btn[aria-busy="true"]::after,
  [data-role="patient"] .loading::after,
  [data-role="patient"] .save-state[data-state="saving"]::after,
  [data-role="patient"] .btn[aria-busy="true"]::after {
    animation: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition: none !important;
    animation: none !important;
    scroll-behavior: auto !important;
  }
}

/* ---- 31. Forced colours -------------------------------------------------------------------------- */

@media (forced-colors: active) {
  .opt > input:checked + span,
  .check > input:checked + .check-box {
    forced-color-adjust: none;
    border-color: Highlight;
    background: Highlight;
    color: HighlightText;
  }

  .check > input:checked + .check-box::after,
  .opts-stack .opt > input:checked + span::after {
    background: HighlightText;
  }

  .step.is-current .step-mark,
  .step.is-done .step-mark,
  .file-row.is-stored .file-mark,
  .file-row.is-failed .file-mark,
  .trace > i,
  .trace > li,
  .status-word::before,
  .status-word::after,
  .btn-stop::before,
  .stop-head,
  .demo-banner {
    forced-color-adjust: none;
  }
}

/* ---- 32. Print ----------------------------------------------------------------------------------- */

/* A page always prints with the day tokens (the night blocks of tokens.css are inside "screen").
   The frame and the controls are left out, the content prints black on white, and the status
   colours keep their fills, their words and their marks. Written for the read-back, the patient
   link sheet and the recovery codes, and safe for any page. */
@page {
  margin: 14mm;
}

@media print {
  html,
  html.patient {
    font-size: 11pt;
  }

  body {
    background: var(--paper);
    color: var(--on-paper);
  }

  .skip,
  .topbar-end,
  .topbar-menu,
  .back,
  .toasts,
  .action-bar,
  .actions,
  .btn,
  .btn-stop,
  .link-btn,
  .no-print,
  dialog {
    display: none !important;
  }

  .print-only {
    display: block;
  }

  .frame,
  .demo-banner {
    position: static;
  }

  .demo-banner {
    border: 1px solid var(--on-paper);
    background: none;
    color: var(--on-paper);
  }

  .topbar-bar,
  .frame {
    border-bottom: 1px solid var(--on-paper);
    background: none;
  }

  .topbar-row,
  .visitbar,
  .page-head,
  main {
    max-width: none;
    padding-right: 0;
    padding-left: 0;
  }

  a {
    color: inherit;
    text-decoration: none;
  }

  h1,
  h2,
  h3,
  h4 {
    color: var(--on-paper);
    break-after: avoid;
  }

  .panel,
  .notice,
  .cards,
  .cards > li,
  .codes,
  .stopwatch {
    border-color: var(--on-paper);
    background: none;
  }

  .sec,
  .readback-part,
  .list,
  .list > li,
  .table th,
  .table td,
  .table thead th {
    border-color: var(--on-paper);
  }

  .readback {
    max-width: none;
    padding: 0;
    border: 0;
    font-size: 11pt;
    line-height: 1.45;
  }

  .hint,
  .muted,
  .row-sub,
  .row-time,
  .dl dt,
  .facts dt,
  .step-sub,
  .file-sub,
  .qa-q,
  .cell-sub,
  .prov,
  .table thead th {
    color: var(--on-paper);
  }

  .row,
  .step,
  .file-row,
  .table tr,
  .notice,
  .field,
  .qa {
    break-inside: avoid;
  }

  .table thead {
    display: table-header-group;
  }

  /* printOnly(): one part of the page goes to the printer and nothing else does. */
  body.print-solo-on * {
    visibility: hidden !important;
  }

  body.print-solo-on .print-solo,
  body.print-solo-on .print-solo * {
    visibility: visible !important;
  }

  body.print-solo-on .print-solo {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
  }

  .table-sortbar,
  .th-sort-mark {
    display: none !important;
  }

  .th-sort {
    visibility: visible !important;
  }

  .badge,
  .codes {
    border: 1px solid var(--on-paper);
  }
}

/* ---- 40. The kit page only ----------------------------------------------------------------------- */

.kit-toc {
  display: flex;
  flex-wrap: wrap;
  gap: 0 var(--s4);
  padding: 0;
  list-style: none;
}

.kit-toc a {
  display: inline-flex;
  align-items: center;
  min-width: var(--target);
  min-height: var(--target);
}

.kit-section {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--s4);
  margin-top: var(--s4);
  padding-top: var(--s4);
  border-top: 2px solid var(--rule);
  scroll-margin-top: 48px;
}

.kit-section > h3 {
  margin-top: var(--s3);
}

.kit-example {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-content: start;
  gap: var(--s3);
  max-width: 46rem;
  min-width: 0;
}

.kit-wide {
  max-width: none;
}

.kit-narrow,
.kit-note {
  max-width: 46rem;
}

.kit-note {
  color: var(--text-2);
}

.kit-narrow-col {
  max-width: 22rem;
}

.kit-states {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 14rem), 1fr));
  align-items: end;
  gap: var(--s4);
}

.kit-states-6 {
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 9.5rem), 1fr));
}

.kit-states-wide {
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 22rem), 1fr));
}

.kit-states-top {
  align-items: start;
}

.kit-state {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-content: start;
  gap: 6px;
  min-width: 0;
}

.kit-state-name {
  color: var(--text-2);
  font-size: var(--t-small);
}

.kit-state > .btn,
.kit-state > .btn-stop,
.kit-state > .link-btn,
.kit-state > .stopwatch:not(.timer) {
  justify-self: start;
}

/* a part that floats or sticks in a real page stands still here */
.kit-static {
  position: static;
  max-width: 100%;
  margin: 0;
}

.kit-pair {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--s5);
}

.kit-trio {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--s5);
}

@media (min-width: 56.25em) {
  .kit-pair {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: start;
  }

  .kit-trio {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    align-items: start;
  }
}

/* a region shown in another tuning carries that tuning's own plate */
.kit-tuning {
  padding: var(--s4);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--page);
  color: var(--text);
  font-size: var(--t-body);
  line-height: var(--leading);
}

/* the same, with no frame: the part takes the whole width of the page, as it does on a phone */
.kit-flat {
  padding: 0;
  border: 0;
  border-radius: 0;
}

.kit-theme {
  max-width: 24rem;
}

.kit-logos {
  gap: var(--s5);
}

.kit-standings,
.kit-files {
  display: grid;
  gap: var(--s3);
  margin: 0;
  padding: 0;
  list-style: none;
}

.kit-files {
  max-width: 46rem;
}

.kit-standings {
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 15rem), 1fr));
}

.kit-code > summary {
  display: inline-flex;
  align-items: center;
  gap: var(--s2);
  min-height: var(--target);
  padding: 0 var(--s1) 0 0;
  border-radius: var(--r-sm);
  color: var(--link);
  font-weight: 600;
  list-style: none;
  cursor: pointer;
}

.kit-code > summary::-webkit-details-marker {
  display: none;
}

.kit-code > summary::before {
  content: "";
  width: 8px;
  height: 8px;
  margin: 0 2px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(-45deg);
}

.kit-code[open] > summary::before {
  transform: rotate(45deg);
}

.kit-code pre,
.kit-pre {
  max-height: 24rem;
  padding: var(--s3);
  overflow: auto;
  border-radius: var(--r);
  background: var(--well);
  font-family: var(--font-mono);
  font-size: var(--t-micro);
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.kit-pre {
  max-height: none;
}

.kit-swatches {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 15rem), 1fr));
  gap: var(--s3);
  padding: 0;
  list-style: none;
}

.kit-swatch {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  align-items: center;
  gap: 0 var(--s3);
}

.kit-chip {
  grid-row: span 2;
  width: 44px;
  height: 44px;
  border: 1px solid var(--edge);
  border-radius: var(--r-sm);
  print-color-adjust: exact;
  -webkit-print-color-adjust: exact;
}

.kit-chip-page { background: var(--page); }
.kit-chip-panel { background: var(--panel); }
.kit-chip-key { background: var(--key); }
.kit-chip-key-hover { background: var(--key-hover); }
.kit-chip-key-press { background: var(--key-press); }
.kit-chip-well { background: var(--well); }
.kit-chip-bar { background: var(--bar); }
.kit-chip-float { background: var(--float); }
.kit-chip-text { background: var(--text); }
.kit-chip-text-2 { background: var(--text-2); }
.kit-chip-title { background: var(--title); }
.kit-chip-line { background: var(--line); }
.kit-chip-edge { background: var(--edge); }
.kit-chip-rule { background: var(--rule); }
.kit-chip-primary { background: var(--primary); }
.kit-chip-link { background: var(--link); }
.kit-chip-tint { background: var(--tint); }
.kit-chip-chosen { background: var(--chosen); }
.kit-chip-danger { background: var(--danger); }
.kit-chip-danger-text { background: var(--danger-text); }
.kit-chip-ok { background: var(--ok); }
.kit-chip-demo { background: var(--demo); }
.kit-chip-track { background: var(--track); }
.kit-chip-trace-0 { background: var(--trace-0); }
.kit-chip-trace-1 { background: var(--trace-1); }
.kit-chip-trace-2 { background: var(--trace-2); }
.kit-chip-trace-3 { background: var(--trace-3); }
.kit-chip-trace-4 { background: var(--trace-4); }
.kit-chip-trace-5 { background: var(--trace-5); }
.kit-chip-trace-6 { background: var(--trace-6); }
.kit-chip-trace-7 { background: var(--trace-7); }
.kit-chip-trace-8 { background: var(--trace-8); }
.kit-chip-trace-9 { background: var(--trace-9); }
.kit-chip-ink { background: var(--ink); }
.kit-chip-action { background: var(--action); }
.kit-chip-surface { background: var(--surface); }
.kit-chip-muted { background: var(--muted); }
.kit-chip-error { background: var(--error); }
.kit-chip-white { background: var(--white); }
.kit-chip-soft { background: var(--action-soft); }
.kit-chip-green { background: var(--green-fill); }
.kit-chip-yellow { background: var(--yellow-fill); }
.kit-chip-red { background: var(--red-fill); }
.kit-chip-gray { background: var(--gray-fill); }

.kit-swatch-name {
  color: var(--title);
  font-weight: 600;
}

.kit-swatch-value {
  color: var(--text-2);
  font-size: var(--t-small);
}

.kit-type {
  display: grid;
  gap: 2px;
  padding: var(--s3) 0;
  border-bottom: 1px solid var(--line);
}

.kit-type > :first-child {
  color: var(--title);
  line-height: 1.15;
}

.kit-t-display { font-size: var(--t-display); font-weight: 700; letter-spacing: -0.03em; }
.kit-t-h1 { font-size: var(--t-h1); font-weight: 700; letter-spacing: -0.02em; }
.kit-t-h2 { font-size: var(--t-h2); font-weight: 700; letter-spacing: -0.015em; }
.kit-t-h3 { font-size: var(--t-h3); font-weight: 600; }
.kit-t-lead { font-size: var(--t-lead); }
.kit-t-body { font-size: var(--t-body); }
.kit-t-small { font-size: var(--t-small); }
.kit-t-micro { font-size: var(--t-micro); font-weight: 600; }
.kit-t-clock { font-size: var(--t-clock); font-weight: 700; letter-spacing: -0.03em; }
.kit-t-count { font-size: var(--t-count); font-weight: 700; letter-spacing: -0.02em; }
.kit-t-reading { font-size: var(--t-reading); font-weight: 700; }

/* ---- Home on a demonstration: the walk of the made-up patient (home.js drawWalk) ---------------------------
   Three steps in order. The step that is next carries the one filled button and a stronger edge; a step done
   is quieter. Nothing here exists off a demonstration. */
.walk-intro {
  max-width: var(--measure);
  font-size: var(--t-lead);
}

.walk-visit {
  margin-top: var(--s3);
}

.walk-visit h3:focus {
  outline: none;
}

.walk-visit h3:focus-visible {
  outline: var(--focus);
  outline-offset: 2px;
}

.walk-steps {
  display: grid;
  gap: var(--s2);
  margin: 0;
  padding: 0;
  list-style: none;
}

.walk-step {
  display: grid;
  gap: var(--s2);
  padding: var(--s3);
  border: 1px solid var(--line);
  border-radius: var(--r);
}

.walk-step.is-next {
  border: 2px solid var(--primary);
  padding: calc(var(--s3) - 1px);
}

.walk-step.is-done .walk-title {
  color: var(--text-2);
}

.walk-words {
  display: grid;
  gap: 2px;
}

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

.walk-state {
  color: var(--text-2);
  font-size: var(--t-small);
}

.walk-step.is-next .walk-state {
  color: var(--text);
  font-weight: 600;
}

@media (min-width: 48em) {
  .walk-step {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
  }
}

/* The package check (static/package.js), on the Referrals page and the front desk's visit page: a held package is
   its row, why it is held, what was checked and what can be done. */
.pc-held > .pc-item {
  display: grid;
  gap: var(--s3);
  padding: var(--s4) 0;
}

.pc-held > .pc-item > .row {
  padding: 0;
  min-height: 0;
  border: 0;
}

.pc-lines {
  display: grid;
  gap: var(--s2);
}
