:root {
	color-scheme: dark;
	--bg: #07090e;
	--bg-card: #0d121c;
	--bg-elevated: #151d2c;
	--bg-glass: rgba(13, 18, 28, 0.82);
	--border: #1e293b;
	--border-light: #334155;
	--fg: #f1f5f9;
	--muted: #8e9bb0;
	--accent: #06b6d4;
	--accent-glow: rgba(6, 182, 212, 0.35);
	--accent-green: #10b981;
	--accent-amber: #f59e0b;
	--accent-orange: #f97316;
	--accent-red: #ef4444;
	--danger: #ef4444;
	--radius: 12px;
	--radius-sm: 8px;
	--radius-lg: 16px;
	--space: 1rem;
	--font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
	--font-mono: ui-monospace, "SF Mono", "Cascadia Code", "Fira Code", monospace;
}

* {
	box-sizing: border-box;
}

body {
	margin: 0;
	background: var(--bg);
	color: var(--fg);
	font-family: var(--font);
	line-height: 1.5;
	-webkit-font-smoothing: antialiased;
	overflow-x: hidden;
	background-image: 
		radial-gradient(ellipse 80% 50% at 50% -20%, rgba(6, 182, 212, 0.12), transparent 70%),
		radial-gradient(ellipse 60% 40% at 80% 90%, rgba(16, 185, 129, 0.06), transparent 70%);
	background-attachment: fixed;
	min-height: 100vh;
}

/* Base Utility Classes */
.shell {
	max-width: 72rem;
	margin: 0 auto;
	padding: 1rem;
}

@media (min-width: 48rem) {
	.shell {
		padding: 1.5rem 2rem;
	}
}

.stack {
	display: flex;
	flex-direction: column;
	gap: 1rem;
}

.row {
	display: flex;
	align-items: center;
	gap: 0.75rem;
	flex-wrap: wrap;
}

.grid {
	display: grid;
	gap: 1rem;
	grid-template-columns: repeat(auto-fit, minmax(min(18rem, 100%), 1fr));
}

/* Card */
.card {
	background: var(--bg-card);
	border: 1px solid var(--border);
	border-radius: var(--radius);
	padding: 1.25rem;
	position: relative;
	box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}

.card-glass {
	background: var(--bg-glass);
	backdrop-filter: blur(12px);
	-webkit-backdrop-filter: blur(12px);
	border: 1px solid rgba(255, 255, 255, 0.08);
}

/* Header & Navigation Bar */
.app-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 0.75rem 1.25rem;
	background: rgba(13, 18, 28, 0.95);
	border: 1px solid var(--border);
	border-radius: var(--radius-lg);
	backdrop-filter: blur(16px);
	margin-bottom: 1.25rem;
	box-shadow: 0 4px 24px rgba(0, 0, 0, 0.5);
}

.brand {
	display: flex;
	align-items: center;
	gap: 0.85rem;
}

.brand-icon {
	width: 38px;
	height: 38px;
	background: linear-gradient(135deg, #06b6d4, #10b981);
	border-radius: 10px;
	display: flex;
	align-items: center;
	justify-content: center;
	color: #000;
	box-shadow: 0 0 16px var(--accent-glow);
}

.brand-title {
	font-size: 1.25rem;
	font-weight: 800;
	letter-spacing: -0.02em;
	background: linear-gradient(90deg, #ffffff, #a5f3fc);
	-webkit-background-clip: text;
	-webkit-text-fill-color: transparent;
	margin: 0;
	line-height: 1.2;
}

.brand-sub {
	font-size: 0.725rem;
	color: var(--muted);
	font-family: var(--font-mono);
	letter-spacing: 0.05em;
	text-transform: uppercase;
	margin: 0;
}

/* Tabs */
.nav-tabs {
	display: flex;
	background: var(--bg);
	padding: 4px;
	border-radius: 10px;
	border: 1px solid var(--border);
	gap: 4px;
	overflow-x: auto;
}

.nav-tab {
	background: transparent;
	border: none;
	color: var(--muted);
	padding: 0.45rem 0.9rem;
	border-radius: 7px;
	font-size: 0.875rem;
	font-weight: 600;
	cursor: pointer;
	display: flex;
	align-items: center;
	gap: 0.45rem;
	white-space: nowrap;
	transition: all 0.15s ease;
}

.nav-tab:hover {
	color: var(--fg);
	background: rgba(255, 255, 255, 0.05);
}

.nav-tab.active {
	background: var(--bg-elevated);
	color: #38bdf8;
	border: 1px solid var(--border-light);
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

/* Buttons */
.btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 0.5rem;
	padding: 0.6rem 1.1rem;
	border-radius: var(--radius-sm);
	font-family: var(--font);
	font-size: 0.875rem;
	font-weight: 600;
	cursor: pointer;
	border: 1px solid transparent;
	transition: all 0.15s ease;
	user-select: none;
}

.btn-primary {
	background: linear-gradient(135deg, #06b6d4, #0284c7);
	color: #fff;
	box-shadow: 0 2px 10px rgba(6, 182, 212, 0.3);
}
.btn-primary:hover {
	filter: brightness(1.1);
	box-shadow: 0 4px 14px rgba(6, 182, 212, 0.45);
}

.btn-record {
	background: linear-gradient(135deg, #ef4444, #dc2626);
	color: #fff;
	box-shadow: 0 0 16px rgba(239, 68, 68, 0.45);
	animation: pulse-red 2s infinite;
}
.btn-record:hover {
	filter: brightness(1.15);
}

.btn-recording-active {
	background: #991b1b;
	color: #fecaca;
	border: 1px solid #ef4444;
	box-shadow: 0 0 20px rgba(239, 68, 68, 0.6);
}

.btn-secondary {
	background: var(--bg-elevated);
	color: var(--fg);
	border: 1px solid var(--border);
}
.btn-secondary:hover {
	background: #1e293b;
	border-color: var(--border-light);
}

.btn-success {
	background: linear-gradient(135deg, #10b981, #059669);
	color: #fff;
	box-shadow: 0 2px 10px rgba(16, 185, 129, 0.3);
}

.btn-sm {
	padding: 0.35rem 0.65rem;
	font-size: 0.8rem;
}

.btn-lg {
	padding: 0.75rem 1.4rem;
	font-size: 1rem;
	border-radius: var(--radius);
}

.btn-icon-only {
	padding: 0.55rem;
	border-radius: var(--radius-sm);
}

/* Video & HUD Viewport */
.viewport-container {
	position: relative;
	width: 100%;
	aspect-ratio: 16 / 9;
	background: #030508;
	border-radius: var(--radius-lg);
	overflow: hidden;
	border: 1px solid var(--border-light);
	box-shadow: 0 8px 32px rgba(0, 0, 0, 0.7), 0 0 0 1px rgba(255, 255, 255, 0.05);
	display: flex;
	align-items: center;
	justify-content: center;
}

@media (max-width: 600px) {
	.viewport-container {
		aspect-ratio: 4 / 3;
	}
}

.viewport-canvas {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
}

.camera-preview-video {
	display: none; /* rendered into canvas with telemetry HUD */
}

.viewport-overlay-controls {
	position: absolute;
	inset: 0;
	pointer-events: none;
	display: flex;
	flex-direction: column;
	justify-content: space-between;
	padding: 1rem;
}

.hud-top-bar {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 0.5rem;
	pointer-events: auto;
}

.hud-pill {
	display: flex;
	align-items: center;
	gap: 0.4rem;
	padding: 0.35rem 0.75rem;
	background: rgba(7, 9, 14, 0.8);
	border: 1px solid rgba(255, 255, 255, 0.15);
	border-radius: 999px;
	font-size: 0.75rem;
	font-family: var(--font-mono);
	backdrop-filter: blur(8px);
}

.rec-beacon {
	width: 10px;
	height: 10px;
	border-radius: 50%;
	background: #ef4444;
	box-shadow: 0 0 8px #ef4444;
	animation: blink 1s ease-in-out infinite;
}

.hud-bottom-bar {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 0.75rem;
	pointer-events: auto;
	flex-wrap: wrap;
}

/* Master SPL Display Card */
.spl-meter-hero {
	background: radial-gradient(circle at 50% 0%, #162438 0%, #0a0e17 80%);
	border: 1px solid var(--border-light);
	border-radius: var(--radius-lg);
	padding: 1.5rem;
	display: flex;
	flex-direction: column;
	align-items: center;
	position: relative;
	overflow: hidden;
}

.spl-meter-hero::after {
	content: "";
	position: absolute;
	top: 0;
	left: 0;
	right: 0;
	height: 2px;
	background: linear-gradient(90deg, transparent, #06b6d4, #10b981, transparent);
}

.spl-value-row {
	display: flex;
	align-items: baseline;
	justify-content: center;
	gap: 0.5rem;
	margin: 0.5rem 0 0.25rem;
}

.spl-number {
	font-family: var(--font-mono);
	font-size: clamp(3.5rem, 8vw, 5.5rem);
	font-weight: 800;
	line-height: 1;
	letter-spacing: -0.04em;
	font-variant-numeric: tabular-nums;
	transition: color 0.1s ease;
}

.spl-unit {
	font-family: var(--font-mono);
	font-size: 1.5rem;
	font-weight: 700;
	color: var(--muted);
}

.spl-rating-badge {
	display: inline-flex;
	align-items: center;
	gap: 0.4rem;
	padding: 0.35rem 1rem;
	border-radius: 999px;
	font-size: 0.85rem;
	font-weight: 700;
	letter-spacing: 0.05em;
	text-transform: uppercase;
	margin-bottom: 1rem;
}

/* Noise Level Classes */
.noise-quiet {
	color: #34d399;
}
.badge-quiet {
	background: rgba(16, 185, 129, 0.15);
	color: #34d399;
	border: 1px solid rgba(16, 185, 129, 0.3);
}

.noise-moderate {
	color: #38bdf8;
}
.badge-moderate {
	background: rgba(6, 182, 212, 0.15);
	color: #38bdf8;
	border: 1px solid rgba(6, 182, 212, 0.3);
}

.noise-loud {
	color: #fbbf24;
}
.badge-loud {
	background: rgba(245, 158, 11, 0.15);
	color: #fbbf24;
	border: 1px solid rgba(245, 158, 11, 0.3);
}

.noise-very-loud {
	color: #fb923c;
}
.badge-very-loud {
	background: rgba(249, 115, 22, 0.15);
	color: #fb923c;
	border: 1px solid rgba(249, 115, 22, 0.3);
}

.noise-danger {
	color: #f87171;
	text-shadow: 0 0 20px rgba(239, 68, 68, 0.6);
}
.badge-danger {
	background: rgba(239, 68, 68, 0.2);
	color: #f87171;
	border: 1px solid rgba(239, 68, 68, 0.4);
	box-shadow: 0 0 12px rgba(239, 68, 68, 0.3);
}

/* Real-time VU Bar Meter */
.vu-bar-track {
	width: 100%;
	height: 14px;
	background: #090c13;
	border-radius: 6px;
	overflow: hidden;
	position: relative;
	border: 1px solid var(--border);
	margin: 0.75rem 0;
}

.vu-bar-fill {
	height: 100%;
	background: linear-gradient(90deg, 
		#10b981 0%, 
		#10b981 50%, 
		#f59e0b 70%, 
		#f97316 85%, 
		#ef4444 100%
	);
	transition: width 0.05s ease-out;
	border-radius: 4px;
}

.vu-bar-peak {
	position: absolute;
	top: 0;
	bottom: 0;
	width: 3px;
	background: #ffffff;
	box-shadow: 0 0 6px #ffffff;
	transition: left 0.1s ease;
}

.vu-scale-ticks {
	display: flex;
	justify-content: space-between;
	width: 100%;
	font-family: var(--font-mono);
	font-size: 0.7rem;
	color: var(--muted);
	padding: 0 2px;
}

/* Telemetry Grid Stats */
.telemetry-grid {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
	gap: 0.75rem;
	width: 100%;
	margin-top: 1rem;
}

.telemetry-box {
	background: rgba(13, 18, 28, 0.7);
	border: 1px solid var(--border);
	border-radius: var(--radius-sm);
	padding: 0.65rem 0.75rem;
	text-align: center;
}

.telemetry-label {
	font-size: 0.7rem;
	font-family: var(--font-mono);
	color: var(--muted);
	text-transform: uppercase;
	letter-spacing: 0.05em;
	margin-bottom: 0.2rem;
}

.telemetry-val {
	font-family: var(--font-mono);
	font-size: 1.15rem;
	font-weight: 700;
	color: #f1f5f9;
	font-variant-numeric: tabular-nums;
}

/* Frequency Spectrum RTA Bars */
.rta-canvas {
	width: 100%;
	height: 90px;
	background: #090d14;
	border: 1px solid var(--border);
	border-radius: var(--radius-sm);
	display: block;
}

/* Signal Generator Panel */
.generator-box {
	background: var(--bg-card);
	border: 1px solid var(--border);
	border-radius: var(--radius);
	padding: 1rem;
}

/* Control Pills / Selectors */
.pill-group {
	display: flex;
	background: #090d15;
	border: 1px solid var(--border);
	border-radius: 8px;
	padding: 3px;
	gap: 3px;
}

.pill-option {
	flex: 1;
	background: transparent;
	border: none;
	color: var(--muted);
	padding: 0.35rem 0.65rem;
	border-radius: 6px;
	font-size: 0.8rem;
	font-weight: 600;
	cursor: pointer;
	transition: all 0.15s;
	text-align: center;
}

.pill-option.selected {
	background: #1e293b;
	color: #38bdf8;
	box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
}

/* Range Inputs */
.range-slider {
	-webkit-appearance: none;
	appearance: none;
	width: 100%;
	height: 6px;
	background: #1e293b;
	border-radius: 3px;
	outline: none;
}

.range-slider::-webkit-slider-thumb {
	-webkit-appearance: none;
	appearance: none;
	width: 18px;
	height: 18px;
	background: #06b6d4;
	border-radius: 50%;
	cursor: pointer;
	box-shadow: 0 0 10px rgba(6, 182, 212, 0.6);
}

.range-slider::-moz-range-thumb {
	width: 18px;
	height: 18px;
	background: #06b6d4;
	border-radius: 50%;
	cursor: pointer;
	border: none;
	box-shadow: 0 0 10px rgba(6, 182, 212, 0.6);
}

/* Form Controls */
.input, .select, .textarea {
	width: 100%;
	padding: 0.6rem 0.85rem;
	background: #0a0e17;
	border: 1px solid var(--border);
	border-radius: var(--radius-sm);
	color: var(--fg);
	font-family: var(--font);
	font-size: 0.875rem;
}

.input:focus, .select:focus, .textarea:focus {
	border-color: #06b6d4;
	outline: none;
	box-shadow: 0 0 0 2px rgba(6, 182, 212, 0.2);
}

/* Recorded Gallery & Video Player */
.recording-card {
	background: var(--bg-card);
	border: 1px solid var(--border);
	border-radius: var(--radius);
	overflow: hidden;
	transition: transform 0.15s, border-color 0.15s;
}

.recording-card:hover {
	border-color: var(--border-light);
	transform: translateY(-2px);
}

.video-thumb-container {
	position: relative;
	width: 100%;
	aspect-ratio: 16 / 9;
	background: #030508;
}

.video-thumb-player {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
}

/* Snapshot Toast */
.toast-banner {
	position: fixed;
	bottom: 2rem;
	left: 50%;
	transform: translateX(-50%);
	background: rgba(13, 18, 28, 0.95);
	border: 1px solid var(--accent);
	box-shadow: 0 8px 30px rgba(0, 0, 0, 0.7), 0 0 20px var(--accent-glow);
	border-radius: 999px;
	padding: 0.6rem 1.4rem;
	color: #fff;
	font-size: 0.875rem;
	display: flex;
	align-items: center;
	gap: 0.6rem;
	z-index: 100;
	animation: slideUp 0.25s ease-out;
}

@keyframes slideUp {
	from { opacity: 0; transform: translate(-50%, 10px); }
	to { opacity: 1; transform: translate(-50%, 0); }
}

@keyframes blink {
	0%, 100% { opacity: 1; }
	50% { opacity: 0.3; }
}

@keyframes pulse-red {
	0%, 100% { box-shadow: 0 0 10px rgba(239, 68, 68, 0.4); }
	50% { box-shadow: 0 0 22px rgba(239, 68, 68, 0.8); }
}

/* Loading & Empty Primitives */
.loading {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 0.6rem;
	padding: 2rem;
	color: var(--muted);
	font-family: var(--font-mono);
	font-size: 0.9rem;
}

.spinner {
	width: 1.25rem;
	height: 1.25rem;
	border: 2px solid var(--border);
	border-top-color: var(--accent);
	border-radius: 50%;
	animation: spin 0.7s linear infinite;
}

@keyframes spin {
	to { transform: rotate(360deg); }
}

.empty {
	padding: 3rem 1.5rem;
	text-align: center;
	color: var(--muted);
}

.empty-title {
	font-size: 1.1rem;
	font-weight: 700;
	color: var(--fg);
	margin: 0.5rem 0 0.25rem;
}

.alert {
	padding: 0.75rem 1rem;
	border-radius: var(--radius-sm);
	font-size: 0.875rem;
	display: flex;
	align-items: center;
	justify-content: space-between;
	border: 1px solid var(--border);
}

.alert-error {
	background: rgba(239, 68, 68, 0.12);
	border-color: rgba(239, 68, 68, 0.3);
	color: #fca5a5;
}

/* Modal Dialog */
.modal-backdrop {
	position: fixed;
	inset: 0;
	background: rgba(0, 0, 0, 0.8);
	backdrop-filter: blur(8px);
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 1rem;
	z-index: 99;
}

.modal-content {
	background: var(--bg-card);
	border: 1px solid var(--border-light);
	border-radius: var(--radius-lg);
	max-width: 34rem;
	width: 100%;
	max-height: 90vh;
	overflow-y: auto;
	padding: 1.5rem;
	box-shadow: 0 16px 40px rgba(0, 0, 0, 0.8);
}
