/* Dark-only palette overrides. The v1.29 light layout and colors are untouched. */
html[data-participant-theme="dark"] .ms-page {
  --ms-line: var(--ui-line);
  --ms-muted: var(--ui-muted);
  --ms-yellow: var(--ui-accent);
  --ms-ink: var(--ui-text);
  --ms-paper: var(--ui-raised);
  color: var(--ui-text);
}
html[data-participant-theme="dark"] .ew-area {
  --ew-line: var(--ui-line);
  --ew-muted: var(--ui-muted);
  --ew-yellow: var(--ui-accent);
  --ew-ink: var(--ui-text);
  --ew-warning-bg: var(--ui-raised);
  --ew-warning-text: #f5d597;
  --ew-success-bg: var(--ui-raised);
  color: var(--ui-text);
}

/* Neutral grouped surfaces, with the original panel geometry preserved. */
html[data-participant-theme="dark"] .ms-page :is(.ms-static-benefit,.ms-plan-card,.ms-checkout-main,.ms-empty) {
  background: var(--ui-surface);
  border-color: var(--ui-line);
}
html[data-participant-theme="dark"] .ms-page .ms-plan-card { border-top-color: var(--ui-line); }
html[data-participant-theme="dark"] .ms-page .ms-plan-card.is-current {
  background: var(--ui-raised);
  border-color: #636366;
}
html[data-participant-theme="dark"] .ms-page :is(.ms-current-strip,.ms-common-benefits,.ms-order-summary,.ms-auth-prompt,.ms-payment-unavailable,.ms-order-reference,.ms-selected-task) {
  background: var(--ui-raised);
  border-color: var(--ui-line);
}
html[data-participant-theme="dark"] .ms-page .ms-payment-unavailable { border-left-color: var(--ui-accent); }
html[data-participant-theme="dark"] .ms-page :is(.ms-current-strip,.ms-selected-task) > .ms-icon,
html[data-participant-theme="dark"] .ms-page .ms-checkout-progress li > span {
  color: var(--ui-text);
  background: var(--ui-surface);
}
html[data-participant-theme="dark"] .ms-page .ms-state-message > .ms-icon,
html[data-participant-theme="dark"] .ms-page .ms-state-tag {
  color: var(--ui-text);
  background: var(--ui-raised);
}
html[data-participant-theme="dark"] .ms-page .ms-static-table :is(th,td):last-child {
  color: var(--ui-text);
  background: var(--ui-accent-soft);
}
html[data-participant-theme="dark"] .ms-page :is(.ms-static-multiplier,.ms-plan-mark),
html[data-participant-theme="dark"] .ms-page .ms-common-benefits > div > .ms-icon,
html[data-participant-theme="dark"] .ms-page .ms-summary-plan h2,
html[data-participant-theme="dark"] .ms-page :is(.ms-auth-prompt,.ms-empty,.ms-state-success) > .ms-icon,
html[data-participant-theme="dark"] .ms-page .ms-checkout-progress .is-current > span {
  color: #141615;
  background: var(--ui-accent);
}
html[data-participant-theme="dark"] .ms-page .ms-checkout-progress .is-current { border-color: #636366; }
html[data-participant-theme="dark"] .ms-page .ms-checkout-progress .is-complete > span {
  color: var(--ui-text);
  background: var(--ui-raised);
}
html[data-participant-theme="dark"] .ms-page .ms-disabled,
html[data-participant-theme="dark"] .ms-page .ms-disabled:hover {
  color: var(--ui-muted);
  background: var(--ui-raised);
  border-color: var(--ui-line);
}
html[data-participant-theme="dark"] .ms-page .ms-order-form > .ms-field-error { color: var(--ui-danger); }
html[data-participant-theme="dark"] .ms-page .ms-text-button {
  color: var(--ui-text);
  border-bottom-color: var(--ui-line);
}
html[data-participant-theme="dark"] .ms-page .ms-text-button:hover { border-bottom-color: var(--ui-text); }
html[data-participant-theme="dark"] .ms-page :is(.ms-preview-details,.ms-reset) > summary:hover { color: var(--ui-accent-text); }
html[data-participant-theme="dark"] .ms-page .ms-checkout-step:focus { outline-color: var(--ui-text); }

/* Ledger, guide, and balance surfaces use the same readable hierarchy. */
html[data-participant-theme="dark"] .ew-area :is(.ew-balances,.ew-ledger,.ew-detail,.ew-sample-summary,.ew-sample-disclosure,.ew-guide-topic,.ew-guide-section) {
  color: var(--ui-text);
  background: var(--ui-surface);
  border-color: var(--ui-line);
}
html[data-participant-theme="dark"] .ew-area .ew-wallet-primary .ew-balances,
html[data-participant-theme="dark"] .ew-area .ew-detail { border-top-color: var(--ui-accent); }
html[data-participant-theme="dark"] .ew-area :is(.ew-balance-main,.ew-wallet-primary .ew-balance-main,.ew-guide-topic.is-current) {
  color: var(--ui-text);
  background: var(--ui-accent-soft);
}
html[data-participant-theme="dark"] .ew-area .ew-guide-topic.is-current { border-color: #636366; }
html[data-participant-theme="dark"] .ew-area :is(.ew-balance-badge,.ew-mobile-amounts) { border-color: var(--ui-line); }
html[data-participant-theme="dark"] .ew-area :is(.ew-own-notice,.ew-example-notice,.ew-record-count,.ew-table caption,.ew-table thead th,.ew-guide-table thead th),
html[data-participant-theme="dark"] .ew-area .ew-guide-section[open] > summary {
  color: var(--ui-text);
  background: var(--ui-raised);
  border-color: var(--ui-line);
}
html[data-participant-theme="dark"] .ew-area .ew-example-notice { border-left-color: var(--ui-accent); }
html[data-participant-theme="dark"] .ew-area :is(.ew-own-notice,.ew-example-notice,.ew-filter-empty) > .ew-icon,
html[data-participant-theme="dark"] .ew-area .ew-guide-section > summary > .ew-icon,
html[data-participant-theme="dark"] .ew-area .ew-dynamic-explain .ew-icon {
  color: var(--ui-accent-text);
  background: var(--ui-accent-soft);
}
html[data-participant-theme="dark"] .ew-area .ew-filters select {
  color: var(--ui-text);
  background: var(--ui-surface);
  border-color: var(--ui-line);
}
html[data-participant-theme="dark"] .ew-area .ew-filters select:disabled {
  color: var(--ui-muted);
  background: var(--ui-raised);
}
html[data-participant-theme="dark"] .ew-area .ew-switch.is-active { border-bottom-color: #636366; }
html[data-participant-theme="dark"] .ew-area .ew-switch:hover,
html[data-participant-theme="dark"] .ew-area .ew-guide-topic:hover,
html[data-participant-theme="dark"] .ew-area .ew-sample-disclosure > summary:hover {
  color: var(--ui-text);
  background: var(--ui-raised);
}
html[data-participant-theme="dark"] .ew-area .ew-table tbody :is(th,td),
html[data-participant-theme="dark"] .ew-area .ew-mobile-transactions > li + li { border-color: var(--ui-line); }
html[data-participant-theme="dark"] .ew-area .ew-table tbody tr:hover,
html[data-participant-theme="dark"] .ew-area .ew-table tbody tr:focus-within { background: var(--ui-raised); }
html[data-participant-theme="dark"] .ew-area :is(.ew-date,.ew-reference,.ew-type,.ew-zero,.ew-guide-list,.ew-footnote) { color: var(--ui-muted); }
html[data-participant-theme="dark"] .ew-area :is(.ew-amount,.ew-earned-points) { color: var(--ui-success); }
html[data-participant-theme="dark"] .ew-area .ew-amount-out { color: var(--ui-text); }
html[data-participant-theme="dark"] .ew-area .ew-status {
  color: var(--ui-muted);
  background: var(--ui-raised);
  border-color: var(--ui-line);
}
html[data-participant-theme="dark"] .ew-area :is(.ew-status-credited,.ew-status-released) {
  color: var(--ui-success);
  background: var(--ew-success-bg);
}
html[data-participant-theme="dark"] .ew-area .ew-status-pending {
  color: var(--ew-warning-text);
  background: var(--ew-warning-bg);
}
html[data-participant-theme="dark"] .ew-area .ew-detail-explanation > .ew-pending-note,
html[data-participant-theme="dark"] .ew-area .ew-guide-table tbody tr:last-child td[colspan] { color: var(--ew-warning-text); }
html[data-participant-theme="dark"] .ew-area :is(.ew-formula,.ew-detail .ew-formula,.ew-context-note,.ew-guide-note) {
  color: var(--ui-text);
  background: var(--ui-accent-soft);
  border-left-color: var(--ui-accent);
}
html[data-participant-theme="dark"] .ew-area .ew-guide-note { color: var(--ui-accent-text); }
html[data-participant-theme="dark"] .ew-area .ew-split-visual > div {
  color: var(--ui-text);
  background: var(--ui-accent-soft);
}
html[data-participant-theme="dark"] .ew-area .ew-split-visual > div + div {
  color: var(--ui-text);
  background: var(--ui-surface);
  border-color: var(--ui-line);
}
html[data-participant-theme="dark"] .ew-area .ew-split-visual > div + div strong {
  color: var(--ui-accent);
}
html[data-participant-theme="dark"] .ew-area .ew-point-symbol {
  color: var(--ui-accent-text);
  background: var(--ui-accent-soft);
  border-color: var(--ui-line);
}
html[data-participant-theme="dark"] .ew-area .ew-point-symbol-bp {
  color: var(--ui-text);
  background: var(--ui-raised);
}
html[data-participant-theme="dark"] :is(.ms-page,.ew-area) :is(summary,a,button,input,select):focus-visible,
html[data-participant-theme="dark"] .ew-area :is(.ew-table-wrap,.ew-detail,.ew-ledger):focus-visible {
  outline-color: var(--ui-accent);
}

/* External SVG icons stay dark where the surface remains brand yellow. */
html[data-participant-theme="dark"] .ms-page .ms-common-benefits > div > .ms-icon img.icon,
html[data-participant-theme="dark"] .ms-page :is(.ms-auth-prompt,.ms-empty,.ms-state-success) > .ms-icon img.icon {
  filter: none;
}
