/* 造人 · 界面
   深色工具面板。所有颜色走变量，改主题只改这一块。 */

@import './tokens.css';


* { box-sizing: border-box; }

html, body {
	margin: 0;
	height: 100%;
	background: var(--bg);
	color: var(--ink);
	font-family: var(--font);
	font-size: 14px;
	-webkit-font-smoothing: antialiased;
	overscroll-behavior: none;
}

button, input { font: inherit; color: inherit; }
kbd {
	font: 500 10px/1 var(--mono);
	padding: 2px 4px;
	border: 1px solid var(--line-2);
	border-radius: 4px;
	color: var(--ink-3);
	vertical-align: middle;
}
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ── 加载 ─────────────────────────────────────────────────────────── */
#loader {
	position: fixed;
	inset: 0;
	z-index: 50;
	display: grid;
	place-content: center;
	justify-items: center;
	gap: 18px;
	background: radial-gradient(120% 90% at 50% 40%, #141926 0%, var(--bg) 70%);
	transition: opacity .45s ease, visibility .45s;
}
#loader.done { opacity: 0; visibility: hidden; }
#loader p { margin: 0; color: var(--ink-2); font-size: 13px; }
#loader .load-note { color: var(--ink-3); font-size: 12px; }
#loader.failed #load-text { color: var(--warn); }

.load-mark { display: flex; gap: 8px; }
.load-mark span {
	width: 10px; height: 10px;
	background: var(--accent);
	animation: pulse 1.05s ease-in-out infinite;
}
.load-mark span:nth-child(1) { animation-delay: 0s; }
.load-mark span:nth-child(2) { animation-delay: .14s; }
.load-mark span:nth-child(3) { animation-delay: .28s; }
@keyframes pulse {
	0%, 100% { opacity: .18; transform: translateY(0); }
	50% { opacity: 1; transform: translateY(-6px); }
}
#load-bar {
	width: 220px; height: 2px;
	background: var(--line);
	overflow: hidden;
}
#load-fill {
	display: block; width: 0; height: 100%;
	background: var(--accent);
	transition: width .2s ease;
}
@media (prefers-reduced-motion: reduce) {
	.load-mark span { animation: none; opacity: .7; }
}

/* ── 顶栏 ─────────────────────────────────────────────────────────── */
#topbar {
	display: flex;
	align-items: center;
	gap: 10px;
	height: 54px;
	padding: 0 14px;
	background: var(--bg-2);
	border-bottom: 1px solid var(--line);
	position: relative;
	z-index: 10;
}
.brand { display: flex; align-items: baseline; gap: 9px; margin-right: 6px; color: inherit; text-decoration: none; }
.brand:hover b { color: var(--accent); }
.brand.back i { font-style: normal; color: var(--ink-3); margin-right: 2px; }
.brand.back:hover i { color: var(--accent); }
.brand b {
	font-size: 19px;
	letter-spacing: .16em;
	font-weight: 800;
}
.brand-sub { color: var(--ink-3); font-size: 11px; letter-spacing: .08em; }

.views { display: flex; gap: 2px; padding: 2px; background: var(--panel); border: 1px solid var(--line); }
.views button {
	border: 0; background: transparent; color: var(--ink-2);
	padding: 5px 11px; cursor: pointer; font-size: 12.5px;
	transition: background .14s, color .14s;
}
.views button:hover { color: var(--ink); background: var(--panel-2); }
.views button.on { background: var(--accent); color: #04231e; font-weight: 600; }
.views kbd { display: none; }
@media (min-width: 1100px) { .views kbd { display: inline; margin-left: 3px; } }

.spacer { flex: 1; }

.name-field input {
	width: 170px;
	background: var(--panel);
	border: 1px solid var(--line);
	padding: 7px 10px;
	color: var(--ink);
	outline: none;
	transition: border-color .15s, box-shadow .15s;
}
.name-field input:focus {
	border-color: var(--accent-dim);
	box-shadow: 0 0 0 3px rgb(63 224 197 / .1);
}

button.primary, button.ghost {
	border: 1px solid var(--line-2);
	background: var(--panel-2);
	color: var(--ink);
	padding: 7px 14px;
	cursor: pointer;
	transition: background .14s, border-color .14s, color .14s, transform .1s;
}
button.ghost:hover { background: #1c2130; border-color: var(--line-2); }
button.primary {
	background: var(--accent);
	border-color: var(--accent);
	color: #04231e;
	font-weight: 700;
}
button.primary:hover { filter: brightness(1.08); }
button.primary:active { transform: translateY(1px); }
button.primary:disabled { opacity: .6; cursor: progress; }
button.icon { padding: 7px 10px; }
button.ghost.on { border-color: var(--accent-dim); color: var(--accent); }
button.small { padding: 5px 10px; font-size: 12.5px; }

/* 导出：主按钮加一个下拉，两条路差 25 倍大小，必须让用户选而不是替他选。
   注意整个顶栏不能加 clip-path，否则这个菜单会被裁掉。 */
.export-group { position: relative; display: flex; }
.export-group .primary:first-child { border-right: 1px solid rgb(4 35 30 / .28); }
button.primary.caret { padding: 7px 8px; font-size: 11px; }
.menu {
	position: absolute;
	top: calc(100% + 6px);
	right: 0;
	width: 300px;
	z-index: 40;
	background: var(--panel-2);
	border: 1px solid var(--line-2);
	box-shadow: 0 18px 48px rgb(0 0 0 / .6);
	display: grid;
}
.menu[hidden] { display: none; }
.menu button {
	display: grid; gap: 3px;
	text-align: left;
	border: 0; background: none; color: var(--ink);
	padding: 11px 13px; cursor: pointer;
	border-bottom: 1px solid var(--line);
	transition: background .12s;
}
.menu button:last-child { border-bottom: 0; }
.menu button:hover { background: #1e2433; }
.menu button b { font-size: 13px; font-weight: 600; }
.menu button span { font-size: 11.5px; color: var(--ink-3); line-height: 1.5; }

/* ── 主区 ─────────────────────────────────────────────────────────── */
main {
	display: grid;
	grid-template-columns: var(--panel-w) 1fr;
	height: calc(100% - 54px);
}
body.panel-hidden main { grid-template-columns: 0 1fr; }

#panel-col {
	overflow-y: auto;
	overflow-x: hidden;
	background: var(--panel);
	border-right: 1px solid var(--line);
	transition: opacity .2s;
	scrollbar-width: thin;
	scrollbar-color: var(--line-2) transparent;
}
body.panel-hidden #panel-col { opacity: 0; pointer-events: none; }
#panel-col::-webkit-scrollbar { width: 9px; }
#panel-col::-webkit-scrollbar-thumb { background: var(--line-2); border: 3px solid var(--panel); border-radius: 9px; }
#panel-col::-webkit-scrollbar-thumb:hover { background: #3b465d; }

.panel-top {
	position: sticky;
	top: 0;
	z-index: 3;
	background: var(--panel);
	border-bottom: 1px solid var(--line);
	padding: 12px 12px 10px;
	display: grid;
	gap: 10px;
}

.row-label { color: var(--ink-3); font-size: 11px; letter-spacing: .1em; display: block; margin-bottom: 6px; }

.chips { display: flex; flex-wrap: wrap; gap: 5px; }
.preset {
	border: 1px solid var(--line);
	background: var(--panel-2);
	color: var(--ink-2);
	padding: 4px 11px;
	cursor: pointer;
	font-size: 12.5px;
	transition: all .14s;
}
.preset:hover { color: var(--ink); border-color: var(--line-2); }
.preset.on { background: var(--accent); border-color: var(--accent); color: #04231e; font-weight: 600; }
.preset.dice { margin-left: auto; font-weight: 600; }

.swatches { display: flex; flex-wrap: nowrap; gap: 3px; align-items: center; min-width: 0; }
/* 色板一行放得下就不换行。换行会让三行颜色把面板顶部撑得很高，
   而这三行是每次调色都要看的东西，它们应该一直是同一屏。 */
.swatch {
	width: 19px; height: 19px;
	border: 2px solid transparent;
	outline: 1px solid var(--line);
	cursor: pointer;
	padding: 0;
	transition: transform .12s, border-color .12s;
}
.swatch:hover { transform: scale(1.12); }
.swatch.on { border-color: var(--accent); outline-color: var(--accent); }
#skin-picker {
	width: 22px; height: 22px;
	padding: 0; border: 1px solid var(--line);
	background: none; cursor: pointer;
}
#skin-picker::-webkit-color-swatch-wrapper { padding: 2px; }
#skin-picker::-webkit-color-swatch { border: 0; }

.panel-tools {
	display: flex; align-items: center; gap: 10px;
	color: var(--ink-3); font-size: 11.5px;
}
.panel-tools .count b, .panel-tools .saved b { color: var(--ink-2); font-weight: 600; }
.panel-tools .saved { margin-left: auto; }

/* ── 可折叠的分区（配饰 / 衣柜 / 动作）───────────────────────────── */
.fold { border-bottom: 1px solid var(--line); }
.fold[hidden] { display: none; }
.fold-head {
	display: flex; align-items: center; gap: 8px;
	width: 100%; border: 0; background: none;
	padding: 11px 12px; cursor: pointer; text-align: left; color: var(--ink);
	transition: background .12s;
}
.fold-head:hover { background: var(--panel-2); }
.fold-body { display: none; padding: 2px 12px 12px; }
.fold.open .fold-body { display: block; animation: reveal .18s ease; }
.fold.open .chev { transform: rotate(90deg); }
.fold-note { margin: 9px 0 0; font-size: 11.5px; color: var(--ink-3); line-height: 1.6; }
@media (prefers-reduced-motion: reduce) { .fold.open .fold-body { animation: none; } }

/* ── 底模切换 ─────────────────────────────────────────────────────── */
.block { display: grid; gap: 7px; }
.seg { display: flex; gap: 2px; padding: 2px; background: var(--bg-2); border: 1px solid var(--line); }
.seg button {
	flex: 1; border: 0; background: transparent; color: var(--ink-2);
	padding: 6px 8px; cursor: pointer; font-size: 12.5px;
	transition: background .14s, color .14s;
}
.seg button:hover { color: var(--ink); background: var(--panel-2); }
.seg button.on { background: var(--accent); color: #04231e; font-weight: 600; }
.seg button:disabled { opacity: .5; cursor: progress; }
.seg-hint { margin: 0; font-size: 11px; color: var(--ink-3); line-height: 1.55; }

/* ── 配色方案 ─────────────────────────────────────────────────────── */
.looks { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; }
.look {
	display: grid; gap: 3px; padding: 0 0 3px;
	border: 1px solid var(--line); background: var(--panel-2);
	cursor: pointer; transition: border-color .12s, transform .1s;
}
.look:hover { border-color: var(--line-2); transform: translateY(-1px); }
.look.on { border-color: var(--accent); background: rgb(63 224 197 / .1); }
.look-strip { display: flex; height: 16px; }
.look-strip i { flex: 1; }
.look em { font-style: normal; font-size: 9.5px; color: var(--ink-3); text-align: center; }
.look.on em { color: var(--accent); }

/* ── 颜色槽位 ─────────────────────────────────────────────────────── */
.color-row { display: flex; align-items: center; gap: 8px; margin-bottom: 7px; }
.color-row:last-child { margin-bottom: 0; }
.color-label { font-size: 12px; color: var(--ink-2); width: 34px; flex: none; }
.color-row .color-row .swatches { flex: 1; overflow: hidden; }
.color-row input[type="color"] { flex: none; }

/* ── 通用小胶囊 ───────────────────────────────────────────────────── */
.chips { display: flex; flex-wrap: wrap; gap: 5px; }
.chip {
	border: 1px solid var(--line); background: var(--panel-2); color: var(--ink-2);
	padding: 4px 11px; font-size: 12.5px; cursor: pointer;
	transition: all .14s;
}
.chip:hover { color: var(--ink); border-color: var(--line-2); }
.chip.on { background: var(--accent); border-color: var(--accent); color: #04231e; font-weight: 600; }
.chip:disabled { opacity: .5; cursor: progress; }

/* ── 衣柜 / 配饰的格子 ────────────────────────────────────────────── */
.slot-row { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 8px; }
.slot-row button {
	border: 1px solid var(--line); background: var(--panel-2); color: var(--ink-2);
	padding: 3px 9px; font-size: 12px; cursor: pointer;
	transition: all .12s;
}
.slot-row button:hover { color: var(--ink); }
.slot-row button.on { background: var(--accent); border-color: var(--accent); color: #04231e; font-weight: 600; }

.closet {
	display: grid;
	grid-template-columns: repeat(3, 1fr);
	gap: 6px;
	max-height: 268px;
	overflow-y: auto;
	scrollbar-width: thin;
	scrollbar-color: var(--line-2) transparent;
}
.closet::-webkit-scrollbar { width: 8px; }
.closet::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 8px; }

.piece {
	position: relative;
	display: grid;
	gap: 3px;
	padding: 3px;
	border: 1px solid var(--line);
	background: var(--panel-2);
	cursor: pointer;
	transition: border-color .12s, background .12s, transform .1s;
}
.piece:hover { border-color: var(--line-2); transform: translateY(-1px); }
.piece.on { border-color: var(--accent); background: rgb(63 224 197 / .09); }
.piece.on::after {
	content: '✓';
	position: absolute; top: 3px; right: 4px;
	font-size: 11px; font-weight: 700;
	color: #04231e; background: var(--accent);
	width: 15px; height: 15px; line-height: 15px; text-align: center;
}
.piece.busy { opacity: .5; cursor: progress; }
.piece img {
	width: 100%; aspect-ratio: 1;
	object-fit: cover;
	background: #0e1118;
	display: block;
}
.piece img.dead { visibility: hidden; }
.piece-name {
	font-size: 10.5px; color: var(--ink-3); line-height: 1.35;
	display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
	overflow: hidden; text-align: left;
}
.piece.on .piece-name { color: var(--ink-2); }
.closet-note {
	grid-column: 1 / -1;
	margin: 2px 0; font-size: 11.5px; color: var(--ink-3); line-height: 1.6;
}
.closet-note.bad { color: var(--warn); }

/* ── 筛选 ─────────────────────────────────────────────────────────── */
.filter { position: relative; padding: 10px 12px 0; }
.filter input {
	width: 100%;
	background: var(--panel-2);
	border: 1px solid var(--line);
	padding: 8px 28px 8px 10px;
	color: var(--ink);
	outline: none;
	transition: border-color .15s, box-shadow .15s;
}
.filter input::placeholder { color: var(--ink-3); }
.filter input:focus { border-color: var(--accent-dim); box-shadow: 0 0 0 3px rgb(63 224 197 / .1); }
.filter-clear {
	position: absolute; right: 18px; top: 50%;
	transform: translateY(-30%);
	border: 0; background: none; color: var(--ink-3);
	font-size: 18px; line-height: 1; cursor: pointer; padding: 4px;
}
.filter-clear:hover { color: var(--ink); }

/* ── 分组 ─────────────────────────────────────────────────────────── */
.group { border-bottom: 1px solid var(--line); }
.group.no-hit { display: none; }
.group-head {
	display: flex; align-items: center; gap: 8px;
	width: 100%; border: 0; background: none;
	padding: 11px 12px; cursor: pointer;
	text-align: left; color: var(--ink);
	transition: background .12s;
}
.group-head:hover { background: var(--panel-2); }
.group-label { font-weight: 600; font-size: 13.5px; letter-spacing: .02em; }
.chev {
	width: 0; height: 0;
	border-left: 4px solid currentColor;
	border-top: 3.5px solid transparent;
	border-bottom: 3.5px solid transparent;
	color: var(--ink-3);
	transition: transform .16s;
	flex: none;
}
.group.open .chev { transform: rotate(90deg); }
.badge {
	font-size: 10.5px; padding: 1px 6px;
	background: rgb(63 224 197 / .14);
	color: var(--accent);
	border: 1px solid rgb(63 224 197 / .3);
	letter-spacing: .02em;
}
.group-actions { margin-left: auto; }
.mini {
	font-size: 11px; color: var(--ink-3);
	border: 1px solid transparent; padding: 1px 6px;
	cursor: pointer; user-select: none;
	transition: all .12s;
}
.mini:hover { color: var(--ink); border-color: var(--line-2); }
.mini.on { color: var(--accent); border-color: var(--accent-dim); background: rgb(63 224 197 / .1); }

.group-body { display: none; padding: 2px 12px 12px; }
.group.open .group-body { display: block; animation: reveal .18s ease; }
@keyframes reveal { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .group.open .group-body { animation: none; } }

.group-hint { margin: 0 0 8px; color: var(--ink-3); font-size: 11.5px; line-height: 1.55; }

/* 筛选时强制展开，但不要动画，一屏几十个一起动会卡 */
#panel.filtering .group-body { animation: none; }

/* ── 单根滑杆 ─────────────────────────────────────────────────────── */
.ctl { margin-bottom: 9px; }
.ctl-head {
	display: flex; align-items: center; gap: 6px;
	margin-bottom: 3px;
}
.ctl-name { font-size: 12.5px; color: var(--ink-2); }
.ctl-val {
	margin-left: auto;
	font: 500 11.5px/1 var(--mono);
	color: var(--ink-3);
	font-variant-numeric: tabular-nums;
	min-width: 42px; text-align: right;
}
.ctl-head .mini.split { margin-left: 4px; }

.rails { display: grid; gap: 3px; }
.rail-row { display: flex; align-items: center; gap: 7px; }
.rail-tag {
	font-size: 10.5px; color: var(--ink-3);
	width: 12px; flex: none; text-align: center;
}
.rail-row span:not(.rail-tag) { font-size: 11px; color: var(--ink-3); width: 46px; flex: none; }

/* 滑杆本体。轨道画一条中线，双极控件靠它读出「原样」在哪。 */
input[type="range"] {
	-webkit-appearance: none;
	appearance: none;
	width: 100%;
	height: 18px;
	background: transparent;
	cursor: pointer;
	display: block;
}
input[type="range"]::-webkit-slider-runnable-track {
	height: 3px;
	background:
		linear-gradient(var(--line-2), var(--line-2)) 50% / 1px 100% no-repeat,
		var(--line);
	border-radius: 0;
}
input[type="range"]::-moz-range-track {
	height: 3px;
	background: var(--line);
}
input[type="range"]::-webkit-slider-thumb {
	-webkit-appearance: none;
	width: 12px; height: 12px;
	margin-top: -4.5px;
	background: var(--ink-2);
	border: 0;
	border-radius: 50%;
	transition: background .12s, transform .1s;
}
input[type="range"]:hover::-webkit-slider-thumb { background: var(--ink); transform: scale(1.15); }
input[type="range"]:active::-webkit-slider-thumb { background: var(--accent); transform: scale(1.25); }
input[type="range"]:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 4px rgb(63 224 197 / .25); }
input[type="range"]:focus-visible { outline: none; }
input[type="range"]::-moz-range-thumb {
	width: 12px; height: 12px;
	background: var(--ink-2); border: 0; border-radius: 50%;
}
input[type="range"]:hover::-moz-range-thumb { background: var(--ink); }
input[type="range"]:active::-moz-range-thumb { background: var(--accent); }

/* ── 视口 ─────────────────────────────────────────────────────────── */
#stage-col { position: relative; overflow: hidden; background: var(--bg); }
#stage { display: block; width: 100%; height: 100%; touch-action: none; }

.stage-hint {
	position: absolute;
	left: 50%; bottom: 14px;
	transform: translateX(-50%);
	color: var(--ink-3);
	font-size: 11.5px;
	background: rgb(11 13 18 / .78);
	padding: 5px 12px;
	border: 1px solid var(--line);
	white-space: nowrap;
	pointer-events: none;
	backdrop-filter: blur(6px);
}

/* ── 提示条 ───────────────────────────────────────────────────────── */
#toast {
	position: fixed;
	left: 50%; bottom: 26px;
	transform: translate(-50%, 14px);
	background: var(--panel-2);
	border: 1px solid var(--line-2);
	border-left: 3px solid var(--accent);
	padding: 10px 16px;
	font-size: 13px;
	opacity: 0;
	pointer-events: none;
	transition: opacity .22s, transform .22s;
	z-index: 60;
	max-width: min(560px, 88vw);
	box-shadow: 0 12px 40px rgb(0 0 0 / .55);
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.bad { border-left-color: var(--warn); }

/* ── 窄屏 ─────────────────────────────────────────────────────────── */
@media (max-width: 860px) {
	main { grid-template-columns: 1fr; grid-template-rows: 46vh 1fr; }
	body.panel-hidden main { grid-template-columns: 1fr; }
	#panel-col {
		border-right: 0;
		border-bottom: 1px solid var(--line);
		order: 2;
	}
	#stage-col { order: 1; }
	.brand-sub, .name-field, .stage-hint { display: none; }
	#topbar { height: 48px; padding: 0 10px; gap: 6px; }
	button.primary kbd, .views kbd { display: none; }
}
