:root {
  --retina-ui-text: var(--text, var(--on-surface, #1a1c1e));
  --retina-ui-border: var(--border-strong, var(--outline-strong, rgba(255, 255, 255, 0.16)));
  --retina-ui-hover: color-mix(in srgb, var(--retina-ui-text) 8%, transparent);
  --retina-ui-hover-strong: color-mix(in srgb, var(--retina-ui-text) 13%, transparent);
  --retina-ui-focus: color-mix(in srgb, var(--primary, #686ae8) 72%, transparent);
  --retina-ui-hover-tone: white;
  --retina-ui-primary-hover-bg: color-mix(in srgb, var(--primary, #686ae8) 92%, var(--retina-ui-hover-tone));
  --retina-ui-speed: 160ms;
}

button,
[role="button"],
.btn,
.back-btn,
.theme-toggle,
.dashboard-return,
.help-corner-btn,
.retina-cloud-button,
.topbar-btn,
.export-btn,
.cluster-btn,
.sidebar-action,
.nav-item,
.setup-import-btn,
.inline-help-btn,
.ops-button,
.help-action,
.desktop-only-actions a {
  transition-property: background-color, border-color, color, opacity, filter;
  transition-duration: var(--retina-ui-speed);
  transition-timing-function: ease;
}

button,
.btn,
.back-btn,
.theme-toggle,
.dashboard-return,
.help-corner-btn,
.retina-cloud-button,
.topbar-btn,
.export-btn,
.cluster-btn,
.sidebar-action,
.nav-item,
.setup-import-btn,
.inline-help-btn,
.ops-button,
.help-action,
.desktop-only-actions a {
  box-shadow: none !important;
}

/* Help uses the same quiet filled hierarchy on every public and app page.
   The compact Docs and Back controls stay content-width; the two primary
   help choices keep their full-row layout from each page. */
.help-action,
.help-back {
  border: 0 !important;
  border-bottom: 0 !important;
  box-shadow: none !important;
}

.help-back {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: auto;
  min-height: 30px;
  padding: 6px 10px;
  border-radius: var(--control-radius, 8px) !important;
  background-color: color-mix(in srgb, var(--retina-ui-text) 6%, transparent) !important;
  color: var(--retina-ui-text);
  text-decoration: none !important;
}

.help-back:hover:not(:disabled) {
  border: 0 !important;
  border-bottom: 0 !important;
  background-color: color-mix(in srgb, var(--retina-ui-text) 11%, transparent) !important;
  text-decoration: none !important;
}

.help-action {
  background-color: color-mix(in srgb, var(--retina-ui-text) 7%, transparent) !important;
}

.help-action:hover:not(:disabled) {
  background-color: color-mix(in srgb, var(--retina-ui-text) 12%, transparent) !important;
}

/* Retina does not use outlined buttons. Keep the transparent border box so
   geometry never shifts between rest, hover, focus, and active states. */
button,
button:hover,
button:active {
  border-color: transparent !important;
}

button:hover,
button:active,
[role="button"]:hover,
[role="button"]:active,
.btn:hover,
.btn:active,
.back-btn:hover,
.back-btn:active,
.theme-toggle:hover,
.theme-toggle:active,
.dashboard-return:hover,
.dashboard-return:active,
.help-corner-btn:hover,
.help-corner-btn:active,
.retina-cloud-button:hover,
.retina-cloud-button:active,
.topbar-btn:hover,
.topbar-btn:active,
.export-btn:hover,
.export-btn:active,
.cluster-btn:hover,
.cluster-btn:active,
.sidebar-action:hover,
.sidebar-action:active,
.nav-item:hover,
.nav-item:active,
.setup-import-btn:hover,
.setup-import-btn:active,
.inline-help-btn:hover,
.inline-help-btn:active,
.ops-button:hover,
.ops-button:active,
.help-action:hover,
.help-action:active,
.desktop-only-actions a:hover,
.desktop-only-actions a:active {
  transform: none !important;
  box-shadow: none !important;
}

:is(button, [role="button"], .btn, .back-btn, .theme-toggle, .dashboard-return, .help-corner-btn, .retina-cloud-button, .topbar-btn, .export-btn, .cluster-btn, .sidebar-action, .nav-item, .setup-import-btn, .inline-help-btn, .ops-button, .help-action, .desktop-only-actions a):focus-visible {
  outline: 2px solid var(--retina-ui-focus);
  outline-offset: 2px;
  box-shadow: none !important;
}

:is(
  .theme-toggle,
  .dashboard-return,
  .back-btn,
  .setup-import-btn,
  .inline-help-btn,
  .export-btn:not(.danger),
  .topbar-btn:not(.primary):not(.danger),
  .cluster-btn:not(.primary):not(.danger),
  .ops-button,
  .btn:not(.btn-primary):not(.primary):not(.danger):not(.ghost-danger),
  .retina-cloud-button:not(.primary):not(.danger)
):hover:not(:disabled) {
  border-color: transparent !important;
  background-color: var(--retina-ui-hover) !important;
}

:is(
  .btn-primary,
  .btn.primary,
  .retina-cloud-button.primary,
  .help-corner-btn,
  .topbar-btn.primary,
  .desktop-only-actions a.primary
):hover:not(:disabled) {
  border-color: var(--retina-ui-primary-hover-bg) !important;
  background-color: var(--retina-ui-primary-hover-bg) !important;
  filter: none !important;
}

html.light {
  --retina-ui-hover-tone: black;
  --retina-ui-primary-hover-bg: color-mix(in srgb, var(--primary, #686ae8) 92%, black);
}

/* Theme controls are intentionally borderless everywhere. Their changing
   surface and animated sun/moon provide the affordance without a hover ring. */
#themeToggle {
  border-color: transparent !important;
  border-width: 1px !important;
  border-style: solid !important;
  background-color: color-mix(in srgb, var(--retina-ui-text) 4%, transparent) !important;
  box-shadow: none !important;
}

#themeToggle:hover:not(:disabled) {
  border-color: transparent !important;
  background-color: color-mix(in srgb, var(--retina-ui-text) 10%, transparent) !important;
  box-shadow: none !important;
}

#themeToggle:active:not(:disabled) {
  border-color: transparent !important;
  background-color: color-mix(in srgb, var(--retina-ui-text) 14%, transparent) !important;
  box-shadow: none !important;
}

.theme-toggle:hover:not(:disabled),
.theme-toggle:active:not(:disabled) {
  border-color: transparent !important;
  background-color: var(--retina-ui-hover) !important;
}

/* Keep the control anchored while Night/Light changes state, and provide one
   shared icon transition for every full-size theme toggle. */
.theme-toggle {
  width: 82px !important;
  min-width: 82px !important;
  justify-content: flex-start !important;
  border-color: transparent !important;
  background-color: color-mix(in srgb, var(--retina-ui-text) 4%, transparent) !important;
}

/* Dashboard's compact theme control lives inside an existing action cluster.
   Match the neighboring icon buttons: transparent at rest, surface on hover. */
body #themeToggle.cluster-btn {
  border-color: transparent !important;
  background-color: transparent !important;
}

body #themeToggle.cluster-btn:hover:not(:disabled) {
  border-color: transparent !important;
  background-color: var(--surface-container-high) !important;
}

body #themeToggle.cluster-btn:active:not(:disabled) {
  border-color: transparent !important;
  background-color: var(--surface-container-highest) !important;
}

#themeToggle.cluster-btn .cluster-theme-icon svg {
  transition: opacity 240ms ease, transform 380ms cubic-bezier(.2, .8, .2, 1) !important;
}

/* Landing-page secondary calls to action use the same quiet surface as the
   app controls. Primary actions retain their filled brand treatment. */
.hero-ctas .btn:not(.btn-primary) {
  border-color: transparent !important;
  background-color: color-mix(in srgb, var(--retina-ui-text) 4%, transparent) !important;
  box-shadow: none !important;
}

.hero-ctas .btn:not(.btn-primary):hover,
.hero-ctas .btn:not(.btn-primary):active {
  border-color: transparent !important;
  background-color: var(--retina-ui-hover) !important;
  box-shadow: none !important;
}

.theme-toggle .icon {
  position: relative;
  width: 16px;
  height: 16px;
  display: inline-block;
  line-height: 1;
  flex: 0 0 auto;
}

.theme-toggle .icon svg {
  position: absolute;
  inset: 0;
  width: 16px;
  height: 16px;
  transition: opacity 220ms ease, transform 340ms cubic-bezier(.2, .8, .2, 1) !important;
}

.theme-toggle .theme-icon-sun {
  opacity: 0;
  transform: rotate(-90deg) scale(.55);
}

.theme-toggle .theme-icon-moon {
  opacity: 1;
  transform: none;
}

html.light .theme-toggle .theme-icon-moon {
  opacity: 0;
  transform: rotate(90deg) scale(.55);
}

html.light .theme-toggle .theme-icon-sun {
  opacity: 1;
  transform: none;
}

/* Setup uses quiet filled actions instead of outlined pills. Inputs, status
   controls, and destructive actions retain their own distinct treatment. */
body.setup-page :is(
  .setup-import-btn,
  .dashboard-return,
  .inline-help-btn,
  .btn:not(.ghost-danger),
  .retina-cloud-button:not(.primary):not(.danger)
) {
  border-color: transparent !important;
  background-color: color-mix(in srgb, var(--retina-ui-text) 5%, transparent) !important;
}

body.setup-page :is(
  .setup-import-btn,
  .dashboard-return,
  .inline-help-btn,
  .btn:not(.ghost-danger),
  .retina-cloud-button:not(.primary):not(.danger)
):hover:not(:disabled) {
  border-color: transparent !important;
  background-color: var(--retina-ui-hover) !important;
}

body.setup-page .btn-primary {
  border-color: transparent !important;
}

body.setup-page .btn-primary:hover:not(:disabled) {
  border-color: transparent !important;
}

/* Application action surfaces. These controls used to mix white fills with
   outlined pills. A quiet fill now carries the affordance; hover strengthens
   the same surface without introducing a border. */
body :is(
  .export-btn:not(.danger),
  .back-btn,
  .detail-back-btn,
  .card-action-btn,
  .price-card-btn,
  .chart-legend-btn:not(.static),
  .maturity-settings-btn,
  .protocol-refresh-action,
  .position-row-edit-btn,
  .pm-config-remove-btn,
  .risk-link-btn,
  .multi-select-btn,
  .history-range-btn,
  .rewards-retry-btn,
  .rewards-manage-wallets-btn,
  .wallet-detail-v2-copy,
  .wallet-detail-v2-table-toggle,
  .ai-suggestion,
  .ai-reset-chat,
  .ai-model-action:not(.primary),
  .topbar-btn.ghost,
  .snap-action-btn,
  .risk-tab,
  .table-sort-btn,
  .pm-apr-sort-btn,
  .protocol-sort-btn,
  .dedup-note-toggle,
  .rewards-source-chip,
  .rewards-source-link,
  .pulse-chip,
  .scv2-showall
) {
  border-color: transparent !important;
  background-color: color-mix(in srgb, var(--retina-ui-text) 6%, transparent) !important;
  box-shadow: none !important;
}

body :is(
  .export-btn:not(.danger),
  .back-btn,
  .detail-back-btn,
  .card-action-btn,
  .price-card-btn,
  .chart-legend-btn:not(.static),
  .maturity-settings-btn,
  .protocol-refresh-action,
  .position-row-edit-btn,
  .pm-config-remove-btn,
  .risk-link-btn,
  .multi-select-btn,
  .history-range-btn,
  .rewards-retry-btn,
  .rewards-manage-wallets-btn,
  .wallet-detail-v2-copy,
  .wallet-detail-v2-table-toggle,
  .ai-suggestion,
  .ai-reset-chat,
  .ai-model-action:not(.primary),
  .topbar-btn.ghost,
  .snap-action-btn,
  .risk-tab,
  .table-sort-btn,
  .pm-apr-sort-btn,
  .protocol-sort-btn,
  .dedup-note-toggle,
  .rewards-source-chip,
  .rewards-source-link,
  .pulse-chip,
  .scv2-showall
):hover:not(:disabled) {
  border-color: transparent !important;
  background-color: color-mix(in srgb, var(--retina-ui-text) 11%, transparent) !important;
  box-shadow: none !important;
  text-decoration: none !important;
}

body :is(.history-range-btn.active, .risk-tab.active) {
  border-color: transparent !important;
  background-color: color-mix(in srgb, var(--primary) 14%, transparent) !important;
}

body .chart-legend-btn.active {
  border-color: transparent !important;
  background-color: color-mix(in srgb, var(--legend-color, var(--primary)) 14%, transparent) !important;
}

body .chart-legend-btn.active:hover:not(:disabled) {
  border-color: transparent !important;
  background-color: color-mix(in srgb, var(--legend-color, var(--primary)) 22%, transparent) !important;
}

body.dashboard-page :is(
  .pm-tabbar,
  .pm-range-control,
  .history-range-strip,
  .protocol-sort-control,
  .rewards-view-toggle,
  .manual-position-pricing
) {
  border-color: transparent !important;
  background-color: color-mix(in srgb, var(--retina-ui-text) 5%, transparent) !important;
  box-shadow: none !important;
}

body.dashboard-page .card-action-group .card-action-btn {
  border-color: transparent !important;
  background-color: transparent !important;
}

body.dashboard-page .card-action-group .card-action-btn:hover:not(:disabled) {
  border-color: transparent !important;
  background-color: var(--retina-ui-hover) !important;
}

body.dashboard-page .rewards-view-toggle button:not(.active):hover:not(:disabled) {
  background-color: var(--retina-ui-hover-strong) !important;
}

body.dashboard-page .rewards-view-toggle button.active {
  background-color: color-mix(in srgb, var(--primary) 14%, transparent) !important;
}

body.dashboard-page .rewards-view-toggle button.active:hover:not(:disabled) {
  background-color: color-mix(in srgb, var(--primary) 22%, transparent) !important;
}

body :is(.export-btn.danger, .retina-cloud-button.danger, .ghost-danger) {
  border-color: transparent !important;
  background-color: color-mix(in srgb, var(--neg, var(--neg-red, #e5484d)) 10%, transparent) !important;
}

body :is(.export-btn.danger, .retina-cloud-button.danger, .ghost-danger):hover:not(:disabled) {
  border-color: transparent !important;
  background-color: color-mix(in srgb, var(--neg, var(--neg-red, #e5484d)) 16%, transparent) !important;
}

:is(.danger, .ghost-danger):hover:not(:disabled) {
  filter: none !important;
}

button:disabled,
[role="button"][aria-disabled="true"],
.btn:disabled {
  transform: none !important;
  box-shadow: none !important;
}

@media (prefers-reduced-motion: reduce) {
  button,
  [role="button"],
  .btn,
  .back-btn,
  .theme-toggle,
  .dashboard-return,
  .help-corner-btn,
  .retina-cloud-button,
  .topbar-btn,
  .export-btn,
  .cluster-btn,
  .sidebar-action,
  .nav-item,
  .setup-import-btn,
  .inline-help-btn,
  .ops-button,
  .help-action,
  .desktop-only-actions a {
    transition-duration: 0.01ms;
  }
}

/* Sortable table headers (Yield, Polymarket, Wallets, Positions, Protocols)
   must read as plain header text at rest and only reveal a surface on hover.
   These load last so they win over the per-table rest styling. */
.table-sort-btn,
.table-sort-btn[aria-pressed="true"],
.pm-apr-sort-btn,
.pm-apr-sort-btn[aria-pressed="true"],
.protocol-sort-btn,
.protocol-sort-btn.active,
.protocol-sort-btn[aria-pressed="true"] {
  background: transparent !important;
  background-color: transparent !important;
  border-color: transparent !important;
  box-shadow: none !important;
}
.table-sort-btn:hover:not(:disabled),
.pm-apr-sort-btn:hover:not(:disabled),
.protocol-sort-btn:hover:not(:disabled) {
  background-color: color-mix(in srgb, var(--on-surface, #e8e6e1) 8%, transparent) !important;
}
