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

:root {
  --bg: #0b0e11;
  --bar: #12161b;
  --border: #1f262e;
  --text: #e8edf2;
  --muted: #7d8896;
  --green: #2bd975;
  --red: #ff4d4d;
  --accent: #2bd975;
  --panel-bg: #0e1216;
  --card-bg: #10151a;
  --cell-bg: #0d1116;
  --hover-bg: #1a2027;
  --gold: #ffd03c;
  /* M1/M3: total fixed-bar height reserved at the bottom of the viewport, read
     by both #stage (bubble canvas) and .cookie-banner so neither ever sits
     under #bottombar/#adSlot/#scrubberBar. Default = #bottombar alone (46px);
     body.cb-strip widens it for the ad strip, body.replay-open widens it for
     the time-scrubber (which force-hides the ad slot instead of stacking on
     top of it — see ".ad-slot" rules below) — see the ad-slot section for the
     source-order note on why replay-open must be declared after cb-strip. */
  --stack-h: 46px;
  /* ---- A11Y(2) colorblind mode: --up/--down are the semantic direction colors
     every color-coded UI part (bubbles/scatter/heatmap on canvas via cssVar() +
     list/modal/tooltip .up/.down classes on DOM) reads from. By default they just
     alias --green/--red (and so still follow the dark/light theme swap below);
     body.colorblind overrides them to a blue/orange pair chosen for ~4.5:1+ AA
     contrast against both bg and card in each theme — see body.colorblind /
     body.light.colorblind. */
  --up: var(--green);
  --down: var(--red);
}

body.light {
  --bg: #f3f5f8;
  --bar: #ffffff;
  --border: #dfe4ea;
  --text: #10151a;
  --muted: #626d7a;
  --green: #12a454;
  --red: #d92d2d;
  --accent: #12a454;
  --panel-bg: #ffffff;
  --card-bg: #ffffff;
  --cell-bg: #f1f4f7;
  --hover-bg: #eef1f5;
}

body.colorblind { --up: #4da3ff; --down: #ff9f40; }
body.light.colorblind { --up: #0a58b3; --down: #a34f00; }

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  overflow: hidden;
  overscroll-behavior: none;
}

/* ---------- top bar ---------- */
#topbar {
  position: fixed; top: 0; left: 0; right: 0; height: 52px; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 14px;
  background: var(--bar);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.brand-dot {
  width: 14px; height: 14px; border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #52f39a, #0f9d4f);
  box-shadow: 0 0 8px rgba(43, 217, 117, .7);
}
.brand-name { font-weight: 700; letter-spacing: .06em; font-size: 15px; }
.brand-demo {
  font-size: 10px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  color: var(--bg); background: var(--accent);
  padding: 2px 6px; border-radius: 4px;
}
.controls-group { display: flex; align-items: center; gap: 8px; min-width: 0; }
.controls { display: flex; align-items: center; gap: 8px; overflow-x: auto; overflow-y: hidden; -webkit-overflow-scrolling: touch; scrollbar-width: none; min-width: 0; }
.controls::-webkit-scrollbar { display: none; }
#rangeSel, #metricSel {
  background: var(--panel-bg); color: var(--text);
  border: 1px solid var(--border); border-radius: 6px;
  height: 32px; padding: 0 8px; font-size: 13px; outline: none;
  flex: none;
}
.searchbox { position: relative; flex: none; }
#search {
  background: var(--panel-bg); color: var(--text);
  border: 1px solid var(--border); border-radius: 6px;
  height: 32px; width: 170px; padding: 0 26px 0 10px;
  font-size: 13px; outline: none;
}
#search:focus { border-color: #35424f; }
#searchClear {
  position: absolute; right: 2px; top: 50%; transform: translateY(-50%);
  width: 24px; height: 24px; border: 0; background: transparent;
  color: var(--muted); font-size: 16px; cursor: pointer; display: none;
}
.searchbox.has-value #searchClear { display: block; }

/* ---------- icon buttons / chips / settings ---------- */
.icon-btn, .chip {
  position: relative;
  flex: none;
  width: 32px; height: 32px;
  background: var(--panel-bg); color: var(--muted);
  border: 1px solid var(--border); border-radius: 6px;
  font-size: 14px; cursor: pointer; line-height: 1;
  display: flex; align-items: center; justify-content: center;
}
.icon-btn:hover, .chip:hover { color: var(--text); background: var(--hover-bg); }
.icon-btn.active { color: var(--bg); background: var(--accent); border-color: var(--accent); }
.chip.active { color: var(--bg); background: var(--gold); border-color: var(--gold); }

/* ---------- filters (FR-13) ---------- */
.filter-badge {
  position: absolute; top: -5px; right: -5px; min-width: 15px; height: 15px; padding: 0 3px;
  background: var(--gold); color: #10151a; border-radius: 8px; font-size: 9px; font-weight: 700;
  display: flex; align-items: center; justify-content: center; line-height: 1;
}
.filters-panel { width: 260px; max-height: 72vh; overflow-y: auto; }
.filters-group { margin-bottom: 12px; }
.filters-group:last-of-type { margin-bottom: 0; }
.filters-group-title {
  font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em;
  margin-bottom: 6px;
}
.filters-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.filter-chip {
  background: var(--panel-bg); color: var(--muted); border: 1px solid var(--border); border-radius: 20px;
  padding: 4px 10px; font-size: 12px; cursor: pointer; line-height: 1.3;
}
.filter-chip:hover { color: var(--text); background: var(--hover-bg); }
.filter-chip.active { color: var(--bg); background: var(--accent); border-color: var(--accent); }
.filters-clear { width: 100%; margin-top: 4px; text-align: center; }

/* ---------- filter presets (FR-25) ---------- */
.filter-presets-row { display: flex; gap: 6px; margin-bottom: 6px; }
#filterPresetsSel {
  flex: 1; min-width: 0;
  background: var(--panel-bg); color: var(--text);
  border: 1px solid var(--border); border-radius: 6px;
  height: 28px; padding: 0 6px; font-size: 12px; outline: none;
}
.filter-presets-save-row { display: flex; gap: 6px; }
.filter-presets-save-row input {
  flex: 1; min-width: 0;
  background: var(--panel-bg); color: var(--text);
  border: 1px solid var(--border); border-radius: 6px;
  height: 28px; padding: 0 8px; font-size: 12px; outline: none;
}

.view-switch {
  display: flex; align-items: center; flex: none;
  background: var(--panel-bg); border: 1px solid var(--border); border-radius: 6px;
  overflow: hidden;
}
.view-btn {
  width: 32px; height: 32px; border: 0; background: transparent; color: var(--muted);
  font-size: 15px; cursor: pointer; line-height: 1;
  display: flex; align-items: center; justify-content: center;
  border-right: 1px solid var(--border);
}
.view-btn:last-child { border-right: 0; }
.view-btn:hover { color: var(--text); background: var(--hover-bg); }
.view-btn.active { color: var(--bg); background: var(--accent); }
/* FR-26: RSI is a text label ("RSI"), not a single glyph like the other four view
   buttons — give it auto width instead of forcing it into the 32px icon square. */
.view-btn-text { width: auto; padding: 0 9px; font-size: 11px; font-weight: 700; letter-spacing: .02em; }

/* ---------- watchlists (FR-19) ---------- */
#watchlistWrap { display: flex; align-items: center; gap: 4px; flex: none; }
.watchlist-caret { width: 18px; font-size: 10px; }
.watchlist-panel { width: 240px; }
.watchlist-list { display: flex; flex-direction: column; gap: 4px; margin-bottom: 8px; max-height: 220px; overflow-y: auto; }
.watchlist-row {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 8px; border-radius: 6px; cursor: pointer;
  border: 1px solid transparent; background: var(--panel-bg);
  font-size: 12px;
}
.watchlist-row:hover { background: var(--hover-bg); }
.watchlist-row.active { border-color: var(--accent); }
.watchlist-row .wl-name {
  flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  color: var(--text);
}
.watchlist-row.active .wl-name { color: var(--accent); font-weight: 700; }
.watchlist-row .wl-count { color: var(--muted); font-size: 11px; flex: none; }
.watchlist-row .wl-btn {
  border: 0; background: transparent; color: var(--muted); cursor: pointer;
  font-size: 13px; line-height: 1; padding: 2px 4px; flex: none;
}
.watchlist-row .wl-btn:hover { color: var(--text); }
.watchlist-add-row { display: flex; gap: 6px; }
.watchlist-add-row input {
  flex: 1; min-width: 0;
  background: var(--panel-bg); color: var(--text);
  border: 1px solid var(--border); border-radius: 6px;
  height: 28px; padding: 0 8px; font-size: 12px; outline: none;
}

.settings-wrap { position: relative; flex: none; }
.settings-panel {
  position: absolute; top: calc(100% + 8px); right: 0; z-index: 50;
  width: 220px; padding: 10px;
  background: var(--card-bg); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, .45);
}
.settings-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 6px 2px; font-size: 13px;
}
.settings-row label { color: var(--muted); }
.settings-row select {
  background: var(--panel-bg); color: var(--text);
  border: 1px solid var(--border); border-radius: 6px;
  height: 28px; padding: 0 6px; font-size: 12px; outline: none;
}
.settings-row input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--accent); }

/* ---------- stage ---------- */
#stage { position: fixed; top: 52px; bottom: var(--stack-h); left: 0; right: 0; }
#bubbles { width: 100%; height: 100%; display: block; touch-action: none; }
#bubbles[hidden] { display: none; }

#tooltip {
  position: fixed; z-index: 30; pointer-events: none;
  background: var(--card-bg); border: 1px solid var(--border);
  border-radius: 8px; padding: 8px 10px; font-size: 12px; line-height: 1.5;
  box-shadow: 0 6px 18px rgba(0, 0, 0, .5);
  max-width: 220px; white-space: nowrap;
  color: var(--text);
}
#tooltip .t-name { font-weight: 700; font-size: 13px; }
#tooltip .t-line { color: var(--muted); }
#tooltip .up { color: var(--up); }
#tooltip .down { color: var(--down); }

/* ---------- list view ---------- */
#listView { position: absolute; inset: 0; display: flex; flex-direction: column; }
#listView[hidden] { display: none; }
.list-wrap { flex: 1; overflow: auto; -webkit-overflow-scrolling: touch; }
#coinTable { width: 100%; min-width: 640px; border-collapse: collapse; font-size: 13px; }
#coinTable thead th {
  position: sticky; top: 0; z-index: 5;
  background: var(--bar); color: var(--muted);
  text-align: right; font-weight: 700; font-size: 11px; letter-spacing: .03em;
  padding: 10px 12px; border-bottom: 1px solid var(--border);
  cursor: pointer; white-space: nowrap; user-select: none;
}
#coinTable thead th[data-col="star"], #coinTable thead th[data-col="rank"] { text-align: center; }
#coinTable thead th[data-col="name"] { text-align: left; }
#coinTable thead th.sort-asc::after { content: ' \25B2'; }
#coinTable thead th.sort-desc::after { content: ' \25BC'; }
#coinTable tbody td {
  padding: 8px 12px; border-bottom: 1px solid var(--border);
  text-align: right; white-space: nowrap;
}
#coinTable tbody td.col-star, #coinTable tbody td:nth-child(2) { text-align: center; }
#coinTable tbody tr { cursor: pointer; }
#coinTable tbody tr:hover { background: var(--hover-bg); }
/* A11Y(3): rows are tabindex=0 + Enter/Space opens the modal (see app.js buildListView) */
#coinTable tbody tr:focus-visible,
#coinTable thead th:focus-visible {
  outline: 2px solid var(--accent); outline-offset: -2px;
}
.col-coin { text-align: left !important; display: flex; align-items: center; gap: 8px; }
.col-coin img { width: 20px; height: 20px; border-radius: 50%; }
.col-coin small { color: var(--muted); }

.star-btn {
  border: 0; background: transparent; color: var(--muted);
  font-size: 15px; cursor: pointer; line-height: 1; padding: 2px;
}
.star-btn.starred { color: var(--gold); }
.star-btn:hover { color: var(--gold); }

/* ---------- RSI heatmap (FR-26) ---------- */
#rsiView { position: absolute; inset: 0; overflow-y: auto; padding: 14px; }
#rsiView[hidden] { display: none; }
.rsi-wrap { display: flex; flex-direction: column; gap: 12px; min-height: 100%; }
.rsi-note {
  font-size: 12px; color: var(--muted);
  background: var(--cell-bg); border: 1px solid var(--border); border-radius: 8px;
  padding: 8px 12px;
}
.rsi-note[hidden] { display: none; }
.rsi-legend { display: flex; gap: 18px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.rsi-legend-item { display: flex; align-items: center; gap: 6px; }
.rsi-swatch { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.rsi-swatch.rsi-oversold { background: var(--up); }
.rsi-swatch.rsi-neutral { background: var(--muted); }
.rsi-swatch.rsi-overbought { background: var(--down); }
.rsi-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 6px;
}
.rsi-tile {
  position: relative; border-radius: 8px; padding: 10px 6px; min-height: 66px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  cursor: pointer; border: 1px solid var(--border);
}
.rsi-tile:hover, .rsi-tile:focus-visible { outline: 2px solid rgba(255,255,255,.6); outline-offset: -2px; }
.rsi-tile .rsi-sym { font-weight: 700; font-size: 13px; color: var(--text); }
.rsi-tile .rsi-val { font-size: 15px; font-weight: 700; }
.rsi-tile.rsi-zone-oversold .rsi-val { color: var(--up); }
.rsi-tile.rsi-zone-overbought .rsi-val { color: var(--down); }
.rsi-tile.rsi-zone-neutral .rsi-val { color: var(--muted); }
.rsi-empty { text-align: center; color: var(--muted); font-size: 13px; padding: 40px 0; }
.rsi-empty[hidden] { display: none; }

/* ---------- bottom bar ---------- */
#bottombar {
  position: fixed; bottom: 0; left: 0; right: 0; height: 46px; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 14px;
  background: var(--bar);
  border-top: 1px solid var(--border);
}
.periods { display: flex; gap: 4px; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
.periods::-webkit-scrollbar { display: none; }
.periods button {
  min-width: 42px; height: 32px; padding: 0 10px; flex: none;
  background: transparent; color: var(--muted);
  border: 0; border-radius: 6px;
  font-size: 13px; font-weight: 700; cursor: pointer;
}
.periods button:hover { color: var(--text); background: var(--hover-bg); }
.periods button.active, #mcBtn.active { color: var(--bg); background: var(--accent); }
.vs-btc-chip {
  flex: none; height: 22px; padding: 0 8px; margin-left: 2px;
  display: flex; align-items: center;
  background: var(--accent); color: var(--bg);
  font-size: 10px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
  border-radius: 20px;
}
/* Pre-existing bug (same root cause as the documented .more-panel[hidden] fix
   above — an author `display: flex` beats the UA `[hidden]{display:none}` rule
   at equal specificity/origin): without this, the chip rendered even while
   JS had chip.hidden = true (state.vsBtc === false). Found while verifying
   A11Y(2)'s colorblind palette against this exact element. */
.vs-btc-chip[hidden] { display: none; }
.meta { display: flex; align-items: center; gap: 12px; font-size: 12px; color: var(--muted); white-space: nowrap; }
.meta #updated.pulse { animation: cbPulse .6s ease; }
@keyframes cbPulse {
  0% { opacity: .35; color: var(--accent); }
  50% { opacity: 1; color: var(--accent); }
  100% { opacity: 1; color: var(--muted); }
}
.attribution { color: var(--muted); text-decoration: none; border-bottom: 1px dotted var(--muted); }
.attribution:hover { color: var(--text); }

/* ---------- more nav dropdown + lang switch (P4/P2) ---------- */
.more-wrap { position: relative; }
.more-btn { flex: none; }
.more-panel {
  bottom: calc(100% + 8px); top: auto; right: 0;
  display: flex; flex-direction: column; gap: 2px; width: 180px; padding: 6px;
}
/* Pre-existing bug fix (found while adding the FR-13 filters panel, unrelated to
   it): an explicit `display` on the same specificity as the UA `[hidden]{display:
   none}` rule loses to it by origin, not specificity — author styles always beat
   UA styles at equal specificity — so `.more-panel{display:flex}` was silently
   keeping the More dropdown visually rendered at all times, `hidden` attribute or
   not. Restate the hidden case explicitly so JS's `morePanel.hidden = true/false`
   actually has an effect. */
.more-panel[hidden] { display: none; }
.more-panel a {
  display: block; padding: 8px 10px; border-radius: 6px;
  color: var(--text); text-decoration: none; font-size: 13px;
}
.more-panel a:hover { background: var(--hover-bg); }
/* ---------- share popover (FR-28) ---------- */
.share-wrap { position: relative; }
.share-panel {
  bottom: calc(100% + 8px); top: auto; right: 0;
  display: flex; flex-direction: column; gap: 6px; width: 200px; padding: 8px;
}
.share-panel[hidden] { display: none; }
.share-panel .mini-btn { width: 100%; text-align: left; }
.share-status { font-size: 11px; color: var(--muted); min-height: 14px; }

/* ---------- language switcher dropdown (9 locales) ---------- */
.lang-wrap { flex: none; }
.lang-btn { flex: none; white-space: nowrap; }
.lang-panel {
  bottom: calc(100% + 8px); top: auto; right: 0;
  display: flex; flex-direction: column; gap: 2px; width: 180px; padding: 6px;
  max-height: 320px; overflow-y: auto;
}
.lang-panel[hidden] { display: none; }
.lang-panel .lang-menu-item {
  display: block; padding: 8px 10px; border-radius: 6px;
  color: var(--text); text-decoration: none; font-size: 13px;
}
.lang-panel .lang-menu-item:hover { background: var(--hover-bg); }
.lang-panel .lang-menu-item.active { color: var(--accent); font-weight: 700; }

/* ---------- ad slot (M1, TZ §11) ---------- */
/* House/placeholder creative only — no real ad network is wired up yet (no
   partner keys exist for this demo). A real network's async loader (e.g.
   Coinzilla, Bitmedia) would mount inside the [data-ad-slot] element below,
   and per the consent gate documented in app.js (initAdSlot()/loadAdNetwork()
   /window.CB_CONSENT), it must only be injected once a real CMP has set
   window.CB_CONSENT = true. The static house creative itself makes no
   third-party request and carries no tracking, so it renders regardless of
   consent — only a *real* network tag would need to wait on the flag.
   Sizing follows the standard IAB leaderboard (728x90 desktop) / mobile
   banner (320x50) creative sizes, centered in a full-width strip so it never
   crowds the canvas — the strip sits ABOVE #bottombar (never inside #stage),
   and #stage's bottom offset is widened via --stack-h (body.cb-strip, set by
   app.js) so the bubble field is reflowed to never render underneath it. */
.ad-slot {
  position: fixed; left: 0; right: 0; bottom: 46px; z-index: 18;
  height: 90px; padding: 8px 44px 8px 14px;
  display: flex; align-items: center; justify-content: center;
  background: var(--bar); border-top: 1px solid var(--border);
}
.ad-slot[hidden] { display: none; }
.ad-slot-inner {
  width: 100%; max-width: 728px; height: 100%;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  border: 1px dashed var(--border); border-radius: 8px;
  background: var(--panel-bg);
}
.ad-slot-tag {
  font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em;
  color: var(--muted);
}
.ad-slot-house {
  color: var(--muted); text-decoration: none; font-size: 12px; text-align: center; padding: 0 12px;
}
.ad-slot-house:hover { color: var(--text); }
.ad-slot-close {
  position: absolute; top: 50%; right: 10px; transform: translateY(-50%);
  width: 22px; height: 22px; border: 0; border-radius: 6px;
  background: var(--hover-bg); color: var(--muted); font-size: 14px; cursor: pointer;
}
.ad-slot-close:hover { color: var(--text); }
@media (max-width: 640px) {
  .ad-slot { height: 50px; padding: 4px 36px 4px 10px; }
  .ad-slot-inner { max-width: 320px; gap: 1px; }
  .ad-slot-house { font-size: 10px; }
}
/* JS (initAdSlot()) adds body.cb-strip only outside embed/dismissed sessions. */
body.cb-strip { --stack-h: 136px; }              /* 46px bottombar + 90px ad */
@media (max-width: 640px) { body.cb-strip { --stack-h: 96px; } } /* 46 + 50 */

/* ---------- featured / sponsored bubble (M2, TZ §11) ---------- */
.featured-card {
  position: fixed; top: 60px; left: 12px; z-index: 22;
  display: flex; align-items: center; gap: 8px; max-width: 200px;
  padding: 8px 10px; cursor: pointer;
  background: var(--card-bg); border: 1px solid var(--gold); border-radius: 10px;
  box-shadow: 0 8px 20px rgba(0, 0, 0, .35);
}
.featured-card[hidden] { display: none; }
.featured-card img { width: 28px; height: 28px; border-radius: 50%; flex: none; }
.featured-card-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.featured-card-eyebrow {
  font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em;
  color: var(--gold);
}
.featured-card-name {
  font-size: 12px; font-weight: 700; color: var(--text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
/* Compliance label — reused wherever a featured coin surfaces (corner card,
   coin modal); ALWAYS rendered together with the coin's name/logo, never on
   its own, and never suppressed even though the gold ring alone would already
   visually flag the bubble on canvas. */
.featured-badge {
  display: inline-block; font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .04em; padding: 2px 7px; border-radius: 20px;
  background: var(--gold); color: #10151a;
}
#mFeaturedBadge[hidden] { display: none; }
#tooltip .t-sponsored {
  display: block; margin-top: 2px; color: var(--gold); font-weight: 700;
  font-size: 10px; text-transform: uppercase; letter-spacing: .04em;
}

/* ---------- cookie consent banner (M3, TZ §12) ---------- */
.cookie-banner {
  position: fixed; left: 14px; z-index: 65;
  bottom: calc(var(--stack-h) + 14px); /* stacks above bottombar/ad-slot/scrubber, same offset #stage uses */
  max-width: 320px; padding: 12px 14px;
  background: var(--card-bg); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, .45);
  font-size: 12px; color: var(--text);
}
.cookie-banner[hidden] { display: none; }
.cookie-banner p { margin: 0 0 10px; color: var(--muted); line-height: 1.5; }
.cookie-banner-actions { display: flex; gap: 8px; }
.cookie-banner-actions .mini-btn { flex: 1; }
.cookie-banner-actions .cookie-accept {
  background: var(--accent); color: var(--bg); border-color: var(--accent); font-weight: 700;
}
@media (max-width: 640px) {
  .cookie-banner { left: 8px; right: 8px; max-width: none; }
}

/* ---------- time-scrubber replay (D9/FR-10) ---------- */
#replayBtn.active { color: var(--bg); background: var(--accent); border-color: var(--accent); }
.scrubber-bar {
  position: fixed; left: 0; right: 0; bottom: 46px; z-index: 19;
  height: 44px; padding: 0 14px;
  display: flex; align-items: center; gap: 10px;
  background: var(--bar); border-top: 1px solid var(--border);
}
.scrubber-bar[hidden] { display: none; }
/* Replay's scrubber bar occupies the same "above #bottombar" strip the ad
   slot uses — rather than stack the two, the ad slot is force-hidden while
   replay is open (next rule) and --stack-h falls back to bottombar+scrubber
   only. This rule must stay declared AFTER body.cb-strip above so it wins the
   cascade when both classes are present (equal specificity, source order
   decides) — see the --stack-h comment in :root. */
body.replay-open { --stack-h: 90px; }
body.replay-open .ad-slot { display: none; }
.scrubber-play { flex: none; width: 36px; }
.scrubber-play:disabled, .scrubber-slider:disabled { opacity: .4; cursor: not-allowed; }
.scrubber-slider { flex: 1 1 auto; min-width: 60px; accent-color: var(--accent); }
.scrubber-label {
  flex: none; min-width: 132px; text-align: right;
  font-size: 12px; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums;
}
.scrubber-note { flex: 1 1 auto; font-size: 12px; color: var(--muted); }
.scrubber-close { flex: none; }
@media (max-width: 640px) {
  .scrubber-label { min-width: 96px; font-size: 11px; }
  .scrubber-bar { gap: 6px; padding: 0 8px; }
}

/* ---------- embed mode (P3 /embed) ---------- */
body.embed #topbar { display: none; }
body.embed #stage { top: 0; bottom: 28px; }
body.embed #bottombar {
  height: 28px; padding: 0 10px; justify-content: center;
}
body.embed .periods,
body.embed .more-wrap,
body.embed .share-wrap,
body.embed .lang-wrap,
body.embed .meta #updated,
body.embed #replayBtn,
body.embed #scrubberBar { display: none; }
body.embed .meta { width: 100%; justify-content: center; gap: 6px; }
body.embed .attribution { font-size: 11px; }
/* M1/M2/M3: keep an embedded widget clean for whoever mounts it on their own
   site — no ad strip, no sponsored corner card, no cookie banner (embed
   never loads/needs its own consent UI; app.js's initAdSlot()/initCookieConsent()
   already no-op under CB_EMBED, this is the belt-and-braces CSS-only guarantee). */
body.embed #adSlot, body.embed #featuredCard, body.embed #cookieBanner { display: none; }

/* ---------- pages (gainers/losers/altseason/fear-greed/coin/widget) nav header ---------- */
.cb-page-header {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  flex-wrap: wrap;
  padding: 14px 18px;
  background: var(--bar); border-bottom: 1px solid var(--border);
}
.cb-page-nav { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.cb-page-nav a { color: var(--muted); text-decoration: none; font-size: 13px; font-weight: 600; }
.cb-page-nav a:hover, .cb-page-nav a.active { color: var(--accent); }
.cb-page-brand { display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--text); font-weight: 700; letter-spacing: .04em; font-size: 14px; white-space: nowrap; }

/* ---------- modal ---------- */
#modal[hidden], #tooltip[hidden] { display: none !important; }

#modal {
  position: fixed; inset: 0; z-index: 40;
  background: rgba(5, 7, 9, .72);
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
}
#modalCard {
  position: relative; width: 100%; max-width: 620px; max-height: 90vh; overflow-y: auto;
  background: var(--card-bg); border: 1px solid var(--border); border-radius: 14px;
  padding: 20px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .6);
}
#modalClose {
  position: absolute; top: 10px; right: 10px;
  width: 30px; height: 30px; border: 0; border-radius: 6px;
  background: var(--hover-bg); color: var(--muted); font-size: 18px; cursor: pointer;
}
#modalClose:hover { color: var(--text); }
.m-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
#mLogo { width: 44px; height: 44px; border-radius: 50%; }
.m-title-row { display: flex; align-items: center; gap: 8px; }
#mName { font-size: 18px; font-weight: 700; }
.m-title-row .star-btn { font-size: 17px; }
.m-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.m-price-wrap { margin-left: auto; text-align: right; padding-right: 30px; }
#mPrice { font-size: 20px; font-weight: 700; }
.m-day { font-size: 13px; font-weight: 700; margin-top: 2px; }
.m-perf {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(56px, 1fr)); gap: 6px; margin-bottom: 14px;
}
.m-perf .cell {
  background: var(--cell-bg); border: 1px solid var(--border); border-radius: 8px;
  padding: 7px 4px; text-align: center;
}
.m-perf .cell span { display: block; font-size: 10px; color: var(--muted); letter-spacing: .05em; }
.m-perf .cell b { display: block; font-size: 13px; margin-top: 2px; }
#mSpark { width: 100%; height: 130px; display: block; margin-bottom: 14px; }
.m-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-bottom: 14px; }
.m-stats div {
  background: var(--cell-bg); border: 1px solid var(--border); border-radius: 8px;
  padding: 8px 12px; display: flex; justify-content: space-between; font-size: 13px;
}
.m-stats span { color: var(--muted); }
.m-links { font-size: 13px; }
.m-links-row { display: flex; gap: 14px; flex-wrap: wrap; }
.m-links-row a { color: var(--accent); text-decoration: none; }
.m-links-row a:hover { text-decoration: underline; }
.m-links-cap { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; margin: 10px 0 4px; }
.m-trade a { color: var(--text); background: var(--cell-bg); border: 1px solid var(--border); border-radius: 6px; padding: 4px 10px; }
.m-trade a:hover { background: var(--hover-bg); text-decoration: none; }
.m-buy-disclosure { font-size: 10px; color: var(--muted); margin-top: 8px; line-height: 1.4; }
.up { color: var(--up); }
.down { color: var(--down); }
.flat { color: var(--muted); }

/* ---------- account / auth ---------- */
.mini-btn {
  background: var(--panel-bg); color: var(--text);
  border: 1px solid var(--border); border-radius: 6px;
  height: 26px; padding: 0 10px; font-size: 12px; cursor: pointer;
}
.mini-btn:hover { background: var(--hover-bg); }

.auth-dropdown { width: 200px; }
.auth-email {
  font-size: 12px; color: var(--muted); word-break: break-all;
  padding: 2px 2px 10px; border-bottom: 1px solid var(--border); margin-bottom: 8px;
}
.auth-dropdown #logoutBtn { width: 100%; }

#authModal[hidden] { display: none !important; }
#authModal {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(5, 7, 9, .72);
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
}
#authCard {
  position: relative; width: 100%; max-width: 320px;
  background: var(--card-bg); border: 1px solid var(--border); border-radius: 14px;
  padding: 20px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .6);
}
#authModalClose {
  position: absolute; top: 10px; right: 10px;
  width: 30px; height: 30px; border: 0; border-radius: 6px;
  background: var(--hover-bg); color: var(--muted); font-size: 18px; cursor: pointer;
}
#authModalClose:hover { color: var(--text); }
.auth-tabs { display: flex; gap: 6px; margin-bottom: 16px; }
.auth-tab {
  flex: 1; height: 34px; border: 1px solid var(--border); border-radius: 6px;
  background: var(--panel-bg); color: var(--muted); font-size: 13px; font-weight: 700; cursor: pointer;
}
.auth-tab.active { color: var(--bg); background: var(--accent); border-color: var(--accent); }
#authForm { display: flex; flex-direction: column; gap: 12px; }
.auth-field { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
.auth-field input {
  background: var(--panel-bg); color: var(--text);
  border: 1px solid var(--border); border-radius: 6px;
  height: 34px; padding: 0 10px; font-size: 13px; outline: none;
}
.auth-field input:focus { border-color: #35424f; }
.auth-error {
  font-size: 12px; color: var(--red);
  background: rgba(255, 77, 77, .1); border: 1px solid rgba(255, 77, 77, .3);
  border-radius: 6px; padding: 8px 10px;
}
#authSubmit {
  height: 36px; border: 0; border-radius: 6px; cursor: pointer;
  background: var(--accent); color: var(--bg); font-size: 13px; font-weight: 700;
}
#authSubmit:disabled { opacity: .6; cursor: default; }

/* ---------- alerts (coin modal) ---------- */
.bell-btn { font-size: 15px; }
.bell-btn.has-alerts { color: var(--gold); }
.m-alert-panel {
  background: var(--cell-bg); border: 1px solid var(--border); border-radius: 8px;
  padding: 10px; margin-bottom: 14px;
}
.m-alert-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 8px; }
.m-alert-list:empty { display: none; }
.m-alert-row {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  font-size: 12px; background: var(--panel-bg); border: 1px solid var(--border);
  border-radius: 6px; padding: 6px 8px;
}
.m-alert-row button {
  border: 0; background: transparent; color: var(--muted); cursor: pointer; font-size: 14px; line-height: 1;
}
.m-alert-row button:hover { color: var(--red); }
.m-alert-form { display: flex; gap: 6px; }
.m-alert-form select, .m-alert-form input {
  background: var(--panel-bg); color: var(--text);
  border: 1px solid var(--border); border-radius: 6px;
  height: 30px; padding: 0 8px; font-size: 12px; outline: none;
}
.m-alert-form select { flex: none; }
.m-alert-form input { flex: 1; min-width: 0; }
.m-alert-form button {
  flex: none; height: 30px; padding: 0 10px; border: 0; border-radius: 6px; cursor: pointer;
  background: var(--accent); color: var(--bg); font-size: 12px; font-weight: 700;
}

/* ---------- portfolio (FR-20) ---------- */
#portfolioModal[hidden] { display: none !important; }
#portfolioModal {
  position: fixed; inset: 0; z-index: 55;
  background: rgba(5, 7, 9, .72);
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
}
#portfolioCard {
  position: relative; width: 100%; max-width: 780px; max-height: 88vh; overflow-y: auto;
  background: var(--card-bg); border: 1px solid var(--border); border-radius: 14px;
  padding: 22px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .6);
}
#portfolioClose {
  position: absolute; top: 10px; right: 10px;
  width: 30px; height: 30px; border: 0; border-radius: 6px;
  background: var(--hover-bg); color: var(--muted); font-size: 18px; cursor: pointer;
}
#portfolioClose:hover { color: var(--text); }
#portfolioHeading { font-size: 18px; font-weight: 700; margin-bottom: 14px; }
.portfolio-summary { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.portfolio-summary div {
  background: var(--cell-bg); border: 1px solid var(--border); border-radius: 8px; padding: 10px 14px;
}
.portfolio-summary span { display: block; font-size: 11px; color: var(--muted); margin-bottom: 2px; }
.portfolio-summary b { font-size: 17px; }
.portfolio-add-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.portfolio-add-row input {
  background: var(--panel-bg); color: var(--text);
  border: 1px solid var(--border); border-radius: 6px;
  height: 34px; padding: 0 10px; font-size: 13px; outline: none;
}
#pfCoinInput { flex: 1; min-width: 160px; }
#pfAmountInput, #pfCostInput { width: 130px; flex: none; }
.portfolio-add-row button {
  flex: none; height: 34px; padding: 0 16px; border: 0; border-radius: 6px; cursor: pointer;
  background: var(--accent); color: var(--bg); font-size: 13px; font-weight: 700;
}
.portfolio-bubble-toggle {
  display: flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--muted); margin-bottom: 14px; cursor: pointer;
}
.portfolio-bubble-toggle input { accent-color: var(--accent); width: 15px; height: 15px; }
.portfolio-table-wrap { overflow-x: auto; }
#portfolioTable { width: 100%; min-width: 560px; border-collapse: collapse; font-size: 13px; }
#portfolioTable thead th {
  text-align: right; font-size: 11px; color: var(--muted); font-weight: 700;
  padding: 8px 10px; border-bottom: 1px solid var(--border); white-space: nowrap;
}
#portfolioTable thead th:first-child { text-align: left; }
#portfolioTable tbody td {
  padding: 8px 10px; border-bottom: 1px solid var(--border); text-align: right; white-space: nowrap;
}
#portfolioTable tbody td:first-child { text-align: left; }
.portfolio-empty { text-align: center; color: var(--muted); font-size: 13px; padding: 24px 0; }

/* ---------- toasts ---------- */
#toastStack {
  position: fixed; right: 14px; bottom: 58px; z-index: 70;
  display: flex; flex-direction: column-reverse; gap: 8px;
  pointer-events: none;
}
.cb-toast {
  background: var(--card-bg); color: var(--text); border: 1px solid var(--border);
  border-radius: 8px; padding: 10px 14px; font-size: 13px; max-width: 280px;
  box-shadow: 0 10px 26px rgba(0, 0, 0, .45);
  opacity: 0; transform: translateY(8px); transition: opacity .25s ease, transform .25s ease;
}
.cb-toast.show { opacity: 1; transform: translateY(0); }

/* ---------- mobile ---------- */
@media (max-width: 640px) {
  #search { width: 110px; }
  .brand-name { display: none; }
  .meta #updated { display: none; }
  .m-perf { grid-template-columns: repeat(5, 1fr); gap: 4px; }
  .m-perf .cell b { font-size: 11px; }
}

/* ---------- empty state (canvas views) ----------
   Shown when the active filters / watchlist leave zero coins to draw. Without it
   the canvas is simply black and indistinguishable from a broken page. */
#emptyState {
  position: absolute; inset: 0; z-index: 15;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 12px; text-align: center; padding: 24px;
  pointer-events: none;
}
#emptyState[hidden] { display: none; }
.empty-state-msg { margin: 0; color: var(--muted); font-size: 15px; max-width: 30ch; line-height: 1.5; }
#emptyStateReset { pointer-events: auto; }
