/* ============================================================
   墨客文学小站 · 全站统一顶栏样式
   由 _worker.js 注入到门户与五个库页面；类名统一加 mk- 前缀避免与各库样式冲突
   ============================================================ */
.mk-topbar {
  --mk-paper: #f6efe0;
  --mk-ink: #2b2b2b;
  --mk-muted: #8a7b58;
  --mk-link: #6b5d3e;
  --mk-accent: #a63a2b;
  --mk-line: #d8c9a3;
  position: sticky;
  top: 0;
  z-index: 500;
  background: rgba(246, 239, 224, 0.94);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--mk-line);
  font-family: "Noto Serif SC", "Songti SC", "SimSun", serif;
  color: var(--mk-ink);
}
.mk-topbar-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 18px;
  height: 54px;
  display: flex;
  align-items: center;
  gap: 14px;
}
/* 品牌 */
.mk-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: inherit;
  flex-shrink: 0;
}
.mk-seal {
  width: 36px;
  height: 36px;
  background: var(--mk-accent);
  color: var(--mk-paper);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 21px;
  font-weight: 700;
  border-radius: 8px 8px 8px 2px;
  box-shadow: 0 2px 5px rgba(166, 58, 43, 0.3);
  flex-shrink: 0;
}
.mk-brand-name { font-size: 19px; font-weight: 700; letter-spacing: 3px; white-space: nowrap; }
.mk-brand-sub { font-size: 10.5px; color: var(--mk-muted); letter-spacing: 1.5px; margin-top: 1px; white-space: nowrap; }

/* 页签 */
.mk-libs {
  display: flex;
  align-items: center;
  gap: 4px;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
  flex: 1;
  min-width: 0;
  justify-content: center;
}
.mk-libs::-webkit-scrollbar { display: none; }
.mk-lib {
  font-size: 14.5px;
  color: var(--mk-link);
  text-decoration: none;
  padding: 6px 12px;
  border-radius: 6px;
  white-space: nowrap;
  transition: color .18s, background .18s;
  position: relative;
}
.mk-lib:hover { color: var(--mk-accent); background: rgba(166, 58, 43, 0.06); }
.mk-lib.on { color: var(--mk-accent); font-weight: 700; }
.mk-lib.on::after {
  content: "";
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 1px;
  height: 2px;
  background: var(--mk-accent);
  border-radius: 1px;
}

/* 搜索 */
.mk-search {
  display: flex;
  align-items: center;
  gap: 0;
  background: #fff;
  border: 1px solid var(--mk-line);
  border-radius: 99px;
  padding: 0;
  flex-shrink: 0;
  transition: border-color .2s, box-shadow .2s;
  overflow: hidden;
}
.mk-search:focus-within { border-color: var(--mk-accent); box-shadow: 0 0 0 3px rgba(166, 58, 43, 0.1); }
.mk-search select {
  border: none;
  outline: none;
  background: #fbf7ee;
  font: inherit;
  font-size: 12.5px;
  color: var(--mk-muted);
  height: 32px;
  padding: 0 6px 0 12px;
  border-right: 1px solid var(--mk-line);
  cursor: pointer;
  max-width: 92px;
  flex-shrink: 0;
}
.mk-search input {
  border: none;
  outline: none;
  background: none;
  font: inherit;
  font-size: 13px;
  color: var(--mk-ink);
  height: 32px;
  padding: 0 10px;
  width: 150px;
}
.mk-search input::placeholder { color: #b3a583; }
.mk-search button {
  border: none;
  background: var(--mk-accent);
  color: var(--mk-paper);
  font: inherit;
  font-size: 12.5px;
  height: 34px;
  padding: 0 14px;
  cursor: pointer;
  letter-spacing: 1px;
  transition: background .18s;
  flex-shrink: 0;
}
.mk-search button:hover { background: #8f3325; }

@media (max-width: 860px) {
  .mk-brand-sub { display: none; }
  .mk-libs { justify-content: flex-start; }
}
@media (max-width: 700px) {
  .mk-topbar-inner { flex-wrap: wrap; height: auto; padding: 8px 12px; gap: 8px; }
  .mk-search { order: 3; width: 100%; }
  .mk-search select { max-width: 84px; }
  .mk-search input { flex: 1; width: auto; }
  .mk-brand-name { font-size: 17px; }
}

/* ============ 各站原顶栏融合处理 ============ */
/* 门户：隐藏原 header.topbar（统一顶栏已含导航） */
body[data-lib="home"] > header.topbar { display: none; }
/* 诗词曲：隐藏原站品牌名（保留搜索与工具栏为第二行） */
body[data-lib="shici"] .topbar .brand { display: none; }
/* 小说：隐藏原站品牌名（保留搜索与按钮为第二行） */
body[data-lib="xiaoshuo"] .topbar .logo { display: none; }
/* 剧本库：隐藏原 navbar（logo/页签/搜索与统一顶栏重复） */
body[data-lib="juben"] .navbar { display: none; }
/* 二十四史 / 古文：侧栏布局，无需处理 */
/* 二十四史 body 是行向 flex（aside+main 左右分栏）：统一顶栏需独占一行，用 wrap + basis 100% 换行 */
body[data-lib="shiji"] { flex-wrap: wrap; align-content: flex-start; }
body[data-lib="shiji"] > .mk-topbar { flex-basis: 100%; flex-shrink: 0; }
