.dl-app {
	--dl-header-h: 56px;
	--dl-panel-w: 300px;
	min-height: 100vh;
	min-height: 100dvh;
	display: flex;
	flex-direction: column;
	background: var(--it-bg);
	color: var(--it-text);
	overflow: hidden;
}

.is-hidden {
	display: none !important;
}

/* Header */
.dl-header {
	position: sticky;
	top: 0;
	z-index: 20;
	display: flex;
	align-items: center;
	gap: 20px;
	height: var(--dl-header-h);
	padding: 0 18px 0 16px;
	border-bottom: 1px solid rgba(255, 255, 255, 0.08);
	background: rgba(10, 11, 13, 0.92);
	backdrop-filter: blur(12px);
}

.dl-header__start {
	display: flex;
	align-items: center;
	gap: 12px;
	min-width: 0;
}

.dl-header__brand {
	display: inline-flex;
	flex-shrink: 0;
}

.dl-header__logo {
	display: block;
	width: 20px;
	height: auto;
	animation: it-logo-glitch 2s steps(1, end) infinite;
}

.dl-header__titles {
	display: flex;
	flex-direction: column;
	gap: 1px;
	min-width: 0;
}

.dl-header__eyebrow {
	font-size: 0.65rem;
	font-weight: 500;
	letter-spacing: 0.1em;
	text-transform: uppercase;
	color: var(--it-muted);
}

.dl-header__title {
	margin: 0;
	font-size: 1rem;
	font-weight: 600;
	letter-spacing: -0.02em;
	line-height: 1.1;
}

.dl-header__nav {
	display: flex;
	align-items: center;
	gap: 18px;
	margin-left: auto;
	font-size: 0.84rem;
}

.dl-header__nav a {
	color: var(--it-muted);
}

.dl-header__nav a:hover {
	color: var(--it-text);
}

.dl-header__actions {
	display: flex;
	align-items: center;
	gap: 10px;
	flex-shrink: 0;
}

/* Workspace */
.dl-workspace {
	flex: 1;
	display: grid;
	grid-template-columns: var(--dl-panel-w) minmax(0, 1fr);
	min-height: 0;
}

.dl-panel {
	padding: 18px 16px 24px;
	border-right: 1px solid rgba(255, 255, 255, 0.08);
	background:
		linear-gradient(180deg, rgba(255, 255, 255, 0.02), transparent 120px),
		#0a0b0d;
	overflow-y: auto;
	overflow-x: hidden;
}

.dl-panel__section {
	margin-bottom: 22px;
}

.dl-panel__section--sliders {
	margin-bottom: 0;
}

.dl-panel__label {
	margin: 0 0 10px;
	font-size: 0.68rem;
	font-weight: 600;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	color: var(--it-muted);
}

/* Upload */
.dl-upload__input {
	position: absolute;
	width: 1px;
	height: 1px;
	opacity: 0;
	pointer-events: none;
}

.dl-upload__empty {
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	gap: 8px;
	padding: 14px;
	border: 1.5px dashed rgba(255, 255, 255, 0.12);
	border-radius: 10px;
	background: rgba(255, 255, 255, 0.02);
	transition: border-color 0.2s ease, background 0.2s ease;
}

.dl-upload.is-drag-over .dl-upload__empty,
.dl-viewport.is-drag-over .dl-viewport__empty {
	border-color: rgba(var(--it-accent-rgb), 0.45);
	background: rgba(var(--it-accent-rgb), 0.06);
}

.dl-upload__hint {
	margin: 0;
	font-size: 0.74rem;
	line-height: 1.45;
	color: var(--it-muted);
}

.dl-upload__loaded {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 10px;
	border: 1px solid rgba(255, 255, 255, 0.1);
	border-radius: 10px;
	background: rgba(255, 255, 255, 0.03);
}

.dl-upload__thumb {
	width: 64px;
	height: 64px;
	object-fit: cover;
	border-radius: 8px;
	border: 1px solid rgba(255, 255, 255, 0.1);
}

.dl-upload__name {
	display: block;
	font-size: 0.8rem;
	font-weight: 500;
	word-break: break-all;
	margin-bottom: 3px;
}

.dl-upload__change {
	font-size: 0.76rem;
	color: var(--it-accent);
	cursor: pointer;
}

.dl-upload__change:hover {
	text-decoration: underline;
}

/* Algorithm list */
.dl-algo-list {
	display: flex;
	flex-direction: column;
	gap: 6px;
}

.dl-algo {
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	gap: 2px;
	width: 100%;
	padding: 10px 12px;
	border: 1px solid rgba(255, 255, 255, 0.08);
	border-radius: 8px;
	background: rgba(255, 255, 255, 0.02);
	color: var(--it-text);
	text-align: left;
	cursor: pointer;
	transition: border-color 0.15s ease, background 0.15s ease;
}

.dl-algo:hover {
	border-color: rgba(255, 255, 255, 0.14);
	background: rgba(255, 255, 255, 0.04);
}

.dl-algo.is-active {
	border-color: rgba(var(--it-accent-rgb), 0.35);
	background: rgba(var(--it-accent-rgb), 0.08);
}

.dl-algo__name {
	font-size: 0.82rem;
	font-weight: 600;
}

.dl-algo__hint {
	font-size: 0.72rem;
	color: var(--it-muted);
}

/* Colors */
.dl-colors {
	display: grid;
	grid-template-columns: 1fr auto 1fr;
	gap: 8px;
	align-items: end;
	margin-bottom: 12px;
}

.dl-colors__pick {
	display: flex;
	flex-direction: column;
	gap: 6px;
}

.dl-colors__pick-label {
	font-size: 0.72rem;
	color: var(--it-muted);
}

.dl-colors__pick input[type="color"] {
	width: 100%;
	height: 34px;
	padding: 2px;
	border: 1px solid rgba(255, 255, 255, 0.12);
	border-radius: 8px;
	background: rgba(255, 255, 255, 0.03);
	cursor: pointer;
}

.dl-colors__swap {
	display: grid;
	place-items: center;
	width: 34px;
	height: 34px;
	margin-bottom: 1px;
	border: 1px solid rgba(255, 255, 255, 0.1);
	border-radius: 8px;
	background: rgba(255, 255, 255, 0.03);
	color: var(--it-muted);
	cursor: pointer;
}

.dl-colors__swap:hover {
	color: var(--it-text);
	border-color: rgba(255, 255, 255, 0.16);
}

.dl-presets {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	margin-bottom: 12px;
}

.dl-presets__btn {
	width: 28px;
	height: 28px;
	padding: 0;
	border: 2px solid transparent;
	border-radius: 999px;
	background: transparent;
	cursor: pointer;
}

.dl-presets__btn span {
	display: block;
	width: 100%;
	height: 100%;
	border-radius: inherit;
	background: linear-gradient(135deg, var(--a) 0 50%, var(--b) 50% 100%);
	box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12);
}

.dl-presets__btn.is-active {
	border-color: var(--it-accent);
}

.dl-levels {
	display: grid;
	grid-template-columns: repeat(3, 1fr);
	gap: 6px;
}

.dl-levels__btn {
	padding: 8px 0;
	border: 1px solid rgba(255, 255, 255, 0.1);
	border-radius: 8px;
	background: rgba(255, 255, 255, 0.02);
	color: var(--it-muted);
	font-size: 0.8rem;
	font-weight: 600;
	font-family: "JetBrains Mono", ui-monospace, monospace;
	cursor: pointer;
}

.dl-levels__btn.is-active {
	color: var(--it-text);
	border-color: rgba(var(--it-accent-rgb), 0.35);
	background: rgba(var(--it-accent-rgb), 0.1);
}

/* Sliders */
.dl-slider {
	--dl-slider-track-h: 2px;
	--dl-slider-track: #666;
	--dl-slider-thumb-size: 18px;
	--dl-slider-thumb-radius: 3px;
	--dl-slider-thumb: #d4d4d4;
	margin-bottom: 14px;
}

.dl-slider__head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	margin-bottom: 8px;
	font-size: 0.78rem;
}

.dl-slider__head label {
	color: var(--it-muted);
}

.dl-slider__head output {
	font-family: "JetBrains Mono", ui-monospace, monospace;
	font-size: 0.74rem;
	color: var(--it-text);
}

.dl-slider input[type="range"] {
	display: block;
	width: 100%;
	height: var(--dl-slider-thumb-size);
	margin: 0;
	padding: 0;
	border: none;
	background: transparent;
	cursor: pointer;
	-webkit-appearance: none;
	appearance: none;
}

.dl-slider input[type="range"]::-webkit-slider-runnable-track {
	height: var(--dl-slider-track-h);
	border: none;
	border-radius: 0;
	background: var(--dl-slider-track);
}

.dl-slider input[type="range"]::-webkit-slider-thumb {
	-webkit-appearance: none;
	width: var(--dl-slider-thumb-size);
	height: var(--dl-slider-thumb-size);
	margin-top: calc((var(--dl-slider-track-h) - var(--dl-slider-thumb-size)) / 2);
	border: none;
	border-radius: var(--dl-slider-thumb-radius);
	background: var(--dl-slider-thumb);
	cursor: pointer;
}

.dl-slider input[type="range"]::-moz-range-track {
	height: var(--dl-slider-track-h);
	border: none;
	border-radius: 0;
	background: var(--dl-slider-track);
}

.dl-slider input[type="range"]::-moz-range-progress {
	height: var(--dl-slider-track-h);
	border: none;
	border-radius: 0;
	background: var(--dl-slider-track);
}

.dl-slider input[type="range"]::-moz-range-thumb {
	width: var(--dl-slider-thumb-size);
	height: var(--dl-slider-thumb-size);
	border: none;
	border-radius: var(--dl-slider-thumb-radius);
	background: var(--dl-slider-thumb);
	cursor: pointer;
}

.dl-slider input[type="range"]:focus {
	outline: none;
}

.dl-slider input[type="range"]:focus-visible::-webkit-slider-thumb {
	outline: 2px solid rgba(255, 255, 255, 0.22);
	outline-offset: 2px;
}

.dl-slider input[type="range"]:focus-visible::-moz-range-thumb {
	outline: 2px solid rgba(255, 255, 255, 0.22);
	outline-offset: 2px;
}

/* Stage */
.dl-stage {
	display: flex;
	flex-direction: column;
	min-width: 0;
	min-height: 0;
	background:
		radial-gradient(ellipse 80% 60% at 50% 0%, rgba(var(--it-accent-rgb), 0.05), transparent 55%),
		linear-gradient(rgba(255, 255, 255, 0.025) 1px, transparent 1px),
		linear-gradient(90deg, rgba(255, 255, 255, 0.025) 1px, transparent 1px),
		#08090b;
	background-size: auto, 24px 24px, 24px 24px, auto;
}

.dl-stage__toolbar {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 16px;
	padding: 10px 16px;
	border-bottom: 1px solid rgba(255, 255, 255, 0.06);
	background: rgba(0, 0, 0, 0.28);
}

.dl-view-tabs {
	display: inline-flex;
	padding: 3px;
	border-radius: 999px;
	border: 1px solid rgba(255, 255, 255, 0.1);
	background: rgba(255, 255, 255, 0.03);
}

.dl-view-tabs__btn {
	padding: 6px 12px;
	border: 0;
	border-radius: 999px;
	background: transparent;
	color: var(--it-muted);
	font-size: 0.78rem;
	font-weight: 500;
	cursor: pointer;
}

.dl-view-tabs__btn.is-active {
	background: rgba(255, 255, 255, 0.1);
	color: var(--it-text);
}

.dl-stage__meta {
	font-family: "JetBrains Mono", ui-monospace, monospace;
	font-size: 0.72rem;
	color: var(--it-muted);
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.dl-viewport {
	position: relative;
	flex: 1;
	min-height: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 20px;
}

.dl-viewport__empty {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 10px;
	width: min(420px, 100%);
	padding: 40px 24px;
	border: 1.5px dashed rgba(255, 255, 255, 0.1);
	border-radius: 16px;
	text-align: center;
	color: var(--it-muted);
	transition: border-color 0.2s ease, background 0.2s ease;
}

.dl-viewport__empty-icon {
	color: rgba(255, 255, 255, 0.35);
}

.dl-viewport__empty-title {
	margin: 0;
	font-size: 1rem;
	font-weight: 600;
	color: var(--it-text);
}

.dl-viewport__empty-hint {
	margin: 0;
	font-size: 0.84rem;
	line-height: 1.5;
}

.dl-viewport__frames {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 100%;
	height: 100%;
	max-height: 100%;
}

.dl-compare {
	width: 100%;
	height: 100%;
	display: flex;
	align-items: center;
	justify-content: center;
}

.dl-compare__stage {
	position: relative;
	display: inline-block;
	line-height: 0;
	max-width: 100%;
	max-height: calc(100vh - var(--dl-header-h) - 120px);
	max-height: calc(100dvh - var(--dl-header-h) - 120px);
	--dl-compare-split: 50%;
	touch-action: none;
	user-select: none;
}

.dl-compare__stage.is-dragging {
	cursor: ew-resize;
}

body.dl-compare-dragging {
	cursor: ew-resize;
	user-select: none;
}

.dl-compare__canvas {
	display: block;
	max-width: 100%;
	max-height: calc(100vh - var(--dl-header-h) - 120px);
	max-height: calc(100dvh - var(--dl-header-h) - 120px);
	width: auto;
	height: auto;
	image-rendering: pixelated;
	image-rendering: crisp-edges;
}

.dl-compare__before {
	position: absolute;
	top: 0;
	left: 0;
	width: var(--dl-compare-split);
	height: 100%;
	overflow: hidden;
	z-index: 1;
}

.dl-compare__before .dl-compare__canvas {
	position: absolute;
	top: 0;
	left: 0;
	max-width: none;
	max-height: none;
}

.dl-compare__divider {
	position: absolute;
	top: 0;
	bottom: 0;
	left: var(--dl-compare-split);
	z-index: 2;
	width: 2px;
	transform: translateX(-50%);
	background: rgba(255, 255, 255, 0.92);
	box-shadow: 0 0 12px rgba(0, 0, 0, 0.35);
	cursor: ew-resize;
	touch-action: none;
}

.dl-compare__divider::before {
	content: "";
	position: absolute;
	top: 0;
	bottom: 0;
	left: -14px;
	right: -14px;
}

.dl-compare__handle {
	position: absolute;
	top: 50%;
	left: 50%;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 44px;
	height: 44px;
	padding: 0;
	border: 2px solid rgba(255, 255, 255, 0.92);
	border-radius: 50%;
	background: rgba(8, 9, 11, 0.42);
	color: #fff;
	backdrop-filter: blur(6px);
	transform: translate(-50%, -50%);
	cursor: ew-resize;
	touch-action: none;
}

.dl-compare__handle:focus {
	outline: none;
}

.dl-compare__handle:focus-visible {
	outline: 2px solid rgba(255, 255, 255, 0.45);
	outline-offset: 3px;
}

.dl-compare__handle-icon {
	width: 22px;
	height: 22px;
}

.dl-compare--result .dl-compare__before,
.dl-compare--result .dl-compare__divider {
	display: none;
}

.dl-compare--source .dl-compare__canvas[data-dl-canvas] {
	visibility: hidden;
}

.dl-compare--source .dl-compare__before {
	position: absolute;
	inset: 0;
	width: 100%;
	overflow: visible;
}

.dl-compare--source .dl-compare__before .dl-compare__canvas {
	position: static;
	width: auto !important;
	height: auto !important;
	max-width: 100%;
	max-height: calc(100vh - var(--dl-header-h) - 120px);
	max-height: calc(100dvh - var(--dl-header-h) - 120px);
}

.dl-compare--source .dl-compare__divider {
	display: none;
}

.dl-canvas {
	display: block;
	max-width: 100%;
	max-height: calc(100vh - var(--dl-header-h) - 120px);
	max-height: calc(100dvh - var(--dl-header-h) - 120px);
	width: auto;
	height: auto;
	image-rendering: pixelated;
	image-rendering: crisp-edges;
}

/* Export */
.dl-export {
	position: relative;
}

.dl-export__caret {
	width: 12px;
	height: 12px;
	margin-left: 2px;
}

.dl-export__menu {
	position: absolute;
	top: calc(100% + 8px);
	right: 0;
	z-index: 30;
	min-width: 168px;
	padding: 6px;
	border: 1px solid rgba(255, 255, 255, 0.1);
	border-radius: 12px;
	background: #12141a;
	box-shadow: 0 18px 48px rgba(0, 0, 0, 0.45);
}

.dl-export__item {
	display: flex;
	align-items: center;
	justify-content: space-between;
	width: 100%;
	padding: 10px 12px;
	border: 0;
	border-radius: 8px;
	background: transparent;
	color: var(--it-text);
	font-size: 0.84rem;
	cursor: pointer;
}

.dl-export__item:hover {
	background: rgba(255, 255, 255, 0.06);
}

.dl-export__item-ext {
	font-family: "JetBrains Mono", ui-monospace, monospace;
	font-size: 0.72rem;
	color: var(--it-muted);
}

.dl-buffer {
	position: absolute;
	left: -9999px;
	top: -9999px;
}

.dl-toast {
	position: fixed;
	right: 18px;
	bottom: 18px;
	z-index: 50;
	padding: 12px 16px;
	border-radius: 10px;
	border: 1px solid rgba(var(--it-accent-rgb), 0.25);
	background: rgba(14, 16, 20, 0.94);
	color: var(--it-text);
	font-size: 0.84rem;
	box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
}

@media (max-width: 960px) {
	.dl-app {
		overflow: auto;
	}

	.dl-workspace {
		display: flex;
		flex-direction: column;
		min-height: calc(100dvh - var(--dl-header-h));
	}

	.dl-stage {
		order: 1;
		flex: 1 1 auto;
		min-height: min(52dvh, 420px);
	}

	.dl-panel {
		order: 2;
		flex: 0 0 auto;
		max-height: none;
		border-right: 0;
		border-top: 1px solid rgba(255, 255, 255, 0.08);
		-webkit-overflow-scrolling: touch;
	}

	.dl-header__nav {
		display: none;
	}

	.dl-algo-list {
		display: grid;
		grid-template-columns: repeat(2, minmax(0, 1fr));
		gap: 8px;
	}

	.dl-algo {
		padding: 9px 10px;
	}

	.dl-stage__toolbar {
		flex-wrap: wrap;
		align-items: flex-start;
		padding: 10px 12px;
		gap: 10px;
	}

	.dl-view-tabs {
		max-width: 100%;
		overflow-x: auto;
		-webkit-overflow-scrolling: touch;
		scrollbar-width: none;
	}

	.dl-view-tabs::-webkit-scrollbar {
		display: none;
	}

	.dl-stage__meta {
		flex: 1 1 100%;
		white-space: normal;
		line-height: 1.4;
	}

	.dl-viewport {
		padding: 12px;
	}

	.dl-compare__stage,
	.dl-compare__canvas,
	.dl-canvas,
	.dl-compare--source .dl-compare__before .dl-compare__canvas {
		max-height: calc(100dvh - var(--dl-header-h) - 148px);
	}

	.dl-toast {
		right: 12px;
		bottom: calc(12px + env(safe-area-inset-bottom, 0px));
		left: 12px;
		max-width: none;
	}
}

@media (max-width: 640px) {
	.dl-header {
		gap: 10px;
		padding: 0 12px 0 10px;
	}

	.dl-header__eyebrow {
		display: none;
	}

	.dl-header__title {
		font-size: 0.92rem;
	}

	.dl-header__actions .it-btn {
		padding: 8px 12px;
		font-size: 0.82rem;
	}

	.dl-panel {
		padding: 14px 12px 20px;
		padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px));
	}

	.dl-panel__section {
		margin-bottom: 18px;
	}

	.dl-upload__empty .it-btn {
		width: 100%;
		justify-content: center;
	}

	.dl-colors {
		gap: 6px;
	}

	.dl-presets {
		gap: 6px;
	}

	.dl-view-tabs__btn {
		padding: 6px 10px;
		font-size: 0.74rem;
	}

	.dl-compare__handle {
		width: 40px;
		height: 40px;
	}

	.dl-viewport__empty {
		padding: 28px 18px;
	}

	.dl-toast {
		bottom: calc(76px + env(safe-area-inset-bottom, 0px));
	}
}

@media (max-width: 400px) {
	.dl-algo-list {
		grid-template-columns: 1fr;
	}

	.dl-levels {
		grid-template-columns: repeat(3, minmax(0, 1fr));
	}
}

@media (prefers-reduced-motion: reduce) {
	.dl-header__logo {
		animation: none;
	}
}
