@layer components {
  /* ─── Icon ──────────────────────────────────────────────────────── */
  .icon {
    inline-size: 20px;
    block-size: 20px;
    flex: none;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.75;
    stroke-linecap: round;
    stroke-linejoin: round;
  }

  .icon--sm {
    inline-size: 16px;
    block-size: 16px;
  }

  .icon--lg {
    inline-size: 24px;
    block-size: 24px;
  }

  .icon--xl {
    inline-size: 32px;
    block-size: 32px;
    stroke-width: 1.5;
  }

  /* ─── Button ────────────────────────────────────────────────────── */
  .btn {
    --btn-bg: var(--color-surface-alt);
    --btn-bg-hover: var(--color-border);
    --btn-fg: var(--color-text);
    --btn-border: transparent;

    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    min-block-size: var(--control-md);
    padding-block: 0;
    padding-inline: var(--space-5);
    border: 1px solid var(--btn-border);
    border-radius: var(--radius-md);
    background: var(--btn-bg);
    color: var(--btn-fg);
    font-size: var(--text-15);
    font-weight: var(--weight-semibold);
    line-height: 1;
    white-space: nowrap;
    text-decoration: none;
    cursor: pointer;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    transition:
      background-color var(--duration-micro) var(--ease-out),
      border-color var(--duration-micro) var(--ease-out),
      color var(--duration-micro) var(--ease-out),
      transform var(--duration-micro) var(--ease-out);
  }

  .btn:hover {
    background: var(--btn-bg-hover);
    color: var(--btn-fg);
  }

  .btn:active {
    transform: scale(0.98);
  }

  .btn--primary {
    --btn-bg: var(--color-primary);
    --btn-bg-hover: var(--color-primary-hover);
    --btn-fg: var(--color-on-primary);
  }

  .btn--primary:active {
    --btn-bg-hover: var(--color-primary-active);
  }

  .btn--outline {
    --btn-bg: var(--color-bg);
    --btn-bg-hover: var(--color-surface);
    --btn-border: var(--color-border-strong);
  }

  .btn--ghost {
    --btn-bg: transparent;
    --btn-bg-hover: var(--color-surface-alt);
  }

  .btn--danger {
    --btn-bg: var(--color-danger);
    --btn-bg-hover: var(--color-danger-hover);
    --btn-fg: var(--color-on-primary);
  }

  .btn--sm {
    min-block-size: var(--control-sm);
    padding-inline: var(--space-3);
    border-radius: var(--radius-sm);
    font-size: var(--text-14);
  }

  .btn--lg {
    min-block-size: var(--control-lg);
    padding-inline: var(--space-6);
    font-size: var(--text-16);
  }

  .btn--block {
    inline-size: 100%;
  }

  .btn--icon {
    inline-size: var(--control-md);
    padding-inline: 0;
  }

  .btn--icon.btn--sm {
    inline-size: var(--control-sm);
  }

  .btn--icon.btn--lg {
    inline-size: var(--control-lg);
  }

  .btn:disabled,
  .btn[aria-disabled="true"] {
    --btn-bg: var(--color-surface-alt);
    --btn-bg-hover: var(--color-surface-alt);
    --btn-fg: var(--color-text-muted);
    --btn-border: transparent;
    cursor: not-allowed;
    transform: none;
  }

  /* Loading: keeps the button's size, hides the label, shows a spinner in the label color. */
  .btn[aria-busy="true"],
  .btn.htmx-request,
  .htmx-request .btn[data-loading] {
    pointer-events: none;
  }

  .btn[aria-busy="true"] > *,
  .btn.htmx-request > *,
  .htmx-request .btn[data-loading] > * {
    visibility: hidden;
  }

  .btn[aria-busy="true"]::after,
  .btn.htmx-request::after,
  .htmx-request .btn[data-loading]::after {
    content: "";
    position: absolute;
    inset: 0;
    margin: auto;
    inline-size: 18px;
    block-size: 18px;
    border: 2px solid var(--btn-fg);
    border-inline-end-color: transparent;
    border-radius: var(--radius-full);
    animation: spin 700ms linear infinite;
  }

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

  @media (prefers-reduced-motion: reduce) {
    .btn[aria-busy="true"]::after,
    .btn.htmx-request::after,
    .htmx-request .btn[data-loading]::after {
      animation-duration: 1.6s !important;
      animation-iteration-count: infinite !important;
    }
  }

  .btn[aria-pressed="true"] .icon {
    fill: currentColor;
    color: var(--color-danger);
    animation: pop var(--duration-normal) var(--ease-out);
  }

  @keyframes pop {
    50% {
      transform: scale(1.2);
    }
  }

  /* ─── Steps (multi-step flows: registration, checkout) ──────────── */
  .steps {
    display: flex;
    gap: var(--space-2);
    margin: 0;
    padding: 0;
    list-style: none;
  }

  .steps li {
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: var(--space-2);
    color: var(--color-text-secondary);
    font-size: var(--text-13);
    line-height: var(--leading-snug);
  }

  .steps li::before {
    content: "";
    block-size: 4px;
    border-radius: var(--radius-full);
    background: var(--color-border);
    transition: background-color var(--duration-normal) var(--ease-out);
  }

  .steps li[data-done]::before,
  .steps li[aria-current]::before {
    background: var(--color-primary);
  }

  .steps li[aria-current] {
    color: var(--color-text);
    font-weight: var(--weight-semibold);
  }

  .steps__optional {
    font-weight: var(--weight-regular);
  }

  @media (max-width: 399px) {
    .steps__optional {
      display: none;
    }
  }

  /* ─── Form field ────────────────────────────────────────────────── */
  .form {
    display: flex;
    flex-direction: column;
    gap: var(--space-5);
  }

  .field {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    min-inline-size: 0;
  }

  .field fieldset {
    margin: 0;
    padding: 0;
    border: 0;
    min-inline-size: 0;
  }

  .field__label,
  .field legend {
    padding: 0;
    color: var(--color-text);
    font-size: var(--text-14);
    font-weight: var(--weight-semibold);
    line-height: var(--leading-snug);
  }

  .field__optional {
    color: var(--color-text-secondary);
    font-weight: var(--weight-regular);
  }

  .field__help {
    color: var(--color-text-secondary);
    font-size: var(--text-13);
    line-height: var(--leading-snug);
  }

  .field__error {
    display: flex;
    align-items: flex-start;
    gap: var(--space-2);
    color: var(--color-danger-text);
    font-size: var(--text-13);
    font-weight: var(--weight-medium);
    line-height: var(--leading-snug);
  }

  .field__error .icon {
    margin-block-start: 1px;
  }

  .input,
  .field :where(input:not([type="checkbox"], [type="radio"], [type="file"], [type="hidden"]), select, textarea) {
    inline-size: 100%;
    min-block-size: var(--control-md);
    padding-block: var(--space-2);
    padding-inline: var(--space-3);
    border: 1px solid var(--color-border-control);
    border-radius: var(--radius-md);
    background-color: var(--color-bg);
    color: var(--color-text);
    font-size: var(--text-16); /* ≥16px prevents iOS zoom on focus */
    line-height: var(--leading-snug);
    transition:
      border-color var(--duration-micro) var(--ease-out),
      box-shadow var(--duration-micro) var(--ease-out);
  }

  .input:hover,
  .field :where(input, select, textarea):hover {
    border-color: var(--color-text-secondary);
  }

  .input:focus,
  .field :where(input:not([type="checkbox"], [type="radio"]), select, textarea):focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: var(--focus-ring-soft);
  }

  .input[aria-invalid="true"],
  .field :where(input, select, textarea)[aria-invalid="true"] {
    border-color: var(--color-danger);
  }

  .input[aria-invalid="true"]:focus,
  .field :where(input, select, textarea)[aria-invalid="true"]:focus {
    box-shadow: var(--focus-ring-danger);
  }

  .input:disabled,
  .field :where(input, select, textarea):disabled {
    border-color: var(--color-border);
    background-color: var(--color-surface-alt);
    color: var(--color-text-secondary);
    cursor: not-allowed;
  }

  .field textarea,
  textarea.input {
    min-block-size: 120px;
    resize: vertical;
  }

  /* Latin-content inputs read left-to-right but stay aligned with the RTL layout. */
  .input--ltr,
  .field :where(input[type="email"], input[type="tel"], input[type="url"], input[type="password"], input[type="number"]) {
    direction: ltr;
    text-align: right;
  }

  .field :where(input[type="email"], input[type="tel"], input[type="url"], input[type="password"], input[type="number"]):placeholder-shown {
    direction: rtl;
  }

  .field select,
  select.input {
    appearance: none;
    padding-inline-end: var(--space-10);
    /* Chevron: backgrounds have no logical positions; the site is RTL-only, so the arrow sits on the left (inline-end).
       The stroke color mirrors --color-text-secondary (custom properties cannot enter data URIs). */
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: left var(--space-3) center;
    background-size: 18px;
    cursor: pointer;
  }

  /* Checkbox & radio: native controls, brand-tinted, full-row tap targets. */
  .choice,
  .field__choices label {
    display: flex;
    align-items: flex-start;
    gap: var(--space-3);
    min-block-size: var(--control-md);
    padding-block: var(--space-2);
    color: var(--color-text);
    font-size: var(--text-15);
    font-weight: var(--weight-regular);
    line-height: var(--leading-snug);
    cursor: pointer;
  }

  .choice input,
  .field__choices input {
    flex: none;
    inline-size: 20px;
    block-size: 20px;
    margin: 2px 0 0;
    accent-color: var(--color-primary);
    cursor: pointer;
  }

  .field__choices > div {
    display: flex;
    flex-direction: column;
  }

  .field[data-invalid] .choice input,
  .field[data-invalid] .field__choices input {
    outline: 2px solid var(--color-danger);
    outline-offset: 1px;
  }

  /* ─── Badge ─────────────────────────────────────────────────────── */
  .badge {
    --badge-bg: var(--color-surface-alt);
    --badge-fg: var(--color-text-strong-muted);

    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    min-block-size: 24px;
    padding-inline: var(--space-2);
    border-radius: var(--radius-sm);
    background: var(--badge-bg);
    color: var(--badge-fg);
    font-size: var(--text-12);
    font-weight: var(--weight-semibold);
    line-height: 1;
    white-space: nowrap;
  }

  .badge--success {
    --badge-bg: var(--color-success-bg);
    --badge-fg: var(--color-success-text);
  }

  .badge--warning {
    --badge-bg: var(--color-warning-bg);
    --badge-fg: var(--color-warning-text);
  }

  .badge--danger {
    --badge-bg: var(--color-danger-bg);
    --badge-fg: var(--color-danger-text);
  }

  .badge--info {
    --badge-bg: var(--color-info-bg);
    --badge-fg: var(--color-info-text);
  }

  .badge__dot {
    inline-size: 6px;
    block-size: 6px;
    border-radius: var(--radius-full);
    background: currentColor;
  }

  /* ─── Alert (inline, persistent) ────────────────────────────────── */
  .alert {
    --alert-bg: var(--color-info-bg);
    --alert-border: var(--color-info-border);
    --alert-accent: var(--color-info-text);

    display: flex;
    align-items: flex-start;
    gap: var(--space-3);
    padding: var(--space-4);
    border: 1px solid var(--alert-border);
    border-radius: var(--radius-lg);
    background: var(--alert-bg);
    color: var(--color-text);
  }

  .alert > .icon {
    color: var(--alert-accent);
    margin-block-start: 2px;
  }

  .alert__content {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
    min-inline-size: 0;
  }

  .alert__title {
    font-size: var(--text-15);
    font-weight: var(--weight-semibold);
    line-height: var(--leading-snug);
  }

  .alert__body {
    font-size: var(--text-14);
    line-height: var(--leading-body);
  }

  .alert--success {
    --alert-bg: var(--color-success-bg);
    --alert-border: var(--color-success-border);
    --alert-accent: var(--color-success-text);
  }

  .alert--warning {
    --alert-bg: var(--color-warning-bg);
    --alert-border: var(--color-warning-border);
    --alert-accent: var(--color-warning-text);
  }

  .alert--danger {
    --alert-bg: var(--color-danger-bg);
    --alert-border: var(--color-danger-border);
    --alert-accent: var(--color-danger-text);
  }

  /* ─── Maintenance banner ────────────────────────────────────────── */
  /* Lives here rather than in shell.css because base.html puts it on *every* page, and the sign-in
     screens load components.css without shell.css. A page-level rule would leave them unstyled.

     Not sticky: it sits above a sticky header, and two stacked bars would eat a third of a phone
     screen for a message that is read once. It is at the top of every page load, and every page
     revalidates (private, no-cache), so it cannot go stale or be missed on arrival. */
  .maintenance-banner {
    border-block-end: 1px solid var(--color-warning-border);
    background: var(--color-warning-bg);
    color: var(--color-warning-text);
  }

  .maintenance-banner__inner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-2) var(--space-3);
    padding-block: var(--space-2);
  }

  .maintenance-banner .icon {
    flex: none;
  }

  .maintenance-banner__text {
    flex: 1 1 16rem;
    font-size: var(--text-14);
    line-height: var(--leading-snug);
  }

  .maintenance-banner__text strong {
    font-weight: var(--weight-semibold);
  }

  /* Pushed to the inline-end edge on a wide screen; on a phone the flex-wrap above drops it onto its
     own line rather than squeezing the sentence. */
  .maintenance-banner__countdown {
    margin-inline-start: auto;
    padding: 2px var(--space-2);
    border-radius: var(--radius-sm);
    background: color-mix(in srgb, var(--color-warning-text) 10%, transparent);
    font-size: var(--text-13);
    font-weight: var(--weight-medium);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
  }

  /* Inline shell commands, for the few places the panel has to name one the operator must run on the
     server. `direction: ltr` is not optional: a command inside an RTL paragraph otherwise has its
     leading `./` reordered to the wrong end and becomes something you cannot copy and paste. */
  code {
    display: inline-block;
    padding: 1px var(--space-2);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: var(--color-surface-alt);
    color: var(--color-text-strong-muted);
    font-family: ui-monospace, "Cascadia Mono", Menlo, Consolas, monospace;
    font-size: 0.875em;
    direction: ltr;
    unicode-bidi: isolate;
  }

  /* The window is open and the reader is staff — a different fact, so a different colour. */
  .maintenance-banner--live {
    border-block-end-color: var(--color-danger-border);
    background: var(--color-danger-bg);
    color: var(--color-danger-text);
  }

  /* ─── Card ──────────────────────────────────────────────────────── */
  .card {
    padding: var(--space-5);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    background: var(--color-bg);
  }

  .card--muted {
    border-color: transparent;
    background: var(--color-surface);
  }

  .card__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
    margin-block-end: var(--space-4);
  }

  .card__title {
    font-size: var(--text-18);
    font-weight: var(--weight-bold);
  }

  @media (min-width: 768px) {
    .card {
      padding: var(--space-6);
    }
  }

  /* ─── Summary (financial rows) ──────────────────────────────────── */
  .summary {
    display: grid;
    gap: var(--space-3);
  }

  .summary__row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: var(--space-4);
    font-size: var(--text-15);
    line-height: var(--leading-snug);
  }

  .summary__row dt {
    color: var(--color-text-secondary);
  }

  .summary__row dd {
    font-weight: var(--weight-medium);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
  }

  .summary__row--discount dd {
    color: var(--color-success-text);
  }

  .summary__row--total {
    margin-block-start: var(--space-1);
    padding-block-start: var(--space-4);
    border-block-start: 1px solid var(--color-border);
  }

  .summary__row--total dt {
    color: var(--color-text);
    font-weight: var(--weight-semibold);
  }

  .summary__row--total dd {
    font-size: var(--text-20);
    font-weight: var(--weight-bold);
  }

  /* ─── Price ─────────────────────────────────────────────────────── */
  .price {
    display: inline-flex;
    align-items: baseline;
    gap: var(--space-1);
    white-space: nowrap;
  }

  .price__amount {
    color: var(--color-text);
    font-size: var(--text-18);
    font-weight: var(--weight-bold);
    font-variant-numeric: tabular-nums;
  }

  .price__unit {
    color: var(--color-text-strong-muted);
    font-size: var(--text-13);
    font-weight: var(--weight-medium);
  }

  /* ─── Product card ──────────────────────────────────────────────── */
  .product-card {
    position: relative;
    display: flex;
    flex-direction: column;
    block-size: 100%;
    overflow: hidden;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    background: var(--color-bg);
    transition: var(--transition-raise);
  }

  /* Gated on `hover: hover`: on a touch screen `:hover` sticks after a tap and the card
     would stay lifted until something else was tapped. The press state is not gated —
     it is the right feedback on both. */
  @media (hover: hover) {
    .product-card:hover {
      border-color: var(--color-border-strong);
      box-shadow: var(--shadow-sm);
      transform: translateY(var(--raise));
    }
  }

  .product-card:active {
    box-shadow: var(--shadow-xs);
    transform: translateY(0);
    transition-duration: var(--duration-micro);
  }

  /* The plate follows the card rather than sitting still inside it. 1.03 is small enough
     that a 4:3 product image never loses its subject to the crop. */
  .product-card__media img {
    transition: transform var(--duration-large) var(--ease-out);
  }

  @media (hover: hover) {
    .product-card:hover .product-card__media img {
      transform: scale(1.03);
    }
  }

  .product-card:has(.product-card__link:focus-visible) {
    outline: 2px solid var(--color-focus);
    outline-offset: 2px;
  }

  .product-card__media {
    display: grid;
    place-items: center;
    aspect-ratio: 4 / 3;
    background: var(--color-surface-alt);
    color: var(--color-text-muted);
  }

  .product-card__media img {
    inline-size: 100%;
    block-size: 100%;
    object-fit: cover;
  }

  .product-card__fav {
    position: absolute;
    z-index: 2;
    inset-block-start: var(--space-3);
    inset-inline-end: var(--space-3);
    --btn-bg: var(--color-bg);
    --btn-bg-hover: var(--color-surface);
    box-shadow: var(--shadow-xs);
  }

  .product-card__body {
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: var(--space-1);
    padding: var(--space-3);
  }

  /* A 2-up grid on a 375px phone leaves ~140px for the price, which is nowrap. Shrinking one step
     keeps a long total readable instead of letting overflow:hidden clip it. */
  .product-card .price__amount {
    font-size: var(--text-16);
  }

  @media (min-width: 480px) {
    .product-card__body {
      padding: var(--space-4);
    }

    .product-card .price__amount {
      font-size: var(--text-18);
    }
  }

  .product-card__meta {
    color: var(--color-text-secondary);
    font-size: var(--text-13);
    line-height: var(--leading-snug);
  }

  .product-card__title {
    display: -webkit-box;
    overflow: hidden;
    font-size: var(--text-15);
    font-weight: var(--weight-semibold);
    line-height: var(--leading-snug);
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
  }

  .product-card__link {
    color: inherit;
    text-decoration: none;
  }

  .product-card__link:hover {
    color: inherit;
  }

  .product-card__link:focus-visible {
    outline: none;
  }

  /* Whole card is the link's tap target; the favorite button sits above it. */
  .product-card__link::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 1;
  }

  /* Real, admin-entered delivery copy — the one thing buyers here want to know before the price.
     Clamped to two lines so a long sentence cannot unbalance the grid. */
  .product-card__delivery {
    display: flex;
    align-items: flex-start;
    gap: var(--space-1);
    margin-block-start: var(--space-2);
    overflow: hidden;
    color: var(--color-text-strong-muted);
    font-size: var(--text-13);
    line-height: var(--leading-snug);
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
  }

  .product-card__delivery .icon {
    flex: none;
    margin-block-start: 1px;
    color: var(--color-text-secondary);
  }

  .product-card__footer {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-2);
    margin-block-start: auto;
    padding-block-start: var(--space-3);
  }

  /* ─── Skeleton ──────────────────────────────────────────────────── */
  .skeleton {
    display: block;
    border-radius: var(--radius-sm);
    background: linear-gradient(90deg, var(--color-surface-alt) 25%, var(--color-surface) 50%, var(--color-surface-alt) 75%);
    background-size: 200% 100%;
    animation: skeleton-sweep 1.4s ease-in-out infinite;
  }

  .skeleton--text {
    block-size: 0.875em;
    margin-block: 0.4em;
  }

  .skeleton--title {
    block-size: 1.1em;
    margin-block: 0.3em;
  }

  .skeleton--block {
    inline-size: 100%;
    block-size: 100%;
    border-radius: 0;
  }

  @keyframes skeleton-sweep {
    from {
      background-position: 100% 0;
    }

    to {
      background-position: -100% 0;
    }
  }

  .product-card--skeleton {
    pointer-events: none;
  }

  /* ─── Toast ─────────────────────────────────────────────────────── */
  .toast-region {
    position: fixed;
    z-index: var(--z-toast);
    inset-inline: var(--space-4);
    inset-block-end: calc(var(--space-4) + env(safe-area-inset-bottom));
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    pointer-events: none;
  }

  @media (min-width: 768px) {
    .toast-region {
      inset-inline: auto var(--space-6);
      inset-block-end: var(--space-6);
      inline-size: min(380px, calc(100vw - 2 * var(--space-6)));
    }
  }

  .toast {
    --toast-accent: var(--color-info-text);

    display: flex;
    align-items: flex-start;
    gap: var(--space-3);
    padding-block: var(--space-3);
    padding-inline: var(--space-4) var(--space-2);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    background: var(--color-bg);
    box-shadow: var(--shadow-md);
    pointer-events: auto;
    animation: toast-in var(--duration-normal) var(--ease-out);
  }

  .toast[data-type="success"] {
    --toast-accent: var(--color-success-text);
  }

  .toast[data-type="warning"] {
    --toast-accent: var(--color-warning-text);
  }

  .toast[data-type="danger"] {
    --toast-accent: var(--color-danger-text);
  }

  .toast__icon {
    margin-block-start: 2px;
    color: var(--toast-accent);
  }

  .toast__message {
    flex: 1;
    padding-block: 1px;
    color: var(--color-text);
    font-size: var(--text-14);
    font-weight: var(--weight-medium);
    line-height: var(--leading-snug);
  }

  .toast__close {
    margin-block: calc(-1 * var(--space-1));
    color: var(--color-text-secondary);
  }

  .toast[data-leaving] {
    animation: toast-out var(--duration-micro) var(--ease-in) forwards;
  }

  @keyframes toast-in {
    from {
      opacity: 0;
      transform: translateY(8px) scale(0.98);
    }
  }

  @keyframes toast-out {
    to {
      opacity: 0;
      transform: translateY(4px);
    }
  }

  /* ─── Modal (native <dialog>): bottom sheet on mobile, centered on desktop ── */
  .modal {
    inline-size: 100%;
    max-inline-size: 100%;
    max-block-size: 100dvh;
    margin: auto 0 0;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--color-text);
    overflow: visible;
  }

  .modal::backdrop {
    background: var(--color-overlay);
  }

  .modal[open] {
    animation: sheet-in var(--duration-large) var(--ease-out);
  }

  .modal[open]::backdrop {
    animation: fade-in var(--duration-normal) var(--ease-out);
  }

  .modal[data-closing] {
    animation: sheet-out var(--duration-normal) var(--ease-in) forwards;
  }

  .modal[data-closing]::backdrop {
    animation: fade-out var(--duration-normal) var(--ease-in) forwards;
  }

  .modal__panel {
    display: flex;
    flex-direction: column;
    max-block-size: 90dvh;
    padding-block-end: env(safe-area-inset-bottom);
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    background: var(--color-bg);
    box-shadow: var(--shadow-lg);
  }

  .modal__header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--space-4);
    padding: var(--space-5) var(--space-5) 0;
  }

  .modal__title {
    padding-block-start: var(--space-2);
    font-size: var(--text-18);
    font-weight: var(--weight-bold);
  }

  .modal__close {
    margin-block-start: calc(-1 * var(--space-1));
    margin-inline-end: calc(-1 * var(--space-2));
    color: var(--color-text-secondary);
  }

  .modal__body {
    overflow-y: auto;
    padding: var(--space-3) var(--space-5) var(--space-5);
    color: var(--color-text-strong-muted);
    font-size: var(--text-15);
    line-height: var(--leading-body);
  }

  .modal__footer {
    display: flex;
    flex-direction: column-reverse;
    gap: var(--space-2);
    padding: var(--space-4) var(--space-5) var(--space-5);
    border-block-start: 1px solid var(--color-border);
  }

  @media (min-width: 768px) {
    .modal {
      inline-size: min(480px, calc(100% - 2 * var(--space-6)));
      margin: auto;
    }

    .modal[open] {
      animation-name: modal-in;
    }

    .modal[data-closing] {
      animation-name: modal-out;
    }

    .modal__panel {
      border-radius: var(--radius-xl);
    }

    .modal__footer {
      flex-direction: row;
      justify-content: flex-start;
    }
  }

  @keyframes sheet-in {
    from {
      transform: translateY(32px);
      opacity: 0;
    }
  }

  @keyframes sheet-out {
    to {
      transform: translateY(24px);
      opacity: 0;
    }
  }

  @keyframes modal-in {
    from {
      transform: translateY(8px) scale(0.98);
      opacity: 0;
    }
  }

  @keyframes modal-out {
    to {
      transform: scale(0.98);
      opacity: 0;
    }
  }

  @keyframes fade-in {
    from {
      opacity: 0;
    }
  }

  @keyframes fade-out {
    to {
      opacity: 0;
    }
  }

  /* ─── Dropdown menu ─────────────────────────────────────────────── */
  .dropdown {
    position: relative;
    display: inline-block;
  }

  .dropdown__menu {
    position: absolute;
    z-index: var(--z-dropdown);
    inset-block-start: calc(100% + var(--space-1));
    inset-inline-start: 0;
    min-inline-size: 220px;
    padding: var(--space-1);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    background: var(--color-bg);
    box-shadow: var(--shadow-md);
    transform-origin: top;
    animation: dropdown-in var(--duration-micro) var(--ease-out);
  }

  .dropdown__menu[data-align="end"] {
    inset-inline: auto 0;
  }

  .dropdown__item {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    inline-size: 100%;
    min-block-size: 40px;
    padding-inline: var(--space-3);
    border: 0;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--color-text);
    font-size: var(--text-14);
    text-align: start;
    text-decoration: none;
    cursor: pointer;
  }

  .dropdown__item .icon {
    color: var(--color-text-secondary);
  }

  .dropdown__item:hover {
    background: var(--color-surface-alt);
    color: var(--color-text);
  }

  .dropdown__item:focus-visible {
    outline: none;
    background: var(--color-surface-alt);
    box-shadow: inset 0 0 0 2px var(--color-focus);
  }

  .dropdown__item--danger,
  .dropdown__item--danger .icon,
  .dropdown__item--danger:hover {
    color: var(--color-danger-text);
  }

  .dropdown__separator {
    block-size: 1px;
    margin-block: var(--space-1);
    background: var(--color-border);
  }

  @media (pointer: coarse) {
    .dropdown__item {
      min-block-size: var(--control-md);
    }
  }

  @keyframes dropdown-in {
    from {
      opacity: 0;
      transform: translateY(-4px);
    }
  }

  /* ─── Tabs ──────────────────────────────────────────────────────── */
  .tabs {
    overflow: hidden;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    background: var(--color-bg);
  }

  .tabs__list {
    display: flex;
    gap: var(--space-1);
    overflow-x: auto;
    padding-inline: var(--space-2);
    box-shadow: inset 0 -1px 0 var(--color-border);
    scrollbar-width: none;
  }

  .tabs__list::-webkit-scrollbar {
    display: none;
  }

  .tabs__tab {
    position: relative;
    flex: none;
    min-block-size: var(--control-md);
    padding-inline: var(--space-4);
    border: 0;
    background: none;
    color: var(--color-text-secondary);
    font-size: var(--text-15);
    font-weight: var(--weight-medium);
    cursor: pointer;
    transition: color var(--duration-micro) var(--ease-out);
  }

  .tabs__tab:hover,
  .tabs__tab[aria-selected="true"] {
    color: var(--color-text);
  }

  .tabs__tab::after {
    content: "";
    position: absolute;
    inset-inline: var(--space-4);
    inset-block-end: 0;
    block-size: 2px;
    border-radius: 2px 2px 0 0;
    background: var(--color-primary);
    transform: scaleX(0);
    transition: transform var(--duration-normal) var(--ease-out);
  }

  .tabs__tab[aria-selected="true"]::after {
    transform: scaleX(1);
  }

  .tabs__tab:focus-visible {
    outline-offset: -2px;
    border-radius: var(--radius-sm);
  }

  .tabs__panel {
    padding: var(--space-5) var(--space-6);
  }

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

  /* ─── Breadcrumb ────────────────────────────────────────────────── */
  .breadcrumb ol {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0 var(--space-2);
    margin: 0;
    padding: 0;
    list-style: none;
    font-size: var(--text-13);
  }

  .breadcrumb li {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    color: var(--color-text-strong-muted);
  }

  .breadcrumb li .icon {
    color: var(--color-text-muted);
  }

  .breadcrumb a {
    display: inline-block;
    padding-block: var(--space-2);
    color: var(--color-text-strong-muted);
    text-decoration: none;
  }

  /* Colour only — the same rule as everywhere else: no underline flicking in under the
     pointer. A breadcrumb is a row of UI links, not prose. */
  .breadcrumb a:hover {
    color: var(--color-text);
    text-decoration: none;
  }

  .breadcrumb [aria-current="page"] {
    color: var(--color-text);
    font-weight: var(--weight-medium);
  }

  /* ─── Pagination ────────────────────────────────────────────────── */
  .pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
  }

  .pagination__pages {
    display: none;
    gap: var(--space-1);
    margin: 0;
    padding: 0;
    list-style: none;
  }

  .pagination__page {
    display: grid;
    place-items: center;
    min-inline-size: 40px;
    block-size: 40px;
    padding-inline: var(--space-2);
    border-radius: var(--radius-md);
    color: var(--color-text);
    font-size: var(--text-14);
    font-weight: var(--weight-medium);
    font-variant-numeric: tabular-nums;
    text-decoration: none;
    transition: background-color var(--duration-micro) var(--ease-out);
  }

  a.pagination__page:hover {
    background: var(--color-surface-alt);
    color: var(--color-text);
  }

  .pagination__page[aria-current="page"] {
    background: var(--color-primary-soft);
    color: var(--color-primary-hover);
    font-weight: var(--weight-semibold);
  }

  .pagination__ellipsis {
    color: var(--color-text-secondary);
  }

  .pagination__status {
    padding-inline: var(--space-2);
    color: var(--color-text-secondary);
    font-size: var(--text-14);
  }

  @media (min-width: 640px) {
    .pagination__pages {
      display: flex;
    }

    .pagination__status {
      display: none;
    }
  }

  /* ─── Empty state ───────────────────────────────────────────────── */
  .empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-12) var(--space-6);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    background: var(--color-bg);
    text-align: center;
  }

  /* Already inside a raised surface (panel card, storefront card) — don't stack two. */
  :is(.card, .panel-card) .empty-state {
    border: 0;
    border-radius: 0;
    background: none;
  }

  .empty-state__icon {
    display: grid;
    place-items: center;
    inline-size: 56px;
    block-size: 56px;
    margin-block-end: var(--space-2);
    border-radius: var(--radius-full);
    background: var(--color-surface-alt);
    color: var(--color-text-strong-muted);
  }

  .empty-state__title {
    font-size: var(--text-18);
    font-weight: var(--weight-bold);
  }

  .empty-state__text {
    max-inline-size: 42ch;
    color: var(--color-text-secondary);
    font-size: var(--text-15);
    line-height: var(--leading-body);
  }

  .empty-state__actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: var(--space-3);
    margin-block-start: var(--space-4);
  }

  /* ─── Ticket thread ───────────────────────────────────────────────
     Shared by the customer area and the admin panel. It used to live in
     `account.css`, which `panel/base.html` never loads — so the panel rendered a
     raw numbered <ol> with no styling at all. It belongs here, where every shell
     already loads it, and both sides now read the same conversation. */
  .thread {
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
    margin: 0;
    padding: 0;
    list-style: none;
  }

  /* Avatar beside bubble. The whole row flips for a staff reply, so the two sides
     of the conversation are told apart by position *and* colour, not colour alone. */
  .thread__message {
    display: flex;
    align-items: flex-start;
    gap: var(--space-3);
    max-inline-size: min(88%, 42rem);
  }

  .thread__message--staff {
    align-self: flex-end;
    flex-direction: row-reverse;
  }

  .thread__avatar {
    display: grid;
    flex: none;
    place-items: center;
    inline-size: 36px;
    block-size: 36px;
    margin-block-start: var(--space-1);
    border-radius: var(--radius-full);
    background: var(--color-surface-alt);
    color: var(--color-text-secondary);
  }

  .thread__message--staff .thread__avatar {
    background: var(--color-primary-soft);
    color: var(--color-primary);
  }

  .thread__bubble {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    min-inline-size: 0;
    padding: var(--space-3) var(--space-4);
    border: 1px solid var(--color-border);
    /* The corner nearest the avatar is squared off: that is what reads as "chat"
       without a cartoon tail. */
    border-radius: var(--radius-lg);
    border-start-end-radius: var(--radius-sm);
    background: var(--color-bg);
    box-shadow: var(--shadow-xs);
  }

  .thread__message--staff .thread__bubble {
    border-color: var(--color-info-border);
    border-radius: var(--radius-lg);
    border-start-start-radius: var(--radius-sm);
    background: var(--color-info-bg);
  }

  .thread__author {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: var(--space-1) var(--space-2);
    font-size: var(--text-14);
    font-weight: var(--weight-semibold);
  }

  .thread__time {
    /* A staff bubble is --color-info-bg, where secondary grey is 4.37:1. */
    color: var(--color-text-strong-muted);
    font-size: var(--text-12);
    font-weight: var(--weight-regular);
    font-variant-numeric: tabular-nums;
  }

  .thread__body {
    color: var(--color-text-strong-muted);
    font-size: var(--text-15);
    line-height: var(--leading-body);
    overflow-wrap: anywhere;
  }

  .thread__files {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
    margin: 0;
    padding: 0;
    list-style: none;
  }

  /* A flex item will not shrink below its content by default, so a long upload name
     ("Screenshot_2026-09-16-…-edit.jpg") pushed its chip straight out of the bubble
     and the ellipsis on the label never had a narrower box to trigger against. */
  .thread__files > li {
    min-inline-size: 0;
    max-inline-size: 100%;
  }

  .thread__file {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    max-inline-size: 100%;
    min-block-size: var(--control-sm);
    padding-inline: var(--space-3);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: var(--color-bg);
    color: var(--color-text-strong-muted);
    font-size: var(--text-13);
    text-decoration: none;
    transition:
      border-color var(--duration-micro) var(--ease-out),
      background-color var(--duration-micro) var(--ease-out);
  }

  .thread__file:hover {
    border-color: var(--color-border-strong);
    background: var(--color-surface);
    color: var(--color-text);
  }

  .thread__file .icon {
    flex: none;
    color: var(--color-text-secondary);
  }

  .thread__file span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  @media (max-width: 479px) {
    .thread__message {
      max-inline-size: 100%;
    }
  }

  /* ─── File upload ─────────────────────────────────────────────────
     `input[type="file"]` is excluded from the `.field` control styles on purpose:
     its native button cannot be restyled far enough and "No file chosen" cannot be
     hidden. `ui.js` wraps the input in the `.filedrop` structure below and hides the
     native control; without JS the bare input still renders as a usable dashed box. */
  .field input[type="file"] {
    inline-size: 100%;
    padding: var(--space-3);
    border: 1px dashed var(--color-border-control);
    border-radius: var(--radius-md);
    background: var(--color-surface);
    font-size: var(--text-14);
  }

  .field input[type="file"]::file-selector-button {
    margin-inline-end: var(--space-3);
    padding-block: var(--space-2);
    padding-inline: var(--space-3);
    border: 1px solid var(--color-border-control);
    border-radius: var(--radius-sm);
    background: var(--color-bg);
    color: var(--color-text);
    font: inherit;
    cursor: pointer;
  }


  /* The file a field already holds, above its upload zone. Bounded on purpose: the name
     ellipsises and the whole chip has `min-inline-size: 0`, because the thing it replaced
     was an unbroken storage path that ran across the next column of the form. */
  .filecurrent {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    min-inline-size: 0;
    padding: var(--space-2);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    background: var(--color-bg);
  }

  .filecurrent__thumb {
    flex: none;
    inline-size: 56px;
    block-size: 56px;
    border-radius: var(--radius-sm);
    background: var(--color-surface-alt);
    object-fit: cover;
  }

  .filecurrent__thumb--icon {
    display: grid;
    place-items: center;
    color: var(--color-text-secondary);
  }

  .filecurrent__text {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
    min-inline-size: 0;
  }

  .filecurrent__name {
    overflow: hidden;
    color: var(--color-text);
    font-size: var(--text-13);
    text-decoration: none;
    text-overflow: ellipsis;
    white-space: nowrap;
    direction: ltr;
    unicode-bidi: isolate;
    text-align: start;
  }

  .filecurrent__name:hover {
    color: var(--color-primary);
  }

  .filecurrent__clear {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    color: var(--color-text-secondary);
    font-size: var(--text-13);
    cursor: pointer;
  }

  .filecurrent__clear input {
    inline-size: 16px;
    block-size: 16px;
    flex: none;
    accent-color: var(--color-danger);
    cursor: pointer;
  }

  /* Once it is ticked the file is going away, so say so rather than leaving the row
     looking unchanged until the form is saved. */
  .filecurrent:has(.filecurrent__clear input:checked) {
    border-color: var(--color-danger-border);
    background: var(--color-danger-bg);
  }

  .filecurrent:has(.filecurrent__clear input:checked) .filecurrent__thumb {
    opacity: 0.45;
  }

  /* No `line-through` here, however natural it would look: `panel.css` lives in the
     `page` layer and strips `text-decoration` from every link in the panel, and a later
     layer wins over any specificity in this one. Colour carries the state instead —
     together with the red chip and the faded thumbnail it is unmistakable. */
  .filecurrent:has(.filecurrent__clear input:checked) .filecurrent__name {
    color: var(--color-text-secondary);
  }

  .filecurrent:has(.filecurrent__clear input:checked) .filecurrent__clear {
    color: var(--color-danger-text);
    font-weight: var(--weight-medium);
  }

  .filedrop {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
  }

  /* The input keeps its place in the tab order — `display: none` would make the file
     picker unreachable by keyboard. It is visually hidden instead, and the zone below
     draws its focus ring. The `.field` dashed styles above are overridden here. */
  .filedrop input[type="file"] {
    position: absolute;
    inline-size: 1px;
    block-size: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip-path: inset(50%);
    border: 0;
    opacity: 0;
  }

  .filedrop__zone {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-4);
    border: 1px dashed var(--color-border-strong);
    border-radius: var(--radius-md);
    background: var(--color-surface);
    cursor: pointer;
    transition:
      border-color var(--duration-normal) var(--ease-out),
      background-color var(--duration-normal) var(--ease-out);
  }

  .filedrop__zone:hover {
    border-color: var(--color-primary);
    background: var(--color-primary-soft);
  }

  .filedrop input[type="file"]:focus-visible + .filedrop__zone {
    outline: 2px solid var(--color-focus);
    outline-offset: 2px;
  }

  .filedrop[data-dragging] .filedrop__zone {
    border-color: var(--color-primary);
    border-style: solid;
    background: var(--color-primary-soft);
  }

  .filedrop__icon {
    display: grid;
    flex: none;
    place-items: center;
    inline-size: 40px;
    block-size: 40px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    background: var(--color-bg);
    color: var(--color-primary);
    transition: transform var(--duration-normal) var(--ease-out);
  }

  .filedrop__zone:hover .filedrop__icon,
  .filedrop[data-dragging] .filedrop__icon {
    transform: translateY(-2px);
  }

  .filedrop__text {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-inline-size: 0;
  }

  .filedrop__title {
    font-size: var(--text-14);
    font-weight: var(--weight-semibold);
  }

  .filedrop__hint {
    color: var(--color-text-secondary);
    font-size: var(--text-12);
    line-height: var(--leading-snug);
  }

  .filedrop__list {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    margin: 0;
    padding: 0;
    list-style: none;
  }

  .filedrop__file {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-2) var(--space-3);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: var(--color-bg);
    animation: filedrop-in var(--duration-normal) var(--ease-out);
  }

  .filedrop__file > .icon {
    flex: none;
    color: var(--color-text-secondary);
  }

  .filedrop__name {
    flex: 1;
    min-inline-size: 0;
    overflow: hidden;
    font-size: var(--text-13);
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .filedrop__size {
    flex: none;
    color: var(--color-text-secondary);
    font-size: var(--text-12);
    font-variant-numeric: tabular-nums;
  }

  .filedrop__remove {
    flex: none;
  }

  @keyframes filedrop-in {
    from {
      opacity: 0;
      transform: translateY(-4px);
    }
  }

  /* ─── Directional nudge ───────────────────────────────────────────
     An arrow that moves the way it points, 3px, on hover. It is the cheapest piece of
     feedback on the page and the one people feel most: the control confirms where it
     is about to take them before they commit.

     The page is RTL, so a forward arrow (`arrow-left`) travels toward -X and a back
     chevron (`chevron-right`) toward +X. There is no logical-property equivalent of
     `translateX`, so the direction is read off the element's own computed direction —
     see the `[dir]`-independent note: the site ships RTL only (BRIEF §2), and these two
     rules are the only place in the stylesheet that assumes it. */
  :where(.section-heading__link, .bento__meta, .thread__file, .empty-state__actions .btn) .icon,
  .panel-back .icon,
  .account-back .icon {
    transition: transform var(--duration-normal) var(--ease-out);
  }

  @media (hover: hover) {
    /* Forward: arrow-left, moving further into the page. */
    .section-heading__link:hover .icon,
    .bento__link:hover .bento__meta .icon {
      transform: translateX(-3px);
    }

    /* Back: chevron-right, retreating the way it came. */
    .panel-back:hover .icon,
    .account-back:hover .icon {
      transform: translateX(3px);
    }
  }

  @media (prefers-reduced-motion: reduce) {
    .section-heading__link:hover .icon,
    .bento__link:hover .bento__meta .icon,
    .panel-back:hover .icon,
    .account-back:hover .icon {
      transform: none;
    }
  }
}
