:root {
  --bg:        #FFFFFF;
  --surface:   #F5F6F8;
  --surface-2: #ECEEF1;
  --surface-3: #E3E6EA;
  --line:      #E5E7EA;
  --text:      #0F1115;
  --dim:       #5A6472;
  --faint:     #9AA3AD;
  --green:     #2563EB;
  --green-hi:  #3B82F6;
  --red:       #F6465D;
  --red-hi:    #FF5C72;
  --gold:      #2563EB;
  --gold-hi:   #3B82F6;
  --green-soft: rgba(37,99,235,.12);
  --red-soft:   rgba(246,70,93,.14);
  --gold-soft:  rgba(37,99,235,.12);
  --font-display: 'Clash Display', -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: 'Consolas', 'SF Mono', 'Roboto Mono', monospace;
  --r-sm: 8px;
  --r-md: 10px;
  --r-lg: 14px;
  --r-xl: 18px;
}

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

[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font-body);
  background: #F1F3F5;
  color: var(--text);
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
img { display: block; max-width: 100%; }
.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

/* ---------- App shell (phone frame) ---------- */
.app {
  position: relative;
  width: 100%;
  max-width: 430px;
  margin: 0 auto;
  min-height: 100dvh;
  background:
    linear-gradient(rgba(255,255,255,.85), rgba(255,255,255,.85)),
    url('nd.png') center / cover no-repeat;
  padding-bottom: 84px;
  overflow-x: hidden;
}

/* ---------- Header ---------- */
.app-header {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 12px 14px;
  background: rgba(255,255,255,.92);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}

.account-wrap { position: relative; }
.account-switcher {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 10px 6px 6px;
  border-radius: var(--r-md);
}
.account-avatar {
  width: 36px; height: 36px; flex: none; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--gold-soft); color: var(--gold);
}
.account-meta { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.2; }
.account-type { display: inline-flex; align-items: center; gap: 3px; font-size: 11px; color: var(--dim); }
.account-type .chev { color: var(--dim); }
.account-balance {
  font-family: var(--font-mono); font-size: 17px; font-weight: 700;
  letter-spacing: -.01em; font-variant-numeric: tabular-nums;
}

.account-menu {
  position: absolute; top: 50px; left: 0; z-index: 40;
  min-width: 190px;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-md);
  list-style: none; padding: 6px; box-shadow: 0 20px 50px -10px rgba(0,0,0,.6);
}
.account-menu li {
  padding: 11px 12px; border-radius: var(--r-sm); font-size: 14px; font-weight: 600; cursor: pointer;
  color: var(--text);
}
.account-menu li.is-selected { color: var(--gold); background: var(--gold-soft); }
.account-menu li:hover { background: var(--surface-3); }

.header-logo { display: flex; align-items: center; }
.header-logo img { height: 38px; width: auto; max-width: 150px; object-fit: contain; }

/* ---------- Main ---------- */
.app-main { padding: 14px 14px 0; }

/* ---------- Asset selector ---------- */
.asset-strip { margin-bottom: 4px; }
.asset-scroll {
  display: flex; gap: 10px;
  overflow-x: auto; scrollbar-width: none;
  padding: 4px 2px 6px;
  -webkit-overflow-scrolling: touch;
}
.asset-scroll::-webkit-scrollbar { display: none; }
.asset-pill {
  flex: none; display: flex; flex-direction: column; align-items: center; gap: 6px;
  width: 64px; padding: 8px 0 7px;
  border-radius: var(--r-md);
  color: var(--dim);
  font-size: 10.5px; font-weight: 600;
}
.asset-pill .asset-icon {
  width: 44px; height: 44px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--surface); border: 1px solid var(--line);
  color: var(--dim);
  transition: transform .15s;
}
.asset-pill.is-active .asset-icon {
  background: var(--green); border-color: var(--green); color: #FFFFFF;
  box-shadow: 0 0 0 3px var(--green-soft);
}
.asset-pill.is-active { color: var(--text); }
.asset-pill:active .asset-icon { transform: scale(.92); }
.asset-pill .asset-icon.has-img { background: #fff; padding: 5px; }
.asset-pill .asset-icon.has-img img { width: 100%; height: 100%; object-fit: contain; }

.asset-add {
  width: 44px; height: 44px; border-radius: 50%;
  display: grid; place-items: center; flex: none;
  background: var(--surface); border: 1px dashed var(--line); color: var(--dim);
  align-self: center;
}
.asset-add:active { background: var(--surface-2); }

/* ---------- Asset detail ---------- */
.asset-detail { padding: 8px 4px 14px; }
.asset-detail-row { display: flex; align-items: baseline; justify-content: space-between; }
.asset-name { font-family: var(--font-display); font-size: 20px; font-weight: 600; letter-spacing: -.01em; }
.asset-price { font-family: var(--font-mono); font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }
.asset-price.up { color: var(--green); }
.asset-price.down { color: var(--red); }
.asset-return { margin-top: 4px; font-size: 12.5px; color: var(--gold); font-weight: 600; }

/* ---------- Chart ---------- */
.chart-card {
  background: var(--surface); border-radius: var(--r-lg);
  padding: 12px 12px 8px; margin-bottom: 14px;
}
.chart-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.chart-symbol { font-family: var(--font-mono); font-size: 12px; color: var(--dim); font-weight: 600; }
.tf-pills { display: flex; gap: 5px; }
.tf {
  padding: 6px 10px; border-radius: 7px;
  background: var(--surface-2); color: var(--dim); font-size: 11.5px; font-weight: 600;
}
.tf.is-active { background: var(--surface-3); color: var(--text); box-shadow: inset 0 0 0 1px var(--line); }

.chart-wrap { position: relative; }
.chart { width: 100%; height: 240px; display: block; }
.chart-live {
  position: absolute; top: 6px; right: 6px;
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 10px; font-weight: 700; letter-spacing: .06em;
  color: var(--green); background: rgba(255,255,255,.85);
  padding: 4px 7px; border-radius: 100px;
}
.live-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--green); animation: pulse 1.4s infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .25; } }

.chart-tools {
  display: flex; align-items: center; gap: 6px;
  margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--line);
}
.tool {
  width: 34px; height: 34px; border-radius: var(--r-sm);
  display: grid; place-items: center; color: var(--dim);
}
.tool.is-active { color: var(--green); background: var(--green-soft); }
.tool:active { background: var(--surface-3); }
.tool-divider { flex: 1; }

/* ---------- Demo amount + Start AI ---------- */
.ctrl-label { font-size: 11px; color: var(--dim); font-weight: 600; letter-spacing: .02em; }
.demo-card {
  background: var(--surface); border-radius: var(--r-lg);
  padding: 14px 16px; margin-bottom: 14px;
  display: flex; flex-direction: column; gap: 6px;
}
.demo-row { display: flex; align-items: baseline; gap: 10px; }
.demo-inr { font-size: 26px; font-weight: 800; letter-spacing: -.01em; }
.demo-usd { font-size: 14px; color: var(--dim); font-weight: 600; }

.ai-status {
  display: flex; align-items: center; justify-content: center; gap: 7px;
  font-size: 12px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
  color: var(--dim); margin-bottom: 12px;
}
.ai-status .live-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--dim); }
.ai-status.is-active { color: var(--green); }
.ai-status.is-active .live-dot { background: var(--green); animation: pulse 1.2s infinite; }
.ai-status.is-done { color: var(--gold); }
.ai-status.is-done .live-dot { background: var(--gold); }

.start-ai-btn {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%; padding: 17px; border-radius: var(--r-lg);
  background: linear-gradient(135deg, #2563EB 0%, #3B82F6 100%); color: #FFFFFF;
  font-size: 17px; font-weight: 800; letter-spacing: .02em;
  margin-bottom: 6px;
  transition: transform .1s, filter .15s;
}
.start-ai-btn:active { background: linear-gradient(135deg, #3B82F6 0%, #60A5FA 100%); transform: translateY(1px); }
.start-ai-btn:disabled { filter: grayscale(.4); opacity: .7; cursor: progress; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: 96px; z-index: 80;
  max-width: 360px; padding: 12px 18px;
  background: var(--surface-3); color: var(--text);
  border-radius: 100px; font-size: 13px; font-weight: 700;
  box-shadow: 0 16px 40px -10px rgba(0,0,0,.6);
  animation: toastIn .3s cubic-bezier(.2,.8,.2,1) both;
}
.toast.is-win { color: var(--green); }
.toast.is-lose { color: var(--red); }
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 10px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* ---------- Bottom nav (floating dock) ---------- */
.bottom-nav {
  position: fixed;
  bottom: calc(14px + env(safe-area-inset-bottom));
  left: 50%; transform: translateX(-50%);
  width: calc(100% - 28px);
  max-width: 402px;
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  background: rgba(255,255,255,.86);
  backdrop-filter: blur(20px) saturate(160%);
  -webkit-backdrop-filter: blur(20px) saturate(160%);
  border: 1px solid rgba(15,17,21,.06);
  border-radius: 24px;
  padding: 8px;
  box-shadow: 0 16px 40px -12px rgba(15,17,21,.25), 0 2px 8px -2px rgba(15,17,21,.08);
  z-index: 20;
}
.nav-item {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 4px; color: var(--faint); font-size: 11px; font-weight: 600;
  padding: 8px 4px; border-radius: 18px;
  transition: color .18s ease, background .18s ease;
}
.nav-item.is-active { color: var(--green); background: var(--green-soft); }
.nav-item svg { width: 22px; height: 22px; }

/* ---------- Registration modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: flex-end; justify-content: center;
  background: rgba(0,0,0,.6);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  animation: fadeIn .35s ease both;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal-card {
  width: 100%; max-width: 430px;
  max-height: 92dvh; overflow-y: auto;
  background: var(--surface);
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  padding: 26px 22px calc(26px + env(safe-area-inset-bottom));
  box-shadow: 0 -20px 60px -20px rgba(0,0,0,.6);
  animation: slideUp .4s cubic-bezier(.2,.8,.2,1) both;
}
@keyframes slideUp { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-brand {
  width: 52px; height: 52px; background: #fff; border-radius: var(--r-md);
  display: grid; place-items: center; padding: 8px; margin: 0 auto 14px; overflow: hidden;
}
.modal-brand img { width: 100%; height: 100%; object-fit: contain; }
.modal-card h2 { font-family: var(--font-display); font-size: 22px; font-weight: 600; text-align: center; letter-spacing: -.01em; }
.modal-sub { text-align: center; color: var(--dim); font-size: 14px; line-height: 1.5; margin: 8px auto 22px; max-width: 320px; }

.earned-banner {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  background: var(--green-soft);
  border-radius: var(--r-lg);
  padding: 14px 16px;
  margin: 16px 0 8px;
}
.earned-banner span {
  font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  color: var(--dim);
}
.earned-amount {
  font-family: var(--font-mono); font-size: 28px; font-weight: 800; letter-spacing: -.01em;
  color: var(--green); font-variant-numeric: tabular-nums;
}

.signup-form { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 7px; }
.field > span { font-size: 12px; font-weight: 600; color: var(--dim); }
.field input {
  width: 100%; background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r-md); padding: 13px 14px;
  font-family: var(--font-body); font-size: 15px; color: var(--text);
  outline: none;
}
.field input::placeholder { color: var(--faint); }
.field input:focus { border-color: var(--green); }

.phone-group { position: relative; display: flex; align-items: center; gap: 8px; }
.phone-group > input { flex: 1; }
.country-picker {
  display: flex; align-items: center; gap: 6px;
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: var(--r-md); padding: 0 10px; height: 46px;
}
.country-flag img { border-radius: 3px; }
.country-code { font-size: 14px; font-weight: 600; }
.country-caret { color: var(--faint); font-size: 12px; }
.country-dropdown {
  position: absolute; top: 52px; left: 0; z-index: 5;
  width: 100%; max-height: 240px; overflow-y: auto;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-lg);
  list-style: none; padding: 6px;
  box-shadow: 0 20px 50px -10px rgba(0,0,0,.5);
}
.country-dropdown li {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: var(--r-md); font-size: 14px;
  cursor: pointer; color: var(--text);
}
.country-dropdown li:hover { background: var(--surface-3); }
.country-dropdown li img { border-radius: 3px; }
.cd-code { margin-left: auto; color: var(--faint); font-size: 13px; }

.submit-button {
  width: 100%; padding: 15px;
  background: var(--gold); color: #FFFFFF;
  font-size: 15px; font-weight: 800; border-radius: var(--r-md); margin-top: 4px;
}
.submit-button:active { background: var(--gold-hi); }
.submit-button:disabled { opacity: .6; cursor: progress; }

.modal-trust { display: flex; align-items: center; justify-content: center; gap: 7px; color: var(--faint); font-size: 12px; }
.modal-trust svg { color: var(--green); }
.form-status { text-align: center; font-size: 13px; min-height: 16px; }

/* ---------- Grant screen (first page) ---------- */
.grant-screen {
  position: fixed; inset: 0; z-index: 200;
  display: flex; align-items: center; justify-content: center;
  background:
    linear-gradient(rgba(255,255,255,.85), rgba(255,255,255,.85)),
    url('nd.png') center / cover no-repeat;
  padding: 24px;
}
.grant-screen-inner { width: 100%; max-width: 340px; text-align: center; }
.grant-screen h2 {
  font-family: var(--font-display); font-size: 26px; font-weight: 600;
  line-height: 1.15; letter-spacing: -.01em; margin: 0 auto 12px;
}
.grant-logo {
  position: absolute; top: 20px; left: 50%;
  transform: translateX(-50%);
  display: block; width: auto; height: 36px;
  object-fit: contain;
}
.grant-screen .modal-sub { margin: 0 auto 26px; }
.grant-screen .submit-button { margin-top: 0; }

/* ---------- Intro tutorial (coach marks) ---------- */
.tutorial-scrim {
  position: fixed; inset: 0; z-index: 1000; overflow: hidden;
}
.tutorial-hole {
  position: absolute; border-radius: 14px;
  background: transparent;
  box-shadow: 0 0 0 4px #2563EB, 0 0 0 9999px rgba(15,17,21,.66);
}
.tutorial-bubble {
  position: fixed; z-index: 1001; width: 280px;
  background: #fff; border-radius: 16px;
  padding: 18px 18px 16px;
  box-shadow: 0 24px 60px -12px rgba(0,0,0,.5);
  color: var(--text);
}
.tutorial-bubble::after {
  content: ''; position: absolute; left: 50%;
  width: 14px; height: 14px; background: #fff;
  transform: translateX(-50%) rotate(45deg);
}
.tutorial-bubble.below::after { top: -7px; }
.tutorial-bubble.above::after { bottom: -7px; }
.tutorial-text { font-size: 14px; line-height: 1.5; font-weight: 500; margin-bottom: 14px; }
.tutorial-next {
  width: 100%; padding: 12px; border-radius: 10px;
  background: var(--green); color: #fff;
  font-size: 14px; font-weight: 800;
}

/* ---------- Start AI pulsing (after tutorial) ---------- */
.start-ai-btn.pulsing {
  animation: ctaPulse 1.6s ease-in-out infinite;
}
@keyframes ctaPulse {
  0%, 100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(37,99,235,.45); }
  50% { transform: scale(1.03); box-shadow: 0 0 0 14px rgba(37,99,235,0); }
}

/* ---------- Desktop ---------- */
@media (min-width: 431px) {
  .app {
    min-height: 100dvh;
  }
  .modal-backdrop { align-items: center; padding: 24px; }
  .modal-card { border-radius: var(--r-xl); max-height: 88dvh; }
}
