
/*
 * BuildBarn header: stable head-loaded styles for layout + nav dropdown structure.
 * Keep menu display rules here so they survive WP Rocket / builder inline drift.
 */
:root {
	--bb-z-search-wrap: 5200;
	--bb-z-live-search: 5300;
	--bb-z-autocomplete-portal: 500000;
}

#header.header-builder {
	position: relative;
	z-index: 1001;
	/* WP Rocket lazy render 会让 header 内交互区域无法稳定接收点击 */
	content-visibility: visible !important;
}

#header.header-builder .custom-header-top {
	display: none !important;
}

#header.header-builder .buildbarn-header-main-row,
#header.header-builder .buildbarn-header-nav-row {
	position: relative;
}

/* Nav row 高于 #main，便于 mega 等不被正文盖住 */
#header.header-builder .buildbarn-header-nav-row {
	z-index: 1002;
}

/*
 * 必须高于 .buildbarn-header-nav-row（1002），否则主行内搜索联想整块画在导航层下面。
 * mega / All Categories 在第二行展开，一般不依赖叠在第一行之上。
 */
#header.header-builder .buildbarn-header-main-row {
	padding-top: 10px !important;
	padding-bottom: 0 !important;
	z-index: 1100 !important;
}

#header.header-builder .buildbarn-header-nav-row {
	padding-bottom: 0 !important;
}

/*
 * 宽度：与正文 #main .container 同一套 max-width + 水平 padding。
 * 勿写死 15px：Bootstrap/Porto 的 .container 使用 calc(var(--bs-gutter-x) * 0.5)，不一致会显得顶栏与下部内容区「对不齐」。
 */
#header.header-builder .buildbarn-header-main-row > .container,
#header.header-builder .buildbarn-header-nav-row > .container {
	background: transparent !important;
	border: none !important;
	border-radius: 0 !important;
	box-shadow: none !important;
}

@media (min-width: 992px) {
	/*
	 * 顶栏 .container：不写 max-width，与 #main .container 共用主题/BS 各断点宽度。
	 * 只统一 margin + gutter，避免此前 !important 固定 1440px 与正文 1320 等不一致。
	 */
	#header.header-builder .buildbarn-header-main-row > .container,
	#header.header-builder .buildbarn-header-nav-row > .container {
		width: 100% !important;
		margin-left: auto !important;
		margin-right: auto !important;
		padding-left: calc(var(--bs-gutter-x, 1.5rem) * 0.5) !important;
		padding-right: calc(var(--bs-gutter-x, 1.5rem) * 0.5) !important;
		box-sizing: border-box !important;
	}

	#header.header-builder .buildbarn-header-main-row > .porto-wrap-container.container,
	#header.header-builder .buildbarn-header-nav-row > .porto-wrap-container.container {
		width: 100% !important;
		margin-left: auto !important;
		margin-right: auto !important;
		padding-left: calc(var(--bs-gutter-x, 1.5rem) * 0.5) !important;
		padding-right: calc(var(--bs-gutter-x, 1.5rem) * 0.5) !important;
		box-sizing: border-box !important;
	}

	/*
	 * 仅有 wrap、无 .container 类名时：默认勿用 1440，否则首页常见比正文 #main .container（如 1320）更宽。
	 * 用 min(Porto 变量, BS5 .container 各断点上限) 与单品页顶栏对齐。
	 */
	#header.header-builder .buildbarn-header-main-row > .porto-wrap-container:not(.container),
	#header.header-builder .buildbarn-header-nav-row > .porto-wrap-container:not(.container) {
		max-width: min(var(--porto-container-width, 2000px), 960px) !important;
		width: 100% !important;
		margin-left: auto !important;
		margin-right: auto !important;
		padding-left: calc(var(--bs-gutter-x, 1.5rem) * 0.5) !important;
		padding-right: calc(var(--bs-gutter-x, 1.5rem) * 0.5) !important;
		box-sizing: border-box !important;
	}

	/* 首页等若用 container-fluid，须同样收束为与 .container 一致，避免顶栏全宽而详情页有边距 */
	#header.header-builder .buildbarn-header-main-row > .container-fluid,
	#header.header-builder .buildbarn-header-nav-row > .container-fluid {
		width: 100% !important;
		max-width: min(var(--porto-container-width, 2000px), 960px) !important;
		margin-left: auto !important;
		margin-right: auto !important;
		padding-left: calc(var(--bs-gutter-x, 1.5rem) * 0.5) !important;
		padding-right: calc(var(--bs-gutter-x, 1.5rem) * 0.5) !important;
		box-sizing: border-box !important;
	}
}

@media (min-width: 1200px) {
	#header.header-builder .buildbarn-header-main-row > .porto-wrap-container:not(.container),
	#header.header-builder .buildbarn-header-nav-row > .porto-wrap-container:not(.container),
	#header.header-builder .buildbarn-header-main-row > .container-fluid,
	#header.header-builder .buildbarn-header-nav-row > .container-fluid {
		max-width: min(var(--porto-container-width, 2000px), 1140px) !important;
	}
}

@media (min-width: 1400px) {
	#header.header-builder .buildbarn-header-main-row > .porto-wrap-container:not(.container),
	#header.header-builder .buildbarn-header-nav-row > .porto-wrap-container:not(.container),
	#header.header-builder .buildbarn-header-main-row > .container-fluid,
	#header.header-builder .buildbarn-header-nav-row > .container-fluid {
		max-width: min(var(--porto-container-width, 2000px), 1320px) !important;
	}
}

@media (max-width: 991px) {
	#header.header-builder .buildbarn-header-main-row > .container,
	#header.header-builder .buildbarn-header-main-row > .porto-wrap-container,
	#header.header-builder .buildbarn-header-nav-row > .container,
	#header.header-builder .buildbarn-header-nav-row > .porto-wrap-container {
		padding-left: calc(var(--bs-gutter-x, 1.5rem) * 0.5) !important;
		padding-right: calc(var(--bs-gutter-x, 1.5rem) * 0.5) !important;
		box-sizing: border-box !important;
	}
}

#header.header-builder .buildbarn-header-main-row > .container {
	padding-top: 12px !important;
	padding-bottom: 10px !important;
	border-bottom: 1px solid #e7e7e7 !important;
}

#header.header-builder .buildbarn-header-nav-row > .container {
	padding-top: 12px !important;
	padding-bottom: 12px !important;
	border-bottom: 1px solid #e7e7e7 !important;
}

/* Critical: nothing in the nav bar may clip mega menu / flyouts */
#header.header-builder .buildbarn-header-nav-row .wpb_wrapper,
#header.header-builder .buildbarn-header-nav-row .vc_porto_hb_menu,
#header.header-builder .buildbarn-header-nav-row .main-menu,
#header.header-builder .buildbarn-header-nav-row .main-menu > li.menu-item {
	overflow: visible !important;
}

/*
 * All Categories：必须整块叠在横向主菜单之上，否则下拉向右展开时落在 flex 主菜单区域下的点击会被横向栏「吃掉」。
 * 原先 #main-toggle-menu 1003 < .vc_porto_hb_menu 1004，且 toggle 内 popup 1310 < 横向 .main-menu .popup 1320 → 二级无法点。
 */
#header.header-builder .buildbarn-header-nav-row #main-toggle-menu {
	position: relative;
	z-index: 1410 !important;
	flex: 0 0 auto !important;
	width: auto !important;
	min-width: 0;
	max-width: 100%;
	overflow: visible !important;
	transition: none !important;
	animation: none !important;
}

#header.header-builder .buildbarn-header-nav-row #main-toggle-menu .toggle-menu-wrap {
	overflow: visible !important;
	max-height: none !important;
	z-index: 1411 !important;
	pointer-events: auto !important;
}

/* All Categories 内多级 flyout：Porto 侧栏 li 常为 static，子级 .popup 需叠在上一级之上 */
#header.header-builder #main-toggle-menu .sidebar-menu li.menu-item-has-children {
	position: relative !important;
}

#header.header-builder #main-toggle-menu .sidebar-menu .popup {
	overflow: visible !important;
}

#header.header-builder #main-toggle-menu .sidebar-menu li.menu-item-has-children > .popup {
	z-index: 1420 !important;
}

#header.header-builder #main-toggle-menu .sidebar-menu .popup li.menu-item-has-children > .popup {
	z-index: 1430 !important;
}

#header.header-builder #main-toggle-menu .sidebar-menu .popup .popup li.menu-item-has-children > .popup {
	z-index: 1440 !important;
}

/* wide 面板列内的有子菜单项：必须作定位参照，否则 3 级 ul.sub-menu / .popup 无法正确叠在列外 */
#header.header-builder #main-toggle-menu .sidebar-menu .popup .inner ul.sub-menu > li.menu-item-has-children {
	position: relative !important;
}

#header.header-builder #main-toggle-menu .sidebar-menu .popup .inner ul.sub-menu,
#header.header-builder #main-toggle-menu .sidebar-menu .popup .inner ul.sub-menu ul.sub-menu {
	overflow: visible !important;
}

/*
 * All Categories（wide）：fragment 对 .inner > ul.sub-menu > li 使用 flex + column，会把 3 级 ul 压在 2 级标题下方。
 * Porto 侧栏预期为自列向右 flyout；仅 #main-toggle-menu，不影响横向主导航 mega。
 */
#header.header-builder #main-toggle-menu ul.sidebar-menu > li.wide > .popup > .inner > ul.sub-menu > li.menu-item-has-children {
	display: block !important;
	flex-direction: unset !important;
	row-gap: unset !important;
	align-self: start !important;
	width: 100% !important;
}

#header.header-builder #main-toggle-menu ul.sidebar-menu li.wide > .popup > .inner ul.sub-menu > li.menu-item-has-children > ul.sub-menu {
	position: absolute !important;
	left: 100% !important;
	top: 0 !important;
	right: auto !important;
	margin: 0 0 0 6px !important;
	padding: 10px 0 !important;
	border-left: none !important;
	min-width: 216px !important;
	max-width: min(92vw, 360px) !important;
	/* 勿默认 display:block，否则会盖掉主题的 none，同级列的三级会一起露出来 */
	display: none !important;
	list-style: none !important;
	background: #ffffff !important;
	border: 1px solid #e7e7e7 !important;
	border-radius: 12px !important;
	box-shadow: 0 12px 28px rgba(0, 0, 0, 0.1) !important;
	z-index: 1450 !important;
	grid-template-columns: unset !important;
	gap: 0 !important;
}

#header.header-builder #main-toggle-menu ul.sidebar-menu li.wide > .popup > .inner ul.sub-menu > li.menu-item-has-children:hover > ul.sub-menu,
#header.header-builder #main-toggle-menu ul.sidebar-menu li.wide > .popup > .inner ul.sub-menu > li.menu-item-has-children:focus-within > ul.sub-menu,
#header.header-builder #main-toggle-menu ul.sidebar-menu li.wide > .popup > .inner ul.sub-menu > li.menu-item-has-children.open > ul.sub-menu {
	display: block !important;
}

#header.header-builder #main-toggle-menu ul.sidebar-menu li.wide > .popup > .inner ul.sub-menu > li.menu-item-has-children > ul.sub-menu > li {
	display: block !important;
	width: 100% !important;
	box-sizing: border-box !important;
}

#header.header-builder #main-toggle-menu ul.sidebar-menu li.wide > .popup > .inner ul.sub-menu > li.menu-item-has-children > ul.sub-menu > li > a {
	display: flex !important;
	align-items: center !important;
	margin: 2px 8px !important;
}

/* 部分版式下三级为 li > .popup */
#header.header-builder #main-toggle-menu ul.sidebar-menu li.wide > .popup > .inner ul.sub-menu > li.menu-item-has-children > .popup {
	position: absolute !important;
	left: 100% !important;
	top: 0 !important;
	margin: 0 0 0 6px !important;
	min-width: 216px !important;
	z-index: 1450 !important;
	box-sizing: border-box !important;
	display: none !important;
}

#header.header-builder #main-toggle-menu ul.sidebar-menu li.wide > .popup > .inner ul.sub-menu > li.menu-item-has-children:hover > .popup,
#header.header-builder #main-toggle-menu ul.sidebar-menu li.wide > .popup > .inner ul.sub-menu > li.menu-item-has-children:focus-within > .popup,
#header.header-builder #main-toggle-menu ul.sidebar-menu li.wide > .popup > .inner ul.sub-menu > li.menu-item-has-children.open > .popup {
	display: block !important;
}

#header.header-builder #main-toggle-menu ul.sidebar-menu li.wide > .popup > .inner ul.sub-menu > li.menu-item-has-children > .popup > .inner {
	overflow: visible !important;
	max-height: none !important;
}

#header.header-builder .buildbarn-header-nav-row #main-toggle-menu .wide .popup,
#header.header-builder .buildbarn-header-nav-row #main-toggle-menu .narrow .popup {
	z-index: 1415 !important;
}

/* 横向主菜单容器：低于 All Categories，避免挡飞出的二级/ mega */
#header.header-builder .buildbarn-header-nav-row .vc_porto_hb_menu:last-child {
	position: relative;
	z-index: 1004;
	flex: 1 1 auto !important;
	min-width: 0 !important;
}

#header.header-builder .buildbarn-header-nav-row .main-menu .popup,
#header.header-builder .buildbarn-header-nav-row .main-menu .narrow ul.sub-menu {
	z-index: 1320 !important;
}

/*
 * Mega / flyout 栅格与缩略图 ::before 已写入 header builder 的 porto_builder_css（BB_MANAGED_NAV_*）。
 * 部署后运行: wp eval-file buildbarn-header-template-deep-clean.php 以同步片段与分类变量块。
 */

/*
 * 仅对 All Categories 容器保证可点；勿对全部 .popup 写 pointer-events:auto，
 * 否则可能干扰主题对未展开下拉的隐藏/穿透逻辑。
 */
#header.header-builder .buildbarn-header-nav-row #main-toggle-menu .toggle-menu-wrap {
	pointer-events: auto !important;
}

/* Mega / flyout：仅导航行内菜单，避免误匹配 #header 下其它 .main-menu / .popup */
#header.header-builder .buildbarn-header-nav-row .main-menu > li .popup,
#header.header-builder .buildbarn-header-nav-row .main-menu > li .popup a,
#header.header-builder #main-toggle-menu .popup,
#header.header-builder #main-toggle-menu .popup a {
	-webkit-font-smoothing: antialiased;
	-moz-osx-font-smoothing: grayscale;
}

/*
 * 二级 / mega 展开：去掉主题默认 transition / animation，避免「停一下才出来」的迟滞感。
 * category_ajax 已在 MU 内清空；此处再砍 CSS 过渡。
 */
#header.header-builder .buildbarn-header-nav-row .main-menu li.menu-item-has-children > .popup,
#header.header-builder .buildbarn-header-nav-row .main-menu .popup,
#header.header-builder .buildbarn-header-nav-row .mega-menu .popup,
#header.header-builder .buildbarn-header-nav-row .mega-menu.narrow .popup,
#header.header-builder .buildbarn-header-nav-row .mega-menu > li.narrow > .popup,
#header.header-builder .buildbarn-header-nav-row .mega-menu > li.wide > .popup,
#header.header-builder #main-toggle-menu .popup,
#header.header-builder #main-toggle-menu .sidebar-menu .popup,
#header.header-builder #main-toggle-menu .sidebar-menu li.menu-item-has-children > .popup {
	transition: none !important;
	transition-property: none !important;
	transition-duration: 0s !important;
	transition-delay: 0s !important;
	animation: none !important;
}

#header.header-builder .buildbarn-header-nav-row .main-menu > li.menu-item-has-children > a:after,
#header.header-builder .buildbarn-header-nav-row .main-menu > li.menu-item > a {
	transition: background-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease !important;
}

/* All Categories 与横向主菜单同一行：禁止换行，右侧菜单可收缩 */
#header.header-builder .buildbarn-header-nav-row .wpb_wrapper {
	display: flex;
	flex-wrap: nowrap !important;
	align-items: center;
	justify-content: flex-start;
	gap: 12px;
	width: 100%;
}

/* Porto 812：外层 Bootstrap .row 勿换行，避免 All Categories 掉到下一行 */
@media (min-width: 992px) {
	#header.header-builder .buildbarn-header-nav-row .porto-wrap-container.container > .row,
	#header.header-builder .buildbarn-header-nav-row > .porto-wrap-container > .row,
	#header.header-builder .buildbarn-header-nav-row > .container > .row {
		display: flex !important;
		flex-wrap: nowrap !important;
		align-items: center !important;
	}

	#header.header-builder .buildbarn-header-nav-row .porto-wrap-container.container > .row > [class*="vc_column"],
	#header.header-builder .buildbarn-header-nav-row > .porto-wrap-container > .row > [class*="vc_column"],
	#header.header-builder .buildbarn-header-nav-row > .container > .row > [class*="vc_column"] {
		flex: 1 1 auto !important;
		min-width: 0 !important;
		max-width: 100% !important;
	}

	/*
	 * 下拉叠在内容之上（脱离文档流），避免展开时把导航行 / #main 整块下压。
	 * #main-toggle-menu 已为 position:relative，作定位参照。
	 */
	#header.header-builder .buildbarn-header-nav-row #main-toggle-menu .toggle-menu-wrap {
		position: absolute !important;
		left: 0 !important;
		top: 100% !important;
	}

	/*
	 * 勿对横向 .main-menu 的 .popup 强制定位：会破坏 Porto 默认的 display/visibility，
	 * 导致刷新后所有二级同时露出。横向下拉若会下压版面，由主题/内联样式处理。
	 */
}

#header.header-builder .buildbarn-header-nav-row .vc_porto_hb_menu:not(:last-child) {
	flex: 0 0 auto;
	min-width: 0;
}

/* ---- Main header row: logo + search + meta + icons (grid) ---- */
#header.header-builder .buildbarn-header-main-row .wpb_wrapper {
	display: grid;
	grid-template-columns: auto minmax(260px, 1fr) repeat(3, minmax(38px, max-content));
	grid-template-rows: auto auto;
	align-items: center;
	column-gap: 6px;
	row-gap: 6px;
	width: 100%;
}

#header.header-builder .buildbarn-header-main-row .mobile-toggle {
	display: none !important;
}

#header.header-builder .buildbarn-header-main-row .logo {
	grid-column: 1;
	grid-row: 1 / span 2;
	align-self: center;
}

/* 812 模板常见为 .searchform-popup；旧版可能为 .vc_porto_hb_search_form，需同时命中否则 5 列网格会错位、图标被拆散 */
#header.header-builder .buildbarn-header-main-row .vc_porto_hb_search_form,
#header.header-builder .buildbarn-header-main-row .searchform-popup {
	grid-column: 2;
	grid-row: 2;
	min-width: 0;
}

#header.header-builder .buildbarn-header-main-row .buildbarn-header-meta {
	grid-column: 2 / 6;
	grid-row: 1;
	margin-bottom: 0;
	justify-self: end;
}

#header.header-builder .buildbarn-header-main-row .buildbarn-header-meta .wpb_wrapper,
#header.header-builder .buildbarn-header-main-row .buildbarn-header-meta-inner {
	display: inline-flex;
	align-items: center;
	gap: 16px;
}

#header.header-builder .buildbarn-header-main-row .buildbarn-header-meta-link {
	display: inline-flex;
	align-items: center;
	font-size: 13px;
	line-height: 1.4;
	font-weight: 500;
	color: #555555;
	text-decoration: none;
	white-space: nowrap;
}

/* 地址 / 电话前小图标（mask + currentColor，随链接色与 hover） */
#header.header-builder .buildbarn-header-main-row .buildbarn-header-meta-link:not(.is-phone)::before,
#header.header-builder .buildbarn-header-main-row .buildbarn-header-meta-link.is-phone::before {
	content: "";
	display: inline-block;
	width: 15px;
	height: 15px;
	flex-shrink: 0;
	margin-right: 6px;
	background-color: currentColor;
	-webkit-mask: center / contain no-repeat;
	mask: center / contain no-repeat;
}

#header.header-builder .buildbarn-header-main-row .buildbarn-header-meta-link:not(.is-phone)::before {
	-webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='black' d='M12 2C8.13 2 5 5.13 5 9c0 5.25 7 13 7 13s7-7.75 7-13c0-3.87-3.13-7-7-7zm0 9.5c-1.38 0-2.5-1.12-2.5-2.5s1.12-2.5 2.5-2.5 2.5 1.12 2.5 2.5-1.12 2.5-2.5 2.5z'/%3E%3C/svg%3E");
	mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='black' d='M12 2C8.13 2 5 5.13 5 9c0 5.25 7 13 7 13s7-7.75 7-13c0-3.87-3.13-7-7-7zm0 9.5c-1.38 0-2.5-1.12-2.5-2.5s1.12-2.5 2.5-2.5 2.5 1.12 2.5 2.5-1.12 2.5-2.5 2.5z'/%3E%3C/svg%3E");
}

#header.header-builder .buildbarn-header-main-row .buildbarn-header-meta-link.is-phone::before {
	-webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='black' d='M6.62 10.79c1.44 2.83 3.76 5.14 6.59 6.59l2.2-2.2c.27-.27.67-.36 1.02-.24 1.12.37 2.33.57 3.57.57.55 0 1 .45 1 1V20c0 .55-.45 1-1 1-9.39 0-17-7.61-17-17 0-.55.45-1 1-1h3.5c.55 0 1 .45 1 1 0 1.25.2 2.45.57 3.57.11.35.03.74-.25 1.02l-2.2 2.2z'/%3E%3C/svg%3E");
	mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='black' d='M6.62 10.79c1.44 2.83 3.76 5.14 6.59 6.59l2.2-2.2c.27-.27.67-.36 1.02-.24 1.12.37 2.33.57 3.57.57.55 0 1 .45 1 1V20c0 .55-.45 1-1 1-9.39 0-17-7.61-17-17 0-.55.45-1 1-1h3.5c.55 0 1 .45 1 1 0 1.25.2 2.45.57 3.57.11.35.03.74-.25 1.02l-2.2 2.2z'/%3E%3C/svg%3E");
}

#header.header-builder .buildbarn-header-main-row .buildbarn-header-meta-link.is-phone {
	color: #222529;
	font-weight: 600;
}

#header.header-builder .buildbarn-header-main-row .buildbarn-header-meta-link + .buildbarn-header-meta-link {
	padding-left: 16px;
	border-left: 1px solid var(--bb-border-soft, #dcdcd8);
}

#header.header-builder .buildbarn-header-main-row .buildbarn-header-meta-link:hover {
	color: var(--porto-primary-color);
}

/*
 * 搜索：与 site-ui 全站「胶囊搜索」一致（20px 圆角、62px 高、软边线+轻阴影），避免顶栏扁直角与正文割裂。
 */
#header.header-builder .buildbarn-header-main-row .searchform,
#header.header-builder .buildbarn-header-main-row .searchform-popup .searchform {
	max-width: none !important;
	border: none !important;
	border-radius: 0 !important;
	background: transparent !important;
	box-shadow: none !important;
}

#header.header-builder .buildbarn-header-main-row form.searchform.search-layout-advanced.searchform-cats .searchform-fields,
#header.header-builder .buildbarn-header-main-row .searchform-popup form.searchform.search-layout-advanced.searchform-cats .searchform-fields {
	display: flex !important;
	align-items: center !important;
	min-height: 62px !important;
	border: 1px solid var(--bb-border-soft, #dcdcd8) !important;
	border-radius: 20px !important;
	background: #ffffff !important;
	box-shadow: var(--bb-elev-soft, 0 12px 26px rgba(42, 42, 42, 0.09)) !important;
	overflow: visible !important;
}

#header.header-builder .buildbarn-header-main-row .searchform .selectric-cat .selectric,
#header.header-builder .buildbarn-header-main-row .searchform-popup .searchform .selectric-cat .selectric {
	height: 62px !important;
	min-height: 62px !important;
	display: flex !important;
	align-items: center !important;
}

#header.header-builder .buildbarn-header-main-row .searchform .selectric-cat .selectric .label,
#header.header-builder .buildbarn-header-main-row .searchform-popup .searchform .selectric-cat .selectric .label {
	line-height: 1.25 !important;
	height: auto !important;
	margin: 0 !important;
	display: flex !important;
	align-items: center !important;
}

#header.header-builder .buildbarn-header-main-row .searchform input,
#header.header-builder .buildbarn-header-main-row .searchform .selectric .label,
#header.header-builder .buildbarn-header-main-row .searchform select,
#header.header-builder .buildbarn-header-main-row .searchform button,
#header.header-builder .buildbarn-header-main-row .searchform-popup .searchform input,
#header.header-builder .buildbarn-header-main-row .searchform-popup .searchform .selectric .label,
#header.header-builder .buildbarn-header-main-row .searchform-popup .searchform select,
#header.header-builder .buildbarn-header-main-row .searchform-popup .searchform button {
	height: 62px !important;
	line-height: normal !important;
}

#header.header-builder .buildbarn-header-main-row .searchform .text,
#header.header-builder .buildbarn-header-main-row .searchform .selectric-cat,
#header.header-builder .buildbarn-header-main-row .searchform .button-wrap,
#header.header-builder .buildbarn-header-main-row .searchform-popup .searchform .text,
#header.header-builder .buildbarn-header-main-row .searchform-popup .searchform .selectric-cat,
#header.header-builder .buildbarn-header-main-row .searchform-popup .searchform .button-wrap {
	background: #ffffff;
}

#header.header-builder .buildbarn-header-main-row .searchform button,
#header.header-builder .buildbarn-header-main-row .searchform-popup .searchform button {
	background: var(--bb-brand-primary, #454545) !important;
	color: #ffffff !important;
	border-radius: 0 20px 20px 0 !important;
	transition: background-color 0.15s ease !important;
}

#header.header-builder .buildbarn-header-main-row .searchform button:hover,
#header.header-builder .buildbarn-header-main-row .searchform-popup .searchform button:hover {
	background: #3a3a3a !important;
}

/*
 * 联想/实时搜索结果层：必须高于下方 .buildbarn-header-nav-row（z-index:1002）及 mega 下拉，
 * 否则下拉向下展开时会被导航条盖住。
 */
#header.header-builder .buildbarn-header-main-row .searchform-popup,
#header.header-builder .buildbarn-header-main-row .vc_porto_hb_search_form,
#header.header-builder .buildbarn-header-main-row form.searchform {
	position: relative !important;
	z-index: var(--bb-z-search-wrap, 5200) !important;
	overflow: visible !important;
}

#header.header-builder .buildbarn-header-main-row .searchform-popup .searchform,
#header.header-builder .buildbarn-header-main-row .vc_porto_hb_search_form .searchform {
	overflow: visible !important;
}

#header.header-builder .buildbarn-header-main-row .live-search-list,
#header.header-builder .buildbarn-header-main-row .live-search-ul,
#header.header-builder .buildbarn-header-main-row .autocomplete-suggestions,
#header.header-builder .buildbarn-header-main-row ul.autocomplete-suggestions,
#header.header-builder .buildbarn-header-main-row .ajaxsearchresults,
#header.header-builder .buildbarn-header-main-row .ajaxsearch-results,
#header.header-builder .buildbarn-header-main-row .search-results,
#header.header-builder .buildbarn-header-main-row .porto-ajax-search .results,
#header.header-builder .buildbarn-header-main-row .simplesearch-result,
#header.header-builder .buildbarn-header-main-row .searchform .ajax-results {
	z-index: var(--bb-z-live-search, 5300) !important;
}

/*
 * Porto 部分版本把联想列表挂到 body 下，不参与 #header 堆叠上下文；需单独抬高以免被 sticky 顶栏挡住。
 */
body > ul.autocomplete-suggestions,
body > .autocomplete-suggestions,
body > .live-search-list,
body .porto-ajax-search-wrapper,
body .porto-ajax-search-wrapper .live-search-list,
body .porto-ajax-search-wrapper .autocomplete-suggestions,
body .porto-live-search-list,
body .porto-search-popup .live-search-list,
body .search-by-category .autocomplete-suggestions {
	z-index: var(--bb-z-autocomplete-portal, 500000) !important;
	/* 勿写 position，避免覆盖主题对联想列表的 absolute/fixed 定位 */
}

/* 联想/分类结果过长：限制高度并内部滚动，避免冲出视口或「跑出框」 */
#header.header-builder .buildbarn-header-main-row .live-search-list,
#header.header-builder .buildbarn-header-main-row .live-search-ul,
#header.header-builder .buildbarn-header-main-row ul.autocomplete-suggestions,
#header.header-builder .buildbarn-header-main-row .autocomplete-suggestions,
#header.header-builder .buildbarn-header-main-row .ajaxsearchresults,
#header.header-builder .buildbarn-header-main-row .searchform .ajax-results,
#header.header-builder .buildbarn-header-main-row .selectric-items,
#header.header-builder .buildbarn-header-main-row .selectric-scroll,
body > ul.autocomplete-suggestions,
body > .autocomplete-suggestions,
body .porto-ajax-search-wrapper .live-search-list,
body .porto-ajax-search-wrapper .autocomplete-suggestions {
	max-height: min(72vh, 520px) !important;
	overflow-y: auto !important;
	overflow-x: hidden !important;
	-webkit-overflow-scrolling: touch;
	box-sizing: border-box !important;
}

/*
 * 勿对 All Categories 的 ul.sidebar-menu 设 max-height + overflow-y:auto：
 * 二级/三级 .popup 向右飞出时会被 scrollport 裁切，表现为「只有二级、三级不出现」。
 */

/* 仅横向主导航 mega 的 .inner 限高滚动；All Categories 同结构必须 overflow:visible（见 fragment / 下条显式覆盖） */
#header.header-builder .buildbarn-header-nav-row .main-menu > li.wide > .popup > .inner {
	max-height: min(82vh, 860px) !important;
	overflow-y: auto !important;
	overflow-x: hidden !important;
	-webkit-overflow-scrolling: touch;
}

/* 覆盖可能来自主题/RUCSS 的滚动裁切，保证宽面板内 3 级可见 */
#header.header-builder .buildbarn-header-nav-row #main-toggle-menu .wide > .popup > .inner,
#header.header-builder #main-toggle-menu .sidebar-menu > li.wide > .popup > .inner {
	max-height: none !important;
	overflow: visible !important;
}

#header.header-builder .buildbarn-header-main-row .my-account,
#header.header-builder .buildbarn-header-main-row .my-wishlist,
#header.header-builder .buildbarn-header-main-row #mini-cart {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 40px;
	min-width: 38px;
	height: 40px;
	border: none;
	border-radius: 4px;
	background: transparent;
	color: #222529;
}

#header.header-builder .buildbarn-header-main-row #mini-cart {
	overflow: visible !important;
}

#header.header-builder .buildbarn-header-main-row .my-account { grid-column: 3; grid-row: 2; }
#header.header-builder .buildbarn-header-main-row .my-wishlist { grid-column: 4; grid-row: 2; }
#header.header-builder .buildbarn-header-main-row #mini-cart { grid-column: 5; grid-row: 2; }

#header.header-builder .buildbarn-header-main-row .my-account:hover,
#header.header-builder .buildbarn-header-main-row .my-wishlist:hover,
#header.header-builder .buildbarn-header-main-row #mini-cart:hover {
	background: rgba(0, 0, 0, 0.06);
	color: var(--porto-primary-color);
}

@media (max-width: 1399px) {
	#header.header-builder .buildbarn-header-main-row .wpb_wrapper {
		display: flex;
		align-items: center;
		gap: 14px;
		flex-wrap: wrap;
	}
	#header.header-builder .buildbarn-header-main-row .buildbarn-header-meta {
		order: 4;
		flex: 1 0 100%;
		display: flex !important;
		justify-content: flex-end;
	}
}

@media (max-width: 991px) {
	/* 手机顶栏：地址/电话置顶一行（此前在 <1199px 被整段隐藏） */
	#header.header-builder .buildbarn-header-main-row .buildbarn-header-meta {
		order: 0 !important;
		flex: 1 0 100% !important;
		width: 100% !important;
		max-width: 100% !important;
		display: flex !important;
		justify-content: center !important;
		align-items: center !important;
		flex-wrap: wrap !important;
		gap: 6px 14px !important;
		padding: 6px 0 8px !important;
		margin: 0 !important;
		justify-self: stretch !important;
		font-size: 12px !important;
		text-align: center !important;
		border-bottom: 1px solid #ececec !important;
	}

	#header.header-builder .buildbarn-header-main-row .buildbarn-header-meta-inner,
	#header.header-builder .buildbarn-header-main-row .buildbarn-header-meta .wpb_wrapper {
		justify-content: center !important;
		flex-wrap: wrap !important;
		row-gap: 4px !important;
	}

	#header.header-builder .buildbarn-header-main-row .buildbarn-header-meta-link {
		white-space: normal !important;
		text-align: center !important;
		max-width: 100% !important;
	}

	/* Restore mobile nav trigger (was hidden by global desktop rule). */
	#header.header-builder .buildbarn-header-main-row .mobile-toggle {
		display: inline-flex !important;
		align-items: center;
		justify-content: center;
		width: 42px;
		height: 42px;
		border-radius: 10px;
		border: 1px solid rgba(69, 69, 69, 0.24);
		background: #ffffff;
		color: #454545 !important;
		order: 2;
	}

	#header.header-builder .buildbarn-header-main-row .logo {
		order: 1;
	}

	#header.header-builder .buildbarn-header-main-row .my-account,
	#header.header-builder .buildbarn-header-main-row .my-wishlist,
	#header.header-builder .buildbarn-header-main-row #mini-cart {
		order: 3;
	}

	#header.header-builder .buildbarn-header-main-row .vc_porto_hb_search_form,
	#header.header-builder .buildbarn-header-main-row .searchform-popup {
		order: 5;
		flex: 1 0 100%;
	}
}

/*
 * 首页：porto-style-inline / RUCSS 会写入 `.home #header .buildbarn-*`（与 #header.header-builder 链特异性相同且早先输出）；
 * Header Builder 在 body 内的 vc_custom 带 !important。此处用 `.home #header.header-builder` 提高特异性并配合 !important，
 * 与 wp_footer 二次加载外链（bb_loc=footer）一起保证最终命中仓库里的灰底/直角布局。
 */
.home #header.header-builder .buildbarn-header-main-row,
.home #header.header-builder .buildbarn-header-nav-row {
	position: relative;
}

.home #header.header-builder .buildbarn-header-nav-row {
	z-index: 1002;
}

.home #header.header-builder .buildbarn-header-main-row {
	padding-top: 10px !important;
	padding-bottom: 0 !important;
	z-index: 1100 !important;
}

.home #header.header-builder .buildbarn-header-nav-row {
	padding-bottom: 0 !important;
}

.home #header.header-builder .buildbarn-header-main-row > .container,
.home #header.header-builder .buildbarn-header-nav-row > .container {
	background: transparent !important;
	border: none !important;
	border-radius: 0 !important;
	box-shadow: none !important;
}

.home #header.header-builder .buildbarn-header-main-row > .container {
	padding-top: 12px !important;
	padding-bottom: 10px !important;
	border-bottom: 1px solid #e7e7e7 !important;
}

.home #header.header-builder .buildbarn-header-nav-row > .container {
	padding-top: 12px !important;
	padding-bottom: 12px !important;
	border-bottom: 1px solid #e7e7e7 !important;
}

/* 首页内联常把顶栏拉宽；与单品页 #main .container 同断点上限 */
@media (min-width: 992px) {
	.home #header.header-builder .buildbarn-header-main-row > .porto-wrap-container:not(.container),
	.home #header.header-builder .buildbarn-header-nav-row > .porto-wrap-container:not(.container) {
		max-width: min(var(--porto-container-width, 2000px), 960px) !important;
	}

	.home #header.header-builder .buildbarn-header-main-row > .container-fluid,
	.home #header.header-builder .buildbarn-header-nav-row > .container-fluid {
		max-width: min(var(--porto-container-width, 2000px), 960px) !important;
		width: 100% !important;
		margin-left: auto !important;
		margin-right: auto !important;
		padding-left: calc(var(--bs-gutter-x, 1.5rem) * 0.5) !important;
		padding-right: calc(var(--bs-gutter-x, 1.5rem) * 0.5) !important;
		box-sizing: border-box !important;
	}
}

@media (min-width: 1200px) {
	.home #header.header-builder .buildbarn-header-main-row > .porto-wrap-container:not(.container),
	.home #header.header-builder .buildbarn-header-nav-row > .porto-wrap-container:not(.container),
	.home #header.header-builder .buildbarn-header-main-row > .container-fluid,
	.home #header.header-builder .buildbarn-header-nav-row > .container-fluid {
		max-width: min(var(--porto-container-width, 2000px), 1140px) !important;
	}
}

@media (min-width: 1400px) {
	.home #header.header-builder .buildbarn-header-main-row > .porto-wrap-container:not(.container),
	.home #header.header-builder .buildbarn-header-nav-row > .porto-wrap-container:not(.container),
	.home #header.header-builder .buildbarn-header-main-row > .container-fluid,
	.home #header.header-builder .buildbarn-header-nav-row > .container-fluid {
		max-width: min(var(--porto-container-width, 2000px), 1320px) !important;
	}
}

/*
 * All Categories（#main-toggle-menu）与右侧横向主菜单同一水平线：列内 flex 居中 + 顶链 a 与 .menu-title 同高。
 */
@media (min-width: 992px) {
	#header.header-builder .buildbarn-header-nav-row .porto-wrap-container.container > .row > [class*="vc_column"] .wpb_wrapper,
	#header.header-builder .buildbarn-header-nav-row > .porto-wrap-container > .row > [class*="vc_column"] .wpb_wrapper,
	#header.header-builder .buildbarn-header-nav-row > .container > .row > [class*="vc_column"] .wpb_wrapper {
		display: flex !important;
		align-items: center !important;
		align-self: stretch !important;
		min-height: 0 !important;
	}

	#header.header-builder .buildbarn-header-nav-row #main-toggle-menu {
		display: flex !important;
		align-items: center !important;
		align-self: center !important;
		margin-top: 0 !important;
		margin-bottom: 0 !important;
	}

	#header.header-builder .buildbarn-header-nav-row #main-toggle-menu .menu-title {
		display: inline-flex !important;
		align-items: center !important;
		justify-content: center !important;
		box-sizing: border-box !important;
		margin: 0 !important;
		min-height: 48px !important;
		line-height: 1.25 !important;
	}

	#header.header-builder .buildbarn-header-nav-row .vc_porto_hb_menu:last-child {
		display: flex !important;
		align-items: center !important;
		align-self: center !important;
		margin-top: 0 !important;
		margin-bottom: 0 !important;
	}

	#header.header-builder .buildbarn-header-nav-row .vc_porto_hb_menu:last-child .main-menu,
	#header.header-builder .buildbarn-header-nav-row .vc_porto_hb_menu:last-child .mega-menu {
		display: flex !important;
		flex-wrap: wrap !important;
		align-items: center !important;
		margin-top: 0 !important;
		margin-bottom: 0 !important;
	}

	#header.header-builder .buildbarn-header-nav-row .vc_porto_hb_menu:last-child .main-menu > li.menu-item {
		display: flex !important;
		align-items: center !important;
		margin-top: 0 !important;
		margin-bottom: 0 !important;
	}

	#header.header-builder .buildbarn-header-nav-row .vc_porto_hb_menu:last-child .main-menu > li.menu-item > a {
		display: inline-flex !important;
		align-items: center !important;
		justify-content: center !important;
		box-sizing: border-box !important;
		min-height: 48px !important;
		line-height: 1.3 !important;
	}
}

