:root {
    --primary: #f7931a;
    --bg-dark: #0f111a;
    --card-bg: rgba(var(--fg), 0.03);
    --card-border: rgba(var(--fg), 0.08);
    --text-main: #e0e0e0;
    --text-dim: #a0a0a0;
    --accent: #00ccff;
    --green: #26e6a4;
    --red: #ff5c5c;
    --orange: #ffaa00;
    --ink: #fff;
    --fg: 255, 255, 255;
    --bg-rgb: 15, 17, 26;
    /* Series colours, validated for colourblind separation against each theme's surface */
    --binance: #b88800;
    --okx: #1a9fe0;
    --surface: #0f111a;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { width: 100%; }
body {
    background: radial-gradient(circle at 50% -20%, #1e2130, #0f111a);
    background-color: var(--bg-dark);
    color: var(--text-main);
    font-family: 'Figtree', sans-serif;
    font-weight: 300;
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
}
.top-nav {
    padding: 20px 40px;
    display: flex; justify-content: space-between; align-items: center;
    background: rgba(var(--bg-rgb), .8); backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--card-border);
    position: sticky; top: 0; z-index: 1000;
}
.logo-link { display: flex; align-items: center; gap: 12px; text-decoration: none; color: var(--text-main); }
.nav-logo { height: 32px; }
.nav-status { font-size: .78rem; color: var(--text-dim); display: flex; align-items: center; gap: 8px; }
/* The footer makes body a flex column: min-width 0 stops the wide tables from stretching the page */
.container { width: 100%; min-width: 0; max-width: 1500px; margin: 0 auto; padding: 40px 24px 60px; }
header { text-align: center; margin-bottom: 28px; }
.status-badge {
    display: inline-flex; align-items: center; gap: 8px;
    font-size: .72rem; letter-spacing: 2px;
    color: var(--green); border: 1px solid rgba(38,230,164,.3);
    background: rgba(38,230,164,.07); padding: 6px 16px; border-radius: 20px; margin-bottom: 14px;
}
h1 {
    font-size: 2.8rem; font-weight: 300; letter-spacing: -1px;
    background: linear-gradient(135deg, var(--primary), #ffc107);
    -webkit-background-clip: text; -webkit-text-fill-color: transparent; margin-bottom: 8px;
}
.subheader { color: var(--text-dim); max-width: 760px; margin: 0 auto; font-size: 1rem; }

/* Stat tiles */
.strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px,1fr)); gap: 14px; margin-bottom: 18px; }
.tile { background: var(--card-bg); border: 1px solid var(--card-border); border-radius: 16px; padding: 18px; text-align: center; }
.tile-label { font-size: .68rem; letter-spacing: 2px; color: var(--text-dim); margin-bottom: 4px; text-transform: uppercase; }
.tile-value { font-size: 1.7rem; font-weight: 300; color: var(--ink); }
.tile-sub { font-size: .8rem; color: var(--text-dim); margin-top: 2px; }

/* Controls */
.controls, .range-row { display: flex; gap: 14px; align-items: center; justify-content: center; flex-wrap: wrap; margin-bottom: 18px; }
.range-row { margin: 10px 0 6px; }
.seg { display: inline-flex; border: 1px solid var(--card-border); border-radius: 22px; padding: 3px; gap: 2px; }
.seg button {
    font-size: .82rem; padding: 7px 18px; border-radius: 18px; border: none;
    background: transparent; color: var(--text-dim); cursor: pointer; transition: all .2s;
}
.seg button:hover { color: var(--accent); }
.seg button.active { background: rgba(0,204,255,.12); color: var(--accent); }
.chips { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; margin: -6px auto 22px; max-width: 1100px; }
.chip {
    font-size: .8rem; padding: 6px 14px; border-radius: 18px; border: 1px solid var(--card-border);
    background: transparent; color: var(--text-dim); cursor: pointer; transition: all .2s;
}
.chip small { opacity: .7; margin-left: 4px; }
.chip:hover { border-color: var(--accent); color: var(--accent); }
.chip.active { border-color: var(--accent); color: var(--accent); background: rgba(0,204,255,.12); }
:root[data-theme="light"] .chip.active { background: rgba(2, 119, 181, 0.1); }
.check { font-size: .85rem; color: var(--text-dim); display: inline-flex; gap: 8px; align-items: center; cursor: pointer; }
.btn {
    font-size: .8rem; letter-spacing: 1px;
    padding: 8px 14px; border-radius: 12px; cursor: pointer; border: 1px solid var(--accent);
    background: rgba(0,204,255,.08); color: var(--accent); transition: all .2s;
}
.btn:hover { background: rgba(0,204,255,.16); }
.btn.ghost { border-color: var(--card-border); color: var(--text-dim); background: transparent; }
.btn.ghost:hover { color: var(--accent); border-color: var(--accent); }
.btn:disabled { opacity: .35; cursor: default; }

/* Sections */
.section { background: var(--card-bg); border: 1px solid var(--card-border); border-radius: 18px; padding: 24px; margin-bottom: 18px; text-align: center; }
.section h2 { font-size: 1.15rem; font-weight: 400; color: var(--ink); margin-bottom: 4px; display: flex; align-items: center; justify-content: center; gap: 8px; }
.section h2 i { color: var(--accent); }
.section-desc { color: var(--text-dim); font-size: .88rem; margin-bottom: 12px; }

/* Legend */
.legend { display: flex; gap: 18px; justify-content: center; font-size: .82rem; color: var(--text-dim); margin-bottom: 10px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }

/* Bar charts: one flex column per period, stacked segments Binance (bottom) + OKX (top) */
.chart { position: relative; height: clamp(260px, 38vh, 460px); display: flex; padding: 0 0 26px 44px; }
.plot { position: relative; flex: 1; display: flex; align-items: flex-end; gap: 2px; border-bottom: 1px solid var(--card-border); }
.grid-line { position: absolute; left: 0; right: 0; border-top: 1px dashed rgba(var(--fg), .07); pointer-events: none; }
.grid-label { position: absolute; left: -44px; width: 38px; text-align: right; font-size: .7rem; color: var(--text-dim); transform: translateY(-50%); }
.col { flex: 1; height: 100%; display: flex; flex-direction: column-reverse; justify-content: flex-start; gap: 2px; cursor: pointer; position: relative; min-width: 0; }
.col:hover { background: rgba(var(--fg), .05); }
.col.sel { background: rgba(0,204,255,.12); }
.seg-b, .seg-o { width: 100%; max-width: 46px; margin: 0 auto; flex: none; }
.seg-b { background: var(--binance); }
.seg-o { background: var(--okx); }
.col > :last-child { border-radius: 4px 4px 0 0; }
.x-label { position: absolute; bottom: -22px; left: 50%; transform: translateX(-50%); font-size: .68rem; color: var(--text-dim); white-space: nowrap; pointer-events: none; }

.tip {
    position: fixed; z-index: 3000; pointer-events: none; min-width: 150px;
    background: rgba(var(--bg-rgb), .96); border: 1px solid var(--card-border); border-radius: 10px;
    padding: 8px 12px; font-size: .8rem; color: var(--text-main); text-align: center;
    box-shadow: 0 8px 24px rgba(0,0,0,.35);
}
.tip b { color: var(--ink); font-weight: 600; display: block; margin-bottom: 2px; }
.tip .row { display: flex; justify-content: space-between; gap: 14px; }
.tip .row i { width: 10px; height: 10px; border-radius: 2px; display: inline-block; margin-right: 6px; }

/* Tables */
.table-wrap { overflow: auto; max-height: calc(100vh - 220px); border: 1px solid var(--card-border); border-radius: 12px; }
.table-wrap:has(table:empty) { display: none; }
.coin-table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.coin-table th, .coin-table td { padding: 8px 12px; text-align: center; border-bottom: 1px solid var(--card-border); }
.coin-table th { position: sticky; top: 0; background: rgba(var(--bg-rgb), .97); color: var(--text-dim); font-weight: 600; font-size: .72rem; letter-spacing: 1px; text-transform: uppercase; }
.coin-table td.coin { color: var(--ink); font-weight: 600; }
.coin-table tbody tr.click { cursor: pointer; }
.coin-table tbody tr.click:hover { background: rgba(0,204,255,.06); }
.coin-table tbody tr.sel { background: rgba(0,204,255,.12); }
.ex-pill { font-size: .7rem; letter-spacing: 1px; padding: 2px 10px; border-radius: 10px; border: 1px solid; white-space: nowrap; }
.ex-pill.Binance { color: var(--binance); border-color: color-mix(in srgb, var(--binance) 30%, transparent); }
.ex-pill.OKX { color: var(--okx); border-color: color-mix(in srgb, var(--okx) 30%, transparent); }
.ex-pill .ex-ico { box-shadow: none; }
.delisted { color: var(--red); font-size: .72rem; }
.coin-table a { color: inherit; text-decoration: none; border-bottom: 1px dotted var(--text-dim); }
.coin-table a:hover { color: var(--accent); border-color: var(--accent); }
.cat-pill { font-size: .74rem; color: var(--text-main); white-space: nowrap; }
/* Heatmap: one hue, cell alpha grows with the count */
.heat td.h { cursor: pointer; font-variant-numeric: tabular-nums; background: rgba(0, 204, 255, var(--a, 0)); }
.heat td.h:hover { outline: 2px solid var(--accent); outline-offset: -2px; }
.heat td.zero { color: rgba(var(--fg), .2); }
.heat tr.all td { font-weight: 600; border-bottom: 2px solid var(--card-border); }
/* Equal columns, headers wrap onto two lines, so all 12 categories fit without sideways scrolling */
.heat { table-layout: fixed; }
.heat th { white-space: normal; line-height: 1.3; padding: 8px 4px; vertical-align: bottom; }
.heat td { padding: 7px 4px; }
.heat th:first-child, .heat td:first-child { width: 100px; white-space: nowrap; }
.heat th:last-child { width: 64px; }
.cat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; }
.cat-card { background: rgba(var(--fg), .025); border: 1px solid var(--card-border); border-radius: 14px; padding: 16px 18px; cursor: pointer; transition: border-color .2s; text-align: center; }
.cat-card:hover { border-color: var(--accent); }
.cat-card.active { border-color: var(--accent); background: rgba(0,204,255,.06); }
.cat-card h3 { font-size: 1rem; font-weight: 600; color: var(--ink); }
.cat-card .cat-n { font-size: .78rem; color: var(--accent); margin-bottom: 8px; }
.cat-card p { font-size: .86rem; color: var(--text-main); text-align: left; margin-bottom: 8px; }
.cat-card .ex { font-size: .78rem; color: var(--text-dim); }
.cat-card .ex b { color: var(--ink); font-weight: 600; }
.cat-card .tags { font-size: .7rem; color: var(--text-dim); opacity: .8; margin-top: 6px; }
:root[data-theme="light"] .cat-card { background: #f7f8fb; }
/* Success & usage */
.sub-h { font-size: .95rem; font-weight: 600; color: var(--ink); margin: 22px 0 10px; }
.stats th { line-height: 1.3; vertical-align: bottom; }
.stats tbody tr:last-child td { border-bottom: none; }
.up { color: var(--green); }
.down { color: var(--red); }
.na { color: var(--text-dim); opacity: .7; }
.foot-note { margin: 12px 0 0; font-size: .78rem; }

/* Exchange logos and category icons */
.ex-ico { width: 15px; height: 15px; border-radius: 50%; vertical-align: -3px; margin-right: 6px; object-fit: contain; box-shadow: 0 0 0 1px rgba(var(--fg), .25); }
.legend .ex-ico, .tip .ex-ico { margin-right: 4px; }
.cat-ico { margin-right: 6px; font-size: 1em; }
.cat-card h3 .cat-ico { font-size: 1.15em; }
.th-ico { display: block; font-size: 1.1rem; line-height: 1.2; }
.th-ico .cat-ico { margin: 0; }
.top-cat { color: var(--ink); font-weight: 600; }
.top-cat + small { color: var(--text-dim); font-weight: 300; margin-left: 6px; }
:root[data-theme="light"] .heat td.h { background: rgba(2, 119, 181, var(--a, 0)); }
.empty { color: var(--text-dim); padding: 18px; }

.warn-box { border: 1px dashed rgba(255,170,0,.4); background: rgba(255,170,0,.05); border-radius: 14px; padding: 16px 18px; font-size: .85rem; color: var(--text-dim); margin-bottom: 40px; text-align: left; }
.warn-box strong { color: var(--orange); font-weight: 400; }
.warn-box li { margin-left: 18px; }
@media (max-width: 640px) { h1 { font-size: 2rem; } .top-nav { padding: 14px 18px; } .container { padding: 24px 14px 50px; } .chart { padding-left: 34px; } .grid-label { left: -36px; width: 30px; } }

button, input, select, textarea, code, kbd, pre { font-family: inherit; }

/* Bright skin */
:root[data-theme="light"] {
    --bg-dark: #f4f6fa;
    --card-bg: #ffffff;
    --card-border: rgba(20, 24, 40, 0.12);
    --text-main: #1a1d29;
    --text-dim: #4a5068;
    --accent: #0277b5;
    --green: #047857;
    --red: #dc2626;
    --orange: #b45309;
    --ink: #0b0d14;
    --fg: 20, 24, 40;
    --bg-rgb: 255, 255, 255;
    --binance: #b7860b;
    --okx: #0277b5;
    --surface: #ffffff;
}
:root[data-theme="light"] body { background: radial-gradient(circle at 50% -20%, #ffffff, #eef1f6); background-color: var(--bg-dark); }
:root[data-theme="light"] .top-nav { background: rgba(255, 255, 255, 0.85); }
:root[data-theme="light"] h1 { background: linear-gradient(135deg, #c2410c, #e88a00); -webkit-background-clip: text; }
:root[data-theme="light"] .tile, :root[data-theme="light"] .section { box-shadow: 0 1px 3px rgba(20, 24, 40, 0.08); }
:root[data-theme="light"] .status-badge { border-color: rgba(4, 120, 87, 0.3); background: rgba(16, 185, 129, 0.08); }
:root[data-theme="light"] .seg button.active { background: rgba(2, 119, 181, 0.1); }
:root[data-theme="light"] .btn { background: rgba(2, 119, 181, 0.06); }
:root[data-theme="light"] .btn.ghost { background: transparent; }
:root[data-theme="light"] .tip { box-shadow: 0 8px 24px rgba(20, 24, 40, 0.15); }
:root[data-theme="light"] .warn-box { border-color: rgba(217, 119, 6, 0.45); background: rgba(245, 158, 11, 0.06); }
