/*
 * csm-ui-kit — style bazowe layoutu i komponentów fundamentowych.
 * Wszystkie klasy z prefiksem `csm-` (patrz zadanie 05-02).
 *
 * Ten plik jest osadzany w bibliotece przez `include_str!` (patrz
 * `pub const CSS` w `src/lib.rs`) — NIE jest linkowany bezpośrednio przez
 * `<Stylesheet>`/cargo-leptos. Uzasadnienie wyboru w komentarzu przy `CSS`.
 */

/* Tokens independent of the theme and the palette. */
:root {
  --csm-sidebar-width: 15rem;
  /* Fixed height of the shell header: the sticky sidebar offsets itself by
   * exactly this much to sit directly under it. */
  --csm-header-height: 3.5rem;
  /* Legacy name, kept for host stylesheets until they move to the semantic
   * name; rules in this file use the semantic names. The alias resolves on
   * `:root` and is inherited as a value, so it follows the theme because the
   * theme attributes sit on `<html>` as well. */
  --csm-color-muted: var(--csm-color-text-muted);
  /* Background of the shell header. Brand colours override it. Like the
   * alias above, it resolves on `:root`, so it follows the theme. */
  --csm-color-header-bg: var(--csm-color-surface);
}

/* ---------------------------------------------------------------------- */
/* Theme tokens: palettes, each in a light and a dark variant.            */
/* ---------------------------------------------------------------------- */
/* `HtmlAppearance` writes `data-theme` (light | dark | system) and
 * `data-palette` (navy | sage | graphite) on `<html>` in the server render,
 * and the blocks below pick the token values by them. Component rules read
 * colours, shadows, radii and the font from these tokens; a new colour goes
 * in as a new token in the colour blocks.
 *
 * - `:root` alone is navy light, so a missing or unknown attribute renders
 *   light navy.
 * - The colour blocks are written to define the same set of tokens, so that
 *   the most specific matching block decides each colour and a dark block
 *   does not mix with the light values of the palette block that also
 *   matches. Specificity: `:root` < one attribute < theme + palette. The navy
 *   dark blocks tie with `:root[data-palette="navy"]` and win by coming
 *   later, which is why the dark blocks sit below the light ones.
 * - The font stacks put `system-ui` after the named fonts: on Linux it is
 *   whatever fontconfig picks, e.g. a CJK font with one weight and without
 *   ż, ś or ć, and those letters then come from another font in another
 *   weight.
 * - Font and radii depend on the palette and live in the light palette
 *   blocks. The dark blocks leave them out; the palette block still matches
 *   under a dark theme and supplies them.
 * - `system` follows the operating system when chosen: the media query
 *   selects `data-theme="system"`, not a page without the attribute. It
 *   repeats the dark values because one selector list cannot span a rule
 *   inside a media query and one outside it.
 * - No `light-dark()`: in a browser that does not know it, a property
 *   reading such a token falls back to its unset value.
 * - `--csm-color-control-border` outlines form controls,
 *   `--csm-color-frame-border` a fieldset frame in a public card. */

:root,
:root[data-palette="navy"] {
  color-scheme: light;
  --csm-font-family: "IBM Plex Sans", -apple-system, "Segoe UI", "Noto Sans", "Liberation Sans", system-ui, sans-serif;
  --csm-radius: 10px;
  --csm-radius-sm: 6px;
  --csm-color-bg: #f3f5f9;
  --csm-color-surface: #ffffff;
  --csm-color-surface-2: #f7f9fc;
  --csm-color-text: #141c2e;
  --csm-color-text-muted: #566176;
  --csm-color-border: #dce2ec;
  --csm-color-control-border: #818a9c;
  --csm-color-frame-border: #aeb6c4;
  --csm-color-primary: #24479e;
  --csm-color-primary-hover: #1c3a84;
  --csm-color-primary-contrast: #ffffff;
  --csm-color-link: #24479e;
  --csm-color-nav-active-bg: #e4ebfa;
  --csm-color-nav-active-text: #1c3a84;
  --csm-color-accent: #0b7285;
  --csm-color-accent-soft: #e0f2f5;
  --csm-color-danger: #b42d2d;
  --csm-color-danger-contrast: #ffffff;
  --csm-color-danger-soft: #fbeaea;
  --csm-color-success: #1d7044;
  --csm-color-success-contrast: #ffffff;
  --csm-color-success-soft: #e4f4ea;
  --csm-color-warning: #8f5300;
  --csm-color-warning-soft: #fdf1dc;
  --csm-color-neutral-soft: #eef1f6;
  --csm-color-focus-ring: #3f6fe0;
  --csm-color-scrim: rgba(20,28,46,.45);
  --csm-shadow: 0 1px 2px rgba(20,28,46,.05), 0 2px 6px rgba(20,28,46,.06);
  --csm-shadow-lg: 0 12px 32px rgba(20,28,46,.18);
}

:root[data-palette="sage"] {
  --csm-font-family: "Public Sans", -apple-system, "Segoe UI", "Noto Sans", "Liberation Sans", system-ui, sans-serif;
  --csm-radius: 12px;
  --csm-radius-sm: 8px;
  --csm-color-bg: #f4f5f1;
  --csm-color-surface: #ffffff;
  --csm-color-surface-2: #f8f9f6;
  --csm-color-text: #1b231e;
  --csm-color-text-muted: #5a655d;
  --csm-color-border: #dde2d9;
  --csm-color-control-border: #838c83;
  --csm-color-frame-border: #afb6ae;
  --csm-color-primary: #355f4c;
  --csm-color-primary-hover: #2a4f3e;
  --csm-color-primary-contrast: #ffffff;
  --csm-color-link: #2f5a46;
  --csm-color-nav-active-bg: #e3ede6;
  --csm-color-nav-active-text: #284a3a;
  --csm-color-accent: #a4501f;
  --csm-color-accent-soft: #f8ebe1;
  --csm-color-danger: #b0302b;
  --csm-color-danger-contrast: #ffffff;
  --csm-color-danger-soft: #fae9e7;
  --csm-color-success: #2c6e36;
  --csm-color-success-contrast: #ffffff;
  --csm-color-success-soft: #e4f2e2;
  --csm-color-warning: #875300;
  --csm-color-warning-soft: #fbf0d9;
  --csm-color-neutral-soft: #eef0eb;
  --csm-color-focus-ring: #4f8f72;
  --csm-color-scrim: rgba(27,35,30,.45);
  --csm-shadow: 0 1px 2px rgba(27,35,30,.05), 0 2px 6px rgba(27,35,30,.06);
  --csm-shadow-lg: 0 12px 32px rgba(27,35,30,.18);
}

:root[data-palette="graphite"] {
  --csm-font-family: -apple-system, "Segoe UI", "Noto Sans", "Liberation Sans", system-ui, sans-serif;
  --csm-radius: 8px;
  --csm-radius-sm: 6px;
  --csm-color-bg: #f5f4f1;
  --csm-color-surface: #ffffff;
  --csm-color-surface-2: #faf9f7;
  --csm-color-text: #1f1c19;
  --csm-color-text-muted: #635d56;
  --csm-color-border: #e2ded8;
  --csm-color-control-border: #8c8680;
  --csm-color-frame-border: #b6b1aa;
  --csm-color-primary: #2b2825;
  --csm-color-primary-hover: #45403b;
  --csm-color-primary-contrast: #ffffff;
  --csm-color-link: #b53d0c;
  --csm-color-nav-active-bg: #f7e6da;
  --csm-color-nav-active-text: #8a3410;
  --csm-color-accent: #b53d0c;
  --csm-color-accent-soft: #fcebe0;
  --csm-color-danger: #b42318;
  --csm-color-danger-contrast: #ffffff;
  --csm-color-danger-soft: #fbe9e7;
  --csm-color-success: #2b7046;
  --csm-color-success-contrast: #ffffff;
  --csm-color-success-soft: #e5f2e8;
  --csm-color-warning: #8a5600;
  --csm-color-warning-soft: #fbf0da;
  --csm-color-neutral-soft: #efece8;
  --csm-color-focus-ring: #d9622b;
  --csm-color-scrim: rgba(31,28,25,.45);
  --csm-shadow: 0 1px 2px rgba(31,28,25,.05), 0 2px 6px rgba(31,28,25,.06);
  --csm-shadow-lg: 0 12px 32px rgba(31,28,25,.2);
}

/* Dark theme, chosen explicitly. */
:root[data-theme="dark"] {
  color-scheme: dark;
  --csm-color-bg: #0e1320;
  --csm-color-surface: #161d2d;
  --csm-color-surface-2: #121827;
  --csm-color-text: #e6eaf3;
  --csm-color-text-muted: #9ba6bc;
  --csm-color-border: #283247;
  --csm-color-control-border: #6a748a;
  --csm-color-frame-border: #485268;
  --csm-color-primary: #86a8ff;
  --csm-color-primary-hover: #a1bbff;
  --csm-color-primary-contrast: #0b1736;
  --csm-color-link: #86a8ff;
  --csm-color-nav-active-bg: #22305a;
  --csm-color-nav-active-text: #c9d7ff;
  --csm-color-accent: #4cc3d1;
  --csm-color-accent-soft: #123940;
  --csm-color-danger: #ff8a80;
  --csm-color-danger-contrast: #0b1736;
  --csm-color-danger-soft: #3d1d22;
  --csm-color-success: #5fd394;
  --csm-color-success-contrast: #0b1736;
  --csm-color-success-soft: #16362a;
  --csm-color-warning: #f0b35a;
  --csm-color-warning-soft: #3a2c14;
  --csm-color-neutral-soft: #222b3e;
  --csm-color-focus-ring: #86a8ff;
  --csm-color-scrim: rgba(3,6,14,.6);
  --csm-shadow: 0 1px 2px rgba(0,0,0,.35), 0 2px 8px rgba(0,0,0,.25);
  --csm-shadow-lg: 0 16px 40px rgba(0,0,0,.55);
}

:root[data-theme="dark"][data-palette="sage"] {
  color-scheme: dark;
  --csm-color-bg: #111512;
  --csm-color-surface: #191f1b;
  --csm-color-surface-2: #151a16;
  --csm-color-text: #e3e9e4;
  --csm-color-text-muted: #9aa69d;
  --csm-color-border: #2b342e;
  --csm-color-control-border: #6a756d;
  --csm-color-frame-border: #49534c;
  --csm-color-primary: #8ec5a7;
  --csm-color-primary-hover: #a6d4ba;
  --csm-color-primary-contrast: #0e1f16;
  --csm-color-link: #8ec5a7;
  --csm-color-nav-active-bg: #22392d;
  --csm-color-nav-active-text: #c4e4d1;
  --csm-color-accent: #eba06b;
  --csm-color-accent-soft: #3a2617;
  --csm-color-danger: #f58a80;
  --csm-color-danger-contrast: #0e1f16;
  --csm-color-danger-soft: #3b1e1c;
  --csm-color-success: #7ccf86;
  --csm-color-success-contrast: #0e1f16;
  --csm-color-success-soft: #1b3520;
  --csm-color-warning: #e8b552;
  --csm-color-warning-soft: #372b12;
  --csm-color-neutral-soft: #232b25;
  --csm-color-focus-ring: #8ec5a7;
  --csm-color-scrim: rgba(4,6,5,.6);
  --csm-shadow: 0 1px 2px rgba(0,0,0,.35), 0 2px 8px rgba(0,0,0,.25);
  --csm-shadow-lg: 0 16px 40px rgba(0,0,0,.55);
}

:root[data-theme="dark"][data-palette="graphite"] {
  color-scheme: dark;
  --csm-color-bg: #151413;
  --csm-color-surface: #1e1c1a;
  --csm-color-surface-2: #191817;
  --csm-color-text: #ece8e3;
  --csm-color-text-muted: #a49d94;
  --csm-color-border: #34302c;
  --csm-color-control-border: #767069;
  --csm-color-frame-border: #534f49;
  --csm-color-primary: #ece8e3;
  --csm-color-primary-hover: #ffffff;
  --csm-color-primary-contrast: #1e1c1a;
  --csm-color-link: #f28c4e;
  --csm-color-nav-active-bg: #3b2518;
  --csm-color-nav-active-text: #ffc29d;
  --csm-color-accent: #f28c4e;
  --csm-color-accent-soft: #3a2216;
  --csm-color-danger: #f88779;
  --csm-color-danger-contrast: #1e1c1a;
  --csm-color-danger-soft: #3c1d1a;
  --csm-color-success: #70c98f;
  --csm-color-success-contrast: #1e1c1a;
  --csm-color-success-soft: #1a3324;
  --csm-color-warning: #eab157;
  --csm-color-warning-soft: #382b13;
  --csm-color-neutral-soft: #2a2724;
  --csm-color-focus-ring: #f28c4e;
  --csm-color-scrim: rgba(5,4,3,.6);
  --csm-shadow: 0 1px 2px rgba(0,0,0,.4), 0 2px 8px rgba(0,0,0,.3);
  --csm-shadow-lg: 0 16px 40px rgba(0,0,0,.6);
}

/* System theme: the dark values while the operating system prefers dark. */
@media (prefers-color-scheme: dark) {
  :root[data-theme="system"] {
    color-scheme: dark;
    --csm-color-bg: #0e1320;
    --csm-color-surface: #161d2d;
    --csm-color-surface-2: #121827;
    --csm-color-text: #e6eaf3;
    --csm-color-text-muted: #9ba6bc;
    --csm-color-border: #283247;
    --csm-color-control-border: #6a748a;
    --csm-color-frame-border: #485268;
    --csm-color-primary: #86a8ff;
    --csm-color-primary-hover: #a1bbff;
    --csm-color-primary-contrast: #0b1736;
    --csm-color-link: #86a8ff;
    --csm-color-nav-active-bg: #22305a;
    --csm-color-nav-active-text: #c9d7ff;
    --csm-color-accent: #4cc3d1;
    --csm-color-accent-soft: #123940;
    --csm-color-danger: #ff8a80;
    --csm-color-danger-contrast: #0b1736;
    --csm-color-danger-soft: #3d1d22;
    --csm-color-success: #5fd394;
    --csm-color-success-contrast: #0b1736;
    --csm-color-success-soft: #16362a;
    --csm-color-warning: #f0b35a;
    --csm-color-warning-soft: #3a2c14;
    --csm-color-neutral-soft: #222b3e;
    --csm-color-focus-ring: #86a8ff;
    --csm-color-scrim: rgba(3,6,14,.6);
    --csm-shadow: 0 1px 2px rgba(0,0,0,.35), 0 2px 8px rgba(0,0,0,.25);
    --csm-shadow-lg: 0 16px 40px rgba(0,0,0,.55);
  }

  :root[data-theme="system"][data-palette="sage"] {
    color-scheme: dark;
    --csm-color-bg: #111512;
    --csm-color-surface: #191f1b;
    --csm-color-surface-2: #151a16;
    --csm-color-text: #e3e9e4;
    --csm-color-text-muted: #9aa69d;
    --csm-color-border: #2b342e;
    --csm-color-control-border: #6a756d;
    --csm-color-frame-border: #49534c;
    --csm-color-primary: #8ec5a7;
    --csm-color-primary-hover: #a6d4ba;
    --csm-color-primary-contrast: #0e1f16;
    --csm-color-link: #8ec5a7;
    --csm-color-nav-active-bg: #22392d;
    --csm-color-nav-active-text: #c4e4d1;
    --csm-color-accent: #eba06b;
    --csm-color-accent-soft: #3a2617;
    --csm-color-danger: #f58a80;
    --csm-color-danger-contrast: #0e1f16;
    --csm-color-danger-soft: #3b1e1c;
    --csm-color-success: #7ccf86;
    --csm-color-success-contrast: #0e1f16;
    --csm-color-success-soft: #1b3520;
    --csm-color-warning: #e8b552;
    --csm-color-warning-soft: #372b12;
    --csm-color-neutral-soft: #232b25;
    --csm-color-focus-ring: #8ec5a7;
    --csm-color-scrim: rgba(4,6,5,.6);
    --csm-shadow: 0 1px 2px rgba(0,0,0,.35), 0 2px 8px rgba(0,0,0,.25);
    --csm-shadow-lg: 0 16px 40px rgba(0,0,0,.55);
  }

  :root[data-theme="system"][data-palette="graphite"] {
    color-scheme: dark;
    --csm-color-bg: #151413;
    --csm-color-surface: #1e1c1a;
    --csm-color-surface-2: #191817;
    --csm-color-text: #ece8e3;
    --csm-color-text-muted: #a49d94;
    --csm-color-border: #34302c;
    --csm-color-control-border: #767069;
    --csm-color-frame-border: #534f49;
    --csm-color-primary: #ece8e3;
    --csm-color-primary-hover: #ffffff;
    --csm-color-primary-contrast: #1e1c1a;
    --csm-color-link: #f28c4e;
    --csm-color-nav-active-bg: #3b2518;
    --csm-color-nav-active-text: #ffc29d;
    --csm-color-accent: #f28c4e;
    --csm-color-accent-soft: #3a2216;
    --csm-color-danger: #f88779;
    --csm-color-danger-contrast: #1e1c1a;
    --csm-color-danger-soft: #3c1d1a;
    --csm-color-success: #70c98f;
    --csm-color-success-contrast: #1e1c1a;
    --csm-color-success-soft: #1a3324;
    --csm-color-warning: #eab157;
    --csm-color-warning-soft: #382b13;
    --csm-color-neutral-soft: #2a2724;
    --csm-color-focus-ring: #f28c4e;
    --csm-color-scrim: rgba(5,4,3,.6);
    --csm-shadow: 0 1px 2px rgba(0,0,0,.4), 0 2px 8px rgba(0,0,0,.3);
    --csm-shadow-lg: 0 16px 40px rgba(0,0,0,.6);
  }
}

/* ---------------------------------------------------------------------- */
/* Entry hues: `--csm-hue-N` (soft background) and `--csm-hue-N-edge`    */
/* (saturated edge), N = 0..11, for `csm-data-table__entry--hue-N`.       */
/* ---------------------------------------------------------------------- */
/* The hues depend on the theme only, not on the palette: a category keeps
 * its colour when the palette changes. That is why they sit in their own
 * blocks instead of the palette blocks above, which would repeat the same
 * values once per palette. The system block repeats the dark values for the
 * same reason as the system palette blocks above. */
:root {
  --csm-hue-0: #ffc8c3;
  --csm-hue-1: #ffcba9;
  --csm-hue-2: #f3d392;
  --csm-hue-3: #d5df9a;
  --csm-hue-4: #b3e8b3;
  --csm-hue-5: #95ebd4;
  --csm-hue-6: #8ce9f4;
  --csm-hue-7: #ace0ff;
  --csm-hue-8: #c5d8ff;
  --csm-hue-9: #dad0ff;
  --csm-hue-10: #f6c4f9;
  --csm-hue-11: #ffc5da;
  --csm-hue-0-edge: #bb5752;
  --csm-hue-1-edge: #b3621e;
  --csm-hue-2-edge: #9a7403;
  --csm-hue-3-edge: #798205;
  --csm-hue-4-edge: #418e47;
  --csm-hue-5-edge: #028f77;
  --csm-hue-6-edge: #008b96;
  --csm-hue-7-edge: #0084b8;
  --csm-hue-8-edge: #5477c7;
  --csm-hue-9-edge: #8168be;
  --csm-hue-10-edge: #a05da4;
  --csm-hue-11-edge: #b4567e;
}

:root[data-theme="dark"] {
  --csm-hue-0: #602a27;
  --csm-hue-1: #5c300b;
  --csm-hue-2: #4f3901;
  --csm-hue-3: #3c4202;
  --csm-hue-4: #1e4821;
  --csm-hue-5: #02483b;
  --csm-hue-6: #01464c;
  --csm-hue-7: #01435f;
  --csm-hue-8: #283b67;
  --csm-hue-9: #413362;
  --csm-hue-10: #522d54;
  --csm-hue-11: #5d293f;
  --csm-hue-0-edge: #df7f78;
  --csm-hue-1-edge: #d78951;
  --csm-hue-2-edge: #c1983a;
  --csm-hue-3-edge: #9ca748;
  --csm-hue-4-edge: #6cb26f;
  --csm-hue-5-edge: #30b69a;
  --csm-hue-6-edge: #05b3c1;
  --csm-hue-7-edge: #45aade;
  --csm-hue-8-edge: #7a9ce9;
  --csm-hue-9-edge: #a48fe1;
  --csm-hue-10-edge: #c483c7;
  --csm-hue-11-edge: #d87da2;
}

@media (prefers-color-scheme: dark) {
  :root[data-theme="system"] {
    --csm-hue-0: #602a27;
    --csm-hue-1: #5c300b;
    --csm-hue-2: #4f3901;
    --csm-hue-3: #3c4202;
    --csm-hue-4: #1e4821;
    --csm-hue-5: #02483b;
    --csm-hue-6: #01464c;
    --csm-hue-7: #01435f;
    --csm-hue-8: #283b67;
    --csm-hue-9: #413362;
    --csm-hue-10: #522d54;
    --csm-hue-11: #5d293f;
    --csm-hue-0-edge: #df7f78;
    --csm-hue-1-edge: #d78951;
    --csm-hue-2-edge: #c1983a;
    --csm-hue-3-edge: #9ca748;
    --csm-hue-4-edge: #6cb26f;
    --csm-hue-5-edge: #30b69a;
    --csm-hue-6-edge: #05b3c1;
    --csm-hue-7-edge: #45aade;
    --csm-hue-8-edge: #7a9ce9;
    --csm-hue-9-edge: #a48fe1;
    --csm-hue-10-edge: #c483c7;
    --csm-hue-11-edge: #d87da2;
  }
}

/* ---------------------------------------------------------------------- */
/* Stage tones: `--csm-stage-tone-{grey|amber|light-blue|blue|green|      */
/* dark-green}`, the filled-block colours of `csm-stage-bar--tone-*`.     */
/* ---------------------------------------------------------------------- */
/* Like the hues, the tones depend on the theme only, not on the palette: a
 * tone keeps its colour when the palette changes. The system block repeats
 * the dark values for the same reason as the hue blocks above. */
:root {
  --csm-stage-tone-grey: #94a3b8;
  --csm-stage-tone-amber: #f59e0b;
  --csm-stage-tone-light-blue: #60a5fa;
  --csm-stage-tone-blue: #2563eb;
  --csm-stage-tone-green: #22c55e;
  --csm-stage-tone-dark-green: #15803d;
}

:root[data-theme="dark"] {
  --csm-stage-tone-grey: #7c8799;
  --csm-stage-tone-amber: #fbbf24;
  --csm-stage-tone-light-blue: #93c5fd;
  --csm-stage-tone-blue: #3b82f6;
  --csm-stage-tone-green: #4ade80;
  --csm-stage-tone-dark-green: #22a355;
}

@media (prefers-color-scheme: dark) {
  :root[data-theme="system"] {
    --csm-stage-tone-grey: #7c8799;
    --csm-stage-tone-amber: #fbbf24;
    --csm-stage-tone-light-blue: #93c5fd;
    --csm-stage-tone-blue: #3b82f6;
    --csm-stage-tone-green: #4ade80;
    --csm-stage-tone-dark-green: #22a355;
  }
}

/* This stylesheet is the applications' base CSS: the shells fill the whole
 * viewport, so the user agent's 8px body margin would only add a frame and a
 * scrollbar. */
body {
  margin: 0;
  background: var(--csm-color-bg);
  color: var(--csm-color-text);
}

/* Content links. Navigation and button links set their own colour on a
 * class, which outranks this element rule. */
a {
  color: var(--csm-color-link);
}

.csm-app-shell,
.csm-app-shell *,
.csm-panel-shell,
.csm-panel-shell * {
  box-sizing: border-box;
}

/* ---------------------------------------------------------------------- */
/* AppShell: sidebar + main content area.                                 */
/*                                                                        */
/* Hiding the sidebar: CHECKBOX HACK (a visually hidden                   */
/* <input type="checkbox"> + <label for=...> as the hamburger button +    */
/* the sibling selector `:checked ~`), because the toggle (header) and    */
/* the controlled element (sidebar) are disjoint elements of the tree,    */
/* which <details>/<summary> cannot control. Two independent checkboxes   */
/* precede the header; one hamburger label shows per breakpoint:          */
/* - `.csm-app-shell__toggle-input` opens the drawer on narrow screens.   */
/*   The open drawer closes through the hamburger or the backdrop         */
/*   <label> (pure CSS); `AppShell` also unchecks the box on Escape and   */
/*   when a link inside the sidebar is clicked (needs hydration).         */
/* - `.csm-app-shell__collapse-input` hides the sidebar on wide screens.  */
/*   It renders checked from the `csm_sidebar` cookie; a change writes    */
/*   the cookie (needs hydration).                                        */
/* ---------------------------------------------------------------------- */
/* Shared by both layouts: page frame, typography, grid rows. What differs is
 * only the column/area geometry, set on each layout below — everything inside
 * the frame (header, its elements, the content area) is styled once, by the
 * `.csm-app-shell__*` element rules, and applies in both. */
.csm-app-shell,
.csm-panel-shell {
  display: grid;
  grid-template-rows: auto 1fr;
  min-height: 100vh;
  min-height: 100dvh;
  font-family: var(--csm-font-family);
  color: var(--csm-color-text);
  background: var(--csm-color-bg);
}

/* The sidebar track is `auto`: as wide as the sidebar (which sets its own
 * width), and 0 while the collapsed sidebar is not displayed. The other
 * track's minimum is 0, not `auto`: the header spans it, and an `auto`
 * minimum would size it to the header's min-content width (the brand's whole
 * unwrapped name), wider than a narrow viewport. Bounded by the viewport, the
 * track leaves the brand to shrink to an ellipsis instead. */
.csm-app-shell {
  grid-template-columns: auto minmax(0, 1fr);
  grid-template-areas:
    "header header"
    "sidebar content";
}

/* PanelShell: one column, no sidebar track. A panel rendered in the
 * `.csm-app-shell` grid instead would leave the `sidebar` column empty and
 * 15rem wide, pushing the content right on every desktop viewport. */
.csm-panel-shell {
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas:
    "header"
    "content";
}

/* Horizontal panel navigation (PanelShell's `nav` slot) — sits between the
 * brand and the account slot, which carries `margin-left: auto`. */
.csm-panel-shell__nav {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

/* The controlling checkboxes are visually hidden but stay in the
 * accessibility tree (no `display: none`), so screen readers and keyboard
 * navigation (Tab) still see them as toggle buttons. The media queries below
 * remove the one that does nothing at the current breakpoint. */
.csm-app-shell__toggle-input,
.csm-app-shell__collapse-input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.csm-app-shell__header {
  grid-area: header;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background: var(--csm-color-header-bg);
  color: var(--csm-color-text);
  border-bottom: 1px solid var(--csm-color-border);
  /* A soft shadow under the header: some depth without being loud. */
  box-shadow: var(--csm-shadow);
  /* Stays at the top, above the content, while the page (the window)
   * scrolls. The narrow-screen drawer and its backdrop start at its bottom
   * edge. */
  position: sticky;
  top: 0;
  z-index: 10;
  height: var(--csm-header-height);
}

/* Hamburger labels: the drawer toggle shows on narrow screens, the collapse
 * toggle on wide ones (see the media queries below). */
.csm-app-shell__toggle,
.csm-app-shell__collapse-toggle {
  display: none;
  cursor: pointer;
  font-size: 1.25rem;
  line-height: 1;
  padding: 0.25rem 0.5rem;
  border-radius: var(--csm-radius-sm);
}

.csm-app-shell__toggle:hover,
.csm-app-shell__collapse-toggle:hover {
  background: var(--csm-color-neutral-soft);
}

.csm-app-shell__brand {
  font-weight: 600;
}

/* In the fixed-height header of `AppShell` and `PanelShell` the name gives
 * way to the logo and the account slot on a narrow screen: it shrinks and a
 * long name ends with an ellipsis. Public pages wrap it instead (below). */
:is(.csm-app-shell, .csm-panel-shell) .csm-app-shell__brand {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* The logo of the brand, before its name. The header has 0.75rem of
 * vertical padding, so the image fills the rest of the header height. The
 * width cap follows the viewport, so a wide logo leaves room for the name
 * and the rest of the header on a narrow screen; `object-fit` keeps the
 * image's proportions inside the capped box. */
.csm-app-shell__logo {
  display: block;
  flex-shrink: 0;
  height: calc(var(--csm-header-height) - 1.5rem);
  width: auto;
  max-width: min(10rem, 30vw);
  object-fit: contain;
}

/* PL/EN language switcher — pushed to the right edge of the header. It renders
 * only in PublicShell's header. */
.csm-lang-switcher {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

/* Each option is its own POST form (see `LangSwitcher`) — the wrapper carries
 * no look of its own, it only has to stop the user agent's form margins from
 * spacing the two options apart. */
.csm-lang-switcher__form {
  margin: 0;
  display: flex;
}

.csm-lang-switcher__option {
  padding: 0.15rem 0.4rem;
  border: 1px solid transparent;
  border-radius: var(--csm-radius-sm);
  font-family: inherit;
  font-size: 0.85rem;
  color: var(--csm-color-text-muted);
  background: transparent;
  text-decoration: none;
  cursor: pointer;
}

.csm-lang-switcher__option:hover {
  background: var(--csm-color-neutral-soft);
}

/* The current language: `LangSwitcher` marks its option `aria-current`. */
.csm-lang-switcher__option[aria-current="true"] {
  color: var(--csm-color-nav-active-text);
  background: var(--csm-color-nav-active-bg);
  font-weight: 600;
}

/* Slot for the account menu / actions outside the modules (e.g. Sign out). */
.csm-app-shell__account {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

/* A header carrying the language switcher keeps it at the right edge, with the
 * account slot next to it. */
.csm-lang-switcher + .csm-app-shell__account {
  margin-left: 0.75rem;
}

/* Link inside the account slot (e.g. "My account"). The slot's content is
 * the shell's contract, so its links are styled here, not by each consumer.
 * Padded to the same height as the `.csm-logout` button standing next to it;
 * hover feedback like the other navigation links. It stays on one line in
 * the fixed-height header; on a narrow screen the brand gives way instead. */
.csm-app-shell__account a {
  white-space: nowrap;
  padding: 0.375rem 0.75rem;
  border-radius: var(--csm-radius-sm);
  color: inherit;
  text-decoration: none;
  transition: background-color 0.15s ease;
}

.csm-app-shell__account a:hover {
  background: var(--csm-color-neutral-soft);
}

.csm-app-shell__sidebar {
  grid-area: sidebar;
  width: var(--csm-sidebar-width);
  display: flex;
  flex-direction: column;
  background: var(--csm-color-surface);
  border-right: 1px solid var(--csm-color-border);
  padding: 1.25rem 0;
  overflow-y: auto;
  /* Pinned under the sticky header and as tall as the rest of the screen.
   * The module navigation fills the free height and scrolls inside itself,
   * so the base navigation stays at the bottom of the SCREEN however long
   * the module list is. The page keeps scrolling on the window. */
  position: sticky;
  top: var(--csm-header-height);
  align-self: start;
  height: calc(100vh - var(--csm-header-height));
  height: calc(100dvh - var(--csm-header-height));
}

/* Module navigation: takes the sidebar's free height and scrolls when the
 * list is longer than that. */
.csm-app-shell__module-nav {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
}

/* The tenant's base links (e.g. Administration) — separated from the module
 * navigation and kept at the bottom of the sidebar (a flex column). */
.csm-app-shell__base-nav {
  flex-shrink: 0;
  margin-top: auto;
  padding-top: 0.75rem;
  border-top: 1px solid var(--csm-color-border);
}

.csm-app-shell__base-nav a {
  display: block;
  padding: 0.5rem 1rem;
  border-radius: var(--csm-radius-sm);
  color: inherit;
  text-decoration: none;
  transition: background-color 0.15s ease;
}

.csm-app-shell__base-nav a:hover {
  background: var(--csm-color-neutral-soft);
}

/* The link of the current page (`<A>` sets `aria-current="page"`). */
.csm-app-shell__base-nav a[aria-current="page"] {
  color: var(--csm-color-nav-active-text);
  background: var(--csm-color-nav-active-bg);
  font-weight: 600;
}

/* Closes the open mobile drawer when clicked (a label for the toggle
 * checkbox). Never shown on desktop. */
.csm-app-shell__backdrop {
  display: none;
}

.csm-app-shell__content {
  grid-area: content;
  padding: 1.75rem;
  min-width: 0;
}

/* Wide screens: the complement of the narrow-screen query below. The
 * collapse checkbox acts here, the drawer checkbox there. */
@media not all and (max-width: 48rem) {
  .csm-app-shell__collapse-toggle {
    display: inline-flex;
  }

  .csm-app-shell__toggle-input {
    display: none;
  }

  .csm-app-shell__collapse-input:checked ~ .csm-app-shell__sidebar {
    display: none;
  }
}

@media (max-width: 48rem) {
  .csm-app-shell {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "header"
      "content";
  }

  .csm-app-shell__toggle {
    display: inline-flex;
  }

  .csm-app-shell__collapse-input {
    display: none;
  }

  /* The drawer opens below the sticky header rather than over it, so the
   * menu button stays visible and clickable while the drawer is open; a
   * click on it unchecks the box like a click on the backdrop. Raising the
   * header above the drawer would instead hide the drawer's top under it.
   * The drawer sits above the backdrop (15). Its size comes from `inset`:
   * `align-self: stretch` replaces the wide-screen `start`, under which the
   * fixed box would shrink to the height of its content. */
  .csm-app-shell__sidebar {
    position: fixed;
    inset: var(--csm-header-height) 20% 0 0;
    align-self: stretch;
    width: auto;
    height: auto;
    transform: translateX(-100%);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    z-index: 20;
  }

  /* The shadow belongs to the open drawer only: the closed one lies just
   * left of the viewport, where its shadow would shade the page's left
   * edge. */
  .csm-app-shell__toggle-input:checked ~ .csm-app-shell__sidebar {
    transform: translateX(0);
    box-shadow: var(--csm-shadow-lg);
  }

  /* While the drawer is open the backdrop dims the page below the header,
   * and a touch on it closes the drawer. */
  .csm-app-shell__toggle-input:checked ~ .csm-app-shell__backdrop {
    display: block;
    position: fixed;
    inset: var(--csm-header-height) 0 0 0;
    z-index: 15;
    background: var(--csm-color-scrim);
    cursor: pointer;
  }
}

/* ---------------------------------------------------------------------- */
/* ModuleNav                                                               */
/* ---------------------------------------------------------------------- */
.csm-module-nav {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
}

/* Pozycja nawigacji renderuje dowolny `NavItem::render()` (patrz
 * module_nav.rs) — nie zakładamy struktury poza tym, że item to `<li>`.
 * Stylizujemy sam `<li>` (padding-fallback dla treści innej niż link) i
 * ewentualny link w środku (blokowy, z tłem na hover). */
.csm-module-nav__item {
  padding: 0.25rem 0.5rem;
}

.csm-module-nav__item a {
  display: block;
  padding: 0.5rem 0.75rem;
  border-radius: var(--csm-radius-sm);
  color: inherit;
  text-decoration: none;
  transition: background-color 0.15s ease;
}

.csm-module-nav__item a:hover {
  background: var(--csm-color-neutral-soft);
}

/* The link of the current page (`<A>` sets `aria-current="page"`). */
.csm-module-nav__item a[aria-current="page"] {
  color: var(--csm-color-nav-active-text);
  background: var(--csm-color-nav-active-bg);
  font-weight: 600;
}

/* ---------------------------------------------------------------------- */
/* NavGroup: a collapsible group of links (<details>/<summary>).          */
/*                                                                         */
/* The summary looks like a sidebar link (`.csm-module-nav__item a`) with */
/* its own expand indicator; the group's links are indented under it.     */
/* ---------------------------------------------------------------------- */
.csm-nav-group__summary {
  display: block;
  position: relative;
  padding: 0.5rem 2rem 0.5rem 0.75rem;
  border-radius: var(--csm-radius-sm);
  cursor: pointer;
  list-style: none;
  transition: background-color 0.15s ease;
}

.csm-nav-group__summary::-webkit-details-marker {
  display: none;
}

/* Expand indicator: a chevron drawn from two borders, pointing right while
 * the group is collapsed and down while it is open. */
.csm-nav-group__summary::after {
  content: "";
  position: absolute;
  top: 50%;
  right: 0.875rem;
  width: 0.4rem;
  height: 0.4rem;
  margin-top: -0.2rem;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(-45deg);
  transition: transform 0.15s ease;
}

.csm-nav-group[open] > .csm-nav-group__summary::after {
  transform: rotate(45deg);
}

.csm-nav-group__summary:hover {
  background: var(--csm-color-neutral-soft);
}

.csm-nav-group__items a {
  display: block;
  padding: 0.5rem 0.75rem 0.5rem 1.75rem;
  border-radius: var(--csm-radius-sm);
  color: inherit;
  text-decoration: none;
  transition: background-color 0.15s ease;
}

.csm-nav-group__items a:hover {
  background: var(--csm-color-neutral-soft);
}

/* The link of the current page (`<A>` sets `aria-current="page"`). */
.csm-nav-group__items a[aria-current="page"] {
  color: var(--csm-color-nav-active-text);
  background: var(--csm-color-nav-active-bg);
  font-weight: 600;
}

/* ---------------------------------------------------------------------- */
/* NavCount: a counter badge inside a navigation link.                    */
/*                                                                        */
/* The badge follows the link text inline, so the link rules above keep   */
/* their display. It sets its own colours (the primary button pair) and   */
/* weight, so the link's hover and current-page states leave it as is.    */
/* The label beside the number is `.csm-visually-hidden` (Utilities).     */
/* ---------------------------------------------------------------------- */
.csm-nav-count {
  display: inline-block;
  margin-inline-start: 0.5rem;
  padding: 0.125rem 0.375rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  color: var(--csm-color-primary-contrast);
  background: var(--csm-color-primary);
}

/* ---------------------------------------------------------------------- */
/* StatusBadge: a short status text in a pill coloured by its tone.       */
/*                                                                        */
/* `csm-status-badge` and                                                 */
/* `csm-status-badge--{success|warning|danger|neutral}` are a contract    */
/* for markup built outside Leptos too, like `csm-btn*`. A tone modifier  */
/* reads the `--csm-color-{tone}` text colour and its `-soft` background  */
/* from the colour blocks; neutral reads the muted text colour and        */
/* `--csm-color-neutral-soft` (there is no `--csm-color-neutral` token).  */
/* The transparent border shows the pill's outline in forced-colors mode. */
/* No outer margin: the caller spaces the badge.                          */
/* ---------------------------------------------------------------------- */
.csm-status-badge {
  display: inline-block;
  padding: 0.125rem 0.5rem;
  border: 1px solid transparent;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.25;
  white-space: nowrap;
  vertical-align: baseline;
}

.csm-status-badge--success {
  color: var(--csm-color-success);
  background: var(--csm-color-success-soft);
}

.csm-status-badge--warning {
  color: var(--csm-color-warning);
  background: var(--csm-color-warning-soft);
}

.csm-status-badge--danger {
  color: var(--csm-color-danger);
  background: var(--csm-color-danger-soft);
}

.csm-status-badge--neutral {
  color: var(--csm-color-text-muted);
  background: var(--csm-color-neutral-soft);
}

/* ---------------------------------------------------------------------- */
/* StatusIcon: a 1rem status glyph coloured by its tone.                  */
/*                                                                        */
/* The glyph's shape is drawn in `currentColor`: a tone modifier sets it  */
/* to `--csm-color-{tone}`, neutral to the muted text colour. The marks   */
/* inside a filled shape (check, X, exclamation mark) take the surface    */
/* colour, so they stand out from the shape in both themes. No outer      */
/* margin: the caller spaces the icon.                                    */
/* ---------------------------------------------------------------------- */
.csm-status-icon {
  display: inline-flex;
  vertical-align: middle;
  width: 1rem;
  height: 1rem;
}

.csm-status-icon svg {
  width: 100%;
  height: 100%;
}

.csm-status-icon__mark {
  fill: none;
  stroke: var(--csm-color-surface);
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.csm-status-icon--success {
  color: var(--csm-color-success);
}

.csm-status-icon--warning {
  color: var(--csm-color-warning);
}

.csm-status-icon--danger {
  color: var(--csm-color-danger);
}

.csm-status-icon--neutral {
  color: var(--csm-color-text-muted);
}

/* ---------------------------------------------------------------------- */
/* StageBar: the stage a linear process has reached, as a status text     */
/* above a row of blocks, one block per stage.                            */
/*                                                                        */
/* The bar takes its container's width between 7rem and 20rem. The        */
/* minimum leaves six blocks about 1rem each and is a floor of the bar's  */
/* min-content width, so an auto-layout table column holding it does not  */
/* collapse; the maximum caps the width the bar adds to such a column and */
/* keeps the bar a short meter on a detail card. The blocks share the     */
/* row's width through flex, whatever their number. The status text       */
/* wraps, in a small font.                                                */
/*                                                                        */
/* A grey block reads `--csm-color-border`, which stands out from the     */
/* surface more than `--csm-color-neutral-soft` does in every palette and */
/* theme. A reached block reads `--csm-stage-bar-fill`, set on the        */
/* wrapper by `--tone-*` from the matching `--csm-stage-tone-*` token;    */
/* every reached block of a bar has that one colour. Under `--failed`     */
/* every block is reached and reads `--csm-color-danger`, whatever the    */
/* tone. The transparent border shows each block's outline in             */
/* forced-colors mode, where the rules at the end of this section fill a  */
/* reached block with `CanvasText` and a reached block of a failed bar    */
/* with `Highlight`. No outer margin: the caller spaces the bar.          */
/* ---------------------------------------------------------------------- */
.csm-stage-bar {
  inline-size: 100%;
  min-inline-size: 7rem;
  max-inline-size: 20rem;
}

.csm-stage-bar--tone-grey {
  --csm-stage-bar-fill: var(--csm-stage-tone-grey);
}

.csm-stage-bar--tone-amber {
  --csm-stage-bar-fill: var(--csm-stage-tone-amber);
}

.csm-stage-bar--tone-light-blue {
  --csm-stage-bar-fill: var(--csm-stage-tone-light-blue);
}

.csm-stage-bar--tone-blue {
  --csm-stage-bar-fill: var(--csm-stage-tone-blue);
}

.csm-stage-bar--tone-green {
  --csm-stage-bar-fill: var(--csm-stage-tone-green);
}

.csm-stage-bar--tone-dark-green {
  --csm-stage-bar-fill: var(--csm-stage-tone-dark-green);
}

.csm-stage-bar__status {
  font-size: 0.8125rem;
  line-height: 1.25;
}

.csm-stage-bar__blocks {
  display: flex;
  gap: 3px;
  margin-block-start: 0.25rem;
}

.csm-stage-bar__block {
  flex: 1 1 0;
  box-sizing: border-box;
  block-size: 0.375rem;
  border: 1px solid transparent;
  border-radius: 2px;
  background: var(--csm-color-border);
}

.csm-stage-bar__block--reached {
  background: var(--csm-stage-bar-fill);
}

.csm-stage-bar--failed .csm-stage-bar__block--reached {
  background: var(--csm-color-danger);
}

/* System colours keep their value in forced-colors mode, while the author
 * colours above give way to the system background. The reached rule here has
 * the weight of the failed rule above and comes after it, so the failed bar's
 * rule repeats the wrapper class to outweigh it. */
@media (forced-colors: active) {
  .csm-stage-bar .csm-stage-bar__block--reached {
    background: CanvasText;
  }

  .csm-stage-bar.csm-stage-bar--failed .csm-stage-bar__block--reached {
    background: Highlight;
  }
}

/* ---------------------------------------------------------------------- */
/* StatusMessage: a message about an action result or page state in a     */
/* box coloured by its tone.                                              */
/*                                                                        */
/* `csm-message` and `csm-message--{success|warning|danger|neutral}` are  */
/* a contract for markup built outside Leptos too, like `csm-btn*`. A     */
/* tone modifier reads the `--csm-color-{tone}` text colour and its       */
/* `-soft` background from the colour blocks, and paints the start-edge   */
/* bar in the tone colour; neutral reads the normal text colour on        */
/* `--csm-color-neutral-soft`, with the muted text colour as the bar      */
/* (there is no `--csm-color-neutral` token). The transparent border      */
/* shows the box's outline in forced-colors mode.                         */
/* ---------------------------------------------------------------------- */
.csm-message {
  margin: 0.5rem 0;
  padding: 0.5rem 0.75rem;
  border: 1px solid transparent;
  border-inline-start-width: 0.25rem;
  border-radius: 0.375rem;
  font-size: 0.875rem;
}

.csm-message--success {
  color: var(--csm-color-success);
  background: var(--csm-color-success-soft);
  border-inline-start-color: var(--csm-color-success);
}

.csm-message--warning {
  color: var(--csm-color-warning);
  background: var(--csm-color-warning-soft);
  border-inline-start-color: var(--csm-color-warning);
}

.csm-message--danger {
  color: var(--csm-color-danger);
  background: var(--csm-color-danger-soft);
  border-inline-start-color: var(--csm-color-danger);
}

.csm-message--neutral {
  color: var(--csm-color-text);
  background: var(--csm-color-neutral-soft);
  border-inline-start-color: var(--csm-color-text-muted);
}

/* ---------------------------------------------------------------------- */
/* Base navigation section title and separator                            */
/*                                                                         */
/* Rendered by a host app in AppShell's `base_nav` slot, or as the first  */
/* item of ModuleNav in an administration mode, to title and divide the   */
/* sections of a sidebar.                                                 */
/* ---------------------------------------------------------------------- */
.csm-base-nav__title {
  margin: 0 0 0.25rem;
  padding: 0 1rem;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--csm-color-text-muted);
}

.csm-base-nav__sep {
  margin: 0.25rem 1rem 0.5rem;
  border: 0;
  border-top: 1px solid var(--csm-color-border);
}

/* A title used as a ModuleNav item lines up with the item links. */
.csm-module-nav__item .csm-base-nav__title {
  padding: 0.25rem 0.75rem;
}

/* ---------------------------------------------------------------------- */
/* Card                                                                    */
/* ---------------------------------------------------------------------- */
.csm-card {
  background: var(--csm-color-surface);
  border: 1px solid var(--csm-color-border);
  border-radius: var(--csm-radius);
  padding: 1rem;
}

.csm-card__title {
  margin: 0 0 0.75rem;
  font-size: 1rem;
  font-weight: 600;
}

.csm-card__body {
  color: var(--csm-color-text);
}

/* Stacked cards: the content area's sections follow one another as sibling
 * cards (`Card`, or a raw `<section class="csm-card">` / `<form
 * class="csm-card">`), and a `Suspense` or fragment around them adds no
 * element, so the sibling combinator sees them adjacent. A `DetailGroup`
 * (`.csm-details-group`) around some of the cards counts as one card of the
 * stack. The gap sits on the following card, so the first and a lone card
 * carry no margin. The whole selector is under `:where()` (specificity
 * `0-0-0`), so a class rule that sets the card's own margin overrides it. */
:where(.csm-app-shell__content
    :is(.csm-card, .csm-details-group) + :is(.csm-card, .csm-details-group)) {
  margin-block-start: 1rem;
}

/* Bare form controls in a card body (a filter row of `<label>`-wrapped
 * `<select>`s, say) are at most as wide as the body: a `<select>` sized by a
 * long option text narrows to the body instead of reaching past the card's
 * edge. Under `:where()` each rule weighs as its type selector alone
 * (`0-0-1`), like the `.csm-public__card` rules below, so a class rule on a
 * control overrides it. */
:where(.csm-card__body) input,
:where(.csm-card__body) select,
:where(.csm-card__body) textarea {
  max-width: 100%;
}

/* ---------------------------------------------------------------------- */
/* DetailList                                                             */
/*                                                                        */
/* `<dl class="csm-details">` of flat `<dt>`/`<dd>` pairs (`DetailList`,  */
/* `DetailItem`), with `csm-details__empty` on the `<dd>` of a missing    */
/* value. Two columns, the label column as wide as its longest label up   */
/* to 40%; a list narrower than 30rem (its own width, not the viewport's) */
/* stacks each label above its value. The first row is flush with the top */
/* and the last with the bottom, so the list sits in a card without       */
/* doubling the card's padding. Inside a `.csm-details-group` ancestor    */
/* the label column is `min(14rem, 40%)` for every list, so lists of      */
/* equal width line up; the width comes through the custom property       */
/* `--csm-details-label-column`, whose percentage resolves against each   */
/* list.                                                                  */
/* ---------------------------------------------------------------------- */
.csm-details {
  container: csm-details / inline-size;
  display: grid;
  grid-template-columns: var(--csm-details-label-column, fit-content(40%)) minmax(0, 1fr);
  margin: 0 0 1rem;
}

.csm-details-group {
  --csm-details-label-column: min(14rem, 40%);
}

.csm-details:last-child {
  margin-block-end: 0;
}

.csm-details > dt {
  grid-column: 1;
  padding: 0.5rem 1.5rem 0.5rem 0;
  min-width: 0;
  overflow-wrap: anywhere;
  color: var(--csm-color-text-muted);
}

.csm-details > dd {
  grid-column: 2;
  margin: 0;
  padding: 0.5rem 0;
  min-width: 0;
  overflow-wrap: anywhere;
  color: var(--csm-color-text);
}

/* The divider between rows sits on every `dt` but the first and on the
 * `dd` right after it. */
.csm-details > dt:not(:first-of-type),
.csm-details > dt:not(:first-of-type) + dd {
  border-top: 1px solid var(--csm-color-border);
}

.csm-details > dt:first-of-type,
.csm-details > dt:first-of-type + dd {
  padding-block-start: 0;
}

.csm-details > dt:last-of-type,
.csm-details > dd:last-child {
  padding-block-end: 0;
}

.csm-details > dd.csm-details__empty {
  color: var(--csm-color-text-muted);
  font-style: italic;
}

@container csm-details (max-width: 30rem) {
  .csm-details > dt,
  .csm-details > dd {
    grid-column: 1 / -1;
  }

  .csm-details > dt {
    padding-inline-end: 0;
    padding-block-end: 0.125rem;
  }

  .csm-details > dt:not(:first-of-type) + dd {
    border-top: 0;
  }

  .csm-details > dd {
    padding-block-start: 0;
  }

  /* The last row keeps the gap between its label and value like the rest. */
  .csm-details > dt:last-of-type {
    padding-block-end: 0.125rem;
  }
}

/* ---------------------------------------------------------------------- */
/* Button                                                                 */
/*                                                                        */
/* `.csm-btn` styles a <button> and an <a> alike (`ButtonLink`, `Pager`'s */
/* `Href` targets). A button takes its box sizing, line height and text   */
/* alignment from the user agent's button rule, a link from the page      */
/* around it, so the rule sets them, the line height at the value         */
/* `.csm-field__input` sets. The variant classes (`0-1-0`) outweigh the   */
/* content-link rule (`a`, `0-0-1`). `aria-pressed` is part of the        */
/* contract: a <button aria-pressed="true"> (`Button`'s `pressed` prop)   */
/* looks selected whatever its variant. So is `data-csm-hydrating`: a     */
/* button carrying it is disabled only until it hydrates, and looks       */
/* and hovers like an enabled one, unless a disabled <fieldset> holds it  */
/* (`BulkActionBar`'s actions), which disables it whether or not it has   */
/* hydrated. The exclusions sit under `:where()`, so they add no          */
/* specificity.                                                           */
/* ---------------------------------------------------------------------- */
.csm-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  box-sizing: border-box;
  border: 1px solid transparent;
  border-radius: var(--csm-radius-sm);
  padding: 0.5rem 1rem;
  font-family: inherit;
  font-size: 0.9375rem;
  font-weight: 500;
  line-height: 1.25;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
}

.csm-btn:disabled:where(:not([data-csm-hydrating]), fieldset:disabled *) {
  cursor: not-allowed;
  opacity: 0.6;
}

.csm-btn--primary {
  background: var(--csm-color-primary);
  color: var(--csm-color-primary-contrast);
}

.csm-btn--primary:hover:not(:where(:disabled:not([data-csm-hydrating]), fieldset:disabled *), [aria-pressed="true"]) {
  background: var(--csm-color-primary-hover);
}

.csm-btn--secondary {
  background: var(--csm-color-neutral-soft);
  color: var(--csm-color-text);
  border-color: var(--csm-color-border);
}

/* Text on the danger background has its own contrast token: brand colours
 * change the primary's contrast colour, not this one. */
.csm-btn--danger {
  background: var(--csm-color-danger);
  color: var(--csm-color-danger-contrast);
}

/* Text on the success background has its own contrast token, like the
 * danger variant's. */
.csm-btn--success {
  background: var(--csm-color-success);
  color: var(--csm-color-success-contrast);
}

/* The buttons of a record table's bulk change (`RecordTable`): text in the
 * surface colour on the warning colour, which is dark in a light theme and
 * light in a dark one. Hovering mixes the text colour in. */
.csm-btn--bulk {
  background: var(--csm-color-warning);
  color: var(--csm-color-surface);
  border-color: var(--csm-color-warning);
}

.csm-btn--bulk:hover:not(:where(:disabled:not([data-csm-hydrating]), fieldset:disabled *), [aria-pressed="true"]) {
  background: color-mix(in srgb, var(--csm-color-warning) 85%, var(--csm-color-text));
  border-color: color-mix(in srgb, var(--csm-color-warning) 85%, var(--csm-color-text));
}

/* A toggle button in the pressed state looks selected whatever its
 * variant: the navigation's active colours, a primary outline and an inner
 * ring that thickens the outline without moving the layout. It outweighs the
 * variant classes (`0-2-0` against `0-1-0`); the primary hover rule leaves
 * a pressed button out. */
.csm-btn[aria-pressed="true"] {
  background: var(--csm-color-nav-active-bg);
  color: var(--csm-color-nav-active-text);
  border-color: var(--csm-color-primary);
  box-shadow: inset 0 0 0 1px var(--csm-color-primary);
}

/* Compact size for row actions and toolbars: `csm-btn--compact` is a
 * contract for markup built outside Leptos too, next to the variant class
 * (`class="csm-btn csm-btn--secondary csm-btn--compact"`). The same metrics
 * apply to every `.csm-btn` inside a data-table cell, so a button in a row
 * is compact without the class. The 2rem minimum height keeps the touch
 * target of a row action usable (a regular button is about 2.3rem tall). */
.csm-btn--compact,
.csm-data-table td .csm-btn {
  min-height: 2rem;
  padding: 0.25rem 0.75rem;
  gap: 0.375rem;
  font-size: 0.8125rem;
}

/* A field in a table cell sits in the line of the cell's other controls
 * (a compact button, a select) instead of stacking as a form block: no
 * bottom margin, inline layout, vertically centred. The selector outweighs
 * `.csm-field`, which sets the block layout and the margin further down. The
 * error message stays inside the field's column and wraps below the input. */
.csm-data-table td .csm-field {
  display: inline-flex;
  vertical-align: middle;
  margin-bottom: 0;
}

/* The input in a table cell takes the compact metrics of the cell's buttons
 * and selects. The selector outweighs `.csm-field__input`, which sets the
 * regular padding and font size. */
.csm-data-table td .csm-field__input {
  min-height: 2rem;
  padding-block: 0.25rem;
  font-size: 0.8125rem;
}

/* ---------------------------------------------------------------------- */
/* TextField                                                               */
/* ---------------------------------------------------------------------- */
.csm-field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin-bottom: 0.75rem;
}

.csm-field__label {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--csm-color-text-muted);
}

/* The `csm-required` class on a `<label>` that points at its control through */
/* `for` appends a danger-coloured asterisk to the label text. It is a        */
/* contract for markup built outside Leptos too. The asterisk is hidden from  */
/* screen readers (alt text of `content`); the `required` attribute on the    */
/* control announces the requirement.                                         */
.csm-required::after {
  content: " *";
  content: " *" / "";
  color: var(--csm-color-danger);
}

.csm-field__input {
  padding: 0.5rem 0.625rem;
  border: 1px solid var(--csm-color-control-border);
  border-radius: var(--csm-radius-sm);
  font-family: inherit;
  font-size: 0.9375rem;
  /* An explicit line height: the `normal` of a text input and of a `<select>`
   * differ by a pixel, which would make a select beside an input shorter. */
  line-height: 1.25;
  color: var(--csm-color-text);
  background: var(--csm-color-surface);
}

.csm-field--error .csm-field__input {
  border-color: var(--csm-color-danger);
}

.csm-field__error {
  margin: 0;
  font-size: 0.8125rem;
  color: var(--csm-color-danger);
}

/* An input with an action button beside it (ServiceSecretField's toggle). */
.csm-field__row {
  display: flex;
  gap: 0.5rem;
}

.csm-field__row .csm-field__input {
  flex: 1;
  min-width: 0;
}

/* `FieldWidth::Short`: room for a 3-4 digit number and the native number
 * spinner. */
.csm-field__input--short {
  inline-size: 6rem;
}

/* ServiceSecretField's input is `type="text"` (its module doc says why), so
 * the stylesheet masks the value. */
.csm-field__input--masked {
  -webkit-text-security: disc;
}

/* ---------------------------------------------------------------------- */
/* DataTable                                                               */
/* ---------------------------------------------------------------------- */
/* The container `DataTable` renders around its table; hosts put a raw
 * `.csm-data-table` in it too. A table wider than the space around it
 * scrolls inside the container instead of widening the page. */
.csm-table-scroll {
  max-width: 100%;
  overflow-x: auto;
}

/* `csm-table-scroll--sticky-head` on the container keeps the table's
 * `thead` (the header row, an add row with its opener and refusal) in view
 * under the app header while the page (the window) scrolls the rows. The
 * container scrolls only horizontally and is as high as the table, so a
 * long list has one vertical scroll, the page's. `position: sticky` cannot
 * do this: `.csm-table-scroll` scrolls horizontally, and an element that
 * scrolls on one axis is the sticky reference on both. Instead a
 * scroll-driven animation moves the `thead` down by as far as the
 * container's top has passed the app header's bottom edge, on a view
 * timeline of the container: its scroller is the page, its start inset the
 * app header. Near the table's end the container clips the moved head; it
 * clips on the block axis (`overflow-y: hidden`) so that the moved head
 * does not make it scroll vertically. In a browser without scroll-driven
 * animations the head stays at the top of the table and scrolls away with
 * the page. A moved `thead` leaves collapsed borders behind, so the table
 * separates them; its cells draw only a bottom border, so it looks the
 * same. `z-index: 2` is above the dense grid's sticky first column (1). */
.csm-table-scroll--sticky-head > .csm-data-table {
  border-collapse: separate;
  border-spacing: 0;
}

.csm-table-scroll--sticky-head > .csm-data-table > thead {
  position: relative;
  z-index: 2;
  background: var(--csm-color-surface);
}

.csm-table-scroll--sticky-head > .csm-data-table > thead > tr > th {
  background: var(--csm-color-surface);
}

@supports (animation-timeline: view()) {
  .csm-table-scroll--sticky-head {
    overflow-y: hidden;
    view-timeline: --csm-table-sticky-head block;
    view-timeline-inset: var(--csm-header-height) 0;
  }

  /* From the moment the container's top reaches the app header the head
   * moves down 1px per 1px of scroll: the range runs 10000000px from there,
   * and so does the head. Firefox runs a scroll-driven animation only with
   * a duration other than 0, hence the 1ms; the timeline sets the pace. */
  .csm-table-scroll--sticky-head > .csm-data-table > thead {
    animation: csm-table-sticky-head linear both;
    animation-duration: 1ms;
    animation-timeline: --csm-table-sticky-head;
    animation-range: exit-crossing 0% exit-crossing 10000000px;
  }
}

@keyframes csm-table-sticky-head {
  from {
    translate: 0 0;
  }

  to {
    translate: 0 10000000px;
  }
}

.csm-data-table {
  width: 100%;
  border-collapse: collapse;
}

.csm-data-table th,
.csm-data-table td {
  text-align: left;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--csm-color-border);
}

.csm-data-table th {
  font-size: 0.8125rem;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  color: var(--csm-color-text-muted);
}

/* The table's title, as a <caption> above it. */
.csm-data-table > caption {
  caption-side: top;
  text-align: start;
  font-weight: 600;
  padding-block-end: 0.5rem;
  color: var(--csm-color-text);
}

/* ---------------------------------------------------------------------- */
/* Grid table: `csm-data-table--grid` on a `.csm-data-table` makes it a   */
/* grid of cells (a week timetable, a calendar) instead of a list of      */
/* rows.                                                                  */
/*                                                                        */
/* `csm-data-table--grid` and `csm-data-table__entry` are a contract for  */
/* markup built outside Leptos too, like `csm-btn*`. The grid draws a     */
/* border round every cell; a <th scope="row"> cell stays on one line.    */
/* `csm-data-table__entry` is an entry of a cell (a card of a few lines   */
/* of text) on a <span> or <div>. A `.csm-btn` in a grid cell takes the   */
/* same layout without the class and keeps its variant colours. Entries   */
/* in a cell's `.csm-actions` group stand side by side and wrap. An entry */
/* holding a `.csm-status-badge--danger` gets a danger start edge. A      */
/* selected entry is a button with `aria-pressed="true"` (see Button).    */
/*                                                                        */
/* `csm-data-table__entry--hue-N` (N = 0..11) on an entry sets its        */
/* background and border colour from the `--csm-hue-N` tokens; the text   */
/* keeps the theme's text colour. A host that writes <colgroup> elements  */
/* (one for the row-header column, one per day with `span`) gets a strong */
/* edge at the start of each group after the first; <th scope="colgroup"> */
/* headers pair with those elements. `csm-data-table__cell--unavailable`  */
/* on a <td> marks a cell that cannot hold an entry (a day off) with a    */
/* hatched neutral background.                                            */
/* ---------------------------------------------------------------------- */
.csm-data-table--grid th,
.csm-data-table--grid td {
  border: 1px solid var(--csm-color-border);
  vertical-align: top;
}

.csm-data-table--grid tbody th {
  white-space: nowrap;
}

.csm-data-table__entry {
  display: block;
  box-sizing: border-box;
  width: 100%;
  padding: 0.375rem 0.5rem;
  border: 1px solid var(--csm-color-border);
  border-radius: var(--csm-radius-sm);
  background: var(--csm-color-neutral-soft);
  color: var(--csm-color-text);
  font-size: 0.8125rem;
  line-height: 1.35;
  text-align: start;
  white-space: normal;
}

/* The hue modifiers come after the entry rule and win on order. The danger
 * start edge below is more specific and keeps its colour on that side. */
.csm-data-table__entry--hue-0 {
  background: var(--csm-hue-0);
  border-color: var(--csm-hue-0-edge);
}

.csm-data-table__entry--hue-1 {
  background: var(--csm-hue-1);
  border-color: var(--csm-hue-1-edge);
}

.csm-data-table__entry--hue-2 {
  background: var(--csm-hue-2);
  border-color: var(--csm-hue-2-edge);
}

.csm-data-table__entry--hue-3 {
  background: var(--csm-hue-3);
  border-color: var(--csm-hue-3-edge);
}

.csm-data-table__entry--hue-4 {
  background: var(--csm-hue-4);
  border-color: var(--csm-hue-4-edge);
}

.csm-data-table__entry--hue-5 {
  background: var(--csm-hue-5);
  border-color: var(--csm-hue-5-edge);
}

.csm-data-table__entry--hue-6 {
  background: var(--csm-hue-6);
  border-color: var(--csm-hue-6-edge);
}

.csm-data-table__entry--hue-7 {
  background: var(--csm-hue-7);
  border-color: var(--csm-hue-7-edge);
}

.csm-data-table__entry--hue-8 {
  background: var(--csm-hue-8);
  border-color: var(--csm-hue-8-edge);
}

.csm-data-table__entry--hue-9 {
  background: var(--csm-hue-9);
  border-color: var(--csm-hue-9-edge);
}

.csm-data-table__entry--hue-10 {
  background: var(--csm-hue-10);
  border-color: var(--csm-hue-10-edge);
}

.csm-data-table__entry--hue-11 {
  background: var(--csm-hue-11);
  border-color: var(--csm-hue-11-edge);
}

/* Same weight (`0-2-1`) as `.csm-data-table td .csm-btn` (the compact
 * metrics) and placed after it, so it wins on order. It outweighs
 * `:where(.csm-actions) .csm-btn` (`0-1-0`), whose `nowrap` would keep the
 * entry's text on one line. */
.csm-data-table--grid td .csm-btn {
  display: block;
  width: 100%;
  text-align: start;
  white-space: normal;
  padding: 0.375rem 0.5rem;
  line-height: 1.35;
}

.csm-data-table--grid td .csm-actions {
  align-items: stretch;
}

/* From a 7rem basis the entries share the row, and wrap where the next one
 * does not fit. `width: auto` replaces the full width of the rules above. A
 * button in a form of the group is an item of the row too (the form
 * generates no box, see ActionGroup). */
.csm-data-table--grid td .csm-actions > :is(.csm-btn, .csm-data-table__entry),
.csm-data-table--grid td .csm-actions > form > .csm-btn {
  flex: 1 1 7rem;
  width: auto;
}

.csm-data-table--grid td :is(.csm-btn, .csm-data-table__entry):has(.csm-status-badge--danger) {
  border-inline-start: 0.25rem solid var(--csm-color-danger);
}

/* The collapsed border model resolves the border of a column group through
 * the head and the body, and the wider border beats the cells' 1px ones. */
.csm-data-table--grid > colgroup + colgroup {
  border-inline-start: 2px solid var(--csm-color-text-muted);
}

.csm-data-table--grid .csm-data-table__cell--unavailable {
  background-color: var(--csm-color-neutral-soft);
  background-image: repeating-linear-gradient(-45deg, transparent 0 0.25rem, var(--csm-color-border) 0.25rem 0.3125rem);
  color: var(--csm-color-text-muted);
  text-align: center;
  vertical-align: middle;
}

/* ---------------------------------------------------------------------- */
/* Dense grid: `csm-data-table--dense` next to `csm-data-table--grid`     */
/* turns the grid into an overview of many rows and narrow columns (a     */
/* school timetable: tens of rows, days x periods columns).               */
/*                                                                        */
/* The table gets the surface background. Cells use a small font and      */
/* almost no padding, and a column is 1.75rem wide at least. Head cells   */
/* are centred and keep their case. An entry (or a `.csm-btn`) in a dense */
/* grid breaks words anywhere, so its text does not set the column's      */
/* width; the full text belongs in the entry's `title`. An entry with    */
/* `csm-data-table__entry--clip` breaks only between words instead, and   */
/* a word wider than the column ends in an ellipsis. Entries in a         */
/* cell's `.csm-actions` group take the whole width, one per line.        */
/* A `.csm-status-badge` takes the entry's font and a narrow padding, and */
/* its text breaks anywhere like the entry's.                             */
/*                                                                        */
/* The first column (the row headers, and the first head row's first      */
/* cell) is sticky at the inline start while the `.csm-table-scroll` is   */
/* scrolled. A sticky cell leaves the collapsed borders behind, so it     */
/* draws its edges as an inset shadow in the border colour. It sticks 1px */
/* outside the container, which covers the sliver of the scrolled cells   */
/* that shows through the collapsed table border at the container's edge; */
/* the start shadow is 2px wide so that 1px of it stays visible.          */
/* ---------------------------------------------------------------------- */
.csm-data-table--dense {
  background: var(--csm-color-surface);
}

.csm-data-table--dense th,
.csm-data-table--dense td {
  min-width: 1.75rem;
  padding: 0.0625rem;
  font-size: 0.6875rem;
  line-height: 1.2;
}

.csm-data-table--dense thead th {
  text-transform: none;
  letter-spacing: 0;
  text-align: center;
}

/* Same weight as `.csm-data-table--grid td .csm-btn` and placed after it.
 * The compact button's minimum height would keep a button-entry tall. */
.csm-data-table--dense .csm-data-table__entry,
.csm-data-table--dense td .csm-btn {
  min-height: 0;
  padding: 0.0625rem 0.125rem;
  font-size: inherit;
  line-height: inherit;
  overflow-wrap: anywhere;
}

/* Same weight as the dense entry rule above and placed after it. The zero
 * width with a full minimum width keeps the text out of the column's
 * width, like the break anywhere does for a plain entry. */
.csm-data-table--dense .csm-data-table__entry--clip {
  width: 0;
  min-width: 100%;
  overflow: hidden;
  overflow-wrap: normal;
  text-overflow: ellipsis;
}

/* Same weight as the 7rem rule of the grid and placed after it. */
.csm-data-table--dense td .csm-actions > :is(.csm-btn, .csm-data-table__entry),
.csm-data-table--dense td .csm-actions > form > .csm-btn {
  flex: 1 1 100%;
}

.csm-data-table--dense .csm-status-badge {
  padding: 0 0.125rem;
  font-size: inherit;
  white-space: normal;
  overflow-wrap: anywhere;
}

.csm-data-table--dense :is(thead tr:first-child, tbody tr) > th:first-child {
  position: sticky;
  inset-inline-start: -1px;
  z-index: 1;
  background: var(--csm-color-surface);
  box-shadow: inset 2px 0 0 var(--csm-color-border), inset -1px 0 0 var(--csm-color-border), inset 0 -1px 0 var(--csm-color-border);
}

/* ---------------------------------------------------------------------- */
/* EditableTable: `csm-data-table--editable` on a `.csm-data-table` makes */
/* it a table of editable records.                                        */
/*                                                                        */
/* `csm-data-table--editable`, `csm-data-table__editable-row` and         */
/* `csm-data-table__add-row` on its rows, `csm-data-table__add-opener` on */
/* the row a collapsed add row shows instead,                             */
/* `csm-data-table__message-row` on the row under a refused one,          */
/* `csm-data-table__refusal` on the box in its cell that holds the        */
/* refusal and a Retry button, `csm-data-table__text` on a cell of plain  */
/* text and `csm-row-status` on a row's save status are a contract for    */
/* markup built outside Leptos too, like `csm-btn*`. A field's input is   */
/* 10rem wide, a short one 6rem, and a select as wide as its longest      */
/* option up to 10rem; the actions column, the last one, is as narrow as  */
/* its content. The add row has the accent's soft background and an       */
/* accent edge at its start; so has the opener's button, in a cell on the */
/* surface background. The field and actions rules apply to the add row   */
/* and to the bulk change row (`csm-data-table__bulk-row`, see            */
/* RecordTable below) of a plain `.csm-data-table` as well. Of the add    */
/* row and the opener row, the one not shown carries `hidden`. The        */
/* opener's `hidden` keeps the user agent's rule; a rule that sets        */
/* `display` on that row restates it, as `.csm-bulk-bar [hidden]` does. A */
/* hidden add row or bulk change row has its own rule below.              */
/* ---------------------------------------------------------------------- */
/* Same weight as the `.csm-data-table th, .csm-data-table td` rule and
 * placed after it. The header cells take the cells' inline padding, so a
 * label stands over its column's field. */
.csm-data-table--editable th,
.csm-data-table--editable td {
  padding-inline: 0.5rem;
  vertical-align: middle;
}

/* The selector (`0-2-1`) outweighs `.csm-field__input--short` (`0-1-0`),
 * so the rule below restates the short width. */
:is(.csm-data-table--editable, .csm-data-table__add-row, .csm-data-table__bulk-row) td .csm-field__input {
  inline-size: 10rem;
  max-inline-size: 100%;
  box-sizing: border-box;
}

/* Same weight as the rule above and placed after it. */
:is(.csm-data-table--editable, .csm-data-table__add-row, .csm-data-table__bulk-row) td .csm-field__input--short {
  inline-size: 6rem;
}

/* Outweighs (`0-2-2`) the two rules above and the `max-width` of
 * `select.csm-field__input` (`0-1-1`). */
:is(.csm-data-table--editable, .csm-data-table__add-row, .csm-data-table__bulk-row) td select.csm-field__input {
  inline-size: auto;
  max-inline-size: 10rem;
}

/* A field's error message adds no width of its own to the field's column:
 * it wraps within the width of the input, breaking inside a word where the
 * word does not fit. */
:is(.csm-data-table--editable, .csm-data-table__add-row, .csm-data-table__bulk-row) td .csm-field__error {
  contain: inline-size;
  overflow-wrap: anywhere;
}

/* A row's buttons and its status stand on one line. Outweighs
 * `.csm-actions` (`0-1-0`). */
:is(.csm-data-table--editable, .csm-data-table__add-row, .csm-data-table__bulk-row) .csm-actions {
  flex-wrap: nowrap;
}

/* A cell of plain text breaks inside a word where the word does not fit,
 * so its min-content width shrinks and a long word no longer widens the
 * table beyond its scroll container; the cell still takes the free space up
 * to the width of its text on one line. `contain: inline-size` is not used:
 * it does not apply to a table cell, and on a wrapper inside the cell it
 * would collapse the column to the width of its header. */
.csm-data-table--editable .csm-data-table__text {
  overflow-wrap: anywhere;
}

/* The actions column is as narrow as its content. Only the record, add and
 * bulk change rows set it: a host's row with one cell spanning the
 * columns, and the message row, keep the table's width rules. */
:is(.csm-data-table__editable-row, .csm-data-table__add-row, .csm-data-table__bulk-row) > td:last-child {
  width: 1%;
  white-space: nowrap;
}

/* The reserved width keeps the actions column from widening when the
 * status text appears. */
.csm-row-status {
  display: inline-block;
  min-inline-size: 6rem;
  font-size: 0.8125rem;
  color: var(--csm-color-text-muted);
  white-space: nowrap;
}

.csm-data-table__add-row > td {
  background: var(--csm-color-accent-soft);
  vertical-align: middle;
}

.csm-data-table__add-row > td:first-child {
  box-shadow: inset 3px 0 0 var(--csm-color-accent);
}

/* A collapsed add row or a closed bulk change row (`hidden`) still counts
 * in the column widths, so the columns keep their widths when the row
 * shows or hides: it stays a table row, with `visibility: collapse`, which
 * shows nothing and takes no height. Its cells and their children are 0
 * high too, for a browser that takes `collapse` on a row for `hidden`
 * (Safari). */
:is(.csm-data-table__add-row, .csm-data-table__bulk-row)[hidden] {
  display: table-row;
  visibility: collapse;
}

:is(.csm-data-table__add-row, .csm-data-table__bulk-row)[hidden] > td {
  padding-block: 0;
  border-block: 0;
  line-height: 0;
}

:is(.csm-data-table__add-row, .csm-data-table__bulk-row)[hidden] > td > * {
  block-size: 0;
  min-block-size: 0;
  margin-block: 0;
  padding-block: 0;
  border-block-width: 0;
  overflow: hidden;
  vertical-align: top;
}

/* The opener row takes less block padding than a record row. Its cell
 * keeps the surface background inside a sticky head as well. */
.csm-data-table__add-opener > td {
  padding-block: 0.375rem;
  background: var(--csm-color-surface);
}

/* The opener and a record table's "+" button: the add row's colours and
 * its accent start edge. `:is()` takes the weight of its heaviest argument,
 * so the rule outweighs the variant classes (`0-2-0` against `0-1-0`); the
 * compact metrics of `.csm-data-table td .csm-btn` set other properties. */
:is(.csm-data-table__add-opener .csm-btn, .csm-table-toolbar__new) {
  background: var(--csm-color-accent-soft);
  color: var(--csm-color-accent);
  border-color: var(--csm-color-border);
  border-inline-start: 3px solid var(--csm-color-accent);
  font-weight: 700;
}

/* The message row joins the row above it: that row drops its bottom border
 * (`0-2-1` outweighs the cells' `0-1-1` rule) and the message cell its top
 * padding. Under the add row and the bulk change row the message takes
 * that row's background and edge. */
:is(.csm-data-table__editable-row, .csm-data-table__add-row, .csm-data-table__bulk-row):has(+ .csm-data-table__message-row) > td {
  border-bottom: 0;
}

.csm-data-table__message-row > td {
  padding-top: 0;
}

.csm-data-table__add-row + .csm-data-table__message-row > td {
  background: var(--csm-color-accent-soft);
  box-shadow: inset 3px 0 0 var(--csm-color-accent);
}

.csm-data-table__bulk-row + .csm-data-table__message-row > td {
  background: var(--csm-color-warning-soft);
  box-shadow: inset 3px 0 0 var(--csm-color-warning);
}

/* The refusal adds no width to any column: it wraps within the table's
 * width, breaking inside a word where the word does not fit. */
.csm-data-table__message-row .csm-message {
  margin: 0;
  contain: inline-size;
  overflow-wrap: anywhere;
}

/* The refusal and the Retry button of a record row stand side by side, the
 * button at the top when the refusal wraps to more lines. */
.csm-data-table__refusal {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
}

/* The refusal fills the width the button leaves. The
 * `.csm-data-table__message-row .csm-message` rule sets other properties,
 * so the order of the two rules does not matter. */
.csm-data-table__refusal .csm-message {
  flex: 1 1 auto;
}

/* The button keeps its size whatever the length of the refusal. */
.csm-data-table__refusal .csm-btn {
  flex: none;
}

/* ---------------------------------------------------------------------- */
/* RecordTable: the toolbar row under the header row and the bulk change  */
/* row.                                                                   */
/*                                                                        */
/* `csm-data-table__toolbar` on the toolbar row, `csm-table-toolbar` on   */
/* the box in its cell, `csm-table-toolbar__new` on its "+" button,       */
/* `csm-table-toolbar__count` on its count and `csm-data-table__bulk-row` */
/* on the bulk change row are a contract for markup built outside Leptos  */
/* too, like `csm-btn*` (`csm-btn--bulk` is in the Button section). The   */
/* toolbar's status of the add row and the bulk change row is a           */
/* `csm-row-status` right before the count; the two rows hold no status   */
/* of their own. The toolbar's buttons, status and count stand on one     */
/* line and wrap on a narrow screen; the status and the count stand at    */
/* the end of their line. The bulk change row has the warning's soft      */
/* background and a warning edge at its start.                            */
/* ---------------------------------------------------------------------- */
/* The toolbar row takes less block padding than a record row. Its cell
 * keeps the surface background inside a sticky head as well. */
.csm-data-table__toolbar > td {
  padding-block: 0.375rem;
  background: var(--csm-color-surface);
}

.csm-table-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

/* The status takes the free space of its line, its text at the end, next
 * to the count. */
.csm-table-toolbar > .csm-row-status {
  flex-grow: 1;
  text-align: end;
}

/* The auto margin keeps the count at the end of a line it stands on
 * without the status. */
.csm-table-toolbar__count {
  margin-inline-start: auto;
  font-size: 0.8125rem;
  color: var(--csm-color-text-muted);
  white-space: nowrap;
}

.csm-data-table__bulk-row > td {
  background: var(--csm-color-warning-soft);
  vertical-align: middle;
}

.csm-data-table__bulk-row > td:first-child {
  box-shadow: inset 3px 0 0 var(--csm-color-warning);
}

/* ---------------------------------------------------------------------- */
/* Row selection: SelectableTable's selection column and BulkActionBar.   */
/*                                                                        */
/* The selection column is as narrow as its content. Its cells drop the   */
/* table's padding, and the label around the checkbox fills the cell, so  */
/* the whole cell is the click target, at least 2.75rem square for a      */
/* finger.                                                                */
/* ---------------------------------------------------------------------- */
.csm-data-table .csm-data-table__select {
  width: 1%;
  padding: 0;
  white-space: nowrap;
}

.csm-data-table__select-label {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 2.75rem;
  min-height: 2.75rem;
  cursor: pointer;
}

.csm-checkbox {
  width: 1.125rem;
  height: 1.125rem;
  margin: 0;
  accent-color: var(--csm-color-primary);
  cursor: pointer;
}

.csm-checkbox:disabled {
  cursor: not-allowed;
}

/* The bar sits outside the table's scroll container, above or below the
 * table: it keeps a margin on the side that faces a sibling. The status
 * starts its line with a basis of 15rem, not its text's width, does not
 * shrink and stays on one line, a text longer than its box cut with an
 * ellipsis (the whole text stays in the element and its live region). Its
 * controls wrap onto further lines on a narrow screen. */
.csm-bulk-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
  margin-block: 0.75rem;
  padding: 0.5rem 0.75rem;
  background: var(--csm-color-surface);
  border: 1px solid var(--csm-color-border);
  border-radius: var(--csm-radius);
}

.csm-bulk-bar:first-child {
  margin-block-start: 0;
}

.csm-bulk-bar:last-child {
  margin-block-end: 0;
}

.csm-bulk-bar__count {
  flex: 1 0 min(15rem, 100%);
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  margin: 0;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--csm-color-text);
}

/* The host's actions sit in a <fieldset>, disabled while nothing is
 * selected or the selection is disabled; the list actions
 * (`csm-bulk-bar__list-actions`) sit in a second one, disabled only while
 * the selection is disabled. The rule drops the fieldset's user agent frame,
 * spacing and min-content width. Focus that was on an action when its
 * fieldset turned disabled moves to the select-all checkbox or to the bar
 * itself (`tabindex="-1"`), which then shows the focus ring. */
.csm-bulk-bar__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0;
  padding: 0;
  border: 0;
  min-inline-size: 0;
}

/* The select-result button carries `hidden` while it does not apply. The
 * user agent's `[hidden] { display: none }` loses to any author rule that
 * sets `display` (`.csm-btn`), so the bar restates it. Focus that was on the
 * button when it hid moves as from a disabled control. */
.csm-bulk-bar [hidden] {
  display: none;
}

/* ---------------------------------------------------------------------- */
/* MenuButton: a button that drops a list of values below it.             */
/*                                                                        */
/* The list lies over the content under the button: above a table's     */
/* sticky header (`z-index: 2`), below the app header (`z-index: 10`).    */
/* ---------------------------------------------------------------------- */
.csm-menu-button {
  position: relative;
  display: inline-block;
}

/* A chevron drawn from two borders, pointing down. */
.csm-menu-button__caret {
  flex: none;
  width: 0.375rem;
  height: 0.375rem;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: translateY(-25%) rotate(45deg);
}

.csm-menu-button__menu {
  position: absolute;
  top: calc(100% + 0.25rem);
  inset-inline-start: 0;
  z-index: 5;
  box-sizing: border-box;
  min-inline-size: 100%;
  margin: 0;
  padding: 0.25rem;
  list-style: none;
  font-size: 0.875rem;
  color: var(--csm-color-text);
  background: var(--csm-color-surface);
  border: 1px solid var(--csm-color-border);
  border-radius: var(--csm-radius-sm);
  box-shadow: var(--csm-shadow);
}

/* The user agent's `[hidden] { display: none }` loses to any author rule
 * that sets `display`, so the list restates it. */
.csm-menu-button__menu[hidden] {
  display: none;
}

.csm-menu-button__item {
  display: block;
  box-sizing: border-box;
  inline-size: 100%;
  min-height: 2rem;
  margin: 0;
  padding: 0.25rem 0.75rem;
  border: 0;
  border-radius: var(--csm-radius-sm);
  background: transparent;
  color: inherit;
  font: inherit;
  line-height: 1.25;
  text-align: start;
  white-space: nowrap;
  cursor: pointer;
}

.csm-menu-button__item:hover:not(:disabled),
.csm-menu-button__item:focus-visible {
  background: var(--csm-color-neutral-soft);
}

/* ---------------------------------------------------------------------- */
/* Pager                                                                   */
/* ---------------------------------------------------------------------- */
.csm-pager {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

/* ---------------------------------------------------------------------- */
/* ActionGroup and FilterBar: a row of actions, and a filter form's       */
/* fields with its actions in one wrapping row.                           */
/*                                                                        */
/* `csm-actions` and `csm-filter-bar` are a contract for markup built     */
/* outside Leptos too, like `csm-btn*`.                                   */
/* ---------------------------------------------------------------------- */
/* The actions stand side by side and wrap onto another line where the row
 * has no room for them. In a data-table cell the group wraps within the
 * width the table gives the column; a table wider than its scroll
 * container scrolls inside it. */
.csm-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

/* A label stays on one line inside its button: the group wraps whole
 * buttons, not words. Under `:where()` the selector weighs as `.csm-btn`
 * alone (`0-1-0`). */
:where(.csm-actions) .csm-btn {
  white-space: nowrap;
}

/* A form in the group (an `ActionForm` holding a button) generates no box
 * of its own, so its children are items of the group's row; the form
 * still submits. Under `:where()` the selector weighs as `form` alone
 * (`0-0-1`), like the bare-control rules, so a class rule on the form
 * overrides it. */
:where(.csm-actions) > form {
  display: contents;
}

/* The fields share the row from a 12rem flex basis, and the row wraps where
 * the next one does not fit at that basis; a field alone on a line narrower
 * than that shrinks, and `min-width: 0` lets it narrow below its control's
 * natural width. The children
 * line up at their bottom edge: the action group, sized by its content,
 * stands level with the inputs of fields that show no error message. */
.csm-filter-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.75rem;
}

/* What follows the bar in its container, e.g. a table, starts one row gap
 * below it, clear of the focus outline of the bar's fields (2px, offset
 * 2px), which a pinned table head would otherwise cover. The selector
 * weighs nothing (`0-0-0`), so a host's class rule that spaces the element
 * overrides it. */
:where(.csm-filter-bar + *) {
  margin-block-start: 0.75rem;
}

/* The selector weighs nothing (`0-0-0`), like the stacked-card rule, so a
 * class rule that sizes a field overrides it. */
:where(.csm-filter-bar > :not(.csm-actions)) {
  flex: 1 1 12rem;
  min-width: 0;
}

/* The bar spaces the fields with its gap. The selector outweighs
 * `.csm-field`, which sets the margin further down. */
.csm-filter-bar .csm-field {
  margin-bottom: 0;
}

/* ---------------------------------------------------------------------- */
/* FieldRow: several fields of a form in one wrapping row.                */
/*                                                                        */
/* `csm-field-row` is a contract for markup built outside Leptos too,     */
/* like `csm-filter-bar`.                                                 */
/* ---------------------------------------------------------------------- */
/* The row stands in the form column where one field would: it keeps the
 * bottom margin of a field, and its gap spaces the fields within it, also
 * between wrapped lines. The fields line up at their bottom edge. */
.csm-field-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

/* The fields share the row from a 12rem flex basis and the row wraps where
 * the next one does not fit at that basis; a field alone on a narrower line
 * shrinks. The selector weighs nothing (`0-0-0`), so a class rule that
 * sizes a field overrides it. */
:where(.csm-field-row > *) {
  flex: 1 1 12rem;
  min-width: 0;
}

/* A field with a short input (`FieldWidth::Short`) keeps the width of its
 * input or label, whichever is wider, and takes no share of the row. Same
 * weight as the rule above, which it follows. */
:where(.csm-field-row > :has(.csm-field__input--short)) {
  flex: 0 0 auto;
}

/* An error message adds no width of its own to a field in the row: it wraps
 * within the width the label and the input give the field, breaking inside
 * a word where the word does not fit. */
.csm-field-row .csm-field__error {
  contain: inline-size;
  overflow-wrap: anywhere;
}

/* The row spaces the fields with its gap. The selector outweighs
 * `.csm-field`, which sets the margin further up. */
.csm-field-row .csm-field {
  margin-bottom: 0;
}

/* ---------------------------------------------------------------------- */
/* FieldGroup: a group of a form's fields under a heading, a <fieldset>   */
/* with a <legend>.                                                       */
/*                                                                        */
/* `csm-field-group` is a contract for markup built outside Leptos too,   */
/* like `csm-field-row`.                                                  */
/* ---------------------------------------------------------------------- */
/* The class selectors outweigh the `:where(.csm-public__card) fieldset`
 * and `legend` rules further down, so a group inside the public card has
 * no frame or background either. */
.csm-field-group {
  /* The user agent's min-content width would widen the form column on a
   * narrow screen. */
  min-width: 0;
  /* Spaces the groups; the fields inside keep their own bottom margin,
   * except the last one in a public card (the frame rules there). */
  margin: 0 0 1.25rem;
  padding: 0;
  border: 0;
  background: none;
}

.csm-field-group__legend {
  /* Spaces the heading from the first field; a legend's own box holds the
   * space as padding. */
  padding: 0 0 0.5rem;
  font-size: 1rem;
  font-weight: 600;
  color: var(--csm-color-text);
}

/* ---------------------------------------------------------------------- */
/* PageHeader: the page's <h1> and its actions in one wrapping row.       */
/*                                                                        */
/* The title keeps the user agent's <h1> type, as on pages that render a  */
/* bare <h1>. Its block margin (0.67em of the h1's 2em) moves to the      */
/* header as 1.34em, so actions wrapped below the title are spaced by the */
/* row gap alone.                                                         */
/*                                                                        */
/* The optional trail of ancestors takes a line of its own above the      */
/* title, as wide as the header. The trail is a size container: at 30rem  */
/* of its width and more it lists every ancestor, each followed by a "/"; */
/* below that only the direct parent stays, with a left chevron in place  */
/* of the separator.                                                      */
/*                                                                        */
/* A page with a way back wraps the title with its back arrow in          */
/* `.csm-page-header__heading`, which takes the title's place in the row: */
/* the arrow stays on the title's line.                                   */
/* ---------------------------------------------------------------------- */
.csm-page-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1rem;
  margin-block: 1.34em;
}

/* Takes the width the actions leave; `min-width: 0` and `overflow-wrap`
 * let a word longer than the row break instead of widening it. */
.csm-page-header__title {
  flex: 1 1 auto;
  min-width: 0;
  margin: 0;
  overflow-wrap: anywhere;
}

.csm-page-header__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.csm-page-header__trail {
  container: csm-page-header-trail / inline-size;
  flex: 1 0 100%;
  min-width: 0;
  font-size: 0.875rem;
}

.csm-page-header__crumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 0.5rem;
  min-width: 0;
  margin: 0;
  padding: 0;
  list-style: none;
}

/* The second `content` declaration gives the separator an empty alternative
 * text, which hides it from screen readers where supported; the first is the
 * fallback. */
.csm-page-header__crumb::after {
  content: "/";
  content: "/" / "";
  margin-inline-start: 0.5rem;
  color: var(--csm-color-text-muted);
}

.csm-page-header__crumb a {
  overflow-wrap: anywhere;
}

.csm-page-header__chevron {
  display: none;
  width: 1em;
  height: 1em;
  margin-inline-end: 0.125rem;
  vertical-align: -0.125em;
}

@container csm-page-header-trail (max-width: 30rem) {
  .csm-page-header__crumb:not(:last-child) {
    display: none;
  }

  .csm-page-header__crumb::after {
    content: none;
  }

  .csm-page-header__chevron {
    display: inline-block;
  }
}

.csm-page-header__heading {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  flex: 1 1 auto;
  min-width: 0;
}

.csm-page-header__back {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 2rem;
  height: 2rem;
  border-radius: var(--csm-radius-sm);
  color: inherit;
  text-decoration: none;
  transition: background-color 0.15s ease;
}

.csm-page-header__back:hover {
  background: var(--csm-color-neutral-soft);
}

.csm-page-header__back svg {
  width: 1.25rem;
  height: 1.25rem;
}

/* ---------------------------------------------------------------------- */
/* Public pages: PublicShell, the layout of pages without a session.      */
/*                                                                        */
/* The shell header (`.csm-app-shell__header`, styled above) over a card  */
/* centred horizontally below it. The bare form controls in the card are  */
/* styled under `:where(.csm-public__card)`, with each `:not()` exclusion */
/* inside `:where()` too: that part adds no specificity, so each rule     */
/* weighs as its type selector alone (`0-0-1`), and a class rule on a     */
/* control overrides each property it sets. The controls of this          */
/* crate's form components (`.csm-field__label`, `.csm-field__input`,     */
/* `.csm-btn`, `.csm-lang-switcher__option`) are excluded, so properties  */
/* their own rules leave unset (width, margin) stay unset on them.        */
/* ---------------------------------------------------------------------- */
.csm-public,
.csm-public * {
  box-sizing: border-box;
}

.csm-public {
  display: grid;
  /* `minmax(0, …)`: content wider than the viewport does not widen the
   * column. */
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto 1fr;
  grid-template-areas:
    "header"
    "content";
  min-height: 100vh;
  min-height: 100dvh;
  font-family: var(--csm-font-family);
  color: var(--csm-color-text);
  background: var(--csm-color-bg);
}

.csm-public__main {
  grid-area: content;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  min-width: 0;
  padding: 4rem 1rem;
}

/* The brand is host-supplied text (e.g. a tenant name): it may shrink and
 * break anywhere, so an unbroken string does not widen the header past a
 * narrow viewport. */
.csm-public .csm-app-shell__brand {
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: 1.25rem;
}

/* A public page shows the logo larger than the panel header does. */
.csm-public .csm-app-shell__logo {
  height: 3rem;
  max-width: min(14rem, 40vw);
}

/* A wrapped brand makes the header taller than the shared fixed height;
 * no public-page layout depends on that height (there is no sidebar). */
.csm-public .csm-app-shell__header {
  height: auto;
  min-height: var(--csm-header-height);
}

/* `min()` keeps the card inside the viewport minus the main area's side
 * padding on narrow screens. */
.csm-public__card {
  width: min(22rem, 100%);
  /* Card content (title, form text, footer links) breaks anywhere, so an
   * unbroken string does not widen the card past the viewport. */
  overflow-wrap: anywhere;
  padding: 1.5rem;
  background: var(--csm-color-surface);
  border: 1px solid var(--csm-color-border);
  border-radius: var(--csm-radius);
  box-shadow: var(--csm-shadow);
}

.csm-public__card--wide {
  width: min(40rem, 100%);
}

.csm-public__title {
  margin: 0 0 1rem;
  font-size: 1.25rem;
  font-weight: 600;
  overflow-wrap: anywhere;
}

/* Helper links under the form. */
.csm-public__footer {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--csm-color-border);
  font-size: 0.875rem;
  color: var(--csm-color-text-muted);
}

:where(.csm-public__card) label:where(:not(.csm-field__label)) {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin-bottom: 0.75rem;
  font-size: 0.875rem;
  color: var(--csm-color-text-muted);
}

/* A raw label marked `csm-required` with no control inside keeps its text
 * and asterisk in one line: as a flex column, the `::after` asterisk would
 * become a separate item below the text. */
:where(.csm-public__card) label.csm-required:where(:not(:has(input, select, textarea))) {
  display: block;
}

/* A label wrapping a checkbox or a radio button puts the box beside its
 * text. */
:where(.csm-public__card) label:where(:not(.csm-field__label):has(> input[type="checkbox"], > input[type="radio"])) {
  flex-direction: row;
  align-items: flex-start;
  gap: 0.5rem;
  color: var(--csm-color-text);
}

:where(.csm-public__card) input:where(:not(.csm-field__input, [type="checkbox"], [type="radio"])),
:where(.csm-public__card) select:where(:not(.csm-field__input)),
:where(.csm-public__card) textarea:where(:not(.csm-field__input)) {
  width: 100%;
  padding: 0.5rem 0.625rem;
  border: 1px solid var(--csm-color-control-border);
  border-radius: var(--csm-radius-sm);
  font-family: inherit;
  font-size: 0.9375rem;
  color: var(--csm-color-text);
  background: var(--csm-color-surface);
}

:where(.csm-public__card) textarea:where(:not(.csm-field__input)) {
  min-height: 6rem;
  resize: vertical;
}

/* `min-width: 0` lets a fieldset shrink below its content's width (the user
 * agent's `min-content` would widen the card on a narrow screen). The frame
 * takes the page background; the controls inside keep the surface colour. */
:where(.csm-public__card) fieldset {
  min-width: 0;
  margin: 0 0 1rem;
  padding: 1rem;
  border: 1px solid var(--csm-color-frame-border);
  border-radius: var(--csm-radius-sm);
  background: var(--csm-color-bg);
}

/* Zeroes the bottom margin of a frame's last child (a bare control, a label,
 * a `.csm-field`, a nested `.csm-field-group`). The rule weighs `0-1-1` and
 * outweighs the bottom margins of those class rules (`0-1-0`) and of the
 * bare-label rule above. */
:where(.csm-public__card) fieldset > :last-child {
  margin-bottom: 0;
}

:where(.csm-public__card) legend {
  padding: 0 0.25rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--csm-color-text);
}

/* The form's buttons. */
:where(.csm-public__card) button:where(:not(.csm-lang-switcher__option, .csm-btn)) {
  width: 100%;
  padding: 0.5rem 1rem;
  border: 1px solid transparent;
  border-radius: var(--csm-radius-sm);
  font-family: inherit;
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--csm-color-primary-contrast);
  background: var(--csm-color-primary);
  cursor: pointer;
}

:where(.csm-public__card) button:where(:not(.csm-lang-switcher__option, .csm-btn):hover:not(:disabled)) {
  background: var(--csm-color-primary-hover);
}

:where(.csm-public__card) button:where(:not(.csm-lang-switcher__option, .csm-btn):disabled) {
  cursor: not-allowed;
  opacity: 0.6;
}

@media (max-width: 48rem) {
  .csm-public__main {
    padding-block: 1.5rem;
  }

  .csm-public__card {
    padding: 1.25rem;
  }
}

/* ---------------------------------------------------------------------- */
/* Build footer and error report.                                         */
/*                                                                        */
/* `.csm-build-footer` closes the content area of AppShell/PanelShell     */
/* with the build of the host: one small muted line, wrapped only when it */
/* does not fit. `.csm-error-report` is the block of the error pages a    */
/* user copies into a bug report; its lines stay selectable text.         */
/* ---------------------------------------------------------------------- */
.csm-build-footer {
  margin-top: 2rem;
  font-size: 0.75rem;
  line-height: 1.25;
  color: var(--csm-color-text-muted);
  overflow-wrap: anywhere;
}

.csm-error-report {
  margin-top: 1rem;
  padding: 0.75rem;
  border: 1px solid var(--csm-color-border);
  border-radius: var(--csm-radius-sm);
  background: var(--csm-color-neutral-soft);
  font-size: 0.8125rem;
  color: var(--csm-color-text-muted);
  overflow-wrap: anywhere;
}

.csm-error-report__line {
  margin: 0 0 0.25rem;
}

.csm-error-report__copy {
  margin-top: 0.5rem;
}

/* CopyField: a `.csm-field__row` whose input grows and whose copy button
 * keeps its width. Below about 12rem of room for the input the button wraps
 * onto its own line. */
.csm-copy-field {
  flex-wrap: wrap;
}

.csm-copy-field .csm-field__input {
  flex: 1 1 12rem;
}

.csm-copy-field__copy {
  flex: none;
}

@media (max-width: 48rem) {
  .csm-build-footer {
    margin-top: 1rem;
  }
}

/* ---------------------------------------------------------------------- */
/* Dialog                                                                 */
/*                                                                        */
/* `.csm-dialog` styles a native `<dialog>` opened with `showModal()`:    */
/* the browser centres it in the top layer and draws `::backdrop` over    */
/* the page behind it. `__title` is its heading, `__description` the      */
/* sentence under it, `__actions` the row of buttons at its foot.         */
/* ---------------------------------------------------------------------- */
.csm-dialog {
  box-sizing: border-box;
  inline-size: min(32rem, calc(100% - 2rem));
  padding: 1.25rem;
  border: 1px solid var(--csm-color-border);
  border-radius: var(--csm-radius);
  background: var(--csm-color-surface);
  color: var(--csm-color-text);
  box-shadow: var(--csm-shadow-lg);
}

/* `::backdrop` takes the tokens from its dialog; the fallback, the light
 * navy scrim, covers a browser where `::backdrop` inherits nothing. */
.csm-dialog::backdrop {
  background: var(--csm-color-scrim, rgba(20,28,46,.45));
}

.csm-dialog__title {
  margin: 0 0 0.5rem;
  font-size: 1.125rem;
  font-weight: 600;
}

.csm-dialog__description {
  margin: 0 0 1rem;
  font-size: 0.875rem;
  color: var(--csm-color-text-muted);
}

.csm-dialog__actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 1.25rem;
}

/* OneTimeSecretDialog: the label above a row of the secret and its two
 * buttons. The secret's box grows and the buttons keep their width; below
 * about 12rem of room for the secret the buttons wrap onto their own line. */
.csm-one-time-secret__label {
  margin: 0 0 0.25rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--csm-color-text-muted);
}

.csm-one-time-secret__row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

/* The secret in a monospace face, its spaces kept (`pre-wrap`), broken at
 * any character when it is longer than the box. */
.csm-one-time-secret__value {
  flex: 1 1 12rem;
  min-width: 0;
  box-sizing: border-box;
  padding: 0.5rem 0.625rem;
  border: 1px solid var(--csm-color-border);
  border-radius: var(--csm-radius-sm);
  background: var(--csm-color-surface-2);
  color: var(--csm-color-text);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 0.9375rem;
  line-height: 1.25;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.csm-one-time-secret__toggle,
.csm-one-time-secret__copy {
  flex: none;
}

/* ---------------------------------------------------------------------- */
/* Select                                                                  */
/*                                                                         */
/* A `<select>` takes the text input's look (`.csm-field__input`: padding, */
/* border, radius, font, surface) and a custom chevron in place of the     */
/* native arrow (`appearance: none`). It applies to                        */
/* - `select.csm-field__input` (SelectField and hosts' raw fields),        */
/* - a bare `<select>` in the content area (`.csm-app-shell__content`,     */
/*   shared by AppShell and PanelShell; the header and the sidebar are     */
/*   outside it) — filter rows and forms that wrap a `<select>` in a       */
/*   plain `<label>`,                                                      */
/* - a bare `<select>` in a public card (its metrics are set above).       */
/* A bare `<textarea>` and a bare text-like `<input>` in the content area  */
/* take the same metrics (padding, border, radius, font, line height,      */
/* colours) through the same rule. The input exclusions are the types with */
/* their own look (`checkbox`, `radio`, `file`, `range`, `color`, the      */
/* button types, `image`) and `hidden`; every other `type`, and an input   */
/* without one, is text-like. The shell's drawer and collapse toggles are  */
/* checkboxes outside the content area, so they are out of reach anyway.   */
/* The bare-control metrics are under `:where()` like the                  */
/* `.csm-public__card` rules: a class rule on a control overrides each     */
/* property they set. `.csm-field__input` is excluded there because its    */
/* own rule already sets the metrics, and `width` stays unset so a control */
/* inside a text line keeps its content width.                             */
/*                                                                         */
/* The chevron is two gradient triangles in `--csm-color-text-muted`, so   */
/* it follows the theme and the palette with the text (no inline image to  */
/* recolour). Its background layers do not use the `background` shorthand: */
/* the surface colour comes from `background-color`. The right padding     */
/* leaves room for it. In forced-colors mode the browser removes           */
/* backgrounds, so the native arrow returns.                               */
/* ---------------------------------------------------------------------- */
:where(.csm-app-shell__content) select:where(:not(.csm-field__input)),
:where(.csm-app-shell__content) textarea:where(:not(.csm-field__input)),
:where(.csm-app-shell__content) input:where(:not(.csm-field__input, [type="checkbox"], [type="radio"], [type="hidden"], [type="file"], [type="range"], [type="color"], [type="submit"], [type="button"], [type="reset"], [type="image"])) {
  max-width: 100%;
  padding: 0.5rem 0.625rem;
  border: 1px solid var(--csm-color-control-border);
  border-radius: var(--csm-radius-sm);
  font-family: inherit;
  font-size: 0.9375rem;
  line-height: 1.25;
  color: var(--csm-color-text);
  background-color: var(--csm-color-surface);
}

/* A textarea has a height of its own: a few lines, resizable vertically. */
:where(.csm-app-shell__content) textarea:where(:not(.csm-field__input)) {
  min-height: 5rem;
  resize: vertical;
}

select.csm-field__input,
:where(.csm-app-shell__content, .csm-public__card) select:where(:not(.csm-field__input)) {
  appearance: none;
  -webkit-appearance: none;
  /* A long option text narrows the select to its container instead of
   * pushing past it; a short one keeps its content width. */
  max-width: 100%;
  padding-right: 2rem;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--csm-color-text-muted) 50%),
    linear-gradient(135deg, var(--csm-color-text-muted) 50%, transparent 50%);
  background-position:
    calc(100% - 1.0625rem) 50%,
    calc(100% - 0.75rem) 50%;
  background-size: 0.3125rem 0.3125rem;
  background-repeat: no-repeat;
}

select.csm-field__input:disabled,
:where(.csm-app-shell__content, .csm-public__card) select:where(:not(.csm-field__input)):disabled,
:where(.csm-app-shell__content) textarea:where(:not(.csm-field__input)):disabled,
:where(.csm-app-shell__content) input:where(:not(.csm-field__input, [type="checkbox"], [type="radio"], [type="hidden"], [type="file"], [type="range"], [type="color"], [type="submit"], [type="button"], [type="reset"], [type="image"])):disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

/* A select or a text-like input in a table cell sits beside compact buttons,
 * so it takes their metrics. Under `:where()` the rule weighs as its type
 * selector alone, so a class rule on the control overrides it. */
:where(.csm-data-table td) select,
:where(.csm-data-table td) input:where(:not([type="checkbox"], [type="radio"], [type="hidden"], [type="file"], [type="range"], [type="color"], [type="submit"], [type="button"], [type="reset"], [type="image"])) {
  min-height: 2rem;
  padding-block: 0.25rem;
  font-size: 0.8125rem;
}

@media (forced-colors: active) {
  /* Forced colors drop `box-shadow` and the author colours: the pressed
   * button is marked by the system selection colours instead. */
  .csm-btn[aria-pressed="true"] {
    background: Highlight;
    color: HighlightText;
    border-color: Highlight;
  }

  select.csm-field__input,
  :where(.csm-app-shell__content, .csm-public__card) select:where(:not(.csm-field__input)) {
    appearance: auto;
    -webkit-appearance: auto;
  }
}

/* ---------------------------------------------------------------------- */
/* Chrome classes used by the applications' markup                         */
/*                                                                         */
/* Rendered by the hosts (panels, login pages, error slots) rather than by  */
/* a component of this crate, but styled HERE: the stylesheet is one and    */
/* shared, so a class defined in an application would either be missing on  */
/* the other surfaces or drift between them.                               */
/* ---------------------------------------------------------------------- */

/* Link of a horizontal navigation (PanelShell's `nav` slot). Same look as a
 * sidebar item (`.csm-module-nav__item a`) — the two navigations differ in
 * direction, not in the appearance of a single link. */
.csm-nav-link {
  display: block;
  padding: 0.5rem 0.75rem;
  border-radius: var(--csm-radius-sm);
  color: inherit;
  text-decoration: none;
  transition: background-color 0.15s ease;
}

.csm-nav-link:hover {
  background: var(--csm-color-neutral-soft);
}

/* The link of the current page (`<A>` sets `aria-current="page"`). */
.csm-nav-link[aria-current="page"] {
  color: var(--csm-color-nav-active-text);
  background: var(--csm-color-nav-active-bg);
  font-weight: 600;
}

/* Log-out button in the header's account slot. A secondary-button look on the
 * shared tokens; a `<button>` inherits nothing from `.csm-btn` here because
 * the hosts render it as a plain form submit. */
.csm-logout {
  border: 1px solid var(--csm-color-border);
  border-radius: var(--csm-radius-sm);
  padding: 0.375rem 0.75rem;
  font: inherit;
  font-size: 0.875rem;
  color: var(--csm-color-text);
  background: var(--csm-color-neutral-soft);
  cursor: pointer;
  transition: background-color 0.15s ease;
}

.csm-logout:hover {
  background: var(--csm-color-border);
}

/* Login page — a standalone surface with no shell around it: a narrow card
 * centred in the viewport. With no shell to inherit from, it sets the font
 * and the text colour itself. */
.csm-login {
  max-width: 22rem;
  margin: 4rem auto;
  padding: 1.5rem;
  font-family: var(--csm-font-family);
  color: var(--csm-color-text);
  background: var(--csm-color-surface);
  border: 1px solid var(--csm-color-border);
  border-radius: var(--csm-radius);
}

.csm-login h1 {
  margin: 0 0 1rem;
  font-size: 1.25rem;
}

.csm-login label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin-bottom: 0.75rem;
  font-size: 0.875rem;
  color: var(--csm-color-text-muted);
}

.csm-login input {
  padding: 0.5rem 0.625rem;
  border: 1px solid var(--csm-color-control-border);
  border-radius: var(--csm-radius-sm);
  font-family: inherit;
  font-size: 0.9375rem;
  color: var(--csm-color-text);
  background: var(--csm-color-surface);
}

/* The form's plain buttons. The language switcher in the card keeps its own
 * look, its options are buttons too, and so does a `.csm-btn`. */
.csm-login button:not(.csm-lang-switcher__option, .csm-btn) {
  width: 100%;
  padding: 0.5rem 1rem;
  border: 1px solid transparent;
  border-radius: var(--csm-radius-sm);
  font-family: inherit;
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--csm-color-primary-contrast);
  background: var(--csm-color-primary);
  cursor: pointer;
}

.csm-login button:not(.csm-lang-switcher__option, .csm-btn):hover:not(:disabled) {
  background: var(--csm-color-primary-hover);
}

/* Error message rendered in place of (or next to) content that failed to
 * load — the `Err(e) => <p class="csm-error">` arm of the hosts' views. */
.csm-error {
  margin: 0.5rem 0;
  color: var(--csm-color-danger);
  font-size: 0.875rem;
}

/* ---------------------------------------------------------------------- */
/* Utilities                                                              */
/* ---------------------------------------------------------------------- */

/* Text for assistive technology only: clipped out of sight and out of the
 * flow, but not `display: none` or `visibility: hidden`, which would also
 * remove it from the accessibility tree. */
.csm-visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: 0;
  padding: 0;
  border: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

/* ---------------------------------------------------------------------- */
/* Keyboard focus: one ring for the interactive elements of this file.    */
/*                                                                        */
/* Last in the file, so at equal specificity it wins over the component   */
/* rules above. A hamburger label shows the ring while its visually       */
/* hidden checkbox has focus (general sibling `~`: both checkboxes        */
/* precede the header).                                                   */
/* ---------------------------------------------------------------------- */
.csm-btn:focus-visible,
.csm-logout:focus-visible,
.csm-field__input:focus-visible,
.csm-checkbox:focus-visible,
.csm-bulk-bar:focus-visible,
.csm-menu-button__item:focus-visible,
.csm-page-header__back:focus-visible,
.csm-login input:focus-visible,
.csm-login button:focus-visible,
:where(.csm-public__card) :where(input, select, textarea, button):focus-visible,
:where(.csm-app-shell__content) select:focus-visible,
:where(.csm-app-shell__content) textarea:focus-visible,
:where(.csm-app-shell__content) input:where(:not([type="checkbox"], [type="radio"], [type="hidden"], [type="file"], [type="range"], [type="color"], [type="submit"], [type="button"], [type="reset"], [type="image"])):focus-visible,
.csm-lang-switcher__option:focus-visible,
.csm-nav-link:focus-visible,
.csm-module-nav__item a:focus-visible,
.csm-nav-group__summary:focus-visible,
.csm-nav-group__items a:focus-visible,
.csm-app-shell__base-nav a:focus-visible,
.csm-app-shell__account a:focus-visible,
.csm-app-shell__toggle-input:focus-visible ~ .csm-app-shell__header .csm-app-shell__toggle,
.csm-app-shell__collapse-input:focus-visible ~ .csm-app-shell__header .csm-app-shell__collapse-toggle {
  outline: 2px solid var(--csm-color-focus-ring);
  outline-offset: 2px;
}

/* A menu entry draws the ring inside its box: the entries of a list touch
 * each other, and the list's border is a padding's width away. */
.csm-menu-button__item:focus-visible {
  outline-offset: -2px;
}
