:root {
  --bg: #0b0b0c;
  --card: #121214;
  --fg: #f2f2f0;
  --dim: #77777a;
  --line: #222226;
  --up: #3ddc84;
  --down: #ff5c5c;
  --accent: #f7931a;
  --blue: #6ea8fe;
  --violet: #b48cff;
}
@media (prefers-color-scheme: light) {
  :root { --bg: #f4f3ef; --card: #fff; --fg: #141414; --dim: #8a8983; --line: #e6e4dc; }
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--fg);
  font: 14px/1.4 ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  font-variant-numeric: tabular-nums; /* digits keep equal width, so numbers do not jitter */
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
small { color: var(--dim); font-size: 11px; letter-spacing: 0; text-transform: none; margin-left: 4px; }

header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 18px clamp(16px, 2vw, 32px) 6px;
}
.brand { font-size: 20px; font-weight: 700; letter-spacing: -.02em; }
.brand b { color: var(--accent); }
.feeds { display: flex; gap: 16px; color: var(--dim); font-size: 12px; }
.feeds i {
  display: inline-block; width: 7px; height: 7px; border-radius: 50%;
  background: var(--dim); margin-right: 6px; vertical-align: 1px;
}
#fullscreen, #edit, .link {
  font: inherit; color: var(--dim); background: none; border: 0; cursor: pointer;
}
#fullscreen, #edit { font-size: 15px; line-height: 1; }
#edit.on { color: var(--accent); }
#currency, .pill-select {
  font: inherit; font-size: 12px; color: var(--fg); background: var(--card);
  border: 1px solid var(--line); border-radius: 8px; padding: 3px 6px; cursor: pointer;
}
#fullscreen:hover, #edit:hover, .link:hover { color: var(--fg); }
.link { font-size: 11px; text-decoration: underline; }
.feeds i.live { background: var(--up); box-shadow: 0 0 8px var(--up); }

main { padding: 10px clamp(16px, 2vw, 32px) 24px; }
.grid {
  display: grid; gap: 14px; margin-top: 14px;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  grid-auto-flow: dense; /* fill gaps left by wide cards */
}
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  padding: 18px; display: flex; flex-direction: column; gap: 6px; min-width: 0; position: relative;
}
.card.wide { grid-column: span 2; }
@media (max-width: 680px) { .card.wide { grid-column: auto; } }

.label { color: var(--dim); font-size: 11px; letter-spacing: .14em; text-transform: uppercase; }
.label.sm { margin-top: 12px; }
.big { font-size: 30px; font-weight: 600; letter-spacing: -.02em; }
.mid { font-size: 18px; font-weight: 500; }
.sub { color: var(--dim); font-size: 13px; }
.src { color: var(--dim); font-size: 11px; margin-top: auto; padding-top: 10px; opacity: .8; }
.row { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; }
.right { text-align: right; }
.up { color: var(--up); }
.down { color: var(--down); }
.dim { color: var(--dim); }

.kv, .fees { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 10px; color: var(--dim); font-size: 11px; }
.fees { grid-template-columns: repeat(4, 1fr); margin-top: 4px; }
.kv span, .fees span { display: block; color: var(--fg); font-size: 14px; margin-top: 2px; white-space: nowrap; }
.fees span { font-size: 22px; font-weight: 600; }

.bar { height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; margin-top: 10px; }
.bar i { display: block; height: 100%; width: 0; background: var(--accent); border-radius: 3px; transition: width .6s ease; }

/* Price hero */
.hero { gap: 10px; }
.hero-top { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 20px; align-items: flex-end; }
#price {
  font-size: clamp(44px, 9vw, 92px); font-weight: 600; letter-spacing: -.03em; line-height: 1.05;
  transition: color .6s ease;
}
#price.tick-up { color: var(--up); transition: none; }
#price.tick-down { color: var(--down); transition: none; }
#change { font-size: 17px; font-weight: 500; }
.hero-stats { display: grid; grid-template-columns: repeat(5, auto); gap: 6px 28px; color: var(--dim); font-size: 11px; }
.hero-stats span { display: block; color: var(--fg); font-size: 16px; margin-top: 2px; }
.hero-stats span.lbl { display: inline; color: inherit; font-size: inherit; margin: 0; }
.hero-stats span.lbl + span { display: block; }
@media (max-width: 680px) { .hero-stats { grid-template-columns: repeat(2, 1fr); width: 100%; } }

.tabs { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.toggles { display: flex; flex-wrap: wrap; gap: 4px; margin-left: auto; align-items: center; }
.pill-select { font-size: 11px; padding: 3px 4px; }
.tabs button {
  font: inherit; font-size: 12px; color: var(--dim); background: none; cursor: pointer;
  border: 1px solid transparent; border-radius: 8px; padding: 4px 10px;
}
.tabs button:hover { color: var(--fg); }
.tabs button.on { color: var(--fg); border-color: var(--line); background: var(--bg); }
.tabs .toggle.on { color: var(--accent); }

/* Indicator panels under the price chart */
.panel { border-top: 1px solid var(--line); margin-top: 4px; padding-top: 4px; }
.panel-label { color: var(--dim); font-size: 10px; letter-spacing: .1em; text-transform: uppercase; }
.panel-label b { color: var(--fg); font-weight: 500; letter-spacing: 0; margin-left: 4px; }
.panel .chart { margin-top: 0; }
[hidden] { display: none !important; }

/* Trades tape */
.trades { list-style: none; display: grid; margin-top: 8px; font-size: 12px; }
.trades li { display: grid; grid-template-columns: 64px 1fr auto; gap: 8px; padding: 3px 0; color: var(--dim); }
.trades li b { font-weight: 500; }
.trades li.big b, .trades li.big span:last-child { font-weight: 700; color: var(--fg); }
.trades li.new { animation: flash 1.2s ease; }
.trades span:last-child { text-align: right; }

/* Charts */
.chart { position: relative; width: 100%; margin-top: 8px; touch-action: pan-y; }
.chart svg { display: block; overflow: visible; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .ref { stroke: var(--dim); stroke-width: 1; stroke-dasharray: 3 4; opacity: .7; }
.chart .band { opacity: .12; }
.chart .tick { fill: var(--dim); font-size: 10px; }
.chart .cursor { stroke: var(--dim); stroke-width: 1; }
.chart-tip {
  position: absolute; top: 0; pointer-events: none; opacity: 0; transition: opacity .1s;
  background: var(--card); border: 1px solid var(--line); border-radius: 8px;
  padding: 6px 9px; font-size: 11px; color: var(--dim); white-space: nowrap; z-index: 2;
  box-shadow: 0 4px 16px rgba(0,0,0,.25);
}
.chart-tip b { color: var(--fg); font-weight: 600; }
.chart-tip i { display: inline-block; width: 8px; height: 2px; vertical-align: 3px; margin-right: 4px; }

/* Blocks */
.blocks { list-style: none; margin-top: 10px; display: grid; gap: 2px; }
.blocks li {
  display: grid; grid-template-columns: 70px 1fr auto; gap: 8px; align-items: baseline;
  padding: 6px 0; border-top: 1px solid var(--line); font-size: 12px; color: var(--dim);
}
.blocks li b { color: var(--fg); font-weight: 500; }
.blocks li span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.blocks li.new { animation: flash 1.6s ease; }
@keyframes flash { from { background: color-mix(in srgb, var(--accent) 25%, transparent); } to { background: transparent; } }

/* Projected mempool blocks, drawn as little cubes */
.mblocks { display: flex; gap: 8px; margin-top: 6px; }
.mblocks div {
  flex: 1; min-width: 0; min-height: 78px; border-radius: 8px; padding: 8px; font-size: 10px;
  display: flex; flex-direction: column; justify-content: space-between; white-space: nowrap; overflow: hidden;
  background: linear-gradient(160deg, color-mix(in srgb, var(--accent) 70%, transparent), color-mix(in srgb, var(--accent) 25%, transparent));
  color: #fff;
}
.mblocks b { font-size: 14px; }

/* Horizontal bars */
.hbars { list-style: none; display: grid; gap: 7px; margin-top: 8px; }
.hbars li { display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; font-size: 12px; }
.hbars li span { color: var(--dim); }
.hbars li i { grid-column: 1 / -1; height: 4px; border-radius: 2px; background: var(--accent); opacity: .85; }

/* Stacked bar and legend */
.stack { display: flex; height: 10px; border-radius: 5px; overflow: hidden; margin-top: 12px; gap: 2px; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 11px; color: var(--dim); margin-top: 6px; }
.legend i { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 5px; }

/* Fear and Greed gauge: a gradient strip with a marker */
.gauge {
  position: relative; height: 8px; border-radius: 4px; margin: 12px 0 4px;
  background: linear-gradient(90deg, #ff5c5c, #f7931a 35%, #e8d44d 50%, #9bd65a 65%, #3ddc84);
}
.gauge i {
  position: absolute; top: -4px; width: 4px; height: 16px; border-radius: 2px;
  background: var(--fg); transform: translateX(-50%); transition: left .6s ease; left: 50%;
}

/* Whales */
.whales { list-style: none; display: grid; margin-top: 8px; }
.whales li {
  display: grid; grid-template-columns: 1fr auto; gap: 0 8px; padding: 7px 0;
  border-top: 1px solid var(--line); font-size: 12px;
}
.whales li:first-child { border-top: 0; }
.whales a { text-decoration: none; font-weight: 600; }
.whales span { color: var(--dim); }
.whales li.new { animation: flash 1.6s ease; }

/* My stack */
.stack-input {
  display: flex; align-items: center; gap: 8px; margin-top: 10px;
  border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; background: var(--bg);
}
.stack-input input {
  flex: 1; min-width: 0; font: inherit; font-size: 16px; color: var(--fg);
  background: none; border: 0; outline: none; font-variant-numeric: tabular-nums;
}
.stack-input span { color: var(--dim); font-size: 12px; }
.blurred { filter: blur(9px); user-select: none; }

/* Headline ticker: the track holds the items twice and slides by half its width, so the loop is seamless. */
.ticker {
  position: relative; overflow: hidden; margin-bottom: 14px; padding: 8px 0;
  border: 1px solid var(--line); border-radius: 10px; background: var(--card); font-size: 12px;
  mask-image: linear-gradient(90deg, transparent, #000 4%, #000 96%, transparent);
}
.ticker.off-until-data { display: none; }
.ticker-track { display: inline-flex; gap: 14px; white-space: nowrap; animation: ticker 120s linear infinite; padding-left: 14px; }
.ticker:hover .ticker-track { animation-play-state: paused; }
.ticker a { text-decoration: none; color: var(--fg); }
.ticker a:hover { color: var(--accent); }
.ticker a b { color: var(--accent); font-weight: 600; margin-right: 6px; }
.ticker a em { color: var(--dim); font-style: normal; margin-left: 6px; }
.ticker i { color: var(--dim); font-style: normal; }
@keyframes ticker { to { transform: translateX(-50%); } }
@media (prefers-reduced-motion: reduce) {
  .ticker { overflow-x: auto; mask-image: none; }
  .ticker-track { animation: none; }
}

/* News list */
.news-tabs { margin-top: 0; }
.news-tabs button { padding: 2px 7px; font-size: 11px; }
.news { list-style: none; display: grid; margin-top: 4px; }
.news li { padding: 7px 0; border-top: 1px solid var(--line); font-size: 13px; line-height: 1.35; }
.news li:first-child { border-top: 0; }
.news a {
  text-decoration: none; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.news a:hover { color: var(--accent); }
.news span { display: block; color: var(--dim); font-size: 11px; margin-top: 2px; }
.news .soon { color: var(--accent); }

/* Layout editing (layout.js) */
.card.off { display: none; }
.card-tools, .corner, #edit-bar { display: none; }
body.editing { user-select: none; -webkit-user-select: none; }
body.editing .card { outline: 1px dashed color-mix(in srgb, var(--dim) 50%, transparent); outline-offset: -1px; }
body.editing .grid > .card { padding-top: 40px; } /* room for the tools, so they cover nothing */
body.editing .card.off { display: flex; opacity: .35; }
.ticker.off { display: none; }
body.editing .ticker.off { display: block; opacity: .35; }
body.editing .ticker { outline: 1px dashed color-mix(in srgb, var(--dim) 50%, transparent); padding-right: 70px; }
body.editing .ticker .card-tools { top: 4px; }
body.editing .card.dragging, body.editing .card.resizing { outline: 2px solid var(--accent); }
body.editing .card.dragging { opacity: .8; }
body.editing .card-tools { display: flex; gap: 4px; position: absolute; top: 8px; right: 8px; z-index: 3; }
.card-tools button, #edit-bar button {
  font: inherit; font-size: 11px; color: var(--fg); background: var(--bg); cursor: pointer;
  border: 1px solid var(--line); border-radius: 6px; padding: 3px 9px;
}
.card-tools .grip { cursor: grab; touch-action: none; font-size: 14px; line-height: 1; padding: 2px 8px; }
body.editing .corner {
  display: block; position: absolute; right: 3px; bottom: 3px; width: 20px; height: 20px; z-index: 3;
  cursor: nwse-resize; touch-action: none; border-radius: 0 0 12px 0;
  background: linear-gradient(135deg, transparent 45%, var(--accent) 45% 52%, transparent 52% 64%, var(--accent) 64% 71%, transparent 71%);
}
body.editing #edit-bar {
  display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap;
  position: sticky; top: 8px; z-index: 5; margin-bottom: 14px; padding: 10px 14px; font-size: 12px; color: var(--dim);
  background: var(--card); border: 1px solid var(--accent); border-radius: 12px; box-shadow: 0 6px 24px rgba(0,0,0,.35);
}
#edit-bar b { color: var(--fg); }
#edit-bar button.on { color: var(--bg); background: var(--accent); border-color: var(--accent); }

footer {
  padding: 8px clamp(16px, 2vw, 32px) 32px;
  color: var(--dim); font-size: 11px; text-align: center;
}

/* Phones: drop the clock so the header fits on one line. */
@media (max-width: 480px) {
  #clock { display: none; }
  .feeds { gap: 10px; }
  .tabs button { padding: 4px 5px; font-size: 11px; }
  .tabs, .toggles { gap: 2px; }
}
