/* modest-ui - Bundled CSS
 * Generated from index.css and all component styles
 * This file contains all styles in a single file for easy distribution
 */

/* modest-ui - Minimal CSS component library */

/* Everything is in the mdst-ui cascade layer (each file wraps itself), so
   any CSS of yours outside a layer always wins. To order it against your
   own layers: @layer reset, mdst-ui, utilities; */
@layer mdst-ui.base, mdst-ui.components;

/* Base */
/* Layer order: base (tokens, reset) below components. Any CSS outside
   a layer, such as your own, always wins over modest-ui. */
@layer mdst-ui.base, mdst-ui.components;

@layer mdst-ui.base {
  :root {
    /* Colors */
    --mdst-color-fg: #000;
    --mdst-color-bg: #fff;
    --mdst-color-border: #000;
    --mdst-color-muted: #666;
    /* Subtle (light fills: skeletons, tracks, code, table lines) is mixed
       from the text and background colours, so a theme that only sets
       those two still gets a subtle shade that shows. If you set it
       yourself, keep it visibly different from the background. */
    --mdst-color-subtle: color-mix(in srgb, var(--mdst-color-fg) 4%, var(--mdst-color-bg));
    --mdst-color-focus: #000;
    --mdst-color-danger: #dc2626;
    --mdst-color-warning: #9d6e00;
    --mdst-color-success: #15803d;
    /* --mdst-color-info is optional: .mdst-info uses the text colour unless
       you set it, e.g. --mdst-color-info: #2563eb; */

    /* Typography */
    --mdst-font-sans: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --mdst-font-mono: ui-monospace, "SF Mono", Consolas, "Liberation Mono", Menlo, monospace;
    --mdst-line-height: 1.5;

    /* Semantic font roles — text is the reading face (prose inherits it from
       the .mdst-ui container); ui is the interface face (components and form
       controls). Override --mdst-font-text to retheme prose without touching
       components. */
    --mdst-font-text: var(--mdst-font-sans);
    --mdst-font-ui: var(--mdst-font-sans);

    /* Font sizes */
    --mdst-text-xs: 0.75rem;
    --mdst-text-sm: 0.875rem;
    --mdst-text-base: 1rem;
    --mdst-text-lg: 1.125rem;
    --mdst-text-xl: 1.25rem;

    /* Spacing */
    --mdst-space-px: 0.0625rem;
    --mdst-space-1: 0.25rem;
    --mdst-space-2: 0.5rem;
    --mdst-space-3: 0.75rem;
    --mdst-space-4: 1rem;
    --mdst-space-5: 1.25rem;
    --mdst-space-6: 1.5rem;
    --mdst-space-8: 2rem;

    /* Semantic spacing aliases */
    --mdst-space-xs: var(--mdst-space-1);
    --mdst-space-sm: var(--mdst-space-2);
    --mdst-space-md: var(--mdst-space-4);
    --mdst-space-lg: var(--mdst-space-6);
    --mdst-space-xl: var(--mdst-space-8);

    /* Flow: space between block elements (headings, paragraphs, lists, tables,
       form fields). In em, so it scales with each element's font size.
       Set to 0 to turn it off. */
    --mdst-flow-space: 1em;

    /* Focus: one keyboard focus ring for every component (:focus-visible).
       By default it's 2px solid in --mdst-color-focus, drawn flush against
       the component's edge (--mdst-focus-offset). Set --mdst-focus-ring
       to replace it everywhere, e.g. 3px dashed hotpink, or none if you draw
       your own:
         --mdst-focus-ring: 2px solid var(--mdst-color-focus); */
    --mdst-focus-offset: 0px;

    /* Border */
    --mdst-radius: 0;
    --mdst-border-width: 0.0625em;

    /* Transitions: fast for small state changes, slow for things that
       enter and leave (drawer, banner, toast) */
    --mdst-transition-fast: 50ms ease-out;
    --mdst-transition: 100ms ease-out;
    --mdst-transition-slow: 200ms ease-out;

    /* Depth */
    --mdst-shadow-sm: 0 0.125rem 0.375rem rgb(0 0 0 / 0.15);
    --mdst-shadow: 0 0.25rem 0.75rem rgb(0 0 0 / 0.2);
    --mdst-backdrop: rgb(0 0 0 / 0.4);
    --mdst-z-overlay: 1000;

    /* State */
    --mdst-disabled-opacity: 0.5;
  }

  /* Reduced motion: transitions finish instantly. Spinners and skeletons
     keep animating, since their motion is what shows something is loading. */
  @media (prefers-reduced-motion: reduce) {
    :root {
      --mdst-transition-fast: 0s;
      --mdst-transition: 0s;
      --mdst-transition-slow: 0s;
    }
  }

  /* Dark mode is opt-in, using the standard color-scheme property:

       :root { color-scheme: light dark; }   follow the visitor's system
       :root { color-scheme: dark; }         always dark

     Without it, pages stay light everywhere. Browsers without light-dark()
     stay light. Setting the colour tokens yourself replaces both values. */

  @supports (color: light-dark(#000, #fff)) {
    :root {
      --mdst-color-fg: light-dark(#000, #fff);
      --mdst-color-bg: light-dark(#fff, #1a1a1a);
      --mdst-color-border: light-dark(#000, #fff);
      --mdst-color-muted: light-dark(#666, #999);
      /* #f5f5f5 and #2a2a2a with the default colours */
      --mdst-color-subtle: light-dark(
        color-mix(in srgb, var(--mdst-color-fg) 4%, var(--mdst-color-bg)),
        color-mix(in srgb, var(--mdst-color-fg) 7%, var(--mdst-color-bg))
      );
      --mdst-color-focus: light-dark(#000, #fff);
      --mdst-color-danger: light-dark(#dc2626, #f87171);
      --mdst-color-warning: light-dark(#9d6e00, #db9705);
      --mdst-color-success: light-dark(#15803d, #4ade80);
    }
  }
}

@layer mdst-ui.base {
  /*
   * Minimal reset
   * Scoped to .mdst-ui, so nothing outside it is touched. The .mdst-ui
   * element itself keeps its own margin (e.g. <body>'s).
   */

  :where(.mdst-ui),
  :where(.mdst-ui) *,
  :where(.mdst-ui) *::before,
  :where(.mdst-ui) *::after {
    box-sizing: border-box;
  }

  :where(.mdst-ui) * {
    margin: 0;
  }

  :where(.mdst-ui) {
    -webkit-font-smoothing: antialiased;
  }

  :where(.mdst-ui) :where(img, picture, video, audio, canvas, svg, iframe, embed, object) {
    display: block;
    max-width: 100%;
  }

  :where(.mdst-ui) iframe {
    border: 0;
  }

  :where(.mdst-ui) :where(a, input, button, textarea, select) {
    font: inherit;
    color: inherit;
  }

  :where(.mdst-ui) :where(p, h1, h2, h3, h4, h5, h6) {
    overflow-wrap: break-word;
  }

  /* Class-only use outside .mdst-ui: components still size predictably
     (inputs are width: 100% plus padding, for example) without touching
     anything else on the page. */
  [class*="mdst-"],
  [class*="mdst-"]::before,
  [class*="mdst-"]::after {
    box-sizing: border-box;
  }

  /* One keyboard focus ring for everything inside .mdst-ui and every
     modest-ui component. Components only override the offset where they
     need to (fields draw it flush, tabs draw it inside). */
  :where(.mdst-ui) :focus-visible,
  :where([class*="mdst-"]):focus-visible {
    outline: var(--mdst-focus-ring, 2px solid var(--mdst-color-focus));
    outline-offset: var(--mdst-focus-offset);
  }

  @media (forced-colors: active) {
    :where(.mdst-ui) :focus-visible,
    :where([class*="mdst-"]):focus-visible {
      outline-color: Highlight;
    }
  }

  /* Small icon buttons keep their look but get at least a 24px tap area,
     from an invisible box centred on the button. Centring is the same in
     either text direction, so physical top/left are fine here. */
  :where(.mdst-banner__close, .mdst-toast__close, .mdst-tag__dismiss, .mdst-dialog__close, .mdst-drawer__close) {
    position: relative;

    &::after {
      content: "";
      position: absolute;
      top: 50%;
      left: 50%;
      width: max(100%, 24px);
      height: max(100%, 24px);
      translate: -50% -50%;
    }
  }

  /* Form controls and code blocks used by class (even outside .mdst-ui) drop
     the browser's default margins. This lives in the base layer, so flow
     spacing in the components layer still applies. */
  .mdst-input,
  .mdst-dropdown,
  .mdst-pre {
    margin: 0;
  }
}


/* Components */

@layer mdst-ui.components {
  /* Avatar */

  .mdst-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 50%;
    overflow: hidden;
    font-family: var(--mdst-font-ui);
    font-weight: 600;
    font-size: 1rem;
    line-height: 1;
    background: var(--mdst-color-subtle);
    color: var(--mdst-color-fg);
    vertical-align: middle;
    flex-shrink: 0;
    box-sizing: border-box;

    /* Images */

    & img {
      width: 100%;
      height: 100%;
      object-fit: cover;
    }

    /* Sizes */

    &.mdst-avatar--sm {
      width: 2rem;
      height: 2rem;
      font-size: 0.75rem;
    }

    &.mdst-avatar--lg {
      width: 3.5rem;
      height: 3.5rem;
      font-size: 1.25rem;
    }

    &.mdst-avatar--xl {
      width: 5rem;
      height: 5rem;
      font-size: 1.75rem;
    }

    /* Square variant */

    &.mdst-avatar--square {
      border-radius: var(--mdst-radius);
    }
  }

  /* Avatar group */

  .mdst-avatar-group {
    display: inline-flex;
    align-items: center;

    & > .mdst-avatar {
      margin-inline-start: -0.5rem;
      border: 2px solid var(--mdst-color-bg);
    }

    & > .mdst-avatar:first-child {
      margin-inline-start: 0;
    }
  }
}

@layer mdst-ui.components {
  /* Badge */

  .mdst-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.6em;
    padding: 0.25em 0.375em;
    font-size: var(--mdst-text-xs);
    font-family: var(--mdst-font-ui);
    line-height: 1;
    border-radius: 9999px;
    border: var(--mdst-border-width) solid var(--mdst-tone, var(--mdst-color-border));
    background: var(--mdst-color-bg);
    color: var(--mdst-tone, var(--mdst-color-fg));
    white-space: nowrap;
    vertical-align: middle;
    box-sizing: border-box;

    /* Tone (.mdst-danger and friends, or your own --mdst-tone) colours the
       text and border, and each variant below. Subtle tints the background
       with 10% of the tone; with no tone, --_tone-subtle is invalid and
       falls back to --mdst-color-subtle. */
    --_tone-subtle: color-mix(in srgb, var(--mdst-tone) 10%, transparent);

    /* Variants */

    &.mdst-badge--solid {
      background: var(--mdst-tone, var(--mdst-color-fg));
      color: var(--mdst-color-bg);
      border-color: var(--mdst-tone, var(--mdst-color-fg));
    }

    &.mdst-badge--subtle {
      background: var(--_tone-subtle, var(--mdst-color-subtle));
      border-color: transparent;
    }

    &.mdst-badge--dot {
      width: 0.6em;
      height: 0.6em;
      min-width: 0;
      padding: 0;
      font-size: var(--mdst-text-base);
      background: var(--mdst-tone, var(--mdst-color-fg));
      border-color: transparent;
      overflow: hidden;
      text-indent: -9999px;
    }

    /* Muted: a quieter badge rather than a status, so it stays a modifier */

    &.mdst-badge--muted {
      --mdst-tone: var(--mdst-color-muted);
      --_tone-subtle: var(--mdst-color-subtle);
    }

    /* Sizes */

    &.mdst-badge--sm {
      font-size: 0.625rem;
      min-width: 1.5em;
      padding: 0.2em 0.3em;
    }

    &.mdst-badge--lg {
      font-size: var(--mdst-text-sm);
      padding: 0.3em 0.5em;
    }

    /* Positioning */

    /* Corner badge at the top end; --_dir flips the nudge in RTL */
    &.mdst-badge--top-end {
      --_dir: 1;

      &:dir(rtl) {
        --_dir: -1;
      }

      position: absolute;
      top: 0;
      inset-inline-end: 0;
      transform: translate(calc(50% * var(--_dir)), -50%);
      z-index: 1;
    }
  }

  /* Deprecated: remove in 3.0. Use the tone classes (.mdst-danger, …). */

  .mdst-badge--danger {
    --mdst-tone: var(--mdst-color-danger);
  }

  .mdst-badge--success {
    --mdst-tone: var(--mdst-color-success);
  }

  .mdst-badge--warning {
    --mdst-tone: var(--mdst-color-warning);
  }

  .mdst-badge--info {
    --mdst-tone: var(--mdst-color-info, var(--mdst-color-fg));
  }

  /* Windows High Contrast (forced colours) removes fills, so the parts that
     show state are redrawn in the user's system colours. */
  @media (forced-colors: active) {
    .mdst-badge.mdst-badge--dot {
      forced-color-adjust: none;
      background: CanvasText;
    }
  }
}

@layer mdst-ui.components {
  /* Banner */

  .mdst-banner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--mdst-space-sm) var(--mdst-space-md);
    padding: var(--mdst-space-md);
    border: var(--mdst-border-width) solid var(--mdst-color-border);
    border-radius: var(--mdst-radius);
    background: var(--mdst-color-bg);
    color: var(--mdst-color-fg);
    font-family: var(--mdst-font-ui);

    /* The start edge: the border modifiers below set --_start, and a tone
       (.mdst-danger and friends, or your own --mdst-tone) replaces it with a
       3px accent edge. With no tone, --_accent is invalid and --_start
       applies. */
    --_start: var(--mdst-border-width) solid var(--mdst-color-border);
    --_accent: 3px solid var(--mdst-tone);
    font-size: var(--mdst-text-sm);
    line-height: var(--mdst-line-height);

    /* Content (grows to fill, pushes actions to the end) */

    & .mdst-banner__content {
      flex: 1 1 16rem;
      min-width: 0;

      & > * + * {
        margin-top: var(--mdst-space-xs);
      }
    }

    /* Actions (buttons, links) */

    & .mdst-banner__actions {
      display: flex;
      flex-wrap: wrap;
      align-items: center;
      gap: var(--mdst-space-sm);
    }

    /* Close button */

    & .mdst-banner__close {
      display: inline-flex;
      align-items: center;
      justify-content: center;
      align-self: flex-start;

      /* One text line tall, so the icon centres on the first line of content.
         Square around an icon, so the focus ring is a neat square; a word
         instead of an icon widens it rather than spilling out */
      height: calc(1em * var(--mdst-line-height));
      min-width: calc(1em * var(--mdst-line-height));
      padding: 0 0.125em;
      white-space: nowrap;
      flex-shrink: 0;
      margin: 0;
      border: none;
      background: none;
      box-shadow: none;
      color: inherit;
      cursor: pointer;
      opacity: 0.6;
      font-size: 1em;
      line-height: 1;
      transition: opacity var(--mdst-transition-fast);

      &:hover {
        opacity: 1;
      }

    }

    /* State: shown and hidden instantly (hidden removes it from layout) */

    &[data-state="visible"] {
      display: flex;
    }

    &[data-state="hidden"] {
      display: none;
    }

    /* Sizes */

    &.mdst-banner--sm {
      gap: var(--mdst-space-xs) var(--mdst-space-md);
      padding: var(--mdst-space-sm) var(--mdst-space-md);
      font-size: var(--mdst-text-xs);

      & .mdst-banner__actions {
        gap: var(--mdst-space-xs);
      }
    }

    /* Borders: remove all, or keep only the listed edges (combinable). A
       tone's accent edge still shows. */

    &:is(
        .mdst-banner--borderless,
        .mdst-banner--border-top,
        .mdst-banner--border-bottom,
        .mdst-banner--border-start,
        .mdst-banner--border-end
      ) {
      border: none;
      --_start: none;
    }

    &.mdst-banner--border-top {
      border-top: var(--mdst-border-width) solid var(--mdst-color-border);
    }

    &.mdst-banner--border-bottom {
      border-bottom: var(--mdst-border-width) solid var(--mdst-color-border);
    }

    &.mdst-banner--border-start {
      --_start: var(--mdst-border-width) solid var(--mdst-color-border);
    }

    &.mdst-banner--border-end {
      border-inline-end: var(--mdst-border-width) solid var(--mdst-color-border);
    }

    /* Start edge: the doubled class outranks the border modifiers above */

    &.mdst-banner {
      border-inline-start: var(--_accent, var(--_start));
    }

    /* Position: sticky to the top/bottom edge of its scrolling section.
       Place --top as the section's first child and --bottom as its last. */

    &.mdst-banner--top,
    &.mdst-banner--bottom {
      position: sticky;
      z-index: 1;
      /* Pinned banners hug their edge, so no flow spacing */
      margin: 0;
    }

    &.mdst-banner--top {
      top: var(--mdst-banner-offset, 0);
    }

    &.mdst-banner--bottom {
      bottom: var(--mdst-banner-offset, 0);
    }

    /* Position: fixed to the viewport (combine with --top or --bottom) */

    &.mdst-banner--fixed {
      position: fixed;
      inset-inline-start: var(--mdst-banner-offset, var(--mdst-space-md));
      inset-inline-end: var(--mdst-banner-offset, var(--mdst-space-md));
      z-index: var(--mdst-z-overlay);

      /* Corner: a compact card at the start/end edge instead of full width */

      &.mdst-banner--start,
      &.mdst-banner--end {
        max-width: var(--mdst-banner-width, 28rem);
      }

      &.mdst-banner--start {
        inset-inline-end: auto;
      }

      &.mdst-banner--end {
        inset-inline-start: auto;
      }

      &.mdst-banner--top {
        top: var(--mdst-banner-offset, var(--mdst-space-md));
      }

      &.mdst-banner--bottom {
        bottom: var(--mdst-banner-offset, var(--mdst-space-md));
      }
    }
  }

  /* Corner banners go full width on narrow screens */

  @media (max-width: 30rem) {
    .mdst-banner.mdst-banner--fixed {
      &.mdst-banner--start,
      &.mdst-banner--end {
        inset-inline-start: var(--mdst-banner-offset, var(--mdst-space-md));
        inset-inline-end: var(--mdst-banner-offset, var(--mdst-space-md));
        max-width: none;
      }
    }
  }

  /* Deprecated: remove in 3.0. Use the tone classes (.mdst-danger, …). */

  .mdst-banner--danger {
    --mdst-tone: var(--mdst-color-danger);
  }

  .mdst-banner--success {
    --mdst-tone: var(--mdst-color-success);
  }

  .mdst-banner--warning {
    --mdst-tone: var(--mdst-color-warning);
  }

  .mdst-banner--info {
    --mdst-tone: var(--mdst-color-info, var(--mdst-color-fg));
  }
}

@layer mdst-ui.components {
  /* Breadcrumbs */

  .mdst-breadcrumbs {
    & ol {
      display: flex;
      align-items: center;
      flex-wrap: wrap;
      gap: var(--mdst-space-xs);
      list-style: none;
      margin: 0;
      padding: 0;
      font-size: var(--mdst-text-sm);
      font-family: var(--mdst-font-ui);
    }

    & li {
      display: inline-flex;
      align-items: center;
      gap: var(--mdst-space-xs);
      margin: 0;
      color: var(--mdst-color-fg);
    }

    & li + li::before {
      content: "/";
      color: var(--mdst-color-muted);
      pointer-events: none;
      user-select: none;
    }

    & a {
      color: var(--mdst-color-muted);
      text-decoration: none;
      transition: color var(--mdst-transition);
      margin: 0;

      &:hover {
        color: var(--mdst-color-fg);
      }
    }

    & [aria-current="page"] {
      color: var(--mdst-color-fg);
      font-weight: 500;
    }

    /* Compact */

    &.mdst-breadcrumbs--sm {
      & ol {
        gap: calc(var(--mdst-space-xs) * 0.5);
        font-size: var(--mdst-text-xs);
      }

      & li {
        gap: calc(var(--mdst-space-xs) * 0.5);
      }
    }

    /* Arrow separator */

    &.mdst-breadcrumbs--arrow {
      & li + li::before {
        content: "\203A";
      }
    }
  }
}

@layer mdst-ui.components {
  /* Button

     Variants only set these public variables. Make your own the same way, on
     a class, a container, or an inline style:

       --mdst-button-tone     text / fill colour   (default: --mdst-color-fg)
       --mdst-button-bg       background           (default: --mdst-color-bg)
       --mdst-button-fg       text colour          (default: the tone)
       --mdst-button-border   border colour        (default: --mdst-color-border)

     Hover draws --mdst-button-hover-shadow (a ring in the text colour by
     default). Set it to none to turn hover off, or to any box-shadow.

     The hover rule only sets the private --_hover, never a property, so other
     components that reuse a bare <button> (a close icon, a tab) can opt out
     with a plain box-shadow: none. */

  :where(.mdst-ui) button,
  :where(.mdst-ui) input:where([type="submit"]),
  :where(.mdst-ui) input:where([type="reset"]),
  :where(.mdst-ui) input:where([type="button"]),
  .mdst-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--mdst-space-xs);
    padding: var(--mdst-space-sm) var(--mdst-space-md);
    font-family: var(--mdst-font-ui);
    font-size: inherit;
    line-height: var(--mdst-line-height);
    text-decoration: none;
    color: var(--mdst-button-fg, var(--mdst-tone, var(--mdst-button-tone, var(--mdst-color-fg))));
    background: var(--mdst-button-bg, var(--mdst-color-bg));
    border: var(--mdst-border-width) solid var(--mdst-button-border, var(--mdst-tone, var(--mdst-color-border)));
    border-radius: var(--mdst-radius);
    box-shadow: var(--_hover, none);
    cursor: pointer;
    transition:
      background var(--mdst-transition),
      color var(--mdst-transition),
      border-color var(--mdst-transition),
      box-shadow var(--mdst-transition);
    -webkit-appearance: none;
    appearance: none;
  }

  :where(.mdst-ui) button:where(:hover),
  :where(.mdst-ui) input:where([type="submit"]:hover),
  :where(.mdst-ui) input:where([type="reset"]:hover),
  :where(.mdst-ui) input:where([type="button"]:hover),
  .mdst-button:hover {
    --_hover: var(--mdst-button-hover-shadow, inset 0 0 0 var(--mdst-border-width) currentColor);
  }

  /* aria-disabled covers links styled as buttons, which can't be disabled */

  :where(.mdst-ui) button:disabled,
  :where(.mdst-ui) input:where([type="submit"]:disabled),
  :where(.mdst-ui) input:where([type="reset"]:disabled),
  :where(.mdst-ui) input:where([type="button"]:disabled),
  .mdst-button:disabled,
  .mdst-button[aria-disabled="true"] {
    --_hover: none;
    opacity: var(--mdst-disabled-opacity);
    cursor: not-allowed;
  }

  /* Variants: single classes that set variables, so they work on <button>,
     <input>, and <a> alike and combine freely (e.g. .mdst-danger + solid).
     A tone class (.mdst-danger and friends) sets --mdst-tone, which colours
     the text and border, and the fill when solid. */

  .mdst-button--borderless {
    --mdst-button-bg: transparent;
    --mdst-button-border: transparent;
  }

  /* Inverted fills the button with its tone. Toggle buttons use the same
     treatment when pressed. */

  .mdst-button--solid,
  :where(.mdst-ui) :where([aria-pressed="true"]),
  .mdst-button[aria-pressed="true"] {
    --mdst-button-bg: var(--mdst-tone, var(--mdst-button-tone, var(--mdst-color-fg)));
    --mdst-button-fg: var(--mdst-color-bg);
    --mdst-button-border: var(--mdst-tone, var(--mdst-button-tone, var(--mdst-color-fg)));
  }

  /* Sizes (input-qualified so they also beat the classless input rule) */

  :where(.mdst-ui) input.mdst-button--sm,
  .mdst-button--sm {
    padding: var(--mdst-space-xs) var(--mdst-space-sm);
    font-size: var(--mdst-text-sm);
  }

  :where(.mdst-ui) input.mdst-button--lg,
  .mdst-button--lg {
    padding: var(--mdst-space-md) var(--mdst-space-lg);
  }

  /* Windows High Contrast (forced colours) removes fills, so the parts that
     show state are redrawn in the user's system colours. */
  @media (forced-colors: active) {
    :where(.mdst-ui) [aria-pressed="true"],
    .mdst-button[aria-pressed="true"] {
      forced-color-adjust: none;
      background: Highlight;
      color: HighlightText;
      border-color: Highlight;
    }
  }

  /* Deprecated: remove in 3.0. Use .mdst-danger. */

  .mdst-button--danger {
    --mdst-tone: var(--mdst-color-danger);
  }
}

@layer mdst-ui.components {
  /* Card */

  .mdst-card {
    border: var(--mdst-border-width) solid var(--mdst-color-border);
    border-radius: var(--mdst-radius);
    background: var(--mdst-color-bg);

    & .mdst-card__header {
      padding: var(--mdst-space-md);
      border-bottom: var(--mdst-border-width) solid var(--mdst-color-border);
      font-weight: 600;

      /* Borderless header — removes the bottom border from the header */
      &.mdst-card__header--borderless {
        border-bottom: none;
      }
    }

    & .mdst-card__body {
      padding: var(--mdst-space-md);
    }

    & .mdst-card__footer {
      margin-top: auto;
      padding: var(--mdst-space-md);
      border-top: var(--mdst-border-width) solid var(--mdst-color-border);

      /* Borderless footer — removes the top border from the footer */
      &.mdst-card__footer--borderless {
        border-top: none;
      }
    }

    /* Variants */

    /* Only the outer border goes; header and footer dividers stay unless they
       are borderless too */
    &.mdst-card--borderless {
      border: none;
    }

    &.mdst-card--interactive {
      transition:
        box-shadow var(--mdst-transition),
        border-color var(--mdst-transition);
      cursor: pointer;

      &:hover {
        border-color: var(--mdst-color-fg);
        box-shadow: var(--mdst-shadow);
      }
    }

    /* A card can be a link, making the whole card the click target */
    &:is(a) {
      display: block;
      color: inherit;
      text-decoration: none;
    }

    /* Padding variants */

    &.mdst-card--sm {
      & > .mdst-card__header,
      & > .mdst-card__body,
      & > .mdst-card__footer {
        padding: var(--mdst-space-sm);
      }
    }

    /* Flush — no padding, for embedding raw content like tables or images */

    &.mdst-card--flush {
      & > .mdst-card__body {
        padding: 0;
      }
    }
  }
}

@layer mdst-ui.components {
  /* Checkbox
     A checkbox with role="switch" is drawn as a toggle (below) instead. */

  :where(.mdst-ui) input:where([type="checkbox"]:not([role="switch"])),
  .mdst-input:where([type="checkbox"]:not([role="switch"])) {
    -webkit-appearance: none;
    appearance: none;
    /* Border included in the size, so a user's border-box reset changes nothing */
    box-sizing: border-box;
    /* --mdst-border-width is in em, so match the surrounding text even
       outside .mdst-ui, where inputs default to a smaller font */
    font-size: inherit;
    flex-shrink: 0;
    width: calc(0.875rem + 2 * var(--mdst-border-width));
    height: calc(0.875rem + 2 * var(--mdst-border-width));
    background: var(--mdst-color-bg);
    border: var(--mdst-border-width) solid var(--mdst-color-border);
    border-radius: 0;
    cursor: pointer;
    position: relative;
    transition: border-color var(--mdst-transition);
  }

  :where(.mdst-ui) input:where([type="checkbox"]:not([role="switch"]):checked)::after,
  .mdst-input:where([type="checkbox"]:not([role="switch"]):checked)::after {
    content: "";
    position: absolute;
    inset: 2px;
    background: var(--mdst-color-fg);
  }

  :where(.mdst-ui) input:where([type="checkbox"]:disabled),
  .mdst-input:where([type="checkbox"]:disabled) {
    opacity: var(--mdst-disabled-opacity);
    cursor: not-allowed;
  }

  /* A label wrapping a checkbox or toggle */

  :where(.mdst-ui) label:where(:has(> input[type="checkbox"])),
  label:where(:has(> .mdst-input[type="checkbox"])) {
    display: inline-flex;
    align-items: center;
    gap: var(--mdst-space-sm);
    font-size: inherit;
    line-height: var(--mdst-line-height);
    cursor: pointer;
    user-select: none;
  }

  :where(.mdst-ui) label:where(:has(> input[type="checkbox"]:disabled)),
  label:where(:has(> .mdst-input[type="checkbox"]:disabled)) {
    opacity: var(--mdst-disabled-opacity);
    cursor: not-allowed;
  }

  /* The label already fades, so the control inside doesn't fade twice */
  :where(.mdst-ui) label:where(:has(> input[type="checkbox"]:disabled)) > input,
  label:where(:has(> .mdst-input[type="checkbox"]:disabled)) > .mdst-input {
    opacity: 1;
  }

  /* Toggle: a checkbox with role="switch", which is also what makes screen
     readers announce it as a switch */

  :where(.mdst-ui) input:where([type="checkbox"][role="switch"]),
  .mdst-input:where([type="checkbox"][role="switch"]) {
    -webkit-appearance: none;
    appearance: none;
    /* Border included in the size, so a user's border-box reset changes nothing */
    box-sizing: border-box;
    /* --mdst-border-width is in em, so match the surrounding text even
       outside .mdst-ui, where inputs default to a smaller font */
    font-size: inherit;
    flex-shrink: 0;
    width: calc(2.125rem + 2 * var(--mdst-border-width));
    height: calc(1.125rem + 2 * var(--mdst-border-width));
    background: var(--mdst-color-subtle);
    border: var(--mdst-border-width) solid var(--mdst-color-border);
    border-radius: 0;
    cursor: pointer;
    position: relative;
    transition:
      background var(--mdst-transition),
      border-color var(--mdst-transition);

    /* The thumb slides towards the end edge; --_dir flips it in RTL */
    --_dir: 1;

    &:dir(rtl) {
      --_dir: -1;
    }

    &::before {
      content: "";
      position: absolute;
      height: 0.875rem;
      width: 0.875rem;
      inset-inline-start: 2px;
      top: 50%;
      transform: translateY(-50%);
      background: var(--mdst-color-muted);
      transition:
        transform var(--mdst-transition),
        background var(--mdst-transition);
    }

    &:checked {
      background: var(--mdst-color-fg);
      border-color: var(--mdst-color-fg);

      &::before {
        transform: translateY(-50%) translateX(calc(1rem * var(--_dir)));
        background: var(--mdst-color-bg);
      }
    }

    &:disabled {
      opacity: var(--mdst-disabled-opacity);
      cursor: not-allowed;
    }

  }

  /* Pill variant */

  .mdst-input--pill:where([type="checkbox"][role="switch"]) {
    border-radius: 9999px;

    &::before {
      border-radius: 50%;
    }
  }

  /* Windows High Contrast (forced colours) removes fills, so the parts that
     show state are redrawn in the user's system colours. */
  @media (forced-colors: active) {
    :where(.mdst-ui) input:where([type="checkbox"]:not([role="switch"]):checked)::after,
    .mdst-input:where([type="checkbox"]:not([role="switch"]):checked)::after {
      forced-color-adjust: none;
      background: CanvasText;
    }

    :where(.mdst-ui) input:where([type="checkbox"][role="switch"]),
    .mdst-input:where([type="checkbox"][role="switch"]) {
      forced-color-adjust: none;
      background: Canvas;
      border-color: CanvasText;

      &::before {
        background: CanvasText;
      }

      &:checked {
        background: Highlight;
        border-color: Highlight;

        &::before {
          background: HighlightText;
        }
      }
    }
  }
}

@layer mdst-ui.components {
  /* Code - Inline code snippets */

  :where(.mdst-ui) code,
  .mdst-code {
    font-family: var(--mdst-font-mono);
    font-size: 0.875em;
    background: var(--mdst-color-subtle);
    border: 0.0625em solid var(--mdst-color-border);
    border-radius: var(--mdst-radius);
    padding: 0.125em 0.375em;
    word-break: break-word;
  }
}

@layer mdst-ui.components {
  /* Color Picker
     Classless (a bare input[type="color"] inside .mdst-ui) and class-based
     (.mdst-input on the input) share every rule. To show the hex value next
     to it, put a text .mdst-input beside it. */

  :where(.mdst-ui) input:where([type="color"]),
  .mdst-input:where([type="color"]) {
    -webkit-appearance: none;
    appearance: none;
    display: inline-block;
    width: var(--mdst-space-8);
    height: var(--mdst-space-8);
    padding: 0;
    /* --mdst-border-width is in em, so match the surrounding text */
    font-size: inherit;
    vertical-align: middle;
    background: none;
    border: var(--mdst-border-width) solid var(--mdst-color-border);
    border-radius: var(--_radius, 50%);
    cursor: pointer;
    transition: border-color var(--mdst-transition);
  }

  :where(.mdst-ui) input:where([type="color"]:focus-visible),
  .mdst-input:where([type="color"]:focus-visible) {
    outline-offset: 0;
  }

  :where(.mdst-ui) input:where([type="color"]:disabled),
  .mdst-input:where([type="color"]:disabled) {
    opacity: var(--mdst-disabled-opacity);
    cursor: not-allowed;
  }

  /* Webkit (Chrome, Safari, Edge) */

  :where(.mdst-ui) input:where([type="color"])::-webkit-color-swatch-wrapper,
  .mdst-input:where([type="color"])::-webkit-color-swatch-wrapper {
    padding: 0;
  }

  :where(.mdst-ui) input:where([type="color"])::-webkit-color-swatch,
  .mdst-input:where([type="color"])::-webkit-color-swatch {
    border: none;
    border-radius: var(--_radius, 50%);
  }

  /* Firefox */

  :where(.mdst-ui) input:where([type="color"])::-moz-color-swatch,
  .mdst-input:where([type="color"])::-moz-color-swatch {
    border: none;
    border-radius: var(--_radius, 50%);
  }

  /* Square variant: follows the theme's radius */

  .mdst-input--square:where([type="color"]) {
    --_radius: var(--mdst-radius);
  }
}

@layer mdst-ui.components {
  /* Date and time
     date, time, datetime-local, month, and week inputs get the text field
     styles from input.css (classless, or with .mdst-input). These rules even
     out what browsers add on top. */

  /* Chrome pads its inner edit box, which makes these fields taller than
     the other inputs */

  :where(.mdst-ui) input::-webkit-datetime-edit,
  :where(.mdst-ui) input::-webkit-datetime-edit-fields-wrapper,
  .mdst-input::-webkit-datetime-edit,
  .mdst-input::-webkit-datetime-edit-fields-wrapper {
    padding-block: 0;
  }

  :where(.mdst-ui) input::-webkit-calendar-picker-indicator,
  .mdst-input::-webkit-calendar-picker-indicator {
    margin-block: 0;
    padding-block: 0;
    cursor: pointer;
  }

  :where(.mdst-ui) input:where(:disabled)::-webkit-calendar-picker-indicator,
  .mdst-input:where(:disabled)::-webkit-calendar-picker-indicator {
    cursor: not-allowed;
  }
}

@layer mdst-ui.components {
  /* Details (Toggle/Disclosure) */

  :where(.mdst-ui) details,
  .mdst-details {
    position: relative;
    border: var(--mdst-border-width) solid var(--mdst-color-border);
    border-radius: var(--mdst-radius);
    background: var(--mdst-color-bg);
  }

  :where(.mdst-ui) details > summary,
  .mdst-details > summary {
    display: flex;
    align-items: center;
    gap: var(--mdst-space-sm);
    padding: var(--mdst-space-md);
    cursor: pointer;
    user-select: none;
    list-style: none;
    font-weight: 500;
    transition: background var(--mdst-transition);
  }

  :where(.mdst-ui) details > summary::-webkit-details-marker,
  .mdst-details > summary::-webkit-details-marker {
    display: none;
  }

  :where(.mdst-ui) details > summary::before,
  .mdst-details > summary::before {
    content: "";
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1em;
    height: 1em;
    flex-shrink: 0;
    background-color: currentColor;
    -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m9 18 6-6-6-6'/%3E%3C/svg%3E");
    mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m9 18 6-6-6-6'/%3E%3C/svg%3E");
    -webkit-mask-repeat: no-repeat;
    mask-repeat: no-repeat;
    -webkit-mask-position: center;
    mask-position: center;
    transition: transform var(--mdst-transition);
  }

  :where(.mdst-ui) details > summary:where(:hover),
  .mdst-details > summary:hover {
    color: var(--mdst-color-muted);
  }

  :where(.mdst-ui) details > summary:where(:focus-visible),
  .mdst-details > summary:focus-visible {
    outline-offset: -2px;
  }

  :where(.mdst-ui) details:where([open]) > summary::before,
  .mdst-details[open] > summary::before {
    transform: rotate(90deg);
  }

  /* The chevron points towards the end edge, so mirror it in RTL. scale
     combines with the open-state rotation, which still points down. */
  :where(.mdst-ui) details > summary:where(:dir(rtl))::before,
  .mdst-details > summary:dir(rtl)::before {
    scale: -1 1;
  }

  /* Content area - only style when open */

  :where(.mdst-ui) details:where([open])::details-content,
  .mdst-details[open]::details-content {
    padding: var(--mdst-space-md);
    border-top: var(--mdst-border-width) solid var(--mdst-color-border);
  }

  /* Variants */

  :where(.mdst-ui) details.mdst-details--borderless,
  .mdst-details.mdst-details--borderless {
    border: none;
  }

  :where(.mdst-ui) details.mdst-details--borderless:where([open])::details-content,
  .mdst-details.mdst-details--borderless[open]::details-content {
    border-top: none;
    padding-inline-start: calc(1em + var(--mdst-space-sm));
  }

  :where(.mdst-ui) details.mdst-details--sm > summary,
  .mdst-details.mdst-details--sm > summary {
    padding: var(--mdst-space-sm) var(--mdst-space-md);
  }

  :where(.mdst-ui) details.mdst-details--sm:where([open])::details-content,
  .mdst-details.mdst-details--sm[open]::details-content {
    padding: var(--mdst-space-sm) var(--mdst-space-md);
  }

  /* Section variant - collapsible header style */

  :where(.mdst-ui) details.mdst-details--section,
  .mdst-details.mdst-details--section {
    border: none;
    border-radius: 0;
    background: transparent;
  }

  :where(.mdst-ui) details.mdst-details--section > summary,
  .mdst-details.mdst-details--section > summary {
    padding: var(--mdst-space-sm) 0;
    font-size: var(--mdst-text-lg);
    font-weight: 600;
    border-bottom: var(--mdst-border-width) solid var(--mdst-color-border);
  }

  :where(.mdst-ui) details.mdst-details--section > summary::before,
  .mdst-details.mdst-details--section > summary::before {
    order: 1;
    margin-inline-start: auto;
    width: 1.25em;
    height: 1.25em;
  }

  :where(.mdst-ui) details.mdst-details--section:where([open]) > summary,
  .mdst-details.mdst-details--section[open] > summary {
    border-bottom-color: transparent;
  }

  :where(.mdst-ui) details.mdst-details--section:where([open])::details-content,
  .mdst-details.mdst-details--section[open]::details-content {
    padding: var(--mdst-space-sm) 0 var(--mdst-space-md);
    border-top: none;
    border-bottom: var(--mdst-border-width) solid var(--mdst-color-border);
  }

  /* Windows High Contrast (forced colours) removes fills, so the parts that
     show state are redrawn in the user's system colours. */
  @media (forced-colors: active) {
    :where(.mdst-ui) details > summary::before,
    .mdst-details > summary::before {
      forced-color-adjust: none;
      background-color: CanvasText;
    }
  }
}

@layer mdst-ui.components {
  /* Dialog */

  :where(.mdst-ui) dialog,
  .mdst-dialog {
    padding: 0;
    border: var(--mdst-border-width) solid var(--mdst-color-border);
    border-radius: var(--mdst-radius);
    background: var(--mdst-color-bg);
    color: var(--mdst-color-fg);
    max-width: min(90vw, 32rem);
    max-height: 90vh;

    /* Center the dialog */
    margin: auto;
    position: fixed;
    inset: 0;
    width: fit-content;
    height: fit-content;
  }

  /* A bare dialog (no class, no .mdst-dialog__ parts) has nothing to pad it,
     so it gets padding of its own, and its children get flow spacing (see
     typography). Give it a class, or build it from the parts, and the
     inside is yours. */

  :where(.mdst-ui) dialog:where(:not([class], [style], :has(> [class*="mdst-dialog__"]))) {
    padding: var(--mdst-space-md);
  }

  :where(.mdst-ui) dialog::backdrop,
  .mdst-dialog::backdrop {
    background: var(--mdst-backdrop);
  }

  /* Dialog Header */

  :where(.mdst-ui) dialog .mdst-dialog__header,
  .mdst-dialog .mdst-dialog__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--mdst-space-md);
    padding: var(--mdst-space-md);
    border-bottom: var(--mdst-border-width) solid var(--mdst-color-border);
  }

  :where(.mdst-ui) dialog .mdst-dialog__title,
  .mdst-dialog .mdst-dialog__title {
    margin: 0;
    font-size: var(--mdst-text-lg);
    font-weight: 600;
    line-height: var(--mdst-line-height);
  }

  :where(.mdst-ui) dialog .mdst-dialog__close,
  .mdst-dialog .mdst-dialog__close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    /* Square around an icon, so the focus ring is a neat square; a word
       instead of an icon widens it rather than spilling out */
    height: 2em;
    min-width: 2em;
    padding: 0 0.125em;
    line-height: 1;
    white-space: nowrap;
    flex-shrink: 0;
    background: transparent;
    border: none;
    box-shadow: none;
    border-radius: var(--mdst-radius);
    cursor: pointer;
    color: var(--mdst-color-muted);
    transition: color var(--mdst-transition);
  }

  :where(.mdst-ui) dialog .mdst-dialog__close:where(:hover),
  .mdst-dialog .mdst-dialog__close:hover {
    color: var(--mdst-color-fg);
  }

  /* Dialog Body */

  :where(.mdst-ui) dialog .mdst-dialog__body,
  .mdst-dialog .mdst-dialog__body {
    padding: var(--mdst-space-md);
    overflow-y: auto;
  }

  /* Dialog Footer */

  :where(.mdst-ui) dialog .mdst-dialog__footer,
  .mdst-dialog .mdst-dialog__footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: var(--mdst-space-sm);
    padding: var(--mdst-space-md);
    border-top: var(--mdst-border-width) solid var(--mdst-color-border);
  }

  /* Variants */

  :where(.mdst-ui) dialog.mdst-dialog--sm,
  .mdst-dialog.mdst-dialog--sm {
    max-width: min(90vw, 24rem);
  }

  :where(.mdst-ui) dialog.mdst-dialog--lg,
  .mdst-dialog.mdst-dialog--lg {
    max-width: min(90vw, 48rem);
  }

  :where(.mdst-ui) dialog.mdst-dialog--full,
  .mdst-dialog.mdst-dialog--full {
    max-width: 90vw;
  }
}

@layer mdst-ui.components {
  /* Drawer */

  .mdst-drawer {
    position: fixed;
    top: 0;
    inset-inline-end: 0;
    bottom: 0;
    inset-inline-start: auto;
    width: 20rem;
    max-width: 100vw;
    max-height: none;
    height: 100%;
    margin: 0;
    padding: 0;
    border: none;
    border-inline-start: var(--mdst-border-width) solid var(--mdst-color-border);
    border-radius: 0;
    background: var(--mdst-color-bg);
    color: var(--mdst-color-fg);
    overflow: hidden;
    flex-direction: column;

    /* Slides in from the end edge; --_dir flips the direction in RTL */
    --_dir: 1;

    &:dir(rtl) {
      --_dir: -1;
    }

    /* Closed state (exit animation target) */
    transform: translateX(calc(100% * var(--_dir)));
    transition:
      transform var(--mdst-transition-slow),
      opacity var(--mdst-transition-slow),
      overlay var(--mdst-transition-slow) allow-discrete,
      display var(--mdst-transition-slow) allow-discrete;

    &[open] {
      display: flex;
      transform: translateX(0);

      @starting-style {
        transform: translateX(calc(100% * var(--_dir)));
      }
    }
  }

  /* Backdrop */

  .mdst-drawer::backdrop {
    background: var(--mdst-backdrop);
    opacity: 0;
    transition:
      opacity var(--mdst-transition-slow),
      overlay var(--mdst-transition-slow) allow-discrete,
      display var(--mdst-transition-slow) allow-discrete;
  }

  .mdst-drawer[open]::backdrop {
    opacity: 1;

    @starting-style {
      opacity: 0;
    }
  }

  /* Position: start (the left edge in left-to-right pages) */

  .mdst-drawer.mdst-drawer--start {
    inset-inline-end: auto;
    inset-inline-start: 0;
    border-inline-start: none;
    border-inline-end: var(--mdst-border-width) solid var(--mdst-color-border);
    transform: translateX(calc(-100% * var(--_dir)));

    &[open] {
      transform: translateX(0);

      @starting-style {
        transform: translateX(calc(-100% * var(--_dir)));
      }
    }
  }

  /* Sizes */

  .mdst-drawer.mdst-drawer--sm {
    width: 16rem;
  }

  .mdst-drawer.mdst-drawer--lg {
    width: 28rem;
  }

  .mdst-drawer.mdst-drawer--full {
    width: 100%;
    border-inline-start: none;
    border-inline-end: none;
  }

  /* Header */

  .mdst-drawer .mdst-drawer__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--mdst-space-md);
    padding: var(--mdst-space-md);
    border-bottom: var(--mdst-border-width) solid var(--mdst-color-border);
    flex-shrink: 0;
  }

  /* Body */

  .mdst-drawer .mdst-drawer__body {
    padding: var(--mdst-space-md);
    overflow-y: auto;
    flex: 1;
  }

  /* Footer */

  .mdst-drawer .mdst-drawer__footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: var(--mdst-space-sm);
    padding: var(--mdst-space-md);
    border-top: var(--mdst-border-width) solid var(--mdst-color-border);
    flex-shrink: 0;
  }

  /* Close button */

  .mdst-drawer .mdst-drawer__close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    /* Square around an icon, so the focus ring is a neat square; a word
       instead of an icon widens it rather than spilling out */
    height: 2em;
    min-width: 2em;
    padding: 0 0.125em;
    line-height: 1;
    white-space: nowrap;
    flex-shrink: 0;
    background: transparent;
    border: none;
    box-shadow: none;
    border-radius: var(--mdst-radius);
    cursor: pointer;
    color: var(--mdst-color-muted);
    transition: color var(--mdst-transition);

    &:hover {
      color: var(--mdst-color-fg);
    }

  }
}

@layer mdst-ui.components {
  /* Dropdown (Native Select) */

  :where(.mdst-ui) select,
  .mdst-dropdown {
    -webkit-appearance: none;
    appearance: none;
    display: block;
    width: 100%;
    padding: var(--mdst-space-sm);
    padding-inline-end: calc(var(--mdst-space-sm) + 1.2em);
    font-family: var(--mdst-font-ui);
    font-size: inherit;
    line-height: var(--mdst-line-height);
    color: var(--mdst-color-fg);
    background-color: var(--mdst-color-bg);
    /* A single symmetrical down-pointing triangle, so it reads the same at
       either edge */
    background-image: conic-gradient(from -45deg at 50% 100%, var(--mdst-color-fg) 90deg, transparent 0);
    background-size: 0.6rem 0.3rem;
    background-position: var(--_side) var(--mdst-space-sm) center;
    background-repeat: no-repeat;

    /* The arrow sits at the end edge; flip it in RTL */
    --_side: right;

    &:dir(rtl) {
      --_side: left;
    }
    border: var(--mdst-border-width) solid var(--mdst-color-border);
    border-radius: var(--mdst-radius);
    cursor: pointer;
    transition: border-color var(--mdst-transition);
  }

  /* Option group labels: bold like the browser's, without its italic */

  :where(.mdst-ui) optgroup {
    font-style: normal;
  }

  :where(.mdst-ui) select:where(:is([aria-invalid="true"], :user-invalid)),
  .mdst-dropdown:is([aria-invalid="true"], :user-invalid) {
    border-color: var(--mdst-color-danger);
  }

  :where(.mdst-ui) select:where(:focus),
  .mdst-dropdown:focus {
    border-color: var(--mdst-color-focus);
  }

  :where(.mdst-ui) select:where(:focus-visible),
  .mdst-dropdown:focus-visible {
    outline-offset: 0;
  }

  :where(.mdst-ui) select:where(:disabled),
  .mdst-dropdown:disabled {
    opacity: var(--mdst-disabled-opacity);
    cursor: not-allowed;
  }

  /* Variants */

  :where(.mdst-ui) select.mdst-dropdown--borderless,
  .mdst-dropdown.mdst-dropdown--borderless {
    border-color: transparent;
    background-color: transparent;
  }

  :where(.mdst-ui) select.mdst-dropdown--borderless:where(:hover),
  .mdst-dropdown.mdst-dropdown--borderless:hover {
    border-color: var(--mdst-color-border);
  }

  :where(.mdst-ui) select.mdst-dropdown--borderless:where(:focus),
  .mdst-dropdown.mdst-dropdown--borderless:focus {
    border-color: var(--mdst-color-focus);
  }

  /* Sizes */

  :where(.mdst-ui) select.mdst-dropdown--sm,
  .mdst-dropdown.mdst-dropdown--sm {
    padding: var(--mdst-space-xs) var(--mdst-space-sm);
    padding-inline-end: calc(var(--mdst-space-sm) + 1.5em);
    font-size: var(--mdst-text-sm);
    background-position: var(--_side) var(--mdst-space-sm) center;
  }

  :where(.mdst-ui) select.mdst-dropdown--lg,
  .mdst-dropdown.mdst-dropdown--lg {
    padding: var(--mdst-space-md) var(--mdst-space-md);
    padding-inline-end: calc(var(--mdst-space-md) + 1.2em);
    background-position: var(--_side) var(--mdst-space-md) center;
  }

  /* Inline variant (auto-width) */

  :where(.mdst-ui) select.mdst-dropdown--inline,
  .mdst-dropdown.mdst-dropdown--inline {
    display: inline-block;
    width: auto;
  }

  /* Windows High Contrast (forced colours) removes fills, so the parts that
     show state are redrawn in the user's system colours. */
  @media (forced-colors: active) {
    :where(.mdst-ui) select,
    .mdst-dropdown {
      forced-color-adjust: none;
      color: CanvasText;
      background-color: Canvas;
      background-image: conic-gradient(from -45deg at 50% 100%, CanvasText 90deg, transparent 0);
      border-color: CanvasText;
    }
  }

  /* Multi-selects and list boxes show as an open list, so they get no
     dropdown arrow. Last in the file so it also wins in forced colours. */
  :where(.mdst-ui) select:where([multiple], [size]:not([size="1"])),
  .mdst-dropdown:is([multiple], [size]:not([size="1"])) {
    background-image: none;
    padding-inline-end: var(--mdst-space-sm);
  }
}

@layer mdst-ui.components {
  /* File Input
     Classless (a bare input[type="file"] inside .mdst-ui) and class-based
     (.mdst-input on the input) share every rule, so both look the same. */

  :where(.mdst-ui) input:where([type="file"]),
  .mdst-input:where([type="file"]) {
    display: block;
    width: 100%;
    color: var(--mdst-color-muted);
    cursor: pointer;
    padding: var(--mdst-space-sm);
    font-family: var(--mdst-font-ui);
    font-size: inherit;
    line-height: var(--mdst-line-height);
    background-color: var(--mdst-color-bg);
    border: var(--mdst-border-width) solid var(--mdst-color-border);
    border-radius: var(--mdst-radius);
    transition: border-color var(--mdst-transition);
  }

  :where(.mdst-ui) input:where([type="file"]:focus),
  .mdst-input:where([type="file"]:focus) {
    border-color: var(--mdst-color-focus);
  }

  :where(.mdst-ui) input:where([type="file"]:focus-visible),
  .mdst-input:where([type="file"]:focus-visible) {
    outline-offset: 0;
  }

  :where(.mdst-ui) input:where([type="file"]:disabled),
  .mdst-input:where([type="file"]:disabled) {
    opacity: var(--mdst-disabled-opacity);
    cursor: not-allowed;
  }

  /* The "Choose file" button follows the button component: same hover ring
     and the same variables */

  :where(.mdst-ui) input:where([type="file"])::file-selector-button,
  .mdst-input:where([type="file"])::file-selector-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--mdst-space-xs);
    padding: var(--mdst-space-xs) var(--mdst-space-md);
    margin-inline-end: var(--mdst-space-md);
    font-family: var(--mdst-font-ui);
    font-size: inherit;
    line-height: var(--mdst-line-height);
    color: var(--_fg, var(--mdst-color-fg));
    background: var(--_bg, var(--mdst-color-bg));
    box-shadow: var(--_hover, none);
    border: var(--mdst-border-width) solid var(--mdst-color-border);
    border-radius: var(--mdst-radius);
    cursor: pointer;
    transition:
      background var(--mdst-transition),
      color var(--mdst-transition),
      border-color var(--mdst-transition),
      box-shadow var(--mdst-transition);
  }

  :where(.mdst-ui) input:where([type="file"]:hover)::file-selector-button,
  .mdst-input:where([type="file"]:hover)::file-selector-button {
    --_hover: var(--mdst-button-hover-shadow, inset 0 0 0 var(--mdst-border-width) currentColor);
  }

  :where(.mdst-ui) input:where([type="file"]:disabled)::file-selector-button,
  .mdst-input:where([type="file"]:disabled)::file-selector-button {
    --_hover: none;
    cursor: not-allowed;
  }

  /* Variants: on the input, with or without .mdst-input */

  .mdst-input--solid:where([type="file"])::file-selector-button {
    --_bg: var(--mdst-color-fg);
    --_fg: var(--mdst-color-bg);
    border-color: var(--mdst-color-fg);
  }

  .mdst-input--borderless:where([type="file"]),
  .mdst-input--borderless:where([type="file"]):focus {
    border-color: transparent;
  }

  .mdst-input--borderless:where([type="file"]) {
    padding: 0;
  }
}

@layer mdst-ui.components {
  /* Form

     A light structure layer so plain forms read well: fields stack with a
     small gap under their label and the flow gap between fields, and
     fieldsets get a border and a legend.

     Everything here has zero specificity, so any rule you write wins. Spacing
     follows --mdst-flow-space (between fields) and --mdst-space-xs (label to
     field). */

  /* Fieldset */

  :where(.mdst-ui) fieldset,
  .mdst-fieldset {
    min-inline-size: 0;
    padding: var(--mdst-space-md);
    border: var(--mdst-border-width) solid var(--mdst-color-border);
    border-radius: var(--mdst-radius);
  }

  /* The content starts below the legend, not below the border line through
     it, so the legend already adds space at the top. A smaller top padding
     keeps the legend close to its content without the top looking heavy. */

  :where(.mdst-ui) fieldset:where(:has(> legend)),
  .mdst-fieldset:has(> legend) {
    padding-block-start: var(--mdst-space-sm);
  }

  :where(.mdst-ui) legend,
  .mdst-legend {
    padding-inline: var(--mdst-space-xs);
    font-weight: 600;
  }

  /* Stacking: fields get the flow gap from typography's flow rule. Here,
     labels sit on their own line with a small gap to the field below, and a
     <small> hint or error sits close to its field. These use a single element
     in the selector so they beat the zero-specificity flow gap, while any
     class you write still wins. */

  :where(.mdst-ui :is(form, fieldset):not([class]), .mdst-form, .mdst-fieldset) > label:where(:not(:has(input, select, textarea))) {
    display: block;
  }

  :where(.mdst-ui :is(form, fieldset):not([class]), .mdst-form, .mdst-fieldset) > label:where(:not(:has(input, select, textarea))) + * {
    margin-block-start: var(--mdst-space-xs);
  }

  :where(.mdst-ui :is(form, fieldset):not([class]), .mdst-form, .mdst-fieldset) > :where(input, select, textarea) + small {
    display: block;
    margin-block-start: var(--mdst-space-xs);
  }

  /* Output: a calculated value, in figures of equal width so it doesn't
     shift about as it changes */

  :where(.mdst-ui) output {
    font-variant-numeric: tabular-nums;
  }

  /* Error text: when the field is invalid (aria-invalid="true", or the
     browser's own validation once the user has interacted), the <small>
     after it takes the error colour, matching the field's border. */

  :where(.mdst-ui :is(form, fieldset):not([class]), .mdst-form, .mdst-fieldset) > :where(input, select, textarea):where([aria-invalid="true"], :user-invalid) + small {
    color: var(--mdst-color-danger);
  }
}

@layer mdst-ui.components {
  /* Input
     Text-like fields: text, email, number, search, tel, url, password, and
     textarea. .mdst-input also styles checkbox, radio, range, file, and colour
     inputs by their type; those rules live in their own components, and the
     selectors here skip them. */

  :where(.mdst-ui)
    input:where(:not(
      [type="checkbox"],
      [type="radio"],
      [type="range"],
      [type="file"],
      [type="color"],
      [type="submit"],
      [type="reset"],
      [type="button"],
      [type="image"],
      [type="hidden"]
    )),
  :where(.mdst-ui) textarea,
  .mdst-input:where(:not([type="checkbox"], [type="radio"], [type="range"], [type="file"], [type="color"])) {
    -webkit-appearance: none;
    appearance: none;
    display: block;
    width: 100%;
    padding: var(--mdst-space-sm);
    font-family: var(--mdst-font-ui);
    font-size: inherit;
    line-height: var(--mdst-line-height);
    color: var(--mdst-color-fg);
    background-color: var(--mdst-color-bg);
    border: var(--mdst-border-width) solid var(--mdst-color-border);
    border-radius: var(--mdst-radius);
    transition: border-color var(--mdst-transition);
  }

  :where(.mdst-ui)
    input:where(:not(
      [type="checkbox"],
      [type="radio"],
      [type="range"],
      [type="file"],
      [type="color"],
      [type="submit"],
      [type="reset"],
      [type="button"],
      [type="image"],
      [type="hidden"]
    ))::placeholder,
  :where(.mdst-ui) textarea::placeholder,
  .mdst-input:where(:not([type="checkbox"], [type="radio"], [type="range"], [type="file"], [type="color"]))::placeholder {
    color: var(--mdst-color-muted);
    opacity: 1;
  }

  /* Search: the browser's own clear button, drawn as a plain X in the text
     colour, not each browser's own (blue in some, grey in others), and shown
     whenever there's text to clear, not only on hover. Browsers without one,
     such as Firefox, show nothing. */

  :where(.mdst-ui) input:where([type="search"])::-webkit-search-cancel-button,
  .mdst-input:where([type="search"])::-webkit-search-cancel-button {
    -webkit-appearance: none;
    appearance: none;
    width: 0.875em;
    height: 0.875em;
    margin-inline-start: var(--mdst-space-sm);
    cursor: pointer;
    background-color: currentColor;
    -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='3'%3E%3Cpath d='M5 5l14 14M19 5 5 19'/%3E%3C/svg%3E");
    mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='3'%3E%3Cpath d='M5 5l14 14M19 5 5 19'/%3E%3C/svg%3E");
    -webkit-mask-repeat: no-repeat;
    mask-repeat: no-repeat;
    -webkit-mask-position: center;
    mask-position: center;
  }

  /* Chrome hides it unless hovered or focused; it still goes when the field is
     empty, read-only, or disabled */
  :where(.mdst-ui) input:where([type="search"]:enabled:read-write)::-webkit-search-cancel-button,
  .mdst-input:where([type="search"]:enabled:read-write)::-webkit-search-cancel-button {
    opacity: 1;
    pointer-events: auto;
  }

  @media (forced-colors: active) {
    :where(.mdst-ui) input:where([type="search"])::-webkit-search-cancel-button,
    .mdst-input:where([type="search"])::-webkit-search-cancel-button {
      forced-color-adjust: none;
      background-color: CanvasText;
    }
  }

  /* Borderless: the field keeps its padding, so it lines up with bordered
     fields, but draws no border. Declared before invalid, so errors still
     show. */

  .mdst-input--borderless:where(:not([type="checkbox"], [type="radio"], [type="range"], [type="file"], [type="color"])) {
    border-color: transparent;
  }

  /* Invalid: aria-invalid="true", or the browser's own validation once the
     user has interacted (:user-invalid). Declared before focus, so a focused
     field still shows the focus colour. */

  :where(.mdst-ui) :is(input, textarea):is([aria-invalid="true"], :user-invalid),
  .mdst-input:is([aria-invalid="true"], :user-invalid) {
    border-color: var(--mdst-color-danger);
  }

  :where(.mdst-ui)
    input:where(:not(
      [type="checkbox"],
      [type="radio"],
      [type="range"],
      [type="file"],
      [type="color"],
      [type="submit"],
      [type="reset"],
      [type="button"],
      [type="image"],
      [type="hidden"]
    ):focus),
  :where(.mdst-ui) textarea:where(:focus),
  .mdst-input:where(:not([type="checkbox"], [type="radio"], [type="range"], [type="file"], [type="color"])):focus {
    border-color: var(--mdst-color-focus);
  }

  .mdst-input--borderless:where(:not([type="checkbox"], [type="radio"], [type="range"], [type="file"], [type="color"])):focus {
    border-color: transparent;
  }

  :where(.mdst-ui)
    input:where(:not(
      [type="checkbox"],
      [type="radio"],
      [type="range"],
      [type="file"],
      [type="color"],
      [type="submit"],
      [type="reset"],
      [type="button"],
      [type="image"],
      [type="hidden"]
    ):focus-visible),
  :where(.mdst-ui) textarea:where(:focus-visible),
  .mdst-input:where(:not([type="checkbox"], [type="radio"], [type="range"], [type="file"], [type="color"])):focus-visible {
    outline-offset: 0;
  }

  :where(.mdst-ui)
    input:where(:not(
      [type="checkbox"],
      [type="radio"],
      [type="range"],
      [type="file"],
      [type="color"],
      [type="submit"],
      [type="reset"],
      [type="button"],
      [type="image"],
      [type="hidden"]
    ):disabled),
  :where(.mdst-ui) textarea:where(:disabled),
  .mdst-input:where(:not([type="checkbox"], [type="radio"], [type="range"], [type="file"], [type="color"])):disabled {
    opacity: var(--mdst-disabled-opacity);
    cursor: not-allowed;
  }

  /* Textarea variant */

  :where(.mdst-ui) textarea,
  .mdst-input:is(textarea) {
    min-height: 6rem;
    resize: vertical;
  }
}

@layer mdst-ui.components {
  /* Meter */

  /* The browser picks the fill colour from low / high / optimum:
     optimum → foreground, sub-optimum → warning, least optimum → error.
     A meter without those attributes always reads as optimum. */

  :where(.mdst-ui) meter,
  .mdst-meter {
    appearance: none;
    -webkit-appearance: none;
    display: block;
    width: 100%;
    height: var(--mdst-meter-height, var(--mdst-space-sm));
    border: none;
    border-radius: var(--mdst-radius);
    overflow: hidden;
    background: var(--mdst-color-subtle);

    /* Webkit (Chrome, Safari, Edge) - track */

    /* WebKit won't resolve percentage heights inside a meter, so the bar and
       fill take the same explicit length as the meter itself */

    &::-webkit-meter-bar {
      box-sizing: border-box;
      height: var(--mdst-meter-height, var(--mdst-space-sm));
      padding: 0;
      border: none;
      border-radius: var(--mdst-radius);
      background: var(--mdst-color-subtle);
    }

    /* Webkit - fills */

    &::-webkit-meter-optimum-value,
    &::-webkit-meter-suboptimum-value,
    &::-webkit-meter-even-less-good-value {
      height: var(--mdst-meter-height, var(--mdst-space-sm));
      border-radius: var(--mdst-radius);
      transition: width var(--mdst-transition);
    }

    &::-webkit-meter-optimum-value {
      background: var(--mdst-color-fg);
    }

    &::-webkit-meter-suboptimum-value {
      background: var(--mdst-color-warning);
    }

    &::-webkit-meter-even-less-good-value {
      background: var(--mdst-color-danger);
    }

    /* Firefox - fills */

    &::-moz-meter-bar {
      border-radius: var(--mdst-radius);
      background: var(--mdst-color-fg);
    }

    &:-moz-meter-sub-optimum::-moz-meter-bar {
      background: var(--mdst-color-warning);
    }

    &:-moz-meter-sub-sub-optimum::-moz-meter-bar {
      background: var(--mdst-color-danger);
    }

    /* Size: Small */

    &.mdst-meter--sm {
      --mdst-meter-height: var(--mdst-space-xs);
    }

    /* Size: Large */

    &.mdst-meter--lg {
      --mdst-meter-height: var(--mdst-space-md);
    }
  }

  /* Windows High Contrast (forced colours) removes fills, so the parts that
     show state are redrawn in the user's system colours. */
  @media (forced-colors: active) {
    :where(.mdst-ui) meter,
    .mdst-meter,
    .mdst-meter[class*="--"] {
      forced-color-adjust: none;
      background: Canvas;
      outline: 1px solid CanvasText;

      &::-webkit-meter-bar {
        background: Canvas;
      }

      &::-webkit-meter-optimum-value,
      &::-webkit-meter-suboptimum-value,
      &::-webkit-meter-even-less-good-value {
        background: Highlight;
      }

      /* Separate rule: a browser drops a whole selector list if one
         vendor pseudo-element in it is unknown */
      &::-moz-meter-bar {
        background: Highlight;
      }
    }
  }
}

@layer mdst-ui.components {
  /*
   * OTP Input
   *
   * Usage:
   * <div class="mdst-otp-input">
   *   <input type="text" maxlength="1" inputmode="numeric">
   *   <input type="text" maxlength="1" inputmode="numeric">
   *   <input type="text" maxlength="1" inputmode="numeric">
   *   <input type="text" maxlength="1" inputmode="numeric">
   * </div>
   *
   * With separator:
   * <div class="mdst-otp-input">
   *   <input type="text" maxlength="1" inputmode="numeric">
   *   <input type="text" maxlength="1" inputmode="numeric">
   *   <span class="mdst-otp-input__separator"></span>
   *   <input type="text" maxlength="1" inputmode="numeric">
   *   <input type="text" maxlength="1" inputmode="numeric">
   * </div>
   */

  .mdst-otp-input {
    display: inline-flex;
    gap: var(--mdst-space-sm);
    align-items: center;

    /* Tone (.mdst-danger and friends, or your own --mdst-tone) colours every
       box's border. --mdst-tone doesn't inherit, so it's copied into --_tone
       for the inputs. */
    --_tone: var(--mdst-tone);

    & > input {
      width: 1.5em;
      height: 2em;
      padding: 0;
      border: var(--mdst-border-width) solid var(--_tone, var(--mdst-color-border));
      border-radius: var(--mdst-radius);
      background: var(--mdst-color-bg);
      color: var(--mdst-color-fg);
      font-family: var(--mdst-font-mono);
      font-size: 1.25em;
      text-align: center;
      caret-color: var(--mdst-color-fg);
      transition: border-color var(--mdst-transition);

      &:focus {
        border-color: var(--_tone, var(--mdst-color-focus));
      }

      &:focus-visible {
        outline-offset: 0;
      }

      &::placeholder {
        color: var(--mdst-color-muted);
      }

      &:disabled {
        opacity: var(--mdst-disabled-opacity);
        cursor: not-allowed;
      }

      /* Filled state: a digit with a placeholder that's no longer showing.
         Needs a placeholder (e.g. placeholder="0"); without one the browser
         can't tell empty from filled. */
      &[placeholder]:not(:placeholder-shown) {
        border-color: var(--_tone, var(--mdst-color-fg));
      }
    }

    /* Separator (e.g., dash between groups) */

    & .mdst-otp-input__separator {
      width: 0.5em;
      height: 0.0625em;
      background: var(--mdst-color-border);
    }
  }

  /* Deprecated: remove in 3.0. Use .mdst-danger or .mdst-success. */

  .mdst-otp-input--danger {
    --mdst-tone: var(--mdst-color-danger);
  }

  .mdst-otp-input--success {
    --mdst-tone: var(--mdst-color-success);
  }
}

@layer mdst-ui.components {
  /* Password Input
     A wrapper around the field (a .mdst-input, or a bare input inside
     .mdst-ui) and a checkbox that draws the eye toggle. The field is picked
     out as "not the checkbox", so it keeps its padding after your JS switches
     it to type="text". */

  .mdst-password-input {
    display: flex;
    position: relative;
    width: 100%;
    cursor: text;

    & > input:not([type="checkbox"]) {
      padding-inline-end: calc(var(--mdst-space-md) + 1.5em + var(--mdst-space-sm));
    }

    /* Toggle — the checkbox itself, styled as the eye icon */

    & > input[type="checkbox"] {
      /* It's a checkbox underneath, so drop the classless checkbox tick */
      &::after {
        content: none;
      }

      -webkit-appearance: none;
      appearance: none;
      position: absolute;
      inset-inline-end: var(--mdst-space-sm);
      top: 50%;
      transform: translateY(-50%);
      display: inline-flex;
      align-items: center;
      justify-content: center;
      width: 1.5em;
      height: 1.5em;
      margin: 0;
      padding: 0;
      background: none;
      border: none;
      color: var(--mdst-color-muted);
      cursor: pointer;
      transition: color var(--mdst-transition);

      &:hover {
        color: var(--mdst-color-fg);
      }

      /* Toggle icon — eye-off by default (password is hidden) */

      &::before {
        content: "";
        display: block;
        width: 1em;
        height: 1em;
        background-color: currentColor;
        -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49'/%3E%3Cpath d='M14.084 14.158a3 3 0 0 1-4.242-4.242'/%3E%3Cpath d='M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143'/%3E%3Cpath d='m2 2 20 20'/%3E%3C/svg%3E");
        mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49'/%3E%3Cpath d='M14.084 14.158a3 3 0 0 1-4.242-4.242'/%3E%3Cpath d='M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143'/%3E%3Cpath d='m2 2 20 20'/%3E%3C/svg%3E");
        -webkit-mask-repeat: no-repeat;
        mask-repeat: no-repeat;
        -webkit-mask-position: center;
        mask-position: center;
        -webkit-mask-size: contain;
        mask-size: contain;
      }

      /* Checked state: swap to the eye icon. Showing the text needs your JS
         to switch the field to type="text" (see the docs for an example). */

      &:checked::before {
        -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0'/%3E%3Ccircle cx='12' cy='12' r='3'/%3E%3C/svg%3E");
        mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0'/%3E%3Ccircle cx='12' cy='12' r='3'/%3E%3C/svg%3E");
      }
    }

    /* The toggle follows the field: disabled with it */

    &:has(> input:not([type="checkbox"]):disabled) > input[type="checkbox"] {
      opacity: var(--mdst-disabled-opacity);
      cursor: not-allowed;
      pointer-events: none;
    }
  }

  /* Windows High Contrast (forced colours) removes fills, so the parts that
     show state are redrawn in the user's system colours. */
  @media (forced-colors: active) {
    .mdst-password-input > input[type="checkbox"]::before {
      forced-color-adjust: none;
      background-color: CanvasText;
    }
  }
}

@layer mdst-ui.components {
  /* Popover
     Classless: any [popover] inside .mdst-ui gets the panel look, at zero
     specificity, so components built on popover (tooltip) and your own
     classes replace it. Class-based: .mdst-popover anywhere. */

  :where(.mdst-ui) :where([popover]),
  .mdst-popover {
    padding: var(--mdst-space-md);
    border: var(--mdst-border-width) solid var(--mdst-color-border);
    border-radius: var(--mdst-radius);
    background: var(--mdst-color-bg);
    color: var(--mdst-color-fg);
    box-shadow: var(--mdst-shadow-sm);

    /* Default: centered on page */
    margin: auto;
    position: fixed;
    inset: 0;
    width: fit-content;
    height: fit-content;
  }

  /* Anchored positioning - use with anchor="" HTML attribute.
     Guarded so browsers without CSS anchor positioning (Baseline Chrome 129 /
     Firefox 147 / Safari 26) keep the centered default above instead of
     mispositioning. */

  @supports (position-area: bottom) {
    :where(.mdst-ui) [popover].mdst-popover--anchored,
    .mdst-popover.mdst-popover--anchored {
      position: absolute;
      inset: unset;
      margin: 0;
      position-area: bottom;
      margin-top: var(--mdst-space-xs);
    }
  }

  /* Variants */

  :where(.mdst-ui) [popover].mdst-popover--sm,
  .mdst-popover.mdst-popover--sm {
    padding: var(--mdst-space-sm);
    font-size: var(--mdst-text-sm);
  }

  :where(.mdst-ui) [popover].mdst-popover--lg,
  .mdst-popover.mdst-popover--lg {
    padding: var(--mdst-space-lg);
    max-width: 24rem;
  }
}

@layer mdst-ui.components {
  /* Pre — block code/JSON display */

  :where(.mdst-ui) pre,
  .mdst-pre {
    display: block;
    padding: var(--mdst-space-md);
    overflow-x: hidden;
    overflow-y: auto;
    overflow-wrap: break-word;
    white-space: pre-wrap;
    font-family: var(--mdst-font-mono);
    font-size: var(--mdst-text-sm);
    line-height: var(--mdst-line-height);
    color: var(--mdst-color-fg);
    background-color: var(--mdst-color-subtle);
    border: var(--mdst-border-width) solid var(--mdst-color-border);
    border-radius: var(--mdst-radius);
    tab-size: 2;
  }

  /* Nested code inside pre — reset styles */

  :where(.mdst-ui) pre code,
  :where(.mdst-ui) pre .mdst-code,
  .mdst-pre code,
  .mdst-pre .mdst-code {
    padding: 0;
    background: transparent;
    border: none;
    border-radius: 0;
    font-size: inherit;
    word-break: break-word;
  }

  /* Variants */

  :where(.mdst-ui) pre.mdst-pre--borderless,
  .mdst-pre.mdst-pre--borderless {
    border: none;
  }

  :where(.mdst-ui) pre.mdst-pre--sm,
  .mdst-pre.mdst-pre--sm {
    padding: var(--mdst-space-sm);
  }

  /* Allow horizontal scroll if explicitly needed */

  :where(.mdst-ui) pre.mdst-pre--scroll,
  .mdst-pre.mdst-pre--scroll {
    overflow-x: auto;
    overflow-wrap: normal;
    word-wrap: normal;
    word-break: normal;
    white-space: pre;
  }
}

@layer mdst-ui.components {
  /* Progress Bar */

  :where(.mdst-ui) progress,
  .mdst-progress {
    appearance: none;
    -webkit-appearance: none;
    display: block;
    width: 100%;
    height: var(--mdst-space-sm);
    border: none;
    border-radius: var(--mdst-radius);
    overflow: hidden;
    background: var(--mdst-color-subtle);
    /* Tone (.mdst-danger and friends, or your own --mdst-tone) colours the
       fill. --mdst-tone doesn't inherit, so it's copied into --_tone for the
       fill pseudo-elements. */
    --_tone: var(--mdst-tone);
    color: var(--_tone, var(--mdst-color-fg));

    /* Webkit (Chrome, Safari, Edge) - bar background */

    &::-webkit-progress-bar {
      background: var(--mdst-color-subtle);
      border-radius: var(--mdst-radius);
    }

    /* Webkit - value fill */

    &::-webkit-progress-value {
      background: var(--_tone, var(--mdst-color-fg));
      border-radius: var(--mdst-radius);
      transition: width var(--mdst-transition);
    }

    /* Firefox - value fill */

    &::-moz-progress-bar {
      background: var(--_tone, var(--mdst-color-fg));
      border-radius: var(--mdst-radius);
    }

    /* Size: Small */

    &.mdst-progress--sm {
      height: var(--mdst-space-xs);
    }

    /* Size: Large */

    &.mdst-progress--lg {
      height: var(--mdst-space-md);
    }
  }

  /* Deprecated: remove in 3.0. Use .mdst-danger or .mdst-success. */

  .mdst-progress--danger {
    --mdst-tone: var(--mdst-color-danger);
  }

  .mdst-progress--success {
    --mdst-tone: var(--mdst-color-success);
  }

  /* Windows High Contrast (forced colours) removes fills, so the parts that
     show state are redrawn in the user's system colours. */
  @media (forced-colors: active) {
    :where(.mdst-ui) progress,
    .mdst-progress,
    .mdst-progress[class*="--"] {
      forced-color-adjust: none;
      background: Canvas;
      outline: 1px solid CanvasText;

      &::-webkit-progress-bar {
        background: Canvas;
      }

      &::-webkit-progress-value {
        background: Highlight;
      }

      &::-moz-progress-bar {
        background: Highlight;
      }
    }
  }
}

@layer mdst-ui.components {
  /* Radio */

  :where(.mdst-ui) input:where([type="radio"]),
  .mdst-input:where([type="radio"]) {
    -webkit-appearance: none;
    appearance: none;
    flex-shrink: 0;
    width: calc(0.875rem + 2 * var(--mdst-border-width));
    height: calc(0.875rem + 2 * var(--mdst-border-width));
    background: var(--mdst-color-bg);
    border: var(--mdst-border-width) solid var(--mdst-color-border);
    /* Border included in the size, so a user's border-box reset changes nothing */
    box-sizing: border-box;
    /* --mdst-border-width is in em, so match the surrounding text */
    font-size: inherit;
    border-radius: 50%;
    cursor: pointer;
    position: relative;
  }

  :where(.mdst-ui) input:where([type="radio"]:checked)::after,
  .mdst-input:where([type="radio"]:checked)::after {
    content: "";
    position: absolute;
    inset: 3px;
    background: var(--mdst-color-fg);
    border-radius: 50%;
  }

  :where(.mdst-ui) input:where([type="radio"]:disabled),
  .mdst-input:where([type="radio"]:disabled) {
    opacity: var(--mdst-disabled-opacity);
    cursor: not-allowed;
  }

  /* A label wrapping a radio */

  :where(.mdst-ui) label:where(:has(> input[type="radio"])),
  label:where(:has(> .mdst-input[type="radio"])) {
    display: inline-flex;
    align-items: center;
    gap: var(--mdst-space-sm);
    font-size: inherit;
    line-height: var(--mdst-line-height);
    cursor: pointer;
    user-select: none;
  }

  :where(.mdst-ui) label:where(:has(> input[type="radio"]:disabled)),
  label:where(:has(> .mdst-input[type="radio"]:disabled)) {
    opacity: var(--mdst-disabled-opacity);
    cursor: not-allowed;
  }

  /* The label already fades, so the radio inside doesn't fade twice */
  :where(.mdst-ui) label:where(:has(> input[type="radio"]:disabled)) > input,
  label:where(:has(> .mdst-input[type="radio"]:disabled)) > .mdst-input {
    opacity: 1;
  }

  /* Radio group */

  .mdst-radio-group {
    display: flex;
    flex-direction: column;
    gap: var(--mdst-space-sm);

    &.mdst-radio-group--horizontal {
      flex-direction: row;
      gap: var(--mdst-space-md);
    }
  }

  /* Radio card — content-rich selectable cards */

  .mdst-radio-card {
    display: block;
    border: var(--mdst-border-width) solid var(--mdst-color-border);
    padding: var(--mdst-space-md);
    cursor: pointer;
    text-align: center;
    user-select: none;
    border-radius: var(--mdst-radius);
    overflow: hidden;

    /* Visually hide the native radio input while keeping it keyboard-accessible */
    & input[type="radio"] {
      position: absolute;
      opacity: 0;
      pointer-events: none;
    }

    &:hover {
      background: var(--mdst-color-subtle);
    }

    &:has(input[type="radio"]:checked) {
      border-color: var(--mdst-color-fg);
      outline: calc(var(--mdst-border-width) * 2) solid var(--mdst-color-fg);
      outline-offset: calc(-1 * var(--mdst-border-width));
    }

    &:has(input[type="radio"]:focus-visible) {
      outline: var(--mdst-focus-ring, 2px solid var(--mdst-color-focus));
      outline-offset: var(--mdst-focus-offset);
    }

    &:has(input[type="radio"]:disabled) {
      opacity: var(--mdst-disabled-opacity);
      cursor: not-allowed;

      &:hover {
        background: transparent;
      }
    }
  }

  /* Radio card group — grid layout for cards */

  .mdst-radio-card-group {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--mdst-space-sm);
  }

  /* Windows High Contrast (forced colours) removes fills, so the parts that
     show state are redrawn in the user's system colours. */
  @media (forced-colors: active) {
    :where(.mdst-ui) input:where([type="radio"]:checked)::after,
    .mdst-input:where([type="radio"]:checked)::after {
      forced-color-adjust: none;
      background: CanvasText;
    }
  }
}

@layer mdst-ui.components {
  /* Range Slider */

  :where(.mdst-ui) input:where([type="range"]),
  .mdst-input:where([type="range"]) {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: var(--mdst-space-1);
    background: var(--mdst-color-fg);
    border-radius: var(--mdst-space-1);
    box-shadow: none;
    cursor: pointer;
  }

  :where(.mdst-ui) input:where([type="range"]:disabled),
  .mdst-input:where([type="range"]:disabled) {
    opacity: var(--mdst-disabled-opacity);
    cursor: not-allowed;
  }

  :where(.mdst-ui) input:where([type="range"]:disabled)::-webkit-slider-thumb,
  .mdst-input:where([type="range"]:disabled)::-webkit-slider-thumb {
    cursor: not-allowed;
  }

  :where(.mdst-ui) input:where([type="range"]:disabled)::-moz-range-thumb,
  .mdst-input:where([type="range"]:disabled)::-moz-range-thumb {
    cursor: not-allowed;
  }

  /* Webkit (Chrome, Safari, Edge) */

  :where(.mdst-ui) input:where([type="range"])::-webkit-slider-thumb,
  .mdst-input:where([type="range"])::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: var(--mdst-space-4);
    height: var(--mdst-space-4);
    box-sizing: border-box;
    background: var(--mdst-color-bg);
    border: calc(var(--mdst-space-px) * 3) solid var(--mdst-color-fg);
    border-radius: 50%;
    box-shadow: none;
    cursor: pointer;
    transition: background var(--mdst-transition);
  }

  /* Firefox */

  :where(.mdst-ui) input:where([type="range"])::-moz-range-thumb,
  .mdst-input:where([type="range"])::-moz-range-thumb {
    appearance: none;
    width: var(--mdst-space-4);
    height: var(--mdst-space-4);
    box-sizing: border-box;
    background: var(--mdst-color-bg);
    border: calc(var(--mdst-space-px) * 3) solid var(--mdst-color-fg);
    border-radius: 50%;
    cursor: pointer;
    transition: background var(--mdst-transition);
  }

  :where(.mdst-ui) input:where([type="range"])::-moz-range-track,
  .mdst-input:where([type="range"])::-moz-range-track {
    background: transparent;
  }

  /* Windows High Contrast (forced colours) removes fills, so the parts that
     show state are redrawn in the user's system colours. */
  @media (forced-colors: active) {
    :where(.mdst-ui) input:where([type="range"]),
    .mdst-input:where([type="range"]) {
      forced-color-adjust: none;
      background: CanvasText;

      &::-webkit-slider-thumb {
        background: Canvas;
        border-color: CanvasText;
      }

      &::-moz-range-thumb {
        background: Canvas;
        border-color: CanvasText;
      }
    }
  }
}

@layer mdst-ui.components {
  /* Skeleton */

  @keyframes mdst-shimmer {
    0% {
      background-position: 200% 0;
    }
    100% {
      background-position: -200% 0;
    }
  }

  .mdst-skeleton {
    display: block;
    height: 1em;
    width: 100%;
    border-radius: var(--mdst-radius);
    background: linear-gradient(
      90deg,
      var(--mdst-color-subtle) 25%,
      color-mix(in srgb, var(--mdst-color-subtle) 50%, var(--mdst-color-bg) 50%) 50%,
      var(--mdst-color-subtle) 75%
    );
    background-size: 200% 100%;
    animation: mdst-shimmer 1.5s ease-in-out infinite;

    /* Text line placeholder */

    &.mdst-skeleton--text {
      height: 1em;
      width: 100%;
    }

    /* Heading placeholder */

    &.mdst-skeleton--heading {
      height: 1.5em;
    }

    /* Circle shape — set size via inline style or custom class */

    &.mdst-skeleton--circle {
      width: 1em;
      height: 1em;
      border-radius: 50%;
    }
  }

  /* Windows High Contrast (forced colours) removes fills, so the parts that
     show state are redrawn in the user's system colours. */
  @media (forced-colors: active) {
    /* CanvasText, not GrayText: themes only promise that text colour
       contrasts with the page, and GrayText can be close to it */
    .mdst-skeleton {
      outline: 1px solid CanvasText;
    }
  }
}

@layer mdst-ui.components {
  /* Spinner */

  @keyframes mdst-spin {
    to {
      transform: rotate(360deg);
    }
  }

  .mdst-spinner {
    display: inline-block;
    width: 1.25em;
    height: 1.25em;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: mdst-spin 0.6s linear infinite;
    vertical-align: middle;
    flex-shrink: 0;

    /* Sizes */

    &.mdst-spinner--sm {
      width: 0.875em;
      height: 0.875em;
      border-width: 1.5px;
    }

    &.mdst-spinner--lg {
      width: 2em;
      height: 2em;
      border-width: 3px;
    }
  }

  /* Windows High Contrast (forced colours) removes fills, so the parts that
     show state are redrawn in the user's system colours. */
  @media (forced-colors: active) {
    .mdst-spinner {
      forced-color-adjust: none;
      border-color: CanvasText;
      border-right-color: transparent;
    }
  }
}


@layer mdst-ui.components {
  /* Stepper / Wizard */

  .mdst-stepper {
    /* --_dir flips sideways nudges in RTL */
    --_dir: 1;

    &:dir(rtl) {
      --_dir: -1;
    }

    display: flex;
    align-items: flex-start;
    width: 100%;
    font-family: var(--mdst-font-ui);

    /* Step */

    & .mdst-stepper__step {
      display: flex;
      flex-direction: column;
      align-items: center;
      flex: 1;
      position: relative;
      text-align: center;

      /* Connector line between steps */

      &:not(:last-child)::after {
        content: "";
        position: absolute;
        top: 1rem;
        inset-inline-start: 50%;
        inset-inline-end: -50%;
        height: var(--mdst-border-width);
        background: var(--mdst-color-border);
      }
    }

    /* Indicator (circle) */

    & .mdst-stepper__indicator {
      width: 2rem;
      height: 2rem;
      border-radius: 50%;
      display: flex;
      align-items: center;
      justify-content: center;
      border: var(--mdst-border-width) solid var(--mdst-color-border);
      font-size: var(--mdst-text-sm);
      font-weight: 600;
      background: var(--mdst-color-bg);
      color: var(--mdst-color-fg);
      position: relative;
      z-index: 1;
      transition:
        background var(--mdst-transition),
        color var(--mdst-transition),
        border-color var(--mdst-transition);
    }

    /* Label */

    & .mdst-stepper__label {
      margin-top: var(--mdst-space-xs);
      font-size: var(--mdst-text-sm);
      color: var(--mdst-color-fg);
      padding: 0 var(--mdst-space-xs);
      transition: color var(--mdst-transition);
    }

    /* Vertical variant */

    &.mdst-stepper--vertical {
      flex-direction: column;
      align-items: flex-start;

      & .mdst-stepper__step {
        flex-direction: row;
        align-items: flex-start;
        flex: none;
        width: 100%;
        text-align: start;

        /* Vertical connector */

        &:not(:last-child)::after {
          top: 2rem;
          inset-inline-start: 1rem;
          inset-inline-end: auto;
          width: var(--mdst-border-width);
          height: calc(100% - 2rem + var(--mdst-space-md));
          transform: translateX(calc(-50% * var(--_dir, 1)));
        }

        &:not(:last-child) {
          padding-bottom: var(--mdst-space-md);
        }
      }

      & .mdst-stepper__label {
        margin-top: 0;
        margin-inline-start: var(--mdst-space-sm);
        padding: 0;
        line-height: 2rem;
      }
    }

    /* Compact variant */

    &.mdst-stepper--sm {
      & .mdst-stepper__indicator {
        width: 1.5rem;
        height: 1.5rem;
        font-size: var(--mdst-text-xs);
      }

      & .mdst-stepper__label {
        font-size: var(--mdst-text-xs);
      }

      & .mdst-stepper__step:not(:last-child)::after {
        top: 0.75rem;
        inset-inline-start: 50%;
        inset-inline-end: -50%;
      }

      /* Compact + vertical */

      &.mdst-stepper--vertical {
        & .mdst-stepper__step:not(:last-child)::after {
          top: 1.5rem;
          inset-inline-start: 0.75rem;
          height: calc(100% - 1.5rem + var(--mdst-space-sm));
        }

        & .mdst-stepper__label {
          line-height: 1.5rem;
        }

        & .mdst-stepper__step:not(:last-child) {
          padding-bottom: var(--mdst-space-sm);
        }
      }
    }

    /* States last, so they refine the base and variant rules above */

    /* Completed connector */

    & .mdst-stepper__step[data-state="completed"]:not(:last-child)::after {
      background: var(--mdst-color-fg);
    }

    /* States */

    & .mdst-stepper__step[data-state="completed"] {
      & .mdst-stepper__indicator {
        background: var(--mdst-color-fg);
        color: var(--mdst-color-bg);
        border-color: var(--mdst-color-fg);
      }

      & .mdst-stepper__label {
        color: var(--mdst-color-fg);
      }
    }

    & .mdst-stepper__step[data-state="active"] {
      & .mdst-stepper__indicator {
        border-color: var(--mdst-color-fg);
        font-weight: 700;
      }

      & .mdst-stepper__label {
        font-weight: 600;
        color: var(--mdst-color-fg);
      }
    }

    & .mdst-stepper__step[data-state="upcoming"] {
      & .mdst-stepper__indicator {
        border-color: var(--mdst-color-border);
        color: var(--mdst-color-muted);
      }

      & .mdst-stepper__label {
        color: var(--mdst-color-muted);
      }
    }

    & .mdst-stepper__step[data-state="error"] {
      & .mdst-stepper__indicator {
        border-color: var(--mdst-color-danger);
        color: var(--mdst-color-danger);
      }

      & .mdst-stepper__label {
        color: var(--mdst-color-danger);
      }
    }
  }

  /* Windows High Contrast (forced colours) removes fills, so the parts that
     show state are redrawn in the user's system colours. */
  @media (forced-colors: active) {
    .mdst-stepper .mdst-stepper__step:not(:last-child)::after {
      forced-color-adjust: none;
      background: CanvasText;
    }

    .mdst-stepper .mdst-stepper__step[data-state="completed"] .mdst-stepper__indicator {
      forced-color-adjust: none;
      background: Highlight;
      color: HighlightText;
      border-color: Highlight;
    }
  }
}

@layer mdst-ui.components {
  /* Table */

  .mdst-table-wrap {
    width: 100%;
    overflow-x: auto;
  }

  :where(.mdst-ui) table,
  .mdst-table {
    width: 100%;
    border-collapse: collapse;
    font-size: inherit;
  }

  :where(.mdst-ui) caption,
  .mdst-table caption {
    caption-side: top;
    padding-block-end: var(--mdst-space-sm);
    text-align: start;
    font-size: var(--mdst-text-sm);
    color: var(--mdst-color-muted);
  }

  :where(.mdst-ui) th,
  .mdst-table th {
    text-align: start;
    font-size: var(--mdst-text-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--mdst-color-muted);
    padding: var(--mdst-space-sm) var(--mdst-space-md) var(--mdst-space-sm) 0;
    border-bottom: var(--mdst-border-width) solid var(--mdst-color-border);
  }

  :where(.mdst-ui) th:where(:last-child),
  .mdst-table th:last-child {
    padding-inline-end: 0;
  }

  :where(.mdst-ui) td,
  .mdst-table td {
    padding: var(--mdst-space-md) var(--mdst-space-md) var(--mdst-space-md) 0;
    vertical-align: middle;
    border-bottom: var(--mdst-border-width) solid var(--mdst-color-subtle);
  }

  .mdst-table td > .mdst-pre {
    overflow-x: auto;
  }

  :where(.mdst-ui) td:where(:last-child),
  .mdst-table td:last-child {
    padding-inline-end: 0;
  }

  :where(.mdst-ui) tbody tr:where(:last-child) td,
  .mdst-table tbody tr:last-child td {
    border-bottom: none;
  }

  /* Footer: totals read as a summary, in bold under a rule. A th here is a
     row label ("Total"), so it drops the column-heading style. */

  :where(.mdst-ui) tfoot :where(th, td),
  .mdst-table tfoot :where(th, td) {
    padding-block: var(--mdst-space-md);
    font-size: inherit;
    font-weight: 600;
    text-transform: none;
    letter-spacing: normal;
    color: inherit;
    border-top: var(--mdst-border-width) solid var(--mdst-color-border);
    border-bottom: none;
  }

  /* Variants */

  :where(.mdst-ui) table.mdst-table--bordered,
  .mdst-table.mdst-table--bordered {
    border: var(--mdst-border-width) solid var(--mdst-color-border);
  }

  :where(.mdst-ui) table.mdst-table--bordered th,
  :where(.mdst-ui) table.mdst-table--bordered td,
  .mdst-table.mdst-table--bordered th,
  .mdst-table.mdst-table--bordered td {
    padding: var(--mdst-space-sm) var(--mdst-space-md);
    border: var(--mdst-border-width) solid var(--mdst-color-border);
  }

  :where(.mdst-ui) table.mdst-table--striped tbody tr:where(:nth-child(odd)),
  .mdst-table.mdst-table--striped tbody tr:nth-child(odd) {
    background: var(--mdst-color-subtle);
  }

  :where(.mdst-ui) table.mdst-table--sm th,
  .mdst-table.mdst-table--sm th {
    padding: var(--mdst-space-xs) var(--mdst-space-sm) var(--mdst-space-xs) 0;
  }

  :where(.mdst-ui) table.mdst-table--sm th:where(:last-child),
  .mdst-table.mdst-table--sm th:last-child {
    padding-inline-end: 0;
  }

  :where(.mdst-ui) table.mdst-table--sm td,
  .mdst-table.mdst-table--sm td {
    padding: var(--mdst-space-sm) var(--mdst-space-sm) var(--mdst-space-sm) 0;
  }

  :where(.mdst-ui) table.mdst-table--sm td:where(:last-child),
  .mdst-table.mdst-table--sm td:last-child {
    padding-inline-end: 0;
  }

  /* Striped rows have a visible edge, so inset the first and last cells */

  :where(.mdst-ui) table.mdst-table--striped :is(th, td):first-child,
  .mdst-table.mdst-table--striped :is(th, td):first-child {
    padding-inline-start: var(--mdst-space-sm);
  }

  :where(.mdst-ui) table.mdst-table--striped :where(:is(th, td):last-child),
  .mdst-table.mdst-table--striped :is(th, td):last-child {
    padding-inline-end: var(--mdst-space-sm);
  }

  /* Fixed/Equal column widths */

  :where(.mdst-ui) table.mdst-table--fixed,
  .mdst-table.mdst-table--fixed {
    table-layout: fixed;
  }

  /* Stack variant - stacks rows on mobile */

  @media (max-width: 480px) {
    :where(.mdst-ui) table.mdst-table--stack thead,
    .mdst-table.mdst-table--stack thead {
      display: none;
    }

    :where(.mdst-ui) table.mdst-table--stack tbody,
    :where(.mdst-ui) table.mdst-table--stack tr,
    :where(.mdst-ui) table.mdst-table--stack td,
    .mdst-table.mdst-table--stack tbody,
    .mdst-table.mdst-table--stack tr,
    .mdst-table.mdst-table--stack td {
      display: block;
      width: 100%;
    }

    :where(.mdst-ui) table.mdst-table--stack tr,
    .mdst-table.mdst-table--stack tr {
      padding: var(--mdst-space-md) 0;
      border-bottom: var(--mdst-border-width) solid var(--mdst-color-subtle);
    }

    :where(.mdst-ui) table.mdst-table--stack tbody tr:where(:last-child),
    .mdst-table.mdst-table--stack tbody tr:last-child {
      border-bottom: none;
    }

    :where(.mdst-ui) table.mdst-table--stack td,
    .mdst-table.mdst-table--stack td {
      padding: 0;
      border-bottom: none;
    }

    :where(.mdst-ui) table.mdst-table--stack td:where(:first-child),
    .mdst-table.mdst-table--stack td:first-child {
      margin-bottom: var(--mdst-space-sm);
    }
  }
}

@layer mdst-ui.components {
  /* Tabs */

  .mdst-tabs {
    display: flex;
    flex-direction: column;

    /* Tabs List */

    & .mdst-tabs__list {
      display: flex;
      overflow-x: auto;
      overflow-y: hidden;
      scrollbar-width: none;

      &::-webkit-scrollbar {
        display: none;
      }
      border-bottom: var(--mdst-border-width) solid var(--mdst-color-border);
      margin: 0;
      padding: 0;
      list-style: none;
    }

    /* Individual Tab */

    & .mdst-tabs__tab {
      display: block;
      padding: var(--mdst-space-sm) var(--mdst-space-md);
      white-space: nowrap;
      border: none;
      background: none;
      box-shadow: none;
      cursor: pointer;
      font-family: var(--mdst-font-ui);
      font-size: inherit;
      line-height: var(--mdst-line-height);
      color: var(--mdst-color-muted);
      border-bottom: 2px solid transparent;
      margin-bottom: calc(-1 * var(--mdst-border-width));
      transition:
        color var(--mdst-transition),
        border-color var(--mdst-transition),
        background-color var(--mdst-transition);

      &:hover {
        color: var(--mdst-color-fg);
      }

      /* Inside: the scrolling tab list would clip an outer ring */
      &:focus-visible {
        outline-offset: -2px;
      }

      &[data-state="active"] {
        color: var(--mdst-color-fg);
        font-weight: 600;
        border-bottom-color: var(--mdst-color-fg);
      }

      &[data-state="inactive"] {
        color: var(--mdst-color-muted);
        border-bottom-color: transparent;
      }

      &[data-disabled],
      &[data-disabled="true"] {
        opacity: var(--mdst-disabled-opacity);
        cursor: not-allowed;

        &:hover {
          color: var(--mdst-color-muted);
        }
      }
    }

    /* Tab Panel */

    & .mdst-tabs__panel {
      padding: var(--mdst-space-md) 0;

      &[data-state="inactive"] {
        display: none;
      }

      &[data-state="active"] {
        display: block;
      }
    }

    /* Variant: Pills */

    &.mdst-tabs--pills {
      & .mdst-tabs__list {
        border-bottom: none;
        gap: var(--mdst-space-xs);
      }

      & .mdst-tabs__tab {
        border-bottom: none;
        margin-bottom: 0;
        border-radius: var(--mdst-radius);
        padding: var(--mdst-space-xs) var(--mdst-space-md);

        &[data-state="active"] {
          background: var(--mdst-color-fg);
          color: var(--mdst-color-bg);
        }

        &:hover:not([data-state="active"]):not([data-disabled]) {
          background: var(--mdst-color-subtle);
          color: var(--mdst-color-fg);
        }
      }
    }

    /* Variant: Vertical */

    &.mdst-tabs--vertical {
      flex-direction: row;

      & .mdst-tabs__list {
        flex-direction: column;
        border-bottom: none;
        border-inline-end: var(--mdst-border-width) solid var(--mdst-color-border);
        min-width: 10rem;
      }

      & .mdst-tabs__tab {
        border-bottom: none;
        margin-bottom: 0;
        border-inline-end: 2px solid transparent;
        margin-inline-end: calc(-1 * var(--mdst-border-width));
        text-align: start;

        &[data-state="active"] {
          border-inline-end-color: var(--mdst-color-fg);
          border-bottom-color: transparent;
        }
      }

      & .mdst-tabs__panel {
        padding: 0 var(--mdst-space-md);
        flex: 1;
      }
    }

    /* Variant: Compact */

    &.mdst-tabs--sm {
      & .mdst-tabs__tab {
        padding: var(--mdst-space-xs) var(--mdst-space-sm);
        font-size: var(--mdst-text-sm);
      }

      & .mdst-tabs__panel {
        padding: var(--mdst-space-sm) 0;
      }
    }
  }

  /* Windows High Contrast (forced colours) removes fills, so the parts that
     show state are redrawn in the user's system colours. */
  @media (forced-colors: active) {
    .mdst-tabs.mdst-tabs--pills .mdst-tabs__tab[data-state="active"] {
      forced-color-adjust: none;
      background: Highlight;
      color: HighlightText;
    }
  }
}

@layer mdst-ui.components {
  /* Tag */

  .mdst-tag {
    display: inline-flex;
    align-items: center;
    gap: var(--mdst-space-xs);
    padding: 0.25em 0.5em;
    font-size: var(--mdst-text-sm);
    line-height: 1;
    border: var(--mdst-border-width) solid var(--mdst-tone, var(--mdst-color-border));
    border-radius: var(--mdst-radius);
    background: var(--mdst-color-bg);
    color: var(--mdst-tone, var(--mdst-color-fg));
    white-space: nowrap;
    vertical-align: middle;

    /* Tone (.mdst-danger and friends, or your own --mdst-tone) colours the
       text and border, and each variant below. Subtle tints the background
       with 10% of the tone; with no tone, --_tone-subtle is invalid and
       falls back to --mdst-color-subtle. */
    --_tone-subtle: color-mix(in srgb, var(--mdst-tone) 10%, transparent);

    /* Variants */

    &.mdst-tag--solid {
      background: var(--mdst-tone, var(--mdst-color-fg));
      color: var(--mdst-color-bg);
    }

    &.mdst-tag--subtle {
      background: var(--_tone-subtle, var(--mdst-color-subtle));
      border-color: transparent;
    }

    &.mdst-tag--borderless {
      border-color: transparent;
      background: transparent;
    }

    /* Muted: a quieter tag rather than a status, so it stays a modifier */

    &.mdst-tag--muted {
      --mdst-tone: var(--mdst-color-muted);
      --_tone-subtle: var(--mdst-color-subtle);
    }

    /* Sizes */

    &.mdst-tag--sm {
      font-size: var(--mdst-text-xs);
      padding: 0.1875em 0.375em;
    }

    &.mdst-tag--lg {
      font-size: var(--mdst-text-base);
      padding: 0.3125em 0.625em;
    }

    /* Pill shape */

    &.mdst-tag--pill {
      border-radius: 9999px;
      padding-inline: 0.75em;
    }

    /* Interactive (dismissible / clickable) */

    &.mdst-tag--interactive {
      cursor: pointer;
      transition: opacity var(--mdst-transition);

      &:hover {
        opacity: 0.75;
      }
    }

    /* Dismiss button inside a tag */

    & .mdst-tag__dismiss {
      display: inline-flex;
      align-items: center;
      justify-content: center;
      padding: 0 0.125em;
      margin: 0;
      /* Square around an icon, so the focus ring is a neat square; a word
         instead of an icon widens it rather than spilling out */
      height: 1.25em;
      min-width: 1.25em;
      white-space: nowrap;
      flex-shrink: 0;
      border: none;
      background: none;
      box-shadow: none;
      color: inherit;
      cursor: pointer;
      opacity: 0.6;
      font-size: 1em;
      line-height: 1;
      transition: opacity var(--mdst-transition-fast);

      &:hover {
        opacity: 1;
      }

      &:focus-visible {
        opacity: 1;
      }
    }
  }

  /* Deprecated: remove in 3.0. Use the tone classes (.mdst-danger, …). */

  .mdst-tag--danger {
    --mdst-tone: var(--mdst-color-danger);
  }

  .mdst-tag--success {
    --mdst-tone: var(--mdst-color-success);
  }

  .mdst-tag--warning {
    --mdst-tone: var(--mdst-color-warning);
  }

  .mdst-tag--info {
    --mdst-tone: var(--mdst-color-info, var(--mdst-color-fg));
  }
}

@layer mdst-ui.components {
  /* Toast */

  .mdst-toast {
    display: flex;
    align-items: center;
    gap: var(--mdst-space-sm);
    padding: var(--mdst-space-sm) var(--mdst-space-md);
    border: var(--mdst-border-width) solid var(--mdst-color-border);
    /* A tone (.mdst-danger and friends, or your own --mdst-tone) draws a 3px
       accent edge at the start. With no tone, --_accent is invalid and the
       normal border applies. */
    --_accent: 3px solid var(--mdst-tone);
    border-inline-start: var(--_accent, var(--mdst-border-width) solid var(--mdst-color-border));
    border-radius: var(--mdst-radius);
    background: var(--mdst-color-bg);
    color: var(--mdst-color-fg);
    font-family: var(--mdst-font-ui);
    font-size: var(--mdst-text-sm);
    line-height: var(--mdst-line-height);
    transition:
      opacity var(--mdst-transition-slow),
      visibility var(--mdst-transition-slow);

    /* State: visible */

    &[data-state="visible"] {
      opacity: 1;
      visibility: visible;
    }

    /* State: hidden */

    &[data-state="hidden"] {
      opacity: 0;
      visibility: hidden;
    }
  }

  /* Toast close button */

  .mdst-toast__close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 0.125em;
    margin: 0;
    margin-inline-start: auto;
    /* Square around an icon, so the focus ring is a neat square; a word
       instead of an icon widens it rather than spilling out */
    height: 1.5em;
    min-width: 1.5em;
    white-space: nowrap;
    flex-shrink: 0;
    border: none;
    background: none;
    box-shadow: none;
    color: inherit;
    cursor: pointer;
    opacity: 0.6;
    font-size: 1em;
    line-height: 1;
    transition: opacity var(--mdst-transition-fast);

    &:hover {
      opacity: 1;
    }

    &:focus-visible {
      opacity: 1;
    }
  }

  /* Toast group (stacking container) */

  .mdst-toast-group {
    position: fixed;
    bottom: var(--mdst-space-md);
    inset-inline-end: var(--mdst-space-md);
    display: flex;
    flex-direction: column;
    gap: var(--mdst-space-sm);
    z-index: calc(var(--mdst-z-overlay) + 1);
  }

  /* Deprecated: remove in 3.0. Use the tone classes (.mdst-danger, …). */

  .mdst-toast--danger {
    --mdst-tone: var(--mdst-color-danger);
  }

  .mdst-toast--success {
    --mdst-tone: var(--mdst-color-success);
  }

  .mdst-toast--warning {
    --mdst-tone: var(--mdst-color-warning);
  }

  .mdst-toast--info {
    --mdst-tone: var(--mdst-color-info, var(--mdst-color-fg));
  }
}

/* --mdst-tone is registered so it doesn't inherit: a tone colours the element
   it's set on, not everything inside it. A danger banner's close button stays
   a plain button. Components that colour their own children or pseudo-elements
   (progress, OTP input) copy it into a private variable at their root. */
@property --mdst-tone {
  syntax: "*";
  inherits: false;
}

@layer mdst-ui.components {
  /* Tone
     One class sets the status colour on any component that has one: button,
     badge, tag, banner, toast, progress, and OTP input. Each component decides
     how to use it (text, border, fill, or an accent edge).

     Make your own by setting --mdst-tone on the element:
       .my-brand { --mdst-tone: rebeccapurple; } */

  .mdst-danger {
    --mdst-tone: var(--mdst-color-danger);
  }

  .mdst-success {
    --mdst-tone: var(--mdst-color-success);
  }

  .mdst-warning {
    --mdst-tone: var(--mdst-color-warning);
  }

  .mdst-info {
    --mdst-tone: var(--mdst-color-info, var(--mdst-color-fg));
  }
}

@layer mdst-ui.components {
  /* Toolbar */

  .mdst-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--mdst-space-sm);
    font-family: var(--mdst-font-ui);
    font-size: var(--mdst-text-sm);

    /* Group of related controls */

    & .mdst-toolbar__group {
      display: flex;
      flex-wrap: wrap;
      align-items: center;
      gap: var(--mdst-space-xs);

      /* Attached: controls share borders and read as one segmented unit */

      &.mdst-toolbar__group--attached {
        flex-wrap: nowrap;
        gap: 0;

        & > * + * {
          margin-inline-start: calc(var(--mdst-border-width) * -1);
        }

        & > :not(:first-child, :last-child) {
          border-radius: 0;
        }

        & > :first-child:not(:last-child) {
          border-start-end-radius: 0;
          border-end-end-radius: 0;
        }

        & > :last-child:not(:first-child) {
          border-start-start-radius: 0;
          border-end-start-radius: 0;
        }

        /* Lift the hovered / focused control so its full border shows */
        & > :hover,
        & > :focus-visible {
          position: relative;
          z-index: 1;
        }
      }
    }

    /* Spacer: pushes everything after it to the far end */

    & .mdst-toolbar__spacer {
      flex: 1 1 0;
    }

    /* Separator: vertical rule between groups (use <hr> or role="separator") */

    & .mdst-toolbar__separator {
      align-self: stretch;
      width: 0;
      height: auto;
      min-height: 1.5em;
      margin: 0;
      border: none;
      border-inline-start: var(--mdst-border-width) solid var(--mdst-color-border);
    }

    /* Form controls size to their content instead of filling the row */

    /* :where() keeps this at the toolbar's own strength, so components with
       their own sizing (OTP digits, colour picker) keep it */
    & :where(input:not([type="checkbox"], [type="radio"]), select) {
      width: auto;
      min-width: 0;
    }

    /* Variants */

    &.mdst-toolbar--bordered {
      padding: var(--mdst-space-sm);
      border: var(--mdst-border-width) solid var(--mdst-color-border);
      border-radius: var(--mdst-radius);
      background: var(--mdst-color-bg);
    }
  }
}

@layer mdst-ui.components {
  /* Tooltip (Popover-based) */

  .mdst-tooltip {
    padding: var(--mdst-space-xs) var(--mdst-space-sm);
    border: var(--mdst-border-width) solid var(--mdst-color-border);
    border-radius: var(--mdst-radius);
    background: var(--mdst-color-fg);
    color: var(--mdst-color-bg);
    font-size: var(--mdst-text-sm);
    box-shadow: var(--mdst-shadow-sm);
    max-width: 16rem;
    text-align: center;

    /* Centered fallback: browsers without CSS anchor positioning keep the
       popover centered on screen rather than pinned to a corner. The @supports
       block below pins it to the trigger where anchor positioning is available. */
    margin: auto;

    /* Anchor positioning links the tooltip to its invoking trigger.
       Baseline Chrome 129 / Firefox 147 / Safari 26; older browsers keep the
       centered fallback above. */
    @supports (position-area: bottom) {
      position-area: bottom;
      margin: 0;
      margin-top: var(--mdst-space-xs);

      /* Position modifiers (default is bottom) */

      &.mdst-tooltip--top {
        position-area: top;
        margin: 0;
        margin-bottom: var(--mdst-space-xs);
      }

      /* Start and end follow the text direction (left and right in LTR) */
      &.mdst-tooltip--start {
        position-area: inline-start;
        margin: 0;
        margin-inline-end: var(--mdst-space-xs);
      }

      &.mdst-tooltip--end {
        position-area: inline-end;
        margin: 0;
        margin-inline-start: var(--mdst-space-xs);
      }
    }
  }
}

@layer mdst-ui.components {
  /* Typography */

  /* Reading face and colours — set once on the container so every element
     inside .mdst-ui inherits them (td, li, summary included, with nothing left
     to fall back to browser defaults). Zero specificity: any user rule on the
     container wins. Components opt into --mdst-font-ui or --mdst-font-mono
     explicitly. */
  :where(.mdst-ui) {
    font-family: var(--mdst-font-text);
    line-height: var(--mdst-line-height);
    color: var(--mdst-color-fg);
    background-color: var(--mdst-color-bg);
    /* Native controls modest-ui doesn't draw itself pick up the text colour */
    accent-color: var(--mdst-color-fg);
  }

  /* Flow — space between the children of plain containers, so plain HTML
     reads as a page. Runs in the .mdst-ui root and in unclassed sectioning,
     form, and wrapper elements, popovers, and dialogs not built from the
     .mdst-dialog__ parts. Give a container a class or an inline style
     (usually because you lay it out with flex or grid) and its spacing is
     yours. Zero specificity; tune or turn off with --mdst-flow-space. */
  :where(
      .mdst-ui,
      .mdst-ui :is(main, article, section, header, footer, aside, div, form, fieldset, details, blockquote, dd, [popover]):not([class], [style]),
      .mdst-ui dialog:not([class], [style], :has(> [class*="mdst-dialog__"])),
      .mdst-form,
      .mdst-fieldset
    )
    /* Spacing goes above an element only when something visible comes
       before it. Scripts, styles, hidden elements, inline links and spans
       (a skip link), a fieldset's legend, and a details element's summary
       (its content sits in a padded box of its own) don't count, so the
       first thing you see never gets a top margin. */
    > :where(:not(script, style, template, link, meta, noscript, a, span, br, [hidden], dialog, [popover], legend, summary))
    ~ :where(:not(dialog, [popover])) {
    margin-block-start: var(--mdst-flow-space);
  }

  :where(.mdst-ui) h1,
  :where(.mdst-ui) h2,
  :where(.mdst-ui) h3,
  :where(.mdst-ui) h4,
  :where(.mdst-ui) h5,
  :where(.mdst-ui) h6,
  .mdst-h1,
  .mdst-h2,
  .mdst-h3,
  .mdst-h4,
  .mdst-h5,
  .mdst-h6 {
    font-weight: 600;
    line-height: 1.25;
    text-wrap: balance;
  }

  :where(.mdst-ui) h1,
  .mdst-h1 {
    font-size: 2.5rem;
  }

  :where(.mdst-ui) h2,
  .mdst-h2 {
    font-size: 2rem;
  }

  :where(.mdst-ui) h3,
  .mdst-h3 {
    font-size: 1.5rem;
  }

  :where(.mdst-ui) h4,
  .mdst-h4 {
    font-size: 1.25rem;
  }

  :where(.mdst-ui) h5,
  .mdst-h5 {
    font-size: 1rem;
  }

  :where(.mdst-ui) h6,
  .mdst-h6 {
    font-size: 0.875rem;
  }

  /* Paragraph — inherits size and colour, so text inside components that set
     their own (a tooltip, a small banner, a coloured tag) keeps them */

  :where(.mdst-ui) p,
  .mdst-p {
    line-height: var(--mdst-line-height);
    text-wrap: pretty;
  }

  :where(.mdst-ui) p.mdst-p--sm,
  .mdst-p--sm {
    font-size: var(--mdst-text-sm);
  }

  :where(.mdst-ui) p.mdst-p--lg,
  .mdst-p--lg {
    font-size: var(--mdst-text-lg);
  }

  :where(.mdst-ui) p.mdst-p--muted,
  .mdst-p--muted {
    color: var(--mdst-color-muted);
  }

  /* Links — inherit the text colour; the underline marks them */

  :where(.mdst-ui) a,
  .mdst-a {
    color: inherit;
    text-decoration: underline;
    text-underline-offset: 0.15em;
  }

  /* The current page's link in a nav: bold, and no underline since it goes
     nowhere new */

  :where(.mdst-ui) nav a:where([aria-current]:not([aria-current="false"])) {
    font-weight: 600;
    text-decoration: none;
  }

  /* Strong / Bold */

  :where(.mdst-ui) strong,
  .mdst-strong {
    font-weight: 600;
  }

  /* Emphasis / Italic */

  :where(.mdst-ui) em,
  .mdst-em {
    font-style: italic;
  }

  /* Small */

  :where(.mdst-ui) small,
  .mdst-small {
    font-size: var(--mdst-text-sm);
  }

  /* Mark / Highlight */

  :where(.mdst-ui) mark,
  .mdst-mark {
    background-color: var(--mdst-color-subtle);
    padding: 0.1em 0.2em;
  }

  /* Keyboard */

  :where(.mdst-ui) kbd,
  .mdst-kbd {
    font-family: var(--mdst-font-mono);
    font-size: 0.875em;
    padding: 0.125em 0.375em;
    border: var(--mdst-border-width) solid var(--mdst-color-border);
    border-radius: var(--mdst-radius);
    background: var(--mdst-color-subtle);
    white-space: nowrap;
  }

  /* Abbreviation — only when it carries an expansion */

  :where(.mdst-ui) abbr:where([title]),
  .mdst-abbr {
    text-decoration: underline dotted;
    text-underline-offset: 0.15em;
    cursor: help;
  }

  /* Edits — deleted and inserted text */

  :where(.mdst-ui) del,
  .mdst-del {
    text-decoration: line-through;
    background-color: color-mix(in srgb, var(--mdst-color-danger) 12%, transparent);
  }

  :where(.mdst-ui) ins,
  .mdst-ins {
    text-decoration: none;
    background-color: color-mix(in srgb, var(--mdst-color-success) 12%, transparent);
  }

  /* Strikethrough — no longer accurate, but not an edit */

  :where(.mdst-ui) s,
  .mdst-s {
    text-decoration: line-through;
    color: var(--mdst-color-muted);
  }

  /* Citation */

  :where(.mdst-ui) cite,
  .mdst-cite {
    font-style: italic;
    color: var(--mdst-color-muted);
  }

  /* Sample output and variables */

  :where(.mdst-ui) samp,
  .mdst-samp {
    font-family: var(--mdst-font-mono);
    font-size: 0.875em;
    padding: 0.125em 0.375em;
    border-radius: var(--mdst-radius);
    background: var(--mdst-color-subtle);
  }

  :where(.mdst-ui) var,
  .mdst-var {
    font-family: var(--mdst-font-mono);
    font-size: 0.875em;
    font-style: italic;
  }

  /* Subscript / Superscript — don't stretch the line height */

  :where(.mdst-ui) sub,
  :where(.mdst-ui) sup,
  .mdst-sub,
  .mdst-sup {
    position: relative;
    font-size: 0.75em;
    line-height: 0;
    vertical-align: baseline;
  }

  :where(.mdst-ui) sub,
  .mdst-sub {
    bottom: -0.25em;
  }

  :where(.mdst-ui) sup,
  .mdst-sup {
    top: -0.5em;
  }

  /* Blockquote */

  :where(.mdst-ui) blockquote,
  .mdst-blockquote {
    margin-inline: 0;
    padding-inline-start: var(--mdst-space-md);
    border-inline-start: var(--mdst-space-1) solid var(--mdst-color-border);
    font-style: italic;
    color: var(--mdst-color-muted);
  }

  /* Horizontal Rule */

  :where(.mdst-ui) hr,
  .mdst-hr {
    border: none;
    border-top: var(--mdst-border-width) solid var(--mdst-color-border);
    margin: var(--mdst-space-lg) 0;
  }

  :where(.mdst-ui) hr.mdst-hr--flush,
  .mdst-hr--flush {
    margin: 0;
  }

  /* Lists */

  :where(.mdst-ui) ul,
  :where(.mdst-ui) ol,
  :where(.mdst-ui) menu,
  .mdst-ul,
  .mdst-ol {
    padding-inline-start: var(--mdst-space-lg);
    line-height: var(--mdst-line-height);
  }

  :where(.mdst-ui) ul,
  :where(.mdst-ui) menu,
  .mdst-ul {
    list-style-type: disc;
  }

  :where(.mdst-ui) ol,
  .mdst-ol {
    list-style-type: decimal;
  }

  :where(.mdst-ui) li,
  .mdst-li {
    margin-bottom: var(--mdst-space-xs);
  }

  :where(.mdst-ui) li:where(:last-child),
  .mdst-li:last-child {
    margin-bottom: 0;
  }

  /* Unstyled list */

  :where(.mdst-ui) ul.mdst-ul--unstyled,
  .mdst-ul--unstyled {
    list-style: none;
    padding-inline-start: 0;
  }

  /* Description list: terms in bold, each description indented under its
     term, and a gap before the next term */

  :where(.mdst-ui) dl {
    line-height: var(--mdst-line-height);
  }

  :where(.mdst-ui) dt {
    font-weight: 600;
  }

  :where(.mdst-ui) dd {
    padding-inline-start: var(--mdst-space-md);
  }

  :where(.mdst-ui) dd + dt {
    margin-block-start: var(--mdst-space-sm);
  }

  /* Figure: a small muted caption, close to what it captions */

  :where(.mdst-ui) figcaption {
    font-size: var(--mdst-text-sm);
    color: var(--mdst-color-muted);
  }

  :where(.mdst-ui) figure > * + * {
    margin-block-start: var(--mdst-space-xs);
  }

  /* Heading group: the subtitle sits close under the heading, muted */

  :where(.mdst-ui) hgroup > * + * {
    margin-block-start: var(--mdst-space-xs);
  }

  :where(.mdst-ui) hgroup > p {
    color: var(--mdst-color-muted);
  }

  /* Address: contact details, not emphasis */

  :where(.mdst-ui) address {
    font-style: normal;
  }

  /* Busy: a region or control that's loading */

  :where(.mdst-ui) :where([aria-busy="true"]) {
    cursor: progress;
  }

  /* Print: always light, and keep blocks and their headings together */

  @media print {
    :where(.mdst-ui) {
      color-scheme: light;
    }

    :where(.mdst-ui) :where(pre, blockquote, figure, img, tr) {
      break-inside: avoid;
    }

    :where(.mdst-ui) :where(h1, h2, h3, h4, h5, h6) {
      break-after: avoid;
    }
  }

  /* Windows High Contrast (forced colours) removes fills, so the parts that
     show state are redrawn in the user's system colours. */
  @media (forced-colors: active) {
    :where(.mdst-ui) ins,
    .mdst-ins {
      text-decoration: underline;
    }
  }
}

@layer mdst-ui.components {
  /* Utilities */

  /* Screen reader only — visually hidden but accessible */

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

  /* Text truncation — single-line ellipsis overflow */

  .mdst-truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  /* Muted text color */

  .mdst-muted {
    color: var(--mdst-color-muted);
  }

  /* Monospace font */

  .mdst-mono {
    font-family: var(--mdst-font-mono);
  }
}

