/*
 * CrossX widgets. Consumes only the --cx-* design tokens from site.css (each
 * with a fallback) plus local --w-* / --hc-* custom properties.
 * Widget roots carry .cxw; JS-enhanced roots also get .is-enhanced.
 */

/* ------------------------------------------------------------ foundation -- */

.cxw {
  --w-bg: var(--cx-bg, #ffffff);
  --w-surface: var(--cx-surface, #ffffff);
  --w-surface-2: var(--cx-surface-2, #f3f4f7);
  --w-ink: var(--cx-ink, #12151c);
  --w-muted: var(--cx-ink-muted, #5b6474);
  --w-line: var(--cx-line, #dfe3ea);
  --w-accent: var(--cx-accent, #ff6a1a);
  --w-accent-ink: var(--cx-accent-ink, #ffffff);
  --w-accent-2: var(--cx-accent-2, #2a7fff);
  --w-focus: var(--cx-focus, #2a7fff);
  --w-radius: var(--cx-radius, 10px);
  --w-radius-lg: var(--cx-radius-lg, 18px);
  --w-shadow: var(--cx-shadow, 0 10px 30px rgb(10 14 20 / 0.08));
  --w-mono: var(--cx-font-mono, ui-monospace, SFMono-Regular, Menlo, Consolas, monospace);
  --w-s1: var(--cx-space-1, 0.25rem);
  --w-s2: var(--cx-space-2, 0.5rem);
  --w-s3: var(--cx-space-3, 0.75rem);
  --w-s4: var(--cx-space-4, 1rem);
  --w-s5: var(--cx-space-5, 1.5rem);
  --w-s6: var(--cx-space-6, 2rem);
  --w-s7: var(--cx-space-7, 3rem);
  --w-danger: #e5484d;
  --w-ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  --w-tint: color-mix(in srgb, var(--w-accent) 9%, var(--w-surface));
  color: var(--w-ink);
  font-family: var(--cx-font, inherit);
  min-width: 0;
}

.cxw [hidden] { display: none !important; }
.cxw *, .cxw *::before, .cxw *::after { box-sizing: border-box; }

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

.cxw :is(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
  outline: 2px solid var(--w-focus);
  outline-offset: 2px;
}
.cxw h3[tabindex="-1"]:focus { outline: none; }

.cxw-heading { margin: 0 0 var(--w-s2); }
.cxw-intro { margin: 0 0 var(--w-s5); color: var(--w-muted); max-width: 60ch; }
.cxw-note, .cxw-hint { margin: 0; font-size: 0.875rem; color: var(--w-muted); line-height: 1.5; }
.cxw-error {
  margin: var(--w-s1) 0 0;
  font-size: 0.875rem; font-weight: 600;
  color: var(--w-danger);
}
.cxw-error::before { content: "! "; font-weight: 800; }
.cxw-req { color: var(--w-accent); font-weight: 700; }
.cxw-link {
  color: inherit;
  font-weight: 600;
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, var(--w-accent) 70%, transparent);
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
  display: inline-flex; align-items: center; gap: 0.35em;
}
.cxw-link:hover { text-decoration-color: var(--w-accent); }
.cxw-link svg { width: 1em; height: 1em; transition: transform 0.2s var(--w-ease); }
.cxw-link:hover svg { transform: translateX(3px); }

.cxw .button { display: inline-flex; align-items: center; justify-content: center; gap: 0.5em; }
.cxw .button svg { width: 1.1em; height: 1.1em; flex: none; }
.cxw .button:disabled { opacity: 0.5; cursor: not-allowed; }

/* Form controls */
.cxw-field { display: flex; flex-direction: column; gap: var(--w-s1); min-width: 0; }
.cxw-field > label, .cxw fieldset > legend {
  font-size: 0.875rem; font-weight: 600; color: var(--w-ink);
}
.cxw fieldset { margin: 0; padding: 0; border: 0; min-width: 0; }
.cxw fieldset > legend { padding: 0; margin-bottom: var(--w-s2); }
.cxw-input {
  width: 100%;
  min-height: 2.75rem;
  padding: 0.6rem 0.8rem;
  font: inherit; font-size: 1rem;
  color: var(--w-ink);
  background: var(--w-bg);
  border: 1px solid var(--w-line);
  border-radius: var(--w-radius);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.cxw-input::placeholder { color: var(--w-muted); opacity: 0.8; }
.cxw-input:hover { border-color: color-mix(in srgb, var(--w-ink) 30%, var(--w-line)); }
.cxw-input:focus-visible {
  outline: none;
  border-color: var(--w-focus);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--w-focus) 30%, transparent);
}
.cxw-input[aria-invalid="true"] { border-color: var(--w-danger); }
.cxw textarea.cxw-input { resize: vertical; min-height: 6rem; line-height: 1.5; }
.cxw select.cxw-input {
  appearance: none;
  padding-right: 2.25rem;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--w-muted) 50%),
    linear-gradient(135deg, var(--w-muted) 50%, transparent 50%);
  background-position: calc(100% - 1.1rem) 52%, calc(100% - 0.75rem) 52%;
  background-size: 0.35rem 0.35rem;
  background-repeat: no-repeat;
}
.cxw input[type="checkbox"], .cxw input[type="radio"] { accent-color: var(--w-accent); width: 1.1rem; height: 1.1rem; margin: 0; flex: none; }
.cxw-grid { display: grid; gap: var(--w-s4); grid-template-columns: minmax(0, 1fr); }
@media (min-width: 560px) {
  .cxw-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cxw-field--full { grid-column: 1 / -1; }
}

/* Search box (stack explorer, role board) */
.cxw-search { position: relative; flex: 1 1 16rem; min-width: 0; }
.cxw-search .cxw-input { padding-left: 2.5rem; }
.cxw-search__icon {
  position: absolute; left: 0.8rem; top: 50%; translate: 0 -50%;
  display: flex; color: var(--w-muted); pointer-events: none;
}
.cxw-search__icon svg { width: 1.1rem; height: 1.1rem; }

@keyframes cxw-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}
@keyframes cxw-pop {
  0% { opacity: 0; transform: scale(0.4); }
  70% { opacity: 1; transform: scale(1.08); }
  100% { opacity: 1; transform: scale(1); }
}

/* --------------------------------------------------- shared: send panel -- */

.cxw-send {
  margin-top: var(--w-s5);
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: var(--w-s4);
  padding: var(--w-s5);
  background: var(--w-tint);
  border: 1px solid color-mix(in srgb, var(--w-accent) 35%, var(--w-line));
  border-radius: var(--w-radius-lg);
  animation: cxw-in 0.35s var(--w-ease);
}
.cxw-send__icon {
  display: grid; place-items: center;
  width: 2.75rem; height: 2.75rem;
  border-radius: 50%;
  color: var(--w-accent-ink);
  background: var(--w-accent);
}
.cxw-send__main { display: grid; gap: var(--w-s2); min-width: 0; }
.cxw-send__main > p { margin: 0; }
.cxw-send__heading { margin: 0; font-size: 1.15rem; }
.cxw-send__fallback { color: var(--w-muted); font-size: 0.9rem; }
.cxw-send__actions { display: flex; flex-wrap: wrap; gap: var(--w-s2); margin-top: var(--w-s2); }
.cxw-send__status { margin: 0; min-height: 1.25em; font-size: 0.875rem; font-weight: 600; color: var(--w-ink); }
.cxw-send__preview summary { cursor: pointer; font-size: 0.875rem; font-weight: 600; color: var(--w-muted); }
.cxw-send__pre {
  margin: var(--w-s2) 0 0;
  padding: var(--w-s3) var(--w-s4);
  max-height: 18rem; overflow: auto;
  font-family: var(--w-mono); font-size: 0.8rem; line-height: 1.55;
  white-space: pre-wrap; overflow-wrap: anywhere;
  background: var(--w-surface);
  border: 1px solid var(--w-line);
  border-radius: var(--w-radius);
}
@media (max-width: 480px) {
  .cxw-send { grid-template-columns: minmax(0, 1fr); padding: var(--w-s4); }
}

/* ---------------------------------------------------------- hero-canvas -- */

.cx-hero-canvas {
  --hc-node: var(--cx-ink, #e9edf5);
  --hc-line: var(--cx-ink-muted, #8a93a6);
  --hc-accent: var(--cx-accent, #ff6a1a);
  --hc-accent-2: var(--cx-accent-2, #3fd0ff);
  position: absolute;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
  background:
    radial-gradient(55% 60% at 78% 30%, color-mix(in srgb, var(--hc-accent) 16%, transparent), transparent 70%),
    radial-gradient(45% 50% at 15% 85%, color-mix(in srgb, var(--hc-accent-2) 10%, transparent), transparent 70%);
}
/* Static "X" mark: the no-JS / pre-paint visual. */
.cx-hero-canvas::before {
  content: "";
  position: absolute;
  right: 6%; top: 50%;
  width: min(42vw, 520px); aspect-ratio: 1;
  translate: 0 -50%;
  background:
    linear-gradient(45deg, transparent calc(50% - 1px), color-mix(in srgb, var(--hc-accent) 45%, transparent) 50%, transparent calc(50% + 1px)),
    linear-gradient(-45deg, transparent calc(50% - 1px), color-mix(in srgb, var(--hc-line) 40%, transparent) 50%, transparent calc(50% + 1px));
  mask-image: radial-gradient(closest-side, #000 55%, transparent);
  opacity: 0.7;
  transition: opacity 1.2s ease;
}
.cx-hero-canvas.is-live::before { opacity: 0; }
.cx-hero-canvas__canvas {
  display: block;
  width: 100%; height: 100%;
  opacity: 0;
  transition: opacity 1.2s ease;
  /* Calmer behind the copy (left), livelier on the right. */
  mask-image: linear-gradient(100deg, rgb(0 0 0 / 0.35) 10%, #000 60%);
}
.cx-hero-canvas.is-live .cx-hero-canvas__canvas { opacity: 1; }
@media (max-width: 720px) {
  .cx-hero-canvas__canvas { mask-image: linear-gradient(180deg, rgb(0 0 0 / 0.45), #000 70%); }
}

/* ----------------------------------------------------- challenge-picker -- */

.cx-cp__fallback-list { padding-left: 1.2em; display: grid; gap: var(--w-s2); }
.cx-cp__fallback-hint { color: var(--w-muted); }

.cx-cp__form {
  display: grid;
  gap: var(--w-s5);
  grid-template-columns: minmax(0, 1fr);
}
@media (min-width: 960px) {
  .cx-cp__form { grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); align-items: start; }
  .cx-cp__side { position: sticky; top: var(--w-s5); }
}
.cx-cp__legend { font-size: 1rem !important; margin-bottom: var(--w-s3) !important; }
.cx-cp__grid { display: grid; gap: var(--w-s3); grid-template-columns: minmax(0, 1fr); }
@media (min-width: 560px) and (max-width: 959px), (min-width: 1200px) {
  .cx-cp__grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
/* The section heading already asks the question. */
.cxw-heading ~ form .cx-cp__legend {
  position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap;
}

.cx-cp__card {
  position: relative;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: var(--w-s3);
  align-items: start;
  padding: var(--w-s4);
  background: var(--w-surface);
  border: 1px solid var(--w-line);
  border-radius: var(--w-radius-lg);
  cursor: pointer;
  transition: border-color 0.2s, background-color 0.2s, transform 0.2s var(--w-ease), box-shadow 0.2s;
  animation: cxw-in 0.4s var(--w-ease) both;
  animation-delay: calc(var(--i, 0) * 40ms);
}
.cx-cp__card:hover { border-color: color-mix(in srgb, var(--w-accent) 50%, var(--w-line)); transform: translateY(-2px); box-shadow: var(--w-shadow); }
.cx-cp__radio { position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none; }
.cx-cp__card:has(.cx-cp__radio:focus-visible) { outline: 2px solid var(--w-focus); outline-offset: 2px; }
.cx-cp__card.is-checked, .cx-cp__card:has(.cx-cp__radio:checked) {
  border-color: var(--w-accent);
  background: var(--w-tint);
  box-shadow: 0 0 0 1px var(--w-accent) inset;
}
.cx-cp__icon {
  display: grid; place-items: center;
  width: 2.5rem; height: 2.5rem;
  border-radius: var(--w-radius);
  color: var(--w-accent);
  background: color-mix(in srgb, var(--w-accent) 12%, transparent);
  transition: background-color 0.2s, color 0.2s;
}
.cx-cp__card.is-checked .cx-cp__icon, .cx-cp__card:has(.cx-cp__radio:checked) .cx-cp__icon { color: var(--w-accent-ink); background: var(--w-accent); }
.cx-cp__card-text { display: grid; gap: 0.15rem; }
.cx-cp__card-title { font-weight: 700; line-height: 1.3; }
.cx-cp__card-hint { font-size: 0.875rem; color: var(--w-muted); line-height: 1.45; }
.cx-cp__check {
  display: grid; place-items: center;
  width: 1.5rem; height: 1.5rem;
  border-radius: 50%;
  border: 1.5px solid var(--w-line);
  color: transparent;
  transition: all 0.2s var(--w-ease);
}
.cx-cp__check svg { width: 0.95rem; height: 0.95rem; }
.cx-cp__card.is-checked .cx-cp__check, .cx-cp__card:has(.cx-cp__radio:checked) .cx-cp__check {
  border-color: var(--w-accent); background: var(--w-accent); color: var(--w-accent-ink); transform: scale(1.05);
}

.cx-cp__side { display: grid; gap: var(--w-s4); }
.cx-cp__panel {
  min-height: 9rem;
  padding: var(--w-s5);
  background: var(--w-surface-2);
  border: 1px solid var(--w-line);
  border-radius: var(--w-radius-lg);
  overflow: hidden;
}
.cx-cp__placeholder { margin: 0; color: var(--w-muted); display: grid; place-items: center; min-height: 6rem; text-align: center; }
.cx-cp__rec { display: grid; gap: var(--w-s3); }
.cx-cp__rec.is-entering { animation: cxw-in 0.35s var(--w-ease); }
.cx-cp__eyebrow {
  margin: 0;
  font-size: 0.75rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--w-accent);
}
.cx-cp__model { margin: 0; font-size: 1.5rem; line-height: 1.2; }
.cx-cp__rec-why { margin: 0; color: var(--w-muted); }
.cx-cp__rec--custom { grid-template-columns: auto minmax(0, 1fr); align-items: center; }
.cx-cp__rec-icon { color: var(--w-accent); display: flex; }
.cx-cp__cols { display: grid; gap: var(--w-s4); grid-template-columns: minmax(0, 1fr); padding-top: var(--w-s3); border-top: 1px solid var(--w-line); }
@media (min-width: 560px) { .cx-cp__cols { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.cx-cp__col h4 { margin: 0 0 var(--w-s1); font-size: 0.875rem; }
.cx-cp__col p { margin: 0; font-size: 0.925rem; }
.cx-cp__bring { margin: 0; padding: 0; list-style: none; display: grid; gap: 0.3rem; font-size: 0.925rem; }
.cx-cp__bring li { position: relative; padding-left: 1.1rem; }
.cx-cp__bring li::before {
  content: ""; position: absolute; left: 0; top: 0.55em;
  width: 0.45rem; height: 0.45rem; border-radius: 2px;
  background: var(--w-accent); rotate: 45deg;
}
.cx-cp__more { margin: 0; }
.cx-cp__details { display: grid; gap: var(--w-s3); grid-template-columns: minmax(0, 1fr); }
@media (min-width: 560px) {
  .cx-cp__details { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cx-cp__details .cxw-field--full { grid-column: 1 / -1; }
}
.cx-cp__submit-row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--w-s3); }
.cx-cp__submit-row .cxw-note { flex: 1 1 14rem; }

/* --------------------------------------------------------- team-builder -- */

.cx-tb__fallback-roles { columns: 2 14rem; padding-left: 1.2em; }
.cx-tb__form {
  display: grid;
  gap: var(--w-s5);
  grid-template-columns: minmax(0, 1fr);
}
@media (min-width: 980px) {
  .cx-tb__form { grid-template-columns: minmax(0, 1.4fr) minmax(320px, 1fr); align-items: start; }
  .cx-tb__summary { position: sticky; top: var(--w-s5); }
}
.cx-tb__builder { display: grid; gap: var(--w-s4); min-width: 0; }
.cx-tb__group {
  padding: clamp(1rem, 3vw, 1.5rem) !important;
  background: var(--w-surface);
  border: 1px solid var(--w-line) !important;
  border-radius: var(--w-radius-lg);
}
.cx-tb__legend-title {
  float: left; width: 100%;
  font-size: 1rem !important;
  margin-bottom: var(--w-s4) !important;
}
.cx-tb__legend-title + * { clear: both; }
.cx-tb__rows { list-style: none; margin: 0 0 var(--w-s3); padding: 0; display: grid; gap: var(--w-s3); }
.cx-tb__row {
  position: relative;
  display: grid;
  gap: var(--w-s3);
  grid-template-columns: minmax(0, 1fr) auto 2.25rem;
  grid-template-areas: "role role remove" "sen count count";
  align-items: end;
  padding: var(--w-s3);
  background: var(--w-surface-2);
  border-radius: var(--w-radius);
  border: 1px solid transparent;
  transition: border-color 0.2s;
}
.cx-tb__row:focus-within { border-color: color-mix(in srgb, var(--w-accent) 40%, var(--w-line)); }
.cx-tb__row.is-new { animation: cxw-in 0.3s var(--w-ease); }
.cx-tb__f-role { grid-area: role; }
.cx-tb__f-sen { grid-area: sen; }
.cx-tb__f-count { grid-area: count; }
.cx-tb__remove {
  grid-area: remove;
  align-self: end;
  margin-bottom: 0.25rem;
  display: grid; place-items: center;
  width: 2.25rem; height: 2.25rem;
  padding: 0;
  color: var(--w-muted);
  background: transparent;
  border: 0; border-radius: 50%;
  cursor: pointer;
  transition: color 0.15s, background-color 0.15s;
}
.cx-tb__remove svg { width: 1.1rem; height: 1.1rem; }
.cx-tb__remove:hover { color: var(--w-danger); background: color-mix(in srgb, var(--w-danger) 12%, transparent); }
@media (min-width: 620px) {
  .cx-tb__row {
    grid-template-columns: minmax(0, 2fr) minmax(0, 1.1fr) auto 2.25rem;
    grid-template-areas: "role sen count remove";
    padding: var(--w-s4);
  }
  .cx-tb__row:not(:first-child) .cxw-field > label {
    position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap;
  }
}
.cx-stepper {
  display: inline-flex; align-items: stretch;
  min-height: 2.75rem;
  border: 1px solid var(--w-line);
  border-radius: var(--w-radius);
  background: var(--w-bg);
  overflow: hidden;
}
.cx-stepper:focus-within { border-color: var(--w-focus); }
.cx-stepper__btn {
  display: grid; place-items: center;
  width: 2.5rem;
  padding: 0;
  color: var(--w-ink);
  background: transparent;
  border: 0;
  cursor: pointer;
  transition: background-color 0.15s;
}
.cx-stepper__btn svg { width: 1rem; height: 1rem; }
.cx-stepper__btn:hover:not(:disabled) { background: var(--w-surface-2); }
.cx-stepper__btn:disabled { color: var(--w-muted); opacity: 0.45; cursor: not-allowed; }
.cx-stepper__btn:focus-visible { outline-offset: -2px !important; }
.cxw .cx-stepper__input {
  width: 3rem; min-height: 0;
  padding: 0;
  text-align: center;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  border: 0; border-radius: 0;
  background: transparent;
  -moz-appearance: textfield;
}
.cx-stepper__input::-webkit-outer-spin-button, .cx-stepper__input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.cxw .cx-stepper__input:focus-visible { box-shadow: none; }
.cx-tb__add svg { width: 1rem; height: 1rem; }

.cx-tb__overlap-opts { display: flex; flex-wrap: wrap; gap: var(--w-s2); }
.cx-tb__pill, .cx-cc__check {
  display: inline-flex; align-items: center; gap: 0.55rem;
  padding: 0.6rem 0.9rem;
  font-size: 0.925rem;
  background: var(--w-bg);
  border: 1px solid var(--w-line);
  border-radius: var(--w-radius);
  cursor: pointer;
  transition: border-color 0.15s, background-color 0.15s;
}
.cx-tb__pill:hover, .cx-cc__check:hover { border-color: color-mix(in srgb, var(--w-accent) 45%, var(--w-line)); }
.cx-tb__pill:has(input:checked), .cx-cc__check:has(input:checked) { border-color: var(--w-accent); background: var(--w-tint); }

.cx-tb__card {
  display: grid;
  gap: var(--w-s3);
  padding: var(--w-s5);
  background:
    radial-gradient(120% 60% at 100% 0%, color-mix(in srgb, var(--w-accent) 12%, transparent), transparent 60%),
    var(--w-surface);
  border: 1px solid var(--w-line);
  border-radius: var(--w-radius-lg);
  box-shadow: var(--w-shadow);
}
.cx-tb__summary-title { margin: 0; font-size: 1rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--w-muted); }
.cx-tb__total { margin: 0; display: flex; align-items: baseline; gap: 0.5rem; flex-wrap: wrap; }
.cx-tb__total-num {
  font-size: clamp(2.5rem, 6vw, 3.25rem); font-weight: 800; line-height: 1;
  font-variant-numeric: tabular-nums;
  color: var(--w-accent);
}
.cx-tb__total-text { color: var(--w-muted); font-weight: 600; }
.cx-tb__avatars { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0.4rem; min-height: 2.4rem; }
.cx-tb__avatar, .cx-tb__swatch {
  --av-bg: var(--w-surface-2);
  --av-fg: var(--w-ink);
  --av-bd: var(--w-line);
}
.cx-tb__avatar {
  display: grid; place-items: center;
  width: 2.4rem; height: 2.4rem;
  font-family: var(--w-mono); font-size: 0.72rem; font-weight: 700; letter-spacing: 0.02em;
  color: var(--av-fg);
  background: var(--av-bg);
  border: 1.5px solid var(--av-bd);
  border-radius: 50%;
}
.cx-tb__avatar.is-new { animation: cxw-pop 0.38s var(--w-ease) both; animation-delay: var(--d, 0ms); }
[data-level="1"] > .cx-tb__swatch, .cx-tb__avatar[data-level="1"] {
  --av-bg: color-mix(in srgb, var(--w-accent-2) 22%, var(--w-surface));
  --av-bd: color-mix(in srgb, var(--w-accent-2) 60%, transparent);
}
[data-level="2"] > .cx-tb__swatch, .cx-tb__avatar[data-level="2"] {
  --av-bg: color-mix(in srgb, var(--w-accent) 28%, var(--w-surface));
  --av-bd: color-mix(in srgb, var(--w-accent) 70%, transparent);
}
[data-level="3"] > .cx-tb__swatch, .cx-tb__avatar[data-level="3"] {
  --av-bg: var(--w-accent);
  --av-fg: var(--w-accent-ink);
  --av-bd: var(--w-accent);
}
.cx-tb__avatar--more { width: auto; padding: 0 0.6rem; border-radius: 999px; }
.cx-tb__empty { margin: 0; color: var(--w-muted); }
.cx-tb__comp { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.2rem; font-size: 0.925rem; }
.cx-tb__comp strong { font-variant-numeric: tabular-nums; }
.cx-tb__legend { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0.35rem 0.9rem; font-size: 0.8rem; color: var(--w-muted); }
.cx-tb__legend li { display: inline-flex; align-items: center; gap: 0.35rem; }
.cx-tb__swatch { width: 0.8rem; height: 0.8rem; border-radius: 50%; background: var(--av-bg); border: 1.5px solid var(--av-bd); }
.cx-tb__tl-title { margin: var(--w-s3) 0 0; padding-top: var(--w-s4); border-top: 1px solid var(--w-line); font-size: 0.95rem; }
.cx-tb__tl-total { margin: 0; font-weight: 600; }
.cx-tb__timeline { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--w-s3); }
.cx-tb__step { display: grid; gap: 0.3rem; }
.cx-tb__step-head { display: flex; justify-content: space-between; gap: var(--w-s2); font-size: 0.875rem; }
.cx-tb__step-label { font-weight: 600; }
.cx-tb__step-when { color: var(--w-muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.cx-tb__step-track {
  position: relative;
  height: 0.5rem;
  border-radius: 999px;
  background: color-mix(in srgb, var(--w-line) 70%, transparent);
  overflow: hidden;
}
.cx-tb__step-bar {
  position: absolute; top: 0; bottom: 0;
  left: var(--start, 0%);
  width: max(var(--width, 10%), 0.5rem);
  border-radius: 999px;
  background: linear-gradient(90deg, var(--w-accent-2), var(--w-accent));
  transition: left 0.45s var(--w-ease), width 0.45s var(--w-ease);
}
.cx-tb__step-detail { margin: 0; font-size: 0.8rem; color: var(--w-muted); }
.cx-tb__disclaimer { margin: 0; font-size: 0.78rem; color: var(--w-muted); font-style: italic; }
.cx-tb__actions { display: flex; flex-wrap: wrap; gap: var(--w-s2); margin-top: var(--w-s2); }
.cx-tb__send { flex: 1 1 100%; }
.cx-tb__status { margin: 0; min-height: 1.2em; font-size: 0.875rem; font-weight: 600; }
.cx-tb__reset {
  padding: 0;
  font: inherit; font-weight: 600;
  color: var(--w-ink);
  background: none; border: 0;
  text-decoration: underline; text-underline-offset: 3px;
  cursor: pointer;
}

/* --------------------------------------------------- engagement-compare -- */

.cx-ec__panels {
  display: grid;
  gap: var(--w-s4);
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr));
}
.cx-ec__panel {
  display: grid;
  align-content: start;
  gap: var(--w-s3);
  padding: var(--w-s5);
  background: var(--w-surface);
  border: 1px solid var(--w-line);
  border-radius: var(--w-radius-lg);
}
.cx-ec__title { margin: 0; font-size: 1.25rem; }
.cx-ec__tagline { margin: 0; color: var(--w-muted); font-size: 1.05rem; }
.cx-ec__meter { display: grid; gap: 0.4rem; }
.cx-ec__meter-label { margin: 0; font-size: 0.85rem; color: var(--w-muted); }
.cx-ec__meter-label strong { color: var(--w-ink); }
.cx-ec__meter-track {
  position: relative;
  height: 0.4rem;
  border-radius: 999px;
  background: linear-gradient(90deg, color-mix(in srgb, var(--w-accent-2) 60%, transparent), color-mix(in srgb, var(--w-accent) 70%, transparent));
}
.cx-ec__meter-dot {
  position: absolute; top: 50%;
  left: var(--ec-pos, 50%);
  width: 1rem; height: 1rem;
  translate: -50% -50%;
  border-radius: 50%;
  background: var(--w-surface);
  border: 3px solid var(--w-ink);
  box-shadow: 0 2px 8px rgb(0 0 0 / 0.2);
}
.cx-ec__panel.is-entering .cx-ec__meter-dot { animation: cx-ec-dot 0.6s var(--w-ease); }
@keyframes cx-ec-dot { from { left: 50%; } }
.cx-ec__meter-ends { margin: 0; display: flex; justify-content: space-between; font-size: 0.75rem; color: var(--w-muted); text-transform: uppercase; letter-spacing: 0.06em; }
.cx-ec__rows { margin: 0; display: grid; }
.cx-ec__row { display: grid; gap: 0.2rem; padding: var(--w-s3) 0; border-top: 1px solid var(--w-line); }
.cx-ec__row dt { font-size: 0.8rem; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; color: var(--w-muted); }
.cx-ec__row dd { margin: 0; }
.cx-ec__more { margin: var(--w-s4) 0 0; }

/* Tabs mode (JS) */
.cx-ec__tablist {
  position: relative;
  isolation: isolate;
  display: flex;
  gap: 0.25rem;
  width: fit-content;
  max-width: 100%;
  margin-bottom: var(--w-s4);
  padding: 0.3rem;
  background: var(--w-surface-2);
  border: 1px solid var(--w-line);
  border-radius: 999px;
}
.cx-ec__tab {
  position: relative;
  z-index: 1;
  flex: 1 1 auto;
  padding: 0.6rem 1.1rem;
  font: inherit; font-weight: 600; font-size: 0.95rem;
  white-space: nowrap;
  color: var(--w-muted);
  background: transparent;
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  transition: color 0.25s;
}
.cx-ec__tab:hover { color: var(--w-ink); }
.cx-ec__tab[aria-selected="true"] { color: var(--w-accent-ink); }
.cx-ec__indicator {
  position: absolute;
  z-index: 0;
  left: 0; top: 0;
  width: var(--w, 0);
  height: var(--h, 0);
  transform: translate(var(--x, 0), var(--y, 0));
  border-radius: 999px;
  background: var(--w-accent);
  box-shadow: 0 4px 14px color-mix(in srgb, var(--w-accent) 35%, transparent);
}
.cx-ec.is-ready .cx-ec__indicator { transition: transform 0.35s var(--w-ease), width 0.35s var(--w-ease), height 0.35s var(--w-ease); }
@media (max-width: 540px) {
  .cx-ec__tablist { flex-direction: column; width: 100%; border-radius: var(--w-radius-lg); }
  .cx-ec__tab { text-align: left; border-radius: var(--w-radius); }
  .cx-ec__indicator { border-radius: var(--w-radius); }
}
.cx-ec.is-tabs .cx-ec__panels { display: grid; grid-template-columns: minmax(0, 1fr); overflow-x: clip; overflow-clip-margin: 8px; }
.cx-ec.is-tabs .cx-ec__panel { grid-area: 1 / 1; }
.cx-ec.is-tabs .cx-ec__title {
  position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap;
}
.cx-ec.is-tabs .cx-ec__tagline { font-size: 1.2rem; color: var(--w-ink); font-weight: 600; }
@media (min-width: 720px) {
  .cx-ec.is-tabs .cx-ec__panel { grid-template-columns: minmax(0, 1fr) minmax(220px, 0.6fr); column-gap: var(--w-s6); }
  .cx-ec.is-tabs .cx-ec__tagline { grid-column: 1; }
  .cx-ec.is-tabs .cx-ec__meter { grid-column: 2; grid-row: 1 / span 2; align-self: start; }
  .cx-ec.is-tabs .cx-ec__rows { grid-column: 1 / -1; }
  .cx-ec.is-tabs .cx-ec__row { grid-template-columns: 13rem minmax(0, 1fr); gap: var(--w-s4); }
}
.cx-ec__panel.is-entering { animation: cx-ec-in 0.32s var(--w-ease) both; }
.cx-ec__panel.is-leaving { animation: cx-ec-out 0.24s ease-in both; pointer-events: none; }
@keyframes cx-ec-in { from { opacity: 0; transform: translateX(calc(var(--ec-dir, 1) * 28px)); } }
@keyframes cx-ec-out { to { opacity: 0; transform: translateX(calc(var(--ec-dir, 1) * -28px)); } }
.cx-ec--compact .cx-ec__panel { padding: var(--w-s4) var(--w-s5); }

/* ------------------------------------------------------- stack-explorer -- */

.cx-se__toolbar { display: grid; gap: var(--w-s3); margin-bottom: var(--w-s5); }
.cx-se__chips { display: flex; flex-wrap: wrap; gap: var(--w-s2); }
.cx-se__chip {
  display: inline-flex; align-items: center; gap: 0.45rem;
  min-height: 2.5rem;
  padding: 0.4rem 0.9rem;
  font: inherit; font-size: 0.9rem; font-weight: 600;
  color: var(--w-ink);
  background: var(--w-surface);
  border: 1px solid var(--w-line);
  border-radius: 999px;
  cursor: pointer;
  transition: background-color 0.2s, border-color 0.2s, color 0.2s;
}
.cx-se__chip:hover { border-color: color-mix(in srgb, var(--w-accent) 50%, var(--w-line)); }
.cx-se__chip[aria-pressed="true"] { color: var(--w-accent-ink); background: var(--w-accent); border-color: var(--w-accent); }
.cx-se__chip-count {
  min-width: 1.5rem;
  padding: 0 0.35rem;
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
  text-align: center;
  border-radius: 999px;
  background: color-mix(in srgb, currentColor 14%, transparent);
}
.cx-se__row { display: flex; flex-wrap: wrap; gap: var(--w-s3); align-items: center; }
.cx-se__count { margin: 0; font-size: 0.9rem; color: var(--w-muted); font-variant-numeric: tabular-nums; }
.cx-se__groups { display: grid; gap: var(--w-s5); }
.cx-se__group-title {
  display: flex; align-items: center; gap: 0.5rem;
  margin: 0 0 var(--w-s3);
  font-size: 0.8rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--w-muted);
}
.cx-se__group-count {
  font-size: 0.7rem; padding: 0.05rem 0.45rem; border-radius: 999px;
  background: var(--w-surface-2); border: 1px solid var(--w-line);
}
.cx-se.is-enhanced .cx-se__group-count { display: none; }
.cx-se__list { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: var(--w-s2); }
.cx-se__item {
  padding: 0.45rem 0.95rem;
  font-weight: 600; font-size: 0.95rem;
  background: var(--w-surface);
  border: 1px solid var(--w-line);
  border-radius: 999px;
  transition: border-color 0.2s, transform 0.2s var(--w-ease);
}
.cx-se__item:hover { border-color: var(--w-accent); }
.cx-se__item mark {
  color: inherit;
  background: color-mix(in srgb, var(--w-accent) 30%, transparent);
  border-radius: 3px;
  padding: 0 1px;
}
.cx-se__empty, .cx-rb__empty {
  display: grid; justify-items: start; gap: var(--w-s2);
  padding: var(--w-s5);
  border: 1.5px dashed var(--w-line);
  border-radius: var(--w-radius-lg);
  animation: cxw-in 0.3s var(--w-ease);
}
.cx-se__empty p, .cx-rb__empty p { margin: 0; }
.cx-se__empty-title, .cx-rb__empty-title { font-weight: 700; font-size: 1.05rem; }
.cx-se__empty-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--w-s3); }

/* ------------------------------------------------------ contact-composer -- */

.cx-cc__fallback ul { padding-left: 1.2em; }
.cx-cc__form {
  display: grid;
  gap: var(--w-s4);
  padding: clamp(1rem, 4vw, 2rem);
  background: var(--w-surface);
  border: 1px solid var(--w-line);
  border-radius: var(--w-radius-lg);
  box-shadow: var(--w-shadow);
}
.cx-cc__top { display: grid; gap: var(--w-s2); }
.cx-cc__progress ol { list-style: none; margin: 0; padding: 0; display: flex; gap: var(--w-s2); }
.cx-cc__progress li { flex: 1 1 0; min-width: 0; }
.cx-cc__pstep {
  display: flex; align-items: center; gap: 0.5rem;
  width: 100%;
  padding: 0.25rem 0;
  font: inherit; font-size: 0.85rem; font-weight: 600;
  text-align: left;
  color: var(--w-muted);
  background: none; border: 0;
  cursor: pointer;
}
.cx-cc__pstep:disabled { cursor: default; }
.cx-cc__pnum {
  display: grid; place-items: center; flex: none;
  width: 1.75rem; height: 1.75rem;
  font-size: 0.8rem; font-variant-numeric: tabular-nums;
  border: 1.5px solid var(--w-line);
  border-radius: 50%;
  transition: all 0.25s var(--w-ease);
}
.cx-cc__plabel { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cx-cc__progress li.is-current .cx-cc__pstep { color: var(--w-ink); }
.cx-cc__progress li.is-current .cx-cc__pnum { color: var(--w-accent-ink); background: var(--w-accent); border-color: var(--w-accent); }
.cx-cc__progress li.is-done .cx-cc__pnum { border-color: var(--w-accent); color: var(--w-accent); background: var(--w-tint); }
.cx-cc__progress li.is-done .cx-cc__pstep:hover .cx-cc__plabel { text-decoration: underline; }
.cx-cc__bar { height: 4px; margin-top: var(--w-s2); border-radius: 999px; background: var(--w-surface-2); overflow: hidden; }
.cx-cc__bar-fill {
  display: block; height: 100%;
  background: linear-gradient(90deg, var(--w-accent-2), var(--w-accent));
  transform-origin: left;
  transform: scaleX(max(var(--p, 0), 0.04));
  transition: transform 0.45s var(--w-ease);
}
.cx-cc__stepof { margin: 0; font-size: 0.8rem; color: var(--w-muted); }
@media (max-width: 600px) {
  .cx-cc__progress li:not(.is-current) .cx-cc__plabel { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .cx-cc__progress li.is-current { flex-grow: 3; }
}
.cx-cc__required { margin: 0; }
.cx-cc__step { display: grid; gap: var(--w-s4); }
.cx-cc__step.is-entering { animation: cx-cc-in 0.32s var(--w-ease); }
@keyframes cx-cc-in { from { opacity: 0; transform: translateX(calc(var(--cc-dir, 1) * 20px)); } }
.cx-cc__step-title { margin: 0; font-size: 1.3rem; }
.cx-cc__check-grid { display: grid; gap: var(--w-s2); grid-template-columns: repeat(auto-fill, minmax(min(100%, 220px), 1fr)); }
.cx-cc__check { display: flex; }
.cx-cc__checks.is-invalid .cx-cc__check { border-color: color-mix(in srgb, var(--w-danger) 50%, var(--w-line)); }
.cx-cc__desc-foot { display: flex; justify-content: space-between; align-items: start; gap: var(--w-s2); }
.cx-cc__counter { margin-left: auto; font-size: 0.8rem; color: var(--w-muted); font-variant-numeric: tabular-nums; }
.cx-cc__counter.is-ok { color: var(--w-accent); }
.cx-cc__review { grid-column: 1 / -1; display: grid; gap: var(--w-s3); }
.cx-cc__rblock { padding: var(--w-s4); background: var(--w-surface-2); border-radius: var(--w-radius); }
.cx-cc__rhead { display: flex; justify-content: space-between; align-items: center; gap: var(--w-s2); margin-bottom: var(--w-s2); }
.cx-cc__rhead h4 { margin: 0; font-size: 0.95rem; }
.cx-cc__edit {
  padding: 0.25rem 0.5rem;
  font: inherit; font-size: 0.85rem; font-weight: 600;
  color: var(--w-ink);
  background: none; border: 0;
  text-decoration: underline; text-underline-offset: 3px;
  cursor: pointer;
}
.cx-cc__rblock dl { margin: 0; display: grid; gap: 0.35rem; }
.cx-cc__rrow { display: grid; grid-template-columns: minmax(0, 1fr); gap: 0.1rem; font-size: 0.925rem; }
@media (min-width: 560px) { .cx-cc__rrow { grid-template-columns: 11rem minmax(0, 1fr); gap: var(--w-s3); } }
.cx-cc__rrow dt { color: var(--w-muted); }
.cx-cc__rrow dd { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.cx-cc__nav { display: flex; flex-wrap: wrap; align-items: center; gap: var(--w-s2); padding-top: var(--w-s4); border-top: 1px solid var(--w-line); }
.cx-cc__spacer { flex: 1 1 auto; }
.cx-cc__status { margin: 0; min-height: 1.2em; font-size: 0.875rem; font-weight: 600; }
.cx-cc__privacy { display: flex; gap: 0.5rem; align-items: flex-start; }
.cx-cc__privacy-icon { display: flex; color: var(--w-accent); }
.cx-cc__privacy-icon svg { width: 1.1rem; height: 1.1rem; }
@media (max-width: 420px) {
  .cx-cc__nav .button { flex: 1 1 100%; }
  .cx-cc__spacer { display: none; }
}

/* ------------------------------------------------------------ role-board -- */

.cx-rb__toolbar {
  display: grid;
  gap: var(--w-s3);
  grid-template-columns: minmax(0, 1fr);
  margin-bottom: var(--w-s3);
}
@media (min-width: 720px) { .cx-rb__toolbar { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) minmax(0, 1fr); align-items: end; } }
.cx-rb__count { margin: 0 0 var(--w-s3); font-size: 0.9rem; color: var(--w-muted); font-variant-numeric: tabular-nums; }
.cx-rb__list { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--w-s3); }
.cx-rb__card {
  display: grid;
  gap: var(--w-s3);
  padding: var(--w-s5);
  background: var(--w-surface);
  border: 1px solid var(--w-line);
  border-radius: var(--w-radius-lg);
  transition: border-color 0.2s, box-shadow 0.2s;
  scroll-margin-top: var(--w-s7);
}
.cx-rb__card:hover { border-color: color-mix(in srgb, var(--w-accent) 40%, var(--w-line)); }
.cx-rb__card:target, .cx-rb__card.is-targeted { border-color: var(--w-accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--w-accent) 25%, transparent); }
.cx-rb__head { display: grid; gap: var(--w-s2); }
.cx-rb__title { margin: 0; font-size: 1.2rem; line-height: 1.3; }
.cx-rb__tags { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0.4rem; }
.cx-rb__tag {
  display: inline-flex; align-items: center; gap: 0.35rem;
  padding: 0.2rem 0.65rem;
  font-size: 0.8rem; font-weight: 600;
  color: var(--w-muted);
  background: var(--w-surface-2);
  border-radius: 999px;
}
.cx-rb__tag--discipline { color: var(--w-ink); background: var(--w-tint); }
.cx-rb__tag--loc::before { content: ""; width: 0.45rem; height: 0.45rem; border-radius: 50%; background: var(--w-accent-2); }
.cx-rb__tag--loc[data-loc="hybrid"]::before { background: var(--w-accent); }
.cx-rb__tag--loc[data-loc="onsite"]::before { background: var(--w-ink); }
.cx-rb__summary { margin: 0; color: var(--w-muted); }
.cx-rb__details { border-top: 1px solid var(--w-line); padding-top: var(--w-s3); }
.cx-rb__toggle {
  display: inline-flex; align-items: center; gap: 0.5rem;
  font-weight: 600;
  cursor: pointer;
  list-style: none;
}
.cx-rb__toggle::-webkit-details-marker { display: none; }
.cx-rb__toggle::after {
  content: "";
  width: 0.5rem; height: 0.5rem;
  border-right: 2px solid currentColor; border-bottom: 2px solid currentColor;
  rotate: 45deg; translate: 0 -0.15rem;
  transition: rotate 0.25s var(--w-ease), translate 0.25s var(--w-ease);
}
.cx-rb__details[open] > .cx-rb__toggle::after { rotate: 225deg; translate: 0 0.1rem; }
.cx-rb__body { display: grid; gap: var(--w-s2); padding-top: var(--w-s3); }
.cx-rb__body h4 { margin: var(--w-s2) 0 0; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--w-muted); }
.cx-rb__body ul { margin: 0; padding-left: 1.2em; display: grid; gap: 0.25rem; }
.cx-rb__body li::marker { color: var(--w-accent); }
@supports selector(::details-content) {
  .cx-rb { interpolate-size: allow-keywords; }
  .cx-rb__details::details-content {
    block-size: 0;
    overflow-y: clip;
    transition: block-size 0.3s var(--w-ease), content-visibility 0.3s allow-discrete;
  }
  .cx-rb__details[open]::details-content { block-size: auto; }
}
.cx-rb__actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--w-s2) var(--w-s4); }
.cx-rb__apply-hint { font-size: 0.85rem; color: var(--w-muted); overflow-wrap: anywhere; }
.cx-rb__general { margin: var(--w-s5) 0 0; }
.cx-rb__none { margin: 0; }

/* -------------------------------------------------------- reduced motion -- */

@media (prefers-reduced-motion: reduce) {
  .cxw *, .cxw *::before, .cxw *::after {
    animation-duration: 0.001ms !important;
    animation-delay: 0ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
  .cx-cp__card:hover { transform: none; }
}
