/* Base styles */
* {
	box-sizing: border-box;
	margin: 0;
	padding: 0;
}

:root {
	--font-family: "Inter", system-ui, -apple-system, sans-serif;
	--text: #e7ecffa3;
	--text-dim: rgba(231, 236, 255, 0.5);
	--bg-panel: rgba(0, 0, 0, 0.671);
	--bg-glass: rgb(0, 0, 0);
	--border: rgba(231, 236, 255, 0.5);
	--radius: 8px;
	--spacing: 12px;
}

html, body {
	height: 100%;
}

body {
	height: 100vh;
	height: 100dvh;
	overflow: hidden;
	font-family: var(--font-family);
	background: #000000;
	color: var(--text);
	display: flex;
	padding-left: env(safe-area-inset-left);
	padding-right: env(safe-area-inset-right);
	padding-top: env(safe-area-inset-top);
	padding-bottom: env(safe-area-inset-bottom);
	overscroll-behavior: none;
	touch-action: none;
}

/* Sidebar */
aside {
	width: min(300px, 25vw);
	display: flex;
	flex-direction: column;
	position: relative;
	margin: var(--spacing);
	margin-right: 0;
	margin-left: 0;
}

.list-container {
	position: relative;
	display: flex;
	flex-direction: column;
	flex: 1;
	min-height: 0;
}

.list-container[hidden] {
	display: none !important;
}

.sidebar-header {
	position: relative;
	display: flex;
	font-size: 1.5rem;
	font-weight: 600;
	margin-bottom: var(--spacing);
	gap: 8px;
	align-items: center;
}

.sidebar-title {
	flex: 1;
	font-size: 14px;
	color: var(--text);
	padding: 10px 14px;
}

.overlay-toggle {
	width: 44px;
	height: 44px;
	border: none;
	border-radius: var(--radius) 0 0 var(--radius);
	background: var(--bg-glass);
	color: var(--text);
	cursor: pointer;
	font-size: 1.2rem;
	transition: background 0.15s;
	flex-shrink: 0;
}

.overlay-toggle:hover:not(:disabled) {
	background: rgba(91, 158, 255, 0.15);
}

.overlay-toggle:disabled {
	opacity: 0.3;
	cursor: not-allowed;
}

.row-input {
	flex: 1;
	min-width: 0;
	border: none;
	border-radius: 0 var(--radius) var(--radius) 0;
	background: var(--bg-glass);
	padding: 10px 40px 10px 14px;
	color: inherit;
	font-size: 16px;
	transition: all 0.2s;
	outline: none;
}

.row-input::placeholder {
	color: var(--text-dim);
}

.row-input:hover,
.row-input:focus {
	background: rgba(91, 158, 255, 0.08);
}

.clear-row-button {
	position: absolute;
	right: 8px;
	top: 50%;
	transform: translateY(-50%);
	width: 24px;
	height: 24px;
	border: none;
	border-radius: 50%;
	background: rgba(255, 255, 255, 0.1);
	color: var(--text);
	cursor: pointer;
	font-size: 18px;
	line-height: 1;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: all 0.2s;
	padding: 0;
	z-index: 1;
}

.clear-row-button:hover {
	background: rgba(255, 255, 255, 0.2);
}

/* Song list */
ul.list {
	flex: 1;
	overflow-y: auto;
	display: flex;
	flex-direction: column;
	scrollbar-width: none;
	-ms-overflow-style: none;
	border-radius: var(--radius);
	touch-action: pan-y;
	overscroll-behavior: contain;
}

ul.list::-webkit-scrollbar {
	display: none;
}

.list-row {
	display: flex;
	justify-content: space-between;
	align-items: center;
	padding: 12px var(--spacing);
	background: var(--bg-glass);
	cursor: pointer;
	gap: var(--spacing);
	border-radius: var(--radius);
	border-bottom: 1px solid rgba(255, 255, 255, 0.03);
	transition: background 0.15s;
	position: relative;
	margin-bottom: 6px;
}

.list-row:hover {
	background: rgba(20, 24, 32, 0.8);
}

.list-row.active {
	background: rgba(18, 37, 26, 0.315);
	z-index: 10;
}

.list-row.active .list-title {
	color: #5ec589;
	font-weight: 600;
}

.list-row.empty {
	justify-content: center;
	color: var(--text-dim);
}

.list-text {
	display: flex;
	flex-direction: column;
	gap: 4px;
	flex: 1;
	min-width: 0;
}

.list-title {
	width: 100%;
	font-weight: 500;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.list-subtitle {
	font-size: 11px;
	letter-spacing: 0.5px;
	color: var(--text-dim);
	text-transform: uppercase;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

/* Slider rows */
.slider-row {
	flex-direction: column;
	align-items: stretch;
	gap: 6px;
	cursor: default;
}

.slider-row .list-title {
	width: 100%;
}

.slider-row .list-title input[type="range"] {
	width: 100%;
}

.slider-row .list-subtitle {
	width: 100%;
	display: flex;
	justify-content: space-between;
}

/* Section titles */
.sidebar-section-title {
	font-size: 11px;
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: 0.5px;
	color: var(--text-dim);
	padding: 12px var(--spacing) 6px;
}

/* Transcription rows */
.transcription-row {
	cursor: pointer;
}

.transcription-row.active {
	background: rgba(94, 197, 137, 0.15);
}

.transcription-row.active .list-title {
	color: #5ec589;
}

/* Main content area */
main {
	flex: 1;
	display: grid;
	grid-template-columns: 1fr 45px;
	grid-template-rows: 4fr 1fr;
	gap: var(--spacing);
	overflow: hidden;
	position: relative;
	isolation: isolate;
}

.choose-song-overlay {
	position: absolute;
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	background: rgba(0, 0, 0, 0.6);
	backdrop-filter: blur(10px);
	-webkit-backdrop-filter: blur(10px);
	z-index: 5;
	padding: calc(var(--spacing) * 3);
	text-align: center;
	font-weight: 600;
	letter-spacing: 0.02em;
	line-height: 1.4;
	color: #f5f7ff;
	transition: opacity 0.25s ease, visibility 0.25s ease;
}

.choose-song-overlay .overlay-card {
	background: rgba(16, 20, 28, 0.8);
	border: 1px solid rgba(255, 255, 255, 0.08);
	border-radius: calc(var(--radius) * 1.5);
	padding: calc(var(--spacing) * 2.5) calc(var(--spacing) * 3);
	box-shadow: 0 18px 60px rgba(0, 0, 0, 0.55);
	max-width: 460px;
	width: min(90%, 520px);
}

.choose-song-overlay.hidden {
	opacity: 0;
	visibility: hidden;
	pointer-events: none;
}

.grid-row {
	display: contents;
}

.grid-cell {
	border-radius: var(--radius);
	min-height: 0;
	min-width: 0;
	display: flex;
	flex-direction: column;
	justify-content: center;
}

.control-cell {
	background: rgba(0, 0, 0, 0.822);
	align-items: center;
	z-index: 1;
}

/* Crossfade slider */
.crossfade-row {
	flex-direction: column;
	align-items: center;
	gap: 6px;
	width: 100%;
	height: 90%;
	text-align: center;
}

#crossfade {
	appearance: slider-vertical;
	-webkit-appearance: slider-vertical;
	inline-size: 12px;
	block-size: 100%;
	background: transparent;
	margin: 0 auto;
	display: block;
}

#crossfade::-webkit-slider-runnable-track {
	width: 12px;
	height: 150px;
	border: 2px solid #17324e;
	border-radius: 999px;
	background: transparent;
}

#crossfade::-webkit-slider-thumb {
	-webkit-appearance: none;
	width: 18px;
	height: 18px;
	border-radius: 50%;
	border: 2px solid #30794e;
	background: #000;
	box-shadow: 0 0 0 2px #5ec589 inset;
	margin-left: -5px;
}

#crossfade::-moz-range-track {
	width: 12px;
	height: 150px;
	border: 2px solid #0c2b49;
	border-radius: 999px;
	background: transparent;
}

#crossfade::-moz-range-thumb {
	width: 18px;
	height: 18px;
	border-radius: 50%;
	border: 2px solid #277548;
	background: #000;
	box-shadow: 0 0 0 2px #5ec589 inset;
}

/* Buttons */
button {
	width: 44px;
	height: 100%;
	border: none;
	border-radius: var(--radius);
	font-size: 1rem;
	background: var(--bg-glass);
	color: var(--text);
	cursor: pointer;
	transition: background 0.15s;
}

button:disabled {
	opacity: 0.3;
	cursor: not-allowed;
}

#play-button:hover:not(:disabled) {
	background: rgba(94, 197, 137, 0.15);
	box-shadow: inset 0 0 20px rgba(94, 197, 137, 0.3), 0 0 0 1px rgba(94, 197, 137, 0.5);
}

/* View containers */
.view-container {
	position: relative;
	height: 100%;
	display: flex;
	overflow: clip;
}

.line-labels {
	display: flex;
	flex-direction: column;
	justify-content: space-evenly;
	align-items: center;
	padding: 0;
	z-index: 3;
	pointer-events: none;
	width: 45px;
	flex-shrink: 0;
	background: rgba(0, 0, 0, 0.8);
}

.line-label {
	color: var(--text-dim);
	font-size: 2rem;
	opacity: 0.3;
}

.line-display {
	position: relative;
	flex: 1;
	scrollbar-width: none;
	transform: translateZ(0);
	touch-action: pan-x;
}

.line-display::-webkit-scrollbar {
	display: none;
}

.line-scroll {
	position: absolute;
	inset: 0;
	will-change: transform;
	min-width: 100%;
	transform: translate3d(0, 0, 0);
	display: flex;
	flex-direction: column;
	justify-content: space-evenly;
}

#tab-scroll {
	padding-right: 100vw;
	padding-left: 0;
	box-sizing: content-box;
}

.line-row {
	position: relative;
	height: 1vh;
}

.line-track {
	position: relative;
	flex: 1;
}

.track-line {
	position: absolute;
	inset: 0;
	top: 50%;
	transform: translateY(-50%);
	height: 1px;
	border-radius: 999px;
	background: var(--line-color, rgba(255, 255, 255, 0.1));
	opacity: 1;
	box-shadow: 3px 2px 2px var(--line-color, rgba(255, 255, 255, 0.5));
	filter: saturate(1.5) brightness(1.2);
}

.line-notes {
	position: absolute;
	inset: 0;
}

/* Notes */
.note-element {
	position: absolute;
	border-radius: 8px;
	padding: 0;
	height: 6vh;
	min-height: 20px;
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 2rem;
	font-weight: 600;
	color: white;
	color: color(display-p3 1.5 1.5 1.5);
	background: rgb(28, 50, 71);
	transform: translateY(-50%);
	top: 50%;
}

#tab-display .note-element {
	opacity: 1;
	box-shadow:
		inset 0 0 8px rgba(0, 0, 0, 0.8),
		inset 0 0 4px rgba(0, 0, 0, 0.8),
		inset 0 1px 1px rgba(255, 255, 255, 0.9),
		inset 0 -1px 2px rgba(0, 0, 0, 0.5),
		0 4px 8px rgba(0, 0, 0, 0.5),
		0 0 5px var(--line-color, rgba(255, 255, 255, 0.2));
	background-image:
		radial-gradient(ellipse at center, rgba(0, 0, 0, 0.5) 0%, rgba(0, 0, 0, 0.2) 30%, transparent 60%),
		linear-gradient(to bottom, rgba(255, 255, 255, 0.3) 0%, transparent 50%),
		linear-gradient(
			135deg,
			transparent 0%, transparent 30%,
			rgba(255, 255, 255, 0.3) 30%, rgba(255, 255, 255, 0.5) 35%, rgba(255, 255, 255, 0.3) 40%,
			transparent 40%, transparent 55%,
			rgba(255, 255, 255, 0.2) 55%, rgba(255, 255, 255, 0.4) 60%, rgba(255, 255, 255, 0.2) 65%,
			transparent 65%
		);
	background-color: var(--line-color, rgba(255, 255, 255, 0.2));
	text-shadow: 0 2px 4px rgba(0, 0, 0, 0.8);
	filter: saturate(1.5) brightness(1.1);
}

.note-element-ghost {
	position: absolute;
	border-radius: 8px;
	padding: 0 10px;
	height: 6vh;
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: clamp(12px, 3vw, 18px);
	font-weight: 600;
	transform: translateY(-50%);
	top: 50%;
	background: rgba(255, 255, 255, 0.05);
	color: var(--text-dim);
	border: 1px dashed rgba(255, 255, 255, 0.2);
	opacity: 0;
	transition: opacity 0.1s;
}

.line-scroll:hover .note-element-ghost {
	opacity: 0.4;
}

/* Playhead and cursor */
.view-cursor,
.view-red-line {
	position: absolute;
	width: 2px;
	top: 2.5%;
	bottom: 2.5%;
	background: rgba(255, 80, 80, 0.7);
	pointer-events: none;
}

.view-cursor {
	z-index: 2;
	transform: translateX(-50%);
}

.view-red-line {
	z-index: 100;
	left: 45px;
}

/* Seek bar */
.seek-time {
	font-variant-numeric: tabular-nums;
	font-size: 13px;
}

#seek-display {
	cursor: pointer;
}

.seek-scroll {
	width: 100%;
}

#seek-display .line-row {
	height: 100%;
}

#seek-display .line-track {
	height: 100%;
}

#seek-display .note-element {
	pointer-events: none;
	height: 95%;
	max-height: none;
}

/* Form elements */
select, input, button {
	font-family: inherit;
}

/* Responsive */
@media (orientation: portrait) {
	body {
		flex-direction: column;
	}

	aside {
		width: auto;
		height: 35vh;
		margin-right: var(--spacing);
		margin-bottom: 0;
		margin-left: 0;
	}
}
