/* Important declarations in this layer take precedence over legacy component
   colors. Each variant supplies its text and surface as a pair. */
@layer control-contrast {
  :root {
    --control-surface: #ffffff;
    --control-ink: #292b2d;
    --control-edge: #647478;
    --control-hover: #edf2f3;
    --control-focus: #775000;
  }

  :root[data-theme="dark"] {
    --control-surface: #1c2025;
    --control-ink: #f2f3f5;
    --control-edge: #a2aeba;
    --control-hover: #303943;
    --control-focus: #f4e7a9;
  }

  body :is(button, a.button, a.primary, a.text-link, [role="button"], [role="tab"],
           input[type="submit"], input[type="button"], input[type="reset"]) {
    --action-surface: #b8dfe2;
    --action-ink: #20282b;
    --action-edge: #64878b;
    --action-hover: #d4f0f2;
    background: var(--action-surface) !important;
    color: var(--action-ink) !important;
    -webkit-text-fill-color: currentColor !important;
    border-color: var(--action-edge) !important;
    opacity: 1 !important;
    text-shadow: none !important;
    transition-property: transform, box-shadow !important;
    font-weight: 700 !important;
    white-space: normal !important;
    overflow-wrap: anywhere;
  }

  body :is(button, a.button, a.primary, a.text-link, [role="button"], [role="tab"])
    :is(span, small, strong, b, em, i, p, label) {
    color: inherit !important;
    -webkit-text-fill-color: currentColor !important;
    opacity: 1 !important;
  }

  body :is(.button.lime, .button.coral, .nav-cta, button.coral, button.lime) {
    --action-surface: #edb0a7;
    --action-ink: #292b2d;
    --action-edge: #a06660;
    --action-hover: #f7cec7;
  }

  body :is(.button.dark, .program-paths button[data-plan="basic"], .chat-tools .chat-send) {
    --action-surface: #292b2d;
    --action-ink: #ffffff;
    --action-edge: #a2aeba;
    --action-hover: #41474c;
  }

  body :is(.button.secondary, button.secondary, .button.quiet, button.quiet, a.text-link,
           :where(#appearance-toggle), .mobile-menu-toggle, .nav-trigger, .nav-panel a,
           .program-paths button[data-plan="coaching"], .ns-tabs button, .subnav button,
           .sidebar nav button, .workspace-tabs button, .program-filters button,
           .feature-switch button, .chat-tools button:not(.chat-send), .chat-file button) {
    --action-surface: var(--control-surface);
    --action-ink: var(--control-ink);
    --action-edge: var(--control-edge);
    --action-hover: var(--control-hover);
  }

  body .nav-panel a {
    transition-property: transform, box-shadow !important;
    background: var(--action-surface) !important;
    color: var(--action-ink) !important;
    -webkit-text-fill-color: currentColor !important;
  }

  body :is(.nav-trigger[aria-expanded="true"], [role="tab"][aria-selected="true"],
           .ns-tabs button[aria-selected="true"], .subnav button.active, .sidebar nav button.active,
           .workspace-tabs button.active, .program-filters button[aria-pressed="true"],
           .feature-switch button.active) {
    --action-surface: #b8dfe2;
    --action-ink: #20282b;
    --action-edge: #64878b;
    --action-hover: #d4f0f2;
  }

  body :is(button, a.button, a.primary, a.text-link, .nav-panel a, [role="button"], [role="tab"],
           input[type="submit"], input[type="button"], input[type="reset"]):not(.flexy-launch):not(:disabled):not([aria-disabled="true"]):hover {
    background: var(--action-hover) !important;
    box-shadow: inset 0 0 0 1px currentColor !important;
  }

  body :is(button, a.button, a.primary, a.text-link, .nav-panel a, [role="button"], [role="tab"],
           input[type="submit"], input[type="button"], input[type="reset"]):focus-visible {
    outline: 3px solid var(--control-focus) !important;
    outline-offset: 3px !important;
  }

  body :is(button, a.button, [role="button"], [role="tab"], input[type="submit"],
           input[type="button"], input[type="reset"]):is(:disabled, [aria-disabled="true"]) {
    --action-surface: var(--control-hover);
    --action-ink: var(--control-ink);
    --action-edge: var(--control-edge);
    border: 1px dashed var(--action-edge) !important;
    cursor: not-allowed;
  }

  body button.flexy-launch,
  body button.flexy-launch:hover {
    background: transparent !important;
    border: 0 !important;
    box-shadow: none !important;
    backdrop-filter: none !important;
    padding: 0 !important;
    border-radius: 0 !important;
    min-height: 0 !important;
  }

  body button.flexy-launch span {
    background: #f3b3aa !important;
    color: #292b2d !important;
  }
}
