/* Coins lab tools: tables, heatmap, dominance chart, fear/greed gauge, funding rounds.
   Uses the Chemist theme tokens (--bg/--ink/--line/--gold/--plate…) so it adapts to light/dark,
   with :root[data-theme="dark"] overrides only for the few colours the palette doesn't cover. */

.cn-section { max-width: 1180px; margin: 0 auto; padding: 8px 32px 16px; }

/* Provenance note above the footer */
.cn-note { margin-top: 30px; padding-top: 18px; border-top: 1px solid var(--line, rgba(42,36,24,0.18)); font-size: 14px; line-height: 1.6; color: var(--ink3, #8A7E60); }
.cn-note a { color: var(--gold, #C8922E); text-decoration: none; }
.cn-note a:hover { text-decoration: underline; }

/* ---- Tables (Top 100 / Trending / Recently / Ecosystems / Exchanges / Funding) ---- */
.cn-table-wrap { overflow-x: auto; border: 1px solid var(--line, rgba(42,36,24,0.18)); border-radius: 4px; background: var(--plate, #E4D8B6); }
.cn-table { width: 100%; border-collapse: collapse; font-size: 15px; }
.cn-table thead th {
    text-align: right; font-family: Cinzel, serif; font-size: 11px; letter-spacing: .12em;
    text-transform: uppercase; color: var(--ink3, #8A7E60); padding: 14px 16px;
    border-bottom: 1px solid var(--line, rgba(42,36,24,0.18)); white-space: nowrap;
}
.cn-table thead th.cn-name, .cn-table thead th.cn-rank { text-align: left; }
.cn-table tbody td {
    padding: 12px 16px; text-align: right; white-space: nowrap; color: var(--ink, #2A2418);
    border-bottom: 1px solid color-mix(in srgb, var(--line, rgba(42,36,24,0.18)) 60%, transparent);
}
.cn-table tbody tr:last-child td { border-bottom: none; }
.cn-table tbody tr:hover td { background: color-mix(in srgb, var(--gold, #C8922E) 8%, transparent); }
.cn-rank { text-align: left !important; color: var(--ink3, #8A7E60); width: 1%; }
.cn-name { text-align: left !important; }
.cn-num { font-variant-numeric: tabular-nums; }

.cn-coin { display: inline-flex; align-items: center; gap: 10px; }
.cn-logo { width: 26px; height: 26px; border-radius: 50%; object-fit: cover; background: var(--bg2, #F4ECD6); flex: 0 0 auto; }
.cn-coin-text { display: inline-flex; flex-direction: column; line-height: 1.2; text-align: left; }
.cn-coin-name { font-weight: 600; color: var(--ink, #2A2418); white-space: normal; }
.cn-coin-sym { font-size: 12px; color: var(--ink3, #8A7E60); text-transform: uppercase; letter-spacing: .04em; }

.cn-trend-up { color: #1E9E63 !important; }
.cn-trend-down { color: #C0392B !important; }
.cn-trend-flat { color: var(--ink3, #8A7E60) !important; }
:root[data-theme="dark"] .cn-trend-up { color: #5BB985 !important; }
:root[data-theme="dark"] .cn-trend-down { color: #E0725F !important; }

/* ---- Chips (funding stage / investors) ---- */
.cn-chip { display: inline-block; padding: 3px 9px; border-radius: 3px; font-size: 12px; font-weight: 600; white-space: nowrap; background: color-mix(in srgb, var(--gold, #C8922E) 20%, transparent); color: var(--ink, #2A2418); }
.cn-chip-soft { background: color-mix(in srgb, var(--ink, #2A2418) 8%, transparent); color: var(--ink2, #5C5238); font-weight: 500; margin: 2px 3px 0 0; }

/* ---- Empty / unavailable state ---- */
.cn-empty { text-align: center; padding: 60px 24px; border: 1px dashed var(--line, rgba(42,36,24,0.28)); border-radius: 4px; background: var(--plate, #E4D8B6); }
.cn-empty-icon { width: 54px; height: 54px; margin: 0 auto 18px; color: var(--gold, #C8922E); }
.cn-empty-icon svg { width: 100%; height: 100%; }
.cn-empty h2 { font-family: "EB Garamond", serif; font-weight: 500; font-size: 24px; margin: 0 0 8px; color: var(--ink, #2A2418); }
.cn-empty p { margin: 0 auto; max-width: 52ch; color: var(--ink2, #5C5238); font-size: 16px; line-height: 1.55; }

/* ---- Heatmap (squarified treemap: tile area is proportional to market cap) ---- */
.cn-treemap { position: relative; width: 100%; aspect-ratio: 21 / 10; border: 1px solid var(--line, rgba(42,36,24,0.18)); border-radius: 3px; overflow: hidden; background: var(--bg, #EDE3C7); }
.cn-tm { position: absolute; box-sizing: border-box; border: 1.5px solid var(--bg, #EDE3C7); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; overflow: hidden; padding: 2px; color: #fff; text-align: center; text-shadow: 0 1px 2px rgba(0,0,0,0.28); }
.cn-tm-sym { font-weight: 700; line-height: 1; letter-spacing: .01em; }
.cn-tm-chg { font-variant-numeric: tabular-nums; opacity: .95; line-height: 1; }
.cn-tm-lg .cn-tm-sym { font-size: 18px; }
.cn-tm-lg .cn-tm-chg { font-size: 12.5px; }
.cn-tm-md .cn-tm-sym { font-size: 12px; }
.cn-tm-md .cn-tm-chg { display: none; }
.cn-tm-initial { display: none; font-weight: 700; font-size: 10px; line-height: 1; }
.cn-tm-sm .cn-tm-sym, .cn-tm-sm .cn-tm-chg { display: none; }
.cn-tm-sm .cn-tm-initial { display: block; }
.cn-hm-strong-up { background: #178a52; }
.cn-hm-up { background: #3aa06e; }
.cn-hm-flat { background: #7c7361; }
.cn-hm-down { background: #c0523f; }
.cn-hm-strong-down { background: #a3342a; }
.cn-hm-legend { display: flex; align-items: center; gap: 5px; margin-top: 16px; font-size: 12px; color: var(--ink3, #8A7E60); }
.cn-hm-swatch { width: 20px; height: 12px; border-radius: 2px; display: inline-block; }
.cn-hm-legend-label { margin: 0 6px; }

/* ---- BTC dominance stats + chart ---- */
.cn-stat-row { display: flex; flex-wrap: wrap; gap: 14px; margin-bottom: 22px; }
.cn-stat { flex: 1 1 180px; padding: 18px 20px; background: var(--plate, #E4D8B6); border: 1px solid var(--line, rgba(42,36,24,0.18)); border-radius: 4px; }
.cn-stat-label { display: block; font-family: Cinzel, serif; font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--ink3, #8A7E60); margin-bottom: 8px; }
.cn-stat-value { font-size: 26px; font-weight: 600; color: var(--ink, #2A2418); font-variant-numeric: tabular-nums; }

.cn-chart { display: flex; gap: 10px; padding: 18px; background: var(--plate, #E4D8B6); border: 1px solid var(--line, rgba(42,36,24,0.18)); border-radius: 4px; }
.cn-chart-axis { display: flex; flex-direction: column; justify-content: space-between; font-size: 12px; color: var(--ink3, #8A7E60); font-variant-numeric: tabular-nums; }
.cn-chart-svg { width: 100%; height: 260px; display: block; overflow: visible; }
.cn-chart-area { fill: color-mix(in srgb, var(--gold, #C8922E) 18%, transparent); stroke: none; }
.cn-chart-line { fill: none; stroke: var(--gold, #C8922E); stroke-width: 2; vector-effect: non-scaling-stroke; }
.cn-chart-caption { margin-top: 10px; font-size: 13px; color: var(--ink3, #8A7E60); text-align: center; }
.cn-muted { color: var(--ink3, #8A7E60); }

/* ---- Fear & Greed: a small sentiment instrument rather than a bare gauge ---- */
.cn-fg { max-width: 560px; margin: 8px auto 0; text-align: center; }
.cn-fg-panel {
    position: relative; overflow: hidden; padding: 18px 28px 25px; border: 1px solid var(--line, rgba(42,36,24,0.2)); border-radius: 8px;
    background: radial-gradient(circle at 50% 78%, color-mix(in srgb, var(--fg-active, var(--gold, #C8922E)) 14%, transparent), transparent 46%), var(--plate, #E4D8B6);
    box-shadow: 0 14px 28px color-mix(in srgb, var(--ink, #2A2418) 8%, transparent);
}
.cn-fg-panel::before { content: ""; position: absolute; width: 230px; height: 230px; left: 50%; bottom: -164px; transform: translateX(-50%); border: 1px solid color-mix(in srgb, var(--fg-active, var(--gold, #C8922E)) 34%, transparent); border-radius: 50%; pointer-events: none; }
.cn-fg-panel-head { position: relative; z-index: 1; display: flex; justify-content: space-between; gap: 16px; color: var(--ink3, #8A7E60); font-family: Cinzel, serif; font-size: 10px; font-weight: 700; letter-spacing: .13em; text-transform: uppercase; }
.cn-fg-gauge-wrap { position: relative; z-index: 1; max-width: 430px; margin: 8px auto 0; }
.cn-fg-svg { display: block; width: 100%; height: auto; overflow: visible; filter: drop-shadow(0 5px 5px color-mix(in srgb, var(--ink, #2A2418) 10%, transparent)); }
.cn-fg-seg { fill: none; stroke-width: 13; }
.cn-fg-needle { stroke: var(--ink, #2A2418); stroke-width: 3; stroke-linecap: round; }
.cn-fg-hub { fill: var(--plate, #E4D8B6); stroke: var(--ink, #2A2418); stroke-width: 2; }
.cn-fg-endpoints { display: flex; justify-content: space-between; margin: -2px 5px 0; color: var(--ink3, #8A7E60); font-size: 11px; letter-spacing: .03em; }
.cn-fg-endpoints b { color: var(--ink2, #5C5238); font-variant-numeric: tabular-nums; }
.cn-fg-readout { position: relative; z-index: 1; margin-top: 7px; }
.cn-fg-reading-label { display: block; color: var(--ink3, #8A7E60); font-family: Cinzel, serif; font-size: 10px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; }
.cn-fg-score { display: flex; align-items: baseline; justify-content: center; gap: 5px; margin-top: 2px; }
.cn-fg-value { display: block; font-size: 64px; font-weight: 700; line-height: .9; letter-spacing: -2px; color: var(--ink, #2A2418); font-variant-numeric: tabular-nums; }
.cn-fg-out-of { color: var(--ink3, #8A7E60); font-size: 14px; font-variant-numeric: tabular-nums; }
.cn-fg-class { display: inline-flex; align-items: center; gap: 7px; margin-top: 7px; padding: 5px 10px; border: 1px solid color-mix(in srgb, var(--fg-active, var(--gold, #C8922E)) 52%, transparent); border-radius: 999px; background: color-mix(in srgb, var(--fg-active, var(--gold, #C8922E)) 12%, transparent); color: var(--fg-active, var(--gold, #C8922E)); font-family: Cinzel, serif; font-size: 11px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; }
.cn-fg-class::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; box-shadow: 0 0 0 3px color-mix(in srgb, currentColor 16%, transparent); }
.cn-fg-zones { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 7px; margin-top: 12px; }
.cn-fg-zone { display: flex; min-width: 0; align-items: flex-start; gap: 7px; padding: 9px 7px; border: 1px solid var(--line, rgba(42,36,24,0.2)); border-radius: 5px; background: color-mix(in srgb, var(--plate, #E4D8B6) 58%, transparent); text-align: left; }
.cn-fg-zone.is-active { border-color: var(--fg-zone); box-shadow: inset 0 0 0 1px var(--fg-zone), 0 5px 13px color-mix(in srgb, var(--fg-zone) 17%, transparent); background: color-mix(in srgb, var(--fg-zone) 12%, var(--plate, #E4D8B6)); }
.cn-fg-swatch { width: 8px; height: 8px; margin-top: 3px; border-radius: 50%; flex: 0 0 auto; }
.cn-fg-zone-copy { display: grid; min-width: 0; gap: 2px; }
.cn-fg-zone-name { font-family: Cinzel, serif; font-size: 9px; font-weight: 700; line-height: 1.25; letter-spacing: .035em; text-transform: uppercase; color: var(--ink2, #5C5238); }
.cn-fg-zone-range { font-size: 11px; line-height: 1; color: var(--ink3, #8A7E60); font-variant-numeric: tabular-nums; }

@media (max-width: 640px) {
    .cn-section { padding-left: 16px; padding-right: 16px; }
    .cn-hide-sm { display: none; }
    .cn-stat-value { font-size: 22px; }
    .cn-fg-panel { padding: 16px 14px 22px; border-radius: 7px; }
    .cn-fg-panel-head { font-size: 9px; }
    .cn-fg-gauge-wrap { margin-top: 12px; }
    .cn-fg-endpoints { margin-left: 0; margin-right: 0; }
    .cn-fg-value { font-size: 52px; }
    .cn-fg-zones { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; margin-top: 10px; }
    .cn-fg-zone { padding: 8px 9px; }
    .cn-fg-zone:last-child { grid-column: span 2; }
    .cn-fg-zone-name { font-size: 9.5px; }
}
