.wcesf-filter {
	--wcesf-ink: #171717;
	--wcesf-muted: #737373;
	--wcesf-surface: #fff;
	--wcesf-tile: #f2f2f2;
	--wcesf-tile-hover: #e8e8e8;
	--wcesf-accent: #171717;
	box-sizing: border-box;
	direction: rtl;
	width: 100%;
	margin: 0 0 1.5rem;
	padding: 22px;
	color: var(--wcesf-ink);
	background: var(--wcesf-surface);
	border: 1px solid rgba(23, 23, 23, 0.08);
	border-radius: 22px;
	box-shadow: 0 10px 36px rgba(15, 23, 42, 0.06);
	font-family: inherit;
}

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

.wcesf-filter__head {
	display: flex;
	align-items: flex-start;
	justify-content: space-between;
	gap: 16px;
	margin-bottom: 18px;
}

.wcesf-filter__head--actions-only {
	justify-content: flex-end;
}

.wcesf-filter__eyebrow {
	display: block;
	margin-bottom: 3px;
	color: var(--wcesf-muted);
	font-size: 11px;
	font-weight: 700;
	letter-spacing: 0;
}

.wcesf-filter__title {
	margin: 0;
	color: var(--wcesf-ink);
	font-size: 18px;
	font-weight: 800;
	line-height: 1.5;
}

.wcesf-filter__sizes {
	min-width: 0;
	margin: 0;
	padding: 0;
	border: 0;
}

.wcesf-filter__grid {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(66px, 72px));
	justify-content: start;
	gap: 12px;
}

.wcesf-filter__size {
	position: relative;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 66px;
	min-height: 64px;
	padding: 10px;
	color: var(--wcesf-ink);
	background: var(--wcesf-tile);
	border: 1px solid transparent;
	border-radius: 14px;
	box-shadow: none;
	cursor: pointer;
	font: inherit;
	font-size: 17px;
	font-weight: 700;
	line-height: 1;
	text-align: center;
	transition: background-color .18s ease, color .18s ease, border-color .18s ease, transform .18s ease, box-shadow .18s ease;
	-webkit-appearance: none;
	appearance: none;
}

.wcesf-filter__size:hover:not(:disabled),
.wcesf-filter__size:focus-visible {
	color: var(--wcesf-ink);
	background: var(--wcesf-tile-hover);
	border-color: rgba(23, 23, 23, 0.12);
	transform: translateY(-2px);
	outline: none;
	box-shadow: 0 8px 18px rgba(15, 23, 42, 0.1);
}

.wcesf-filter__size.is-selected {
	color: #fff;
	background: var(--wcesf-accent);
	border-color: var(--wcesf-accent);
	box-shadow: 0 8px 18px rgba(23, 23, 23, 0.18);
}

.wcesf-filter__size:disabled {
	opacity: .38;
	cursor: not-allowed;
}

.wcesf-filter__size-name {
	direction: rtl;
	font-variant-numeric: tabular-nums;
}

.wcesf-filter__count {
	position: absolute;
	top: -7px;
	left: -7px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 23px;
	height: 23px;
	padding: 0 6px;
	color: #fff;
	background: #ef4444;
	border: 2px solid #fff;
	border-radius: 999px;
	font-size: 10px;
	font-weight: 800;
	line-height: 1;
}

.wcesf-filter__footer {
	display: flex;
	align-items: center;
	justify-content: space-between;
	flex-wrap: wrap;
	gap: 12px 18px;
	margin-top: 20px;
	padding-top: 17px;
	border-top: 1px solid rgba(23, 23, 23, 0.07);
}

.wcesf-filter__stock {
	display: inline-flex;
	align-items: center;
	gap: 10px;
	margin: 0;
	color: var(--wcesf-ink);
	cursor: pointer;
	font-size: 13px;
	font-weight: 700;
}

.wcesf-filter__stock input {
	position: absolute;
	opacity: 0;
	pointer-events: none;
}

.wcesf-filter__stock-switch {
	position: relative;
	display: inline-block;
	width: 40px;
	height: 22px;
	flex: 0 0 40px;
	background: #d6d6d6;
	border-radius: 999px;
	transition: background-color .2s ease;
}

.wcesf-filter__stock-switch::after {
	position: absolute;
	top: 3px;
	right: 3px;
	width: 16px;
	height: 16px;
	background: #fff;
	border-radius: 50%;
	box-shadow: 0 1px 4px rgba(0, 0, 0, .2);
	content: '';
	transition: transform .2s ease;
}

.wcesf-filter__stock input:checked + .wcesf-filter__stock-switch {
	background: var(--wcesf-accent);
}

.wcesf-filter__stock input:checked + .wcesf-filter__stock-switch::after {
	transform: translateX(-18px);
}

.wcesf-filter__stock input:focus-visible + .wcesf-filter__stock-switch {
	outline: 2px solid var(--wcesf-accent);
	outline-offset: 3px;
}

.wcesf-filter__selection {
	color: var(--wcesf-muted);
	font-size: 12px;
	font-weight: 600;
}

.wcesf-filter__clear {
	display: inline-flex;
	align-items: center;
	gap: 5px;
	min-height: 32px;
	padding: 5px 9px;
	color: var(--wcesf-muted);
	background: transparent;
	border: 0;
	border-radius: 9px;
	font-size: 11px;
	font-weight: 700;
	text-decoration: none;
}

.wcesf-filter__clear:hover,
.wcesf-filter__clear:focus {
	color: #b91c1c;
	background: #fef2f2;
	text-decoration: none;
}

.wcesf-filter__clear span {
	font-size: 18px;
	font-weight: 400;
	line-height: 1;
}

.wcesf-filter__apply {
	width: 100%;
	margin-top: 14px;
	padding: 11px 16px;
	color: #fff;
	background: var(--wcesf-accent);
	border: 0;
	border-radius: 11px;
	font: inherit;
	font-weight: 700;
}

.wcesf-filter--widget {
	--wcesf-widget-size: 45px;
	margin: 0;
	padding: 18px;
	border-radius: 18px;
	box-shadow: none;
}

.wcesf-filter--widget .wcesf-filter__eyebrow {
	display: none;
}

.wcesf-filter--widget .wcesf-filter__title {
	font-size: 15px;
}

.wcesf-filter--widget .wcesf-filter__grid {
	grid-template-columns: repeat(3, var(--wcesf-widget-size));
	gap: 9px;
}

.wcesf-filter--widget.wcesf-filter--columns-1 .wcesf-filter__grid {
	grid-template-columns: var(--wcesf-widget-size);
}

.wcesf-filter--widget.wcesf-filter--columns-2 .wcesf-filter__grid {
	grid-template-columns: repeat(2, var(--wcesf-widget-size));
}

.wcesf-filter--widget .wcesf-filter__size {
	width: var(--wcesf-widget-size);
	height: var(--wcesf-widget-size);
	min-width: var(--wcesf-widget-size);
	min-height: var(--wcesf-widget-size);
	max-width: var(--wcesf-widget-size);
	max-height: var(--wcesf-widget-size);
	padding: 8px 5px;
	font-size: 15px;
}

.wcesf-filter--widget .wcesf-filter__footer {
	display: block;
}

.wcesf-filter--widget .wcesf-filter__selection {
	display: block;
	margin-top: 10px;
}

@media (max-width: 480px) {
	.wcesf-filter {
		padding: 17px;
		border-radius: 17px;
	}

	.wcesf-filter__grid {
		grid-template-columns: repeat(4, minmax(0, 1fr));
		gap: 9px;
	}

	.wcesf-filter__size {
		width: 100%;
		min-width: 0;
		min-height: 57px;
		font-size: 15px;
	}

	.wcesf-filter__footer {
		align-items: flex-start;
		flex-direction: column;
	}
}

@media (prefers-reduced-motion: reduce) {
	.wcesf-filter__size,
	.wcesf-filter__stock-switch,
	.wcesf-filter__stock-switch::after {
		transition: none;
	}
}

/* ------------------------------------------------------------------
   Chip look shared by the archive filter and the sidebar widget:
   white chip, hairline border, solid black when picked.
   ------------------------------------------------------------------ */
.wcesf-filter--archive,
.wcesf-filter--widget {
	--wcesf-line: #e4e4e4;
	--wcesf-chip-h: 36px;
	--wcesf-gap: 6px;
}

.wcesf-filter--archive .wcesf-filter__size,
.wcesf-filter--widget .wcesf-filter__size {
	min-width: 0;
	min-height: 0;
	height: var(--wcesf-chip-h);
	margin: 0;
	padding: 0 4px;
	line-height: 1;
	letter-spacing: 0;
	text-transform: none;
	color: var(--wcesf-ink);
	background: #fff;
	border: 1px solid var(--wcesf-line);
	border-radius: 9px;
	font-size: 13px;
	font-weight: 700;
	transition: background-color .15s ease, color .15s ease, border-color .15s ease, opacity .15s ease, transform .1s ease;
	-webkit-tap-highlight-color: transparent;
}

.wcesf-filter--archive .wcesf-filter__size:hover:not(:disabled),
.wcesf-filter--archive .wcesf-filter__size:focus-visible,
.wcesf-filter--widget .wcesf-filter__size:hover:not(:disabled),
.wcesf-filter--widget .wcesf-filter__size:focus-visible {
	background: #fff;
	border-color: var(--wcesf-ink);
	transform: none;
	box-shadow: none;
}

.wcesf-filter--archive .wcesf-filter__size:active:not(:disabled),
.wcesf-filter--widget .wcesf-filter__size:active:not(:disabled) {
	transform: scale(.94);
}

.wcesf-filter--archive .wcesf-filter__size.is-selected,
.wcesf-filter--widget .wcesf-filter__size.is-selected {
	color: #fff;
	background: var(--wcesf-accent);
	border-color: var(--wcesf-accent);
	box-shadow: none;
}

.wcesf-filter--archive .wcesf-filter__size:disabled,
.wcesf-filter--widget .wcesf-filter__size:disabled {
	color: #b5b5b5;
	background: #fafafa;
	border-style: dashed;
	opacity: 1;
}

/* «۴۵.۵»: the half step sits smaller so the whole number fits a narrow chip. */
.wcesf-filter__size-name {
	direction: ltr;
	unicode-bidi: isolate;
	white-space: nowrap;
	letter-spacing: -.2px;
}

.wcesf-filter__size-half {
	font-size: .78em;
	font-weight: 600;
	opacity: .8;
}

.wcesf-filter--archive .wcesf-filter__count,
.wcesf-filter--widget .wcesf-filter__count {
	top: -5px;
	left: -5px;
	min-width: 16px;
	height: 16px;
	padding: 0 3px;
	border-width: 1.5px;
	font-size: 9px;
}

/* Tap feedback while the filtered page loads. */
.wcesf-filter.is-pending .wcesf-filter__size:not(.is-pending) {
	opacity: .45;
}

.wcesf-filter .wcesf-filter__size.is-pending {
	color: #fff;
	background: var(--wcesf-accent);
	border-color: var(--wcesf-accent);
}

/* ------------------------------------------------------------------
   Archive (above the products): every size visible, wrapping in rows.
   ------------------------------------------------------------------ */
.wcesf-filter--archive {
	margin: 0 0 1rem;
	padding: 12px 14px 14px;
	border-color: var(--wcesf-line);
	border-radius: 14px;
	box-shadow: none;
}

.wcesf-filter--archive .wcesf-filter__head {
	align-items: center;
	margin-bottom: 10px;
}

.wcesf-filter--archive .wcesf-filter__eyebrow {
	display: none;
}

.wcesf-filter--archive .wcesf-filter__title {
	font-size: 13px;
	font-weight: 800;
	line-height: 1.4;
}

.wcesf-filter--archive .wcesf-filter__clear {
	min-height: 24px;
	padding: 2px 8px;
}

.wcesf-filter--archive .wcesf-filter__grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, 49px);
	justify-content: start;
	gap: var(--wcesf-gap);
}

.wcesf-filter--archive .wcesf-filter__footer {
	margin-top: 10px;
	padding-top: 10px;
}

@media (max-width: 849px) {
	.wcesf-filter--archive {
		--wcesf-chip-h: 34px;
		--wcesf-gap: 4px;
		padding: 10px 0 12px;
		background: transparent;
		border-width: 0 0 1px;
		border-radius: 0;
	}

	.wcesf-filter--archive .wcesf-filter__head {
		margin-bottom: 8px;
	}

	/* 9 columns on a phone: 17 sizes fill two rows; more sizes simply add a row. */
	.wcesf-filter--archive .wcesf-filter__grid {
		grid-template-columns: repeat(auto-fill, minmax(32px, 1fr));
	}

	.wcesf-filter--archive .wcesf-filter__size {
		width: 100%;
		padding: 0 2px;
		border-radius: 8px;
		font-size: 12.5px;
	}
}

/* ------------------------------------------------------------------
   Sidebar widget: 1–6 columns of fixed-size chips.
   ------------------------------------------------------------------ */
.wcesf-filter--widget {
	--wcesf-chip-h: var(--wcesf-widget-size);
}

.wcesf-filter--widget .wcesf-filter__grid {
	gap: var(--wcesf-gap);
}

.wcesf-filter--widget .wcesf-filter__size {
	width: auto;
	height: var(--wcesf-widget-size);
	min-width: 0;
	max-width: none;
	min-height: 0;
	max-height: none;
	padding: 0 2px;
	font-size: 13px;
}

.wcesf-filter--widget.wcesf-filter--columns-3 .wcesf-filter__grid { grid-template-columns: repeat(3, minmax(0, var(--wcesf-widget-size))); }
.wcesf-filter--widget.wcesf-filter--columns-4 .wcesf-filter__grid { grid-template-columns: repeat(4, minmax(0, var(--wcesf-widget-size))); }
.wcesf-filter--widget.wcesf-filter--columns-5 .wcesf-filter__grid { grid-template-columns: repeat(5, minmax(0, var(--wcesf-widget-size))); }
.wcesf-filter--widget.wcesf-filter--columns-6 .wcesf-filter__grid { grid-template-columns: repeat(6, minmax(0, var(--wcesf-widget-size))); }

/* Phones: the widget's own column count, chips stretch to fill the row. */
@media (max-width: 849px) {
	.wcesf-filter--widget[class*="wcesf-filter--m-columns-"] .wcesf-filter__size {
		width: 100%;
	}

	.wcesf-filter--widget.wcesf-filter--m-columns-1 .wcesf-filter__grid { grid-template-columns: minmax(0, 1fr); }
	.wcesf-filter--widget.wcesf-filter--m-columns-2 .wcesf-filter__grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
	.wcesf-filter--widget.wcesf-filter--m-columns-3 .wcesf-filter__grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
	.wcesf-filter--widget.wcesf-filter--m-columns-4 .wcesf-filter__grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
	.wcesf-filter--widget.wcesf-filter--m-columns-5 .wcesf-filter__grid { grid-template-columns: repeat(5, minmax(0, 1fr)); }
	.wcesf-filter--widget.wcesf-filter--m-columns-6 .wcesf-filter__grid { grid-template-columns: repeat(6, minmax(0, 1fr)); }
}

@media (prefers-reduced-motion: reduce) {
	.wcesf-filter--archive .wcesf-filter__size,
	.wcesf-filter--widget .wcesf-filter__size {
		transition: none;
	}

	.wcesf-filter--archive .wcesf-filter__size:active:not(:disabled),
	.wcesf-filter--widget .wcesf-filter__size:active:not(:disabled) {
		transform: none;
	}
}

.wcesf-filter__clear {
	flex: 0 0 auto;
	white-space: nowrap;
}
