/* CoderDojo event-site component styles. Built on the compiled tokens.css
   custom properties (--surface, --primary, --space-4, --radius-md, --shadow-sm,
   and the generated type-style classes: .display-2xl, .heading-md, .body, .label, .code, …).
   Every rule below reads a token — nothing here is a hard-coded value. */

*, *::before, *::after { box-sizing: border-box; }

.cd-root {
  background: var(--surface);
  color: var(--ink);
  font-family: var(--font-sans);
  /* A short page's background still reaches the bottom of the window. */
  min-height: 100vh;
}

/* Visible keyboard focus on every interactive element */
.cd-root a:focus-visible,
.cd-root button:focus-visible,
.cd-root input:focus-visible,
.cd-root summary:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* ---------- Button ---------- */
.cd-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-5);
  border-radius: var(--radius-pill);
  border: none;
  cursor: pointer;
  text-decoration: none;
  box-shadow: var(--shadow-sm);
}
.cd-btn.label { /* type-style class + component class combine */ }
.cd-btn--primary { background: var(--primary); color: var(--on-primary); }
.cd-btn--primary:hover, .cd-btn--primary:active { background: var(--primary-hover); }
.cd-btn--secondary { background: var(--secondary); color: var(--on-secondary); }
.cd-btn--secondary:hover, .cd-btn--secondary:active { background: var(--secondary-hover); }
.cd-btn--ghost {
  background: transparent;
  color: var(--secondary);
  border: 2px solid var(--border-strong);
  box-shadow: none;
}
.cd-btn--ghost:hover { background: var(--surface-sunken); }
.cd-btn--danger {
  background: transparent;
  color: var(--danger);
  border: 2px solid var(--danger);
  box-shadow: none;
}
.cd-btn--danger:hover { background: var(--danger-surface); }
.cd-btn:disabled { opacity: 0.5; cursor: not-allowed; box-shadow: none; }
.cd-btn--block { display: flex; width: 100%; justify-content: center; }
/* A smaller button, for a toolbar or a row of a list: still at least 32px high (WCAG 2.5.8 asks 24). */
.cd-btn--small { padding: var(--space-2) var(--space-4); min-height: 32px; box-sizing: border-box; }
.cd-btn--small.cd-btn--ghost { padding: calc(var(--space-2) - 2px) calc(var(--space-4) - 2px); }

/* ---------- Badge (status + session-type tags) ---------- */
.cd-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-pill);
  white-space: nowrap;
}
.cd-badge--accent { background: var(--accent); color: var(--on-accent); }
.cd-badge--success { background: var(--success); color: var(--on-success); }
.cd-badge--warning { background: var(--warning); color: var(--on-warning); }
.cd-badge--danger { background: var(--danger); color: var(--on-danger); }
.cd-badge--outline {
  background: transparent;
  color: var(--ink);
  border: 1.5px solid var(--border-strong);
}

/* ---------- Card shell (used by SessionCard, MentorCard, SponsorLogo) ---------- */
.cd-card {
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  box-shadow: var(--shadow-sm);
}

/* The menu's and the footer's frame (core/base.html): the same on every page.
   Each page sizes its own .shell (720px for a form, none at all on some), which
   made the menu jump in width, or wrap the name, from one page to the next. */
.cd-root > .shell.site-shell { max-width: 1080px; margin: 0 auto; padding: var(--space-5) var(--space-4); box-sizing: border-box; }

/* ---------- NavBar ---------- */
.cd-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-3) var(--space-5);
  background: var(--surface-raised);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}
.cd-nav__brand { display: inline-flex; align-items: center; gap: var(--space-2); color: var(--logo-ink); text-decoration: none; transition: color 0.15s ease; }
.cd-nav__logo { width: 28px; height: 28px; flex: none; }
.cd-nav__logo-bg { fill: var(--logo-bg); transition: fill 0.15s ease; }
.cd-nav__logo-ink { fill: var(--logo-ink); transition: fill 0.15s ease; }
.cd-nav__links { display: flex; align-items: center; gap: var(--space-5); list-style: none; margin: 0; padding: 0; }
.cd-nav__link { color: var(--ink); text-decoration: none; }
.cd-nav__link:hover { color: var(--secondary); }
.cd-nav__link--active { color: var(--primary); }

.cd-nav__lang-select {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--ink);
  padding: var(--space-1) var(--space-2);
  cursor: pointer;
}

.cd-nav__theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-pill);
  background: transparent;
  border: none;
  color: var(--ink);
  cursor: pointer;
}
.cd-nav__theme-toggle:hover { background: var(--surface-sunken); }
.cd-nav__theme-icon { width: 18px; height: 18px; }

.cd-nav__account { position: relative; }
.cd-nav__account > button.cd-nav__link {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  background: none;
  border: none;
  cursor: pointer;
  font: inherit;
}
.cd-nav__account-menu {
  position: absolute;
  top: calc(100% + var(--space-2));
  right: 0;
  min-width: 160px;
  display: flex;
  flex-direction: column;
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  z-index: 20;
}
.cd-nav__account-menu[hidden] { display: none; }
.cd-nav__account-link {
  display: block;
  width: 100%;
  padding: var(--space-3) var(--space-4);
  color: var(--ink);
  text-decoration: none;
  text-align: left;
  background: none;
  border: none;
  cursor: pointer;
  font: inherit;
}
.cd-nav__account-link:hover { background: var(--surface-sunken); }

/* The hamburger: only below 820px, where the links fold into a panel under
   the bar (menu.html toggles .cd-nav--open). */
.cd-nav__menu-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-pill);
  background: transparent;
  border: none;
  color: var(--ink);
  cursor: pointer;
}
.cd-nav__menu-toggle:hover { background: var(--surface-sunken); }
.cd-nav__menu-icon { width: 22px; height: 22px; }
.cd-nav__menu-icon--close { display: none; }
@media (max-width: 820px) {
  .cd-nav { position: relative; }
  .cd-nav__menu-toggle { display: inline-flex; }
  .cd-nav--open .cd-nav__menu-icon--open { display: none; }
  .cd-nav--open .cd-nav__menu-icon--close { display: block; }
  .cd-nav__links {
    display: none;
    position: absolute;
    top: calc(100% + var(--space-2));
    left: 0;
    right: 0;
    z-index: 30;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    padding: var(--space-2);
    background: var(--surface-raised);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
  }
  .cd-nav--open .cd-nav__links { display: flex; }
  .cd-nav__links > li { display: flex; align-items: center; }
  .cd-nav__links .cd-nav__link { display: block; width: 100%; padding: var(--space-3); border-radius: var(--radius-sm); }
  .cd-nav__links .cd-nav__link:hover { background: var(--surface-sunken); }
  .cd-nav__links .cd-nav__lang { padding: var(--space-2) var(--space-3); }
  .cd-nav__links .cd-nav__lang form, .cd-nav__links .cd-nav__lang-select { width: 100%; }
  .cd-nav__links .cd-nav__theme-toggle { margin: var(--space-1) var(--space-2); }
  .cd-nav__links .cd-btn { width: 100%; justify-content: center; margin-top: var(--space-2); }
  /* The account menu opens inside the panel instead of floating over it. */
  .cd-nav__links .cd-nav__account { flex-direction: column; align-items: stretch; }
  .cd-nav__links .cd-nav__account > button.cd-nav__link { justify-content: space-between; }
  .cd-nav__links .cd-nav__account-menu { position: static; box-shadow: none; border: none; min-width: 0; padding-left: var(--space-3); }
}

/* ---------- Hero ---------- */
.cd-hero {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  padding: var(--space-6);
  background: var(--surface-raised);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
}
.cd-hero__eyebrow { color: var(--secondary); }
.cd-hero__title { color: var(--ink); margin: 0; }
.cd-hero__subtitle { color: var(--ink-muted); margin: 0; max-width: 56ch; }
.cd-hero__actions { display: flex; gap: var(--space-3); flex-wrap: wrap; margin-top: var(--space-2); }

/* ---------- SessionCard (schedule item) ---------- */
.cd-session {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}
.cd-session__time { color: var(--secondary); }
.cd-session__title { color: var(--ink); margin: 0; }
.cd-session__meta { color: var(--ink-muted); display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; }

/* ---------- MentorCard ---------- */
.cd-mentor { display: flex; align-items: center; gap: var(--space-4); }
.cd-mentor__avatar {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-pill);
  background: var(--surface-sunken);
  border: 2px solid var(--border);
  flex-shrink: 0;
  display: block;
  object-fit: cover;
}
.cd-mentor__name { color: var(--ink); margin: 0; }
.cd-mentor__role { color: var(--ink-muted); margin: 0; }

/* ---------- Registration CTA panel ---------- */
.cd-cta {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  align-items: flex-start;
  padding: var(--space-6);
  background: var(--primary);
  color: var(--on-primary);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
}
.cd-cta__title { margin: 0; color: var(--on-primary); }
.cd-cta__subtitle { margin: 0; color: var(--on-primary); max-width: 52ch; }
.cd-cta .cd-btn--primary { background: var(--on-primary); color: var(--primary); }
.cd-cta .cd-btn--primary:hover { background: var(--surface-sunken); }

/* ---------- Sponsor grid ---------- */
.cd-sponsor-grid { display: flex; flex-wrap: wrap; gap: var(--space-5); align-items: center; }
.cd-sponsor-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 64px;
  padding: 0 var(--space-4);
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--ink-muted);
  text-decoration: none;
}
a.cd-sponsor-logo:hover { border-color: var(--ink-muted); color: var(--ink); }
.cd-sponsor-logo img { max-height: 40px; max-width: 140px; object-fit: contain; }

/* ---------- FAQ accordion ---------- */
.cd-faq { border-top: 1px solid var(--border); }
.cd-faq__item { border-bottom: 1px solid var(--border); }
.cd-faq__question {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  width: 100%;
  padding: var(--space-4) var(--space-2);
  background: transparent;
  border: none;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}
.cd-faq__icon { color: var(--secondary); transition: transform 0.15s ease; flex-shrink: 0; }
.cd-faq__item[data-open="true"] .cd-faq__icon { transform: rotate(45deg); }
.cd-faq__answer { color: var(--ink-muted); padding: 0 var(--space-2) var(--space-4); margin: 0; }
.cd-faq__answer[hidden] { display: none; }

/* ---------- Footer ---------- */
.cd-footer {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  padding: var(--space-6) var(--space-5);
  background: var(--surface-sunken);
  border-radius: var(--radius-lg);
  color: var(--ink-muted);
}
.cd-footer__links { display: flex; gap: var(--space-2) var(--space-5); flex-wrap: wrap; list-style: none; margin: 0; padding: 0; }
.cd-footer__links a { color: var(--ink-muted); text-decoration: underline; }
.cd-footer__links a:hover { color: var(--ink); }
.cd-footer p a { color: inherit; }
.cd-footer p a:hover { color: var(--ink); }

/* ---------- EventCard (Eventbrite-style listing tile) ---------- */
.cd-event {
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
}
.cd-event__image {
  position: relative;
  aspect-ratio: 16 / 10;
  background: var(--surface-sunken);
  border-radius: var(--radius-md) var(--radius-md) 0 0;
  overflow: hidden;
}
.cd-event__image img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.cd-event__date-badge {
  position: absolute;
  top: var(--space-3);
  left: var(--space-3);
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1.1;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  background: var(--primary);
  color: var(--on-primary);
  box-shadow: var(--shadow-sm);
}
.cd-event__body { padding: var(--space-4); display: flex; flex-direction: column; gap: var(--space-2); }
.cd-event__title { color: var(--ink); margin: 0; }
.cd-event__badges { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center; }
.cd-event__meta { color: var(--ink-muted); margin: 0; }
.cd-event__price { color: var(--success); margin-top: var(--space-1); }

/* ---------- TicketPanel (Eventbrite-style sticky sidebar) ---------- */
.cd-ticket-panel {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  padding: var(--space-6);
}
.cd-ticket-panel__row { display: flex; gap: var(--space-3); align-items: flex-start; }
.cd-ticket-panel__label { color: var(--ink-muted); min-width: 84px; }
.cd-ticket-panel__value { color: var(--ink); }
.cd-ticket-panel__divider { border: none; border-top: 1px solid var(--border); margin: 0; }
.cd-ticket-panel__price { color: var(--ink); margin: 0; }
.cd-ticket-panel__note { color: var(--ink-muted); margin: 0; }

.cd-ticket-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-3);
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-sm);
}
.cd-ticket-option__name { color: var(--ink); }
.cd-ticket-option__price { color: var(--ink-muted); }
.cd-ticket-option[data-disabled="true"] { opacity: 0.55; }

/* ---------- PathwayCard (Code Club-style "what you'll learn") ---------- */
.cd-pathway {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}
.cd-pathway__image {
  aspect-ratio: 4 / 3;
  background: var(--surface-sunken);
  border-radius: var(--radius-sm);
}
.cd-pathway__title { color: var(--ink); margin: 0; }
.cd-pathway__desc { color: var(--ink-muted); margin: 0; }
.cd-pathway__link {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  color: var(--secondary);
  text-decoration: none;
}
.cd-pathway__link:hover { color: var(--secondary-hover); }

/* ---------- Testimonial ---------- */
.cd-testimonial {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  padding: var(--space-6);
  margin: 0;
  background: var(--surface-raised);
  border-radius: var(--radius-lg);
}
.cd-testimonial__quote { color: var(--ink); margin: 0; }
.cd-testimonial__quote::before { content: "\201C"; color: var(--primary-bright); }
.cd-testimonial__quote::after { content: "\201D"; color: var(--primary-bright); }
.cd-testimonial__author { color: var(--ink-muted); margin: 0; }

/* ---------- Table ---------- */
.cd-table-wrap {
  overflow-x: auto;
  /* Keeps absolutely positioned content (a .visually-hidden header) inside the
     scrolling box, instead of widening the whole page. */
  position: relative;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}
.cd-table { width: 100%; border-collapse: collapse; min-width: 480px; }
/* A button in a row stays on one line ("Close registrations" wrapped inside its pill). */
.cd-table .cd-btn { white-space: nowrap; }
.cd-table thead th {
  padding: var(--space-3) var(--space-4);
  text-align: left;
  color: var(--ink-muted);
  background: var(--surface-raised);
  border-bottom: 1.5px solid var(--border-strong);
  white-space: nowrap;
}
.cd-table th[aria-sort] { cursor: pointer; user-select: none; }
.cd-table th[aria-sort] .cd-table__sort-icon {
  display: inline-block;
  margin-left: var(--space-1);
  color: var(--ink-muted);
  transition: transform 0.15s ease;
}
.cd-table th[aria-sort="descending"] .cd-table__sort-icon { transform: rotate(180deg); }
.cd-table th[aria-sort="none"] .cd-table__sort-icon { opacity: 0.4; }
.cd-table tbody td {
  padding: var(--space-3) var(--space-4);
  color: var(--ink);
  border-bottom: 1px solid var(--border);
}
.cd-table tbody tr:last-child td { border-bottom: none; }
.cd-table tbody tr:hover td { background: var(--surface-sunken); }
.cd-table--zebra tbody tr:nth-child(even) td { background: var(--surface-raised); }
.cd-table--zebra tbody tr:nth-child(even):hover td { background: var(--surface-sunken); }
.cd-table td.cd-table__num, .cd-table th.cd-table__num { text-align: right; }

/* ---------- Calendar (Outlook-style upcoming-events agenda: only dates with something on) ---------- */
.cd-calendar {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  padding: var(--space-4);
  width: 100%;
  max-width: 440px;
}
.cd-calendar__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}
.cd-calendar__title { color: var(--ink); margin: 0; }
.cd-calendar__nav {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: none;
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--ink-muted);
  cursor: pointer;
}
.cd-calendar__nav:hover { background: var(--surface-sunken); color: var(--ink); }

.cd-calendar__list { display: flex; flex-direction: column; gap: var(--space-5); }

/* A relative time bucket: "Today", "This week", "Next week", or a month name once far out */
.cd-calendar__period { display: flex; flex-direction: column; gap: var(--space-2); }
.cd-calendar__period-title {
  color: var(--ink-muted);
  margin: 0;
  padding: 0 var(--space-2);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.cd-calendar__dates { display: flex; flex-direction: column; gap: var(--space-3); }

/* One date that has something on it — never rendered for an empty day */
.cd-calendar__date { display: flex; flex-direction: column; }
.cd-calendar__date-header {
  display: flex;
  align-items: baseline;
  gap: var(--space-2);
  width: 100%;
  padding: var(--space-2);
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}
.cd-calendar__date-header:hover { background: var(--surface-sunken); }
.cd-calendar__date-weekday { color: var(--ink-muted); }
.cd-calendar__date-day { color: var(--ink); }

.cd-calendar__date--selected .cd-calendar__date-header,
.cd-calendar__date--selected .cd-calendar__date-header:hover {
  background: var(--primary);
}
.cd-calendar__date--selected .cd-calendar__date-weekday,
.cd-calendar__date--selected .cd-calendar__date-day { color: var(--on-primary); }
.cd-calendar__date--selected .cd-calendar__events { border-left-color: var(--primary); }

/* The events under one date, indented like a sub-list under its header */
.cd-calendar__events {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  margin-left: var(--space-4);
  padding-left: var(--space-4);
  border-left: 2px solid var(--border);
}
.cd-calendar__event {
  display: flex;
  align-items: baseline;
  gap: var(--space-3);
  padding: var(--space-1) var(--space-2);
}
.cd-calendar__event-time { color: var(--ink-muted); min-width: 64px; flex-shrink: 0; }
.cd-calendar__event-title { color: var(--ink); }

.cd-calendar__empty {
  color: var(--ink-muted);
  padding: var(--space-4) var(--space-2);
}

/* ---------- AwardCard (gamification: badges, streaks, milestones) ---------- */
.cd-award-grid { display: flex; flex-wrap: wrap; gap: var(--space-5); }
.cd-award {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: var(--space-2);
  padding: var(--space-5) var(--space-4);
  width: 184px;
}
.cd-award__badge {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 72px;
  height: 72px;
  border-radius: var(--radius-pill);
  flex-shrink: 0;
}
.cd-award__badge svg { width: 36px; height: 36px; }
.cd-award__badge--attendance { background: var(--secondary); color: var(--on-secondary); }
.cd-award__badge--skill { background: var(--primary); color: var(--on-primary); }
.cd-award__badge--milestone { background: var(--accent); color: var(--on-accent); }
.cd-award__badge--locked { background: var(--surface-sunken); color: var(--ink-muted); }

.cd-award__title { color: var(--ink); margin: 0; }
.cd-award__desc { color: var(--ink-muted); margin: 0; }
.cd-award__meta { color: var(--ink-muted); margin-top: var(--space-1); }

.cd-award--locked .cd-award__title { color: var(--ink-muted); }

.cd-award__progress {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  margin-top: var(--space-1);
}
.cd-award__progress-track {
  width: 100%;
  height: 6px;
  border-radius: var(--radius-pill);
  background: var(--surface-sunken);
  overflow: hidden;
}
.cd-award__progress-fill { height: 100%; background: var(--secondary); border-radius: inherit; }

/* ---------- Form (fieldset subgroups + repeatable child subgroups) ---------- */
.cd-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
}

/* Wrap one or more .cd-form__note in this when a submission has more than
   one — a tight stack of related messages, not separate form sections, so
   it gets its own small gap instead of inheriting .cd-form's space-6. */
.cd-form__notes { display: flex; flex-direction: column; gap: var(--space-2); }

/* Form-level note, aligned with Django's admin "errornote" convention: a
   bordered summary at the very top of the form, above every field, used
   when a whole submission needs attention rather than one control. */
.cd-form__note {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  border: 1.5px solid;
  border-radius: var(--radius-sm);
  background: var(--surface);
  margin: 0;
}
/* display: flex above would otherwise override the hidden attribute (e.g. the
   passkey error note that CoderDojo.initPasskey only shows on a failure). */
.cd-form__note[hidden] { display: none; }
.cd-form__note svg { width: 18px; height: 18px; flex-shrink: 0; margin-top: 1px; }
.cd-form__note--error { background: var(--danger-surface); border-color: var(--danger); color: var(--danger); }
.cd-form__note--warning { background: var(--warning-surface); border-color: var(--warning); color: var(--warning); }
.cd-form__note--success { background: var(--success-surface); border-color: var(--success); color: var(--success); }

/* A named section of the form — "Your details", "Children" */
.cd-form__group {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  padding: var(--space-5);
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}
.cd-form__group-title { color: var(--ink); margin: 0; }
.cd-form__group-desc { color: var(--ink-muted); margin: 0; margin-top: calc(var(--space-1) * -1); }

/* A repeatable nested subgroup inside a group — one per child */
.cd-form__subgroup {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding: var(--space-4);
  background: var(--surface);
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius-sm);
}
/* Children added on family sign-up: a gap, not two dashed borders touching. */
.cd-form__subgroup + .cd-form__subgroup { margin-top: var(--space-3); }
.cd-form__subgroup-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}
.cd-form__subgroup-title { color: var(--ink); margin: 0; }
.cd-form__remove {
  background: transparent;
  border: none;
  padding: var(--space-1) var(--space-2);
  color: var(--danger);
  cursor: pointer;
  text-decoration: underline;
}
.cd-form__remove:hover { color: var(--danger); opacity: 0.8; }

.cd-form__add-button {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  background: transparent;
  color: var(--secondary);
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.cd-form__add-button:hover { background: var(--surface-sunken); color: var(--secondary-hover); }

/* A row of fields laid side by side, wrapping on narrow widths */
.cd-form__row { display: flex; flex-wrap: wrap; gap: var(--space-4); }
.cd-form__field { display: flex; flex-direction: column; gap: var(--space-1); flex: 1 1 160px; min-width: 160px; }
/* flex: 1 1 160px is a width for fields side by side in a .cd-form__row. Stacked
   straight in a column (.cd-form, .cd-form__group) it would be a 160px minimum
   height, leaving a gap under a single input. */
.cd-form > .cd-form__field, .cd-form__group > .cd-form__field { flex: 0 0 auto; }

/* A radio or checkbox list (core/forms/field.html): a fieldset without the browser's box. */
.cd-form__fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
/* A help text can be a list (Django's password rules). */
.cd-form__help ul { margin: 0; padding-left: 1.2em; }
.cd-form__fieldset legend { padding: 0; margin-bottom: var(--space-1); }
/* A radio or checkbox in a list: at least 24px to tap (WCAG 2.5.8). */
.cd-form__fieldset input[type="radio"],
.cd-form__fieldset input[type="checkbox"] {
  width: 24px; height: 24px; margin: 0 var(--space-2) 0 0; vertical-align: middle; accent-color: var(--primary);
}
.cd-form__label { color: var(--ink); }
/* An upload with a current file (core/widgets/clearable_file_input.html). */
.cd-file-input { display: flex; flex-direction: column; gap: var(--space-2); }
.cd-file-input__current { color: var(--ink-muted); margin: 0; overflow-wrap: anywhere; }
.cd-file-input__current a { color: var(--secondary); }
.cd-form__required { color: var(--danger); margin-left: var(--space-1); }

.cd-form__input,
.cd-form__select,
.cd-form__textarea {
  padding: var(--space-2) var(--space-3);
  background: var(--surface);
  color: var(--ink);
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-family: var(--font-sans);
  width: 100%;
}
.cd-form__textarea { resize: vertical; min-height: 72px; }
.cd-form__input::placeholder, .cd-form__textarea::placeholder { color: var(--ink-muted); }
.cd-form__input:focus-visible,
.cd-form__select:focus-visible,
.cd-form__textarea:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
  border-color: var(--focus-ring);
}
.cd-form__input--invalid { border-color: var(--danger); }

.cd-form__help { color: var(--ink-muted); margin: 0; }

/* Per-field errors: a plain <ul> (like Django's own .errorlist) under the
   input and its help text (core/forms/_help_and_errors.html), able to hold
   more than one message. Under the input, an error never moves a sibling
   field's input in a .cd-form__row, as long as the row keeps its fields
   aligned at the top. */
.cd-form__errors { list-style: none; margin: 0; padding: 0; min-height: 18px; display: flex; flex-direction: column; gap: 2px; }
.cd-form__errors li { color: var(--danger); }
/* No errors: no reserved line. The list often sits between the label and the
   input, where an empty 18px line reads as a gap (e.g. family sign-up). */
.cd-form__errors:not(:has(li)) { display: none; }

.cd-form__checkbox-row {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
}
.cd-form__checkbox-row input[type="checkbox"] {
  accent-color: var(--primary);
  width: 24px; /* WCAG 2.5.8: a target of at least 24px */
  height: 24px;
  flex-shrink: 0;
  margin-top: 0;
}
.cd-form__checkbox-row label { color: var(--ink); }

/* A stack of .cd-form__checkbox-row's — e.g. a multi-select list of
   mentors, as opposed to .cd-form__checkbox-row used bare for a single
   consent checkbox. */
.cd-form__checkbox-list { display: flex; flex-direction: column; gap: var(--space-2); }

/* ---------- Template picker (a small gallery of bundled images to pick from,
   as an alternative to uploading your own — event banners, dojo icons) ---------- */
.cd-template-picker {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: var(--space-3);
}
.cd-template-picker__option {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  text-align: center;
}
.cd-template-picker__option:has(input:checked) {
  border-color: var(--primary);
  background: var(--surface-sunken);
}
.cd-template-picker__option input[type="radio"] { accent-color: var(--primary); }
.cd-template-picker__option-img {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: var(--radius-sm);
  background: var(--surface-sunken);
}
.cd-template-picker__option-none {
  width: 100%;
  aspect-ratio: 16 / 9;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  background: var(--surface-sunken);
  color: var(--ink-muted);
}
/* A round-icon picker (dojo icons) wants square/round tiles, not the
   16:9 banner aspect ratio above — override just the aspect ratio+shape. */
.cd-template-picker--round .cd-template-picker__option-img,
.cd-template-picker--round .cd-template-picker__option-none {
  aspect-ratio: 1 / 1;
  border-radius: 50%;
}

.cd-form__actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-3);
  flex-wrap: wrap;
}

/* ---------- AngledBanner (exact reproduction of the uploaded tilted-ribbon asset) ---------- */
/* The banner is drawn from the asset's own path geometry (viewBox 0 0 233.5 140.882:
   two hand-tilted navy tiles + the small arrow tile, all ~-14deg, exactly as cut in the
   original), with the vector-outlined lettering swapped for live, accessible <text> set
   in the display face — same shapes, real editable words. */
.cd-tilt-mark { display: block; width: 100%; height: auto; overflow: visible; }
.cd-tilt-mark__tile { fill: var(--ink-bright); }
.cd-tilt-mark__arrow { fill: var(--accent-bright); }
.cd-tilt-mark__text {
  font-family: var(--font-display);
  font-weight: 700;
  fill: #fff;
}

/* A standalone version of the small arrow tile, for reuse as an inline "next"/scroll
   cue elsewhere (before a link, between sections) — same navy, same -14deg tilt. */
.cd-tilt-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  background: var(--ink-bright);
  box-shadow: var(--shadow-sm);
  color: var(--accent-bright);
  transform: rotate(-14deg);
}
.cd-tilt-chip svg { width: 20px; height: 20px; }
.cd-tilt-chip--sm { width: 32px; height: 32px; }
.cd-tilt-chip--sm svg { width: 14px; height: 14px; }

/* ---------- Login (account sign-in panel) ---------- */
.cd-login {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
  width: 100%;
  max-width: 380px;
}
.cd-login__header { display: flex; flex-direction: column; gap: var(--space-1); }
.cd-login__title { color: var(--ink); margin: 0; }
.cd-login__subtitle { color: var(--ink-muted); margin: 0; }

.cd-login__fields { display: flex; flex-direction: column; gap: var(--space-4); }
.cd-login__fields .cd-form__field { flex: none; }

.cd-login__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  flex-wrap: wrap;
}
.cd-login__forgot { color: var(--secondary); text-decoration: none; }
.cd-login__forgot:hover { color: var(--secondary-hover); text-decoration: underline; }

.cd-login__footer { color: var(--ink-muted); margin: 0; text-align: center; }
.cd-login__footer a { color: var(--secondary); text-decoration: none; }
.cd-login__footer a:hover { text-decoration: underline; }

/* ---------- Wizard (a multi-step shell for splitting a long form, e.g. registration) ---------- */
.cd-wizard {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
  width: 100%;
  max-width: 480px;
}

.cd-wizard__steps { display: flex; align-items: flex-start; list-style: none; margin: 0; padding: 0; }
.cd-wizard__step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  flex: 1;
  position: relative;
  text-align: center;
}
/* The connecting line either side of a step's circle — each half colors independently,
   so the colored line always ends exactly at the current step, never past it. */
.cd-wizard__step::before,
.cd-wizard__step::after {
  content: "";
  position: absolute;
  top: 15px;
  width: 50%;
  height: 2px;
  background: var(--border-strong);
}
.cd-wizard__step::before { left: 0; }
.cd-wizard__step::after { left: 50%; }
.cd-wizard__step:first-child::before { display: none; }
.cd-wizard__step:last-child::after { display: none; }
.cd-wizard__step--complete::before,
.cd-wizard__step--complete::after,
.cd-wizard__step--current::before { background: var(--primary); }

.cd-wizard__step-index {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-pill);
  border: 2px solid var(--border-strong);
  background: var(--surface);
  color: var(--ink-muted);
  position: relative;
  z-index: 1;
}
.cd-wizard__step-index svg { width: 16px; height: 16px; }
.cd-wizard__step--current .cd-wizard__step-index { border-color: var(--primary); color: var(--primary); }
.cd-wizard__step--complete .cd-wizard__step-index { border-color: var(--primary); background: var(--primary); color: var(--on-primary); }

.cd-wizard__step-label { color: var(--ink-muted); }
.cd-wizard__step--current .cd-wizard__step-label,
.cd-wizard__step--complete .cd-wizard__step-label { color: var(--ink); }

/* A text fallback for narrow widths, where the full step row gets cramped */
.cd-wizard__progress-text { display: none; color: var(--ink-muted); margin: 0; }
@media (max-width: 420px) {
  .cd-wizard__steps { display: none; }
  .cd-wizard__progress-text { display: block; }
}

.cd-wizard__panel { display: flex; flex-direction: column; gap: var(--space-4); padding: var(--space-6); }
.cd-wizard__panel-title { color: var(--ink); margin: 0; }
.cd-wizard__panel-desc { color: var(--ink-muted); margin: 0; }

.cd-wizard__actions { display: flex; justify-content: space-between; gap: var(--space-3); }

/* ---------- SearchTable (a search field that live-filters the table beneath it) ---------- */
.cd-search-table { display: flex; flex-direction: column; gap: var(--space-4); }

.cd-search-table__bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  flex-wrap: wrap;
}
.cd-search-table__field { position: relative; flex: 1; min-width: 200px; }
.cd-search-table__icon {
  position: absolute;
  left: var(--space-3);
  top: 50%;
  transform: translateY(-50%);
  color: var(--ink-muted);
  pointer-events: none;
  display: flex;
}
.cd-search-table__icon svg { width: 16px; height: 16px; }
.cd-search-table__input {
  width: 100%;
  padding: var(--space-2) var(--space-3) var(--space-2) calc(var(--space-3) * 2 + 16px);
  background: var(--surface);
  color: var(--ink);
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-family: var(--font-sans);
}
.cd-search-table__input::placeholder { color: var(--ink-muted); }
.cd-search-table__input:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
  border-color: var(--focus-ring);
}
.cd-search-table__input::-webkit-search-cancel-button { -webkit-appearance: none; appearance: none; }

.cd-search-table__count { color: var(--ink-muted); white-space: nowrap; }

.cd-search-table__empty {
  padding: var(--space-6) var(--space-4);
  text-align: center;
  color: var(--ink-muted);
}

/* ---------- Search forms of the finder pages (dojos, events): one look ---------- */
/* A card of labelled fields that wrap to fill each line (the location first
   and wider, with a pin), the buttons at the end of the last line. Used by
   dojos/dojo_list.html and events/event_list.html, so the two pages read as
   one design. */
.cd-search { padding: var(--space-5); margin-bottom: var(--space-6); }
.cd-search__fields { display: flex; flex-wrap: wrap; gap: var(--space-4); align-items: flex-end; }
.cd-search__field { flex: 1 1 170px; display: flex; flex-direction: column; gap: var(--space-1); min-width: 0; }
.cd-search__field--wide { flex: 2 1 260px; }
.cd-search__label { color: var(--ink-muted); }
.cd-search__actions { flex: 0 0 auto; margin-left: auto; display: flex; flex-wrap: wrap; gap: var(--space-3); }
@media (max-width: 560px) {
  .cd-search__actions { flex: 1 1 100%; }
  .cd-search__actions .cd-btn { flex: 1 1 auto; justify-content: center; }
}

/* The filters a search applies, under its form (core/partials/_active_filters.html):
   one removable chip each, and "Clear all" when there's more than one. */
.cd-active-filters {
  display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2);
  margin: calc(var(--space-6) * -1 + var(--space-4)) 0 var(--space-5);
}
.cd-active-filters__intro { color: var(--ink-muted); }
.cd-active-filters__list { display: contents; list-style: none; }
.cd-filter-chip {
  display: inline-flex; align-items: center; gap: var(--space-2);
  background: var(--surface-sunken); border-radius: var(--radius-pill);
  padding: var(--space-1) var(--space-1) var(--space-1) var(--space-3);
  color: var(--ink);
}
.cd-filter-chip a {
  color: var(--ink-muted); text-decoration: none;
  width: 24px; height: 24px; border-radius: 50%; font-size: 16px; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center;
}
.cd-filter-chip a:hover { background: var(--border); color: var(--ink); }
.cd-filter-chip a:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 1px; }
.cd-active-filters__clear { color: var(--ink-muted); margin-left: var(--space-1); }
.cd-active-filters__clear:hover { color: var(--ink); }

/* The location field's pin: inside the input, on the left (also the
   homepage's compact dojo finder, .cd-dojo-finder__field). */
.cd-search__location { position: relative; }
.cd-search__location > svg {
  position: absolute;
  left: var(--space-3);
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--ink-muted);
  pointer-events: none;
}
.cd-search__location .cd-form__input,
.cd-dojo-finder__field .cd-form__input { padding-left: calc(var(--space-3) * 2 + 16px); }

/* ---------- DojoFinder ("find a dojo near you", sorted by distance) ---------- */
.cd-dojo-finder {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
  width: 100%;
  max-width: 520px;
}

.cd-dojo-finder__bar { display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap; }
.cd-dojo-finder__field { position: relative; flex: 1; min-width: 200px; }
.cd-dojo-finder__icon {
  position: absolute;
  left: var(--space-3);
  top: 50%;
  transform: translateY(-50%);
  color: var(--ink-muted);
  display: flex;
  /* It's a real submit button (the search field's icon doubles as the
     search action), so reset the browser's default button chrome —
     otherwise its own padding/border pushes it wider than the input's
     padding-left leaves room for, and it overlaps the typed text. */
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  /* A 24px target around the 16px icon (WCAG 2.5.8), centred where the icon was. */
  min-width: 24px;
  min-height: 24px;
  margin-left: -4px;
  align-items: center;
  justify-content: center;
}
.cd-dojo-finder__icon svg { width: 16px; height: 16px; }

.cd-dojo-finder__meta { color: var(--ink-muted); margin: 0; }

.cd-dojo-finder__list { display: flex; flex-direction: column; gap: var(--space-3); list-style: none; margin: 0; padding: 0; }

.cd-dojo-finder__result { display: flex; align-items: center; gap: var(--space-4); }

/* The distance is the whole point of this list, so it leads every row — same
   leading-badge shape as EventCard's date badge, but always on `primary` (not
   `primary-bright`), since the unit label underneath is small text. */
.cd-dojo-finder__distance {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  line-height: 1.1;
  padding: var(--space-2) 0;
  border-radius: var(--radius-sm);
  background: var(--primary);
  color: var(--on-primary);
  flex-shrink: 0;
  /* A fixed width (fits "248.7"), so the names line up whatever the distance. */
  width: 64px;
  box-sizing: border-box;
}

.cd-dojo-finder__info { flex: 1; display: flex; flex-direction: column; gap: var(--space-1); min-width: 0; }
.cd-dojo-finder__name { color: var(--ink); margin: 0; }
.cd-dojo-finder__address { color: var(--ink-muted); margin: 0; }
.cd-dojo-finder__next { color: var(--ink-muted); margin: 0; display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; }

.cd-dojo-finder__empty {
  padding: var(--space-6) var(--space-4);
  text-align: center;
  color: var(--ink-muted);
}

/* ---------- AttendanceList (quick Present/Absent flagging during a session) ---------- */
.cd-attendance { display: flex; flex-direction: column; gap: var(--space-4); }

.cd-attendance__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  flex-wrap: wrap;
}
.cd-attendance__title { color: var(--ink); margin: 0; }
.cd-attendance__summary { color: var(--ink-muted); margin: 0; }

.cd-attendance__list { display: flex; flex-direction: column; }
/* A row's "Award belt" / "Award badge" form (AwardBeltForm, AwardBadgeForm). */
.cd-attendance__award { display: flex; flex-direction: column; align-items: flex-start; gap: var(--space-2); margin-top: var(--space-2); max-width: 320px; }
.cd-attendance__award .cd-form__field { flex: 0 0 auto; align-self: stretch; }
.cd-attendance__add { margin-top: var(--space-3); padding: var(--space-3); border: 1px dashed var(--border); border-radius: var(--radius-md, 8px); }
.cd-attendance__add > summary { cursor: pointer; min-height: 24px; }
.cd-attendance__add-form { margin-top: var(--space-3); }
.cd-attendance__team-title { color: var(--ink-muted); margin: var(--space-5) 0 var(--space-2); text-transform: uppercase; letter-spacing: 0.04em; }
.cd-attendance__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-2);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.cd-attendance__row:last-child { border-bottom: none; }

.cd-attendance__person { display: flex; flex-direction: column; gap: 2px; min-width: 120px; }
.cd-attendance__name { color: var(--ink); }
.cd-attendance__meta { color: var(--ink-muted); }
/* The yes/no sign-up questions card (dojos/partials/_questions_card.html):
   a session's page and the dojo's Settings page. */
.questions-card { margin: var(--space-5) 0; max-width: 720px; }
.questions-card__head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-4); flex-wrap: wrap; }
.questions-card__head h2 { margin: 0; }
.questions-card__count, .questions-card__help, .questions-card__totals { color: var(--ink-muted); }
.questions-card__help { margin: var(--space-1) 0 0; }
.questions-card__list { list-style: none; margin: var(--space-3) 0 0; padding: 0; display: flex; flex-direction: column; }
.questions-card__question { padding: var(--space-3) 0; border-top: 1px solid var(--border); }
.questions-card__question-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); flex-wrap: wrap; }
.questions-card__text { flex: 1 1 16rem; min-width: 0; overflow-wrap: anywhere; }
.questions-card__actions { display: flex; gap: var(--space-1); flex-wrap: wrap; }
.questions-card__totals { margin: var(--space-1) 0 0; }
.questions-card__edit, .questions-card__add { margin-top: var(--space-2); }
.questions-card__edit summary, .questions-card__add summary { cursor: pointer; min-height: 24px; color: var(--secondary); }
.questions-card__edit .cd-form, .questions-card__add .cd-form { margin-top: var(--space-3); }
.questions-card__empty { margin: var(--space-3) 0 0; }
/* The session's yes/no sign-up questions (events.questions): totals above
   the list, each child's answers as badges with the question shortened. */
.cd-attendance__questions { list-style: none; margin: var(--space-1) 0 0; padding: 0; color: var(--ink-muted); }
.cd-attendance__answers { display: flex; flex-wrap: wrap; gap: var(--space-1); margin-top: var(--space-1); }
.cd-attendance__answers-form { display: flex; flex-direction: column; gap: var(--space-2); margin-top: var(--space-2); }
.cd-attendance__answers-form label { display: inline-flex; align-items: center; min-height: 24px; margin-right: var(--space-3); }
.cd-attendance__answer-q { display: inline-block; max-width: 14em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: bottom; }

/* A two-button segmented toggle, sized for a thumb — this is the whole point
   of the component, so it's the biggest tap target on the row. */
.cd-attendance__toggle {
  display: inline-flex;
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-pill);
  overflow: hidden;
  flex-shrink: 0;
}
.cd-attendance__btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-2) var(--space-4);
  min-height: 40px;
  background: var(--surface);
  color: var(--ink-muted);
  border: none;
  cursor: pointer;
}
.cd-attendance__btn:first-child { border-right: 1.5px solid var(--border-strong); }
.cd-attendance__btn svg { width: 16px; height: 16px; }
.cd-attendance__btn:hover { background: var(--surface-sunken); }
.cd-attendance__btn--present[aria-pressed="true"] { background: var(--success); color: var(--on-success); }
.cd-attendance__btn--absent[aria-pressed="true"] { background: var(--danger); color: var(--on-danger); }

/* ---------- MagicLink (passwordless email sign-in, built on the Login shell) ---------- */
/* .cd-magic-link reuses .cd-card and .cd-login__header/footer as-is; only the
   two swappable panels below are new. */
.cd-magic-link__panel { display: flex; flex-direction: column; gap: var(--space-4); }
.cd-magic-link__panel[hidden] { display: none; }

.cd-magic-link__icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  border-radius: var(--radius-pill);
  background: var(--surface-sunken);
  color: var(--secondary);
  flex-shrink: 0;
}
.cd-magic-link__icon svg { width: 26px; height: 26px; }

.cd-magic-link__sent-title { color: var(--ink); margin: 0; }
.cd-magic-link__sent-text { color: var(--ink-muted); margin: 0; }
.cd-magic-link__email { color: var(--ink); font-weight: 700; }

.cd-magic-link__status {
  color: var(--success);
  margin: 0;
  min-height: 18px;
}

.cd-magic-link__resend {
  align-self: flex-start;
  background: transparent;
  border: none;
  padding: 0;
  color: var(--secondary);
  text-decoration: underline;
  cursor: pointer;
}
.cd-magic-link__resend:hover { color: var(--secondary-hover); }
.cd-magic-link__resend:disabled { color: var(--ink-muted); text-decoration: none; cursor: not-allowed; }

.cd-magic-link__change { color: var(--secondary); }

/* ---------- Notification (bell + dropdown panel) ---------- */
.cd-notif { position: relative; display: inline-block; }

.cd-notif__bell {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-pill);
  background: transparent;
  border: none;
  color: var(--ink);
  cursor: pointer;
}
.cd-notif__bell svg { width: 20px; height: 20px; }
.cd-notif__bell:hover { background: var(--surface-sunken); }
.cd-notif__bell:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }

.cd-notif__count {
  position: absolute;
  top: 2px;
  right: 2px;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  border-radius: var(--radius-pill);
  background: var(--danger);
  color: var(--on-danger);
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
  box-shadow: 0 0 0 2px var(--surface-raised);
}
.cd-notif__count[hidden] { display: none; }

.cd-notif__panel {
  position: absolute;
  top: calc(100% + var(--space-2));
  right: 0;
  width: 336px;
  max-width: calc(100vw - var(--space-5));
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  z-index: 20;
}
.cd-notif__panel[hidden] { display: none; }

.cd-notif__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border);
}
.cd-notif__title { color: var(--ink); margin: 0; }
.cd-notif__mark-all {
  background: transparent;
  border: none;
  padding: 0;
  color: var(--secondary);
  text-decoration: underline;
  cursor: pointer;
}
.cd-notif__mark-all:hover { color: var(--secondary-hover); }
.cd-notif__mark-all:disabled { color: var(--ink-muted); text-decoration: none; cursor: not-allowed; }

.cd-notif__list { list-style: none; margin: 0; padding: 0; max-height: 340px; overflow-y: auto; }

.cd-notif__item-btn {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  width: 100%;
  padding: var(--space-3) var(--space-4);
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--border);
  text-align: left;
  cursor: pointer;
  font-family: var(--font-sans);
}
.cd-notif__list li:last-child .cd-notif__item-btn { border-bottom: none; }
.cd-notif__item-btn:hover { background: var(--surface-sunken); }
.cd-notif__item-btn:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: -2px; }

.cd-notif__dot {
  width: 8px;
  height: 8px;
  border-radius: var(--radius-pill);
  background: var(--secondary);
  margin-top: 6px;
  flex-shrink: 0;
}
/* Read items keep the dot's layout space so text doesn't shift, just hide it */
.cd-notif__item:not([data-unread]) .cd-notif__dot { visibility: hidden; }

.cd-notif__body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.cd-notif__text { color: var(--ink); margin: 0; }
.cd-notif__item:not([data-unread]) .cd-notif__text { color: var(--ink-muted); }
.cd-notif__time { color: var(--ink-muted); margin: 0; }

.cd-notif__empty { padding: var(--space-5) var(--space-4); color: var(--ink-muted); text-align: center; margin: 0; }

/* ---------- AdminNav (left sidebar for the dojo owner's admin area) ---------- */
/* Plain Heading/Body throughout, same reasoning as Login: this is a utility
   screen an owner uses daily, not a marketing moment for the display face. */
.cd-admin-nav-shell { position: relative; }

.cd-admin-nav__toggle {
  display: inline-flex;;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--ink);
  cursor: pointer;
}
.cd-admin-nav__toggle svg { width: 18px; height: 18px; }
.cd-admin-nav__toggle:disabled { opacity: 0.5; cursor: not-allowed; }

.cd-admin-nav__backdrop { display: none; }

.cd-admin-nav {
  display: flex;
  flex-direction: column;
  width: 240px;
  min-width: 240px;
  /* No explicit height — .cd-admin-nav-shell's default flex
     align-items: stretch already grows this to match .admin-main's full
     (natural, unconstrained) height, so the sidebar's background/border
     run the whole length of the page instead of stopping at the viewport. */
  background: var(--surface-raised);
  border-right: 1px solid var(--border);
  padding: var(--space-4) 0;
  box-sizing: border-box;
}

.cd-admin-nav__brand {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-2);
  padding: 0 var(--space-4) var(--space-4);
  margin-bottom: var(--space-3);
  border-bottom: 1px solid var(--border);
}
.cd-admin-nav__brand-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.cd-admin-nav__brand-name { color: var(--ink); margin: 0; }
.cd-admin-nav__brand-role { color: var(--ink-muted); margin: 0; }

/* The dojo switcher replaces the plain .cd-admin-nav__brand-text with a
   button when the signed-in owner has more than one dojo — same dropdown
   panel look as .cd-nav__account-menu (core/templates/core/menu.html),
   just anchored to the sidebar's brand area instead of the top nav. */
.cd-admin-nav__switcher { position: relative; min-width: 0; flex: 1 1 auto; }
.cd-admin-nav__switcher-toggle {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-2);
  width: 100%;
  padding: 0;
  background: none;
  border: none;
  cursor: pointer;
  font: inherit;
  text-align: left;
  color: inherit;
}
.cd-admin-nav__switcher-toggle:hover .cd-admin-nav__brand-name { color: var(--primary); }
.cd-admin-nav__switcher-chevron { width: 16px; height: 16px; flex-shrink: 0; margin-top: 3px; color: var(--ink-muted); transition: transform 0.15s ease; }
.cd-admin-nav__switcher-toggle[aria-expanded="true"] .cd-admin-nav__switcher-chevron { transform: rotate(180deg); }
.cd-admin-nav__switcher-menu {
  position: absolute;
  top: calc(100% + var(--space-2));
  left: 0;
  min-width: 200px;
  max-width: 260px;
}
.cd-admin-nav__switcher-menu[hidden] { display: none; }
.cd-admin-nav__switcher-link--current { color: var(--primary); font-weight: 600; }
/* The switcher's groups (the organisation, organisation events, your
   dojos: core/templates/core/partials/_manage_switcher.html). */
.cd-admin-nav__switcher-group {
  margin: 0;
  padding: var(--space-3) var(--space-4) var(--space-1);
  color: var(--ink-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.cd-admin-nav__switcher-group:not(:first-child) { border-top: 1px solid var(--border); }

/* Only meaningful once there's a collapse to lock against, so it only
   shows at the same 901px+ width the collapse feature itself applies at. */
.cd-admin-nav__pin {
  display: none;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  border: none;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--ink-muted);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}
.cd-admin-nav__pin svg { width: 16px; height: 16px; }
.cd-admin-nav__pin:hover { background: var(--surface-sunken); }
.cd-admin-nav__pin:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }
.cd-admin-nav__pin[aria-pressed="true"] { color: var(--primary); background: var(--surface-sunken); }

/* A flex item (not cd-btn--block) so it stretches via the column's default
   align-items: stretch, which correctly subtracts these margins — combining
   cd-btn--block's own width:100% with margins here would overflow instead. */
.cd-admin-nav__create { margin: 0 var(--space-4) var(--space-5); justify-content: center; }
.cd-admin-nav__create svg { width: 18px; height: 18px; flex-shrink: 0; }

.cd-admin-nav__group { margin-bottom: var(--space-5); padding: 0 var(--space-3); }
.cd-admin-nav__group-label {
  color: var(--ink-muted);
  margin: 0 0 var(--space-2);
  padding: 0 var(--space-2);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.cd-admin-nav__list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }

.cd-admin-nav__link {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  border-left: 3px solid transparent;
  color: var(--ink);
  text-decoration: none;
}
.cd-admin-nav__link svg { width: 18px; height: 18px; flex-shrink: 0; color: var(--ink-muted); }
.cd-admin-nav__link:hover { background: var(--surface-sunken); }
.cd-admin-nav__link:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }

/* Active state leans on weight + icon color + a left accent bar, not on
   primary-colored text — primary text only reaches 4.2:1 against this
   sunken background, short of the 4.5:1 small text needs. */
.cd-admin-nav__link--active {
  background: var(--surface-sunken);
  border-left-color: var(--primary);
  color: var(--ink);
  font-weight: 700;
}
.cd-admin-nav__link--active svg { color: var(--primary); }

.cd-admin-nav__count {
  margin-left: auto;
  background: var(--surface);
  color: var(--ink-muted);
  font-size: 11px;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: var(--radius-pill);
  flex-shrink: 0;
}

.cd-admin-nav__footer {
  margin-bottom: auto;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-4) 0;
  border-top: 1px solid var(--border);
  padding-top: var(--space-4);
}
.cd-admin-nav__avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-pill);
  background: var(--secondary);
  color: var(--on-secondary);
  font-weight: 700;
  font-size: 13px;
  flex-shrink: 0;
}
.cd-admin-nav__footer-info { display: flex; flex-direction: column; gap: 0; min-width: 0; }
.cd-admin-nav__footer-name { color: var(--ink); margin: 0; }
.cd-admin-nav__signout {
  margin-left: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  color: var(--ink-muted);
  flex-shrink: 0;
}
.cd-admin-nav__signout svg { width: 18px; height: 18px; }
.cd-admin-nav__signout:hover { background: var(--surface-sunken); color: var(--danger); }

@media (max-width: 900px) {
  .cd-admin-nav__toggle { display: inline-flex; }
  .cd-admin-nav__backdrop[data-open="true"] {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(12, 16, 21, 0.5);
    z-index: 30;
  }
  .cd-admin-nav {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 31;
    height: 100vh;
    box-shadow: var(--shadow-lg);
    transform: translateX(-100%);
    transition: transform 0.2s ease;
  }
  .cd-admin-nav[data-open="true"] { transform: translateX(0); }
}
/* At desktop widths the same toggle collapses the sidebar in place instead
   of opening it as a drawer, so the content column can use the full width.
   Collapsed to a zero-width column (not display:none) so it can transition;
   JS also sets `inert` on the nav itself so it can't be focused while
   collapsed, since a width/opacity collapse alone leaves it tabbable. */
@media (min-width: 901px) {
  .cd-admin-nav__pin { display: inline-flex; }
  .cd-admin-nav {
    transition: width 0.2s ease, min-width 0.2s ease, padding 0.2s ease, opacity 0.2s ease, border-color 0.2s ease;
  }
  .cd-admin-nav-shell[data-collapsed="true"] .cd-admin-nav {
    width: 0;
    min-width: 0;
    padding: 0;
    opacity: 0;
    overflow: hidden;
    border-right-color: transparent;
  }
}
/* Respect reduced motion */
@media (prefers-reduced-motion: reduce) {
  .cd-faq__icon { transition: none; }
  .cd-table__sort-icon { transition: none; }
  .cd-admin-nav { transition: none; }
}
/* ---------- Promotion (content.Promotion placements) ---------- */
.cd-promo-list { display: flex; flex-direction: column; gap: var(--space-3); margin-bottom: var(--space-5); }
.cd-promo {
  display: flex;
  gap: var(--space-5);
  align-items: center;
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-left: 4px solid var(--primary-bright);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
}
.cd-promo--hero { margin-top: var(--space-5); }
.cd-promo__image { flex: 0 0 auto; object-fit: cover; border-radius: var(--radius-md); }
.cd-promo__body { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: var(--space-2); }
.cd-promo__eyebrow { color: var(--secondary); margin: 0; }
.cd-promo__title { color: var(--ink); margin: 0; }
.cd-promo__text { color: var(--ink); margin: 0; }
.cd-promo__meta { color: var(--ink-muted); margin: 0; }
.cd-promo__meta a { color: var(--secondary); }
.cd-promo__actions { display: flex; gap: var(--space-3); flex-wrap: wrap; margin-top: var(--space-2); }
.cd-promo__link { flex: 0 0 auto; }
.cd-promo--hero { padding: var(--space-6); box-shadow: var(--shadow-md); }
.cd-promo--hero .cd-promo__image { width: 280px; height: 200px; }
.cd-promo--banner .cd-promo__image { width: 72px; height: 72px; }
/* A homepage_hero promotion in the featured-events carousel: the same wide
   card, one per view (the carousel's own margin replaces the card's). */
.cd-promo--slide { margin-top: 0; }
@media (max-width: 640px) {
  .cd-promo { flex-direction: column; align-items: stretch; }
  .cd-promo--hero .cd-promo__image { width: 100%; height: 180px; }
  .cd-promo--banner .cd-promo__image { display: none; }
}

/* --- Accessibility helpers -------------------------------------------------------
   Text for screen readers only (an empty-looking table header, an icon's name), and
   the "Skip to content" link: off-screen until it gets keyboard focus. */
.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}
.cd-skip-link {
  position: absolute;
  left: var(--space-3);
  top: -200px;
  z-index: 1000;
  padding: var(--space-2) var(--space-4);
  background: var(--surface, #fff);
  color: var(--ink);
  border: 2px solid var(--accent);
  border-radius: var(--radius-md, 8px);
  text-decoration: none;
}
.cd-skip-link:focus { top: var(--space-3); }
/* The skip link's target: focused from a script, not something to click. */
main:focus { outline: none; }
/* A plain link in running text (no class of its own) uses the site's link colour in
   both themes: the browser's default blue is 1.9:1 on the dark surface. :where() keeps
   this weaker than any link style a component sets. */
:where(.cd-root a:not([class])) { color: var(--secondary); }
:where(.cd-root a:not([class]):hover) { color: var(--secondary-hover); }
/* The attendance row's Award belt / Award badge / Pathways toggles: a 24px target. */
.cd-attendance details > summary { padding: var(--space-1) 0; cursor: pointer; }

/* ---------------------------------------------------------------------------
   The chat app (conversations, DATA_MODEL_MESSAGES.md §32): the list and the
   open chat side by side on wide screens, one at a time on a phone. Your own
   messages on the right in the brand colour, the other side's on the left.
   Text on a primary bubble is always --on-primary (never faded), and the other
   side's bubbles sit on --surface-raised, where --ink-muted keeps 4.5:1. */
/* The end-user design's page head above it: the display-lg title in the site's
   column, the tools on the right (in a dojo's admin area the shell's top bar has both). */
.cd-chat-head { width: min(1080px - 2 * var(--space-4), 100% - 2 * var(--space-4)); margin: var(--space-5) auto var(--space-4); display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: var(--space-2) var(--space-4); }
.cd-chat-head h1 { margin: 0; color: var(--ink); }
/* The frame: a card in the site's column (1080px, like the menu above it), or the
   admin area's content width in a dojo's admin area (cd-chat--admin). The list on
   the raised surface like the admin sidebar, the open chat on the page surface. */
.cd-chat { display: grid; grid-template-columns: minmax(260px, 340px) minmax(0, 1fr); height: calc(100dvh - 280px); min-height: 440px; width: min(1080px - 2 * var(--space-4), 100% - 2 * var(--space-4)); margin: 0 auto; box-sizing: border-box; border: 1px solid var(--border); border-radius: var(--radius-md); overflow: hidden; background: var(--surface); box-shadow: var(--shadow-sm); }
.cd-chat--admin { width: auto; height: calc(100dvh - 210px); }
/* In a dojo's admin area every chat is that dojo's: no need to name it on each row. */
.cd-chat--admin .cd-chat__row-dojo { display: none; }
.cd-chat__list { border-right: 1px solid var(--border); overflow-y: auto; padding: var(--space-4) var(--space-3); background: var(--surface-raised); }
.cd-chat__list-links { display: flex; flex-wrap: wrap; gap: 0 var(--space-3); }
/* Text links in the list's head and the admin area's scope line: the site's link colour, a 24px target. */
.cd-chat__tool { display: inline-flex; align-items: center; min-height: 24px; color: var(--secondary); text-decoration: none; }
.cd-chat__tool:hover { color: var(--secondary-hover); text-decoration: underline; }
/* A link inside a sentence keeps its underline (WCAG 1.4.1, axe: link-in-text-block). */
.cd-chat__scope a { color: var(--secondary); }
.cd-chat__scope a:hover { color: var(--secondary-hover); }
.cd-chat__scope { margin: 0 var(--space-2) var(--space-3); color: var(--ink-muted); }
.cd-chat__section { color: var(--ink-muted); text-transform: uppercase; letter-spacing: .04em; margin: var(--space-4) var(--space-2) var(--space-2); font-size: inherit; }
.cd-chat__rows { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.cd-chat__row-link { display: flex; gap: var(--space-3); align-items: center; padding: var(--space-2); border-radius: var(--radius-sm); color: var(--ink); text-decoration: none; min-height: 48px; }
.cd-chat__row-link:hover { background: var(--surface-sunken); }
/* The open chat: the same mark as the admin sidebar's active link. */
.cd-chat__row--open .cd-chat__row-link { background: var(--surface); box-shadow: inset 3px 0 0 var(--primary), var(--shadow-sm); }
.cd-chat__avatar { flex: none; width: 40px; height: 40px; border-radius: 50%; object-fit: cover; }
.cd-chat__avatar--letter { display: grid; place-items: center; background: var(--surface-sunken); color: var(--ink); font-weight: 700; }
.cd-chat__row--open .cd-chat__avatar--letter { background: var(--surface-raised); }
.cd-chat__row-main { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.cd-chat__row-title, .cd-chat__row-preview { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cd-chat__row-sub, .cd-chat__row-preview { color: var(--ink-muted); }
.cd-chat__row--unread .cd-chat__row-title, .cd-chat__row--unread .cd-chat__row-preview { color: var(--ink); font-weight: 700; }
.cd-chat__row-meta { display: flex; flex-direction: column; align-items: flex-end; gap: var(--space-1); color: var(--ink-muted); flex: none; }
.cd-chat__row-meta .cd-badge { padding: 0 var(--space-2); }
.cd-chat__dot { width: 10px; height: 10px; border-radius: 50%; background: var(--primary); }
.cd-chat__empty { color: var(--ink-muted); margin: var(--space-3) var(--space-2); }
.cd-chat__pane { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--surface); }
.cd-chat__placeholder { margin: auto; text-align: center; padding: var(--space-6); color: var(--ink-muted); max-width: 420px; }
.cd-chat__header { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--border); background: var(--surface); }
.cd-chat__heading { flex: 1; min-width: 0; }
.cd-chat__heading h2 { margin: 0; color: var(--ink); }
.cd-chat__subtitle { margin: 0; color: var(--ink-muted); }
.cd-chat__back { display: none; color: var(--secondary); }
.cd-chat__menu { position: relative; }
.cd-chat__menu > summary { list-style: none; padding: calc(var(--space-2) - 2px) calc(var(--space-4) - 2px); min-height: 32px; box-sizing: border-box; }
.cd-chat__menu > summary::-webkit-details-marker { display: none; }
.cd-chat__menu-panel, .cd-chat__actions-panel { position: absolute; right: 0; z-index: 5; min-width: 220px; display: flex; flex-direction: column; gap: var(--space-1); padding: var(--space-2); background: var(--surface-raised); border: 1px solid var(--border); border-radius: var(--radius-sm); box-shadow: var(--shadow-md); }
.cd-chat__mute { display: flex; flex-direction: column; gap: var(--space-1); }
.cd-chat__mute p { margin: var(--space-1) var(--space-2) 0; color: var(--ink-muted); }
.cd-chat__action { display: block; width: 100%; text-align: left; min-height: 32px; padding: var(--space-1) var(--space-2); border: 0; border-radius: var(--radius-sm); background: none; color: var(--ink); text-decoration: none; cursor: pointer; font: inherit; }
.cd-chat__action:hover, .cd-chat__action:focus-visible { background: var(--surface-sunken); }
.cd-chat__action--danger { color: var(--danger); }
.cd-chat__scroll { flex: 1; overflow-y: auto; padding: var(--space-4); }
.cd-chat__earlier { text-align: center; margin: 0 0 var(--space-3); }
.cd-chat__log { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--space-2); }
.cd-chat__day { align-self: center; color: var(--ink-muted); background: var(--surface-raised); border: 1px solid var(--border); border-radius: 999px; padding: 2px var(--space-3); margin: var(--space-3) 0; }
.cd-chat__msg { display: flex; align-items: flex-start; gap: var(--space-1); max-width: min(78%, 640px); }
.cd-chat__msg--mine { align-self: flex-end; flex-direction: row-reverse; }
.cd-chat__msg--theirs { align-self: flex-start; }
.cd-chat__bubble { padding: var(--space-2) var(--space-3); border-radius: 16px; min-width: 120px; overflow-wrap: anywhere; }
.cd-chat__msg--theirs .cd-chat__bubble { background: var(--surface-raised); color: var(--ink); border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.cd-chat__msg--mine .cd-chat__bubble { background: var(--primary); color: var(--on-primary); border-bottom-right-radius: 4px; }
.cd-chat__msg--mine .cd-chat__bubble a { color: var(--on-primary); }
.cd-chat__author { margin: 0 0 2px; font-weight: 700; }
.cd-chat__about { margin: 0 0 var(--space-1); }
.cd-chat__msg--theirs .cd-chat__about, .cd-chat__msg--theirs .cd-chat__meta, .cd-chat__msg--theirs .cd-chat__by-email { color: var(--ink-muted); }
.cd-chat__text { margin: 0; }
.cd-chat__msg--deleted .cd-chat__text { font-style: italic; }
.cd-chat__quote { display: block; margin: 0 0 var(--space-1); padding: var(--space-1) var(--space-2); border-left: 3px solid currentColor; border-radius: 4px; background: rgba(127, 127, 127, .15); color: inherit; text-decoration: none; }
.cd-chat__quote-author, .cd-chat__quote-text { display: block; }
.cd-chat__meta { margin: 2px 0 0; text-align: right; }
.cd-chat__tick--read { font-weight: 700; }
.cd-chat__msg--theirs .cd-chat__tick--read, .cd-chat__msg--mine .cd-chat__tick--read { text-decoration: underline; text-underline-offset: 2px; }
.cd-chat__reactions { list-style: none; display: flex; flex-wrap: wrap; gap: var(--space-1); margin: var(--space-1) 0 0; padding: 0; }
.cd-chat__reactions form { margin: 0; }
.cd-chat__reaction { min-height: 24px; min-width: 24px; padding: 0 var(--space-2); border: 1px solid var(--border); border-radius: 999px; background: var(--surface); color: var(--ink); cursor: pointer; }
.cd-chat__reaction--mine { border-color: var(--ink); font-weight: 700; }
.cd-chat__actions { position: relative; flex: none; }
.cd-chat__actions-toggle { list-style: none; cursor: pointer; display: grid; place-items: center; min-width: 28px; min-height: 28px; border-radius: 50%; color: var(--ink-muted); }
.cd-chat__actions-toggle::-webkit-details-marker { display: none; }
.cd-chat__actions-toggle:hover, .cd-chat__actions-toggle:focus-visible { background: var(--surface-sunken); color: var(--ink); }
.cd-chat__msg--theirs .cd-chat__actions-panel { left: 0; right: auto; }
.cd-chat__react-row { display: flex; gap: 2px; flex-wrap: wrap; }
.cd-chat__react-choice { min-width: 32px; min-height: 32px; border: 0; border-radius: 50%; background: none; font-size: 1.1rem; cursor: pointer; }
.cd-chat__react-choice:hover, .cd-chat__react-choice:focus-visible { background: var(--surface-sunken); }
.cd-chat__edit { min-width: min(420px, 70vw); }
.cd-chat__edit-actions { display: flex; gap: var(--space-2); }
.cd-chat__compose { border-top: 1px solid var(--border); padding: var(--space-3) var(--space-4); background: var(--surface-raised); margin: 0; }
.cd-chat__compose.cd-form { gap: var(--space-2); }
.cd-chat__compose-row { display: flex; gap: var(--space-2); align-items: flex-end; }
.cd-chat__compose-row textarea { flex: 1; resize: none; max-height: 40vh; min-height: 44px; }
.cd-chat__replying { display: flex; justify-content: space-between; gap: var(--space-2); padding: var(--space-1) var(--space-2); border-left: 3px solid var(--primary); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; background: var(--surface); }
.cd-chat__replying[hidden] { display: none; }
.cd-chat__compose-tools { display: flex; flex-wrap: wrap; align-items: flex-start; gap: var(--space-2); }
.cd-chat__compose-tools:not(:has(*)) { display: none; }
.cd-chat__tool-chip { display: inline-flex; align-items: center; min-height: 28px; padding: 0 var(--space-3); border: 1px solid var(--border-strong); border-radius: var(--radius-pill); background: var(--surface); color: var(--ink); text-decoration: none; cursor: pointer; list-style: none; }
.cd-chat__tool-chip::-webkit-details-marker { display: none; }
.cd-chat__tool-chip:hover { background: var(--surface-sunken); }
.cd-chat__tool-panel[open] { flex-basis: 100%; order: 1; padding: var(--space-3); border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); }
.cd-chat__tool-panel[open] > .cd-chat__tool-chip { margin-bottom: var(--space-3); background: var(--surface-sunken); }
.cd-chat__hint { margin: 0; color: var(--ink-muted); }
/* The chat's other pages: the end-user design's column (aligned with the menu) and title;
   in a dojo's admin area the admin content's full width. */
.cd-root .cd-chat-page { width: min(1080px - 2 * var(--space-4), 100% - 2 * var(--space-4)); margin: 0 auto; padding-top: var(--space-6); box-sizing: border-box; }
.cd-chat-page__title { color: var(--ink); margin: 0 0 var(--space-4); }
.admin-main .cd-chat-page { width: auto; margin: 0; padding-top: 0; }
.admin-main .cd-chat-page > p:first-child { margin-top: 0; }
.cd-chat__log--read-only .cd-chat__msg { max-width: 90%; }
@media (max-width: 760px) {
  .cd-chat { grid-template-columns: minmax(0, 1fr); width: auto; height: calc(100dvh - 130px); min-height: 0; border-radius: 0; border-left: 0; border-right: 0; box-shadow: none; }
  .cd-chat--admin { height: calc(100dvh - 170px); border: 1px solid var(--border); border-radius: var(--radius-md); }
  .cd-chat--open .cd-chat__list, .cd-chat-head--open { display: none; }
  .cd-chat:not(.cd-chat--open) .cd-chat__pane { display: none; }
  .cd-chat__list { border-right: 0; }
  .cd-chat__back { display: inline-flex; gap: var(--space-1); white-space: nowrap; text-decoration: none; }
  .cd-chat__msg { max-width: 92%; }
  .cd-chat__scroll, .cd-chat__compose, .cd-chat__header { padding-left: var(--space-3); padding-right: var(--space-3); }
}
.cd-chat__new { display: flex; flex-wrap: wrap; gap: var(--space-2); margin: var(--space-3) var(--space-2); }
/* Chat phase 2: mentions, threads, pins, typing. */
.cd-chat__mention { font-weight: 700; text-decoration: underline; text-underline-offset: 2px; }
.cd-chat__thread-link { display: inline-block; margin-top: var(--space-1); color: inherit; }
.cd-chat__pinned-mark { margin: 0; }
.cd-chat__by-email { margin: 0 0 var(--space-1); }
.cd-chat-settings__section { margin-block: var(--space-5); }
.cd-chat-settings__devices { list-style: none; margin: 0 0 var(--space-3); padding: 0; }
.cd-chat-settings__device { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2) var(--space-3); padding-block: var(--space-2); border-bottom: 1px solid var(--border); }
.cd-chat-settings__device form { margin-left: auto; }
.cd-chat__pins { display: flex; flex-direction: column; gap: 2px; padding: var(--space-2) var(--space-4); border-bottom: 1px solid var(--border); background: var(--surface-raised); }
.cd-chat__pin { color: var(--ink); text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cd-chat__typing { min-height: 1.4em; margin: 0; padding: 0 var(--space-4); color: var(--ink-muted); background: var(--surface); }
.cd-chat__typing:not(:empty) { animation: cd-chat-typing 6s forwards; }
@keyframes cd-chat-typing { 0%, 80% { opacity: 1; } 100% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .cd-chat__typing:not(:empty) { animation: cd-chat-typing 6s steps(1, end) forwards; } }
@media (max-width: 760px) { .cd-chat--open .cd-chat__back--thread { display: inline-flex; } }
.cd-chat__back--thread { display: inline-flex; gap: var(--space-1); white-space: nowrap; text-decoration: none; color: var(--secondary); }
/* Chat polls: answers with a bar behind them (decorative), counts and names in text. */
.cd-chat__poll { margin-top: var(--space-2); min-width: min(320px, 70vw); }
.cd-chat__poll-options { border: 0; margin: 0 0 var(--space-2); padding: 0; display: flex; flex-direction: column; gap: var(--space-1); }
.cd-chat__poll-option { position: relative; display: grid; grid-template-columns: auto 1fr auto; gap: var(--space-2); align-items: center; padding: var(--space-1) var(--space-2); border: 1px solid currentColor; border-radius: var(--radius-sm); overflow: hidden; cursor: pointer; min-height: 32px; }
.cd-chat__poll-option--mine { font-weight: 700; }
.cd-chat__poll-bar { position: absolute; inset: 0 auto 0 0; background: currentColor; opacity: .12; pointer-events: none; }
.cd-chat__poll-option input, .cd-chat__poll-text, .cd-chat__poll-count { position: relative; }
.cd-chat__poll-voters { grid-column: 2 / -1; position: relative; }
.cd-chat__poll-meta { margin: var(--space-1) 0; }
.cd-chat__remind { display: flex; flex-direction: column; gap: var(--space-1); }
.cd-chat__remind p { margin: var(--space-1) var(--space-2) 0; color: var(--ink-muted); }
.cd-chat__scheduled { padding: var(--space-2) var(--space-4); border-top: 1px solid var(--border); background: var(--surface-raised); }
.cd-chat__scheduled p { margin: 0 0 var(--space-1); }
.cd-chat__scheduled-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--space-1); }
.cd-chat__scheduled-list li { display: flex; gap: var(--space-2); align-items: center; flex-wrap: wrap; }
.cd-chat__scheduled-list form { margin: 0; }
/* Chat: files, link previews, formatting. */
.cd-chat__image { display: block; margin-top: var(--space-2); }
.cd-chat__image img { display: block; max-width: min(320px, 100%); max-height: 320px; border-radius: var(--radius-sm); }
.cd-chat__file { display: inline-flex; gap: var(--space-1); align-items: baseline; margin-top: var(--space-2); color: inherit; }
.cd-chat__preview { display: flex; flex-direction: column; margin-top: var(--space-2); padding: var(--space-2); border-left: 3px solid currentColor; border-radius: 4px; background: rgba(127, 127, 127, .15); color: inherit; text-decoration: none; }
.cd-chat__text a { color: inherit; text-decoration: underline; overflow-wrap: anywhere; }
.cd-chat__text code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .9em; padding: 0 .2em; border-radius: 3px; background: rgba(127, 127, 127, .2); }
.cd-chat__archived summary { cursor: pointer; }
.cd-chat__file-list { padding-left: var(--space-5); }
/* A mail tile in a dojo chat: centred, outlined, never a bubble colour. */
.cd-chat__mail { align-self: center; display: flex; gap: var(--space-2); align-items: flex-start; max-width: min(90%, 520px); padding: var(--space-2) var(--space-3); border: 1px dashed var(--border); border-radius: var(--radius-md); background: var(--surface); color: var(--ink); }
.cd-chat__mail-text { display: flex; flex-direction: column; }
.cd-chat__mail .caption { color: var(--ink-muted); }
.cd-chat__mail--failed { border-style: solid; border-color: var(--danger); }
/* geo.widgets.PointPickerWidget: one pin on an OpenStreetMap map (geo/js/point_picker.js). */
.cd-point-picker__map { width: 100%; height: 320px; border: 1px solid var(--border); border-radius: var(--radius-md); overflow: hidden; background: var(--surface-sunken); }
.cd-point-picker__map:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }
.cd-point-picker__status { margin: var(--space-2) 0 0; color: var(--ink-muted); }
.cd-point-picker__actions { display: flex; flex-wrap: wrap; gap: var(--space-2); margin-top: var(--space-2); }
.cd-point-picker__actions[hidden] { display: none; }
/* OpenLayers' own zoom buttons are 22px: at least 24px (WCAG 2.5.8 target size). */
.cd-point-picker__map .ol-zoom button { min-width: 24px; min-height: 24px; }
@media (max-width: 600px) { .cd-point-picker__map { height: 260px; } }

/* A menu button (cd-menu): one button that opens a short list of actions, so
   a page keeps one or two buttons in view and the rest a click away.
   <details class="cd-menu"><summary class="cd-btn cd-btn--ghost label">More</summary>
   <div class="cd-menu__panel"> links or submit buttons with .cd-menu__item </div></details>.
   Plain HTML (works without JavaScript); bundle.js closes it on an outside
   click or Escape. */
.cd-menu { position: relative; display: inline-block; }
.cd-menu > summary { list-style: none; cursor: pointer; display: inline-flex; align-items: center; gap: var(--space-1); }
.cd-menu > summary::-webkit-details-marker { display: none; }
.cd-menu > summary::after { content: ""; width: 7px; height: 7px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: translateY(-2px) rotate(45deg); margin-left: var(--space-1); }
.cd-menu[open] > summary::after { transform: translateY(2px) rotate(-135deg); }
.cd-menu__panel { position: absolute; right: 0; top: calc(100% + var(--space-1)); z-index: 20; min-width: 240px; max-width: calc(100vw - 2 * var(--space-4)); display: flex; flex-direction: column; gap: 2px; padding: var(--space-2); background: var(--surface-raised); border: 1px solid var(--border); border-radius: var(--radius-sm); box-shadow: var(--shadow-md); }
.cd-menu--start .cd-menu__panel { right: auto; left: 0; }
.cd-menu__item { display: block; width: 100%; box-sizing: border-box; text-align: left; min-height: 36px; padding: var(--space-2) var(--space-3); border: 0; border-radius: var(--radius-sm); background: none; color: var(--ink); text-decoration: none; cursor: pointer; font: inherit; }
.cd-menu__item:hover, .cd-menu__item:focus-visible { background: var(--surface-sunken); }
.cd-menu__item--danger { color: var(--danger); }
.cd-menu__divider { border: 0; border-top: 1px solid var(--border); margin: var(--space-1) 0; }
