@import url("https://fonts.googleapis.com/css2?family=Nunito:wght@500;600;700;800;900&family=JetBrains+Mono:wght@400;600&display=swap");

:root {
	--bg: #10131a;
	--bg-2: #151a23;
	--panel: #1a202b;
	--panel-2: #212836;
	--line: #2b3343;
	--line-2: #38425a;
	--text: #e9edf5;
	--muted: #8c97ab;
	--gold: #f2b33d;
	--gold-ink: #2a1d00;
	--green: #68c95a;
	--blue: #5aa9ff;
	--red: #ff6b6b;
	--radius: 12px;
	--font: "Nunito", system-ui, -apple-system, "Segoe UI", sans-serif;
	--mono: "JetBrains Mono", ui-monospace, Consolas, monospace;
	color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
	margin: 0;
	background: radial-gradient(1200px 600px at 70% -10%, #1b2335 0%, transparent 60%), var(--bg);
	color: var(--text);
	font: 600 14px/1.45 var(--font);
	display: flex;
	flex-direction: column;
	overflow: hidden;
}
button, input, select, textarea { font: inherit; color: inherit; }
code { font-family: var(--mono); font-size: 12px; background: var(--panel-2); padding: 1px 6px; border-radius: 6px; }
.muted { color: var(--muted); font-weight: 600; }
[hidden] { display: none !important; }
.icon { display: inline-block; flex: none; vertical-align: -0.18em; }
.seg button, .btn, .eyebrow, .slider > span, .picked a { display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.slider > span { justify-content: flex-start; }
.slider > span .icon { color: var(--muted); }

/* ---------- top bar ---------- */
.topbar {
	display: flex; align-items: center; gap: 24px;
	padding: 10px 18px; border-bottom: 1px solid var(--line);
	background: rgba(16, 19, 26, 0.85); backdrop-filter: blur(8px);
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 210px; }
.brand strong { display: block; font-size: 17px; font-weight: 900; letter-spacing: 0.2px; }
.brand small { color: var(--muted); font-size: 12px; }
.brand-mark {
	width: 30px; height: 30px; border-radius: 7px; position: relative;
	background: linear-gradient(#68c95a 0 34%, #8a5a34 34% 100%);
	box-shadow: inset 0 -4px 0 rgba(0, 0, 0, 0.25), 0 0 0 2px #0b0d12;
}
.tabs { display: flex; gap: 4px; background: var(--bg-2); padding: 4px; border-radius: 12px; border: 1px solid var(--line); }
.tabs button {
	border: 0; background: none; padding: 7px 16px; border-radius: 9px; cursor: pointer; color: var(--muted); font-weight: 800; white-space: nowrap;
}
.tabs button.active { background: var(--panel-2); color: var(--text); box-shadow: 0 1px 0 rgba(255, 255, 255, 0.05) inset; }
.tabs .count { background: var(--gold); color: var(--gold-ink); border-radius: 99px; padding: 0 7px; font-size: 11px; margin-left: 4px; }
.topbar-meta { margin-left: auto; display: flex; gap: 8px; align-items: center; font-size: 12px; color: var(--muted); flex-wrap: wrap; justify-content: flex-end; min-width: 0; }

/* ---------- shared bits ---------- */
main { flex: 1; min-height: 0; position: relative; }
.tab-page { position: absolute; inset: 0; display: none; padding: 14px; gap: 14px; }
.tab-page.active { display: grid; }
.panel {
	background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
	min-height: 0; overflow: auto; padding: 14px;
}
.panel::-webkit-scrollbar, .results::-webkit-scrollbar { width: 10px; }
.panel::-webkit-scrollbar-thumb, .results::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 10px; border: 3px solid var(--panel); }

.btn {
	border: 1px solid var(--line-2); background: var(--panel-2); border-radius: 10px;
	padding: 8px 14px; cursor: pointer; font-weight: 800; white-space: nowrap;
	transition: transform 0.08s ease, background 0.15s ease, border-color 0.15s ease;
}
.btn:hover { border-color: #4a5672; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--gold); border-color: var(--gold); color: var(--gold-ink); }
.btn.primary:hover { background: #ffc552; }
.btn.ghost { background: transparent; }
.btn.wide { width: 100%; margin-top: 10px; }
a.btn { text-decoration: none; color: inherit; }
.link { background: none; border: 0; color: var(--blue); cursor: pointer; padding: 0 4px; font-size: 12px; }

.seg { display: flex; gap: 3px; padding: 3px; background: var(--bg-2); border: 1px solid var(--line); border-radius: 11px; }
.seg button { flex: 1; border: 0; background: none; border-radius: 8px; padding: 7px 8px; cursor: pointer; color: var(--muted); font-weight: 800; }
.seg button.active { background: var(--panel-2); color: var(--text); box-shadow: inset 0 0 0 1px var(--line-2); }
.seg-sm button { padding: 5px 8px; font-size: 12.5px; }

.field { display: flex; flex-direction: column; gap: 5px; margin-top: 12px; }
.field > span { font-size: 12px; color: var(--muted); font-weight: 800; letter-spacing: 0.2px; display: flex; align-items: center; gap: 6px; }
input:not([type="range"]):not([type="checkbox"]), select, textarea {
	width: 100%; background: var(--bg-2); border: 1px solid var(--line); border-radius: 9px; padding: 8px 10px; outline: none;
	transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
input:focus, select:focus, textarea:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(242, 179, 61, 0.15); }
textarea { resize: vertical; }
input[type="range"] { accent-color: var(--gold); width: 100%; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.grid4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0 10px; }
.inline { display: flex; gap: 8px; align-items: center; }
.check { display: flex; gap: 8px; align-items: center; margin-top: 30px; font-size: 13px; cursor: pointer; }
.check input { accent-color: var(--gold); width: 16px; height: 16px; }
.eyebrow { font-size: 11px; text-transform: uppercase; letter-spacing: 1.2px; color: var(--gold); font-weight: 900; }
.pill { background: var(--panel-2); border: 1px solid var(--line); border-radius: 99px; padding: 4px 10px; font-size: 12.5px; white-space: nowrap; }
.tier { font-style: normal; border-radius: 99px; padding: 1px 8px; font-size: 11px; color: #111; font-weight: 900; }
.actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 14px; }

.luau { margin-top: 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg-2); }
.luau summary { cursor: pointer; padding: 8px 12px; font-weight: 800; font-size: 12.5px; color: var(--muted); }
.luau pre {
	margin: 0; padding: 10px 12px; border-top: 1px solid var(--line); font: 12px/1.5 var(--mono);
	white-space: pre-wrap; word-break: break-word; max-height: 260px; overflow: auto; color: #cfe3ff;
}

/* ---------- wearables ---------- */
.wear-page { grid-template-columns: 300px minmax(0, 1fr) 340px; }
.catalog { display: flex; flex-direction: column; gap: 10px; overflow: hidden; min-width: 0; }
.search { display: flex; gap: 6px; min-width: 0; }
.search input { min-width: 0; flex: 1; }
.results { flex: 1; overflow-y: auto; overflow-x: hidden; display: grid; grid-template-columns: repeat(auto-fill, minmax(116px, 1fr)); gap: 8px; align-content: start; padding-right: 2px; }
.result {
	background: var(--bg-2); border: 1px solid var(--line); border-radius: 10px; padding: 6px; cursor: pointer; text-align: left;
	display: flex; flex-direction: column; gap: 4px; transition: border-color 0.12s ease, transform 0.12s ease;
}
.result:hover { border-color: var(--line-2); transform: translateY(-1px); }
.result.active { border-color: var(--gold); box-shadow: 0 0 0 2px rgba(242, 179, 61, 0.25); }
.result img { width: 100%; aspect-ratio: 1; object-fit: contain; background: radial-gradient(circle at 50% 40%, #2b3346, #1a1f2a); border-radius: 7px; }
.result { min-width: 0; }
.result .r-name { font-size: 12px; line-height: 1.25; min-height: 2.5em; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.result .r-meta { display: block; max-width: 100%; font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.results .note { grid-column: 1 / -1; color: var(--muted); text-align: center; padding: 30px 10px; }

.stage {
	position: relative; border-radius: var(--radius); border: 1px solid var(--line); overflow: hidden;
	background:
		radial-gradient(60% 50% at 50% 38%, rgba(120, 170, 255, 0.16), transparent 70%),
		linear-gradient(180deg, #1f2a3d 0%, #151b26 75%);
}
.viewer, .viewer canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.stage-top { position: absolute; top: 12px; left: 12px; right: 12px; display: flex; justify-content: space-between; gap: 10px; pointer-events: none; }
.stage-top > * { pointer-events: auto; }
.worn { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
	display: inline-flex; align-items: center; gap: 6px; background: rgba(16, 19, 26, 0.75); border: 1px solid var(--line-2);
	border-radius: 99px; padding: 3px 4px 3px 10px; font-size: 12px; backdrop-filter: blur(6px);
}
.chip b { color: var(--gold); font-weight: 900; }
.chip button { border: 0; background: var(--panel-2); width: 20px; height: 20px; border-radius: 50%; cursor: pointer; line-height: 1; }
.views { display: flex; gap: 2px; background: rgba(16, 19, 26, 0.75); border: 1px solid var(--line-2); border-radius: 10px; padding: 3px; backdrop-filter: blur(6px); height: fit-content; }
.views button { border: 0; background: none; padding: 5px 9px; border-radius: 7px; cursor: pointer; color: var(--muted); font-size: 12px; font-weight: 800; }
.views button:hover { color: var(--text); background: var(--panel-2); }
.stage-bottom {
	position: absolute; bottom: 12px; left: 50%; transform: translateX(-50%); max-width: 90%;
	background: rgba(16, 19, 26, 0.75); border: 1px solid var(--line-2); border-radius: 10px; padding: 6px 12px; font-size: 12px; color: var(--muted);
	backdrop-filter: blur(6px); text-align: center;
}
.stage-bottom:empty { display: none; }

.empty-state { text-align: center; color: var(--muted); padding: 60px 16px; }
.empty-icon { margin-bottom: 10px; color: var(--gold); display: flex; justify-content: center; }
.empty-state p { color: var(--text); margin: 0 0 6px; font-weight: 800; }
.picked { display: flex; gap: 12px; align-items: center; }
.picked img { width: 72px; height: 72px; object-fit: contain; border-radius: 10px; background: var(--bg-2); border: 1px solid var(--line); }
.picked-name { font-weight: 800; line-height: 1.25; margin: 2px 0; }
.picked a { color: var(--blue); font-size: 12px; text-decoration: none; }
fieldset { border: 1px solid var(--line); border-radius: 10px; margin: 14px 0 0; padding: 6px 12px 10px; }
legend { padding: 0 6px; font-size: 12px; color: var(--muted); font-weight: 800; }
.slider { display: grid; grid-template-columns: 104px 1fr 64px; align-items: center; gap: 8px; margin-top: 5px; font-size: 12.5px; }
.slider input.num { padding: 3px 6px; font-family: var(--mono); font-size: 12px; text-align: right; color: var(--gold); border-radius: 7px; }
.fit-group { margin: 10px 0 2px; font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); font-weight: 900; }
.fit-group small { text-transform: none; letter-spacing: 0; font-weight: 700; }
.fit-hint { display: block; margin-top: 8px; font-size: 11.5px; line-height: 1.4; }
.template-row { display: flex; gap: 10px; align-items: flex-start; }
.template-row img { width: 96px; aspect-ratio: 585 / 559; object-fit: contain; background: repeating-conic-gradient(#2a3142 0 25%, #222836 0 50%) 0 0 / 12px 12px; border-radius: 8px; border: 1px solid var(--line); }
.template-row .field { margin-top: 0; }

/* ---------- blocks ---------- */
.block-page { grid-template-columns: minmax(0, 1fr) 380px; }
.block-form { padding: 16px 18px 24px; }
.form-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.form-head h2 { margin: 2px 0 0; font-size: 22px; font-weight: 900; }
.card { background: var(--bg-2); border: 1px solid var(--line); border-radius: 12px; padding: 14px; margin-top: 14px; }
.card h3 { margin: 0 0 10px; font-size: 14px; font-weight: 900; }
.advanced summary { cursor: pointer; list-style: none; display: flex; align-items: baseline; gap: 10px; }
.advanced summary::-webkit-details-marker { display: none; }
.advanced summary h3 { margin: 0; }
.advanced summary small { color: var(--muted); }
.advanced[open] summary { margin-bottom: 4px; }
.ref-pane { margin-top: 10px; }
.drop {
	display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 26px 12px; border: 2px dashed var(--line-2);
	border-radius: 12px; cursor: pointer; color: var(--muted); text-align: center; transition: border-color 0.15s ease, background 0.15s ease;
}
.drop strong { color: var(--text); }
.drop.over, .drop:hover { border-color: var(--gold); background: rgba(242, 179, 61, 0.06); }
.block-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(62px, 1fr)); gap: 6px; max-height: 230px; overflow: auto; margin-top: 8px; padding: 2px; }
.block-grid button {
	background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 5px 3px; cursor: pointer;
	display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 10px; line-height: 1.15; color: var(--muted);
}
.block-grid button.active { border-color: var(--gold); color: var(--text); }
.block-grid img { width: 36px; height: 36px; image-rendering: pixelated; object-fit: contain; }
.gt-row { display: flex; gap: 14px; align-items: flex-end; }
.gt-row .field { width: 170px; margin-top: 0; }
.gt-pair { display: flex; gap: 10px; }
.gt-pair figure { margin: 0; text-align: center; font-size: 11px; color: var(--muted); }
.gt-pair img { width: 56px; height: 56px; image-rendering: pixelated; object-fit: contain; background: var(--panel); border-radius: 8px; border: 1px solid var(--line); display: block; margin-bottom: 3px; }
.recipe { display: grid; grid-template-columns: 1fr auto 1fr; gap: 8px; align-items: center; }
.recipe b { color: var(--gold); font-size: 18px; }
.rarity { display: grid; grid-template-columns: 1fr 76px; gap: 8px; align-items: center; }
.gems-out { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
.gems-out div { background: var(--panel); border: 1px solid var(--line); border-radius: 9px; padding: 7px 10px; font-size: 12.5px; }
.gems-out b { display: block; font-size: 11px; color: var(--muted); }
.recipe-bad { color: var(--red) !important; }
.recipe-ok { color: var(--green) !important; }

.block-preview { display: flex; flex-direction: column; }
.preview-card { background: var(--bg-2); border: 1px solid var(--line); border-radius: 12px; padding: 12px; }
.ref-stage {
	height: 210px; border-radius: 10px; display: grid; place-items: center;
	background: repeating-conic-gradient(#232a39 0 25%, #1c2230 0 50%) 0 0 / 20px 20px;
}
.ref-stage img { width: 180px; height: 180px; object-fit: contain; image-rendering: pixelated; }
.pixel-row { display: flex; gap: 14px; margin-top: 10px; }
.pixel-row figure { margin: 0; font-size: 11px; color: var(--muted); }
.pixel-row canvas { display: block; image-rendering: pixelated; background: #6ab7ff; border-radius: 6px; border: 1px solid var(--line); margin-bottom: 4px; }
#px32 { width: 96px; height: 96px; }
#pxTile { width: 144px; height: 96px; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 12px 0 0; }
.stats div { background: var(--bg-2); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; }
.stats dt { font-size: 11px; color: var(--muted); font-weight: 800; }
.stats dd { margin: 2px 0 0; font-weight: 900; font-size: 14px; }
.stats .wide { grid-column: 1 / -1; }
.warnings { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.warnings li { background: rgba(255, 107, 107, 0.1); border: 1px solid rgba(255, 107, 107, 0.4); color: #ffb3b3; border-radius: 9px; padding: 7px 10px; font-size: 12.5px; }

/* ---------- queue ---------- */
.queue-page { grid-template-rows: auto 1fr; overflow: auto; }
.queue-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; }
.queue-head h2 { margin: 0; font-size: 22px; font-weight: 900; }
.queue-head p { margin: 4px 0 0; max-width: 720px; }
.queue-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; min-height: 0; }
.queue-cols h3 { margin: 4px 0 8px; font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; }
.queue-list { display: flex; flex-direction: column; gap: 8px; }
.q-item { display: grid; grid-template-columns: 52px 1fr auto; gap: 12px; align-items: center; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 8px 10px; }
.q-item img { width: 52px; height: 52px; object-fit: contain; border-radius: 8px; background: var(--bg-2); image-rendering: pixelated; }
.q-name { font-weight: 900; }
.q-sub { font-size: 12px; color: var(--muted); }
.q-actions { display: flex; gap: 6px; align-items: center; }
.q-actions .btn { padding: 5px 10px; font-size: 12px; }
.status { border-radius: 99px; padding: 2px 9px; font-size: 11px; font-weight: 900; text-transform: uppercase; letter-spacing: 0.6px; }
.status.draft { background: #2e3546; color: #aab4c8; }
.status.ready { background: rgba(242, 179, 61, 0.18); color: var(--gold); }
.status.done { background: rgba(104, 201, 90, 0.18); color: var(--green); }
.status.working { background: rgba(90, 169, 255, 0.18); color: var(--blue); }
.status.failed { background: rgba(255, 107, 107, 0.18); color: var(--red); }
.q-note { font-size: 12px; margin-top: 3px; color: var(--blue); }
.q-note.bad { color: #ffb3b3; }
.q-note.good { color: var(--green); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.user-pill { display: inline-flex; align-items: center; gap: 6px; color: var(--text); }
.role-badge { font-size: 10px; text-transform: uppercase; letter-spacing: 0.6px; padding: 1px 7px; border-radius: 99px; background: #2e3546; color: #aab4c8; }
.role-badge.admin { background: rgba(90, 169, 255, 0.18); color: var(--blue); }
.role-badge.superadmin { background: rgba(242, 179, 61, 0.2); color: var(--gold); }

/* ---------- users ---------- */
.users-page { grid-template-rows: auto 1fr; overflow: auto; }
.users-cols { display: grid; grid-template-columns: 320px minmax(0, 1fr); gap: 14px; align-items: start; min-height: 0; }
.user-form h3 { margin: 0 0 4px; font-size: 15px; font-weight: 900; }
.users-list { padding: 6px 14px; }
.users-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.users-table th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); padding: 10px 8px; border-bottom: 1px solid var(--line); }
.users-table td { padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.users-table tr:last-child td { border-bottom: 0; }
.user-name { display: inline-flex; align-items: center; gap: 6px; font-weight: 800; }
.role-select { width: auto; padding: 5px 8px; }
.user-actions { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }
.pw-form { display: flex; gap: 6px; }
.pw-form input { width: 160px; padding: 5px 8px; }
@media (max-width: 1180px) { .users-cols { grid-template-columns: 1fr; } }

/* ---------- login ---------- */
.login-body { overflow: auto; }
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.login-card {
	width: min(380px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 16px;
	padding: 26px 24px 24px; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
}
.login-card h1 { margin: 22px 0 2px; font-size: 22px; font-weight: 900; }
.login-card p { margin: 0 0 6px; }
.login-card .btn.wide { margin-top: 18px; padding: 10px 14px; }
.login-error { margin: 12px 0 0; padding: 8px 10px; border-radius: 9px; background: rgba(255, 107, 107, 0.1); border: 1px solid rgba(255, 107, 107, 0.4); color: #ffb3b3; font-size: 13px; }
.queue-list .note { color: var(--muted); padding: 24px; text-align: center; border: 1px dashed var(--line); border-radius: 12px; }

/* ---------- toast ---------- */
.toast {
	position: fixed; left: 50%; bottom: 22px; transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
	background: #232b3a; border: 1px solid var(--line-2); border-radius: 12px; padding: 10px 16px; font-weight: 800;
	transition: opacity 0.2s ease, transform 0.2s ease; z-index: 50; max-width: 80vw;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { border-color: var(--red); color: #ffc9c9; }

@media (max-width: 1280px) {
	.topbar-meta .pill:not(.user-pill) { display: none; }
}

@media (max-width: 1180px) {
	body { overflow: auto; }
	.topbar { flex-wrap: wrap; row-gap: 8px; gap: 12px; }
	.brand { min-width: 0; }
	.tab-page { position: static; }
	.wear-page { grid-template-columns: 1fr; }
	.stage { height: 520px; }
	.catalog { max-height: 520px; }
	.block-page, .queue-cols { grid-template-columns: 1fr; }
}
