/* =============================================================
   Palette Lab chrome. Fixed colors only (never theme tokens) so
   recoloring the site never recolors the tool itself.
   Text #1A1A1A / #4A4A4A on #FFFFFF = 17.4:1 / 8.9:1.
   Focus ring #0B57D0 on white = 6.6:1, with a white halo so it
   also reads on dark page surfaces behind the orb.
   ============================================================= */

.txpl,
.txpl * ,
.txpl *::before,
.txpl *::after {
	box-sizing: border-box;
}

.txpl {
	--txpl-ink: #1A1A1A;
	--txpl-muted: #4A4A4A;
	--txpl-line: #767676;
	--txpl-soft: #E6E6E6;
	--txpl-bg: #FFFFFF;
	--txpl-alt: #F6F6F6;
	--txpl-yellow: #FFD84D;
	--txpl-focus: #0B57D0;
	--txpl-pass: #146B3A;
	--txpl-fail: #B3261E;
	font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
	font-size: 14px;
	line-height: 1.4;
	color: var(--txpl-ink);
}

.txpl-sr {
	position: absolute !important;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	overflow: hidden;
	clip: rect(0 0 0 0);
	white-space: nowrap;
	border: 0;
}

.txpl :focus {
	outline: none;
}

.txpl :focus-visible {
	outline: 3px solid var(--txpl-focus);
	outline-offset: 2px;
	box-shadow: 0 0 0 5px #FFFFFF;
}

/* ---------- Orb ---------- */

.txpl-orb {
	position: fixed;
	z-index: 2147483000;
	width: 56px;
	height: 56px;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: transparent;
	cursor: grab;
	touch-action: none;
	-webkit-user-select: none;
	user-select: none;
	box-shadow: 0 6px 18px rgba(0, 0, 0, 0.28);
}

.txpl-orb.is-dragging {
	cursor: grabbing;
	box-shadow: 0 10px 28px rgba(0, 0, 0, 0.35);
}

.txpl-orb__ring,
.txpl-orb__core {
	position: absolute;
	border-radius: 50%;
	pointer-events: none;
}

.txpl-orb__ring {
	inset: 0;
	background: var(--txpl-ring, conic-gradient(#49555C, #D2A348, #E8C85A, #F3E9D8, #A0522D, #49555C));
	border: 2px solid #FFFFFF;
}

.txpl-orb__core {
	inset: 16px;
	background: #FFFFFF;
	border: 2px solid var(--txpl-ink);
}

.txpl-orb.has-changes .txpl-orb__core {
	background: var(--txpl-yellow);
}

.txpl-orb:focus-visible {
	outline-offset: 3px;
}

@media (prefers-reduced-motion: no-preference) {
	.txpl-orb__ring {
		animation: txpl-spin 7s linear infinite;
	}
	.txpl-orb::after {
		content: "";
		position: absolute;
		inset: -6px;
		border-radius: 50%;
		border: 2px solid var(--txpl-yellow);
		opacity: 0;
		animation: txpl-pulse 3.2s ease-out infinite;
		pointer-events: none;
	}
	.txpl-orb:hover .txpl-orb__ring,
	.txpl-orb:focus-visible .txpl-orb__ring,
	.txpl-orb.is-dragging .txpl-orb__ring,
	.txpl.is-open .txpl-orb__ring {
		animation-play-state: paused;
	}
	.txpl-orb:hover::after,
	.txpl-orb:focus-visible::after,
	.txpl-orb.is-dragging::after,
	.txpl.is-open .txpl-orb::after {
		animation: none;
	}
}

@keyframes txpl-spin {
	to { transform: rotate(360deg); }
}

@keyframes txpl-pulse {
	0%   { opacity: 0.9; transform: scale(0.9); }
	70%  { opacity: 0;   transform: scale(1.25); }
	100% { opacity: 0;   transform: scale(1.25); }
}

/* ---------- Panel ---------- */

.txpl-panel {
	position: fixed;
	z-index: 2147482999;
	top: 12px;
	bottom: 12px;
	right: 80px;
	width: min(400px, calc(100vw - 104px));
	display: flex;
	flex-direction: column;
	background: var(--txpl-bg);
	border: 1px solid var(--txpl-line);
	border-radius: 12px;
	box-shadow: 0 18px 48px rgba(0, 0, 0, 0.3);
	overflow: hidden;
}

.txpl.is-left .txpl-panel {
	right: auto;
	left: 80px;
}

.txpl-panel[hidden] {
	display: none;
}

@media (max-width: 600px) {
	.txpl-panel,
	.txpl.is-left .txpl-panel {
		left: 8px;
		right: 8px;
		top: 8px;
		bottom: 8px;
		width: auto;
	}
	.txpl.is-open .txpl-orb {
		visibility: hidden;
	}
}

.txpl-head {
	display: flex;
	align-items: flex-start;
	justify-content: space-between;
	gap: 12px;
	padding: 12px 14px;
	background: var(--txpl-yellow);
	border-bottom: 1px solid var(--txpl-ink);
}

.txpl .txpl-title {
	margin: 0;
	font: 700 18px/1.2 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
	color: var(--txpl-ink);
	letter-spacing: 0;
	text-transform: none;
}

.txpl .txpl-sub {
	margin: 2px 0 0;
	font-size: 13px;
	color: var(--txpl-ink);
}

.txpl .txpl-close {
	flex: none;
	width: 36px;
	height: 36px;
	margin: 0;
	padding: 0;
	border: 1px solid var(--txpl-ink);
	border-radius: 8px;
	background: #FFFFFF;
	color: var(--txpl-ink);
	font: 400 24px/1 system-ui, sans-serif;
	cursor: pointer;
}

.txpl-body {
	flex: 1 1 auto;
	overflow-y: auto;
	overscroll-behavior: contain;
	padding: 4px 14px 14px;
}

/* Basic / Advanced switch */
.txpl .txpl-seg {
	display: flex;
	margin: 12px 0 0;
	padding: 3px;
	border: 1px solid var(--txpl-ink);
	border-radius: 10px;
	background: var(--txpl-alt);
}

.txpl .txpl-seg__input {
	position: absolute;
	opacity: 0;
	width: 1px;
	height: 1px;
	margin: 0;
}

.txpl .txpl-seg__label {
	flex: 1 1 50%;
	padding: 7px 10px;
	border-radius: 7px;
	text-align: center;
	font-weight: 600;
	font-size: 13px;
	color: var(--txpl-ink);
	cursor: pointer;
}

.txpl .txpl-seg__input:checked + .txpl-seg__label {
	background: var(--txpl-ink);
	color: #FFFFFF;
}

.txpl .txpl-seg__input:focus-visible + .txpl-seg__label {
	outline: 3px solid var(--txpl-focus);
	outline-offset: 2px;
	box-shadow: 0 0 0 5px #FFFFFF;
}

.txpl-section {
	padding: 12px 0;
	border-bottom: 1px solid var(--txpl-soft);
}

.txpl-section:last-child {
	border-bottom: 0;
}

.txpl .txpl-h3 {
	margin: 0 0 8px;
	font: 700 15px/1.3 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
	color: var(--txpl-ink);
	letter-spacing: 0;
	text-transform: none;
}

.txpl .txpl-h4 {
	margin: 10px 0 6px;
	font: 600 13px/1.3 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
	color: var(--txpl-muted);
	letter-spacing: 0;
	text-transform: none;
}

.txpl-editing__name {
	font-weight: 600;
}

.txpl .txpl-label {
	display: block;
	margin: 0 0 4px;
	padding: 0;
	font-weight: 600;
	font-size: 13px;
	color: var(--txpl-ink);
}

.txpl .txpl-help,
.txpl .txpl-desc {
	margin: 4px 0 8px;
	font-size: 12.5px;
	color: var(--txpl-muted);
}

.txpl-field {
	margin: 8px 0;
}

.txpl-inline {
	display: flex;
	align-items: center;
	gap: 8px;
	margin-top: 8px;
}

.txpl-inline--wrap {
	flex-wrap: wrap;
}

.txpl .txpl-input {
	width: 100%;
	min-height: 36px;
	margin: 0;
	padding: 6px 10px;
	border: 1px solid var(--txpl-line);
	border-radius: 8px;
	background: #FFFFFF;
	color: var(--txpl-ink);
	font: 400 14px/1.3 ui-monospace, "SF Mono", Consolas, monospace;
	box-shadow: none;
}

.txpl select.txpl-input {
	font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

.txpl .txpl-export {
	min-height: 180px;
	resize: vertical;
	font-size: 12px;
	white-space: pre;
}

.txpl .txpl-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-height: 34px;
	margin: 0;
	padding: 6px 12px;
	border: 1px solid var(--txpl-ink);
	border-radius: 8px;
	background: #FFFFFF;
	color: var(--txpl-ink);
	font: 600 13px/1.2 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
	text-transform: none;
	letter-spacing: 0;
	white-space: nowrap;
	cursor: pointer;
}

.txpl .txpl-btn:hover {
	background: var(--txpl-alt);
}

.txpl .txpl-btn--primary {
	background: var(--txpl-ink);
	color: #FFFFFF;
}

.txpl .txpl-btn--primary:hover {
	background: #333333;
}

.txpl .txpl-btn--danger {
	border-color: var(--txpl-fail);
	color: var(--txpl-fail);
}

.txpl .txpl-btn:disabled,
.txpl .txpl-item__reset:disabled {
	opacity: 0.55;
	cursor: not-allowed;
}

.txpl [hidden] {
	display: none !important;
}

/* Wheel */
.txpl-wheel {
	display: flex;
	justify-content: center;
	min-height: 200px;
	margin: 4px 0 8px;
	color: var(--txpl-muted);
}

/* Swatches */
.txpl-swatches {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
}

.txpl .txpl-sw {
	width: 28px;
	height: 28px;
	margin: 0;
	padding: 0;
	border: 1px solid var(--txpl-line);
	border-radius: 6px;
	background:
		linear-gradient(var(--txpl-sw, transparent), var(--txpl-sw, transparent)),
		repeating-conic-gradient(#DDDDDD 0 25%, #FFFFFF 0 50%) 0 0 / 10px 10px;
	cursor: pointer;
}

.txpl .txpl-sw:hover {
	transform: scale(1.08);
}

/* Features */
.txpl-feature {
	margin: 0 0 6px;
	border: 1px solid var(--txpl-soft);
	border-radius: 8px;
	background: #FFFFFF;
}

.txpl-summary {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 8px;
	padding: 9px 12px;
	font-weight: 600;
	cursor: pointer;
	list-style: none;
}

.txpl-summary::-webkit-details-marker {
	display: none;
}

.txpl-summary::before {
	content: "\25B8";
	margin-right: 6px;
	color: var(--txpl-muted);
}

.txpl-feature[open] > .txpl-summary::before {
	content: "\25BE";
}

.txpl-summary__name {
	flex: 1 1 auto;
}

.txpl-badge {
	font-size: 12px;
	font-weight: 600;
	color: var(--txpl-ink);
}

.txpl-badge:not(:empty) {
	padding: 1px 8px;
	border-radius: 999px;
	background: var(--txpl-yellow);
}

.txpl-feature > :not(summary) {
	margin-left: 12px;
	margin-right: 12px;
}

.txpl-feature > .txpl-inline:last-child {
	margin-bottom: 12px;
}

.txpl .txpl-items,
.txpl .txpl-contrast {
	margin: 0 12px;
	padding: 0;
	list-style: none;
}

.txpl .txpl-item {
	display: flex;
	align-items: stretch;
	gap: 6px;
	margin: 0 0 4px;
	padding: 0;
}

.txpl .txpl-item::before,
.txpl .txpl-contrast li::before {
	content: none;
}

.txpl .txpl-item__pick {
	flex: 1 1 auto;
	display: grid;
	grid-template-columns: 26px 1fr;
	grid-template-rows: auto auto;
	column-gap: 8px;
	align-items: center;
	min-height: 40px;
	margin: 0;
	padding: 5px 8px;
	border: 1px solid var(--txpl-soft);
	border-radius: 8px;
	background: #FFFFFF;
	color: var(--txpl-ink);
	text-align: left;
	font: inherit;
	cursor: pointer;
}

.txpl .txpl-item__pick:hover {
	border-color: var(--txpl-line);
}

.txpl .txpl-item.is-active .txpl-item__pick {
	border: 2px solid var(--txpl-ink);
	background: var(--txpl-alt);
}

.txpl .txpl-item.is-changed .txpl-item__label::after {
	content: " \2022 changed";
	font-weight: 600;
	font-size: 12px;
}

.txpl-swatch {
	grid-row: 1 / span 2;
	width: 26px;
	height: 26px;
	border: 1px solid var(--txpl-line);
	border-radius: 50%;
	background:
		linear-gradient(var(--txpl-sw, transparent), var(--txpl-sw, transparent)),
		repeating-conic-gradient(#DDDDDD 0 25%, #FFFFFF 0 50%) 0 0 / 8px 8px;
}

.txpl-item--basic .txpl-swatch {
	grid-row: 1 / span 3;
	align-self: start;
	width: 30px;
	height: 30px;
	margin-top: 2px;
}

.txpl .txpl-item--basic .txpl-item__pick {
	grid-template-columns: 30px 1fr;
	padding: 8px 10px;
}

.txpl-item__used {
	margin-top: 2px;
	font-size: 12px;
	line-height: 1.35;
	color: var(--txpl-muted);
}

.txpl-item__label {
	font-size: 13px;
	font-weight: 600;
}

.txpl-item__value {
	font: 12px/1.3 ui-monospace, "SF Mono", Consolas, monospace;
	color: var(--txpl-muted);
}

.txpl .txpl-item__reset {
	flex: none;
	margin: 0;
	padding: 0 10px;
	border: 1px solid var(--txpl-line);
	border-radius: 8px;
	background: #FFFFFF;
	color: var(--txpl-ink);
	font: 600 12px/1 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
	cursor: pointer;
}

.txpl .txpl-contrast li {
	display: flex;
	justify-content: space-between;
	gap: 8px;
	margin: 0 0 3px;
	padding: 0;
	font-size: 12.5px;
	color: var(--txpl-ink);
}

.txpl-contrast__val {
	font-family: ui-monospace, "SF Mono", Consolas, monospace;
	font-weight: 600;
	white-space: nowrap;
}

.txpl .txpl-contrast .is-pass .txpl-contrast__val { color: var(--txpl-pass); }
.txpl .txpl-contrast .is-fail .txpl-contrast__val { color: var(--txpl-fail); }

/* Export */
.txpl .txpl-fieldset {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 6px 16px;
	margin: 0 0 8px;
	padding: 0;
	border: 0;
}

.txpl .txpl-fieldset legend {
	float: left;
	margin-right: 8px;
}

.txpl-choice {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	margin: 0 0 8px;
}

.txpl-choice input {
	width: 16px;
	height: 16px;
	margin: 0;
	accent-color: var(--txpl-ink);
}

.txpl-choice label {
	margin: 0;
	font-size: 13px;
	color: var(--txpl-ink);
}

/* Footer */
.txpl-foot {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	padding: 10px 14px;
	background: var(--txpl-alt);
	border-top: 1px solid var(--txpl-soft);
}

.txpl .txpl-status {
	flex: 1 1 auto;
	margin: 0;
	font-size: 12.5px;
	color: var(--txpl-ink);
}
