@layer components {
  /* ---------- Exchange BiDi ---------- */
  .crtoday-widget:dir(rtl) .crtoday-row:hover {
    transform: translateX(-var(--crtoday-space-2));
  }

  .crtoday-widget:dir(rtl) .crtoday-rates-header-label,
  .crtoday-widget:dir(rtl) .crtoday-mid,
  .crtoday-widget:dir(rtl) .crtoday-bid,
  .crtoday-widget:dir(rtl) .crtoday-ask {
    text-align: left;
    justify-content: flex-start;
  }

  /* ---------- Rates Grid ---------- */

  /*
   * Column-width + gap tokens: set once at widget level, compact overrides below.
   * All grid-template-columns and gaps reference these -- keeping combos DRY.
   */
  .crtoday-exchange-rates {
    --crtoday-col-rate: var(--crtoday-space-90);
    --crtoday-col-delta: var(--crtoday-space-72);
    --crtoday-col-gap: var(--crtoday-space-12);
  }

  .crtoday-exchange-rates:not(.crtoday-compact) {
    --crtoday-header-padding-y: calc((var(--crtoday-space-60) - var(--crtoday-space-1) - var(--crtoday-space-32)) / 2);
  }

  .crtoday-exchange-rates.crtoday-compact {
    --crtoday-col-rate: var(--crtoday-space-76);
    --crtoday-col-delta: var(--crtoday-space-60);
    --crtoday-col-gap: var(--crtoday-space-8);
  }

  .crtoday-widget .crtoday-rates {
    padding: var(--crtoday-space-8) var(--crtoday-space-6) var(--crtoday-space-8);
  }

  .crtoday-widget .crtoday-row {
    display: grid;
    grid-template-columns: 1fr var(--crtoday-col-rate) var(--crtoday-col-delta);
    align-items: center;
    gap: 0 var(--crtoday-col-gap);
    padding: var(--crtoday-space-10) var(--crtoday-space-14);
    border-bottom: var(--crtoday-space-1) solid var(--crtoday-separator);
    transition: background 0.18s ease, transform 0.18s ease;
    cursor: default;
  }

  .crtoday-widget:not(.crtoday-has-adjustment) .crtoday-row:last-child {
    border-bottom: none;
  }

  /* ---------- Currency Pair ---------- */
  .crtoday-widget .crtoday-pair {
    display: flex;
    align-items: center;
    gap: var(--crtoday-space-10);
    min-width: 0;
  }

  .crtoday-widget .crtoday-row:hover .crtoday-flag-wrap {
    transform: scale(1.06);
    box-shadow: 0 var(--crtoday-space-2) var(--crtoday-space-8) rgb(var(--crtoday-accent-rgb) / 0.12);
  }

  .crtoday-widget .crtoday-symbol {
    font-size: var(--crtoday-space-16);
    font-weight: 600;
    color: var(--crtoday-text-1);
    letter-spacing: -0.01em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* ---------- Rate / Bid / Ask Values (merged -- DRY) ---------- */
  .crtoday-widget .crtoday-mid,
  .crtoday-widget .crtoday-bid,
  .crtoday-widget .crtoday-ask {
    display: inline-flex;
    align-items: center;
    gap: var(--crtoday-space-4);
    font-size: var(--crtoday-space-16);
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    color: var(--crtoday-text-1);
    text-align: right;
    letter-spacing: -0.02em;
    white-space: nowrap;
    min-width: var(--crtoday-space-54);
    justify-content: flex-end;
  }

  /* ---------- Rates Column Header ---------- */
  .crtoday-widget .crtoday-rates-header {
    display: grid;
    grid-template-columns: 1fr var(--crtoday-col-rate) var(--crtoday-col-delta);
    align-items: center;
    gap: 0 var(--crtoday-col-gap);
    padding: 0 var(--crtoday-space-14) var(--crtoday-space-6);
  }

  .crtoday-widget .crtoday-rates-header-label {
    font-size: var(--crtoday-space-11);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--crtoday-text-3);
    text-align: right;
    min-width: var(--crtoday-space-54);
    white-space: nowrap;
  }

  .crtoday-widget .crtoday-rates-header-spacer {
    display: block;
  }

  .crtoday-widget .crtoday-rates-header-spacer-delta,
  .crtoday-widget .crtoday-row-spacer-delta {
    justify-self: end;
    width: 100%;
    min-height: var(--crtoday-space-20);
  }

  /* ---------- Grid Column Combos ----------
     Using --crtoday-col-rate / --crtoday-col-delta variables means
     these rules work for BOTH base and compact without duplication.
     :is() merges header + row selectors -- DRY. */

  .crtoday-widget.crtoday-pricing-bidask :is(.crtoday-rates-header, .crtoday-row) {
    grid-template-columns: 1fr var(--crtoday-col-rate) var(--crtoday-col-rate) var(--crtoday-col-delta);
  }

  .crtoday-widget.crtoday-has-row-cta :is(.crtoday-rates-header, .crtoday-row) {
    grid-template-columns: 1fr var(--crtoday-col-rate) var(--crtoday-col-delta) var(--crtoday-col-rate);
  }

  .crtoday-widget.crtoday-has-row-cta.crtoday-pricing-bidask :is(.crtoday-rates-header, .crtoday-row) {
    grid-template-columns: 1fr var(--crtoday-col-rate) var(--crtoday-col-rate) var(--crtoday-col-delta) var(--crtoday-col-rate);
  }

  .crtoday-widget.crtoday-no-change :is(.crtoday-rates-header, .crtoday-row) {
    grid-template-columns: 1fr var(--crtoday-col-rate);
  }

  .crtoday-widget.crtoday-no-change.crtoday-pricing-bidask :is(.crtoday-rates-header, .crtoday-row) {
    grid-template-columns: 1fr var(--crtoday-col-rate) var(--crtoday-col-rate);
  }

  .crtoday-widget.crtoday-no-change.crtoday-has-row-cta :is(.crtoday-rates-header, .crtoday-row) {
    grid-template-columns: 1fr var(--crtoday-col-rate) var(--crtoday-col-rate);
  }

  .crtoday-widget.crtoday-no-change.crtoday-has-row-cta.crtoday-pricing-bidask :is(.crtoday-rates-header, .crtoday-row) {
    grid-template-columns: 1fr var(--crtoday-col-rate) var(--crtoday-col-rate) var(--crtoday-col-rate);
  }

  /* ---------- Trend SVG Arrow ---------- */
  .crtoday-widget .crtoday-trend {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    line-height: 0;
    transition: transform 0.15s ease;
  }

  .crtoday-widget .crtoday-trend-icon {
    width: var(--crtoday-space-14);
    height: var(--crtoday-space-14);
  }

  .crtoday-widget .crtoday-trend-icon-neutral {
    width: var(--crtoday-space-10);
    height: var(--crtoday-space-10);
  }

  .crtoday-widget .crtoday-row:hover .crtoday-trend {
    transform: scale(1.2);
  }

  .crtoday-widget .crtoday-trend-up {
    color: var(--crtoday-up);
  }

  .crtoday-widget .crtoday-trend-down {
    color: var(--crtoday-down);
  }

  .crtoday-widget .crtoday-trend-neutral {
    color: var(--crtoday-neutral);
  }

  /* ---------- Hide Flags ---------- */
  .crtoday-widget.crtoday-no-flags .crtoday-flag-wrap {
    display: none;
  }

  /* ---------- Delta Pill ---------- */
  .crtoday-widget .crtoday-delta {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: var(--crtoday-space-48);
    padding: var(--crtoday-space-4) var(--crtoday-space-10);
    border-radius: var(--crtoday-space-6);
    font-size: var(--crtoday-space-12);
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    text-align: center;
    transition: transform 0.12s ease;
  }

  .crtoday-widget .crtoday-row:hover .crtoday-delta {
    transform: scale(1.04);
  }

  .crtoday-widget .crtoday-delta-up {
    color: var(--crtoday-up);
    background: var(--crtoday-up-bg);
  }

  .crtoday-widget .crtoday-delta-down {
    color: var(--crtoday-down);
    background: var(--crtoday-down-bg);
  }

  .crtoday-widget .crtoday-delta-neutral {
    color: var(--crtoday-neutral);
    background: var(--crtoday-neutral-bg);
  }

  /* ---------- Stacked Delta Pair (bid/ask) ---------- */
  .crtoday-widget .crtoday-delta-pair {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: var(--crtoday-space-2);
  }

  .crtoday-widget .crtoday-delta-pair .crtoday-delta {
    min-width: 0;
    padding: var(--crtoday-space-2) var(--crtoday-space-6);
    font-size: var(--crtoday-space-10);
    border-radius: var(--crtoday-space-4);
  }

  .crtoday-widget .crtoday-row-cta,
  .crtoday-widget .crtoday-row-cta:visited,
  .crtoday-widget .crtoday-row-cta:active {
    justify-self: stretch;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-width: 0;
    padding: var(--crtoday-space-4) var(--crtoday-space-10);
    border: var(--crtoday-space-1) solid rgb(var(--crtoday-accent-rgb) / 0.4);
    border-radius: var(--crtoday-space-6);
    background: rgb(var(--crtoday-accent-rgb) / 0.1);
    color: var(--crtoday-text-1) !important;
    font-size: var(--crtoday-space-12);
    font-weight: 600;
    text-decoration: none !important;
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
  }

  .crtoday-widget .crtoday-row-cta:hover {
    background: rgb(var(--crtoday-accent-rgb) / 0.16);
    border-color: rgb(var(--crtoday-accent-rgb) / 0.55);
    color: var(--crtoday-text-1) !important;
    text-decoration: none !important;
  }

  .crtoday-widget .crtoday-row-cta:is(:focus, :focus-visible) {
    outline: none !important;
    border-color: var(--crtoday-conv-field-focus-border, rgb(var(--crtoday-accent-rgb) / 0.45)) !important;
    box-shadow: var(--crtoday-conv-field-focus-ring, 0 0 0 0.1875rem rgb(var(--crtoday-accent-rgb) / 0.08)) !important;
    color: var(--crtoday-text-1) !important;
    text-decoration: none !important;
  }

  .crtoday-widget .crtoday-row-cta.crtoday-row-cta-disabled,
  .crtoday-widget .crtoday-row-cta[aria-disabled='true'] {
    opacity: 0.6;
    pointer-events: none;
  }

  /* ---------- Compact exchange grid ---------- */
  .crtoday-widget.crtoday-compact .crtoday-rates {
    padding: var(--crtoday-space-6) var(--crtoday-space-4) var(--crtoday-space-4);
  }

  .crtoday-widget.crtoday-compact .crtoday-row {
    /* grid-template-columns + gap: handled by --crtoday-col-* variables */
    padding: var(--crtoday-space-6) var(--crtoday-space-10);
    border-radius: var(--crtoday-space-6);
  }

  .crtoday-widget.crtoday-compact .crtoday-pair {
    gap: var(--crtoday-space-6);
  }

  .crtoday-widget.crtoday-compact .crtoday-flag-wrap {
    width: var(--crtoday-size-flag-md);
    height: var(--crtoday-size-flag-md);
  }

  .crtoday-widget.crtoday-compact .crtoday-symbol {
    font-size: var(--crtoday-space-12);
  }

  /* Merged mid + bid/ask -- DRY */
  .crtoday-widget.crtoday-compact .crtoday-mid,
  .crtoday-widget.crtoday-compact .crtoday-bid,
  .crtoday-widget.crtoday-compact .crtoday-ask {
    font-size: var(--crtoday-space-12);
    gap: var(--crtoday-space-3);
    min-width: var(--crtoday-space-46);
  }

  .crtoday-widget.crtoday-compact .crtoday-rates-header {
    /* grid-template-columns + gap: handled by --crtoday-col-* variables */
    padding: 0 var(--crtoday-space-10) var(--crtoday-space-2);
  }

  .crtoday-widget.crtoday-compact .crtoday-rates-header-label {
    font-size: var(--crtoday-space-10);
    min-width: var(--crtoday-space-46);
  }

  /* Grid column combos for compact: fully handled by --crtoday-col-* vars -- zero duplication. */

  .crtoday-widget.crtoday-compact .crtoday-trend-icon {
    width: var(--crtoday-space-11);
    height: var(--crtoday-space-11);
  }

  .crtoday-widget.crtoday-compact .crtoday-trend-icon-neutral {
    width: var(--crtoday-space-8);
    height: var(--crtoday-space-8);
  }

  .crtoday-widget.crtoday-compact .crtoday-delta {
    min-width: var(--crtoday-space-56);
    padding: var(--crtoday-space-2) var(--crtoday-space-6);
    font-size: var(--crtoday-space-10);
    border-radius: var(--crtoday-space-4);
  }

  .crtoday-widget.crtoday-compact .crtoday-delta-pair .crtoday-delta {
    min-width: 0;
    padding: var(--crtoday-space-1) var(--crtoday-space-4);
    font-size: 0.5625rem;
    border-radius: var(--crtoday-space-3);
  }

  .crtoday-widget.crtoday-compact .crtoday-row-cta {
    min-width: var(--crtoday-space-56);
    padding: var(--crtoday-space-2) var(--crtoday-space-6);
    font-size: var(--crtoday-space-10);
    border-radius: var(--crtoday-space-4);
  }

  /* ---------- Empty / Error State ---------- */
  .crtoday-widget .crtoday-empty-msg {
    padding: var(--crtoday-space-24) var(--crtoday-space-20);
    text-align: center;
    font-size: var(--crtoday-space-14);
    font-weight: 500;
    color: var(--crtoday-text-3);
  }
}
