/* 大模型原理教学 - 样式表 */
:root {
    --bg: #0f1117; --bg-card: #1a1d27; --text: #e4e4e7; --text-dim: #9ca3af;
    --accent: #6366f1; --accent-light: #818cf8; --green: #22c55e; --red: #ef4444;
    --yellow: #eab308; --blue: #3b82f6; --border: #2d3148; --code-bg: #1e2030;
    --sidebar-w: 220px; --radius: 10px;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { font-family: 'Segoe UI','PingFang SC','Microsoft YaHei',sans-serif; background: var(--bg); color: var(--text); line-height: 1.7; display: flex; }

/* 侧边导航 */
.sidebar { position: fixed; top: 0; left: 0; width: var(--sidebar-w); height: 100vh; background: #13151f; border-right: 1px solid var(--border); padding: 20px 0; overflow-y: auto; z-index: 100; }
.nav-title { padding: 0 20px 16px; font-size: 15px; font-weight: 700; color: var(--accent-light); border-bottom: 1px solid var(--border); margin-bottom: 10px; }
.nav-link { display: block; padding: 8px 20px; color: var(--text-dim); text-decoration: none; font-size: 13px; transition: all 0.2s; border-left: 3px solid transparent; }
.nav-link:hover { color: var(--text); background: rgba(99,102,241,0.08); }
.nav-link.active { color: var(--accent-light); border-left-color: var(--accent); background: rgba(99,102,241,0.1); }

/* 主内容（.content 与裸 main 两种写法都要避让侧边栏并居中） */
.content, main {
    width: min(100%, 900px);
    margin-left: max(var(--sidebar-w), calc((100vw - var(--sidebar-w) - 900px) / 2));
    padding: 40px 50px;
}
.hero-section { text-align: center; padding: 80px 0 60px; }
.hero-section h1 { font-size: 42px; font-weight: 800; background: linear-gradient(135deg, var(--accent-light), #a78bfa, #f472b6); -webkit-background-clip: text; -webkit-text-fill-color: transparent; margin-bottom: 8px; }
.hero-section h2 { font-size: 22px; color: var(--text-dim); font-weight: 400; margin-bottom: 16px; }
.subtitle { color: var(--text-dim); font-size: 15px; margin-bottom: 24px; }
.chapter-tags { display: flex; justify-content: center; gap: 10px; margin-bottom: 32px; flex-wrap: wrap; }
.tag { background: rgba(99,102,241,0.15); color: var(--accent-light); padding: 4px 14px; border-radius: 20px; font-size: 13px; }
.intro-text { max-width: 600px; margin: 0 auto; color: var(--text-dim); font-size: 15px; line-height: 1.8; }

/* 章节 */
.section { padding: 60px 0 40px; border-top: 1px solid var(--border); }
.section h2 { font-size: 26px; font-weight: 700; margin-bottom: 16px; color: #fff; }
.lead { font-size: 16px; color: var(--text-dim); margin-bottom: 28px; line-height: 1.8; }
.lead strong { color: var(--accent-light); }

/* 概念框 */
.concept-box { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; margin: 24px 0; }
.concept-box h3 { font-size: 17px; color: var(--accent-light); margin-bottom: 12px; }
.concept-box p { color: var(--text-dim); line-height: 1.8; }

/* 交互框 */
.interactive-box { background: linear-gradient(135deg, rgba(99,102,241,0.06), rgba(139,92,246,0.04)); border: 1px solid rgba(99,102,241,0.25); border-radius: var(--radius); padding: 24px; margin: 28px 0; }
.interactive-box h3 { font-size: 17px; color: var(--yellow); margin-bottom: 10px; }
.interactive-box > p { color: var(--text-dim); font-size: 14px; margin-bottom: 16px; }

/* 按钮 */
.btn { background: var(--accent); color: #fff; border: none; padding: 8px 20px; border-radius: 6px; cursor: pointer; font-size: 14px; transition: all 0.2s; margin-right: 8px; margin-bottom: 8px; text-decoration: none; display: inline-block; }
.btn:hover { background: var(--accent-light); }
.btn.active { background: var(--accent-light); box-shadow: 0 0 12px rgba(99,102,241,0.4); }
.btn-secondary { background: #374151; }
.btn-secondary:hover { background: #4b5563; }

/* 关键要点 */
.key-point { background: rgba(34,197,94,0.08); border-left: 4px solid var(--green); padding: 16px 20px; border-radius: 0 var(--radius) var(--radius) 0; margin: 28px 0; font-size: 14px; color: var(--text); line-height: 1.8; }
.key-point code { background: var(--code-bg); padding: 2px 8px; border-radius: 4px; font-size: 13px; color: var(--yellow); }

/* Token */
.token-example { margin: 16px 0; }
.token-label { font-size: 13px; color: var(--text-dim); margin: 8px 0 4px; }
.token-text { font-size: 15px; color: var(--text); margin-bottom: 12px; }
.token-list { display: flex; gap: 6px; flex-wrap: wrap; }
.token { background: var(--accent); color: #fff; padding: 4px 12px; border-radius: 6px; font-size: 14px; transition: all 0.3s; }
.token.highlight { background: var(--yellow); color: #000; transform: scale(1.1); }
.token.predicted { background: var(--green); animation: popIn 0.3s ease; }
@keyframes popIn { 0% { transform: scale(0); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }

/* 生成演示 */
.gen-demo { background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 16px; margin: 12px 0; min-height: 80px; }
.gen-sequence { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 8px; }
.gen-prediction { font-size: 14px; color: var(--text-dim); min-height: 24px; }
.gen-explanation { font-size: 13px; color: var(--text-dim); margin-top: 12px; padding: 10px; background: var(--bg); border-radius: 6px; }

/* 错位法 */
.text-input { background: var(--bg); border: 1px solid var(--border); color: var(--text); padding: 10px 16px; border-radius: 6px; font-size: 15px; width: 100%; max-width: 400px; margin-right: 10px; margin-bottom: 10px; }
.text-input:focus { outline: none; border-color: var(--accent); }
.shift-result { margin-top: 16px; }
.shift-row { display: flex; align-items: center; gap: 8px; margin: 6px 0; font-size: 13px; animation: fadeSlide 0.3s ease; }
@keyframes fadeSlide { 0% { opacity: 0; transform: translateX(-10px); } 100% { opacity: 1; transform: translateX(0); } }
.shift-label { color: var(--text-dim); min-width: 50px; }
.shift-tokens { display: flex; gap: 3px; flex-wrap: wrap; }
.shift-token { background: var(--code-bg); padding: 2px 8px; border-radius: 4px; font-size: 13px; }
.shift-token.target { background: var(--green); color: #fff; }
.shift-token.dim { opacity: 0.3; }
.shift-arrow { color: var(--yellow); font-size: 16px; margin: 0 6px; }

/* 对比网格 */
.comparison-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 16px; }
.compare-card { padding: 16px; border-radius: 8px; border: 1px solid var(--border); }
.compare-card h4 { font-size: 14px; margin-bottom: 8px; }
.compare-card p { font-size: 13px; color: var(--text-dim); line-height: 1.6; }
.compare-bad { background: rgba(239,68,68,0.06); border-color: rgba(239,68,68,0.2); }
.compare-good { background: rgba(34,197,94,0.06); border-color: rgba(34,197,94,0.2); }

/* 掩码矩阵 */
.mask-grid-container { display: flex; justify-content: center; margin: 16px 0; overflow-x: auto; }
.mask-grid { display: grid; gap: 2px; }
.mask-cell { width: 48px; height: 48px; display: flex; align-items: center; justify-content: center; font-size: 13px; border-radius: 4px; cursor: pointer; transition: all 0.15s; user-select: none; }
.mask-cell.header { background: var(--accent); color: #fff; font-weight: 600; cursor: default; }
.mask-cell.visible { background: rgba(34,197,94,0.2); color: var(--green); }
.mask-cell.hidden-cell { background: rgba(239,68,68,0.1); color: rgba(239,68,68,0.4); }
.mask-cell.current { background: var(--yellow); color: #000; font-weight: 700; }
.mask-cell.clickable:hover { transform: scale(1.08); }
.mask-cell.row-label { background: var(--accent); color: #fff; font-weight: 600; cursor: pointer; }
.mask-cell.row-label:hover { background: var(--accent-light); }
.mask-explanation { display: flex; gap: 20px; justify-content: center; margin-top: 12px; flex-wrap: wrap; }
.mask-legend { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-dim); }
.legend-box { width: 16px; height: 16px; border-radius: 3px; display: inline-block; }
.legend-box.visible { background: rgba(34,197,94,0.3); }
.legend-box.hidden { background: rgba(239,68,68,0.15); }
.legend-box.current { background: var(--yellow); }

/* ─── Packing 块对角掩码矩阵 ─── */
.pack-selector { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.pack-selector .btn { font-size: 12px; padding: 5px 14px; margin: 0; }
.pack-mask-wrap { display: flex; justify-content: center; margin: 10px 0; overflow-x: auto; padding: 4px; }
.pack-mask-grid { display: grid; gap: 2px; }
.pm-cell { width: 26px; height: 26px; display: flex; align-items: center; justify-content: center; font-size: 11px; border-radius: 3px; user-select: none; }
.pm-corner { background: transparent; }
.pm-head { background: rgba(99,102,241,0.22); color: #c7d2fe; font-weight: 600; font-size: 10px; }
.pm-rowhead { background: rgba(99,102,241,0.22); color: #c7d2fe; font-weight: 600; font-size: 10px; cursor: pointer; width: 100%; }
.pm-rowhead:hover { background: rgba(99,102,241,0.45); }
.pm-visible { background: rgba(34,197,94,0.22); color: #4ade80; }
.pm-future { background: rgba(239,68,68,0.10); color: rgba(239,68,68,0.42); }
.pm-cross { background: rgba(168,85,247,0.14); color: rgba(192,132,252,0.55); }
.pm-pad { background: rgba(107,114,128,0.12); color: rgba(156,163,175,0.5); }
.pm-block-gap { box-shadow: inset 2px 0 0 #f59e0b; }
.pm-active-row { outline: 1px solid rgba(234,179,8,0.7); outline-offset: -1px; }
.pack-mask-legend { display: flex; gap: 16px; justify-content: center; flex-wrap: wrap; margin-top: 6px; }
.pm-explain { display: flex; gap: 16px; justify-content: center; flex-wrap: wrap; font-size: 12.5px; color: var(--text-dim); margin-top: 10px; line-height: 1.7; }
.pm-note { margin-top: 14px; font-size: 12px; color: var(--text-dim); line-height: 1.8; padding: 12px 14px; background: var(--code-bg); border-radius: 8px; border-left: 3px solid var(--yellow); }
.pm-note code { background: rgba(99,102,241,0.15); padding: 1px 6px; border-radius: 4px; color: var(--accent-light); }
.legend-box.pm-visible { background: rgba(34,197,94,0.35); }
.legend-box.pm-future { background: rgba(239,68,68,0.22); }
.legend-box.pm-cross { background: rgba(168,85,247,0.35); }
.legend-box.pm-pad { background: rgba(107,114,128,0.3); }

/* 等价 */
.equivalence { display: flex; align-items: center; justify-content: center; gap: 24px; margin: 16px 0; flex-wrap: wrap; }
.equiv-left, .equiv-right { text-align: center; }
.equiv-left h4, .equiv-right h4 { font-size: 14px; color: var(--text-dim); margin-bottom: 8px; }
.equiv-arrow { font-size: 32px; color: var(--yellow); font-weight: 700; }
.equiv-sample { background: var(--code-bg); padding: 4px 12px; border-radius: 4px; font-size: 13px; margin: 4px 0; font-family: monospace; }
.equiv-sample.big { padding: 12px 20px; font-size: 15px; color: var(--green); background: rgba(34,197,94,0.1); }

/* Batch */
.batch-viz { display: grid; gap: 8px; margin: 16px 0; }
.batch-row { display: flex; gap: 3px; align-items: center; padding: 8px; background: var(--bg); border-radius: 6px; border: 1px solid var(--border); flex-wrap: wrap; }
.batch-label { min-width: 50px; font-size: 12px; color: var(--text-dim); }
.batch-token { background: var(--code-bg); padding: 3px 8px; border-radius: 3px; font-size: 12px; min-width: 28px; text-align: center; }
.batch-token.loss { border-bottom: 2px solid var(--green); }
.batch-token.pad { background: rgba(239,68,68,0.08); color: rgba(239,68,68,0.5); border: 1px dashed rgba(239,68,68,0.3); font-size: 10px; }
.batch-token.eos { background: rgba(239,68,68,0.15); color: var(--red); border: 1px solid rgba(239,68,68,0.4); font-size: 10px; font-weight: 700; }
.batch-token.mask-on { background: rgba(34,197,94,0.15); color: var(--green); font-size: 10px; min-width: 24px; border: 1px solid rgba(34,197,94,0.3); }
.batch-token.mask-off { background: rgba(239,68,68,0.08); color: rgba(239,68,68,0.4); font-size: 10px; min-width: 24px; border: 1px dashed rgba(239,68,68,0.2); }
.batch-info { font-size: 14px; color: var(--text-dim); margin-top: 12px; }

/* 表格 */
.scale-table, .arch-table, .evolution-table { width: 100%; border-collapse: collapse; margin-top: 12px; font-size: 14px; }
.scale-table th, .arch-table th, .evolution-table th { background: var(--accent); color: #fff; padding: 10px 14px; text-align: left; font-weight: 600; }
.scale-table td, .arch-table td, .evolution-table td { padding: 10px 14px; border-bottom: 1px solid var(--border); }
.scale-table tr:hover td, .arch-table tr:hover td, .evolution-table tr:hover td { background: rgba(99,102,241,0.05); }

/* 架构切换 */
.arch-buttons { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.arch-viz { background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 24px; min-height: 160px; margin-bottom: 12px; }
.arch-row { display: flex; align-items: center; gap: 4px; margin: 10px 0; justify-content: center; flex-wrap: wrap; }
.arch-token { padding: 8px 14px; border-radius: 6px; font-size: 15px; font-weight: 600; transition: all 0.3s; }
.arch-token.source { background: var(--accent); color: #fff; }
.arch-token.target { background: var(--yellow); color: #000; }
.arch-token.future-visible { background: rgba(239,68,68,0.3); color: var(--red); }
.arch-token.future-hidden { background: rgba(239,68,68,0.1); color: rgba(239,68,68,0.3); text-decoration: line-through; }
.arch-arrow-viz { font-size: 18px; color: var(--green); margin: 0 2px; }
.arch-desc { font-size: 14px; color: var(--text-dim); line-height: 1.8; padding: 12px; background: var(--bg); border-radius: 6px; }

/* Transformer SVG */
.arch-svg { width: 100%; max-width: 800px; display: block; margin: 0 auto; }
.arch-block { cursor: pointer; transition: all 0.2s; }
.arch-block:hover { filter: brightness(1.2); }
.output-block { fill: #7c3aed; } .linear-block { fill: #6d28d9; }
.layer-block { fill: rgba(99,102,241,0.1); stroke: var(--accent); stroke-width: 2; }
.norm-block { fill: #374151; } .ffn-block { fill: #2563eb; }
.attn-block { fill: #dc2626; } .pos-block { fill: #0891b2; }
.embed-block { fill: #059669; } .input-block { fill: #4b5563; }
.arch-text { fill: #fff; font-size: 16px; font-weight: 600; }
.arch-text-small { fill: #fff; font-size: 14px; font-weight: 500; }
.arch-text-tiny { fill: rgba(255,255,255,0.6); font-size: 11px; }
.arch-arrow { stroke: var(--text-dim); stroke-width: 2; }
.arch-arrow-head { fill: var(--text-dim); }
.residual-line { fill: none; stroke: var(--yellow); stroke-width: 2; stroke-dasharray: 6,4; cursor: pointer; }
.arch-annotation { fill: var(--text-dim); font-size: 12px; font-style: italic; }
.arch-info-panel { background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 16px; margin-top: 12px; font-size: 14px; color: var(--text-dim); line-height: 1.8; min-height: 60px; }
.arch-info-panel h4 { color: var(--accent-light); margin-bottom: 8px; }

/* 胜出原因 */
.reasons-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 14px; margin-top: 16px; }
.reason-card { background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 20px; transition: all 0.2s; }
.reason-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.reason-num { display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; background: var(--accent); color: #fff; border-radius: 50%; font-size: 14px; font-weight: 700; margin-bottom: 10px; }
.reason-card h4 { font-size: 15px; margin-bottom: 8px; color: #fff; }
.reason-card p { font-size: 13px; color: var(--text-dim); line-height: 1.7; }

/* 两栏 */
.two-column { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-top: 16px; }
.col-unchanged, .col-changed { padding: 16px; border-radius: 8px; }
.col-unchanged { background: rgba(34,197,94,0.06); border: 1px solid rgba(34,197,94,0.2); }
.col-changed { background: rgba(59,130,246,0.06); border: 1px solid rgba(59,130,246,0.2); }
.col-unchanged h4, .col-changed h4 { font-size: 14px; margin-bottom: 10px; }
.col-unchanged li, .col-changed li { font-size: 13px; color: var(--text-dim); margin: 4px 0; line-height: 1.6; }

/* 总结 */
.summary-item { background: var(--bg-card); border: 1px solid var(--border); border-radius: 8px; padding: 16px 20px; margin: 10px 0; font-size: 14px; line-height: 1.8; transition: all 0.2s; }
.summary-item:hover { border-color: var(--accent); }
.summary-item strong { color: var(--accent-light); }
.next-chapter { text-align: center; margin-top: 48px; padding: 32px; background: linear-gradient(135deg, rgba(99,102,241,0.08), rgba(139,92,246,0.05)); border-radius: var(--radius); border: 1px solid rgba(99,102,241,0.2); }
.next-chapter p { font-size: 16px; color: var(--text); }
.coming-soon { color: var(--text-dim); font-size: 14px; margin-top: 8px; }

/* ═══ Token → 向量流水线 ═══ */
.embedding-pipeline { display: flex; align-items: flex-start; gap: 8px; overflow-x: auto; padding: 16px 0; }
.pipe-step { background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 14px; min-width: 140px; flex-shrink: 0; }
.pipe-final { border-color: var(--green); background: rgba(34,197,94,0.05); }
.pipe-title { font-size: 12px; color: var(--accent-light); font-weight: 600; margin-bottom: 8px; white-space: nowrap; }
.pipe-content { font-size: 13px; }
.pipe-text { font-size: 16px; color: #fff; }
.pipe-tokens { display: flex; flex-direction: column; gap: 4px; }
.pipe-tok { background: var(--code-bg); padding: 2px 8px; border-radius: 4px; display: flex; justify-content: space-between; gap: 8px; }
.tok-id { font-size: 10px; color: var(--text-dim); }
.pipe-arrow { font-size: 20px; color: var(--yellow); font-weight: 700; padding-top: 30px; flex-shrink: 0; }

/* Embedding 矩阵 */
.embed-matrix { font-family: monospace; font-size: 11px; }
.matrix-row { display: flex; gap: 6px; margin: 3px 0; align-items: center; }
.matrix-label { background: var(--accent); color: #fff; padding: 1px 6px; border-radius: 3px; min-width: 20px; text-align: center; font-size: 12px; }
.matrix-vals { color: var(--text-dim); }
.dim-row .matrix-vals { color: var(--yellow); font-style: italic; }

/* 位置编码 */
.pos-formula { color: var(--green); font-weight: 600; margin-bottom: 8px; font-size: 14px; }
.pos-detail { font-size: 12px; color: var(--text-dim); line-height: 1.6; }
.pos-tag { display: inline-block; background: var(--code-bg); padding: 1px 6px; border-radius: 3px; color: var(--accent-light); margin-right: 4px; font-family: monospace; }
.pos-detail-note { margin-top: 6px; color: var(--yellow); font-size: 11px; }

/* 最终向量 */
.final-vectors { display: flex; gap: 8px; margin-bottom: 8px; }
.vec-box { text-align: center; }
.vec-token { background: var(--green); color: #fff; padding: 4px 12px; border-radius: 4px; font-weight: 600; }
.vec-dim { font-size: 10px; color: var(--text-dim); margin-top: 2px; }
.final-note { font-size: 12px; color: var(--yellow); }

.key-insight { font-size: 13px; color: var(--text-dim); margin-top: 14px; padding: 10px 14px; background: rgba(34,197,94,0.06); border-radius: 6px; border-left: 3px solid var(--green); line-height: 1.7; }
.key-insight strong { color: var(--green); }

/* ═══ 注意力机制可视化 ═══ */
.attention-viz { display: flex; flex-direction: column; gap: 20px; }
.attn-scene-title { text-align: center; font-size: 15px; color: #fff; padding: 12px; background: var(--bg); border-radius: 8px; border: 1px solid var(--border); }
.attn-highlight { color: var(--yellow); font-weight: 700; }

.attn-step { background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 16px; }
.attn-step-title { font-size: 14px; color: var(--accent-light); font-weight: 600; margin-bottom: 12px; }
.attn-note { font-size: 12px; color: var(--text-dim); margin-top: 10px; padding: 8px; background: var(--code-bg); border-radius: 4px; line-height: 1.6; }
.attn-note strong { color: var(--yellow); }

/* QKV 表 */
.qkv-table { width: 100%; font-size: 13px; }
.qkv-header { display: grid; grid-template-columns: 60px 1fr 1fr 1fr; gap: 4px; margin-bottom: 6px; font-weight: 600; font-size: 12px; color: var(--text-dim); }
.qkv-row { display: grid; grid-template-columns: 60px 1fr 1fr 1fr; gap: 4px; margin: 3px 0; }
.qkv-cell { padding: 6px 8px; background: var(--code-bg); border-radius: 4px; text-align: center; }
.q-color { color: #f472b6; } .k-color { color: #60a5fa; } .v-color { color: #34d399; }
.attn-current .qkv-cell { background: rgba(234,179,8,0.1); }
.attn-current .q-color { background: rgba(244,114,182,0.15); font-weight: 700; }

/* 相关性分数 */
.score-desc { font-size: 13px; color: var(--text-dim); margin-bottom: 10px; }
.score-rows { display: flex; flex-direction: column; gap: 8px; }
.score-row { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.score-calc { font-family: monospace; color: var(--accent-light); min-width: 70px; white-space: nowrap; }
.score-eq { color: var(--text-dim); }
.score-val { color: var(--yellow); font-weight: 700; min-width: 30px; }
.score-bar { flex: 1; height: 18px; background: var(--code-bg); border-radius: 9px; overflow: hidden; max-width: 120px; }
.score-fill { height: 100%; background: linear-gradient(90deg, var(--accent), var(--yellow)); border-radius: 9px; transition: width 0.5s; }
.score-meaning { font-size: 12px; color: var(--text-dim); min-width: 180px; }

/* Softmax */
.softmax-flow { display: flex; align-items: center; gap: 8px; justify-content: center; flex-wrap: wrap; }
.softmax-col { background: var(--code-bg); border-radius: 6px; padding: 10px; min-width: 120px; }
.softmax-label { font-size: 11px; color: var(--text-dim); margin-bottom: 6px; text-align: center; }
.softmax-vals { display: flex; flex-direction: column; gap: 4px; }
.sv { font-family: monospace; font-size: 14px; text-align: center; padding: 4px; border-radius: 4px; }
.highlight-sv { background: rgba(234,179,8,0.15); color: var(--yellow); font-weight: 700; }
.sv-pct { font-size: 11px; color: var(--text-dim); }
.sv-mean { font-size: 12px; color: var(--text-dim); font-family: inherit; }
.softmax-arrow-col { text-align: center; }
.softmax-arrow { font-size: 24px; color: var(--yellow); }
.softmax-arrow-label { font-size: 10px; color: var(--text-dim); }

/* 加权求和 */
.ws-formula { text-align: center; font-size: 15px; padding: 14px; background: var(--code-bg); border-radius: 8px; margin-bottom: 10px; }
.ws-result { color: var(--green); font-weight: 700; }
.ws-eq { color: var(--text-dim); margin: 0 6px; }
.ws-term { color: var(--text); }
.ws-weight { color: var(--yellow); font-weight: 700; }
.ws-plus { color: var(--text-dim); margin: 0 4px; }
.ws-highlight { background: rgba(234,179,8,0.1); padding: 2px 8px; border-radius: 4px; }
.ws-explain { font-size: 13px; color: var(--text-dim); line-height: 1.7; text-align: center; }
.ws-explain strong { color: var(--yellow); }

/* 注意力总结 */
.attn-summary { background: linear-gradient(135deg, rgba(99,102,241,0.08), rgba(34,197,94,0.05)); border: 1px solid var(--accent); border-radius: 10px; padding: 20px; text-align: center; }
.attn-summary-title { font-size: 15px; color: #fff; font-weight: 600; margin-bottom: 10px; }
.attn-summary-text { font-size: 14px; line-height: 2; }
.as-q { color: #f472b6; font-weight: 600; } .as-k { color: #60a5fa; font-weight: 600; }
.as-v { color: #34d399; font-weight: 600; } .as-softmax { color: var(--yellow); font-weight: 600; }
.attn-summary-sub { margin-top: 12px; font-size: 13px; color: var(--text-dim); line-height: 1.7; }

/* ═══ 数学洞察卡片 ═══ */
.math-insight-card {
    margin: 24px 0; border: 2px solid var(--yellow); border-radius: 14px;
    background: linear-gradient(135deg, rgba(234,179,8,0.04), rgba(234,179,8,0.01));
    overflow: hidden;
}
.math-insight-header {
    display: flex; align-items: center; gap: 10px;
    padding: 14px 20px; background: rgba(234,179,8,0.1);
    border-bottom: 1px solid rgba(234,179,8,0.2);
}
.math-insight-icon { font-size: 22px; }
.math-insight-title { font-size: 15px; font-weight: 700; color: var(--yellow); }
.math-insight-sub { font-size: 12px; color: var(--text-dim); margin-left: 8px; }
.math-insight-body { padding: 20px; }

/* 步骤流 */
.math-steps { display: flex; flex-direction: column; gap: 14px; margin: 16px 0; }
.math-step-item {
    display: flex; gap: 14px; align-items: flex-start;
    padding: 12px 16px; border-radius: 10px;
    background: var(--code-bg); border-left: 3px solid var(--accent);
}
.math-step-item.highlight { border-left-color: var(--green); }
.math-step-item.key { border-left-color: var(--yellow); }
.math-step-num {
    width: 28px; height: 28px; border-radius: 50%;
    background: var(--accent); color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-size: 13px; font-weight: 700; flex-shrink: 0;
}
.math-step-item.highlight .math-step-num { background: var(--green); }
.math-step-item.key .math-step-num { background: var(--yellow); color: #000; }
.math-step-content { flex: 1; }
.math-step-label { font-size: 13px; font-weight: 700; color: #fff; margin-bottom: 4px; }
.math-step-desc { font-size: 12px; color: var(--text-dim); line-height: 1.7; }
.math-step-formula {
    display: inline-block; margin-top: 6px; padding: 4px 12px;
    background: rgba(234,179,8,0.1); border-radius: 6px;
    font-size: 14px; font-weight: 600; color: var(--yellow);
    font-family: 'Consolas', 'Courier New', monospace;
}

/* 对比可视化 */
.math-viz-compare {
    display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin: 16px 0;
}
.math-viz-panel {
    padding: 14px; border-radius: 10px; background: var(--code-bg);
}
.math-viz-panel.bad { border: 1px solid rgba(239,68,68,0.3); }
.math-viz-panel.good { border: 2px solid var(--green); background: rgba(34,197,94,0.03); }
.math-viz-title { font-size: 12px; font-weight: 700; margin-bottom: 10px; text-align: center; }
.math-viz-title.red { color: var(--red); }
.math-viz-title.green { color: var(--green); }
.math-viz-bars { display: flex; flex-direction: column; gap: 6px; }
.math-viz-bar-row { display: flex; align-items: center; gap: 6px; }
.math-viz-bar-label { font-size: 10px; color: var(--text-dim); min-width: 32px; text-align: right; }
.math-viz-bar-track { flex: 1; height: 14px; background: rgba(255,255,255,0.04); border-radius: 7px; overflow: hidden; }
.math-viz-bar-fill { height: 100%; border-radius: 7px; transition: width 1s ease; }
.math-viz-bar-val { font-size: 10px; color: var(--text-dim); min-width: 36px; }

/* 底部总结 */
.math-takeaway {
    margin-top: 14px; padding: 10px 16px; border-radius: 8px;
    background: rgba(234,179,8,0.08); font-size: 13px; color: var(--text);
    line-height: 1.7;
}
.math-takeaway strong { color: var(--yellow); }

/* ═══ 上下文窗口可视化 ═══ */
.ctx-window-bar {
    display: flex; height: 36px; border-radius: 8px; overflow: hidden; margin: 10px 0;
}
.ctx-bar-seg {
    display: flex; align-items: center; justify-content: center;
    font-size: 12px; font-weight: 600; white-space: nowrap; padding: 0 8px;
}
.ctx-bar-seg.prompt { background: rgba(99,102,241,0.4); color: var(--accent-light); }
.ctx-bar-seg.output { background: rgba(34,197,94,0.3); color: var(--green); }
.ctx-bar-seg.unused { background: rgba(255,255,255,0.05); color: var(--text-dim); font-size: 11px; }
.ctx-formula {
    text-align: center; font-size: 13px; color: var(--text); padding: 8px 0;
}
.ctx-formula strong { color: var(--yellow); }
.ctx-scenarios {
    display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 12px 0;
}
.ctx-scenario {
    background: var(--code-bg); border-radius: 8px; padding: 12px 14px;
}
.ctx-scenario.ok { border: 1px solid rgba(34,197,94,0.3); }
.ctx-scenario.warn { border: 1px solid rgba(239,68,68,0.3); }
.ctx-scenario-title { font-size: 13px; font-weight: 700; margin-bottom: 6px; }
.ctx-scenario-title.green { color: var(--green); }
.ctx-scenario-title.red { color: var(--red); }
.ctx-scenario-detail { font-size: 12px; color: var(--text-dim); line-height: 1.8; }
.ctx-wrapper {
    background: var(--code-bg); border-radius: 10px; padding: 16px; margin: 12px 0;
}
.ctx-wrapper .ctx-caption {
    font-size: 12px; color: var(--text-dim); margin-bottom: 6px;
}
.math-insight-body > p {
    font-size: 13px; color: var(--text); margin-bottom: 14px;
}

/* ═══ §8 现代架构对比卡 ═══ */
.arch-compare-section {
    margin-top: 32px;
}
.arch-compare-section > h3 {
    font-size: 18px; color: #fff; font-weight: 700; margin-bottom: 12px;
}
.arch-compare-section > .arch-compare-intro {
    color: var(--text-dim); margin-bottom: 16px; font-size: 14px;
}
.arch-compare-grid {
    display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 20px;
}
.arch-compare-card {
    background: var(--code-bg); border-radius: 10px; padding: 16px;
    border: 1px solid rgba(239,68,68,0.3);
}
.arch-compare-card.modern {
    background: rgba(34,197,94,0.03); border: 2px solid var(--green);
}
.arch-compare-card-title {
    font-size: 14px; font-weight: 700; margin-bottom: 10px; text-align: center;
}
.arch-compare-card-title.classic { color: var(--red); }
.arch-compare-card-title.modern { color: var(--green); }
.arch-compare-layers {
    display: flex; flex-direction: column; gap: 4px;
}
.arch-layer {
    padding: 6px 8px; border-radius: 6px; font-size: 12px; text-align: center;
}
.arch-layer.input-layer {
    background: rgba(255,255,255,0.03); color: var(--text-dim); border-radius: 4px;
}
.arch-layer.attn-layer {
    background: rgba(99,102,241,0.08); border-left: 3px solid var(--accent);
}
.arch-layer.ffn-layer {
    background: rgba(99,102,241,0.08); border-left: 3px solid var(--accent);
}
.arch-layer.modern-attn {
    background: rgba(34,197,94,0.08); border-left: 3px solid var(--green);
}
.arch-layer.modern-ffn {
    background: rgba(34,197,94,0.08); border-left: 3px solid var(--green);
}
.arch-layer-main {
    font-size: 11px; color: var(--text); font-weight: 600;
}
.arch-layer-sub {
    font-size: 10px; color: var(--text-dim); margin-top: 2px;
}
.arch-improvements {
    background: rgba(234,179,8,0.08); padding: 12px 16px; border-radius: 8px;
    font-size: 13px; color: var(--text); line-height: 1.8;
}
.arch-improvements strong { color: var(--yellow); }
.arch-improvements a { color: var(--accent-light); }

@media (max-width: 600px) {
    .ctx-scenarios { grid-template-columns: 1fr; }
    .ctx-bar-seg { font-size: 10px; }
    .arch-compare-grid { grid-template-columns: 1fr; }
}

/* RoPE 旋转可视化 */
.rope-viz { display: flex; justify-content: center; align-items: center; gap: 30px; margin: 16px 0; flex-wrap: wrap; }
.rope-circle { position: relative; width: 160px; height: 160px; }
.rope-explain { max-width: 280px; font-size: 12px; color: var(--text-dim); line-height: 1.8; }
.rope-explain strong { color: var(--accent-light); }

@media (max-width: 900px) {
    .sidebar { display: none; }
    .content, main { margin-left: 0; width: 100%; max-width: 900px; padding: 20px; }
    .comparison-grid { grid-template-columns: 1fr; }
    .two-column { grid-template-columns: 1fr; }
    .equivalence { flex-direction: column; }
    .math-viz-compare { grid-template-columns: 1fr; }
    .rope-viz { flex-direction: column; }
}
