/* Premium v2: reader / labs / drawer / particles. Loaded after premium.css. */
:root { --nx-gold-2: #f3d894; }

/* ---------- 粒子层 ---------- */
#nx-particle-webgpu { position: fixed; inset: 0; width: 100vw; height: 100vh; z-index: 1; pointer-events: none; opacity: 0; transition: opacity 1.2s; }
#nx-particle-webgpu.is-live { opacity: 0.55; }

/* ---------- 移动抽屉导航 ---------- */
.nx-nav-toggle { display: none; }
.nx-mobile-drawer { position: fixed; inset: 0; z-index: 75; background: rgba(2,4,10,.7); backdrop-filter: blur(8px); }
.nx-mobile-drawer-panel { position: absolute; right: 0; top: 0; bottom: 0; width: min(84vw, 340px); background: linear-gradient(180deg,#0c1226,#05070f); border-left: 1px solid rgba(232,196,122,.25); padding: 1.2rem; display: flex; flex-direction: column; gap: .4rem; animation: nxDrawerIn .32s cubic-bezier(.2,.7,.2,1); }
@keyframes nxDrawerIn { from { transform: translateX(30px); opacity: 0; } to { transform: none; opacity: 1; } }
.nx-mobile-drawer-panel a { padding: .8rem .9rem; border-radius: 10px; border: 1px solid rgba(255,255,255,.07); font-family: var(--nx-font-mono); font-size: .8rem; color: #dbe2ef; }
.nx-mobile-drawer-panel a.is-active { border-color: rgba(232,196,122,.5); color: var(--nx-gold); }
@media (max-width: 1023px) { .nx-nav-toggle { display: inline-flex; } }

/* ---------- 阅读页 ---------- */
body.nx-reader-mode { background: #05070f; }
.nx-article-body { max-width: 68ch; font-size: 1.04rem; line-height: 1.92; color: #dde5f2; }
.nx-article-body > p:first-of-type::first-letter { font-family: var(--nx-display); font-size: 3.2em; float: left; line-height: .9; padding-right: .12em; color: var(--nx-gold); font-weight: 800; }
.nx-article-heading { border-bottom: 1px solid rgba(255,255,255,.09); position: relative; }
.nx-article-heading::before { content: ""; position: absolute; left: 0; bottom: -1px; width: 54px; height: 2px; background: linear-gradient(90deg,var(--nx-gold),transparent); }
.nx-code-block-wrap { position: relative; }
.nx-code-block-wrap::before { content: attr(data-lang); position: absolute; top: .7rem; left: .9rem; font-family: var(--nx-font-mono); font-size: .6rem; letter-spacing: .14em; color: var(--nx-gold); opacity: .8; }
.nx-code-pane { padding-top: 1.6rem; tab-size: 2; }
.nx-bench-bar div { transition: width 1s cubic-bezier(.2,.7,.2,1); position: relative; overflow: hidden; }
.nx-bench-bar div::after { content: ""; position: absolute; inset: 0; background: linear-gradient(100deg,transparent 30%,rgba(255,255,255,.45) 50%,transparent 70%); transform: translateX(-100%); animation: nxShimmer 2.6s ease infinite; }
@keyframes nxShimmer { 60%,100% { transform: translateX(100%); } }
.nx-callout-ai { border-left: 2px solid var(--nx-gold); }
.nx-toc-nav a.is-active { border-left: 2px solid var(--nx-gold); background: rgba(232,196,122,.08); color: var(--nx-gold-2); }
.nx-lightbox { position: fixed; inset: 0; z-index: 120; background: rgba(2,4,10,.9); display: flex; align-items: center; justify-content: center; padding: 2rem; cursor: zoom-out; }
.nx-lightbox img { max-width: min(1100px,92vw); max-height: 86vh; border-radius: 12px; border: 1px solid rgba(255,255,255,.15); box-shadow: 0 30px 80px rgba(0,0,0,.6); }
.nx-reader-cover img { cursor: zoom-in; }
.nx-reader-cover-caption h1 { letter-spacing: -.025em; text-wrap: balance; }

/* ---------- Lab 页 ---------- */
.nx-radar-chart-panel, .nx-graph-canvas-panel, .nx-codelab-controls { transform-style: preserve-3d; will-change: transform; }
.nx-radar-svg-wrap { position: relative; }
.nx-radar-sweep { position: absolute; inset: 6% 8%; border-radius: 999px; pointer-events: none; background: conic-gradient(from 0deg, transparent 0deg, rgba(232,196,122,.14) 40deg, transparent 80deg); animation: nxSweep 9s linear infinite; }
@keyframes nxSweep { to { transform: rotate(360deg); } }
.nx-radar-node circle { filter: drop-shadow(0 0 5px currentColor); }
.nx-radar-node { transition: transform .25s; transform-box: fill-box; transform-origin: center; }
.nx-radar-node:hover, .nx-radar-node:focus { transform: scale(1.5); }
.nx-graph-canvas { filter: drop-shadow(0 0 22px rgba(34,211,238,.12)); }
.nx-maturity-bar div, .nx-mem-bar div, .nx-term-bar div { transition: width 1s cubic-bezier(.2,.7,.2,1); }
.nx-codelab-terminal { position: relative; overflow: hidden; }
.nx-codelab-terminal::after { content: ""; position: absolute; inset: 0; pointer-events: none; background: radial-gradient(600px 200px at 50% 0%, rgba(232,196,122,.07), transparent 70%); }
input[type="range"] { cursor: pointer; }
.nx-slider-row input[type="range"]::-webkit-slider-thumb { box-shadow: 0 0 12px rgba(232,196,122,.7); }

/* ---------- 衬线阅读模式 ---------- */
.nx-settings-grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.25rem; }
.nx-settings-grid3 button { padding: 0.4rem; border-radius: 8px; background: rgba(255,255,255,0.05); text-align: center; font-family: var(--nx-font-mono); font-size: 0.65rem; }
.nx-settings-grid3 button.is-active { background: var(--nx-gold); color: #1a1206; font-weight: 700; }
.nx-article-body.nx-font-serif { font-family: Georgia, 'Times New Roman', 'Noto Serif SC', 'Songti SC', serif; letter-spacing: 0.01em; }
.nx-article-body.nx-font-serif p { text-align: justify; }
body.nx-reader-mode .nx-article-body.nx-font-serif { color: #e6dfcf; }

/* ---------- 图片 CLS / 渲染优化 ---------- */
.nx-card-media { aspect-ratio: 800 / 480; height: auto; min-height: 180px; }
.nx-card-media img { width: 100%; height: 100%; aspect-ratio: 800 / 480; }
.nx-reader-cover img { aspect-ratio: 21 / 9; min-height: 220px; }
.nx-card-wrap { content-visibility: auto; contain-intrinsic-size: auto 520px; }

/* ---------- View Transitions + 导航收隐 + 返回顶部 ---------- */
@view-transition { navigation: auto; }
::view-transition-old(root) { animation: nxVtOut .28s ease; }
::view-transition-new(root) { animation: nxVtIn .32s ease; }
@keyframes nxVtOut { to { opacity: 0; transform: translateY(10px); } }
@keyframes nxVtIn { from { opacity: 0; transform: translateY(10px); } }
.nx-navbar { transition: transform .35s cubic-bezier(.2,.7,.2,1), background .3s, padding .3s; }
.nx-navbar.nx-nav-hidden { transform: translateY(-110%); }
.nx-back-top { position: fixed; right: 1.2rem; bottom: 1.4rem; z-index: 65; width: 42px; height: 42px; border-radius: 12px; display: flex; align-items: center; justify-content: center; background: rgba(12,18,38,.85); border: 1px solid rgba(232,196,122,.4); color: var(--nx-gold); box-shadow: 0 12px 30px rgba(0,0,0,.5); backdrop-filter: blur(10px); }
.nx-back-top:hover { background: var(--nx-gold); color: #1a1206; }
.nx-back-top[hidden] { display: none !important; }

/* ---------- 浅色纸张阅读主题 ---------- */
body.nx-theme-light { background: #f4f1e8; color: #1c2333; }
body.nx-theme-light.nx-reader-mode { background: #f4f1e8; }
body.nx-theme-light .nx-reader-header { background: rgba(244,241,232,.9); border-bottom-color: rgba(28,35,51,.1); }
body.nx-theme-light .nx-reader-header-title { color: #4a5568; }
body.nx-theme-light .nx-article-body { color: #2b3348; }
body.nx-theme-light .nx-article-body strong { color: #111827; }
body.nx-theme-light .nx-article-heading { color: #8a6d2b; border-bottom-color: rgba(28,35,51,.12); }
body.nx-theme-light .nx-article-body h3 { color: #1c2333; }
body.nx-theme-light .nx-panel-sm, body.nx-theme-light .nx-callout-ai { background: #fffdf7; border-color: rgba(28,35,51,.12); box-shadow: 0 10px 30px -18px rgba(28,35,51,.35); }
body.nx-theme-light .nx-callout-head, body.nx-theme-light .nx-panel-sm-head { color: #8a6d2b; }
body.nx-theme-light .nx-takeaway-list p { color: #2b3348; }
body.nx-theme-light .nx-toc-nav a { color: #5b6577; }
body.nx-theme-light .nx-toc-nav a.is-active { background: rgba(138,109,43,.1); color: #8a6d2b; border-left-color: #b98a2e; }
body.nx-theme-light .nx-comment { background: #fffdf7; border-color: rgba(28,35,51,.1); }
body.nx-theme-light .nx-comment-body { color: #3c465c; }
body.nx-theme-light .nx-comment-form { background: #fffdf7; border-color: rgba(28,35,51,.12); }
body.nx-theme-light .nx-comment-form textarea, body.nx-theme-light .nx-comment-name-field input { background: #fff; border-color: rgba(28,35,51,.15); color: #1c2333; }
body.nx-theme-light .nx-ai-panel { background: #fffdf7; border-color: rgba(28,35,51,.12); }
body.nx-theme-light .nx-ai-msg.is-assistant { background: #f4f1e8; border-color: rgba(28,35,51,.1); color: #3c465c; }
body.nx-theme-light .nx-ai-input-row input { background: #fff; border-color: rgba(28,35,51,.15); color: #1c2333; }
body.nx-theme-light .nx-code-block-wrap, body.nx-theme-light .nx-term-console { background: #0d1326; }
body.nx-theme-light .nx-clap-btn { background: #fffdf7; border-color: rgba(28,35,51,.15); color: #8a6d2b; }
body.nx-theme-light .nx-reader-cover-caption h1 { color: #fff; }
body.nx-theme-light .nx-reader-cover-caption p { color: #dbe2ef; }

/* ---------- 搜索预览图 + 键盘焦点 ---------- */
.nx-search-result { gap: 0.8rem; }
.nx-search-result:focus { outline: none; border-color: var(--nx-gold); background: rgba(232,196,122,.07); }
.nx-search-thumb { width: 64px; height: 44px; object-fit: cover; border-radius: 8px; flex-shrink: 0; border: 1px solid rgba(255,255,255,.12); background: #0a1024; }
.nx-search-thumb-ph { display: flex; align-items: center; justify-content: center; font-family: var(--nx-display); font-size: .6rem; font-weight: 800; letter-spacing: .1em; color: var(--nx-gold); }
.nx-search-result > div { min-width: 0; flex: 1; }

/* ---------- 404 + 页脚收尾 ---------- */
.nx-404-panel { text-align: center; padding: 5rem 2rem 4rem; position: relative; overflow: hidden; background: linear-gradient(180deg, rgba(255,255,255,.035), rgba(255,255,255,.01)); border: 1px solid var(--nx-hair-soft); border-radius: 18px; }
.nx-404-panel::before { content: ""; position: absolute; top: 0; left: 0; right: 0; height: 1px; background: linear-gradient(90deg, transparent, rgba(232,196,122,.8), transparent); }
.nx-404-code { font-family: var(--nx-display); font-weight: 900; font-size: clamp(6rem, 18vw, 12rem); line-height: 1; letter-spacing: -0.04em; background: linear-gradient(180deg, #fff 20%, rgba(232,196,122,.75) 60%, rgba(232,196,122,.15) 100%); -webkit-background-clip: text; background-clip: text; color: transparent; }
.nx-404-sub { color: #8d99b0; margin: 1rem 0 1.8rem; }
.nx-404-actions { display: flex; gap: 0.8rem; justify-content: center; align-items: center; flex-wrap: wrap; }
.nx-404-actions kbd { font-size: 0.62rem; background: rgba(0,0,0,.4); padding: 0.1rem 0.35rem; border-radius: 6px; border: 1px solid rgba(255,255,255,.1); }
.nx-404-links { display: flex; gap: 1.4rem; justify-content: center; margin-top: 2rem; font-family: var(--nx-font-mono); font-size: 0.75rem; }
.nx-404-links a { color: #8d99b0; }
.nx-404-links a:hover { color: var(--nx-gold); }
.nx-footer { position: relative; }
.nx-footer::before { content: ""; position: absolute; top: -1px; left: 0; right: 0; height: 1px; background: linear-gradient(90deg, transparent, rgba(232,196,122,.6), transparent); }
.nx-footer-nominal { font-style: normal; display: inline-flex; align-items: center; gap: 0.35rem; color: var(--nx-gold); letter-spacing: 0.1em; margin-left: 0.6rem; }

/* ---------- Lab 纵深光球 + 透视地网 ---------- */
.nx-lab-orb { position: fixed; top: 0; left: 0; width: 520px; height: 520px; z-index: 1; pointer-events: none; border-radius: 999px; background: radial-gradient(circle, rgba(232,196,122,.1), rgba(34,211,238,.06) 45%, transparent 70%); filter: blur(40px); mix-blend-mode: screen; }
.nx-view-header { position: relative; }
.nx-view-header::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 120px; pointer-events: none; background-image: linear-gradient(rgba(255,255,255,.05) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.05) 1px, transparent 1px); background-size: 44px 44px; transform: perspective(500px) rotateX(48deg); transform-origin: bottom; mask-image: linear-gradient(to top, black 20%, transparent 90%); opacity: .6; }

/* ---------- Radar / Graph 3D ---------- */
#nx-radar-3d, #nx-graph-3d { position: relative; width: 100%; height: 520px; border-radius: 12px; overflow: hidden; cursor: grab; }
#nx-graph-3d { height: 540px; }
#nx-radar-3d:active, #nx-graph-3d:active { cursor: grabbing; }
#nx-radar-3d canvas, #nx-graph-3d canvas { display: block; width: 100% !important; height: 100% !important; }
.nx-3d-boot { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-family: var(--nx-font-mono); font-size: 0.7rem; letter-spacing: 0.14em; color: var(--nx-gold); }
/* 3D 接管后隐藏原 SVG/2D 画布（仍保留在 DOM 供爬虫与降级） */
.nx-3d-live svg.nx-radar-svg { display: none; }
.nx-3d-live #nx-graph-canvas { display: none; }
.nx-3d-hint { font-family: var(--nx-font-mono); font-size: 0.62rem; letter-spacing: 0.1em; color: #8d99b0; }

/* ---------- Code Lab 可视化 ---------- */
.nx-codelab-viz-panel { grid-column: 1 / -1; }
.nx-viz-body { display: grid; grid-template-columns: minmax(0, 1fr); gap: 1rem; }
.nx-viz-canvas { width: 100%; height: 220px; border-radius: 12px; background: #02040a; border: 1px solid rgba(232,196,122,.18); display: block; opacity: 0; transition: opacity .8s; }
.nx-viz-canvas.is-live { opacity: 1; }
.nx-viz-readout { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.6rem; }
.nx-viz-readout > div { padding: 0.6rem 0.75rem; border-radius: 10px; background: rgba(255,255,255,.03); border: 1px solid rgba(255,255,255,.08); display: flex; flex-direction: column; gap: 0.15rem; }
.nx-viz-readout span { font-family: var(--nx-font-mono); font-size: 0.6rem; letter-spacing: 0.1em; color: #8d99b0; }
.nx-viz-readout b { font-family: var(--nx-display); font-size: 1.05rem; color: var(--nx-gold); }
.nx-viz-note { grid-column: 1 / -1; font-family: var(--nx-font-mono); font-size: 0.62rem; color: #5b6577; }
@media (min-width: 1024px) { .nx-viz-body { grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); align-items: stretch; } .nx-viz-canvas { height: 100%; min-height: 220px; } .nx-viz-readout { align-content: start; } }

/* ---------- 命令面板美化 ---------- */
.nx-search-result mark { background: rgba(232,196,122,.28); color: var(--nx-gold-2, #f3d894); border-radius: 3px; padding: 0 1px; }
.nx-recent-row { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem; padding: 0.6rem 0.85rem; font-family: var(--nx-font-mono); font-size: 0.62rem; letter-spacing: 0.1em; color: #8d99b0; }
.nx-recent-row button { padding: 0.3rem 0.6rem; border-radius: 999px; border: 1px solid rgba(232,196,122,.35); color: var(--nx-gold); font-size: 0.68rem; letter-spacing: 0; }
.nx-recent-row button:hover { background: rgba(232,196,122,.12); }
.nx-search-foot { display: flex; align-items: center; gap: 1rem; padding: 0.55rem 1rem; border-top: 1px solid rgba(255,255,255,.07); background: rgba(0,0,0,.3); font-family: var(--nx-font-mono); font-size: 0.62rem; color: #8d99b0; }
.nx-search-foot kbd { font-size: 0.6rem; background: rgba(255,255,255,.07); padding: 0.08rem 0.32rem; border-radius: 5px; border: 1px solid rgba(255,255,255,.12); margin-right: 0.2rem; }
.nx-search-count { margin-left: auto; color: var(--nx-gold); font-weight: 700; }

/* ---------- 阅读章节进度 ---------- */
.nx-read-pct { position: fixed; top: 8px; right: 12px; z-index: 61; font-family: var(--nx-font-mono); font-size: 0.62rem; font-weight: 700; color: var(--nx-gold); background: rgba(8,12,26,.85); border: 1px solid rgba(232,196,122,.35); padding: 0.15rem 0.5rem; border-radius: 999px; }
.nx-read-pct.is-done { background: var(--nx-gold); color: #1a1206; }
.nx-toc-nav a.is-done { color: #6ee7b7; }
.nx-toc-nav a.is-done::before { content: "✓ "; color: #6ee7b7; font-weight: 700; }

/* ---------- 页脚巨字收尾 ---------- */
.nx-footer-giant { overflow: hidden; padding: 1.5rem 0 0; text-align: center; user-select: none; }
.nx-footer-giant span { display: inline-block; font-family: var(--nx-display); font-weight: 900; font-size: clamp(3.4rem, 12.5vw, 11rem); letter-spacing: 0.04em; line-height: 1; color: transparent; -webkit-text-stroke: 1px rgba(255,255,255,0.13); background: linear-gradient(100deg, rgba(232,196,122,0) 40%, rgba(232,196,122,.55) 50%, rgba(232,196,122,0) 60%); background-size: 250% 100%; -webkit-background-clip: text; background-clip: text; animation: nxGiantSweep 7s ease-in-out infinite; }
@keyframes nxGiantSweep { 0%,100% { background-position: 110% 0; } 50% { background-position: -10% 0; } }

/* ---------- 通用 ---------- */
.nx-card-media img, .nx-reader-cover img { background: #0a1024; }
@media (prefers-reduced-motion: reduce) {
  .nx-radar-sweep, .nx-bench-bar div::after { animation: none !important; }
  .nx-footer-giant span { animation: none !important; }
  #nx-particle-webgpu { display: none; }
}
@media (max-width: 768px) {
  .nx-article-body { font-size: .98rem; line-height: 1.85; }
  .nx-hero-terminal { margin-top: 1rem; }
}
