.app-main:has(.exchange-page) {
  padding: 0 0 calc(16px + var(--safe-bottom));
  background: #020302;
}

body:has(.exchange-subpage) .tabbar {
  display: none !important;
}

.exchange-subpage {
  --ex-sub-topbar-height: 48px;
  padding-top: calc(var(--ex-sub-topbar-height) + var(--safe-top));
}

.ex-sub-topbar {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  margin: 0 auto !important;
  width: 100%;
  max-width: 480px;
  height: calc(var(--ex-sub-topbar-height) + var(--safe-top));
  padding: var(--safe-top) 16px 0;
  box-sizing: border-box;
  z-index: 90;
  display: grid;
  grid-template-columns: 36px 1fr auto;
  align-items: center;
  gap: 8px;
  background: linear-gradient(180deg, rgba(2, 3, 2, 0.94), rgba(2, 3, 2, 0.78) 75%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.ex-sub-back {
  width: 36px;
  height: 36px;
  margin-left: -4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  color: #eef7dc;
  border: 1px solid rgba(182, 245, 58, 0.16);
  background: rgba(182, 245, 58, 0.06);
  text-decoration: none;
}

.ex-sub-back:active {
  background: rgba(182, 245, 58, 0.14);
  color: var(--ex-accent);
}

.ex-sub-title {
  margin: 0;
  text-align: center;
  font-size: 16px;
  font-weight: 650;
  line-height: 1;
  letter-spacing: 0.03em;
  color: var(--ex-text);
}

.ex-sub-records {
  font-size: 12px;
  font-weight: 600;
  color: var(--ex-accent);
  text-decoration: none;
  white-space: nowrap;
}

.ex-sub-records:active {
  opacity: 0.75;
}

.exchange-page {
  --ex-bg: #020302;
  --ex-card: rgba(14, 18, 12, 0.72);
  --ex-border: rgba(182, 245, 58, 0.14);
  --ex-accent: #b6f53a;
  --ex-text: #f4f7ef;
  --ex-muted: #8f9688;
  --ex-sub: #8f9688;
  --ex-panel: rgba(14, 18, 12, 0.75);
  position: relative;
  isolation: isolate;
  min-height: 100%;
  padding: 12px 0 20px;
  background:
    radial-gradient(120% 70% at 50% -8%, rgba(126, 201, 34, 0.14), transparent 55%),
    linear-gradient(180deg, #050805 0%, #020302 50%, #000 100%);
  color: var(--ex-text);
  font-feature-settings: "tnum" 1;
}

.ex-atmosphere {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 0;
}

.ex-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(42px);
  opacity: 0.48;
  animation: ex-float 10s ease-in-out infinite;
}

.ex-orb-a {
  width: 210px;
  height: 210px;
  top: 8%;
  right: -70px;
  background: radial-gradient(circle, rgba(182, 245, 58, 0.3), transparent 68%);
}

.ex-orb-b {
  width: 240px;
  height: 240px;
  bottom: 18%;
  left: -90px;
  background: radial-gradient(circle, rgba(90, 160, 30, 0.22), transparent 70%);
  animation-delay: -3.5s;
}

.ex-grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(182, 245, 58, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(182, 245, 58, 0.03) 1px, transparent 1px);
  background-size: 28px 28px;
  mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.45), transparent 70%);
  opacity: 0.6;
}

@keyframes ex-float {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(14px) scale(1.05); }
}

.ex-hero,
.ex-card {
  position: relative;
  z-index: 1;
}

.ex-header {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  margin: 0 auto !important;
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  z-index: 90;
}

.ex-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1;
}

.ex-logo-wrap {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(182, 245, 58, 0.08);
  border: 1px solid rgba(182, 245, 58, 0.22);
  box-shadow: 0 0 16px rgba(182, 245, 58, 0.16);
  flex-shrink: 0;
}

.ex-logo {
  width: 22px;
  height: 22px;
  object-fit: contain;
  border-radius: 5px;
}

.ex-brand-name {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.03em;
  white-space: nowrap;
}

.ex-lang,
.ex-wallet {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 34px;
  padding: 0 10px;
  border-radius: 11px;
  border: 1px solid rgba(182, 245, 58, 0.14);
  background: var(--ex-panel);
  color: var(--ex-text);
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  transition: border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}

.ex-lang img,
.ex-wallet img {
  width: 15px;
  height: 15px;
  object-fit: contain;
}

.ex-lang-caret {
  width: 12px;
  height: 12px;
  flex-shrink: 0;
  display: block;
  color: #cfd8c2;
}

.ex-wallet {
  border-color: rgba(182, 245, 58, 0.45);
  background: rgba(182, 245, 58, 0.08);
  box-shadow: 0 0 14px rgba(182, 245, 58, 0.12);
}

.ex-wallet-wrap {
  position: relative;
  flex-shrink: 0;
}

.ex-wallet.connected {
  border-color: rgba(182, 245, 58, 0.55);
  box-shadow: 0 0 16px rgba(182, 245, 58, 0.2);
}

.ex-wallet-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 118px;
  padding: 6px;
  border-radius: 12px;
  background: rgba(12, 16, 10, 0.96);
  border: 1px solid rgba(182, 245, 58, 0.2);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.5), 0 0 18px rgba(182, 245, 58, 0.08);
  z-index: 100;
  backdrop-filter: blur(12px);
}

.ex-wallet-menu-item {
  width: 100%;
  height: 34px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #f2f2f2;
  font-size: 13px;
  cursor: pointer;
}

.ex-wallet-menu-item:active {
  background: rgba(182, 245, 58, 0.12);
  color: var(--ex-accent);
}

.ex-hero {
  position: relative;
  margin: 8px 16px 0;
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid rgba(182, 245, 58, 0.2);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.04),
    0 12px 28px rgba(0, 0, 0, 0.3),
    0 0 24px rgba(182, 245, 58, 0.08);
}

.ex-banner {
  display: block;
  width: 100%;
  height: 162px;
  object-fit: cover;
  object-position: right center;
}

.ex-hero::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, rgba(2, 3, 2, 0.72) 0%, rgba(2, 3, 2, 0.28) 55%, transparent 100%);
  pointer-events: none;
}

.ex-hero-text {
  position: absolute;
  left: 16px;
  top: 22px;
  right: 38%;
  z-index: 1;
}

.ex-hero-text h1 {
  margin: 0;
  font-size: 26px;
  font-weight: 750;
  line-height: 1;
  letter-spacing: 0.04em;
  text-shadow: 0 0 18px rgba(182, 245, 58, 0.25);
}

.ex-hero-text p {
  margin: 14px 0 0;
  font-size: 13px;
  color: #cfd8c2;
  line-height: 1.35;
}

.ex-card {
  margin: 14px 16px 0;
  border: 1px solid var(--ex-border);
  border-radius: 16px;
  background:
    linear-gradient(145deg, rgba(182, 245, 58, 0.07), transparent 42%),
    var(--ex-card);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.04),
    0 10px 28px rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  overflow: hidden;
}

.ex-swap-card {
  padding: 16px 14px 18px;
}

.ex-card-glow {
  position: absolute;
  width: 160px;
  height: 160px;
  right: -40px;
  top: -50px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(182, 245, 58, 0.18), transparent 70%);
  pointer-events: none;
}

.ex-swap-mid {
  position: relative;
  height: 0;
  margin: 16px 0;
}

.ex-side + .ex-side {
  padding-top: 16px;
  border-top: 1px solid rgba(182, 245, 58, 0.1);
}

.ex-side-label {
  font-size: 13px;
  font-weight: 650;
  margin-bottom: 12px;
  letter-spacing: 0.02em;
  color: #dfe8d2;
}

.ex-side-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.ex-token {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 117px;
  height: 58px;
  padding: 0 10px;
  border-radius: 14px;
  border: 1px solid rgba(182, 245, 58, 0.18);
  background: rgba(8, 12, 6, 0.72);
  color: var(--ex-text);
  cursor: pointer;
  text-align: left;
  box-shadow: 0 0 14px rgba(182, 245, 58, 0.06);
  transition: border-color 0.2s ease, background 0.2s ease;
}

.ex-token:active {
  border-color: rgba(182, 245, 58, 0.4);
  background: rgba(182, 245, 58, 0.08);
}

.ex-token-icon {
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.ex-token-icon img,
.ex-coin-fallback,
.ex-coin-usdt {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.ex-coin-fallback,
.ex-coin-usdt {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #3a3a3a;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
}

.ex-coin-usdt {
  background: #1ba27a;
  font-size: 14px;
}

.ex-token-meta {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.ex-token-name {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 14px;
  font-weight: 650;
}

.ex-token-name i {
  width: 0;
  height: 0;
  border-left: 3.5px solid transparent;
  border-right: 3.5px solid transparent;
  border-top: 4px solid #cfd8c2;
  opacity: 0.85;
}

.ex-token-bal {
  font-size: 11px;
  color: var(--ex-muted);
  white-space: nowrap;
}

.ex-amount {
  text-align: right;
  min-width: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.ex-amount-input,
.ex-amount-value {
  width: 100%;
  max-width: 160px;
  border: 0;
  outline: none;
  background: transparent;
  color: var(--ex-accent);
  font-size: 22px;
  font-weight: 750;
  line-height: 1.1;
  text-align: right;
  padding: 0;
  text-shadow: 0 0 14px rgba(182, 245, 58, 0.22);
}

.ex-amount-input::placeholder {
  color: #4a5540;
  text-shadow: none;
  font-weight: 500;
}

.ex-amount-fiat {
  margin-top: 6px;
  font-size: 12px;
  color: var(--ex-muted);
}

.ex-amount-max {
  margin-top: 4px;
  border: 0;
  background: rgba(182, 245, 58, 0.1);
  border: 1px solid rgba(182, 245, 58, 0.22);
  color: var(--ex-accent);
  font-size: 11px;
  font-weight: 650;
  padding: 3px 8px;
  border-radius: 999px;
  cursor: pointer;
}

.ex-rate-row {
  margin-top: 14px;
  font-size: 11px;
  color: var(--ex-muted);
  text-align: center;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid rgba(182, 245, 58, 0.1);
  background: rgba(0, 0, 0, 0.22);
}

.ex-swap-btn {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid rgba(182, 245, 58, 0.35);
  background: rgba(12, 16, 10, 0.95);
  color: var(--ex-accent);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 2;
  padding: 0;
  box-shadow: 0 0 18px rgba(182, 245, 58, 0.22);
  transition: transform 0.2s ease, background 0.2s ease;
}

.ex-swap-btn:active {
  transform: translate(-50%, -50%) rotate(180deg) scale(0.96);
  background: rgba(182, 245, 58, 0.14);
}

.ex-submit {
  margin-top: 14px;
  width: 100%;
  height: 46px;
  border: 0;
  border-radius: 12px;
  background: linear-gradient(90deg, #7ec922, #c8ff4a);
  color: #0b1204;
  font-size: 14px;
  font-weight: 750;
  letter-spacing: 0.04em;
  cursor: pointer;
  box-shadow: 0 0 22px rgba(182, 245, 58, 0.28);
  transition: transform 0.15s ease, opacity 0.2s ease;
}

.ex-submit:active {
  transform: scale(0.99);
}

.ex-submit:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  box-shadow: none;
}

.ex-record-empty {
  padding: 24px 0;
  text-align: center;
  font-size: 12px;
  color: var(--ex-muted);
}

.ex-picker[hidden] {
  display: none !important;
}

.ex-picker {
  position: fixed;
  inset: 0;
  z-index: 1180;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: calc(var(--tabbar-height) + var(--safe-bottom));
}

.ex-picker-mask {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.62);
}

.ex-picker-sheet {
  position: relative;
  width: 100%;
  max-width: 480px;
  max-height: min(60vh, calc(100% - var(--tabbar-height) - var(--safe-bottom) - 24px));
  background:
    linear-gradient(180deg, rgba(182, 245, 58, 0.08), transparent 28%),
    rgba(10, 14, 8, 0.98);
  border: 1px solid rgba(182, 245, 58, 0.18);
  border-bottom: 0;
  border-radius: 18px 18px 0 0;
  padding: 14px 14px calc(14px + var(--safe-bottom));
  display: flex;
  flex-direction: column;
  min-height: 0;
  box-shadow: 0 -12px 36px rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(14px);
}

.ex-picker-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  font-size: 15px;
  font-weight: 650;
}

.ex-picker-close {
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 50%;
  background: rgba(182, 245, 58, 0.1);
  border: 1px solid rgba(182, 245, 58, 0.18);
  color: #fff;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}

.ex-picker-list {
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}

.ex-picker-item {
  width: 100%;
  min-height: 56px;
  padding: 10px 4px;
  border: 0;
  border-top: 1px solid rgba(182, 245, 58, 0.08);
  background: transparent;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: left;
  cursor: pointer;
}

.ex-picker-item:first-child {
  border-top: 0;
}

.ex-picker-item.is-active {
  color: var(--ex-accent);
}

.ex-picker-meta {
  min-width: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.ex-picker-name {
  font-size: 14px;
  font-weight: 650;
}

.ex-picker-bal {
  font-size: 11px;
  color: var(--ex-muted);
}

.ex-confirm {
  position: fixed;
  inset: 0;
  z-index: 1190;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 20px calc(var(--tabbar-height) + var(--safe-bottom) + 24px);
}

.ex-confirm[hidden] {
  display: none !important;
}

.ex-confirm-mask {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.66);
}

.ex-confirm-card {
  position: relative;
  width: 100%;
  max-width: 320px;
  padding: 20px 18px 16px;
  border-radius: 16px;
  background:
    linear-gradient(145deg, rgba(182, 245, 58, 0.08), transparent 45%),
    rgba(12, 16, 10, 0.98);
  border: 1px solid rgba(182, 245, 58, 0.22);
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.45), 0 0 24px rgba(182, 245, 58, 0.1);
  z-index: 1;
  backdrop-filter: blur(14px);
}

.ex-confirm-card h3 {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  text-align: center;
}

.ex-confirm-desc {
  margin: 8px 0 0;
  font-size: 12px;
  color: var(--ex-muted);
  text-align: center;
}

.ex-confirm-rows {
  margin-top: 16px;
  padding: 12px 12px 4px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid rgba(182, 245, 58, 0.12);
}

.ex-confirm-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
  font-size: 13px;
}

.ex-confirm-row[hidden] {
  display: none !important;
}

.ex-confirm-row span {
  color: var(--ex-muted);
  flex-shrink: 0;
}

.ex-confirm-row strong {
  font-weight: 650;
  text-align: right;
  color: #fff;
  word-break: break-all;
}

.ex-confirm-actions {
  margin-top: 18px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.ex-confirm-cancel,
.ex-confirm-ok {
  height: 42px;
  border-radius: 12px;
  border: 0;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.ex-confirm-cancel {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(182, 245, 58, 0.12);
  color: #f2f2f2;
}

.ex-confirm-ok {
  background: linear-gradient(90deg, #7ec922, #c8ff4a);
  color: #0b1204;
  box-shadow: 0 0 18px rgba(182, 245, 58, 0.25);
}

.ex-confirm-ok:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  box-shadow: none;
}

.app-toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--tabbar-height) + var(--safe-bottom) + 24px);
  transform: translateX(-50%) translateY(12px);
  max-width: min(86vw, 360px);
  padding: 10px 14px;
  border-radius: 12px;
  background: rgba(10, 14, 8, 0.94);
  border: 1px solid rgba(182, 245, 58, 0.22);
  color: #f2f2f2;
  font-size: 13px;
  line-height: 1.35;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 240;
  text-align: center;
  box-shadow: 0 0 24px rgba(182, 245, 58, 0.12);
}

.app-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.ex-records {
  padding: 16px 14px 8px;
}

.ex-records-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.ex-records-head h2 {
  margin: 0;
  font-size: 14px;
  font-weight: 650;
}

.ex-records-all {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  font-size: 12px;
  font-weight: 650;
  color: var(--ex-accent);
}

.ex-record-item {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 56px;
  padding: 10px 0;
  border-top: 1px solid rgba(182, 245, 58, 0.1);
  color: inherit;
  text-decoration: none;
}

.ex-record-list .ex-record-item:first-child {
  border-top: 0;
}

.ex-pair-icons {
  width: 36px;
  height: 28px;
  position: relative;
  flex-shrink: 0;
}

.ex-pair-icons img,
.ex-pair-icons .ex-coin-usdt {
  width: 22px;
  height: 22px;
  position: absolute;
  top: 3px;
  border: 1px solid #0e0f11;
}

.ex-pair-icons img:first-child,
.ex-pair-icons .ex-coin-usdt:first-child {
  left: 0;
  z-index: 1;
}

.ex-pair-icons img:last-child,
.ex-pair-icons .ex-coin-usdt:last-child {
  left: 12px;
  z-index: 2;
}

.ex-record-main {
  min-width: 0;
  flex: 1;
}

.ex-record-pair {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
}

.ex-record-pair-arrow {
  width: 12px;
  height: 10px;
  object-fit: contain;
  flex-shrink: 0;
  opacity: 0.9;
}

.ex-record-time {
  margin-top: 6px;
  font-size: 10px;
  color: var(--ex-muted);
}

.ex-record-vals {
  text-align: right;
  flex-shrink: 0;
}

.ex-record-from {
  font-size: 12px;
}

.ex-record-to {
  margin-top: 6px;
  font-size: 10px;
  color: var(--ex-accent);
  text-shadow: 0 0 8px rgba(182, 245, 58, 0.2);
}

.ex-record-arrow {
  flex-shrink: 0;
  opacity: 0.85;
}

@media (prefers-reduced-motion: reduce) {
  .ex-orb {
    animation: none !important;
  }
}
