:root {
  --bg: #08080b;
  --surface: #101017;
  --surface-2: #16161f;
  --fg: #f4f4f7;
  --muted: #86869a;
  --line: rgba(255, 255, 255, 0.08);
  --accent: #7c5cff;
  --accent-2: #22d3ee;
  --radius: 16px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--fg);
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  overscroll-behavior: none;
}

body { display: flex; flex-direction: column; height: 100vh; height: 100dvh; position: relative; }

.glow {
  position: fixed;
  top: -180px;
  left: 50%;
  transform: translateX(-50%);
  width: 520px;
  height: 320px;
  background: radial-gradient(circle at center, rgba(124, 92, 255, 0.22), transparent 65%);
  filter: blur(24px);
  pointer-events: none;
  z-index: 0;
}

.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }

/* boot */

.boot {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: var(--bg);
  z-index: 100;
}

.spinner {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.12);
  border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}

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

/* top bar */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(12px + env(safe-area-inset-top)) 16px 12px;
  position: sticky;
  top: 0;
  z-index: 20;
  background: linear-gradient(180deg, rgba(8, 8, 11, 0.96), rgba(8, 8, 11, 0.72));
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}

.brand { display: flex; align-items: center; gap: 9px; }

.mark {
  width: 27px;
  height: 27px;
  border-radius: 9px;
  display: block;
  box-shadow: 0 6px 18px rgba(124, 92, 255, 0.35);
}

.word { font-weight: 680; letter-spacing: -0.015em; font-size: 16.5px; }

.pill {
  display: flex;
  align-items: baseline;
  gap: 5px;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--fg);
  border-radius: 999px;
  padding: 6px 13px;
  font-size: 13px;
  font-weight: 650;
  transition: border-color 0.15s ease;
}

.pill:active { border-color: rgba(124, 92, 255, 0.5); }
.pill .unit { color: var(--muted); font-weight: 500; font-size: 11.5px; }
.pill .mini { color: var(--muted); font-weight: 500; font-size: 10.5px; }

.top-actions { display: flex; align-items: center; gap: 8px; }

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

.ghost.danger { color: #ff6b6b; border-color: rgba(255, 107, 107, 0.28); }

/* views */

main { flex: 1; position: relative; overflow: hidden; z-index: 1; }

.view { display: none; height: 100%; overflow-y: auto; padding: 16px 16px 28px; }
.view.active { display: block; }

#view-chat { padding: 0; }
#view-chat.active { display: flex; flex-direction: column; }

.view-head { margin: 4px 2px 10px; }
.view-head h2 { margin: 0; font-size: 15px; font-weight: 680; letter-spacing: -0.015em; }
.view-head p { margin: 4px 0 0; font-size: 13px; }

/* chat */

.thread {
  flex: 1;
  overflow-y: auto;
  padding: 20px 16px 8px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.empty { margin: auto; text-align: center; max-width: 340px; padding: 20px 4px; }

.empty-mark {
  width: 62px;
  height: 62px;
  margin: 0 auto 18px;
  border-radius: 19px;
  display: block;
  box-shadow: 0 14px 36px rgba(124, 92, 255, 0.32);
}

.empty h1 { margin: 0 0 6px; font-size: 20px; font-weight: 680; letter-spacing: -0.025em; }
.empty p { margin: 0 0 20px; font-size: 13.5px; line-height: 1.5; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }

.chip {
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--fg);
  border-radius: 999px;
  padding: 9px 14px;
  font-size: 12.5px;
  font-weight: 500;
  transition: 0.15s ease;
}

.chip:active { background: var(--surface-2); transform: scale(0.98); }

.msg { display: flex; gap: 9px; animation: rise 0.22s ease both; }
.msg.user { justify-content: flex-end; }

@keyframes rise { from { opacity: 0; transform: translateY(6px); } }

.avatar {
  width: 26px;
  height: 26px;
  border-radius: 9px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  font-size: 11.5px;
  font-weight: 750;
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  margin-top: 2px;
}

.bubble {
  padding: 11px 14px;
  border-radius: 15px;
  font-size: 14.5px;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.62;
  max-width: calc(100% - 36px);
}

.msg.assistant .bubble {
  background: var(--surface);
  border: 1px solid var(--line);
  border-top-left-radius: 6px;
}

.msg.user .bubble {
  background: linear-gradient(135deg, #7c5cff, #6448e8);
  color: #fff;
  border-top-right-radius: 6px;
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 12.5px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent-2);
  animation: pulse 1.2s ease-in-out infinite;
}

@keyframes pulse { 50% { opacity: 0.25; } }

/* composer */

.composer {
  padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: rgba(8, 8, 11, 0.94);
  backdrop-filter: blur(14px);
}

.modes {
  display: flex;
  gap: 6px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 4px;
  margin-bottom: 9px;
}

.mode {
  flex: 1;
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 5px;
  background: transparent;
  border: 0;
  color: var(--muted);
  border-radius: 9px;
  padding: 7px 6px;
  transition: 0.15s ease;
}

.mode.active { background: rgba(124, 92, 255, 0.16); color: var(--fg); }
.mode-name { font-size: 12.5px; font-weight: 680; }
.mode-sub { font-size: 10.5px; opacity: 0.7; }

.input-row { display: flex; align-items: flex-end; gap: 9px; }

#input {
  flex: 1;
  resize: none;
  background: var(--surface);
  color: var(--fg);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 11px 14px;
  font: inherit;
  font-size: 15px;
  max-height: 132px;
  outline: none;
  transition: border-color 0.15s ease;
}

#input:focus { border-color: rgba(124, 92, 255, 0.55); }

.send {
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  border: 0;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  display: grid;
  place-items: center;
  box-shadow: 0 8px 22px rgba(124, 92, 255, 0.3);
}

.send:disabled { opacity: 0.4; box-shadow: none; }

/* cards */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 12px;
}

.primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  border: 0;
  border-radius: 12px;
  padding: 12px 16px;
  font-weight: 650;
  font-size: 14px;
}

.wide { width: 100%; margin-top: 10px; }

.field {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--line);
  color: var(--fg);
  border-radius: 11px;
  padding: 10px 12px;
  font: inherit;
  font-size: 14px;
  outline: none;
  margin-bottom: 8px;
}

.inline { display: flex; gap: 8px; }

.legal { text-align: center; font-size: 12.5px; }
.legal a { color: var(--muted); text-decoration: none; }
.dotsep { color: var(--muted); margin: 0 8px; }

/* plans */

.plans { display: flex; flex-direction: column; gap: 10px; margin-bottom: 6px; }

.plan {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 15px;
}

.plan.featured {
  border-color: rgba(124, 92, 255, 0.55);
  background: linear-gradient(180deg, rgba(124, 92, 255, 0.1), transparent 62%), var(--surface);
  box-shadow: 0 10px 30px rgba(124, 92, 255, 0.12);
}

.badge {
  position: absolute;
  top: -9px;
  right: 14px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  font-size: 10.5px;
  font-weight: 750;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  padding: 4px 9px;
  border-radius: 999px;
}

.plan-top { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 5px; }
.plan-name { font-size: 15.5px; font-weight: 680; letter-spacing: -0.015em; }
.plan-price { font-size: 14px; font-weight: 650; }
.plan-meta { font-size: 12.5px; color: var(--muted); margin-bottom: 4px; }
.plan-actions { display: flex; gap: 8px; margin-top: 12px; }

.btn-stars {
  flex: 1;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid var(--line);
  color: var(--fg);
  border-radius: 11px;
  padding: 10px;
  font-weight: 650;
  font-size: 13.5px;
}

.btn-crypto {
  flex: 1;
  background: transparent;
  border: 1px solid var(--line);
  color: var(--muted);
  border-radius: 11px;
  padding: 10px;
  font-size: 13.5px;
}

.btn-stars:active, .btn-crypto:active { background: rgba(255, 255, 255, 0.1); }

.amount-row { display: flex; gap: 8px; }

.amount {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--line);
  color: var(--muted);
  border-radius: 11px;
  padding: 10px;
  font-size: 13.5px;
  font-weight: 650;
}

.amount.active { border-color: rgba(124, 92, 255, 0.6); color: var(--fg); background: rgba(124, 92, 255, 0.1); }

.hint { font-size: 12px; margin: 9px 0 0; }

/* account */

.row-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
}

.row-line:last-child { border-bottom: 0; }
.row-line .k { color: var(--muted); font-size: 13px; }

.list { display: flex; flex-direction: column; gap: 2px; }
.list-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}
.list-row:last-child { border-bottom: 0; }
.list-row .tag { color: var(--muted); text-transform: capitalize; }

.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat { background: var(--bg); border-radius: 12px; padding: 11px 12px; }
.stat .n { font-size: 18px; font-weight: 750; letter-spacing: -0.025em; }
.stat .l { font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }

/* nav */

.nav {
  display: flex;
  border-top: 1px solid var(--line);
  background: rgba(8, 8, 11, 0.96);
  backdrop-filter: blur(14px);
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 20;
}

.nav-btn {
  flex: 1;
  background: transparent;
  border: 0;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 9px 0 10px;
  font-size: 10.5px;
  font-weight: 550;
}

.nav-btn.active { color: var(--fg); }
.nav-btn.active svg { filter: drop-shadow(0 0 8px rgba(124, 92, 255, 0.5)); }

/* segmented */

.seg {
  display: flex;
  gap: 4px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 4px;
  margin-top: 12px;
}

.seg-btn {
  flex: 1;
  background: transparent;
  border: 0;
  color: var(--muted);
  border-radius: 9px;
  padding: 8px 6px;
  font-size: 12.5px;
  font-weight: 650;
}

.seg-btn.active { background: rgba(124, 92, 255, 0.16); color: var(--fg); }

/* sheet */

.sheet-wrap {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.62);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: 0.2s ease;
  z-index: 70;
}

.sheet-wrap.open { opacity: 1; pointer-events: auto; }

.sheet {
  width: 100%;
  max-width: 520px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: 20px 20px 0 0;
  padding: 12px 18px calc(20px + env(safe-area-inset-bottom));
  transform: translateY(18px);
  transition: 0.24s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.sheet-wrap.open .sheet { transform: translateY(0); }

.sheet .grip {
  width: 38px;
  height: 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.16);
  margin: 0 auto 14px;
}

.sheet h3 { margin: 0 0 6px; font-size: 17px; font-weight: 680; letter-spacing: -0.015em; }
.sheet p { margin: 0 0 14px; font-size: 13.5px; }

.sheet .ghost {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--fg);
  border-radius: 12px;
  padding: 11px 16px;
  font-size: 14px;
  font-weight: 650;
}

.sheet .dismiss {
  width: 100%;
  background: transparent;
  border: 0;
  color: var(--muted);
  font-size: 13px;
  padding: 12px 0 0;
}

/* gate */

.gate-wrap {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.gate {
  width: 100%;
  max-width: 380px;
  text-align: center;
}

.gate-mark { width: 64px; height: 64px; border-radius: 20px; margin-bottom: 18px; box-shadow: 0 14px 36px rgba(124, 92, 255, 0.32); }
.gate h1 { font-size: 22px; letter-spacing: -0.025em; margin: 0 0 6px; font-weight: 680; }
.gate p { margin: 0 0 18px; font-size: 13.5px; }

.gate-links { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }

.gate-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 13px;
  padding: 13px 15px;
  color: var(--fg);
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
}

.gate-link .go { color: var(--muted); font-size: 12px; font-weight: 500; }
.gate-link.joined { border-color: rgba(120, 230, 160, 0.4); }
.gate-link.joined .go { color: rgb(120, 230, 160); }

/* toast */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(84px + env(safe-area-inset-bottom));
  transform: translate(-50%, 12px);
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--fg);
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 13px;
  opacity: 0;
  transition: 0.18s ease;
  pointer-events: none;
  z-index: 60;
  max-width: 86vw;
  text-align: center;
}

.toast.show { opacity: 1; transform: translate(-50%, 0); }
