/* ============== 全局变量 ============== */
:root {
    --bg-dark: #0a0e1a;
    --bg-deep: #050811;
    --bg-card: #131828;
    --bg-card-2: #1a2138;
    --primary: #4ade80;
    --primary-glow: #4ade8044;
    --accent: #38bdf8;
    --accent-2: #a78bfa;
    --danger: #f87171;
    --warning: #fbbf24;
    --evil: #ec4899;
    --text: #e2e8f0;
    --text-dim: #94a3b8;
    --text-faint: #64748b;
    --border: #1e293b;
    --border-light: #334155;
    --code-bg: #0d1117;
    --gradient: linear-gradient(135deg, #4ade80 0%, #38bdf8 50%, #a78bfa 100%);
    --gradient-evil: linear-gradient(135deg, #ec4899 0%, #f87171 100%);
    --shadow-sm: 0 2px 8px rgba(0,0,0,0.3);
    --shadow-md: 0 8px 24px rgba(0,0,0,0.4);
    --shadow-lg: 0 16px 48px rgba(0,0,0,0.5);
    --shadow-glow: 0 0 40px rgba(74, 222, 128, 0.15);
}

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

html { scroll-behavior: smooth; }

body {
    font-family: 'Noto Sans SC', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-dark);
    color: var(--text);
    line-height: 1.7;
    overflow-x: hidden;
}

code, pre, .mono { font-family: 'JetBrains Mono', 'Courier New', monospace; }

/* ============== 通用容器 ============== */
.container {
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 32px;
}

/* ============== 导航栏 ============== */
.navbar {
    position: fixed;
    top: 0; left: 0; right: 0;
    z-index: 1000;
    background: rgba(10, 14, 26, 0.85);
    backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border);
    transition: all 0.3s;
}

.nav-inner {
    max-width: 1400px;
    margin: 0 auto;
    padding: 14px 32px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    font-weight: 700;
    font-size: 17px;
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text);
}

.logo-icon {
    font-size: 24px;
    filter: drop-shadow(0 0 12px var(--primary-glow));
}

.nav-links {
    display: flex;
    gap: 8px;
    list-style: none;
}

.nav-link {
    color: var(--text-dim);
    text-decoration: none;
    font-size: 14px;
    padding: 8px 14px;
    border-radius: 8px;
    transition: all 0.2s;
    font-weight: 500;
}

.nav-link:hover, .nav-link.active {
    color: var(--primary);
    background: var(--primary-glow);
}

/* ============== Hero 区 ============== */
.hero {
    min-height: 100vh;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    padding: 80px 32px 0;
}

.hero-bg {
    position: absolute;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
}

.grid-bg {
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(rgba(74, 222, 128, 0.05) 1px, transparent 1px),
        linear-gradient(90deg, rgba(74, 222, 128, 0.05) 1px, transparent 1px);
    background-size: 50px 50px;
    mask-image: radial-gradient(ellipse at center, #000 0%, transparent 70%);
}

.floating-hex {
    position: absolute;
    font-family: 'JetBrains Mono', monospace;
    color: var(--primary);
    opacity: 0.15;
    font-weight: 700;
    letter-spacing: 2px;
    user-select: none;
    animation: floatHex 18s linear infinite;
}

.hex1 { top: 10%; left: 10%; font-size: 28px; animation-delay: 0s; }
.hex2 { top: 20%; right: 15%; font-size: 22px; animation-delay: -3s; color: var(--accent); }
.hex3 { top: 65%; left: 8%; font-size: 26px; animation-delay: -6s; color: var(--accent-2); }
.hex4 { bottom: 15%; right: 10%; font-size: 30px; animation-delay: -9s; }
.hex5 { top: 45%; left: 50%; font-size: 36px; animation-delay: -12s; opacity: 0.1; color: var(--accent); }
.hex6 { bottom: 25%; left: 35%; font-size: 24px; animation-delay: -15s; color: var(--evil); opacity: 0.12; }

@keyframes floatHex {
    0%, 100% { transform: translate(0, 0) rotate(0deg); }
    25% { transform: translate(30px, -20px) rotate(5deg); }
    50% { transform: translate(-20px, 30px) rotate(-3deg); }
    75% { transform: translate(20px, 10px) rotate(2deg); }
}

.hero-content {
    position: relative;
    z-index: 2;
    text-align: center;
    max-width: 900px;
}

.badge-pulse {
    display: inline-block;
    padding: 8px 20px;
    background: rgba(248, 113, 113, 0.1);
    border: 1px solid var(--danger);
    border-radius: 100px;
    color: var(--danger);
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 32px;
    animation: pulseBadge 2s ease-in-out infinite;
}

@keyframes pulseBadge {
    0%, 100% { box-shadow: 0 0 0 0 rgba(248, 113, 113, 0.4); }
    50% { box-shadow: 0 0 0 12px rgba(248, 113, 113, 0); }
}

.hero-title {
    font-size: clamp(42px, 7vw, 88px);
    font-weight: 900;
    line-height: 1.1;
    margin-bottom: 20px;
    letter-spacing: -2px;
}

.gradient-text {
    background: var(--gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    background-size: 200% 200%;
    animation: gradientShift 8s ease infinite;
}

@keyframes gradientShift {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

.hero-subtitle {
    font-size: 20px;
    color: var(--text-dim);
    font-family: 'JetBrains Mono', monospace;
    margin-bottom: 28px;
    letter-spacing: 1px;
}

.hero-desc {
    font-size: 18px;
    color: var(--text-dim);
    margin-bottom: 40px;
    line-height: 1.9;
}

.hero-cta {
    display: flex;
    gap: 16px;
    justify-content: center;
    margin-bottom: 60px;
    flex-wrap: wrap;
}

.btn-primary {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 16px 36px;
    background: var(--gradient);
    color: #0a0e1a;
    text-decoration: none;
    border-radius: 12px;
    font-weight: 700;
    font-size: 16px;
    transition: all 0.3s;
    box-shadow: 0 8px 32px rgba(74, 222, 128, 0.3);
    border: none;
    cursor: pointer;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 40px rgba(74, 222, 128, 0.5);
}

.btn-primary .arrow { transition: transform 0.3s; }
.btn-primary:hover .arrow { transform: translateX(6px); }

.btn-secondary {
    display: inline-flex;
    align-items: center;
    padding: 16px 36px;
    background: rgba(255,255,255,0.05);
    color: var(--text);
    text-decoration: none;
    border: 1px solid var(--border-light);
    border-radius: 12px;
    font-weight: 500;
    font-size: 16px;
    transition: all 0.3s;
}

.btn-secondary:hover {
    background: rgba(255,255,255,0.08);
    border-color: var(--primary);
    color: var(--primary);
}

.hero-stats {
    display: flex;
    gap: 60px;
    justify-content: center;
    flex-wrap: wrap;
}

.stat-num {
    font-family: 'JetBrains Mono', monospace;
    font-size: 36px;
    font-weight: 700;
    color: var(--primary);
    line-height: 1;
}

.stat-label {
    color: var(--text-faint);
    font-size: 13px;
    margin-top: 6px;
}

.scroll-hint {
    position: absolute;
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%);
    text-align: center;
    color: var(--text-faint);
    font-size: 12px;
    animation: bounce 2s infinite;
}

.scroll-hint span { display: block; margin-bottom: 8px; }

.mouse {
    width: 22px;
    height: 36px;
    border: 2px solid var(--text-faint);
    border-radius: 12px;
    position: relative;
    margin: 0 auto;
}

.wheel {
    width: 3px;
    height: 8px;
    background: var(--primary);
    border-radius: 2px;
    position: absolute;
    top: 6px;
    left: 50%;
    transform: translateX(-50%);
    animation: wheel 1.5s ease-in-out infinite;
}

@keyframes wheel {
    0% { opacity: 1; transform: translate(-50%, 0); }
    100% { opacity: 0; transform: translate(-50%, 14px); }
}

@keyframes bounce {
    0%, 100% { transform: translate(-50%, 0); }
    50% { transform: translate(-50%, -10px); }
}

/* ============== 章节通用 ============== */
.chapter {
    padding: 100px 0;
    position: relative;
}

.chapter-alt {
    background: linear-gradient(180deg, var(--bg-deep) 0%, var(--bg-dark) 100%);
}

.chapter-header {
    text-align: center;
    margin-bottom: 70px;
    max-width: 800px;
    margin-left: auto;
    margin-right: auto;
}

.chapter-num {
    display: inline-block;
    font-family: 'JetBrains Mono', monospace;
    font-size: 13px;
    color: var(--primary);
    letter-spacing: 4px;
    margin-bottom: 16px;
    padding: 6px 16px;
    background: var(--primary-glow);
    border-radius: 6px;
}

.chapter-header h2 {
    font-size: clamp(32px, 4.5vw, 48px);
    font-weight: 800;
    margin-bottom: 20px;
    line-height: 1.2;
    letter-spacing: -1px;
}

.chapter-sub {
    font-size: 17px;
    color: var(--text-dim);
}

/* ============== 第 1 章: Story Card ============== */
.story-card {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 32px;
    margin-bottom: 60px;
}

.story-text {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 32px;
}

.story-text h3 {
    font-size: 22px;
    margin-bottom: 16px;
    color: var(--accent);
}

.story-text p { margin-bottom: 14px; }

.story-list {
    list-style: none;
    margin: 16px 0;
}

.story-list li {
    padding: 10px 0 10px 28px;
    position: relative;
    color: var(--text-dim);
}

.story-list li::before {
    content: "▸";
    color: var(--primary);
    position: absolute;
    left: 6px;
    font-size: 16px;
}

.story-note {
    margin-top: 20px;
    padding: 16px;
    background: rgba(251, 191, 36, 0.08);
    border-left: 3px solid var(--warning);
    border-radius: 6px;
}

.warn { color: var(--danger); }

.story-code {
    background: var(--code-bg);
    border-radius: 16px;
    overflow: hidden;
    border: 1px solid var(--border);
}

.code-header {
    background: #161b22;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 6px;
    border-bottom: 1px solid var(--border);
}

.dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    display: inline-block;
}
.dot.red { background: #ff5f56; }
.dot.yellow { background: #ffbd2e; }
.dot.green { background: #27c93f; }
.code-title {
    margin-left: 16px;
    font-size: 13px;
    color: var(--text-faint);
    font-family: 'JetBrains Mono', monospace;
}

.story-code pre {
    padding: 24px;
    font-size: 14px;
    line-height: 1.8;
    overflow-x: auto;
}

.story-code .kw { color: #ff7b72; }
.story-code .str { color: #a5d6ff; }
.story-code .cmt { color: #8b949e; font-style: italic; }
.story-code .fn { color: #d2a8ff; }

.key-code {
    color: var(--warning);
    background: rgba(251, 191, 36, 0.1);
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 0.92em;
}

/* Attack Preview */
.attack-preview {
    background: linear-gradient(135deg, var(--bg-card) 0%, var(--bg-card-2) 100%);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 40px;
}

.ap-title {
    text-align: center;
    font-size: 24px;
    margin-bottom: 30px;
}

.ap-flow {
    display: flex;
    align-items: stretch;
    gap: 20px;
    justify-content: center;
    flex-wrap: wrap;
    margin-bottom: 30px;
}

.ap-step {
    flex: 1;
    min-width: 280px;
    background: var(--bg-deep);
    border: 1px solid var(--border-light);
    border-radius: 14px;
    padding: 24px;
    display: flex;
    gap: 16px;
    align-items: flex-start;
}

.ap-step-evil {
    border-color: var(--evil);
    background: linear-gradient(135deg, var(--bg-deep) 0%, rgba(236, 72, 153, 0.08) 100%);
}

.ap-step-icon {
    font-size: 36px;
    flex-shrink: 0;
}

.ap-arrow {
    font-size: 32px;
    color: var(--primary);
    align-self: center;
    font-weight: 700;
}

.mini-mono {
    margin-top: 10px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
    color: var(--text-dim);
    background: rgba(0,0,0,0.4);
    padding: 10px 12px;
    border-radius: 6px;
    word-break: break-all;
}

.ap-shock {
    text-align: center;
    font-size: 17px;
    color: var(--text);
    padding: 20px;
    background: rgba(236, 72, 153, 0.08);
    border-radius: 12px;
    border-left: 4px solid var(--evil);
}

/* ============== 第 2 章: Sub Section ============== */
.sub-section {
    margin-bottom: 80px;
}

.sub-title {
    font-size: 26px;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 14px;
    font-weight: 700;
}

.num-tag {
    font-family: 'JetBrains Mono', monospace;
    font-size: 16px;
    color: var(--primary);
    background: var(--primary-glow);
    padding: 4px 10px;
    border-radius: 6px;
    font-weight: 700;
}

.sub-desc {
    color: var(--text-dim);
    margin-bottom: 30px;
    font-size: 16px;
}

/* ============== Merkle-Damgård 纵向流水线（详细展开） ============== */
.md-vert {
    background: linear-gradient(180deg, var(--bg-card) 0%, var(--bg-deep) 100%);
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 32px clamp(14px, 2.5vw, 36px);
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 18px;
}

/* 顶部消息条 */
.mdv-msg-strip {
    background: var(--bg-card-2);
    border: 1px dashed var(--border-light);
    border-radius: 12px;
    padding: 14px 16px 16px;
}
.mdv-strip-title {
    font-size: 12px;
    color: var(--text-faint);
    letter-spacing: 1px;
    text-transform: uppercase;
    margin-bottom: 10px;
    text-align: center;
}
.mdv-strip-blocks {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}
.mdv-msg-card {
    background: rgba(56, 189, 248, 0.06);
    border: 1px solid var(--accent);
    border-radius: 10px;
    padding: 10px 12px;
    position: relative;
    transition: all 0.4s;
    opacity: 0.45;
}
.mdv-msg-card.consumed {
    opacity: 0.25;
    filter: grayscale(0.6);
}
.mdv-msg-card.active {
    opacity: 1;
    box-shadow: 0 0 24px rgba(56, 189, 248, 0.45);
    transform: translateY(-2px);
}
.mdv-msg-card-tag {
    font-family: 'JetBrains Mono', monospace;
    color: var(--accent);
    font-weight: 800;
    font-size: 14px;
    margin-bottom: 4px;
}
.mdv-msg-card-hex {
    font-family: 'JetBrains Mono', monospace;
    font-size: 10.5px;
    color: var(--text-dim);
    line-height: 1.5;
    word-break: break-all;
    max-height: 3em;
    overflow: hidden;
}
.mdv-msg-card-bits {
    font-size: 10px;
    color: var(--text-faint);
    margin-top: 6px;
}

/* 状态卡（IV / 中间状态 / 最终哈希） */
.mdv-state {
    background: var(--bg-card-2);
    border: 2px solid var(--border-light);
    border-radius: 14px;
    padding: 14px 18px;
    position: relative;
    transition: all 0.5s;
}
.mdv-state-iv { border-color: var(--accent); }
.mdv-state-mid { border-color: var(--primary); }
.mdv-state-final {
    border-color: var(--primary);
    background: linear-gradient(135deg, rgba(74, 222, 128, 0.08), rgba(56, 189, 248, 0.06));
}
.mdv-state.flash {
    box-shadow: 0 0 0 4px var(--primary-glow), 0 0 40px var(--primary-glow);
    transform: scale(1.01);
}

.mdv-state-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 10px;
    flex-wrap: wrap;
    gap: 8px;
}
.mdv-state-name {
    font-weight: 700;
    color: var(--text);
    font-size: 14px;
    letter-spacing: 0.5px;
}
.mdv-state-bits {
    font-size: 11px;
    color: var(--text-faint);
}

.mdv-words {
    display: grid;
    grid-template-columns: repeat(8, minmax(0, 1fr));
    gap: 6px;
}
.mdv-word {
    background: var(--bg-deep);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 6px 4px 5px;
    text-align: center;
    font-family: 'JetBrains Mono', monospace;
    transition: all 0.3s;
    min-width: 0;
}
.mdv-word i {
    display: block;
    font-style: normal;
    font-size: 10px;
    color: var(--text-faint);
    margin-bottom: 2px;
}
.mdv-word b {
    display: block;
    font-size: clamp(9px, 0.85vw, 11px);
    color: var(--primary);
    font-weight: 700;
    letter-spacing: 0.4px;
    overflow: hidden;
    text-overflow: ellipsis;
}
.mdv-word.updated {
    background: rgba(74, 222, 128, 0.15);
    border-color: var(--primary);
    transform: scale(1.04);
}
.mdv-word.updated b { color: #c5f7d8; }

/* 三个 stage 容器 */
.mdv-stages {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* 单个 stage（压缩函数 f 的展开） */
.mdv-stage {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 20px clamp(14px, 2vw, 24px) 22px;
    position: relative;
    transition: all 0.4s;
    opacity: 0.55;
}
.mdv-stage.active {
    opacity: 1;
    border-color: var(--primary);
    box-shadow: 0 12px 36px rgba(74, 222, 128, 0.12), 0 0 0 1px var(--primary-glow) inset;
}
.mdv-stage.done { opacity: 0.85; }

.mdv-stage-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    flex-wrap: wrap;
    gap: 8px;
}
.mdv-stage-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 15px;
    font-weight: 700;
    color: var(--text);
}
.mdv-stage-num {
    width: 28px; height: 28px;
    background: var(--primary);
    color: #051a0c;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 800;
}
.mdv-stage-formula {
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
    color: var(--text-dim);
    background: var(--bg-deep);
    padding: 4px 10px;
    border-radius: 999px;
    border: 1px solid var(--border);
}

/* 压缩函数 f 内部主体：左输入 - 中处理 - 右输入 */
.mdv-f-body {
    display: grid;
    grid-template-columns: 1fr 1.4fr 1fr;
    gap: 14px;
    align-items: stretch;
}
.mdv-f-col {
    background: var(--bg-card-2);
    border: 1px solid var(--border-light);
    border-radius: 12px;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-width: 0;
}
.mdv-f-col-title {
    font-size: 11px;
    color: var(--text-faint);
    letter-spacing: 1px;
    text-transform: uppercase;
    text-align: center;
}
.mdv-f-col-sub {
    font-size: 10px;
    color: var(--text-faint);
    text-align: center;
    margin-top: -4px;
}
.mdv-f-input-state .mdv-words { grid-template-columns: repeat(4, 1fr); }
.mdv-f-input-msg .mdv-msg-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 4px;
}
.mdv-w-cell {
    background: var(--bg-deep);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 4px 2px;
    text-align: center;
    font-family: 'JetBrains Mono', monospace;
    font-size: 9.5px;
    color: var(--accent);
    transition: all 0.3s;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.mdv-w-cell.expanded { background: rgba(56, 189, 248, 0.18); border-color: var(--accent); color: #cdf3ff; }
.mdv-w-cell.current  { background: rgba(245, 191, 0, 0.22); border-color: #fbbf24; color: #fde68a; box-shadow: 0 0 10px rgba(245, 191, 0, 0.45); }

/* 中央：64 轮压缩 */
.mdv-f-core {
    background: linear-gradient(160deg, rgba(74, 222, 128, 0.04), rgba(56, 189, 248, 0.04));
    border: 1px dashed var(--border-light);
    border-radius: 12px;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-width: 0;
}
.mdv-f-core-title {
    font-size: 11px;
    color: var(--text-faint);
    letter-spacing: 1px;
    text-transform: uppercase;
    text-align: center;
}
.mdv-rounds {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 3px;
}
.mdv-round {
    aspect-ratio: 1;
    background: var(--bg-deep);
    border: 1px solid var(--border);
    border-radius: 3px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 8px;
    color: var(--text-faint);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}
.mdv-round.fired {
    background: rgba(74, 222, 128, 0.5);
    border-color: var(--primary);
    color: #051a0c;
    font-weight: 800;
    box-shadow: 0 0 6px var(--primary-glow);
}
.mdv-round.now {
    background: #fbbf24;
    border-color: #fbbf24;
    color: #2a1b00;
    transform: scale(1.35);
    z-index: 2;
    box-shadow: 0 0 12px rgba(251, 191, 36, 0.8);
}

.mdv-round-formula {
    background: var(--bg-deep);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px 10px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 10.5px;
    color: var(--text-dim);
    line-height: 1.55;
    overflow: hidden;
}
.mdv-round-formula em {
    color: var(--accent);
    font-style: normal;
}
.mdv-round-formula strong {
    color: var(--primary);
    font-weight: 700;
}
.mdv-round-counter {
    display: flex;
    justify-content: space-between;
    font-size: 10px;
    color: var(--text-faint);
}
.mdv-round-counter b { color: var(--primary); font-family: 'JetBrains Mono', monospace; font-size: 12px; }

/* working state a..h 在中央底部展示 */
.mdv-working {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 4px;
}
.mdv-working .mdv-w-cell { font-size: 9px; }

/* stage 输出箭头 */
.mdv-stage-output {
    margin-top: 14px;
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--bg-deep);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 10px 14px;
    transition: all 0.4s;
}
.mdv-stage-output.lit {
    border-color: var(--primary);
    background: linear-gradient(90deg, rgba(74, 222, 128, 0.08), transparent);
}
.mdv-stage-output-label {
    font-size: 11px;
    color: var(--text-faint);
    letter-spacing: 1px;
    text-transform: uppercase;
    flex-shrink: 0;
}
.mdv-stage-output-formula {
    font-family: 'JetBrains Mono', monospace;
    font-size: 11.5px;
    color: var(--accent);
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* 状态导线（连接 stage 之间的纵向虚线） */
.mdv-wire {
    align-self: center;
    width: 2px;
    height: 22px;
    background: repeating-linear-gradient(
        180deg,
        var(--border-light) 0 4px,
        transparent 4px 8px
    );
    position: relative;
}
.mdv-wire::after {
    content: "";
    position: absolute;
    bottom: -3px;
    left: 50%;
    transform: translateX(-50%);
    border-top: 8px solid var(--border-light);
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
}
.mdv-wire.active { background: repeating-linear-gradient(180deg, var(--primary) 0 4px, transparent 4px 8px); }
.mdv-wire.active::after { border-top-color: var(--primary); }

/* 控制条 */
.md-control {
    margin-top: 8px;
    display: flex;
    gap: 12px;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
}
.md-control-hint {
    font-size: 12px;
    color: var(--text-faint);
    margin-left: 8px;
}

.btn-play, .btn-reset {
    padding: 10px 24px;
    background: var(--bg-card-2);
    border: 1px solid var(--border-light);
    color: var(--text);
    border-radius: 8px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s;
    font-size: 14px;
}

.btn-play:hover { border-color: var(--primary); color: var(--primary); }
.btn-reset:hover { border-color: var(--accent); color: var(--accent); }
.btn-play:disabled { opacity: 0.5; cursor: not-allowed; }

.md-keypoint {
    margin-top: 30px;
    background: linear-gradient(135deg, rgba(74, 222, 128, 0.05) 0%, rgba(56, 189, 248, 0.05) 100%);
    border: 1px solid rgba(74, 222, 128, 0.3);
    border-radius: 14px;
    padding: 24px;
    display: flex;
    gap: 18px;
    align-items: flex-start;
}

.kp-icon { font-size: 32px; flex-shrink: 0; }
.kp-text strong { color: var(--primary); }
.bug-tag {
    display: inline-block;
    margin-left: 8px;
    padding: 2px 10px;
    background: var(--evil);
    color: white;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 1px;
}

/* Padding 演示 */
.padding-rules {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.rule-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 24px;
    transition: transform 0.3s, border-color 0.3s;
}

.rule-card:hover {
    transform: translateY(-4px);
    border-color: var(--primary);
}

.rule-step {
    width: 36px;
    height: 36px;
    background: var(--gradient);
    color: var(--bg-dark);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 18px;
    margin-bottom: 14px;
}

.rule-card h4 { margin-bottom: 8px; font-size: 16px; }
.rule-card p { color: var(--text-dim); font-size: 14px; }
.rule-card code {
    background: var(--code-bg);
    padding: 2px 6px;
    border-radius: 4px;
    color: var(--accent);
    font-size: 0.9em;
}

.padding-demo {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 28px;
}

.pd-input { margin-bottom: 24px; }
.pd-input label {
    display: block;
    margin-bottom: 10px;
    color: var(--text-dim);
    font-size: 14px;
}

.pd-input-row {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.pd-input-row input {
    flex: 1;
    min-width: 200px;
    padding: 12px 16px;
    background: var(--bg-deep);
    border: 1px solid var(--border-light);
    color: var(--text);
    border-radius: 8px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 14px;
}

.pd-input-row input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

.btn-primary-small {
    padding: 12px 20px;
    background: var(--gradient);
    color: var(--bg-dark);
    border: none;
    border-radius: 8px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 14px;
    white-space: nowrap;
}

.btn-primary-small:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(74, 222, 128, 0.3);
}

.btn-evil { background: var(--gradient-evil); color: white; }
.btn-evil:hover { box-shadow: 0 6px 20px rgba(236, 72, 153, 0.4); }
.btn-verify { background: linear-gradient(135deg, #38bdf8, #a78bfa); color: white; }

.pd-output { background: var(--code-bg); border-radius: 8px; padding: 18px; }
.pd-line {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 12px;
    align-items: center;
}

.pd-label {
    color: var(--text-faint);
    font-size: 13px;
    min-width: 180px;
}

.pd-content {
    font-family: 'JetBrains Mono', monospace;
    color: var(--text);
    font-size: 13px;
}

.pd-padded { flex-direction: column; align-items: flex-start; }
.pd-padded .pd-label { margin-bottom: 8px; }

.pd-bytes {
    display: grid;
    grid-template-columns: repeat(16, 1fr);
    gap: 4px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    width: 100%;
}

.pd-byte {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    font-weight: 600;
    transition: transform 0.2s;
    cursor: default;
    min-height: 32px;
}

.pd-byte:hover { transform: scale(1.15); z-index: 2; }

.byte-orig { background: rgba(74, 222, 128, 0.25); color: #4ade80; }
.byte-one { background: rgba(251, 191, 36, 0.4); color: #fbbf24; box-shadow: 0 0 8px rgba(251, 191, 36, 0.5); }
.byte-zero { background: rgba(100, 116, 139, 0.2); color: #64748b; }
.byte-len { background: rgba(236, 72, 153, 0.3); color: #ec4899; }

.pd-legend {
    margin-top: 16px;
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    font-size: 12px;
}

.tag-orig { color: #4ade80; }
.tag-one { color: #fbbf24; }
.tag-zero { color: #64748b; }
.tag-len { color: #ec4899; }

/* State viz */
.state-viz {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 30px;
    margin-bottom: 24px;
}

.state-grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 10px;
    margin-bottom: 20px;
}

.state-cell {
    background: var(--bg-deep);
    border: 1px solid var(--border-light);
    border-radius: 8px;
    padding: 14px 8px;
    text-align: center;
}

.cell-label {
    font-size: 12px;
    color: var(--text-faint);
    margin-bottom: 6px;
    font-family: 'JetBrains Mono', monospace;
}

.cell-val {
    font-family: 'JetBrains Mono', monospace;
    color: var(--accent);
    font-weight: 700;
    font-size: 13px;
}

.state-caption { color: var(--text-dim); font-size: 14px; text-align: center; }

.state-output {
    text-align: center;
    margin: 24px 0;
}

.so-arrow {
    color: var(--primary);
    font-size: 14px;
    margin-bottom: 10px;
    font-weight: 600;
    letter-spacing: 1px;
}

.so-result {
    display: inline-block;
    padding: 14px 24px;
    background: linear-gradient(135deg, var(--primary-glow) 0%, rgba(56, 189, 248, 0.15) 100%);
    border: 1px solid var(--primary);
    border-radius: 12px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 15px;
    color: var(--primary);
    font-weight: 600;
}

.so-emph { color: var(--warning); }

.state-warning {
    background: linear-gradient(135deg, rgba(248, 113, 113, 0.08) 0%, rgba(236, 72, 153, 0.08) 100%);
    border: 1px solid rgba(248, 113, 113, 0.4);
    border-radius: 14px;
    padding: 24px;
    display: flex;
    gap: 18px;
    align-items: center;
}

.sw-icon { font-size: 36px; flex-shrink: 0; }

/* ============== 第 3 章 ============== */
.reveal-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 24px;
    margin-bottom: 50px;
}

.reveal-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 30px;
    position: relative;
    overflow: hidden;
    transition: transform 0.3s;
}

.reveal-card::before {
    content: "";
    position: absolute;
    top: 0; left: 0;
    width: 4px; height: 100%;
    background: var(--gradient);
}

.reveal-card:hover { transform: translateY(-6px); }

.rc-num {
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
    color: var(--primary);
    letter-spacing: 2px;
    margin-bottom: 12px;
}

.reveal-card h3 { font-size: 20px; margin-bottom: 14px; }
.reveal-card p { color: var(--text-dim); font-size: 14px; }

.aha-moment {
    background: linear-gradient(135deg, var(--bg-card) 0%, rgba(167, 139, 250, 0.08) 100%);
    border: 1px solid var(--accent-2);
    border-radius: 20px;
    padding: 40px;
    text-align: center;
    box-shadow: 0 0 60px rgba(167, 139, 250, 0.1);
}

.aha-bulb {
    font-size: 56px;
    margin-bottom: 12px;
    animation: bulbGlow 2s ease-in-out infinite;
}

@keyframes bulbGlow {
    0%, 100% { filter: drop-shadow(0 0 16px rgba(251, 191, 36, 0.5)); }
    50% { filter: drop-shadow(0 0 32px rgba(251, 191, 36, 0.9)); }
}

.aha-moment h3 {
    font-size: 28px;
    margin-bottom: 20px;
    color: var(--accent-2);
}

.aha-text {
    text-align: left;
    max-width: 800px;
    margin: 0 auto 24px;
    font-size: 16px;
    line-height: 2;
}

.aha-text .ck { color: var(--warning); background: rgba(251, 191, 36, 0.1); padding: 2px 6px; border-radius: 4px; }

.formula-box {
    background: var(--code-bg);
    border-radius: 14px;
    padding: 24px;
    text-align: left;
    max-width: 800px;
    margin: 0 auto;
}

.formula-line {
    color: var(--text-faint);
    font-size: 13px;
    margin: 12px 0 6px;
}

.formula {
    font-family: 'JetBrains Mono', monospace;
    font-size: 15px;
    padding: 12px;
    background: var(--bg-deep);
    border-radius: 8px;
    overflow-x: auto;
    white-space: nowrap;
}

.f-secret { color: var(--warning); padding: 2px 6px; background: rgba(251, 191, 36, 0.1); border-radius: 4px; }
.f-data { color: var(--accent); }
.f-pad { color: var(--text-faint); font-style: italic; }
.f-evil { color: var(--evil); padding: 2px 6px; background: rgba(236, 72, 153, 0.1); border-radius: 4px; }
.f-hash { color: var(--primary); font-weight: 700; }

.formula-note {
    color: var(--text-dim);
    font-size: 14px;
    margin-top: 16px;
    text-align: center;
    line-height: 1.7;
}

/* ============== 第 4 章 ============== */
.attack-setup {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 30px;
    margin-bottom: 40px;
}

.attack-setup h3 { margin-bottom: 20px; font-size: 20px; }

.setup-grid { display: flex; flex-direction: column; gap: 14px; }

.setup-row {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    padding: 14px;
    background: var(--bg-deep);
    border-radius: 8px;
    align-items: center;
}

.setup-label {
    color: var(--text-dim);
    font-size: 13px;
    min-width: 220px;
}

.setup-val {
    flex: 1;
    font-family: 'JetBrains Mono', monospace;
    font-size: 13px;
    color: var(--text);
    word-break: break-all;
}

.secret-val { color: var(--warning); }
.token-val { color: var(--primary); }
.evil-val { color: var(--evil); }

.hidden-tag, .hint-tag {
    display: inline-block;
    margin-left: 10px;
    padding: 2px 8px;
    background: rgba(100, 116, 139, 0.2);
    border-radius: 4px;
    font-size: 11px;
    color: var(--text-faint);
}

.attack-stage {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 30px;
}

.stage-controls {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 24px;
    padding-bottom: 24px;
    border-bottom: 1px solid var(--border);
}

.btn-stage {
    padding: 10px 22px;
    background: var(--bg-card-2);
    border: 1px solid var(--border-light);
    color: var(--text);
    border-radius: 8px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s;
}

.btn-stage:not(:disabled):hover {
    border-color: var(--primary);
    color: var(--primary);
}

.btn-stage:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-stage-reset:not(:disabled):hover {
    border-color: var(--danger);
    color: var(--danger);
}

.stage-speed {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-dim);
    font-size: 14px;
}

.stage-speed select {
    padding: 6px 10px;
    background: var(--bg-deep);
    color: var(--text);
    border: 1px solid var(--border-light);
    border-radius: 6px;
    cursor: pointer;
}

.stage-progress {
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    margin-bottom: 30px;
    overflow: hidden;
}

.stage-progress-bar {
    height: 100%;
    background: var(--gradient);
    width: 0%;
    transition: width 0.5s ease;
}

.stage-step {
    display: flex;
    gap: 24px;
    margin-bottom: 24px;
    opacity: 0.35;
    transition: all 0.5s;
}

.stage-step.active { opacity: 1; }
.stage-step.done { opacity: 0.7; }

.step-marker {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    background: var(--bg-card-2);
    border: 2px solid var(--border-light);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: var(--text-dim);
    transition: all 0.3s;
    margin-top: 6px;
}

.stage-step.active .step-marker {
    background: var(--gradient);
    color: var(--bg-dark);
    border-color: transparent;
    box-shadow: 0 0 24px var(--primary-glow);
    transform: scale(1.1);
}

.stage-step.done .step-marker {
    background: var(--primary);
    color: var(--bg-dark);
    border-color: transparent;
}

.step-card {
    flex: 1;
    background: var(--bg-deep);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 24px;
}

.stage-step.active .step-card {
    border-color: var(--primary);
    box-shadow: 0 0 30px var(--primary-glow);
}

.step-card h4 { font-size: 18px; margin-bottom: 10px; }
.step-desc { color: var(--text-dim); font-size: 14px; margin-bottom: 16px; line-height: 1.8; }

.step-canvas {
    background: var(--code-bg);
    border-radius: 10px;
    padding: 20px;
    min-height: 80px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 13px;
    overflow-x: auto;
}

.step-canvas:empty::before {
    content: "（点击播放查看动画）";
    color: var(--text-faint);
    font-style: italic;
}

.step-bomb {
    color: var(--danger);
    font-weight: 700;
    font-size: 16px;
}

/* Step canvas 内部的可视化字节块 */
.byte-row {
    display: flex;
    flex-wrap: wrap;
    gap: 3px;
    margin-bottom: 6px;
    align-items: center;
}

.byte-row-label {
    color: var(--text-faint);
    font-size: 11px;
    width: 100px;
    flex-shrink: 0;
}

.byte-cell {
    padding: 4px 6px;
    border-radius: 3px;
    font-size: 11px;
    font-weight: 600;
    min-width: 28px;
    text-align: center;
    animation: byteFadeIn 0.4s ease-out;
}

@keyframes byteFadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.byte-cell.bc-secret { background: rgba(251, 191, 36, 0.3); color: #fbbf24; }
.byte-cell.bc-data { background: rgba(74, 222, 128, 0.25); color: #4ade80; }
.byte-cell.bc-pad-one { background: rgba(168, 85, 247, 0.4); color: #c084fc; box-shadow: 0 0 8px rgba(168, 85, 247, 0.5); }
.byte-cell.bc-pad-zero { background: rgba(100, 116, 139, 0.2); color: #64748b; }
.byte-cell.bc-pad-len { background: rgba(56, 189, 248, 0.3); color: #38bdf8; }
.byte-cell.bc-evil { background: rgba(236, 72, 153, 0.35); color: #ec4899; }

.canvas-line { margin: 8px 0; line-height: 1.7; }
.canvas-label { color: var(--text-faint); font-size: 12px; margin-bottom: 6px; letter-spacing: 1px; }
.canvas-value { color: var(--primary); word-break: break-all; }
.canvas-arrow { text-align: center; color: var(--primary); margin: 10px 0; font-size: 18px; }

.state-row-display {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 6px;
    margin: 10px 0;
}

.state-display-cell {
    background: var(--bg-card-2);
    border: 1px solid var(--accent);
    padding: 10px 4px;
    border-radius: 6px;
    text-align: center;
    font-size: 11px;
    animation: byteFadeIn 0.4s;
}

.state-display-cell .l { color: var(--text-faint); font-size: 10px; }
.state-display-cell .v { color: var(--accent); font-weight: 700; margin-top: 2px; font-size: 12px; }

.success-banner {
    background: linear-gradient(135deg, rgba(74, 222, 128, 0.15), rgba(74, 222, 128, 0.05));
    border: 1px solid var(--primary);
    border-radius: 10px;
    padding: 16px;
    color: var(--primary);
    margin-top: 12px;
    font-weight: 600;
    text-align: center;
    animation: successPulse 1s;
}

@keyframes successPulse {
    0% { transform: scale(0.95); opacity: 0; }
    50% { transform: scale(1.02); }
    100% { transform: scale(1); opacity: 1; }
}

/* ============== 第 5 章: 实验室 ============== */
.lab {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    margin-bottom: 40px;
}

.lab-side {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 30px;
}

.lab-side h3 { margin-bottom: 20px; font-size: 20px; }

.lab-field { margin-bottom: 18px; }
.lab-field label {
    display: block;
    margin-bottom: 8px;
    font-size: 13px;
    color: var(--text-dim);
}

.lab-field code {
    color: var(--accent);
    background: rgba(56, 189, 248, 0.1);
    padding: 1px 5px;
    border-radius: 4px;
    font-size: 0.9em;
}

.lab-field input {
    width: 100%;
    padding: 12px 14px;
    background: var(--bg-deep);
    border: 1px solid var(--border-light);
    color: var(--text);
    border-radius: 8px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 13px;
    transition: all 0.2s;
}

.lab-field input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

.lab-field input[readonly] {
    color: var(--primary);
    background: var(--code-bg);
}

.lab-hint {
    color: var(--text-faint);
    font-size: 11px;
    margin-left: 8px;
    font-style: italic;
}

.secret-field input { color: var(--warning); }

.lab-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 24px;
}

.lab-result-block {
    margin-bottom: 18px;
    padding: 14px;
    background: var(--bg-deep);
    border-radius: 8px;
}

.result-label {
    font-size: 12px;
    color: var(--text-faint);
    margin-bottom: 6px;
}

.result-val {
    font-family: 'JetBrains Mono', monospace;
    font-size: 13px;
    color: var(--text);
    word-break: break-all;
    line-height: 1.6;
}

.result-verdict {
    font-family: 'JetBrains Mono', monospace;
    font-size: 16px;
    font-weight: 700;
    padding: 8px;
    border-radius: 6px;
    text-align: center;
}

.result-verdict.verdict-success {
    color: var(--primary);
    background: rgba(74, 222, 128, 0.1);
    border: 1px solid var(--primary);
}

.result-verdict.verdict-fail {
    color: var(--danger);
    background: rgba(248, 113, 113, 0.1);
    border: 1px solid var(--danger);
}

.lab-explain {
    margin-top: 20px;
    padding: 16px;
    background: linear-gradient(135deg, rgba(56, 189, 248, 0.05), rgba(167, 139, 250, 0.05));
    border-left: 3px solid var(--accent);
    border-radius: 6px;
    color: var(--text-dim);
    font-size: 14px;
    line-height: 1.8;
}

.lab-explain p { margin-bottom: 8px; }

.brute-section {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 30px;
}

.brute-section h3 { margin-bottom: 12px; font-size: 22px; }
.brute-section p { color: var(--text-dim); margin-bottom: 20px; }

.brute-controls { margin-bottom: 20px; }

.brute-table {
    background: var(--code-bg);
    border-radius: 10px;
    padding: 16px;
    max-height: 380px;
    overflow-y: auto;
    font-family: 'JetBrains Mono', monospace;
    font-size: 13px;
}

.brute-row {
    display: grid;
    grid-template-columns: 70px 1fr 80px;
    gap: 12px;
    padding: 6px 8px;
    border-radius: 4px;
    align-items: center;
    animation: byteFadeIn 0.3s;
}

.brute-row:hover { background: var(--bg-card-2); }

.brute-row.match {
    background: rgba(74, 222, 128, 0.15) !important;
    border-left: 3px solid var(--primary);
    font-weight: 700;
}

.brute-len { color: var(--text-faint); }
.brute-hash { color: var(--text-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.brute-status { text-align: right; }
.brute-status.s-yes { color: var(--primary); }
.brute-status.s-no { color: var(--text-faint); }

/* ============== 第 6 章: 防御 ============== */
.defense-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 20px;
    margin-bottom: 40px;
}

.defense-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 24px;
    position: relative;
    transition: transform 0.3s;
}

.defense-card:hover { transform: translateY(-4px); }

.def-status {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 100px;
    font-size: 12px;
    margin-bottom: 14px;
    font-weight: 600;
}

.defense-bad { border-color: rgba(248, 113, 113, 0.3); }
.defense-bad .def-status { background: rgba(248, 113, 113, 0.15); color: var(--danger); }

.defense-meh { border-color: rgba(251, 191, 36, 0.3); }
.defense-meh .def-status { background: rgba(251, 191, 36, 0.15); color: var(--warning); }

.defense-good { border-color: rgba(74, 222, 128, 0.3); }
.defense-good .def-status { background: rgba(74, 222, 128, 0.15); color: var(--primary); }

.defense-card h3 {
    font-size: 17px;
    margin-bottom: 12px;
    word-break: break-all;
}

.defense-card h3 code {
    color: var(--accent);
    font-size: 0.95em;
}

.defense-card p {
    color: var(--text-dim);
    font-size: 14px;
    line-height: 1.8;
}

.defense-card p code {
    background: var(--code-bg);
    padding: 2px 6px;
    border-radius: 4px;
    color: var(--accent);
    font-size: 0.9em;
}

.defense-key {
    background: linear-gradient(135deg, var(--bg-card) 0%, rgba(74, 222, 128, 0.05) 100%);
    border: 1px solid var(--primary);
    border-radius: 16px;
    padding: 30px;
    margin-bottom: 50px;
}

.defense-key h3 {
    margin-bottom: 20px;
    font-size: 22px;
    color: var(--primary);
}

.kp-list {
    list-style: none;
}

.kp-list li {
    padding: 10px 0 10px 30px;
    position: relative;
    color: var(--text-dim);
    line-height: 1.8;
}

.kp-list li::before {
    content: "✓";
    position: absolute;
    left: 0;
    top: 10px;
    color: var(--primary);
    font-weight: 700;
    font-size: 18px;
}

.kp-list strong { color: var(--text); }

.kp-list code {
    background: var(--code-bg);
    padding: 2px 8px;
    border-radius: 4px;
    color: var(--accent);
    font-size: 0.9em;
}

/* Recap */
.recap {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 30px;
}

.recap h3 { margin-bottom: 24px; text-align: center; }

.recap-flow {
    display: flex;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
    justify-content: center;
}

.recap-box {
    flex: 1;
    min-width: 320px;
    background: var(--bg-deep);
    border: 1px solid var(--border-light);
    border-radius: 12px;
    padding: 20px;
}

.recap-victim { border-color: var(--primary); }
.recap-attack { border-color: var(--evil); }

.recap-title {
    text-align: center;
    margin-bottom: 14px;
    font-size: 14px;
    color: var(--text-dim);
    letter-spacing: 1px;
    text-transform: uppercase;
}

.recap-victim .recap-title { color: var(--primary); }
.recap-attack .recap-title { color: var(--evil); }

.recap-content {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
    justify-content: center;
    font-family: 'JetBrains Mono', monospace;
    font-size: 13px;
}

.r-secret {
    background: rgba(251, 191, 36, 0.15);
    color: var(--warning);
    padding: 4px 10px;
    border-radius: 4px;
}

.r-data {
    background: rgba(74, 222, 128, 0.15);
    color: var(--primary);
    padding: 4px 10px;
    border-radius: 4px;
}

.r-pad {
    background: rgba(100, 116, 139, 0.2);
    color: var(--text-dim);
    padding: 4px 10px;
    border-radius: 4px;
    font-style: italic;
}

.r-evil {
    background: rgba(236, 72, 153, 0.2);
    color: var(--evil);
    padding: 4px 10px;
    border-radius: 4px;
}

.r-arrow { color: var(--text-faint); font-size: 14px; }

.r-hash {
    background: rgba(56, 189, 248, 0.15);
    color: var(--accent);
    padding: 4px 10px;
    border-radius: 4px;
    font-weight: 700;
}

.recap-vs {
    font-size: 28px;
    font-weight: 800;
    color: var(--text-faint);
    letter-spacing: 2px;
}

.recap-note {
    margin-top: 14px;
    text-align: center;
    color: var(--text-dim);
    font-size: 13px;
}

/* ============== 页脚 ============== */
.footer {
    background: var(--bg-deep);
    border-top: 1px solid var(--border);
    padding: 50px 0 30px;
    margin-top: 80px;
}

.footer-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 40px;
    margin-bottom: 30px;
}

.footer-logo {
    font-weight: 700;
    font-size: 18px;
    margin-bottom: 12px;
}

.footer-left p { color: var(--text-dim); font-size: 14px; }

.footer-right p { color: var(--text); margin-bottom: 12px; font-weight: 600; }

.footer-right ul {
    list-style: none;
    color: var(--text-dim);
    font-size: 13px;
    line-height: 2;
}

.footer-bottom {
    text-align: center;
    color: var(--text-faint);
    font-size: 13px;
    padding-top: 24px;
    border-top: 1px solid var(--border);
}

/* ============== 响应式 ============== */
@media (max-width: 1024px) {
    .nav-links { display: none; }
    .story-card { grid-template-columns: 1fr; }
    .lab { grid-template-columns: 1fr; }
    .footer-content { grid-template-columns: 1fr; }
    .state-grid { grid-template-columns: repeat(4, 1fr); }
}

@media (max-width: 640px) {
    .container { padding: 0 20px; }
    .chapter { padding: 60px 0; }
    .hero-stats { gap: 30px; }
    .pd-bytes { grid-template-columns: repeat(8, 1fr); }
    .padding-rules { grid-template-columns: 1fr; }
    .state-row-display { grid-template-columns: repeat(4, 1fr); }
    .stage-step { flex-direction: column; gap: 12px; }
    .step-marker { margin: 0; }
    .recap-vs { transform: rotate(90deg); margin: 10px 0; }

    /* MD 纵向流水线小屏适配 */
    .md-vert { padding: 22px 12px; gap: 14px; }
    .mdv-strip-blocks { grid-template-columns: 1fr; }
    .mdv-msg-card-hex { font-size: 10px; }
    .mdv-words { grid-template-columns: repeat(4, 1fr); }
    .mdv-f-body { grid-template-columns: 1fr; }
    .mdv-rounds { grid-template-columns: repeat(8, 1fr); }
    .mdv-stage { padding: 16px 12px 18px; }
    .mdv-stage-formula { font-size: 11px; }
    .mdv-stage-output { flex-direction: column; align-items: flex-start; gap: 4px; }
    .mdv-stage-output-formula { white-space: normal; word-break: break-all; }
}

/* 滚动条 */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--bg-deep); }
::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 5px; }
::-webkit-scrollbar-thumb:hover { background: var(--primary); }
