:root {
	--sidebar-width: 320px;
	--bg: #0b0d12;
	--bg-glow: radial-gradient(circle at 15% 0%, #2a1d4d44, transparent 55%),
		radial-gradient(circle at 85% 100%, #0d3b4d44, transparent 55%);
	--panel: #15171ecc;
	--card: #1b1e26;
	--card-hover: #21252f;
	--border: #2a2f3a;
	--text: #eef0f4;
	--text-dim: #9aa0ac;
	--accent: #7c5cff;
	--accent-2: #36c5f0;
	--accent-green: #2ecc71;
	--accent-green-2: #1abc9c;
	--accent-red: #e74c3c;
	--accent-red-2: #c0392b;
	--gradient: linear-gradient(135deg, var(--accent), var(--accent-2));
	--gradient-play: linear-gradient(135deg, var(--accent-green), var(--accent-green-2));
	--gradient-stop: linear-gradient(135deg, var(--accent-red), var(--accent-red-2));
	--radius: 14px;
	--radius-sm: 8px;
	--shadow: 0 8px 24px -8px #00000080;
}

* {
	box-sizing: border-box;
}

html,
body {
	margin: 0;
	padding: 0;
	min-height: 100vh;
	background: var(--bg-glow), var(--bg);
	color: var(--text);
	font-family: 'Segoe UI', system-ui, -apple-system, Roboto, sans-serif;
}

a {
	color: var(--accent-2);
}

button {
	font-family: inherit;
	cursor: pointer;
}

button:focus-visible {
	outline: 2px solid var(--accent-2);
	outline-offset: 2px;
}

.layout {
	display: flex;
	min-height: 100vh;
}

/* ---------- Sidebar (desktop) ---------- */
.sidebar {
	width: var(--sidebar-width);
	flex: 0 0 var(--sidebar-width);
	background: var(--panel);
	backdrop-filter: blur(16px);
	border-right: 1px solid var(--border);
	padding: 1.75rem 1.25rem;
	display: flex;
	flex-direction: column;
	gap: 1.5rem;
	overflow-y: auto;
	scrollbar-width: thin;
	scrollbar-color: var(--border) transparent;
}

.brand-link {
	display: flex;
	align-items: center;
	gap: 0.7rem;
	text-decoration: none;
}

.brand-icon {
	width: 36px;
	height: 36px;
	flex-shrink: 0;
}

.sidebar h1 {
	font-size: 1.15rem;
	font-weight: 700;
	margin: 0;
	background: var(--gradient);
	-webkit-background-clip: text;
	background-clip: text;
	color: transparent;
	letter-spacing: 0.01em;
}

.now-playing {
	display: flex;
	align-items: center;
	gap: 0.9rem;
	height: 80px;
	background: var(--card);
	border: 1px solid var(--border);
	border-radius: var(--radius);
	box-shadow: var(--shadow);
	position: relative;
}

.now-playing::before {
	content: '';
	position: absolute;
	inset: 0;
	background: var(--gradient);
	opacity: 0;
	transition: opacity 0.3s;
}

body.is-playing .now-playing::before {
	opacity: 0.06;
}

.now-playing-art {
	position: relative;
	width: 56px;
	height: 56px;
	flex-shrink: 0;
	border-radius: calc(var(--radius) - 6px);
	background: linear-gradient(135deg, hsl(260 70% 55%), hsl(200 70% 50%));
	display: flex;
	align-items: center;
	justify-content: center;
	overflow: hidden;
}

.now-playing-art-initial {
	font-size: 1.4rem;
	font-weight: 700;
	color: #fff;
}

.now-playing-art .equalizer {
	position: absolute;
	bottom: 6px;
	right: 6px;
}

.now-playing-info {
	min-width: 0;
	flex: 1;
}

.now-playing .station-name {
	font-weight: 600;
	margin: 0;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.now-playing .track-ticker {
	color: var(--text-dim);
	font-size: 0.85rem;
	min-height: 1.2em;
	margin-top: 0.25rem;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.equalizer {
	display: flex;
	align-items: flex-end;
	gap: 3px;
	height: 14px;
	flex-shrink: 0;
}

.equalizer span {
	width: 3px;
	height: 30%;
	background: var(--gradient);
	border-radius: 2px;
	opacity: 0.35;
	transition: opacity 0.2s;
}

body.is-playing .equalizer span {
	opacity: 1;
	animation: equalize 0.9s ease-in-out infinite;
}

body.is-playing .equalizer span:nth-child(1) {
	animation-delay: -0.6s;
}

body.is-playing .equalizer span:nth-child(2) {
	animation-delay: -0.3s;
}

.now-playing-art .equalizer span {
	background: #fff;
	width: 2px;
}

@keyframes equalize {
	0%,
	100% {
		height: 25%;
	}
	50% {
		height: 100%;
	}
}

.controls {
	display: flex;
	gap: 0.6rem;
}

.transport-btn {
	flex: 1;
	display: flex;
	align-items: center;
	justify-content: center;
	height: 46px;
	border-radius: var(--radius-sm);
	border: 1px solid var(--border);
	background: var(--card);
	color: var(--text);
	transition: transform 0.15s, border-color 0.15s, background 0.15s;
}

.transport-btn:hover {
	border-color: var(--accent);
	background: var(--card-hover);
}

.transport-btn:active {
	transform: scale(0.94);
}

.transport-btn--primary {
	background: var(--gradient-play);
	border: none;
	color: #fff;
	box-shadow: 0 4px 16px -4px #2ecc7180;
}

.transport-btn--primary:hover {
	filter: brightness(1.1);
}

.transport-btn--primary[aria-pressed='true'] {
	background: var(--gradient-stop);
	box-shadow: 0 4px 16px -4px #e74c3c80;
}

.transport-btn[aria-pressed='true']:not(.transport-btn--primary) {
	border-color: var(--accent-2);
	color: var(--accent-2);
}

.volume-row {
	display: flex;
	align-items: center;
	gap: 0.7rem;
}

.icon-volume-label {
	width: 18px;
	height: 18px;
	color: var(--text-dim);
	flex-shrink: 0;
}

.volume-slider {
	flex: 1;
	appearance: none;
	height: 4px;
	border-radius: 999px;
	background: var(--border);
	outline: none;
}

.volume-slider::-webkit-slider-thumb {
	appearance: none;
	width: 16px;
	height: 16px;
	border-radius: 50%;
	background: var(--gradient);
	cursor: pointer;
	border: none;
}

.volume-slider::-moz-range-thumb {
	width: 16px;
	height: 16px;
	border-radius: 50%;
	background: var(--gradient);
	cursor: pointer;
	border: none;
}

.sleep-timer {
	background: var(--card);
	border: 1px solid var(--border);
	border-radius: var(--radius);
	padding: 0.9rem 1rem;
}

.sleep-timer-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	margin-bottom: 0.6rem;
}

.sleep-timer-header .label {
	font-size: 0.85rem;
	font-weight: 600;
	color: var(--text-dim);
}

.sleep-timer-header .timer-display {
	font-size: 0.85rem;
	font-weight: 600;
	color: var(--accent-2);
}

.sleep-timer-controls {
	display: flex;
	gap: 0.5rem;
}

.sleep-timer-controls select {
	flex: 1;
	min-width: 0;
	padding: 0.5rem;
	border-radius: var(--radius-sm);
	border: 1px solid var(--border);
	background: var(--bg);
	color: var(--text);
	font-size: 0.85rem;
}

.sleep-btn {
	padding: 0.5rem 0.8rem;
	border-radius: var(--radius-sm);
	border: 1px solid var(--border);
	background: var(--card-hover);
	color: var(--text);
	font-size: 0.85rem;
	font-weight: 600;
	transition: border-color 0.15s, opacity 0.15s;
}

.sleep-btn:hover:not(:disabled) {
	border-color: var(--accent);
}

.sleep-btn:disabled {
	opacity: 0.4;
	cursor: not-allowed;
}

.sleep-btn--cancel {
	border-color: var(--accent-red);
	color: var(--accent-red);
}

.player-toast {
	font-size: 0.85rem;
	color: var(--accent-red);
	background: hsl(6 70% 50% / 0.12);
	border: 1px solid hsl(6 70% 50% / 0.3);
	border-radius: var(--radius-sm);
	padding: 0.6rem 0.8rem;
}

.icon {
	width: 20px;
	height: 20px;
}

.icon--hidden {
	display: none;
}

.sidebar-section-label {
	font-size: 0.75rem;
	font-weight: 700;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	color: var(--text-dim);
	margin-top: -0.5rem;
}

.recently-played-section[hidden] {
	display: none;
}

.recently-played-section {
	display: flex;
	flex-direction: column;
	gap: 0.5rem;
}

.recently-played {
	display: flex;
	flex-wrap: wrap;
	gap: 0.4rem;
}

.recent-chip {
	font-size: 0.78rem;
	color: var(--text-dim);
	background: var(--card);
	border: 1px solid var(--border);
	border-radius: 999px;
	padding: 0.3rem 0.7rem;
	max-width: 100%;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.recent-chip:hover {
	border-color: var(--accent);
	color: var(--text);
}

.categories {
	display: flex;
	flex-direction: column;
	gap: 0.3rem;
}

.categories .category-btn {
	text-align: left;
	padding: 0.55rem 0.8rem;
	border-radius: var(--radius-sm);
	border: 1px solid transparent;
	background: transparent;
	color: var(--text-dim);
	font-size: 0.95rem;
	transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.categories .category-btn:hover {
	background: var(--card);
	color: var(--text);
}

.categories .category-btn.active {
	background: var(--card);
	border-color: var(--accent);
	color: var(--text);
	box-shadow: 0 0 0 1px #7c5cff33;
}

/* ---------- Dashboard ---------- */
.dashboard {
	flex: 1;
	margin-left: var(--sidebar-width);
	padding: 2rem;
}

.dashboard-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 1rem;
	margin-bottom: 1.5rem;
}

.dashboard-header h2 {
	margin: 0;
	font-size: 1.3rem;
	font-weight: 700;
}

.back-link {
	display: inline-block;
	color: var(--text-dim);
	font-size: 0.9rem;
	margin-bottom: 1.5rem;
}

.back-link:hover {
	color: var(--text);
}

.station-detail {
	display: grid;
	grid-template-columns: 280px 1fr;
	gap: 2rem;
	align-items: start;
}

.station-detail .station-card {
	cursor: pointer;
}

.station-detail-body {
	color: var(--text-dim);
	line-height: 1.7;
}

.station-detail-body :first-child {
	margin-top: 0;
}

@media (max-width: 699px) {
	.station-detail {
		grid-template-columns: 1fr;
	}
}

.search-box {
	display: flex;
	align-items: center;
	gap: 0.5rem;
	background: var(--card);
	border: 1px solid var(--border);
	border-radius: 999px;
	padding: 0.5rem 0.9rem;
	width: 280px;
	transition: border-color 0.15s;
}

.search-box:focus-within {
	border-color: var(--accent);
}

.search-box .icon {
	width: 16px;
	height: 16px;
	color: var(--text-dim);
	flex-shrink: 0;
}

.search-box input {
	flex: 1;
	min-width: 0;
	border: none;
	outline: none;
	background: transparent;
	color: var(--text);
	font-size: 0.9rem;
	font-family: inherit;
}

.no-results {
	color: var(--text-dim);
	text-align: center;
	margin-top: 3rem;
}

#stations-grid-container {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
	gap: 1.1rem;
}

.station-card {
	background: var(--card);
	border: 1px solid var(--border);
	border-radius: var(--radius);
	padding: 1.1rem;
	display: flex;
	flex-direction: column;
	gap: 0.6rem;
	text-align: left;
	color: var(--text);
	transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease,
		background 0.18s ease;
}

.station-card:hover {
	border-color: var(--accent);
	background: var(--card-hover);
	transform: translateY(-3px);
	box-shadow: var(--shadow);
}

.station-card:hover .play-overlay {
	opacity: 1;
}

.station-card:focus-visible {
	outline: 2px solid var(--accent-2);
	outline-offset: 2px;
}

.station-card.unavailable {
	opacity: 0.45;
	pointer-events: none;
}

.station-card.playing {
	border-color: var(--accent-2);
	box-shadow: 0 0 0 1px var(--accent-2), 0 0 24px -6px #36c5f066;
}

.station-card.playing .live-badge {
	display: flex;
}

.station-art {
	position: relative;
	width: 100%;
	aspect-ratio: 16 / 9;
	border-radius: calc(var(--radius) - 6px);
	overflow: hidden;
	background: linear-gradient(135deg, hsl(var(--art-hue) 65% 45%), hsl(calc(var(--art-hue) + 50) 65% 35%));
	display: flex;
	align-items: center;
	justify-content: center;
}

.station-art img {
	width: 100%;
	height: 100%;
	object-fit: cover;
}

.station-art-initial {
	font-size: 2rem;
	font-weight: 700;
	color: #ffffffcc;
}

.live-badge {
	display: none;
	position: absolute;
	top: 0.5rem;
	left: 0.5rem;
	align-items: center;
	gap: 0.3rem;
	background: #000000aa;
	color: #fff;
	font-size: 0.65rem;
	font-weight: 700;
	letter-spacing: 0.05em;
	text-transform: uppercase;
	padding: 0.2rem 0.5rem 0.2rem 0.4rem;
	border-radius: 999px;
}

.live-dot {
	width: 6px;
	height: 6px;
	border-radius: 50%;
	background: var(--accent-red);
	animation: pulse-dot 1.4s ease-in-out infinite;
}

@keyframes pulse-dot {
	0%,
	100% {
		opacity: 1;
	}
	50% {
		opacity: 0.35;
	}
}

.play-overlay {
	position: absolute;
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	background: #00000066;
	opacity: 0;
	transition: opacity 0.18s;
}

.play-overlay svg {
	width: 42px;
	height: 42px;
	color: #fff;
	filter: drop-shadow(0 2px 6px #00000080);
}

.favorite-btn {
	position: absolute;
	top: 0.5rem;
	right: 0.5rem;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 28px;
	height: 28px;
	border-radius: 50%;
	border: none;
	background: #000000aa;
	color: #ffffffaa;
	transition: color 0.15s, transform 0.15s;
}

.favorite-btn:hover {
	transform: scale(1.1);
}

.favorite-btn svg {
	width: 15px;
	height: 15px;
}

.favorite-btn[aria-pressed='true'] {
	color: #ffd24c;
}

.station-card-body {
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	gap: 0.5rem;
}

.station-card .title {
	font-weight: 600;
	margin: 0;
}

.info-link {
	font-size: 0.75rem;
	color: var(--accent-2);
	white-space: nowrap;
	flex-shrink: 0;
}

.info-link:hover {
	text-decoration: underline;
}

.station-card .description {
	color: var(--text-dim);
	font-size: 0.85rem;
	margin: 0;
}

.station-card .category-tags {
	display: flex;
	flex-wrap: wrap;
	gap: 0.4rem;
}

.station-card .category-tag {
	font-size: 0.7rem;
	font-weight: 600;
	color: hsl(var(--tag-hue) 80% 75%);
	background: hsl(var(--tag-hue) 70% 50% / 0.15);
	border: 1px solid hsl(var(--tag-hue) 70% 50% / 0.3);
	border-radius: 999px;
	padding: 0.15rem 0.6rem;
}

.station-card .location-tag {
	font-size: 0.7rem;
	font-weight: 600;
	color: var(--text-dim);
	border: 1px solid var(--border);
	border-radius: 999px;
	padding: 0.15rem 0.6rem;
}

/* ---------- Mobile ---------- */
.sidebar-toggle {
	display: none;
}

@media (max-width: 899px) {
	.layout {
		flex-direction: column;
	}

	.sidebar {
		position: fixed;
		bottom: 0;
		left: 0;
		right: 0;
		top: auto;
		width: 100%;
		flex: none;
		height: auto;
		max-height: 75vh;
		border-right: none;
		border-top: 1px solid var(--border);
		border-radius: var(--radius) var(--radius) 0 0;
		z-index: 50;
		padding-bottom: calc(1.25rem + env(safe-area-inset-bottom));
	}

	.brand,
	.volume-row,
	.sleep-timer,
	.sidebar-section-label,
	.categories {
		display: none;
	}

	.sidebar.is-expanded .brand,
	.sidebar.is-expanded .volume-row,
	.sidebar.is-expanded .sleep-timer,
	.sidebar.is-expanded .sidebar-section-label,
	.sidebar.is-expanded .categories {
		display: flex;
	}

	.sidebar.is-expanded .sidebar-section-label {
		display: block;
	}

	.sidebar-toggle {
		display: flex;
		align-items: center;
		justify-content: center;
		width: 100%;
		padding: 0.4rem 0;
		background: transparent;
		border: none;
		color: var(--text-dim);
		order: -1;
	}

	.sidebar-toggle svg {
		width: 20px;
		height: 20px;
		transition: transform 0.2s;
	}

	.sidebar.is-expanded .sidebar-toggle svg {
		transform: rotate(180deg);
	}

	.dashboard {
		margin-left: 0;
		padding-bottom: 8rem;
	}

	.dashboard-header {
		flex-direction: column;
		align-items: stretch;
	}

	.search-box {
		width: 100%;
	}

	#stations-grid-container {
		grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
	}
}

@media (min-width: 900px) {
	.sidebar {
		position: fixed;
		top: 0;
		left: 0;
		height: 100vh;
		overflow-y: auto;
	}
}
