/* ── Reset ────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:         #080810;
  --surface:    #10101C;
  --card:       #181826;
  --border:     #232336;
  --primary:    #7C6FFF;
  --primary-dk: #5B4EDD;
  --primary-lt: #7C6FFF22;
  --accent:     #00D18C;
  --danger:     #FF4B4B;
  --warn:       #F59E0B;
  --text:       #F0F0FF;
  --muted:      #5A5A7A;
  --muted2:     #3A3A56;
  --radius:     16px;
  --radius-sm:  10px;
  --font:       -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

a { color: var(--primary); text-decoration: none; }
a:hover { opacity: .8; }
button { font-family: var(--font); cursor: pointer; }
input, textarea { font-family: var(--font); }

/* ── App Shell ────────────────────────────────────────────────────────────── */
#app { min-height: 100vh; display: flex; flex-direction: column; }

.splash {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  min-height: 100vh; gap: 1rem;
}
.splash-logo { animation: breathe 2s ease-in-out infinite; }
@keyframes breathe { 0%,100%{opacity:.4;transform:scale(.96)} 50%{opacity:1;transform:scale(1)} }

/* ── Main Wallet Screen ───────────────────────────────────────────────────── */
.main-screen {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  padding: env(safe-area-inset-top, 1rem) 1.5rem env(safe-area-inset-bottom, 1.5rem);
}

.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: max(env(safe-area-inset-top), 1rem);
  margin-bottom: auto;
}
.top-bar-brand {
  font-size: .8rem;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: .04em;
}
.top-bar-username {
  font-size: .85rem;
  color: var(--primary);
  font-weight: 600;
}
.icon-btn {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--muted);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--border); color: var(--text); }
.icon-btn svg { width: 18px; height: 18px; }

/* ── Balance Display ──────────────────────────────────────────────────────── */
.balance-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  padding: 2rem 0 1.5rem;
  text-align: center;
}
.balance-kin-amount {
  font-size: clamp(5rem, 22vw, 9rem);
  font-weight: 800;
  line-height: .9;
  letter-spacing: -.04em;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.balance-kin-label {
  font-size: 1.5rem;
  font-weight: 300;
  color: var(--muted);
  letter-spacing: .25em;
  margin-top: .35rem;
  text-transform: uppercase;
}
.balance-sol {
  font-size: .85rem;
  color: var(--muted);
  margin-top: .85rem;
  letter-spacing: .02em;
}

/* ── Action Buttons ───────────────────────────────────────────────────────── */
.action-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .75rem;
  margin-bottom: 1rem;
}
.action-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  padding: 1.25rem 1rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: .02em;
  transition: background .15s, border-color .15s, transform .1s;
}
.action-btn:active { transform: scale(.97); }
.action-btn:hover  { background: var(--border); border-color: var(--primary); }
.action-btn.primary-btn {
  background: var(--primary);
  border-color: transparent;
  color: #fff;
}
.action-btn.primary-btn:hover { background: var(--primary-dk); border-color: transparent; }
.action-btn svg { width: 24px; height: 24px; opacity: .8; }

.share-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  padding: .75rem;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-size: .875rem;
  font-weight: 500;
  transition: color .15s, border-color .15s;
}
.share-btn:hover { color: var(--text); border-color: var(--muted); }
.share-btn svg { width: 16px; height: 16px; }

/* ── PIN Pad ──────────────────────────────────────────────────────────────── */
.pin-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 2rem 2rem env(safe-area-inset-bottom, 2rem);
  gap: 2.5rem;
}
.pin-title {
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--text);
  text-align: center;
}
.pin-subtitle {
  font-size: .85rem;
  color: var(--muted);
  margin-top: .3rem;
  text-align: center;
}
.pin-error {
  font-size: .85rem;
  color: var(--danger);
  min-height: 1.2rem;
  text-align: center;
  margin-top: -.5rem;
}
.pin-dots {
  display: flex;
  gap: 1rem;
}
.pin-dot {
  width: 14px; height: 14px;
  border-radius: 50%;
  border: 2px solid var(--muted2);
  transition: background .15s, border-color .15s, transform .1s;
}
.pin-dot.filled {
  background: var(--primary);
  border-color: var(--primary);
  transform: scale(1.1);
}
.pin-dot.shake { animation: shake .3s ease; }
@keyframes shake {
  0%,100%{transform:translateX(0)}
  20%,60%{transform:translateX(-6px)}
  40%,80%{transform:translateX(6px)}
}
.pin-pad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: .6rem;
  width: 100%;
  max-width: 300px;
}
.pin-key {
  aspect-ratio: 1;
  border-radius: 50%;
  border: none;
  background: var(--card);
  color: var(--text);
  font-size: 1.5rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background .1s, transform .1s;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.pin-key:active { background: var(--border); transform: scale(.92); }
.pin-key.empty  { background: none; cursor: default; pointer-events: none; }
.pin-key.back   { font-size: 1.1rem; color: var(--muted); }

/* ── Setup / Onboarding Flow ──────────────────────────────────────────────── */
.flow-screen {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  padding: 1.5rem 1.5rem env(safe-area-inset-bottom, 1.5rem);
  max-width: 480px;
  margin: 0 auto;
  width: 100%;
}
.flow-back {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  color: var(--muted);
  font-size: .875rem;
  background: none;
  border: none;
  padding: .5rem 0;
  margin-bottom: 1.5rem;
  cursor: pointer;
  transition: color .15s;
}
.flow-back:hover { color: var(--text); }
.flow-title {
  font-size: 1.6rem;
  font-weight: 700;
  margin-bottom: .4rem;
}
.flow-sub {
  color: var(--muted);
  font-size: .9rem;
  margin-bottom: 2rem;
  line-height: 1.6;
}

/* ── Cards ────────────────────────────────────────────────────────────────── */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
}
.card + .card { margin-top: .75rem; }

/* ── Alerts ───────────────────────────────────────────────────────────────── */
.alert {
  display: flex;
  gap: .75rem;
  padding: .85rem 1rem;
  border-radius: var(--radius-sm);
  font-size: .875rem;
  align-items: flex-start;
  margin-bottom: 1rem;
}
.alert-warn    { background: #F59E0B18; border: 1px solid #F59E0B44; color: #FCD34D; }
.alert-info    { background: #7C6FFF18; border: 1px solid #7C6FFF44; color: #A89FFF; }
.alert-success { background: #00D18C18; border: 1px solid #00D18C44; color: #00D18C; }
.alert-danger  { background: #FF4B4B18; border: 1px solid #FF4B4B44; color: #FF7878; }
.alert-icon    { flex-shrink: 0; line-height: 1.4; }

/* ── Mnemonic Grid ────────────────────────────────────────────────────────── */
.mnemonic-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: .4rem;
  margin: 1rem 0;
}
.mnemonic-word {
  display: flex;
  align-items: center;
  gap: .35rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: .4rem .6rem;
  font-size: .8rem;
}
.mnemonic-num { font-size: .68rem; color: var(--muted); min-width: 1.1rem; flex-shrink: 0; }
.mnemonic-word span:last-child { font-weight: 600; color: var(--text); }

/* ── Forms ────────────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 1rem; }
.form-group label {
  display: block;
  font-size: .8rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .05em;
  margin-bottom: .4rem;
}
.form-group input,
.form-group textarea {
  width: 100%;
  padding: .8rem 1rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 1rem;
  background: var(--surface);
  color: var(--text);
  transition: border-color .15s, box-shadow .15s;
  outline: none;
}
.form-group input::placeholder,
.form-group textarea::placeholder { color: var(--muted2); }
.form-group input:focus,
.form-group textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-lt);
}
.form-group textarea { min-height: 90px; resize: none; }
.form-hint  { font-size: .78rem; color: var(--muted); margin-top: .3rem; }
.form-error { font-size: .8rem;  color: var(--danger);margin-top: .3rem; }
.input-row  { display: flex; gap: .5rem; align-items: flex-end; }
.input-row .form-group { flex: 1; margin-bottom: 0; }

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  padding: .875rem 1.5rem;
  border-radius: var(--radius-sm);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: opacity .15s, transform .1s;
  font-family: var(--font);
  text-decoration: none;
}
.btn:disabled { opacity: .4; pointer-events: none; }
.btn:active   { transform: scale(.98); }
.btn-full     { width: 100%; }
.btn-sm       { padding: .55rem 1rem; font-size: .875rem; border-radius: 8px; }

.btn-primary  { background: var(--primary); color: #fff; }
.btn-primary:hover { opacity: .88; }

.btn-outline  { background: transparent; color: var(--text); border: 1.5px solid var(--border); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }

.btn-ghost    { background: var(--card); color: var(--muted); border: 1px solid var(--border); }
.btn-ghost:hover { color: var(--text); }

.btn-danger   { background: var(--danger); color: #fff; }

/* ── Receive / QR screen ──────────────────────────────────────────────────── */
.qr-wrap { display: flex; justify-content: center; margin: 1.5rem 0 1rem; }
.qr-wrap canvas { border-radius: 12px; border: 4px solid var(--card); }

.addr-box {
  display: flex;
  align-items: center;
  gap: .5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: .65rem .85rem;
  margin-bottom: .5rem;
}
.addr-box code {
  flex: 1;
  font-size: .72rem;
  word-break: break-all;
  color: var(--muted);
  font-family: monospace;
}
.copy-btn {
  flex-shrink: 0;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--muted);
  padding: .2rem;
  transition: color .15s;
}
.copy-btn:hover { color: var(--primary); }
.copy-feedback {
  font-size: .78rem;
  color: var(--accent);
  font-weight: 600;
  text-align: center;
  min-height: 1.1rem;
}

/* ── Share Sheet (bottom overlay) ────────────────────────────────────────── */
.overlay-bg {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.7);
  z-index: 200;
  display: flex;
  align-items: flex-end;
  animation: fadeIn .2s ease;
}
@keyframes fadeIn { from{opacity:0} to{opacity:1} }
.share-sheet {
  background: var(--surface);
  border-radius: var(--radius) var(--radius) 0 0;
  border-top: 1px solid var(--border);
  padding: 1.5rem 1.5rem calc(env(safe-area-inset-bottom) + 1.5rem);
  width: 100%;
  animation: slideUp .25s ease;
}
@keyframes slideUp { from{transform:translateY(100%)} to{transform:translateY(0)} }
.share-sheet-handle {
  width: 40px; height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin: 0 auto 1.25rem;
}
.share-sheet-title {
  font-size: 1rem;
  font-weight: 700;
  text-align: center;
  margin-bottom: .25rem;
}
.share-sheet-subtitle {
  font-size: .8rem;
  color: var(--muted);
  text-align: center;
  margin-bottom: 1.25rem;
}
.share-options {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: .75rem;
  margin-bottom: 1.25rem;
}
.share-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .4rem;
  padding: .85rem .5rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: .75rem;
  color: var(--muted);
  font-weight: 500;
  transition: border-color .15s, color .15s;
}
.share-option:hover { border-color: var(--primary); color: var(--text); }
.share-option svg, .share-option .share-ico { width: 28px; height: 28px; }
.share-msg-box {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: .85rem;
  font-size: .85rem;
  color: var(--muted);
  margin-bottom: 1rem;
  line-height: 1.5;
}
.share-msg-box strong { color: var(--primary); }

/* ── TX History ───────────────────────────────────────────────────────────── */
.tx-list { display: flex; flex-direction: column; gap: .5rem; }
.tx-item {
  display: flex;
  align-items: center;
  gap: .85rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: .85rem 1rem;
}
.tx-icon {
  width: 36px; height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
}
.tx-icon.in    { background: #00D18C18; color: var(--accent); }
.tx-icon.out   { background: #FF4B4B18; color: var(--danger); }
.tx-icon.other { background: var(--surface); color: var(--muted); }
.tx-body  { flex: 1; min-width: 0; }
.tx-type  { font-weight: 600; font-size: .875rem; }
.tx-meta  { font-size: .72rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tx-amt   { font-weight: 700; font-size: .9rem; white-space: nowrap; }
.tx-amt.in  { color: var(--accent); }
.tx-amt.out { color: var(--danger); }

/* ── Send form specifics ──────────────────────────────────────────────────── */
.asset-tabs { display: flex; gap: .5rem; margin-bottom: 1rem; }
.asset-tab {
  flex: 1;
  padding: .55rem;
  border-radius: 8px;
  border: 1.5px solid var(--border);
  background: none;
  color: var(--muted);
  font-size: .875rem;
  font-weight: 600;
  cursor: pointer;
  transition: all .15s;
}
.asset-tab.active {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-lt);
}

/* ── Settings list ────────────────────────────────────────────────────────── */
.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: .5rem;
  cursor: pointer;
  transition: border-color .15s;
}
.settings-row:hover { border-color: var(--primary); }
.settings-row-title { font-weight: 600; font-size: .9rem; }
.settings-row-sub   { font-size: .78rem; color: var(--muted); margin-top: .1rem; }
.settings-row-end   { color: var(--muted); font-size: 1.1rem; }

/* ── Receive public page ──────────────────────────────────────────────────── */
.pub-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 2rem 1.5rem 3rem;
  max-width: 420px;
  margin: 0 auto;
}
.pub-back { align-self: flex-start; margin-bottom: 2rem; color: var(--muted); font-size: .875rem; }
.pub-back:hover { color: var(--text); }
.pub-avatar {
  width: 80px; height: 80px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), #B8AFFF);
  color: #fff;
  font-size: 2rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1rem;
  box-shadow: 0 0 40px #7C6FFF44;
}
.pub-name { font-size: 1.8rem; font-weight: 800; margin-bottom: .25rem; }
.pub-sub  { color: var(--muted); font-size: .9rem; margin-bottom: 2rem; }

/* ── Utility ──────────────────────────────────────────────────────────────── */
.muted { color: var(--muted); }
.text-center { text-align: center; }
.mt-1 { margin-top: .5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: .5rem; }
.mb-2 { margin-bottom: 1rem; }
.divider { height: 1px; background: var(--border); margin: 1.25rem 0; }
.mono { font-family: monospace; }
.section-title {
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--muted);
  margin: 1.25rem 0 .6rem;
}

/* ── Loading dots ─────────────────────────────────────────────────────────── */
.dots::after {
  content: '';
  animation: dotsAnim 1.4s infinite;
}
@keyframes dotsAnim { 0%{content:''} 25%{content:'.'} 50%{content:'..'} 75%{content:'...'} }

/* ── Responsive (tablet+) ────────────────────────────────────────────────── */
@media (min-width: 500px) {
  .main-screen, .flow-screen { max-width: 420px; margin-left: auto; margin-right: auto; }
  .pin-screen { max-width: 380px; margin: 0 auto; }
}
