:root {
  color-scheme: dark;
  --bg: #0b0b0c;
  --surface: #151517;
  --surface-2: #1d1d20;
  --line: #2b2b2f;
  --text: #f7f6f2;
  --muted: #949499;
  --orange: #ff5a36;
  --green: #a8ff5d;
  --red: #ff5e75;
  --yellow: #ffd84d;
  --safe-top: max(env(safe-area-inset-top), var(--tg-content-safe-area-inset-top, 0px));
  --safe-right: max(env(safe-area-inset-right), var(--tg-content-safe-area-inset-right, 0px));
  --safe-bottom: max(env(safe-area-inset-bottom), var(--tg-content-safe-area-inset-bottom, 0px));
  --safe-left: max(env(safe-area-inset-left), var(--tg-content-safe-area-inset-left, 0px));
  --radius: 20px;
  --font: Inter, "SF Pro Display", "SF Pro Text", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

body {
  min-width: 300px;
}

button,
input,
select,
textarea {
  color: inherit;
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

.noise {
  position: fixed;
  inset: 0;
  z-index: 20;
  opacity: 0.025;
  pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.8'/%3E%3C/svg%3E");
}

.app-shell {
  min-height: 100vh;
  min-height: var(--tg-viewport-stable-height, 100vh);
  padding: calc(var(--safe-top) + 12px) var(--safe-right) calc(92px + var(--safe-bottom)) var(--safe-left);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 56px;
  padding: 0 18px 12px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 37px;
  height: 37px;
  border-radius: 11px;
  color: #0b0b0c;
  background: var(--orange);
  font-size: 25px;
  font-weight: 950;
  line-height: 1;
  transform: rotate(-4deg);
  box-shadow: 2px 2px 0 #fff;
}

.brand-name {
  font-size: 12px;
  font-weight: 900;
  line-height: 0.92;
  letter-spacing: 0.08em;
}

.wallet {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 1px;
  min-width: 90px;
  padding: 7px 11px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  text-align: right;
}

.wallet:active {
  transform: scale(0.98);
}

.wallet-label {
  color: var(--muted);
  font-size: 10px;
  line-height: 1;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.wallet strong {
  font-size: 16px;
  font-variant-numeric: tabular-nums;
}

.ticker {
  overflow: hidden;
  border-block: 1px solid var(--line);
  background: #101011;
  white-space: nowrap;
}

.ticker-track {
  display: inline-flex;
  align-items: center;
  min-width: max-content;
  min-height: 34px;
  animation: ticker 26s linear infinite;
}

.ticker-track span {
  padding: 0 10px;
  font-size: 11px;
  font-weight: 850;
  letter-spacing: 0.06em;
}

.ticker-track b {
  padding-left: 4px;
  font-variant-numeric: tabular-nums;
}

.ticker-track i {
  color: var(--orange);
  font-size: 7px;
  font-style: normal;
}

.ticker-track .up {
  color: var(--green);
}

.ticker-track .down {
  color: var(--red);
}

@keyframes ticker {
  to { transform: translateX(-50%); }
}

.main {
  width: min(100%, 680px);
  margin: 0 auto;
  padding: 24px 16px 32px;
}

.view-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.view-kicker {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 4px rgba(168, 255, 93, 0.12);
  animation: live 1.5s ease-in-out infinite;
}

@keyframes live {
  50% { opacity: 0.45; }
}

.view-head h1,
.portfolio-hero h1,
.leaderboard-hero h1 {
  margin: 0;
  font-size: clamp(30px, 9vw, 46px);
  font-weight: 950;
  line-height: 0.92;
  letter-spacing: -0.06em;
}

.view-count {
  flex: none;
  padding-bottom: 2px;
  color: var(--muted);
  font-size: 12px;
}

.filters {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  margin: 0 -16px 18px;
  padding: 0 16px;
  scrollbar-width: none;
}

.filters::-webkit-scrollbar {
  display: none;
}

.filter-chip {
  flex: none;
  min-height: 38px;
  padding: 0 15px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

.filter-chip.is-active {
  border-color: var(--text);
  background: var(--text);
  color: var(--bg);
}

.asset-list {
  display: grid;
  gap: 11px;
}

.asset-card {
  position: relative;
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  width: 100%;
  min-height: 91px;
  padding: 14px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  text-align: left;
  transition: border-color 120ms ease, transform 120ms ease;
}

.asset-card::after {
  content: "";
  position: absolute;
  inset: auto -22px -35px auto;
  width: 90px;
  height: 90px;
  border-radius: 50%;
  background: var(--asset-accent, var(--orange));
  opacity: 0.08;
  filter: blur(2px);
}

.asset-card:active {
  transform: scale(0.985);
  border-color: #515157;
}

.asset-icon {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border-radius: 15px;
  background: var(--asset-accent, var(--orange));
  color: #111;
  font-size: 26px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.28);
}

.asset-copy {
  min-width: 0;
}

.asset-meta {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.asset-symbol {
  color: var(--asset-accent, var(--orange));
}

.asset-copy h2 {
  display: -webkit-box;
  margin: 0;
  overflow: hidden;
  font-size: 15px;
  font-weight: 760;
  line-height: 1.17;
  letter-spacing: -0.02em;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.asset-quote {
  position: relative;
  z-index: 1;
  min-width: 78px;
  text-align: right;
}

.asset-quote strong {
  display: block;
  margin-bottom: 4px;
  font-size: 17px;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.04em;
}

.change {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 56px;
  padding: 4px 7px;
  border-radius: 7px;
  font-size: 11px;
  font-weight: 850;
  font-variant-numeric: tabular-nums;
}

.change.is-up {
  background: rgba(168, 255, 93, 0.11);
  color: var(--green);
}

.change.is-down {
  background: rgba(255, 94, 117, 0.11);
  color: var(--red);
}

.change.is-flat {
  background: rgba(255, 255, 255, 0.07);
  color: var(--muted);
}

.bottom-nav {
  position: fixed;
  z-index: 15;
  right: 0;
  bottom: 0;
  left: 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  min-height: calc(68px + var(--safe-bottom));
  padding: 7px max(10px, var(--safe-right)) var(--safe-bottom) max(10px, var(--safe-left));
  border-top: 1px solid var(--line);
  background: rgba(11, 11, 12, 0.94);
  backdrop-filter: blur(22px);
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  border: 0;
  background: transparent;
  color: #737378;
  font-size: 10px;
  font-weight: 720;
}

.nav-item svg {
  width: 23px;
  height: 23px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.nav-item.is-active {
  color: var(--text);
}

.nav-item.is-active svg {
  color: var(--orange);
}

.sheet-backdrop {
  position: fixed;
  z-index: 40;
  inset: 0;
  background: rgba(0, 0, 0, 0.68);
  backdrop-filter: blur(6px);
  animation: fade-in 180ms ease both;
}

.trade-sheet {
  position: fixed;
  z-index: 50;
  right: 0;
  bottom: 0;
  left: 0;
  max-height: min(88vh, var(--tg-viewport-stable-height, 88vh));
  padding: 11px max(18px, var(--safe-right)) calc(20px + var(--safe-bottom)) max(18px, var(--safe-left));
  overflow-y: auto;
  border: 1px solid #35353a;
  border-bottom: 0;
  border-radius: 28px 28px 0 0;
  background: #121214;
  box-shadow: 0 -22px 70px rgba(0, 0, 0, 0.58);
  animation: sheet-in 230ms cubic-bezier(0.22, 0.75, 0.2, 1) both;
}

@keyframes fade-in { from { opacity: 0; } }
@keyframes sheet-in { from { transform: translateY(100%); } }

.sheet-handle {
  width: 42px;
  height: 4px;
  margin: 0 auto 5px;
  border-radius: 5px;
  background: #46464b;
}

.sheet-close {
  position: absolute;
  top: 19px;
  right: max(18px, var(--safe-right));
  z-index: 2;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  padding: 0 0 3px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 25px;
}

.trade-asset-head {
  display: flex;
  align-items: center;
  gap: 13px;
  margin: 18px 42px 17px 0;
}

.trade-asset-head .asset-icon {
  flex: none;
  width: 58px;
  height: 58px;
  font-size: 29px;
}

.trade-asset-head h2 {
  margin: 3px 0 0;
  font-size: 21px;
  line-height: 1.03;
  letter-spacing: -0.04em;
}

.trade-chart {
  position: relative;
  height: 145px;
  margin: 0 -3px 8px;
  overflow: hidden;
  border-block: 1px solid var(--line);
}

.trade-chart::before {
  content: "";
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(to bottom, transparent 0, transparent 35px, rgba(255, 255, 255, 0.045) 36px);
}

.trade-chart svg {
  position: absolute;
  inset: 16px 0 8px;
  width: 100%;
  height: calc(100% - 24px);
  overflow: visible;
}

.trade-price-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin: 16px 0 14px;
}

.trade-price-label,
.metric-label {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 780;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.trade-price {
  font-size: 35px;
  font-weight: 900;
  line-height: 1;
  letter-spacing: -0.06em;
  font-variant-numeric: tabular-nums;
}

.trade-summary {
  margin: 0 0 17px;
  color: #b5b5ba;
  font-size: 14px;
  line-height: 1.4;
}

.trade-metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 17px;
}

.metric {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #171719;
}

.metric strong {
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}

.trade-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  border-radius: 13px;
  background: #080809;
}

.trade-tab {
  min-height: 42px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  font-weight: 820;
}

.trade-tab.is-active[data-side="buy"] {
  background: var(--green);
  color: #0a0a0b;
}

.trade-tab.is-active[data-side="sell"] {
  background: var(--red);
  color: #0a0a0b;
}

.order-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: end;
  margin: 16px 0 12px;
}

.quantity-block label {
  display: block;
  margin: 0 0 7px 2px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.quantity-control {
  display: grid;
  grid-template-columns: 42px minmax(60px, 1fr) 42px;
  min-height: 48px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--surface-2);
}

.quantity-control button {
  border: 0;
  background: transparent;
  color: var(--text);
  font-size: 23px;
}

.quantity-control input {
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  text-align: center;
  font-size: 18px;
  font-weight: 820;
  font-variant-numeric: tabular-nums;
  appearance: textfield;
}

.quantity-control input::-webkit-outer-spin-button,
.quantity-control input::-webkit-inner-spin-button {
  margin: 0;
  appearance: none;
}

.order-total {
  min-width: 112px;
  padding-bottom: 9px;
  text-align: right;
}

.order-total strong {
  display: block;
  font-size: 20px;
  letter-spacing: -0.04em;
  font-variant-numeric: tabular-nums;
}

.order-total small {
  color: var(--muted);
  font-size: 10px;
}

.primary-button {
  width: 100%;
  min-height: 55px;
  padding: 0 18px;
  border: 0;
  border-radius: 15px;
  background: var(--orange);
  color: #0c0c0d;
  font-size: 16px;
  font-weight: 900;
  letter-spacing: -0.02em;
}

.primary-button.buy {
  background: var(--green);
}

.primary-button.sell {
  background: var(--red);
}

.primary-button:disabled {
  opacity: 0.45;
}

.trade-footnote {
  margin: 9px 0 0;
  color: var(--muted);
  font-size: 10px;
  text-align: center;
}

.portfolio-hero,
.leaderboard-hero {
  padding: 6px 0 20px;
}

.portfolio-value {
  margin-top: 15px;
  font-size: clamp(42px, 13vw, 68px);
  font-weight: 950;
  line-height: 0.92;
  letter-spacing: -0.075em;
  font-variant-numeric: tabular-nums;
}

.portfolio-delta {
  display: inline-flex;
  margin-top: 10px;
  font-size: 13px;
  font-weight: 800;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 9px;
  margin: 2px 0 24px;
}

.summary-card {
  min-height: 88px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
}

.summary-card span {
  display: block;
  margin-bottom: 13px;
  color: var(--muted);
  font-size: 11px;
}

.summary-card strong {
  font-size: 19px;
  letter-spacing: -0.04em;
  font-variant-numeric: tabular-nums;
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 0 0 11px;
}

.section-title h2 {
  margin: 0;
  font-size: 19px;
  letter-spacing: -0.035em;
}

.section-title span {
  color: var(--muted);
  font-size: 11px;
}

.position-list,
.leader-list {
  display: grid;
  gap: 8px;
}

.position,
.leader {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 11px;
  align-items: center;
  min-height: 72px;
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: var(--surface);
}

button.position {
  width: 100%;
  text-align: left;
}

.position .asset-icon {
  width: 43px;
  height: 43px;
  border-radius: 12px;
  font-size: 21px;
}

.position-copy,
.leader-copy {
  min-width: 0;
}

.position-copy strong,
.leader-copy strong {
  display: block;
  overflow: hidden;
  font-size: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.position-copy span,
.leader-copy span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
}

.position-value,
.leader-value {
  text-align: right;
}

.position-value strong,
.leader-value strong {
  display: block;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}

.position-value span {
  display: block;
  margin-top: 4px;
  font-size: 11px;
  font-weight: 750;
}

.positive { color: var(--green) !important; }
.negative { color: var(--red) !important; }
.muted { color: var(--muted) !important; }

.leaderboard-hero p {
  max-width: 310px;
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.leader-rank {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--muted);
  font-size: 13px;
  font-weight: 850;
}

.leader:nth-child(1) .leader-rank {
  border: 0;
  background: var(--yellow);
  color: #111;
}

.leader:nth-child(2) .leader-rank {
  border: 0;
  background: #d7d7da;
  color: #111;
}

.leader:nth-child(3) .leader-rank {
  border: 0;
  background: #c98c62;
  color: #111;
}

.leader-avatar {
  width: 38px;
  height: 38px;
  overflow: hidden;
  border-radius: 50%;
  background: #29292d;
}

.leader-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.leader-avatar span {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  font-size: 14px;
  font-weight: 900;
}

.empty-state {
  padding: 38px 24px;
  border: 1px dashed #36363b;
  border-radius: 18px;
  text-align: center;
}

.empty-state b {
  display: block;
  margin-bottom: 8px;
  font-size: 18px;
}

.empty-state p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.welcome {
  position: fixed;
  z-index: 80;
  inset: 0;
  display: grid;
  place-items: center;
  padding: calc(24px + var(--safe-top)) max(18px, var(--safe-right)) calc(24px + var(--safe-bottom)) max(18px, var(--safe-left));
  background: rgba(4, 4, 5, 0.92);
  backdrop-filter: blur(16px);
}

.welcome-card {
  position: relative;
  width: min(100%, 410px);
  padding: 27px 22px 20px;
  overflow: hidden;
  border: 1px solid #37373c;
  border-radius: 28px;
  background: #111113;
  text-align: center;
}

.welcome-card::before {
  content: "";
  position: absolute;
  top: -70px;
  left: 50%;
  width: 280px;
  height: 180px;
  transform: translateX(-50%);
  border-radius: 50%;
  background: var(--orange);
  opacity: 0.16;
  filter: blur(50px);
}

.welcome-stamp {
  position: relative;
  display: inline-flex;
  padding: 6px 9px;
  border: 1px solid #4a4a50;
  border-radius: 7px;
  color: var(--muted);
  font-size: 9px;
  font-weight: 850;
  letter-spacing: 0.09em;
}

.welcome-coin {
  position: relative;
  display: grid;
  place-items: center;
  width: 98px;
  height: 98px;
  margin: 24px auto 19px;
  border: 3px solid #ff8b72;
  border-radius: 50%;
  background: var(--orange);
  color: #09090a;
  font-size: 59px;
  font-weight: 950;
  box-shadow: 0 0 0 7px #301b17, 0 18px 40px rgba(255, 90, 54, 0.28);
  transform: rotate(-7deg);
}

.welcome-card h1 {
  position: relative;
  margin: 0;
  font-size: 42px;
  font-weight: 950;
  line-height: 0.9;
  letter-spacing: -0.065em;
}

.welcome-card h1 span {
  color: var(--green);
}

.welcome-card p {
  margin: 20px auto;
  max-width: 290px;
  color: #b4b4ba;
  font-size: 14px;
  line-height: 1.42;
}

.welcome-card small {
  display: block;
  margin-top: 12px;
  color: #68686e;
  font-size: 9px;
}

.toast {
  position: fixed;
  z-index: 100;
  top: calc(16px + var(--safe-top));
  left: 50%;
  width: max-content;
  max-width: calc(100% - 32px);
  padding: 12px 16px;
  transform: translateX(-50%);
  border: 1px solid #3c3c41;
  border-radius: 13px;
  background: #222225;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.38);
  font-size: 13px;
  font-weight: 720;
  text-align: center;
  animation: toast-in 180ms ease both;
}

@keyframes toast-in {
  from { opacity: 0; transform: translate(-50%, -10px); }
}

.error-view {
  padding: 30px 0;
  text-align: center;
}

.error-view .error-mark {
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  margin: 20px auto;
  border-radius: 19px;
  background: var(--red);
  color: #111;
  font-size: 35px;
  font-weight: 950;
  transform: rotate(5deg);
}

.error-view h1 {
  margin: 0 0 10px;
  font-size: 28px;
}

.error-view p {
  margin: 0 auto 20px;
  max-width: 290px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.loading-view {
  padding-top: 9px;
}

.skeleton {
  position: relative;
  overflow: hidden;
  border-radius: 16px;
  background: #19191b;
}

.skeleton::after {
  content: "";
  position: absolute;
  inset: 0;
  transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.06), transparent);
  animation: shimmer 1.5s infinite;
}

@keyframes shimmer { to { transform: translateX(100%); } }

.skeleton-head { width: 62%; height: 48px; margin-bottom: 20px; }
.skeleton-filter { width: 100%; height: 38px; margin-bottom: 19px; border-radius: 999px; }
.skeleton-card { height: 91px; margin-bottom: 11px; }

[hidden] {
  display: none !important;
}

@media (min-width: 700px) {
  .topbar {
    width: min(100%, 720px);
    margin-inline: auto;
  }

  .bottom-nav {
    right: 50%;
    left: auto;
    width: 440px;
    transform: translateX(50%);
    border: 1px solid var(--line);
    border-bottom: 0;
    border-radius: 22px 22px 0 0;
  }

  .trade-sheet {
    left: 50%;
    width: 520px;
    transform: translateX(-50%);
  }

  @keyframes sheet-in {
    from { transform: translate(-50%, 100%); }
    to { transform: translate(-50%, 0); }
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Trading terminal */
:root {
  --bg: #080b10;
  --surface: #0e131a;
  --surface-2: #151b23;
  --line: #222a35;
  --text: #f1f5f9;
  --muted: #7d8794;
  --orange: #ff5b35;
  --green: #35d07f;
  --red: #ff586f;
  --yellow: #f6c85f;
  --radius: 14px;
}

html,
body {
  background:
    radial-gradient(circle at 80% -5%, rgba(54, 85, 116, 0.13), transparent 30%),
    var(--bg);
}

.noise {
  opacity: 0.014;
}

.app-shell {
  padding-top: calc(var(--safe-top) + 4px);
  padding-bottom: calc(72px + var(--safe-bottom));
}

.topbar {
  position: relative;
  z-index: 15;
  min-height: 58px;
  padding: 7px 14px 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.025);
  background: rgba(8, 11, 16, 0.82);
  backdrop-filter: blur(18px);
}

.brand {
  gap: 10px;
}

.brand-mark {
  width: 35px;
  height: 35px;
  border-radius: 9px;
  font-size: 23px;
  box-shadow: none;
  transform: rotate(-3deg);
}

.brand-copy {
  display: grid;
  gap: 4px;
}

.brand-name {
  font-size: 12px;
  line-height: 1;
  letter-spacing: 0.045em;
}

.market-status {
  display: flex;
  align-items: center;
  gap: 5px;
  color: var(--muted);
  font-size: 9px;
  font-weight: 720;
  letter-spacing: 0.045em;
  text-transform: uppercase;
}

.market-status i,
.session-badge i,
.listing-status i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 8px rgba(53, 208, 127, 0.75);
}

.wallet {
  min-width: 102px;
  padding: 7px 10px 6px;
  border-color: #293341;
  border-radius: 9px;
  background: linear-gradient(145deg, #131922, #0e131a);
}

.wallet-label {
  font-size: 8px;
  letter-spacing: 0.1em;
}

.wallet strong {
  font-size: 15px;
  letter-spacing: -0.025em;
}

.ticker {
  border-top: 0;
  border-bottom-color: #202833;
  background: #0b1016;
}

.ticker-track {
  min-height: 29px;
  animation-duration: 38s;
}

.ticker-track span {
  padding: 0 12px;
  color: #bac3ce;
  font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
  font-size: 9px;
  font-weight: 720;
  letter-spacing: 0.025em;
}

.ticker-track b {
  color: #eef2f7;
  font-weight: 700;
}

.ticker-track em {
  padding-left: 4px;
  font-style: normal;
}

.ticker-track i {
  color: #36404d;
  font-size: 4px;
}

.main {
  width: min(100%, 720px);
  padding: 20px 13px 32px;
}

.view-head {
  align-items: center;
  margin-bottom: 15px;
}

.view-kicker {
  margin-bottom: 5px;
  color: #6f7a87;
  font-size: 9px;
  font-weight: 780;
  letter-spacing: 0.12em;
}

.view-head h1,
.portfolio-hero h1,
.leaderboard-hero h1 {
  font-size: clamp(26px, 7vw, 36px);
  line-height: 0.95;
  letter-spacing: -0.045em;
}

.session-badge,
.account-mode {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 27px;
  padding: 0 9px;
  border: 1px solid #27313d;
  border-radius: 7px;
  background: #0d1218;
  color: #9aa4af;
  font-size: 9px;
  font-weight: 780;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.market-overview {
  display: grid;
  grid-template-columns: 1.35fr 1fr 1fr;
  gap: 7px;
  margin-bottom: 15px;
}

.market-stat {
  min-width: 0;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: linear-gradient(145deg, #111720, #0c1117);
}

.market-stat > span {
  display: block;
  margin-bottom: 9px;
  overflow: hidden;
  color: #727d8a;
  font-size: 8px;
  font-weight: 720;
  letter-spacing: 0.07em;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.market-stat strong {
  display: flex;
  align-items: baseline;
  gap: 5px;
  overflow: hidden;
  font-size: 16px;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.035em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.market-stat strong em {
  font-style: normal;
}

.market-stat strong b {
  color: #4e5966;
  font-size: 11px;
}

.market-stat small {
  display: block;
  margin-top: 5px;
  overflow: hidden;
  color: #626d79;
  font-size: 8px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.market-stat small.is-up { color: var(--green); }
.market-stat small.is-down { color: var(--red); }
.market-stat small.is-flat { color: var(--muted); }

.filters {
  gap: 6px;
  margin: 0 -13px 11px;
  padding: 0 13px;
}

.filter-chip {
  min-height: 31px;
  padding: 0 11px;
  border-radius: 8px;
  border-color: #25303b;
  background: #0d1218;
  color: #818c99;
  font-size: 10px;
  font-weight: 720;
}

.filter-chip.is-active {
  border-color: #d9e0e8;
  background: #dfe5ec;
  color: #0b1016;
}

.market-columns {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 76px 94px;
  gap: 8px;
  padding: 0 11px 7px;
  color: #56616d;
  font-size: 8px;
  font-weight: 750;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.market-columns span:nth-child(2),
.market-columns span:nth-child(3) {
  text-align: right;
}

.asset-list.terminal-list {
  display: block;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #0c1117;
}

.asset-card {
  grid-template-columns: 38px minmax(0, 1fr) 76px 94px;
  gap: 9px;
  min-height: 68px;
  padding: 10px;
  border: 0;
  border-bottom: 1px solid #1d2530;
  border-radius: 0;
  background: transparent;
}

.asset-card:last-child {
  border-bottom: 0;
}

.asset-card::after {
  display: none;
}

.asset-card:active {
  border-color: #1d2530;
  background: #121923;
  transform: none;
}

.asset-icon {
  width: 38px;
  height: 38px;
  border-radius: 9px;
  font-size: 19px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.2);
}

.asset-meta {
  gap: 6px;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 9px;
  letter-spacing: 0.045em;
}

.asset-symbol {
  color: #edf2f7;
  font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
  font-size: 11px;
}

.asset-kind {
  padding: 2px 4px;
  border: 1px solid #293440;
  border-radius: 4px;
  color: #64707c;
  font-size: 7px;
}

.asset-copy h2 {
  font-size: 11px;
  font-weight: 600;
  line-height: 1.2;
  color: #a9b2bd;
  -webkit-line-clamp: 1;
}

.asset-spark {
  display: block;
  width: 76px;
  height: 31px;
}

.asset-spark svg {
  width: 100%;
  height: 100%;
}

.asset-spark.is-up { color: var(--green); }
.asset-spark.is-down { color: var(--red); }
.asset-spark.is-flat { color: #65717e; }

.asset-quote {
  min-width: 0;
}

.asset-quote strong {
  margin-bottom: 4px;
  font-size: 14px;
  letter-spacing: -0.025em;
}

.quote-change {
  font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
  font-size: 10px;
  font-weight: 720;
  font-variant-numeric: tabular-nums;
}

.quote-change.is-up { color: var(--green); }
.quote-change.is-down { color: var(--red); }
.quote-change.is-flat { color: var(--muted); }

.bottom-nav {
  min-height: calc(62px + var(--safe-bottom));
  padding-top: 5px;
  border-top-color: #202833;
  background: rgba(8, 11, 16, 0.95);
}

.nav-item {
  gap: 3px;
  color: #5e6976;
  font-size: 9px;
  font-weight: 680;
}

.nav-item svg {
  width: 21px;
  height: 21px;
}

.nav-item.is-active {
  color: #dfe5ec;
}

.nav-item.is-active svg {
  color: var(--orange);
}

.trade-sheet {
  max-height: min(92vh, var(--tg-viewport-stable-height, 92vh));
  padding: 9px max(14px, var(--safe-right)) calc(16px + var(--safe-bottom)) max(14px, var(--safe-left));
  border-color: #293340;
  border-radius: 20px 20px 0 0;
  background: #0b1016;
}

.sheet-handle {
  width: 34px;
  height: 3px;
  background: #303a46;
}

.sheet-close {
  top: 14px;
  right: max(14px, var(--safe-right));
  width: 30px;
  height: 30px;
  border-color: #29333f;
  background: #121923;
  font-size: 21px;
}

.trade-asset-head {
  gap: 10px;
  margin: 15px 40px 13px 0;
}

.trade-asset-head .asset-icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  font-size: 22px;
}

.trade-asset-head h2 {
  margin-top: 2px;
  overflow: hidden;
  color: #b8c1cb;
  font-size: 12px;
  font-weight: 620;
  line-height: 1.15;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.listing-status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: #6f7b88;
  font-size: 7px;
}

.trade-price-row {
  margin: 11px 0 8px;
}

.trade-price-label,
.metric-label {
  color: #65717e;
  font-size: 8px;
  letter-spacing: 0.09em;
}

.trade-price {
  font-size: 32px;
  letter-spacing: -0.045em;
}

.change {
  min-width: 60px;
  padding: 5px 7px;
  border-radius: 6px;
  font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
  font-size: 10px;
}

.chart-toolbar,
.order-ticket-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: #66717e;
  font-size: 8px;
  font-weight: 720;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.chart-toolbar b {
  padding: 4px 6px;
  border: 1px solid #26313c;
  border-radius: 5px;
  color: #919ca8;
  font-size: 7px;
}

.trade-chart {
  height: 128px;
  margin: 3px 0 8px;
  border: 1px solid #1f2833;
  border-radius: 8px;
  background:
    linear-gradient(to right, transparent calc(100% - 1px), rgba(255,255,255,.035) 1px),
    linear-gradient(to bottom, transparent calc(100% - 1px), rgba(255,255,255,.035) 1px);
  background-size: 25% 25%;
}

.trade-chart::before {
  display: none;
}

.trade-chart svg {
  inset: 9px 5px 6px;
  width: calc(100% - 10px);
  height: calc(100% - 15px);
}

.trade-summary {
  margin: 10px 0 13px;
  color: #909ba7;
  font-size: 11px;
  line-height: 1.35;
}

.trade-metrics {
  gap: 6px;
  margin-bottom: 15px;
}

.metric {
  padding: 9px;
  border-color: #202a35;
  border-radius: 8px;
  background: #0e141b;
}

.metric strong {
  font-size: 12px;
}

.order-ticket-label {
  margin-bottom: 7px;
}

.order-ticket-label small {
  color: #596573;
}

.trade-tabs {
  gap: 3px;
  padding: 3px;
  border: 1px solid #202a35;
  border-radius: 9px;
  background: #080c11;
}

.trade-tab {
  min-height: 37px;
  border-radius: 6px;
  font-size: 12px;
}

.trade-tab.is-active[data-side="buy"] {
  background: rgba(53, 208, 127, 0.16);
  color: var(--green);
}

.trade-tab.is-active[data-side="sell"] {
  background: rgba(255, 88, 111, 0.16);
  color: var(--red);
}

.order-row {
  margin: 12px 0 10px;
}

.quantity-block label {
  color: #65717e;
  font-size: 8px;
}

.quantity-control {
  grid-template-columns: 38px minmax(52px, 1fr) 38px;
  min-height: 43px;
  border-color: #28333f;
  border-radius: 8px;
  background: #101720;
}

.quantity-control input {
  font-size: 15px;
}

.order-total {
  min-width: 126px;
  padding-bottom: 5px;
}

.order-total strong {
  font-size: 18px;
}

.order-total small {
  font-size: 8px;
}

.primary-button {
  min-height: 48px;
  border-radius: 9px;
  font-size: 13px;
  font-weight: 820;
}

.primary-button.buy {
  background: var(--green);
}

.primary-button.sell {
  background: var(--red);
}

.trade-footnote {
  margin-top: 8px;
  color: #56616d;
  font-size: 8px;
}

.portfolio-hero,
.leaderboard-hero {
  padding: 1px 0 17px;
}

.portfolio-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 23px;
}

.account-mode {
  min-height: 24px;
  color: #74808d;
  font-size: 7px;
}

.portfolio-caption {
  color: #788390;
  font-size: 10px;
}

.portfolio-value {
  margin-top: 5px;
  font-size: clamp(38px, 11vw, 58px);
  letter-spacing: -0.055em;
}

.portfolio-delta {
  margin-top: 8px;
  font-size: 10px;
}

.summary-grid {
  gap: 7px;
  margin: 0 0 8px;
}

.summary-card {
  min-height: 80px;
  padding: 11px;
  border-radius: 10px;
  background: linear-gradient(145deg, #111720, #0d1218);
}

.summary-card span {
  margin-bottom: 10px;
  font-size: 9px;
}

.summary-card strong {
  display: block;
  font-size: 17px;
}

.summary-card small {
  display: block;
  margin-top: 5px;
  color: #626e7a;
  font-size: 8px;
}

.allocation-bar {
  height: 3px;
  margin: 3px 1px 23px;
  overflow: hidden;
  border-radius: 4px;
  background: var(--orange);
}

.allocation-bar i {
  display: block;
  height: 100%;
  background: #435264;
}

.section-title {
  margin-bottom: 8px;
}

.section-title h2 {
  font-size: 14px;
}

.section-title span {
  display: grid;
  place-items: center;
  min-width: 22px;
  height: 20px;
  border-radius: 5px;
  background: #151c25;
  color: #8b96a2;
  font-size: 9px;
}

.position-list,
.leader-list {
  gap: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: #0c1117;
}

.position,
.leader {
  min-height: 64px;
  padding: 9px 10px;
  border: 0;
  border-bottom: 1px solid #1d2530;
  border-radius: 0;
  background: transparent;
}

.position:last-child,
.leader:last-child {
  border-bottom: 0;
}

.position .asset-icon {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  font-size: 18px;
}

.position-copy strong,
.leader-copy strong,
.position-value strong,
.leader-value strong {
  font-size: 11px;
}

.position-copy span,
.leader-copy span,
.position-value span {
  font-size: 9px;
}

.leaderboard-hero p {
  max-width: 350px;
  margin-top: 9px;
  font-size: 10px;
}

.leader-rank {
  width: 31px;
  height: 31px;
  font-size: 10px;
}

.leader-avatar {
  width: 34px;
  height: 34px;
}

.empty-state {
  padding: 30px 20px;
  border: 0;
  border-radius: 10px;
}

.empty-state b {
  font-size: 14px;
}

.empty-state p {
  font-size: 10px;
}

.welcome {
  background: rgba(5, 8, 12, 0.94);
}

.welcome-card {
  border-color: #28333f;
  border-radius: 18px;
  background: #0d131a;
}

.welcome-card h1 {
  font-size: 36px;
}

.welcome-card p {
  color: #929daa;
  font-size: 12px;
}

.welcome-coin {
  width: 84px;
  height: 84px;
  margin: 21px auto 18px;
  border: 0;
  font-size: 50px;
  box-shadow: 0 0 0 6px #2a1713, 0 16px 35px rgba(255, 91, 53, 0.18);
}

.error-view {
  padding-top: 70px;
}

.error-view .error-mark {
  border-radius: 12px;
}

.skeleton-card {
  height: 68px;
  margin-bottom: 1px;
  border-radius: 0;
}

@media (max-width: 430px) {
  .market-overview {
    grid-template-columns: repeat(2, 1fr);
  }

  .market-stat-wide {
    grid-column: 1 / -1;
  }
}

@media (max-width: 365px) {
  .asset-card {
    grid-template-columns: 36px minmax(0, 1fr) 88px;
  }

  .asset-spark,
  .market-columns span:nth-child(2) {
    display: none;
  }

  .market-columns {
    grid-template-columns: minmax(0, 1fr) 88px;
  }

  .market-columns span:nth-child(3) {
    grid-column: 2;
  }
}

/* Editorial dashboard */
.admin-body {
  min-height: 100vh;
  padding-bottom: 50px;
}

.admin-topbar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 18px;
  min-height: 78px;
  padding: 16px max(20px, var(--safe-right)) 16px max(20px, var(--safe-left));
  border-bottom: 1px solid var(--line);
}

.admin-label {
  padding: 6px 9px;
  border: 1px solid #45454a;
  border-radius: 7px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 850;
  letter-spacing: 0.09em;
}

.text-button {
  justify-self: end;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
}

.admin-main {
  width: min(100% - 32px, 1160px);
  margin: 0 auto;
  padding-top: 38px;
}

.admin-login {
  width: min(100%, 430px);
  margin: 8vh auto 0;
  padding: 30px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--surface);
}

.admin-login h1,
.admin-heading h1 {
  margin: 0;
  font-size: clamp(40px, 7vw, 72px);
  font-weight: 950;
  line-height: 0.87;
  letter-spacing: -0.065em;
}

.admin-login p {
  margin: 20px 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.field {
  display: block;
}

.field > span {
  display: block;
  margin: 0 0 7px 2px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 780;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  min-height: 48px;
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: 12px;
  outline: 0;
  background: #101012;
  font-size: 14px;
  resize: vertical;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: #74747a;
}

.field input[type="color"] {
  padding: 5px;
}

.admin-login .primary-button {
  margin-top: 12px;
}

.form-error {
  margin: 11px 0 0 !important;
  color: var(--red) !important;
  font-size: 12px !important;
}

.admin-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 30px;
}

.outline-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0 15px;
  border: 1px solid #48484e;
  border-radius: 11px;
  color: var(--text);
  font-size: 12px;
  font-weight: 750;
  text-decoration: none;
}

.admin-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 20px;
}

.admin-stats article {
  min-height: 104px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
}

.admin-stats span {
  display: block;
  margin-bottom: 18px;
  color: var(--muted);
  font-size: 11px;
}

.admin-stats strong {
  font-size: 26px;
  letter-spacing: -0.05em;
  font-variant-numeric: tabular-nums;
}

.admin-grid {
  display: grid;
  grid-template-columns: minmax(340px, 0.8fr) minmax(420px, 1.2fr);
  gap: 20px;
  align-items: start;
}

.admin-panel {
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--surface);
}

.asset-form {
  display: grid;
  gap: 13px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.form-row-short {
  grid-template-columns: 0.6fr 1fr 0.8fr;
}

.admin-asset-list {
  display: grid;
  gap: 8px;
  max-height: 650px;
  overflow: auto;
}

.admin-asset {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto;
  gap: 11px;
  align-items: center;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: #101012;
}

.admin-asset.is-archived {
  opacity: 0.52;
}

.admin-asset .asset-icon {
  width: 44px;
  height: 44px;
  border-radius: 11px;
  font-size: 21px;
}

.admin-asset > div {
  min-width: 0;
}

.admin-asset > div > strong {
  display: block;
  overflow: hidden;
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-asset small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 10px;
}

.status-button {
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid #414147;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
}

@media (max-width: 800px) {
  .admin-main { padding-top: 24px; }
  .admin-heading { align-items: flex-start; flex-direction: column; }
  .admin-stats { grid-template-columns: repeat(2, 1fr); }
  .admin-grid { grid-template-columns: 1fr; }
  .admin-assets-panel { order: -1; }
}

@media (max-width: 480px) {
  .admin-topbar { grid-template-columns: 1fr auto; }
  .admin-label { display: none; }
  .form-row,
  .form-row-short { grid-template-columns: 1fr; }
  .admin-panel { padding: 16px; }
}
