/* ============================================================================
   通用样式 + 主题变量（light / dark）
   ============================================================================ */

* { margin: 0; padding: 0; box-sizing: border-box; }

/* HTML hidden 属性强制生效，避免被自定义 display: flex 覆盖 */
[hidden] { display: none !important; }

/* ----------------------------------------------------------------------------
   主题预设：用 [data-preset="<id>"] + [data-mode="dark"] 控制
   兼容旧规则：dark 时同时设置 [data-theme="dark"]
   ---------------------------------------------------------------------------- */

:root {
  /* 与主题无关的全局 token */
  --radius: 6px;
  --radius-lg: 10px;
  --nav-height: 60px;
  --content-max: 980px;
  --font-sans: -apple-system, BlinkMacSystemFont, "Helvetica Neue", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "微软雅黑", Arial, sans-serif;
  --font-mono: "SF Mono", Menlo, Monaco, Consolas, "Courier New", monospace;
}

/* ===== preset: jianshu（默认） ===== */
:root,
:root[data-preset="jianshu"] {
  --primary: #EA6F5A;
  --primary-hover: #D9684F;
  --primary-soft: #FDEBE7;
  --text-main: #2F2F2F;
  --text-secondary: #6B6B6B;
  --text-tertiary: #9C9C9C;
  --border: #ECECEC;
  --border-strong: #D9D9D9;
  --bg: #FFFFFF;
  --bg-soft: #F8F8F8;
  --bg-elev: #FFFFFF;
  --bg-mask: rgba(20, 20, 22, 0.45);
  --code-bg: #F4F5F5;
  --code-text: #C7254E;
  --pre-bg: #2B2B2B;
  --pre-text: #E6E6E6;
  --highlight: #FFF1B8;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.04), 0 1px 2px rgba(0, 0, 0, 0.06);
  --shadow-strong: 0 8px 24px rgba(0, 0, 0, 0.10);
  --nav-bg: rgba(255, 255, 255, 0.85);
  color-scheme: light;
}

:root[data-mode="dark"],
:root[data-theme="dark"],
:root[data-preset="jianshu"][data-mode="dark"] {
  --primary: #FF8A75;
  --primary-hover: #FF6F58;
  --primary-soft: #3A2622;
  --text-main: #E6E6E6;
  --text-secondary: #A3A3A3;
  --text-tertiary: #6F6F6F;
  --border: #2A2A2D;
  --border-strong: #3A3A3D;
  --bg: #131316;
  --bg-soft: #1A1A1E;
  --bg-elev: #1F1F23;
  --bg-mask: rgba(0, 0, 0, 0.6);
  --code-bg: #2A2A2D;
  --code-text: #FFB86C;
  --pre-bg: #0F0F12;
  --pre-text: #E6E6E6;
  --highlight: #4D3F1F;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.3), 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-strong: 0 8px 24px rgba(0, 0, 0, 0.4);
  --nav-bg: rgba(19, 19, 22, 0.78);
  color-scheme: dark;
}

/* ===== preset: github ===== */
:root[data-preset="github"] {
  --primary: #0969DA;
  --primary-hover: #0860C7;
  --primary-soft: #DDF4FF;
  --text-main: #1F2328;
  --text-secondary: #656D76;
  --text-tertiary: #8C959F;
  --border: #D0D7DE;
  --border-strong: #AFB8C1;
  --bg: #FFFFFF;
  --bg-soft: #F6F8FA;
  --bg-elev: #FFFFFF;
  --bg-mask: rgba(0, 0, 0, 0.45);
  --code-bg: rgba(175, 184, 193, 0.20);
  --code-text: #CF222E;
  --pre-bg: #F6F8FA;
  --pre-text: #1F2328;
  --highlight: #FFF8C5;
  --shadow: 0 0 0 1px rgba(31, 35, 40, 0.06), 0 1px 2px rgba(31, 35, 40, 0.08);
  --shadow-strong: 0 8px 24px rgba(140, 149, 159, 0.20);
  --nav-bg: rgba(255, 255, 255, 0.82);
  --radius: 6px;
  color-scheme: light;
}
:root[data-preset="github"][data-mode="dark"],
:root[data-preset="github"][data-theme="dark"] {
  --primary: #4493F8;
  --primary-hover: #58A6FF;
  --primary-soft: #0C2D6B;
  --text-main: #E6EDF3;
  --text-secondary: #8D96A0;
  --text-tertiary: #6E7681;
  --border: #30363D;
  --border-strong: #484F58;
  --bg: #0D1117;
  --bg-soft: #161B22;
  --bg-elev: #0D1117;
  --bg-mask: rgba(0, 0, 0, 0.7);
  --code-bg: rgba(110, 118, 129, 0.40);
  --code-text: #FF7B72;
  --pre-bg: #161B22;
  --pre-text: #E6EDF3;
  --highlight: #4D3F1F;
  --shadow: 0 0 0 1px #30363D;
  --shadow-strong: 0 16px 32px rgba(1, 4, 9, 0.85);
  --nav-bg: rgba(13, 17, 23, 0.85);
  color-scheme: dark;
}

/* ===== preset: solarized ===== */
:root[data-preset="solarized"] {
  --primary: #CB4B16;
  --primary-hover: #B33D0F;
  --primary-soft: #EEE8D5;
  --text-main: #073642;
  --text-secondary: #586E75;
  --text-tertiary: #93A1A1;
  --border: #E6DEC3;
  --border-strong: #C8C1A3;
  --bg: #FDF6E3;
  --bg-soft: #F4EED1;
  --bg-elev: #FDF6E3;
  --bg-mask: rgba(7, 54, 66, 0.35);
  --code-bg: #EEE8D5;
  --code-text: #CB4B16;
  --pre-bg: #002B36;
  --pre-text: #93A1A1;
  --highlight: #FFE08C;
  --shadow: 0 1px 4px rgba(7, 54, 66, 0.07);
  --shadow-strong: 0 12px 28px rgba(7, 54, 66, 0.18);
  --nav-bg: rgba(253, 246, 227, 0.86);
  --radius: 4px;
  color-scheme: light;
}
:root[data-preset="solarized"][data-mode="dark"],
:root[data-preset="solarized"][data-theme="dark"] {
  --primary: #FD9D6C;
  --primary-hover: #FFB48A;
  --primary-soft: #073642;
  --text-main: #93A1A1;
  --text-secondary: #839496;
  --text-tertiary: #586E75;
  --border: #0E4654;
  --border-strong: #586E75;
  --bg: #002B36;
  --bg-soft: #073642;
  --bg-elev: #002B36;
  --bg-mask: rgba(0, 0, 0, 0.7);
  --code-bg: #073642;
  --code-text: #FD9D6C;
  --pre-bg: #073642;
  --pre-text: #93A1A1;
  --highlight: #4D3F1F;
  --shadow: 0 0 0 1px rgba(0, 0, 0, 0.5);
  --shadow-strong: 0 14px 32px rgba(0, 0, 0, 0.6);
  --nav-bg: rgba(0, 43, 54, 0.85);
  color-scheme: dark;
}

/* ===== preset: monokai ===== */
:root[data-preset="monokai"] {
  --primary: #F92672;
  --primary-hover: #E61F69;
  --primary-soft: #FDEBED;
  --text-main: #272822;
  --text-secondary: #555555;
  --text-tertiary: #888888;
  --border: #D8D6CC;
  --border-strong: #B8B6AC;
  --bg: #F9F8F5;
  --bg-soft: #EFEEE9;
  --bg-elev: #FFFFFF;
  --bg-mask: rgba(39, 40, 34, 0.50);
  --code-bg: #F5F3EE;
  --code-text: #F92672;
  --pre-bg: #272822;
  --pre-text: #F8F8F2;
  --highlight: #FFE08C;
  --shadow: 0 1px 4px rgba(39, 40, 34, 0.08);
  --shadow-strong: 0 12px 28px rgba(39, 40, 34, 0.15);
  --nav-bg: rgba(249, 248, 245, 0.86);
  --radius: 8px;
  color-scheme: light;
}
:root[data-preset="monokai"][data-mode="dark"],
:root[data-preset="monokai"][data-theme="dark"] {
  --primary: #F92672;
  --primary-hover: #FF4488;
  --primary-soft: #2B1822;
  --text-main: #F8F8F2;
  --text-secondary: #A6A39A;
  --text-tertiary: #75715E;
  --border: #383830;
  --border-strong: #4A493E;
  --bg: #1E1F1C;
  --bg-soft: #272822;
  --bg-elev: #232420;
  --bg-mask: rgba(0, 0, 0, 0.75);
  --code-bg: #383830;
  --code-text: #FD971F;
  --pre-bg: #131310;
  --pre-text: #F8F8F2;
  --highlight: #4D3F1F;
  --shadow: 0 0 0 1px rgba(0, 0, 0, 0.6);
  --shadow-strong: 0 16px 36px rgba(0, 0, 0, 0.8);
  --nav-bg: rgba(30, 31, 28, 0.85);
  color-scheme: dark;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text-main);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background 0.2s, color 0.2s;
  /* 锁定渲染比例，避免 iOS Safari 横屏/输入框聚焦时自动放大字号；
     避免页面内容溢出时浏览器自动 shrink-to-fit 整页缩小 */
  -webkit-text-size-adjust: 100%;
  -ms-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
html, body {
  /* hidden 兜底（iOS 14- 不支持 clip），clip 给现代浏览器（不破坏 position: sticky） */
  overflow-x: hidden;
  overflow-x: clip;
  max-width: 100vw;
}

/* 图片懒加载占位：未注入真实 src 时显示浅灰底，避免空白闪烁与布局抖动 */
img.lazy-pending {
  background: var(--bg-soft, #f3f3f3);
  min-height: 60px;
}

a { color: inherit; text-decoration: none; transition: color 0.15s; }
a:hover { color: var(--primary); }
img { max-width: 100%; display: block; }

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: transparent;
  color: inherit;
}

input, textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
  outline: none;
  border: none;
  background: transparent;
}

::selection { background: var(--primary); color: #fff; }
mark { background: var(--highlight); color: var(--text-main); padding: 0 2px; border-radius: 2px; }

/* ---------- 顶部导航 ---------- */
.nav {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--nav-height);
  background: var(--nav-bg, rgba(255, 255, 255, 0.85));
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
}

.nav-inner {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 18px;
}

.nav-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 17px;
  font-weight: 700;
  color: var(--primary);
  white-space: nowrap;
}

.nav-logo svg { width: 26px; height: 26px; }
.nav-logo-img {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  object-fit: cover;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 4px;
}

.nav-link {
  padding: 6px 12px;
  font-size: 14px;
  color: var(--text-secondary);
  border-radius: 4px;
  transition: all 0.15s;
}

.nav-link:hover { color: var(--text-main); background: var(--bg-soft); }
.nav-link.active { color: var(--primary); }

.nav-spacer { flex: 1; }

.icon-btn {
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  color: var(--text-secondary);
  transition: all 0.15s;
}

.icon-btn:hover { background: var(--bg-soft); color: var(--text-main); }
.icon-btn svg { width: 18px; height: 18px; }

/* 主题图标三态显示 */
#themeToggle .icon-light,
#themeToggle .icon-dark,
#themeToggle .icon-auto { display: none; }
[data-theme-choice="light"] #themeToggle .icon-light { display: block; }
[data-theme-choice="dark"] #themeToggle .icon-dark { display: block; }
[data-theme-choice="auto"] #themeToggle .icon-auto { display: block; }
:root:not([data-theme-choice]) #themeToggle .icon-auto { display: block; }

.btn-write {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 34px;
  padding: 0 14px;
  border-radius: 999px;
  background: var(--primary);
  color: #fff;
  font-size: 13px;
  font-weight: 500;
  transition: background 0.2s;
}

.btn-write:hover { background: var(--primary-hover); color: #fff; }
.btn-write svg { width: 14px; height: 14px; }

/* 移动端导航汉堡菜单 */
.nav-menu-btn { display: none; }

.nav-drawer {
  position: fixed;
  inset: 0;
  background: var(--bg-mask);
  z-index: 200;
  animation: overlayIn 0.18s ease-out;
}
.nav-drawer.is-hidden { display: none !important; }
.nav-drawer-panel {
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  width: min(280px, 80vw);
  background: var(--bg-elev);
  box-shadow: var(--shadow-strong);
  display: flex;
  flex-direction: column;
  padding: 16px 14px;
  animation: drawerIn 0.22s ease-out;
}
@keyframes drawerIn { from { transform: translateX(-100%); } to { transform: translateX(0); } }

.nav-drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 6px 12px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 10px;
  font-size: 12px;
  color: var(--text-tertiary);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.nav-drawer-links {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}
.nav-drawer-link {
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 15px;
  color: var(--text-main);
  transition: background 0.15s, color 0.15s;
}
.nav-drawer-link:hover { background: var(--bg-soft); color: var(--primary); }
.nav-drawer-link.active { background: var(--bg-soft); color: var(--primary); font-weight: 600; }
.nav-drawer-cta {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 12px;
  padding: 12px;
  border-radius: 10px;
  background: var(--primary);
  color: #fff !important;
  font-size: 14px;
  font-weight: 500;
}
.nav-drawer-cta:hover { background: var(--primary-hover); }
.nav-drawer-cta svg { width: 16px; height: 16px; }

/* ---------- 通用按钮 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 18px;
  border-radius: var(--radius);
  font-size: 14px;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
  border: 1px solid transparent;
}

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); color: #fff; }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }

.btn-secondary {
  border: 1px solid var(--border-strong);
  color: var(--text-main);
  background: var(--bg-elev);
}
.btn-secondary:hover { border-color: var(--primary); color: var(--primary); }

.btn-danger {
  color: #d9534f;
  border: 1px solid #f5d7d4;
  background: var(--bg-elev);
}
.btn-danger:hover { background: #d9534f; color: #fff; border-color: #d9534f; }
[data-theme="dark"] .btn-danger { border-color: #5a2c2a; }

.btn-ghost {
  display: inline-flex;
  align-items: center;
  height: 32px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  font-size: 13px;
  background: var(--bg-elev);
  color: var(--text-main);
  transition: all 0.15s;
}
.btn-ghost:hover { border-color: var(--primary); color: var(--primary); }

/* ---------- 页脚 ---------- */
.footer {
  margin-top: 60px;
  padding: 32px 24px;
  text-align: center;
  color: var(--text-tertiary);
  font-size: 12px;
  border-top: 1px solid var(--border);
}
.footer p { margin: 0; }
.footer a:hover { color: var(--primary); }
.footer-stats {
  margin-top: 10px;
  display: inline-flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  color: var(--text-tertiary);
}
.footer-stats .bsz-sep { color: var(--border); }

/* ---------- 不蒜子访问计数通用占位 ---------- */
/* 在不蒜子脚本拿到数据前 .bsz-num 会是空，我们让它至少占住 0.5em，避免数字"咚"地一下蹦出来 */
.bsz {
  display: inline-flex;
  align-items: baseline;
  gap: 2px;
}
.bsz .bsz-num {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  color: var(--text-secondary);
  min-width: 0.6em;
  display: inline-block;
}
.hero-stats .stat.bsz strong.bsz-num { color: var(--primary); }
.article-author .meta .bsz { color: var(--text-tertiary); }
.pvapi {
  display: inline-flex;
  align-items: baseline;
  gap: 2px;
}
.pvapi .pvapi-num {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  min-width: 0.6em;
  display: inline-block;
}

/* ---------- saobby 计数器（图片即数字）---------- */
/* 内联版：[前缀] [小图] [后缀] —— 用于 footer / 文章 meta */
.saobby-slot {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  line-height: 1;
}
.saobby-slot[hidden] { display: none; }
.saobby-prefix,
.saobby-suffix {
  color: inherit;
  font-size: inherit;
}
.saobby-counter {
  height: 1.05em;
  width: auto;
  display: inline-block;
  border-radius: 4px;
  vertical-align: -0.15em;
  background: #fff;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.06);
}
[data-mode="dark"] .saobby-counter {
  /* 让白底图在暗色背景上不那么刺眼 */
  filter: brightness(0.92) contrast(0.95);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.08), 0 1px 2px rgba(0, 0, 0, 0.3);
}

/* 卡片版：用于首页 hero 区，和其它 stat 卡片对齐 —— 和 .stat <strong>N</strong>label 一致的横向布局 */
.saobby-slot-stat {
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  gap: 0;
}
.saobby-slot-stat .saobby-num {
  display: inline-flex;
  align-items: center;
  font-weight: 600;
}
.saobby-slot-stat .saobby-num .saobby-counter {
  height: 18px;
  border-radius: 4px;
  vertical-align: -0.18em;
}
.saobby-slot-stat .saobby-label {
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: normal;
  margin-left: 2px;
}

/* footer 紧凑：把字号缩到正文小字一致 */
.footer-stats .saobby-slot { gap: 2px; font-size: 12px; align-items: center; }
.footer-stats .saobby-slot .saobby-counter { height: 14px; border-radius: 3px; }
.footer-stats .saobby-slot .saobby-prefix { margin-right: 1px; }
.footer-stats .saobby-slot .saobby-suffix { margin-left: 2px; }

/* 文章 meta 内联版：和「字数 / 分钟」一行 */
.article-author .meta .saobby-slot-inline { gap: 4px; }
.article-author .meta .saobby-slot-inline .saobby-counter { height: 14px; border-radius: 3px; }

.footer-social {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-bottom: 14px;
}
.social-link {
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--bg-soft);
  color: var(--text-secondary);
  transition: all 0.15s;
}
.social-link:hover { background: var(--primary); color: #fff; }

/* ---------- 通用标签 ---------- */
.tag {
  display: inline-flex;
  align-items: center;
  background: var(--bg-soft);
  color: var(--text-secondary);
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 12px;
  border: 1px solid var(--border);
  transition: all 0.15s;
}
.tag:hover,
.tag.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
.tag.tag-colored {
  background: var(--tag-bg);
  color: var(--tag-text);
  border-color: var(--tag-border);
}
[data-mode="dark"] .tag.tag-colored,
[data-theme="dark"] .tag.tag-colored {
  background: var(--tag-dark-bg);
  color: var(--tag-dark-text);
  border-color: var(--tag-dark-border);
}
.tag.tag-colored:hover,
.tag.tag-colored.active {
  background: var(--tag-text);
  color: #fff;
  border-color: var(--tag-text);
}
[data-mode="dark"] .tag.tag-colored:hover,
[data-mode="dark"] .tag.tag-colored.active,
[data-theme="dark"] .tag.tag-colored:hover,
[data-theme="dark"] .tag.tag-colored.active {
  background: var(--tag-dark-text);
  color: #151515;
  border-color: var(--tag-dark-text);
}

/* ---------- 加载/空状态 ---------- */
.loading, .empty, .error {
  text-align: center;
  padding: 60px 24px;
  color: var(--text-secondary);
  font-size: 14px;
}
.error { color: #d9534f; }

/* ---------- toast ---------- */
.toast {
  position: fixed;
  top: 80px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  background: rgba(0, 0, 0, 0.84);
  color: #fff;
  padding: 10px 22px;
  border-radius: 4px;
  font-size: 13px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s;
  white-space: nowrap;
  max-width: calc(100vw - 40px);
  overflow: hidden;
  text-overflow: ellipsis;
}
.toast.show { opacity: 1; }
.toast.error { background: #d9534f; }

/* ---------- 搜索浮层 ---------- */
.search-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg-mask);
  z-index: 1000;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 80px 16px 16px;
  animation: overlayIn 0.15s ease-out;
}
/* 兜底：用 .is-hidden 也能关，不依赖 [hidden] 属性 */
.search-overlay.is-hidden { display: none !important; }
@keyframes overlayIn { from { opacity: 0 } to { opacity: 1 } }

.search-modal {
  width: 100%;
  max-width: 600px;
  background: var(--bg-elev);
  border-radius: 12px;
  box-shadow: var(--shadow-strong);
  overflow: hidden;
}

.search-input-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}
.search-input-wrap svg { width: 18px; height: 18px; color: var(--text-tertiary); flex-shrink: 0; }
.search-input-wrap input {
  flex: 1;
  font-size: 15px;
}
.search-input-wrap kbd {
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 2px 6px;
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  color: var(--text-tertiary);
}
.search-close {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-tertiary);
  flex-shrink: 0;
  cursor: pointer;
  transition: all 0.15s;
}
.search-close:hover { background: var(--bg-soft); color: var(--text-main); }

.search-results {
  max-height: 60vh;
  overflow-y: auto;
}

.search-empty {
  padding: 40px 20px;
  text-align: center;
  color: var(--text-tertiary);
  font-size: 13px;
}

.search-item {
  display: block;
  padding: 12px 18px;
  border-bottom: 1px solid var(--border);
  transition: background 0.12s;
}
.search-item:last-child { border-bottom: none; }
.search-item:hover { background: var(--bg-soft); }

.search-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 4px;
}
.search-summary {
  font-size: 13px;
  color: var(--text-secondary);
  display: -webkit-box;
  -webkit-line-clamp: 1;
  line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 4px;
}
.search-meta {
  font-size: 12px;
  color: var(--text-tertiary);
}

/* ---------- 响应式 ---------- */
@media (max-width: 880px) {
  .nav-links { display: none; }
  .nav-menu-btn { display: inline-flex; }
}

@media (max-width: 720px) {
  .nav { padding: 0 12px; height: 56px; }
  :root { --nav-height: 56px; }
  .nav-inner { gap: 6px; }
  .nav-logo { font-size: 15px; }
  .nav-logo svg, .nav-logo-img { width: 24px; height: 24px; }
  .btn-write { padding: 0 10px; height: 32px; font-size: 12px; gap: 4px; }
  .btn-write svg { width: 13px; height: 13px; }
  .icon-btn { width: 32px; height: 32px; }
  .icon-btn svg { width: 16px; height: 16px; }
  .footer { margin-top: 36px; padding: 24px 16px; font-size: 11px; }
  .toast { top: 70px; font-size: 12px; padding: 8px 16px; }
  .search-overlay { padding: 50px 12px 12px; }
  .search-input-wrap { padding: 12px 14px; gap: 8px; }
  .search-input-wrap input { font-size: 14px; }
  .search-input-wrap kbd { display: none; }
  .search-results { max-height: 70vh; }
  .search-item { padding: 12px 14px; }
  .search-title { font-size: 14px; }
  .search-summary { font-size: 12.5px; }
}

@media (max-width: 420px) {
  .btn-write-label { display: none; }
  .btn-write { padding: 0; width: 32px; justify-content: center; }
}

/* ---------- 主题选择器弹层 ---------- */
.preset-picker-layer {
  position: fixed;
  inset: 0;
  z-index: 1100;
  background: var(--bg-mask);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  animation: overlayIn 0.16s ease-out;
}
.preset-picker-layer.is-hidden { display: none !important; }

.preset-picker-panel {
  width: 100%;
  max-width: 520px;
  background: var(--bg-elev);
  border-radius: 16px;
  padding: 22px 22px 18px;
  box-shadow: var(--shadow-strong);
}
.preset-picker-title {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 14px;
  color: var(--text-main);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.preset-picker-title .close-x {
  color: var(--text-tertiary);
  font-size: 18px;
  background: transparent;
  border: none;
  cursor: pointer;
}
.preset-picker-mode {
  display: flex;
  gap: 4px;
  margin-bottom: 16px;
  background: var(--bg-soft);
  padding: 4px;
  border-radius: 999px;
}
.preset-picker-mode button {
  flex: 1;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 12.5px;
  color: var(--text-secondary);
  border: none;
  background: transparent;
  cursor: pointer;
}
.preset-picker-mode button.active {
  background: var(--bg-elev);
  color: var(--primary);
  font-weight: 500;
  box-shadow: var(--shadow);
}

.preset-picker-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.preset-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg);
  cursor: pointer;
  transition: border-color 0.15s, transform 0.15s;
  text-align: left;
}
.preset-card:hover { transform: translateY(-1px); }
.preset-card.active {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}
.preset-swatch {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  flex-shrink: 0;
  position: relative;
  border: 1px solid var(--border);
  overflow: hidden;
}
.preset-dot {
  position: absolute;
  bottom: 6px;
  right: 6px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.18);
}
.preset-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.preset-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-main);
}
.preset-tag {
  font-size: 11px;
  color: var(--text-tertiary);
}

@media (max-width: 420px) {
  .preset-picker-grid { grid-template-columns: 1fr; }
}
