﻿:root {
  --bg: #050914;
  --panel: rgba(10, 18, 35, 0.78);
  --panel2: rgba(14, 28, 49, 0.74);
  --line: rgba(83, 127, 168, 0.26);
  --line-strong: rgba(36, 230, 196, 0.36);
  --text: #f1f6ff;
  --muted: #8f9dbb;
  --accent: #21e2ab;
  --accent2: #35a5ff;
  --violet: #8b5cff;
  --danger: #ff6b7a;
  --glow: rgba(33, 226, 171, 0.2);
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.45);
  --radius: 26px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  height: 100%;
  height: 100dvh;
  overflow: hidden; /* lock page scroll by default */
  overscroll-behavior: none;
}
body {
  margin: 0;
  height: 100%;
  height: 100dvh;
  max-height: 100dvh;
  font-family: "Segoe UI", Tahoma, sans-serif;
  color: var(--text);
  background:
    radial-gradient(900px 520px at 18% -10%, rgba(0, 245, 194, 0.16), transparent 56%),
    radial-gradient(720px 420px at 100% 8%, rgba(45, 120, 255, 0.18), transparent 54%),
    linear-gradient(180deg, #030712 0%, #07101f 55%, #050914 100%);
  overflow: hidden; /* no vertical page scroll on normal phones */
  overscroll-behavior: none;
  touch-action: manipulation;
}
/* Small / short screens: unlock vertical scroll */
html.allow-v-scroll,
html.allow-v-scroll body,
body.allow-v-scroll {
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
  max-height: none;
  height: auto;
  min-height: 100dvh;
}
@media (max-height: 740px) {
  html, body {
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: contain;
    max-height: none;
    height: auto;
    min-height: 100dvh;
  }
}
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(90deg, rgba(33, 226, 171, .035) 1px, transparent 1px),
    linear-gradient(180deg, rgba(53, 165, 255, .025) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: linear-gradient(180deg, rgba(0,0,0,.72), transparent 78%);
}
button, input { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }
img, svg {
  -webkit-user-drag: none;
  user-select: none;
}
.net-error {
  margin: 0 0 12px;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid rgba(255, 107, 122, .55);
  background: rgba(255, 107, 122, .12);
  color: #ff8a9a;
  font-weight: 800;
  text-align: center;
  letter-spacing: .02em;
}
.hidden { display: none !important; }
.ltr { direction: ltr; text-align: left; }

.boot-splash {
  position: fixed;
  inset: 0;
  z-index: 100000;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 18px;
  padding: 28px;
  background:
    linear-gradient(rgba(2, 6, 17, 0.02), rgba(2, 6, 17, 0.02)),
    #020611 url("art/loading-splash.png") center center / cover no-repeat;
  transition: opacity .45s ease, visibility .45s ease;
}
.boot-splash img {
  display: none;
}
.boot-progress {
  position: fixed;
  left: 50%;
  bottom: calc(58px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  width: min(62vw, 300px);
  height: 3px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(92, 117, 160, .28);
  box-shadow: 0 0 18px rgba(43, 201, 255, .2);
}
.boot-progress span {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #2de2ab, #37b6ff);
  animation: bootFill 3s ease-out forwards;
}
.boot-splash p {
  position: fixed;
  left: 0;
  right: 0;
  bottom: calc(22px + env(safe-area-inset-bottom, 0px));
  margin: 0;
  text-align: center;
  color: #8fa6c7;
  font-size: .82rem;
}
body.booting .phone-frame,
body.booting .mobile-nav,
body.booting .desktop-fit {
  opacity: 0;
  pointer-events: none;
}
body.booted .boot-splash {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}
@keyframes bootFill {
  from { width: 0%; }
  to { width: 100%; }
}

.desktop-fit {
  display: none;
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 60;
  width: min(760px, calc(100vw - 32px));
  gap: 14px;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border: 1px solid var(--line-strong);
  border-radius: 18px;
  background: rgba(6, 15, 29, 0.9);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}
.desktop-fit strong { display: block; font-size: .9rem; }
.desktop-fit span { color: var(--muted); font-size: .78rem; }
.desktop-fit button {
  border: 1px solid rgba(33, 226, 171, .42);
  background: linear-gradient(135deg, rgba(33, 226, 171, .18), rgba(53, 165, 255, .18));
  color: var(--text);
  border-radius: 14px;
  padding: 9px 12px;
  cursor: pointer;
  white-space: nowrap;
}

.phone-frame {
  width: min(100vw, 520px);
  height: 100dvh;
  max-height: 100dvh;
  margin: 0 auto;
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(220px 180px at 88% 8%, rgba(33,226,171,.12), transparent 70%),
    radial-gradient(300px 260px at 10% 36%, rgba(53,165,255,.09), transparent 70%),
    rgba(3, 8, 18, .18);
}
.shell {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  height: 100%;
  padding-bottom: calc(106px + env(safe-area-inset-bottom, 0px));
  overflow: hidden;
}
.rail { display: none; }
main {
  width: 100%;
  flex: 1;
  min-height: 0;
  padding: calc(18px + env(safe-area-inset-top, 0px)) 18px 26px;
  overflow: hidden; /* tabs fit without scroll on normal height */
  display: flex;
  flex-direction: column;
}
main > .panel {
  flex: 1;
  min-height: 0;
  overflow: hidden;
}
body.allow-v-scroll .phone-frame,
html.allow-v-scroll .phone-frame {
  height: auto;
  max-height: none;
  min-height: 100dvh;
  overflow: visible;
}
body.allow-v-scroll .shell,
html.allow-v-scroll .shell,
body.allow-v-scroll main,
html.allow-v-scroll main,
body.allow-v-scroll main > .panel,
html.allow-v-scroll main > .panel {
  overflow: visible;
  height: auto;
  max-height: none;
}
@media (max-height: 740px) {
  .phone-frame {
    height: auto;
    max-height: none;
    min-height: 100dvh;
    overflow: visible;
  }
  .shell,
  main,
  main > .panel {
    overflow: visible;
    height: auto;
    max-height: none;
  }
}
.top {
  min-height: 52px;
  display: flex;
  flex-direction: row; /* RTL: first = right */
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  width: 100%;
}
.top.hidden { display: none !important; }
.top-title {
  margin: 0;
  font-size: clamp(1.15rem, 4.8vw, 1.55rem);
  line-height: 1.2;
  letter-spacing: -.02em;
  white-space: nowrap;
  flex-shrink: 0;
}
.top-cluster {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  /* RTL: pack cluster toward the left (near logout) */
  justify-content: flex-end;
}
.hdr-wallet-label {
  /* Priority: show full label; push neighbors when long */
  flex: 0 0 auto;
  max-width: none;
  overflow: visible;
  white-space: nowrap;
  font-size: .88rem;
  font-weight: 800;
  color: #21e2ab;
  text-shadow: 0 0 12px rgba(33, 226, 171, .35);
}
.hdr-wallet-label.hidden { display: none !important; }
.pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  max-width: 28vw;
  padding: 6px 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: rgba(7, 16, 31, 0.66);
  box-shadow: inset 0 0 24px rgba(33, 226, 171, .04);
  white-space: nowrap;
  font-size: .8rem;
  overflow: hidden;
  text-overflow: ellipsis;
  flex-shrink: 1;
}
.pill::after {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #7a879e;
  box-shadow: 0 0 14px currentColor;
  flex-shrink: 0;
}
.pill.on { color: var(--accent); border-color: rgba(33, 226, 171, .34); }
.pill.on::after { background: var(--accent); }
.pill.off { color: #ff8a9a; border-color: rgba(255, 107, 122, .4); }
.pill.off::after { background: #ff4d5e; }
.pill.out { color: var(--muted); border-color: var(--line); }
.pill.out::after { background: #7a879e; }
.icon-btn {
  border: 1px solid var(--line);
  background: rgba(7, 16, 31, 0.7);
  color: var(--text);
  border-radius: 12px;
  min-height: 36px;
  min-width: 36px;
  padding: 6px 10px;
  cursor: pointer;
  font-size: .82rem;
  flex-shrink: 0;
}
.icon-btn.phosphor-btn {
  /* Match username pill: dark fill, light-green border + glyph */
  color: #21e2ab;
  font-size: 1.15rem;
  font-weight: 800;
  line-height: 1;
  border: 1px solid rgba(33, 226, 171, .55);
  background: rgba(7, 16, 31, 0.72);
  box-shadow: inset 0 0 18px rgba(33, 226, 171, .06);
}
.icon-btn.phosphor-btn:active {
  border-color: rgba(33, 226, 171, .9);
  background: rgba(33, 226, 171, .12);
}
.icon-btn.danger-btn { color: #ffb4bc; border-color: rgba(255,107,122,.4); }
.icon-btn.ghost-btn { color: var(--muted); font-size: 1.1rem; font-weight: 700; }
.wallet-switcher {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  gap: 6px;
  margin: -4px 0 12px;
  padding: 10px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: rgba(6, 14, 28, 0.94);
  backdrop-filter: blur(10px);
}
.wallet-switcher button {
  text-align: right;
  border: 1px solid transparent;
  background: rgba(255,255,255,.03);
  color: var(--text);
  border-radius: 12px;
  padding: 10px 12px;
  cursor: pointer;
}
.wallet-switcher button.active {
  border-color: rgba(33,226,171,.45);
  background: rgba(33,226,171,.1);
}
.wallet-card-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  margin-bottom: 8px;
}
.wallet-card-meta .wallet-label {
  margin: 0 0 2px;
  font-size: .95rem;
  font-weight: 700;
  color: var(--accent);
  text-align: left;
  direction: ltr;
  width: 100%;
  word-break: break-word;
}
.wallet-card-meta .net-name {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  text-align: left;
  direction: ltr;
  width: 100%;
}
.wallet-card-meta .group-line {
  margin: 0;
  font-size: .78rem;
  color: var(--muted);
  text-align: left;
  direction: ltr;
  width: 100%;
}
.subpage {
  position: fixed;
  inset: 0;
  z-index: 80;
  background:
    radial-gradient(900px 520px at 18% -10%, rgba(0, 245, 194, 0.12), transparent 56%),
    linear-gradient(180deg, #030712 0%, #07101f 55%, #050914 100%);
  overflow: hidden; /* locked on tall phones */
  overscroll-behavior: contain;
  padding: calc(12px + env(safe-area-inset-top, 0px)) 16px calc(28px + env(safe-area-inset-bottom, 0px));
}
@media (max-height: 740px) {
  .subpage {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
}
body.allow-v-scroll .subpage,
html.allow-v-scroll .subpage {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.subpage-inner { width: min(430px, 100%); margin: 0 auto; display: grid; gap: 14px; }
.subpage-head {
  display: flex;
  align-items: center;
  gap: 12px;
}
.subpage-head h1 { margin: 0; font-size: 1.25rem; }
.totp-card .qr-wrap { margin: 10px auto; }
body.subpage-open .mobile-nav,
body.subpage-open .phone-frame { pointer-events: none; }
body.subpage-open .phone-frame { filter: brightness(.55); }
.panel {
  display: grid;
  gap: 18px;
  width: 100%;
}

.card,
.hero-card,
.action-card,
.balance-card,
.security-card,
.install-hint,
.modal-card,
.pay-result .cell,
.pay-qr-block {
  position: relative;
  overflow: hidden;
  background: linear-gradient(145deg, rgba(12, 23, 43, .86), rgba(7, 12, 27, .9));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 14px 45px rgba(0, 0, 0, .28), inset 0 0 0 1px rgba(255,255,255,.02);
  backdrop-filter: blur(18px);
}
.card::before,
.hero-card::before,
.action-card::before,
.balance-card::before,
.security-card::before,
.pay-qr-block::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(260px 160px at 88% 8%, rgba(33,226,171,.12), transparent 66%),
    linear-gradient(130deg, rgba(255,255,255,.04), transparent 38%);
}
.card { padding: 22px; }
.card.glow { border-color: rgba(33,226,171,.34); box-shadow: 0 0 34px rgba(33,226,171,.11), var(--shadow); }
.card h2, .card h3 { margin: 0 0 10px; }
.hint { color: var(--muted); font-size: .88rem; line-height: 1.75; }

.hero-card {
  min-height: 250px;
  display: grid;
  grid-template-columns: 45% 1fr;
  align-items: center;
  gap: 8px;
  padding: 22px 20px;
}
.hero-art, .pay-art, .form-art {
  width: min(100%, 210px);
  max-height: 220px;
  object-fit: contain;
  filter: drop-shadow(0 0 28px rgba(33, 226, 171, .3));
  justify-self: center;
}
.hero-copy { position: relative; z-index: 1; }
.eyebrow { color: var(--accent); font-size: .8rem; letter-spacing: .03em; }
.hero-copy h2 { margin: 12px 0 10px; font-size: clamp(1.35rem, 6vw, 2rem); line-height: 1.4; }
.hero-copy p { margin: 0 0 16px; color: var(--muted); line-height: 1.8; }
.cta { width: auto !important; min-width: 150px; }

.quick-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.action-card {
  min-height: 116px;
  border: 1px solid var(--line);
  color: var(--text);
  text-align: right;
  padding: 18px 18px 16px;
  cursor: pointer;
}
.action-card b { display: block; font-size: 1.1rem; margin-bottom: 8px; }
.action-card small { color: var(--muted); font-size: .82rem; }
.action-ico {
  float: left;
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  color: var(--accent);
  background: rgba(33, 226, 171, .08);
  border: 1px solid rgba(33, 226, 171, .18);
  font-size: 2rem;
  box-shadow: inset 0 0 22px rgba(33,226,171,.07);
}
.action-ico.down { color: #19d6a1; }
.action-ico.blue { color: var(--accent2); }
.action-ico.violet { color: var(--violet); }
.muted-action { opacity: .82; }

.balance-card,
.security-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 16px;
  align-items: center;
  padding: 22px;
}
.balance-card img { width: 150px; max-width: 34vw; opacity: .9; }
.balance-card h2 { margin: 12px 0 6px; font-size: 1.55rem; }
.balance-card small, .security-card p, .terms { color: var(--muted); line-height: 1.7; }
#walletBalanceCard { order: -1; }
#walletBalanceCard.hidden { display: none !important; }
.security-card img { width: 116px; max-width: 30vw; }
.security-card h3 { margin: 0 0 8px; }
.security-card.compact { margin-top: 0; }

.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 4px;
  margin-bottom: 22px;
  background: rgba(4, 10, 22, .7);
}
.chip {
  border: 0;
  border-radius: 14px;
  padding: 10px;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  font-weight: 800;
}
.chip.active {
  color: var(--accent);
  box-shadow: inset 0 0 0 1px rgba(33, 226, 171, .5), 0 0 22px rgba(33,226,171,.08);
  background: rgba(33, 226, 171, .06);
}
.auth-card, .pay-card { padding-top: 28px; }
.form-art.small { width: 108px; float: left; margin: -10px 0 10px 8px; }
.auth-card .form-art { width: 150px; margin-bottom: 8px; }
.tips-card ul { margin: 0; padding: 0; list-style: none; }
.tips-card li {
  padding: 12px 28px 12px 10px;
  border-bottom: 1px solid rgba(83, 127, 168, .16);
  color: var(--muted);
  position: relative;
}
.tips-card li::before {
  content: "";
  position: absolute;
  right: 10px;
  top: 19px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 12px var(--accent);
}
.tips-card li:last-child { border-bottom: 0; }

/* Login: tips lower + 10% shorter; username/password inputs −3% height */
#tab-auth .tips-card {
  margin-top: 2.25rem;
  padding: 19.8px; /* 22px × 0.9 */
}
#tab-auth .tips-card h3 {
  margin: 0 0 9px;
  font-size: .95em;
}
#tab-auth .tips-card li {
  padding: 10.8px 25px 10.8px 9px;
  font-size: .95em;
  line-height: 1.35;
}
#tab-auth .tips-card li::before {
  top: 16px;
  width: 6px;
  height: 6px;
}
#tab-auth .auth-card input#username,
#tab-auth .auth-card input#password,
#tab-auth .auth-card input#password2 {
  min-height: calc(58px * 0.97);
  padding-top: calc(12px * 0.97);
  padding-bottom: calc(12px * 0.97);
}

/* Auth page: login box priority; tips flexible / collapses while typing */
#tab-auth.panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
  height: 100%;
  min-height: 0;
  overflow: hidden;
}
#tab-auth .auth-card {
  flex: 1.1 1 0; /* ~10% taller share than equal split */
  min-height: min(62vh, 100%);
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  display: flex;
  flex-direction: column;
  z-index: 2;
  transition: flex-grow .22s ease, min-height .22s ease;
}
#tab-auth .auth-card .primary {
  flex-shrink: 0;
  position: sticky;
  bottom: 0;
  z-index: 3;
}
#tab-auth .tips-card {
  flex: 0 1 auto;
  min-height: 0;
  max-height: 26vh;
  margin-top: 0;
  padding: 14px 16px;
  overflow: hidden;
  z-index: 1;
  transition: max-height .22s ease, opacity .18s ease, padding .22s ease, flex .22s ease, border-width .22s ease;
}
#tab-auth .tips-card h3 {
  margin: 0 0 8px;
  font-size: .92em;
}
#tab-auth .tips-card li {
  padding: 8px 22px 8px 8px;
  font-size: .9em;
  line-height: 1.3;
}
#tab-auth .tips-card li::before {
  top: 13px;
  width: 6px;
  height: 6px;
}
#tab-auth .auth-card input#username,
#tab-auth .auth-card input#password,
#tab-auth .auth-card input#password2 {
  min-height: calc(58px * 0.97);
  padding-top: calc(12px * 0.97);
  padding-bottom: calc(12px * 0.97);
}

/* While typing: auth fills height; tips collapse so submit stays visible */
#tab-auth.auth-typing .auth-card,
#tab-auth .auth-card:focus-within {
  flex: 1 1 auto;
  min-height: 100%;
  max-height: 100%;
}
#tab-auth.auth-typing .auth-card .form-art,
#tab-auth .auth-card:focus-within .form-art {
  width: 72px;
  max-height: 72px;
  margin-bottom: 4px;
}
#tab-auth.auth-typing .tips-card,
#tab-auth .auth-card:focus-within ~ .tips-card {
  flex: 0 0 0;
  max-height: 0;
  opacity: 0;
  padding-top: 0;
  padding-bottom: 0;
  margin: 0;
  border-width: 0;
  pointer-events: none;
}
@media (max-height: 740px) {
  #tab-auth.panel {
    overflow: hidden;
    height: 100%;
  }
  #tab-auth .auth-card {
    min-height: 70%;
  }
  #tab-auth .tips-card {
    max-height: 16vh;
  }
  #tab-auth.auth-typing .tips-card,
  #tab-auth .auth-card:focus-within ~ .tips-card {
    max-height: 0;
    opacity: 0;
  }
}

label { display: block; margin: 12px 0; color: var(--muted); font-size: .86rem; }
input {
  width: 100%;
  min-height: 58px;
  margin-top: 8px;
  padding: 12px 16px;
  border-radius: 18px;
  border: 1px solid rgba(83, 127, 168, .28);
  background: rgba(4, 10, 22, .76);
  color: var(--text);
  outline: none;
  box-shadow: inset 0 0 22px rgba(53, 165, 255, .03);
}
input:focus { border-color: rgba(33, 226, 171, .55); box-shadow: 0 0 0 3px rgba(33,226,171,.08); }
.primary,
.ghost,
.file-btn,
.link-btn {
  border-radius: 18px;
  cursor: pointer;
  font-weight: 900;
}
.primary {
  width: 100%;
  min-height: 56px;
  margin-top: 12px;
  padding: 13px 16px;
  border: 0;
  color: #042225;
  background: linear-gradient(100deg, #22e3a3 0%, #3fb6ff 100%);
  box-shadow: 0 16px 32px rgba(33, 226, 171, .16);
}
.ghost,
.file-btn,
.link-btn {
  min-height: 48px;
  padding: 12px 14px;
  color: var(--text);
  background: rgba(11, 22, 42, .72);
  border: 1px solid var(--line);
  text-decoration: none;
}
.primary.narrow { width: auto; min-width: 118px; margin-top: 0; }
.row { display: flex; align-items: center; gap: 10px; }
.row input { width: auto; min-height: auto; margin: 0; }
.addr { display: block; direction: ltr; text-align: left; word-break: break-all; font-size: .82rem; color: #cde6ff; }
.msg { margin-top: 10px; font-size: .86rem; }
.msg.err { color: var(--danger); }
.msg.ok { color: var(--accent); }
.grid2 { display: grid; grid-template-columns: 1fr; gap: 16px; }

.pay-card { min-height: 0; }
.pay-art { width: 205px; display: block; margin: 0 auto 12px; }
.secure-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 13px;
  border-radius: 999px;
  color: var(--accent);
  background: rgba(33, 226, 171, .08);
  border: 1px solid rgba(33, 226, 171, .25);
  font-size: .8rem;
}
.pay-actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 18px; }
.pay-actions > * {
  margin: 0 !important;
  width: 100% !important;
  min-height: 96px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 12px 8px !important;
  font-size: .86rem;
}
.pay-amount-block { display: flex; flex-direction: column; gap: 8px; }
.pay-amount-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.pay-amount-head > span:first-child { color: var(--muted); font-size: .75rem; }
.pay-amount-block input { margin-top: 0; max-width: 190px; }
.badge-fixed,
.badge-var {
  display: inline-block;
  font-size: .72rem;
  padding: 3px 10px;
  border-radius: 999px;
  width: auto;
}
.badge-fixed { border: 1px solid rgba(33,226,171,.38); color: var(--accent); background: rgba(33,226,171,.08); }
.badge-var { border: 1px solid var(--line); color: var(--muted); }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; align-items: center; }

/* Wallet cards: compact chrome; meta/address (red-box content) stay full size */
.wallet-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px 14px; /* ~20% less vertical chrome than 22px */
  min-height: 0;
}
.wallet-item .wallet-card-meta {
  flex: 0 0 auto;
  margin-bottom: 4px;
  gap: 4px;
  /* keep existing font sizes — do not shrink */
}
.wallet-item > .addr {
  flex: 0 0 auto;
  margin: 0;
  font-size: .82rem; /* unchanged from global .addr */
}
.wallet-item .btn-row {
  flex: 0 0 auto;
  margin-top: 6px;
  gap: 7px;
}
/* Buttons: −15% overall, then height −5% more */
.wallet-item .btn-row .primary,
.wallet-item .btn-row .ghost {
  font-size: calc(1em * 0.85);
  border-radius: 14px;
  line-height: 1.15;
}
.wallet-item .btn-row .primary {
  min-height: calc(56px * 0.85 * 0.95);
  padding: calc(13px * 0.85 * 0.95) calc(16px * 0.85);
  margin-top: 0;
}
.wallet-item .btn-row .ghost {
  min-height: calc(48px * 0.85 * 0.95);
  padding: calc(12px * 0.85 * 0.95) calc(14px * 0.85);
}
.wallet-item .btn-row .primary.narrow {
  min-width: calc(118px * 0.85);
}
#tab-wallets.panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
  height: 100%;
  overflow: hidden;
}
#tab-wallets #walletList.grid2 {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  gap: 10px;
  align-content: start;
}
#tab-wallets .balance-card {
  flex: 0 0 auto;
  padding: 14px 16px;
}
.qr-wrap {
  width: 220px;
  height: 220px;
  margin: 12px auto;
  background: #fff;
  border-radius: 18px;
  padding: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.qr-wrap img, .qr-wrap canvas { max-width: 100%; height: auto; }
.pay-result { margin-top: 18px; display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.pay-result .cell { padding: 13px; }
.pay-result .cell span.label { display: block; color: var(--muted); font-size: .75rem; margin-bottom: 6px; }
.pay-result .cell.wide, .pay-qr-block { grid-column: 1 / -1; }
.pay-qr-block { text-align: center; padding: 16px; }

.amt-mode { border: 1px solid var(--line); border-radius: 18px; padding: 12px; margin: 12px 0; }
.amt-mode legend { color: var(--muted); font-size: .8rem; padding: 0 6px; }
.scan-box { margin-top: 14px; }
.scan-box video { width: 100%; max-height: 280px; border-radius: 18px; background: #000; object-fit: cover; }
.install-hint { padding: 14px; color: #b8d8ff; border-style: dashed; }

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .72);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 70;
  padding: 18px;
}
.modal-card { width: min(430px, 100%); padding: 22px; }
.modal-x {
  position: absolute;
  left: 14px;
  top: 10px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 1.6rem;
  cursor: pointer;
}

.mobile-nav {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(0, 1fr));
  position: fixed;
  left: max(0px, calc((100vw - 520px) / 2 + 14px));
  right: max(0px, calc((100vw - 520px) / 2 + 14px));
  bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  z-index: 50;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: rgba(8, 17, 34, .92);
  backdrop-filter: blur(18px);
  box-shadow: 0 16px 44px rgba(0,0,0,.38);
}
body.session-on .nav[data-tab="auth"] { display: none !important; }
.mobile-nav .nav {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-height: 64px;
  border: 0;
  border-radius: 18px;
  background: transparent;
  color: var(--muted);
  font-size: .75rem;
  font-weight: 800;
  cursor: pointer;
}
.mobile-nav .nav .ico { font-size: 1.2rem; line-height: 1; }
.mobile-nav .nav.active {
  color: var(--accent);
  background: rgba(33, 226, 171, .12);
  box-shadow: inset 0 0 0 1px rgba(33,226,171,.18), 0 0 24px rgba(33,226,171,.08);
}

.nanom-pwa-update {
  position: fixed;
  top: calc(12px + env(safe-area-inset-top, 0px));
  left: 12px;
  right: 12px;
  z-index: 10000;
  display: flex;
  justify-content: center;
  pointer-events: none;
}
.nanom-pwa-update.hidden { display: none !important; }
.nanom-pwa-update-card {
  pointer-events: auto;
  width: min(420px, 100%);
  background: rgba(10, 28, 22, .96);
  border: 1px solid rgba(33,226,171,.35);
  color: #e8fff7;
  border-radius: 18px;
  padding: 14px 16px;
  box-shadow: var(--shadow);
  direction: rtl;
  text-align: right;
}
.nanom-pwa-update-card strong { display: block; font-size: .95rem; }
.nanom-pwa-update-card p { margin: 6px 0 0; font-size: .8rem; color: #bde7dc; line-height: 1.45; }
.nanom-pwa-update-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 12px; }
.nanom-pwa-update-actions .primary.narrow { margin-top: 0; min-width: 110px; }
.nanom-pwa-update-actions .ghost { margin-top: 0; }

@media (min-width: 821px) {
  .desktop-fit { display: flex; }
  body { padding-top: 78px; }
  .phone-frame {
    min-height: calc(100vh - 96px);
    border: 1px solid rgba(83, 127, 168, .18);
    border-radius: 34px;
    box-shadow: 0 28px 90px rgba(0,0,0,.46);
    overflow: hidden;
  }
  .shell { min-height: calc(100vh - 96px); }
}
@media (max-width: 430px) {
  main { padding-inline: 14px; }
  .hero-card { grid-template-columns: 1fr; text-align: right; }
  .hero-art { width: 210px; }
  .quick-grid { gap: 10px; }
  .action-card { min-height: 108px; padding: 15px; }
  .action-ico { width: 48px; height: 48px; font-size: 1.65rem; }
  .pay-actions { grid-template-columns: 1fr 1fr; }
  .pay-actions > * { min-height: 78px; }
  .balance-card, .security-card { grid-template-columns: 1fr auto; padding: 18px; }
  .security-card img { width: 92px; }
}
@media (max-width: 340px) {
  .top { align-items: flex-start; flex-direction: column-reverse; }
  .quick-grid, .pay-result, .pay-actions { grid-template-columns: 1fr; }
  .mobile-nav { gap: 4px; padding: 8px 6px; }
  .mobile-nav .nav { min-height: 56px; font-size: .68rem; }
}

/* Tip popups (categorized; managed via tipPrefs) */
.tip-modal {
  position: fixed;
  inset: 0;
  z-index: 12000;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(2, 6, 17, 0.72);
  backdrop-filter: blur(8px);
}
.tip-modal.hidden { display: none !important; }
.tip-card {
  width: min(400px, 100%);
  border: 1px solid var(--line-strong);
  border-radius: 22px;
  padding: 18px 16px 14px;
  background: linear-gradient(180deg, rgba(14, 28, 49, 0.96), rgba(8, 16, 32, 0.96));
  box-shadow: var(--shadow);
  display: grid;
  gap: 12px;
}
.tip-cat {
  justify-self: start;
  font-size: .72rem;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--accent2);
  border: 1px solid rgba(53, 165, 255, .35);
  border-radius: 999px;
  padding: 4px 10px;
  background: rgba(53, 165, 255, .1);
}
.tip-card h2 { margin: 0; font-size: 1.15rem; }
.tip-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.tip-actions .primary { grid-column: 1 / -1; }
body:not(.session-on) .mobile-nav { display: none !important; }
body.session-on .mobile-nav.hidden { display: none !important; }
body.session-on .mobile-nav:not(.hidden) { display: grid; }
body.auth-only .shell { padding-bottom: calc(18px + env(safe-area-inset-bottom, 0px)); }

/* Market tabs + token rows — LTR box (all on left, names left) */
.market-card {
  direction: ltr;
  text-align: left;
}
#tab-market.panel {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  overflow: hidden;
  gap: 0;
}
#tab-market .market-card {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.market-tabs {
  display: flex;
  flex-direction: row;
  gap: .4rem;
  margin: 0 0 .85rem;
  padding: .3rem;
  border-radius: 12px;
  border: 1px solid rgba(33, 226, 171, .22);
  background: rgba(0, 0, 0, .28);
  flex-shrink: 0;
}
.market-tab {
  flex: 1;
  min-height: 2.4rem;
  border-radius: 9px;
  border: 1px solid transparent;
  background: transparent;
  color: #9fd8c4;
  font-weight: 800;
  font-size: .88rem;
  letter-spacing: .04em;
  text-transform: uppercase;
  cursor: pointer;
  text-align: center;
}
.market-tab.active {
  border-color: rgba(33, 226, 171, .55);
  background: rgba(33, 226, 171, .12);
  color: #21e2ab;
  box-shadow: inset 0 0 14px rgba(33, 226, 171, .08);
}
.market-token-list {
  display: grid;
  gap: 0;
  margin-top: 4px;
  flex: 1;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}
.market-token-row {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  padding: .72rem .55rem;
  border-bottom: 1px solid rgba(33, 226, 171, .12);
  direction: ltr;
  text-align: left;
}
.market-token-row:last-child { border-bottom: 0; }
.market-token-main {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: .65rem;
  min-width: 0;
  text-align: left;
}
.token-logo, .chain-logo {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  background: transparent;
  border: 1px solid rgba(33, 226, 171, .25);
}
.token-logo.sm, .chain-logo.sm { width: 22px; height: 22px; }
.market-token-name {
  font-weight: 700;
  color: #dffcf0;
  font-size: .92rem;
  text-align: left;
}
.market-token-meta {
  font-size: .72rem;
  color: #7eb9a5;
  margin-top: .12rem;
  text-align: left;
}
.market-token-price {
  font-family: ui-monospace, monospace;
  font-weight: 700;
  color: #21e2ab;
  font-size: .9rem;
  direction: ltr;
  text-align: right;
  white-space: nowrap;
  margin-left: auto;
}
.market-token-price .unit {
  font-size: .68rem;
  font-weight: 600;
  color: #7eb9a5;
  margin-left: .2rem;
}
.market-empty {
  text-align: center;
  color: var(--muted);
  padding: 28px 12px;
  border: 1px dashed var(--line);
  border-radius: 16px;
}
.wallet-chain-badge {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  font-size: .78rem;
  color: #9fd8c4;
  margin: .2rem 0 .35rem;
}
.wallet-label-text { font-weight: 800; color: #21e2ab; margin: 0 0 .25rem; }
.detail-token-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .6rem;
  padding: .7rem 0;
  border-bottom: 1px solid rgba(33, 226, 171, .12);
}
.detail-token-row:last-child { border-bottom: 0; }
.token-pick-list { display: grid; gap: .55rem; margin-top: .5rem; }
.token-pick-btn {
  display: flex;
  align-items: center;
  gap: .65rem;
  width: 100%;
  text-align: right;
  padding: .75rem .8rem;
  border-radius: 12px;
  border: 1px solid rgba(33, 226, 171, .35);
  background: rgba(7, 16, 31, 0.72);
  color: #dffcf0;
  cursor: pointer;
}
.token-pick-btn:active {
  border-color: rgba(33, 226, 171, .85);
  background: rgba(33, 226, 171, .12);
}
.token-pick-btn .bal {
  margin-right: auto;
  font-family: ui-monospace, monospace;
  color: #21e2ab;
  direction: ltr;
}
.net-name {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
}

/* Home + Pay: same compact density as wallet cards (no page-fill stretch) */
#tab-home.panel,
#tab-pay.panel {
  display: flex;
  flex-direction: column;
  gap: 10px;
  height: 100%;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  align-content: flex-start;
}
#tab-home .hero-card {
  flex: 0 0 auto;
  min-height: 0;
  padding: 14px 16px;
  gap: 6px;
}
#tab-home .hero-art {
  width: min(100%, 148px);
  max-height: 132px;
}
#tab-home .hero-copy h2 {
  margin: 8px 0 6px;
  font-size: clamp(1.12rem, 4.8vw, 1.5rem);
  line-height: 1.35;
}
#tab-home .hero-copy p {
  margin: 0 0 10px;
  font-size: .86rem;
  line-height: 1.55;
}
#tab-home .cta {
  min-width: calc(150px * 0.85);
  min-height: calc(56px * 0.85 * 0.95);
  padding: calc(13px * 0.85 * 0.95) calc(16px * 0.85);
  font-size: .85em;
  border-radius: 14px;
}
#tab-home .quick-grid {
  gap: 8px;
  flex: 0 0 auto;
}
#tab-home .action-card {
  min-height: calc(116px * 0.8);
  padding: 12px 12px 10px;
}
#tab-home .action-card b {
  font-size: 1rem;
  margin-bottom: 4px;
}
#tab-home .action-card small {
  font-size: .78rem;
}
#tab-home .action-ico {
  width: calc(56px * 0.85);
  height: calc(56px * 0.85);
  font-size: calc(2rem * 0.85);
}
#tab-home .security-card,
#tab-pay .security-card {
  flex: 0 0 auto;
  padding: 12px 14px;
  gap: 10px;
}
#tab-home .security-card img,
#tab-pay .security-card img {
  width: 76px;
  max-width: 22vw;
}
#tab-home .security-card h3,
#tab-pay .security-card h3 {
  margin: 0 0 4px;
  font-size: 1rem;
}
#tab-home .security-card p,
#tab-pay .security-card p {
  margin: 0;
  font-size: .84rem;
  line-height: 1.45;
}
#tab-home .install-hint {
  flex: 0 0 auto;
  padding: 10px 12px;
  font-size: .82rem;
}

#tab-pay .pay-card {
  flex: 0 0 auto;
  min-height: 0 !important;
  padding: 14px 16px 16px;
  padding-top: 16px;
}
#tab-pay .pay-art {
  width: 132px;
  max-height: 120px;
  margin: 0 auto 8px;
}
#tab-pay .secure-badge {
  padding: 6px 10px;
  font-size: .74rem;
}
#tab-pay .pay-card h2 {
  margin: 8px 0 6px;
  font-size: 1.12rem;
}
#tab-pay .pay-card > .hint {
  margin: 0 0 8px;
  font-size: .84rem;
  line-height: 1.5;
}
#tab-pay .pay-card label {
  margin: 8px 0;
}
#tab-pay .pay-card input {
  min-height: calc(58px * 0.85 * 0.95);
  padding-top: calc(12px * 0.85 * 0.95);
  padding-bottom: calc(12px * 0.85 * 0.95);
  font-size: .92em;
}
#tab-pay .pay-actions {
  gap: 8px;
  margin-top: 10px;
}
#tab-pay .pay-actions > * {
  min-height: calc(96px * 0.85 * 0.95) !important;
  padding: calc(10px * 0.85) calc(8px * 0.85) !important;
  font-size: calc(.86rem * 0.85) !important;
  border-radius: 14px;
}
#tab-pay .scan-box {
  margin-top: 10px;
}
#tab-pay .scan-box video {
  max-height: 200px;
}
@media (max-width: 430px) {
  #tab-home .action-card {
    min-height: calc(108px * 0.8);
    padding: 11px;
  }
  #tab-pay .pay-actions > * {
    min-height: calc(78px * 0.85 * 0.95) !important;
  }
}

/* Compact UI: −15% everywhere except header, bottom nav, market tab */
:root {
  --ui-compact: 0.85;
}
main > .panel:not(#tab-market),
#walletSwitcher,
.subpage,
.tip-modal,
.modal,
.rail {
  zoom: var(--ui-compact);
}
/* Explicit keep full size (safety if nested) */
#appTopBar.top,
.mobile-nav,
#tab-market,
#tab-market .market-card {
  zoom: 1;
}
