/* Drift Lab -- layout and controls */

#driftlab {
	--dl-border: #d9d9d9;
	--dl-panel: #f7f7f7;
	--dl-panel2: #fff;
	--dl-text: #222;
	--dl-muted: #666;
	--dl-accent: #1f77b4;
	--dl-bad: #d62728;
	--dl-good: #2ca02c;
	display: flex;
	gap: 0;
	border: 1px solid var(--dl-border);
	border-radius: 6px;
	overflow: hidden;
	min-height: 640px;
	font-size: 14px;
	color: var(--dl-text);
	background: var(--dl-panel2);
}

:root[dark] {   /* the site's Dark/Light setting */
	#driftlab {
		--dl-border: #3a3a3a;
		--dl-panel: #232323;
		--dl-panel2: #1a1a1a;
		--dl-text: #e2e2e2;
		--dl-muted: #999;
	}
}

/* ---- left rail: the run library ---- */
#dl-library {
	width: 268px;
	flex: 0 0 268px;
	background: var(--dl-panel);
	border-right: 1px solid var(--dl-border);
	overflow-y: auto;
	max-height: 78vh;
}
#dl-library h3 {
	margin: 0;
	padding: 10px 12px 6px;
	font-size: 11px;
	letter-spacing: .08em;
	text-transform: uppercase;
	color: var(--dl-muted);
	font-weight: 600;
}
.dl-run {
	padding: 8px 12px;
	border-bottom: 1px solid var(--dl-border);
	cursor: pointer;
	line-height: 1.35;
}
.dl-run:hover { background: rgba(31, 119, 180, .08); }
.dl-run.selected { background: rgba(31, 119, 180, .16); box-shadow: inset 3px 0 0 var(--dl-accent); }
.dl-run b { display: block; font-weight: 600; }
.dl-run span { color: var(--dl-muted); font-size: 12px; }
.dl-run .dl-verdict { font-size: 12px; font-weight: 600; }
.dl-run .dl-down { color: var(--dl-bad); }
.dl-run .dl-flat { color: var(--dl-good); }

/* ---- right side ---- */
#dl-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
#dl-tabs {
	display: flex;
	gap: 2px;
	border-bottom: 1px solid var(--dl-border);
	background: var(--dl-panel);
	padding: 0 8px;
}
#dl-tabs button {
	border: 0;
	background: transparent;
	padding: 9px 14px;
	font: inherit;
	font-size: 13px;
	color: var(--dl-muted);
	cursor: pointer;
	border-bottom: 2px solid transparent;
}
#dl-tabs button.active { color: var(--dl-text); border-bottom-color: var(--dl-accent); font-weight: 600; }
.dl-panel { display: none; padding: 14px 16px; overflow-y: auto; max-height: 78vh; }
.dl-panel.active { display: block; }

#dl-chart-wrap { position: relative; }
#dl-chart { width: 100%; height: 290px; display: block; }
#dl-chart2 { width: 100%; height: 150px; display: block; margin-top: 6px; }
.dl-chart-title { font-weight: 600; margin: 0 0 2px; }
.dl-chart-sub { color: var(--dl-muted); font-size: 12px; margin: 0 0 8px; }

#dl-controls { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 10px 0 6px; }
#dl-controls button {
	font: inherit; font-size: 13px; padding: 6px 14px; cursor: pointer;
	border: 1px solid var(--dl-border); border-radius: 4px;
	background: var(--dl-panel2); color: var(--dl-text);
}
#dl-controls button.primary { background: var(--dl-accent); color: #fff; border-color: var(--dl-accent); }
#dl-controls button:disabled { opacity: .5; cursor: default; }
#dl-status { color: var(--dl-muted); font-size: 12px; }

.dl-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(168px, 1fr)); gap: 10px; margin-top: 12px; }
.dl-stat { border: 1px solid var(--dl-border); border-radius: 5px; padding: 8px 10px; background: var(--dl-panel); }
.dl-stat .k { font-size: 11px; color: var(--dl-muted); text-transform: uppercase; letter-spacing: .05em; }
.dl-stat .v { font-size: 19px; font-weight: 600; font-variant-numeric: tabular-nums; }
.dl-stat .n { font-size: 11px; color: var(--dl-muted); }

.dl-fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 12px 18px; }
.dl-field label { display: block; font-size: 12px; color: var(--dl-muted); margin-bottom: 2px; }
.dl-field input, .dl-field select {
	width: 100%; box-sizing: border-box; font: inherit; font-size: 13px;
	padding: 5px 7px; border: 1px solid var(--dl-border); border-radius: 4px;
	background: var(--dl-panel2); color: var(--dl-text);
}
.dl-field .hint { font-size: 11px; color: var(--dl-muted); margin-top: 2px; }
.dl-section { margin: 16px 0 6px; font-weight: 600; font-size: 13px; }
.dl-section.dl-group {
	margin: 22px 0 8px; padding-bottom: 4px;
	border-bottom: 1px solid var(--dl-border);
	text-transform: uppercase; letter-spacing: .06em;
	font-size: 11px; color: var(--dl-muted);
}
.dl-section.dl-group:first-child { margin-top: 4px; }

/* Label row carries the (?) button at its right edge. */
.dl-field label {
	display: flex; align-items: center; justify-content: flex-start; gap: 6px;
}
.dl-field label > span:first-child { flex: 0 1 auto; }
.dl-help-btn {
	flex: none; width: 17px; height: 17px; padding: 0; cursor: pointer;
	border: 1px solid var(--dl-border); border-radius: 50%;
	background: var(--dl-panel2); color: var(--dl-muted);
	font: inherit; font-size: 11px; line-height: 1; font-weight: 700;
}
.dl-help-btn:hover { color: var(--dl-text); border-color: var(--dl-muted); }
.dl-field.open .dl-help-btn {
	background: var(--dl-muted); color: var(--dl-panel); border-color: var(--dl-muted);
}
.dl-help { display: none; }
.dl-field.open .dl-help {
	display: block; margin-top: 7px; padding: 8px 10px;
	border-left: 2px solid var(--dl-border); border-radius: 0 4px 4px 0;
	background: var(--dl-panel2);
	font-size: 12px; line-height: 1.5; color: var(--dl-text);
}
.dl-field.open .dl-help p { margin: 0 0 7px; }
.dl-field.open .dl-help p:last-child { margin-bottom: 0; }
/* An open explainer gets the full width of the grid rather than one column. */
.dl-fields { align-items: start; }
.dl-field.open { grid-column: 1 / -1; }

#dl-verify table, #dl-code table { width: 100%; border-collapse: collapse; font-size: 13px; }
#dl-verify td { padding: 7px 6px; border-bottom: 1px solid var(--dl-border); vertical-align: top; }
.dl-pass { color: var(--dl-good); font-weight: 600; }
.dl-fail { color: var(--dl-bad); font-weight: 600; }
.dl-why { color: var(--dl-muted); font-size: 12px; margin-top: 3px; line-height: 1.45; }

#dl-code pre {
	background: var(--dl-panel); border: 1px solid var(--dl-border); border-radius: 4px;
	padding: 10px; overflow: auto; max-height: 460px; font-size: 12px; line-height: 1.45;
}
.dl-note { color: var(--dl-muted); font-size: 12px; line-height: 1.5; }

@media (max-width: 800px) {
	#driftlab { flex-direction: column; }
	#dl-library { width: auto; flex: none; max-height: 220px; border-right: 0; border-bottom: 1px solid var(--dl-border); }
}
