/* =========================================================================
   搜索联想面板
   -------------------------------------------------------------------------
   挂在页头的 .tk-form-search 上。面板是绝对定位，所以表单本身必须是
   position:relative 的定位容器；表单里的 input 要被面板撑满，所以表单
   自己也要是 flex 容器 —— 否则在不同页面上宽度会忽大忽小。
   ========================================================================= */

.tk-form-search {
	position: relative;
	display: flex;
	align-items: center;
	gap: 10px;
	flex: 1 1 auto;
	min-width: 0;
}

.tk-form-search > input[type="search"],
.tk-form-search > input[type="text"] {
	flex: 1 1 0%;
	min-width: 0;
}

.tk-form-search > .tk-btn {
	flex: 0 0 auto;
}

/* ---------- 面板 ---------- */
.tk-sg {
	position: absolute;
	top: calc(100% + 8px);
	left: 0;
	right: 0;
	z-index: 70;
	max-height: min(66vh, 540px);
	overflow-y: auto;
	overscroll-behavior: contain;
	-webkit-overflow-scrolling: touch;
	background: var(--tk-white);
	border: 1px solid var(--tk-ink);
	box-shadow: 0 22px 48px -22px rgba(21, 24, 28, 0.34);
}

/* [hidden] 默认的 display:none 会被任何显式 display 覆盖，
   这里必须单独写一条，否则面板关不掉。 */
.tk-sg[hidden] {
	display: none;
}

/* ---------- 商品行 ---------- */
.tk-sg-list {
	margin: 0;
	padding: 0;
	list-style: none;
}

.tk-sg-hit {
	position: relative;
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 10px 14px;
	color: var(--tk-ink);
	text-decoration: none;
	border-bottom: 1px solid var(--tk-line-soft);
	transition: background-color 0.12s var(--tk-ease);
}

.tk-sg-hit:hover,
.tk-sg-hit.is-on {
	background: var(--tk-paper-2);
}

.tk-sg-hit.is-on::before {
	content: "";
	position: absolute;
	top: 0;
	bottom: 0;
	left: 0;
	width: 2px;
	background: var(--tk-accent);
}

.tk-sg-img {
	flex: 0 0 auto;
	width: 42px;
	height: 52px;
	object-fit: contain;
	background: var(--tk-paper);
	border: 1px solid var(--tk-line-soft);
}

.tk-sg-img--no {
	display: block;
}

.tk-sg-main {
	flex: 1 1 0%;
	min-width: 0;
	display: block;
}

.tk-sg-name {
	display: block;
	font-size: 13.5px;
	font-weight: 600;
	line-height: 1.45;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.tk-sg-sub {
	display: block;
	margin-top: 3px;
	font-size: 11.5px;
	line-height: 1.4;
	color: var(--tk-ink-3);
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.tk-sg-price {
	flex: 0 0 auto;
	font-family: var(--tk-mono);
	font-size: 12px;
	color: var(--tk-accent);
	white-space: nowrap;
}

.tk-sg-price .tk-price-tilde {
	opacity: 0.7;
}

/* ---------- 词条分组 ---------- */
.tk-sg-grp {
	padding: 12px 14px 4px;
	border-bottom: 1px solid var(--tk-line-soft);
}

.tk-sg-h {
	margin: 0 0 8px;
	font-family: var(--tk-mono);
	font-size: 10px;
	font-weight: 500;
	letter-spacing: 0.12em;
	color: var(--tk-ink-3);
}

.tk-sg-chips {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
	margin-bottom: 10px;
}

.tk-sg-chips .tk-sg-hit {
	display: inline-flex;
	align-items: baseline;
	gap: 6px;
	padding: 6px 11px;
	border: 1px solid var(--tk-line);
	background: var(--tk-white);
	font-size: 12.5px;
}

.tk-sg-chips .tk-sg-hit.is-on::before {
	display: none;
}

.tk-sg-chips b {
	font-family: var(--tk-mono);
	font-size: 10px;
	font-weight: 500;
	color: var(--tk-ink-3);
}

/* ---------- 状态行 / 全部结果 ---------- */
.tk-sg-state {
	margin: 0;
	padding: 16px 14px;
	font-size: 12.5px;
	line-height: 1.8;
	color: var(--tk-ink-3);
	border-bottom: 1px solid var(--tk-line-soft);
}

.tk-sg-all {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	padding: 13px 14px;
	font-size: 12.5px;
	font-weight: 600;
	color: var(--tk-accent);
	text-decoration: none;
	background: var(--tk-paper);
}

.tk-sg-all:hover,
.tk-sg-all.is-on {
	background: var(--tk-paper-2);
}

/* ---------- 窄屏 ---------- */
@media (max-width: 640px) {
	.tk-sg {
		max-height: 62vh;
		border-left: 0;
		border-right: 0;
		left: -1px;
		right: -1px;
	}

	.tk-sg-hit {
		padding: 9px 12px;
		gap: 10px;
	}

	.tk-sg-img {
		width: 36px;
		height: 46px;
	}

	.tk-sg-name {
		font-size: 13px;
	}
}
