/* ==========================================================================
   CryptoCorrelator 3 — design system
   ========================================================================== */

:root {
	--font-sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
	--font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

	--radius-xs: 6px;
	--radius-sm: 9px;
	--radius: 14px;
	--radius-lg: 20px;

	--topbar-h: 60px;
	--ease: cubic-bezier(.2, .8, .2, 1);
	--t-fast: .15s var(--ease);
	--t: .25s var(--ease);

	--accent-grad: linear-gradient(135deg, #22d3ee 0%, #6366f1 55%, #a855f7 100%);
	--up: #2ee59d;
	--down: #ff5c7a;
	--warn: #f5a524;
	--danger: #ff4d6d;

	color-scheme: dark;
}

/* ---------- Dark (default) */
:root,
[data-theme="dark"] {
	--bg: #060912;
	--bg-elev: #0b1020;
	--surface: rgba(16, 21, 37, .72);
	--surface-solid: #111727;
	--surface-2: rgba(255, 255, 255, .035);
	--surface-3: rgba(255, 255, 255, .06);
	--surface-hover: rgba(255, 255, 255, .07);
	--border: rgba(148, 163, 209, .12);
	--border-strong: rgba(148, 163, 209, .22);
	--text: #e8ecf6;
	--text-2: #a1aac0;
	--text-3: #6c7590;
	--accent: #7c8cff;
	--accent-2: #22d3ee;
	--accent-soft: rgba(124, 140, 255, .14);
	--focus: rgba(124, 140, 255, .55);
	--plot-bg: rgba(5, 8, 16, .55);
	--shadow: 0 1px 0 rgba(255, 255, 255, .04) inset, 0 12px 32px -12px rgba(0, 0, 0, .6);
	--shadow-pop: 0 24px 60px -12px rgba(0, 0, 0, .7), 0 0 0 1px var(--border-strong);
	--glow-a: rgba(56, 189, 248, .10);
	--glow-b: rgba(139, 92, 246, .10);
}

/* ---------- Light */
[data-theme="light"] {
	color-scheme: light;
	--bg: #eef1f8;
	--bg-elev: #ffffff;
	--surface: rgba(255, 255, 255, .78);
	--surface-solid: #ffffff;
	--surface-2: rgba(15, 23, 42, .035);
	--surface-3: rgba(15, 23, 42, .06);
	--surface-hover: rgba(15, 23, 42, .06);
	--border: rgba(15, 23, 42, .09);
	--border-strong: rgba(15, 23, 42, .16);
	--text: #0d1424;
	--text-2: #4a5671;
	--text-3: #7d879e;
	--accent: #4f5bea;
	--accent-2: #0891b2;
	--accent-soft: rgba(79, 91, 234, .10);
	--focus: rgba(79, 91, 234, .45);
	--plot-bg: rgba(255, 255, 255, .7);
	--up: #0fa36b;
	--down: #e11d48;
	--shadow: 0 1px 2px rgba(15, 23, 42, .05), 0 10px 30px -14px rgba(15, 23, 42, .18);
	--shadow-pop: 0 24px 60px -16px rgba(15, 23, 42, .28), 0 0 0 1px var(--border);
	--glow-a: rgba(56, 189, 248, .16);
	--glow-b: rgba(139, 92, 246, .12);
}

/* ---------- Base */
*, *::before, *::after { box-sizing: border-box; }

html {
	-webkit-text-size-adjust: 100%;
	text-size-adjust: 100%;
	scroll-padding-top: calc(var(--topbar-h) + 72px);
}

body {
	margin: 0;
	min-height: 100vh;
	min-height: 100dvh;
	display: flex;
	flex-direction: column;
	background: var(--bg);
	color: var(--text);
	font: 400 14px/1.5 var(--font-sans);
	font-feature-settings: "cv11", "ss01";
	-webkit-font-smoothing: antialiased;
	-moz-osx-font-smoothing: grayscale;
	transition: background-color var(--t), color var(--t);
}

img, svg { vertical-align: middle; }
[hidden] { display: none !important; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
::selection { background: var(--accent-soft); }

h1, h2, h3, h4 { margin: 0; line-height: 1.2; letter-spacing: -.01em; }
.h2 { font-size: 22px; font-weight: 700; }
.h3 { font-size: 16px; font-weight: 650; }
p { margin: 0; }
kbd {
	font: 500 11px var(--font-mono);
	padding: 1px 6px;
	border-radius: 5px;
	border: 1px solid var(--border-strong);
	border-bottom-width: 2px;
	background: var(--surface-2);
}

.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.icon { width: 18px; height: 18px; flex: none; }
.icon--xs { width: 13px; height: 13px; }
.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.muted { color: var(--text-2); }
.small { font-size: 12.5px; }
.sr-only {
	position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
	overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip-link {
	position: fixed; left: 12px; top: -60px; z-index: 100;
	padding: 8px 14px; border-radius: var(--radius-sm);
	background: var(--accent); color: #fff;
}
.skip-link:focus { top: 12px; }

.eyebrow {
	display: inline-flex; align-items: center; gap: 6px;
	margin: 0 0 10px;
	font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase;
	color: var(--text-3);
}
.eyebrow .icon { width: 14px; height: 14px; }
.eyebrow--accent { color: var(--accent); }

.gradient-text {
	background: var(--accent-grad);
	-webkit-background-clip: text;
	background-clip: text;
	color: transparent;
}

/* Soft ambient light behind everything */
.backdrop-glow {
	position: fixed; inset: 0; z-index: -1; pointer-events: none;
	background:
		radial-gradient(900px 500px at 8% -10%, var(--glow-a), transparent 60%),
		radial-gradient(800px 600px at 105% 10%, var(--glow-b), transparent 60%);
}

/* ---------- Surfaces */
.card {
	position: relative;
	background: var(--surface-solid);
	border: 1px solid var(--border);
	border-radius: var(--radius);
	box-shadow: var(--shadow);
}
.card--pad { padding: 22px; }
.glass { background: var(--surface-solid); }
[data-glass="1"] .glass {
	background: var(--surface);
	-webkit-backdrop-filter: blur(18px) saturate(150%);
	backdrop-filter: blur(18px) saturate(150%);
}

/* ---------- Buttons */
.btn {
	display: inline-flex; align-items: center; justify-content: center; gap: 7px;
	height: 38px; padding: 0 16px;
	border: 1px solid transparent; border-radius: var(--radius-sm);
	font-weight: 600; font-size: 13.5px; white-space: nowrap;
	text-decoration: none !important;
	transition: background var(--t-fast), border-color var(--t-fast), color var(--t-fast), transform var(--t-fast), box-shadow var(--t-fast), opacity var(--t-fast);
	user-select: none;
}
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn.is-busy { opacity: .6; pointer-events: none; }
.btn .icon { width: 16px; height: 16px; }
.btn--sm { height: 32px; padding: 0 12px; font-size: 13px; }
.btn--xs { height: 26px; padding: 0 9px; font-size: 12px; gap: 5px; }
.btn--xs .icon { width: 13px; height: 13px; }
.btn--block { width: 100%; }

.btn--primary {
	color: #fff;
	background: var(--accent-grad);
	background-size: 140% 140%;
	box-shadow: 0 6px 20px -8px rgba(99, 102, 241, .7), inset 0 1px 0 rgba(255, 255, 255, .25);
}
.btn--primary:hover { background-position: 100% 0; box-shadow: 0 8px 26px -8px rgba(99, 102, 241, .9), inset 0 1px 0 rgba(255, 255, 255, .25); }
.btn--secondary { background: var(--surface-3); border-color: var(--border); color: var(--text); }
.btn--secondary:hover { background: var(--surface-hover); border-color: var(--border-strong); }
.btn--ghost { background: transparent; color: var(--text-2); }
.btn--ghost:hover { background: var(--surface-3); color: var(--text); }
.btn--danger { background: rgba(255, 77, 109, .14); color: var(--danger); border-color: rgba(255, 77, 109, .3); }
.btn--danger:hover { background: rgba(255, 77, 109, .24); }
.btn--warn { background: rgba(245, 165, 36, .14); color: var(--warn); border-color: rgba(245, 165, 36, .3); }
.btn--warn:hover { background: rgba(245, 165, 36, .24); }
.btn--donate .icon { color: #ff6b8b; }

.icon-btn {
	display: inline-grid; place-items: center;
	width: 38px; height: 38px; padding: 0;
	border: 1px solid transparent; border-radius: var(--radius-sm);
	background: transparent; color: var(--text-2);
	position: relative;
	transition: background var(--t-fast), color var(--t-fast), border-color var(--t-fast);
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.icon-btn--boxed { width: 34px; height: 32px; background: var(--surface-3); border-color: var(--border); }
.icon-btn--boxed:hover { border-color: var(--border-strong); }
.icon-btn--boxed.is-active { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }
.icon-btn--sm { width: 28px; height: 28px; }
.icon-btn--sm .icon { width: 16px; height: 16px; }
.icon-btn--in { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); width: 32px; height: 32px; }

.badge {
	display: inline-flex; align-items: center; height: 20px; padding: 0 8px;
	border-radius: 999px; font-size: 11px; font-weight: 600; letter-spacing: .02em;
	background: var(--surface-3); color: var(--text-2);
}
.badge--plan { background: var(--accent-soft); color: var(--accent); }

.avatar {
	display: inline-grid; place-items: center;
	width: 28px; height: 28px; border-radius: 50%;
	background: var(--accent-grad); color: #fff;
	font-weight: 700; font-size: 13px;
	box-shadow: 0 0 0 2px var(--bg);
}
.avatar--lg { width: 48px; height: 48px; font-size: 20px; }

.dot-badge {
	position: absolute; top: 5px; right: 5px; width: 8px; height: 8px;
	border-radius: 50%; background: var(--down); box-shadow: 0 0 0 2px var(--bg);
}
.count-badge:not(:empty) {
	min-width: 20px; height: 18px; padding: 0 6px; border-radius: 999px;
	display: inline-grid; place-items: center;
	background: var(--surface-3); font-size: 11px; color: var(--text-2);
}

/* ---------- Top bar */
.topbar {
	position: sticky; top: 0; z-index: 40;
	display: flex; align-items: center; gap: 14px;
	height: var(--topbar-h);
	padding: 0 max(16px, env(safe-area-inset-left)) 0 max(16px, env(safe-area-inset-left));
	background: color-mix(in srgb, var(--bg) 88%, transparent);
	border-bottom: 1px solid var(--border);
}
[data-glass="1"] .topbar {
	background: color-mix(in srgb, var(--bg) 62%, transparent);
	-webkit-backdrop-filter: blur(20px) saturate(160%);
	backdrop-filter: blur(20px) saturate(160%);
}

.brand {
	display: inline-flex; align-items: center; gap: 10px;
	color: var(--text); text-decoration: none !important;
	font-size: 16.5px; letter-spacing: -.02em; white-space: nowrap;
}
.brand__mark {
	display: grid; place-items: center;
	width: 34px; height: 34px; border-radius: 10px;
	background: var(--accent-grad); color: #fff;
	box-shadow: 0 6px 18px -6px rgba(99, 102, 241, .8);
}
.brand__mark .icon { width: 20px; height: 20px; }
.brand__name { font-weight: 500; }
.brand__name strong { font-weight: 750; }

.topnav { display: flex; gap: 2px; margin-left: 8px; }
.topnav__link {
	display: inline-flex; align-items: center; gap: 7px;
	height: 34px; padding: 0 11px; border-radius: var(--radius-sm);
	color: var(--text-2); font-weight: 500; font-size: 13.5px;
	text-decoration: none !important;
	transition: background var(--t-fast), color var(--t-fast);
}
.topnav__link .icon { width: 16px; height: 16px; }
.topnav__link:hover { color: var(--text); background: var(--surface-3); }
.topnav__link.is-active { color: var(--text); background: var(--surface-3); box-shadow: inset 0 0 0 1px var(--border); }

.topbar__actions { display: flex; align-items: center; gap: 6px; margin-left: auto; flex-shrink: 0; }
.topnav { min-width: 0; overflow: hidden; }

.account-btn {
	display: inline-flex; align-items: center; gap: 9px;
	height: 38px; padding: 0 10px 0 5px;
	border: 1px solid var(--border); border-radius: 999px;
	background: var(--surface-2);
	transition: background var(--t-fast), border-color var(--t-fast);
}
.account-btn:hover { background: var(--surface-3); border-color: var(--border-strong); }
.account-btn__name { font-weight: 600; font-size: 13px; max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

#theme-toggle .icon--sun { display: none; }
[data-theme="light"] #theme-toggle .icon--sun { display: block; }
[data-theme="light"] #theme-toggle .icon--moon { display: none; }

/* Connection status */
.status-pill {
	display: inline-flex; align-items: center; gap: 8px;
	height: 28px; padding: 0 11px 0 9px;
	border-radius: 999px; border: 1px solid var(--border);
	background: var(--surface-2);
	font-size: 12px; font-weight: 600; color: var(--text-2);
	white-space: nowrap;
	cursor: default;
}
.status-pill__dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-3); flex: none; }
.status-pill[data-state="live"] { color: var(--up); border-color: color-mix(in srgb, var(--up) 30%, transparent); }
.status-pill[data-state="live"] .status-pill__dot { background: var(--up); box-shadow: 0 0 0 0 var(--up); animation: pulse 2s infinite; }
.status-pill[data-state="paused"] { color: var(--warn); }
.status-pill[data-state="paused"] .status-pill__dot { background: var(--warn); }
.status-pill[data-state="connecting"] .status-pill__dot { background: var(--accent); animation: blink 1s infinite; }
.status-pill[data-state="offline"], .status-pill[data-state="error"] { color: var(--down); cursor: pointer; }
.status-pill[data-state="offline"] .status-pill__dot, .status-pill[data-state="error"] .status-pill__dot { background: var(--down); }
.status-pill[data-state="demo"] { color: var(--accent-2); }
.status-pill[data-state="history"] { color: var(--accent); }
.status-pill[data-state="history"] .status-pill__dot { background: var(--accent); }
.status-pill[data-state="demo"] .status-pill__dot { background: var(--accent-2); animation: pulse 2s infinite; }

@keyframes pulse {
	0% { box-shadow: 0 0 0 0 color-mix(in srgb, currentColor 60%, transparent); }
	70% { box-shadow: 0 0 0 7px transparent; }
	100% { box-shadow: 0 0 0 0 transparent; }
}
@keyframes blink { 50% { opacity: .3; } }

/* ---------- Dashboard layout
   No z-index here on purpose: the toolbar (z 20), tooltip (30) and windows (35)
   must stack above the WebGL canvas (10) while chart cards stay below it. */
.dashboard {
	flex: 1;
	width: 100%;
	max-width: 1720px;
	margin: 0 auto;
	padding: 14px max(16px, env(safe-area-inset-right)) 28px max(16px, env(safe-area-inset-left));
}

.toolbar {
	position: sticky; top: calc(var(--topbar-h) + 8px); z-index: 20;
	display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px;
	padding: 9px 10px 9px 14px;
	margin-bottom: 14px;
	border-radius: var(--radius);
	border: 1px solid var(--border);
	background: var(--surface-solid);
	box-shadow: var(--shadow);
}
[data-glass="1"] .toolbar {
	background: var(--surface);
	-webkit-backdrop-filter: blur(20px) saturate(160%);
	backdrop-filter: blur(20px) saturate(160%);
}
.toolbar__group { display: flex; align-items: center; gap: 10px; }
.toolbar__group--end { gap: 8px; }
.toolbar__label {
	display: inline-flex; align-items: center; gap: 6px;
	font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em;
	color: var(--text-3);
}
.toolbar__label .icon { width: 14px; height: 14px; }
.toolbar__spacer { flex: 1; }

.segmented {
	display: inline-flex; padding: 3px; gap: 2px;
	border-radius: 10px;
	background: var(--surface-2);
	border: 1px solid var(--border);
}
.segmented__btn {
	display: inline-flex; align-items: center; gap: 5px;
	height: 28px; padding: 0 11px;
	border: 0; border-radius: 7px;
	background: transparent; color: var(--text-2);
	font: 600 12.5px var(--font-mono); letter-spacing: -.02em;
	transition: background var(--t-fast), color var(--t-fast), box-shadow var(--t-fast);
}
.segmented__btn:hover { color: var(--text); }
.segmented__btn[aria-checked="true"] {
	background: var(--surface-solid);
	color: var(--text);
	box-shadow: 0 1px 3px rgba(0, 0, 0, .25), 0 0 0 1px var(--border-strong);
}
[data-theme="dark"] .segmented__btn[aria-checked="true"] { background: rgba(255, 255, 255, .1); }
.segmented__btn.is-locked { color: var(--text-3); }
.segmented__btn.is-locked .icon { opacity: .8; }
.segmented--sm .segmented__btn { height: 26px; padding: 0 9px; font-size: 12px; font-family: var(--font-sans); }

.btn--play {
	height: 32px; padding: 0 13px 0 11px; gap: 7px;
	border-radius: var(--radius-sm);
	background: color-mix(in srgb, var(--up) 14%, transparent);
	border: 1px solid color-mix(in srgb, var(--up) 35%, transparent);
	color: var(--up);
	font-size: 13px;
}
.btn--play .icon { width: 14px; height: 14px; }
.btn--play .icon--play { display: none; }
.btn--play[aria-pressed="true"] { background: color-mix(in srgb, var(--warn) 14%, transparent); border-color: color-mix(in srgb, var(--warn) 40%, transparent); color: var(--warn); }
.btn--play[aria-pressed="true"] .icon--play { display: block; }
.btn--play[aria-pressed="true"] .icon--pause { display: none; }

.pair-chip { font: 600 13px var(--font-mono); }
.segmented__btn:disabled { opacity: .35; cursor: default; }
.segmented__btn .icon--xs { width: 15px; height: 15px; }

/* Timeline scrollbar (visible while zoomed in or looking at history) */
.timeline {
	flex-basis: 100%;
	display: flex; align-items: center; gap: 12px;
	padding: 2px 2px 0;
	animation: drop-in .2s var(--ease);
}
.timeline__track {
	position: relative; flex: 1; height: 22px;
	border-radius: 7px;
	background: var(--surface-2);
	border: 1px solid var(--border);
	cursor: pointer; touch-action: none;
	background-image: repeating-linear-gradient(90deg, transparent 0 calc(10% - 1px), var(--border) calc(10% - 1px) 10%);
}
.timeline__thumb {
	position: absolute; top: 2px; bottom: 2px; min-width: 6px;
	border-radius: 5px;
	background: color-mix(in srgb, var(--accent) 28%, transparent);
	border: 1px solid var(--accent);
	cursor: grab;
	transition: background var(--t-fast);
}
.timeline__thumb:hover, .timeline__track.is-dragging .timeline__thumb { background: color-mix(in srgb, var(--accent) 42%, transparent); }
.timeline__track.is-dragging .timeline__thumb { cursor: grabbing; }
.timeline__label { font-size: 12px; color: var(--text-2); white-space: nowrap; }
.timeline .btn .icon { width: 12px; height: 12px; }

.freeze-banner {
	position: sticky; top: calc(var(--topbar-h) + 72px); z-index: 19;
	display: flex; align-items: center; gap: 10px;
	width: fit-content; max-width: 100%;
	margin: -4px auto 12px;
	padding: 6px 6px 6px 14px;
	border-radius: 999px;
	background: color-mix(in srgb, var(--warn) 16%, var(--surface-solid));
	border: 1px solid color-mix(in srgb, var(--warn) 40%, transparent);
	color: var(--warn); font-weight: 600; font-size: 13px;
	box-shadow: var(--shadow-pop);
	animation: drop-in .25s var(--ease);
}
.freeze-banner .icon { width: 14px; height: 14px; }

/* ---------- Popovers & menus */
.popover-host { position: relative; }
.popover {
	position: absolute; top: calc(100% + 8px); z-index: 45;
	min-width: 220px; max-height: min(70vh, 480px); overflow: auto;
	padding: 8px;
	border-radius: var(--radius);
	background: var(--surface-solid);
	box-shadow: var(--shadow-pop);
	animation: pop-in .16s var(--ease);
	overscroll-behavior: contain;
}
[data-glass="1"] .popover {
	background: color-mix(in srgb, var(--surface-solid) 86%, transparent);
	-webkit-backdrop-filter: blur(24px) saturate(160%);
	backdrop-filter: blur(24px) saturate(160%);
}
.popover--right { right: 0; }
.popover--fixed { position: fixed; z-index: 45; width: 240px; }
.popover__title { padding: 6px 8px 8px; font-size: 11px; font-weight: 600; letter-spacing: .07em; text-transform: uppercase; color: var(--text-3); }

.menu-list { display: flex; flex-direction: column; gap: 1px; margin-bottom: 6px; }
.menu-item {
	display: flex; align-items: center; gap: 10px;
	width: 100%; min-height: 36px; padding: 6px 10px;
	border: 0; border-radius: var(--radius-xs);
	background: transparent; text-align: left;
	font-size: 13.5px; color: var(--text);
}
.menu-item:hover, .menu-item:focus-visible { background: var(--surface-3); }
.menu-item[aria-selected="true"] { color: var(--accent); font-weight: 600; }
.menu-item__check {
	display: grid; place-items: center;
	width: 18px; height: 18px; border-radius: 5px;
	border: 1.5px solid var(--border-strong);
	transition: background var(--t-fast), border-color var(--t-fast);
}
.menu-item__check .icon { width: 12px; height: 12px; color: #fff; opacity: 0; }
.menu-item[aria-checked="true"] .menu-item__check { background: var(--accent); border-color: var(--accent); }
.menu-item[aria-checked="true"] .menu-item__check .icon { opacity: 1; }

.search {
	display: flex; align-items: center; gap: 8px;
	height: 36px; padding: 0 10px; margin-bottom: 6px;
	border-radius: var(--radius-sm);
	background: var(--surface-2); border: 1px solid var(--border);
	color: var(--text-3);
}
.search .icon { width: 15px; height: 15px; }
.search__input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; font-size: 13.5px; }

@keyframes pop-in { from { opacity: 0; transform: translateY(-4px) scale(.98); } }
@keyframes drop-in { from { opacity: 0; transform: translateY(-8px); } }

/* ---------- Chart cards */
.charts { display: flex; flex-direction: column; gap: 14px; }

.chart-card {
	position: relative;
	border-radius: var(--radius);
	border: 1px solid var(--border);
	background: var(--surface-solid);
	box-shadow: var(--shadow);
	transition: box-shadow var(--t), transform var(--t), opacity var(--t);
}
[data-glass="1"] .chart-card {
	background: var(--surface);
	-webkit-backdrop-filter: blur(16px) saturate(140%);
	backdrop-filter: blur(16px) saturate(140%);
}
.chart-card.is-dragging { z-index: 5; opacity: .92; transform: scale(.995); box-shadow: var(--shadow-pop); }
.chart-card.is-drop-target { box-shadow: 0 0 0 2px var(--accent), var(--shadow); }

.chart-card__head {
	display: flex; align-items: center; gap: 8px;
	min-height: 50px; padding: 7px 8px 7px 6px;
	user-select: none;
}
.chart-card__grip {
	display: grid; place-items: center;
	width: 26px; height: 34px; border-radius: 7px;
	padding: 0; border: 0; background: transparent;
	color: var(--text-3); cursor: grab; touch-action: none;
}
.chart-card__grip:hover { background: var(--surface-3); color: var(--text-2); }
.chart-card__grip:active { cursor: grabbing; }
.chart-card__title { font-size: 14.5px; font-weight: 650; white-space: nowrap; margin-right: 6px; }
.chart-card__title { display: inline-flex; align-items: center; gap: 2px; }
.chart-card__unit { color: var(--text-3); font-weight: 500; font-size: 12px; margin-left: 4px; }
.chart-card__tag { margin-left: 8px; }
.pair-switch {
	display: inline-flex; align-items: center; gap: 5px;
	height: 30px; margin: -2px 0 -2px -4px; padding: 0 8px 0 6px;
	border: 1px solid var(--border); border-radius: 8px;
	background: var(--surface-2); color: var(--text);
	font: inherit; font-weight: 650;
	transition: background var(--t-fast), border-color var(--t-fast);
}
.pair-switch:hover, .pair-switch[aria-expanded="true"] { background: var(--surface-3); border-color: var(--accent); }
.pair-switch .icon { color: var(--text-3); }
.chart-card__stats {
	display: flex; flex-wrap: wrap; gap: 6px;
	flex: 1; min-width: 0;
}
.stat {
	display: inline-flex; align-items: baseline; gap: 6px;
	height: 26px; padding: 4px 9px;
	border-radius: 7px;
	background: var(--surface-2);
	border: 1px solid var(--border);
	white-space: nowrap;
}
.stat__k { font-size: 10.5px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--text-3); }
.stat__v { font: 600 12.5px var(--font-mono); font-variant-numeric: tabular-nums; }
.stat__v.is-up { color: var(--up); }
.stat__v.is-down { color: var(--down); }
.stat--avg .stat__v { font-size: 13px; }

.chart-card__actions { display: flex; gap: 2px; margin-left: auto; }
.chart-card__actions .icon-btn { width: 32px; height: 32px; }
.chart-card__actions .icon-btn .icon { width: 16px; height: 16px; }
.chart-card__actions .icon-btn[aria-pressed="true"] { color: var(--accent); background: var(--accent-soft); }

.chart-card__body {
	display: grid;
	grid-template-columns: minmax(0, 1fr) auto;
	gap: 0;
	padding: 0 8px 8px;
}
.chart-card.is-collapsed .chart-card__body,
.chart-card.is-collapsed .chart-card__resize { display: none; }
.chart-card.is-collapsed .chart-card__head { min-height: 46px; }

/* Plot: WebGL draws inside .plot__area; the axes sit outside it */
.plot {
	position: relative;
	display: grid;
	grid-template-columns: minmax(0, 1fr) 74px;
	grid-template-rows: minmax(0, 1fr) 22px;
	min-height: 120px;
	border-radius: 10px;
	background: var(--plot-bg);
	border: 1px solid var(--border);
	overflow: hidden;
}
.plot__area {
	position: relative;
	grid-column: 1; grid-row: 1;
	cursor: crosshair;
	touch-action: pan-y;
}
.plot__yaxis, .plot__xaxis { position: relative; overflow: hidden; pointer-events: none; }
.plot__xaxis { pointer-events: auto; cursor: ew-resize; touch-action: none; }
.plot__xaxis:hover { background: var(--surface-2); }
.is-panning, .is-panning * { cursor: grabbing !important; user-select: none; }
.plot__yaxis { grid-column: 2; grid-row: 1; border-left: 1px solid var(--border); }
.plot__xaxis { grid-column: 1; grid-row: 2; border-top: 1px solid var(--border); }
.plot__corner { grid-column: 2; grid-row: 2; border-left: 1px solid var(--border); border-top: 1px solid var(--border); }
.tick {
	position: absolute;
	font: 500 10.5px var(--font-mono); color: var(--text-3);
	white-space: nowrap;
	font-variant-numeric: tabular-nums;
}
.plot__yaxis .tick { left: 7px; transform: translateY(-50%); }
.plot__xaxis .tick { top: 4px; transform: translateX(-50%); }
.tick--live {
	left: 3px !important; padding: 1px 5px; border-radius: 5px;
	color: #fff; font-weight: 600;
	background: var(--accent);
	z-index: 1;
}
.plot__empty {
	position: absolute; inset: 0;
	display: grid; place-items: center;
	color: var(--text-3); font-size: 13px;
	pointer-events: none;
}

.crosshair-x, .crosshair-y { position: absolute; pointer-events: none; opacity: 0; transition: opacity .12s; }
.crosshair-x { top: 0; bottom: 0; width: 0; border-left: 1px dashed color-mix(in srgb, var(--text) 45%, transparent); }
.crosshair-y { left: 0; right: 0; height: 0; border-top: 1px dashed color-mix(in srgb, var(--text) 45%, transparent); }
.plot__area.is-hover .crosshair-x, .plot__area.is-hover .crosshair-y { opacity: 1; }
.selection {
	position: absolute; pointer-events: none;
	background: color-mix(in srgb, var(--accent) 16%, transparent);
	border: 1px solid color-mix(in srgb, var(--accent) 70%, transparent);
	border-radius: 4px;
}
.selection__label {
	position: absolute; left: 50%; top: -8px; transform: translate(-50%, -100%);
	padding: 5px 9px; border-radius: 8px;
	background: var(--surface-solid); box-shadow: var(--shadow-pop);
	font: 600 12px var(--font-mono); white-space: nowrap; color: var(--text);
	display: flex; gap: 10px;
}
.selection__label.is-below { top: auto; bottom: -8px; transform: translate(-50%, 100%); }

/* Legend (exchanges) */
.legend {
	width: 248px;
	margin-left: 8px;
	display: flex; flex-direction: column;
	border-radius: 10px;
	border: 1px solid var(--border);
	background: var(--surface-2);
	overflow: hidden;
}
.chart-card:not(.has-legend) .legend { display: none; }
.legend__head {
	display: flex; align-items: center; justify-content: space-between;
	padding: 6px 6px 6px 10px;
	font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--text-3);
	border-bottom: 1px solid var(--border);
}
.legend__list { flex: 1; display: flex; flex-direction: column; overflow-y: auto; padding: 4px; overscroll-behavior: contain; scrollbar-width: thin; }
.legend-row {
	display: grid;
	grid-template-columns: 4px minmax(0, 1fr) auto 10px 18px;
	align-items: center; gap: 8px;
	width: 100%; min-height: 34px; padding: 3px 4px 3px 4px;
	border: 0; border-radius: 7px;
	background: transparent; text-align: left;
	transition: background var(--t-fast), opacity var(--t-fast);
}
.legend-row:hover { background: var(--surface-3); }
.legend-row__swatch { width: 4px; height: 22px; border-radius: 3px; background: var(--c); box-shadow: 0 0 10px var(--c); }
.legend-row__name { display: flex; flex-direction: column; min-width: 0; line-height: 1.15; }
.legend-row__name b { font-size: 12.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.legend-row__name small { font-size: 10.5px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.legend-row__price { font: 500 12px var(--font-mono); font-variant-numeric: tabular-nums; color: var(--text-2); text-align: right; }
.legend-row__heat {
	position: relative; width: 6px; height: 20px; border-radius: 3px;
	background: var(--surface-3); overflow: hidden;
}
.legend-row__heat::after {
	content: ""; position: absolute; left: 0; right: 0; bottom: 0;
	height: var(--h, 0%); background: var(--hc, var(--text-3));
	border-radius: 3px; transition: height .4s var(--ease), background .4s;
}
.legend-row__link {
	display: grid; place-items: center; width: 18px; height: 22px; border-radius: 5px;
	color: var(--text-3);
}
.legend-row__link:hover { color: var(--accent); background: var(--surface-3); }
.legend-row__link .icon { width: 13px; height: 13px; }
/* The activity heat column only appears when the data server reports ExchangesActivity. */
.charts:not(.has-activity) .legend-row__heat { display: none; }
.charts:not(.has-activity) .legend-row { grid-template-columns: 4px minmax(0, 1fr) auto 18px; }
.legend-row.is-idle { order: 1; }
.legend-row.is-idle .legend-row__price { color: var(--text-3); }
.legend-row.is-idle .legend-row__swatch { opacity: .35; box-shadow: none; }
.legend-row.is-off { opacity: .38; }
.legend-row.is-off .legend-row__swatch { box-shadow: none; background: var(--text-3); }
.legend-row.is-off .legend-row__name b { text-decoration: line-through; text-decoration-color: var(--text-3); }
.legend-row[hidden] { display: none; }

.chart-card__resize {
	position: absolute; left: 24px; right: 24px; bottom: -5px; height: 10px;
	cursor: ns-resize; touch-action: none; z-index: 2;
}
.chart-card__resize::after {
	content: ""; position: absolute; left: 50%; top: 3px; width: 44px; height: 4px; margin-left: -22px;
	border-radius: 2px; background: var(--border-strong); opacity: 0; transition: opacity var(--t-fast);
}
.chart-card:hover .chart-card__resize::after, .chart-card__resize.is-active::after { opacity: 1; }

/* The single WebGL canvas, fixed over the viewport; it only paints inside plot areas. */
.gl-canvas {
	position: fixed; inset: 0; z-index: 10;
	width: 100%; height: 100%;
	pointer-events: none;
}

.chart-tooltip {
	position: fixed; z-index: 30; left: 0; top: 0;
	min-width: 190px; max-width: 280px;
	padding: 10px 12px;
	border-radius: 12px;
	background: color-mix(in srgb, var(--surface-solid) 94%, transparent);
	-webkit-backdrop-filter: blur(16px);
	backdrop-filter: blur(16px);
	box-shadow: var(--shadow-pop);
	pointer-events: none;
	font-size: 12px;
	will-change: transform;
}
.tt__head { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 7px; color: var(--text-2); font-weight: 600; }
.tt__head .mono { color: var(--text); }
.tt__row { display: grid; grid-template-columns: 8px 1fr auto; align-items: center; gap: 8px; padding: 1.5px 0; }
.tt__dot { width: 8px; height: 8px; border-radius: 50%; background: var(--c); }
.tt__name { color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tt__val { font: 600 12px var(--font-mono); font-variant-numeric: tabular-nums; }
.tt__more { margin-top: 4px; color: var(--text-3); font-size: 11px; }

/* Skeletons / empty states */
.skeleton-card { padding: 14px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface-solid); }
.skeleton {
	border-radius: 8px;
	background: linear-gradient(90deg, var(--surface-2) 0%, var(--surface-3) 50%, var(--surface-2) 100%);
	background-size: 200% 100%;
	animation: shimmer 1.4s linear infinite;
}
.skeleton--title { width: 220px; height: 20px; margin-bottom: 14px; }
.skeleton--plot { height: 300px; }
.skeleton--short { height: 180px; }
@keyframes shimmer { to { background-position: -200% 0; } }

.empty-state {
	display: flex; flex-direction: column; align-items: center; gap: 10px;
	padding: 48px 16px; color: var(--text-2);
}
.empty-state .icon { width: 32px; height: 32px; color: var(--text-3); }

.upsell {
	display: flex; align-items: center; gap: 14px;
	margin-top: 16px; padding: 14px 16px;
}
.upsell__icon {
	display: grid; place-items: center; width: 40px; height: 40px; border-radius: 12px; flex: none;
	background: var(--accent-soft); color: var(--accent);
}
.upsell__text { display: flex; flex-direction: column; flex: 1; min-width: 0; }

/* ---------- Floating windows (admin, chat) */
.float-win {
	position: fixed; z-index: 35;
	top: 140px; left: 24px;
	width: 360px; max-width: calc(100vw - 24px);
	border-radius: var(--radius);
	background: var(--surface-solid);
	box-shadow: var(--shadow-pop);
	overflow: hidden;
	animation: pop-in .18s var(--ease);
}
[data-glass="1"] .float-win {
	background: color-mix(in srgb, var(--surface-solid) 88%, transparent);
	-webkit-backdrop-filter: blur(24px) saturate(150%);
	backdrop-filter: blur(24px) saturate(150%);
}
.float-win__head {
	display: flex; align-items: center; gap: 8px;
	height: 44px; padding: 0 6px 0 14px;
	border-bottom: 1px solid var(--border);
	cursor: grab; user-select: none; touch-action: none;
}
.float-win__head:active { cursor: grabbing; }
.float-win__title { display: inline-flex; align-items: center; gap: 8px; font-weight: 650; margin-right: auto; }
.float-win__title .icon { width: 16px; height: 16px; color: var(--accent); }
.float-win__body { padding: 14px; max-height: 70vh; overflow: auto; }
.float-win__overlay {
	position: absolute; inset: 44px 0 0;
	display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px;
	padding: 20px; text-align: center;
	background: color-mix(in srgb, var(--surface-solid) 90%, transparent);
	-webkit-backdrop-filter: blur(6px);
	backdrop-filter: blur(6px);
}
.float-win--chat { width: 380px; height: 460px; display: flex; flex-direction: column; resize: both; min-width: 300px; min-height: 300px; }

.metric-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-bottom: 16px; }
.metric { padding: 10px 12px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--border); }
.metric__label { display: block; font-size: 11px; color: var(--text-3); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.metric__value { font-size: 18px; }

.mini-table { width: 100%; border-collapse: collapse; margin-bottom: 16px; font-size: 12px; }
.mini-table th, .mini-table td { padding: 5px 6px; text-align: right; border-bottom: 1px solid var(--border); }
.mini-table th:first-child { text-align: left; color: var(--text-3); font-weight: 500; font-family: var(--font-sans); }
.mini-table thead th { color: var(--text-3); font-weight: 600; font-family: var(--font-sans); }

.ex-stat { display: flex; flex-direction: column; gap: 2px; }
.ex-stat__row {
	display: flex; justify-content: space-between; gap: 10px;
	padding: 6px 8px; border: 0; border-radius: 7px; background: transparent;
	font-size: 12.5px; text-align: left;
}
.ex-stat__row:hover { background: var(--surface-3); }
.ex-stat__row.is-disabled .ex-stat__name { color: var(--warn); }
.ex-stat__traffic { font-family: var(--font-mono); color: var(--text-2); }

.form-grid { display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 10px 12px; margin-bottom: 16px; }
.form-grid .segmented { justify-self: start; }
.param-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 14px; }
.param { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-3); }
.param .input { width: 100%; min-width: 0; }

.btn-row { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.btn-row--end { justify-content: flex-end; }

.chat-log { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.chat-msg { padding: 8px 10px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--border); }
.chat-msg__head { display: flex; justify-content: space-between; gap: 8px; font-size: 11.5px; margin-bottom: 2px; }
.chat-msg__head b { color: var(--accent); }
.chat-msg__head time { color: var(--text-3); }
.chat-msg__text { overflow-wrap: anywhere; }
.chat-form { display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--border); }
.chat-form .input { flex: 1; }
.chat-form--locked { align-items: center; justify-content: space-between; }

/* ---------- Forms */
.form { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field__label { font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.field__row { display: flex; gap: 8px; position: relative; }
.field__row .input { flex: 1; min-width: 0; }
.field__row--pw .input { padding-right: 42px; }
.field__hint { font-size: 11.5px; color: var(--text-3); }
.input {
	height: 40px; padding: 0 12px;
	border-radius: var(--radius-sm);
	border: 1px solid var(--border-strong);
	background: var(--surface-2);
	outline: none;
	transition: border-color var(--t-fast), box-shadow var(--t-fast), background var(--t-fast);
}
.input:hover { border-color: color-mix(in srgb, var(--text) 25%, transparent); }
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); background: transparent; }
.input.is-invalid { border-color: var(--down); box-shadow: 0 0 0 3px color-mix(in srgb, var(--down) 15%, transparent); }
.input--sm { height: 32px; padding: 0 9px; font-size: 13px; }
.form__msg { min-height: 0; font-size: 13px; color: var(--down); }
.form__msg:empty { display: none; }
.form__msg.is-ok { color: var(--up); }
.form__perks { display: flex; align-items: center; justify-content: center; gap: 6px; font-size: 12.5px; color: var(--text-2); }
.form__perks .icon { width: 15px; height: 15px; color: var(--accent); }
.check { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-2); cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--accent); }

.meter { display: block; height: 4px; border-radius: 2px; background: var(--surface-3); overflow: hidden; }
.meter__bar { display: block; height: 100%; width: 0; border-radius: 2px; background: var(--down); transition: width .3s var(--ease), background .3s; }

.switch {
	appearance: none; -webkit-appearance: none;
	position: relative; width: 40px; height: 23px; flex: none; margin: 0;
	border-radius: 999px; background: var(--surface-3);
	border: 1px solid var(--border-strong);
	cursor: pointer;
	transition: background var(--t-fast), border-color var(--t-fast);
}
.switch::after {
	content: ""; position: absolute; top: 2px; left: 2px;
	width: 17px; height: 17px; border-radius: 50%;
	background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .35);
	transition: transform var(--t);
}
.switch:checked { background: var(--accent); border-color: var(--accent); }
.switch:checked::after { transform: translateX(17px); }

.tabs { display: flex; padding: 3px; margin-bottom: 18px; border-radius: 11px; background: var(--surface-2); border: 1px solid var(--border); }
.tabs__tab {
	flex: 1; height: 34px; border: 0; border-radius: 8px;
	background: transparent; color: var(--text-2); font-weight: 600; font-size: 13.5px;
	transition: background var(--t-fast), color var(--t-fast);
}
.tabs__tab.is-active { background: var(--surface-solid); color: var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, .2), 0 0 0 1px var(--border); }
[data-theme="dark"] .tabs__tab.is-active { background: rgba(255, 255, 255, .09); }

/* ---------- Dialogs */
.dialog {
	width: min(440px, calc(100vw - 24px));
	max-height: calc(100dvh - 40px);
	padding: 0;
	border: 0;
	border-radius: var(--radius-lg);
	background: var(--surface-solid);
	color: var(--text);
	box-shadow: var(--shadow-pop);
	overflow: auto;
}
.dialog[open] { animation: dialog-in .22s var(--ease); }
.dialog::backdrop { background: rgba(3, 6, 14, .55); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); }
@keyframes dialog-in { from { opacity: 0; transform: translateY(10px) scale(.98); } }
.dialog__head { display: flex; align-items: center; justify-content: space-between; padding: 18px 14px 6px 22px; }
.dialog__body { padding: 12px 22px 22px; display: flex; flex-direction: column; gap: 14px; }
.dialog__foot { display: flex; justify-content: flex-end; padding: 12px 16px; border-top: 1px solid var(--border); }

.profile { display: flex; align-items: center; gap: 14px; padding: 14px; border-radius: var(--radius); background: var(--surface-2); border: 1px solid var(--border); }
.profile > div { flex: 1; min-width: 0; }
.profile__name { font-weight: 700; font-size: 16px; }

.sent { display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 12px 0; text-align: center; }
.sent__icon { display: grid; place-items: center; width: 56px; height: 56px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); }
.sent__icon .icon { width: 26px; height: 26px; }

.wallet {
	display: flex; align-items: center; gap: 12px;
	padding: 12px; border-radius: var(--radius);
	background: var(--surface-2); border: 1px solid var(--border);
}
.wallet__icon { width: 32px; height: 32px; border-radius: 50%; }
.wallet__body { flex: 1; min-width: 0; }
.wallet__label { font-weight: 600; font-size: 13px; }
.wallet__addr { display: block; font: 11.5px/1.35 var(--font-mono); color: var(--text-2); overflow-wrap: anywhere; }

/* ---------- Drawer */
.drawer { position: fixed; inset: 0; z-index: 60; }
.drawer__scrim { position: absolute; inset: 0; background: rgba(3, 6, 14, .45); animation: fade-in .2s; }
.drawer__panel {
	position: absolute; top: 0; right: 0; bottom: 0;
	width: min(360px, 92vw);
	display: flex; flex-direction: column; gap: 6px;
	padding: 14px 16px calc(16px + env(safe-area-inset-bottom));
	background: var(--surface-solid);
	border-left: 1px solid var(--border);
	box-shadow: var(--shadow-pop);
	overflow-y: auto;
	animation: slide-in .26s var(--ease);
}
@keyframes slide-in { from { transform: translateX(100%); } }
@keyframes fade-in { from { opacity: 0; } }
.drawer__head { display: flex; align-items: center; justify-content: space-between; padding: 4px 0 8px 6px; }
.drawer__section { padding: 14px 6px; border-top: 1px solid var(--border); }
.drawer__foot { margin-top: auto; padding: 14px 6px 0; font-size: 12px; }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 0; cursor: pointer; }
.switch-row__label { display: inline-flex; align-items: center; gap: 10px; font-weight: 500; }
.switch-row__label .icon { color: var(--text-3); width: 17px; height: 17px; }
.hint { font-size: 12px; color: var(--text-3); margin-top: 4px; }
.kv { display: flex; justify-content: space-between; gap: 10px; padding: 5px 0; font-size: 13px; color: var(--text-2); }
.kv strong { color: var(--text); font-weight: 600; font-size: 12.5px; }
.nav-tile {
	display: flex; align-items: center; gap: 12px;
	padding: 10px; margin: 0 -4px 4px; border-radius: var(--radius-sm);
	color: var(--text); text-decoration: none !important;
	transition: background var(--t-fast);
}
.nav-tile:hover { background: var(--surface-3); }
.nav-tile > .icon { width: 36px; height: 36px; padding: 8px; border-radius: 10px; background: var(--accent-soft); color: var(--accent); }
.nav-tile span { display: flex; flex-direction: column; }
.nav-tile strong { font-size: 13.5px; }
.nav-tile small { color: var(--text-3); font-size: 12px; }

/* ---------- Toasts */
.toasts {
	position: fixed; z-index: 70;
	left: 50%; bottom: calc(18px + env(safe-area-inset-bottom));
	transform: translateX(-50%);
	display: flex; flex-direction: column; align-items: center; gap: 8px;
	width: min(440px, calc(100vw - 24px));
	pointer-events: none;
}
.toast {
	display: flex; align-items: flex-start; gap: 10px;
	width: 100%; padding: 12px 12px 12px 14px;
	border-radius: var(--radius);
	background: var(--surface-solid);
	box-shadow: var(--shadow-pop);
	pointer-events: auto;
	animation: toast-in .3s var(--ease);
}
.toast.is-leaving { animation: toast-out .25s var(--ease) forwards; }
.toast > .icon { margin-top: 1px; color: var(--accent); }
.toast--error > .icon { color: var(--down); }
.toast--ok > .icon { color: var(--up); }
.toast__body { flex: 1; min-width: 0; font-size: 13px; }
.toast__title { font-weight: 650; }
.toast__text { color: var(--text-2); }
.toast .icon-btn { width: 28px; height: 28px; margin: -4px -4px 0 0; }
@keyframes toast-in { from { opacity: 0; transform: translateY(12px) scale(.98); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(8px) scale(.98); } }

/* ---------- Content pages */
.page {
	flex: 1;
	width: 100%; max-width: 1100px;
	margin: 0 auto;
	padding: 40px max(16px, env(safe-area-inset-right)) 56px max(16px, env(safe-area-inset-left));
}
.page--narrow { max-width: 560px; }

.hero { text-align: center; margin: 12px auto 36px; max-width: 760px; }
.hero--compact { margin-bottom: 28px; }
.hero__title { font-size: clamp(30px, 5vw, 48px); font-weight: 800; letter-spacing: -.035em; line-height: 1.08; margin-bottom: 14px; }
.hero__lead { font-size: 16.5px; color: var(--text-2); max-width: 620px; margin: 0 auto; }

.widget-builder { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.widget-builder .card { display: flex; flex-direction: column; gap: 14px; }
.swatch-row { display: flex; gap: 12px; flex-wrap: wrap; }
.color-field {
	flex: 1; min-width: 160px;
	display: flex; align-items: center; gap: 12px;
	padding: 10px; border-radius: var(--radius-sm);
	background: var(--surface-2); border: 1px solid var(--border);
	cursor: pointer;
}
.color-field input[type="color"] { width: 38px; height: 38px; padding: 0; border: 0; border-radius: 9px; background: none; cursor: pointer; }
.color-field input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
.color-field input[type="color"]::-webkit-color-swatch { border: 1px solid var(--border-strong); border-radius: 9px; }
.color-field input[type="color"]::-moz-color-swatch { border: 1px solid var(--border-strong); border-radius: 9px; }
.color-field span { display: flex; flex-direction: column; font-size: 13px; }
.color-field small { color: var(--text-3); }
.preset-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.preset {
	width: 30px; height: 30px; border-radius: 50%;
	border: 2px solid var(--border-strong);
	background: linear-gradient(135deg, var(--a) 50%, var(--b) 50%);
	transition: transform var(--t-fast);
}
.preset:hover { transform: scale(1.1); }
.preview-stage {
	display: grid; place-items: center;
	min-height: 120px; padding: 20px;
	border-radius: var(--radius);
	background: #0e1220 radial-gradient(circle at 30% 20%, rgba(99, 102, 241, .25), transparent 60%);
	border: 1px solid var(--border);
	transition: background var(--t);
}
.preview-stage.is-light { background: #f3f5fa radial-gradient(circle at 30% 20%, rgba(99, 102, 241, .12), transparent 60%); }
.preview-stage iframe { border: 0; width: 300px; height: 35px; background: transparent; color-scheme: normal; }
.code-block { position: relative; border-radius: var(--radius); background: #0a0e1a; border: 1px solid var(--border); }
.code-block pre { margin: 0; padding: 16px 16px 56px; overflow-x: auto; font: 12.5px/1.6 var(--font-mono); color: #c3d0f5; white-space: pre-wrap; word-break: break-all; }
.code-block .tok-tag { color: #7dd3fc; }
.code-block .tok-attr { color: #c4b5fd; }
.code-block .tok-str { color: #86efac; }
.code-block__copy { position: absolute; right: 10px; bottom: 10px; }
.feature-list { list-style: none; margin: 4px 0 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.feature-list li { display: flex; align-items: center; gap: 10px; color: var(--text-2); }
.feature-list .icon { width: 16px; height: 16px; color: var(--up); }

.guide { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 460px), 1fr)); gap: 16px; }
.guide__title { display: flex; align-items: center; gap: 12px; font-size: 18px; margin-bottom: 16px; }
.guide__icon { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 11px; background: var(--accent-soft); color: var(--accent); }
.guide__list { margin: 0; display: flex; flex-direction: column; gap: 14px; }
.guide__item dt { font-weight: 650; margin-bottom: 3px; }
.guide__item dd { margin: 0; color: var(--text-2); }
.cta { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-top: 16px; flex-wrap: wrap; }

.notice-card { display: flex; flex-direction: column; align-items: center; gap: 14px; text-align: center; margin-top: 40px; }
.notice-card__icon { display: grid; place-items: center; width: 56px; height: 56px; border-radius: 50%; background: color-mix(in srgb, var(--warn) 15%, transparent); color: var(--warn); }
.notice-card__icon .icon { width: 26px; height: 26px; }

/* ---------- Language switcher */
.lang-switch { position: relative; }
.lang-switch__btn { width: auto; padding: 0 9px; gap: 5px; display: inline-flex; }
.lang-switch__code { font: 600 11.5px var(--font-mono); letter-spacing: .03em; }
.lang-switch__menu { min-width: 200px; }
.lang-switch__menu .menu-item { text-decoration: none !important; color: var(--text); }
.lang-switch__menu .menu-item[aria-current="true"] { color: var(--accent); font-weight: 600; }
.lang-switch__badge {
	display: inline-grid; place-items: center;
	min-width: 28px; height: 20px; padding: 0 5px;
	border-radius: 6px; border: 1px solid var(--border-strong);
	font: 600 10.5px var(--font-mono); color: var(--text-2);
}
.lang-switch__check { width: 15px; height: 15px; margin-left: auto; color: var(--accent); }
.lang-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.lang-grid__item {
	display: flex; align-items: center; gap: 8px;
	padding: 8px 10px; border-radius: var(--radius-sm);
	border: 1px solid var(--border); background: var(--surface-2);
	color: var(--text); font-size: 13px; text-decoration: none !important;
	transition: border-color var(--t-fast), background var(--t-fast);
}
.lang-grid__item:hover { background: var(--surface-3); }
.lang-grid__item.is-active { border-color: var(--accent); background: var(--accent-soft); }
.lang-grid__item.is-active .lang-switch__badge { border-color: var(--accent); color: var(--accent); }
.field--inline { flex-direction: row; align-items: center; justify-content: space-between; gap: 12px; }
.field--inline .input { width: auto; min-width: 180px; }

/* ---------- Disclaimer & cookie consent */
.data-note {
	display: flex; gap: 10px; align-items: flex-start;
	margin: 14px 2px 0; padding: 10px 14px;
	border-radius: var(--radius-sm);
	border: 1px dashed var(--border-strong);
	font-size: 12.5px; line-height: 1.5; color: var(--text-2);
}
.data-note .icon { width: 16px; height: 16px; margin-top: 1px; color: var(--warn); flex: none; }
.form__legal { font-size: 11.5px; line-height: 1.45; color: var(--text-3); text-align: center; }

.cookie-banner {
	position: fixed; z-index: 65;
	left: 0; right: 0; margin: 0 auto; bottom: calc(16px + env(safe-area-inset-bottom));
	width: min(880px, calc(100vw - 24px));
	display: flex; align-items: center; gap: 16px;
	padding: 16px 18px;
	border-radius: var(--radius);
	background: var(--surface-solid);
	box-shadow: var(--shadow-pop);
	animation: toast-in .35s var(--ease);
}
[data-glass="1"] .cookie-banner {
	background: color-mix(in srgb, var(--surface-solid) 90%, transparent);
	-webkit-backdrop-filter: blur(24px) saturate(160%);
	backdrop-filter: blur(24px) saturate(160%);
}
.cookie-banner__icon {
	display: grid; place-items: center; flex: none;
	width: 40px; height: 40px; border-radius: 12px;
	background: color-mix(in srgb, var(--warn) 15%, transparent); color: var(--warn);
}
.cookie-banner__text { flex: 1; min-width: 0; font-size: 13px; line-height: 1.5; color: var(--text-2); }
.cookie-banner__title { font-size: 14.5px; color: var(--text); margin-bottom: 3px; }
.cookie-banner__actions { display: flex; gap: 8px; flex: none; }

.link-btn {
	padding: 0; border: 0; background: none;
	color: var(--text-2); font: inherit; cursor: pointer;
}
.link-btn:hover { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }

.legal h2 { font-size: 18px; margin: 26px 0 10px; scroll-margin-top: calc(var(--topbar-h) + 20px); }
.legal h2:first-child { margin-top: 0; }
.legal p { color: var(--text-2); margin-bottom: 10px; line-height: 1.65; }
.legal strong { color: var(--text); }
.page--legal { max-width: 860px; }
.table-wrap { overflow-x: auto; margin: 12px 0 16px; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.legal-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.legal-table th, .legal-table td { padding: 9px 12px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--border); }
.legal-table th { font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-3); background: var(--surface-2); }
.legal-table tr:last-child td { border-bottom: 0; }
.legal-table td:first-child { white-space: nowrap; }

/* ---------- Footer */
.site-footer { border-top: 1px solid var(--border); }
.site-footer__inner {
	display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap;
	max-width: 1720px; margin: 0 auto; padding: 18px 16px calc(18px + env(safe-area-inset-bottom));
	font-size: 12.5px; color: var(--text-3);
}
.site-footer__links { display: flex; gap: 18px; flex-wrap: wrap; }
.site-footer__disclaimer { flex-basis: 100%; order: 3; margin: 0; font-size: 11.5px; color: var(--text-3); }
.site-footer__disclaimer a { color: var(--text-2); }
.site-footer a { color: var(--text-2); }

/* ---------- Responsive */
@media (max-width: 1180px) {
	.hide-md { display: none !important; }
	.topnav__link span { display: none; }
	.topnav__link { padding: 0 9px; }
}

@media (max-width: 960px) {
	.btn--donate { padding: 0 10px; }
	.btn--donate span { display: none; }
	.lang-switch__btn { width: 38px; padding: 0; justify-content: center; }
	.lang-switch__code { display: none; }
	.status-pill__text { max-width: 110px; overflow: hidden; text-overflow: ellipsis; }
	.topnav { display: none; } /* same links live in the menu drawer */
}

@media (max-width: 900px) {
	.chart-card__body { grid-template-columns: minmax(0, 1fr); }
	.legend { width: auto; margin: 8px 0 0; }
	.legend__list {
		display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
		max-height: 180px; gap: 2px;
	}
	.legend-row { grid-template-columns: 4px minmax(0, 1fr) auto 6px 0; }
	.charts:not(.has-activity) .legend-row { grid-template-columns: 4px minmax(0, 1fr) auto 0; }
	.legend-row__link { display: none; }
	.widget-builder { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
	:root { --topbar-h: 56px; }
	.topnav { display: none; }
	.hide-sm { display: none !important; }
	.status-pill { padding: 0 9px; }
	.status-pill__text { display: none; }
	.brand__name { display: none; }
	.toolbar { position: relative; top: 0; gap: 8px 10px; padding: 8px; }
	.toolbar__label { display: none; }
	.timeline__label { display: none; }
	.toolbar__spacer { display: none; }
	.toolbar__group--end { margin-left: auto; }
	.dashboard { padding-top: 10px; }
	.plot { grid-template-columns: minmax(0, 1fr) 64px; }
	.tick--live { font-size: 10px; padding: 1px 3px; }
	.chart-card__head { flex-wrap: wrap; }
	.chart-card__stats { order: 3; flex-basis: 100%; padding-left: 4px; }
	.stat { height: 24px; padding: 3px 7px; }
	.param-grid { grid-template-columns: repeat(2, 1fr); }
	.float-win { left: 12px !important; right: 12px; top: auto !important; bottom: 12px; width: auto; }
	.float-win--chat { height: 60vh; resize: none; }
	.upsell { flex-wrap: wrap; }
	.cookie-banner { flex-wrap: wrap; bottom: 8px; padding: 14px; }
	.cookie-banner__icon { display: none; }
	.cookie-banner__actions { width: 100%; }
	.cookie-banner__actions .btn { flex: 1; }
	.freeze-banner { top: calc(var(--topbar-h) + 8px); }
}

@media (max-width: 480px) {
	.legend__list { grid-template-columns: 1fr; max-height: 168px; }
}

@media (max-width: 420px) {
	.segmented__btn { padding: 0 8px; font-size: 12px; }
	.btn--play .play-label { display: none; }
}

@media (prefers-reduced-motion: reduce) {
	*, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}

/* No WebGL and no Canvas 2D: explain instead of a blank page */
.no-render .plot__area::after {
	content: "Your browser cannot draw charts (WebGL disabled).";
	position: absolute; inset: 0; display: grid; place-items: center; color: var(--text-3);
}
