:root{ --header-height: 72px; }
html, body {
    height: 100%;
}

body {
	margin: 0;
	font-family: sans-serif;
	min-height: 100vh;
	background: #0f0f0f;
	color: #fff;
}

.gallery {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
	gap: 12px;
	width: min(1200px, 94%);
	padding: 8px;
	box-sizing: border-box;
	
	 margin: 0 auto 40px auto;
	 min-height: 40vh;

	 overflow: visible;
	align-content: stretch;
	grid-auto-rows: 1fr; 
}

.tile {
	background: #0f0f0f;
	border-radius: 8px;
	overflow: hidden;
	display: flex;
	align-items: center;
	justify-content: center;
	box-shadow: 0 4px 10px rgba(0,0,0,0.6);
}

.tile img {
	width: 100%;
	height: 100%;
	max-width: 100%;
	max-height: 100%;
	object-fit: contain;
	display: block;
}

.tile:focus {
	outline: 3px solid rgba(255,255,255,0.12);
	outline-offset: 4px;
}

.tile.playing {
	box-shadow: 0 8px 20px rgba(0,0,0,0.7), 0 0 0 4px rgba(255,255,255,0.03) inset;
	transform: translateY(-4px);
}


.tile.playing{
	position: relative;
}
.tile.playing::after{
	content: "";
	position: absolute;
	top: 8px;
	left: 8px;
	display: inline-block;
	width: 12px;
	height: 12px;
	background: #ff5252;
	border-radius: 50%;
	box-shadow: 0 0 0 6px rgba(255,82,82,0.12);
	animation: pulse 1.4s infinite ease-out;
}
.tile.playing .playing-pill{
	display: none; 
}

.playing-label{
	position: absolute;
	top: 6px;
	left: 28px;
	background: rgba(0,0,0,0.6);
	color: #fff;
	padding: 4px 8px;
	border-radius: 12px;
	font-size: 12px;
	pointer-events: none;
	backdrop-filter: blur(2px);
}

@keyframes pulse{
	0%{ transform: scale(0.9); opacity: 1 }
	70%{ transform: scale(1.6); opacity: 0 }
	100%{ transform: scale(1.6); opacity: 0 }
}

.tile.queued {
	box-shadow: 0 6px 14px rgba(255,215,0,0.06);
	outline: 2px dashed rgba(255,215,0,0.12);
}

.tile.favorite{
	box-shadow: 0 6px 16px rgba(42,157,143,0.18);
	outline: 3px solid rgba(42,157,143,0.12);
}

.controls{
	position: fixed;
	top: 0;
	left: 0;
	right: 0;
	height: auto;
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	align-items: center;
	padding: 10px 12px;
	z-index: 2000;
	background: rgba(10,10,10,0.95);
	box-shadow: 0 2px 12px rgba(0,0,0,0.5);
}

.controls .color{
	width: 22px;
	height: 22px;
	border: none;
	border-radius: 5px;
	cursor: pointer;
}

.toolbar-actions{ display:flex; gap:8px; align-items:center }
.menu-panel{ width:100%; padding:8px 0; display:block; border-top:1px solid rgba(255,255,255,0.04); margin-top:8px }
.menu-panel .menu-row{ display:flex; gap:8px; align-items:center; flex-wrap:wrap; padding:6px 8px }
.menu-panel label{ color:#ddd }
.menu-panel input, .menu-panel select{ background:#111; color:#fff; border:1px solid #333; padding:6px 8px; border-radius:6px }
.menu-panel .color{ margin-right:4px }
.menu-panel[hidden]{ display:none }

#menuToggle{ padding:6px 8px; border-radius:6px; border:none; background:#333; color:#fff; cursor:pointer }
#menuToggle[aria-expanded="true"]{ background: linear-gradient(180deg,#444,#222) }

.controls button#playBtn,
.controls button#pauseBtn{
	padding: 5px 8px;
	border-radius: 6px;
	border: none;
	cursor: pointer;
	color: #fff;
	background: #444;
	margin-left: 6px;
	font-size: 13px;
}
.controls button#playBtn:disabled,
.controls button#pauseBtn:disabled{ opacity: 0.45; cursor: default }
.controls button#playBtn{ background: linear-gradient(180deg,#2a9d8f,#207a6b) }
.controls button#pauseBtn{ background: linear-gradient(180deg,#c0392b,#90221a) }

.controls label{ color: #ddd; font-size: 14px; margin-right: 6px; }

.controls #clearPrefs{ padding: 6px 8px; background: #222; color: #fff; border: none; border-radius: 6px; cursor: pointer; }

.controls .selected-name{ color: #ddd; margin-left: 8px; font-size: 14px; max-width: 36vw; white-space: nowrap; overflow: hidden; text-overflow: ellipsis }
.controls .color.selected{ outline: 3px solid rgba(255,255,255,0.12); transform: translateY(-2px); }

.controls input#userName{ padding: 6px 8px; border-radius: 6px; border: 1px solid #333; background: #111; color: #fff; margin-left:6px }
.controls #speakBtn{ padding: 6px 8px; margin-left:4px; background:#2a9d8f; color:#fff; border:none; border-radius:6px; cursor:pointer }
.controls select#favoriteSelect{ margin-left:6px; padding:6px 8px; border-radius:6px; background:#111; color:#fff; border:1px solid #333 }

@media (min-width: 900px) {

	.gallery { padding: 12px; }
}


@media (min-width: 1200px) {
    .gallery { grid-template-columns: repeat(4, 1fr); }
}

@media (max-width: 420px) {
	.gallery { padding: 6px; gap: 8px; }
	.controls{ padding: 8px; gap: 6px; }
	.controls label{ font-size: 12px }
	.controls input#userName, .controls select#favoriteSelect{ width: 100%; margin-left: 0 }
	.controls .selected-name{ width: 100%; margin-left: 0 }
	.menu-panel .menu-row{ padding:6px 12px }
}


@media (min-width: 1024px) {
	html, body { overflow: hidden; height: 100%; }
	.gallery {

		height: calc(100vh - 72px);
		margin-bottom: calc(72px + 8px);
	}
}



h7 {
	color: #fff;
	font-size: 24px;
	margin-right: 12px;
	font-weight: normal;
}