/* ============================================================
   算法沙盘 · 站点样式
   原则：一层信息一层视觉权重，动画只服务于“当前这一步”
   ============================================================ */

:root {
  --bg: #F7F7F8;
  --surface: #FFFFFF;
  --surface-2: #F1F2F4;
  --text: #17181A;
  --muted: #6B7076;
  --border: rgba(23, 24, 26, 0.10);
  --border-strong: rgba(23, 24, 26, 0.20);
  --brand: #0FDC78;
  --brand-ink: #04783F;
  --brand-soft: #E7FFF1;
  --accent: #F0764A;
  --accent-soft: #FFF0E9;
  --bar: #CDD2D9;
  --bar-ink: #555B63;
  --danger: #C0392B;
  --radius: 8px;
  --radius-lg: 14px;
  --shadow: 0 1px 2px rgba(16, 20, 24, 0.04), 0 10px 28px rgba(16, 20, 24, 0.045);
  --font: "SF Pro Text", "PingFang SC", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "SF Mono", ui-monospace, Menlo, Consolas, "JetBrains Mono", monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0E1011;
    --surface: #17191B;
    --surface-2: #1F2225;
    --text: #E7E9EA;
    --muted: #9BA3AB;
    --border: rgba(255, 255, 255, 0.09);
    --border-strong: rgba(255, 255, 255, 0.18);
    --brand: #32F08C;
    --brand-ink: #7DF5B6;
    --brand-soft: #0D2A1B;
    --accent: #FF8A5C;
    --accent-soft: #2B160F;
    --bar: #2B3035;
    --bar-ink: #C9CFD6;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 10px 28px rgba(0, 0, 0, 0.25);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
button, input, select { font: inherit; color: inherit; }
h1, h2, h3, p { margin: 0; }

/* ---------- 顶栏 ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  gap: 24px;
  flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 8px; font-size: 16px; font-weight: 700; letter-spacing: .2px; }
.brand-mark { display: inline-flex; width: 22px; height: 22px; flex: none; }
.brand-mark svg { width: 100%; height: 100%; display: block; }
.brand-mark .mark-frame,
.brand-mark .mark-path { stroke-dasharray: 1; stroke-dashoffset: 0; }
.brand-mark .mark-dot { transform-box: fill-box; transform-origin: center; }
/* 启动动画：外框 → 路径“走”一遍 → 当前帧圆点点亮 */
.brand-mark.is-intro .mark-frame {
  stroke-dashoffset: 1;
  animation: mark-draw .4s cubic-bezier(.4, 0, .2, 1) .04s forwards;
}
.brand-mark.is-intro .mark-path {
  stroke-dashoffset: 1;
  animation: mark-draw .55s cubic-bezier(.4, 0, .2, 1) .18s forwards;
}
.brand-mark.is-intro .mark-dot {
  transform: scale(0);
  animation: mark-pop .3s cubic-bezier(.34, 1.56, .64, 1) .7s forwards;
}
@keyframes mark-draw { to { stroke-dashoffset: 0; } }
@keyframes mark-pop {
  from { transform: scale(0); }
  to { transform: scale(1); }
}
@media (prefers-reduced-motion: reduce) {
  .brand-mark.is-intro .mark-frame,
  .brand-mark.is-intro .mark-path { stroke-dashoffset: 0; animation: none; }
  .brand-mark.is-intro .mark-dot { transform: none; animation: none; }
}
.brand-sub { font-size: 12px; font-weight: 400; color: var(--muted); letter-spacing: 0; }
.algo-nav { display: flex; gap: 4px; flex-wrap: wrap; margin-left: auto; }
.nav-split { width: 1px; height: 18px; margin: 0 7px; align-self: center; background: var(--line); }
.menu { position: relative; }
.menu-trigger {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1px solid transparent;
  background: transparent;
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 13px;
  color: var(--muted);
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
}
.menu-trigger:hover { background: var(--surface-2); color: var(--text); }
.menu.is-open .menu-trigger,
.menu-trigger.is-current {
  background: var(--surface-2);
  border-color: var(--border);
  color: var(--text);
  font-weight: 600;
}
.menu-trigger.is-current::before {
  content: '';
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--brand);
}
.caret {
  width: 0;
  height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid currentColor;
  opacity: .55;
  transition: transform .15s;
}
.menu.is-open .caret { transform: rotate(180deg); }
.menu-panel {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 40;
  min-width: 224px;
  max-height: min(640px, 72vh);
  overflow-y: auto;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  display: none;
}
.menu.is-open .menu-panel { display: block; animation: menu-in .12s ease-out; }
.menu:last-child .menu-panel { left: auto; right: 0; }
@keyframes menu-in {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: none; }
}
.menu-item {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border: 0;
  background: transparent;
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 13px;
  color: var(--text);
  text-align: left;
  cursor: pointer;
  transition: background .12s, color .12s;
}
.menu-item:hover { background: var(--surface-2); }
.menu-item[aria-current="true"] {
  background: var(--brand-soft);
  color: var(--brand-ink);
  font-weight: 600;
}
.menu-item-tag { font-size: 11px; font-weight: 400; color: var(--muted); }
.menu-item-name { white-space: nowrap; }
.menu-panel-app { min-width: 316px; }
.menu-item-tag.is-academic { color: #4CC9F0; opacity: .9; white-space: nowrap; }
.menu-item[aria-current="true"] .menu-item-tag { color: var(--brand-ink); opacity: .8; }
.menu-kind {
  font-size: 9.5px; font-weight: 600; letter-spacing: .4px;
  padding: 1px 6px; border-radius: 999px;
  color: #4CC9F0; background: rgba(76, 201, 240, .13);
}
.menu-group + .menu-group { border-top: 1px solid var(--border); margin-top: 2px; padding-top: 2px; }
.menu-group-label {
  position: sticky;
  top: -6px;
  z-index: 1;
  padding: 8px 10px 4px;
  font-size: 11px;
  letter-spacing: .5px;
  color: var(--muted);
  background: var(--surface);
}
@media (prefers-reduced-motion: reduce) {
  .menu.is-open .menu-panel { animation: none; }
  .caret { transition: none; }
}

/* ---------- 页面骨架 ---------- */
.page { max-width: 1280px; margin: 0 auto; padding: 20px 24px 48px; }
.layout {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(320px, 1fr);
  gap: 16px;
  align-items: start;
}
.side { display: flex; flex-direction: column; gap: 16px; }
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

/* ---------- 舞台 ---------- */
.stage { padding: 20px; }
.stage-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; }
.algo-title { font-size: 20px; font-weight: 650; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; letter-spacing: -.2px; }
.tag {
  font-size: 11px; font-weight: 500; padding: 2px 9px; border-radius: 999px;
  background: var(--surface-2); color: var(--muted); letter-spacing: .2px;
}
.tag-app {
  background: rgba(15, 220, 120, .09);
  color: var(--brand);
  box-shadow: inset 0 0 0 1px rgba(15, 220, 120, .28);
}
.summary { margin-top: 6px; color: var(--muted); font-size: 13px; max-width: 58ch; }

.canvas {
  margin-top: 16px;
  border-radius: 12px;
  background: var(--surface-2);
  padding: 16px;
  overflow: hidden;
}

.note {
  margin-top: 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 46px;
  padding: 10px 14px;
  border-radius: 10px;
  background: var(--brand-soft);
  color: var(--brand-ink);
  font-size: 13px;
  line-height: 1.5;
  transition: background .2s;
}
.note.is-idle { background: var(--surface-2); color: var(--muted); }
.note-idx {
  flex: none;
  font-family: var(--mono);
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--brand-ink) 14%, transparent);
}

/* ---------- 播放器 ---------- */
.player { margin-top: 12px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.icon-btn {
  width: 36px; height: 36px;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 10px;
  cursor: pointer;
  font-size: 13px;
  transition: background .15s, border-color .15s, transform .1s;
}
.icon-btn:hover { background: var(--surface-2); }
.icon-btn:active { transform: scale(.96); }
.icon-btn:disabled { opacity: .35; cursor: not-allowed; }
.icon-btn:disabled:active { transform: none; }
.icon-btn.primary {
  width: 42px; height: 42px;
  background: var(--brand);
  border-color: var(--brand-ink);
  color: #04331C;
  font-weight: 700;
  font-size: 15px;
}
.icon-btn.primary:hover { filter: brightness(1.04); }

.slider { flex: 1; min-width: 120px; accent-color: var(--brand-ink); cursor: pointer; }
.counter { font-family: var(--mono); font-size: 12px; color: var(--muted); white-space: nowrap; }
.speed {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 8px;
  padding: 6px 8px;
  font-size: 12px;
  cursor: pointer;
}
.metrics { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--border); }
.metric { font-size: 12px; color: var(--muted); }
.metric b { font-family: var(--mono); font-size: 14px; color: var(--text); font-weight: 600; margin-right: 4px; }

/* ---------- 输入 ---------- */
.inputs { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.field { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.field input, .field select {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 13px;
  color: var(--text);
  outline: none;
  transition: border-color .15s;
}
.field input:focus, .field select:focus { border-color: var(--brand-ink); }
.field input.wide { width: 236px; font-family: var(--mono); font-size: 12px; }
.btn {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 8px;
  padding: 6px 14px;
  font-size: 13px;
  cursor: pointer;
  transition: background .15s;
}
.btn:hover { background: var(--surface-2); }
.btn-ghost { border-color: transparent; color: var(--muted); }
.err { flex-basis: 100%; color: var(--danger); font-size: 12px; }

/* ---------- 代码面板 ---------- */
.code-card { padding: 16px; }
.code-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.code-title { font-size: 12px; font-weight: 600; color: var(--muted); letter-spacing: .4px; }
.code-tip { font-size: 11px; color: var(--muted); }
.code-body { font-family: var(--mono); font-size: 12.5px; line-height: 1.85; overflow-x: auto; }
.code-line {
  display: flex;
  gap: 12px;
  padding: 0 8px;
  border-radius: 6px;
  white-space: pre;
  cursor: pointer;
  transition: background .15s, box-shadow .15s;
}
.code-line:hover { background: var(--surface-2); }
.code-line.is-active { background: var(--brand-soft); box-shadow: inset 2px 0 0 var(--brand-ink); }
.ln { flex: none; width: 18px; text-align: right; color: var(--muted); font-size: 11px; user-select: none; }

/* ---------- 讲解区 ---------- */
.depth-zone { margin-top: 16px; display: flex; flex-direction: column; gap: 16px; }
.panel { padding: 20px; }
.panel-label { font-size: 11px; font-weight: 600; letter-spacing: .8px; color: var(--muted); text-transform: uppercase; }
.panel-title { font-size: 16px; font-weight: 650; margin-top: 6px; }

.l1-grid { display: grid; grid-template-columns: 1.15fr 1fr; gap: 20px; margin-top: 14px; }
@media (max-width: 860px) { .l1-grid { grid-template-columns: 1fr; } }
.analogy { font-size: 15px; line-height: 1.8; }
.essence { border-left: 3px solid var(--brand); padding-left: 14px; line-height: 1.8; }
.steps { margin: 8px 0 0; padding-left: 20px; color: var(--muted); font-size: 13px; }
.steps li + li { margin-top: 4px; }
.l1-foot { margin-top: 16px; padding-top: 14px; border-top: 1px dashed var(--border); font-size: 12px; color: var(--muted); }

.l3-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 12px; margin-top: 14px; }
.kv { border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px; }
.kv h3 { font-size: 13px; font-weight: 600; margin-bottom: 8px; }
.kv ul { margin: 0; padding-left: 18px; color: var(--muted); font-size: 13px; }
.kv li + li { margin-top: 5px; }
.kv .mono { font-family: var(--mono); font-size: 12.5px; color: var(--text); }
.kv p { color: var(--muted); font-size: 13px; }

/* ---------- 数组条形视图 ---------- */
.av { display: flex; flex-direction: column; gap: 0; }
.av-bars { display: flex; align-items: flex-end; gap: 8px; height: 236px; padding: 0 4px; }
.av-slot { flex: 1; min-width: 0; height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; }
.av-bar {
  width: 100%;
  max-width: 64px;
  border: 1px solid transparent;
  border-radius: 6px 6px 3px 3px;
  background: var(--bar);
  display: flex;
  justify-content: center;
  transition: height .3s cubic-bezier(.4, 0, .2, 1), background-color .18s, border-color .18s, box-shadow .18s;
}
.av-val { font-family: var(--mono); font-size: 11px; padding-top: 4px; color: var(--bar-ink); transition: color .18s; }
.av-idx { font-family: var(--mono); font-size: 11px; color: var(--muted); margin-top: 6px; }
.av-slot.is-sorted .av-bar { background: var(--brand-soft); border-color: var(--brand); }
.av-slot.is-sorted .av-val { color: var(--brand-ink); }
.av-slot.is-compare .av-bar { background: var(--brand); border-color: var(--brand-ink); }
.av-slot.is-compare .av-val { color: #04331C; }
.av-slot.is-swap .av-bar { background: var(--accent); border-color: var(--accent); }
.av-slot.is-swap .av-val { color: #2A0F06; }
.av-slot.is-pivot .av-bar {
  background: #F5C451;
  border-color: #F5C451;
  box-shadow: 0 0 14px rgba(245, 196, 81, .55);
}
.av-slot.is-pivot .av-val { color: #2E2205; }
.av-markers { display: flex; gap: 8px; padding: 0 4px; margin-top: 6px; }
.av-marker-slot { flex: 1; text-align: center; min-height: 16px; }
.av-marker { font-family: var(--mono); font-size: 10px; color: var(--muted); }

/* ---------- 区间格视图 ---------- */
.rc { display: flex; flex-direction: column; gap: 12px; padding-top: 4px; }
.rc-head { display: flex; align-items: center; justify-content: space-between; font-size: 12px; color: var(--muted); }
.rc-target {
  font-family: var(--mono); font-size: 12px; color: var(--text);
  background: var(--surface); border: 1px solid var(--border);
  padding: 3px 11px; border-radius: 999px;
}
.rc-cells { display: flex; gap: 6px; }
.rc-cell {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 12px 0 9px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  transition: opacity .2s, background .2s, border-color .2s, box-shadow .2s;
}
.rc-val { font-family: var(--mono); font-size: 14px; }
.rc-idx { font-family: var(--mono); font-size: 10px; color: var(--muted); }
.rc-cell.is-out { opacity: .26; }
.rc-cell.is-mid { border-color: var(--brand); background: var(--brand-soft); box-shadow: 0 0 0 1px var(--brand); }
.rc-cell.is-mid .rc-val { color: var(--brand-ink); }
.rc-cell.is-found { border-color: var(--brand-ink); background: var(--brand); }
.rc-cell.is-found .rc-val { color: #04331C; font-weight: 700; }
.rc-cell.is-found .rc-idx { color: #04331C; opacity: .75; }
.rc-ptrs { display: flex; gap: 6px; }
.rc-ptr-slot { flex: 1; min-width: 0; display: flex; justify-content: center; gap: 4px; min-height: 22px; }
.rc-ptr {
  font-family: var(--mono); font-size: 10px; line-height: 1.4;
  padding: 1px 5px; border-radius: 999px; white-space: nowrap;
  background: var(--surface-2); color: var(--muted); border: 1px solid var(--border);
}
.rc-ptr.lo { color: var(--brand-ink); border-color: var(--brand); }
.rc-ptr.hi { color: var(--accent); border-color: var(--accent); }
.rc-ptr.mid { background: var(--brand); color: #04331C; border-color: var(--brand-ink); font-weight: 600; }
.rc-foot { font-size: 12px; color: var(--muted); font-family: var(--mono); }

/* ---------- 图视图 ---------- */
.gv { display: flex; flex-direction: column; gap: 10px; }
.gv-stage {
  position: relative;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, .07);
  background:
    radial-gradient(120% 90% at 18% 0%, rgba(76, 201, 240, .13) 0%, transparent 55%),
    radial-gradient(100% 100% at 90% 100%, rgba(15, 220, 120, .10) 0%, transparent 60%),
    #080C11;
  overflow: hidden;
}
.gv-stage::before {
  content: '';
  position: absolute; inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, .035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, .035) 1px, transparent 1px);
  background-size: 28px 28px;
  -webkit-mask-image: radial-gradient(80% 80% at 50% 45%, #000 40%, transparent 100%);
  mask-image: radial-gradient(80% 80% at 50% 45%, #000 40%, transparent 100%);
  pointer-events: none;
}
.gv-svg { position: relative; width: 100%; height: auto; display: block; }
.gv-stage::after {
  content: '';
  position: absolute; inset: 0;
  background: linear-gradient(180deg, transparent 0%, rgba(76, 201, 240, .055) 48%, rgba(15, 220, 120, .045) 52%, transparent 100%);
  background-size: 100% 220%;
  animation: gv-scan 7s linear infinite;
  pointer-events: none;
}
.gv-edge { stroke: rgba(255, 255, 255, .17); stroke-width: 2; fill: none; transition: stroke .18s, stroke-width .18s, opacity .18s; }
.gv-edge.is-active { stroke: var(--brand); stroke-width: 3; filter: drop-shadow(0 0 4px rgba(15, 220, 120, .55)); }
.gv-edge.is-tree { stroke: var(--brand); stroke-width: 2.6; filter: drop-shadow(0 0 3px rgba(15, 220, 120, .4)); }
.gv-edge.is-path {
  stroke: var(--accent); stroke-width: 3; stroke-dasharray: 7 7;
  animation: gv-flow .9s linear infinite;
  filter: drop-shadow(0 0 5px rgba(240, 118, 74, .6));
}
.gv-edge.is-relax { stroke: #F5C451; stroke-width: 2.4; stroke-dasharray: 4 4; }
.gv-edge.is-reject { stroke: rgba(255, 255, 255, .10); stroke-dasharray: 3 5; }
.gv-edge.is-fail { stroke: rgba(245, 196, 81, .45); stroke-width: 1.6; stroke-dasharray: 3 6; }
.gv-edge.is-critical { stroke: #FF6B6B; stroke-width: 3.2; filter: drop-shadow(0 0 5px rgba(255, 107, 107, .6)); }
.gv-arrow { fill: rgba(255, 255, 255, .55); }
.gv-edge-label {
  font-family: var(--mono); font-size: 10.5px; fill: #B7C3CF;
  paint-order: stroke; stroke: #080C11; stroke-width: 4px; stroke-linejoin: round;
}

.gv-node text { text-anchor: middle; }
.gv-node .gv-disc { fill: #101820; stroke: rgba(255, 255, 255, .20); stroke-width: 2; transition: fill .2s, stroke .2s; }
.gv-node .gv-halo { fill: none; stroke: transparent; transform-box: fill-box; transform-origin: center; }
.gv-node .id { font-family: var(--mono); font-size: 13px; font-weight: 600; fill: #DDE6EE; transition: fill .18s; }
.gv-node .dist { font-family: var(--mono); font-size: 10px; fill: #8494A3; }
.gv-node.is-frontier .gv-disc { stroke: #4CC9F0; fill: rgba(76, 201, 240, .10); }
.gv-node.is-visited .gv-disc { fill: rgba(15, 220, 120, .14); stroke: rgba(15, 220, 120, .85); }
.gv-node.is-done .gv-disc { stroke: rgba(15, 220, 120, .45); }
.gv-node.tone-scc0 .gv-disc { fill: rgba(155, 140, 255, .20); stroke: #9B8CFF; }
.gv-node.tone-scc1 .gv-disc { fill: rgba(76, 201, 240, .18); stroke: #4CC9F0; }
.gv-node.tone-scc2 .gv-disc { fill: rgba(240, 118, 74, .18); stroke: var(--accent); }
.gv-node.tone-scc3 .gv-disc { fill: rgba(255, 107, 168, .18); stroke: #FF6BA8; }
.gv-node.tone-scc4 .gv-disc { fill: rgba(15, 220, 120, .16); stroke: var(--brand); }
.gv-node.tone-scc5 .gv-disc { fill: rgba(245, 196, 81, .16); stroke: #F5C451; }
.gv-node.tone-critical .gv-disc { stroke: #FF6B6B; fill: rgba(255, 107, 107, .16); }
.gv-node.tone-good .gv-disc { stroke: var(--brand); fill: rgba(15, 220, 120, .18); }
.gv-node.tone-wall .gv-disc { fill: rgba(255, 255, 255, .07); stroke: rgba(255, 255, 255, .10); }
.gv-node.tone-goal .gv-disc { stroke: #F5C451; fill: rgba(245, 196, 81, .22); }
.gv-node.is-current .gv-disc { fill: var(--brand); stroke: #C8FFE0; filter: drop-shadow(0 0 12px rgba(15, 220, 120, .85)); }
.gv-node.is-current .id { fill: #04331C; }
.gv-node.is-current .gv-halo { stroke: rgba(15, 220, 120, .55); animation: gv-pulse 1.6s ease-out infinite; }
.gv-node.is-visited .gv-disc { filter: drop-shadow(0 0 6px rgba(15, 220, 120, .35)); }
.gv-node.tone-critical .gv-disc { filter: drop-shadow(0 0 7px rgba(255, 107, 107, .55)); }
.gv-node.tone-good .gv-disc { filter: drop-shadow(0 0 7px rgba(15, 220, 120, .5)); }
.gv-node.tone-goal .gv-disc { filter: drop-shadow(0 0 9px rgba(245, 196, 81, .6)); }
.gv-node.tone-scc0 .gv-disc { filter: drop-shadow(0 0 6px rgba(155, 140, 255, .5)); }
.gv-node.tone-scc1 .gv-disc { filter: drop-shadow(0 0 6px rgba(76, 201, 240, .5)); }
.gv-node.tone-scc2 .gv-disc { filter: drop-shadow(0 0 6px rgba(240, 118, 74, .5)); }

.gv-node .gv-badge { opacity: 0; transform: scale(.6); transform-box: fill-box; transform-origin: center; transition: opacity .18s, transform .18s; }
.gv-node .gv-badge.is-on { opacity: 1; transform: scale(1); }
.gv-node .gv-badge circle { fill: var(--accent); stroke: #FFE2D4; stroke-width: 1; }
.gv-node .gv-badge text { fill: #3A1B0E; font-size: 9px; font-weight: 700; font-family: var(--mono); }
.gv-node.is-hidden { opacity: 0; pointer-events: none; transition: opacity .25s; }
.gv-edge.is-hidden { opacity: 0; }
.gv-edge-label.is-hidden { opacity: 0; }

.gv-queue { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; font-size: 12px; color: var(--muted); min-height: 30px; }
.gv-queue .label { font-weight: 600; color: var(--muted); }
.gv-chip {
  font-family: var(--mono); font-size: 11.5px; padding: 3px 10px;
  border-radius: 999px; border: 1px solid var(--border); background: var(--surface);
  transition: border-color .18s, color .18s, opacity .18s;
}
.gv-chip.front { border-color: var(--brand); color: var(--brand-ink); background: var(--brand-soft); }
.gv-chip.empty { border-style: dashed; background: transparent; }
.gv-chip.accept { border-color: var(--brand); color: var(--brand-ink); }
.gv-chip.reject { opacity: .45; text-decoration: line-through; }
.gv-chip.active { border-color: var(--accent); color: var(--accent); }

.gv-legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 11px; color: var(--muted); }
.gv-legend span { display: inline-flex; align-items: center; gap: 5px; }
.gv-legend .dot { width: 9px; height: 9px; border-radius: 50%; border: 2px solid var(--border-strong); background: var(--surface); display: inline-block; }
.gv-legend .dot.visited { border-color: var(--brand); background: rgba(15, 220, 120, .25); }
.gv-legend .dot.current { border-color: var(--brand); background: var(--brand); box-shadow: 0 0 0 3px rgba(15, 220, 120, .2); }
.gv-legend .dot.frontier { border-color: #4CC9F0; }
.gv-legend .dot.path { border-color: var(--accent); background: var(--accent-soft); }
.gv-legend .dot.tree { border-color: var(--brand); background: var(--brand-soft); }
.gv-legend .dot.critical { border-color: #FF6B6B; }
.gv-legend .dot.reject { border-color: var(--border-strong); opacity: .5; }
.gv-legend .dot.active { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(15, 220, 120, .18); }
.gv-legend .dot.relax { border-color: #F5C451; background: rgba(245, 196, 81, .25); }
.gv-legend .dot.good { border-color: var(--brand); background: rgba(15, 220, 120, .24); }

@keyframes gv-flow { to { stroke-dashoffset: -14; } }
@keyframes gv-scan {
  0% { background-position: 0 -110%; }
  100% { background-position: 0 210%; }
}
@keyframes gv-pulse {
  0% { stroke-width: 2; stroke-opacity: .8; transform: scale(.92); }
  70% { stroke-width: 2; stroke-opacity: 0; transform: scale(1.22); }
  100% { stroke-width: 2; stroke-opacity: 0; transform: scale(1.22); }
}
@media (prefers-reduced-motion: reduce) {
  .gv-edge.is-path { animation: none; }
  .gv-node.is-current .gv-halo { animation: none; }
  .gv-stage::after { animation: none; }
}

/* ---------- 矩阵视图 ---------- */
.mx { display: flex; flex-direction: column; gap: 10px; }
.mx-title { font-size: 12px; color: var(--muted); }
.mx-stage {
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, .07);
  background:
    radial-gradient(120% 90% at 15% 0%, rgba(76, 201, 240, .12) 0%, transparent 55%),
    radial-gradient(100% 100% at 92% 100%, rgba(15, 220, 120, .10) 0%, transparent 60%),
    #080C11;
  padding: 14px;
  overflow-x: auto;
}
.mx-grid { display: grid; gap: 5px; }
.mx-corner {
  font-family: var(--mono); font-size: 10px; color: #5F7180;
  display: flex; align-items: center; justify-content: center;
}
.mx-head {
  font-family: var(--mono); font-size: 11.5px; color: #8FA0B0;
  display: flex; align-items: center; justify-content: center;
  min-height: 32px; border-radius: 7px;
  transition: background .18s, color .18s, box-shadow .18s;
}
.mx-head.is-active {
  color: #04331C; background: var(--brand);
  box-shadow: 0 0 14px rgba(15, 220, 120, .45);
}
.mx-cell {
  min-height: 38px; display: flex; align-items: center; justify-content: center;
  border-radius: 7px; border: 1px solid rgba(255, 255, 255, .08);
  background: rgba(255, 255, 255, .03);
  font-family: var(--mono); font-size: 12.5px; color: #C6D2DD;
  transition: border-color .18s, background .18s, color .18s, box-shadow .18s;
}
.mx-cell.is-active {
  border-color: var(--brand); background: rgba(15, 220, 120, .16);
  color: #C8FFE0; box-shadow: 0 0 16px rgba(15, 220, 120, .30);
  animation: mx-pop .32s ease-out;
}
.mx-cell.is-relax {
  border-color: rgba(245, 196, 81, .75); background: rgba(245, 196, 81, .13);
  color: #F5C451;
}
.mx-cell.is-path {
  border-color: var(--accent); background: rgba(240, 118, 74, .15);
  color: #FFB99E;
}
.mx-cell.is-good {
  border-color: rgba(15, 220, 120, .55); color: #A7F5C9;
}
.mx-caption {
  font-family: var(--mono); font-size: 12px; color: var(--muted); min-height: 20px;
}
.mx-caption.is-done { color: var(--brand-ink); }
@keyframes mx-pop {
  0% { transform: scale(.92); }
  60% { transform: scale(1.04); }
  100% { transform: scale(1); }
}
@media (prefers-reduced-motion: reduce) {
  .mx-cell.is-active { animation: none; }
}

/* ---------- 页脚 ---------- */
.footer {
  max-width: 1280px; margin: 0 auto; padding: 0 24px 40px;
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  color: var(--muted); font-size: 12px;
}
.badge-ok { color: var(--brand-ink); border: 1px solid var(--brand); background: var(--brand-soft); padding: 2px 9px; border-radius: 999px; }
.badge-bad { color: var(--danger); border: 1px solid var(--danger); padding: 2px 9px; border-radius: 999px; }
.badge-warn { color: var(--accent); border: 1px solid var(--accent); background: var(--accent-soft); padding: 2px 9px; border-radius: 999px; }

/* ---------- 序列 / 散点视图 ---------- */
.sv { display: flex; flex-direction: column; gap: 10px; }
.sv-svg { width: 100%; height: auto; display: block; }
.sv-legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 11px; color: var(--muted); }
.sv-legend span { display: inline-flex; align-items: center; gap: 5px; }
.sv-key { width: 14px; height: 3px; border-radius: 2px; display: inline-block; }
.sv-axis { font-family: var(--mono); font-size: 10px; fill: var(--muted); }
.sv-grid-line { stroke: var(--border); stroke-width: 1; }
.sv-cursor { stroke: var(--brand-ink); stroke-width: 1; stroke-dasharray: 3 3; opacity: .55; }
.sv-mark-label { font-family: var(--mono); font-size: 10px; font-weight: 600; }
.sv-band { opacity: .1; }
.sv-path { fill: none; stroke: var(--brand); stroke-width: 1; opacity: .16; }
.sv-ref { stroke: var(--accent); stroke-width: 1; stroke-dasharray: 4 4; opacity: .8; }
.sv-ref-label { font-family: var(--mono); font-size: 10px; fill: var(--accent); }
.sv-guide { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 2 4; opacity: .45; }
.sv-legend-sub { color: var(--muted); opacity: .8; }
.sc-dot { fill: var(--bar-ink); opacity: .55; }
.sc-dot.cls-1 { fill: var(--accent); opacity: .75; }
.sc-dot.cls-2 { fill: var(--cyan); opacity: .85; }
.sc-dot.is-active { fill: var(--brand); opacity: 1; }
.sc-fit { stroke: var(--brand); stroke-width: 2.4; stroke-linecap: round; }
.sc-curve {
  fill: none;
  stroke: var(--brand);
  stroke-width: 2.4;
  stroke-linejoin: round;
  stroke-linecap: round;
  filter: drop-shadow(0 0 6px rgba(58, 240, 162, .45));
}
.sc-curve.is-accent { stroke: var(--accent); filter: drop-shadow(0 0 6px rgba(255, 160, 63, .4)); }
.sc-curve.is-cyan { stroke: var(--cyan); filter: drop-shadow(0 0 6px rgba(95, 227, 255, .45)); }
.sc-residual { stroke: var(--accent); stroke-width: 1; stroke-dasharray: 3 3; opacity: .5; }
.sc-proj { stroke: rgba(95, 227, 255, .45); stroke-width: 1; stroke-dasharray: 3 3; }
.sc-center { stroke: #F5C451; stroke-width: 1.6; opacity: .95; }
.sc-center-label,
.sc-centroid-label {
  fill: #F5C451;
  font-family: var(--mono);
  font-size: 10px;
  text-anchor: middle;
}
.sc-centroid {
  fill: none;
  stroke: var(--brand);
  stroke-width: 2;
  stroke-dasharray: 3 3;
  filter: drop-shadow(0 0 5px rgba(58, 240, 162, .55));
}
.sc-centroid-label { fill: var(--brand-ink); }

/* ---------- 概率统计视图 ---------- */
.st { display: flex; flex-direction: column; gap: 10px; }
.st-title {
  font-size: 12px; color: var(--muted); font-family: var(--mono);
  letter-spacing: .02em;
}
.st-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 190px;
  gap: 14px;
  align-items: start;
}
.st-stage {
  position: relative;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, .07);
  background:
    radial-gradient(120% 90% at 16% 0%, rgba(76, 201, 240, .12) 0%, transparent 55%),
    radial-gradient(100% 100% at 92% 100%, rgba(15, 220, 120, .10) 0%, transparent 60%),
    #080C11;
  overflow: hidden;
  min-height: 180px;
}
.st-stage::before {
  content: '';
  position: absolute; inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, .035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, .035) 1px, transparent 1px);
  background-size: 28px 28px;
  -webkit-mask-image: radial-gradient(80% 80% at 50% 45%, #000 40%, transparent 100%);
  mask-image: radial-gradient(80% 80% at 50% 45%, #000 40%, transparent 100%);
  pointer-events: none;
  animation: st-grid-drift 26s linear infinite;
}
.st-stage::after {
  content: '';
  position: absolute; inset: 0;
  background: linear-gradient(180deg, transparent 0%, rgba(76, 201, 240, .06) 48%, rgba(15, 220, 120, .05) 52%, transparent 100%);
  background-size: 100% 220%;
  animation: gv-scan 7s linear infinite;
  pointer-events: none;
}
@keyframes st-grid-drift {
  to { background-position: 28px 28px, -28px 28px; }
}
.st-svg { position: relative; width: 100%; height: auto; display: block; }
.st-values {
  background: #0B1117;
  border: 1px solid rgba(255, 255, 255, .07);
  border-radius: 10px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.st-value {
  display: flex; justify-content: space-between; align-items: baseline; gap: 8px;
  font-size: 12px; color: #8494A3;
}
.st-value b {
  font-family: var(--mono); font-size: 12.5px; font-weight: 600; color: #E7E9EA;
  white-space: nowrap;
  animation: st-val-in .3s ease-out;
}
.st-value b.tone-good { color: var(--brand); }
.st-value b.tone-warn { color: #F5C451; }
.st-value b.tone-hot { color: var(--accent); }
.st-value b.tone-cool { color: #4CC9F0; }
.st-caption { font-family: var(--mono); font-size: 12px; color: var(--muted); min-height: 20px; }
.st-caption.is-done { color: var(--brand-ink); }
.st-legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 11px; color: #8494A3; }
.st-legend span { display: inline-flex; align-items: center; gap: 5px; }
.st-dot {
  width: 9px; height: 9px; border-radius: 50%; display: inline-block;
  border: 1px solid rgba(255, 255, 255, .25);
  animation: st-dot-pulse 3s ease-in-out infinite;
}
.st-legend span:nth-child(2) .st-dot { animation-delay: .5s; }
.st-legend span:nth-child(3) .st-dot { animation-delay: 1s; }
.st-legend span:nth-child(4) .st-dot { animation-delay: 1.5s; }
@keyframes st-dot-pulse {
  0%, 100% { transform: scale(1); opacity: .8; }
  50% { transform: scale(1.18); opacity: 1; }
}
.st-dot.tone-a { background: rgba(15, 220, 120, .85); box-shadow: 0 0 8px rgba(15, 220, 120, .55); }
.st-dot.tone-b { background: rgba(76, 201, 240, .85); box-shadow: 0 0 8px rgba(76, 201, 240, .55); }
.st-dot.tone-both { background: #9B8CFF; box-shadow: 0 0 8px rgba(155, 140, 255, .55); }
.st-dot.tone-warm { background: var(--accent); box-shadow: 0 0 8px rgba(240, 118, 74, .55); }
.st-dot.tone-outside { background: rgba(255, 255, 255, .22); }

.st-region .st-shape { transition: stroke-width .2s; }
.st-region .st-halo {
  fill: none;
  stroke-width: 2;
  opacity: 0;
  transform-box: fill-box;
  transform-origin: center;
  pointer-events: none;
}
.st-region.is-active .st-shape {
  stroke-width: 3;
  animation: st-reg-glow 1.8s ease-in-out infinite;
}
.st-region.is-active .st-halo { animation: st-halo 1.7s ease-out infinite; }
.st-reg-label {
  font-family: var(--font); font-size: 2.4px; font-weight: 600; fill: #DDE6EE;
  pointer-events: none;
}
.st-reg-count {
  font-family: var(--mono); font-size: 3px; font-weight: 700; fill: #FFFFFF;
  pointer-events: none;
}
.st-region.is-pop .st-reg-count { animation: st-pop .32s ease-out; }
@keyframes st-pop {
  0% { opacity: .2; }
  60% { opacity: 1; }
  100% { opacity: 1; }
}

.st-grid-line { stroke: rgba(255, 255, 255, .07); stroke-width: 1; }
.st-axis { font-family: var(--mono); font-size: 10px; fill: #8494A3; }
.st-baseline { stroke: rgba(255, 255, 255, .22); stroke-width: 1.2; }
.st-bar {
  fill: rgba(76, 201, 240, .52);
  transform-box: fill-box;
  transform-origin: bottom;
  animation: st-bar-grow .48s cubic-bezier(.18, .86, .3, 1);
  transition: fill .18s;
}
.st-bar.is-hot {
  fill: var(--brand);
  animation:
    st-bar-grow .48s cubic-bezier(.18, .86, .3, 1),
    st-bar-pulse 1.5s ease-in-out .48s infinite;
}
.st-bar-label { font-family: var(--mono); font-size: 10px; fill: #8494A3; }
.st-bar-val { font-family: var(--mono); font-size: 9.5px; fill: #C9CFD6; }
.st-bar-val.is-hot { fill: #C8FFE0; }

.st-area { fill: rgba(15, 220, 120, .10); animation: st-area-breathe 4.2s ease-in-out infinite; }
.st-shade { fill: rgba(240, 118, 74, .22); stroke: rgba(240, 118, 74, .55); stroke-width: 1; animation: st-shade-pulse 2.4s ease-in-out infinite; }
.st-curve {
  fill: none; stroke: var(--brand); stroke-width: 2.6;
  stroke-linejoin: round; stroke-linecap: round;
  animation: st-breathe 3.4s ease-in-out infinite;
}
.st-curve-alt { fill: none; stroke: #4CC9F0; stroke-width: 1.9; stroke-dasharray: 6 5; opacity: .85; animation: st-dash-flow 1.2s linear infinite; }
.st-marker { stroke: #4CC9F0; stroke-width: 1; stroke-dasharray: 3 4; opacity: .7; }
.st-marker-label { font-family: var(--mono); font-size: 10px; font-weight: 600; fill: #4CC9F0; }
.st-head { fill: var(--brand); filter: drop-shadow(0 0 9px rgba(15, 220, 120, .95)); }
.st-head-halo {
  fill: none; stroke-width: 2; opacity: 0;
  transform-box: fill-box; transform-origin: center;
  animation: st-halo 1.4s ease-out infinite;
}
.st-head-line { stroke: rgba(15, 220, 120, .22); stroke-width: 1; stroke-dasharray: 3 5; }

@keyframes st-bar-grow {
  from { transform: scaleY(.12); opacity: .3; }
  to { transform: scaleY(1); opacity: 1; }
}
@keyframes st-bar-pulse {
  0%, 100% { filter: drop-shadow(0 0 7px rgba(15, 220, 120, .55)); }
  50% { filter: drop-shadow(0 0 18px rgba(15, 220, 120, 1)); }
}
@keyframes st-reg-glow {
  0%, 100% { filter: drop-shadow(0 0 5px currentColor); }
  50% { filter: drop-shadow(0 0 17px currentColor); }
}
@keyframes st-halo {
  0% { opacity: .75; transform: scale(.97); }
  70%, 100% { opacity: 0; transform: scale(1.14); }
}
@keyframes st-breathe {
  0%, 100% { filter: drop-shadow(0 0 5px rgba(15, 220, 120, .35)); }
  50% { filter: drop-shadow(0 0 13px rgba(15, 220, 120, .75)); }
}
@keyframes st-area-breathe {
  0%, 100% { opacity: .7; }
  50% { opacity: 1; }
}
@keyframes st-shade-pulse {
  0%, 100% { opacity: .75; }
  50% { opacity: 1; }
}
@keyframes st-dash-flow {
  to { stroke-dashoffset: -22; }
}

.st-joint-wrap { position: relative; z-index: 1; padding: 12px; }
.st-joint { display: grid; gap: 3px; }
.st-joint-head {
  display: flex; align-items: center; justify-content: center;
  font-family: var(--mono); font-size: 9.5px; color: #8494A3; min-height: 18px;
}
.st-joint-rowhead { justify-content: flex-end; padding-right: 4px; }
.st-joint-cell {
  min-height: 28px; border-radius: 4px;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--mono); font-size: 10.5px; color: rgba(255, 255, 255, .92);
  text-shadow: 0 1px 2px rgba(0, 0, 0, .5);
  background: rgba(255, 255, 255, .04);
  transition: background .2s, box-shadow .2s, outline-color .2s;
  animation: st-cell-in .45s cubic-bezier(.2, .8, .3, 1) both;
}
.st-joint-cell.is-active {
  outline: 2px solid var(--brand);
  animation: st-cell-pulse 1.4s ease-in-out infinite;
  color: #fff;
}
@keyframes st-cell-in {
  from { opacity: 0; transform: scale(.9); }
  to { opacity: 1; transform: scale(1); }
}
@keyframes st-cell-pulse {
  0%, 100% { box-shadow: 0 0 10px rgba(15, 220, 120, .45), inset 0 0 8px rgba(15, 220, 120, .18); }
  50% { box-shadow: 0 0 24px rgba(15, 220, 120, .9), inset 0 0 17px rgba(15, 220, 120, .38); }
}
@keyframes st-val-in {
  from { opacity: .2; transform: translateY(3px); }
  to { opacity: 1; transform: none; }
}

@media (max-width: 720px) {
  .st-body { grid-template-columns: minmax(0, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
  .st-stage::before,
  .st-stage::after,
  .st-dot,
  .st-bar,
  .st-bar.is-hot,
  .st-region.is-active .st-shape,
  .st-region.is-active .st-halo,
  .st-curve,
  .st-curve-alt,
  .st-area,
  .st-shade,
  .st-head-halo,
  .st-joint-cell,
  .st-joint-cell.is-active,
  .st-value b { animation: none; }
  .st-head-halo { opacity: .4; }
}

#fatal {
  position: fixed; left: 16px; right: 16px; bottom: 16px; z-index: 99;
  background: var(--danger); color: #fff; padding: 12px 16px;
  border-radius: 10px; font-size: 13px; box-shadow: 0 10px 30px rgba(0, 0, 0, .3);
}

/* ---------- 窄屏 ---------- */
@media (max-width: 1040px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .algo-nav { margin-left: 0; }
}
@media (max-width: 640px) {
  .topbar-inner, .page, .footer { padding-left: 16px; padding-right: 16px; }
  .av-bars { height: 190px; gap: 4px; }
  .av-val { font-size: 10px; }
  .rc-cells { gap: 4px; }
  .rc-val { font-size: 12px; }
}

/* ============================================================
   深空主题 · 算法星图
   ============================================================ */
:root {
  --bg: #050A11;
  --bg-deep: #03060B;
  --surface: rgba(13, 22, 34, .78);
  --surface-2: rgba(20, 33, 48, .72);
  --surface-3: rgba(28, 45, 62, .65);
  --text: #E9F1F8;
  --muted: #93A6BA;
  --border: rgba(148, 180, 214, .14);
  --border-strong: rgba(148, 180, 214, .28);
  --brand: #3AF0A2;
  --brand-ink: #9CFFD0;
  --brand-soft: rgba(58, 240, 162, .12);
  --accent: #FF9C6B;
  --accent-soft: rgba(255, 156, 107, .13);
  --cyan: #5FE3FF;
  --violet: #A99BFF;
  --bar: rgba(118, 154, 184, .42);
  --bar-ink: #C9D8E6;
  --danger: #FF7373;
  --radius: 10px;
  --radius-lg: 16px;
  --shadow: 0 1px 0 rgba(255, 255, 255, .04) inset, 0 24px 60px rgba(0, 0, 0, .45);
  color-scheme: dark;
}

html { background: var(--bg-deep); }

body {
  min-height: 100vh;
  background:
    radial-gradient(1100px 720px at 12% -12%, rgba(95, 227, 255, .13), transparent 62%),
    radial-gradient(900px 680px at 92% -5%, rgba(169, 155, 255, .12), transparent 58%),
    radial-gradient(1000px 760px at 50% 118%, rgba(58, 240, 162, .09), transparent 62%),
    linear-gradient(180deg, #060B12 0%, #04080D 55%, #03060A 100%);
  background-attachment: fixed;
}

::selection {
  background: rgba(95, 227, 255, .28);
  color: #fff;
}

#app { position: relative; z-index: 1; }

/* 背景层：极光、网格、星图、暗角 */
.bg-layers {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}

.bg-aurora {
  position: absolute;
  inset: -20%;
  z-index: 0;
  background:
    radial-gradient(closest-side, rgba(95, 227, 255, .18), transparent),
    radial-gradient(closest-side, rgba(169, 155, 255, .16), transparent),
    radial-gradient(closest-side, rgba(58, 240, 162, .14), transparent);
  background-size: 55% 55%, 50% 50%, 60% 60%;
  background-position: 12% 8%, 88% 20%, 50% 100%;
  background-repeat: no-repeat;
  filter: blur(48px);
  opacity: .7;
  animation: auroraDrift 26s ease-in-out infinite alternate;
}

.bg-grid {
  position: absolute;
  inset: 0;
  z-index: 1;
  background-image:
    linear-gradient(rgba(95, 227, 255, .035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(95, 227, 255, .035) 1px, transparent 1px);
  background-size: 44px 44px;
  -webkit-mask-image: radial-gradient(ellipse 85% 75% at 50% 38%, #000 18%, transparent 78%);
  mask-image: radial-gradient(ellipse 85% 75% at 50% 38%, #000 18%, transparent 78%);
  opacity: .55;
}

.bg-canvas {
  position: absolute;
  inset: 0;
  z-index: 2;
  width: 100%;
  height: 100%;
  opacity: .95;
}

.bg-vignette {
  position: absolute;
  inset: 0;
  z-index: 3;
  background:
    radial-gradient(ellipse 90% 72% at 50% 38%, transparent 42%, rgba(2, 5, 9, .58) 100%),
    linear-gradient(180deg, rgba(2, 5, 9, .18) 0%, transparent 22%, transparent 78%, rgba(2, 5, 9, .55) 100%);
}

@keyframes auroraDrift {
  0% { background-position: 12% 8%, 88% 20%, 50% 100%; }
  50% { background-position: 24% 22%, 70% 8%, 40% 86%; }
  100% { background-position: 6% 16%, 96% 30%, 60% 94%; }
}

/* 顶栏与导航 */
.topbar {
  background: rgba(5, 10, 17, .72);
  backdrop-filter: blur(18px) saturate(150%);
  border-bottom: 1px solid rgba(95, 227, 255, .12);
  box-shadow: 0 10px 30px rgba(0, 0, 0, .22);
}

.brand {
  color: #F1F7FC;
  text-shadow: 0 0 18px rgba(95, 227, 255, .18);
}

.brand-mark { filter: drop-shadow(0 0 8px rgba(58, 240, 162, .35)); }
.brand-sub { color: var(--muted); }
.nav-split { background: var(--border); }

.algo-nav { gap: 18px; }
.nav-group { display: flex; align-items: center; gap: 2px; }
.nav-divider {
  width: 1px;
  height: 20px;
  background: var(--border);
  opacity: .8;
}
.nav-group-label {
  font-size: 10px;
  letter-spacing: 1.4px;
  color: #7E95AA;
  margin-right: 6px;
  padding-right: 9px;
  border-right: 1px solid rgba(148, 180, 214, .16);
  user-select: none;
}
.nav-apps {
  padding: 3px 5px;
  border: 1px solid rgba(95, 227, 255, .18);
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(95, 227, 255, .09), rgba(95, 227, 255, .02));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, .05),
    0 0 20px rgba(95, 227, 255, .06);
}
.nav-apps .nav-group-label {
  color: rgba(95, 227, 255, .75);
  border-right-color: rgba(95, 227, 255, .22);
}
.nav-apps .menu-trigger { padding: 5px 11px; font-size: 12.5px; }
.nav-apps .menu-trigger.is-current::before {
  background: var(--cyan);
  box-shadow: 0 0 8px rgba(95, 227, 255, .8);
}

.menu-trigger {
  color: var(--muted);
  border-color: transparent;
}

.menu-trigger:hover {
  background: rgba(95, 227, 255, .07);
  border-color: rgba(95, 227, 255, .14);
  color: var(--text);
}

.menu.is-open .menu-trigger,
.menu-trigger.is-current {
  background: rgba(95, 227, 255, .10);
  border-color: rgba(95, 227, 255, .26);
  color: var(--text);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .06), 0 0 18px rgba(95, 227, 255, .08);
}

.menu-trigger.is-current::before {
  background: var(--brand);
  box-shadow: 0 0 8px rgba(58, 240, 162, .8);
}

.menu-panel {
  background: rgba(7, 13, 21, .97);
  border-color: rgba(95, 227, 255, .16);
  box-shadow: 0 24px 60px rgba(0, 0, 0, .6), inset 0 1px 0 rgba(255, 255, 255, .06);
  backdrop-filter: blur(20px);
}

.menu-item {
  color: var(--text);
}

.menu-item:hover {
  background: rgba(95, 227, 255, .07);
}

.menu-item[aria-current="true"] {
  background: rgba(58, 240, 162, .12);
  color: var(--brand-ink);
  box-shadow: inset 0 0 0 1px rgba(58, 240, 162, .18);
}

.menu-item-tag { color: var(--muted); }
.menu-item-tag.is-academic { color: var(--cyan); }
.menu-item[aria-current="true"] .menu-item-tag { color: var(--brand-ink); }

.menu-kind {
  color: var(--cyan);
  background: rgba(95, 227, 255, .12);
}

.menu-group + .menu-group { border-top-color: var(--border); }

.menu-group-label {
  background: #070D15;
  color: #8EA6BC;
  letter-spacing: .7px;
}

/* 卡片与内容 */
.card {
  position: relative;
  overflow: hidden;
  background:
    linear-gradient(160deg, rgba(17, 28, 42, .86) 0%, rgba(9, 15, 24, .76) 58%, rgba(5, 9, 15, .84) 100%);
  border-color: rgba(148, 180, 214, .2);
  border-radius: var(--radius-lg);
  box-shadow:
    0 24px 60px rgba(0, 0, 0, .38),
    inset 0 1px 0 rgba(255, 255, 255, .05);
  backdrop-filter: blur(18px) saturate(120%);
  animation: region-glow 4.2s ease-in-out infinite;
}

.side .card { animation-delay: -1.4s; }
.depth-zone .card:nth-child(2n) { animation-delay: -2.4s; }
.depth-zone .card:nth-child(3n) { animation-delay: -3.2s; }

@keyframes region-glow {
  0%, 100% {
    border-color: rgba(148, 180, 214, .18);
    box-shadow:
      0 24px 60px rgba(0, 0, 0, .38),
      inset 0 1px 0 rgba(255, 255, 255, .05),
      0 0 0 rgba(95, 227, 255, 0);
  }
  50% {
    border-color: rgba(95, 227, 255, .34);
    box-shadow:
      0 24px 60px rgba(0, 0, 0, .38),
      inset 0 1px 0 rgba(255, 255, 255, .07),
      0 0 24px rgba(95, 227, 255, .16);
  }
}

.card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 22px;
  right: 22px;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(95, 227, 255, .55), rgba(58, 240, 162, .4), transparent);
  opacity: .55;
  pointer-events: none;
}

.algo-title {
  color: #F3F8FD;
  text-shadow: 0 0 24px rgba(95, 227, 255, .12);
}

.summary { color: var(--muted); }

.tag {
  background: rgba(95, 227, 255, .07);
  color: #A9C0D4;
  border: 1px solid rgba(95, 227, 255, .12);
}

.tag-app {
  background: rgba(58, 240, 162, .10);
  color: var(--brand);
  box-shadow: inset 0 0 0 1px rgba(58, 240, 162, .22);
}

.canvas {
  background:
    radial-gradient(120% 100% at 20% 0%, rgba(95, 227, 255, .05), transparent 55%),
    rgba(3, 8, 14, .62);
  border: 1px solid rgba(95, 227, 255, .14);
  box-shadow: inset 0 0 38px rgba(0, 0, 0, .35), inset 0 1px 0 rgba(255, 255, 255, .03);
  animation: canvas-glow 3.6s ease-in-out infinite;
}

@keyframes canvas-glow {
  0%, 100% {
    border-color: rgba(95, 227, 255, .12);
    box-shadow:
      inset 0 0 38px rgba(0, 0, 0, .35),
      inset 0 1px 0 rgba(255, 255, 255, .03),
      0 0 0 rgba(95, 227, 255, 0);
  }
  50% {
    border-color: rgba(95, 227, 255, .32);
    box-shadow:
      inset 0 0 38px rgba(0, 0, 0, .35),
      inset 0 1px 0 rgba(255, 255, 255, .03),
      0 0 20px rgba(95, 227, 255, .14);
  }
}

.note {
  background: rgba(58, 240, 162, .09);
  border: 1px solid rgba(58, 240, 162, .18);
  color: var(--brand-ink);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .03);
  animation: note-glow 3.2s ease-in-out infinite;
}

@keyframes note-glow {
  0%, 100% {
    border-color: rgba(58, 240, 162, .16);
    box-shadow:
      inset 0 1px 0 rgba(255, 255, 255, .03),
      0 0 0 rgba(58, 240, 162, 0);
  }
  50% {
    border-color: rgba(58, 240, 162, .38);
    box-shadow:
      inset 0 0 12px rgba(58, 240, 162, .06),
      0 0 16px rgba(58, 240, 162, .12);
  }
}

.note.is-idle {
  background: rgba(95, 227, 255, .04);
  color: var(--muted);
  border-color: var(--border);
  animation: none;
}

.note-idx {
  background: rgba(58, 240, 162, .14);
  color: var(--brand-ink);
}

/* 播放器与输入 */
.icon-btn {
  background: rgba(14, 23, 35, .8);
  border-color: var(--border);
  color: var(--text);
  backdrop-filter: blur(8px);
}

.icon-btn:hover {
  background: rgba(95, 227, 255, .08);
  border-color: rgba(95, 227, 255, .28);
  color: #fff;
}

.icon-btn.primary {
  background: linear-gradient(180deg, #41F5AA, #19C67C);
  border-color: rgba(58, 240, 162, .65);
  color: #032B1A;
  box-shadow: 0 0 22px rgba(58, 240, 162, .28), inset 0 1px 0 rgba(255, 255, 255, .35);
}

.slider { accent-color: var(--brand); }
.counter { color: var(--muted); }

.speed {
  background: rgba(14, 23, 35, .8);
  border-color: var(--border);
  color: var(--text);
}

.speed:hover { border-color: rgba(95, 227, 255, .28); }

.metrics {
  border-top-color: var(--border);
}

.metric { color: var(--muted); }
.metric b { color: var(--text); }

.field { color: var(--muted); }

.field input,
.field select {
  background: rgba(4, 9, 15, .7);
  border-color: var(--border);
  color: var(--text);
}

.field input::placeholder { color: #61758A; }

.field input:focus,
.field select:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 0 3px rgba(95, 227, 255, .10);
}

.btn {
  background: rgba(14, 23, 35, .8);
  border-color: var(--border);
  color: var(--text);
}

.btn:hover {
  background: rgba(95, 227, 255, .08);
  border-color: rgba(95, 227, 255, .28);
  color: #fff;
}

.btn-ghost { color: var(--muted); }
.btn-ghost:hover { background: rgba(95, 227, 255, .06); color: var(--text); }
.err { color: var(--danger); }

/* 代码面板 */
.code-card {
  background: linear-gradient(160deg, rgba(9, 16, 25, .9), rgba(4, 8, 13, .86));
}

.code-title { color: #9FB6CB; }
.code-tip { color: var(--muted); }
.code-body { color: #C9D8E6; }

.code-line:hover { background: rgba(95, 227, 255, .06); }

.code-line.is-active {
  background: rgba(58, 240, 162, .16);
  box-shadow:
    inset 2px 0 0 var(--brand-ink),
    inset 0 0 10px rgba(58, 240, 162, .12),
    0 0 10px rgba(58, 240, 162, .16);
  animation: code-line-glow 1.7s ease-in-out infinite;
}

@keyframes code-line-glow {
  0%, 100% {
    background: rgba(58, 240, 162, .09);
    box-shadow:
      inset 2px 0 0 var(--brand-ink),
      inset 0 0 8px rgba(58, 240, 162, .05),
      0 0 6px rgba(58, 240, 162, .08);
  }
  50% {
    background: rgba(58, 240, 162, .22);
    box-shadow:
      inset 2px 0 0 var(--brand-ink),
      inset 0 0 16px rgba(58, 240, 162, .18),
      0 0 16px rgba(58, 240, 162, .30);
  }
}

.ln { color: #5E7488; }

/* 讲解区 */
.panel-label { color: #8EA6BC; }
.panel-title { color: #EAF4FC; }
.analogy { color: #D7E4EF; }
.essence { border-left-color: var(--brand); color: #C9D8E6; }
.steps { color: var(--muted); }
.l1-foot { border-top-color: var(--border); color: var(--muted); }

.kv {
  background: rgba(4, 9, 15, .35);
  border-color: var(--border);
  border-radius: 12px;
}

.kv h3 { color: #E7F2FA; }
.kv ul { color: var(--muted); }
.kv .mono { color: #E7F2FA; }
.kv p { color: var(--muted); }

/* 视图容器微调 */
.gv-stage,
.mx-stage,
.st-stage {
  border-color: rgba(95, 227, 255, .10);
  box-shadow: inset 0 0 50px rgba(0, 0, 0, .28);
}

.st-values {
  background: rgba(4, 9, 15, .72);
  border-color: rgba(95, 227, 255, .10);
}

.rc-target,
.rc-cell,
.rc-ptr,
.gv-chip {
  background-color: rgba(14, 23, 35, .8);
}

/* 页脚与状态 */
.footer { color: var(--muted); }

.badge-ok {
  color: var(--brand-ink);
  border-color: rgba(58, 240, 162, .3);
  background: rgba(58, 240, 162, .10);
}

.badge-warn {
  color: #FFB594;
  border-color: rgba(255, 156, 107, .3);
  background: rgba(255, 156, 107, .10);
}

.badge-bad {
  color: var(--danger);
  border-color: rgba(255, 115, 115, .4);
  background: rgba(255, 115, 115, .10);
}

/* ============================================================
   搜索、工具条、弹层（搜索面板 / 小测 / 对比）
   ============================================================ */

.kbd {
  font-family: var(--mono);
  font-size: 10.5px;
  line-height: 1.4;
  padding: 2px 6px;
  border-radius: 6px;
  border: 1px solid rgba(148, 180, 214, .18);
  background: rgba(3, 8, 15, .6);
  color: #9FB6CB;
  white-space: nowrap;
}

.search-trigger {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  flex: none;
  margin-left: auto;
  padding: 6px 8px 6px 12px;
  border-radius: 999px;
  border: 1px solid rgba(95, 227, 255, .18);
  background: linear-gradient(180deg, rgba(95, 227, 255, .08), rgba(95, 227, 255, .02));
  color: var(--muted);
  font-size: 12.5px;
  cursor: pointer;
  white-space: nowrap;
  transition: color .15s, border-color .15s, box-shadow .15s, background .15s;
}

.search-trigger:hover {
  color: var(--text);
  border-color: rgba(95, 227, 255, .42);
  background: rgba(95, 227, 255, .1);
  box-shadow: 0 0 20px rgba(95, 227, 255, .16);
}

.stage-tools {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px dashed var(--border);
}

.btn-sm {
  padding: 4px 11px;
  font-size: 12px;
  border-radius: 7px;
}

.btn-sm:disabled {
  opacity: .35;
  cursor: not-allowed;
}

.btn-sm:disabled:hover {
  background: rgba(14, 23, 35, .8);
  border-color: var(--border);
  color: var(--text);
}

.tools-hint {
  margin-left: auto;
  font-size: 11.5px;
  letter-spacing: .3px;
  color: #6F8499;
  white-space: nowrap;
}

.input-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.inputs .input-actions .btn {
  padding: 5px 11px;
  font-size: 12px;
}

.inputs.is-empty {
  justify-content: flex-start;
}

.inputs-hint {
  font-size: 12px;
  color: var(--muted);
  padding: 2px 0;
}

/* 导航项名称永不折行 */
.menu-trigger { white-space: nowrap; }

/* 弹层基础 */
.modal-layer {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 10vh 24px 24px;
  background: rgba(2, 5, 9, .62);
  backdrop-filter: blur(10px) saturate(120%);
  overflow-y: auto;
  animation: modal-fade .18s ease-out;
}

.modal-layer[hidden] { display: none; }

body.is-modal { overflow: hidden; }

@keyframes modal-fade {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes modal-rise {
  from { opacity: 0; transform: translateY(-10px) scale(.985); }
  to { opacity: 1; transform: none; }
}

/* 搜索面板 */
.palette-layer { padding-top: 12vh; }

.palette {
  width: min(680px, 100%);
  border-radius: 16px;
  border: 1px solid rgba(95, 227, 255, .22);
  background: linear-gradient(165deg, rgba(15, 26, 40, .98), rgba(6, 11, 18, .99));
  box-shadow:
    0 40px 90px rgba(0, 0, 0, .65),
    inset 0 1px 0 rgba(255, 255, 255, .05),
    0 0 44px rgba(95, 227, 255, .08);
  overflow: hidden;
  animation: modal-rise .22s cubic-bezier(.2, .8, .3, 1);
}

.palette-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}

.palette-glyph {
  color: var(--cyan);
  font-size: 18px;
  line-height: 1;
  text-shadow: 0 0 12px rgba(95, 227, 255, .55);
}

.palette-input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  outline: none;
  font-size: 15px;
  color: var(--text);
}

.palette-input::placeholder { color: #6F8499; }

.palette-input::-webkit-search-cancel-button { appearance: none; }

.palette-list {
  max-height: min(56vh, 420px);
  overflow-y: auto;
  padding: 6px;
}

.palette-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  width: 100%;
  padding: 9px 12px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: var(--text);
  text-align: left;
  cursor: pointer;
  transition: background .12s, border-color .12s, box-shadow .12s;
}

.palette-item-main {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.palette-item-main strong {
  font-size: 13.5px;
  font-weight: 600;
}

.palette-item-meta {
  font-size: 11.5px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.palette-item-tag {
  flex: none;
  font-size: 10.5px;
  padding: 1px 8px;
  border-radius: 999px;
  color: #9FB6CB;
  background: rgba(95, 227, 255, .08);
  border: 1px solid rgba(95, 227, 255, .14);
}

.palette-item.is-active {
  background: rgba(95, 227, 255, .1);
  border-color: rgba(95, 227, 255, .34);
  box-shadow:
    inset 0 0 0 1px rgba(95, 227, 255, .06),
    0 0 20px rgba(95, 227, 255, .14);
}

.palette-item.is-active .palette-item-meta { color: #BBD0E2; }

.palette-empty {
  padding: 26px 16px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

.palette-foot {
  padding: 9px 16px;
  border-top: 1px solid var(--border);
  background: rgba(3, 8, 15, .4);
  font-size: 11px;
  letter-spacing: .3px;
  color: #6F8499;
}

/* 小测 */
.quiz-layer { padding-top: 9vh; }

.quiz {
  width: min(640px, 100%);
  border-radius: 18px;
  border: 1px solid rgba(95, 227, 255, .2);
  background: linear-gradient(165deg, rgba(15, 26, 40, .98), rgba(6, 11, 18, .99));
  box-shadow:
    0 40px 90px rgba(0, 0, 0, .65),
    inset 0 1px 0 rgba(255, 255, 255, .05),
    0 0 44px rgba(95, 227, 255, .07);
  animation: modal-rise .22s cubic-bezier(.2, .8, .3, 1);
}

.quiz-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
}

.quiz-title {
  font-size: 17px;
  font-weight: 650;
  color: var(--text);
}

.quiz-sub {
  margin-top: 3px;
  font-size: 12px;
  color: var(--muted);
}

.quiz-body { padding: 16px 18px 18px; }

.quiz-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.quiz-dots { display: flex; align-items: center; gap: 6px; }

.quiz-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: rgba(148, 180, 214, .25);
  transition: background .15s, box-shadow .15s, transform .15s;
}

.quiz-dot.is-done {
  background: var(--brand);
  box-shadow: 0 0 8px rgba(58, 240, 162, .55);
}

.quiz-dot.is-current {
  background: var(--cyan);
  box-shadow: 0 0 10px rgba(95, 227, 255, .8);
  transform: scale(1.3);
}

.quiz-count {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--muted);
  white-space: nowrap;
}

.quiz-prompt {
  margin-top: 14px;
  font-size: 14.5px;
  line-height: 1.55;
  color: #EAF4FC;
}

.quiz-algo {
  margin-top: 4px;
  font-size: 11.5px;
  color: #6F8499;
}

.quiz-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 14px;
}

.quiz-option {
  padding: 10px 13px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(9, 16, 25, .65);
  color: #CFDDEA;
  font-size: 13px;
  line-height: 1.5;
  text-align: left;
  cursor: pointer;
  transition: background .14s, border-color .14s, box-shadow .14s, color .14s;
}

.quiz-option:hover:not(:disabled) {
  border-color: rgba(95, 227, 255, .35);
  background: rgba(95, 227, 255, .07);
  box-shadow: 0 0 16px rgba(95, 227, 255, .1);
}

.quiz-option:disabled {
  cursor: default;
  opacity: .7;
}

.quiz-option.is-correct {
  border-color: rgba(58, 240, 162, .55);
  background: rgba(58, 240, 162, .13);
  color: var(--brand-ink);
  box-shadow: 0 0 20px rgba(58, 240, 162, .16);
  opacity: 1;
}

.quiz-option.is-wrong {
  border-color: rgba(255, 115, 115, .5);
  background: rgba(255, 115, 115, .1);
  color: #FFB4B4;
  opacity: 1;
}

.quiz-feedback {
  min-height: 20px;
  margin-top: 10px;
  font-size: 12.5px;
  color: var(--muted);
}

.quiz-feedback.is-good { color: var(--brand-ink); }
.quiz-feedback.is-bad { color: #FF9B9B; }

.quiz-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 14px;
}

.quiz-result {
  text-align: center;
  padding: 10px 0 6px;
}

.quiz-result + .quiz-actions { justify-content: center; }

.quiz-score {
  font-family: var(--mono);
  font-size: 42px;
  font-weight: 700;
  line-height: 1.2;
  color: var(--brand-ink);
  text-shadow: 0 0 26px rgba(58, 240, 162, .38);
}

.quiz-verdict {
  margin-top: 6px;
  font-size: 13px;
  color: var(--muted);
}

.quiz-empty {
  padding: 6px 0 18px;
  font-size: 13px;
  color: var(--muted);
}

/* 并排对比 */
.compare-layer { padding: 5vh 20px 20px; }

.compare {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: min(1180px, 100%);
  padding: 16px 18px 18px;
  border-radius: 18px;
  border: 1px solid rgba(95, 227, 255, .2);
  background: linear-gradient(165deg, rgba(15, 26, 40, .98), rgba(6, 11, 18, .99));
  box-shadow:
    0 40px 90px rgba(0, 0, 0, .65),
    inset 0 1px 0 rgba(255, 255, 255, .05),
    0 0 44px rgba(95, 227, 255, .07);
  animation: modal-rise .22s cubic-bezier(.2, .8, .3, 1);
}

.compare-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.compare-title {
  font-size: 17px;
  font-weight: 650;
  color: var(--text);
}

.compare-sub {
  margin-top: 3px;
  font-size: 12px;
  color: var(--muted);
}

.compare-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(4, 9, 15, .45);
}

.compare-select {
  border: 1px solid var(--border);
  background: rgba(4, 9, 15, .7);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 12.5px;
  color: var(--text);
  cursor: pointer;
}

.compare-select:hover { border-color: rgba(95, 227, 255, .3); }

.compare-controls .slider { min-width: 160px; }

.compare-controls .counter {
  margin-left: auto;
  font-size: 11.5px;
}

.compare-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.compare-pane {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(5, 10, 17, .45);
}

.compare-name {
  font-size: 14px;
  font-weight: 650;
  color: var(--text);
}

.compare-meta {
  font-size: 11px;
  color: #6F8499;
}

.compare-canvas {
  margin-top: 0;
  padding: 10px;
  min-height: 200px;
  overflow: auto;
}

.compare-note {
  margin-top: 0;
  min-height: 40px;
  padding: 8px 11px;
  font-size: 12px;
}

.compare-note.is-error {
  background: rgba(255, 115, 115, .1);
  border: 1px solid rgba(255, 115, 115, .32);
  color: #FFB4B4;
  animation: none;
}

@media (max-width: 1200px) {
  .tools-hint { display: none; }
  .compare-layer { padding: 4vh 14px 14px; }
}

@media (max-width: 900px) {
  .compare-grid { grid-template-columns: 1fr; }
  .compare-canvas { min-height: 160px; }
}

@media (max-width: 720px) {
  .modal-layer { padding: 4vh 12px 12px; }
  .palette-layer,
  .quiz-layer { padding-top: 6vh; }
  .quiz-head,
  .compare-head { padding: 12px 14px; }
  .quiz-body { padding: 12px 14px 16px; }
  .compare { padding: 12px 14px 14px; }
  .search-trigger { padding: 5px 10px; }
  .search-trigger .kbd { display: none; }
  .stage-tools .btn-sm { flex: 1 1 auto; }
  .inputs .input-actions { flex: 1 1 100%; }
  .inputs .input-actions .btn { flex: 1 1 auto; }
  .compare-controls .counter { margin-left: 0; }
  .quiz-score { font-size: 34px; }
}

@media (max-width: 560px) {
  .topbar-inner { gap: 10px; padding: 10px 14px; }
  .algo-nav {
    flex-wrap: nowrap;
    overflow-x: auto;
    margin-left: 0;
    padding-bottom: 4px;
    scrollbar-width: none;
  }
  .algo-nav::-webkit-scrollbar { display: none; }
  .nav-group { flex: none; }
  .stage-tools .btn-sm { flex: 1 1 40%; }
}

@media (prefers-reduced-motion: reduce) {
  .modal-layer,
  .palette,
  .quiz,
  .compare { animation: none; }
}

/* 滚动条与焦点 */
* {
  scrollbar-color: rgba(95, 227, 255, .25) transparent;
  scrollbar-width: thin;
}

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }

::-webkit-scrollbar-thumb {
  background: rgba(95, 227, 255, .18);
  border: 2px solid transparent;
  border-radius: 999px;
  background-clip: padding-box;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(95, 227, 255, .35);
  background-clip: padding-box;
}

:focus-visible {
  outline: 2px solid rgba(95, 227, 255, .65);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  .bg-aurora { animation: none; }
  .code-line.is-active {
    animation: none;
    background: rgba(58, 240, 162, .16);
  }
  .card,
  .canvas,
  .note { animation: none; }
}

@media (max-width: 1200px) {
  .nav-divider { display: none; }
}

@media (max-width: 720px) {
  .layout > *,
  .side,
  .stage { min-width: 0; }
  .stage-head { flex-direction: column; }
  .stage-head > * { width: 100%; min-width: 0; }
  .stage { padding: 16px; }
  .algo-title { font-size: 18px; }
  .inputs { width: 100%; }
  .field { flex: 1 1 100%; min-width: 0; }
  .field > span { flex: none; }
  .field input,
  .field select,
  .field input.wide {
    width: auto;
    max-width: 100%;
    flex: 1 1 auto;
    min-width: 0;
  }
  .inputs .btn { flex: 1 1 auto; }
  .player { gap: 8px; }
  .player .slider { min-width: 60px; }
  .av-bars { gap: 5px; }
  .av-bar { max-width: none; }
  .menu-kind { display: none; }
  .algo-nav { gap: 8px; }
  .nav-group-label { display: none; }
  .nav-apps { padding: 2px 3px; }
  .nav-divider { height: 16px; }
  .menu-trigger { padding: 6px 10px; font-size: 12px; }
  .nav-apps .menu-trigger { padding: 5px 9px; font-size: 12px; }
}
