/* 网页版功能关键词搜索（顶栏） */
.dk-feature-search {
  --dk-fs-green: #059669;
  --dk-fs-green-dark: #047857;
  --dk-fs-green-light: #ecfdf5;
  --dk-fs-black: #111827;
  --dk-fs-muted: #6b7280;
  --dk-fs-border: #e5e7eb;
  position: relative;
  margin-left: 0.75rem;
  margin-right: 0.5rem;
  flex-shrink: 0;
  z-index: 1080;
}

/* 顶栏 container 的 overflow-x:hidden 会裁切搜索/全部下拉 */
nav.navbar,
nav.navbar > .container {
  overflow: visible !important;
}

.dk-feature-search-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

  .dk-feature-search-input {
  width: 240px;
  height: 36px;
  padding: 0.35rem 2.6rem 0.35rem 0.85rem;
  border: 1.5px solid rgba(5, 150, 105, 0.35);
  border-radius: 999px;
  background: #fff;
  color: var(--dk-fs-black);
  font-size: 0.875rem;
  line-height: 1.2;
  transition: width 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.dk-feature-search-input::placeholder {
  color: #9ca3af;
}

.dk-feature-search-input:focus {
  outline: none;
  width: 300px;
  border-color: var(--dk-fs-green);
  box-shadow: 0 0 0 3px rgba(5, 150, 105, 0.15);
}

.dk-feature-search-kbd {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.65rem;
  color: #9ca3af;
  border: 1px solid #e5e7eb;
  border-radius: 4px;
  padding: 0 4px;
  line-height: 1.4;
  background: #f9fafb;
  pointer-events: none;
}

.dk-feature-search-input:focus ~ .dk-feature-search-kbd,
.dk-feature-search-input:not(:placeholder-shown) ~ .dk-feature-search-kbd {
  display: none;
}

.dk-feature-search-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 1.5px solid rgba(5, 150, 105, 0.35);
  border-radius: 50%;
  background: #fff;
  color: var(--dk-fs-green);
  cursor: pointer;
  padding: 0;
}

.dk-feature-search-toggle:hover {
  background: var(--dk-fs-green-light);
  border-color: var(--dk-fs-green);
}

.dk-feature-search-results {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  min-width: 340px;
  max-width: min(440px, 92vw);
  max-height: min(440px, 65vh);
  overflow-y: auto;
  background: #fff;
  border: 1px solid var(--dk-fs-border);
  border-radius: 12px;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.12);
  z-index: 1080;
}

.dk-feature-search-results.show {
  display: block;
}

/* fixed 定位时由 JS 写入 top/left/width，避免被祖先 overflow 裁切 */
.dk-feature-search-results.is-fixed {
  position: fixed;
  right: auto;
}

.dk-feature-search-suggest-label {
  padding: 0.45rem 0.9rem 0.2rem;
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--dk-fs-muted);
  letter-spacing: 0.02em;
  text-transform: none;
}

.dk-feature-search-suggest-item {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  width: 100%;
  padding: 0.45rem 0.9rem;
  border: 0;
  background: transparent;
  text-align: left;
  color: var(--dk-fs-black) !important;
  -webkit-text-fill-color: var(--dk-fs-black);
  font-size: 0.875rem;
  cursor: pointer;
  text-decoration: none !important;
}

.dk-feature-search-suggest-item:hover,
.dk-feature-search-suggest-item.active {
  background: var(--dk-fs-green-light);
  color: var(--dk-fs-green-dark) !important;
  -webkit-text-fill-color: var(--dk-fs-green-dark);
}

.dk-feature-search-suggest-item i {
  color: var(--dk-fs-green);
  font-size: 0.85rem;
  flex-shrink: 0;
}

.dk-feature-search-suggest-item mark {
  background: #fef3c7;
  color: inherit;
  padding: 0 1px;
  border-radius: 2px;
  font-weight: 600;
}

.dk-feature-search-result-item {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  padding: 0.7rem 0.9rem;
  text-decoration: none !important;
  color: var(--dk-fs-black) !important;
  -webkit-text-fill-color: var(--dk-fs-black);
  border-bottom: 1px solid #f3f4f6;
}

.dk-feature-search-result-item:last-child {
  border-bottom: none;
}

.dk-feature-search-result-item:hover,
.dk-feature-search-result-item.active {
  background: var(--dk-fs-green-light);
  color: var(--dk-fs-green-dark) !important;
  -webkit-text-fill-color: var(--dk-fs-green-dark);
}

.dk-feature-search-result-item i {
  margin-top: 0.15rem;
  color: var(--dk-fs-green);
  width: 1.1rem;
  text-align: center;
  flex-shrink: 0;
}

.dk-fs-result-body {
  flex: 1;
  min-width: 0;
}

.dk-fs-result-title {
  display: block;
  font-size: 0.9rem;
  font-weight: 600;
  line-height: 1.3;
}

.dk-fs-result-title mark {
  background: #fef3c7;
  color: inherit;
  padding: 0 2px;
  border-radius: 2px;
}

.dk-fs-result-desc {
  display: block;
  font-size: 0.75rem;
  color: var(--dk-fs-muted);
  margin-top: 0.15rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dk-fs-result-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.2rem;
  flex-shrink: 0;
}

.dk-fs-result-category {
  font-size: 0.65rem;
  color: var(--dk-fs-muted);
  background: #f3f4f6;
  border-radius: 999px;
  padding: 0.1rem 0.45rem;
  white-space: nowrap;
}

.dk-fs-result-badge {
  font-size: 0.6rem;
  color: #fff !important;
  -webkit-text-fill-color: #fff;
  background: var(--dk-fs-green);
  border-radius: 999px;
  padding: 0.1rem 0.4rem;
  white-space: nowrap;
}

.dk-feature-search-empty,
.dk-feature-search-hint {
  padding: 1.25rem 1rem;
  text-align: center;
  color: var(--dk-fs-muted);
  font-size: 0.8rem;
}

.dk-feature-search-empty i,
.dk-feature-search-hint i {
  display: block;
  font-size: 1.5rem;
  margin-bottom: 0.4rem;
  color: #9ca3af;
}

.dk-fs-empty-tip {
  font-size: 0.7rem;
  margin-top: 0.25rem;
  color: var(--dk-fs-muted);
}

/* 无匹配时主引导：绿底白字，对抗全站 a 链 greencolor */
a.dk-fs-fallback-cta,
a.dk-fs-fallback-cta:link,
a.dk-fs-fallback-cta:visited,
a.dk-fs-fallback-cta:hover,
a.dk-fs-fallback-cta:focus,
a.dk-fs-fallback-cta:active {
  background: #059669;
  border-color: #047857;
  color: #ffffff !important;
  -webkit-text-fill-color: #ffffff !important;
}

a.dk-fs-fallback-cta .dk-fs-result-title,
a.dk-fs-fallback-cta .dk-fs-result-desc,
a.dk-fs-fallback-cta .dk-fs-result-category,
a.dk-fs-fallback-cta i {
  color: #ffffff !important;
  -webkit-text-fill-color: #ffffff !important;
}

a.dk-fs-fallback-cta .dk-fs-result-desc {
  opacity: 0.92;
}

a.dk-fs-fallback-cta .dk-fs-result-category {
  background: rgba(255, 255, 255, 0.22);
  border: none;
}

a.dk-fs-fallback-cta:hover,
a.dk-fs-fallback-cta:focus {
  background: #047857;
}

/* 已有功能结果时的轻量引导 */
a.dk-fs-fallback-soft {
  border-top: 1px dashed #e5e7eb;
  margin-top: 0.15rem;
}

a.dk-fs-fallback-soft .dk-fs-result-title {
  color: #059669;
}

.dk-feature-search-footer {
  padding: 0.45rem 0.9rem;
  border-top: 1px solid #f3f4f6;
  font-size: 0.7rem;
  color: var(--dk-fs-muted);
  background: #fafafa;
  border-radius: 0 0 12px 12px;
}

.dk-feature-search-footer a.dk-fs-footer-link,
.dk-feature-search-footer a.dk-fs-footer-link:link,
.dk-feature-search-footer a.dk-fs-footer-link:visited,
.dk-feature-search-footer a.dk-fs-footer-link:hover,
.dk-feature-search-footer a.dk-fs-footer-link:focus,
.dk-feature-search-footer a.dk-fs-footer-link:active {
  color: #059669 !important;
  -webkit-text-fill-color: #059669 !important;
  text-decoration: none;
  font-weight: 600;
}

.dk-feature-search-footer a.dk-fs-footer-link:hover,
.dk-feature-search-footer a.dk-fs-footer-link:focus {
  color: #047857 !important;
  -webkit-text-fill-color: #047857 !important;
  text-decoration: underline;
}

/* 移动端：图标按钮 + 展开输入 */
@media (max-width: 1199.98px) {
  .dk-feature-search {
    margin-left: 0.35rem;
    margin-right: 0.25rem;
  }

  .dk-feature-search:not(.is-open) .dk-feature-search-input-wrap {
    display: none;
  }

  .dk-feature-search-toggle {
    display: inline-flex;
  }

  .dk-feature-search.is-open .dk-feature-search-toggle {
    display: none;
  }

  .dk-feature-search.is-open .dk-feature-search-input-wrap {
    display: flex;
  }

  .dk-feature-search-input,
  .dk-feature-search-input:focus {
    width: min(240px, 55vw);
  }

  .dk-feature-search-kbd {
    display: none;
  }

  .dk-feature-search-results {
    left: auto;
    right: 0;
    min-width: min(340px, 90vw);
  }
}

@media (max-width: 575.98px) {
  .dk-feature-search.is-open {
    position: static;
  }

  .dk-feature-search.is-open .dk-feature-search-input-wrap {
    position: absolute;
    left: 0.75rem;
    right: 0.75rem;
    top: 100%;
    margin-top: 0.35rem;
    z-index: 1081;
  }

  .dk-feature-search-input,
  .dk-feature-search-input:focus {
    width: 100%;
  }

  .dk-feature-search-results {
    left: 0.75rem;
    right: 0.75rem;
    width: auto;
    min-width: 0;
    max-width: none;
  }
}
