/* Shared controls: approved outlined / flowing gradient / solid pressed states.
   Structural buttons retain the row, card, tab and icon layouts they belong to. */
:root body :is(button, a.button, a.text-button),
:root body input[type="file"]::file-selector-button {
  --button-accent: var(--accent);
  --button-deep: var(--accent-deep);
  border: 0;
  border-radius: 14px;
  background: transparent;
  color: #fff;
  box-shadow: inset 0 0 0 1px var(--button-accent);
  background-clip: border-box;
  transform: none;
  transition: none;
  animation: none;
}

/* Content-sized actions, including links that are presented as buttons. */
:root body :is(.button, .text-button, .admin-body button, button[data-edit-sub]),
:root body input[type="file"]::file-selector-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  width: fit-content;
  max-width: 100%;
  min-height: 43px;
  padding: 11px 18px;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.3;
  text-align: center;
  white-space: normal;
  overflow-wrap: anywhere;
  justify-self: start;
}

:root body input[type="file"]::file-selector-button {
  margin-right: 12px;
  cursor: pointer;
}

/* The approved authentication action keeps its larger typography. */
:root body .token-auth .login-panel .button[type="submit"] {
  justify-self: center;
  min-height: 52px;
  padding: 15px 29px;
  font-size: 20px;
  font-weight: 700;
  line-height: 1.2;
}

:root body .auth-switch .text-button {
  min-height: 34px;
  padding: 6px 10px;
  margin-left: 5px;
  font-size: 12px;
  color: var(--accent);
  vertical-align: middle;
}

/* Compact contexts keep their established geometry and usable hit areas. */
:root body .quick-actions .button {
  width: auto;
  justify-self: stretch;
  min-height: 40px;
  padding: 9px 7px;
  font-size: 12px;
  gap: 6px;
}

:root body :is(.page-heading, .inline-form) .button {
  min-height: 40px;
  padding: 9px 14px;
  font-size: 14px;
}

:root body .admin-table button,
:root body button[data-edit-sub] {
  min-height: 34px;
  padding: 8px 12px;
  font-size: 12px;
}

:root body .admin-nav footer button {
  width: fit-content;
}

:root body .icon-button {
  padding: 0;
}

:root body .hide-control {
  min-height: 32px;
  padding: 6px 8px;
}

:root body .market-footer button {
  min-width: 30px;
  min-height: 30px;
  padding: 5px;
}

:root body button.tab {
  min-height: 38px;
  padding: 9px 14px;
  font-size: 12px;
}

:root body button.tab.active::after {
  display: none;
}

/* Selection remains persistent instead of looking like an ordinary idle action. */
:root body :is(button.active, button.selected, button[aria-selected="true"], button[aria-pressed="true"]) {
  background: color-mix(in srgb, var(--button-accent) 24%, var(--bg));
  color: #fff;
  box-shadow: inset 0 0 0 2px var(--button-accent);
}

/* Dangerous actions keep a warning outline, with readable white action text. */
:root body :is(button.danger, a.button.danger, a.text-button.danger, #delete-sub) {
  --button-accent: #e0837b;
  --button-deep: #532629;
  color: #fff;
}

@media (hover: hover) {
  :root body :is(button, a.button, a.text-button):hover:not(:active):not(:disabled):not([aria-disabled="true"]),
  :root body input[type="file"]:hover:not(:active):not(:disabled)::file-selector-button {
    color: #fff;
    border: 0;
    box-shadow: none;
    background: linear-gradient(90deg, var(--button-accent) 0%, color-mix(in srgb, var(--button-accent) 65%, #000) 25%, var(--button-deep) 50%, color-mix(in srgb, var(--button-accent) 65%, #000) 75%, var(--button-accent) 100%) 0% 50% / 200% 100% repeat-x;
    transform: none;
    animation: wallet-button-gradient-flow 3s linear infinite;
  }
}

/* Matching ends move one full tile right and loop without a seam or edge stroke. */
@keyframes wallet-button-gradient-flow {
  from { background-position: 0% 50%; }
  to { background-position: -200% 50%; }
}

:root body :is(button, a.button, a.text-button):active:not(:disabled):not([aria-disabled="true"]),
:root body input[type="file"]:active:not(:disabled)::file-selector-button {
  border: 0;
  background: var(--button-accent);
  color: #fff;
  box-shadow: none;
  transform: none;
  animation: none;
}

:root body :is(button, a.button, a.text-button):focus-visible {
  outline: 2px solid var(--button-accent);
  outline-offset: 4px;
}

:root body :is(button.account-row, button.activity-row, .control-list button, button.discover-panel):focus-visible {
  outline-offset: -3px;
}

/* Disabled controls may be unavailable, not necessarily waiting for a request. */
:root body :is(button, a.button, a.text-button):is(:disabled, [aria-disabled="true"]),
:root body input[type="file"]:disabled::file-selector-button {
  opacity: .55;
  background: transparent;
  color: #fff;
  box-shadow: inset 0 0 0 1px var(--button-accent);
  cursor: not-allowed;
  transform: none;
  animation: none;
}

:root body :is(button, a.button, a.text-button)[aria-busy="true"] {
  cursor: wait;
}

@media (prefers-reduced-motion: reduce) and (hover: hover) {
  /* Preserve the requested hover effect at a gentler pace. */
  :root body :is(button, a.button, a.text-button):hover:not(:active):not(:disabled):not([aria-disabled="true"]),
  :root body input[type="file"]:hover:not(:active):not(:disabled)::file-selector-button {
    animation-duration: 6s;
  }
}

@media (max-width: 600px) {
  :root body .modal-actions {
    flex-wrap: wrap;
  }

  :root body .page-heading > .button {
    padding: 9px 12px;
    font-size: 12px;
  }

  :root body button.tab {
    padding: 9px 12px;
    font-size: 11px;
  }
}
