:root {
  --bg: #f4f6fb;
  --panel: #ffffff;
  --line: #e3e8f0;
  --text: #1e293b;
  --muted: #64748b;
  --primary: #4f46e5;
  --primary-soft: #eef2ff;

  /* 演示配色（全站统一语义） */
  --c-base: #93c5fd;     /* 普通元素 */
  --c-cmp: #fbbf24;      /* 正在比较 / 当前 */
  --c-swap: #f87171;     /* 交换 / 移动 / 冲突 */
  --c-ok: #34d399;       /* 已完成 / 命中 */
  --c-pivot: #a78bfa;    /* 枢轴 / 特殊 */
  --c-active: #60a5fa;   /* 活跃区间 */
  --c-dim: #e2e8f0;      /* 不参与 */
  --c-red: #e11d48;
  --c-black: #1f2937;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 4px 16px rgba(15, 23, 42, .06);
  --mono: "JetBrains Mono", "Cascadia Code", Consolas, "PingFang SC", "Microsoft YaHei", "Courier New", monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  background: var(--bg); color: var(--text); font-size: 14px;
  display: flex;
}
.hidden { display: none !important; }
b.k { color: var(--primary); }
b.r { color: #dc2626; }
b.g { color: #059669; }
b.o { color: #d97706; }

/* ---------------- 侧边栏 ---------------- */
#sidebar {
  width: 232px; flex-shrink: 0; background: #0f172a; color: #cbd5e1;
  display: flex; flex-direction: column; height: 100vh; position: sticky; top: 0; overflow-y: auto;
}
.brand { display: flex; gap: 10px; align-items: center; padding: 20px 18px; color: #fff; text-decoration: none; }
.brand .logo {
  width: 42px; height: 42px; border-radius: 10px; display: grid; place-items: center;
  background: linear-gradient(135deg, #6366f1, #22d3ee); font-weight: 800; font-size: 15px;
}
.brand b { display: block; font-size: 15px; }
.brand small { color: #94a3b8; font-size: 12px; }
#nav { flex: 1; padding: 0 10px 10px; }
.nav-group { margin-top: 14px; }
.nav-group h4 { margin: 0 8px 6px; font-size: 12px; color: #64748b; font-weight: 600; letter-spacing: .08em; }
.nav-item {
  display: flex; gap: 8px; align-items: center; padding: 8px 10px; border-radius: 8px;
  color: #cbd5e1; text-decoration: none; font-size: 13.5px; margin: 1px 0;
}
.nav-item:hover { background: #1e293b; color: #fff; }
.nav-item.active { background: #4f46e5; color: #fff; }
.nav-item .ico { width: 20px; text-align: center; }
.side-foot { padding: 14px 18px; font-size: 12px; color: #64748b; line-height: 1.9; border-top: 1px solid #1e293b; }
kbd {
  background: #1e293b; border: 1px solid #334155; border-radius: 4px; padding: 0 5px;
  font-family: var(--mono); font-size: 11px; color: #e2e8f0;
}

/* ---------------- 主区域 ---------------- */
#main { flex: 1; min-width: 0; padding: 20px 24px 28px; overflow-x: hidden; }
.mod-head { display: flex; justify-content: space-between; gap: 24px; align-items: flex-end; margin-bottom: 14px; }
.mod-head h1 { margin: 2px 0 0; font-size: 22px; }
.mod-head p { margin: 0; color: var(--muted); max-width: 680px; line-height: 1.6; font-size: 13px; }
.crumb { color: var(--primary); font-size: 12px; font-weight: 600; }

/* 工具栏 */
.toolbar {
  display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: flex-end;
  background: var(--panel); border-radius: var(--radius); padding: 12px 14px; box-shadow: var(--shadow); margin-bottom: 14px;
}
.field { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
.field input[type=text], .field input[type=number], .field select, .field textarea {
  border: 1px solid var(--line); border-radius: 8px; padding: 6px 9px; font-size: 13px; color: var(--text);
  background: #fff; outline: none; font-family: inherit; height: 32px;
}
.field textarea { height: auto; font-family: var(--mono); font-size: 12px; resize: vertical; line-height: 1.5; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.check { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text); height: 32px; cursor: pointer; }
.tsep { width: 1px; align-self: stretch; background: var(--line); margin: 0 2px; }
.btn {
  height: 32px; padding: 0 14px; border-radius: 8px; border: 1px solid var(--line); background: #fff;
  font-size: 13px; cursor: pointer; color: var(--text); font-family: inherit; white-space: nowrap;
}
.btn:hover { border-color: var(--primary); color: var(--primary); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: #4338ca; color: #fff; }
.btn.danger:hover { border-color: #dc2626; color: #dc2626; }

/* 舞台 + 侧栏 */
.work-grid { display: grid; grid-template-columns: minmax(0, 1fr) clamp(360px, 27vw, 470px); gap: 14px; align-items: start; }
@media (max-width: 1200px) { .work-grid { grid-template-columns: 1fr; } }
.stage-card { background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.stage { position: relative; min-height: 480px; padding: 14px; overflow: auto; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; padding: 8px 16px; border-top: 1px solid var(--line); font-size: 12px; color: var(--muted); }
.legend:empty { display: none; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 14px; height: 14px; border-radius: 4px; display: inline-block; border: 1px solid rgba(0,0,0,.08); }
.legend i.round { border-radius: 50%; }

.controls { display: flex; align-items: center; gap: 8px; padding: 10px 14px; border-top: 1px solid var(--line); background: #fafbfe; }
.cbtn {
  width: 38px; height: 34px; border-radius: 8px; border: 1px solid var(--line); background: #fff; cursor: pointer;
  font-size: 13px; color: var(--text);
}
.cbtn:hover { border-color: var(--primary); color: var(--primary); }
.cbtn.play { width: 52px; background: var(--primary); color: #fff; border-color: var(--primary); font-size: 15px; }
.cbtn.play:hover { color: #fff; background: #4338ca; }
#progress { flex: 1; accent-color: var(--primary); }
.step-count { font-family: var(--mono); font-size: 12px; color: var(--muted); min-width: 74px; text-align: right; }
.speed { font-size: 12px; color: var(--muted); display: flex; gap: 6px; align-items: center; }
.speed select { border: 1px solid var(--line); border-radius: 6px; padding: 4px; }

.side { display: flex; flex-direction: column; gap: 14px; position: sticky; top: 14px; max-height: calc(100vh - 28px); overflow-y: auto; }
@media (max-width: 1200px) { .side { position: static; } }
.card { background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow); padding: 12px 14px; }
.card h3 { margin: 0 0 8px; font-size: 13px; color: var(--muted); font-weight: 600; }
.card h3 small { font-weight: 400; color: #94a3b8; }
.desc { font-size: 14px; line-height: 1.75; min-height: 74px; }
.desc.fresh { animation: fadeUp .35s ease-out; }
@keyframes fadeUp { from { opacity: .25; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.desc-card { border-left: 4px solid var(--primary); }
.desc .tip { display: block; margin-top: 6px; padding: 6px 10px; background: #fffbeb; border-radius: 6px; color: #92400e; font-size: 12.5px; }
.code { font-family: var(--mono); font-size: 12px; line-height: 1.6; max-height: max(240px, calc(100vh - 470px)); overflow: auto; background: #0f172a; color: #cbd5e1; border-radius: 8px; padding: 8px 0; scroll-behavior: smooth; }
.code .ln { display: flex; padding: 1px 10px 1px 4px; border-left: 3px solid transparent; transition: background .25s, border-color .25s; }
.code .ln .no { flex: none; color: #475569; width: 22px; text-align: right; margin-right: 10px; user-select: none; }
.code .ln .tx { flex: 1; min-width: 0; white-space: pre-wrap; word-break: break-word; }
.code .ln.hl { background: rgba(250, 204, 21, .18); border-left-color: #facc15; color: #fff; }
.code .cm { color: #64748b; }
.vars { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; font-size: 13px; }
.vars .vk { color: var(--muted); white-space: nowrap; }
.vars .vv { font-family: var(--mono); word-break: break-all; }
.vars .empty { color: #94a3b8; grid-column: 1 / -1; }

/* ---------------- 首页 ---------------- */
.hero {
  background: linear-gradient(135deg, #312e81, #4f46e5 55%, #0891b2); color: #fff; border-radius: 18px;
  padding: 34px 36px; margin-bottom: 22px; box-shadow: var(--shadow);
}
.hero h1 { margin: 0 0 10px; font-size: 28px; }
.hero p { margin: 0; opacity: .88; line-height: 1.8; max-width: 760px; }
.home-group h2 { font-size: 16px; margin: 22px 0 12px; color: var(--text); }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.mcard {
  background: var(--panel); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow);
  text-decoration: none; color: var(--text); border: 1px solid transparent; transition: .2s;
}
.mcard:hover { border-color: var(--primary); transform: translateY(-2px); }
.mcard .ico { font-size: 24px; }
.mcard h3 { margin: 6px 0 6px; font-size: 15px; }
.mcard p { margin: 0; color: var(--muted); font-size: 12.5px; line-height: 1.6; }
.mcard .tags { margin-top: 10px; display: flex; flex-wrap: wrap; gap: 6px; }
.mcard .tags span { background: var(--primary-soft); color: var(--primary); font-size: 11px; padding: 2px 8px; border-radius: 99px; }

#toast {
  position: fixed; left: 50%; top: 20px; transform: translate(-50%, -80px); background: #1e293b; color: #fff;
  padding: 10px 18px; border-radius: 10px; font-size: 13px; transition: transform .3s; z-index: 99; box-shadow: var(--shadow);
}
#toast.show { transform: translate(-50%, 0); }
#toast.err { background: #dc2626; }

/* ---------------- 通用 SVG 场景（树 / 图） ---------------- */
svg.scene { width: 100%; height: auto; display: block; overflow: visible; }
.node circle, .node rect { fill: #dbeafe; stroke: #3b82f6; stroke-width: 2; transition: fill .3s, stroke .3s, stroke-width .3s; }
.node .nl { font-size: 15px; font-weight: 700; fill: #1e293b; pointer-events: none; font-family: var(--mono); }
.node .nb { font-size: 12px; font-weight: 700; fill: #64748b; font-family: var(--mono); }
.node .nb.bad { fill: #dc2626; font-size: 13px; }
.node .ns { font-size: 12px; fill: #475569; font-family: var(--mono); font-weight: 600; paint-order: stroke; stroke: #fff; stroke-width: 4px; }
.node { transition: opacity .3s; }
.node.s-cur circle, .node.s-cur rect { stroke: #f59e0b; stroke-width: 5; fill: #fef3c7; }
.node.s-new circle { stroke: #2563eb; stroke-width: 5; fill: #bfdbfe; }
.node.s-ok circle { fill: #a7f3d0; stroke: #059669; }
.node.s-done circle { fill: #d1fae5; stroke: #10b981; }
.node.s-bad circle { stroke: #dc2626; stroke-width: 5; fill: #fee2e2; }
.node.s-rot circle { stroke: #8b5cf6; stroke-width: 5; fill: #ede9fe; }
.node.s-dim circle { fill: #f1f5f9; stroke: #cbd5e1; }
.node.s-dim .nl { fill: #94a3b8; }
.node.s-q circle { fill: #fde68a; stroke: #d97706; }
.node.s-src circle { fill: #c7d2fe; stroke: #4f46e5; stroke-width: 4; }
/* 红黑树：颜色由 fill 表达，状态由描边表达 */
.node.rb-red circle { fill: var(--c-red); stroke: #9f1239; }
.node.rb-black circle, .node.rb-black rect { fill: var(--c-black); stroke: #000; }
.node.rb-red .nl, .node.rb-black .nl { fill: #fff; }
.node.rb-red.s-cur circle, .node.rb-black.s-cur circle, .node.rb-black.s-cur rect { stroke: #f59e0b; stroke-width: 6; }
.node.rb-red.s-new circle, .node.rb-black.s-new circle { stroke: #3b82f6; stroke-width: 6; }
.node.rb-red.s-rot circle, .node.rb-black.s-rot circle { stroke: #a78bfa; stroke-width: 6; }
.node.rb-red.s-bad circle, .node.rb-black.s-bad circle, .node.rb-black.s-bad rect { stroke: #06b6d4; stroke-width: 6; stroke-dasharray: 5 3; }
.node.rb-red.s-ok circle, .node.rb-black.s-ok circle { stroke: #10b981; stroke-width: 6; }
.node.nil rect { stroke-width: 1; }
.node.nil .nl { font-size: 9px; fill: #fff; font-weight: 400; }

.edge { fill: none; stroke: #94a3b8; stroke-width: 2.2; transition: stroke .3s, stroke-width .3s, opacity .3s; }
.edge.hl { stroke: #f59e0b; stroke-width: 4; }
.edge.ok { stroke: #10b981; stroke-width: 4.5; }
.edge.bad { stroke: #ef4444; stroke-width: 3; stroke-dasharray: 6 4; }
.edge.dim { stroke: #e2e8f0; }
.edge.rot { stroke: #8b5cf6; stroke-width: 4; }
.el { font-size: 13px; font-weight: 700; fill: #475569; font-family: var(--mono); paint-order: stroke; stroke: #fff; stroke-width: 5px; transition: opacity .3s; }
.el.hl { fill: #b45309; }
.el.ok { fill: #047857; }
.el.dim { fill: #cbd5e1; }
.el.bad { fill: #dc2626; }

/* ---------------- 排序 ---------------- */
.sort-stage { position: relative; width: 100%; }
.sort-stage .bar {
  position: absolute; left: 0; top: 0; border-radius: 6px 6px 3px 3px; background: var(--c-base);
  transition-property: transform, background-color, opacity; transition-timing-function: ease-in-out;
  display: flex; justify-content: center;
}
.sort-stage .bar span { position: absolute; top: -20px; font-family: var(--mono); font-size: 12px; font-weight: 700; color: #334155; }
.sort-stage .bar.cmp { background: var(--c-cmp); }
.sort-stage .bar.swap { background: var(--c-swap); }
.sort-stage .bar.done { background: var(--c-ok); }
.sort-stage .bar.pivot { background: var(--c-pivot); }
.sort-stage .bar.act { background: var(--c-active); }
.sort-stage .bar.left { background: #60a5fa; }
.sort-stage .bar.right { background: #c084fc; }
.sort-stage .bar.dim { background: var(--c-dim); }
.sort-stage .bar.dim span { color: #94a3b8; }
.sort-stage .idx { position: absolute; font-family: var(--mono); font-size: 11px; color: #94a3b8; text-align: center; }
.sort-stage .hole { position: absolute; border: 2px dashed #cbd5e1; border-radius: 6px; }
.sort-stage .ptr {
  position: absolute; left: 0; top: 0; font-family: var(--mono); font-size: 12px; font-weight: 700; color: #4f46e5; text-align: center;
  transition: transform .35s ease-in-out; white-space: nowrap;
}
.sort-stage .ptr.alt { color: #db2777; }
.sort-stage .ptr.alt2 { color: #059669; }
.sort-stage .range { position: absolute; background: rgba(99, 102, 241, .07); border: 1px dashed rgba(99, 102, 241, .4); border-radius: 8px; transition: all .35s; }
.sort-stage .zone-label { position: absolute; left: 0; font-size: 12px; color: #94a3b8; }
.sort-stage .zone-line { position: absolute; left: 0; right: 0; border-top: 1px dashed #e2e8f0; }
.sort-stage .tag { position: absolute; left: 0; top: 0; font-size: 11px; color: #7c3aed; font-weight: 700; text-align: center; transition: transform .35s; white-space: nowrap; }
.sort-stage .heap-wrap { position: absolute; left: 0; right: 0; }

/* ---------------- 表格类面板 ---------------- */
.ptable { border-collapse: collapse; font-family: var(--mono); font-size: 12.5px; margin: 4px 0; }
.ptable th, .ptable td { border: 1px solid var(--line); padding: 4px 9px; text-align: center; min-width: 34px; height: 28px; transition: background-color var(--dur, .3s), color var(--dur, .3s), box-shadow var(--dur, .3s); }
.ptable td.chg, .ptable td.new, .ptable td.in-cell, .ptable td.victim { animation: pop .45s ease-out; }
@keyframes pop { 0% { transform: scale(.7); } 60% { transform: scale(1.12); } 100% { transform: none; } }
.ptable th { background: #f8fafc; color: var(--muted); font-weight: 600; }
.ptable td.cur, .ptable th.cur { background: #fef3c7; }
.ptable td.ok { background: #d1fae5; color: #065f46; font-weight: 700; }
.ptable td.bad { background: #fee2e2; color: #b91c1c; font-weight: 700; }
.ptable td.chg { background: #fee2e2; color: #b91c1c; font-weight: 700; }
.ptable td.dim { color: #cbd5e1; }
.ptable td.hl { background: #ede9fe; color: #6d28d9; font-weight: 700; }
.ptable td.new { background: #dbeafe; color: #1d4ed8; font-weight: 700; }
.ptable td.left { text-align: left; }
.panel-row { display: flex; flex-wrap: wrap; gap: 18px; align-items: flex-start; }
.panel-box { min-width: 0; }
.panel-box h4 { margin: 6px 0 6px; font-size: 12.5px; color: var(--muted); font-weight: 600; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; min-height: 32px; }
.chip {
  min-width: 34px; height: 32px; padding: 0 8px; border-radius: 8px; display: inline-grid; place-items: center;
  background: #e0e7ff; color: #3730a3; font-family: var(--mono); font-weight: 700; font-size: 13px; border: 2px solid transparent;
}
.chip.tall { height: auto; padding: 4px 8px; line-height: 1.3; }
.chip.cur { background: #fef3c7; color: #92400e; border-color: #f59e0b; }
.chip.ok { background: #d1fae5; color: #065f46; }
.chip.bad { background: #fee2e2; color: #b91c1c; border-color: #f87171; }
.chip.dim { background: #f1f5f9; color: #94a3b8; }
.chip.empty { background: transparent; border: 2px dashed #cbd5e1; color: #94a3b8; }
.chip small { font-size: 10px; font-weight: 400; display: block; line-height: 1.2; }
.arrow-lbl { font-size: 12px; color: var(--muted); }

/* ---------------- KMP ---------------- */
.kmp { font-family: var(--mono); }
.kmp .row { display: flex; align-items: center; min-height: 42px; position: relative; }
.kmp .row .lbl { width: 96px; flex-shrink: 0; font-size: 12px; color: var(--muted); font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif; }
.kmp .track { position: relative; height: 40px; flex: 1; }
.kmp .track.short { height: 22px; }
.kmp .strip { position: absolute; top: 0; left: 0; display: flex; transition: transform .45s ease-in-out; }
.kmp .cell {
  width: 38px; height: 38px; border: 1px solid #cbd5e1; display: grid; place-items: center; font-size: 16px; font-weight: 700;
  background: #fff; margin-right: -1px; transition: background .25s;
}
.kmp .cell.idx { border: none; background: transparent; font-size: 11px; color: #94a3b8; font-weight: 400; height: 20px; margin-right: 0; width: 37px; }
.kmp .cell.ok { background: #d1fae5; color: #065f46; }
.kmp .cell.bad { background: #fee2e2; color: #b91c1c; }
.kmp .cell.cur { background: #fef3c7; color: #92400e; box-shadow: inset 0 0 0 2px #f59e0b; }
.kmp .cell.dim { color: #cbd5e1; }
.kmp .cell.hl { background: #ede9fe; color: #6d28d9; }
.kmp .cell.found { background: #a7f3d0; color: #065f46; }
.kmp .cell.blank { border-color: transparent; }
.kmp .pointer { position: absolute; top: 0; left: 0; font-size: 12px; font-weight: 700; color: #4f46e5; transition: transform .45s ease-in-out; width: 37px; text-align: center; }
.kmp .pointer.p2 { color: #db2777; }
.kmp .section-title { margin: 14px 0 8px; font-size: 13px; color: var(--text); font-weight: 600; font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif; }

/* ---------------- 页面置换 ---------------- */
.pg-table td.hit-cell { background: #d1fae5; color: #065f46; font-weight: 700; }
.pg-table td.in-cell { background: #fee2e2; color: #b91c1c; font-weight: 700; }
.pg-table td.victim { background: #fde68a; color: #92400e; text-decoration: line-through; font-weight: 700; }
.pg-table th.future, .pg-table td.future { color: #cbd5e1; background: #fff; }
.pg-table td.mark-f { color: #dc2626; font-weight: 700; }
.pg-table td.mark-h { color: #059669; }
.pg-table th.colcur { background: #fef3c7; color: #92400e; box-shadow: inset 0 0 0 2px #f59e0b; }
.pg-table th.next-use { background: #ede9fe; color: #6d28d9; }

/* ---------------- 地址变换流程图 ---------------- */
.addr-grid { display: grid; grid-template-columns: 430px minmax(0, 1fr); gap: 16px; }
@media (max-width: 1500px) { .addr-grid { grid-template-columns: 1fr; } .addr-grid .flow { max-width: 520px; } }
.flow .fbox rect, .flow .fbox polygon { fill: #f8fafc; stroke: #cbd5e1; stroke-width: 1.5; transition: fill .3s, stroke .3s; }
.flow .fbox text { font-size: 12.5px; fill: #334155; }
.flow .fbox.on rect, .flow .fbox.on polygon { fill: #fef3c7; stroke: #f59e0b; stroke-width: 3; }
.flow .fbox.done rect, .flow .fbox.done polygon { fill: #ecfdf5; stroke: #6ee7b7; }
.flow .fbox.bad rect, .flow .fbox.bad polygon { fill: #fee2e2; stroke: #ef4444; stroke-width: 3; }
.flow .farrow { stroke: #cbd5e1; stroke-width: 1.6; fill: none; }
.flow .farrow.on { stroke: #f59e0b; stroke-width: 3; }
.flow .flabel { font-size: 11px; fill: #64748b; }
.addr-bits { display: flex; font-family: var(--mono); font-size: 12px; flex-wrap: wrap; gap: 2px; }
.addr-bits .bit { width: 16px; height: 22px; display: grid; place-items: center; border-radius: 3px; }
.addr-bits .bit.p { background: #e0e7ff; color: #3730a3; }
.addr-bits .bit.w { background: #fef3c7; color: #92400e; }
.addr-bits .bit.f { background: #d1fae5; color: #065f46; }
.addr-bits .gap { width: 8px; }
.addr-line { display: flex; align-items: center; gap: 10px; margin: 6px 0; font-size: 13px; flex-wrap: wrap; }
.addr-line .lab { width: 74px; color: var(--muted); font-size: 12px; }
.mem-frames { display: flex; gap: 8px; flex-wrap: wrap; }
.mem-frame { width: 96px; border: 2px solid #cbd5e1; border-radius: 8px; padding: 6px; text-align: center; font-family: var(--mono); font-size: 11.5px; background: #fff; transition: .3s; }
.mem-frame b { display: block; font-size: 15px; margin-top: 2px; }
.mem-frame.cur { border-color: #f59e0b; background: #fef3c7; }
.mem-frame.out { border-color: #ef4444; background: #fee2e2; }
.mem-frame.in { border-color: #3b82f6; background: #dbeafe; }
.timeline { font-family: var(--mono); font-size: 12.5px; line-height: 1.9; }
.timeline .t-item { display: inline-block; padding: 0 8px; margin: 2px; border-radius: 6px; background: #f1f5f9; }
.timeline .t-item.big { background: #fee2e2; color: #b91c1c; }
.timeline .t-sum { font-weight: 700; color: var(--primary); }

/* ---------------- 进程调度 ---------------- */
.gantt-wrap { overflow-x: auto; padding: 0 16px 0 4px; }
.gantt { position: relative; height: 96px; margin: 6px 0 4px; }
.gantt .blk {
  position: absolute; top: 22px; height: 40px; display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 13px;
  border-right: 1px solid rgba(255,255,255,.8); overflow: hidden; transition: width var(--dur, .3s) linear, left var(--dur, .3s);
}
.gantt .blk.idle { background: repeating-linear-gradient(45deg, #f1f5f9, #f1f5f9 5px, #e2e8f0 5px, #e2e8f0 10px); color: #94a3b8; }
.gantt .tick { position: absolute; top: 66px; font-family: var(--mono); font-size: 11px; color: #64748b; transform: translateX(-50%); }
.gantt .tickline { position: absolute; top: 18px; height: 48px; border-left: 1px dashed #e2e8f0; }
.gantt .now { position: absolute; top: 2px; height: 84px; border-left: 2px solid #ef4444; transition: left .3s; }
.gantt .now span { position: absolute; top: -2px; left: 4px; font-size: 11px; color: #ef4444; font-family: var(--mono); white-space: nowrap; }
.gantt .arrive { position: absolute; top: 82px; font-size: 10.5px; color: #4f46e5; transform: translateX(-50%); white-space: nowrap; font-family: var(--mono); }

/* ---------------- 磁盘调度 ---------------- */
.disk-svg .axis { stroke: #94a3b8; stroke-width: 1.5; }
.disk-svg .tk { font-size: 11px; fill: #94a3b8; font-family: var(--mono); }
.disk-svg .req { fill: #3b82f6; }
.disk-svg .req.done { fill: #cbd5e1; }
.disk-svg .req.cur { fill: #f59e0b; }
.disk-svg .reqlbl { font-size: 11.5px; fill: #1d4ed8; font-family: var(--mono); font-weight: 700; }
.disk-svg .reqlbl.done { fill: #94a3b8; }
.disk-svg .reqlbl.cur { fill: #b45309; }
.disk-svg .path { fill: none; stroke: #6366f1; stroke-width: 2.5; }
.disk-svg .seg-new { fill: none; stroke: #f59e0b; stroke-width: 3.5; }
.disk-svg .seg-jump { fill: none; stroke: #94a3b8; stroke-width: 2; stroke-dasharray: 6 5; }
.disk-svg .pt { fill: #6366f1; }
.disk-svg .ptl { font-size: 11px; fill: #475569; font-family: var(--mono); paint-order: stroke; stroke: #fff; stroke-width: 4px; }
.disk-svg .head { fill: #f59e0b; stroke: #fff; stroke-width: 2; transition: cx var(--dur, .4s) ease-in-out, cy var(--dur, .4s) ease-in-out; }
.disk-svg .grid { stroke: #f1f5f9; }
.disk-svg .anim { animation: draw .5s ease-out both; }
@keyframes draw { from { stroke-dashoffset: var(--len); } to { stroke-dashoffset: 0; } }

/* ---------------- 通用：过渡、代码放大 ---------------- */
.instant, .instant * { transition: none !important; animation: none !important; }
.vars .vv.changed { animation: flashVar .8s ease-out; border-radius: 4px; }
@keyframes flashVar { 0% { background: #fde68a; } 100% { background: transparent; } }
.mem-frame, .chip, .kmp .cell, .bitcell { transition: background-color var(--dur, .3s), border-color var(--dur, .3s), color var(--dur, .3s); }
.card h3 .mini { float: right; border: 1px solid var(--line); background: #fff; border-radius: 6px; cursor: pointer; font-size: 12px; color: var(--muted); padding: 1px 7px; }
.card h3 .mini:hover { color: var(--primary); border-color: var(--primary); }
.card.expanded { position: fixed; z-index: 60; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(900px, 92vw); box-shadow: 0 0 0 100vmax rgba(15, 23, 42, .55), var(--shadow); }
.card.expanded .code { max-height: 78vh; font-size: 14.5px; }
.nav-group h4 { cursor: pointer; user-select: none; display: flex; justify-content: space-between; }
.nav-group h4::after { content: '▾'; transition: transform .2s; }
.nav-group.collapsed h4::after { transform: rotate(-90deg); }
.nav-group.collapsed .nav-item { display: none; }
.nav-search { margin: 0 14px 4px; padding: 7px 10px; border-radius: 8px; border: 1px solid #334155; background: #1e293b; color: #e2e8f0; font-size: 13px; outline: none; }
.nav-search:focus { border-color: #6366f1; }
