.jwbf {
	--jwbf-background: var(--wp--preset--color--base, #f5f2eb);
	--jwbf-surface: #fff;
	--jwbf-text: var(--wp--preset--color--contrast, #292e33);
	--jwbf-accent: var(--wp--preset--color--accent-1, #243b53);
	--jwbf-secondary: var(--wp--preset--color--accent-2, #a3443f);
	--jwbf-border: var(--wp--preset--color--accent-6, #d8d6d0);
	--jwbf-muted: #686d72;
	box-sizing: border-box;
	width: 100%;
}

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

.jwbf__toolbar {
	display: flex;
	align-items: stretch;
	gap: 10px;
	width: 100%;
	margin: 0 0 2rem;
}

.jwbf__search {
	display: flex;
	flex: 1 1 420px;
	min-width: 0;
}

.jwbf__search input[type="search"] {
	width: 100%;
	min-width: 0;
	height: 42px;
	margin: 0;
	padding: 0 14px;
	border: 1px solid var(--jwbf-border);
	border-right: 0;
	border-radius: 2px 0 0 2px;
	background: var(--jwbf-surface);
	color: var(--jwbf-text);
	font: inherit;
	font-size: 0.95rem;
	box-shadow: none;
}

.jwbf__search input[type="search"]:focus {
	position: relative;
	z-index: 1;
	outline: 2px solid var(--jwbf-accent);
	outline-offset: -2px;
}

.jwbf__search-button,
.jwbf__filter-button,
.jwbf__apply {
	min-height: 42px;
	border: 1px solid var(--jwbf-accent);
	border-radius: 20px;
	background: var(--jwbf-accent);
	color: #fff;
	font: inherit;
	font-size: 0.875rem;
	font-weight: 650;
	line-height: 1;
	cursor: pointer;
}

.jwbf__search-button {
	padding: 0 16px;
	border-radius: 0 20px 20px 0;
}

.jwbf__filter-button {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 7px;
	flex: 0 0 auto;
	padding: 0 13px;
	background: transparent;
	color: var(--jwbf-accent);
}

.jwbf__filter-button svg {
	width: 17px;
	height: 17px;
	fill: none;
	stroke: currentColor;
	stroke-width: 1.8;
	stroke-linecap: round;
}

.jwbf__filter-count {
	display: inline-grid;
	place-items: center;
	min-width: 19px;
	height: 19px;
	padding: 0 5px;
	border-radius: 20px;
	background: var(--jwbf-secondary);
	color: #fff;
	font-size: 0.7rem;
}

.jwbf__search-button:hover,
.jwbf__apply:hover {
	background: color-mix(in srgb, var(--jwbf-accent) 86%, #000);
}

.jwbf__filter-button:hover {
	background: color-mix(in srgb, var(--jwbf-accent) 8%, transparent);
}

.jwbf__search-button:focus-visible,
.jwbf__filter-button:focus-visible,
.jwbf__apply:focus-visible,
.jwbf__close:focus-visible,
.jwbf__tag-order button:focus-visible,
.jwbf__tag input:focus-visible + span,
.jwbf__choices input:focus-visible + span {
	outline: 2px solid var(--jwbf-accent);
	outline-offset: 2px;
}

.jwbf__modal[hidden] {
	display: none;
}

.jwbf__modal {
	position: fixed;
	inset: 0;
	z-index: 999999;
	display: grid;
	place-items: center;
	padding: 20px;
	opacity: 0;
	transition: opacity 180ms ease;
}

.jwbf__modal.is-open {
	opacity: 1;
}

.jwbf__backdrop {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	padding: 0;
	border: 0;
	background: rgba(20, 27, 34, 0.68);
	cursor: default;
}

.jwbf__panel {
	position: relative;
	z-index: 1;
	width: min(720px, 100%);
	max-height: min(86vh, 820px);
	overflow: auto;
	padding: 26px;
	border: 1px solid var(--jwbf-border);
	border-radius: 3px;
	background: var(--jwbf-background);
	color: var(--jwbf-text);
	box-shadow: 0 24px 70px rgba(0, 0, 0, 0.24);
	transform: translateY(10px);
	transition: transform 180ms ease;
}

.jwbf__modal.is-open .jwbf__panel {
	transform: translateY(0);
}

.jwbf-modal-open {
	overflow: hidden;
}

.jwbf__modal-header,
.jwbf__actions {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 20px;
}

.jwbf__modal-header {
	margin-bottom: 24px;
}

.jwbf__modal-header h2 {
	margin: 0;
	font-size: clamp(1.5rem, 3vw, 2rem);
}

.jwbf__close {
	display: grid;
	place-items: center;
	flex: 0 0 auto;
	width: 38px;
	height: 38px;
	padding: 0;
	border: 1px solid var(--jwbf-border);
	border-radius: 50%;
	background: transparent;
	color: var(--jwbf-text);
	cursor: pointer;
}

.jwbf__close svg {
	width: 18px;
	height: 18px;
	fill: none;
	stroke: currentColor;
	stroke-width: 1.8;
	stroke-linecap: round;
}

.jwbf__section {
	min-width: 0;
	margin: 0;
	padding: 22px 0;
	border: 0;
	border-top: 1px solid var(--jwbf-border);
}

.jwbf__section legend {
	padding: 0;
	font-size: 0.78rem;
	font-weight: 750;
	letter-spacing: 0.08em;
	text-transform: uppercase;
}

.jwbf__section--tags {
	position: relative;
}

.jwbf__section--tags > .jwbf__tag-order {
	position: absolute;
	top: -5px;
	right: 0;
}

.jwbf__choices {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: 10px;
	margin-top: 14px;
}

.jwbf__choices label,
.jwbf__tag {
	position: relative;
	cursor: pointer;
}

.jwbf__choices input,
.jwbf__tag input {
	position: absolute;
	opacity: 0;
	pointer-events: none;
}

.jwbf__choices span,
.jwbf__tag {
	border: 1px solid var(--jwbf-border);
	background: color-mix(in srgb, var(--jwbf-surface) 68%, transparent);
}

.jwbf__choices span {
	display: block;
	padding: 11px 13px;
	font-size: 0.9rem;
	text-align: center;
}

.jwbf__choices input:checked + span,
.jwbf__tag:has(input:checked) {
	border-color: var(--jwbf-accent);
	background: var(--jwbf-accent);
	color: #fff;
}

.jwbf__tag-order {
	display: inline-flex;
	gap: 3px;
	padding: 3px;
	border: 1px solid var(--jwbf-border);
	border-radius: 2px;
}

.jwbf__tag-order button {
	padding: 6px 9px;
	border: 0;
	border-radius: 1px;
	background: transparent;
	color: var(--jwbf-muted);
	font: inherit;
	font-size: 0.75rem;
	font-weight: 650;
	cursor: pointer;
}

.jwbf__tag-order button[aria-pressed="true"] {
	background: var(--jwbf-accent);
	color: #fff;
}

.jwbf__tags {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: 7px;
	max-height: 42vh;
	margin-top: 15px;
	padding-right: 5px;
	overflow-y: auto;
}

.jwbf__tag {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 10px;
	min-width: 0;
	padding: 9px 11px;
	font-size: 0.82rem;
	line-height: 1.25;
}

.jwbf__tag-name {
	min-width: 0;
	overflow-wrap: anywhere;
}

.jwbf__tag-count {
	flex: 0 0 auto;
	opacity: 0.72;
	font-size: 0.72rem;
}

.jwbf__actions {
	padding-top: 22px;
	border-top: 1px solid var(--jwbf-border);
}

.jwbf__clear {
	color: var(--jwbf-text);
	font-size: 0.85rem;
	font-weight: 600;
	text-underline-offset: 3px;
}

.jwbf__apply {
	padding: 0 18px;
}

@media (max-width: 600px) {
	.jwbf__toolbar {
		flex-wrap: wrap;
	}

	.jwbf__section--tags > .jwbf__tag-order {
		position: static;
		margin-top: 12px;
	}

	.jwbf__search {
		flex-basis: 100%;
	}

	.jwbf__filter-button {
		margin-left: auto;
	}

	.jwbf__modal {
		place-items: end center;
		padding: 0;
	}

	.jwbf__panel {
		width: 100%;
		max-height: 92vh;
		padding: 22px 18px;
		border-width: 1px 0 0;
		border-radius: 3px 3px 0 0;
	}

	.jwbf__tags {
		grid-template-columns: 1fr;
	}
}

@media (prefers-reduced-motion: reduce) {
	.jwbf__modal,
	.jwbf__panel {
		transition: none;
	}
}
