:root {
	--bg:        #0a0c10;
	--surface:   #111318;
	--border:    #1e2128;
	--accent:    #c8f135;
	--accent2:   #35b8f1;
	--muted:     #4a5060;
	--text:      #d8dce8;
	--text-dim:  #6a7080;
	--row-h:     22px;
	--label-w:   52px;
	--scrollbar: #1e2128;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
	background: var(--bg);
	color: var(--text);
	font-family: 'DMMono', monospace;
	min-height: 100vh;
	overflow-x: hidden;
}

/* ── Header ── */
header {
	padding: 2rem 2rem 1.2rem;
	border-bottom: 1px solid var(--border);
	display: flex;
	align-items: flex-end;
	gap: 2rem;
	flex-wrap: wrap;
}

header h1 {
	font-family: 'Syne', sans-serif;
	font-weight: 800;
	font-size: clamp(1.4rem, 3vw, 2rem);
	letter-spacing: -0.02em;
	color: var(--accent);
	line-height: 1;
}

header p {
	font-size: .75rem;
	color: var(--text-dim);
	line-height: 1.5;
}

.badge {
	margin-left: auto;
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: 6px;
	padding: .4rem .9rem;
	font-size: .72rem;
	color: var(--text-dim);
	white-space: nowrap;
}

.badge span { color: var(--accent); font-weight: 500; }

.nav-back {
	margin-left: auto;
	color: var(--text-dim);
	text-decoration: none;
	font-size: .72rem;
	border: 1px solid var(--border);
	padding: .35rem .8rem;
	border-radius: 4px;
	transition: border-color .15s, color .15s;
	white-space: nowrap;
}

.nav-back:hover { border-color: var(--accent2); color: var(--accent2); }

/* ── Controls ── */
.controls {
	padding: .8rem 2rem;
	display: flex;
	align-items: center;
	gap: 1.2rem;
	flex-wrap: wrap;
	border-bottom: 1px solid var(--border);
	background: var(--surface);
}

.controls label { font-size: .72rem; color: var(--text-dim); }

.controls input[type=range] {
	accent-color: var(--accent);
	width: 140px;
}

.controls select, .controls input[type=text] {
	background: var(--bg);
	border: 1px solid var(--border);
	color: var(--text);
	font-family: inherit;
	font-size: .72rem;
	padding: .3rem .6rem;
	border-radius: 4px;
	outline: none;
}

.controls select:focus, .controls input[type=text]:focus {
	border-color: var(--accent);
}

.sep { width: 1px; height: 20px; background: var(--border); }

.ctrl-val { color: var(--accent); font-size: .72rem; min-width: 2ch; }

/* ── Legend ── */
.legend {
	padding: .5rem 2rem;
	display: flex;
	gap: 1.6rem;
	font-size: .68rem;
	color: var(--text-dim);
	border-bottom: 1px solid var(--border);
}

.legend-item { display: flex; align-items: center; gap: .4rem; }

.legend-dot {
	width: 10px; height: 10px; border-radius: 2px;
	flex-shrink: 0;
}

/* ── Chart wrapper ── */
#chart-outer {
	position: relative;
	display: flex;
	align-items: flex-start;
}

#chart-wrapper {
	flex: 1;
	padding: 1rem 0 1rem var(--label-w);
	overflow-x: auto;
	overflow-y: hidden;
	position: relative;
	scrollbar-width: thin;
	scrollbar-color: var(--scrollbar) transparent;
}

#chart-wrapper::-webkit-scrollbar { height: 6px; }

#chart-wrapper::-webkit-scrollbar-thumb { background: var(--scrollbar); border-radius: 3px; }

/* ── Axis labels fixed on left ── */
#y-axis {
	position: absolute;
	left: 0;
	top: 1rem;
	width: var(--label-w);
	display: flex;
	flex-direction: column;
	pointer-events: none;
	z-index: 10;
}

/* ── Axis labels fixed on right ── */
#y-axis-right {
	width: var(--label-w);
	padding-top: 1rem;
	display: flex;
	flex-direction: column;
	flex-shrink: 0;
	pointer-events: none;
	z-index: 10;
}

.y-label {
	height: var(--row-h);
	display: flex;
	align-items: center;
	justify-content: flex-end;
	padding-right: 8px;
	font-size: .65rem;
	color: var(--text-dim);
	transition: color .15s;
	cursor: default;
}

.y-label-right {
	height: var(--row-h);
	display: flex;
	align-items: center;
	justify-content: flex-start;
	padding-left: 8px;
	font-size: .65rem;
	color: var(--text-dim);
	transition: color .15s;
	cursor: default;
}
.y-label.active, .y-label-right.active { color: var(--accent); font-weight: 500; }

/* ── Canvas ── */
#main-canvas {
	display: block;
	cursor: crosshair;
}

/* ── Tooltip ── */
#tooltip {
	position: fixed;
	background: var(--surface);
	border: 1px solid var(--accent);
	border-radius: 6px;
	padding: .5rem .8rem;
	font-size: .7rem;
	line-height: 1.7;
	pointer-events: none;
	opacity: 0;
	transition: opacity .1s;
	z-index: 100;
	max-width: 220px;
}

#tooltip.visible { opacity: 1; }

#tooltip strong { color: var(--accent); font-weight: 500; }

/* ── X-axis sorteo ruler ── */
#x-ruler {
	margin-left: var(--label-w);
	margin-right: var(--label-w);
	overflow-x: hidden;
	overflow-y: hidden;
	height: 24px;
	position: relative;
}

#x-canvas { display: block; }

/* ── Stats bar ── */
#statsbar {
	padding: .6rem 2rem;
	background: var(--surface);
	border-top: 1px solid var(--border);
	font-size: .68rem;
	color: var(--text-dim);
	display: flex;
	gap: 2rem;
	flex-wrap: wrap;
	min-height: 2.2rem;
	align-items: center;
}

#statsbar span { color: var(--text); }

#statsbar strong { color: var(--accent2); }

/* ── File picker overlay ── */
#drop-overlay {
	position: fixed; inset: 0;
	background: rgba(10,12,16,.92);
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 1rem;
	z-index: 200;
}

#drop-overlay h2 {
	font-family: 'Syne', sans-serif;
	font-size: 1.5rem;
	color: var(--accent);
}

#drop-overlay p { font-size: .8rem; color: var(--text-dim); }

#file-btn {
	background: var(--accent);
	color: #0a0c10;
	border: none;
	padding: .7rem 1.8rem;
	border-radius: 6px;
	font-family: 'Syne', sans-serif;
	font-weight: 700;
	font-size: .9rem;
	cursor: pointer;
	letter-spacing: .02em;
	transition: opacity .15s;
}

#file-btn:hover { opacity: .85; }

#file-input { display: none; }

.or { font-size: .7rem; color: var(--muted); }

#demo-btn {
	background: transparent;
	border: 1px solid var(--border);
	color: var(--text-dim);
	padding: .5rem 1.2rem;
	border-radius: 6px;
	font-family: inherit;
	font-size: .75rem;
	cursor: pointer;
	transition: border-color .15s, color .15s;
}

#demo-btn:hover { border-color: var(--accent2); color: var(--accent2); }

#loading {
	position: fixed; inset: 0;
	background: var(--bg);
	display: none;
	align-items: center;
	justify-content: center;
	z-index: 300;
	font-family: 'Syne', sans-serif;
	font-size: 1rem;
	color: var(--accent);
	letter-spacing: .1em;
}
