/* =====================================================
   TehGuys Design-System Component Layer
   Reusable UI primitives built ONLY on theme.css tokens.
   No hardcoded colors or spacing — everything via var(--...).
   ===================================================== */

/* =====================================================
   Card — .ds-card + header / body / footer
   ===================================================== */
.ds-card {
  background: var(--bg-card);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  box-shadow: var(--shadow-card);
  color: var(--text-primary);
  transition: box-shadow var(--transition-base), border-color var(--transition-base);
}

.ds-card__header {
  font-weight: 600;
  font-size: var(--font-size-lg);
  color: var(--text-primary);
  margin-bottom: var(--space-md);
  padding-bottom: var(--space-md);
  border-bottom: 1px solid var(--border-dark);
}

.ds-card__body {
  color: var(--text-secondary);
  font-size: var(--font-size-base);
}
/* A body of stacked paragraphs: the card's padding is its edge, so the first
   and last paragraph add no margin of their own to it (the gaps between them
   stay). The element in the selector beats a spacing class on the paragraph. */
.ds-card__body--trim > p:first-child {
  margin-block-start: 0;
}
.ds-card__body--trim > p:last-child {
  margin-block-end: 0;
}

.ds-card__footer {
  margin-top: var(--space-md);
  padding-top: var(--space-md);
  border-top: 1px solid var(--border-dark);
  display: flex;
  gap: var(--space-sm);
  align-items: center;
}

/* Interactive card + display title. Moved here from
   frontend/src/styles/tokens.css in P0.2 — these two were defined ONLY in
   the island bundle and are consumed by frontend/src/components/ui/Card.tsx
   (`hover` prop and `CardTitle`), so they had to move rather than be
   dropped. Living here also makes them available to server templates. */
.ds-card--hover,
.ds-card--interactive {
  cursor: pointer;
  transition: transform 200ms ease, box-shadow 200ms ease;
}

.ds-card--hover:hover,
.ds-card--interactive:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-card-hover);
}

.ds-card__title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.125rem;
  line-height: 1.2;
}

/* =====================================================
   Contextual help — SSR counterpart of HintText/HintTooltip
   ===================================================== */
.help-hint,
.help-hint-tooltip {
  display: none;
}

html[data-help="on"] .help-hint {
  display: flex;
  align-items: flex-start;
  gap: var(--space-sm);
  margin: 0 0 var(--space-md);
  padding: var(--space-sm) var(--space-md);
  border: 1px solid var(--hint-strong);
  border-radius: var(--radius-md);
  background: var(--hint-pale);
  color: var(--hint-strong);
  font-size: var(--font-size-sm);
  line-height: var(--text-scale-body-leading);
}

.help-hint__icon {
  flex: 0 0 auto;
  width: 1.125rem;
  height: 1.125rem;
  margin-top: 0.1rem;
}

html[data-help="on"] .help-hint-tooltip {
  position: relative;
  display: inline-flex;
}

.help-hint-tooltip__trigger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  height: 1.5rem;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: var(--radius-full);
  background: transparent;
  color: var(--hint-strong);
  cursor: help;
}

.help-hint-tooltip__trigger > svg {
  width: 1.125rem;
  height: 1.125rem;
}

.help-hint-tooltip__trigger:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: var(--focus-ring-offset);
}

.help-hint-tooltip__content {
  position: absolute;
  z-index: var(--z-popover);
  bottom: calc(100% + var(--space-sm));
  left: 0;
  width: max-content;
  max-width: min(280px, calc(100vw - var(--space-xl)));
  padding: var(--space-sm) var(--space-md);
  border: 1px solid var(--hint-strong);
  border-radius: var(--radius-md);
  background: var(--hint-pale);
  color: var(--hint-strong);
  font-size: var(--font-size-sm);
  line-height: var(--text-scale-body-leading);
  opacity: 0;
  pointer-events: none;
  transform: translateY(2px);
  transition: opacity var(--transition-fast), transform var(--transition-fast);
}

.help-hint-tooltip:hover .help-hint-tooltip__content,
.help-hint-tooltip:focus-within .help-hint-tooltip__content,
.help-hint-tooltip[data-long-press-open="true"] .help-hint-tooltip__content {
  opacity: 1;
  transform: translateY(0);
}

/* React TooltipContent is portaled to document.body, so it cannot inherit the
   SSR wrapper's hover/focus state above. Radix owns its visibility state. */
.help-hint-tooltip__content--react {
  position: relative;
  bottom: auto;
  left: auto;
  width: auto;
  opacity: 1;
  pointer-events: auto;
  transform: none;
}

@media (pointer: coarse) {
  .help-hint-tooltip__trigger {
    width: 2.75rem;
    height: 2.75rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .help-hint-tooltip__content {
    transition: none;
  }
}

/* Variants (B1). Four of them, sharing ONE radius scale and ONE elevation
   scale, so a card never invents a corner or a shadow of its own:

     variant       radius        rest elevation   hover elevation
     default       --radius-lg   --shadow-card    -
     raised        --radius-lg   --shadow-lg      -
     inset         --radius-md   none             -
     interactive   --radius-lg   --shadow-card    --shadow-card-hover

   `inset` is the nested rung: it sits INSIDE another card, so it steps down
   one radius and drops its shadow. Two stacked elevations read as one
   blurred edge, and a nested corner larger than its parent's looks broken.

   .ds-card--hover is the older name for the same interactive treatment and
   is what frontend/src/components/ui/Card.tsx already emits for its `hover`
   prop. Both names carry identical declarations above rather than one
   aliasing the other, so the two stacks cannot drift. New call sites use
   --interactive; --hover is kept only so the React prop keeps working.

   Whole-card click targets must not nest another interactive target - see
   templates/includes/_card.html for why. The focus ring below is not
   decoration: when the card IS the control there is no inner button to
   borrow an indicator from, so this rule is the only thing a keyboard user
   sees. */
.ds-card--raised {
  box-shadow: var(--shadow-lg);
}

.ds-card--inset {
  border-radius: var(--radius-md);
  border-color: var(--border-light);
  background: var(--surface-light);
  box-shadow: none;
}

.ds-card--interactive {
  display: block;
  color: inherit;
  text-decoration: none;
}

.ds-card--interactive:focus-visible {
  outline: 2px solid var(--focus-ring, #1E8F4E);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  .ds-card {
    transition: none;
  }

  .ds-card--hover,
  .ds-card--interactive {
    transition: none;
  }

  .ds-card--hover:hover,
  .ds-card--interactive:hover {
    transform: none;
  }
}

/* =====================================================
   Button — .ds-btn + variants + sizes + states
   ===================================================== */
.ds-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-lg);
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  font-family: var(--font-family);
  font-size: var(--font-size-sm);
  font-weight: 600;
  line-height: 1.2;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  -webkit-appearance: none;
  appearance: none;
  transition: background var(--transition-fast), border-color var(--transition-fast),
    color var(--transition-fast), box-shadow var(--transition-fast);
}

.ds-btn:focus-visible {
  outline: 2px solid var(--focus-ring, #1E8F4E);
  outline-offset: var(--focus-ring-offset, 2px);
  box-shadow: 0 0 0 3px var(--accent-blue-glow);
}

.ds-btn:disabled,
.ds-btn[aria-disabled="true"] {
  opacity: 0.55;
  cursor: not-allowed;
  pointer-events: none;
}

/* Sizes */
.ds-btn--sm {
  padding: var(--space-xs) var(--space-md);
  font-size: var(--font-size-xs);
  border-radius: var(--radius-sm);
}

.ds-btn--lg {
  padding: var(--space-md) var(--space-xl);
  font-size: var(--font-size-base);
  border-radius: var(--radius-lg);
}

/* Variants */
.ds-btn--primary {
  background: var(--accent-blue);
  /* Ink on light accents (Electric Green); white on dark accents (Indigo /
     Dark Purple). Per-palette --accent-contrast keeps the label readable. */
  color: var(--accent-contrast, #0E2233);
  border-color: var(--accent-blue);
}

.ds-btn--primary:hover {
  background: var(--accent-blue-hover);
  border-color: var(--accent-blue-hover);
  color: var(--accent-contrast, #0E2233);
}

.ds-btn--secondary {
  background: var(--surface-light);
  color: var(--text-primary);
  border-color: var(--border-medium);
}

.ds-btn--secondary:hover {
  background: var(--surface-highlight);
  border-color: var(--border-strong);
  color: var(--text-primary);
}

.ds-btn--ghost {
  background: rgba(83, 232, 103, 0.04);
  color: var(--text-secondary);
  border-color: var(--border-medium);
}

.ds-btn--ghost:hover {
  background: var(--surface-light);
  color: var(--text-primary);
  border-color: var(--border-strong);
}

.ds-btn--danger {
  background: var(--accent-red);
  color: #fff;
  border-color: var(--accent-red);
}

.ds-btn--danger:hover {
  background: var(--accent-red);
  border-color: var(--accent-red);
  color: #fff;
  filter: brightness(0.92);
}

/* Accent (craft pink) — used for the profile Message button so it stays
   visually distinct from the indigo primary Subscribe button beside it. */
.ds-btn--accent {
  background: var(--craft-pink);
  color: #fff;
  border-color: var(--craft-pink);
}

.ds-btn--accent:hover {
  background: var(--craft-pink);
  border-color: var(--craft-pink);
  color: #fff;
  filter: brightness(0.94);
}

/* ── Alert (token-styled message box) ──────────────────────────────────── */
.ds-alert {
  display: flex;
  gap: var(--space-sm);
  align-items: flex-start;
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-medium);
  background: var(--surface-light);
  color: var(--text-secondary);
  font-size: 0.9rem;
}
.ds-alert--info {
  border-color: var(--craft-indigo);
  background: var(--craft-indigo-tint);
  color: var(--craft-green-text);
}
.ds-alert--success {
  border-color: var(--accent-green);
  background: color-mix(in srgb, var(--accent-green) 10%, transparent);
  color: var(--accent-green);
}
.ds-alert--warning {
  border-color: var(--accent-yellow);
  background: color-mix(in srgb, var(--accent-yellow) 12%, transparent);
  color: var(--text-primary);
}
.ds-alert--danger {
  border-color: var(--accent-red);
  background: var(--craft-pink-tint);
  color: var(--status-danger-text);
}
/* An alert that follows other content (a form widget): a step of space above. */
.ds-alert--spaced {
  margin-block-start: var(--space-sm);
}
/* A leading icon keeps its size however long the text beside it runs. */
.ds-alert > .icon {
  flex-shrink: 0;
}
/* The quieter second line of an alert: on its own line, a step below. */
.ds-alert__detail {
  display: block;
  margin-block-start: var(--space-sm);
}

/* ── Site banners (templates/includes/_site_banners.html) ──────────────────
   Staff-written texts on top of the page content: the permanent announcement
   bar and the instruction card. Both are a .ds-alert; these rules only place
   them and lay out the card's button and close control. */
.site-banner {
  margin-block-end: var(--space-md);
  color: var(--text-primary);
}
/* The class sets display: flex, which would beat the hidden attribute. */
.site-banner[hidden] {
  display: none;
}
/* The home feed's "Vote" links land on one poll of an activity: stop below
   the top bar and the sticky Join and Share row. */
#activity-polls,
details[data-poll] {
  scroll-margin-block-start: 9rem;
}
/* The sign-in and profile pages have no padding of their own around the
   content (theme.css releases it for .auth-wrapper and .prof-page): keep the
   bar and the card off the screen edges there. */
.main-content:has(.auth-wrapper) > .site-banner,
.main-content:has(.prof-page) > .site-banner {
  margin: var(--space-md) var(--space-md) 0;
}
/* A very small screen has no room for the permanent bar: on a 320 by 568
   phone the reply box of a thread, of the message centre and of the forum
   would start under the floating row (owner, 2026-11-28). The instruction
   card stays: it can be closed. */
@media (max-width: 359.98px), (max-width: 1023.98px) and (max-height: 599.98px) {
  .site-banner[data-site-announcement] {
    display: none;
  }
}
.site-banner__text {
  margin: 0;
  min-inline-size: 0;
  overflow-wrap: anywhere;
}
.site-banner__body {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-sm);
  min-inline-size: 0;
}
/* The close control is a shared icon button; this only tucks it into the
   card's corner. */
.site-banner__close {
  flex: none;
  margin-block: calc(var(--space-sm) * -1);
  margin-inline-end: calc(var(--space-sm) * -1);
}

/* ── Tabs (token-styled tab row) ───────────────────────────────────────── */
.ds-tabs {
  display: flex;
  gap: var(--space-xs);
  border-bottom: 2px solid var(--border-dark);
  overflow-x: auto;
  scrollbar-width: none;
}
.ds-tabs::-webkit-scrollbar {
  display: none;
}
.ds-tab {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-sm) var(--space-md);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none;
  transition: color 0.15s, border-color 0.15s;
}
.ds-tab:hover {
  color: var(--text-primary);
}
.ds-tab.is-active,
.ds-tab[aria-selected="true"] {
  color: var(--craft-green-text);
  border-bottom-color: var(--craft-indigo);
  font-weight: 600;
}

/* Mobile touch-target floor, same rule the button contract holds (C3). A tab
   is a control people tap, and this one had no min-height at all: measured in
   a browser at 390px, all nine .ds-tab elements came out 34px tall - 8px of
   padding either side of a 14.4px line box - which is 10px under the 44px
   floor (WCAG 2.5.5 / 2.5.8). Both axes are set, because a floor on one axis
   only is the exact half-fix the sm button carried above.
   Deliberately NOT applied at desktop widths: a pointer is precise, the row
   scrolls horizontally, and 44px tall tabs would push the content of every
   tabbed page down by a third of a row for no accessibility gain. */
@media (max-width: 639px) {
  .ds-tab {
    min-height: 44px;
    min-width: 44px;
    justify-content: center;
  }
}

@media (prefers-reduced-motion: reduce) {
  .ds-btn {
    transition: none;
  }
}

/* =====================================================
   Field — .ds-field (label, input, help, error)
   ===================================================== */
.ds-field {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

/* Stacked fields get their own rhythm: the label is nearer its own control
   (the 4px gap above) than the field before it. One rule here, not a margin
   in every form's stylesheet. Scoped to fields that are direct children of a
   <form> (block flow, where it collapses with a page's own margin): a flex or
   grid wrapper such as SchemaForm's .ds-form owns its gap and must not get a
   second one. */
form > .ds-field + .ds-field {
  margin-top: var(--space-md);
}

.ds-field__label {
  font-size: var(--font-size-sm);
  font-weight: 500;
  color: var(--text-secondary);
}

/* Required / optional marker inside the label (B2). The `required` ATTRIBUTE
   on the input is what assistive tech announces, so the visual asterisk is
   aria-hidden and colour is never the only cue; "(optional)" has no
   equivalent attribute and is therefore plain readable text. */
.ds-field__marker {
  margin-left: 0.25ch;
  color: var(--text-muted);
  font-weight: 400;
}

.ds-field__input {
  width: 100%;
  padding: var(--space-md);
  background: var(--bg-input);
  color: var(--text-primary);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  font-family: var(--font-family);
  font-size: var(--font-size-base);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.ds-field__input::placeholder {
  color: var(--text-placeholder);
}

.ds-field__input:focus {
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 3px var(--accent-blue-glow);
}

.ds-field__input:focus-visible {
  outline: 2px solid var(--focus-ring, #1E8F4E);
  outline-offset: var(--focus-ring-offset, 2px);
}

.ds-field__help {
  font-size: var(--font-size-xs);
  color: var(--text-muted);
}

.ds-field__error {
  font-size: var(--font-size-xs);
  color: var(--status-danger-text);
  font-weight: 500;
}

/* Invalid state */
.ds-field--invalid .ds-field__input {
  border-color: var(--accent-red);
}

.ds-field--invalid .ds-field__input:focus,
.ds-field--invalid .ds-field__input:focus-visible {
  box-shadow: 0 0 0 3px var(--accent-blue-glow);
  border-color: var(--accent-red);
}

@media (prefers-reduced-motion: reduce) {
  .ds-field__input {
    transition: none;
  }
}

/* =====================================================
   Toggle switch — .toggle-switch > input + .toggle-slider
   A hidden checkbox or radio drives a track-and-thumb switch. Moved here
   from templates/users/settings.html (47.M); the community edit page uses
   the same markup and still restyles the colours in its own template.
   The two track greys are literals carried over unchanged - --switch-track-off
   is a different colour, so adopting it would be a visual change.
   ===================================================== */
.toggle-switch {
  position: relative;
  display: inline-block;
  flex-shrink: 0;
  width: 44px;
  height: 24px;
}

/* The [type="checkbox"] selector is load-bearing: it outranks
   .form-check-input:checked (theme.css, and social_platform.css which loads
   after this file), which would otherwise paint the hidden input once checked.
   No !important is needed - nothing else styles these inputs with it. */
.toggle-switch input,
.toggle-switch input[type="checkbox"],
.toggle-switch .form-check-input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
  pointer-events: none;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  margin: 0;
  padding: 0;
  border: none;
  background: transparent;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--toggle-track-bg, #a0a0a0);
  border-radius: 24px;
  /* Only the track colour animates. `0.3s` alone is `all`, which would also
     fade the focus ring in (and delay its outline-style flip by 150ms). */
  transition: background 0.3s;
}

body.dark-mode .toggle-slider {
  --toggle-track-bg: #404040;
}

.toggle-slider::before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background: var(--bg-card);
  border-radius: 50%;
  transition: 0.3s;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.toggle-switch input:checked + .toggle-slider {
  background: var(--accent-blue);
}

.toggle-switch input:checked + .toggle-slider::before {
  transform: translateX(20px);
}

/* The input that takes keyboard focus is 0x0 and invisible, so the ring is
   painted on the visible slider instead (WCAG 2.4.7). */
.toggle-switch input:focus-visible + .toggle-slider {
  outline: 2px solid var(--focus-ring, #1E8F4E);
  outline-offset: var(--focus-ring-offset, 2px);
}

/* =====================================================
   Empty state — .ds-empty (icon, title, subtitle, action)
   ===================================================== */
.ds-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: var(--space-md);
  padding: var(--space-2xl) var(--space-lg);
  color: var(--text-secondary);
}

.ds-empty__icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: var(--avatar-lg);
  height: var(--avatar-lg);
  border-radius: var(--radius-full);
  background: var(--surface-light);
  color: var(--text-muted);
  font-size: var(--font-size-4xl);
}

.ds-empty__title {
  font-size: var(--font-size-xl);
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
}

.ds-empty__subtitle {
  font-size: var(--font-size-sm);
  color: var(--text-muted);
  max-width: 40ch;
  margin: 0;
}

.ds-empty__action {
  margin-top: var(--space-sm);
}

/* State variants (B3). Empty, loading and error are the same surface, not
   three unrelated blocks: a list that swaps between a skeleton, a red panel
   and a centred illustration as its data resolves reads as three different
   pages. Only the icon treatment changes here; the live-region role and the
   next action are set in templates/includes/_empty_state.html.

   The spinner reuses the button contract's btn-spin keyframes rather than
   declaring a second identical rotation - one spin definition, so the two
   spinners cannot drift apart or be silenced separately. */
.ds-empty--error .ds-empty__icon {
  color: var(--accent-red);
}

.ds-empty__spinner {
  width: 28px;
  height: 28px;
  border: 3px solid var(--border-medium);
  border-top-color: var(--craft-indigo);
  border-radius: var(--radius-full);
  animation: btn-spin 0.8s linear infinite;
}

@media (prefers-reduced-motion: reduce) {
  .ds-empty__spinner {
    animation: none;
    opacity: 0.6;
  }
}

/* =====================================================
   Avatar — .ds-avatar (sizes sm/md/lg, circle, fallback)
   ===================================================== */
.ds-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--avatar-md);
  height: var(--avatar-md);
  border-radius: var(--radius-full);
  background: var(--gradient-primary);
  color: var(--accent-contrast, #0E2233);
  font-weight: 600;
  font-size: var(--font-size-base);
  overflow: hidden;
  flex-shrink: 0;
  text-transform: uppercase;
  line-height: 1;
}

.ds-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
}

.ds-avatar--sm {
  width: var(--avatar-sm);
  height: var(--avatar-sm);
  font-size: var(--font-size-sm);
}

.ds-avatar--lg {
  width: var(--avatar-lg);
  height: var(--avatar-lg);
  font-size: var(--font-size-3xl);
}

/* =====================================================
   Badge — .ds-badge (default/success/warning/danger + dot)
   ===================================================== */
.ds-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-xs) var(--space-sm);
  border-radius: var(--radius-full);
  font-size: var(--font-size-xs);
  font-weight: 600;
  line-height: 1;
  background: var(--surface-light);
  color: var(--text-secondary);
  border: 1px solid var(--border-medium);
}

.ds-badge--success {
  background: var(--status-success-fill);
  color: var(--status-success-on-fill);
  border-color: var(--status-success-fill);
}

.ds-badge--warning {
  background: var(--status-warning-fill);
  color: var(--status-warning-on-fill);
  border-color: var(--status-warning-fill);
}

.ds-badge--danger {
  background: var(--accent-red);
  color: #fff;
  border-color: var(--accent-red);
}

/* Leading status dot */
.ds-badge__dot {
  display: inline-block;
  width: var(--space-sm);
  height: var(--space-sm);
  border-radius: var(--radius-full);
  background: currentColor;
}

/* Craft-palette variants (moved here from frontend/src/styles/tokens.css in
   P0.2 — they previously shipped only inside the island bundle, so they had
   no effect on any server-rendered page that mounted no island). */
/* Text is --text-primary, not the accent colour, on all three craft-tint
   badges. Accent-on-its-own-tint fails WCAG AA (4.5:1) at this size and
   weight: indigo measured 3.92:1 on --bg-card and 3.15:1 in dark mode,
   pink 4.11:1 / 3.17:1, and orange 1.93:1 — effectively illegible. The
   tint and border already carry the categorical signal, so the label does
   not need to repeat it in colour, and --text-primary is per-palette so
   this holds across all 14 themes rather than only the default one.
   These badges became reachable from server templates in P0.2 and the
   disclosure partial exposes badge_variant as a public knob, so the
   pre-existing values would otherwise have propagated. */
.ds-badge--indigo {
  background: var(--craft-indigo-tint);
  color: var(--text-primary);
  border: 1px solid color-mix(in srgb, var(--craft-indigo) 20%, transparent);
}

.ds-badge--pink {
  background: var(--craft-pink-tint);
  color: var(--text-primary);
  border: 1px solid rgba(236, 72, 153, 0.20);
}

.ds-badge--orange {
  background: var(--craft-orange-tint);
  color: var(--text-primary);
  border: 1px solid rgba(249, 115, 22, 0.20);
}

/* Event-type variants (mirror of eventColors in frontend/src/tokens.ts) */
.ds-badge--sports {
  background: #fff7ed;
  color: #c2410c;
  border: 1px solid #fed7aa;
}

.ds-badge--arts {
  background: #f5f3ff;
  color: #7c3aed;
  border: 1px solid #ddd6fe;
}

.ds-badge--social {
  background: #fdf2f8;
  color: #be185d;
  border: 1px solid #fbcfe8;
}

.ds-badge--outdoor {
  background: #f0fdf4;
  color: #15803d;
  border: 1px solid #bbf7d0;
}

.ds-badge--food {
  background: #fffbeb;
  color: #b45309;
  border: 1px solid #fde68a;
}

.ds-badge--other {
  background: #f8fafc;
  color: #475569;
  border: 1px solid #e2e8f0;
}

/* =====================================================
   Button variant — Warning (.ds-btn--warning)
   Amber/orange surface; dark text for WCAG contrast.
   Mirrors .btn-warning in social_platform.css.
   ===================================================== */
.ds-btn--warning {
  background: var(--accent-yellow);
  color: var(--text-primary);
  border-color: var(--accent-yellow);
}

.ds-btn--warning:hover {
  background: var(--craft-orange);
  border-color: var(--craft-orange);
  color: var(--text-primary);
  filter: brightness(0.97);
}

/* =====================================================
   Modal — .ds-modal system
   Mirrors Bootstrap .modal-content / .modal-header /
   .modal-body / .modal-footer look from social_platform.css.
   ===================================================== */
.ds-modal__overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  /* Hidden by default; shown by JS via .is-open / [data-open] / .show, or kept
     visible in static demos by adding one of those. The [hidden] attribute
     (used by some templates' onclick toggles) always wins. */
  display: none;
  align-items: center;
  justify-content: center;
  z-index: var(--z-modal);
  padding: var(--space-md);
}
.ds-modal__overlay.is-open,
.ds-modal__overlay[data-open],
.ds-modal__overlay.show {
  display: flex;
}
.ds-modal__overlay[hidden] {
  display: none;
}

.ds-modal {
  background: var(--bg-card);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  width: 100%;
  max-width: 540px;
  max-height: 90vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  color: var(--text-primary);
}

.ds-modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-lg) var(--space-xl);
  border-bottom: 1px solid var(--border-dark);
  font-weight: 600;
  font-size: var(--font-size-lg);
  color: var(--text-primary);
  flex-shrink: 0;
}

.ds-modal__title {
  margin: 0;
  font-family: var(--font-display);
  font-size: var(--font-size-lg);
  font-weight: 700;
  color: var(--text-primary);
}

.ds-modal__body {
  padding: var(--space-xl);
  color: var(--text-primary);
  flex: 1;
}

.ds-modal__footer {
  padding: var(--space-md) var(--space-xl);
  border-top: 1px solid var(--border-dark);
  display: flex;
  gap: var(--space-sm);
  justify-content: flex-end;
  flex-shrink: 0;
}

.ds-modal__close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: var(--font-size-lg);
  line-height: 1;
  transition: background var(--transition-fast), color var(--transition-fast);
  flex-shrink: 0;
}

.ds-modal__close:hover {
  background: var(--surface-light);
  color: var(--text-primary);
}

.ds-modal__close:focus-visible,
.ds-dialog__close:focus-visible {
  outline: 2px solid var(--focus-ring, #1E8F4E);
  outline-offset: var(--focus-ring-offset, 2px);
}

.ds-dropdown__item:focus-visible {
  outline: 2px solid var(--focus-ring, #1E8F4E);
  outline-offset: -2px;
}

/* Starts below the header at every width: at the old `top: var(--space-md)` the
   toast covered the whole mobile header and the desktop bar's controls. */
.alert-toast-host {
  position: fixed;
  top: var(--topbar-clearance, 88px);
  inset-inline-end: var(--space-md);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  width: min(24rem, calc(100vw - 2 * var(--space-md)));
  pointer-events: none;
}

.alert-toast-host > * {
  pointer-events: auto;
}

/* =====================================================
   Dropdown — .ds-dropdown system
   Mirrors .dropdown-menu / .dropdown-item from theme.css.
   ===================================================== */
.ds-dropdown {
  position: relative;
  display: inline-block;
}

.ds-dropdown__menu {
  position: absolute;
  top: calc(100% + var(--space-xs));
  left: 0;
  min-width: 180px;
  background: var(--bg-card);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: var(--space-xs);
  z-index: var(--z-dropdown);
  display: none;
}

.ds-dropdown__menu.is-open,
.ds-dropdown__menu[data-open] {
  display: block;
}

.ds-dropdown__item {
  display: block;
  width: 100%;
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-sm);
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: var(--font-size-sm);
  font-family: var(--font-family);
  text-align: left;
  text-decoration: none;
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast);
  white-space: nowrap;
}

.ds-dropdown__item:hover,
.ds-dropdown__item:focus {
  background: var(--surface-light);
  color: var(--text-primary);
}

/* =====================================================
   List — .ds-list system
   Mirrors Bootstrap .list-group / .list-group-item
   and the social_platform.css overrides.
   ===================================================== */
.ds-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
}

.ds-list__item {
  background: var(--bg-card);
  border: 1px solid var(--border-medium);
  color: var(--text-primary);
  padding: var(--space-md) var(--space-lg);
  margin-top: -1px; /* collapse adjacent borders */
}

.ds-list__item:first-child {
  border-radius: var(--radius-md) var(--radius-md) 0 0;
  margin-top: 0;
}

.ds-list__item:last-child {
  border-radius: 0 0 var(--radius-md) var(--radius-md);
}

.ds-list__item:only-child {
  border-radius: var(--radius-md);
}

.ds-list__item--action {
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast);
  text-decoration: none;
  display: block;
}

.ds-list__item--action:hover {
  background: var(--surface-light);
  color: var(--text-primary);
}

/* =====================================================
   Table — .ds-table system
   Mirrors .table / .table thead th / .table tbody td
   from social_platform.css.
   ===================================================== */
.ds-table {
  width: 100%;
  border-collapse: collapse;
  color: var(--text-primary);
  font-size: var(--font-size-base);
}

.ds-table th {
  background: var(--surface-dark);
  border-bottom: 1px solid var(--border-medium);
  color: var(--text-secondary);
  font-weight: 600;
  padding: var(--space-md) var(--space-lg);
  text-align: left;
}

.ds-table td {
  border-bottom: 1px solid var(--border-medium);
  padding: var(--space-md) var(--space-lg);
  vertical-align: middle;
  color: var(--text-primary);
}

.ds-table tbody tr:last-child td {
  border-bottom: none;
}

/* Striped variant — alternating row bg-surface-light */
.ds-table--striped tbody tr:nth-child(even) {
  background: var(--surface-light);
}

/* =====================================================
   Responsive 12-column grid — .ds-row / .ds-col-*
   Pixel-equivalent to Bootstrap's .row / .col-* grid
   (same breakpoints, same 12-col %, same gutter math).
   .ds-col-{n} → {n}/12 * 100%
   .ds-col-{bp}-{n} → responsive variant
   .ds-g-{0..5} → gutter steps (mirrors Bootstrap g-*)
   ===================================================== */
/* Base gutter size (mirrors Bootstrap $grid-gutter-width = 1.5rem → ±0.75rem) */
:root {
  --ds-gutter: 0.75rem;
}

/* Centered page container (mirrors Bootstrap .container) */
.ds-container {
  width: 100%;
  max-width: var(--content-max-width, 1400px);
  margin-inline: auto;
  padding-inline: var(--container-pad, clamp(16px, 4vw, 48px));
}
.ds-container--fluid {
  max-width: none;
}

.ds-row {
  display: flex;
  flex-wrap: wrap;
  margin-inline: calc(-1 * var(--ds-gutter));
}

.ds-row > * {
  box-sizing: border-box;
  padding-inline: var(--ds-gutter);
  width: 100%;
}

.ds-col   { flex: 1 0 0%; }

/* --- Fixed-width columns (mobile-first: all apply at any width) --- */
.ds-col-1  { width:  8.3333%; }
.ds-col-2  { width: 16.6667%; }
.ds-col-3  { width: 25%; }
.ds-col-4  { width: 33.3333%; }
.ds-col-5  { width: 41.6667%; }
.ds-col-6  { width: 50%; }
.ds-col-7  { width: 58.3333%; }
.ds-col-8  { width: 66.6667%; }
.ds-col-9  { width: 75%; }
.ds-col-10 { width: 83.3333%; }
.ds-col-11 { width: 91.6667%; }
.ds-col-12 { width: 100%; }

/* --- sm breakpoint (≥576px) --- */
@media (min-width: 576px) {
  .ds-col-sm-1  { width:  8.3333%; }
  .ds-col-sm-2  { width: 16.6667%; }
  .ds-col-sm-3  { width: 25%; }
  .ds-col-sm-4  { width: 33.3333%; }
  .ds-col-sm-5  { width: 41.6667%; }
  .ds-col-sm-6  { width: 50%; }
  .ds-col-sm-7  { width: 58.3333%; }
  .ds-col-sm-8  { width: 66.6667%; }
  .ds-col-sm-9  { width: 75%; }
  .ds-col-sm-10 { width: 83.3333%; }
  .ds-col-sm-11 { width: 91.6667%; }
  .ds-col-sm-12 { width: 100%; }
}

/* --- md breakpoint (≥768px) --- */
@media (min-width: 768px) {
  .ds-col-md-1  { width:  8.3333%; }
  .ds-col-md-2  { width: 16.6667%; }
  .ds-col-md-3  { width: 25%; }
  .ds-col-md-4  { width: 33.3333%; }
  .ds-col-md-5  { width: 41.6667%; }
  .ds-col-md-6  { width: 50%; }
  .ds-col-md-7  { width: 58.3333%; }
  .ds-col-md-8  { width: 66.6667%; }
  .ds-col-md-9  { width: 75%; }
  .ds-col-md-10 { width: 83.3333%; }
  .ds-col-md-11 { width: 91.6667%; }
  .ds-col-md-12 { width: 100%; }
}

/* --- lg breakpoint (≥992px) --- */
@media (min-width: 992px) {
  .ds-col-lg-1  { width:  8.3333%; }
  .ds-col-lg-2  { width: 16.6667%; }
  .ds-col-lg-3  { width: 25%; }
  .ds-col-lg-4  { width: 33.3333%; }
  .ds-col-lg-5  { width: 41.6667%; }
  .ds-col-lg-6  { width: 50%; }
  .ds-col-lg-7  { width: 58.3333%; }
  .ds-col-lg-8  { width: 66.6667%; }
  .ds-col-lg-9  { width: 75%; }
  .ds-col-lg-10 { width: 83.3333%; }
  .ds-col-lg-11 { width: 91.6667%; }
  .ds-col-lg-12 { width: 100%; }
}

/* --- xl breakpoint (≥1200px) --- */
@media (min-width: 1200px) {
  .ds-col-xl-1  { width:  8.3333%; }
  .ds-col-xl-2  { width: 16.6667%; }
  .ds-col-xl-3  { width: 25%; }
  .ds-col-xl-4  { width: 33.3333%; }
  .ds-col-xl-5  { width: 41.6667%; }
  .ds-col-xl-6  { width: 50%; }
  .ds-col-xl-7  { width: 58.3333%; }
  .ds-col-xl-8  { width: 66.6667%; }
  .ds-col-xl-9  { width: 75%; }
  .ds-col-xl-10 { width: 83.3333%; }
  .ds-col-xl-11 { width: 91.6667%; }
  .ds-col-xl-12 { width: 100%; }
}

/* --- Gutter utilities (mirrors Bootstrap g-0..g-5) --- */
/* g-0: no gutters */
.ds-row.ds-g-0 { margin-inline: 0; }
.ds-row.ds-g-0 > * { padding-inline: 0; }

/* g-1: 0.25rem each side → 0.5rem column gap */
.ds-row.ds-g-1 { margin-inline: -0.125rem; row-gap: 0.25rem; }
.ds-row.ds-g-1 > * { padding-inline: 0.125rem; }

/* g-2: 0.25rem each side → 0.5rem column gap (Bootstrap step) */
.ds-row.ds-g-2 { margin-inline: -0.25rem; row-gap: 0.5rem; }
.ds-row.ds-g-2 > * { padding-inline: 0.25rem; }

/* g-3: 0.5rem each side → 1rem column gap */
.ds-row.ds-g-3 { margin-inline: -0.5rem; row-gap: 1rem; }
.ds-row.ds-g-3 > * { padding-inline: 0.5rem; }

/* g-4: 0.75rem each side → 1.5rem column gap */
.ds-row.ds-g-4 { margin-inline: -0.75rem; row-gap: 1.5rem; }
.ds-row.ds-g-4 > * { padding-inline: 0.75rem; }

/* g-5: 1.5rem each side → 3rem column gap */
.ds-row.ds-g-5 { margin-inline: -1.5rem; row-gap: 3rem; }
.ds-row.ds-g-5 > * { padding-inline: 1.5rem; }

/* =====================================================
   Button contract — [data-btn] (moved here in P1.1)

   Canonical, shared by BOTH rendering stacks. Previously lived in
   frontend/src/styles/tokens.css, which ships inside the island
   bundle — so server-rendered markup could not use it, and in dev
   mode django-vite injects that CSS via the HMR client, meaning any
   server-rendered button styled from there would render unstyled
   until JS executed. components.css ships as a plain <link> on every
   page (base.html:51), so it is the correct owner.

   Server templates emit this contract via templates/includes/_button.html;
   islands emit it via frontend/src/components/ui/Button.tsx. The legacy
   .ds-btn class system above is FROZEN — no new variants, no new call
   sites — and is being drained per page family. scripts/
   check_component_ownership.py ratchets it down and forbids redefining
   any of this in the bundle.
   ===================================================== */
/* ── Button system ([data-btn]) ──────────────────────────────────────────── */
[data-btn] {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: inherit;
  font-weight: 600;
  border-radius: var(--radius-full);
  border: 1px solid transparent;
  line-height: 1;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  user-select: none;
  transition: background 150ms ease, color 150ms ease, border-color 150ms ease,
              box-shadow 150ms ease, filter 150ms ease, transform 150ms ease,
              opacity 150ms ease;
}

[data-btn]:focus-visible,
[data-chip]:focus-visible {
  outline: 2px solid var(--focus-ring, #1E8F4E);
  outline-offset: var(--focus-ring-offset, 2px);
}

[data-btn]:not(:disabled):not([data-loading]):active {
  transform: scale(0.97);
}

/* aria-disabled covers disabled LINKS. An <a> cannot carry a real `disabled`
   attribute — browsers ignore it and :disabled never matches — so a disabled
   navigation action would otherwise stay fully styled and clickable. Both
   templates/includes/_button.html and Button.tsx with asChild can produce
   this case. */
[data-btn]:disabled,
[data-btn][aria-disabled="true"],
[data-btn][data-loading] {
  opacity: 0.5;
  pointer-events: none;
  cursor: not-allowed;
}

[data-btn][data-full-width] { width: 100%; }

/* ── sizes: three input densities ────────────────────────────────────────────

   Density is a property of the POINTER, not of the viewport. A single 44px
   floor for every device applied a touch ergonomic to mouse users: it made
   every control ~26% taller than the .ds-btn it replaced (34.8px -> 44px)
   without buying any conformance, because the AA requirement (WCAG 2.5.8
   Target Size (Minimum)) is 24x24 CSS px. 44x44 is 2.5.5 (Enhanced, AAA) and
   is authored for fingers. So the floor is kept where a finger is the input
   and relaxed where a cursor is.

   `max-width` was the wrong axis to branch on: it shrinks a windowed desktop
   and misses tablets entirely. `pointer:` asks the question actually meant.

   Phone   — base, below. Also the fallback for any device matching NO query
             (a pointer-less or unreported input gets the safest target).
   Tablet  — a fingertip is ~10mm regardless of screen size, so md/lg/icon KEEP
             the 44px tap floor. Only horizontal rhythm tightens, which is what
             the extra width is actually for.
   Desktop — cursor precision; heights come down to the pre-migration density.

   `sm` carries min-width as well as min-height wherever it is a touch target:
   min-height ALONE does not make a target 44x44, it makes it 44 tall and as
   wide as its label. At 375px a two-letter label measured 39px ("Hi") and a
   one-character one 33px ("+"), against a floor that is 44 in BOTH axes. The
   flex centring already on [data-btn] keeps the label centred in the wider box.
   The desktop block must therefore release min-width, not just min-height. */

/* Phone (base) */
[data-btn][data-size="sm"]   { min-height: 44px; min-width: 44px; padding: 0 14px; gap: 6px;  font-size: 13px; }
/* Raw `data-btn` markup (islands that don't go through <Button>) omits
   data-size — without a size rule those buttons get no padding/min-height at
   all and collapse to the line box. Default them to the md size. */
[data-btn][data-size="md"],
[data-btn]:not([data-size])  { min-height: 44px; padding: 0 20px; gap: 8px;  font-size: 14px; }
[data-btn][data-size="lg"]   { min-height: 48px; padding: 0 28px; gap: 10px; font-size: 16px; }
[data-btn][data-size="icon"] { width: 44px; height: 44px; padding: 0; font-size: 14px; }

/* Tablet: touch, with room to breathe horizontally. Tap floor unchanged. */
@media (pointer: coarse) and (min-width: 768px) {
  [data-btn][data-size="sm"]   { min-height: 40px; min-width: 40px; padding: 0 12px; }
  [data-btn][data-size="md"],
  [data-btn]:not([data-size])  { padding: 0 16px; gap: 6px; }
  [data-btn][data-size="lg"]   { min-height: 46px; padding: 0 24px; gap: 8px; }
}

/* Desktop: cursor input. Restores the density the .ds-btn system had, while
   staying far above the 24x24 AA floor. */
@media (pointer: fine) {
  [data-btn][data-size="sm"]   { min-height: 30px; min-width: 0; padding: 0 12px; }
  [data-btn][data-size="md"],
  [data-btn]:not([data-size])  { min-height: 36px; padding: 0 18px; }
  [data-btn][data-size="lg"]   { min-height: 42px; padding: 0 24px; gap: 8px; }
  [data-btn][data-size="icon"] { width: 36px; height: 36px; }
}

/* variants */
[data-btn][data-variant="primary"] {
  background: var(--craft-indigo);
  /* Ink fallback, not white: Electric Green is a LIGHT accent, so white lands at
     ~1.6:1. themes.css flips this to white for the dark indigo/purple palettes. */
  color: var(--accent-contrast, #0E2233);
  box-shadow: var(--shadow-tinted-sm);
}
[data-btn][data-variant="primary"]:not(:disabled):hover {
  background: var(--craft-indigo-hover);
  box-shadow: var(--shadow-tinted-md);
}

/* Secondary is the NEUTRAL treatment, matching .ds-btn--secondary (P1.2).
   Decided deliberately: .ds-btn--secondary is the single most-used variant
   in the codebase (139 of the 749 server call sites) and renders as a
   neutral sand chip. The bundle's version rendered as a green-outlined
   button instead. Converging on the neutral treatment means the eventual
   migration of those 749 call sites changes radius, height and focus ring
   but NOT colour on the most common variant — which is what makes that
   migration reviewable. It also reads as genuinely secondary next to the
   Electric Green primary, where a green outline competed with it.
   Callers that specifically want the emphasised outlined look should use
   variant="outline", which keeps that treatment. */
[data-btn][data-variant="secondary"] {
  background: var(--surface-light);
  border-color: var(--border-medium);
  color: var(--text-primary);
}
[data-btn][data-variant="secondary"]:not(:disabled):hover {
  background: var(--surface-highlight);
  border-color: var(--border-strong);
}

[data-btn][data-variant="ghost"] {
  background: transparent;
  color: var(--craft-green-text);
}
[data-btn][data-variant="ghost"]:not(:disabled):hover { background: var(--craft-indigo-tint); }

[data-btn][data-variant="outline"] {
  background: transparent;
  border: 2px solid var(--craft-indigo);
  color: var(--craft-green-text);
}
[data-btn][data-variant="outline"]:not(:disabled):hover { background: var(--craft-indigo-tint); }

[data-btn][data-variant="danger"] {
  background: var(--status-danger-fill);
  color: var(--status-danger-on-fill);
  box-shadow: 0 2px 8px rgba(239, 68, 68, 0.2);
}
[data-btn][data-variant="danger"]:not(:disabled):hover {
  background: color-mix(in srgb, var(--status-danger-fill) 85%, #000);
  box-shadow: 0 4px 14px rgba(239, 68, 68, 0.28);
}

/* Accent and warning are the two legacy .ds-btn variants still used by
   templates/users/. Ink #0E2233 is used on both light palette surfaces:
   5.24:1 on Terracotta and 9.95:1 on Sunbeam yellow. */
[data-btn][data-variant="accent"] {
  background: var(--craft-pink);
  color: #0E2233;
  border-color: var(--craft-pink);
}
[data-btn][data-variant="accent"]:not(:disabled):hover {
  background: var(--craft-pink);
  border-color: var(--craft-pink);
  color: #0E2233;
  filter: brightness(0.94);
}

[data-btn][data-variant="warning"] {
  background: var(--accent-yellow);
  color: #0E2233;
  border-color: var(--accent-yellow);
}
[data-btn][data-variant="warning"]:not(:disabled):hover {
  background: var(--craft-orange);
  border-color: var(--craft-orange);
  color: #0E2233;
  filter: brightness(0.97);
}

/* --craft-gradient-contrast (themes.css), not --accent-contrast: the latter
   was tuned only for the flat solid accent, not this separately-authored
   3-stop gradient -- reusing it left several palettes (worst: indigo dark
   mode, 2.05:1) with a near-invisible label on every gradient button
   ("Send message"/"Sign In"/etc, 2026-09-02 fix). W24 D5 retunes these
   gradient/label pairs to clear 4.5:1 along every palette/theme's full run;
   the shadow remains part of the "glass" look. */
[data-btn][data-variant="gradient"] {
  background: var(--craft-gradient-hero);
  color: var(--craft-gradient-contrast, var(--accent-contrast, #0E2233));
  text-shadow: 0 1px 2px var(--craft-gradient-contrast-shadow, rgba(0, 0, 0, 0.35));
  box-shadow: var(--shadow-tinted-md);
}
[data-btn][data-variant="gradient"]:not(:disabled):hover {
  filter: brightness(1.07);
  box-shadow: var(--shadow-tinted-lg);
}

[data-btn][data-variant="link"] {
  background: transparent;
  border: none;
  border-radius: 0;
  color: var(--craft-green-text);
  text-decoration: underline;
  min-height: unset;
  height: auto;
  padding: 0;
  font-size: inherit;
}
[data-btn][data-variant="link"]:not(:disabled):hover {
  color: var(--craft-green-text);
  text-decoration-thickness: 2px;
}

/* Glass (46.G G3-B): the liquid-glass look templates/users/settings.html
   carried as page-local .settings-btn*, promoted into the contract unchanged.
   Colours are the theme-aware --glass-* tokens in theme.css, shared with the
   React GlassButton. The default tone is the frosted neutral; data-tone picks
   primary (brand accent fill), danger or outline. The 10px corner is part of
   the look, so it overrides the pill radius.

   Label contrast, measured with scripts/check_domain_contrast.py's maths on
   --bg-card and --surface-light (worst case): neutral 12.05 light / 10.68
   dark, outline 12.52 / 12.14, danger 4.67 / 8.94. primary is the palette's
   --accent-contrast on --craft-indigo, the [data-variant="primary"] pair. */
[data-btn][data-variant="glass"] {
  border-radius: 10px;
  background: var(--glass-neutral-bg);
  -webkit-backdrop-filter: blur(12px) saturate(1.4);
  backdrop-filter: blur(12px) saturate(1.4);
  border-color: var(--glass-neutral-border);
  color: var(--glass-neutral-text);
  box-shadow: var(--glass-inset), var(--glass-neutral-shadow);
}
[data-btn][data-variant="glass"]:not(:disabled):hover {
  transform: translateY(-1px);
  box-shadow: var(--glass-inset), var(--glass-neutral-shadow-hover);
}
[data-btn][data-variant="glass"][data-tone="primary"] {
  background: var(--glass-primary-bg);
  -webkit-backdrop-filter: blur(12px) saturate(1.5);
  backdrop-filter: blur(12px) saturate(1.5);
  border-color: var(--glass-primary-border);
  color: var(--glass-primary-text);
  box-shadow: var(--glass-inset), var(--glass-primary-shadow);
}
[data-btn][data-variant="glass"][data-tone="primary"]:not(:disabled):hover {
  box-shadow: var(--glass-inset), var(--glass-primary-shadow-hover);
}
[data-btn][data-variant="glass"][data-tone="danger"] {
  background: var(--glass-danger-bg);
  -webkit-backdrop-filter: blur(12px) saturate(1.5);
  backdrop-filter: blur(12px) saturate(1.5);
  border-color: var(--glass-primary-border);
  color: #fff;
  box-shadow: var(--glass-inset), var(--glass-danger-shadow);
}
[data-btn][data-variant="glass"][data-tone="danger"]:not(:disabled):hover {
  box-shadow: var(--glass-inset), var(--glass-danger-shadow-hover);
}
[data-btn][data-variant="glass"][data-tone="outline"] {
  background: var(--glass-outline-bg);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border-color: var(--glass-outline-border);
  box-shadow: none;
}
[data-btn][data-variant="glass"][data-tone="outline"]:not(:disabled):hover {
  box-shadow: var(--glass-inset), var(--glass-neutral-shadow);
}

/* spinner */
[data-btn-spinner] {
  width: 14px;
  height: 14px;
  border-radius: 9999px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  display: inline-block;
  animation: btn-spin 0.8s linear infinite;
  flex-shrink: 0;
}

@keyframes btn-spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
  [data-btn-spinner] { animation: none; opacity: 0.6; }
}

/* ── Chip system ([data-chip]) ──────────────────────────────────────────────

   A chip is a compact, usually-toggleable filter token, not a button. Its
   painted box has its own density, while coarse pointers get a transparent
   hit-area expansion.

   The row owns the gap for exactly that reason. Two neighbours each expanding
   7px into an 8px gap consume 14px of it, so their tap targets would OVERLAP
   by 6px and a tap in that band would land on whichever chip paints last --
   in both axes, since chips wrap at the same gap. `[data-chip-row]` therefore
   opens to 16px wherever the expansion applies, leaving 16 - 7 - 7 = 2px
   between adjacent hit areas, and stays at 8px for a cursor, which never gets
   the expansion. Density is preserved where it is looked at and spacing is
   corrected where it is touched. */
[data-chip-row] {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

@media (pointer: coarse) {
  [data-chip-row] { gap: 16px; }
}

[data-chip] {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  min-width: 30px;
  min-height: 32px;
  padding: 5px 12px;
  border: 1.5px solid var(--border-light);
  border-radius: var(--radius-full);
  background: var(--bg-card);
  color: var(--text-secondary);
  font: inherit;
  font-size: var(--font-size-sm);
  line-height: 1;
  cursor: pointer;
  white-space: nowrap;
  transition: background 120ms ease, border-color 120ms ease, color 120ms ease,
              opacity 120ms ease;
}

[data-chip][aria-pressed="true"] {
  border-color: var(--craft-indigo);
  background: var(--craft-indigo-tint);
  color: var(--craft-green-text);
  font-weight: 600;
}

/* A chip that wraps a checkbox (label[data-chip] > input.visually-hidden)
   needs no script: the browser keeps the input's state, and these two rules
   draw it. They are separate rules, not extra selectors on the ones above:
   a browser without :has() drops a whole rule whose list it cannot parse. */
[data-chip]:has(input:checked) {
  border-color: var(--craft-indigo);
  background: var(--craft-indigo-tint);
  color: var(--craft-green-text);
  font-weight: 600;
}

[data-chip]:has(input:focus-visible) {
  outline: 2px solid var(--focus-ring, #1E8F4E);
  outline-offset: var(--focus-ring-offset, 2px);
}

/* Coarse pointer: the painted chip stays compact, but its hit area is at
   least 30 + 7 + 7 = 44px in each axis. The pseudo-element belongs to the
   chip, so it remains one keyboard and pointer target. */
@media (pointer: coarse) {
  [data-chip]::after {
    content: "";
    position: absolute;
    inset: -7px;
  }
}

/* Tablet: touch density, with the same 44px hit-area expansion above. */
@media (pointer: coarse) and (min-width: 768px) {
  [data-chip] {
    min-width: 30px;
    min-height: 30px;
    padding: 4px 10px;
  }
}

/* Desktop: cursor precision; the painted box stays at or above the 24px AA
   Target Size (Minimum) floor without inheriting the 44px touch floor. */
@media (pointer: fine) {
  [data-chip] {
    min-width: 24px;
    min-height: 24px;
    padding: 3px 10px;
  }
}

@media (prefers-reduced-motion: reduce) {
  [data-chip] { transition: none; }
}

/* =====================================================
   Disclosure — .ds-disclosure (P2.1)

   Server-side twin of the React SectionCard
   (frontend/src/components/ui/SectionCard.tsx), built on a native
   <details>/<summary> so it needs no JavaScript at all. Keyboard toggle,
   focus, and the open/closed state come free from the element.

   Matches SectionCard's visual language deliberately: a tinted header band
   (--domain-tint, falling back to --surface-light) carrying the title, an
   optional count badge, and a chevron in a bordered circle, over a neutral
   body. Reads the same --domain-* custom properties from any ancestor, so
   [data-domain="activities"] tints a server section exactly as it tints an
   island one.

   Before this existed, four templates hand-rolled <details> with their own
   inline <style> blocks and there was no bare details/summary rule anywhere
   in static/.

   Markup contract — see templates/includes/_disclosure_summary.html:
     <details class="ds-disclosure" open>
       <summary class="ds-disclosure__summary">
         <span class="ds-disclosure__title">...</span>
         <span class="ds-disclosure__meta">
           <span class="ds-badge ...">3</span>
           <span class="ds-disclosure__indicator" aria-hidden="true">svg</span>
         </span>
       </summary>
       <div class="ds-disclosure__body">...</div>
     </details>
   ===================================================== */
.ds-disclosure {
  background: var(--bg-card);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  color: var(--text-primary);
  overflow: hidden;
}

.ds-disclosure + .ds-disclosure {
  margin-top: var(--space-md);
}

.ds-disclosure__summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-sm);
  /* 3.5rem matches SectionCard's min-h-[3.5rem] and clears the 44px
     touch-target floor with room to spare. */
  min-height: 3.5rem;
  padding: var(--space-sm) var(--space-md);
  background: var(--domain-tint, var(--surface-light));
  border-bottom: 1px solid transparent;
  cursor: pointer;
  list-style: none;
  transition: background var(--transition-fast);
}

/* Hide the native disclosure triangle in every engine; the chevron below
   replaces it. */
.ds-disclosure__summary::-webkit-details-marker {
  display: none;
}

.ds-disclosure__summary::marker {
  content: "";
}

.ds-disclosure__summary:hover {
  background: var(--domain-tint-strong, var(--bg-card-hover));
}

.ds-disclosure__summary:focus-visible {
  outline: 2px solid var(--focus-ring, #1E8F4E);
  outline-offset: -3px;
}

.ds-disclosure[open] > .ds-disclosure__summary {
  border-bottom-color: var(--border-light);
}

.ds-disclosure__title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: var(--font-size-lg);
  line-height: 1.2;
}

/* Title over an optional muted line: the wrapper exists only when the summary
   partial is given a subtitle (_disclosure_summary.html). */
.ds-disclosure__text {
  display: grid;
  min-inline-size: 0;
  gap: var(--space-xs);
}

.ds-disclosure__subtitle {
  color: var(--text-secondary);
  font-size: var(--font-size-sm);
  line-height: 1.3;
}

.ds-disclosure__meta {
  display: inline-flex;
  flex: none;
  align-items: center;
  gap: var(--space-sm);
}

.ds-disclosure__indicator {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.75rem;
  height: 1.75rem;
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-full);
  color: var(--domain-accent, var(--craft-indigo));
  transition: transform var(--transition-fast);
}

.ds-disclosure[open] > .ds-disclosure__summary .ds-disclosure__indicator {
  transform: rotate(180deg);
}

.ds-disclosure__body {
  padding: var(--space-md);
  color: var(--text-secondary);
  font-size: var(--font-size-base);
}

@media (prefers-reduced-motion: reduce) {
  .ds-disclosure__summary,
  .ds-disclosure__indicator {
    transition: none;
  }
}

/* =====================================================
   Activity action surfaces (P3, revised)

   Two separate pieces, by product decision (2026-08-13):

   .ds-activity-actions  static row of secondary actions (Message, Rate),
                         lower on the page. Never moves.
   .ds-activity-primary  Join/Leave, Share, Rally and the overflow menu. It sits
                         right under the title, above every detail, and sticks
                         at every width so it stays in reach while the page is
                         read (owner, 2026-11-26, QC14). Below 1024px it is a
                         one-line band under the phone header (see the rule
                         below).

   This replaced a fixed bottom bar. Notes worth keeping, because both
   mistakes are easy to repeat:

   - position:sticky with `bottom` does NOT pin an element near the end of a
     page. A bottom-sticky element only floats while its containing block
     still has content below it, so it renders exactly where it sits in flow.
     Sticky with `top` on an element early in a tall column is the opposite
     case and works, which is why the primary sticks and the old bar did not.
   - A sticky element's travel is bounded by its PARENT's box, so
     .ds-activity-primary has to be a direct child of the tall content column.
     Nesting it inside a short header row silently reduces its range to zero.
   ===================================================== */
.ds-activity-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-sm);
  margin-bottom: var(--space-sm);
}

.ds-activity-primary {
  position: sticky;
  /* Flush under the sticky .top-bar (--z-nav), below it in the stack: it
     must never cover the navigation. */
  top: var(--topbar-min-height, 72px);
  z-index: var(--z-sticky);
  /* A solid toolbar across the content column (QC14), not a floating pill:
     the pill had no surface of its own, so whatever scrolled behind it showed
     through around its buttons. On its surface the page scrolls under it.
     One line that never wraps: when the buttons do not fit they scroll
     sideways inside it. The overflow menu opens in a portal, so this
     scrolling never clips it. */
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: var(--space-sm);
  overflow-x: auto;
  scrollbar-width: none;
  margin-bottom: var(--space-md);
  padding: var(--space-xs) var(--space-sm);
  background: var(--bg-secondary);
  border: 1px solid var(--border-dark);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
}

.ds-activity-primary::-webkit-scrollbar {
  display: none;
}

.ds-activity-primary > *,
.ds-activity-primary .ds-action-bar > * {
  flex: none;
}

.ds-activity-primary .ds-action-bar {
  flex: none;
  flex-wrap: nowrap;
}

.ds-activity-primary [data-btn] {
  white-space: nowrap;
}

/* The primary slot renders empty for the activity's creator and for a locked
   non-viewer - both are legitimate branches with no primary action - so it
   must collapse rather than leave a sticky gap under the actions row. */
.ds-activity-primary:empty {
  display: none;
}

/* Join Activity (and Join waitlist) is the one thing the page asks of a
   member who has not joined: big and hard to miss (owner, 2026-11-28, QC16).
   Same colours as every primary button; only its size and weight change.
   Two selectors for one button: the island's (ActionBar's primary slot; Join
   is its only action with the primary variant) and the form that stands in
   the row until the island mounts. */
.ds-activity-primary [data-action-bar-primary][data-variant="primary"],
.ds-activity-primary > form > [data-btn][data-variant="primary"] {
  min-height: 56px;
  min-width: 16rem;
  padding-inline: var(--space-2xl);
  font-size: var(--font-size-lg);
  font-weight: 700;
}

/* On a phone (below 768px) Join takes a whole line of the row, and Share and
   the story button share the one line under it: the last of them takes the
   room that is left, its label on two lines when a language needs it
   (Persian at 320px). The row is then two lines high for as long as the
   member has not joined; joined, it is the one-line row again. The bar is a
   wrapping flex row by its own inline style (layout/Stack.tsx), so only the
   flex values of its children are set here. */
@media (max-width: 767.98px) {
  .ds-activity-primary:has(> form > [data-btn][data-variant="primary"]) {
    flex-wrap: wrap;
  }

  .ds-activity-primary .ds-action-bar:has(> [data-action-bar-primary][data-variant="primary"]) {
    flex: 1 1 auto;
    min-inline-size: 0;
  }

  .ds-activity-primary .ds-action-bar > [data-action-bar-primary][data-variant="primary"],
  .ds-activity-primary > form:has(> [data-btn][data-variant="primary"]) {
    flex: 1 1 100%;
  }

  .ds-activity-primary [data-action-bar-primary][data-variant="primary"],
  .ds-activity-primary > form > [data-btn][data-variant="primary"] {
    min-width: 0;
    inline-size: 100%;
    padding-inline: var(--space-md);
  }

  /* The last inline action starts from no width, so it never opens a third
     line while 9rem of room is left beside the one before it. */
  .ds-activity-primary .ds-action-bar:has(> [data-action-bar-primary][data-variant="primary"]) > [data-action-bar-secondary]:not(:has(~ [data-action-bar-secondary])) {
    flex: 1 1 0;
    min-width: 9rem;
    padding-inline: var(--space-md);
    line-height: 1.2;
    text-align: center;
    white-space: normal;
  }
}

/* Phones and tablets (below 1024px, the phone shell): the same toolbar as a
   band pinned under the fixed phone header (--topbar-height), on the
   header's own surface. Before QC14 the row was not sticky here: wrapped to
   about 179px at 390px it covered the open poll; as one 44px line that the
   page scrolls under, it covers nothing for good. A participant's badge and
   buttons (You're going, I changed my mind, Share, Rally, Share to Instagram
   Story, More)
   scroll sideways inside it. The band reaches the screen's edges through a
   spread shadow clipped to its height, so no text shows in the gutters. */
@media (max-width: 1023.98px) {
  .ds-activity-primary {
    top: var(--topbar-height, 60px);
    padding-inline: 0;
    border-width: 0 0 1px;
    border-radius: 0;
    box-shadow: 0 0 0 100vmax var(--bg-secondary);
    clip-path: inset(0 -100vmax);
  }

  .ds-activity-actions > [data-btn] {
    flex: 1 1 auto;
  }
}

/* =====================================================
   Action bar — .ds-action-bar (P2.4)

   A plain, in-flow row of actions: one primary, up to three inline
   secondaries, the rest behind an overflow menu. Consumed by
   frontend/src/components/ui/ActionBar.tsx.

   Deliberately NOT positioned. An earlier revision pinned it to the bottom
   of the viewport; the product decision moved activity actions to the top of
   the page instead (see .ds-activity-primary above), and leaving a competing
   fixed-bottom behaviour here would have let the React and Django surfaces
   drift apart again - which is the whole failure this phase exists to fix.
   ===================================================== */
.ds-action-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-sm);
}

/* Overflow menu, server flavour. The React bar opens a Radix dropdown; a
   Django page has no React, so the same slot is a native <details> and needs
   no JavaScript. Both render .ds-action-bar__menu / __menu-item, so the menu
   surface and item styling above are shared. */
.ds-action-bar__more {
  position: relative;
}

.ds-action-bar__more > summary {
  list-style: none;
  cursor: pointer;
}

.ds-action-bar__more > summary::-webkit-details-marker {
  display: none;
}

.ds-action-bar__more > summary::marker {
  content: "";
}

/* Opens downward and right-aligned. This is the ONLY consumer of
   .ds-action-bar__more (the server-rendered <details> overflow menu on the
   activity detail page); the bar it belongs to sits in flow right under the
   page title, not bottom-sticky like the React ActionBar's Radix menu that
   the shared .ds-action-bar__menu / __menu-item styling also serves — so
   unlike that one, opening upward here pushed items off the top of the
   viewport (some of the menu's own entries were never visible). */
.ds-action-bar__more > .ds-action-bar__menu {
  position: absolute;
  right: 0;
  top: calc(100% + var(--space-xs));
  display: none;
}

.ds-action-bar__more[open] > .ds-action-bar__menu {
  display: block;
}

/* Server menu entries are <a> and <span>, not only <button> as in Radix. */
a.ds-action-bar__menu-item {
  text-decoration: none;
}

.ds-action-bar__menu-item[data-disabled] {
  pointer-events: none;
}

.ds-action-bar__menu {
  min-width: 180px;
  padding: 6px;
  background: var(--bg-elevated);
  color: var(--text-primary);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-xl);
  z-index: var(--z-dropdown);
}

.ds-action-bar__menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  /* Touch-target floor, same as the button contract. */
  min-height: 44px;
  padding: 8px 10px;
  color: var(--text-secondary);
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  font: inherit;
  font-size: var(--font-size-sm);
  text-align: left;
  cursor: pointer;
}

/* Radix drives keyboard navigation through [data-highlighted], so that state
   IS the focus indicator and has to be visible on its own. --surface-light
   against the --bg-elevated menu is only 1.22:1 in both themes (in dark it is
   actually DARKER than the menu), and the text shift alone is imperceptible,
   which fails SC 2.4.7 / 2.4.11. --bg-card-hover carries a real delta, and an
   explicit ring is kept for non-Radix consumers. `outline: none` was removed
   rather than overridden. */
.ds-action-bar__menu-item:hover,
.ds-action-bar__menu-item[data-highlighted] {
  color: var(--text-primary);
  background: var(--bg-card-hover);
  box-shadow: inset 2px 0 0 var(--focus-ring, #1E8F4E);
}

.ds-action-bar__menu-item:focus-visible {
  outline: 2px solid var(--focus-ring, #1E8F4E);
  outline-offset: -2px;
}

.ds-action-bar__menu-item[data-disabled] {
  opacity: 0.5;
  cursor: not-allowed;
}

/* =====================================================
   Activity summary — .ds-activity-summary (B4, reshaped in wave C2)

   ONE contract at five form factors, per DESIGN.md section 5: row (the
   default), card, dashboard row, calendar item, gallery detail. Emitted by
   templates/includes/_activity_summary.html; the island twin is
   frontend/src/components/ActivityCard.tsx. Both write the same classes, and
   core/tests/fixtures/activity_summary_parity.json holds them to the same
   parts.

   The parts, in order: a type chip; a status dot and the status WORD (the
   word carries the meaning, the dot only repeats it, and colour comes from
   --status-* and the neutral text tokens); the date and time at the inline
   end; the title; place and host on one line; then avatars, a capacity bar
   with its count, an optional trailing slot (island only) and ONE action at
   the inline end. The row, dashboard and calendar factors carry no media, as
   drawn in the mock-up; card and detail keep the media slot and its fallback.

   The title is the row's one link and its ::after covers the row, so the
   whole row is the hit area; the action sits above it (z-index 2). A
   keyboard focus on the title rings the row through :focus-within, and the
   link's own :focus-visible outline (the global rule in theme.css) is turned
   off, so there is one ring. Everything is logical properties:
   in a right-to-left page the row mirrors with no extra rule.

   Not a .ds-card: the summary carries its own action, and a .ds-card with
   href would make the whole surface one click target with a button nested in
   it. The calendar factor IS a whole-element link and renders no action.
   ===================================================== */
.ds-activity-summary {
  position: relative;
  display: flex;
  gap: var(--space-md);
  min-width: 0;
  padding: var(--space-md);
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  color: var(--text-primary);
}

.ds-activity-summary:focus-within {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

.ds-activity-summary__body {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  /* min-width:0 or a long unbroken title (a URL, a German compound) forces
     the flex item wider than the row and pushes the action off the edge. */
  min-width: 0;
  flex: 1 1 auto;
}

/* Top line: chip, status, then the time at the inline end. It wraps as whole
   items, so a long category name moves the time down instead of clipping. */
.ds-activity-summary__head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-xs) var(--space-sm);
  font-size: var(--font-size-xs);
}

.ds-activity-summary__type {
  display: inline-block;
  max-width: 100%;
  padding: 2px var(--space-sm);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-full);
  background: var(--surface-light);
  color: var(--text-primary);
  font-weight: 700;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

/* The category's own colour tints the chip when the caller gives one; the
   text stays on a text token, so the tint can never lower its contrast. */
.ds-activity-summary__type[style] {
  border-color: color-mix(in srgb, var(--ds-activity-tint) 45%, var(--bg-card));
  background: color-mix(in srgb, var(--ds-activity-tint) 14%, var(--bg-card));
}

.ds-activity-summary__status {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  font-weight: 700;
}

.ds-activity-summary__dot {
  flex-shrink: 0;
  width: 6px;
  height: 6px;
  border-radius: var(--radius-full);
  background: var(--text-muted);
}

.ds-activity-summary__status-word {
  color: var(--text-secondary);
}

.ds-activity-summary[data-status="open"] .ds-activity-summary__dot {
  background: var(--status-success-fill);
}
.ds-activity-summary[data-status="open"] .ds-activity-summary__status-word {
  color: var(--status-success-text);
}

/* A Team Up that still has roles to fill: neither open for Participate nor full. */
.ds-activity-summary[data-status="team_up"] .ds-activity-summary__dot {
  background: var(--status-info-fill);
}
.ds-activity-summary[data-status="team_up"] .ds-activity-summary__status-word {
  color: var(--status-info-text);
}
.ds-activity-summary[data-status="team_up"] .ds-activity-summary__bar-fill {
  background: var(--status-info-fill);
}

.ds-activity-summary[data-status="full"] .ds-activity-summary__dot,
.ds-activity-summary[data-status="waitlist"] .ds-activity-summary__dot {
  background: var(--status-warning-fill);
}
.ds-activity-summary[data-status="full"] .ds-activity-summary__status-word,
.ds-activity-summary[data-status="waitlist"] .ds-activity-summary__status-word {
  color: var(--status-warning-text);
}

.ds-activity-summary[data-status="cancelled"] .ds-activity-summary__dot {
  background: var(--status-danger-fill);
}
.ds-activity-summary[data-status="cancelled"] .ds-activity-summary__status-word {
  color: var(--status-danger-text);
}

/* Draft is the one marker for an unpublished activity (it replaces
   .ca-draft-badge and .hf-draft-tag): a hollow dot, so it does not read as
   a state of the audience. */
.ds-activity-summary[data-status="draft"] .ds-activity-summary__dot {
  background: transparent;
  box-shadow: inset 0 0 0 1.5px var(--text-muted);
}

.ds-activity-summary__when {
  margin-inline-start: auto;
  color: var(--text-secondary);
  font-weight: 600;
  white-space: nowrap;
}

.ds-activity-summary__title {
  margin: 0;
  font-family: var(--font-display);
  font-size: var(--font-size-base);
  font-weight: 700;
  line-height: 1.3;
  /* A long title wraps to two lines and stops: the row keeps its height and
     the action stays on screen at 320. */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  overflow-wrap: anywhere;
}

.ds-activity-summary__link {
  color: inherit;
  text-decoration: none;
}

/* The ring is the row's, from .ds-activity-summary:focus-within above. The
   global :focus-visible outline (theme.css) would draw a second one on the link
   itself, clipped by the title's overflow:hidden, inside the row's. */
.ds-activity-summary__link:focus-visible {
  outline: none;
}

/* Stretched link: the title is the one real anchor, so keyboard focus,
   middle-click and open-in-new-tab keep working, and its ::after is the
   row's hit area. */
.ds-activity-summary__link::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
}

/* Hovering anywhere on the row highlights the title. */
.ds-activity-summary:hover .ds-activity-summary__link {
  color: var(--link-color);
  text-decoration: underline;
}

.ds-activity-summary__where {
  display: flex;
  flex-wrap: wrap;
  gap: 0 var(--space-xs);
  margin: 0;
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  overflow-wrap: anywhere;
}

/* The separator belongs to the pair, so a missing place or host leaves none. */
.ds-activity-summary__place + .ds-activity-summary__host::before {
  content: "\00B7";
  margin-inline-end: var(--space-xs);
}

/* Bottom line: avatars, capacity, the optional trailing slot, then the one
   action at the inline end. It wraps, so at 320 the action takes its own line. */
.ds-activity-summary__foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-sm) var(--space-md);
  margin-block-start: var(--space-xs);
}

.ds-activity-summary__avatars {
  display: inline-flex;
  flex-shrink: 0;
}

.ds-activity-summary__avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  /* Wide enough for two initials at the scale's smallest size, with the
     overlap still leaving each pair readable. */
  width: 1.75rem;
  height: 1.75rem;
  overflow: hidden;
  border-radius: var(--radius-full);
  background: var(--bg-tertiary);
  box-shadow: 0 0 0 2px var(--bg-card);
  color: var(--text-primary);
  font-size: var(--font-size-xs);
  font-weight: 800;
  line-height: 1;
}

.ds-activity-summary__avatar + .ds-activity-summary__avatar {
  margin-inline-start: -4px;
}

.ds-activity-summary__avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.ds-activity-summary__avatar--more {
  background: var(--surface-light);
}

.ds-activity-summary__capacity {
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
  flex: 1 1 5rem;
  min-width: 0;
  max-width: 14rem;
}

.ds-activity-summary__bar {
  flex: 1 1 auto;
  min-width: 2rem;
  height: 4px;
  overflow: hidden;
  border-radius: 2px;
  background: var(--bg-tertiary);
}

.ds-activity-summary__bar-fill {
  display: block;
  height: 100%;
  border-radius: 2px;
  background: var(--status-success-fill);
}

.ds-activity-summary[data-status="full"] .ds-activity-summary__bar-fill,
.ds-activity-summary[data-status="waitlist"] .ds-activity-summary__bar-fill {
  background: var(--status-warning-fill);
}

.ds-activity-summary[data-status="cancelled"] .ds-activity-summary__bar-fill,
.ds-activity-summary[data-status="past"] .ds-activity-summary__bar-fill,
.ds-activity-summary[data-status="draft"] .ds-activity-summary__bar-fill {
  background: var(--text-muted);
}

.ds-activity-summary__count {
  flex-shrink: 0;
  color: var(--text-secondary);
  font-size: var(--font-size-xs);
  font-weight: 700;
  font-variant-numeric: var(--numeric-variant);
  white-space: nowrap;
}

/* The slot the island row offers a caller (the 7-day trend on Explore rows):
   a 60 by 18 box, never part of the server partial. It sits UNDER the stretched
   link on purpose, so a click on it opens the activity: trailing content must
   not be interactive. */
.ds-activity-summary__trailing {
  display: inline-flex;
  flex-shrink: 0;
  align-items: center;
  min-width: 60px;
  min-height: 18px;
}

.ds-activity-summary__action {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  flex-shrink: 0;
  margin-inline-start: auto;
}

/* The Share button and the action, together at the inline end: one group, so a
   row that offers Share wraps them as one and the action never ends up alone at
   the wrong edge. Side by side by default, which is what a single-column list
   (a phone, the Manage and Participating pages, Explore) has room for. The group
   takes the push the action takes on its own. */
.ds-activity-summary__controls {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  gap: var(--space-sm);
  margin-inline-start: auto;
}

.ds-activity-summary__controls > .ds-activity-summary__action {
  margin-inline-start: 0;
}

/* Above the stretched link like the action, so a press on it opens the share
   popup, not the row. */
.ds-activity-summary__share {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

/* Cards that share a row (the home feed's grid, from the tablet edge up) are
   narrow: Share goes directly above the action, at the inline end, and the two
   take one width (the wider of them) so the pair reads as one stack. On a phone
   the feed is one wide column and stacking only made the card taller (measured:
   13px at 390, 48px at 360 and 320, where the stack drops to a line of its own),
   so there the pair stays side by side. */
@media (min-width: 768px) {
  .animated-list--activities .ds-activity-summary__controls {
    flex-direction: column;
    align-items: stretch;
    gap: var(--space-xs);
  }

  .animated-list--activities .ds-activity-summary__controls [data-btn] {
    flex: 1 1 auto;
    justify-content: center;
    white-space: nowrap;
  }
}

/* Media slot (card and detail only). Fixed box with an object-fit image, so
   a portrait upload and a landscape one produce the same height — the
   fallback exists for the same reason, and both are why the slot never
   collapses. */
.ds-activity-summary__media {
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
  background: var(--surface-light);
  border-radius: var(--radius-md);
}

.ds-activity-summary__media-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
}

.ds-activity-summary__media-fallback {
  display: inline-flex;
  font-size: var(--font-size-2xl);
  color: var(--text-muted);
}

/* ── Factor: row (the default) ───────────────────────────────────────────
   Every list in the product. Nothing to add: the base block is the row. */

/* ── Factor: card ────────────────────────────────────────────────────────
   Feed / grid tile. Vertical, media on top. */
.ds-activity-summary--card {
  flex-direction: column;
  gap: var(--space-sm);
}

.ds-activity-summary--card .ds-activity-summary__media {
  width: 100%;
  height: 160px;
}

.ds-activity-summary--card .ds-activity-summary__title {
  font-size: var(--font-size-lg);
}

/* ── Factor: dashboard ───────────────────────────────────────────────────
   Stacked rows inside a narrow widget column. No surface of its own: it sits
   inside a card that already has one, and a border on both reads as a box in
   a box. */
.ds-activity-summary--dashboard {
  padding: var(--space-sm) 0;
  background: none;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

.ds-activity-summary--dashboard + .ds-activity-summary--dashboard {
  border-top: 1px solid var(--border-light);
}

/* ── Factor: calendar ────────────────────────────────────────────────────
   One item in a day or week grid. The whole item is the link, so it needs
   the hover state a nested title link would have carried; the ring is the
   row's :focus-within, as in every factor. */
.ds-activity-summary--calendar {
  flex-direction: column;
  gap: 2px;
  padding: var(--space-xs) var(--space-sm);
  border-radius: var(--radius-md);
  box-shadow: none;
  font-size: var(--font-size-xs);
  text-decoration: none;
  /* The grid cell owns the width; the item must never widen it. */
  max-width: 100%;
  overflow: hidden;
}

.ds-activity-summary--calendar:hover {
  background: var(--bg-card-hover);
}

.ds-activity-summary--calendar .ds-activity-summary__title {
  display: block;
  font-size: var(--font-size-xs);
  white-space: nowrap;
  text-overflow: ellipsis;
}

.ds-activity-summary--calendar .ds-activity-summary__where,
.ds-activity-summary--calendar .ds-activity-summary__foot {
  font-size: var(--font-size-xs);
  margin-block-start: 0;
}

/* ── Factor: detail ──────────────────────────────────────────────────────
   The gallery / activity-detail header. Same parts, biggest media. */
.ds-activity-summary--detail {
  flex-direction: column;
  gap: var(--space-md);
  padding: var(--space-lg);
}

.ds-activity-summary--detail .ds-activity-summary__media {
  width: 100%;
  height: 320px;
  border-radius: var(--radius-lg);
}

.ds-activity-summary--detail .ds-activity-summary__title {
  font-size: var(--font-size-2xl);
}

.ds-activity-summary--detail .ds-activity-summary__where {
  font-size: var(--font-size-base);
}

/* Loading skeleton (island): the row's footprint, nothing in it. */
.ds-activity-summary--skeleton {
  min-height: 7.5rem;
  background: var(--bg-card);
  opacity: 0.5;
}

/* Narrow viewports: the detail media shrinks. */
@media (max-width: 767.98px) {
  .ds-activity-summary--detail {
    padding: var(--space-md);
  }

  .ds-activity-summary--detail .ds-activity-summary__media {
    height: 200px;
  }
}

/* =====================================================
   Person / member — .ds-person (B5)

   The person contract from DESIGN.md section 5, emitted by
   templates/includes/_person.html: avatar with fallback, display name,
   relationship or role, profile link, contextual action. Shared by
   communities, attendees, messages and profile lists.

   The avatar is .ds-avatar, not a .ds-person__avatar. A second
   circle-with-initials implementation is exactly how two surfaces end up
   with two different fallback colours for the same missing picture.

   The NAME is the link, never the row. The row carries an action of its
   own, and the whole-element-click-target rule documented on .ds-card
   applies here for the same reason.
   ===================================================== */
.ds-person {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  min-width: 0;
  color: var(--text-primary);
}

.ds-person__body {
  display: flex;
  flex-direction: column;
  /* min-width:0 so a long display name ellipsises instead of pushing the
     contextual action off the end of a narrow row. */
  min-width: 0;
  flex: 1 1 auto;
}

.ds-person__name {
  font-size: var(--font-size-base);
  font-weight: 600;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ds-person__name a {
  color: inherit;
  text-decoration: none;
}

.ds-person__name a:hover {
  text-decoration: underline;
}

.ds-person__name a:focus-visible {
  outline: 2px solid var(--focus-ring, #1E8F4E);
  outline-offset: var(--focus-ring-offset, 2px);
  border-radius: var(--radius-xs);
}

/* Role is --text-secondary rather than a badge: it is a relationship, not a
   status, and giving every member row a coloured pill turns a list of people
   into a list of labels. */
.ds-person__role {
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ds-person__action {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  margin-left: auto;
}

.ds-person--sm .ds-person__name {
  font-size: var(--font-size-sm);
}

.ds-person--sm .ds-person__role {
  font-size: var(--font-size-xs);
}

.ds-person--lg {
  gap: var(--space-md);
}

.ds-person--lg .ds-person__name {
  font-size: var(--font-size-lg);
}

/* =====================================================
   Tab variants — .ds-tabs--contained / --pill (C3 follow-on)

   frontend/src/components/ui/Tabs.tsx (branch w46/e-islands) emits
   `ds-tabs--contained` / `ds-tab--contained` and `ds-tabs--pill` /
   `ds-tab--pill`, and no CSS existed for either name, so both variants
   rendered as the plain underline row - a variant that silently does
   nothing. components.css is the canonical owner of the .ds-tab vocabulary
   (the ownership gate forbids defining it in the bundle), so the rules
   belong here rather than beside the component.

   Both variants have to UNDO the underline treatment the base block carries:
   .ds-tabs owns a 2px bottom border and .ds-tab hangs a transparent 2px
   border into it with a -2px margin. Left in place, a pill row shows a stray
   rule under the chips and each chip sits 2px low.

   Written to sit AFTER the base active-state rule on purpose: `.ds-tab--pill
   .is-active` and `.ds-tab.is-active` have identical specificity, so source
   order is what decides, and a variant defined earlier in the file would
   lose to the underline it is trying to replace.
   ===================================================== */
.ds-tabs--contained,
.ds-tabs--pill {
  border-bottom: 0;
  gap: var(--space-xs);
}

.ds-tab--contained,
.ds-tab--pill {
  border-bottom: 0;
  margin-bottom: 0;
  border-radius: var(--radius-full);
}

/* Contained: a segmented control. The track carries the surface, the active
   segment lifts out of it. */
.ds-tabs--contained {
  padding: var(--space-xs);
  background: var(--surface-light);
  border-radius: var(--radius-full);
  /* The track is shrink-wrapped; a full-bleed pill track reads as a search
     field, not as a choice between two or three things. */
  width: max-content;
  max-width: 100%;
}

.ds-tab--contained.is-active,
.ds-tab--contained[aria-selected="true"] {
  background: var(--bg-elevated);
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
}

/* Pill: free-standing chips, no track. The active chip is filled. */
.ds-tab--pill {
  border: 1px solid var(--border-medium);
}

.ds-tab--pill:hover {
  background: var(--craft-indigo-tint);
}

.ds-tab--pill.is-active,
.ds-tab--pill[aria-selected="true"] {
  background: var(--craft-indigo);
  border-color: var(--craft-indigo);
  /* Ink fallback, not white, for the same reason the primary button uses it:
     Electric Green is a light accent and white lands near 1.6:1 on it.
     themes.css flips --accent-contrast for the dark palettes. */
  color: var(--accent-contrast, #0E2233);
}

/* Selection is never carried by colour alone (DESIGN.md non-negotiable), and
   for these two variants the underline that used to carry it is gone. Weight
   is the second cue, inherited from the base active rule; aria-selected is
   the third and is what assistive tech actually reads. */
.ds-tab--contained.is-active,
.ds-tab--contained[aria-selected="true"],
.ds-tab--pill.is-active,
.ds-tab--pill[aria-selected="true"] {
  font-weight: 600;
}

/* MessagesApp main nav (frontend/src/components/MessagesApp.tsx): a 3-way
   PRIMARY switcher (Conversations/Groups/Communities), not a peripheral
   filter toggle. The base --contained track shrink-wraps to content
   (`width: max-content`) and scrolls the overflow with no visible
   scrollbar (`scrollbar-width: none`) - at the list column's normal ~340px
   width the third tab silently falls off-screen behind an undiscoverable
   horizontal scroll. Force the track full-width with equal-width segments
   instead, same visual weight as the Django-template contained variant
   keeps everywhere else. */
.messages-nav-tabs.ds-tabs--contained {
  width: 100%;
}

.messages-nav-tabs.ds-tabs--contained .ds-tab--contained {
  flex: 1;
  /* flex-basis:0 alone doesn't let a text-content flex item shrink below its
     unwrapped label width (flex items default to min-width:auto) - without
     this the three labels still overflow the 1/3 share flex:1 hands them,
     identically to the un-flexed shrink-wrap this was meant to fix. */
  min-width: 0;
}

/* .ds-tab is display:inline-flex; text-overflow:ellipsis doesn't reliably
   truncate a flex container's own text child, so the label renders in its
   own block-level span (MessagesApp.tsx TabLabel) and gets the ellipsis
   treatment here instead. */
.messages-nav-tab__label {
  display: block;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

/* ── My activities: the page grammar of Manage and Participating ─────────
   One wrapper per row (li.my-activity): an optional selection box, the
   activity summary, then one tools strip. Both pages share the intro, the
   filter form, the section head and the list. The bulk bar, the note, the
   selection box and the privacy switch are used by Manage alone. */
/* ──────────────────────────────────────────────────────────
   MANAGE ACTIVITIES — scoped styles
   The my-* rules are the page grammar Manage shares with Participating
   (the same block sits in templates/users/participating_activities.html):
   one wrapper per activity, one filter bar, one section heading. They belong
   in static/core/components.css once lane C2-A's file opens again.
   ────────────────────────────────────────────────────────── */

/* ── Page grammar shared with Participating ── */
.my-intro {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-sm) var(--space-md);
  margin-block-end: var(--space-lg);
}

.my-lede {
  margin: 0;
  color: var(--text-muted);
  font-size: var(--font-size-sm);
}

.my-filters {
  margin-block-end: var(--space-xl);
}

.my-filters__fields {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 12rem), 1fr));
  gap: var(--space-sm) var(--space-md);
}

.my-section {
  margin-block-end: var(--space-xl);
}

.my-section__head {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin-block-end: var(--space-md);
}

.my-section__title {
  flex: 1;
  margin: 0;
  color: var(--text-primary);
  font-size: var(--font-size-lg);
  font-weight: 700;
}

.my-section__sub {
  margin: calc(var(--space-xs) * -1) 0 var(--space-md);
  color: var(--text-muted);
  font-size: var(--font-size-xs);
}

.my-list {
  display: grid;
  gap: var(--space-lg);
  margin: 0;
  padding: 0;
  list-style: none;
}

/* One activity: the selection box where the page has one, the summary row,
   then the tools strip. The box has the first column to itself; without one
   the column collapses and the row and the strip take the full width. */
.my-activity {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  row-gap: var(--space-xs);
}

.my-activity > :not(.my-activity__check) {
  grid-column: 2;
}

.my-activity__check {
  display: flex;
  grid-column: 1;
  grid-row: 1;
  align-items: center;
  justify-content: center;
  min-inline-size: 44px;
  min-block-size: 44px;
  cursor: pointer;
}

.my-activity__check input,
.my-bulk__all input {
  inline-size: 1.5rem;
  block-size: 1.5rem;
  margin: 0;
  /* The text-safe brand colour: the checked fill keeps 3:1 against the surface
     on every palette (--craft-indigo is 1.5:1 on the green palette). */
  accent-color: var(--craft-green-text);
  cursor: pointer;
}

.my-activity__tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-xs) var(--space-lg);
  padding-inline: var(--space-md);
}

.my-activity__privacy {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-xs) var(--space-sm);
  min-inline-size: 0;
}

.my-activity__note {
  color: var(--text-muted);
  font-size: var(--font-size-xs);
}

.my-activity__actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-xs);
  margin-inline-start: auto;
}

/* A destructive control on a row is quiet: the neutral button, its words in
   the danger text colour. The danger fill is for the one control that acts on
   a selection, once there is one (see the bulk bar). */
.my-quiet-danger[data-variant="secondary"] {
  color: var(--status-danger-text);
}

.my-bulk {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-sm);
  margin-block-end: var(--space-md);
}

.my-bulk__all {
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
  min-block-size: 44px;
  color: var(--text-secondary);
  font-size: var(--font-size-sm);
  cursor: pointer;
}

.my-note {
  margin-block-end: var(--space-xl);
}

/* ── Manage alone: the intro actions, the jump bar, the filter bar, the row
   actions (templates/users/manage_activities.html). Scoped to .manage-scope
   or to an ma-* name, so Participating, which shares the my-* grammar above,
   is untouched. ── */
.manage-scope .my-section__title {
  /* The jump bar scrolls to these; the phone header is sticky above them. */
  scroll-margin-block-start: 5rem;
}

.ma-intro-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-xs);
}

/* The pill row wraps instead of scrolling sideways: every list stays in view. */
.manage-scope .ds-tabs.ma-jump {
  flex-wrap: wrap;
  margin-block-end: var(--space-lg);
  overflow-x: visible;
}

.ma-filters {
  margin-block-end: var(--space-lg);
}

.ma-filters__summary {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  min-block-size: 44px;
  padding-inline: var(--space-md);
  border: 1px solid var(--border-dark);
  border-radius: var(--radius-md);
  background: var(--surface-light);
  color: var(--text-primary);
  font-size: var(--font-size-sm);
  font-weight: 600;
  list-style: none;
  cursor: pointer;
}

.ma-filters__summary::-webkit-details-marker {
  display: none;
}

.ma-filters__chevron {
  margin-inline-start: auto;
}

.ma-filters[open] .ma-filters__chevron {
  transform: rotate(180deg);
}

.ma-filters[open] .ma-filters__summary {
  margin-block-end: var(--space-md);
}

.ma-filters .my-filters {
  margin-block-end: 0;
}

/* Row actions: on a phone they take the row's full width and share it, so
   Edit, Share and Cancel are each one 44px tap and none is cut off. */
@media (max-width: 767px) {
  .manage-scope .my-activity__actions {
    flex: 1 1 100%;
    margin-inline-start: 0;
  }

  .manage-scope .my-activity__actions > [data-btn] {
    flex: 1 1 auto;
    justify-content: center;
  }

  /* Select all and Delete selected share one line; the label wraps, the
     button keeps its width. */
  .manage-scope .my-bulk {
    flex-wrap: nowrap;
  }

  .manage-scope .my-bulk__all {
    flex: 1 1 0;
    min-inline-size: 0;
  }

  .manage-scope .my-bulk > [data-btn] {
    flex: 0 0 auto;
  }
}

/* Wide screens: two rows side by side instead of one long column. */
@media (min-width: 1024px) {
  .manage-scope .my-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: start;
  }
}

/* ── Password requirement checklist ──────────────────────────────────────
   Rendered by the signup island (frontend/src/components/SchemaForm.tsx) from
   the server's own policy (core.password_validators.password_rules). Defined
   here because static/core owns the shared .ds-* vocabulary; the ownership
   gate blocks the bundle from redefining it.
   The mark is a CSS-drawn dot/check rather than a glyph so it carries no text
   for a screen reader to read out - the met/unmet state belongs to the
   aria-live list, not to a decorative character. */
.ds-password-rules {
  list-style: none;
  margin: var(--space-xs) 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.ds-password-rules li {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.ds-password-rules li[data-met="true"] {
  color: var(--craft-green-text, var(--text-secondary));
}

.ds-password-rules__mark {
  flex: 0 0 auto;
  width: 0.85rem;
  height: 0.85rem;
  border-radius: 50%;
  border: 1.5px solid currentColor;
  opacity: 0.55;
  position: relative;
}

.ds-password-rules li[data-met="true"] .ds-password-rules__mark {
  opacity: 1;
  background: currentColor;
}

/* The check, drawn inside the filled dot. */
.ds-password-rules li[data-met="true"] .ds-password-rules__mark::after {
  content: "";
  position: absolute;
  left: 0.24rem;
  top: 0.08rem;
  width: 0.2rem;
  height: 0.4rem;
  border: solid var(--bg-primary);
  border-width: 0 1.5px 1.5px 0;
  transform: rotate(45deg);
}


/* ── Create-kind switch ──────────────────────────────────────────────────
   Segmented control under the heading on the three "start something" forms.
   Each option is a link (see the template for why), so the moving highlight
   is driven by data-active on the container rather than :checked. */
.create-kind-switch {
  position: relative;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0;
  max-width: 34rem;
  margin: 0 0 var(--space-lg);
  padding: 0.3rem;
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-lg);
  background: var(--bg-subtle, var(--surface-light));
  isolation: isolate;
}

/* The highlight is one element that slides, so the movement reads as the
   same object rather than two things fading. */
.create-kind-switch::before {
  content: "";
  position: absolute;
  z-index: var(--z-below);
  inset-block: 0.3rem;
  inset-inline-start: 0.3rem;
  width: calc((100% - 0.6rem) / 3);
  border-radius: var(--radius-md);
  background: var(--bg-card);
  box-shadow: 0 1px 4px rgb(15 23 42 / 22%);
  transition: transform 260ms cubic-bezier(0.34, 1.4, 0.64, 1);
}

.create-kind-switch[data-active="1"]::before { transform: translateX(100%); }
.create-kind-switch[data-active="2"]::before { transform: translateX(200%); }

/* The highlight starts at the inline start, so in a right-to-left page it
   starts on the right and slides left: transforms have no logical form. */
[dir="rtl"] .create-kind-switch[data-active="1"]::before { transform: translateX(-100%); }
[dir="rtl"] .create-kind-switch[data-active="2"]::before { transform: translateX(-200%); }

.create-kind-option {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  align-items: center;
  justify-content: center;
  min-height: 58px;
  padding: 0.5rem 0.4rem;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  text-align: center;
  text-decoration: none;
  transition:
    color var(--transition-fast),
    transform 160ms ease;
}

.create-kind-option:hover {
  color: var(--text-primary);
  transform: translateY(-1px);
}

.create-kind-option:active {
  transform: translateY(0) scale(0.98);
}

.create-kind-option:focus-visible {
  outline: 2px solid var(--focus-ring, #1e8f4e);
  outline-offset: -2px;
}

.create-kind-option--active {
  color: var(--text-primary);
}

.create-kind-option--active .create-kind-option__name {
  font-weight: 900;
}

.create-kind-option__name {
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 1.2;
}

.create-kind-option__hint {
  color: var(--text-muted);
  font-size: 0.72rem;
  line-height: 1.2;
}

.create-kind-option--active .create-kind-option__hint {
  color: var(--text-secondary);
}

/* Nothing should slide or lift for someone who asked it not to. */
@media (prefers-reduced-motion: reduce) {
  .create-kind-switch::before,
  .create-kind-option {
    transition: none;
  }

  .create-kind-option:hover,
  .create-kind-option:active {
    transform: none;
  }
}

/* The hint is the first thing to go when there is no room for it. */
@media (max-width: 420px) {
  .create-kind-option__hint {
    display: none;
  }

  .create-kind-option {
    min-height: 46px;
  }
}
/* Activity open slots: a compact organizer/requester workflow on the detail page. */
.open-slots-heading,
.open-slot-row,
.open-slot-request-row {
  align-items: flex-start;
  display: flex;
  gap: var(--space-md);
  justify-content: space-between;
}

/* An opened add-slot form drops under the heading, full width. */
.open-slots-heading {
  flex-wrap: wrap;
}

.open-slots-add-control > summary {
  cursor: pointer;
  list-style: none;
}

.open-slots-add-control > summary::-webkit-details-marker {
  display: none;
}

.open-slots-form,
.open-slot-request-form {
  display: grid;
  gap: var(--space-sm);
  margin-top: var(--space-md);
}

/* Two columns only while both datetime inputs fit side by side: a
   datetime-local input is about 11.5rem wide, so the grid falls to one column
   on its own where the form is narrower, at any viewport width (L2-009: the
   old fixed two columns overlapped the inputs from 641px up). */
.open-slots-time-fields {
  display: grid;
  gap: var(--space-sm);
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 12.5rem), 1fr));
}

.open-slots-time-fields > div {
  display: grid;
  gap: var(--space-xs);
  min-width: 0;
}

.open-slots-time-fields input {
  width: 100%;
  min-width: 0;
}

/* The add-slot disclosure may shrink below its content, and once open it takes
   the whole row under the heading instead of a right-aligned sliver. */
.open-slots-add-control {
  min-width: 0;
}

.open-slots-add-control[open] {
  flex: 1 1 100%;
}

.open-slot-request-form {
  min-width: min(100%, 17rem);
  margin-top: 0;
}

.open-slot-lineup {
  color: var(--craft-green-text);
  font-weight: 600;
  margin-top: var(--space-xs);
}

.open-slot-request-note {
  cursor: help;
}

.open-slot-request-note a {
  color: var(--craft-green-text);
  font-weight: 700;
}

@media (max-width: 1023.98px) {
  .open-slots-heading,
  .open-slot-row,
  .open-slot-request-row {
    align-items: stretch;
    flex-direction: column;
  }

  .open-slots-time-fields {
    grid-template-columns: 1fr;
  }

  .open-slot-request-form {
    width: 100%;
  }
}

/* =====================================================
   Page header — .ds-page-header (wave C1, lane C1-A)
   Emitted by templates/includes/_page_header.html. The one visible h1 of a
   page, in the display face and the display role of the type scale, with an
   optional count, one action and a way back to the route family's parent.
   It sits inside <main>, so it spans the shell's one content width.
   ===================================================== */
.ds-page-header {
  display: grid;
  gap: var(--space-xs);
  width: 100%;
  margin-block: 0 var(--space-lg);
}

.ds-page-header__back {
  justify-self: start;
}

/* The arrow points at the parent: it mirrors on a right-to-left page. */
[dir="rtl"] .ds-page-header__back-icon {
  transform: scaleX(-1);
}

.ds-page-header__row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
}

.ds-page-header__heading {
  display: flex;
  align-items: baseline;
  gap: var(--space-sm);
  min-width: 0;
}

.ds-page-header__title {
  margin: 0;
  color: var(--text-primary);
  font-family: var(--font-display);
  font-size: clamp(var(--text-scale-display-size, 1.375rem), 1rem + 1.6vw, var(--font-size-3xl, 2rem));
  font-weight: var(--text-scale-display-weight, 800);
  line-height: var(--text-scale-display-leading, 1.2);
  letter-spacing: var(--text-scale-display-tracking, -0.02em);
  overflow-wrap: anywhere;
}

.ds-page-header__count {
  color: var(--text-secondary);
  font-size: var(--font-size-lg);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* Content measure (wave C1, clean-up 4). A form card, a confirm card or a
   single-column list keeps a readable line length under the page header. It
   only caps the width: it starts at the header's left edge and is never
   centred, because the shell's <main> owns the page's width and gutter. 42.5rem
   is 680px, the cap the old centred wrappers used. */
.ds-measure {
  max-inline-size: 42.5rem;
}

/* A row of choices under a warning (a confirm page: the safe one first, the
   destructive one second). Side by side, wrapping on a phone, a step apart so
   they do not read as one control. Logical, so the first choice sits at the
   start edge in either direction. */
.ds-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-md);
  margin-block-start: var(--space-lg);
}
