*,
*::before,
*::after {
	box-sizing: border-box;
}

body {
	font-family: -apple-system, sans-serif;
	max-width: 640px;
	margin: 2rem auto;
	padding: 0 1rem;
	color: #111;
}

h1 {
	font-size: 1.25rem;
	margin: 0 0 .25rem;
}

.byline {
	font-size: .875rem;
	color: #888;
	margin: 0 0 1.5rem;
}

section {
	border: 1px solid #e0e0e0;
	border-radius: 8px;
	padding: 1rem;
	margin-bottom: 1rem;
}

section h2 {
	font-size: .7rem;
	font-weight: 600;
	color: #888;
	text-transform: uppercase;
	letter-spacing: .08em;
	margin: 0 0 .75rem;
}

input,
select,
button {
	padding: .45rem .65rem;
	font-size: .9rem;
	line-height: 1.4;
	height: 2.1rem;
	border: 1px solid #d0d0d0;
	border-radius: 6px;
	background: #fff;
	color: #111;
}

button {
	cursor: pointer;
}

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

/* Search */
#btn-search {
	background: #000;
	color: #fff;
	border-color: #000;
	white-space: nowrap;
}

#btn-search:disabled {
	background: #999;
	border-color: #999;
}

/* Output controls */
.controls-row {
	display: flex;
	gap: 1rem;
	align-items: flex-end;
}

.field {
	display: flex;
	flex-direction: column;
	gap: .3rem;
}

.field label {
	font-size: .75rem;
	font-weight: 500;
	color: #666;
}

#search-type {
	width: 8rem;
}

#search-limit {
	width: 5rem;
}

/* Results */
#results-header {
	display: flex;
	align-items: center;
	gap: .5rem;
	margin-bottom: .5rem;
}

#results-header:empty {
	display: none;
}

#results-header .back-btn {
	font-size: .8rem;
	background: none;
	border: 1px solid #ccc;
	border-radius: 4px;
	padding: .2rem .5rem;
	height: auto;
	color: #555;
}

#results-header .album-title {
	font-size: .875rem;
	color: #555;
}

#results {
	margin: 0;
	padding-left: 1.25rem;
}

#results:empty::before {
	content: "No results yet.";
	color: #aaa;
	font-size: .875rem;
}

li {
	margin: .4rem 0;
	font-size: .9rem;
}

/* Login */
.btn-row {
	display: flex;
	gap: .5rem;
}

/* Player */
.player-layout {
	display: flex;
	gap: 1rem;
	align-items: flex-start;
}

#artwork {
	width: 80px;
	height: 80px;
	border-radius: 8px;
	object-fit: cover;
	display: none;
	flex-shrink: 0;
	box-shadow: 0 4px 16px rgba(0, 0, 0, .2);
}

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

.player-track {
	margin-bottom: .6rem;
	min-height: 2.5rem;
}

#now-playing-title {
	font-size: .95rem;
	font-weight: 600;
	color: #111;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

#now-playing-artist {
	font-size: .825rem;
	color: #888;
	margin-top: .15rem;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.player-buttons {
	display: flex;
	gap: .4rem;
	margin-bottom: .6rem;
}

#btn-playpause {
	flex: 1;
	background: #000;
	color: #fff;
	border-color: #000;
	font-weight: 500;
}

#btn-playpause:disabled {
	background: #999;
	border-color: #999;
}

.player-seek {
	margin-bottom: .6rem;
}

.player-seek input[type="range"] {
	width: 100%;
	height: auto;
	padding: 0;
	border: none;
	background: transparent;
	cursor: pointer;
	display: block;
}

.seek-times {
	display: flex;
	justify-content: space-between;
	font-size: .7rem;
	color: #aaa;
	margin-top: .15rem;
}

.player-volume {
	display: flex;
	align-items: center;
	gap: .5rem;
}

.vol-label {
	font-size: .75rem;
	color: #999;
	white-space: nowrap;
}

#volume {
	flex: 1;
	height: auto;
	padding: 0;
	border: none;
	background: transparent;
	cursor: pointer;
}

/* Messages */
#status {
	font-size: .875rem;
	color: #333;
	margin: 0;
}

/* Login note */
.login-note {
	font-size: .775rem;
	color: #aaa;
	margin: .6rem 0 0;
}

/* Genres */
.genres-legend {
	font-size: .8rem;
	color: #666;
	margin: 0 0 .75rem;
	display: flex;
	gap: 1rem;
	flex-wrap: wrap;
}

.genres-legend-item {
	display: flex;
	align-items: center;
	gap: .4rem;
}

.genres-legend-dot {
	display: inline-block;
	width: 12px;
	height: 12px;
	border-radius: 50%;
	flex-shrink: 0;
}

.genres-legend-dot-off {
	background: #f0f0f0;
	border: 1px solid #d0d0d0;
}

.genres-legend-dot-or {
	background: #34c759;
}

.genres-legend-dot-and {
	background: #ff3b30;
}

.genres-grid {
	display: flex;
	flex-wrap: wrap;
	gap: .5rem;
}

.genre-tag {
	display: inline-block;
	padding: .4rem .8rem;
	background: #f0f0f0;
	border: 1px solid #d0d0d0;
	border-radius: 20px;
	font-size: .8rem;
	color: #555;
	white-space: nowrap;
	cursor: pointer;
	transition: all .2s;
}

.genre-tag:hover {
	background: #e8e8e8;
}

.genre-tag-or {
	background: #34c759 !important;
	color: #fff !important;
	border-color: #34c759 !important;
}

.genre-tag-and {
	background: #ff3b30 !important;
	color: #fff !important;
	border-color: #ff3b30 !important;
}

/* Recently Played */
.recently-played-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
	gap: 1rem;
	margin-bottom: .5rem;
}

.recently-played-item {
	display: flex;
	flex-direction: column;
	gap: .4rem;
	cursor: pointer;
	text-decoration: none;
	color: inherit;
}

.recently-played-item img {
	width: 100%;
	aspect-ratio: 1;
	border-radius: 8px;
	object-fit: cover;
	box-shadow: 0 2px 8px rgba(0, 0, 0, .15);
	transition: transform .2s;
}

.recently-played-item:active img {
	transform: scale(.95);
}

.recently-played-item .name {
	font-size: .8rem;
	font-weight: 500;
	color: #111;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.recently-played-item .type {
	font-size: .7rem;
	color: #aaa;
}

/* Responsive */
@media (max-width: 540px) {
	body {
		margin: 1rem auto;
	}

	input,
	select,
	button {
		height: 2.75rem;
		font-size: 1rem;
	}

	.controls-row {
		flex-wrap: wrap;
	}

	.controls-row .field:first-child {
		flex: 1 1 100%;
	}

	#search-type {
		width: 100%;
	}

	#results-header .back-btn {
		padding: .4rem .75rem;
		font-size: .875rem;
	}

	.recently-played-grid {
		grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
		gap: .75rem;
	}

	.genre-tag {
		font-size: .75rem;
		padding: .3rem .6rem;
	}
}