/* =========================================================================
 * CryptoAnim 设计系统
 * 深色 · 玻璃拟态 · 霓虹渐变 · 灵动微交互
 * ========================================================================= */
:root {
  --bg: #06080f;
  --bg-2: #0b0e1c;
  --panel: rgba(17, 21, 40, 0.66);
  --panel-2: rgba(26, 31, 56, 0.6);
  --panel-solid: #11152a;
  --line: rgba(120, 160, 255, 0.14);
  --line-2: rgba(120, 160, 255, 0.3);
  --text: #e8ecff;
  --muted: #8990b8;
  --dim: #5c6288;
  --c-cyan: #5ee7f5;
  --c-blue: #60a5fa;
  --c-violet: #a78bfa;
  --c-pink: #f472b6;
  --c-green: #34d399;
  --c-amber: #fbbf24;
  --c-red: #fb7185;
  --grad-main: linear-gradient(135deg, #5ee7f5, #60a5fa 45%, #a78bfa 75%, #f472b6);
  --grad-soft: linear-gradient(135deg, rgba(94,231,245,.16), rgba(167,139,250,.16));
  --radius: 16px;
  --radius-sm: 10px;
  --blur: 16px;
  --shadow: 0 12px 40px rgba(0, 0, 0, .5);
  --shadow-glow: 0 0 30px rgba(96, 165, 250, .22);
  --ease: cubic-bezier(.22, 1, .36, 1);
}

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

body {
  background:
    radial-gradient(1100px 700px at 12% -10%, rgba(94, 231, 245, .10), transparent 60%),
    radial-gradient(1000px 640px at 100% 0%, rgba(167, 139, 250, .12), transparent 62%),
    radial-gradient(900px 900px at 50% 130%, rgba(244, 114, 182, .07), transparent 60%),
    var(--bg);
  color: var(--text);
  font-family: "Segoe UI", "Microsoft YaHei", "PingFang SC", system-ui, -apple-system, sans-serif;
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

#bg-canvas {
  position: fixed; inset: 0; z-index: 0; pointer-events: none; display: block;
}

::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(120, 160, 255, .2); border-radius: 5px; }
::-webkit-scrollbar-thumb:hover { background: rgba(120, 160, 255, .4); }

/* ------------------------------ 布局 ------------------------------ */
#app {
  position: relative; z-index: 1;
  display: grid;
  grid-template-columns: 264px minmax(0, 1fr);
  min-height: 100vh;
}

/* ------------------------------ 侧边栏 ------------------------------ */
#sidebar {
  position: sticky; top: 0; align-self: start;
  height: 100vh;
  display: flex; flex-direction: column;
  padding: 22px 16px 18px;
  background: linear-gradient(180deg, rgba(14, 18, 36, .82), rgba(8, 10, 22, .72));
  backdrop-filter: blur(var(--blur));
  -webkit-backdrop-filter: blur(var(--blur));
  border-right: 1px solid var(--line);
  overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 11px; padding: 4px 6px 20px; }
.brand-mark {
  width: 42px; height: 42px; border-radius: 12px; flex: none;
  display: grid; place-items: center;
  font-weight: 900; font-size: 22px; color: #06121a;
  background: var(--grad-main);
  box-shadow: 0 6px 20px rgba(96, 165, 250, .45);
  animation: markFloat 5s ease-in-out infinite;
}
@keyframes markFloat { 0%,100% { transform: translateY(0) rotate(-2deg); } 50% { transform: translateY(-4px) rotate(2deg); } }
.brand-text { display: flex; flex-direction: column; line-height: 1.25; }
.brand-text b { font-size: 17px; letter-spacing: .5px;
  background: var(--grad-main); -webkit-background-clip: text; background-clip: text; color: transparent; }
.brand-text span { font-size: 11px; color: var(--dim); letter-spacing: .5px; }

#nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.nav-group-title {
  font-size: 11px; color: var(--dim); letter-spacing: 2px;
  padding: 14px 10px 6px; text-transform: uppercase;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 10px;
  color: #aeb5d8; text-decoration: none; font-size: 14px; cursor: pointer;
  border: 1px solid transparent;
  transition: background .2s, color .2s, border-color .2s, transform .15s;
  position: relative;
}
.nav-item .ico { width: 20px; text-align: center; font-size: 15px; opacity: .85; }
.nav-item:hover { background: rgba(96, 165, 250, .08); color: var(--text); transform: translateX(3px); }
.nav-item.active {
  background: var(--grad-soft);
  border-color: var(--line-2);
  color: #fff; font-weight: 600;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.03), 0 4px 18px rgba(96,165,250,.12);
}
.nav-item.active::before {
  content: ''; position: absolute; left: -16px; top: 50%; transform: translateY(-50%);
  width: 3px; height: 20px; border-radius: 2px; background: var(--grad-main);
  box-shadow: 0 0 12px rgba(96,165,250,.8);
}
.nav-badge { margin-left: auto; font-size: 10px; color: var(--c-green); }

.side-foot { padding-top: 16px; border-top: 1px solid var(--line); }
.progress-box { padding: 10px 8px; }
.progress-title { font-size: 12px; color: var(--muted); margin-bottom: 8px; letter-spacing: 1px; }
.progress-bar { height: 6px; border-radius: 4px; background: rgba(255,255,255,.07); overflow: hidden; }
.progress-bar > i {
  display: block; height: 100%; border-radius: 4px;
  background: var(--grad-main); box-shadow: 0 0 10px rgba(96,165,250,.7);
  transition: width .6s var(--ease);
}
.progress-text { font-size: 11px; color: var(--dim); margin-top: 7px; }

/* ------------------------------ 主区 ------------------------------ */
#main { padding: 34px 40px 70px; max-width: 1180px; width: 100%; margin: 0 auto; }

.page { animation: pageIn .5s var(--ease) both; }
@keyframes pageIn { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

.page-head { margin-bottom: 22px; }
.page-kicker {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 12px; letter-spacing: 2px; color: var(--c-cyan);
  padding: 4px 12px; border-radius: 999px;
  background: rgba(94, 231, 245, .09); border: 1px solid rgba(94, 231, 245, .25);
  margin-bottom: 12px;
}
.page-title { font-size: 34px; margin: 0 0 8px; font-weight: 800; letter-spacing: .5px; }
.page-title .accent { background: var(--grad-main); -webkit-background-clip: text; background-clip: text; color: transparent; }
.page-sub { color: var(--muted); margin: 0; line-height: 1.7; max-width: 760px; }

/* ------------------------------ 首页 ------------------------------ */
.hero {
  position: relative; overflow: hidden;
  border-radius: 22px; padding: 40px 40px 34px;
  background: linear-gradient(135deg, rgba(24, 30, 58, .8), rgba(12, 16, 34, .6));
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  margin-bottom: 30px;
}
.hero::after {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(600px 260px at 85% 10%, rgba(167,139,250,.2), transparent 60%);
}
.hero h1 { font-size: 42px; margin: 0 0 12px; letter-spacing: 1px; line-height: 1.2; }
.hero h1 span { background: var(--grad-main); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero p { color: var(--muted); line-height: 1.8; max-width: 640px; margin: 0 0 20px; font-size: 15px; }
.hero-actions { display: flex; gap: 12px; flex-wrap: wrap; }
.hero-chip {
  position: absolute; right: 42px; top: 50%; transform: translateY(-50%);
  display: flex; gap: 8px; opacity: .9;
}
.hero-chip .mini {
  width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center;
  font-family: Consolas, monospace; font-weight: 800; font-size: 17px;
  background: rgba(94,231,245,.1); border: 1px solid rgba(94,231,245,.28); color: var(--c-cyan);
  animation: chipFloat 3.6s ease-in-out infinite;
}
.hero-chip .mini:nth-child(2) { animation-delay: .5s; color: var(--c-violet); background: rgba(167,139,250,.1); border-color: rgba(167,139,250,.28); }
.hero-chip .mini:nth-child(3) { animation-delay: 1s; color: var(--c-pink); background: rgba(244,114,182,.1); border-color: rgba(244,114,182,.28); }
.hero-chip .mini:nth-child(4) { animation-delay: 1.5s; color: var(--c-green); background: rgba(52,211,153,.1); border-color: rgba(52,211,153,.28); }
@keyframes chipFloat { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-10px); } }

.section-title { font-size: 15px; letter-spacing: 2px; color: var(--muted); margin: 26px 0 14px; display: flex; align-items: center; gap: 10px; }
.section-title::after { content: ''; flex: 1; height: 1px; background: linear-gradient(90deg, var(--line), transparent); }

.home-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 16px; }
.algo-card {
  position: relative; overflow: hidden; cursor: pointer;
  padding: 20px; border-radius: 16px;
  background: linear-gradient(160deg, rgba(26,31,56,.72), rgba(13,17,34,.6));
  backdrop-filter: blur(var(--blur));
  border: 1px solid var(--line);
  transition: transform .28s var(--ease), box-shadow .28s, border-color .28s;
  animation: cardIn .5s var(--ease) both;
}
.algo-card:nth-child(1) { animation-delay: .04s; }
.algo-card:nth-child(2) { animation-delay: .08s; }
.algo-card:nth-child(3) { animation-delay: .12s; }
.algo-card:nth-child(4) { animation-delay: .16s; }
.algo-card:nth-child(5) { animation-delay: .2s; }
.algo-card:nth-child(6) { animation-delay: .24s; }
.algo-card:nth-child(7) { animation-delay: .28s; }
@keyframes cardIn { from { opacity: 0; transform: translateY(16px) scale(.97); } to { opacity: 1; transform: none; } }
.algo-card:hover { transform: translateY(-6px); border-color: var(--line-2); box-shadow: var(--shadow), var(--shadow-glow); }
.algo-card .card-ico {
  width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center;
  font-size: 22px; margin-bottom: 14px;
  background: rgba(96,165,250,.1); border: 1px solid rgba(96,165,250,.25);
  transition: transform .3s var(--ease);
}
.algo-card:hover .card-ico { transform: scale(1.1) rotate(-6deg); }
.algo-card h3 { margin: 0 0 8px; font-size: 17px; }
.algo-card p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.7; }
.algo-card .card-tag {
  display: inline-block; margin-top: 14px; font-size: 11px; letter-spacing: 1px;
  padding: 3px 10px; border-radius: 999px; color: var(--c-cyan);
  background: rgba(94,231,245,.08); border: 1px solid rgba(94,231,245,.22);
}
.algo-card.visited::after {
  content: '✓ 已学'; position: absolute; top: 14px; right: 14px;
  font-size: 11px; color: var(--c-green); opacity: .9;
}

/* ------------------------------ 按钮 ------------------------------ */
.btn {
  position: relative; overflow: hidden;
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 18px; border-radius: 10px; cursor: pointer;
  font-size: 14px; font-weight: 600; font-family: inherit;
  color: var(--text); border: 1px solid var(--line-2);
  background: linear-gradient(180deg, rgba(38,44,78,.7), rgba(20,25,46,.7));
  transition: transform .15s, box-shadow .2s, border-color .2s;
  box-shadow: 0 4px 14px rgba(0,0,0,.28);
}
.btn:hover:not(:disabled) { transform: translateY(-2px); border-color: var(--c-blue); box-shadow: 0 8px 22px rgba(96,165,250,.25); }
.btn:active:not(:disabled) { transform: translateY(0); }
.btn:disabled { opacity: .38; cursor: not-allowed; }
.btn.primary {
  background: var(--grad-main); border: none; color: #051320; font-weight: 800;
  box-shadow: 0 8px 24px rgba(96,165,250,.4);
}
.btn.primary:hover:not(:disabled) { box-shadow: 0 10px 34px rgba(96,165,250,.6); }
.btn.ghost { background: transparent; }
.btn.sm { padding: 7px 13px; font-size: 13px; }
.btn.icon-btn { width: 40px; height: 40px; padding: 0; justify-content: center; font-size: 15px; }

/* ------------------------------ 算法页 ------------------------------ */
.algo-wrap { display: grid; grid-template-columns: 1fr; gap: 18px; }

.input-panel {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px; padding: 18px; border-radius: var(--radius);
  background: var(--panel); border: 1px solid var(--line);
  backdrop-filter: blur(var(--blur)); box-shadow: var(--shadow);
  animation: pageIn .45s var(--ease) both;
}
.field { display: flex; flex-direction: column; gap: 7px; }
.field label { font-size: 12px; color: var(--muted); letter-spacing: 1px; }
.field input, .field select {
  width: 100%; padding: 10px 12px; border-radius: 9px; font-family: inherit; font-size: 14px;
  color: var(--text); background: rgba(9, 12, 26, .72);
  border: 1px solid var(--line-2); transition: border-color .2s, box-shadow .2s;
}
.field input:focus, .field select:focus {
  outline: none; border-color: var(--c-cyan); box-shadow: 0 0 0 3px rgba(94,231,245,.12);
}
.field input.mono { font-family: Consolas, "Courier New", monospace; letter-spacing: 2px; }
.field .hint { font-size: 11px; color: var(--dim); }
.field.err input { border-color: var(--c-red); }

/* 舞台 */
.stage-panel {
  border-radius: var(--radius); overflow: hidden;
  background: linear-gradient(160deg, rgba(20,25,48,.7), rgba(9,12,26,.66));
  border: 1px solid var(--line); box-shadow: var(--shadow);
  backdrop-filter: blur(var(--blur));
}
.stage-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 18px; border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
  background: rgba(255,255,255,.015);
}
.stage-bar .title { font-size: 13px; color: var(--muted); letter-spacing: 1px; display: flex; align-items: center; gap: 8px; }
.stage-bar .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--c-green); box-shadow: 0 0 8px var(--c-green); }

.stage {
  position: relative; min-height: 320px; padding: 26px 22px;
  display: flex; flex-direction: column; justify-content: center; gap: 18px;
  background-image:
    linear-gradient(rgba(120,160,255,.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(120,160,255,.04) 1px, transparent 1px);
  background-size: 26px 26px;
}
.stage-inner { width: 100%; }

/* 控制栏 */
.controls { display: grid; grid-template-columns: 1fr auto; gap: 14px; align-items: center; padding: 14px 18px; border-top: 1px solid var(--line); background: rgba(0,0,0,.12); }
.ctrl-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.step-indicator { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.step-indicator b { color: var(--c-cyan); font-size: 14px; }
.speed { display: flex; align-items: center; gap: 9px; font-size: 12px; color: var(--muted); white-space: nowrap; }
.speed input[type=range] { width: 120px; accent-color: var(--c-cyan); }
.speed b { color: var(--text); min-width: 34px; text-align: right; font-variant-numeric: tabular-nums; }
.timeline { display: flex; gap: 5px; flex-wrap: wrap; padding: 10px 18px 13px; border-top: 1px solid var(--line); }
.timeline .tl-dot {
  width: 24px; height: 6px; padding: 0; border: none; border-radius: 3px; cursor: pointer;
  background: rgba(255, 255, 255, .09); transition: all .25s var(--ease);
}
.timeline .tl-dot:hover { background: rgba(96, 165, 250, .45); transform: scaleY(1.5); }
.timeline .tl-dot.done { background: rgba(96, 165, 250, .4); }
.timeline .tl-dot.active { background: var(--grad-main); box-shadow: 0 0 12px rgba(96, 165, 250, .8); transform: scaleY(1.8); }
.note-badge.pop { animation: badgePop .45s var(--ease); }
@keyframes badgePop { 0% { transform: scale(.65); } 60% { transform: scale(1.15); } 100% { transform: scale(1); } }

/* 讲解面板 */
.note-panel {
  display: grid; grid-template-columns: 1fr auto; gap: 16px; align-items: start;
  padding: 18px 20px; border-radius: var(--radius);
  background: var(--panel); border: 1px solid var(--line);
  backdrop-filter: blur(var(--blur)); box-shadow: var(--shadow);
  min-height: 112px;
}
.note-body { display: flex; gap: 14px; }
.note-badge {
  flex: none; width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center;
  font-weight: 800; font-size: 15px; color: #06121a;
  background: var(--grad-main); box-shadow: 0 4px 16px rgba(96,165,250,.35);
  font-variant-numeric: tabular-nums;
}
.note-text { font-size: 15px; line-height: 1.9; color: #cdd3f2; }
.note-text .hl { color: var(--c-cyan); font-weight: 600; }
.note-formula {
  font-family: Consolas, monospace; font-size: 13px; color: var(--c-violet);
  background: rgba(167,139,250,.08); border: 1px solid rgba(167,139,250,.2);
  padding: 8px 12px; border-radius: 8px; white-space: pre-wrap; line-height: 1.6;
}
.note-extra { font-size: 12px; color: var(--dim); text-align: right; white-space: nowrap; }

.knowledge { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; }
.know-card {
  padding: 16px 18px; border-radius: 14px;
  background: var(--panel-2); border: 1px solid var(--line);
  transition: border-color .2s, transform .2s;
}
.know-card:hover { border-color: var(--line-2); transform: translateY(-2px); }
.know-card h4 { margin: 0 0 8px; font-size: 14px; color: var(--c-cyan); display: flex; align-items: center; gap: 7px; }
.know-card p { margin: 0; font-size: 13px; color: var(--muted); line-height: 1.75; }

/* ------------------------------ 字母块（古典密码） ------------------------------ */
.letter-row { display: flex; gap: 9px; flex-wrap: wrap; align-items: flex-start; }
.letter-col { display: flex; flex-direction: column; align-items: center; gap: 5px; }
.chip {
  width: 42px; height: 42px; border-radius: 10px;
  display: grid; place-items: center;
  font-family: Consolas, monospace; font-weight: 800; font-size: 18px;
  transition: transform .3s var(--ease), box-shadow .3s, background .3s, border-color .3s, color .3s;
  border: 1px solid rgba(120,160,255,.26);
  background: rgba(22, 28, 52, .85); color: #b9c2ea;
}
.chip.plain { color: #9fb4ff; }
.chip.cipher { color: var(--c-amber); border-color: rgba(251,191,36,.35); background: rgba(46,38,16,.6); }
.chip.hl {
  transform: translateY(-6px) scale(1.12);
  color: #051320;
  background: linear-gradient(135deg, var(--c-cyan), var(--c-blue));
  border-color: transparent;
  box-shadow: 0 0 26px rgba(94,231,245,.7);
}
.chip.hl.cipher { background: linear-gradient(135deg, var(--c-amber), #f97316); box-shadow: 0 0 26px rgba(251,191,36,.7); }
.chip.dim { opacity: .28; }
.chip.pop { animation: chipPop .45s var(--ease); }
@keyframes chipPop { 0% { transform: scale(.4); opacity: 0; } 70% { transform: scale(1.1); } 100% { transform: scale(1); opacity: 1; } }
.chip-meta { font-size: 10px; color: var(--dim); font-family: Consolas, monospace; height: 13px; }
.chip-meta.on { color: var(--c-amber); }

.row-label { font-size: 11px; letter-spacing: 2px; color: var(--dim); margin-bottom: 2px; }
.stage-rows { display: flex; flex-direction: column; gap: 16px; }

/* 密钥条 */
.key-strip { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px; }
.key-cell {
  width: 34px; height: 26px; border-radius: 7px; display: grid; place-items: center;
  font-family: Consolas, monospace; font-size: 12px; font-weight: 700;
  color: var(--c-violet); background: rgba(167,139,250,.1); border: 1px solid rgba(167,139,250,.25);
  transition: all .25s var(--ease);
}
.key-cell.on { color: #051320; background: linear-gradient(135deg, var(--c-violet), var(--c-pink)); border-color: transparent; box-shadow: 0 0 18px rgba(167,139,250,.6); }

/* 数学算式气泡 */
.eq-bubble {
  display: inline-flex; align-items: center; gap: 6px; margin-top: 10px;
  padding: 8px 14px; border-radius: 10px;
  font-family: Consolas, monospace; font-size: 13px; color: var(--c-cyan);
  background: rgba(94,231,245,.07); border: 1px solid rgba(94,231,245,.22);
  animation: fadeUp .35s var(--ease) both;
}
@keyframes fadeUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* 栅栏排布 */
.fence-grid { display: flex; flex-direction: column; gap: 10px; }
.fence-row { display: flex; gap: 10px; align-items: center; min-height: 46px; }
.fence-row .row-index { width: 22px; font-size: 11px; color: var(--dim); font-family: Consolas, monospace; }
.fence-slot {
  width: 42px; height: 42px; border-radius: 10px; display: grid; place-items: center;
  font-family: Consolas, monospace; font-weight: 700; font-size: 17px;
  background: rgba(22,28,52,.5); border: 1px dashed rgba(120,160,255,.18); color: var(--dim);
  transition: all .35s var(--ease);
}
.fence-slot.filled { color: #cdd3f2; border-style: solid; border-color: rgba(120,160,255,.3); background: rgba(28, 36, 66, .8); }
.fence-slot.hl { color: #051320; background: linear-gradient(135deg, var(--c-cyan), var(--c-blue)); border-color: transparent; box-shadow: 0 0 22px rgba(94,231,245,.6); transform: scale(1.1); }
.fence-slot.read { color: var(--c-amber); border-color: rgba(251,191,36,.4); background: rgba(46,38,16,.5); }

/* ------------------------------ AES 矩阵 ------------------------------ */
.aes-stage { display: flex; flex-direction: column; align-items: center; gap: 18px; }
.matrix-wrap { position: relative; }
.matrix {
  display: grid; grid-template-columns: repeat(4, 58px); grid-template-rows: repeat(4, 52px); gap: 7px;
  padding: 12px; border-radius: 14px;
  background: rgba(9,12,26,.55); border: 1px solid var(--line-2);
  box-shadow: inset 0 0 30px rgba(96,165,250,.06);
}
.cell {
  border-radius: 8px; display: grid; place-items: center;
  font-family: Consolas, monospace; font-size: 15px; font-weight: 700;
  color: #b9c2ea; background: rgba(26, 34, 62, .9);
  border: 1px solid rgba(120,160,255,.14);
  transition: all .35s var(--ease);
  position: relative; overflow: hidden;
}
.cell .hex { position: absolute; bottom: 3px; right: 5px; font-size: 9px; color: var(--dim); font-weight: 400; }
.cell.hl { color: #051320; background: linear-gradient(135deg, var(--c-cyan), var(--c-blue)); border-color: transparent; box-shadow: 0 0 20px rgba(94,231,245,.55); transform: scale(1.06); z-index: 2; }
.cell.changed { animation: cellFlip .5s var(--ease); border-color: rgba(251,191,36,.5); color: var(--c-amber); }
@keyframes cellFlip { 0% { transform: rotateY(0) scale(1); } 50% { transform: rotateY(90deg) scale(1.08); background: rgba(251,191,36,.25); } 100% { transform: rotateY(0) scale(1); } }
.cell.shift-src { border-color: rgba(167,139,250,.6); color: var(--c-violet); }
.aes-slabel { text-align: center; font-size: 12px; color: var(--muted); letter-spacing: 1px; margin-top: 6px; }
.aes-legend { display: flex; gap: 16px; font-size: 11px; color: var(--dim); flex-wrap: wrap; justify-content: center; }
.aes-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: middle; }

/* ------------------------------ RSA / DH 流程 ------------------------------ */
.flow-stage { display: flex; flex-direction: column; gap: 22px; width: 100%; }
.flow-lanes { display: grid; grid-template-columns: 1fr 120px 1fr; gap: 10px; align-items: start; }
.lane { display: flex; flex-direction: column; gap: 12px; }
.lane-title { text-align: center; font-size: 13px; letter-spacing: 2px; color: var(--c-cyan); margin-bottom: 2px; }
.lane.bob .lane-title { color: var(--c-pink); }
.node-box {
  padding: 12px 14px; border-radius: 12px; text-align: center;
  background: rgba(22,28,52,.8); border: 1px solid var(--line-2);
  transition: all .35s var(--ease); position: relative;
  animation: fadeUp .4s var(--ease) both;
}
.node-box .nb-title { font-size: 11px; color: var(--muted); letter-spacing: 1px; margin-bottom: 5px; }
.node-box .nb-value {
  font-family: Consolas, monospace; font-size: 18px; font-weight: 800; color: var(--c-cyan);
  word-break: break-all; line-height: 1.35;
}
.lane.bob .node-box .nb-value { color: var(--c-pink); }
.node-box.active { border-color: var(--c-cyan); box-shadow: 0 0 24px rgba(94,231,245,.35); transform: scale(1.03); }
.lane.bob .node-box.active { border-color: var(--c-pink); box-shadow: 0 0 24px rgba(244,114,182,.35); }
.node-box.public .nb-value { color: var(--c-amber); }
.node-box.secret { border-style: dashed; }
.node-box.secret .nb-value { color: var(--c-green); }

.transfer-col { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; padding-top: 40px; min-height: 220px; }
.arrow-line { position: relative; width: 2px; flex: 1; min-height: 80px; background: linear-gradient(180deg, transparent, rgba(120,160,255,.35), transparent); }
.arrow-line .packet {
  position: absolute; left: 50%; width: 30px; height: 22px; margin-left: -15px;
  border-radius: 6px; display: grid; place-items: center;
  font-family: Consolas, monospace; font-size: 11px; font-weight: 800; color: #051320;
  background: linear-gradient(135deg, var(--c-amber), #f97316);
  box-shadow: 0 0 18px rgba(251,191,36,.7);
  opacity: 0; transition: opacity .25s;
}
.arrow-line .packet.go { animation: packetDown 1.1s var(--ease) forwards; }
@keyframes packetDown { 0% { top: 0; opacity: 0; } 15% { opacity: 1; } 85% { opacity: 1; } 100% { top: 100%; opacity: 0; } }
.arrow-line .packet.up.go { animation: packetUp 1.1s var(--ease) forwards; }
@keyframes packetUp { 0% { top: 100%; opacity: 0; } 15% { opacity: 1; } 85% { opacity: 1; } 100% { top: 0; opacity: 0; } }
.transfer-label { font-size: 10px; color: var(--dim); letter-spacing: 1px; }

.formula-ladder { display: flex; flex-direction: column; gap: 8px; padding: 14px 16px; border-radius: 12px; background: rgba(9,12,26,.5); border: 1px solid var(--line); }
.formula-line {
  font-family: Consolas, monospace; font-size: 13px; color: #b9c2ea;
  padding: 6px 10px; border-radius: 6px; transition: all .3s;
  border-left: 2px solid transparent;
}
.formula-line.on { color: var(--c-cyan); background: rgba(94,231,245,.08); border-left-color: var(--c-cyan); }
.formula-line.done { color: var(--dim); }

/* ------------------------------ SHA ------------------------------ */
.sha-stage { display: flex; flex-direction: column; gap: 16px; align-items: center; width: 100%; }
.sha-blocks { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.sha-block {
  padding: 9px 12px; border-radius: 9px; font-family: Consolas, monospace; font-size: 12px;
  background: rgba(22,28,52,.8); border: 1px solid var(--line-2); color: #b9c2ea;
  transition: all .3s var(--ease);
}
.sha-block.pad { color: var(--c-amber); border-color: rgba(251,191,36,.35); background: rgba(46,38,16,.5); }
.sha-block.active { color: #051320; background: linear-gradient(135deg, var(--c-cyan), var(--c-blue)); border-color: transparent; box-shadow: 0 0 22px rgba(94,231,245,.6); transform: translateY(-3px); }
.sha-block.done { opacity: .45; }
.sha-compress {
  display: flex; align-items: center; gap: 14px; padding: 16px 22px; border-radius: 14px;
  background: rgba(9,12,26,.55); border: 1px solid var(--line-2); width: 100%; max-width: 620px;
  transition: all .35s;
}
.sha-compress.active { border-color: var(--c-violet); box-shadow: 0 0 30px rgba(167,139,250,.3); }
.sha-registers { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; flex: 1; }
.sha-reg {
  text-align: center; padding: 8px 4px; border-radius: 8px;
  background: rgba(22,28,52,.8); border: 1px solid var(--line);
  font-family: Consolas, monospace; font-size: 12px;
  transition: all .3s var(--ease);
}
.sha-reg .n { font-size: 10px; color: var(--dim); display: block; margin-bottom: 3px; }
.sha-reg .v { color: var(--c-cyan); font-weight: 700; word-break: break-all; }
.sha-reg.changed { border-color: var(--c-amber); animation: cellFlip .5s var(--ease); }
.sha-arrow { font-size: 20px; color: var(--c-violet); animation: pulseArrow 1.6s infinite; }
@keyframes pulseArrow { 0%,100% { opacity: .4; transform: translateX(0); } 50% { opacity: 1; transform: translateX(4px); } }
.sha-digest {
  font-family: Consolas, monospace; font-size: 13px; line-height: 1.8; word-break: break-all;
  padding: 14px 18px; border-radius: 12px; text-align: center;
  background: rgba(52,211,153,.06); border: 1px solid rgba(52,211,153,.28); color: var(--c-green);
  max-width: 680px;
}

/* ------------------------------ 雪崩演示 ------------------------------ */
.avalanche {
  margin: 4px 0 8px; padding: 22px 24px; border-radius: var(--radius);
  background: var(--panel); border: 1px solid var(--line);
  backdrop-filter: blur(var(--blur)); box-shadow: var(--shadow);
}
.av-note { font-size: 13px; color: var(--muted); line-height: 1.75; margin-bottom: 18px; }
.av-inputs { display: grid; grid-template-columns: 1fr 1fr auto; gap: 14px; align-items: end; margin-bottom: 18px; }
.av-inputs .field input { font-family: Consolas, monospace; letter-spacing: .5px; }
.av-actions { padding-bottom: 1px; }
.av-actions .btn { white-space: nowrap; }
.av-digests { display: flex; flex-direction: column; gap: 10px; margin-bottom: 18px; }
.av-digest-row { display: flex; align-items: flex-start; gap: 12px; }
.av-tag {
  width: 26px; height: 26px; border-radius: 8px; flex: none; margin-top: 1px;
  display: grid; place-items: center; font-weight: 800; font-size: 13px;
  background: rgba(94,231,245,.15); color: var(--c-cyan); border: 1px solid rgba(94,231,245,.3);
}
.av-tag.b { background: rgba(244,114,182,.15); color: var(--c-pink); border-color: rgba(244,114,182,.3); }
.av-digest-row code {
  font-family: Consolas, monospace; font-size: 13px; letter-spacing: .5px; line-height: 1.9;
  word-break: break-all; color: #b9c2ea;
}
.av-digest-row code .hx { padding: 0 1px; border-radius: 2px; display: inline-block; }
.av-digest-row code .hx.diff {
  color: #fff; background: rgba(251,113,133,.55);
  box-shadow: 0 0 8px rgba(251,113,133,.55);
  animation: avFlash .5s var(--ease) both;
}
@keyframes avFlash { from { opacity: 0; transform: scale(.5); } to { opacity: 1; transform: none; } }
.av-stats { display: flex; gap: 14px; flex-wrap: wrap; margin-bottom: 16px; }
.av-stat {
  flex: 1; min-width: 110px; padding: 12px 16px; border-radius: 12px; text-align: center;
  background: rgba(9,12,26,.5); border: 1px solid var(--line);
}
.av-stat b {
  display: block; font-size: 24px; font-weight: 800; margin-bottom: 2px;
  background: var(--grad-main); -webkit-background-clip: text; background-clip: text; color: transparent;
  font-variant-numeric: tabular-nums;
}
.av-stat span { font-size: 11px; color: var(--dim); letter-spacing: .5px; }
.av-heat { display: grid; grid-template-columns: repeat(32, 1fr); gap: 3px; margin-bottom: 10px; }
.av-bit { height: 9px; border-radius: 2px; background: rgba(255,255,255,.06); transition: background .3s; }
.av-bit.diff { background: var(--c-red); box-shadow: 0 0 6px rgba(251,113,133,.7); }
.av-hint { font-size: 11px; color: var(--dim); line-height: 1.7; }
@media (max-width: 700px) { .av-inputs { grid-template-columns: 1fr; } .av-heat { grid-template-columns: repeat(16, 1fr); } }

/* ------------------------------ 术语 ------------------------------ */
.term {
  color: var(--c-cyan); cursor: pointer; border-bottom: 1px dashed rgba(94,231,245,.5);
  transition: color .2s, border-color .2s;
}
.term:hover { color: #fff; border-bottom-color: #fff; }
.term-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
.term-search { max-width: 380px; margin-bottom: 18px; }
.term-search input {
  width: 100%; padding: 10px 14px; border-radius: 10px; font-size: 14px; font-family: inherit;
  color: var(--text); background: rgba(9, 12, 26, .72); border: 1px solid var(--line-2);
  transition: border-color .2s, box-shadow .2s;
}
.term-search input:focus { outline: none; border-color: var(--c-cyan); box-shadow: 0 0 0 3px rgba(94, 231, 245, .12); }
.term-card {
  padding: 16px 18px; border-radius: 14px; cursor: pointer;
  background: var(--panel-2); border: 1px solid var(--line);
  transition: all .25s var(--ease);
}
.term-card:hover { transform: translateY(-4px); border-color: var(--line-2); box-shadow: var(--shadow-glow); }
.term-card h4 { margin: 0 0 6px; font-size: 15px; color: var(--c-cyan); }
.term-card p { margin: 0; font-size: 12px; color: var(--muted); line-height: 1.7; }

/* ------------------------------ 习题 ------------------------------ */
.ex-layout { display: flex; flex-direction: column; gap: 18px; max-width: 820px; }
.ex-card {
  padding: 22px 24px; border-radius: 16px;
  background: var(--panel); border: 1px solid var(--line);
  backdrop-filter: blur(var(--blur)); box-shadow: var(--shadow);
  animation: pageIn .45s var(--ease) both;
}
.ex-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.ex-tag { font-size: 11px; color: var(--c-violet); letter-spacing: 1px; padding: 3px 10px; border-radius: 999px; background: rgba(167,139,250,.1); border: 1px solid rgba(167,139,250,.24); }
.ex-q { font-size: 15px; line-height: 1.75; margin: 8px 0 16px; }
.ex-options { display: flex; flex-direction: column; gap: 9px; }
.ex-option {
  padding: 12px 16px; border-radius: 10px; cursor: pointer; font-size: 14px;
  background: rgba(22,28,52,.6); border: 1px solid var(--line);
  transition: all .2s var(--ease); display: flex; align-items: center; gap: 10px;
}
.ex-option .opt-key {
  width: 24px; height: 24px; border-radius: 7px; display: grid; place-items: center; flex: none;
  font-size: 12px; font-weight: 700; background: rgba(120,160,255,.1); color: var(--muted);
}
.ex-option:hover { border-color: var(--line-2); transform: translateX(4px); }
.ex-option.correct { border-color: var(--c-green); background: rgba(52,211,153,.12); }
.ex-option.correct .opt-key { background: var(--c-green); color: #051320; }
.ex-option.wrong { border-color: var(--c-red); background: rgba(251,113,133,.1); }
.ex-option.wrong .opt-key { background: var(--c-red); color: #051320; }
.ex-explain {
  margin-top: 14px; padding: 12px 16px; border-radius: 10px; font-size: 13px; line-height: 1.7;
  background: rgba(94,231,245,.06); border: 1px solid rgba(94,231,245,.2); color: #b9c2ea;
  animation: fadeUp .3s var(--ease) both;
}
.ex-score {
  position: sticky; top: 16px; z-index: 5;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 14px 22px; border-radius: 14px;
  background: linear-gradient(135deg, rgba(24,30,58,.9), rgba(12,16,34,.8));
  border: 1px solid var(--line-2); backdrop-filter: blur(var(--blur));
  box-shadow: var(--shadow);
}
.ex-score .val { font-size: 22px; font-weight: 800; background: var(--grad-main); -webkit-background-clip: text; background-clip: text; color: transparent; }

/* ------------------------------ 模态 & Toast ------------------------------ */
.modal { position: fixed; inset: 0; z-index: 80; display: grid; place-items: center; padding: 20px;
  background: rgba(4, 6, 14, .7); backdrop-filter: blur(8px); animation: fadeIn .25s both; }
.modal.hidden { display: none; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal-card {
  position: relative; max-width: 460px; width: 100%; padding: 26px 28px; border-radius: 18px;
  background: linear-gradient(160deg, rgba(28,34,62,.98), rgba(13,17,34,.98));
  border: 1px solid var(--line-2); box-shadow: 0 24px 60px rgba(0,0,0,.6);
  animation: modalIn .35s var(--ease) both;
}
@keyframes modalIn { from { opacity: 0; transform: translateY(20px) scale(.96); } to { opacity: 1; transform: none; } }
.modal-card h3 { margin: 0 0 10px; color: var(--c-cyan); font-size: 20px; }
.modal-card p { margin: 0; color: #c3c9e8; line-height: 1.85; font-size: 14px; }
.modal-close { position: absolute; top: 12px; right: 16px; font-size: 24px; color: var(--dim); cursor: pointer; line-height: 1; transition: color .2s; }
.modal-close:hover { color: #fff; }

#toast {
  position: fixed; bottom: 28px; left: 50%; transform: translateX(-50%) translateY(20px);
  z-index: 90; padding: 12px 22px; border-radius: 11px; font-size: 14px; font-weight: 600;
  background: linear-gradient(135deg, rgba(94,231,245,.95), rgba(96,165,250,.95)); color: #051320;
  box-shadow: 0 10px 30px rgba(96,165,250,.5); opacity: 0; pointer-events: none;
  transition: all .3s var(--ease);
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ------------------------------ 响应式 ------------------------------ */
@media (max-width: 900px) {
  #app { grid-template-columns: 1fr; }
  #sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; z-index: 60; width: 264px;
    transform: translateX(-100%); transition: transform .3s var(--ease);
  }
  #sidebar.open { transform: none; box-shadow: 0 0 60px rgba(0,0,0,.7); }
  #main { padding: 20px 16px 60px; }
  .hero { padding: 28px 22px; }
  .hero h1 { font-size: 30px; }
  .hero-chip { display: none; }
  .page-title { font-size: 26px; }
  #menu-toggle { display: flex; }
}
#menu-toggle {
  display: none; position: fixed; top: 14px; left: 14px; z-index: 70;
  width: 42px; height: 42px; border-radius: 11px; align-items: center; justify-content: center;
  background: rgba(20,25,48,.9); border: 1px solid var(--line-2); color: var(--text);
  font-size: 18px; cursor: pointer; backdrop-filter: blur(10px);
}
@media (max-width: 620px) {
  .controls { grid-template-columns: 1fr; }
  .note-panel { grid-template-columns: 1fr; }
  .flow-lanes { grid-template-columns: 1fr; }
  .transfer-col { min-height: 60px; padding: 0; }
  .arrow-line { width: 100%; height: 2px; min-height: 2px; background: linear-gradient(90deg, transparent, rgba(120,160,255,.35), transparent); }
  .matrix { grid-template-columns: repeat(4, 46px); grid-template-rows: repeat(4, 42px); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important; animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}
