:root {
  --x-bg-0: #060b16;
  --x-bg-1: #0a1327;
  --x-surface: rgba(12, 19, 36, 0.86);
  --x-surface-2: rgba(18, 30, 54, 0.92);
  --x-line: rgba(95, 128, 220, 0.28);
  --x-line-soft: rgba(95, 128, 220, 0.15);
  --x-text: #e7eeff;
  --x-text-dim: #8da0cf;
  --x-primary: #3c8cff;
  --x-secondary: #00c2ff;
  --x-success: #28c285;
  --x-danger: #ff5f74;
  --x-radius: 12px;
  --x-radius-sm: 9px;
  --x-shadow: 0 18px 38px -18px rgba(0, 0, 0, 0.7);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  color: var(--x-text);
  background:
    radial-gradient(920px 420px at 0% 0%, rgba(36, 120, 255, 0.28), transparent 62%),
    radial-gradient(820px 340px at 100% 0%, rgba(0, 194, 255, 0.2), transparent 66%),
    linear-gradient(180deg, var(--x-bg-1), var(--x-bg-0));
  font-family: "Inter", "Segoe UI", sans-serif;
}

a {
  color: inherit;
}

.hidden {
  display: none !important;
}

.app-body {
  min-height: 100vh;
  background: transparent !important;
}

/* Decorative particle layer should never block UI clicks */
#particles-js,
#particles-js canvas {
  pointer-events: none !important;
}

.app-header {
  margin: 12px;
  min-height: 64px;
  border: 1px solid var(--x-line);
  border-radius: var(--x-radius);
  background: rgba(8, 14, 26, 0.84);
  backdrop-filter: blur(8px);
  padding: 10px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  position: sticky;
  top: 10px;
  z-index: 25;
}

.brandmark {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.brandmark__icon {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  flex-shrink: 0;
}

.brandmark__text {
  font-family: "IBM Plex Sans", "Inter", "Segoe UI", sans-serif;
  font-size: 24px;
  font-weight: 700;
  letter-spacing: 1px;
  color: #f4f8ff;
  line-height: 1;
}

.brandmark--compact .brandmark__icon {
  width: 26px;
  height: 26px;
}

.brandmark--compact .brandmark__text {
  font-size: 22px;
}

.wallet-area {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.wallet-area a {
  text-decoration: none;
  padding: 8px 12px !important;
  border-radius: var(--x-radius-sm) !important;
  border: 1px solid transparent !important;
  background: transparent !important;
  color: var(--x-text-dim) !important;
  font-size: 12px !important;
  font-weight: 600;
}

.wallet-area a:hover {
  border-color: var(--x-line) !important;
  background: rgba(255, 255, 255, 0.02) !important;
  color: #fff !important;
}

.main-shell {
  padding: 34px 16px 60px;
  display: flex;
  justify-content: center;
}

.swap-card {
  width: min(100%, 500px);
  border-radius: 14px;
  border: 1px solid var(--x-line);
  background: var(--x-surface);
  box-shadow: var(--x-shadow);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.swap-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.swap-card-head h1 {
  margin: 0;
  font-size: 21px;
  font-weight: 700;
}

.network-switch-wrapper,
.language-selector {
  position: relative;
}

.network-select-btn,
.btn,
.btn-secondary,
.btn-primary,
.token-select-btn,
.max-btn,
.connect-btn {
  border: 1px solid var(--x-line);
  border-radius: var(--x-radius-sm);
  height: 38px;
  padding: 0 12px;
  font-size: 12px;
  font-weight: 700;
  color: #fff;
  background: var(--x-surface-2);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

/* Ensure selected-token icons inside buttons never overflow */
.token-select-btn .token-btn-logo {
  width: 18px;
  height: 18px;
  min-width: 18px;
  min-height: 18px;
  border-radius: 50%;
  object-fit: cover;
  display: block;
  background: rgba(255, 255, 255, 0.05);
}

.token-select-btn img {
  max-width: 22px;
  max-height: 22px;
}

.btn-primary,
.connect-btn {
  background: linear-gradient(100deg, var(--x-primary), var(--x-secondary));
  border: none;
}

.btn-secondary {
  color: var(--x-text-dim);
}

.w-full {
  width: 100%;
}

/* Make primary swap action visually active */
#actionBtn {
  background: linear-gradient(90deg, #4a90ff 0%, #12cfff 100%);
  color: #ffffff;
  border: 1px solid rgba(133, 197, 255, 0.55);
  box-shadow: 0 10px 22px rgba(18, 135, 255, 0.35);
}

#actionBtn:hover {
  filter: brightness(1.08);
}

#actionBtn:disabled {
  opacity: 1;
  color: #eaf4ff;
  background: linear-gradient(90deg, rgba(78, 126, 201, 0.95), rgba(42, 109, 170, 0.95));
  border: 1px solid rgba(149, 192, 255, 0.45);
  box-shadow: 0 8px 18px rgba(32, 94, 167, 0.25);
}

.network-select-btn {
  min-width: 128px;
  justify-content: space-between;
}

.network-select-arrow {
  font-size: 10px;
}

.network-dropdown,
.language-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 170px;
  padding: 8px;
  border: 1px solid var(--x-line);
  border-radius: var(--x-radius-sm);
  background: rgba(7, 12, 24, 0.96);
  box-shadow: var(--x-shadow);
  z-index: 35;
}

.gs-lang-btn {
  min-width: 110px;
  justify-content: center;
  gap: 8px;
}

.gs-lang-dropdown {
  min-width: 190px;
  padding: 10px;
  border-radius: 14px;
  background: linear-gradient(160deg, rgba(14, 20, 38, 0.96), rgba(18, 24, 44, 0.96));
  border: 1px solid rgba(122, 157, 255, 0.28);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(8px);
}

.gs-lang-option {
  padding: 8px 12px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  color: #e6eeff;
  font-size: 14px;
  transition: background 0.15s ease, transform 0.12s ease;
}

.gs-lang-option:hover {
  background: rgba(116, 152, 255, 0.16);
  transform: translateX(1px);
}

.gs-lang-option-code {
  font-size: 12px;
  opacity: 0.85;
}

.network-option {
  padding: 8px 10px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 12px;
}

.network-option:hover {
  background: rgba(255, 255, 255, 0.04);
}

.network-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.field-block {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.field-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.field-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: #eef5ff;
}

.mini-balance {
  font-size: 11px;
  color: #e6efff;
}

.token-input-row {
  height: 54px;
  border: 1px solid var(--x-line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.02);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 8px;
}

.amount-input-wrapper {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
}

.amount-input {
  width: 100%;
  border: none;
  background: transparent;
  color: #fff;
  font-size: 18px;
  font-weight: 600;
  outline: none;
}

.amount-input::placeholder {
  color: #6176a9;
}

.switch-zone {
  display: flex;
  justify-content: center;
}

.switch-circle {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid var(--x-line);
  background: var(--x-surface-2);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.quote-panel {
  border: 1px solid var(--x-line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.02);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 7px;
  font-size: 12px;
}

.quote-row {
  display: flex;
  justify-content: space-between;
  color: #eaf3ff;
}

.quote-row span:last-child {
  color: #dce7ff;
}

.swap-card-head h1,
.provider-row label,
.quote-row span:first-child {
  color: #f4f8ff !important;
}

.quote-row.final {
  margin-top: 2px;
  padding-top: 7px;
  border-top: 1px dashed var(--x-line-soft);
  font-weight: 700;
}

/* Global contrast guard for Trust browser/webviews */
.swap-card .field-label,
.swap-card .mini-balance,
.swap-card .provider-row label,
.swap-card #execModeStatus,
.swap-card .swap-card-head h1,
.swap-card .quote-row span:first-child,
.swap-card .quote-row {
  color: #f4f8ff !important;
  opacity: 1 !important;
}

.swap-card .quote-row span:last-child,
.swap-card #quoteValue,
.swap-card #quoteCommission,
.swap-card #quoteSpread,
.swap-card #quoteResult {
  color: #ffffff !important;
  font-weight: 700 !important;
  opacity: 1 !important;
}

#actionBtn,
#connectBtn {
  color: #ffffff !important;
}

/* Ultimate fallback for Trust Wallet WebView contrast */
.app-body .swap-card {
  background: #09162d !important;
  border-color: rgba(164, 198, 255, 0.46) !important;
}

.app-body .token-input-row,
.app-body .quote-panel,
.app-body .disclaimer {
  background: #0b1a33 !important;
  border-color: rgba(164, 198, 255, 0.4) !important;
}

.app-body .swap-card .field-label,
.app-body .swap-card .mini-balance,
.app-body .swap-card .provider-row label,
.app-body .swap-card #execModeStatus,
.app-body .swap-card .quote-row,
.app-body .swap-card .quote-row span,
.app-body .swap-card .swap-card-head h1 {
  color: #ffffff !important;
  opacity: 1 !important;
}

.app-body #actionBtn,
.app-body #connectBtn {
  color: #ffffff !important;
  -webkit-text-fill-color: #ffffff !important;
}

.app-body #actionBtn:disabled,
.app-body #connectBtn:disabled {
  opacity: 1 !important;
  color: #f5f9ff !important;
  -webkit-text-fill-color: #f5f9ff !important;
}

/* Desktop + Mobile final contrast lock */
.app-body .swap-card .field-label,
.app-body .swap-card .mini-balance,
.app-body .swap-card .provider-row,
.app-body .swap-card .provider-row label,
.app-body .swap-card #execModeStatus,
.app-body .swap-card .quote-row,
.app-body .swap-card .quote-row span,
.app-body .swap-card .swap-card-head h1,
.app-body #quoteValue,
.app-body #quoteCommission,
.app-body #quoteSpread,
.app-body #quoteResult {
  color: #ffffff !important;
  opacity: 1 !important;
  text-shadow: none !important;
}

.app-body .quote-panel {
  background: #0c1e3b !important;
  border-color: rgba(176, 209, 255, 0.5) !important;
}

.app-body #actionBtn,
.app-body #connectBtn {
  background: linear-gradient(90deg, #56a6ff 0%, #18d6ff 100%) !important;
  border: 1px solid rgba(192, 227, 255, 0.8) !important;
  box-shadow: 0 10px 24px rgba(27, 146, 255, 0.4) !important;
}

.disclaimer {
  margin: 0;
  border: 1px dashed var(--x-line);
  border-radius: 10px;
  padding: 9px 10px;
  font-size: 11px;
  color: var(--x-text-dim);
}

.account-tag,
.wallet-display {
  height: 34px;
  border-radius: 8px;
  border: 1px solid var(--x-line);
  background: rgba(255, 255, 255, 0.03);
  padding: 0 10px;
  display: inline-flex;
  align-items: center;
  font-size: 12px;
  color: #dce7ff;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 100002;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(4, 8, 16, 0.82);
}

.modal-dialog,
.modal-content {
  position: relative;
  width: min(100%, 530px);
  border: 1px solid var(--x-line);
  border-radius: 14px;
  background: rgba(9, 15, 28, 0.96);
  box-shadow: var(--x-shadow);
  padding: 18px;
  z-index: 2;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.modal-header h2 {
  margin: 0;
  font-size: 18px;
}

.modal-close,
.success-close,
.search-clear {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  border: 1px solid var(--x-line);
  background: rgba(255, 255, 255, 0.04);
  color: #fff;
  cursor: pointer;
}

.modal-search {
  margin-top: 12px;
}

.search-input {
  width: 100%;
  height: 40px;
  border-radius: 9px;
  border: 1px solid var(--x-line);
  background: rgba(255, 255, 255, 0.02);
  color: #fff;
  padding: 0 36px 0 12px;
}

.token-list {
  margin-top: 10px;
  max-height: 380px;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.token-row {
  min-height: 48px;
  border: 1px solid var(--x-line-soft);
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.02);
  padding: 8px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  cursor: pointer;
}

.token-row:hover {
  border-color: var(--x-line);
  background: rgba(255, 255, 255, 0.05);
}

.token-row-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.token-info-section {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1;
}

.token-logo-wrap {
  position: relative;
  width: 28px;
  height: 28px;
  flex: 0 0 28px;
}

.token-avatar,
.token-logo {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: block;
  object-fit: cover;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(146, 174, 255, 0.2);
}

.token-network-badge {
  position: absolute;
  right: -3px;
  bottom: -3px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 1px solid #0f172b;
  background: #0f172b;
}

.token-details {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.token-details strong {
  display: block;
  font-size: 14px;
  line-height: 1.2;
  color: #e9f1ff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.token-details .opacity-60 {
  display: block;
  font-size: 12px;
  line-height: 1.2;
  color: #9eb0d8;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.token-balance {
  margin-left: 10px;
  flex-shrink: 0;
}

.token-symbol {
  font-size: 13px;
  font-weight: 700;
}

.token-name {
  font-size: 11px;
  color: var(--x-text-dim);
}

.toast-container {
  position: fixed;
  top: 14px;
  right: 14px;
  z-index: 80;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  min-width: 220px;
  border: 1px solid var(--x-line);
  border-radius: 10px;
  background: rgba(9, 15, 28, 0.96);
  padding: 10px 12px;
  font-size: 12px;
}

.toast.error {
  border-color: rgba(255, 95, 116, 0.45);
}

/* Minimal helpers used by embedded pages */
.images-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
}

.token-image-card {
  border: 1px solid var(--x-line);
  border-radius: 10px;
  padding: 14px;
  background: rgba(9, 15, 28, 0.88);
}

.token-actions {
  display: flex;
  gap: 8px;
}

.success-modal-dialog {
  border-color: rgba(40, 194, 133, 0.34);
}

.success-title {
  margin: 0;
}

.success-message {
  color: var(--x-text-dim);
}

@media (max-width: 860px) {
  #particles-js {
    opacity: 0.18;
  }

  .app-body::before {
    display: none;
  }

  .app-header {
    margin: 8px;
    min-height: 56px;
    top: 8px;
    background: rgba(7, 12, 24, 0.94);
    border-color: rgba(132, 166, 255, 0.34);
  }

  .brandmark--compact .brandmark__icon {
    width: 22px;
    height: 22px;
  }

  .brandmark--compact .brandmark__text {
    font-size: 18px;
    letter-spacing: 0.7px;
  }

  .main-shell {
    padding-top: 22px;
  }

  .swap-card {
    padding: 18px;
    background: rgba(10, 16, 30, 0.95);
    border-color: rgba(132, 166, 255, 0.34);
  }

  .swap-card-head h1 {
    font-size: 30px;
    line-height: 1.08;
    letter-spacing: 0.2px;
  }

  .network-select-btn,
  .token-select-btn,
  .btn,
  .btn-secondary,
  .btn-primary,
  .max-btn {
    font-size: 14px;
    height: 42px;
  }

  .token-input-row,
  .quote-panel,
  .disclaimer,
  .modal-dialog,
  .modal-content {
    background: rgba(10, 18, 36, 1);
    border-color: rgba(153, 188, 255, 0.42);
  }

  .field-label,
  .mini-balance,
  .quote-row,
  .disclaimer,
  .wallet-area a,
  .btn-secondary {
    color: #d8e6ff !important;
  }

  .field-label {
    font-size: 13px;
    letter-spacing: 0.4px;
  }

  .mini-balance {
    font-size: 12px;
    font-weight: 600;
  }

  .quote-row {
    font-size: 14px;
    line-height: 1.4;
  }

  .disclaimer {
    font-size: 13px;
    line-height: 1.45;
  }

  .quote-row span:last-child,
  .swap-card-head h1,
  .amount-input {
    color: #f2f6ff !important;
  }

  .provider-row label,
  .provider-row span,
  #execModeStatus {
    color: #dce9ff !important;
    opacity: 1 !important;
  }

  .amount-input {
    font-size: 27px;
    font-weight: 700;
    line-height: 1.1;
  }

  #actionBtn {
    height: 46px;
    font-size: 15px;
    font-weight: 800;
    letter-spacing: 0.2px;
    color: #ffffff !important;
    background: linear-gradient(90deg, #4f99ff 0%, #11d2ff 100%);
    border-color: rgba(162, 210, 255, 0.62);
    box-shadow: 0 10px 24px rgba(19, 132, 246, 0.36);
  }

  #actionBtn:disabled {
    color: #ecf5ff !important;
    background: linear-gradient(90deg, rgba(82, 132, 212, 0.98), rgba(52, 121, 189, 0.98));
    border-color: rgba(161, 201, 255, 0.5);
    box-shadow: 0 8px 20px rgba(34, 101, 179, 0.28);
  }

  .wallet-area a {
    padding: 7px 10px !important;
    font-size: 12px !important;
    background: rgba(255, 255, 255, 0.03) !important;
    border-color: rgba(132, 166, 255, 0.28) !important;
  }

  /* High-contrast readability fix for mobile swap card */
  .swap-card .swap-card-head h1,
  .swap-card .field-label,
  .swap-card .mini-balance,
  .swap-card .provider-row label,
  .swap-card #execModeStatus,
  .swap-card .quote-row span:first-child {
    color: #f4f8ff !important;
    opacity: 1 !important;
    text-shadow: none !important;
  }

  .swap-card .quote-row,
  .swap-card .quote-row span {
    color: #ffffff !important;
    opacity: 1 !important;
    text-shadow: none !important;
  }

  .swap-card .quote-row span:last-child,
  .swap-card #quoteValue,
  .swap-card #quoteCommission,
  .swap-card #quoteSpread,
  .swap-card #quoteResult {
    color: #ffffff !important;
    font-weight: 700;
  }

  #actionBtn,
  #connectBtn {
    color: #ffffff !important;
    background: linear-gradient(90deg, #4f99ff 0%, #0ecbff 100%) !important;
    border: 1px solid rgba(173, 219, 255, 0.72) !important;
    box-shadow: 0 10px 24px rgba(20, 136, 255, 0.38) !important;
    opacity: 1 !important;
    filter: none !important;
  }

  #actionBtn:disabled,
  #connectBtn:disabled {
    color: #f3f9ff !important;
    background: linear-gradient(90deg, rgba(89, 145, 226, 0.98), rgba(60, 132, 205, 0.98)) !important;
    border: 1px solid rgba(182, 215, 255, 0.65) !important;
    box-shadow: 0 8px 18px rgba(41, 111, 193, 0.3) !important;
    opacity: 1 !important;
  }
}
