:root {
    /* ===== 变量名沿用旧版,只换值:金 → 蓝 ===== */
    --bg-0: #f5f6f8;
    --bg-1: #ffffff;

    --gold-deep: #2f47b8;
    --gold: #4d6bfe;
    --gold-bright: #8aa1ff;
    --gold-highlight: #dfe6ff;
    --link-color: var(--gold-deep);

    --ink: #101319;
    --ink-dim: rgba(16, 19, 25, 0.62);
    --ink-faint: rgba(16, 19, 25, 0.40);

    --surface: rgba(255, 255, 255, 0.78);
    --surface-2: rgba(255, 255, 255, 0.55);
    --border: rgba(16, 24, 45, 0.10);
    --border-strong: rgba(16, 24, 45, 0.18);
    --shadow: rgba(24, 34, 60, 0.07);

    --glass: rgba(255, 255, 255, 0.78);
    --glass-soft: rgba(255, 255, 255, 0.60);
    --hover: rgba(16, 24, 45, 0.06);

    --grid-line: rgba(30, 48, 90, 0.045);
    --grid-dot: rgba(30, 48, 90, 0.10);

    --echo-op: 0.55;
    --avatar-ring: rgba(16, 24, 45, 0.18);

    /* 代码块与语法高亮 */
    --code-bg: rgba(255, 255, 255, 0.78);
    --code-head-bg: rgba(255, 255, 255, 0.42);
    --tk-cmt: rgba(16, 19, 25, 0.40);
    --tk-sec: #c2410c;
    --tk-key: #3355d1;
    --tk-str: #0f7b52;
    --tk-num: #a35a12;
    --tk-bool: #7a45cf;

    --font-sans: "Avenir Next", "Futura", "Helvetica Neue", -apple-system,
                 BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
    --font-mono: "SF Mono", "JetBrains Mono", "Consolas", "Courier New", monospace;

    --sw: 60px;
  }

  [data-theme="dark"] {
    --bg-0: #1b1a2d;
    --bg-1: #232238;

    --gold-deep: #93a9ff;
    --gold: #5b7cfa;
    --gold-bright: #b3c2ff;
    --gold-highlight: #dfe6ff;
    --link-color: var(--gold-deep);

    --ink: #f0f2f7;
    --ink-dim: rgba(240, 242, 247, 0.60);
    --ink-faint: rgba(240, 242, 247, 0.36);

    --surface: rgba(28, 27, 46, 0.74);
    --surface-2: rgba(255, 255, 255, 0.055);
    --border: rgba(255, 255, 255, 0.09);
    --border-strong: rgba(255, 255, 255, 0.16);
    --shadow: rgba(0, 0, 0, 0.55);

    --glass: rgba(28, 27, 46, 0.74);
    --glass-soft: rgba(28, 27, 46, 0.52);
    --hover: rgba(255, 255, 255, 0.07);

    --grid-line: rgba(255, 255, 255, 0.032);
    --grid-dot: rgba(255, 255, 255, 0.07);

    --echo-op: 0.62;
    --avatar-ring: rgba(255, 255, 255, 0.30);

    --code-bg: rgba(28, 27, 46, 0.74);
    --code-head-bg: rgba(255, 255, 255, 0.055);
    --tk-cmt: rgba(240, 242, 247, 0.34);
    --tk-sec: #ff9d5c;
    --tk-key: #7ea2ff;
    --tk-str: #56d39b;
    --tk-num: #e0a45e;
    --tk-bool: #c39bf5;
  }

  body.pinned { --sw: 200px; }

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

  /* ===== iOS Safari 全屏适配 =====
     ①背景层向上下各多铺一段,地址栏收放、橡皮筋回弹露出的区域由它填满
     ②html 显式设底色做兜底,并跟随主题 —— 背景层没盖到的极端情况下
       Safari 填的就是这个颜色
     变量在桌面端恒为 0,桌面端渲染不受影响。 */
  :root { --bleed-top: 0px; --bleed-bottom: 0px; }
  @media (max-width: 767px) {
    :root { --bleed-top: 140px; --bleed-bottom: 260px; }
  }

  /* 这两个值必须与着色器里的 base 完全一致 —— iOS Safari 用根元素的
     背景色填充状态栏和底部工具栏那两条,对不上就会看到一道边。 */
  html { scroll-behavior: smooth; background: #f7f6fc; transition: background 0.5s ease; }
  html.is-dark { background: #1b192a; }

  body {
    font-family: var(--font-sans);
    min-height: 100vh; min-height: 100dvh;
    overflow-x: hidden; overflow-x: clip;
    color: var(--ink);
    background: var(--bg-0);
    position: relative;
    -webkit-font-smoothing: antialiased;
    transition: background 0.5s ease, color 0.5s ease;
  }

  /* ===== 背景 =====
     WebGL 只在加载时和切换主题时各画一帧,没有逐帧循环。
     流动感来自两层同一张位图的反向漂移 + 旋转 + 透明度起伏 ——
     只动 transform / opacity,走合成器不触发重绘。 */
  .bg-stage {
    position: fixed; z-index: 0; overflow: hidden;
    left: 0; width: 100%;
    top: calc(-1 * var(--bleed-top));
    height: calc(100% + var(--bleed-top) + var(--bleed-bottom));
    height: calc(100lvh + var(--bleed-top) + var(--bleed-bottom));
    pointer-events: none; background: var(--bg-0);
    transition: background 0.5s ease;
  }
  #bgCanvas, .bg-echo {
    position: absolute; top: -20%; left: -20%;
    width: 140%; height: 140%; display: block;
    will-change: transform, opacity;
  }
  #bgCanvas { animation: drift-a 17s ease-in-out infinite alternate; }
  .bg-echo {
    background-repeat: no-repeat; background-size: 100% 100%;
    opacity: var(--echo-op);
    animation: drift-b 23s ease-in-out infinite alternate,
               breathe 11s ease-in-out infinite alternate;
  }
  @keyframes drift-a {
    from { transform: translate3d(-6%, -4%, 0) scale(1.00) rotate(-3.5deg); }
    to   { transform: translate3d( 7%,  5%, 0) scale(1.14) rotate( 3.5deg); }
  }
  @keyframes drift-b {
    from { transform: translate3d( 8%,  5%, 0) scale(1.16) rotate( 4deg) scaleX(-1); }
    to   { transform: translate3d(-7%, -6%, 0) scale(1.02) rotate(-4deg) scaleX(-1); }
  }
  @keyframes breathe {
    from { opacity: calc(var(--echo-op) * 0.45); }
    to   { opacity: var(--echo-op); }
  }
  @media (prefers-reduced-motion: reduce) {
    #bgCanvas, .bg-echo { animation: none; transform: none; }
  }

  /* 细网格 + 点阵。纯 CSS 渐变,不占 GPU */
  .grid-overlay {
    position: fixed; z-index: 1; pointer-events: none;
    left: 0; width: 100%;
    top: calc(-1 * var(--bleed-top));
    height: calc(100% + var(--bleed-top) + var(--bleed-bottom));
    height: calc(100lvh + var(--bleed-top) + var(--bleed-bottom));
    background-image:
      linear-gradient(var(--grid-line) 1px, transparent 1px),
      linear-gradient(90deg, var(--grid-line) 1px, transparent 1px),
      radial-gradient(var(--grid-dot) 1px, transparent 1px);
    background-size: 96px 96px, 96px 96px, 24px 24px;
    -webkit-mask-image: linear-gradient(180deg, #000 0%, #000 58%, transparent 94%);
            mask-image: linear-gradient(180deg, #000 0%, #000 58%, transparent 94%);
  }

  /* ================= 导航栏:顶部无形状,滚过哨兵才显形 ================= */
  /* 哨兵的高度 = 导航保持透明的滚动距离。
     不能用 1px + 负 rootMargin:那样在页面顶部哨兵就已经在收缩后的
     视口之外,导航一上来就是显形状态。 */
  .nav-sentinel {
    position: absolute; top: 0; left: 0;
    width: 1px; height: 110px; pointer-events: none;
  }

  .navbar {
    position: fixed; top: calc(0.8rem + env(safe-area-inset-top));
    left: 50%; transform: translateX(-50%);
    z-index: 30;
    width: calc(100% - 2rem); max-width: 1180px;
    display: flex; align-items: center; gap: 0.6rem;
    padding: 0.55rem 0.6rem 0.55rem 1.1rem;
    border-radius: 999px;
    background: transparent; border: 1px solid transparent; box-shadow: none;
    -webkit-backdrop-filter: none; backdrop-filter: none;
    transition: background 0.35s ease, border-color 0.35s ease,
                box-shadow 0.35s ease, backdrop-filter 0.35s ease, max-width 0.35s ease;
  }
  .navbar.stuck {
    max-width: 1080px;
    background: var(--glass);
    border-color: var(--border);
    box-shadow: 0 8px 30px -14px var(--shadow);
    -webkit-backdrop-filter: blur(14px) saturate(140%);
            backdrop-filter: blur(14px) saturate(140%);
  }

  .navbar-brand { display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--ink); flex-shrink: 0; }
  /* 圆形头像位:用 cover 裁切,方图/长图都能填满不变形 */
  /* 描边用独立变量而非 --border:头像多半是深色照片,
     边界要能从同样深色的导航底上分辨出来。 */
  .navbar-brand-mark {
    width: 30px; height: 30px; flex-shrink: 0;
    border-radius: 50%; overflow: hidden;
    background: var(--surface-2);
    box-shadow: inset 0 0 0 1px var(--avatar-ring);
  }
  .navbar-brand-mark img {
    width: 100%; height: 100%; object-fit: cover;
    display: block; border-radius: 50%;
  }

  .nav-tag {
    font-family: var(--font-mono); font-size: 11px;
    padding: 3px 10px; border-radius: 999px;
    border: 1px solid var(--border-strong); color: var(--ink-dim);
    white-space: nowrap;
  }
  .nav-spacer { flex: 1; }

  .nav-links { display: flex; align-items: center; gap: 2px; }
  .nav-link {
    font-size: 13.5px; font-weight: 500; text-decoration: none;
    color: var(--ink-dim); padding: 7px 13px; border-radius: 999px;
    transition: color 0.2s ease, background 0.2s ease;
  }
  .nav-link:hover { color: var(--ink); background: var(--hover); }
  .nav-link.active { color: var(--ink); font-weight: 600; }

  .nav-btns { display: flex; align-items: center; gap: 4px; margin-left: 0.3rem; }
  .nav-icon-btn {
    width: 34px; height: 34px; border-radius: 50%; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; color: var(--ink-dim); text-decoration: none;
    border: 1px solid transparent;
    transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
  }
  .nav-icon-btn:hover { background: var(--hover); color: var(--ink); border-color: var(--border); }
  .nav-icon-btn svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 1.7; }
  .nav-icon-btn .icon-moon { display: none; }
  html[data-theme="dark"] .nav-icon-btn .icon-sun { display: none; }
  html[data-theme="dark"] .nav-icon-btn .icon-moon { display: block; }

  /* ================= 侧边栏 ================= */
  .sidebar {
    position: fixed; top: calc(4.8rem + env(safe-area-inset-top));
    bottom: calc(1rem + env(safe-area-inset-bottom)); left: 0.75rem; z-index: 29;
    width: var(--sw); border-radius: 18px; padding: 0.9rem 0.45rem;
    display: flex; flex-direction: column; gap: 2px;
    background: var(--glass-soft);
    -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
    border: 1px solid var(--border);
    transition: width 0.26s cubic-bezier(0.4,0,0.2,1), background 0.5s ease;
    overflow: hidden;
  }
  .sidebar-label {
    font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.12em;
    color: var(--ink-faint); text-transform: uppercase; padding: 0 10px; margin-bottom: 6px;
    white-space: nowrap; opacity: 0; transition: opacity 0.25s ease 0.08s;
  }
  .sidebar.expanded .sidebar-label { opacity: 1; }

  .side-item {
    display: flex; align-items: center; gap: 12px; padding: 8px 10px; border-radius: 10px;
    cursor: pointer; color: var(--ink-dim); text-decoration: none;
    transition: background 0.2s ease, color 0.2s ease;
    white-space: nowrap; overflow: hidden;
  }
  .side-item:hover { background: var(--hover); color: var(--ink); }
  .side-item.active { background: rgba(91,124,250,0.14); color: var(--gold-deep); }
  .side-icon { width: 18px; height: 18px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; }
  .side-icon svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 1.6; }
  .side-text { font-size: 13px; font-weight: 500; opacity: 0; transition: opacity 0.22s ease; }
  .sidebar.expanded .side-text { opacity: 1; }
  .side-item.add-more { color: var(--ink-faint); border: 1px dashed var(--border-strong); }

  .side-chevron {
    margin-left: auto; width: 16px; height: 16px; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    opacity: 0; transition: opacity 0.22s ease, transform 0.28s cubic-bezier(0.4,0,0.2,1);
  }
  .sidebar.expanded .side-chevron { opacity: 0.5; }
  .side-chevron.open { transform: rotate(90deg); }

  .side-sub {
    max-height: 0; overflow: hidden; margin-left: 26px;
    border-left: 1px solid var(--border); padding-left: 10px;
    transition: max-height 0.3s cubic-bezier(0.4,0,0.2,1);
  }
  .side-sub.open { max-height: 120px; }
  .side-sub-item {
    display: flex; align-items: center; gap: 10px; font-size: 12.5px;
    color: var(--ink-faint); text-decoration: none; padding: 5px 8px; border-radius: 8px;
    white-space: nowrap; opacity: 0; transition: opacity 0.22s ease, background 0.2s ease, color 0.2s ease;
  }
  .side-sub-item img { width: 12px; height: 12px; flex-shrink: 0; object-fit: contain; }
  .sidebar.expanded .side-sub-item { opacity: 1; }
  .side-sub-item:hover { background: var(--hover); color: var(--ink); }
  .side-sub-item.active { color: var(--gold-deep); }

  .hamburger-mini {
    margin-top: auto; display: flex; align-items: center; justify-content: center; gap: 4px;
    flex-direction: column; width: 100%; height: 32px; border-radius: 10px;
    cursor: pointer; transition: background 0.2s ease;
  }
  .hamburger-mini:hover { background: var(--hover); }
  .hamburger-mini span {
    display: block; width: 14px; height: 1.5px; background: var(--ink-dim); border-radius: 2px;
    transition: transform 0.3s cubic-bezier(0.34,1.56,0.64,1), opacity 0.2s ease;
  }
  .hamburger-mini.pinned span:nth-child(1) { transform: translateY(5.5px) rotate(45deg); }
  .hamburger-mini.pinned span:nth-child(2) { opacity: 0; }
  .hamburger-mini.pinned span:nth-child(3) { transform: translateY(-5.5px) rotate(-45deg); }

  .sidebar-toggle-float { display: none; }

  /* ================= 主体 ================= */
  .main-shell { transition: margin-left 0.35s cubic-bezier(0.65,0,0.35,1); margin-left: 76px; }
  .main-shell.pinned-shell { margin-left: 216px; }

  .container {
    position: relative; z-index: 2; max-width: 1080px; margin: 0 auto;
    padding: 0 2rem calc(4rem + env(safe-area-inset-bottom));
  }
  .container.narrow { max-width: 900px; }

  /* ---------- Hero / 页头 ---------- */
  .hero { padding: 9rem 0 7rem; max-width: 720px; }
  .page-head { padding: 8rem 0 3.4rem; max-width: 760px; }
  .eyebrow {
    display: inline-block; font-family: var(--font-mono);
    font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase;
    color: var(--ink-dim); padding: 5px 12px; border-radius: 999px;
    border: 1px solid var(--border-strong); background: var(--glass-soft);
    margin-bottom: 1.8rem;
  }
  /* hero 的眉标用朴素文字,只有段落眉标保留描边胶囊 —— 参考站就是这么分的 */
  .hero .eyebrow {
    border: none; background: none; padding: 0;
    font-size: 12px; letter-spacing: 0.1em;
    color: var(--ink-dim); margin-bottom: 1.3rem;
  }

  .hero-title {
    font-size: clamp(2.1rem, 4.2vw, 3.25rem); font-weight: 600;
    letter-spacing: -0.03em; line-height: 1.12; margin-bottom: 1.4rem;
  }
  .page-title {
    font-size: clamp(1.8rem, 3.4vw, 2.5rem); font-weight: 600;
    letter-spacing: -0.028em; line-height: 1.14; margin-bottom: 1rem;
  }
  .hero-sub, .page-sub {
    font-size: 15.5px; line-height: 1.78; color: var(--ink-dim);
    max-width: 580px;
  }
  .hero-sub { font-size: 15px; line-height: 1.85; margin-bottom: 2.3rem; }
  .page-sub a { color: var(--gold-deep); text-decoration: none; border-bottom: 1px solid var(--border-strong); }
  .page-sub a:hover { border-bottom-color: var(--gold); }

  .btn-row { display: flex; flex-wrap: wrap; gap: 12px; }
  .btn {
    display: inline-flex; align-items: center; gap: 9px;
    font-size: 14.5px; font-weight: 500; text-decoration: none;
    padding: 12px 22px; border-radius: 999px;
    border: 1px solid var(--border-strong); color: var(--ink);
    background: var(--glass-soft);
    transition: background 0.2s ease, transform 0.2s ease;
  }
  .btn:hover { background: var(--surface); transform: translateY(-1px); }
  .btn svg { width: 16px; height: 16px; flex-shrink: 0; }
  .btn-primary { background: var(--ink); color: var(--bg-0); border-color: var(--ink); }
  .btn-primary:hover { background: var(--ink); opacity: 0.86; }

  .back-link {
    display: inline-flex; align-items: center; gap: 7px;
    font-family: var(--font-mono); font-size: 12px;
    color: var(--ink-dim); text-decoration: none;
    padding: 6px 13px 6px 10px; border-radius: 999px;
    border: 1px solid var(--border); background: var(--glass-soft);
    transition: color 0.2s ease, border-color 0.2s ease;
  }
  .back-link:hover { color: var(--ink); border-color: var(--border-strong); }
  .back-link svg { width: 13px; height: 13px; stroke: currentColor; fill: none; stroke-width: 1.8; }

  /* ---------- Section ---------- */
  .section { padding: 4.5rem 0 0; }
  .section:first-of-type { padding-top: 0; }
  .section-head { margin-bottom: 2.6rem; }
  .section-title {
    font-size: clamp(1.45rem, 2.6vw, 1.95rem); font-weight: 600;
    letter-spacing: -0.025em; line-height: 1.24; max-width: 620px;
  }

  /* ---------- 卡片 ---------- */
  .card-grid {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 1rem;
  }
  .card-stack { display: flex; flex-direction: column; gap: 1rem; }

  .card {
    display: flex; flex-direction: column;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 16px; padding: 1.6rem 1.5rem 1.4rem;
    -webkit-backdrop-filter: blur(14px) saturate(140%);
            backdrop-filter: blur(14px) saturate(140%);
    transition: border-color 0.25s ease, box-shadow 0.25s ease, transform 0.25s ease;
  }
  .card:hover {
    border-color: rgba(91,124,250,0.4);
    box-shadow: 0 14px 34px -20px var(--shadow);
    transform: translateY(-2px);
  }
  .card.no-lift:hover { transform: none; }
  a.card { text-decoration: none; color: inherit; }

  .card-icon {
    width: 34px; height: 34px; margin-bottom: 1.1rem;
    display: flex; align-items: center; justify-content: center;
    border-radius: 9px; border: 1px solid var(--border);
    background: var(--surface-2); color: var(--gold);
    overflow: hidden; flex-shrink: 0;
  }
  .card-icon svg { width: 17px; height: 17px; stroke: currentColor; fill: none; stroke-width: 1.5; }
  .card-icon img { width: 17px; height: 17px; object-fit: contain; }
  .card-title { font-size: 16.5px; font-weight: 600; letter-spacing: -0.015em; margin-bottom: 0.5rem; }
  .card-desc { font-size: 13.5px; line-height: 1.72; color: var(--ink-dim); }
  .card-desc code {
    font-family: var(--font-mono); font-size: 11.5px;
    background: var(--hover); padding: 1.5px 5px; border-radius: 4px; color: var(--gold-deep);
  }
  .card-desc a { color: var(--gold-deep); text-decoration: none; border-bottom: 1px solid var(--border-strong); }
  .card-note {
    display: flex; align-items: flex-start; gap: 6px; margin-top: 0.8rem;
    font-family: var(--font-mono); font-size: 10.5px; line-height: 1.6; color: var(--ink-faint);
    text-decoration: none;
  }
  .card-note svg { width: 12px; height: 12px; fill: currentColor; flex-shrink: 0; margin-top: 2px; }
  .card-note:hover { color: var(--gold-deep); }

  .card-foot { margin-top: auto; padding-top: 1.2rem; }
  .card-foot.divided { border-top: 1px solid var(--border); margin-top: 1.2rem; }
  .card-btn {
    display: inline-flex; align-items: center; gap: 6px;
    font-size: 13.5px; font-weight: 500; color: var(--gold-deep); text-decoration: none;
  }
  .card-btn .arrow { transition: transform 0.28s cubic-bezier(0.34,1.56,0.64,1); }
  .card-btn:hover .arrow { transform: translateX(4px); }
  .card-foot.disabled { color: var(--ink-faint); font-size: 12.5px; }

  /* 带 logo 的横向卡头(ruleset / config / 文章页共用) */
  .card-head { display: flex; align-items: flex-start; gap: 14px; }
  .card-head .card-icon { width: 40px; height: 40px; margin-bottom: 0; border-radius: 11px; }
  .card-head .card-icon img { width: 19px; height: 19px; }
  .card-head-main { min-width: 0; flex: 1; }
  .card-head .card-title {
    display: flex; align-items: center; gap: 7px;
    cursor: pointer; user-select: none;
  }
  .card-head .card-title.static { cursor: default; }
  .title-chevron {
    display: inline-flex; align-items: center; justify-content: center;
    width: 15px; height: 15px; flex-shrink: 0; color: var(--ink-faint);
    transition: transform 0.3s cubic-bezier(0.4,0,0.2,1), color 0.2s ease;
  }
  .title-chevron svg { width: 11px; height: 11px; stroke: currentColor; fill: none; stroke-width: 2; }
  .card-title:hover .title-chevron { color: var(--gold); }
  .title-chevron.open { transform: rotate(90deg); color: var(--gold); }

  /* ---------- 文件树 ---------- */
  .tree-container { margin-top: 1.2rem; padding-top: 1rem; border-top: 1px solid var(--border); }
  .tree-loading { font-family: var(--font-mono); font-size: 11.5px; color: var(--ink-faint); padding: 0.4rem 0; }

  .tree-node { font-family: var(--font-mono); font-size: 12.5px; }
  .tree-row {
    display: flex; align-items: center; gap: 10px; padding: 5px 8px; border-radius: 8px;
    cursor: pointer; color: var(--ink-dim); text-decoration: none;
    transition: background 0.2s ease, color 0.2s ease;
  }
  .tree-row:hover { background: var(--hover); color: var(--ink); }
  .tree-chevron {
    width: 12px; height: 12px; flex-shrink: 0; display: flex; align-items: center; justify-content: center;
    transition: transform 0.28s cubic-bezier(0.4,0,0.2,1); opacity: 0.55;
  }
  .tree-node.open > .tree-row .tree-chevron { transform: rotate(90deg); }
  .tree-icon { flex-shrink: 0; width: 14px; height: 14px; display: flex; align-items: center; justify-content: center; opacity: 0.7; }
  .tree-icon svg { width: 13px; height: 13px; stroke: currentColor; fill: none; stroke-width: 1.6; }
  .tree-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .tree-children {
    max-height: 0; overflow: hidden; margin-left: 16px;
    border-left: 1px solid var(--border); padding-left: 8px;
    transition: max-height 0.35s cubic-bezier(0.4,0,0.2,1);
  }
  .tree-node.open > .tree-children { max-height: 2000px; }
  .tree-file .tree-row { padding-left: 8px; }
  .tree-file .tree-chevron { visibility: hidden; }
  .tree-file.active > .tree-row { background: rgba(91,124,250,0.16); color: var(--gold-deep); }

  /* ---------- 就地展开的代码查看器 ---------- */
  .code-viewer {
    margin-top: 1rem; border-radius: 14px; overflow: hidden;
    border: 1px solid var(--border); background: var(--code-bg);
    -webkit-backdrop-filter: blur(14px) saturate(140%);
            backdrop-filter: blur(14px) saturate(140%);
    max-height: 0; opacity: 0;
    transition: max-height 0.4s cubic-bezier(0.4,0,0.2,1), opacity 0.3s ease, margin-top 0.4s ease;
  }
  .code-viewer.open { max-height: 620px; opacity: 1; }

  .code-head {
    display: flex; align-items: center; gap: 10px;
    padding: 9px 10px 9px 14px;
    border-bottom: 1px solid var(--border);
    background: var(--code-head-bg);
  }
  .code-path {
    flex: 1; min-width: 0;
    font-family: var(--font-mono); font-size: 11.5px;
    color: var(--ink-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  .code-btn {
    display: flex; align-items: center; justify-content: center; gap: 5px;
    height: 26px; padding: 0 11px; border-radius: 999px;
    border: 1px solid var(--border); background: transparent;
    color: var(--ink-dim); cursor: pointer;
    font-family: var(--font-mono); font-size: 10.5px;
    text-decoration: none; flex-shrink: 0;
    transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
  }
  .code-btn:hover { background: var(--hover); color: var(--ink); border-color: var(--border-strong); }
  .code-btn svg { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 1.6; }

  .code-body {
    -webkit-text-size-adjust: 100%; text-size-adjust: 100%;
    max-height: 560px; overflow: auto;
    font-family: var(--font-mono); font-size: 12px; line-height: 1.7;
    padding: 12px 0;
  }
  .code-body::-webkit-scrollbar { width: 8px; height: 8px; }
  .code-body::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 999px; }
  .code-body::-webkit-scrollbar-track { background: transparent; }

  .code-body table { border-collapse: collapse; width: 100%; }
  .code-body td { vertical-align: top; padding: 0; }
  .code-ln {
    width: 1%; white-space: nowrap; text-align: right;
    padding: 0 12px 0 14px !important;
    color: var(--ink-faint); user-select: none;
    border-right: 1px solid var(--border);
  }
  .code-src { padding: 0 14px !important; white-space: pre; color: var(--ink); }

  /* 语法高亮:与主色同族,深浅色各一套(见 :root / [data-theme=dark]) */
  .tk-cmt  { color: var(--tk-cmt); font-style: italic; }
  .tk-sec  { color: var(--tk-sec); font-weight: 600; }
  .tk-key  { color: var(--tk-key); }
  .tk-str  { color: var(--tk-str); }
  .tk-num  { color: var(--tk-num); }
  .tk-bool { color: var(--tk-bool); font-weight: 600; }

  /* ---------- 文章正文 ---------- */
  .article-content { font-size: 14px; line-height: 1.85; color: var(--ink-dim); }
  .article-content p { margin-bottom: 0.7rem; }
  .article-content p:last-child { margin-bottom: 0; }
  .article-content code {
    font-family: var(--font-mono); font-size: 12px;
    background: var(--hover); padding: 1.5px 5px; border-radius: 4px; color: var(--gold-deep);
  }
  .article-content a { color: var(--gold-deep); text-decoration: none; border-bottom: 1px solid var(--border-strong); }
  .article-content a:hover { border-bottom-color: var(--gold); }

  /* ---------- Stack ---------- */
  .stack-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 2.2rem; }
  .stack-chip {
    font-family: var(--font-mono); font-size: 11.5px;
    padding: 6px 13px; border-radius: 999px; text-decoration: none;
    color: var(--ink-dim); border: 1px solid var(--border);
    background: var(--glass-soft);
    transition: color 0.2s ease, border-color 0.2s ease;
  }
  .stack-chip:hover { color: var(--gold-deep); border-color: rgba(91,124,250,0.4); }

  /* ---------- Footer ---------- */
  .site-footer { margin-top: 5rem; padding-top: 2rem; border-top: 1px solid var(--border); }
  .site-disclaimer { font-size: 11px; line-height: 1.9; color: var(--ink-faint); max-width: 760px; }
  .site-disclaimer strong {
    display: inline-block; color: var(--ink-dim); font-weight: 600;
    font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.1em;
    text-transform: uppercase; margin-bottom: 0.5rem;
  }
  .build-time {
    margin-top: 1.6rem; font-family: var(--font-mono); font-size: 10px;
    color: var(--ink-faint);
  }

  /* ---------- 入场动画:只跑一次,不常驻 ---------- */
  @keyframes rise { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
  .rise { animation: rise 0.7s cubic-bezier(0.22,1,0.36,1) both; }
  .d1 { animation-delay: 0.05s; } .d2 { animation-delay: 0.12s; } .d3 { animation-delay: 0.19s; }
  @media (prefers-reduced-motion: reduce) {
    .rise { animation: none; }
    html { scroll-behavior: auto; }
  }

  /* ---------- 移动端 ---------- */
  @media (max-width: 767px) {
    /* iOS Safari 会用根元素背景色填充状态栏那条,页面画不到那里。
       这里把画面上缘淡出到同一个基色,让接缝看不出来。 */
    .bg-stage::after {
      content: ""; position: absolute; left: 0; right: 0;
      top: 0; height: calc(var(--bleed-top) + 190px);
      background: linear-gradient(180deg,
        var(--bg-0) 0%, var(--bg-0) 42%, transparent 100%);
      pointer-events: none;
    }

    .container { padding: 0 1.25rem calc(4rem + env(safe-area-inset-bottom)); }
    .hero { padding: 6rem 0 4rem; }
    .page-head { padding: 5.6rem 0 2.4rem; }
    .navbar { width: calc(100% - 1.2rem); padding: 0.45rem 0.5rem 0.45rem 0.85rem; gap: 0.35rem; }
    .navbar.stuck { max-width: none; }
    .nav-link { padding: 6px 9px; font-size: 12.5px; }
    .nav-tag { font-size: 10.5px; padding: 3px 8px; }
    .nav-btns { margin-left: 0.1rem; gap: 0; }
    .nav-icon-btn { width: 30px; height: 30px; }

    .main-shell, body.pinned .main-shell { margin-left: 0 !important; }

    .sidebar {
      width: 200px; transform: translateX(calc(-100% - 1.4rem));
      transition: transform 0.32s cubic-bezier(0.4,0,0.2,1);
      box-shadow: 0 24px 50px -20px var(--shadow);
    }
    .sidebar.mobile-open { transform: translateX(0); }

    .sidebar-toggle-float {
      display: flex; position: fixed; left: 0; top: 50%;
      transform: translateY(-50%); z-index: 31;
      width: 20px; height: 44px; border-radius: 0 10px 10px 0;
      background: var(--glass);
      -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
      border: 1px solid var(--border); border-left: none;
      align-items: center; justify-content: center;
      cursor: pointer; color: var(--ink-dim);
      transition: left 0.32s cubic-bezier(0.4,0,0.2,1);
    }
    .sidebar-toggle-float.shifted { left: calc(0.75rem + 200px); }

    .hamburger-mini { display: none; }
    .sidebar.mobile-open .hamburger-mini { display: flex; }
  }
