:root {
	--bg: #0b0d12;
	--bg-soft: #10131a;
	--panel: #151923;
	--panel-raised: #1b2030;
	--border: #252b3a;
	--border-soft: #1e2432;
	--text: #eef1f7;
	--muted: #8c94a8;
	--accent: #ff335f;
	--accent-2: #ff6b8a;
	--green: #3ddc97;
	--yellow: #ffb020;
	--radius: 16px;
	--shadow: 0 24px 70px rgb(0 0 0 / 45%);
	color-scheme: dark;
}

* {
	box-sizing: border-box;
}

[hidden] {
	display: none !important;
}

html,
body {
	margin: 0;
	min-height: 100%;
}

body {
	background:
		radial-gradient(1100px 600px at 12% -10%, rgb(255 51 95 / 13%), transparent 60%),
		radial-gradient(900px 520px at 100% 0%, rgb(79 140 255 / 10%), transparent 55%),
		var(--bg);
	background-attachment: fixed;
	color: var(--text);
	font-family:
		ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
	-webkit-font-smoothing: antialiased;
}

button,
input {
	font: inherit;
}

button {
	cursor: pointer;
}

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

h1,
h2,
p {
	margin: 0;
}

.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;
}

.muted {
	color: var(--muted);
}

.small {
	font-size: 12px;
}

/* Brand ------------------------------------------------------------------ */

.brand {
	display: flex;
	align-items: center;
	gap: 10px;
	font-size: 15px;
	font-weight: 700;
	letter-spacing: -0.02em;
}

.brand.compact {
	font-size: 14px;
}

.brand-mark {
	display: grid;
	place-items: center;
	width: 28px;
	height: 28px;
	flex: none;
	border-radius: 9px;
	background: linear-gradient(135deg, var(--accent), #ff7a45);
	color: #fff;
	font-size: 11px;
	box-shadow: 0 6px 18px rgb(255 51 95 / 35%);
}

/* Join screen ------------------------------------------------------------ */

.join-screen {
	display: grid;
	place-items: center;
	min-height: 100dvh;
	padding: 24px;
}

.join-card {
	width: min(440px, 100%);
	padding: clamp(26px, 5vw, 42px);
	border: 1px solid var(--border);
	border-radius: 24px;
	background:
		linear-gradient(180deg, rgb(255 255 255 / 3%), transparent 38%),
		var(--panel);
	box-shadow: var(--shadow);
}

.join-card h1 {
	margin-top: 28px;
	font-size: clamp(30px, 7vw, 42px);
	font-weight: 750;
	line-height: 1.04;
	letter-spacing: -0.045em;
}

.join-intro {
	max-width: 34ch;
	margin-top: 14px;
	font-size: 14px;
	line-height: 1.55;
}

.join-form {
	margin-top: 28px;
}

.join-form label {
	display: block;
	margin: 16px 0 7px;
	color: var(--muted);
	font-size: 11px;
	font-weight: 700;
	letter-spacing: 0.09em;
	text-transform: uppercase;
}

.join-form input {
	width: 100%;
	padding: 12px 14px;
	border: 1px solid var(--border);
	border-radius: 11px;
	outline: none;
	background: var(--bg-soft);
	color: var(--text);
	transition:
		border-color 0.15s ease,
		box-shadow 0.15s ease;
}

.join-form input::placeholder,
.url-form input::placeholder {
	color: #626b80;
}

.join-form input:focus,
.url-form input:focus {
	border-color: rgb(255 51 95 / 70%);
	box-shadow: 0 0 0 3px rgb(255 51 95 / 14%);
}

.hint {
	margin-top: 8px;
	color: #6f7789;
	font-size: 11.5px;
}

.form-error {
	margin-top: 12px;
	color: var(--accent-2);
	font-size: 13px;
	line-height: 1.4;
}

.button {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	padding: 10px 16px;
	border: 1px solid transparent;
	border-radius: 10px;
	font-size: 13px;
	font-weight: 650;
	line-height: 1.2;
	white-space: nowrap;
	transition:
		transform 0.12s ease,
		filter 0.12s ease,
		border-color 0.12s ease,
		background 0.12s ease;
}

.button:hover:not(:disabled) {
	transform: translateY(-1px);
	filter: brightness(1.06);
}

.button:active:not(:disabled) {
	transform: translateY(0);
}

.button:disabled {
	cursor: default;
	opacity: 0.55;
}

.button.primary {
	background: linear-gradient(135deg, var(--accent), #ff5a4d);
	color: #fff;
	box-shadow: 0 8px 22px rgb(255 51 95 / 25%);
}

.button.ghost {
	border-color: var(--border);
	background: var(--bg-soft);
	color: var(--text);
}

.button.ghost:hover:not(:disabled) {
	border-color: #343c4f;
	background: var(--panel-raised);
}

.button.wide {
	width: 100%;
	margin-top: 20px;
	padding-block: 12px;
}

.button.small-button {
	padding: 6px 10px;
	font-size: 11.5px;
}

/* Room shell ------------------------------------------------------------- */

.room-screen {
	min-height: 100dvh;
}

.topbar {
	position: sticky;
	top: 0;
	z-index: 10;
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 16px;
	padding: 13px clamp(16px, 3vw, 32px);
	border-bottom: 1px solid var(--border);
	background: rgb(11 13 18 / 82%);
	backdrop-filter: blur(14px);
}

.topbar-right {
	display: flex;
	align-items: center;
	gap: 14px;
}

.status-pill {
	display: inline-flex;
	align-items: center;
	gap: 7px;
	padding: 5px 10px;
	border: 1px solid var(--border);
	border-radius: 999px;
	background: var(--bg-soft);
	color: var(--muted);
	font-size: 12px;
	font-weight: 600;
}

.status-dot {
	width: 7px;
	height: 7px;
	border-radius: 50%;
	background: var(--muted);
}

.status-pill.connected {
	border-color: rgb(61 220 151 / 25%);
	color: #a9f2ce;
}

.status-pill.connected .status-dot {
	background: var(--green);
	box-shadow: 0 0 0 3px rgb(61 220 151 / 15%);
}

.status-pill.connecting .status-dot,
.status-pill.reconnecting .status-dot {
	background: var(--yellow);
	animation: pulse 1.4s ease-in-out infinite;
}

.status-pill.offline .status-dot {
	background: var(--accent);
}

@keyframes pulse {
	50% {
		opacity: 0.3;
	}
}

.room-layout {
	display: grid;
	grid-template-columns: minmax(0, 1fr) auto;
	align-items: start;
	gap: 20px;
	width: min(1800px, 100%);
	margin: 0 auto;
	padding: clamp(14px, 2.5vw, 26px);
}

.player-column {
	min-width: 0;
}

.panel {
	border: 1px solid var(--border);
	border-radius: var(--radius);
	background:
		linear-gradient(180deg, rgb(255 255 255 / 2.5%), transparent 30%),
		var(--panel);
	box-shadow: 0 16px 44px rgb(0 0 0 / 22%);
}

.player-panel {
	padding: 12px;
}

.player-frame {
	position: relative;
	width: 100%;
	width: clamp(240px, calc((100dvh - 270px) * 16 / 9), 100%);
	margin-inline: auto;
	aspect-ratio: 16 / 9;
	overflow: hidden;
	border-radius: 12px;
	background: #000;
}

.player-frame iframe,
#player {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	border: 0;
}

.player-overlay {
	position: absolute;
	inset: 0;
	z-index: 2;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 12px;
	padding: 24px;
	text-align: center;
}

.player-overlay.placeholder {
	background: radial-gradient(circle at 50% 38%, #1a2030, #090b10 72%);
}

.placeholder-icon {
	display: grid;
	place-items: center;
	width: 54px;
	height: 54px;
	border: 1px solid var(--border);
	border-radius: 50%;
	background: rgb(255 255 255 / 4%);
	color: var(--muted);
	font-size: 18px;
}

.placeholder p {
	max-width: 42ch;
	color: var(--muted);
	font-size: 14px;
	line-height: 1.5;
}

.start-overlay {
	z-index: 3;
	background: rgb(6 8 12 / 72%);
	backdrop-filter: blur(5px);
}

.now-playing {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 16px;
	padding: 14px 4px 4px;
}

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

.eyebrow {
	color: var(--muted);
	font-size: 10.5px;
	font-weight: 750;
	letter-spacing: 0.11em;
	text-transform: uppercase;
}

.now-playing-title {
	overflow: hidden;
	margin-top: 3px;
	color: var(--text);
	font-size: 19px;
	font-weight: 680;
	line-height: 1.25;
	letter-spacing: -0.025em;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.now-playing-actions {
	display: flex;
	align-items: center;
	gap: 8px;
	flex: none;
}

.playback-badge {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 5px 9px;
	border: 1px solid var(--border);
	border-radius: 999px;
	background: var(--bg-soft);
	color: var(--muted);
	font-size: 10.5px;
	font-weight: 750;
	letter-spacing: 0.055em;
	line-height: 1;
	text-transform: uppercase;
}

.playback-dot {
	width: 6px;
	height: 6px;
	border-radius: 50%;
	background: currentColor;
}

.playback-badge.playing {
	border-color: rgb(61 220 151 / 25%);
	color: #a9f2ce;
}

.playback-badge.playing .playback-dot {
	background: var(--green);
	box-shadow: 0 0 0 3px rgb(61 220 151 / 12%);
}

.playback-badge.paused {
	border-color: rgb(255 176 32 / 22%);
	color: #f3d591;
}

.playback-badge.paused .playback-dot {
	background: var(--yellow);
}

.now-playing-link {
	text-decoration: none;
	white-space: nowrap;
}

.now-playing-link:hover {
	color: var(--text);
	text-decoration: underline;
}

.url-form {
	display: grid;
	grid-template-columns: minmax(0, 1fr) auto auto;
	gap: 8px;
}

.player-url-form {
	padding-bottom: 10px;
}

.url-form input {
	min-width: 0;
	padding: 11px 14px;
	border: 1px solid var(--border);
	border-radius: 10px;
	outline: none;
	background: var(--bg-soft);
	color: var(--text);
	font-size: 13px;
	transition:
		border-color 0.15s ease,
		box-shadow 0.15s ease;
}

.player-panel > .form-error {
	padding: 0 4px 8px;
}

/* Sidebar ---------------------------------------------------------------- */

.sidebar {
	display: flex;
	align-items: flex-start;
	gap: 12px;
	width: 340px;
	min-width: 0;
	transition: width 0.18s ease;
}

.sidebar.collapsed {
	width: 48px;
}

.sidebar-rail {
	position: sticky;
	top: 72px;
	display: flex;
	flex-direction: column;
	gap: 5px;
	width: 48px;
	flex: none;
	padding: 6px;
	border: 1px solid var(--border);
	border-radius: 14px;
	background:
		linear-gradient(180deg, rgb(255 255 255 / 3%), transparent 40%),
		var(--panel);
	box-shadow: 0 16px 44px rgb(0 0 0 / 22%);
}

.rail-button {
	position: relative;
	display: grid;
	place-items: center;
	width: 34px;
	height: 34px;
	padding: 0;
	border: 0;
	border-radius: 9px;
	background: transparent;
	color: var(--muted);
}

.rail-button svg {
	width: 18px;
	height: 18px;
	transition: transform 0.18s ease;
}

.rail-button:hover {
	background: var(--panel-raised);
	color: var(--text);
}

.rail-toggle {
	margin-bottom: 2px;
	background: var(--bg-soft);
	color: var(--text);
}

.sidebar:not(.collapsed) .rail-toggle svg {
	transform: rotate(180deg);
}

.rail-count {
	position: absolute;
	top: -3px;
	right: -3px;
	display: grid;
	place-items: center;
	min-width: 15px;
	height: 15px;
	padding: 0 4px;
	border: 1px solid var(--border);
	border-radius: 999px;
	background: var(--panel-raised);
	color: var(--text);
	font-size: 9px;
	font-weight: 750;
	line-height: 1;
	pointer-events: none;
}

.sidebar-panels {
	display: flex;
	flex-direction: column;
	gap: 16px;
	width: 280px;
	min-width: 0;
}

.sidebar.collapsed .sidebar-panels {
	display: none;
}

.sidebar-card {
	padding: 0;
}

.sidebar-card .panel-heading {
	padding: 15px 16px 10px;
}

.sidebar-card .panel-content {
	padding: 0 16px 16px;
}

.panel-heading {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	padding-bottom: 12px;
}

.panel-hint {
	margin: -2px 0 10px;
	line-height: 1.45;
}

.panel-heading h2 {
	font-size: 13px;
	font-weight: 700;
	letter-spacing: 0.02em;
}

.count {
	display: inline-grid;
	place-items: center;
	min-width: 22px;
	height: 22px;
	padding: 0 7px;
	border: 1px solid var(--border);
	border-radius: 999px;
	background: var(--bg-soft);
	color: var(--muted);
	font-size: 11px;
	font-weight: 700;
}

.user-list {
	display: flex;
	flex-direction: column;
	gap: 2px;
	max-height: 32vh;
	margin: 0;
	padding: 0;
	overflow: auto;
	list-style: none;
}

.user-row {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 7px 8px;
	border-radius: 10px;
}

.user-row:hover {
	background: rgb(255 255 255 / 3%);
}

.avatar {
	display: grid;
	place-items: center;
	width: 30px;
	height: 30px;
	flex: none;
	border-radius: 50%;
	color: #fff;
	font-size: 12px;
	font-weight: 750;
}

.user-name {
	overflow: hidden;
	min-width: 0;
	font-size: 13px;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.you-tag {
	margin-left: auto;
	padding: 2px 7px;
	border-radius: 999px;
	background: rgb(255 51 95 / 12%);
	color: var(--accent-2);
	font-size: 10px;
	font-weight: 700;
	letter-spacing: 0.04em;
	text-transform: uppercase;
}

.queue-list {
	display: flex;
	flex-direction: column;
	gap: 6px;
	max-height: 46vh;
	margin: 0;
	padding: 0;
	overflow: auto;
	list-style: none;
}

.queue-item {
	display: grid;
	grid-template-columns: auto minmax(0, 1fr) auto;
	align-items: center;
	gap: 10px;
	padding: 9px 9px 9px 10px;
	border: 1px solid transparent;
	border-radius: 11px;
	background: rgb(255 255 255 / 2.2%);
	transition:
		border-color 0.12s ease,
		background 0.12s ease;
}

.queue-item:hover {
	border-color: var(--border);
	background: rgb(255 255 255 / 3.5%);
}

.queue-index {
	color: #596175;
	font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
	font-size: 11px;
}

.queue-main {
	min-width: 0;
}

.queue-title {
	overflow: hidden;
	color: var(--text);
	font-size: 12.5px;
	font-weight: 550;
	line-height: 1.35;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.queue-sub {
	overflow: hidden;
	margin-top: 3px;
	color: var(--muted);
	font-size: 11px;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.queue-actions {
	display: flex;
	align-items: center;
	gap: 4px;
}

.mini-button {
	padding: 5px 8px;
	border: 1px solid var(--border);
	border-radius: 7px;
	background: transparent;
	color: var(--muted);
	font-size: 11px;
	font-weight: 650;
	line-height: 1;
}

.mini-button:hover {
	border-color: #3a4256;
	background: var(--bg-soft);
	color: var(--text);
}

.mini-button.remove:hover {
	border-color: rgb(255 51 95 / 45%);
	color: var(--accent-2);
}

.empty {
	padding: 8px 4px 4px;
	font-size: 12.5px;
	line-height: 1.5;
}

/* Playlist --------------------------------------------------------------- */

.playlist-form {
	display: grid;
	grid-template-columns: minmax(0, 1fr) auto;
	gap: 8px;
}

.playlist-form input {
	min-width: 0;
	padding: 10px 12px;
	border: 1px solid var(--border);
	border-radius: 10px;
	outline: none;
	background: var(--bg-soft);
	color: var(--text);
	font-size: 12.5px;
	transition:
		border-color 0.15s ease,
		box-shadow 0.15s ease;
}

.playlist-form input:focus {
	border-color: rgb(255 51 95 / 70%);
	box-shadow: 0 0 0 3px rgb(255 51 95 / 14%);
}

.playlist-form input::placeholder {
	color: #626b80;
}

.playlist-meta {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 8px 10px;
	margin: 12px 0 8px;
}

#playlist-name {
	flex: 1 1 100%;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

#playlist-name.has-playlist {
	color: var(--text);
	font-weight: 600;
}

.segmented {
	display: inline-flex;
	padding: 2px;
	border: 1px solid var(--border);
	border-radius: 9px;
	background: var(--bg-soft);
}

.mode-button {
	padding: 5px 9px;
	border: 0;
	border-radius: 6px;
	background: transparent;
	color: var(--muted);
	font-size: 11px;
	font-weight: 650;
	line-height: 1.2;
}

.mode-button.active {
	background: var(--panel-raised);
	color: var(--text);
}

.mode-button:disabled {
	cursor: default;
	opacity: 0.45;
}

#playlist-clear {
	margin-left: auto;
}

.playlist-list {
	max-height: 38vh;
}

.playlist-item {
	grid-template-columns: auto minmax(0, 1fr);
}

.playlist-list .queue-title {
	font-family: inherit;
}

/* Toast ------------------------------------------------------------------ */

.notice {
	position: fixed;
	right: 20px;
	bottom: 20px;
	z-index: 50;
	max-width: min(380px, calc(100vw - 40px));
	padding: 12px 16px;
	border: 1px solid rgb(255 51 95 / 35%);
	border-radius: 12px;
	background: #1c1420;
	color: #ffd9e1;
	font-size: 13px;
	line-height: 1.4;
	box-shadow: var(--shadow);
}

/* Responsive ------------------------------------------------------------- */

@media (max-width: 960px) {
	.room-layout {
		grid-template-columns: minmax(0, 1fr);
	}

	.sidebar,
	.sidebar.collapsed {
		flex-direction: column;
		width: 100%;
		gap: 10px;
	}

	.sidebar-rail {
		position: static;
		flex-direction: row;
		align-items: center;
		width: 100%;
	}

	.rail-toggle {
		order: 99;
		margin-bottom: 0;
		margin-left: auto;
	}

	.sidebar-panels {
		width: 100%;
	}

	.user-list {
		max-height: 26vh;
	}

	.queue-list {
		max-height: 34vh;
	}

	.playlist-list {
		max-height: 42vh;
	}
}

@media (max-width: 640px) {
	.topbar {
		padding: 12px 16px;
	}

	.topbar .brand span:last-child {
		display: none;
	}

	.room-layout {
		padding: 12px;
		gap: 14px;
	}

	.player-panel {
		padding: 8px;
	}

	.sidebar {
		display: flex;
		flex-direction: column;
		align-items: stretch;
	}

	.sidebar-panels {
		width: 100%;
	}

	.url-form {
		grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
	}

	.url-form input {
		grid-column: 1 / -1;
	}

	.now-playing {
		flex-wrap: wrap;
		align-items: flex-start;
		padding-top: 12px;
	}

	.now-playing-actions {
		width: 100%;
		margin-left: 0;
		justify-content: flex-start;
	}

	.queue-list,
	.playlist-list {
		max-height: 40vh;
	}

	.topbar-right {
		gap: 8px;
	}

	#user-count {
		display: none;
	}

	.notice {
		right: 12px;
		bottom: 12px;
	}
}

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