:root {
  --bg: #000000;
  --panel: #0c0c0d;
  --panel-2: #131316;
  --line-soft: #1e1e22;
  --line-hard: #2a2a30;
  --ink: #ffffff;
  --ink-dim: #8a8a92;
  --ink-faint: #55555c;
  --up: #00d18f;       /* OKX-ish green */
  --down: #ff3b54;     /* OKX-ish red */
  --accent: #c8ff00;   /* sharp electric accent */
  --line: var(--up);   /* chart stroke, recolored by JS */
  --r: 6px;
}

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

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: "Space Grotesk", sans-serif;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  overflow-x: hidden;
  position: relative;
}

/* ---------- atmosphere ---------- */
.grain {
  position: fixed; inset: 0; z-index: 1; pointer-events: none; opacity: 0.05;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
.gridlines {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background-image:
    linear-gradient(to right, var(--line-soft) 1px, transparent 1px),
    linear-gradient(to bottom, var(--line-soft) 1px, transparent 1px);
  background-size: 64px 64px;
  -webkit-mask-image: radial-gradient(ellipse 90% 70% at 50% 0%, #000 35%, transparent 80%);
          mask-image: radial-gradient(ellipse 90% 70% at 50% 0%, #000 35%, transparent 80%);
  opacity: 0.6;
}

/* ---------- topbar ---------- */
.topbar {
  position: relative; z-index: 3;
  display: flex; align-items: center; justify-content: space-between;
  padding: 22px clamp(20px, 5vw, 64px);
  border-bottom: 1px solid var(--line-soft);
}
.brand { display: flex; align-items: center; gap: 14px; }
.mark {
  display: grid; grid-template-columns: 1fr 1fr; gap: 3px;
  width: 26px; height: 26px;
}
.mark i {
  display: block; background: var(--ink); border-radius: 2px;
  animation: blink 4s infinite steps(1);
}
.mark i:nth-child(1) { animation-delay: 0s; }
.mark i:nth-child(2) { animation-delay: .5s; background: var(--accent); }
.mark i:nth-child(3) { animation-delay: 1.5s; background: var(--accent); }
.mark i:nth-child(4) { animation-delay: 1s; }
@keyframes blink { 0%,85% { opacity: 1; } 92% { opacity: .25; } 100% { opacity: 1; } }

.brand-text { font-weight: 700; letter-spacing: 1px; font-size: 15px; }
.brand-text em { font-style: normal; color: var(--ink-dim); font-weight: 600; }

.live-dot {
  font-family: "IBM Plex Mono", monospace; font-size: 11px; letter-spacing: 1px;
  color: var(--ink-dim); display: inline-flex; align-items: center; gap: 8px;
}
.live-dot::before {
  content: ""; width: 7px; height: 7px; border-radius: 50%;
  background: var(--up); box-shadow: 0 0 10px var(--up);
  animation: pulse 1.8s infinite;
}
.live-dot.mock::before { background: var(--accent); box-shadow: 0 0 10px var(--accent); }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .3; } }

.sync {
  font-family: "IBM Plex Mono", monospace; font-size: 11px; letter-spacing: 1px;
  color: var(--ink-faint); margin-left: 14px; padding-left: 14px;
  border-left: 1px solid var(--line-soft);
}

/* ---------- live ticker (pinned to top) ---------- */
.ticker {
  position: sticky; top: 0; z-index: 30; overflow: hidden;
  border-bottom: 1px solid var(--line-soft); background: #050505;
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 6%, #000 94%, transparent);
          mask-image: linear-gradient(90deg, transparent, #000 6%, #000 94%, transparent);
}
.ticker-track {
  display: inline-flex; white-space: nowrap; padding: 11px 0;
  animation: marquee 48s linear infinite; will-change: transform;
}
.ticker:hover .ticker-track { animation-play-state: paused; }
@keyframes marquee { from { transform: translateX(0); } to { transform: translateX(-50%); } }
.tk {
  display: inline-flex; align-items: center; gap: 9px; padding: 0 26px;
  border-right: 1px solid var(--line-soft); font-family: "IBM Plex Mono", monospace;
}
.tk .tk-sym {
  width: 18px; height: 18px; border-radius: 50%; display: grid; place-items: center;
  font-size: 9px; font-weight: 700; color: #000;
}
.tk .tk-name { font-size: 12px; font-weight: 600; color: var(--ink-dim); letter-spacing: .5px; }
.tk .tk-price { font-size: 13px; font-weight: 600; color: var(--ink); transition: color .25s; }
.tk .tk-chg { font-size: 11px; font-weight: 600; }
.tk .tk-chg.up { color: var(--up); }
.tk .tk-chg.down { color: var(--down); }
.tk.flash .tk-price { animation: tkflash .6s; }
@keyframes tkflash { 0% { color: var(--accent); transform: scale(1.06); } 100% { color: var(--ink); transform: none; } }

/* ---------- icons (real img + graceful letter fallback) ---------- */
.ic {
  position: relative; flex-shrink: 0; border-radius: 50%; overflow: hidden;
  display: grid; place-items: center; background: var(--c);
}
.ic .ic-l { font-weight: 700; color: #000; line-height: 1; font-size: .5em; }
.ic img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.ic.logo:not(.broken) { background: #fff; }
.ic.logo img { object-fit: contain; padding: 16%; }
.ic.broken img { display: none; }
/* fallback badge (no icon / failed load): readable colored letter on a dark chip */
.ic.badge, .ic.broken { background: #15151a; box-shadow: inset 0 0 0 1.5px var(--c); }
.ic.badge .ic-l, .ic.broken .ic-l { color: var(--c); }
.asset-btn .ic { width: 30px; height: 30px; font-size: 26px; }
.bar-id .ic { width: 28px; height: 28px; font-size: 24px; }
.tk .ic { width: 18px; height: 18px; font-size: 18px; }

/* ---------- layout ---------- */
.wrap {
  position: relative; z-index: 2;
  max-width: 1180px; margin: 0 auto;
  padding: clamp(40px, 7vw, 90px) clamp(20px, 5vw, 64px) 40px;
}

/* ---------- hero ---------- */
.hero { margin-bottom: clamp(40px, 6vw, 70px); }
.kicker {
  font-family: "IBM Plex Mono", monospace; font-size: 12px; letter-spacing: 4px;
  color: var(--ink-dim); margin-bottom: 22px;
  opacity: 0; animation: rise .7s .05s forwards;
}
.headline {
  font-weight: 700; letter-spacing: -2px; line-height: 0.94;
  font-size: clamp(44px, 8.5vw, 104px);
  text-transform: uppercase;
}
.headline .accent { color: var(--accent); }
.headline .amt {
  font-family: "IBM Plex Mono", monospace; font-weight: 700;
  background: var(--ink); color: #000; padding: 0 .12em; letter-spacing: -2px;
  display: inline-block;
}
.headline .asset { color: var(--up); }
.headline span, .headline br { opacity: 0; animation: rise .7s forwards; }
.headline { display: block; }
.headline .accent { animation-delay: .12s; }
.headline .amt { animation-delay: .18s; }
.headline .asset { animation-delay: .26s; }
.sub {
  margin-top: 26px; color: var(--ink-dim); font-size: clamp(15px, 1.6vw, 18px);
  max-width: 540px; opacity: 0; animation: rise .7s .34s forwards;
}
@keyframes rise { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: none; } }

/* ---------- console ---------- */
.console {
  display: grid; grid-template-columns: minmax(300px, 380px) 1fr; gap: 18px;
  opacity: 0; animation: rise .8s .42s forwards;
}
.panel {
  background: var(--panel);
  border: 1px solid var(--line-hard);
  border-radius: var(--r);
  padding: clamp(20px, 3vw, 30px);
}

/* controls */
.field { margin-bottom: 26px; }
.field:last-of-type { margin-bottom: 28px; }
.field > label {
  display: block; font-family: "IBM Plex Mono", monospace; font-size: 11px;
  letter-spacing: 2px; color: var(--ink-faint); margin-bottom: 12px;
}

.money-input {
  display: flex; align-items: center; gap: 4px;
  background: var(--bg); border: 1px solid var(--line-hard); border-radius: var(--r);
  padding: 14px 18px; transition: border-color .2s;
}
.money-input:focus-within { border-color: var(--accent); }
.money-input .ccy { font-family: "IBM Plex Mono", monospace; font-size: 26px; color: var(--ink-dim); }
.money-input input {
  flex: 1; background: none; border: none; outline: none; color: var(--ink);
  font-family: "IBM Plex Mono", monospace; font-weight: 600; font-size: 30px;
  width: 100%; letter-spacing: -1px;
}

.chips { display: flex; gap: 8px; margin-top: 12px; }
.chips button {
  flex: 1; background: var(--panel-2); border: 1px solid var(--line-hard);
  color: var(--ink-dim); border-radius: var(--r); padding: 9px 0;
  font-family: "IBM Plex Mono", monospace; font-size: 12px; cursor: pointer;
  transition: all .15s;
}
.chips button:hover { color: var(--ink); border-color: var(--ink-faint); }
.chips button.on { background: var(--ink); color: #000; border-color: var(--ink); }

.asset-stack { display: flex; flex-direction: column; gap: 8px; }
.asset-group-label {
  font-family: "IBM Plex Mono", monospace; font-size: 10px; letter-spacing: 1.5px;
  color: var(--ink-faint); margin: 6px 0 2px; display: flex; align-items: center; gap: 8px;
}
.asset-group-label::after { content: ""; flex: 1; height: 1px; background: var(--line-soft); }
.asset-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.asset-btn {
  display: flex; align-items: center; gap: 10px;
  background: var(--panel-2); border: 1px solid var(--line-hard); border-radius: var(--r);
  padding: 11px 12px; cursor: pointer; transition: all .15s; text-align: left;
}
.asset-btn:hover { border-color: var(--ink-faint); transform: translateY(-1px); }
.asset-btn.on { border-color: var(--accent); background: #16170c; }
.asset-btn .sym {
  width: 30px; height: 30px; border-radius: 50%; flex-shrink: 0;
  display: grid; place-items: center; font-weight: 700; font-size: 13px; color: #000;
}
.asset-btn .meta { display: flex; flex-direction: column; line-height: 1.15; overflow: hidden; }
.asset-btn .meta b { font-size: 13px; font-weight: 700; color: var(--ink); }
.asset-btn .meta small { font-size: 10px; color: var(--ink-faint); font-family: "IBM Plex Mono", monospace; }

.seg {
  display: grid; grid-template-columns: repeat(7, 1fr); gap: 0;
  border: 1px solid var(--line-hard); border-radius: var(--r); overflow: hidden;
}
.seg button {
  background: var(--panel-2); border: none; border-right: 1px solid var(--line-hard);
  color: var(--ink-dim); padding: 12px 0; cursor: pointer;
  font-family: "IBM Plex Mono", monospace; font-size: 13px; font-weight: 500; transition: all .15s;
}
.seg button:last-child { border-right: none; }
.seg button:hover { color: var(--ink); }
.seg button.on { background: var(--ink); color: #000; }
@media (max-width: 420px) { .seg button { font-size: 12px; padding: 11px 0; } }

.run {
  width: 100%; display: flex; align-items: center; justify-content: center; gap: 10px;
  background: var(--accent); color: #000; border: none; border-radius: var(--r);
  padding: 17px; font-family: "Space Grotesk", sans-serif; font-weight: 700; font-size: 14px;
  letter-spacing: 1.5px; cursor: pointer; transition: transform .12s, box-shadow .2s;
}
.run:hover { transform: translateY(-2px); box-shadow: 0 10px 30px -8px rgba(200,255,0,.5); }
.run:active { transform: translateY(0); }
.run.loading { pointer-events: none; opacity: .7; }
.run.loading span::after {
  content: "..."; display: inline-block; width: 1.2em; text-align: left;
  animation: dots 1s infinite steps(4);
}
@keyframes dots { 0%{content:"";} 25%{content:".";} 50%{content:"..";} 75%{content:"...";} }

/* result */
.result { display: flex; flex-direction: column; }
.result-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.r-label { font-family: "IBM Plex Mono", monospace; font-size: 11px; letter-spacing: 2px; color: var(--ink-faint); }
.r-value {
  font-family: "IBM Plex Mono", monospace; font-weight: 700; letter-spacing: -2px;
  font-size: clamp(40px, 6.5vw, 72px); margin-top: 6px; line-height: 1;
}
.r-badge {
  font-family: "IBM Plex Mono", monospace; font-weight: 700; font-size: 15px;
  padding: 8px 14px; border-radius: var(--r); white-space: nowrap;
  background: var(--panel-2); color: var(--ink-dim); border: 1px solid var(--line-hard);
}
.r-badge.up { color: var(--up); border-color: rgba(0,209,143,.4); background: rgba(0,209,143,.08); }
.r-badge.down { color: var(--down); border-color: rgba(255,59,84,.4); background: rgba(255,59,84,.08); }

.chart-shell { position: relative; margin: 24px 0 8px; height: 200px; cursor: crosshair; }
#chart { width: 100%; height: 100%; display: block; }
#chartLine { transition: stroke .3s; }
.chart-empty {
  position: absolute; inset: 0; display: grid; place-items: center;
  color: var(--ink-faint); font-family: "IBM Plex Mono", monospace; font-size: 13px;
  border: 1px dashed var(--line-hard); border-radius: var(--r);
}
.chart-shell.has-data .chart-empty { display: none; }

/* hover crosshair + dot + tooltip */
.crosshair {
  position: absolute; top: 0; bottom: 0; width: 1px; background: var(--line-hard);
  transform: translateX(-0.5px); opacity: 0; pointer-events: none; transition: opacity .12s;
}
.hover-dot {
  position: absolute; width: 11px; height: 11px; border-radius: 50%;
  background: var(--line); border: 2px solid var(--bg); box-shadow: 0 0 0 1px var(--line);
  transform: translate(-50%, -50%); opacity: 0; pointer-events: none; transition: opacity .12s;
}
.chart-tip {
  position: absolute; pointer-events: none; opacity: 0; transition: opacity .12s;
  transform: translate(-50%, -100%); margin-top: -14px; z-index: 5;
  background: #000; border: 1px solid var(--line-hard); border-radius: var(--r);
  padding: 9px 11px; white-space: nowrap; box-shadow: 0 8px 24px -8px #000;
}
.chart-tip .tip-date { font-family: "IBM Plex Mono", monospace; font-size: 10px; letter-spacing: .5px; color: var(--ink-faint); margin-bottom: 4px; }
.chart-tip .tip-price { font-family: "IBM Plex Mono", monospace; font-size: 14px; font-weight: 600; color: var(--ink); }
.chart-tip .tip-val { font-family: "IBM Plex Mono", monospace; font-size: 11px; margin-top: 3px; }
.chart-tip .tip-val.up { color: var(--up); }
.chart-tip .tip-val.down { color: var(--down); }
.chart-tip.below { transform: translate(-50%, 0); margin-top: 14px; }
.chart-shell.show-hover .crosshair,
.chart-shell.show-hover .hover-dot,
.chart-shell.show-hover .chart-tip { opacity: 1; }

.chart-axis {
  display: flex; justify-content: space-between; margin: 0 6px 16px;
  font-family: "IBM Plex Mono", monospace; font-size: 10px; color: var(--ink-faint); letter-spacing: .5px;
}
.chart-axis span { transform: translateX(-50%); white-space: nowrap; }
.chart-axis span:first-child { transform: none; }
.chart-axis span:last-child { transform: translateX(0); }
.chart-axis:empty { display: none; }

/* draw animation */
#chartLine.draw { stroke-dasharray: var(--len); stroke-dashoffset: var(--len); animation: draw 1.1s ease-out forwards; }
#chartFill.draw { opacity: 0; animation: fadein .8s .5s forwards; }
@keyframes draw { to { stroke-dashoffset: 0; } }
@keyframes fadein { to { opacity: 1; } }

.stats {
  display: grid; grid-template-columns: repeat(3, 1fr);
  border: 1px solid var(--line-hard); border-radius: var(--r); overflow: hidden;
}
.stat {
  padding: 16px; border-right: 1px solid var(--line-hard); border-bottom: 1px solid var(--line-hard);
  background: var(--panel-2);
}
.stat:nth-child(3n) { border-right: none; }
.stat:nth-child(n+4) { border-bottom: none; }
.s-label { display: block; font-family: "IBM Plex Mono", monospace; font-size: 10px; letter-spacing: 1px; color: var(--ink-faint); margin-bottom: 7px; }
.s-val { font-family: "IBM Plex Mono", monospace; font-weight: 600; font-size: clamp(15px, 1.7vw, 19px); letter-spacing: -.5px; }
.s-val.up { color: var(--up); }
.s-val.down { color: var(--down); }

.verdict {
  margin-top: 22px; padding: 16px 18px; border-left: 3px solid var(--accent);
  background: var(--panel-2); color: var(--ink-dim); font-size: 14px; line-height: 1.6;
  border-radius: 0 var(--r) var(--r) 0;
}
.verdict b { color: var(--ink); }
.verdict .pos { color: var(--up); }
.verdict .neg { color: var(--down); }

/* count-up flash */
.r-value.flash { animation: flash .5s; }
@keyframes flash { 0% { opacity: .3; } 100% { opacity: 1; } }

/* ---------- share ---------- */
.share-btn {
  margin-top: 18px; width: 100%; display: flex; align-items: center; justify-content: center; gap: 9px;
  background: transparent; color: var(--ink); border: 1px solid var(--line-hard); border-radius: var(--r);
  padding: 14px; font-family: "Space Grotesk", sans-serif; font-weight: 700; font-size: 13px; letter-spacing: 1.5px;
  cursor: pointer; transition: all .15s;
}
.share-btn:hover { border-color: var(--accent); color: var(--accent); }

.share-overlay {
  position: fixed; inset: 0; z-index: 100; display: grid; place-items: center;
  background: rgba(0,0,0,.78); backdrop-filter: blur(6px); padding: 20px;
  animation: fadein .25s;
}
.share-overlay[hidden] { display: none; }
.share-box {
  background: var(--panel); border: 1px solid var(--line-hard); border-radius: 10px;
  padding: 18px; max-width: 640px; width: 100%;
}
.share-canvas-wrap { border-radius: var(--r); overflow: hidden; border: 1px solid var(--line-soft); }
#shareCanvas { display: block; width: 100%; height: auto; }
.share-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.sa {
  flex: 1; min-width: 110px; padding: 13px; border-radius: var(--r); cursor: pointer;
  font-family: "IBM Plex Mono", monospace; font-size: 12px; font-weight: 600; letter-spacing: .5px;
  background: var(--panel-2); color: var(--ink); border: 1px solid var(--line-hard); transition: all .15s;
}
.sa:hover { border-color: var(--ink-faint); }
.sa.primary { background: var(--accent); color: #000; border-color: var(--accent); }
.sa.primary:hover { filter: brightness(1.08); }
.sa.ghost { flex: 0 0 auto; min-width: 80px; color: var(--ink-dim); }
.share-hint { margin-top: 12px; text-align: center; font-family: "IBM Plex Mono", monospace; font-size: 11px; color: var(--ink-faint); }

/* ---------- comparison leaderboard ---------- */
.compare {
  margin-top: 50px; opacity: 0; animation: rise .8s .5s forwards;
}
.compare-head {
  display: flex; align-items: flex-end; justify-content: space-between; flex-wrap: wrap;
  gap: 14px; margin-bottom: 26px;
}
.compare-title {
  font-weight: 700; letter-spacing: -1px; text-transform: uppercase;
  font-size: clamp(24px, 3.6vw, 40px); line-height: 1; margin-top: 10px;
}
.compare-title span {
  font-family: "IBM Plex Mono", monospace; background: var(--accent); color: #000; padding: 0 .14em;
}
.compare-cap {
  font-family: "IBM Plex Mono", monospace; font-size: 12px; letter-spacing: 1px; color: var(--ink-dim);
}

.bars { display: flex; flex-direction: column; gap: 2px; }
.bar-row {
  display: grid; grid-template-columns: 30px 190px 1fr auto; align-items: center; gap: 16px;
  padding: 14px 16px; border: 1px solid transparent; border-radius: var(--r);
  background: var(--panel); transition: all .2s;
  opacity: 0; transform: translateX(-12px); animation: barIn .5s forwards;
}
@keyframes barIn { to { opacity: 1; transform: none; } }
.bar-row:hover { background: var(--panel-2); }
.bar-row.sel { border-color: var(--accent); background: #14150b; }
.bar-rank { font-family: "IBM Plex Mono", monospace; font-size: 15px; font-weight: 700; color: var(--ink-faint); }
.bar-row.sel .bar-rank { color: var(--accent); }
.bar-id { display: flex; align-items: center; gap: 10px; min-width: 0; }
.bar-id .sym {
  width: 28px; height: 28px; border-radius: 50%; flex-shrink: 0;
  display: grid; place-items: center; font-weight: 700; font-size: 12px; color: #000;
}
.bar-id .nm { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.bar-id .nm b { font-size: 14px; font-weight: 700; white-space: nowrap; }
.bar-id .nm small { font-size: 10px; color: var(--ink-faint); font-family: "IBM Plex Mono", monospace; }
.bar-track { height: 10px; background: var(--panel-2); border-radius: 3px; overflow: hidden; }
.bar-fill {
  height: 100%; width: 0; border-radius: 3px; transition: width 1s cubic-bezier(.2,.8,.2,1);
}
.bar-fill.up { background: linear-gradient(90deg, rgba(0,209,143,.4), var(--up)); }
.bar-fill.down { background: linear-gradient(90deg, rgba(255,59,84,.4), var(--down)); }
.bar-num { text-align: right; min-width: 140px; }
.bar-num .v { font-family: "IBM Plex Mono", monospace; font-weight: 700; font-size: 17px; letter-spacing: -.5px; }
.bar-num .p { font-family: "IBM Plex Mono", monospace; font-size: 12px; display: block; margin-top: 2px; }
.bar-num .p.up { color: var(--up); }
.bar-num .p.down { color: var(--down); }
.bar-skeleton { padding: 14px 16px; color: var(--ink-faint); font-family: "IBM Plex Mono", monospace; font-size: 13px; }

@media (max-width: 640px) {
  .bar-row { grid-template-columns: 22px 1fr auto; gap: 10px; }
  .bar-track { display: none; }
  .bar-num { min-width: 0; }
}

/* ---------- foot ---------- */
.foot {
  margin-top: 50px; padding-top: 22px; border-top: 1px solid var(--line-soft);
  display: flex; justify-content: space-between; flex-wrap: wrap; gap: 10px;
  font-family: "IBM Plex Mono", monospace; font-size: 11px; color: var(--ink-faint); letter-spacing: 1px;
}

/* ---------- responsive ---------- */
@media (max-width: 860px) {
  .console { grid-template-columns: 1fr; }
}
@media (max-width: 480px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .stat:nth-child(3n) { border-right: 1px solid var(--line-hard); }
  .stat:nth-child(2n) { border-right: none; }
  .stat:nth-child(n+4) { border-bottom: 1px solid var(--line-hard); }
  .stat:nth-child(n+5) { border-bottom: none; }
}
