/* ==========================================================================
   CRAscoping.com: the core stylesheet, loaded on every public page.
   The page families have a file each in css/pages/ (asked for by the page: 'styles' in render_page()).
   Conventions, tokens, breakpoints and layout primitives: css/README.md.

   Layers, weakest first. A later layer wins over an earlier one whatever the specificity, so a page file
   never needs a longer selector (or !important) to adjust a component.
   ========================================================================== */
@layer reset, tokens, base, layout, components, pages, utilities;

/* ==========================================================================
   reset
   ========================================================================== */
@layer reset {
  *,
  *::before,
  *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
  }

  /* The hidden attribute hides, whatever display a class gives (!important: see "Layers" in css/README.md) */
  [hidden]:not([hidden="until-found"]) {
    display: none !important;
  }
}

/* ==========================================================================
   tokens
   Breakpoints (custom properties cannot be used in a media query: this list is the reference).
   Mobile first, min-width, in em:
     --bp-xs: 30em      480px   two columns become four (figures), rows get their button beside them
     --bp-sm: 40em      640px   first two-column grids
     --bp-md: 48em      768px   wide cards, form labels beside fields
     --bp-nav: 60em     960px   the header shows its menu instead of the menu button (the whole menu fits)
     --bp-lg: 64em      1024px  two-column pages, three-column pricing, footer on one line
   The core itself only uses nav (header) and lg (footer): everything else in it is fluid.
   ========================================================================== */
@layer tokens {
  :root {
    /* A browser without light-dark() (Safari before 17.5, Chrome before 123) gets the light theme. */
    color-scheme: light;

    /* fonts */
    --font-sans: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;

    /* type scale (the "-plus" steps are the in-between sizes the site uses today, to be folded into their
       neighbour when a page is redesigned; five more sizes are still written as they were in the rules:
       0.76, 0.775, 0.8125, 0.82 and 0.92rem, see css/README.md) */
    --fs-xs: 0.75rem;        /* 12px    the smallest text: labels, badges, meta */
    --fs-xs-plus: 0.78rem;   /* 12.5px  hints of the catalogue */
    --fs-sm: 0.8rem;         /* 12.8px  small text, menus */
    --fs-sm-plus: 0.825rem;  /* 13.2px  meta lines, small notes */
    --fs-md: 0.85rem;        /* 13.6px  notes, boxes */
    --fs-md-plus: 0.875rem;  /* 14px    fields, buttons, subtitles */
    --fs-lg: 0.9rem;         /* 14.4px  running text of documents */
    --fs-lg-plus: 0.95rem;   /* 15.2px  titles inside a card */
    --fs-xl: 1rem;           /* 16px */
    --fs-xl-plus: 1.05rem;   /* 16.8px */
    --fs-2xl: 1.1rem;        /* 17.6px */
    --fs-2xl-plus: 1.15rem;  /* 18.4px  section titles of documents, dialog titles */
    --fs-3xl: 1.25rem;       /* 20px    card titles */
    --fs-4xl: 1.4rem;        /* 22.4px */
    --fs-5xl: 1.5rem;        /* 24px    figures */
    --fs-display: clamp(1.6rem, 1.34rem + 1.066vw, 2.25rem); /* page titles, fluid: 25.6px at 390px wide, 36px at 1366px */
    --fs-icon-md: 1.6rem;    /* icons of the icon font */
    --fs-icon-lg: 1.75rem;
    --fs-icon-xl: 2.25rem;

    /* space scale: --space-N is N x 0.25rem */
    --space-0-5: 0.125rem;
    --space-1: 0.25rem;
    --space-1-5: 0.375rem;
    --space-2: 0.5rem;
    --space-2-5: 0.625rem;
    --space-3: 0.75rem;
    --space-3-5: 0.875rem;
    --space-4: 1rem;
    --space-5: 1.25rem;
    --space-6: 1.5rem;
    --space-8: 2rem;
    --space-9: 2.25rem;
    --space-10: 2.5rem;
    --space-12: 3rem;
    --space-14: 3.5rem;

    /* fluid spacing: each grows with the width of the window, from its value at 390px wide to its value at
       1366px wide (the values of the former phone and desktop layouts), and stops at both ends */
    --gutter: clamp(0.75rem, 0.65rem + 0.41vw, 1rem);                    /* side margin of the page: 12px to 16px */
    --space-main-start: clamp(0.75rem, 0.45rem + 1.23vw, 1.5rem);        /* above the content of the page: 12px to 24px */
    --space-main-end: clamp(0.75rem, -0.149rem + 3.689vw, 3rem);         /* under the content of the page: 12px to 48px */
    --space-section-block: clamp(1.5rem, 0.9rem + 2.46vw, 3rem);         /* top and bottom padding of a document card: 24px to 48px */
    --space-section-inline: clamp(1.25rem, 0.351rem + 3.689vw, 3.5rem);  /* side padding of a document card: 20px to 56px */

    /* the notch and the rounded corners of a phone (viewport-fit=cover in the layout): 0 everywhere else */
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-end: env(safe-area-inset-right, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --safe-start: env(safe-area-inset-left, 0px);

    /* radii */
    --radius-xs: 0.25rem;
    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-control: 0.6rem;  /* menu entries, small controls */
    --radius-lg: 0.75rem;      /* fields, buttons, inner boxes */
    --radius-xl: 1rem;         /* cards */
    --radius-full: 9999px;

    /* border widths */
    --border-width: 1px;
    --border-width-strong: 2px;

    /* shadows */
    --shadow-card: 0 1px 3px rgba(0, 0, 0, 0.05);
    --shadow-header: 0 2px 8px rgba(0, 0, 0, 0.04);
    --shadow-dropdown: 0 12px 32px rgba(15, 23, 42, 0.12);
    --shadow-drawer: -4px 0 24px rgba(0, 0, 0, 0.12);
    --shadow-toast: 0 12px 32px rgba(0, 0, 0, 0.22);
    --shadow-dialog: 0 20px 50px rgba(0, 0, 0, 0.25);
    --shadow-focus-ring: 0 0 0 3px rgba(33, 122, 255, 0.15);

    /* motion */
    --duration-fast: 0.15s;
    --duration: 0.2s;
    --duration-slow: 0.3s;

    /* stacking */
    --z-sticky: 100;      /* the header */
    --z-dropdown: 120;    /* a menu opened from the header */
    --z-backdrop: 998;
    --z-drawer: 999;
    --z-skip-link: 1000;
    --z-toast: 1200;

    /* widths */
    --width-main: max(46rem, 80vw - 2rem);  /* the content column at most: 46rem, then four fifths of the window */
    --width-footer: 75rem;
    --width-narrow: 28.125rem;              /* a single small card (sign-in) */

    /* controls: one height per size, shared by buttons and fields */
    --control-height: 2.75rem;        /* 44px  buttons (.btn) and fields */
    --control-height-sm: 2rem;        /* 32px  small buttons (.btn-sm) */
    --control-height-dialog: 2.5rem;  /* 40px  buttons of a dialog (.verify-btn) */
    --target-min: 2.75rem;            /* 44px  the smallest touch target (pointer: coarse) */
    --header-offset: 5rem;            /* room kept above an anchor for the sticky header */

    /* colours: surfaces */
    --surface-page: #ffffff;  /* the page itself, under the cards */
    --surface-page-translucent: rgba(255, 255, 255, 0.96);  /* the sticky header before it is scrolled */
    --surface-card: #ffffff;  /* cards, menus, dialogs, fields on a sunken surface */
    --surface-sunken: #f8fafc;  /* fields, inner boxes, table heads: one step below a card */
    --surface-muted: #f1f5f9;  /* neutral badges and quiet buttons */
    --surface-strong: #e2e8f0;  /* tracks of meters, hover of quiet buttons */
    --surface-neutral: #f3f4f6;  /* chat: grey controls */
    --surface-neutral-strong: #e5e7eb;  /* chat: hover of grey controls; chart segment "not possible" */
    --surface-neutral-stronger: #e1e4e8;  /* chat: hover of the reset button */
    --surface-inverse: #0f172a;  /* code blocks: dark in both themes */
    --overlay-backdrop: rgba(15, 23, 42, 0.45);  /* behind the mobile menu */
    --neutral-solid: #cbd5e1;  /* chart segment "Out of scope" */
    --overlay-edge: rgba(15, 23, 42, 0.14);  /* the shadow at the edge of a scrolling table */

    /* colours: brand and accent */
    --accent: #0044aa;  /* filled buttons, meters: the brand blue as a background */
    --accent-hover: #217aff;  /* hover of a filled button; chart segment "Default" */
    --accent-pressed: #003388;  /* chat: hover of the send button */
    --accent-tint-1: #f4f8ff;  /* the lightest blue: highlighted cards, hovered menu entries, notices */
    --accent-tint-2: #eff6ff;  /* soft blue panels and chips */
    --accent-tint-3: #e8f0fe;  /* hover of a blue-tinted control */
    --accent-tint-4: #dbe8ff;  /* the strongest tint: drag-over, a new row */
    --brand-blue: #0044aa;  /* the brand blue, the same in both themes (accent-color of native controls) */
    --brand-blue-light: #217aff;  /* the light brand blue, the same in both themes (scrollbar thumb) */
    --brand-surface: #f8fafc;  /* the light brand grey, the same in both themes (scrollbar track) */

    /* colours: text and icons */
    --text-strong: #0f172a;  /* titles and the default text of the page */
    --text-emphasis: #1e293b;  /* text of a callout */
    --text: #334155;  /* running text */
    --text-muted: #475569;  /* secondary text, labels */
    --text-subtle: #64748b;  /* hints, meta lines, counters */
    --text-faint: #8da1be;  /* the quietest text: footer, placeholders of content */
    --text-disabled: #94a3b8;  /* inactive labels */
    --text-decorative: #cbd5e1;  /* separators drawn with a character */
    --text-link: #0044aa;  /* links and everything written in the brand blue */
    --text-link-hover: #217aff;  /* a link under the pointer; the current page in the menu */
    --text-on-accent: #ffffff;  /* text on a filled (accent) background */
    --text-on-inverse: #f8fafc;  /* text on the inverse surface */
    --text-neutral-strong: #24292e;  /* chat: text of an answer */
    --text-neutral: #586069;  /* chat: grey controls */
    --text-neutral-subtle: #6a737d;  /* chat: small print */

    /* colours: borders and outlines */
    --border: #e2e8f0;  /* the default border of cards, boxes and separators */
    --border-strong: #cbd5e1;  /* fields, quiet buttons, dashed placeholders */
    --border-faint: #f1f5f9;  /* a separator under a section title */
    --border-ghost: #f8fafc;  /* separators between the cells of a product card */
    --border-accent: #0044aa;  /* highlighted cards and selected controls */
    --border-accent-soft: #c0d8ff;  /* blue-tinted panels */
    --border-accent-pale: #c8e1ff;  /* blue-tinted notices and chips */
    --border-accent-mid: #93c5fd;  /* hover of a blue-tinted chip */
    --border-focus: #217aff;  /* focused field, current page in the menu */
    --focus-ring: #217aff;  /* the outline of keyboard focus */
    --border-on-accent: rgba(255, 255, 255, 0.7);  /* an outline drawn on a filled button */
    --border-neutral: #e1e4e8;  /* chat: panels */
    --border-neutral-strong: #d1d5da;  /* chat: fields and controls */
    --border-neutral-stronger: #bac0c7;  /* chat: hover of a control */
    --border-neutral-faint: #f0f2f5;  /* chat: separators inside an answer */

    /* colours: status: info */
    --info-bg: #e0f2fe;
    --info-border: #bae6fd;
    --info-text: #0369a1;

    /* colours: status: success ("done" is the teal of a finished action, e.g. copied) */
    --success-bg: #dcfce7;
    --success-border: #86efac;
    --success-text: #166534;
    --success-text-strong: #047857;  /* a positive word in running text */
    --done-bg: #e6fffa;
    --done-border: #79d5cc;
    --done-text: #047481;

    /* colours: status: warning (yellow, also "Important class I") and caution (orange, also "Important class II") */
    --warning-bg: #fef3c7;
    --warning-border: #fde047;
    --warning-text: #92400e;
    --warning-text-strong: #b45309;  /* a warning word in running text */
    --warning-solid: #fde047;  /* chart segment */
    --caution-bg: #ffedd5;
    --caution-border: #fdba74;
    --caution-text: #9a3412;
    --caution-solid: #fdba74;  /* chart segment */

    /* colours: status: danger (red, also "Critical") */
    --danger-bg: #fee2e2;
    --danger-bg-hover: #fecaca;
    --danger-bg-soft: #fef2f2;  /* error boxes */
    --danger-border: #fca5a5;
    --danger-border-alt: #feb2b2;  /* chat: error bubble */
    --danger-text: #991b1b;
    --danger-text-strong: #b91c1c;  /* error lines */
    --danger-text-vivid: #dc2626;  /* error boxes: the same red in both themes */
    --danger-text-alt: #c53030;  /* chat: error bubble */
    --danger-text-deep: #742a2a;  /* chat: error details */
    --danger-solid: #ef4444;  /* a meter that is full */
    --danger-solid-soft: #f87171;  /* chart segment */
  }

  /* Both themes: light-dark() takes the first value on a light page, the second on a dark one; the browser
     follows the device (color-scheme), unless the visitor chose a theme: data-theme on <html>, set by
     js/theme.js (visitor) or by the server (signed-in customer, includes/theme.php). */
  @supports (color: light-dark(#000, #fff)) {
    :root {
      color-scheme: light dark;
      --surface-page: light-dark(#ffffff, #020617);
      --surface-page-translucent: light-dark(rgba(255, 255, 255, 0.96), rgba(2, 6, 23, 0.96));
      --surface-card: light-dark(#ffffff, #0f172a);
      --surface-sunken: light-dark(#f8fafc, #131a2d);
      --surface-muted: light-dark(#f1f5f9, #161e30);
      --surface-strong: light-dark(#e2e8f0, #202736);
      --surface-neutral: light-dark(#f3f4f6, #171e30);
      --surface-neutral-strong: light-dark(#e5e7eb, #212836);
      --surface-neutral-stronger: light-dark(#e1e4e8, #242a38);
      --neutral-solid: light-dark(#cbd5e1, #2b3344);
      --accent: light-dark(#0044aa, #1565d8);
      --accent-hover: light-dark(#217aff, #1852aa);
      --accent-pressed: light-dark(#003388, #1565d8);
      --accent-tint-1: light-dark(#f4f8ff, #192943);
      --accent-tint-2: light-dark(#eff6ff, #1b2e47);
      --accent-tint-3: light-dark(#e8f0fe, #1d2e4d);
      --accent-tint-4: light-dark(#dbe8ff, #203355);
      --text-strong: light-dark(#0f172a, #f1f2f6);
      --text-emphasis: light-dark(#1e293b, #d8dce6);
      --text: light-dark(#334155, #b3bbcf);
      --text-muted: light-dark(#475569, #94a0bb);
      --text-subtle: light-dark(#64748b, #7c8aab);
      --text-link: light-dark(#0044aa, #5c9bff);
      --text-neutral-strong: light-dark(#24292e, #dde1ea);
      --text-neutral: light-dark(#586069, #8794b2);
      --text-neutral-subtle: light-dark(#6a737d, #7c8aab);
      --border: light-dark(#e2e8f0, #202634);
      --border-strong: light-dark(#cbd5e1, #343e55);
      --border-faint: light-dark(#f1f5f9, #1d232f);
      --border-ghost: light-dark(#f8fafc, #1d232f);
      --border-accent: light-dark(#0044aa, #5c9bff);
      --border-accent-soft: light-dark(#c0d8ff, #315693);
      --border-accent-pale: light-dark(#c8e1ff, #2f5a8d);
      --border-accent-mid: light-dark(#93c5fd, #3b72b0);
      --border-focus: light-dark(#217aff, #3b6ab0);
      --focus-ring: light-dark(#217aff, #5c9bff);
      --border-on-accent: light-dark(rgba(255, 255, 255, 0.7), rgba(29, 35, 47, 0.7));
      --border-neutral: light-dark(#e1e4e8, #252c3c);
      --border-neutral-strong: light-dark(#d1d5da, #353f56);
      --border-neutral-stronger: light-dark(#bac0c7, #424e6c);
      --border-neutral-faint: light-dark(#f0f2f5, #1d232f);
      --info-bg: light-dark(#e0f2fe, #1f3e52);
      --info-border: light-dark(#bae6fd, #337699);
      --info-text: light-dark(#0369a1, #5c9bff);
      --success-bg: light-dark(#dcfce7, #215733);
      --success-border: light-dark(#86efac, #3bb065);
      --success-text: light-dark(#166534, #a3ebbe);
      --success-text-strong: light-dark(#047857, #92fbdd);
      --done-bg: light-dark(#e6fffa, #1d4d44);
      --done-border: light-dark(#79d5cc, #3bb0a4);
      --done-text: light-dark(#047481, #8cf0fb);
      --warning-bg: light-dark(#fef3c7, #645826);
      --warning-border: light-dark(#fde047, #b09d3b);
      --warning-text: light-dark(#92400e, #f3ae84);
      --warning-text-strong: light-dark(#b45309, #f8af77);
      --warning-solid: light-dark(#fde047, #aa9218);
      --caution-bg: light-dark(#ffedd5, #5a4222);
      --caution-border: light-dark(#fdba74, #b0773b);
      --caution-text: light-dark(#9a3412, #f09c80);
      --caution-solid: light-dark(#fdba74, #aa6218);
      --danger-bg: light-dark(#fee2e2, #511f1f);
      --danger-bg-hover: light-dark(#fecaca, #622525);
      --danger-bg-soft: light-dark(#fef2f2, #451a1a);
      --danger-border: light-dark(#fca5a5, #a93838);
      --danger-border-alt: light-dark(#feb2b2, #9e3535);
      --danger-text: light-dark(#991b1b, #ea8686);
      --danger-text-strong: light-dark(#b91c1c, #ec8383);
      --danger-text-alt: light-dark(#c53030, #e38c8c);
      --danger-text-deep: light-dark(#742a2a, #db9d9d);
      --danger-solid: light-dark(#ef4444, #aa1818);
      --danger-solid-soft: light-dark(#f87171, #aa1818);
    }

    :root[data-theme="light"] {
      color-scheme: light;
    }

    :root[data-theme="dark"] {
      color-scheme: dark;
    }
  }

  /* Visitors who ask for more contrast: stronger borders, and the quietest greys of text one step stronger.
     After the themes, so that it wins over them. */
  @media (prefers-contrast: more) {
    :root {
      --border: #64748b;
      --border-strong: #475569;
      --border-faint: #94a3b8;
      --border-ghost: #94a3b8;
      --text-subtle: #475569;
      --text-faint: #475569;
      --text-disabled: #64748b;
    }

    @supports (color: light-dark(#000, #fff)) {
      :root {
        --border: light-dark(#64748b, #94a0bb);
        --border-strong: light-dark(#475569, #b3bbcf);
        --border-faint: light-dark(#94a3b8, #7c8aab);
        --border-ghost: light-dark(#94a3b8, #7c8aab);
        --text-subtle: light-dark(#475569, #b3bbcf);
        --text-faint: light-dark(#475569, #b3bbcf);
        --text-disabled: light-dark(#64748b, #94a0bb);
      }
    }
  }
}

/* ==========================================================================
   base: element defaults, links, form controls, keyboard focus, motion
   ========================================================================== */
@layer base {
  /* ---- Document ----
     The page is a grid of three rows: header, content (takes the room that is left), footer. The single
     column is minmax(0, 1fr): nothing inside can make the page wider than the window. */
  html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    accent-color: var(--accent);                        /* checkboxes, radio buttons, progress bars */
    scroll-padding-block-start: var(--header-offset);   /* an anchor is not hidden under the sticky header */
  }

  body {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto 1fr auto;
    grid-template-areas:
      "header"
      "main"
      "footer";
    min-block-size: 100vh;
    min-block-size: 100dvh;
    font-family: var(--font-sans);
    line-height: 1.5;
    background-color: var(--surface-page);
    color: var(--text-strong);
    overflow-wrap: break-word;
    -webkit-font-smoothing: antialiased;
  }

  /* ---- Text ---- */
  :where(h1, h2, h3, h4, h5, h6) {
    text-wrap: balance;   /* lines of about the same length */
  }

  :where(p, li, dd, figcaption, blockquote) {
    text-wrap: pretty;    /* no single word alone on the last line */
  }

  :where(table, time) {
    font-variant-numeric: tabular-nums;   /* figures of one width: columns of numbers line up */
  }

  :where(img, svg, video, canvas) {
    max-inline-size: 100%;
  }

  :where(img) {
    block-size: auto;
  }

  /* ---- Links ---- */
  a {
    color: var(--text-link);
    text-decoration: none;
    transition: color var(--duration) ease;
  }

  @media (hover: hover) {
    a:hover {
      color: var(--text-link-hover);
      text-decoration: underline;
    }
  }

  /* ---- Form controls: the font of the page, never the browser's own ---- */
  :where(button, input, select, textarea, optgroup) {
    font: inherit;
  }

  :where(button:not(:disabled), summary, select, label[for], input:is([type="checkbox"], [type="radio"], [type="file"])) {
    cursor: pointer;
  }

  :where(textarea) {
    resize: vertical;
  }

  /* ---- Keyboard: skip link and visible focus ----
     no text under 12px anywhere (sizes are floored at 0.75rem)
     a "skip to content" link, the first stop of the keyboard
     one visible focus ring for everything that takes the keyboard
     visitors who ask for less motion get none */
  .skip-link {
    position: absolute;
    inset-block-start: calc(var(--space-2) + var(--safe-top));
    inset-inline-start: calc(var(--space-2) + var(--safe-start));
    z-index: var(--z-skip-link);
    padding: var(--space-2-5) var(--space-4);
    border-radius: var(--radius-md);
    background-color: var(--accent);
    color: var(--text-on-accent);
    font-weight: 700;
    text-decoration: none;
    transform: translateY(-200%);
  }

  .skip-link:focus {
    transform: none;
  }

  #main:focus {
    outline: none;
  }

  :where(a, button, summary, input, select, textarea, [tabindex], [contenteditable]):focus-visible {
    outline: 2px solid var(--focus-ring);
    outline-offset: 2px;
  }

  /* Visitors who ask for more contrast: a link inside a text is underlined, not only coloured */
  @media (prefers-contrast: more) {
    :where(p, li, dd, td) a {
      text-decoration: underline;
    }
  }

  /* Visitors who ask for less motion get none */
  @media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
      animation-duration: 0.01ms !important;
      animation-iteration-count: 1 !important;
      transition-duration: 0.01ms !important;
      scroll-behavior: auto !important;
    }
  }
}

/* ==========================================================================
   layout: page shell, header, mobile menu, footer, theme switch, layout primitives
   ========================================================================== */
@layer layout {
  /* ---- Page shell ----
     .site-main is the one centred column of the site: as wide as the window less the gutters on a phone, never
     wider than --width-main. Its children are centred in it and take its whole width unless they set their own. */
  .site-main {
    grid-area: main;
    display: grid;
    place-items: stretch center;
    inline-size: min(100% - 2 * var(--gutter) - var(--safe-start) - var(--safe-end), var(--width-main));
    margin-inline: auto;
    padding-block: var(--space-main-start) var(--space-main-end);
  }

  /* ---- Header ----
     Sticky, shrinks once the page is scrolled (js/sticky.js adds .is-scrolled).
     Below 60em: the logo at the start, the menu button at the end. From 60em, where the whole menu fits beside
     the logo: the logo in the middle when there is room on both sides, the menu at the end.
     The paddings are fluid: 16px above and 20px at the sides at 390px wide, 24px and 16px at 1366px. */
  .site-header {
    grid-area: header;
    position: sticky;
    inset-block-start: 0;
    z-index: var(--z-sticky);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--space-4);
    padding-block: calc(clamp(1rem, 0.8rem + 0.82vw, 1.5rem) + var(--safe-top)) var(--space-4);
    padding-inline: max(clamp(1rem, 1.35rem - 0.41vw, 1.25rem), var(--safe-start)) max(clamp(1rem, 1.35rem - 0.41vw, 1.25rem), var(--safe-end));
    background-color: var(--surface-page-translucent);
    border-block-end: var(--border-width) solid transparent;
    transition: padding var(--duration) ease,
                background-color var(--duration) ease,
                border-color var(--duration) ease,
                box-shadow var(--duration) ease;
  }

  .site-header.is-scrolled {
    padding-block: calc(var(--space-2-5) + var(--safe-top)) var(--space-2-5);
    background-color: var(--surface-page);
    border-block-end-color: var(--border);
    box-shadow: var(--shadow-header);
  }

  /* Logo and "by cetome". The logo gets smaller rather than push the menu button out of a very narrow window. */
  .header-brand-group {
    display: flex;
    align-items: flex-end;
    justify-content: center;
    gap: var(--space-2);
    min-inline-size: 0;
  }

  .brand-logo {
    display: inline-flex;
    align-items: center;
    flex: 0 1 auto;
    min-inline-size: 0;
    text-decoration: none;
  }

  .brand-logo .logo-img {
    display: block;
    block-size: clamp(1.75rem, 1.55rem + 0.82vw, 2.25rem);   /* 28px at 390px wide, 36px at 1366px */
    inline-size: auto;
    max-inline-size: 100%;
    object-fit: contain;
    object-position: left bottom;
    transition: block-size var(--duration) ease;
  }

  .site-header.is-scrolled .logo-img {
    block-size: 1.5rem;
  }

  .by-line {
    flex: none;
    margin-block-end: var(--space-0-5);
    font-size: var(--fs-sm);
    font-weight: 600;
    letter-spacing: 0.15em;
    text-transform: lowercase;
    white-space: nowrap;
    color: var(--text-faint);
    transition: font-size var(--duration) ease, margin var(--duration) ease;
  }

  .site-header.is-scrolled .by-line {
    font-size: var(--fs-xs);
    margin-block-end: 0;
  }

  /* The menu: hidden below 60em (the menu button and the drawer replace it). From 60em to 68.75em its text,
     its gaps and the padding of its entries grow with the window, from the tightest that is still comfortable
     (12px text) to the full size; nothing in it is ever smaller than 12px. */
  .header-nav {
    display: none;
  }

  @media (min-width: 60em) {
    .site-header {
      display: grid;
      grid-template-columns: minmax(0, 1fr) auto minmax(max-content, 1fr);   /* the logo is centred while the menu leaves room for it, then moves towards the start */
      justify-content: normal;
    }

    .header-brand-group {
      grid-column: 2;
    }

    .header-nav {
      --nav-pad: clamp(var(--space-2), 0.5rem + (100vw - 60rem) * 0.043, var(--space-3-5));
      grid-column: 3;
      display: flex;
      align-items: center;
      justify-content: flex-end;
      gap: clamp(0rem, (100vw - 60rem) * 0.0286, var(--space-1));
      font-size: clamp(var(--fs-xs), 0.75rem + (100vw - 60rem) * 0.0058, var(--fs-sm));
      font-weight: 700;
      letter-spacing: 0.04em;
      text-transform: uppercase;
    }
  }

  .header-nav > a,
  .header-account-toggle {
    display: inline-flex;
    align-items: center;
    padding: var(--space-2) var(--nav-pad, var(--space-3-5));
    border: var(--border-width) solid transparent;
    border-radius: var(--radius-control);
    line-height: 1.25;   /* room for descenders (the "g" of catalogue) */
    white-space: nowrap;
    color: var(--text-link);
    text-decoration: none;
    transition: background-color var(--duration-fast) ease, color var(--duration-fast) ease, border-color var(--duration-fast) ease;
  }

  .header-nav > .active,
  .header-account-toggle.active {
    background-color: var(--accent-tint-1);
    border-color: var(--border-focus);
    color: var(--text-link-hover);
  }

  /* ---- Account entry of the header: "Sign in", or the "My account" menu ----
     A <details>: it opens and closes without JavaScript; js/account-menu.js adds closing on Escape, on a click
     outside and when the keyboard leaves it. */
  .header-account {
    position: relative;
  }

  .header-account-toggle {
    display: block;
    list-style: none;
    letter-spacing: 0;      /* "My account" is written as it is, not in the capitals of the menu */
    text-transform: none;
    cursor: pointer;
    user-select: none;
  }

  .header-account-toggle::-webkit-details-marker {
    display: none;
  }

  .header-account-label {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1-5);
  }

  .header-account[open] > .header-account-toggle {
    color: var(--text-link-hover);
    background-color: var(--accent-tint-1);
  }

  /* Small chevron drawn with borders (no icon font): 0.45rem is the size of the drawing */
  .header-account-caret {
    inline-size: 0.45rem;
    block-size: 0.45rem;
    margin-block-start: -0.2rem;
    border-inline-end: var(--border-width-strong) solid currentColor;
    border-block-end: var(--border-width-strong) solid currentColor;
    transform: rotate(45deg);
    transition: transform var(--duration-fast) ease, margin var(--duration-fast) ease;
  }

  .header-account[open] .header-account-caret {
    margin-block-start: 0.2rem;
    transform: rotate(-135deg);
  }

  .header-account-menu {
    position: absolute;
    inset-block-start: calc(100% + var(--space-2));
    inset-inline-end: 0;
    z-index: var(--z-dropdown);
    inline-size: max-content;
    min-inline-size: 16rem;
    max-inline-size: min(22rem, 100vw - 2 * var(--gutter));
    padding: var(--space-1-5);
    border: var(--border-width) solid var(--border);
    border-radius: var(--radius-lg);
    background-color: var(--surface-card);
    box-shadow: var(--shadow-dropdown);
    font-size: var(--fs-md);
    font-weight: 600;
    letter-spacing: 0;
    text-transform: none;
  }

  .header-account-email {
    margin-block-end: var(--space-1);
    padding: var(--space-2) var(--space-3) var(--space-2-5);
    border-block-end: var(--border-width) solid var(--border);
    font-size: var(--fs-xs);
    font-weight: 500;
    color: var(--text-subtle);
    overflow-wrap: anywhere;
  }

  .header-account-email strong {
    display: block;
    margin-block-start: var(--space-0-5);
    font-size: var(--fs-sm);
    font-weight: 700;
    color: var(--text-strong);
  }

  .header-account-item {
    display: block;
    inline-size: 100%;
    padding: var(--space-2) var(--space-3);
    border: 0;
    border-radius: var(--radius-md);
    background: none;
    line-height: 1.25;
    text-align: start;
    color: var(--text-link);
    text-decoration: none;
    cursor: pointer;
  }

  .header-account-item:focus-visible {
    outline-offset: -2px;
  }

  .header-account-signout {
    margin-block-start: var(--space-1);
    padding-block-start: var(--space-1);
    border-block-start: var(--border-width) solid var(--border);
  }

  .header-account-item-signout {
    color: var(--danger-text-strong);
  }

  /* ---- Theme switch (header button, entry of the mobile menu) ----
     The button in the header (and in the mobile menu) switches between light and dark; js/theme.js keeps the
     choice. The account page has the three-way choice (system, light, dark) saved with the account. */
  .theme-toggle {
    display: inline-grid;
    place-items: center;
    flex: none;
    inline-size: var(--space-9);
    block-size: var(--space-9);
    border: var(--border-width) solid transparent;
    border-radius: var(--radius-control);
    background: none;
    color: var(--text-link);
    transition: background-color var(--duration) ease, border-color var(--duration) ease;
  }

  .theme-icon {
    display: block;
    flex: none;
    inline-size: var(--space-5);
    block-size: var(--space-5);
  }

  :is(.theme-toggle, .mobile-theme-toggle)[aria-pressed="true"] .theme-icon-dark,
  :is(.theme-toggle, .mobile-theme-toggle)[aria-pressed="false"] .theme-icon-light {
    display: none;
  }

  .mobile-theme-toggle {
    display: flex;
    align-items: center;
    gap: var(--space-2-5);
    inline-size: 100%;
    padding: var(--space-3-5) var(--space-4);
    border: 0;
    border-block-start: var(--border-width) solid var(--border);
    background: none;
    color: var(--text-link);
    font-weight: 700;
    text-align: start;
  }

  /* The wordmark is drawn in the brand's dark blue: white on a dark page (only where the dark theme exists) */
  @supports (color: light-dark(#000, #fff)) {
    @media (prefers-color-scheme: dark) {
      :root:not([data-theme="light"]) :is(.logo-img, .footer-logo) {
        filter: brightness(0) invert(1);
      }
    }

    :root[data-theme="dark"] :is(.logo-img, .footer-logo) {
      filter: brightness(0) invert(1);
    }
  }

  /* No dark theme in this browser, or no JavaScript (js/theme.js puts the class "js" on <html>): no switch */
  @supports not (color: light-dark(#000, #fff)) {
    [data-theme-toggle] {
      display: none;
    }
  }

  html:not(.js) [data-theme-toggle] {
    display: none;
  }

  /* ---- Mobile menu: button, drawer, backdrop (below 60em) ----
     The button is a link to the drawer: without JavaScript (no class "js" on <html>, see js/theme.js) the
     drawer opens as the target of that link (:target) and its close button, a link too, closes it.
     js/menu.js turns it into a modal: the focus goes in
     and stays in, the rest of the page is inert, Escape closes, the focus goes back to the button.
     The drawer is as tall as the visible screen and scrolls when its entries do not fit (short or landscape
     phones, and signed-in customers, who have more entries). It slides in from the end side: the offset is
     logical, the transform is not (the site has no right-to-left version). */
  .mobile-menu-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: none;
    inline-size: var(--target-min);
    block-size: var(--target-min);
    padding: var(--space-2);
    border-radius: var(--radius-md);
    color: var(--text-strong);
    transition: background-color var(--duration) ease, color var(--duration) ease;
  }

  .mobile-nav-drawer {
    position: fixed;
    inset-block: 0;
    inset-inline-end: 0;
    z-index: var(--z-drawer);
    display: flex;
    flex-direction: column;
    inline-size: min(82vw, 21.25rem);
    padding-block: max(var(--space-6), var(--safe-top)) max(var(--space-6), var(--safe-bottom));
    padding-inline: var(--space-6) max(var(--space-6), var(--safe-end));
    overflow-y: auto;
    overscroll-behavior: contain;
    background-color: var(--surface-card);
    box-shadow: var(--shadow-drawer);
    transform: translateX(100%);
    visibility: hidden;
    /* closing: hidden once it has slid out. Opening (below): visibility is not in the transition, so the
       drawer is visible at once and can take the focus. */
    transition: transform var(--duration-slow) cubic-bezier(0.16, 1, 0.3, 1),
                visibility 0s linear var(--duration-slow);
  }

  .mobile-nav-drawer.is-active,
  html:not(.js) .mobile-nav-drawer:target {
    transform: none;
    visibility: visible;
    transition: transform var(--duration-slow) cubic-bezier(0.16, 1, 0.3, 1);
  }

  /* Dimmed backdrop: a click on it closes the menu */
  .mobile-nav-backdrop {
    position: fixed;
    inset: 0;
    z-index: var(--z-backdrop);
    background-color: var(--overlay-backdrop);
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    cursor: default;
    transition: opacity var(--duration-slow) ease, visibility 0s linear var(--duration-slow);
  }

  .mobile-nav-backdrop.is-active,
  html:not(.js) .mobile-nav-drawer:target + .mobile-nav-backdrop {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transition: opacity var(--duration-slow) ease;
  }

  /* Top of the drawer: title and close button */
  .mobile-drawer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-block-end: var(--space-4);
    border-block-end: var(--border-width) solid var(--border);
  }

  .mobile-drawer-title {
    font-size: var(--fs-lg);
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--text-faint);
  }

  .mobile-nav-close {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: none;
    inline-size: var(--target-min);
    block-size: var(--target-min);
    margin: calc((var(--space-10) - var(--target-min)) / 2);   /* drawn as a 40px square, 44px to touch */
    border-radius: var(--radius-md);
    color: var(--text-strong);
    transition: background-color var(--duration) ease, color var(--duration) ease;
  }

  /* The entries */
  .mobile-nav-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    margin-block-start: var(--space-6);
    list-style: none;
  }

  .mobile-nav-link {
    display: flex;
    align-items: center;
    gap: var(--space-3-5);
    padding: calc(var(--space-3-5) - var(--border-width)) calc(var(--space-4) - var(--border-width));
    border: var(--border-width) solid transparent;   /* coloured on the current page: every entry has the same size */
    border-radius: var(--radius-lg);
    font-size: var(--fs-xl-plus);
    font-weight: 700;
    text-transform: uppercase;
    text-decoration: none;
    color: var(--text-link);
    transition: background-color var(--duration) ease, color var(--duration) ease;
  }

  /* "Sign out" in the menu is a form button that looks like the links around it */
  .mobile-nav-button {
    inline-size: 100%;
    background: none;
    text-align: start;
  }

  .mobile-nav-link.active {
    background-color: var(--accent-tint-1);
    border-color: var(--border-focus);
    color: var(--text-link-hover);
  }

  .mobile-nav-link:focus-visible,
  .mobile-theme-toggle:focus-visible {
    outline-offset: -2px;
  }

  .mobile-nav-account {
    overflow-wrap: anywhere;
  }

  .mobile-drawer-footer {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    margin-block-start: auto;
    padding-block-start: var(--space-6);
    border-block-start: var(--border-width) solid var(--border);
    font-size: var(--fs-sm);
    color: var(--text-faint);
  }

  /* The page behind the open menu does not scroll */
  body.mobile-menu-open {
    overflow: hidden;
  }

  @media (min-width: 60em) {
    .mobile-menu-toggle,
    .mobile-nav-drawer,
    .mobile-nav-backdrop {
      display: none;
    }
  }

  /* ---- Pointer feedback of the shell: only where a pointer can hover ---- */
  @media (hover: hover) {
    .header-nav > a:hover,
    .header-account-toggle:hover {
      color: var(--text-link-hover);
      background-color: var(--accent-tint-1);
      text-decoration: none;
    }

    .header-account-item:hover {
      background-color: var(--accent-tint-1);
      color: var(--text-link-hover);
      text-decoration: none;
    }

    .header-account-item-signout:hover {
      background-color: var(--danger-bg-soft);
      color: var(--danger-text);
    }

    .theme-toggle:hover {
      background-color: var(--accent-tint-1);
      border-color: var(--border);
    }

    .mobile-menu-toggle:hover {
      background-color: var(--surface-sunken);
      color: var(--text-link);
    }

    .mobile-nav-close:hover {
      background-color: var(--danger-bg);
      color: var(--danger-text-vivid);
    }

    .mobile-nav-link:hover,
    .mobile-theme-toggle:hover {
      background-color: var(--surface-sunken);
      color: var(--text-link-hover);
      text-decoration: none;
    }

    .footer-nav a:hover {
      color: var(--text-link-hover);
    }

    .footer-initiative:hover,
    .footer-initiative:hover strong {
      color: var(--text-link-hover);
      text-decoration: none;
    }
  }

  /* ---- Touch: every control of the shell is at least 44px to touch, without being drawn any bigger ----
     The entry keeps its size; an invisible area around it takes the touches. */
  @media (pointer: coarse) {
    .header-nav > a,
    .header-account-toggle,
    .theme-toggle,
    .header-account-item,
    .footer-nav a,
    .by-line a {
      position: relative;
    }

    .header-nav > a::before,
    .header-account-toggle::before,
    .theme-toggle::before,
    .header-account-item::before,
    .footer-nav a::before,
    .by-line a::before {
      content: "";
      position: absolute;
      inset-block: min(0rem, (100% - var(--target-min)) / 2);
      inset-inline: min(0rem, (100% - var(--target-min)) / 2);
    }
  }

  /* ---- Footer ----
     One column, centred. From 64em, where the three groups fit on one line: brand, links, 1-click initiative. */
  .site-footer {
    grid-area: footer;
    padding-block: var(--space-8) calc(var(--space-8) + var(--safe-bottom));
    padding-inline: max(var(--space-6), var(--safe-start)) max(var(--space-6), var(--safe-end));
    border-block-start: var(--border-width) solid var(--border);
    background-color: var(--surface-card);
    color: var(--text-faint);
  }

  .footer-container {
    display: grid;
    justify-items: center;
    gap: var(--space-6);
    inline-size: min(100%, var(--width-footer));
    margin-inline: auto;
    text-align: center;
  }

  .footer-brand-group {
    display: grid;
    justify-items: center;
    gap: var(--space-1-5);
  }

  .footer-brand-link {
    display: inline-block;
    text-decoration: none;
  }

  .footer-logo {
    display: block;
    block-size: var(--space-6);
    inline-size: auto;
  }

  .copyright {
    font-size: var(--fs-xs-plus);
    line-height: 1.4;
    color: var(--text-faint);
  }

  .footer-nav {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: var(--space-3-5);
    font-size: var(--fs-sm);
    font-weight: 700;
    letter-spacing: 0.05em;
  }

  .footer-nav a {
    color: var(--text-link);
    text-decoration: none;
    transition: color var(--duration) ease;
  }

  .footer-nav .separator {
    color: var(--text-decorative);
    font-size: var(--fs-xs);
  }

  .footer-meta {
    display: grid;
    justify-items: center;
    font-size: var(--fs-sm);
  }

  /* 1-click initiative badge (image + label, one link): "Part of the" over a bold "1-click initiative" */
  .footer-initiative {
    display: inline-flex;
    align-items: center;
    gap: var(--space-3);
    font-size: var(--fs-md);
    text-align: start;
    text-decoration: none;
    color: var(--text-faint);
    transition: color var(--duration) ease;
  }

  .footer-initiative-text {
    display: grid;
    line-height: 1.35;
  }

  .footer-initiative strong {
    font-weight: 700;
    color: var(--text-link);
  }

  .footer-initiative-logo {
    display: block;
    block-size: var(--space-12);
    inline-size: auto;
  }

  @media (min-width: 64em) {
    .footer-container {
      grid-template-columns: 1fr auto 1fr;
      align-items: center;
      gap: var(--space-8);
      text-align: start;
    }

    .footer-brand-group {
      justify-items: start;
    }

    .footer-meta {
      justify-items: end;
    }
  }

  /* ---- Layout primitives ----
     The building blocks of a page. Each takes its settings from custom properties, set in the page file on the
     element (never in a style attribute). Recipes: css/README.md. */

  /* Vertical rhythm: children one under the other, one gap between them */
  .l-stack {
    display: flex;
    flex-direction: column;
    gap: var(--stack-gap, var(--space-4));
  }

  /* A row of small things that wraps: buttons, chips, a title with its actions */
  .l-cluster {
    display: flex;
    flex-wrap: wrap;
    align-items: var(--cluster-align, center);
    justify-content: var(--cluster-justify, flex-start);
    gap: var(--cluster-gap, var(--space-2));
  }

  /* As many equal columns as fit, none narrower than --grid-min; one column when even that does not fit */
  .l-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(var(--grid-min, 16rem), 100%), 1fr));
    gap: var(--grid-gap, var(--space-6));
  }

  /* Two columns, a side one of --sidebar-width and a main one; they stack as soon as the main one would get
     less than --sidebar-main-min of the width of the container (no media query: it follows its container) */
  .l-sidebar {
    display: flex;
    flex-wrap: wrap;
    gap: var(--sidebar-gap, var(--space-6));
  }

  .l-sidebar > :first-child {
    flex: 1 1 var(--sidebar-width, 20rem);
  }

  .l-sidebar > :last-child {
    flex: 999 1 0;
    min-inline-size: var(--sidebar-main-min, 55%);
  }

  /* A centred column of --center-max at most, inside .site-main (which already has the gutters) */
  .l-center {
    inline-size: min(100%, var(--center-max, 46rem));
    margin-inline: auto;
  }

  /* A container for @container queries: its children can adapt to its width instead of the window's */
  .l-container {
    container-type: inline-size;
  }

  /* Something wider than its place (a table) scrolls sideways inside it instead of widening the page */
  .l-scroll {
    max-inline-size: 100%;
    overflow-x: auto;
    overscroll-behavior-x: contain;
  }
}

/* ==========================================================================
   components: everything used by more than one page family.
   One implementation per component: the class names of the former pages (.scoping-card and .portal-card,
   .submit-analyze-btn and .btn-primary-action...) are kept, because templates and scripts use them, and share
   one rule. A page file adjusts a component with a one-class selector in its own layer.
   ========================================================================== */
@layer components {
  /* ---- Cards ----
     One card: .scoping-card (home, pricing), .portal-card (account, catalogue, contact), .document-card (terms,
     privacy, page not found). The first two lay their content out as a grid with one gap; the document card
     has the fluid padding of a document. */
  .scoping-card,
  .portal-card,
  .document-card {
    inline-size: 100%;
    border: var(--border-width) solid var(--border);
    border-radius: var(--radius-xl);
    background-color: var(--surface-card);
    box-shadow: var(--shadow-card);
  }

  .scoping-card,
  .portal-card {
    display: grid;
    align-content: start;
    gap: var(--space-5);
    block-size: 100%;
    padding: var(--space-5) var(--space-6);
  }

  .document-card {
    margin-inline: auto;
    padding: var(--space-section-block) var(--space-section-inline);
  }

  /* ---- Page grids ---- */
  @media (min-width: 40em) {
    .app-layout {
      display: grid;
      grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr);
      gap: var(--space-6);
    }
  }

  .portal-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: var(--space-6);
    inline-size: 100%;
    margin-inline: auto;
  }

  @media (min-width: 64em) {
    .portal-layout {
      grid-template-columns: minmax(0, 1fr) minmax(0, 1.5fr);
      align-items: stretch;
    }
  }

  /* A single small card, centred (sign-in) */
  .auth-card-wrapper {
    inline-size: 100%;
    max-inline-size: var(--width-narrow);
    margin-inline: auto;
  }

  .auth-card {
    text-align: center;
  }

  .auth-header-group {
    display: grid;
    gap: var(--space-1-5);
    text-align: center;
  }

  .auth-subtitle {
    margin-inline: auto;
  }

  .auth-footer-prompt {
    margin-block-start: var(--space-1);
    text-align: center;
  }

  /* ---- Titles of cards and documents ---- */
  .input-header-group {
    display: grid;
    gap: var(--space-1-5);
  }

  .section-title {
    font-size: var(--fs-3xl);
    font-weight: 700;
    letter-spacing: -0.025em;
    color: var(--text-strong);
  }

  .section-subtitle {
    font-size: var(--fs-md-plus);
    line-height: 1.5;
    color: var(--text-muted);
  }

  .document-header {
    display: grid;
    gap: var(--space-2);
    margin-block-end: var(--space-8);
    padding-block-end: var(--space-6);
    border-block-end: var(--border-width) solid var(--border);
  }

  .document-title {
    font-size: var(--fs-display);
    font-weight: 800;
    letter-spacing: -0.03em;
    line-height: 1.2;
    color: var(--text-strong);
  }

  .document-meta {
    font-family: var(--font-mono);
    font-size: var(--fs-sm-plus);
    color: var(--text-subtle);
  }

  .document-content {
    display: grid;
    gap: var(--space-9);
  }

  .registry-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
  }

  /* ---- Inner boxes and lists ---- */
  .recent-scopes-box {
    display: grid;
    gap: var(--space-2);
    padding-block-start: var(--space-4);
    border-block-start: var(--border-width) solid var(--border);
  }

  .recent-scope-row {
    display: grid;
    grid-template-columns: auto 1fr;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-3);
    border: var(--border-width) solid var(--border);
    border-radius: var(--radius-md);
    background-color: var(--surface-sunken);
  }

  .result-header-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: var(--space-3);
    padding-block-end: var(--space-4);
    border-block-end: var(--border-width) solid var(--border);
  }

  @media (min-width: 40em) {
    .result-header-row {
      grid-template-columns: minmax(0, 1fr) auto;
      align-items: center;
    }
  }

  .statutory-match-box {
    display: grid;
    gap: var(--space-3);
    padding: var(--space-4);
    border: var(--border-width) solid var(--border);
    border-radius: var(--radius-lg);
    background-color: var(--surface-sunken);
  }

  .statutory-details-content {
    display: grid;
    gap: var(--space-2);
  }

  .statutory-finding-title {
    font-size: var(--fs-lg-plus);
    font-weight: 700;
    color: var(--text-strong);
  }

  .legal-list {
    display: grid;
    gap: var(--space-2-5);
    padding-inline-start: var(--space-5);
  }

  .legal-list li {
    font-size: var(--fs-md-plus);
    line-height: 1.6;
    color: var(--text);
  }

  .legal-list li strong {
    color: var(--text-strong);
  }

  .legal-list code {
    padding: var(--space-0-5) var(--space-1-5);
    border: var(--border-width) solid var(--border);
    border-radius: var(--radius-xs);
    background-color: var(--surface-sunken);
    font-family: var(--font-mono);
    font-size: max(0.75rem, 0.825em);
    color: var(--text-link);
  }

  .api-docs-instruction {
    margin-block-end: var(--space-2);
    font-size: var(--fs-xs-plus);
    color: var(--text-muted);
  }

  /* ---- Buttons ----
     One button, three sizes, five looks.
       sizes   .btn (44px)   .btn-sm (32px)   .verify-btn (40px, in a dialog)
       looks   filled     .submit-analyze-btn  .btn-primary-action  .verify-btn-primary
               quiet      .btn-secondary-action  .verify-btn (its default)  .disagree-toggle-btn
               danger     .btn-danger-action  .verify-btn-danger
               outlined   .next-step-btn-secondary
               tinted     .confirm-pill-btn
     A link and a button with the same classes look the same: same font, same height (the padding is worked out
     from the height of the size and the line of text, so a page that changes the font size keeps the height),
     always a border of one hairline (transparent on a filled button), the focus ring of the site, one look
     when disabled. The pointer feedback is at the end of the layer, under (hover: hover). */
  .btn,
  .btn-sm,
  .verify-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    border: var(--border-width) solid transparent;
    font-weight: 700;
    line-height: 1.25;
    text-align: center;
    text-decoration: none;
    cursor: pointer;
    transition: background-color var(--duration) ease, border-color var(--duration) ease, color var(--duration) ease, opacity var(--duration) ease;
  }

  .btn {
    padding: calc((var(--control-height) - 1.25em) / 2 - var(--border-width)) calc(var(--space-6) - var(--border-width));
    border-radius: var(--radius-lg);
    font-size: var(--fs-md-plus);
  }

  .btn-sm {
    padding: calc((var(--control-height-sm) - 1.25em) / 2 - var(--border-width)) var(--space-3);
    border-radius: var(--radius-md);
    font-size: var(--fs-xs);
  }

  .verify-btn {
    padding: calc((var(--control-height-dialog) - 1.25em) / 2 - var(--border-width)) var(--space-4);
    border-radius: var(--radius-lg);
    font-size: var(--fs-md-plus);
  }

  .btn-full-width {
    inline-size: 100%;
  }

  /* quiet (first: the default look of a dialog button, which the other looks replace) */
  .btn-secondary-action,
  .verify-btn {
    background-color: var(--surface-sunken);
    border-color: var(--border-strong);
    color: var(--text);
  }

  /* filled */
  .submit-analyze-btn,
  .btn-primary-action,
  .verify-btn-primary {
    background-color: var(--accent);
    border-color: transparent;
    color: var(--text-on-accent);
  }

  /* danger */
  .btn-danger-action,
  .verify-btn-danger {
    background-color: var(--danger-bg);
    border-color: var(--danger-border);
    color: var(--danger-text);
  }

  /* outlined */
  .next-step-btn-secondary {
    background-color: var(--surface-card);
    border-color: var(--border-focus);
    color: var(--text-link);
  }

  /* Small choices offered under a field or a result ("Try: ...", "I agree", "I disagree") */
  .sample-pill-btn {
    flex-shrink: 0;
    padding: var(--space-1) var(--space-2-5);
    border: var(--border-width) solid var(--border);
    border-radius: var(--radius-sm);
    background-color: var(--surface-sunken);
    font-size: var(--fs-xs);
    font-weight: 500;
    line-height: 1.25;
    text-align: center;
    white-space: normal;
    color: var(--text-muted);
    cursor: pointer;
    transition: background-color var(--duration) ease, border-color var(--duration) ease, color var(--duration) ease;
  }

  /* tinted */
  .confirm-pill-btn {
    background-color: var(--accent-tint-1);
    border-color: var(--border-accent-soft);
    color: var(--text-link);
  }

  .disagree-toggle-btn {
    background-color: var(--surface-sunken);
    border-color: var(--border-strong);
    color: var(--text-strong);
  }

  /* disabled: one look, whatever the button */
  :is(.btn, .btn-sm, .verify-btn, .sample-pill-btn):is(:disabled, .is-disabled, [aria-disabled="true"]) {
    opacity: 0.6;
    cursor: not-allowed;
  }

  /* Groups of buttons */
  .button-wrapper {
    display: grid;
    justify-content: end;
  }

  .account-actions-group {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-2);
  }

  .account-actions-group .inline-form {
    display: flex;
  }

  .account-actions-group .btn-sm {
    white-space: nowrap;
  }

  .inline-form {
    display: inline;
  }

  /* ---- Form fields ----
     One field: .portal-input-field (account, catalogue, contact, dialogs), .text-input-field (home) and
     .verify-input (the code of a dialog). As tall as a button (44px), the same radius. A focused field shows a
     coloured border and a soft ring; the transparent outline is what forced colours draw instead. */
  .field-label {
    font-size: var(--fs-xs);
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--text-muted);
  }

  .portal-form-group {
    display: grid;
    gap: var(--space-1-5);
  }

  .portal-input-field,
  .text-input-field,
  .verify-input {
    inline-size: 100%;
    padding: calc((var(--control-height) - 1.35em) / 2 - var(--border-width)) var(--space-4);
    border: var(--border-width) solid var(--border-strong);
    border-radius: var(--radius-lg);
    background-color: var(--surface-sunken);
    font-size: var(--fs-md-plus);
    font-weight: 500;
    line-height: 1.35;
    color: var(--text-strong);
    transition: border-color var(--duration) ease, box-shadow var(--duration) ease;
  }

  :is(.portal-input-field, .text-input-field, .verify-input):focus {
    border-color: var(--border-focus);
    box-shadow: var(--shadow-focus-ring);
    outline: 2px solid transparent;
    outline-offset: 2px;
  }

  :is(.portal-input-field, .text-input-field, .verify-input)[aria-invalid="true"] {
    border-color: var(--danger-border);
  }

  textarea:is(.portal-input-field, .text-input-field) {
    min-block-size: 10rem;
    padding-block: var(--space-3);
    line-height: 1.5;
    resize: vertical;
  }

  /* The code of a dialog: large, spaced out figures */
  .verify-input {
    font-family: var(--font-mono);
    font-size: var(--fs-4xl);
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.3em;
    text-align: center;
  }

  /* The line under a field: help, or what is wrong with it */
  .field-help {
    font-size: var(--fs-sm);
    line-height: 1.5;
    color: var(--text-subtle);
  }

  .field-error {
    font-size: var(--fs-sm);
    font-weight: 600;
    line-height: 1.5;
    color: var(--danger-text-strong);
  }

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

  .portal-checkbox {
    inline-size: var(--space-4);
    block-size: var(--space-4);
    cursor: pointer;
  }

  /* ---- Badges ---- */
  .custom-badge {
    display: inline-grid;
    align-items: center;
    border: var(--border-width) solid transparent;
    border-radius: var(--radius-full);
    font-size: var(--fs-xs);
    font-weight: 700;
    letter-spacing: 0.025em;
    text-align: center;
    text-transform: uppercase;
    white-space: nowrap;
  }

  .badge-lg {
    padding: var(--space-1-5) var(--space-3-5);
  }

  .badge-sm {
    padding: var(--space-0-5) var(--space-2);
  }

  .badge-critical {
    background-color: var(--danger-bg);
    border-color: var(--danger-border);
    color: var(--danger-text);
  }

  .badge-class2 {
    background-color: var(--caution-bg);
    border-color: var(--caution-border);
    color: var(--caution-text);
  }

  .badge-class1 {
    background-color: var(--warning-bg);
    border-color: var(--warning-border);
    color: var(--warning-text);
  }

  .badge-out-of-scope {
    background-color: var(--surface-muted);
    border-color: var(--border-strong);
    color: var(--text-muted);
  }

  .badge-impossible {
    background-color: var(--danger-bg-soft);
    border-color: var(--danger-border);
    color: var(--danger-text);
  }

  .badge-default {
    background-color: var(--surface-muted);
    border-color: var(--border-strong);
    color: var(--text);
  }

  .confirmed-badge {
    padding: var(--space-1-5) var(--space-2-5);
    border: var(--border-width) solid var(--border-accent);
    border-radius: var(--radius-sm);
    background-color: var(--accent-tint-1);
    font-size: var(--fs-xs);
    font-weight: 700;
    color: var(--text-link);
  }

  /* ---- Message boxes and notices ----
     One box: the same radius, text size and line; each kind has its colours. */
  .error-message-box,
  .success-message-box,
  .limit-warning-box,
  .account-notice {
    padding: var(--space-3) var(--space-4);
    border: var(--border-width) solid var(--border);
    border-radius: var(--radius-lg);
    font-size: var(--fs-md-plus);
    line-height: 1.5;
  }

  .error-message-box {
    margin-block-start: var(--space-2);
    background-color: var(--danger-bg-soft);
    border-color: var(--danger-border);
    font-weight: 600;
    color: var(--danger-text-vivid);
  }

  /* The ways out of a limit ("Create a free account or sign in", "See the plans") inside an error */
  .error-message-link {
    color: inherit;
    font-weight: 700;
    text-decoration: underline;
  }

  .success-message-box {
    background-color: var(--accent-tint-1);
    border: var(--border-width-strong) solid var(--border-accent);   /* the one box with a strong border: it reports what the visitor just did */
    color: var(--text-link);
  }

  .success-message-box strong {
    font-weight: 600;
  }

  .limit-warning-box {
    background-color: var(--danger-bg);
    border-color: var(--danger-border);
    color: var(--danger-text);
  }

  .callout-text {
    font-size: var(--fs-md);
    line-height: 1.6;
    color: var(--text-emphasis);
  }

  /* State of the customer's plan (trial running, payment failed, plan ended): account and catalogue pages.
     The text and its button share a line while they fit, the button goes under the text when they do not. */
  .account-notice {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3) var(--space-5);
    padding-block: var(--space-3-5);
    background-color: var(--accent-tint-1);
    border-color: var(--border-accent-soft);
    color: var(--text-strong);
  }

  .account-notice-warning {
    background-color: var(--warning-bg);
    border-color: var(--caution-border);
  }

  .account-notice-text {
    display: grid;
    gap: var(--space-0-5);
    flex: 1 1 18rem;
    min-inline-size: 0;
  }

  /* ---- Tables ---- */
  .key-table-wrapper {
    inline-size: 100%;
    overflow-x: auto;
  }

  .key-table {
    inline-size: 100%;
    margin-block-start: var(--space-2);
    border-collapse: collapse;
    font-size: var(--fs-md-plus);
  }

  .key-table th {
    padding: var(--space-3) var(--space-4);
    border-block-end: var(--border-width) solid var(--border);
    background-color: var(--surface-sunken);
    font-size: var(--fs-xs);
    font-weight: 700;
    letter-spacing: 0.05em;
    text-align: start;
    text-transform: uppercase;
    color: var(--text-muted);
  }

  .key-table td {
    padding: var(--space-3-5) var(--space-4);
    border-block-end: var(--border-width) solid var(--border);
    text-align: start;
    vertical-align: middle;
    color: var(--text);
  }

  .key-empty-cell {
    padding: var(--space-8);
    text-align: center;
    color: var(--text-faint);
  }

  .key-name {
    color: var(--text-strong);
  }

  /* ---- Usage meter ---- */
  .usage-meter-card {
    margin-block-start: var(--space-4);
    padding: var(--space-4);
    border: var(--border-width) solid var(--border);
    border-radius: var(--radius-lg);
    background-color: var(--surface-sunken);
  }

  .usage-meter-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--space-2);
    margin-block-end: var(--space-2);
  }

  .usage-meter-title {
    font-size: var(--fs-md);
    font-weight: 700;
    color: var(--text-strong);
  }

  .usage-meter-stat {
    font-family: var(--font-mono);
    font-size: var(--fs-sm);
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    color: var(--text-link);
  }

  .usage-progress-track {
    inline-size: 100%;
    block-size: var(--space-2-5);
    border-radius: var(--radius-full);
    background-color: var(--surface-strong);
    overflow: hidden;
  }

  .usage-progress-fill {
    block-size: 100%;
    background-color: var(--accent);
    transition: inline-size var(--duration-slow) ease;
  }

  .usage-progress-fill.is-critical {
    background-color: var(--danger-solid);
  }

  .usage-meter-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--space-2);
    margin-block-start: var(--space-1-5);
    font-size: var(--fs-xs);
    font-variant-numeric: tabular-nums;
    color: var(--text-subtle);
  }

  /* ---- Link to another site ---- */
  a.external-link::after {
    content: "";
    display: inline-block;
    inline-size: 1.25em;
    block-size: 1.25em;
    margin-inline-start: var(--space-1);
    margin-block-end: var(--space-1);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%230044aa'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14'%3E%3C/path%3E%3C/svg%3E");
    background-size: contain;
    background-repeat: no-repeat;
    vertical-align: middle;
  }

  /* In a button the icon is centred by the button itself */
  :is(.btn, .btn-sm).external-link::after {
    margin-block-end: 0;
  }

  /* ---- Dialogs (js/dialogs.js, js/passkeys.js) ----
     A native <dialog>, centred: as wide as the window less the gutters on a phone, 28rem at most; never taller
     than the visible screen, its content scrolls inside. */
  .verify-dialog {
    inline-size: min(100% - 2 * var(--gutter), 28rem);
    max-inline-size: none;
    max-block-size: calc(100vh - 2 * var(--gutter));
    max-block-size: calc(100dvh - 2 * var(--gutter) - var(--safe-top) - var(--safe-bottom));
    margin: auto;
    padding: var(--space-6);
    overflow-y: auto;
    overscroll-behavior: contain;
    border: var(--border-width) solid var(--border);
    border-radius: var(--radius-xl);
    background: var(--surface-card);
    color: var(--text-strong);
    box-shadow: var(--shadow-dialog);
  }

  .verify-dialog::backdrop {
    background: rgba(2, 6, 23, 0.6);
  }

  .verify-title {
    margin-block-end: var(--space-2);
    font-size: var(--fs-2xl-plus);
    font-weight: 800;
  }

  .verify-text,
  .verify-help,
  .verify-ok,
  .verify-note {
    font-size: var(--fs-md-plus);
    line-height: 1.6;
    color: var(--text);
  }

  .verify-body,
  .verify-form {
    display: grid;
    gap: var(--space-3);
    margin-block-start: var(--space-4);
  }

  .verify-label {
    font-size: var(--fs-sm);
    font-weight: 700;
  }

  .verify-actions {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
  }

  .verify-dialog > .verify-actions {
    margin-block-start: var(--space-4);
  }

  .verify-note {
    margin-block-start: var(--space-3);
  }

  .verify-note:empty {
    display: none;
  }

  .verify-note.is-error {
    color: var(--danger-text-strong);
  }

  .verify-ok {
    font-weight: 700;
  }

  /* ---- Toasts (js/dialogs.js) ----
     A short message at the bottom of the screen, above everything (js/dialogs.js puts it inside the open
     dialog when there is one, so that it is above it too). It can be dismissed; an error is announced at once. */
  .cra-toast {
    position: fixed;
    inset-inline: calc(var(--gutter) + var(--safe-start)) calc(var(--gutter) + var(--safe-end));
    bottom: calc(var(--space-5) + var(--safe-bottom));
    z-index: var(--z-toast);
    display: flex;
    align-items: flex-start;
    gap: var(--space-3);
    inline-size: -webkit-fit-content;
    inline-size: fit-content;
    max-inline-size: 34rem;
    margin-inline: auto;
    padding: var(--space-3) var(--space-4);
    border: var(--border-width) solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--surface-card);
    box-shadow: var(--shadow-toast);
    font-size: var(--fs-lg);
    line-height: 1.5;
    color: var(--text-strong);
    transform: translateY(1rem);
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--duration) ease, transform var(--duration) ease, visibility var(--duration);
  }

  .cra-toast.is-visible {
    transform: none;
    opacity: 1;
    visibility: visible;
  }

  .cra-toast.is-error {
    border-color: var(--danger-border);
    color: var(--danger-text-strong);
  }

  .cra-toast-text {
    flex: 1 1 auto;
    min-inline-size: 0;
  }

  .cra-toast-close {
    position: relative;
    display: grid;
    place-items: center;
    flex: none;
    inline-size: var(--space-6);
    block-size: var(--space-6);
    border: 0;
    border-radius: var(--radius-sm);
    background: none;
    color: var(--text-subtle);
  }

  .cra-toast-close svg {
    inline-size: var(--space-4);
    block-size: var(--space-4);
  }

  /* ---- Pointer feedback of the components: only where a pointer can hover ---- */
  @media (hover: hover) {
    :is(.submit-analyze-btn, .btn-primary-action, .verify-btn-primary):hover:not(:disabled, .is-disabled, [aria-disabled="true"]) {
      background-color: var(--accent-hover);
    }

    :is(.btn-secondary-action, .verify-btn):hover:not(:disabled, .is-disabled, [aria-disabled="true"], .verify-btn-primary, .verify-btn-danger) {
      background-color: var(--surface-strong);
    }

    :is(.btn-danger-action, .verify-btn-danger):hover:not(:disabled, .is-disabled, [aria-disabled="true"]) {
      background-color: var(--danger-bg-hover);
    }

    .next-step-btn-secondary:hover {
      background-color: var(--accent-tint-1);
      border-color: var(--border-accent);
    }

    .sample-pill-btn:hover:not(:disabled) {
      background-color: var(--accent-tint-2);
      border-color: var(--border-accent-soft);
      color: var(--text-link);
    }

    .cra-toast-close:hover {
      background-color: var(--surface-muted);
      color: var(--text-strong);
    }

    a.external-link:hover::after {
      background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%23217aff'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14'%3E%3C/path%3E%3C/svg%3E");
    }
  }

  /* ---- Touch: the small buttons are at least 44px to touch, without being drawn any bigger ----
     (.btn and the fields are 44px already.) An invisible area around the button takes the touches. */
  @media (pointer: coarse) {
    .btn-sm,
    .verify-btn,
    .sample-pill-btn {
      position: relative;
    }

    .btn-sm::before,
    .verify-btn::before,
    .sample-pill-btn::before,
    .cra-toast-close::before {
      content: "";
      position: absolute;
      inset-block: min(0rem, (100% - var(--target-min)) / 2);
      inset-inline: min(0rem, (100% - var(--target-min)) / 2);
    }
  }
}

/* ==========================================================================
   pages: the page files (css/pages/*.css), each wrapped in @layer pages { ... }
   ========================================================================== */

/* ==========================================================================
   utilities: single-purpose classes and the rules that must win over every page
   ========================================================================== */
@layer utilities {
  /* Read by a screen reader, not shown */
  .visually-hidden {
    position: absolute;
    inline-size: 1px;
    block-size: 1px;
    margin: -1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }

  /* A long token (e-mail address, key, URL) breaks anywhere rather than widen its box */
  .u-break-anywhere {
    overflow-wrap: anywhere;
  }

  /* Figures of one width (amounts, counters, dates in a column) */
  .u-tabular-nums {
    font-variant-numeric: tabular-nums;
  }

  /* Touch screens: a field with text under 16px makes iOS zoom into the page when it takes the focus */
  @media (pointer: coarse) {
    :where(input:not([type="checkbox"], [type="radio"], [type="range"], [type="file"], [type="color"], [type="button"], [type="submit"], [type="reset"], [type="image"]), select, textarea):not(.verify-input) {
      font-size: max(1rem, 16px);
    }
  }

  /* Forced colours (Windows contrast themes): the browser replaces the colours and drops backgrounds and
     shadows. What was only drawn with them gets a border or a system colour. */
  @media (forced-colors: active) {
    .mobile-nav-drawer,
    .header-account-menu {
      border: var(--border-width) solid CanvasText;
    }

    .site-header {
      border-block-end-color: CanvasText;
    }

    .usage-progress-track {
      border: var(--border-width) solid CanvasText;
    }

    .usage-progress-fill {
      background-color: Highlight;
      forced-color-adjust: none;
    }

    .header-nav > .active,
    .header-account-toggle.active,
    .mobile-nav-link.active {
      border-color: Highlight;
    }

    :root :is(.logo-img, .footer-logo) {
      filter: none;
    }

    a.external-link::after {
      forced-color-adjust: none;
    }
  }

  @media (forced-colors: active) and (prefers-color-scheme: dark) {
    :root :is(.logo-img, .footer-logo) {
      filter: brightness(0) invert(1);
    }
  }

  /* Paper: the content only (a legal page, a scoping result), black on white, with the addresses of the links */
  @media print {
    :root,
    :root[data-theme] {
      color-scheme: light;
    }

    @page {
      margin: 1.5cm;
    }

    body {
      display: block;
      min-block-size: 0;
      background: #fff;
      color: #000;
    }

    .skip-link,
    .site-header,
    .mobile-nav-drawer,
    .mobile-nav-backdrop,
    .site-footer,
    .cra-toast,
    .verify-dialog,
    .btn,
    .btn-sm,
    .sample-pill-btn,
    button,
    form {
      display: none;
    }

    .site-main {
      display: block;
      inline-size: auto;
      padding: 0;
    }

    .scoping-card,
    .portal-card,
    .document-card {
      padding: 0;
      border: 0;
      box-shadow: none;
      background: none;
    }

    :is(.logo-img, .footer-logo) {
      filter: none;
    }

    :where(h1, h2, h3, h4) {
      break-after: avoid;
    }

    :where(p, li) {
      orphans: 3;
      widows: 3;
    }

    :where(table, figure, .statutory-match-box, .callout-box) {
      break-inside: avoid;
    }

    .site-main :where(*) {
      color: #000;
    }

    .site-main a {
      text-decoration: underline;
    }

    .site-main a[href^="http"]::after {
      content: " (" attr(href) ")";
      display: inline;
      inline-size: auto;
      block-size: auto;
      margin: 0;
      background: none;
      font-size: 0.9em;
      font-weight: 400;
      overflow-wrap: anywhere;
    }
  }
}
