#cpApp {
	--cp-ink: #0f172a;
	--cp-muted: #475569;
	--cp-line: #e2e8f0;
	--cp-primary: #3b82f6;
	--cp-primary-hover: #2563eb;
	--cp-soft: #eff6ff;
	--cp-accent: #1d4ed8;
	--cp-radius: 0.375rem;
	--cp-shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 8px 24px rgba(15, 23, 42, 0.06);
	--cp-font-display: system-ui, -apple-system, "Segoe UI", sans-serif;
	--cp-font-body: system-ui, -apple-system, "Segoe UI", sans-serif;
	--cp-font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
	font-family: var(--cp-font-body);
	color: var(--cp-ink);
}

#cpApp .cp-shell {
	background:
		radial-gradient(1100px 400px at 8% -12%, rgba(59, 130, 246, 0.14), transparent 55%),
		radial-gradient(900px 360px at 100% 0%, rgba(37, 99, 235, 0.07), transparent 50%),
		linear-gradient(180deg, #f8fafc 0%, #ffffff 48%);
	border: 1px solid var(--cp-line);
	border-radius: var(--cp-radius);
	box-shadow: var(--cp-shadow);
	overflow: hidden;
}

#cpApp .cp-shell-form {
	height: auto;
	align-self: start;
}

#cpApp .cp-shell-result {
	height: 100%;
	min-height: 22rem;
}

#cpApp .cp-panel {
	background: rgba(255, 255, 255, 0.94);
	backdrop-filter: blur(6px);
}

#cpApp .cp-shell-result .cp-panel {
	min-height: 100%;
}

/* 图片取色：左侧（含 Tab）与右侧栏等高，上传/预览区撑满剩余高度 */
#cpApp.is-image-mode #cpGrid {
	align-items: stretch;
}

#cpApp.is-image-mode .cp-shell-form {
	align-self: stretch;
	height: auto;
	min-height: 100%;
}

#cpApp.is-image-mode .cp-shell-form .cp-panel {
	min-height: 100%;
}

#cpApp.is-image-mode .cp-panel-image {
	flex: 1 1 auto;
	display: flex;
	flex-direction: column;
	gap: 1rem;
	min-height: 0;
}

#cpApp.is-image-mode .cp-drop:not(.hidden) {
	flex: 1 1 auto;
	min-height: 14rem;
}

#cpApp.is-image-mode .cp-img-wrap:not(.hidden) {
	flex: 1 1 auto;
	display: flex;
	flex-direction: column;
	min-height: 14rem;
}

#cpApp.is-image-mode .cp-img-stage {
	flex: 1 1 auto;
	display: flex;
	align-items: center;
	justify-content: center;
	min-height: 0;
	overflow: hidden;
}

#cpApp.is-image-mode .cp-img-canvas {
	max-width: 100%;
	max-height: 100%;
	width: auto;
	height: auto;
	object-fit: contain;
}

#cpApp .cp-label {
	display: block;
	margin-bottom: 0.5rem;
	font-size: 0.875rem;
	font-weight: 600;
	color: #334155;
	font-family: var(--cp-font-display);
}

#cpApp .cp-tabs {
	display: flex;
	flex-wrap: nowrap;
	gap: 0.5rem;
	padding: 0.35rem;
	border-radius: 999px;
	background: var(--cp-soft);
	border: 1px solid #dbeafe;
	overflow-x: auto;
	-webkit-overflow-scrolling: touch;
	scrollbar-width: none;
}

#cpApp .cp-tabs::-webkit-scrollbar {
	display: none;
}

#cpApp .cp-tab {
	flex: 1 0 auto;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	height: 2.5rem;
	padding: 0 0.95rem;
	border: 0;
	border-radius: 999px;
	background: transparent;
	color: #475569;
	font-size: 0.875rem;
	font-weight: 600;
	white-space: nowrap;
	cursor: pointer;
	transition: background-color 200ms ease, color 200ms ease, box-shadow 200ms ease;
}

#cpApp .cp-tab:hover {
	background: rgba(255, 255, 255, 0.7);
}

#cpApp .cp-tab.is-active {
	background: #fff;
	color: var(--cp-primary-hover);
	box-shadow: 0 1px 3px rgba(37, 99, 235, 0.18);
}

#cpApp .cp-tab:focus-visible {
	outline: 2px solid var(--cp-primary);
	outline-offset: 2px;
}

#cpApp .cp-sv-wrap {
	position: relative;
	width: 100%;
	aspect-ratio: 280 / 200;
	border-radius: 0.65rem;
	overflow: hidden;
	border: 1px solid var(--cp-line);
	cursor: crosshair;
	touch-action: none;
	user-select: none;
}

#cpApp .cp-sv-canvas {
	display: block;
	width: 100%;
	height: 100%;
}

#cpApp .cp-sv-cursor {
	position: absolute;
	width: 16px;
	height: 16px;
	margin: -8px 0 0 -8px;
	border: 2px solid #fff;
	border-radius: 50%;
	box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.35), 0 2px 6px rgba(15, 23, 42, 0.25);
	pointer-events: none;
	left: 100%;
	top: 0;
	transition: left 60ms linear, top 60ms linear;
}

#cpApp .cp-hue-wrap {
	padding: 0.15rem 0;
}

#cpApp .cp-hue {
	-webkit-appearance: none;
	appearance: none;
	width: 100%;
	height: 14px;
	border-radius: 999px;
	border: 1px solid var(--cp-line);
	background: linear-gradient(
		to right,
		#ff0000 0%,
		#ffff00 17%,
		#00ff00 33%,
		#00ffff 50%,
		#0000ff 67%,
		#ff00ff 83%,
		#ff0000 100%
	);
	cursor: pointer;
	outline: none;
}

#cpApp .cp-hue::-webkit-slider-thumb {
	-webkit-appearance: none;
	appearance: none;
	width: 18px;
	height: 18px;
	border-radius: 50%;
	background: #fff;
	border: 2px solid #0f172a;
	box-shadow: 0 1px 3px rgba(15, 23, 42, 0.25);
	cursor: pointer;
}

#cpApp .cp-hue::-moz-range-thumb {
	width: 18px;
	height: 18px;
	border-radius: 50%;
	background: #fff;
	border: 2px solid #0f172a;
	box-shadow: 0 1px 3px rgba(15, 23, 42, 0.25);
	cursor: pointer;
}

#cpApp .cp-hue:focus-visible {
	outline: 2px solid var(--cp-primary);
	outline-offset: 2px;
}

#cpApp .cp-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 0.4rem;
	min-height: 2.75rem;
	padding: 0 1.15rem;
	border-radius: 0.5rem;
	font-size: 0.875rem;
	font-weight: 600;
	border: 1px solid transparent;
	cursor: pointer;
	transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease, opacity 0.2s ease;
}

#cpApp .cp-btn-icon {
	width: 1.1rem;
	height: 1.1rem;
	flex-shrink: 0;
}

#cpApp .cp-btn:focus-visible {
	outline: 2px solid var(--cp-primary);
	outline-offset: 2px;
}

#cpApp .cp-btn-primary {
	background: var(--cp-primary);
	color: #fff;
}

#cpApp .cp-btn-primary:hover {
	background: var(--cp-primary-hover);
}

#cpApp .cp-btn-muted {
	background: #f8fafc;
	color: #1e293b;
	border-color: #e2e8f0;
}

#cpApp .cp-btn-muted:hover {
	background: #f1f5f9;
}

#cpApp .cp-actions {
	display: flex;
	flex-direction: column;
	gap: 0.4rem;
}

#cpApp .cp-hint {
	margin: 0;
	font-size: 0.75rem;
	color: #64748b;
	line-height: 1.45;
}

#cpApp .cp-drop {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 0.35rem;
	min-height: 9rem;
	padding: 1.25rem;
	border: 1.5px dashed #93c5fd;
	border-radius: 0.65rem;
	background: linear-gradient(180deg, var(--cp-soft), #fff 70%);
	cursor: pointer;
	text-align: center;
	transition: border-color 0.2s ease, background-color 0.2s ease, box-shadow 0.2s ease;
}

#cpApp .cp-drop:hover,
#cpApp .cp-drop.is-drag {
	border-color: var(--cp-primary);
	background: #dbeafe;
	box-shadow: inset 0 0 0 1px rgba(59, 130, 246, 0.12);
}

#cpApp .cp-drop:focus-visible {
	outline: 2px solid var(--cp-primary);
	outline-offset: 2px;
}

#cpApp .cp-drop-icon {
	width: 2.25rem;
	height: 2.25rem;
	color: var(--cp-primary);
	margin-bottom: 0.25rem;
}

#cpApp .cp-drop-title {
	margin: 0;
	font-size: 0.9375rem;
	font-weight: 600;
	color: #1e293b;
}

#cpApp .cp-drop-sub {
	margin: 0;
	font-size: 0.75rem;
	color: #64748b;
}

#cpApp .cp-panel-image {
	display: flex;
	flex-direction: column;
	gap: 1rem;
}

#cpApp .cp-img-wrap {
	border: 1px solid var(--cp-line);
	border-radius: 0.65rem;
	overflow: hidden;
	background: #fff;
}

#cpApp .cp-img-stage {
	display: block;
	/* 透明图棋盘格背景 */
	background-color: #ffffff;
	background-image:
		linear-gradient(45deg, #e5e7eb 25%, transparent 25%),
		linear-gradient(-45deg, #e5e7eb 25%, transparent 25%),
		linear-gradient(45deg, transparent 75%, #e5e7eb 75%),
		linear-gradient(-45deg, transparent 75%, #e5e7eb 75%);
	background-size: 16px 16px;
	background-position: 0 0, 0 8px, 8px -8px, -8px 0;
}

#cpApp .cp-img-canvas {
	display: block;
	width: 100%;
	height: auto;
	max-height: 22rem;
	cursor: crosshair;
	touch-action: none;
}

#cpApp .cp-meta {
	margin: 0;
	padding: 0.55rem 0.85rem;
	font-size: 0.75rem;
	color: #64748b;
	border-top: 1px solid var(--cp-line);
	background: #fff;
	flex-shrink: 0;
}

#cpApp .cp-preview {
	display: flex;
	align-items: center;
	gap: 1rem;
	padding: 1rem;
	border-radius: 0.65rem;
	border: 1px solid var(--cp-line);
	background: #f8fafc;
}

#cpApp .cp-swatch {
	width: 4.5rem;
	height: 4.5rem;
	flex-shrink: 0;
	border-radius: 0.75rem;
	background: var(--cp-swatch, #2563eb);
	border: 1px solid rgba(15, 23, 42, 0.12);
	box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.25), 0 4px 14px rgba(15, 23, 42, 0.12);
	transition: background-color 120ms ease;
}

#cpApp .cp-preview-hex {
	margin: 0;
	font-size: 1.35rem;
	font-weight: 700;
	font-family: var(--cp-font-mono);
	letter-spacing: 0.02em;
	color: var(--cp-ink);
}

#cpApp .cp-preview-contrast {
	margin: 0.35rem 0 0;
	font-size: 0.75rem;
	color: #64748b;
}

#cpApp .cp-formats {
	display: flex;
	flex-direction: column;
	gap: 0.55rem;
}

#cpApp .cp-format {
	display: grid;
	grid-template-columns: 3.25rem 1fr auto;
	align-items: center;
	gap: 0.5rem;
}

#cpApp .cp-format-label {
	font-size: 0.75rem;
	font-weight: 700;
	color: #64748b;
	font-family: var(--cp-font-mono);
}

#cpApp .cp-format-input {
	width: 100%;
	min-width: 0;
	height: 2.35rem;
	padding: 0 0.75rem;
	border: 1px solid var(--cp-line);
	border-radius: 0.45rem;
	background: #fff;
	color: var(--cp-ink);
	font-size: 0.875rem;
	font-family: var(--cp-font-mono);
	transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

#cpApp .cp-format-input:focus {
	outline: none;
	border-color: #93c5fd;
	box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

#cpApp .cp-copy {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-height: 2.35rem;
	padding: 0 0.7rem;
	border: 1px solid #d1d5db;
	border-radius: 0.4rem;
	background: #fff;
	color: #374151;
	font-size: 0.75rem;
	font-weight: 600;
	cursor: pointer;
	transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

#cpApp .cp-copy:hover,
#cpApp .cp-copy.is-done {
	background: var(--cp-soft);
	border-color: #93c5fd;
	color: var(--cp-accent);
}

#cpApp .cp-copy:focus-visible {
	outline: 2px solid var(--cp-primary);
	outline-offset: 2px;
}

#cpApp .cp-shades {
	display: grid;
	grid-template-columns: repeat(9, 1fr);
	gap: 0.35rem;
}

#cpApp .cp-shade {
	aspect-ratio: 1;
	border-radius: 0.4rem;
	border: 1px solid rgba(15, 23, 42, 0.1);
	cursor: pointer;
	transition: box-shadow 0.15s ease, transform 0.15s ease;
}

#cpApp .cp-shade:hover {
	box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--cp-primary);
}

#cpApp .cp-shade:focus-visible {
	outline: 2px solid var(--cp-primary);
	outline-offset: 2px;
}

#cpApp .cp-history {
	display: flex;
	flex-wrap: wrap;
	gap: 0.45rem;
	min-height: 2.25rem;
}

#cpApp .cp-history-empty {
	margin: 0;
	font-size: 0.8125rem;
	color: #94a3b8;
}

#cpApp .cp-history-swatch {
	width: 2rem;
	height: 2rem;
	border-radius: 0.4rem;
	border: 1px solid rgba(15, 23, 42, 0.12);
	cursor: pointer;
	transition: box-shadow 0.15s ease;
}

#cpApp .cp-history-swatch:hover {
	box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--cp-primary);
}

#cpApp .cp-history-swatch:focus-visible {
	outline: 2px solid var(--cp-primary);
	outline-offset: 2px;
}

#cpApp .cp-error {
	padding: 0.75rem 0.95rem;
	border: 1px solid #fecaca;
	border-radius: 0.5rem;
	background: #fef2f2;
	color: #991b1b;
	font-size: 0.875rem;
	line-height: 1.5;
}

#cpApp .hidden {
	display: none !important;
}

#cpApp .sr-only {
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

#cpApp .cp-notes {
	background: #fff;
	border-radius: var(--cp-radius);
	box-shadow: var(--cp-shadow);
	border: 1px solid var(--cp-line);
}

#cpApp .cp-notes a {
	color: #2563eb;
}

#cpApp .cp-notes code {
	font-size: 0.85em;
	font-family: var(--cp-font-mono);
	background: #f1f5f9;
	padding: 0.05em 0.3em;
	border-radius: 0.25rem;
}

@media (max-width: 640px) {
	#cpApp .cp-format {
		grid-template-columns: 3rem 1fr auto;
	}

	#cpApp .cp-shades {
		grid-template-columns: repeat(5, 1fr);
	}
}

@media (prefers-reduced-motion: reduce) {
	#cpApp .cp-tab,
	#cpApp .cp-btn,
	#cpApp .cp-copy,
	#cpApp .cp-swatch,
	#cpApp .cp-sv-cursor,
	#cpApp .cp-shade,
	#cpApp .cp-history-swatch,
	#cpApp .cp-format-input {
		transition: none !important;
	}
}
