* {
	box-sizing: border-box;
}

:root {
	--bg: #0b0d10;
	--panel: #111419;
	--panel-soft: #161a21;
	--surface: #0c0f14;
	--border: #262c36;
	--text: #f4f4f5;
	--muted: #9ca3af;
	--accent: #5eabde;
	--accent-soft: rgba(94, 171, 222, 0.14);
}

body {
	margin: 0;
	overflow: hidden;
	font-family: Inter, system-ui, sans-serif;
	background: var(--bg);
	color: var(--text);
}

button,
input,
select {
	font: inherit;
}

button {
	cursor: pointer;
}

h1,
h2,
p {
	margin: 0;
}

.app {
	height: 100vh;
	display: grid;
	grid-template-columns: 280px minmax(0, 1fr) 340px;
	gap: 16px;
	padding: 16px;
	overflow: hidden;
}

.sidebar,
.content,
.details {
	min-height: 0;
	overflow: auto;
	background: var(--panel);
	border: 1px solid var(--border);
	border-radius: 16px;
	padding: 16px;
}

.brand {
	margin-bottom: 20px;
}

.brand h1 {
	font-size: 20px;
}

.brand p,
.status,
.field,
.spriteAtlas,
.meta,
.shown {
	color: var(--muted);
	font-size: 13px;
}

.logo {
	display: none;
}

.field {
	display: grid;
	gap: 6px;
	margin-bottom: 12px;
	font-weight: 600;
}

select,
input {
	width: 100%;
	height: 40px;
	border: 1px solid var(--border);
	border-radius: 10px;
	background: var(--surface);
	color: var(--text);
	padding: 0 10px;
	outline: none;
}

select:focus,
input:focus {
	border-color: var(--accent);
}

.actions {
	display: flex;
	gap: 8px;
	margin-bottom: 12px;
}

#loadBtn,
#rebuildBtn,
.copyBtn {
	height: 40px;
	border: 0;
	border-radius: 10px;
	background: var(--accent);
	color: #061016;
	font-weight: 800;
	padding: 0 14px;
}

#rebuildBtn {
	background: var(--panel-soft);
	color: var(--text);
	border: 1px solid var(--border);
}

.status {
	margin-bottom: 18px;
	line-height: 1.35;
}

.atlasHeader {
	display: flex;
	justify-content: space-between;
	margin: 16px 0 8px;
	color: var(--muted);
	font-size: 12px;
	font-weight: 800;
	text-transform: uppercase;
	letter-spacing: 0.08em;
}

.atlasList {
	display: grid;
	gap: 8px;
}

.atlasBtn {
	width: 100%;
	min-height: 38px;
	border: 1px solid var(--border);
	border-radius: 10px;
	background: var(--surface);
	color: var(--text);
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 0 10px;
}

.atlasBtn small {
	color: var(--muted);
	font-weight: 800;
}

.atlasBtn.active {
	border-color: var(--accent);
	background: var(--accent-soft);
}

.content {
	display: flex;
	flex-direction: column;
}

.topbar {
	flex: 0 0 auto;
	display: flex;
	justify-content: space-between;
	align-items: end;
	gap: 16px;
	margin-bottom: 16px;
}

.topbar h2 {
	font-size: 24px;
}

.grid {
	flex: 1 1 auto;
	min-height: 0;
	overflow: auto;
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(128px, 1fr));
	align-content: start;
	gap: 12px;
	padding-right: 4px;
}

.spriteCard {
	min-height: 164px;
	border: 1px solid var(--border);
	border-radius: 14px;
	background: var(--surface);
	color: var(--text);
	padding: 10px;
	display: grid;
	grid-template-rows: 92px auto auto;
	gap: 8px;
	text-align: center;
}

.spriteCard:hover,
.spriteCard.selected {
	border-color: var(--accent);
}

.preview,
.bigPreview {
	display: grid;
	place-items: center;
	overflow: hidden;
	border-radius: 10px;
	background-color: var(--panel-soft);
	background-image:
		linear-gradient(45deg, rgba(255, 255, 255, 0.04) 25%, transparent 25%),
		linear-gradient(-45deg, rgba(255, 255, 255, 0.04) 25%, transparent 25%),
		linear-gradient(45deg, transparent 75%, rgba(255, 255, 255, 0.04) 75%),
		linear-gradient(-45deg, transparent 75%, rgba(255, 255, 255, 0.04) 75%);
	background-size: 24px 24px;
	background-position: 0 0, 0 12px, 12px -12px, -12px 0;
}

.preview img,
.bigPreview img {
	image-rendering: pixelated;
	image-rendering: crisp-edges;
	transform-origin: center;
}

.preview img {
	max-width: 48px;
	max-height: 48px;
}

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

.spriteAtlas {
	font-weight: 700;
}

.details.empty {
	display: grid;
	place-items: center;
	color: var(--muted);
}

.bigPreview {
	height: 220px;
	margin-bottom: 16px;
}

.bigPreview img {
	max-width: 96px;
	max-height: 96px;
}

.detailName {
	margin-bottom: 4px;
	font-size: 24px;
}

.copyBtn {
	width: 100%;
	margin: 16px 0;
}

.info {
	display: grid;
	gap: 10px;
}

.info div {
	display: grid;
	gap: 5px;
}

.info b {
	color: var(--muted);
	font-size: 12px;
}

code {
	display: block;
	overflow: auto;
	padding: 10px;
	border: 1px solid var(--border);
	border-radius: 10px;
	background: var(--surface);
	color: var(--text);
	font-size: 12px;
}

.toast {
	position: fixed;
	right: 16px;
	bottom: 16px;
	border: 1px solid var(--border);
	border-radius: 10px;
	background: var(--panel);
	padding: 10px 12px;
}

@media (max-width: 1000px) {
	body {
		overflow: auto;
	}

	.app {
		height: auto;
		min-height: 100vh;
		grid-template-columns: 1fr;
		overflow: visible;
	}

	.sidebar,
	.content,
	.details,
	.grid {
		overflow: visible;
	}
}