/* Xendra wallet — layout patterns aligned with common Solana mobile wallets (Phantom / Solflare). */
:root {
  color-scheme: dark;
  --accent: #1b1bff;
  --accent-soft: rgba(27, 27, 255, 0.14);
  --green: #22c55e;
  --red: #ef4444;
  --bg: #101012;
  --bg-elevated: #18181b;
  --bg-muted: #27272a;
  --border: rgba(255, 255, 255, 0.06);
  --border-strong: rgba(255, 255, 255, 0.1);
  --text: #fafafa;
  --text-secondary: #a1a1aa;
  --text-tertiary: #71717a;
  --sans: "DM Sans", system-ui, -apple-system, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  --r-sm: 10px;
  --r-md: 14px;
  --r-lg: 18px;
  --r-xl: 22px;
  --phone-w: min(100%, 420px);
  --phone-h: min(100dvh, 880px);
  --tab-h: 56px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  background: #09090b;
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

button,
input {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

.xn-shell {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 12px;
  background: #09090b;
}

.xn-phone {
  width: var(--phone-w);
  height: var(--phone-h);
  max-height: 100dvh;
  background: var(--bg);
  border-radius: var(--r-xl);
  border: 1px solid var(--border-strong);
  display: grid;
  grid-template-rows: auto 1fr var(--tab-h);
  overflow: hidden;
}

/* ——— Header ——— */
.xn-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 16px 10px;
}

.xn-top-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.xn-chain-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 36px;
  padding: 0 10px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--bg-elevated);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  max-width: 118px;
}

.xn-chain-btn span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.xn-chain-btn img {
  width: 20px;
  height: 20px;
  border-radius: 6px;
  object-fit: cover;
  flex-shrink: 0;
}

.xn-chain-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 8px;
}

.xn-chain-row {
  width: 100%;
  border: 1px solid var(--border);
  background: var(--bg);
  border-radius: var(--r-md);
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: left;
}

.xn-chain-row.is-active {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.xn-chain-row img {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  object-fit: cover;
  background: var(--bg-muted);
}

.xn-chain-row strong {
  display: block;
  font-size: 15px;
}

.xn-chain-row span {
  font-size: 12px;
  color: var(--text-secondary);
}

.xn-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text);
}

.xn-brand-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
}

.xn-brand-word {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.04em;
}

.xn-pill-account {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 36px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--bg-elevated);
}

.xn-pill-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-tertiary);
}

.xn-pill-account.is-live .xn-pill-dot {
  background: var(--green);
}

.xn-pill-label {
  font-size: 13px;
  font-weight: 500;
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ——— Views ——— */
.xn-screen {
  min-height: 0;
  overflow: hidden;
}

.xn-view {
  display: none;
  height: 100%;
  overflow-y: auto;
  padding: 0 20px 16px;
  -webkit-overflow-scrolling: touch;
}

.xn-view.is-active {
  display: block;
}

.xn-view-browser {
  padding: 0;
  display: none;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
}

.xn-view-browser.is-active {
  display: grid;
}

.xn-view-swap.is-active,
.xn-view.xn-view-swap.is-active {
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 0 16px 12px;
}

.xn-browser-body {
  grid-row: 2;
  min-height: 0;
  position: relative;
}

.xn-dapp-hub {
  height: 100%;
  overflow-y: auto;
  padding: 12px 20px 16px;
}

.xn-dapp-stage {
  display: none;
  position: absolute;
  inset: 0;
}

.xn-phone.xn-dapp-live .xn-dapp-hub {
  display: none;
}

.xn-phone.xn-dapp-live .xn-dapp-stage {
  display: block;
}

/* ——— Home: balance ——— */
.xn-hero {
  text-align: center;
  padding: 8px 0 20px;
}

.xn-eyebrow {
  margin: 0 0 4px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
}

.xn-balance {
  font-size: clamp(2.5rem, 11vw, 3rem);
  font-weight: 700;
  letter-spacing: -0.04em;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.xn-change-pill {
  display: inline-flex;
  margin-top: 8px;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text-secondary);
  background: var(--bg-muted);
}

.xn-change-pill.up {
  color: var(--green);
  background: rgba(34, 197, 94, 0.12);
}

.xn-change-pill.down {
  color: var(--red);
  background: rgba(239, 68, 68, 0.12);
}

/* ——— Action bar (Phantom-style row) ——— */
.xn-actions {
  display: flex;
  gap: 8px;
  padding: 4px;
  margin-bottom: 20px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
}

.xn-action {
  flex: 1;
  border: 0;
  background: transparent;
  padding: 12px 4px;
  border-radius: var(--r-md);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  transition: background 0.15s;
}

.xn-action:active {
  background: var(--bg-muted);
}

.xn-action-icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--bg-muted);
  color: var(--text);
}

.xn-action-icon svg {
  width: 20px;
  height: 20px;
}

.xn-action-send .xn-action-icon {
  background: var(--accent);
  color: #fff;
}

/* ——— Cards / sections ——— */
.xn-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 14px 16px;
  margin-bottom: 12px;
}

.xn-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.xn-card-title {
  font-size: 15px;
  font-weight: 600;
}

.xn-brief-body {
  margin: 0;
  font-size: 14px;
  line-height: 1.55;
  color: var(--text-secondary);
}

.xn-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 6px;
  background: var(--bg-muted);
  color: var(--text-tertiary);
}

.xn-badge.live {
  color: var(--green);
  background: rgba(34, 197, 94, 0.12);
}

.xn-tokens-card {
  padding: 0;
  overflow: hidden;
}

.xn-tokens-card .xn-card-head {
  padding: 14px 16px 0;
  margin-bottom: 4px;
}

.xn-token-list {
  display: flex;
  flex-direction: column;
}

.xn-token-row {
  display: grid;
  grid-template-columns: 40px 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 14px 16px;
  border-top: 1px solid var(--border);
}

.xn-token-row:first-child {
  border-top: 0;
}

.xn-token-icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--bg-muted);
  overflow: hidden;
  display: grid;
  place-items: center;
  font-size: 10px;
  font-family: var(--mono);
}

.xn-token-icon img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.xn-token-meta strong {
  display: block;
  font-size: 16px;
  font-weight: 600;
}

.xn-token-meta span {
  font-size: 13px;
  color: var(--text-secondary);
}

.xn-token-val {
  text-align: right;
}

.xn-token-val strong {
  display: block;
  font-size: 15px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.xn-token-val span {
  font-size: 12px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.xn-token-val span.up {
  color: var(--green);
}

.xn-token-val span.down {
  color: var(--red);
}

/* ——— Pages ——— */
.xn-page-title {
  margin: 12px 0 0;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.xn-page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 8px;
}

.xn-text-btn {
  border: 0;
  background: none;
  color: var(--accent);
  font-size: 14px;
  font-weight: 600;
  padding: 8px 0;
}

.xn-swap-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 4px 8px;
}

.xn-powered {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-tertiary);
}

.xn-jupiter-root {
  flex: 1;
  min-height: 400px;
  border-radius: var(--r-lg);
  overflow: hidden;
  border: 1px solid var(--border);
  background: #0c0c0f;
}

.xn-evm-swap-root {
  flex: 1;
  min-height: 420px;
  border-radius: var(--r-lg);
  overflow: hidden;
  border: 1px solid var(--border);
  background: #0c0c0f;
}

.xn-swap-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px;
}

.xn-swap-row {
  display: flex;
  gap: 10px;
  align-items: stretch;
  padding: 14px;
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  background: var(--bg-elevated);
}

.xn-swap-field {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  color: var(--text-secondary);
}

.xn-swap-field input {
  border: 0;
  background: transparent;
  font-size: 22px;
  font-weight: 600;
  color: var(--text);
  outline: none;
  width: 100%;
}

.xn-swap-token {
  align-self: center;
  border: 1px solid var(--border-strong);
  background: var(--bg-muted);
  color: var(--text);
  font-weight: 600;
  font-size: 13px;
  padding: 10px 14px;
  border-radius: 999px;
  cursor: pointer;
}

.xn-swap-meta {
  margin: 4px 0 0;
  font-size: 12px;
  color: var(--text-tertiary);
  text-align: center;
}

.xn-swap-submit {
  margin-top: 6px;
}

.xn-onboard-mnemonic {
  font-size: 12px;
  line-height: 1.5;
  color: var(--text-secondary);
  word-break: break-word;
  padding: 10px;
  border-radius: var(--r-md);
  background: var(--bg-muted);
  border: 1px solid var(--border);
}

.xn-field textarea {
  width: 100%;
  min-height: 72px;
  resize: vertical;
  border-radius: var(--r-md);
  border: 1px solid var(--border-strong);
  background: var(--bg);
  color: var(--text);
  padding: 10px 12px;
  font-family: inherit;
  font-size: 14px;
}

/* ——— Browser ——— */
.xn-browser-chrome {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-elevated);
}

.xn-icon-btn {
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: var(--r-sm);
  background: var(--bg-muted);
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.xn-icon-btn-accent {
  background: var(--accent);
  color: #fff;
}

.xn-url-field {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  height: 36px;
  padding: 0 12px;
  border-radius: var(--r-sm);
  background: var(--bg);
  border: 1px solid var(--border);
}

.xn-url-lock {
  color: var(--text-tertiary);
  display: flex;
}

.xn-url-field input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  font-size: 12px;
  font-family: var(--mono);
  outline: none;
}

.xn-hub-title {
  margin: 0 0 12px;
  font-size: 17px;
  font-weight: 600;
}

.xn-dapp-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.xn-dapp-tile {
  width: 100%;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  border-radius: var(--r-md);
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: left;
}

.xn-dapp-tile.is-active {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.xn-dapp-tile img {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: #fff;
  object-fit: cover;
  flex-shrink: 0;
}

.xn-dapp-tile-body {
  flex: 1;
  min-width: 0;
}

.xn-dapp-tile-body strong {
  display: block;
  font-size: 15px;
  font-weight: 600;
}

.xn-dapp-tile-body span {
  font-size: 12px;
  color: var(--text-secondary);
}

.xn-dapp-tile-chevron {
  color: var(--text-tertiary);
  flex-shrink: 0;
}

.xn-dapp-frame-wrap {
  position: relative;
  height: 100%;
  background: #fff;
}

.xn-dapp-frame-wrap iframe {
  width: 100%;
  height: 100%;
  border: 0;
}

.xn-dapp-loading {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
}

.xn-dapp-external {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 28px 24px;
  text-align: center;
  background: var(--bg);
}

.xn-dapp-external-mark {
  width: 52px;
  height: 52px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  font-size: 22px;
  font-weight: 600;
  color: var(--accent);
  background: rgba(27, 27, 255, 0.12);
  border: 1px solid var(--border);
}

.xn-dapp-external-title {
  margin: 8px 0 0;
  font-size: 18px;
  font-weight: 600;
}

.xn-dapp-external-desc {
  margin: 0;
  max-width: 280px;
  font-size: 13px;
  line-height: 1.45;
  color: var(--text-secondary);
}

.xn-spinner {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid var(--border-strong);
  border-top-color: var(--accent);
  animation: xn-spin 0.7s linear infinite;
}

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

/* ——— News ——— */
.xn-news-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 8px;
}

.xn-news-item {
  padding: 14px 16px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
}

.xn-news-item h3 {
  margin: 0 0 6px;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.35;
}

.xn-news-item h3 a {
  color: var(--text);
  text-decoration: none;
}

.xn-news-item p {
  margin: 0;
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
}

.xn-news-item footer {
  margin-top: 8px;
  font-size: 11px;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* ——— Tab bar ——— */
.xn-tabs {
  display: flex;
  border-top: 1px solid var(--border);
  background: var(--bg-elevated);
  padding-bottom: env(safe-area-inset-bottom);
}

.xn-tabs button {
  flex: 1;
  border: 0;
  background: transparent;
  padding: 8px 0 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-tertiary);
}

.xn-tabs button svg {
  width: 24px;
  height: 24px;
}

.xn-tabs button.is-active {
  color: var(--text);
}

.xn-tabs button.is-active svg {
  color: var(--accent);
}

.xn-empty {
  padding: 16px;
  text-align: center;
  color: var(--text-secondary);
  font-size: 14px;
}

/* ——— Sheets ——— */
.xn-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 40;
  opacity: 0;
  transition: opacity 0.2s;
}

.xn-overlay.show {
  opacity: 1;
}

.xn-sheet {
  position: fixed;
  left: 50%;
  bottom: 0;
  transform: translate(-50%, 105%);
  width: min(100%, 420px);
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: 20px 20px 0 0;
  padding: 8px 20px calc(20px + env(safe-area-inset-bottom));
  z-index: 50;
  transition: transform 0.28s cubic-bezier(0.32, 0.72, 0, 1);
}

.xn-sheet.open {
  transform: translate(-50%, 0);
}

.xn-sheet-handle {
  width: 36px;
  height: 4px;
  border-radius: 999px;
  background: var(--bg-muted);
  margin: 0 auto 16px;
}

.xn-sheet-title {
  margin: 0 0 16px;
  font-size: 20px;
  font-weight: 700;
}

.xn-field {
  display: block;
  margin-bottom: 12px;
}

.xn-field > span {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.xn-field input {
  width: 100%;
  height: 48px;
  padding: 0 14px;
  border-radius: var(--r-md);
  border: 1px solid var(--border-strong);
  background: var(--bg);
  font-size: 16px;
  outline: none;
}

.xn-field input:focus {
  border-color: var(--accent);
}

.xn-field-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.xn-field-row input {
  flex: 1;
}

.xn-sheet-hint {
  margin: 0 0 12px;
  font-size: 12px;
  color: var(--text-tertiary);
}

.xn-btn-primary {
  width: 100%;
  height: 48px;
  border: 0;
  border-radius: var(--r-md);
  background: var(--accent);
  color: #fff;
  font-size: 16px;
  font-weight: 600;
  margin-top: 4px;
}

.xn-qr-wrap {
  display: grid;
  place-items: center;
  padding: 20px;
  background: #fff;
  border-radius: var(--r-lg);
  margin-bottom: 12px;
}

.xn-receive-addr {
  font-family: var(--mono);
  font-size: 12px;
  text-align: center;
  word-break: break-all;
  color: var(--text-secondary);
  margin: 0 0 12px;
}

.xn-toast {
  position: fixed;
  bottom: calc(72px + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  padding: 10px 16px;
  border-radius: var(--r-md);
  background: var(--bg-muted);
  border: 1px solid var(--border-strong);
  font-size: 14px;
  font-weight: 500;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
  z-index: 99;
  max-width: 90vw;
}

.xn-toast.show {
  opacity: 1;
}

@media (min-width: 520px) {
  .xn-shell {
    padding: 24px;
  }
}

html.xn-embed,
html.xn-mobile {
  background: var(--bg);
}

html.xn-embed .xn-shell,
html.xn-mobile .xn-shell {
  padding: 0;
  background: var(--bg);
}

html.xn-embed .xn-phone,
html.xn-mobile .xn-phone {
  width: 100%;
  max-width: none;
  height: 100dvh;
  max-height: none;
  border-radius: 0;
  border: none;
}
