/* ==========================================================================
   图表与网络示意图：全部是内联 SVG / Canvas，样式都在这里。
   颜色约定与全站一致：蓝 = 前向，琥珀 = 损失，玫红 = 反向（梯度），绿 = 更新；
   连线 / 矩阵里“正数蓝、负数橙”。
   ========================================================================== */

/* ---------- 折线图等通用 SVG 图表 ---------- */
.chart-wrap {
  width: 100%;
  min-width: 0;
}
.chart-svg {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
}
.chart-svg.seekable {
  cursor: ew-resize;
  touch-action: pan-y;
}
.chart-svg text {
  font-family: var(--font-sans);
  font-size: 11px;
  fill: var(--muted);
}
.chart-svg .grid {
  stroke: var(--border);
  stroke-width: 1;
}
.chart-svg .axis {
  stroke: var(--border-strong);
  stroke-width: 1.2;
}
.chart-svg .axis-title {
  font-size: 11.5px;
  font-weight: 600;
  fill: var(--text-2);
}
.chart-svg .thr {
  stroke: var(--good);
  stroke-width: 1.4;
  stroke-dasharray: 6 4;
  opacity: 0.85;
}
.chart-svg .ref-label {
  font-size: 11px;
  font-weight: 700;
}
.chart-svg .ref-label.good {
  fill: var(--good);
}
.chart-svg .cursor {
  stroke: var(--text-2);
  stroke-width: 1.4;
  stroke-dasharray: 4 3;
}
.chart-svg .cursor.soft {
  opacity: 0.5;
}
.chart-svg .tip-t {
  font-size: 11px;
  font-weight: 700;
  fill: var(--text-2);
}
.chart-svg .tip-v {
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-weight: 600;
  fill: var(--text);
}
.chart-svg .lbl {
  font-size: 11.5px;
  fill: var(--text-2);
}
.chart-svg .lbl.strong {
  font-weight: 800;
  fill: var(--text);
}

/* loss 切片 */
.chart-svg .tangent {
  stroke: var(--grad);
  stroke-width: 2.4;
  stroke-linecap: round;
  opacity: 0.9;
}
.chart-svg .step-link {
  stroke: var(--upd);
  stroke-width: 3;
  stroke-linecap: round;
}
.chart-svg .step-link.soft {
  stroke-width: 2;
  stroke-dasharray: 4 4;
  opacity: 0.85;
}
.chart-svg .pt-now {
  fill: var(--surface);
  stroke: var(--brand);
  stroke-width: 3.5;
}
.chart-svg .pt-next {
  fill: var(--upd);
  stroke: var(--surface);
  stroke-width: 2;
}
.chart-svg .pt-next.worse {
  fill: var(--bad);
}
.chart-svg .pt-label {
  font-size: 11.5px;
  font-weight: 700;
  fill: var(--text-2);
}
.chart-svg .pt-label.bad {
  fill: var(--bad);
}
.chart-svg .cur-tick {
  fill: var(--brand-ink);
  font-weight: 800;
}

/* 激活函数曲线上的标记点 */
.act-pt circle {
  fill: var(--surface);
  stroke: var(--brand);
  stroke-width: 3;
}
.act-pt .proj {
  stroke: var(--muted);
  stroke-width: 1.2;
  stroke-dasharray: 3 3;
  opacity: 0.8;
}
.act-pt.bad circle {
  stroke: var(--bad);
}
.act-pt.good circle {
  stroke: var(--good);
}
.act-pt.alt circle {
  stroke: var(--accent);
}

/* 图例 */
.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
  margin-top: 6px;
  padding-left: 2px;
  font-size: 12.5px;
  color: var(--text-2);
}
.chart-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.chart-legend i {
  display: inline-block;
  width: 14px;
  height: 4px;
  border-radius: 2px;
}
.chart-legend i.dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--surface);
  border: 3px solid var(--brand);
}
.chart-legend i.dot.next {
  background: var(--upd);
  border-color: var(--upd);
}
.chart-legend i.dot.bad {
  background: var(--bad);
  border-color: var(--bad);
}

/* 极简折线 */
.spark {
  display: block;
  width: 100%;
  height: auto;
  max-height: 64px;
}

/* ---------- 决策图 ---------- */
.dmap {
  margin: 0;
  display: grid;
  gap: 8px;
  justify-items: center;
  min-width: 0;
}
.dmap-box {
  position: relative;
  max-width: 100%;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
}
.dmap-box.probing {
  cursor: crosshair;
  touch-action: none;
}
.dmap-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
.dmap-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
.dmap-svg text {
  font-size: 10.5px;
  fill: var(--muted);
}
.dmap-svg .grid {
  stroke: rgb(127 127 150 / 0.28);
  stroke-width: 1;
}
.dmap-svg .axis-title {
  font-size: 11px;
  font-weight: 700;
  fill: var(--text-2);
}
.dmap-line {
  fill: none;
  stroke: var(--text);
  stroke-width: 2.2;
  stroke-linecap: round;
}
.dmap-pt circle {
  stroke: var(--surface);
  stroke-width: 2.5;
}
.dmap-pt.c0 circle {
  fill: rgb(59 130 246);
}
.dmap-pt.c1 circle {
  fill: rgb(249 115 22);
}
.dmap-pt.bad circle {
  stroke: var(--bad);
  stroke-width: 3.5;
}
.dmap-pt.hl circle {
  stroke: var(--brand-ink);
  stroke-width: 3.5;
}
.dmap-svg .dmap-pt .pt-y {
  fill: #fff;
  font-size: 11px;
  font-weight: 800;
}
.dmap-svg .dmap-pt .pt-pred {
  fill: var(--text);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  paint-order: stroke;
  stroke: var(--surface);
  stroke-width: 3px;
  stroke-linejoin: round;
}
.dmap-probe line {
  stroke: var(--text);
  stroke-width: 2;
}
.dmap-probe circle {
  fill: var(--surface);
  stroke: var(--text);
  stroke-width: 2;
}
.dmap-cap {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 4px 14px;
  font-size: 12.5px;
  color: var(--text-2);
}
.dmap-cap .lg {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.dmap-cap .lg i {
  display: inline-block;
  width: 11px;
  height: 11px;
  border-radius: 50%;
}
.dmap-cap .lg i.c0 {
  background: rgb(59 130 246);
}
.dmap-cap .lg i.c1 {
  background: rgb(249 115 22);
}
.dmap-cap .lg i.ln {
  width: 18px;
  height: 3px;
  border-radius: 2px;
  background: var(--text);
}

/* ---------- 预测与答案的“差距”刻度尺 ---------- */
.gauge {
  position: relative;
  padding: 34px 12px 50px;
}
.gauge-track {
  position: relative;
  height: 10px;
  border-radius: 6px;
  background: linear-gradient(90deg, rgb(var(--c-pos) / 0.32), var(--surface-3) 50%, rgb(var(--c-neg) / 0.32));
}
.gauge-gap {
  position: absolute;
  top: -1px;
  bottom: -1px;
  border-radius: 6px;
  background: var(--loss);
  opacity: 0.85;
}
.gauge-pin {
  position: absolute;
  top: -5px;
  width: 4px;
  height: 20px;
  margin-left: -2px;
  border-radius: 2px;
}
.gauge-pin.y {
  background: var(--good);
}
.gauge-pin.p {
  background: var(--brand);
}
.gauge-pin span {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  white-space: nowrap;
  font-size: 12px;
  font-weight: 700;
  padding: 1px 8px;
  border-radius: 7px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
}
.gauge-pin.edge-r span {
  left: auto;
  right: -2px;
  transform: none;
}
.gauge-pin.edge-l span {
  left: -2px;
  transform: none;
}
.gauge-pin.y span {
  bottom: 24px;
  color: var(--good);
}
.gauge-pin.p span {
  top: 24px;
  color: var(--brand-ink);
}
.gauge-scale {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 8px;
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--muted);
  font-family: var(--font-mono);
}

/* ---------- 网络示意图 ---------- */
.nd-wrap {
  width: 100%;
  min-width: 0;
}
.nd-svg {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
}
.nd-svg text {
  font-family: var(--font-sans);
  font-size: 12px;
  fill: var(--text-2);
}
.nd-heads text {
  font-size: 11.5px;
  font-weight: 700;
  fill: var(--muted);
  letter-spacing: 0.03em;
}

/* 连线：粗细 = 数值大小，颜色 = 正（蓝）负（橙）；反向时 玫红 = 梯度为正，橙 = 梯度为负 */
.nd-edge {
  fill: none;
  stroke-linecap: round;
  transition: opacity 0.25s ease, stroke-width 0.25s ease;
}
.nd-edge.tone-pos {
  stroke: rgb(var(--c-pos) / 0.8);
}
.nd-edge.tone-neg {
  stroke: rgb(var(--c-neg) / 0.8);
}
.nd-edge.tone-grad {
  stroke: rgb(var(--c-grad) / 0.85);
}
.nd-edge.tone-loss {
  stroke: var(--loss);
  stroke-dasharray: 4 4;
}
.nd-edge.dim {
  opacity: 0.16;
}
.nd-edge.flow-fwd,
.nd-edge.flow-bwd {
  stroke-dasharray: 8 7;
}
.nd-edge.flow-fwd {
  animation: ndFlowFwd 1.1s linear infinite;
}
.nd-edge.flow-bwd {
  animation: ndFlowBwd 1.1s linear infinite;
}
@keyframes ndFlowFwd {
  to {
    stroke-dashoffset: -15;
  }
}
@keyframes ndFlowBwd {
  to {
    stroke-dashoffset: 15;
  }
}
@media (prefers-reduced-motion: reduce) {
  .nd-edge.flow-fwd,
  .nd-edge.flow-bwd {
    animation: none;
  }
}
.nd-arrow.fwd {
  fill: var(--fwd);
}
.nd-arrow.bwd {
  fill: var(--grad);
}
.nd-svg g.dim {
  opacity: 0.22;
}

/* 数值小标签（压在线上也看得清：不透明底色） */
.nd-chip rect {
  fill: var(--surface);
  stroke: var(--border-strong);
  stroke-width: 1;
}
.nd-chip text {
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-weight: 600;
  fill: var(--text);
}
.nd-chip.strong rect {
  stroke: var(--brand);
  stroke-width: 1.6;
}
.nd-chip.strong text {
  font-weight: 800;
}
.nd-chip.tone-fwd rect {
  fill: color-mix(in srgb, var(--fwd) 13%, var(--surface));
  stroke: color-mix(in srgb, var(--fwd) 55%, var(--surface));
}
.nd-chip.tone-out rect {
  fill: color-mix(in srgb, var(--brand) 12%, var(--surface));
  stroke: color-mix(in srgb, var(--brand) 50%, var(--surface));
}
.nd-chip.tone-grad rect {
  fill: color-mix(in srgb, var(--grad) 11%, var(--surface));
  stroke: color-mix(in srgb, var(--grad) 50%, var(--surface));
}
.nd-chip.tone-bias rect {
  fill: var(--surface-2);
  stroke-dasharray: 3 2;
}
.nd-chip.pick {
  cursor: pointer;
}

/* 节点 */
.nd-node .nd-fill {
  fill: color-mix(in srgb, var(--brand) calc(var(--a, 0) * 100%), var(--surface));
  stroke: var(--border-strong);
  stroke-width: 2.2;
  transition: fill 0.3s ease, stroke 0.2s ease, stroke-width 0.2s ease;
}
.nd-node.is-in .nd-fill {
  fill: var(--surface-2);
  stroke: var(--muted);
}
.nd-node.is-hid .nd-fill {
  stroke: var(--brand);
}
.nd-node.is-out .nd-fill {
  stroke: var(--accent);
}
.nd-node .nd-sym {
  font-size: 14px;
  font-weight: 800;
  fill: var(--text);
}
.nd-node .nd-val {
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-weight: 600;
  fill: var(--text-2);
}
.nd-node.dim {
  opacity: 0.28;
}
.nd-node.pick {
  cursor: pointer;
  outline: none;
}
.nd-node.pick:hover .nd-fill,
.nd-node.pick:focus-visible .nd-fill {
  stroke-width: 3.6;
}
.nd-node.sel .nd-fill {
  stroke: var(--brand-ink);
  stroke-width: 4.2;
}

/* loss 节点 */
.nd-loss.dim {
  opacity: 0.28;
}
.nd-lossbox {
  fill: color-mix(in srgb, var(--loss) 15%, var(--surface));
  stroke: var(--loss);
  stroke-width: 1.8;
}
.nd-svg .nd-losst {
  font-size: 13px;
  font-weight: 800;
  fill: var(--text);
}
.nd-svg .nd-lossv {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  fill: var(--text);
}
.nd-svg .nd-ytxt {
  font-size: 11px;
  fill: var(--muted);
}
