:root {
  --bg: #f4f6fb;
  --card: #ffffff;
  --line: rgba(24, 34, 66, 0.08);
  --text: #1a2340;
  --muted: #7c869e;
  --blue: #4f6bff;
  --blue-2: #3a55e6;
  --yes: #16a34a;
  --yes-bg: rgba(22, 163, 74, 0.12);
  --no: #e11d48;
  --no-bg: rgba(225, 29, 72, 0.12);
}

/* Base reset */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: Inter, "PingFang SC", "Noto Sans SC", sans-serif;
  background: #eef1f8;
  color: var(--text);
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
.hidden { display: none !important; }

/* Phone stage */
.stage { min-height: 100dvh; }
.phone {
  min-height: 100dvh;
  background: linear-gradient(180deg, #ffffff, #f4f6fb);
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}
.notch { display: none; }

/* Top bar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: calc(10px + env(safe-area-inset-top)) 14px 8px;
}
.brand { display: flex; align-items: center; gap: 8px; }
.logo-mark {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  object-fit: cover;
  display: block;
  background: #e8edf6;
  flex: 0 0 auto;
}
.brand strong { display: block; font-size: 16px; letter-spacing: -0.03em; color: var(--text); }
.brand span { display: block; color: var(--muted); font-size: 11px; }
.top-actions { display: flex; gap: 6px; }
.chip {
  height: 30px;
  padding: 0 10px;
  border-radius: 999px;
  background: #ffffff;
  border: 1px solid var(--line);
  box-shadow: 0 2px 6px rgba(26, 35, 64, 0.05);
  font-size: 11px;
  font-weight: 600;
  color: var(--text);
  max-width: 124px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chip.ghost { background: rgba(255,255,255,.75); }
.chip.balance { background: linear-gradient(135deg, #4f6bff, #7a5bff); color: #fff; border: 0; box-shadow: 0 6px 16px rgba(79, 107, 255, 0.35); }

/* Main content */
.content {
  flex: 1;
  overflow: auto;
  padding: 0 14px 92px;
  overscroll-behavior: contain;
}
.search {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 44px;
  padding: 0 12px;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 4px 14px rgba(26, 35, 64, 0.06);
}
.search span { color: var(--muted); font-size: 18px; }
.search input { flex: 1; min-width: 0; background: none; border: 0; outline: none; color: var(--text); }

/* Gift banner */
.gift {
  margin-top: 12px;
  width: 100%;
  text-align: left;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 12px 14px;
  border-radius: 16px;
  background: linear-gradient(135deg, #eef2ff, #f8f6ff);
  border: 1px solid rgba(79, 107, 255, 0.28);
}
.gift b { color: var(--blue-2); font-size: 13px; }
.gift span { color: #4a5470; font-size: 12px; line-height: 1.35; }
.gift em {
  font-style: normal;
  font-size: 11px;
  font-weight: 700;
  background: var(--blue);
  color: #fff;
  border-radius: 999px;
  padding: 6px 8px;
}

/* Category chips */
.cats {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  margin: 14px 0 8px;
  padding-bottom: 4px;
  scrollbar-width: none;
}
.cats::-webkit-scrollbar { display: none; }
.cats button {
  flex: 0 0 auto;
  height: 32px;
  padding: 0 12px;
  border-radius: 999px;
  background: #ffffff;
  border: 1px solid var(--line);
  color: #5b6680;
  font-size: 13px;
  font-weight: 600;
}
.cats button.on { background: var(--blue); border-color: var(--blue); color: #fff; box-shadow: 0 6px 14px rgba(79, 107, 255, 0.3); }
.source, .muted, .hint { color: var(--muted); font-size: 12px; line-height: 1.5; }

/* Market feed */
.feed { display: grid; gap: 12px; padding-bottom: 12px; }
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 12px;
  box-shadow: 0 6px 20px rgba(26, 35, 64, 0.06);
}
.card.sk {
  height: 148px;
  background: linear-gradient(90deg, #eef1f8, #ffffff, #eef1f8);
  background-size: 200% 100%;
  animation: shine 1.2s infinite;
}
@keyframes shine {
  0% { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}
.card-head { display: flex; gap: 10px; margin-bottom: 10px; }
.card-head img, .ph {
  width: 44px; height: 44px; border-radius: 12px;
  object-fit: cover; background: #e8edf6; flex: 0 0 auto;
}
.card-head h3, .sheet h3 { margin: 0; font-size: 15px; line-height: 1.35; color: var(--text); }
.card-head p, .desc { margin: 4px 0 0; color: var(--muted); font-size: 12px; line-height: 1.45; }
.rows { display: grid; gap: 10px; }
.row { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: center; }
.row .label { font-size: 13px; color: #3d4764; }
.row.col { display: block; }
.row-top { display: flex; justify-content: space-between; margin-bottom: 8px; font-size: 13px; }
.btns { grid-column: 1 / -1; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.btns button, .btn {
  height: 38px; border-radius: 12px; font-size: 12px; font-weight: 700;
}
.yes { background: var(--yes-bg); color: var(--yes); }
.no { background: var(--no-bg); color: var(--no); }
.btn { width: 100%; background: var(--blue); color: #fff; margin-top: 8px; box-shadow: 0 8px 18px rgba(79, 107, 255, 0.28); }
.btn.ghost { background: #f0f3fa; color: var(--text); box-shadow: none; }

/* Bottom tab bar */
.tabbar {
  position: absolute; left: 0; right: 0; bottom: 0;
  height: calc(64px + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: rgba(255,255,255,.92);
  backdrop-filter: blur(16px);
  border-top: 1px solid var(--line);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
}
.tabbar button {
  color: #8a93a8;
  font-size: 11px;
  font-weight: 600;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
}
.tabbar button.on { color: var(--blue); }
.ico { width: 18px; height: 18px; border: 1.6px solid currentColor; border-radius: 5px; }
.ico.portfolio { border-radius: 99px; }
.ico.profile { border-radius: 99px 99px 4px 4px; }

/* Bottom sheet & mask */
.mask {
  position: absolute; inset: 0;
  background: rgba(18, 26, 48, 0.5);
  display: flex; align-items: flex-end;
  z-index: 20;
}
.sheet {
  width: 100%;
  max-height: 86%;
  overflow: auto;
  background: #ffffff;
  border-radius: 22px 22px 0 0;
  padding: 8px 16px calc(20px + env(safe-area-inset-bottom));
  animation: up .28s ease;
}
@keyframes up {
  from { transform: translateY(24px); opacity: .6; }
  to { transform: none; opacity: 1; }
}
.handle { width: 42px; height: 4px; border-radius: 99px; background: #dbe0ec; margin: 4px auto 12px; }
.field { display: grid; gap: 6px; margin: 10px 0; font-size: 12px; color: var(--muted); }
.field input {
  height: 44px; border-radius: 12px; border: 1px solid var(--line);
  background: #f7f9fd; padding: 0 12px; outline: none; color: var(--text);
}
.captcha-row { display: flex; gap: 10px; align-items: end; }
.grow { flex: 1; }
.captcha { height: 44px; border-radius: 10px; overflow: hidden; border: 1px solid var(--line); }
.captcha canvas { display: block; }
.err { color: var(--no); font-size: 12px; }
.link { width: 100%; margin-top: 10px; color: var(--blue-2); font-size: 13px; }
.claim { text-align: center; padding: 12px 0 8px; }
.coin {
  width: 72px; height: 72px; margin: 8px auto 12px; border-radius: 50%;
  display: grid; place-items: center;
  background: radial-gradient(circle at 30% 30%, #ffedb0, #f0b429);
  color: #6b4a00; font-weight: 800; font-size: 18px;
  box-shadow: 0 10px 24px rgba(240, 180, 41, 0.35);
}
.pick {
  display: flex; justify-content: space-between; align-items: center;
  background: #f0f3ff; border-radius: 12px; padding: 12px; margin: 8px 0;
}
.quick { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.quick button { height: 34px; border-radius: 10px; background: #f0f3fa; font-size: 12px; font-weight: 700; color: var(--text); }
.meta-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin: 12px 0; }
.meta-grid div { background: #f7f9fd; border: 1px solid var(--line); border-radius: 12px; padding: 10px; }
.meta-grid span { display: block; color: var(--muted); font-size: 11px; margin-bottom: 4px; }
.page-title { margin: 6px 0 12px; font-size: 22px; }
.stat {
  background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 14px;
  display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px;
  box-shadow: 0 6px 20px rgba(26, 35, 64, 0.06);
}
.stat b { font-size: 20px; }
.profile-card { display: flex; gap: 12px; align-items: center; margin-bottom: 12px; }
.profile-card p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.stack { display: grid; gap: 8px; }
.empty { text-align: center; padding: 40px 12px; color: var(--muted); }
.lang-list { display: grid; gap: 8px; }
.lang-list button {
  height: 44px; border-radius: 12px; background: #f0f3fa;
  text-align: left; padding: 0 14px; font-weight: 600; color: var(--text);
}
.lang-list button.on { background: var(--blue); color: #fff; }

/* Success modal & toast */
.success-mask { align-items: center; padding: 20px; z-index: 50; }
.success {
  width: 100%; background: #ffffff; border-radius: 22px;
  padding: 24px 18px 18px; text-align: center; animation: up .28s ease;
  box-shadow: 0 24px 60px rgba(18, 26, 48, 0.25);
}
.check {
  width: 64px; height: 64px; margin: 0 auto 12px; border-radius: 50%;
  display: grid; place-items: center; background: var(--yes);
  color: #fff; font-size: 28px; font-weight: 800;
}
.toast {
  position: absolute; left: 16px; right: 16px;
  top: calc(18px + env(safe-area-inset-top));
  background: #ffffff; border: 1px solid var(--line);
  border-radius: 12px; padding: 10px 12px;
  text-align: center; font-size: 13px; z-index: 30;
  box-shadow: 0 10px 26px rgba(18, 26, 48, 0.18);
}

/* Desktop frame (phone shell) */
@media (min-width: 540px) {
  .stage {
    min-height: 100dvh;
    display: grid;
    place-items: center;
    background: radial-gradient(circle at 50% 0%, #dfe6ff 0%, transparent 42%), #eef1f8;
  }
  .phone {
    width: 390px;
    height: min(844px, 96dvh);
    min-height: 0;
    border-radius: 40px;
    border: 10px solid #dde3f0;
    box-shadow: 0 24px 60px rgba(26, 35, 64, 0.22), inset 0 0 0 1px #cfd6e6;
  }
  .notch {
    display: block;
    position: absolute;
    top: 8px; left: 50%;
    width: 118px; height: 22px;
    transform: translateX(-50%);
    background: #1a2340;
    border-radius: 20px;
    z-index: 5;
  }
  .topbar { padding-top: 34px; }
}

/* Welcome popup */
.welcome-mask {
  position: absolute;
  inset: 0;
  background: rgba(18, 26, 48, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 40;
  padding: 20px;
}
.welcome-card {
  position: relative;
  width: 100%;
  background: linear-gradient(180deg, #ffffff, #eef2ff);
  border: 1px solid rgba(79, 107, 255, 0.3);
  border-radius: 22px;
  padding: 22px 18px 18px;
  text-align: center;
  animation: pop 0.28s ease;
  box-shadow: 0 24px 60px rgba(18, 26, 48, 0.28);
}
.welcome-card.shrink {
  animation: shrink-away 0.26s ease forwards;
}
@keyframes pop {
  from { transform: scale(0.92); opacity: 0; }
  to { transform: none; opacity: 1; }
}
@keyframes shrink-away {
  to { transform: scale(0.18) translate(140px, 220px); opacity: 0; }
}
.welcome-close {
  position: absolute;
  top: 10px;
  right: 12px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(79, 107, 255, 0.1);
  font-size: 20px;
  color: #5b6680;
}
.welcome-card h3 { margin: 8px 0; font-size: 18px; color: var(--text); }
.welcome-card .desc {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
  margin: 0 0 16px;
}
.gift-mini {
  position: absolute;
  right: 14px;
  bottom: calc(78px + env(safe-area-inset-bottom));
  z-index: 35;
  height: 40px;
  padding: 0 14px;
  border-radius: 999px;
  background: linear-gradient(135deg, #4f6bff, #7a5bff);
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  box-shadow: 0 10px 24px rgba(79, 107, 255, 0.4);
  animation: pop 0.28s ease;
}
