/* Same design tokens as klap-checkout's styles.css — dark-only, this is
   the Klappay brand for anything that carries the Klappay name, not a
   per-merchant theme — one-js's own button is the only customizable
   surface, this page never is. */
:root {
  color-scheme: dark;
  --canvas: #000000;
  --surface: #0a0a0a;
  --surface-soft: #111111;
  --surface-raised: #161616;
  --border-subtle: #1a1a1a;
  --highlight-100: #cccccc;
  --highlight-200: #e6e6e6;
  --highlight-300: #ffffff;
  --gold-400: #f2b90c;
  --gold-500: #eab308;
  --danger-400: #ff6b6b;
  --danger-500: #ff4d4d;
  --success-400: #4ade80;
  --success-500: #22c55e;
  --text-strong: rgba(255, 255, 255, 0.8);
  --text-subtle: rgba(255, 255, 255, 0.5);
  --overlay-hover: rgba(255, 255, 255, 0.08);
}

* {
  box-sizing: border-box;
}

/* Same scrollbar treatment as klap-app's app/index.html — the Klappay
   brand's global scrollbar styling, not a one-off for this page. */
* {
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.18) transparent;
}
*::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
*::-webkit-scrollbar-track {
  background: transparent;
}
*::-webkit-scrollbar-thumb {
  background-color: rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  border: 2px solid transparent;
  background-clip: content-box;
}
*::-webkit-scrollbar-thumb:hover {
  background-color: rgba(255, 255, 255, 0.32);
}

/* No global reset library — this is the entire reset. Browser default
   margins on p/h1-etc. are inconsistent and were leaving elements
   looking "glued together" wherever spacing came from a default margin
   instead of an explicit `gap` — every layout below relies on `gap`,
   never on a tag's own default margin, so it has to be zeroed here. */
h1,
h2,
h3,
p {
  margin: 0;
}

body {
  margin: 0;
  min-height: 100vh;
  min-width: 320px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--canvas);
  padding: 24px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
  color: var(--highlight-300);
}

/* Same ambient glow as klap-checkout's own styles.css — this is the
   Klappay brand's dark-mode background treatment everywhere the brand
   shows up, not a one-off for this page. */
body::before {
  content: "";
  position: fixed;
  inset: -10%;
  z-index: -1;
  background: radial-gradient(45% 40% at 50% 0%, rgba(242, 185, 12, 0.2), transparent 70%),
    radial-gradient(50% 45% at 50% 100%, rgba(255, 255, 255, 0.1), transparent 70%);
  filter: blur(60px);
  animation: drift 24s ease-in-out infinite alternate;
}

@keyframes drift {
  from {
    transform: translate3d(0, 0, 0) scale(1);
  }
  to {
    transform: translate3d(2%, -2%, 0) scale(1.06);
  }
}

@media (prefers-reduced-motion: reduce) {
  body::before,
  .card,
  .fade-in,
  .pop-in {
    animation: none;
  }
}

.page {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  width: 100%;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border-subtle);
  border-radius: 15px;
  padding: 25px 20px;
  width: 100%;
  min-width: 280px;
  max-width: 380px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  /* Same entrance klap-checkout's own .card uses. Every screen in the
     flow (identify → verify → wallets → sign → success) mounts a brand
     new .card element rather than mutating one in place, so this single
     rule doubles as the transition between screens, not just first load. */
  animation: card-in 0.5s cubic-bezier(0.16, 1, 0.3, 1) both;
}

@keyframes card-in {
  from {
    opacity: 0;
    transform: translateY(16px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Generic entrance for anything that appears in place after the card has
   already settled (a QR/deep-link button replacing the spinner, an error
   line revealed by lib/dom.ts's reveal()) — smaller and quicker than
   card-in since it's a small in-place appearance, not a whole screen. */
.fade-in {
  animation: fade-in 0.25s ease both;
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* The one payoff moment in the whole flow (sign.ts's showSuccess) —
   deliberately a little bouncier than fade-in, not reused elsewhere. */
.pop-in {
  animation: pop-in 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

@keyframes pop-in {
  from {
    opacity: 0;
    transform: scale(0.5);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* Same markup/sizing as klap-checkout's <Brand /> — shown at the top of
   every card, always Klappay's own name/mark. This is deliberate, not
   incidental: this page is never white-label — the payer needs a
   consistent, recognizable "this is really Klappay asking" anchor before
   OTP/wallet screens. */
.brand {
  display: flex;
  align-items: center;
  gap: 5px;
}

.brand__icon {
  height: 22px;
  width: 22px;
}

.brand__name {
  font-size: 14px;
  font-weight: 400;
  letter-spacing: -0.01em;
  color: var(--highlight-300);
}

.brand-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.brand__sandbox-badge {
  flex-shrink: 0;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #d0e4ff;
  border: 1px solid #4a89dd;
  border-radius: 4px;
  padding: 2px 8px;
}

/* Every group of stacked children (a list of rows, a form's fields) gets
   one of these instead of a bare wrapper div — a plain div has no `gap`
   of its own, which is exactly what left wallet rows/menu links/form
   fields touching each other with zero space in between. */
.stack-sm {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.stack-md {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.stack-lg {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.card__title {
  font-size: 16px;
  font-weight: 600;
  color: var(--highlight-300);
  margin: 0;
}

.card__subtitle {
  font-size: 13px;
  color: var(--text-subtle);
  margin: 0;
}

.alias-row {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.alias-row .alias-value {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.alias-row__chevron {
  flex-shrink: 0;
  color: var(--highlight-100);
  font-size: 16px;
}

.alias-row:hover .alias-row__chevron {
  color: var(--highlight-300);
}

.charge-amount {
  font-size: 28px;
  font-weight: 600;
  color: var(--highlight-300);
}

.input {
  width: 100%;
  background: var(--surface-soft);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 12px 14px;
  color: var(--highlight-300);
  /* 16px, not 15px — iOS Safari auto-zooms the whole page on focus for
     any input under 16px, which is exactly the kind of thing that only
     shows up on a real phone, never in a desktop screenshot. */
  font-size: 16px;
  font-family: inherit;
}

.input:focus {
  outline: 2px solid var(--gold-400);
  outline-offset: -1px;
}

.btn {
  width: 100%;
  height: 40px;
  border-radius: 10px;
  border: none;
  background: var(--gold-400);
  color: #000000;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: opacity 0.15s ease, background-color 0.15s ease;
}

/* .btn's own `display: flex` above has the same specificity as the [hidden]
   UA-stylesheet rule and loads after it, so it silently wins — setting
   .hidden on a .btn element (see sign.ts's showSuccess) would otherwise
   render it anyway. Found live-testing the real payment flow end to end. */
.btn[hidden] {
  display: none;
}

.btn:disabled {
  background: var(--highlight-300);
  opacity: 0.5;
  cursor: not-allowed;
}

.btn--secondary {
  background: var(--surface-raised);
  color: var(--highlight-300);
  border: 1px solid var(--border-subtle);
}

.btn--danger {
  background: transparent;
  color: var(--danger-400);
  border: 1px solid var(--danger-400);
}

.btn--danger:hover {
  background: rgba(255, 107, 107, 0.1);
}

/* Used for both <div> (wallet rows) and <a> (preview menu links) — the
   text-decoration/color resets only matter for the latter. */
.wallet-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface-soft);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 12px 14px;
  cursor: pointer;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px;
  color: var(--highlight-200);
  text-decoration: none;
}

.wallet-row:hover {
  background: var(--overlay-hover);
}

.wallet-row__name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.wallet-row__meta {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.wallet-row__star {
  color: var(--gold-400);
  font-size: 12px;
}

.wallet-row__count {
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--surface-raised);
  border: 1px solid var(--border-subtle);
  color: var(--highlight-200);
  font-size: 11px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
}

.wallet-row__count--empty {
  color: var(--text-subtle);
}

.wallet-address {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.chain-select {
  position: relative;
}

.chain-select-trigger {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface-soft);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 10px 12px;
  color: var(--highlight-300);
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
}

.chain-select-trigger__chevron {
  color: var(--text-subtle);
  font-size: 11px;
}

.chain-select-panel {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 10;
  background: var(--surface-raised);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 6px;
  max-height: 220px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.chain-select-panel[hidden] {
  display: none;
}

.chain-select-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  color: var(--highlight-200);
}

.chain-select-option:hover {
  background: var(--overlay-hover);
}

.chain-select-option__check {
  color: var(--highlight-300);
  font-weight: 700;
  opacity: 0;
}

.chain-select-option.is-selected .chain-select-option__check {
  opacity: 1;
}

.chain-select-option--all {
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 4px;
  padding-bottom: 10px;
}

.link-btn {
  border: none;
  background: none;
  padding: 0;
  margin: 0;
  color: inherit;
  font: inherit;
  text-decoration: underline;
  cursor: pointer;
}

.coverage-list {
  margin: 0;
  padding-left: 18px;
  font-size: 13px;
  color: var(--text-subtle);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(0, 0, 0, 0.6);
}

.modal-panel {
  background: var(--surface);
  border: 1px solid var(--border-subtle);
  border-radius: 15px;
  padding: 20px;
  width: 100%;
  max-width: 360px;
  max-height: 80vh;
  overflow-y: auto;
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-strong);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--gold-400);
}

.status[data-tone="success"] .status-dot {
  background: var(--success-400);
}

.status[data-tone="danger"] .status-dot {
  background: var(--danger-400);
}

.error-text {
  font-size: 13px;
  color: var(--danger-400);
  margin: 0;
}

.spinner {
  width: 24px;
  height: 24px;
  border-radius: 999px;
  border: 3px solid var(--border-subtle);
  border-top-color: var(--highlight-300);
  animation: spin 0.8s linear infinite;
}

.qr-frame {
  /* Fixed 220px broke on any viewport/popup narrower than ~260px (card
     padding + frame). min() keeps it square (aspect-ratio) while
     shrinking to fit instead of overflowing the card. */
  width: min(220px, 100%);
  aspect-ratio: 1;
  margin: 0 auto;
  background: var(--surface-soft);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.footer {
  font-size: 11px;
  color: var(--text-subtle);
  text-align: center;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
