.tsq {
	--tsq-primary: var(--theme-palette-color-1, #2563eb);
	--tsq-primary-hover: var(--theme-palette-color-2, #1d4ed8);
	--tsq-text: var(--theme-palette-color-3, #334155);
	--tsq-heading: var(--theme-palette-color-4, #0f172a);
	--tsq-border: var(--theme-palette-color-5, #e2e8f0);
	--tsq-soft: var(--theme-palette-color-6, #f1f5f9);
	--tsq-card: var(--theme-palette-color-8, #fff);
	--tsq-danger: #b91c1c;
	--tsq-radius: 14px;
	color: var(--tsq-text);
	font-size: 15px;
}

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

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

.tsq-grid {
	display: grid;
	grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
	grid-template-areas:
		"model form"
		"summary form";
	/* Wysoka kolumna formularza obejmuje oba wiersze. Bez tego jej nadmiar wysokości dzieli się
	   po równo na oba wiersze i pod kartą modelu powstaje pusta przestrzeń. */
	grid-template-rows: auto 1fr;
	gap: 20px;
	align-items: start;
}
.tsq-model { grid-area: model; }
.tsq-form { grid-area: form; }
/* Wycena zostaje w zasięgu wzroku przy przewijaniu długiej listy materiałów i kolorów. */
.tsq-summary { grid-area: summary; position: sticky; top: 24px; }
.admin-bar .tsq-summary { top: 56px; }

@media (max-width: 900px) {
	.tsq-grid {
		grid-template-columns: minmax(0, 1fr);
		grid-template-areas: "model" "form" "summary";
		grid-template-rows: none;
	}
	.tsq-summary { position: static; }
}

.tsq-card {
	background: var(--tsq-card);
	border: 1px solid var(--tsq-border);
	border-radius: var(--tsq-radius);
	padding: 22px;
	box-shadow: 0 1px 2px rgb(15 23 42 / 5%);
}

.tsq-h {
	display: flex;
	align-items: center;
	gap: 10px;
	margin: 0 0 16px;
	font-size: 18px;
	color: var(--tsq-heading);
}
.tsq-step {
	display: inline-grid;
	place-items: center;
	width: 26px;
	height: 26px;
	border-radius: 50%;
	background: var(--tsq-primary);
	color: #fff;
	font-size: 13px;
	font-weight: 700;
}

.tsq-sr {
	position: absolute;
	width: 1px;
	height: 1px;
	overflow: hidden;
	clip: rect(0 0 0 0);
}

/* Upload */
.tsq-drop {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 6px;
	padding: 48px 20px;
	border: 2px dashed var(--tsq-border);
	border-radius: var(--tsq-radius);
	background: var(--tsq-soft);
	text-align: center;
	cursor: pointer;
	transition: border-color .15s, background .15s;
}
.tsq-drop:hover,
.tsq-drop.is-over,
.tsq-drop:focus-within {
	border-color: var(--tsq-primary);
	background: rgb(37 99 235 / 5%);
}
.tsq-drop svg { color: var(--tsq-primary); }
.tsq-drop strong { color: var(--tsq-heading); }
.tsq-drop span { font-size: 13px; }

.tsq-viewer {
	position: relative;
	border-radius: var(--tsq-radius);
	background: radial-gradient(ellipse at 50% 30%, #f8fafc, #e2e8f0);
	overflow: hidden;
}
.tsq-viewer canvas {
	display: block;
	width: 100%;
	height: 340px;
	cursor: grab;
}
.tsq-viewer-note {
	margin: 0;
	padding: 60px 20px;
	text-align: center;
}

.tsq-model-info {
	display: grid;
	grid-template-columns: repeat(3, minmax(0, 1fr)) auto;
	gap: 12px;
	align-items: end;
	margin-top: 14px;
}
.tsq-model-info span {
	display: block;
	font-size: 12px;
	text-transform: uppercase;
	letter-spacing: .05em;
}
.tsq-model-info strong {
	color: var(--tsq-heading);
	word-break: break-all;
}
@media (max-width: 560px) {
	.tsq-model-info { grid-template-columns: 1fr 1fr; }
}

.tsq-status { margin: 10px 0 0; min-height: 1em; }
.tsq-status.is-error,
.tsq-error { color: var(--tsq-danger); }

.tsq-link {
	padding: 0;
	border: 0;
	background: none;
	color: var(--tsq-primary);
	text-decoration: underline;
	cursor: pointer;
}

/* Formularz */
.tsq fieldset {
	margin: 0 0 16px;
	padding: 0;
	border: 0;
	min-width: 0;
}
.tsq legend,
.tsq-row > label {
	margin-bottom: 6px;
	font-weight: 600;
	color: var(--tsq-heading);
}
.tsq-row {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 12px;
	margin-bottom: 16px;
}
.tsq-row > label {
	display: flex;
	flex-direction: column;
	gap: 6px;
}
.tsq select,
.tsq input[type="number"] {
	width: 100%;
	font-weight: 400;
}

.tsq-materials {
	display: grid;
	gap: 8px;
}
.tsq-material {
	display: flex;
	gap: 10px;
	padding: 12px 14px;
	border: 1px solid var(--tsq-border);
	border-radius: min(var(--tsq-radius), 10px);
	cursor: pointer;
	transition: border-color .15s, background .15s;
}
.tsq-material:has(input:checked) {
	border-color: var(--tsq-primary);
	background: rgb(37 99 235 / 5%);
	box-shadow: inset 0 0 0 1px var(--tsq-primary);
}
.tsq-material input { margin-top: 4px; }
.tsq-material-body {
	display: flex;
	flex-direction: column;
	gap: 2px;
}
.tsq-material-head {
	display: flex;
	justify-content: space-between;
	gap: 10px;
	color: var(--tsq-heading);
}
.tsq-material-head em {
	font-style: normal;
	font-size: 13px;
	white-space: nowrap;
}
.tsq-material-desc { font-size: 13px; line-height: 1.45; }

.tsq-segmented {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
}
.tsq-segmented legend { width: 100%; }
/* Szerokość wg treści: etykieta nigdy nie łamie się w środku, najwyżej cały przycisk przechodzi do nowego wiersza. */
.tsq-segmented label { flex: 1 1 auto; }
.tsq-segmented input {
	position: absolute;
	opacity: 0;
}
.tsq-segmented span {
	display: block;
	padding: 10px 14px;
	border: 1px solid var(--tsq-border);
	border-radius: min(var(--tsq-radius), 10px);
	text-align: center;
	font-size: 14px;
	white-space: nowrap;
	cursor: pointer;
}
.tsq-segmented span:hover { border-color: var(--tsq-primary); }
.tsq-segmented input:checked + span {
	border-color: var(--tsq-primary);
	background: var(--tsq-primary);
	color: #fff;
}
.tsq-segmented input:focus-visible + span {
	outline: 2px solid var(--tsq-primary);
	outline-offset: 2px;
}

.tsq-hint {
	margin: 8px 0 0;
	font-size: 13px;
	line-height: 1.5;
}

/* Doradca */
.tsq-advisor {
	margin-bottom: 18px;
	border: 1px solid var(--tsq-border);
	border-radius: min(var(--tsq-radius), 10px);
	background: var(--tsq-soft);
}
.tsq-advisor summary {
	padding: 12px 14px;
	cursor: pointer;
}
.tsq-advisor summary strong { color: var(--tsq-primary); }
.tsq-advisor-body {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 4px 16px;
	padding: 0 14px 14px;
}
.tsq-advisor-body fieldset { margin-bottom: 8px; }
.tsq-advisor-body label {
	display: flex;
	gap: 8px;
	align-items: baseline;
	font-size: 14px;
	line-height: 1.6;
}
.tsq-advice { grid-column: 1 / -1; }
.tsq-advice p {
	margin: 0 0 10px;
	padding: 12px;
	border-left: 3px solid var(--tsq-primary);
	background: var(--tsq-card);
	border-radius: min(var(--tsq-radius), 6px);
}
@media (max-width: 560px) {
	.tsq-advisor-body,
	.tsq-row { grid-template-columns: 1fr; }
}

/* Wycena */
.tsq-result { min-height: 120px; }
.tsq-empty { margin: 0; }
.tsq-price {
	display: flex;
	flex-direction: column;
	padding: 16px;
	border-radius: min(var(--tsq-radius), 12px);
	background: linear-gradient(135deg, #0b1220, #1e3a8a);
	color: #cbd5e1;
}
.tsq-price strong {
	font-size: 32px;
	line-height: 1.2;
	color: #fff;
}
.tsq-price small { font-size: 13px; }
.tsq-facts {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 10px;
	margin: 14px 0 0;
}
.tsq-facts dt { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; }
.tsq-facts dd { margin: 0; font-weight: 600; color: var(--tsq-heading); }
.is-stale { opacity: .45; }

.tsq-loading {
	display: flex;
	align-items: center;
	gap: 10px;
	margin-top: 12px;
}
.tsq-spinner {
	width: 18px;
	height: 18px;
	border: 2px solid var(--tsq-border);
	border-top-color: var(--tsq-primary);
	border-radius: 50%;
	animation: tsq-spin .8s linear infinite;
}
@keyframes tsq-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
	.tsq-spinner { animation-duration: 2.4s; }
}

.tsq-check {
	display: flex;
	gap: 10px;
	align-items: flex-start;
	margin: 18px 0 14px;
	font-size: 14px;
	line-height: 1.5;
}
.tsq-check input { margin-top: 3px; }

.tsq-btn {
	display: inline-flex;
	justify-content: center;
	width: 100%;
	padding: 13px 20px;
	border: 0;
	border-radius: min(var(--tsq-radius), 10px);
	background: var(--tsq-primary);
	color: #fff;
	font-weight: 600;
	font-size: 16px;
	cursor: pointer;
}
.tsq-btn:hover:not(:disabled) { background: var(--tsq-primary-hover); }
.tsq-btn:disabled {
	opacity: .5;
	cursor: not-allowed;
}
.tsq-btn-ghost {
	width: auto;
	padding: 8px 14px;
	font-size: 14px;
	background: transparent;
	color: var(--tsq-primary);
	border: 1px solid var(--tsq-primary);
}
.tsq-btn-ghost:hover:not(:disabled) {
	background: var(--tsq-primary);
	color: #fff;
}

/* Próbki kolorów (konfigurator i strona produktu) */
.tsq-colors {
	margin-bottom: 16px;
}
.tsq-colors-label {
	display: block;
	margin-bottom: 8px;
	font-weight: 600;
	color: var(--tsq-heading, #0f172a);
}
.tsq-colors-label strong {
	font-weight: 500;
	color: var(--tsq-text, #334155);
}
.tsq-swatches {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
}
.tsq-swatch {
	width: 34px;
	height: 34px;
	padding: 0;
	border: 2px solid #fff;
	border-radius: 50%;
	box-shadow: 0 0 0 1px var(--tsq-border, #cbd5e1), inset 0 -2px 4px rgb(0 0 0 / 15%);
	cursor: pointer;
	transition: transform .12s ease, box-shadow .12s ease;
}
.tsq-swatch:hover {
	transform: scale(1.08);
}
.tsq-swatch[aria-checked="true"] {
	box-shadow: 0 0 0 2px var(--tsq-primary, #2563eb), inset 0 -2px 4px rgb(0 0 0 / 15%);
}
.tsq-swatch:focus-visible {
	outline: 2px solid var(--tsq-primary, #2563eb);
	outline-offset: 3px;
}
.tsq-swatches {
	flex-direction: column;
	gap: 10px;
}
.tsq-swatch-group-name {
	display: block;
	margin-bottom: 4px;
	font-size: 12px;
	letter-spacing: .04em;
	text-transform: uppercase;
	color: var(--tsq-text, #64748b);
}
.tsq-swatch-row {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
}
.tsq-swatch.has-image::after {
	content: "";
	display: block;
	width: 6px;
	height: 6px;
	margin: 26px auto 0;
	border-radius: 50%;
	background: var(--tsq-primary, #2563eb);
}
