:root {
  --bg: #0b1220;
  --bg-2: #101a2c;
  --card: #141f33;
  --card-2: #1a2740;
  --line: #22304a;
  --text: #e9eefb;
  --muted: #8fa0bd;
  --dim: #63748f;
  --brand: #4f8cff;
  --brand-2: #7c5cff;
  --ok: #34d399;
  --warn: #fbbf24;
  --bad: #f87171;
  --radius: 16px;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
}

* { box-sizing: border-box; }

/* `hidden` must win over the display rules below (.btn.block sets display:block). */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

body {
  min-height: 100vh;
  background:
    radial-gradient(1100px 500px at 80% -10%, rgba(79, 140, 255, 0.16), transparent 60%),
    radial-gradient(900px 500px at -10% 20%, rgba(124, 92, 255, 0.12), transparent 55%),
    var(--bg);
}

button { font: inherit; color: inherit; cursor: pointer; }
input, textarea, select { font: inherit; color: var(--text); }

h1 { font-size: 26px; line-height: 1.2; margin: 0 0 10px; letter-spacing: -0.02em; }
h2 { font-size: 18px; margin: 0; letter-spacing: -0.01em; }
h3 { font-size: 13px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin: 26px 0 10px; }

.muted { color: var(--muted); line-height: 1.5; }
.fineprint { color: var(--dim); font-size: 12px; line-height: 1.5; }
.fineprint.center { text-align: center; }
.error { color: var(--bad); font-size: 13px; min-height: 18px; margin: 8px 0 0; }
.hint { color: var(--dim); font-size: 12px; }

/* ---------------- screens ---------------- */
.screen { display: none; min-height: 100vh; }
.screen.active { display: block; }

.onboard-wrap {
  max-width: 460px;
  margin: 0 auto;
  padding: 28px 20px 40px;
}
.lock-wrap { padding-top: 18vh; }

.brand { display: flex; align-items: center; gap: 10px; margin-bottom: 30px; }
.brand.small { margin: 0; }
.brand-mark {
  width: 38px; height: 38px; border-radius: 12px;
  display: grid; place-items: center;
  font-weight: 800; font-size: 20px; color: #fff;
  background: linear-gradient(140deg, var(--brand), var(--brand-2));
  box-shadow: 0 6px 18px rgba(79, 140, 255, 0.35);
}
.brand-name { font-weight: 700; letter-spacing: 0.01em; }

.step { display: none; }
.step.active { display: block; animation: fade 0.18s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.seed-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 16px 0;
}
.seed-word {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px 8px;
  font-size: 13px;
  display: flex;
  gap: 6px;
  align-items: baseline;
}
.seed-word b { color: var(--dim); font-weight: 600; font-size: 11px; min-width: 14px; }
.seed-word span { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; word-break: break-all; }

.check {
  display: flex; gap: 10px; align-items: flex-start;
  margin: 14px 0 18px; color: var(--muted); font-size: 14px; line-height: 1.4;
}
.check input { width: 18px; height: 18px; margin-top: 1px; accent-color: var(--brand); }

.strength { height: 4px; border-radius: 4px; background: var(--line); margin: 10px 0 16px; overflow: hidden; }
.strength i { display: block; height: 100%; width: 0; transition: width 0.2s, background 0.2s; }

/* ---------------- inputs ---------------- */
input[type="text"], input[type="password"], textarea, select {
  width: 100%;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 13px 14px;
  margin-bottom: 10px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus, textarea:focus, select:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(79, 140, 255, 0.18);
}
textarea { resize: vertical; min-height: 84px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; line-height: 1.6; }

/* ---------------- buttons ---------------- */
.btn {
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 13px 16px;
  font-weight: 600;
  background: var(--card);
  color: var(--text);
  transition: transform 0.08s, filter 0.15s, background 0.15s;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.block { display: block; width: 100%; margin-top: 10px; }
.btn.primary { background: linear-gradient(140deg, var(--brand), var(--brand-2)); color: #fff; box-shadow: 0 8px 24px rgba(79, 140, 255, 0.3); }
.btn.primary:hover { filter: brightness(1.07); }
.btn.ghost { background: transparent; border-color: var(--line); color: var(--text); }
.btn.ghost:hover { background: var(--card); }
.btn.danger { background: rgba(248, 113, 113, 0.12); color: var(--bad); border-color: rgba(248, 113, 113, 0.35); }
.btn.small { padding: 9px 12px; font-size: 13px; border-radius: 10px; }

.link { background: none; border: 0; color: var(--brand); padding: 0; font-size: 14px; }
.link.back { margin-bottom: 18px; color: var(--muted); }
.link.tiny { font-size: 12px; margin: -4px 0 10px; display: inline-block; }

.icon-btn {
  background: transparent; border: 1px solid var(--line);
  width: 36px; height: 36px; border-radius: 10px;
  display: grid; place-items: center; color: var(--muted);
}
.icon-btn:hover { background: var(--card); color: var(--text); }

/* ---------------- top bar ---------------- */
#screen-app { max-width: 520px; margin: 0 auto; padding: 14px 16px 40px; }

.topbar {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 0 14px;
}
.chip {
  background: var(--card); border: 1px solid var(--line);
  border-radius: 999px; padding: 7px 12px; font-size: 12px; color: var(--muted);
  white-space: nowrap;
}
.chip.ok { color: var(--ok); border-color: rgba(52, 211, 153, 0.3); }
.chip.bad { color: var(--bad); border-color: rgba(248, 113, 113, 0.35); }

.account-chip {
  display: flex; align-items: center; gap: 8px;
  margin-left: auto;
  background: var(--card); border: 1px solid var(--line);
  border-radius: 999px; padding: 5px 12px 5px 5px;
  font-size: 13px; max-width: 46%;
}
.avatar {
  width: 26px; height: 26px; border-radius: 50%;
  display: grid; place-items: center; font-size: 12px; font-weight: 700;
  background: linear-gradient(140deg, var(--brand), var(--brand-2)); color: #fff;
  flex: none;
}
#accountName { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.caret { color: var(--dim); font-size: 10px; }

/* ---------------- balance ---------------- */
.balance-card {
  background: linear-gradient(160deg, rgba(79, 140, 255, 0.16), rgba(124, 92, 255, 0.08) 55%, transparent),
    var(--card);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 22px 20px 16px;
  box-shadow: var(--shadow);
}
.balance-label { color: var(--muted); font-size: 13px; }
.balance-value { font-size: 40px; font-weight: 750; letter-spacing: -0.03em; margin: 4px 0 2px; }
.balance-value .unit { font-size: 16px; color: var(--muted); font-weight: 600; }
.balance-sub { color: var(--dim); font-size: 12px; }
.balance-actions { display: flex; gap: 10px; margin-top: 18px; }
.action {
  flex: 1;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 8px;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  font-size: 12px; color: var(--muted);
}
.action:hover { background: rgba(255, 255, 255, 0.09); color: var(--text); }
.action-ico { font-size: 16px; color: var(--text); }

/* ---------------- tabs + lists ---------------- */
.tabs { display: flex; gap: 6px; margin: 22px 0 12px; background: var(--bg-2); padding: 5px; border-radius: 12px; border: 1px solid var(--line); }
.tab {
  flex: 1; background: transparent; border: 0; border-radius: 9px;
  padding: 9px 6px; font-size: 13px; color: var(--muted); font-weight: 600;
}
.tab.active { background: var(--card-2); color: var(--text); box-shadow: 0 2px 10px rgba(0,0,0,0.25); }

.tab-pane { display: none; }
.tab-pane.active { display: block; }

.list { display: flex; flex-direction: column; gap: 8px; }
.list.compact { gap: 6px; }

.item {
  display: flex; align-items: center; gap: 12px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 13px 14px;
}
.item[data-asset] { cursor: pointer; }
.item[data-asset]:active { background: var(--card-2); }
.item-main { flex: 1; min-width: 0; }
.item-title { font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-sub { color: var(--dim); font-size: 12px; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-right { text-align: right; font-size: 14px; font-weight: 600; flex: none; }
.item-right small { display: block; color: var(--dim); font-weight: 500; font-size: 11px; margin-top: 2px; }

.coin {
  width: 36px; height: 36px; border-radius: 50%; flex: none;
  display: grid; place-items: center; font-size: 12px; font-weight: 700;
  background: var(--card-2); border: 1px solid var(--line); color: var(--brand);
}
.coin.mnc { background: linear-gradient(140deg, var(--brand), var(--brand-2)); color: #fff; border: 0; }

.amount-in { color: var(--ok); }
.amount-out { color: var(--text); }
.amount-pending { color: var(--warn); }
.empty { color: var(--dim); text-align: center; padding: 26px 10px; font-size: 13px; }

.nft-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.nft-card {
  background: var(--card); border: 1px solid var(--line); border-radius: 14px; overflow: hidden;
}
.nft-thumb {
  aspect-ratio: 1 / 1; background: var(--card-2);
  display: grid; place-items: center; color: var(--dim); font-size: 12px;
  overflow: hidden;
}
.nft-thumb img { width: 100%; height: 100%; object-fit: cover; }
.nft-meta { padding: 9px 10px; }
.nft-name { font-size: 12px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nft-sub { font-size: 11px; color: var(--dim); margin-top: 2px; }

/* ---------------- panels + modals ---------------- */
.panel {
  position: fixed; inset: 0 0 0 auto;
  width: min(440px, 100%);
  background: var(--bg-2);
  border-left: 1px solid var(--line);
  transform: translateX(105%);
  transition: transform 0.22s ease;
  z-index: 40;
  display: flex; flex-direction: column;
  box-shadow: var(--shadow);
}
.panel.open { transform: none; }
.panel-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 18px 12px;
  border-bottom: 1px solid var(--line);
}
.panel-body { padding: 6px 18px 40px; overflow-y: auto; }
.panel-body h3:first-of-type { margin-top: 16px; }
.row-buttons { display: flex; flex-wrap: wrap; gap: 8px; }

.field { display: block; margin: 0 0 12px; }
.field > span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.field input, .field select, .field textarea { margin-bottom: 0; }
.amount-row { display: flex; gap: 8px; align-items: center; }
.amount-row input { flex: 1; }

.backdrop {
  position: fixed; inset: 0; background: rgba(4, 8, 16, 0.6);
  opacity: 0; pointer-events: none; transition: opacity 0.2s; z-index: 30;
}
.backdrop.show { opacity: 1; pointer-events: auto; }

.modal {
  position: fixed; inset: 0; z-index: 50;
  display: none; align-items: flex-end; justify-content: center;
  background: rgba(4, 8, 16, 0.65);
}
.modal.show { display: flex; }
.sheet {
  width: min(440px, 100%);
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 20px 20px 0 0;
  padding: 18px;
  max-height: 92vh; overflow-y: auto;
  animation: sheetUp 0.2s ease;
}
@keyframes sheetUp { from { transform: translateY(24px); opacity: 0.6; } to { transform: none; opacity: 1; } }
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }

@media (min-width: 640px) {
  .modal { align-items: center; }
  .sheet { border-radius: 20px; }
}

.fee-box {
  display: flex; justify-content: space-between;
  background: var(--card); border: 1px solid var(--line);
  border-radius: 12px; padding: 12px 14px;
  font-size: 13px; color: var(--muted); margin: 4px 0 14px;
}

/* ---------------- asset detail ---------------- */
.asset-hero { display: flex; align-items: center; gap: 12px; margin: 4px 0 16px; }
.asset-hero .coin { width: 44px; height: 44px; font-size: 13px; }
.asset-hero-main { flex: 1; min-width: 0; }
.asset-symbol { font-size: 18px; font-weight: 700; }
.asset-name { color: var(--dim); font-size: 12px; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.asset-amount { font-weight: 700; font-size: 16px; text-align: right; white-space: nowrap; }
.asset-contract {
  display: flex; align-items: center; gap: 10px;
  margin-top: 16px; padding-top: 12px;
  border-top: 1px solid var(--line);
  font-size: 12px; color: var(--dim);
}
.asset-contract .addr { flex: 1; text-align: left; color: var(--text); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.asset-contract .link.tiny { margin: 0; }

/* ---------------- receive ---------------- */
.qr-wrap { display: grid; place-items: center; padding: 8px 0 12px; }
#qrBox {
  background: #fff; padding: 12px; border-radius: 16px;
  display: grid; place-items: center; min-width: 216px; min-height: 216px;
}
#qrBox img, #qrBox canvas { display: block; border-radius: 8px; }
.addr-full {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px; text-align: center; word-break: break-all;
  color: var(--muted); background: var(--card);
  border: 1px solid var(--line); border-radius: 12px; padding: 12px;
  margin: 0 0 12px;
}

/* ---------------- toasts ---------------- */
#toasts { position: fixed; left: 50%; transform: translateX(-50%); bottom: 22px; z-index: 60; display: flex; flex-direction: column; gap: 8px; width: min(420px, calc(100% - 24px)); }
.toast {
  background: var(--card-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 13px;
  box-shadow: var(--shadow);
  animation: toastIn 0.18s ease;
}
.toast.ok { border-color: rgba(52, 211, 153, 0.45); }
.toast.bad { border-color: rgba(248, 113, 113, 0.45); }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* ---------------- misc ---------------- */
textarea.keystore { min-height: 180px; font-size: 11px; }

.seed-reveal {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 14px; line-height: 1.8;
  background: var(--card); border: 1px solid var(--line);
  border-radius: 12px; padding: 14px; word-spacing: 6px;
  user-select: all;
}
.warn-box {
  background: rgba(251, 191, 36, 0.1);
  border: 1px solid rgba(251, 191, 36, 0.35);
  color: #fcd34d; border-radius: 12px; padding: 12px 14px; font-size: 13px; line-height: 1.5;
}

/* ---------------- create page ---------------- */
#screen-create {
  max-width: 520px;
  margin: 0 auto;
  padding: 14px 16px 40px;
}

.btn.linklike { text-decoration: none; text-align: center; line-height: 1.2; }

.page-title { font-size: 28px; margin: 6px 0 6px; letter-spacing: -0.02em; }
.page-sub { margin: 0 0 18px; font-size: 14px; }

.account-select {
  margin-left: auto;
  max-width: 52%;
  width: auto;
  padding: 8px 30px 8px 12px;
  font-size: 13px;
  border-radius: 999px;
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 16px) 55%, calc(100% - 11px) 55%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  margin-bottom: 0;
}

.create-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 16px;
  margin-bottom: 14px;
}
.create-card h3 { margin: 0; }
.create-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.create-title { font-weight: 650; font-size: 15px; }
.create-sub { color: var(--dim); font-size: 12px; margin-top: 2px; }
.create-card .coin { font-size: 12px; }
