/* 全站共享交互组件：搜索框 + 移动端抽屉
   由 assets/kb-ui.js 注入，各页只需引入一次。
   配色走 hermes.css 的 CSS 变量，控件规格走同一套 --radius-* / --ctl-* token
   （取自 gxwtf 实测值），深浅色自动跟随。 */

/* ---------- 搜索框 ---------- */
/* 注意用 display:flex !important —— 有些页的通用容器规则会把 div 设成 block/grid */
.kb-search {
  display: flex !important; gap: .5rem; align-items: center;
  margin-bottom: 1.1rem; width: 100%; max-width: 720px;
}
.kb-search input {
  flex: 1 1 auto; min-width: 0; font: inherit; font-size: 16px;
  color: var(--fg); background: var(--panel);
  border: 1px solid var(--border); border-radius: var(--radius-input);
  padding: 0 var(--ctl-px); height: var(--ctl-h);
  -webkit-appearance: none; appearance: none;
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.kb-search input:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 var(--ring-w) color-mix(in srgb, var(--accent) 22%, transparent);
}
.kb-search input::placeholder { color: var(--dim); }
.kb-search .kbd {
  font-family: ui-monospace, monospace; font-size: .68rem; color: var(--dim);
  border: 1px solid var(--border); border-radius: 4px; padding: .08rem .32rem;
  white-space: nowrap;
}

/* ---------- 搜索结果面板 ---------- */
.kb-hits {
  border: 1px solid var(--border); border-radius: var(--radius-input);
  background: var(--panel); overflow: hidden; margin-bottom: 1.4rem;
}
.kb-hits[hidden] { display: none; }
.kb-hits a {
  display: block; padding: .62rem .95rem; text-decoration: none; color: inherit;
  border-bottom: 1px solid var(--border-muted); background-image: none;
}
.kb-hits a:last-child { border-bottom: 0; }
.kb-hits a:hover, .kb-hits a.sel { background: var(--accent-subtle); }
.kb-hits .ht { font-size: .9rem; color: var(--fg); }
.kb-hits .hp {
  font-size: .72rem; color: var(--dim); font-family: ui-monospace, monospace;
  margin-top: .1rem;
}
.kb-hits .hs {
  font-size: .78rem; color: var(--muted); margin-top: .2rem; line-height: 1.45;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}
.kb-hits mark {
  background: color-mix(in srgb, var(--accent) 30%, transparent);
  color: inherit; border-radius: 2px;
}
.kb-hits .none { padding: 1rem .95rem; color: var(--dim); font-size: .86rem; }
.kb-hits .grphead {
  padding: .4rem .95rem; font-size: .7rem; letter-spacing: .08em;
  text-transform: uppercase; color: var(--dim);
  background: var(--canvas-subtle); border-bottom: 1px solid var(--border-muted);
}

/* ---------- 移动端抽屉 ---------- */
.kb-drawer-btn {
  display: none; position: fixed; left: 14px; bottom: 18px; z-index: 60;
  width: 46px; height: 46px; border-radius: 50%;
  border: 1px solid var(--border); background: var(--panel);
  color: var(--fg); font-size: 19px; cursor: pointer;
  box-shadow: var(--shadow-lift);
  align-items: center; justify-content: center; padding: 0;
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease),
              box-shadow var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.kb-drawer-btn:hover { border-color: var(--accent); }
.kb-drawer-btn:focus-visible {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 var(--ring-w) color-mix(in srgb, var(--accent) 22%, transparent);
}
.kb-drawer-btn:active { transform: scale(.95); }
.kb-drawer-mask {
  display: none; position: fixed; inset: 0; z-index: 70;
  background: rgba(0,0,0,.4);
  -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px);
}
.kb-drawer {
  position: fixed; top: 0; bottom: 0; left: 0; z-index: 71;
  width: min(84vw, 320px); background: var(--bg);
  border-right: 1px solid var(--border);
  transform: translateX(-102%); transition: transform .22s ease;
  overflow-y: auto; overscroll-behavior: contain;
  padding: 1rem .9rem 4rem;
  -webkit-overflow-scrolling: touch;
}
.kb-drawer.open { transform: translateX(0); }
.kb-drawer-mask.open { display: block; }
.kb-drawer .dh {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: .9rem;
}
.kb-drawer .dh b { font-size: .95rem; color: var(--fg); font-weight: 600; }
.kb-drawer .dh button {
  border: 0; background: none; color: var(--muted); font-size: 22px;
  cursor: pointer; line-height: 1; padding: 0 .2rem;
  border-radius: var(--radius-btn);
  transition: color var(--dur) var(--ease), background var(--dur) var(--ease);
}
.kb-drawer .dh button:hover { color: var(--fg); background: var(--panel2); }
.kb-drawer .dh button:focus-visible {
  outline: none; color: var(--fg);
  box-shadow: 0 0 0 var(--ring-w) color-mix(in srgb, var(--accent) 22%, transparent);
}
.kb-drawer .grp { margin-bottom: 1.1rem; }
.kb-drawer .grp > b {
  display: block; font-size: .7rem; letter-spacing: .08em;
  text-transform: uppercase; color: var(--dim); font-weight: 500;
  margin-bottom: .35rem;
}
.kb-drawer a {
  display: block; padding: .42rem .5rem; border-radius: 6px;
  color: var(--muted); text-decoration: none; line-height: 1.4;
  font-size: .88rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  background-image: none;
}
.kb-drawer a:hover, .kb-drawer a.cur {
  background: var(--accent-subtle); color: var(--accent-text);
}
.kb-drawer .dsearch {
  width: 100%; font: inherit; font-size: 16px; box-sizing: border-box;
  color: var(--fg); background: var(--panel2);
  border: 1px solid var(--border); border-radius: var(--radius-input);
  padding: 0 var(--ctl-px); height: var(--ctl-h);
  -webkit-appearance: none; appearance: none;
  margin-bottom: .9rem;
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.kb-drawer .dsearch:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 var(--ring-w) color-mix(in srgb, var(--accent) 22%, transparent);
}

/* 只在触屏 / 窄屏显示抽屉按钮 */
@media (max-width: 880px) {
  .kb-drawer-btn { display: flex; }
  body { padding-bottom: 5.5rem; }
}
