/* ==========================================================================
   个人博客 · 前台样式
   ========================================================================== */

:root {
  /* 前台主色：浅蓝 */
  --accent: #4a8fd4;
  --accent-soft: color-mix(in srgb, var(--accent) 12%, transparent);
  --accent-line: color-mix(in srgb, var(--accent) 28%, transparent);

  --bg: #eff5fc;
  --bg-elev: #ffffff;
  --bg-soft: #e6f0fa;
  --bg-sink: #dce9f7;
  --text: #1d2836;
  --text-soft: #586a7c;
  --text-mute: #8697a8;
  --line: #d5e4f3;
  --line-soft: #e9f2fb;

  --shadow-sm: 0 1px 2px rgba(28, 68, 116, .05);
  --shadow: 0 14px 34px -18px rgba(28, 68, 116, .26), 0 2px 6px -2px rgba(28, 68, 116, .06);
  --shadow-lift: 0 22px 48px -22px rgba(28, 68, 116, .32), 0 4px 10px -4px rgba(28, 68, 116, .08);

  /* 代码块：浅色下还原 MetaEditor（白底 + 蓝关键字 + 红棕常量 + 绿注释） */
  --code-bg: #ffffff;
  --code-head: #f4f6f9;
  --code-text: #1c1f26;
  --code-line: rgba(15, 32, 62, .1);
  --code-gutter: #a8b2c0;
  --code-mute: #7b8697;
  --code-btn-text: #56617a;
  --code-btn-bg: rgba(15, 32, 62, .035);
  --code-btn-border: rgba(15, 32, 62, .13);
  --code-dot: #d5dbe4;
  --code-scroll: rgba(15, 32, 62, .22);
  --code-shadow: 0 14px 30px -20px rgba(20, 45, 85, .28), 0 1px 2px rgba(20, 45, 85, .05);
  --code-ok: #1a7f37;
  --code-ok-bg: rgba(26, 127, 55, .09);
  --code-ok-border: rgba(26, 127, 55, .32);

  --radius-sm: 10px;
  --radius: 16px;
  --radius-lg: 22px;

  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB",
               "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  --font-serif: "Iowan Old Style", "Palatino Linotype", Georgia, "Songti SC", "STSong", "SimSun", serif;
  /* 代码/终端风格：标题、标签、导航统一走等宽 */
  --font-mono: "JetBrains Mono", "Cascadia Mono", "Cascadia Code", "SFMono-Regular", Consolas,
               "Liberation Mono", Menlo, "Sarasa Mono SC", "Microsoft YaHei", monospace;
  --font-display: var(--font-mono);

  --wrap: 1180px;
  --wrap-post: 1100px;
  --wrap-read: 820px;
}

/* 宽屏模式：铺满整个屏幕宽度，由头部按钮切换（选择会被记住） */
html[data-width="wide"] {
  --wrap: 100%;
  --wrap-post: 100%;
  --wrap-read: 100%;
}
html[data-width="wide"] .post-grid {
  grid-template-columns: repeat(auto-fit, minmax(320px, 420px));
  justify-content: center;
}
html[data-width="wide"] .layout {
  grid-template-columns: minmax(0, 1fr) 320px;
}

[data-theme="dark"] {
  --bg: #0f141b;
  --bg-elev: #161d26;
  --bg-soft: #1b2430;
  --bg-sink: #202a37;
  --text: #e6edf5;
  --text-soft: #a3b2c2;
  --text-mute: #7a8899;
  --line: #26313e;
  --line-soft: #202a36;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow: 0 16px 40px -20px rgba(0, 0, 0, .7), 0 2px 8px -4px rgba(0, 0, 0, .4);
  --shadow-lift: 0 26px 56px -24px rgba(0, 0, 0, .8);

  /* 代码块：深色主题沿用同一套色相，整体提亮 */
  --code-bg: #141a24;
  --code-head: #1a222e;
  --code-text: #ccd6e4;
  --code-line: rgba(255, 255, 255, .07);
  --code-gutter: #4d5871;
  --code-mute: #6d7590;
  --code-btn-text: #b9bdd1;
  --code-btn-bg: rgba(255, 255, 255, .04);
  --code-btn-border: rgba(255, 255, 255, .1);
  --code-dot: #3a3c4d;
  --code-scroll: rgba(255, 255, 255, .18);
  --code-shadow: 0 12px 30px -18px rgba(0, 0, 0, .55);
  --code-ok: #7ee787;
  --code-ok-bg: rgba(126, 231, 135, .1);
  --code-ok-border: rgba(126, 231, 135, .4);
}

* { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

/* 背景微光 + 编辑器点阵 */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background-image:
    radial-gradient(900px 500px at 12% -8%, color-mix(in srgb, var(--accent) 9%, transparent), transparent 70%),
    radial-gradient(700px 420px at 92% 4%, color-mix(in srgb, var(--accent) 5%, transparent), transparent 72%),
    radial-gradient(circle at 1px 1px, color-mix(in srgb, var(--accent) 14%, transparent) 1px, transparent 0);
  background-size: auto, auto, 24px 24px;
}

[data-theme="dark"] body::before {
  background-image:
    radial-gradient(900px 520px at 10% -10%, color-mix(in srgb, var(--accent) 16%, transparent), transparent 70%),
    radial-gradient(760px 460px at 94% 0%, color-mix(in srgb, var(--accent) 8%, transparent), transparent 72%),
    radial-gradient(circle at 1px 1px, color-mix(in srgb, var(--accent) 12%, transparent) 1px, transparent 0);
  background-size: auto, auto, 24px 24px;
}

img { max-width: 100%; height: auto; display: block; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; }
::selection { background: color-mix(in srgb, var(--accent) 26%, transparent); }

.wrap {
  width: 100%;
  max-width: var(--wrap);
  margin: 0 auto;
  padding: 0 26px;
  position: relative;
  z-index: 1;
}
.narrow { max-width: var(--wrap-read); }

.skip-link {
  position: absolute;
  left: -9999px;
  top: 8px;
  background: var(--bg-elev);
  padding: 8px 14px;
  border-radius: 8px;
  z-index: 999;
}
.skip-link:focus { left: 12px; }

/* 顶部阅读进度 */
.scroll-progress {
  position: fixed;
  top: 0; left: 0;
  height: 2.5px;
  width: 0;
  background: linear-gradient(90deg, var(--accent), color-mix(in srgb, var(--accent) 45%, #8ec4ee));
  z-index: 120;
  transition: width .1s linear;
  border-radius: 0 3px 3px 0;
}

/* ==========================================================================
   顶部导航
   ========================================================================== */
.site-head {
  position: sticky;
  top: 0;
  z-index: 90;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(180%) blur(16px);
  -webkit-backdrop-filter: saturate(180%) blur(16px);
  border-bottom: 1px solid var(--line-soft);
}

.head-inner {
  display: flex;
  align-items: center;
  gap: 22px;
  height: 72px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-mark {
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  color: #fff;
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 600;
  background: linear-gradient(145deg, var(--accent), color-mix(in srgb, var(--accent) 70%, #7a3f22));
  box-shadow: 0 6px 16px -8px color-mix(in srgb, var(--accent) 80%, transparent);
}

.brand-text { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.brand-text strong {
  font-size: 16.5px;
  letter-spacing: .01em;
  font-weight: 650;
  white-space: nowrap;
}
.brand-text em {
  font-style: normal;
  font-size: 11.5px;
  color: var(--text-mute);
  letter-spacing: .04em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 240px;
}

.nav {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
}
.nav a {
  position: relative;
  padding: 7px 13px;
  border-radius: 9px;
  font-size: 14.5px;
  color: var(--text-soft);
  transition: color .18s, background .18s;
}
.nav a:hover { color: var(--text); background: var(--bg-soft); }
.nav a.is-active { color: var(--accent); font-weight: 600; }
.nav a.is-active::after {
  content: "";
  position: absolute;
  left: 13px; right: 13px; bottom: 1px;
  height: 2px;
  border-radius: 2px;
  background: var(--accent);
  opacity: .75;
}

.head-tools { display: flex; align-items: center; gap: 6px; }

.icon-btn {
  width: 36px; height: 36px;
  display: grid;
  place-items: center;
  border: 1px solid transparent;
  background: transparent;
  border-radius: 10px;
  cursor: pointer;
  color: var(--text-soft);
  transition: all .18s;
}
.icon-btn:hover { background: var(--bg-soft); color: var(--text); border-color: var(--line); }
.menu-btn { display: none; }

[data-theme="light"] .ico-moon { display: none; }
[data-theme="dark"] .ico-sun { display: none; }

/* 宽屏切换按钮 */
[data-width="wide"] .ico-expand { display: none; }
html:not([data-width="wide"]) .ico-collapse { display: none; }
[data-width="wide"] #widthToggle { color: var(--accent); }
@media (max-width: 900px) { #widthToggle { display: none; } }

/* 搜索栏 */
.search-bar {
  max-height: 0;
  overflow: hidden;
  transition: max-height .32s cubic-bezier(.4, 0, .2, 1);
  border-top: 1px solid transparent;
}
.search-bar.is-open {
  max-height: 88px;
  border-top-color: var(--line-soft);
}
.search-form {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-top: 16px;
  padding-bottom: 16px;
  color: var(--text-mute);
}
.search-form input {
  flex: 1;
  border: none;
  background: transparent;
  font-size: 15.5px;
  color: var(--text);
  outline: none;
  padding: 6px 0;
}
.search-form input::placeholder { color: var(--text-mute); }
.search-form button {
  border: 1px solid var(--line);
  background: var(--bg-elev);
  padding: 6px 16px;
  border-radius: 9px;
  cursor: pointer;
  font-size: 13.5px;
  color: var(--text-soft);
  transition: all .18s;
}
.search-form button:hover { border-color: var(--accent-line); color: var(--accent); }

/* ==========================================================================
   Hero
   ========================================================================== */
.hero {
  position: relative;
  display: flex;
  align-items: center;
  gap: 30px;
  padding: 66px 0 46px;
}

.hero-left { flex: 1; min-width: 0; }

.hero-kicker {
  margin: 0 0 16px;
  font-size: 12.5px;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 600;
}

.hero-title {
  margin: 0 0 18px;
  font-family: var(--font-display);
  font-size: clamp(2.1rem, 4.4vw, 3.35rem);
  line-height: 1.22;
  letter-spacing: -.015em;
  font-weight: 600;
}

.hero-desc {
  margin: 0 0 26px;
  max-width: 560px;
  font-size: 15.5px;
  color: var(--text-soft);
  line-height: 1.85;
}

.hero-stats {
  display: flex;
  align-items: center;
  gap: 18px;
  font-size: 13.5px;
  color: var(--text-mute);
}
.hero-stats b { color: var(--text); font-size: 15px; font-weight: 650; margin-right: 3px; }
.hs-sep { width: 4px; height: 4px; border-radius: 50%; background: var(--line); }

.hero-art {
  position: relative;
  width: 300px;
  height: 220px;
  flex: 0 0 300px;
}
.blob {
  position: absolute;
  border-radius: 48% 52% 58% 42% / 52% 44% 56% 48%;
  filter: blur(2px);
  opacity: .55;
}
.b1 {
  inset: 20px 40px 40px 10px;
  background: linear-gradient(140deg, color-mix(in srgb, var(--accent) 60%, #9fcdf2), color-mix(in srgb, var(--accent) 22%, transparent));
  animation: float1 16s ease-in-out infinite;
}
.b2 {
  width: 130px; height: 130px;
  right: 6px; top: 8px;
  background: linear-gradient(160deg, color-mix(in srgb, var(--accent) 34%, #c2ddf7), transparent);
  opacity: .38;
  animation: float2 20s ease-in-out infinite;
}
.b3 {
  width: 90px; height: 90px;
  left: 58px; bottom: 6px;
  background: linear-gradient(160deg, color-mix(in srgb, var(--accent) 40%, #d3e7fa), transparent);
  opacity: .3;
  animation: float1 24s ease-in-out infinite reverse;
}
@keyframes float1 {
  0%, 100% { border-radius: 48% 52% 58% 42% / 52% 44% 56% 48%; transform: translateY(0) rotate(0); }
  50% { border-radius: 56% 44% 42% 58% / 44% 56% 44% 56%; transform: translateY(-14px) rotate(6deg); }
}
@keyframes float2 {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(-10px, 12px) scale(1.06); }
}

/* ==========================================================================
   页面小标题
   ========================================================================== */
.page-head { padding: 54px 0 30px; }
.page-kicker {
  margin: 0 0 12px;
  font-size: 12px;
  letter-spacing: .22em;
  color: var(--accent);
  font-weight: 600;
}
.page-head h1 {
  margin: 0 0 10px;
  font-family: var(--font-display);
  font-size: clamp(1.7rem, 3vw, 2.3rem);
  font-weight: 600;
  line-height: 1.3;
}
.page-desc { margin: 0; color: var(--text-soft); font-size: 14.5px; }
.inline-link { color: var(--accent); border-bottom: 1px solid var(--accent-line); }

/* ==========================================================================
   两栏布局 + 文章卡片
   ========================================================================== */
.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 38px;
  align-items: start;
  padding-bottom: 70px;
}

.post-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 22px;
}

.card {
  position: relative;
  display: flex;
  flex-direction: column;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px 24px 20px;
  box-shadow: var(--shadow-sm);
  transition: transform .25s cubic-bezier(.2, .7, .3, 1), box-shadow .25s, border-color .25s;
  overflow: hidden;
}
.card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lift);
  border-color: color-mix(in srgb, var(--accent) 26%, var(--line));
}
.card-hit { position: absolute; inset: 0; z-index: 2; }

.card-cover {
  margin: -24px -24px 18px;
  aspect-ratio: 16 / 8.4;
  overflow: hidden;
  background: var(--bg-soft);
}
.card-cover img {
  width: 100%; height: 100%;
  object-fit: cover;
  transition: transform .5s cubic-bezier(.2, .7, .3, 1);
}
.card:hover .card-cover img { transform: scale(1.045); }

.card-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 12.5px;
  color: var(--text-mute);
  letter-spacing: .02em;
}
.dot { width: 3px; height: 3px; border-radius: 50%; background: currentColor; opacity: .5; }
.card-lock {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 2px 8px 2px 6px;
  border-radius: 20px;
  font-size: 11.5px;
}

.card-title {
  margin: 10px 0 9px;
  font-size: 19px;
  line-height: 1.48;
  font-weight: 650;
  letter-spacing: -.005em;
  transition: color .2s;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card:hover .card-title { color: var(--accent); }

.card-excerpt {
  margin: 0 0 18px;
  font-size: 13.8px;
  line-height: 1.78;
  color: var(--text-soft);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-foot {
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding-top: 14px;
  border-top: 1px dashed var(--line-soft);
}
.card-tags { display: flex; gap: 6px; flex-wrap: wrap; flex: 1; min-width: 0; }
.mini-tag {
  font-size: 11.5px;
  color: var(--text-mute);
  background: var(--bg-soft);
  padding: 2px 8px;
  border-radius: 6px;
  white-space: nowrap;
}
.card-more {
  font-size: 12.5px;
  color: var(--accent);
  white-space: nowrap;
  opacity: 0;
  transform: translateX(-4px);
  transition: all .25s;
}
.card:hover .card-more { opacity: 1; transform: translateX(0); }

/* 侧栏 */
.side-col { display: flex; flex-direction: column; gap: 18px; position: sticky; top: 94px; }

.side-card {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}
.side-title {
  margin: 0 0 14px;
  font-size: 13px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--text-mute);
  font-weight: 600;
}

.about-top { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.avatar {
  width: 46px; height: 46px;
  border-radius: 14px;
  object-fit: cover;
  flex: 0 0 46px;
}
.avatar-text {
  display: grid;
  place-items: center;
  background: linear-gradient(145deg, color-mix(in srgb, var(--accent) 85%, #fff), var(--accent));
  color: #fff;
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 600;
}
.about-name { margin: 0; font-weight: 650; font-size: 15px; }
.about-role { margin: 2px 0 0; font-size: 12px; color: var(--text-mute); }
.about-bio { margin: 0; font-size: 13.3px; color: var(--text-soft); line-height: 1.8; }

.hot-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 3px; }
.hot-list a {
  display: flex;
  align-items: baseline;
  gap: 9px;
  padding: 7px 6px;
  border-radius: 8px;
  font-size: 13.4px;
  transition: background .18s;
}
.hot-list a:hover { background: var(--bg-soft); }
.hot-no {
  flex: 0 0 18px;
  font-family: var(--font-display);
  font-size: 13px;
  color: var(--text-mute);
  font-style: italic;
}
.hot-list li:nth-child(1) .hot-no { color: var(--accent); font-weight: 700; }
.hot-title {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-soft);
}
.hot-list a:hover .hot-title { color: var(--text); }
.hot-views { font-size: 11.5px; color: var(--text-mute); }

.side-tags { display: flex; flex-wrap: wrap; gap: 7px; }
.side-tag {
  font-size: 12.5px;
  padding: 4px 10px;
  border-radius: 8px;
  background: var(--bg-soft);
  color: var(--text-soft);
  transition: all .18s;
}
.side-tag em { font-style: normal; opacity: .5; margin-left: 4px; font-size: 11px; }
.side-tag:hover { background: var(--accent-soft); color: var(--accent); }

/* 分页 */
.pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin-top: 34px;
}
.pager-btn {
  padding: 8px 18px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 13.5px;
  color: var(--text-soft);
  background: var(--bg-elev);
  transition: all .18s;
}
.pager-btn:hover { border-color: var(--accent-line); color: var(--accent); }
.pager-btn.is-disabled { opacity: .4; pointer-events: none; }
.pager-info { font-size: 12.5px; color: var(--text-mute); letter-spacing: .06em; }

/* 空状态 */
.empty-state {
  text-align: center;
  padding: 70px 20px;
  background: var(--bg-elev);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
}
.empty-mark { font-size: 34px; color: var(--accent); opacity: .5; }
.empty-state h2 { font-size: 18px; margin: 10px 0 8px; }
.empty-state p { margin: 0 0 22px; color: var(--text-soft); font-size: 14px; }
.empty { color: var(--text-mute); text-align: center; padding: 40px; }

.btn-primary {
  display: inline-block;
  padding: 10px 22px;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  font-size: 14px;
  box-shadow: 0 8px 20px -10px color-mix(in srgb, var(--accent) 90%, transparent);
  transition: transform .2s, box-shadow .2s;
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 12px 26px -10px color-mix(in srgb, var(--accent) 90%, transparent); }

/* ==========================================================================
   文章页
   ========================================================================== */
.post-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 220px;
  gap: 52px;
  align-items: start;
  padding: 42px 26px 80px;
  max-width: var(--wrap-post);
}
.post-layout:not(:has(.toc)) { grid-template-columns: minmax(0, var(--wrap-read)); justify-content: center; }

.post { min-width: 0; }

.post-head { margin-bottom: 30px; }

.back-link {
  display: inline-block;
  font-size: 13px;
  color: var(--text-mute);
  margin-bottom: 18px;
  transition: color .18s, transform .18s;
}
.back-link:hover { color: var(--accent); transform: translateX(-2px); }

.post-title {
  margin: 0 0 16px;
  font-family: var(--font-display);
  font-size: clamp(1.85rem, 3.6vw, 2.6rem);
  line-height: 1.32;
  font-weight: 600;
  letter-spacing: -.01em;
}

.post-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 9px;
  font-size: 13px;
  color: var(--text-mute);
}
.meta-lock { display: inline-flex; align-items: center; gap: 4px; color: var(--accent); }

.post-cover {
  margin: 26px 0 34px;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--line);
}
.post-cover img { width: 100%; }

.post-body { font-size: 16.5px; line-height: 1.92; color: var(--text); }

.post-foot {
  margin-top: 42px;
  padding-top: 22px;
  border-top: 1px solid var(--line-soft);
}
.post-tags { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.tag-chip {
  font-size: 12.5px;
  padding: 4px 12px;
  border-radius: 20px;
  background: var(--bg-soft);
  color: var(--text-soft);
  transition: all .18s;
}
.tag-chip:hover { background: var(--accent-soft); color: var(--accent); }
.post-updated { margin: 0; font-size: 12.5px; color: var(--text-mute); }

.post-nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-top: 32px;
}
.pn-item {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg-elev);
  transition: all .2s;
  min-height: 74px;
}
.pn-item:not(.is-empty):hover { border-color: var(--accent-line); transform: translateY(-2px); box-shadow: var(--shadow); }
.pn-item.is-empty { background: transparent; border-style: dashed; }
.pn-item.is-next { text-align: right; }
.pn-label { font-size: 11.5px; letter-spacing: .1em; color: var(--text-mute); text-transform: uppercase; }
.pn-title {
  font-size: 14px;
  font-weight: 550;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* 目录 */
.toc {
  position: sticky;
  top: 100px;
  font-size: 13px;
  max-height: calc(100vh - 140px);
  overflow-y: auto;
  padding-left: 18px;
  border-left: 1px solid var(--line-soft);
}
.toc-title {
  margin: 0 0 12px;
  font-size: 11.5px;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--text-mute);
  font-weight: 600;
}
.toc-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.toc-list a {
  display: block;
  padding: 4px 0 4px 10px;
  margin-left: -19px;
  border-left: 2px solid transparent;
  color: var(--text-mute);
  line-height: 1.55;
  transition: color .18s, border-color .18s;
}
.toc-list a:hover { color: var(--text); }
.toc-list a.is-active { color: var(--accent); border-left-color: var(--accent); font-weight: 550; }
.toc-lv3 a { padding-left: 22px; font-size: 12.4px; opacity: .85; }

/* ==========================================================================
   Markdown 正文排版
   ========================================================================== */
.md > *:first-child { margin-top: 0; }
.md > *:last-child { margin-bottom: 0; }

.md h1, .md h2, .md h3, .md h4 {
  font-family: var(--font-display);
  font-weight: 600;
  line-height: 1.4;
  margin: 2.1em 0 .75em;
  scroll-margin-top: 96px;
  letter-spacing: -.005em;
}
.md h1 { font-size: 1.72em; }
.md h2 {
  font-size: 1.45em;
  padding-bottom: .38em;
  border-bottom: 1px solid var(--line-soft);
}
.md h2::before {
  content: "";
  display: inline-block;
  width: 4px; height: .82em;
  background: var(--accent);
  border-radius: 2px;
  margin-right: .5em;
  vertical-align: -.04em;
}
.md h3 { font-size: 1.22em; }
.md h4 { font-size: 1.06em; color: var(--text-soft); }

.md p { margin: 1.25em 0; }

.md a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-color: var(--accent-line);
  text-underline-offset: 3px;
  text-decoration-thickness: 1.5px;
  transition: text-decoration-color .18s;
}
.md a:hover { text-decoration-color: var(--accent); }

.md strong { font-weight: 650; }
.md del { color: var(--text-mute); }
.md mark { background: color-mix(in srgb, #a8d0f5 55%, transparent); color: inherit; padding: 0 3px; border-radius: 3px; }

.md .inline-code {
  font-family: var(--font-mono);
  font-size: .86em;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: .12em .42em;
  color: color-mix(in srgb, var(--accent) 72%, var(--text));
  white-space: break-spaces;
}

.md blockquote {
  margin: 1.6em 0;
  padding: 4px 20px;
  border-left: 3px solid var(--accent);
  background: linear-gradient(90deg, var(--accent-soft), transparent 70%);
  border-radius: 0 10px 10px 0;
  color: var(--text-soft);
}
.md blockquote p { margin: .7em 0; }

.md ul, .md ol { margin: 1.2em 0; padding-left: 1.5em; }
.md li { margin: .45em 0; }
.md li::marker { color: var(--accent); }
.md ul ul, .md ol ol, .md ul ol, .md ol ul { margin: .3em 0; }
.md li.task-item { list-style: none; margin-left: -1.4em; display: flex; gap: .55em; align-items: flex-start; }
.task-box {
  flex: 0 0 16px;
  width: 16px; height: 16px;
  margin-top: .42em;
  border: 1.5px solid color-mix(in srgb, var(--text-mute) 55%, transparent);
  border-radius: 4px;
  background: var(--bg-elev);
  position: relative;
}
.task-box.is-done { background: var(--accent); border-color: var(--accent); }
.task-box.is-done::after {
  content: "";
  position: absolute;
  left: 4.5px; top: 1.5px;
  width: 4px; height: 8px;
  border: solid #fff;
  border-width: 0 1.8px 1.8px 0;
  transform: rotate(42deg);
}

.md hr {
  border: none;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--line), transparent);
  margin: 2.6em 0;
}

.md img, .md-img {
  border-radius: var(--radius-sm);
  margin: 1.6em auto;
}
.md-figure { margin: 1.8em 0; text-align: center; }
.md-figure img { margin: 0 auto; border: 1px solid var(--line); }
.md-figure figcaption {
  margin-top: .7em;
  font-size: 12.5px;
  color: var(--text-mute);
}

.md .table-wrap {
  margin: 1.7em 0;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg-elev);
}
.md table { width: 100%; border-collapse: collapse; font-size: 14.5px; }
.md th, .md td { padding: 10px 16px; border-bottom: 1px solid var(--line-soft); text-align: left; }
.md th { background: var(--bg-soft); font-weight: 600; font-size: 13.5px; color: var(--text-soft); }
.md tbody tr:last-child td { border-bottom: none; }
.md tbody tr:hover { background: color-mix(in srgb, var(--bg-soft) 60%, transparent); }

/* 代码块 */
.code-card {
  margin: 1.7em 0;
  border-radius: 14px;
  overflow: hidden;
  background: var(--code-bg);
  border: 1px solid var(--code-line);
  box-shadow: var(--code-shadow);
}
.code-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 14px;
  background: var(--code-head);
  border-bottom: 1px solid var(--code-line);
}
.code-dots { display: flex; gap: 5px; }
.code-dots i {
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--code-dot);
  display: block;
}
.code-dots i:nth-child(1) { background: #ff5f57; opacity: .55; }
.code-dots i:nth-child(2) { background: #febc2e; opacity: .55; }
.code-dots i:nth-child(3) { background: #28c840; opacity: .55; }

.code-lang {
  font-family: var(--font-mono);
  font-size: 11.5px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--code-mute);
}

.code-copy {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 11px;
  border: 1px solid var(--code-btn-border);
  border-radius: 7px;
  background: var(--code-btn-bg);
  color: var(--code-btn-text);
  font-size: 12px;
  cursor: pointer;
  transition: all .18s;
  -webkit-tap-highlight-color: transparent;
}
.code-copy:hover { color: var(--code-text); border-color: var(--code-line); }
.code-copy.is-done { color: var(--code-ok); border-color: var(--code-ok-border); background: var(--code-ok-bg); }
.code-copy svg { flex: 0 0 auto; }

.code-body {
  margin: 0;
  padding: 16px 18px 18px;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 13.4px;
  line-height: 1.72;
  color: var(--code-text);
  tab-size: 4;
  -webkit-overflow-scrolling: touch;
}
.code-body code { font-family: inherit; white-space: pre; }

.code-body::-webkit-scrollbar,
.code-scroll::-webkit-scrollbar { height: 8px; }
.code-body::-webkit-scrollbar-thumb,
.code-scroll::-webkit-scrollbar-thumb { background: var(--code-scroll); border-radius: 4px; }
.code-body::-webkit-scrollbar-track,
.code-scroll::-webkit-scrollbar-track { background: transparent; }

/* 代码块底部复制条 */
.code-foot {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
  background: var(--code-head);
  border-top: 1px solid var(--code-line);
}
.code-meta {
  font-family: var(--font-mono);
  font-size: 11.5px;
  letter-spacing: .04em;
  color: var(--code-mute);
}
.code-copy-foot {
  background: var(--code-btn-bg);
  border-color: var(--code-btn-border);
}

/* MetaEditor / MQL5 官网配色：白底、蓝标识符、绿字符串、青注释、红预处理 */
.tok-kw    { color: #0000cc; }
.tok-fn    { color: #0000cc; }
.tok-num   { color: #0000cc; }
.tok-const { color: #0000cc; }
.tok-str   { color: #008000; }
.tok-com   { color: #008080; }
.tok-pre   { color: #c00000; }

[data-theme="dark"] .tok-kw    { color: #7aa2f7; }
[data-theme="dark"] .tok-fn    { color: #7aa2f7; }
[data-theme="dark"] .tok-num   { color: #7aa2f7; }
[data-theme="dark"] .tok-const { color: #7aa2f7; }
[data-theme="dark"] .tok-str   { color: #7ec699; }
[data-theme="dark"] .tok-com   { color: #4fb3bf; }
[data-theme="dark"] .tok-pre   { color: #ff7b72; }

/* ==========================================================================
   密码页
   ========================================================================== */
.lock-page {
  min-height: calc(100vh - 72px - 220px);
  display: grid;
  place-items: center;
  padding: 60px 26px 90px;
}

.lock-card {
  width: 100%;
  max-width: 430px;
  text-align: center;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 40px 34px 32px;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}
.lock-card::before {
  content: "";
  position: absolute;
  top: -60px; left: 50%;
  width: 220px; height: 160px;
  transform: translateX(-50%);
  background: radial-gradient(circle, color-mix(in srgb, var(--accent) 22%, transparent), transparent 70%);
  pointer-events: none;
}

.lock-badge {
  width: 54px; height: 54px;
  margin: 0 auto 18px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid var(--accent-line);
}
.lock-ico { width: 22px; height: 22px; }

.lock-kicker {
  margin: 0 0 8px;
  font-size: 11.5px;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--text-mute);
}
.lock-title {
  margin: 0 0 10px;
  font-family: var(--font-display);
  font-size: 21px;
  line-height: 1.45;
  font-weight: 600;
}
.lock-desc { margin: 0 0 24px; font-size: 13.5px; color: var(--text-soft); line-height: 1.75; }

.lock-field {
  display: flex;
  gap: 8px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 5px;
  transition: border-color .2s, box-shadow .2s;
}
.lock-field:focus-within {
  border-color: var(--accent-line);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.lock-field input {
  flex: 1;
  min-width: 0;
  border: none;
  background: transparent;
  padding: 9px 12px;
  font-size: 15px;
  color: var(--text);
  outline: none;
  letter-spacing: .06em;
}
.lock-field input::placeholder { color: var(--text-mute); letter-spacing: 0; }
.lock-field button {
  flex: 0 0 auto;
  border: none;
  background: var(--accent);
  color: #fff;
  border-radius: 9px;
  padding: 0 20px;
  font-size: 14px;
  cursor: pointer;
  transition: filter .2s;
}
.lock-field button:hover { filter: brightness(1.06); }

.lock-error {
  margin: 14px 0 0;
  font-size: 13px;
  color: #d9534f;
}
[data-theme="dark"] .lock-error { color: #ff8a80; }

.lock-back {
  display: inline-block;
  margin-top: 22px;
  font-size: 13px;
  color: var(--text-mute);
}
.lock-back:hover { color: var(--accent); }

.shake { animation: shake .42s cubic-bezier(.36, .07, .19, .97); }
@keyframes shake {
  10%, 90% { transform: translateX(-2px); }
  20%, 80% { transform: translateX(4px); }
  30%, 50%, 70% { transform: translateX(-7px); }
  40%, 60% { transform: translateX(7px); }
}

/* ==========================================================================
   归档 / 标签 / 404
   ========================================================================== */
.archive-year { margin-bottom: 34px; }
.year-label {
  display: flex;
  align-items: baseline;
  gap: 10px;
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 600;
  margin: 0 0 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
  color: var(--accent);
}
.year-label span {
  font-family: var(--font-sans);
  font-size: 12px;
  color: var(--text-mute);
  letter-spacing: .06em;
  font-weight: 400;
}

.archive-list { list-style: none; margin: 0; padding: 0; }
.archive-list a {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 11px 10px;
  border-radius: 9px;
  transition: background .18s, transform .18s;
}
.archive-list a:hover { background: var(--bg-elev); transform: translateX(3px); }
.al-date {
  flex: 0 0 54px;
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--text-mute);
}
.al-title { flex: 1; font-size: 15px; min-width: 0; }
.al-lock { color: var(--accent); display: inline-flex; }

.tag-cloud { display: flex; flex-wrap: wrap; gap: 12px; align-items: baseline; }
.cloud-tag {
  padding: 6px 16px;
  border-radius: 24px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  color: var(--text-soft);
  transition: all .2s;
}
.cloud-tag sup { font-size: .58em; opacity: .45; margin-left: 3px; }
.cloud-tag:hover { color: var(--accent); border-color: var(--accent-line); background: var(--accent-soft); transform: translateY(-2px); }

.notfound { text-align: center; padding: 110px 26px; }
.nf-code {
  font-family: var(--font-display);
  font-size: 90px;
  line-height: 1;
  margin: 0 0 10px;
  color: var(--accent);
  opacity: .22;
  font-weight: 700;
}
.notfound h1 { font-size: 22px; margin: 0 0 10px; font-family: var(--font-display); }
.nf-desc { color: var(--text-soft); margin: 0 0 26px; font-size: 14.5px; }

.muted { color: var(--text-mute); }

/* ==========================================================================
   页脚
   ========================================================================== */
.site-foot {
  margin-top: 20px;
  border-top: 1px solid var(--line-soft);
  background: color-mix(in srgb, var(--bg-soft) 55%, transparent);
  padding: 46px 0 30px;
  position: relative;
  z-index: 1;
}
.foot-inner { display: flex; flex-direction: column; gap: 34px; }

.foot-title {
  margin: 0 0 16px;
  font-size: 12.5px;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--text-mute);
  font-weight: 600;
}

.link-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 10px;
}
.link-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 11px 14px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--bg-elev);
  transition: all .2s;
}
.link-item:hover {
  border-color: var(--accent-line);
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}
.link-name { font-size: 13.5px; font-weight: 550; }
.link-note {
  font-size: 11.5px;
  color: var(--text-mute);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.foot-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  padding-top: 22px;
  border-top: 1px solid var(--line);
}
.foot-copy, .foot-meta { margin: 0; font-size: 12.5px; color: var(--text-mute); }
.foot-meta { display: flex; align-items: center; gap: 8px; }
.foot-meta a { transition: color .18s; }
.foot-meta a:hover { color: var(--accent); }

/* ==========================================================================
   响应式
   ========================================================================== */
@media (max-width: 1080px) {
  .layout { grid-template-columns: minmax(0, 1fr) 270px; gap: 28px; }
  .post-layout { grid-template-columns: minmax(0, 1fr) 190px; gap: 34px; }
  .hero-art { width: 240px; flex-basis: 240px; height: 190px; }
}

@media (max-width: 900px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .side-col { position: static; order: 2; }
  .main-col { order: 1; }
  .hero-art { display: none; }
  .hero { padding: 46px 0 34px; }
  .post-layout { grid-template-columns: minmax(0, 1fr); padding-top: 30px; }
  .toc { display: none; }
}

@media (max-width: 720px) {
  body { font-size: 15.5px; }
  .wrap { padding: 0 18px; }
  .post-layout { padding: 24px 18px 60px; }

  .head-inner { height: 62px; gap: 10px; }
  .brand-mark { width: 34px; height: 34px; flex-basis: 34px; font-size: 17px; }
  .brand-text strong { font-size: 15px; }
  .brand-text em { display: none; }

  .menu-btn { display: grid; }

  .nav {
    position: absolute;
    top: 62px;
    left: 0; right: 0;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    padding: 8px 14px 14px;
    background: var(--bg-elev);
    border-bottom: 1px solid var(--line);
    box-shadow: var(--shadow);
    transform: translateY(-8px);
    opacity: 0;
    visibility: hidden;
    transition: all .22s;
  }
  .nav.is-open { transform: translateY(0); opacity: 1; visibility: visible; }
  .nav a { padding: 12px 14px; border-radius: 9px; font-size: 15px; }
  .nav a.is-active::after { display: none; }
  .nav a.is-active { background: var(--accent-soft); }

  .hero { padding: 34px 0 26px; }
  .hero-title { font-size: 1.9rem; }
  .hero-desc { font-size: 14.5px; margin-bottom: 20px; }
  .hero-stats { gap: 12px; font-size: 12.5px; }

  .page-head { padding: 34px 0 22px; }

  .post-grid { grid-template-columns: minmax(0, 1fr); gap: 16px; }
  .card { padding: 20px 20px 16px; }
  .card-cover { margin: -20px -20px 16px; }
  .card-title { font-size: 17.5px; }
  .card-more { display: none; }

  .post-title { font-size: 1.62rem; }
  .post-body { font-size: 16px; line-height: 1.88; }
  .post-nav { grid-template-columns: 1fr; }
  .pn-item.is-empty { display: none; }

  .lock-card { padding: 32px 22px 26px; }
  .lock-field { flex-direction: column; background: transparent; border: none; padding: 0; gap: 10px; }
  .lock-field input {
    background: var(--bg-soft);
    border: 1px solid var(--line);
    border-radius: 11px;
    padding: 13px 14px;
  }
  .lock-field button { padding: 13px; border-radius: 11px; }

  .link-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
  .foot-bottom { flex-direction: column; align-items: flex-start; }

  .md h2 { font-size: 1.3em; }
  .md h3 { font-size: 1.13em; }
  .code-body { font-size: 12.6px; padding: 14px; }
  .code-copy span { display: none; }
  .code-copy { padding: 6px 9px; }
}

@media (max-width: 400px) {
  .hero-title { font-size: 1.68rem; }
  .card-title { font-size: 16.5px; }
}

/* 打印 */
@media print {
  .site-head, .site-foot, .post-nav, .toc, .scroll-progress, .code-copy { display: none !important; }
  body { background: #fff; }
  .post-layout { display: block; padding: 0; }
}

/* ==========================================================================
   C++ / MQL 开发者风格：等宽 UI、提示符、行号
   ========================================================================== */

/* 品牌与导航：编辑器质感 */
.brand-mark {
  font-family: var(--font-display);
  font-size: 16px;
  letter-spacing: -.02em;
  border-radius: 9px;
}
.brand-text strong {
  font-family: var(--font-display);
  font-size: 15.5px;
  letter-spacing: .01em;
}
.brand-text strong::after {
  content: "_";
  margin-left: 2px;
  color: var(--accent);
  font-weight: 500;
  animation: caret-blink 1.15s step-end infinite;
}
@keyframes caret-blink { 0%, 45% { opacity: 1; } 50%, 100% { opacity: 0; } }

.nav a {
  font-family: var(--font-display);
  font-size: 13.5px;
  letter-spacing: .01em;
}
.nav a.is-active::before {
  content: "> ";
  color: var(--accent);
  font-weight: 700;
}

/* 小标题前面加注释符，像代码里的分段注释 */
.hero-kicker,
.page-kicker {
  font-family: var(--font-display);
  font-size: 12px;
  letter-spacing: .1em;
  text-transform: none;
}
.hero-kicker::before,
.page-kicker::before {
  content: "// ";
  color: color-mix(in srgb, var(--accent) 60%, var(--text-mute));
  font-weight: 700;
}

/* 元信息、标签、目录统一等宽 */
.card-meta,
.post-meta,
.hero-stats,
.foot-meta,
.foot-copy,
.code-meta,
.tag-chip,
.back-link,
.post-updated,
.pn-item em,
.link-note {
  font-family: var(--font-display);
}
.card-meta, .post-meta { font-size: 12px; letter-spacing: .015em; }
.tag-chip { font-size: 12px; letter-spacing: .01em; }
.card-meta .dot, .post-meta .dot { opacity: .65; }

/* 卡片标题：等宽，像变量名 */
.card-title {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -.005em;
}

/* 正文标题前缀改成 # 号 */
.md h2::before {
  content: "##";
  width: auto;
  height: auto;
  background: none;
  border-radius: 0;
  font-family: var(--font-display);
  font-size: .78em;
  font-weight: 500;
  color: color-mix(in srgb, var(--accent) 65%, var(--text-mute));
  margin-right: .42em;
  vertical-align: .06em;
  letter-spacing: -.08em;
}
.md h3::before {
  content: "###";
  font-family: var(--font-display);
  font-size: .76em;
  font-weight: 500;
  color: color-mix(in srgb, var(--accent) 45%, var(--text-mute));
  margin-right: .4em;
  vertical-align: .08em;
  letter-spacing: -.08em;
}

/* 目录：等宽 + 行号感 */
.toc-list a { font-family: var(--font-display); font-size: 12.5px; }
.toc-title { font-family: var(--font-display); letter-spacing: .08em; }

/* ==========================================================================
   代码块：行号栏（水平滚动时吸附在左侧）
   ========================================================================== */
.code-scroll {
  display: flex;
  align-items: stretch;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
}

.code-body {
  flex: 1 1 auto;
  min-width: 0;
  overflow: visible;
  padding: 16px 18px 18px;
}

.code-gutter {
  flex: 0 0 auto;
  position: sticky;
  left: 0;
  z-index: 1;
  padding: 16px 10px 18px 14px;
  background: var(--code-bg);
  border-right: 1px solid var(--code-line);
  font-family: var(--font-mono);
  font-size: 13.4px;
  line-height: 1.72;
  color: var(--code-gutter);
  text-align: right;
  white-space: pre;
  font-variant-numeric: tabular-nums;
  user-select: none;
  -webkit-user-select: none;
  pointer-events: none;
}

/* 移动端：行号收窄，避免挤压代码 */
@media (max-width: 640px) {
  .code-gutter { padding-left: 10px; padding-right: 8px; font-size: 12.4px; }
  .code-body { padding-left: 12px; padding-right: 14px; font-size: 12.9px; }
  .card-title { font-size: 16.5px; }
}
