/* ==========================================================================
 * VectorPulse Studio — 工业硬件风 · 全量重构版
 * 风格保持：米灰机箱 / 粗黑描边 / 硬阴影 / 等宽遥测字体
 * 布局目标：桌面 100dvh 一屏（无整页滚动），小屏降级滚动单列
 * ========================================================================== */

/* ---- 设计令牌 ---- */
:root {
  --hw-chassis: #e7e4db;
  --hw-panel: #f3f0e8;
  --hw-groove: #dad6c9;
  --hw-border: #141414;
  --hw-text: #141414;
  --hw-dim: #726f65;
  --hw-orange: #ff3e00;
  --hw-orange-hi: #ff521a;
  --hw-ok: #00c853;
  --hw-shadow: 4px 4px 0 var(--hw-border);
  --hw-shadow-sm: 2px 2px 0 var(--hw-border);
  --radius: 3px;
  --font-mono: ui-monospace, "SF Mono", "JetBrains Mono", Consolas, monospace;
  --header-h: 48px;
  --side-w: clamp(248px, 19vw, 300px);
  --gap: 10px;
  --ctl-h: 32px;
}

/* ---- 基座 ---- */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; padding: 0; }
html, body { height: 100%; }
[hidden] { display: none !important; }

body {
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--hw-chassis);
  color: var(--hw-text);
  font: 12px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  user-select: none;
  -webkit-font-smoothing: antialiased;
}

:focus-visible {
  outline: 2px solid var(--hw-orange);
  outline-offset: 2px;
}

::selection { background: var(--hw-orange); color: #fff; }

/* ---- 顶栏 ---- */
.topbar {
  flex: 0 0 var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 16px;
  background: var(--hw-panel);
  border-bottom: 2px solid var(--hw-border);
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.status-led {
  width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0;
  background: #00ff66; border: 1.5px solid var(--hw-border);
  box-shadow: 0 0 8px #00ff66;
  animation: led-pulse 2.4s ease-in-out infinite;
}
@keyframes led-pulse { 50% { opacity: .55; } }
.brand h1 { font-size: 15px; font-weight: 900; letter-spacing: .08em; white-space: nowrap; }
.brand h1 b { background: var(--hw-orange); color: #fff; padding: 1px 6px; border-radius: 2px; }
.brand-sub {
  color: var(--hw-dim); font: 700 10.5px var(--font-mono);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.header-badges { display: flex; gap: 6px; flex-shrink: 0; }
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  font: 800 10px var(--font-mono); padding: 3px 8px;
  background: var(--hw-groove); border: 1.5px solid var(--hw-border);
  border-radius: var(--radius); white-space: nowrap;
}
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--hw-ok); }

/* ---- 三舱网格 ---- */
.layout {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: var(--side-w) minmax(0, 1fr) var(--side-w);
}

/* ---- 机架 ---- */
.rack {
  background: var(--hw-panel);
  padding: var(--gap);
  display: flex;
  flex-direction: column;
  gap: var(--gap);
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: var(--hw-border) transparent;
}
.rack-left { border-right: 2px solid var(--hw-border); }
.rack-right { border-left: 2px solid var(--hw-border); }
.rack-note {
  margin-top: auto;
  font: 700 9.5px var(--font-mono);
  color: var(--hw-dim);
  letter-spacing: .08em;
  text-align: center;
  padding-top: 2px;
}

/* ---- 模块 ---- */
.sec {
  position: relative;
  background: var(--hw-chassis);
  border: 2px solid var(--hw-border);
  border-radius: var(--radius);
  box-shadow: var(--hw-shadow-sm);
  padding: 12px 10px 11px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-shrink: 0;
}
.sec-grow { flex: 0 0 auto; }
.sec h2 {
  font-size: 10.5px; font-weight: 900; letter-spacing: .1em; text-transform: uppercase;
  border-bottom: 1.5px dashed var(--hw-border);
  padding-bottom: 6px;
}
.screw {
  position: absolute; top: 3px; font: 9px var(--font-mono);
  color: var(--hw-dim); pointer-events: none;
}
.screw.tl { left: 5px; } .screw.tr { right: 5px; }
.fld-label { font-size: 11px; font-weight: 800; text-transform: uppercase; }
.sec > select { width: 100%; }
.hint { color: var(--hw-dim); font-size: 10.5px; font-weight: 600; line-height: 1.4; }
.sec-foot { margin-top: 2px; }
.sec-foot .bt { width: 100%; }

/* ---- 表单行：定宽 label + 弹性控件 ---- */
.row { display: flex; align-items: center; gap: 8px; min-height: var(--ctl-h); }
.row > label { flex: 0 0 66px; font-size: 11px; font-weight: 800; text-transform: uppercase; }
.row > select, .row > input[type="range"] { flex: 1; min-width: 0; }
.val {
  flex: 0 0 42px;
  height: 22px; line-height: 22px; text-align: center;
  font: 800 11px var(--font-mono);
  background: var(--hw-border); color: #fff; border-radius: 2px;
}

/* ---- 控件 ---- */
select {
  min-height: var(--ctl-h);
  max-width: 100%;
  padding: 4px 6px;
  font-size: 12px; font-weight: 700; color: var(--hw-text);
  background: #fff;
  border: 2px solid var(--hw-border); border-radius: var(--radius);
  box-shadow: 1px 1px 0 var(--hw-border);
  outline: none;
}
select:disabled { opacity: .4; }

input[type="range"] {
  appearance: none; -webkit-appearance: none;
  height: 24px; background: transparent; cursor: ew-resize; margin: 0;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 8px; background: var(--hw-groove);
  border: 1.5px solid var(--hw-border); border-radius: 2px;
  background-image: repeating-linear-gradient(90deg, var(--hw-border) 0, var(--hw-border) 1px, transparent 0, transparent 6px);
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 14px; height: 20px; margin-top: -7.5px;
  background: #fff; border: 2px solid var(--hw-border); border-radius: 2px;
  box-shadow: 1px 1px 0 var(--hw-border);
}
input[type="range"]::-moz-range-track {
  height: 8px; background: var(--hw-groove);
  border: 1.5px solid var(--hw-border); border-radius: 2px;
}
input[type="range"]::-moz-range-thumb {
  width: 10px; height: 16px; background: #fff;
  border: 2px solid var(--hw-border); border-radius: 2px;
}

.check {
  display: flex; align-items: center; gap: 8px; min-height: 26px;
  font-size: 11px; font-weight: 800; text-transform: uppercase; cursor: pointer;
}
.check input { width: 15px; height: 15px; accent-color: var(--hw-orange); flex-shrink: 0; }
.check.inline { font-size: 10.5px; }

/* ---- 按钮 ---- */
.btns { display: flex; gap: 8px; flex-wrap: wrap; }
.btns.col { flex-direction: column; align-items: stretch; gap: 6px; }
.bt {
  appearance: none;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: var(--ctl-h); padding: 6px 12px;
  font-size: 12px; font-weight: 800; text-transform: uppercase; line-height: 1.2;
  color: var(--hw-text); background: #fff;
  border: 2px solid var(--hw-border); border-radius: var(--radius);
  box-shadow: var(--hw-shadow-sm);
  cursor: pointer; white-space: nowrap;
  transition: transform .08s, box-shadow .08s, background .12s;
}
.bt:hover:not(:disabled) { background: #fcfbfa; }
.bt:active:not(:disabled) { transform: translate(2px, 2px); box-shadow: none; }
.bt:disabled { opacity: .35; cursor: not-allowed; box-shadow: none; background: var(--hw-groove); }
.bt.primary { background: var(--hw-orange); color: #fff; }
.bt.primary:hover:not(:disabled) { background: var(--hw-orange-hi); }
.bt.sub { background: var(--hw-groove); }
.bt.large { min-height: 38px; padding: 7px 18px; font-size: 12.5px; }

body[data-state="busy"] .bt.primary { position: relative; }

/* ---- 中央舞台 ---- */
.rack-center {
  min-width: 0; min-height: 0;
  padding: 10px 16px;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  overflow: hidden;
  background-image: radial-gradient(var(--hw-border) 1px, transparent 1px);
  background-size: 20px 20px;
}

/* 上传槽 */
.drop {
  width: 100%; max-width: 880px; flex: 0 0 auto;
  min-height: 54px;
  display: flex; align-items: center; justify-content: center; gap: 12px;
  padding: 6px 14px;
  background: var(--hw-panel);
  border: 2px dashed var(--hw-border); border-radius: var(--radius);
  box-shadow: var(--hw-shadow-sm);
  color: var(--hw-dim); font-weight: 600; font-size: 12px;
  cursor: pointer;
  transition: border-color .12s, background .12s;
}
.drop:hover, .drop.over, .drop:focus-visible { border-color: var(--hw-orange); background: #fff; }
.drop-icon {
  width: 32px; height: 32px; flex-shrink: 0;
  display: grid; place-items: center;
  font-size: 16px; color: var(--hw-border);
  background: #fff; border: 2px solid var(--hw-border); border-radius: var(--radius);
}
.drop-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.drop b { color: var(--hw-orange); }
.drop-sep { color: var(--hw-text); }
.drop-sub { font-size: 10.5px; opacity: .85; }
kbd {
  font: 9.5px var(--font-mono);
  background: var(--hw-border); color: #fff;
  padding: 2px 5px; border-radius: 2px;
}

/* HUD */
.screen-hud {
  width: 100%; max-width: 880px; flex: 0 0 auto;
  min-height: 30px;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.stats { display: flex; gap: 6px; min-width: 0; overflow: hidden; }
.stats:empty { display: none; }
.chip {
  font: 800 10.5px var(--font-mono); white-space: nowrap;
  background: #fff; border: 1.5px solid var(--hw-border); border-radius: 2px;
  box-shadow: 1.5px 1.5px 0 var(--hw-border);
  padding: 3px 8px;
}
.chip b { color: var(--hw-orange); }
.view-tabs {
  display: inline-flex; gap: 0; padding: 2px; flex-shrink: 0;
  background: var(--hw-groove);
  border: 2px solid var(--hw-border); border-radius: var(--radius);
  box-shadow: var(--hw-shadow-sm);
}
.tab-btn {
  border: 0; background: transparent; color: var(--hw-text);
  padding: 5px 11px; font-size: 10.5px; font-weight: 800; text-transform: uppercase;
  border-radius: 2px; cursor: pointer; white-space: nowrap;
}
.tab-btn.active { background: var(--hw-border); color: #fff; }

/* 舞台视口：吃掉所有剩余高度 */
.stage-wrapper {
  width: 100%; max-width: 880px;
  flex: 1; min-height: 0; min-width: 0;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
}
.stage-viewport {
  width: 100%; flex: 1; min-height: 0; min-width: 0;
  display: grid; place-items: center; overflow: hidden;
  container-type: size;
}
.stage-empty {
  width: min(100%, 560px);
  flex: 1; min-height: 0; max-height: 100%;
  aspect-ratio: 16 / 8.2;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  background: rgba(243, 240, 232, .88);
  border: 2px dashed var(--hw-border); border-radius: 4px;
  color: var(--hw-dim); font: 700 11px var(--font-mono);
  text-align: center; padding: 12px;
  cursor: pointer;
  transition: border-color .12s, background .12s, transform .08s;
}
.stage-empty:hover, .stage-empty.over, .stage-empty:focus-visible {
  border-color: var(--hw-orange);
  background: #fff;
}
.stage-empty:active { transform: translate(1px, 1px); }
.stage-empty .big { font-size: 26px; color: var(--hw-border); }
.empty-title { letter-spacing: .06em; color: var(--hw-text); }
.empty-sub { font-size: 10.5px; }

/* 监视屏：尺寸由 JS 写入 */
.diff-container {
  position: relative; overflow: hidden; flex-shrink: 0;
  max-width: 100%; max-height: 100%;
  background: #fff;
  border: 3px solid var(--hw-border); border-radius: 4px;
  box-shadow: inset 0 0 10px rgba(0,0,0,.06), var(--hw-shadow);
}
.crosshair {
  position: absolute; z-index: 8; pointer-events: none;
  font: 12px var(--font-mono); color: var(--hw-dim); line-height: 1;
}
.crosshair.tl { top: 6px; left: 8px; }
.crosshair.tr { top: 6px; right: 8px; }
.crosshair.bl { bottom: 6px; left: 8px; }
.crosshair.br { bottom: 6px; right: 8px; }
.diff-layer { position: absolute; inset: 0; width: 100%; height: 100%; }
.diff-layer canvas, .diff-layer svg { display: block; width: 100%; height: 100%; }
.diff-before { z-index: 1; }
.diff-after {
  z-index: 2; overflow: hidden;
  clip-path: inset(0 0 0 calc(var(--split, 50%) * 1%));
}
#diffSvg { width: 100%; height: 100%; }
.diff-slider-input { position: absolute; inset: 0; z-index: 5; width: 100%; height: 100%; opacity: 0; margin: 0; cursor: ew-resize; }
.diff-divider {
  position: absolute; top: 0; bottom: 0; left: calc(var(--split, 50%) * 1%);
  width: 2px; background: var(--hw-orange); z-index: 4;
  pointer-events: none; transform: translateX(-50%);
}
.diff-handle {
  position: absolute; top: 50%; left: 50%;
  width: 26px; height: 26px;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 900; color: #fff;
  background: var(--hw-orange); border: 2px solid var(--hw-border); border-radius: 2px;
  box-shadow: 2px 2px 0 var(--hw-border);
  transform: translate(-50%, -50%);
}

/* 双轨 */
.side-wrap {
  display: flex; align-items: center; justify-content: center; gap: 12px;
  max-width: 100%; max-height: 100%; flex-shrink: 0;
}
.pv-box {
  position: relative; overflow: hidden; flex-shrink: 0;
  max-width: 100%; max-height: 100%;
  background: #fff; border: 2px solid var(--hw-border); border-radius: 3px;
  box-shadow: var(--hw-shadow);
}
.pv-box svg, .pv-box canvas { display: block; width: 100%; height: 100%; }
.tag {
  position: absolute; left: 8px; top: 8px; z-index: 10;
  font: 800 9.5px var(--font-mono); letter-spacing: .05em;
  background: var(--hw-border); color: #fff;
  padding: 2px 6px; border-radius: 2px;
}
.tag.right { left: auto; right: 8px; }

/* 播控条 */
.anim-bar-wrap {
  width: 100%; max-width: 560px; flex: 0 0 auto;
  min-height: 40px;
  display: flex; align-items: center; gap: 8px;
  padding: 5px 10px;
  background: var(--hw-panel);
  border: 2px solid var(--hw-border); border-radius: 3px;
  box-shadow: var(--hw-shadow-sm);
}
.anim-bar-wrap select { min-height: 28px; font-size: 11px; }
.ctrl-icon-btn {
  width: 28px; height: 28px; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  background: #fff; color: var(--hw-text);
  border: 1.5px solid var(--hw-border); border-radius: 2px;
  box-shadow: 1px 1px 0 var(--hw-border);
  cursor: pointer; padding: 4px;
}
.ctrl-icon-btn:active { transform: translate(1px, 1px); box-shadow: none; }
.anim-progress {
  flex: 1; min-width: 40px; height: 8px;
  background: var(--hw-groove);
  border: 1.5px solid var(--hw-border); border-radius: 2px;
  overflow: hidden;
}
.anim-progress-inner { height: 100%; width: 0%; background: var(--hw-orange); }
.playing .anim-progress-inner {
  animation: progress-fill var(--total-duration, 5s) linear forwards;
  animation-play-state: var(--play-state, running);
}
@keyframes progress-fill { from { width: 0%; } to { width: 100%; } }

/* ---- GSAP 时间轴 scrub：有 GSAP 时替代静态进度条（显隐由 JS 切 hidden） ---- */
.scrub { flex: 1; min-width: 40px; }
body[data-engine="gsap"] #progressWrap { display: none; }
#scrub::-webkit-slider-runnable-track {
  height: 8px; background: var(--hw-groove);
  border: 1.5px solid var(--hw-border); border-radius: 2px;
}
#scrub::-webkit-slider-thumb {
  -webkit-appearance: none; width: 12px; height: 20px; margin-top: -7.5px;
  background: var(--hw-orange); border: 2px solid var(--hw-border); border-radius: 2px;
  box-shadow: 1px 1px 0 var(--hw-border); cursor: ew-resize;
}
#scrub::-moz-range-track {
  height: 8px; background: var(--hw-groove);
  border: 1.5px solid var(--hw-border); border-radius: 2px;
}
#scrub::-moz-range-thumb {
  width: 9px; height: 16px; background: var(--hw-orange);
  border: 2px solid var(--hw-border); border-radius: 2px; cursor: ew-resize;
}

/* ---- 笔尖跟随 ---- */
.stage-viewport { position: relative; }
.pen-tip {
  position: absolute; left: 0; top: 0; z-index: 30;
  pointer-events: none;
  will-change: transform;
  filter: drop-shadow(2px 2px 0 rgba(20, 20, 20, .55));
}
.pen-nib {
  display: grid; place-items: center;
  width: 26px; height: 26px; font-size: 15px;
  background: #fff; border: 2px solid var(--hw-border); border-radius: 50%;
  transform: translate(-50%, -78%) rotate(-18deg);
}
.pen-tip.beam .pen-nib { background: var(--hw-orange); color: #fff; }
.pen-trail {
  position: absolute; left: -3px; top: -3px; width: 6px; height: 6px; border-radius: 50%;
  background: var(--hw-orange); opacity: .85;
  transform: translate(-50%, -50%);
  box-shadow: 0 0 8px 2px rgba(255, 62, 0, .55);
}

/* ---- GSAP 接管时禁用 CSS 关键帧（逐帧由引擎写入行内样式） ---- */
body[data-engine="gsap"] .playing .pg,
body[data-engine="gsap"] .playing .beam-svg,
body[data-engine="gsap"] .playing .glow,
body[data-engine="gsap"] .playing .anim-progress-inner { animation: none; }

/* 底栏：触发 + 日志同行 */
.stage-foot {
  width: 100%; max-width: 880px; flex: 0 0 auto;
  min-height: 38px;
  display: flex; align-items: center; gap: 12px;
}
#log {
  flex: 1; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: left;
  font: 700 11px var(--font-mono); color: var(--hw-dim);
}
.spin {
  display: inline-block; width: 12px; height: 12px; margin-right: 6px; vertical-align: -2px;
  border: 2px solid rgba(20,20,20,.2); border-top-color: var(--hw-orange); border-radius: 50%;
  animation: rot .75s linear infinite;
}
@keyframes rot { to { transform: rotate(360deg); } }

/* ---- 播放动效关键帧（与导出 HTML 共用语义，保持一致） ---- */
.sketch { opacity: 0; filter: grayscale(1) brightness(.6) contrast(1.4); }
.playing .sketch {
  animation: sketch-in .8s ease-out var(--tone, 0s) forwards,
    ink .8s ease-in-out var(--ink) forwards,
    sketch-out 1.4s ease-in var(--out) forwards;
  animation-play-state: var(--play-state, running);
}
.skb path {
  fill: none; stroke: #141414; stroke-width: 2.2;
  stroke-linejoin: round; stroke-linecap: round;
  stroke-dasharray: 1; stroke-dashoffset: 1;
}
.playing .skb path {
  animation: draw .7s ease-out both;
  animation-delay: calc(.2s + var(--i) * .04s);
  animation-play-state: var(--play-state, running);
}
.playing .skst { animation: skst-out .8s ease both var(--tone); animation-play-state: var(--play-state, running); }
@keyframes draw { to { stroke-dashoffset: 0; } }
@keyframes skst-out { from { opacity: 1; } to { opacity: 0; } }
@keyframes sketch-in { from { opacity: 0; } to { opacity: .45; } }
@keyframes ink { from { opacity: .45; } to { opacity: .75; } }
@keyframes sketch-out { to { opacity: 0; } }

.pg { will-change: opacity, clip-path, transform; transform-box: fill-box; transform-origin: 50% 50%; }
.playing .pg {
  animation: .55s cubic-bezier(.45,.05,.25,1) both;
  animation-delay: var(--d);
  animation-play-state: var(--play-state, running);
}
.playing .wipe-r { animation-name: wipe-r; }
.playing .wipe-l { animation-name: wipe-l; }
.playing .wipe-d { animation-name: wipe-d; }
.playing .dab { animation-name: dab; }
.playing .bloom { animation-name: bloom; }
@keyframes wipe-r { 0% { opacity: 0; clip-path: polygon(0 0, 0 0, 0 100%, 0 100%); } 35% { opacity: 1; } 100% { opacity: 1; clip-path: polygon(-3% 0, 113% 0, 113% 100%, -3% 100%); } }
@keyframes wipe-l { 0% { opacity: 0; clip-path: polygon(100% 0, 100% 0, 100% 100%, 100% 100%); } 35% { opacity: 1; } 100% { opacity: 1; clip-path: polygon(-3% 0, 103% 0, 103% 100%, -3% 100%); } }
@keyframes wipe-d { 0% { opacity: 0; clip-path: polygon(0 0, 100% 0, 100% 0, 0 0); } 35% { opacity: 1; } 100% { opacity: 1; clip-path: polygon(0 -3%, 100% -3%, 100% 113%, 0 113%); } }
@keyframes dab { 0% { opacity: 0; clip-path: circle(0% at 50% 50%); } 35% { opacity: 1; } 100% { opacity: 1; clip-path: circle(120% at 50% 50%); } }
@keyframes bloom { 0% { opacity: 0; filter: blur(8px); transform: scale(1.04); } 100% { opacity: 1; filter: blur(0); transform: scale(1); } }
.playing #art { animation: settle .8s ease-out forwards; animation-delay: var(--settle); animation-play-state: var(--play-state, running); }
@keyframes settle { from { filter: saturate(.9) brightness(1.02); } to { filter: none; } }

/* 极光 */
.beam-svg {
  transform: scale(1.03);
  -webkit-mask-image: linear-gradient(105deg, #000 42%, rgba(0,0,0,.35) 50%, transparent 58%);
  mask-image: linear-gradient(105deg, #000 42%, rgba(0,0,0,.35) 50%, transparent 58%);
  -webkit-mask-size: 260% 100%; mask-size: 260% 100%;
  -webkit-mask-repeat: no-repeat; mask-repeat: no-repeat;
}
.playing .beam-svg {
  animation: reveal 2.5s cubic-bezier(.55,.06,.28,.99) forwards, bzoom 3.2s cubic-bezier(.2,.6,.2,1) forwards;
  animation-play-state: var(--play-state, running);
}
@keyframes reveal { from { -webkit-mask-position: 100% 0; mask-position: 100% 0; } to { -webkit-mask-position: 0% 0; mask-position: 0% 0; } }
@keyframes bzoom { to { transform: scale(1); } }
.glow {
  position: absolute; top: -10%; bottom: -10%; left: 0; width: 100px;
  opacity: 0; pointer-events: none; z-index: 3;
  background: linear-gradient(90deg, transparent 0%, rgba(255,62,0,.3) 30%, #fff 60%, rgba(255,62,0,.3) 80%, transparent 100%);
  filter: blur(6px); mix-blend-mode: screen;
}
.playing .glow { animation: sweep 2.5s cubic-bezier(.55,.06,.28,.99) forwards; animation-play-state: var(--play-state, running); }
@keyframes sweep { 0% { transform: translateX(-160px); opacity: 0; } 8% { opacity: 1; } 90% { opacity: 1; } 100% { transform: translateX(calc(100cqw + 80px)); opacity: 0; } }

/* ---- 弹窗 ---- */
.modal-mask { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; background: rgba(20,20,20,.75); }
.modal {
  width: min(780px, 92vw); max-height: 85vh;
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--hw-panel); border: 2px solid var(--hw-border); border-radius: 4px;
  box-shadow: 6px 6px 0 var(--hw-border);
}
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px; background: var(--hw-chassis);
  border-bottom: 2px solid var(--hw-border);
}
.modal-head h3 { font-size: 12px; font-weight: 800; }
.modal-body { padding: 12px; flex: 1; min-height: 0; }
.modal-body textarea {
  width: 100%; height: 360px; padding: 10px; resize: vertical; outline: none;
  font: 11px var(--font-mono); color: var(--hw-text);
  background: #fff; border: 2px solid var(--hw-border); border-radius: 2px;
}
.modal-foot {
  display: flex; justify-content: flex-end; gap: 8px;
  padding: 10px 16px; background: var(--hw-chassis);
  border-top: 2px solid var(--hw-border);
}

/* ---- 右上语言切换（徽章组首位，橙色强调凸显） ---- */
.header-badges { align-items: center; }
.lang-toggle {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 4px 12px;
  font: 800 11px var(--font-mono);
  letter-spacing: .08em;
  color: var(--hw-orange);
  background: #fff;
  border: 2px solid var(--hw-orange);
  border-radius: var(--radius);
  box-shadow: 1.5px 1.5px 0 var(--hw-border);
  cursor: pointer;
  white-space: nowrap;
  transition: transform .08s, box-shadow .08s, background .12s, color .12s;
}
.lang-toggle:hover { background: var(--hw-orange); color: #fff; }
.lang-toggle:active { transform: translate(2px, 2px); box-shadow: none; }
.lang-toggle.on {
  background: var(--hw-orange);
  color: #fff;
}
.lang-toggle.on:hover { background: var(--hw-orange-hi); }

/* ---- 断点 ---- */
@media (min-width: 1500px) {
  .rack-center { padding: 12px 28px; }
}
@media (max-width: 1240px) {
  .brand-sub { display: none; }
  .rack-center { padding: 10px 12px; }
  .hide-sm { display: none; }
}
@media (max-width: 1023px) {
  body { height: auto; min-height: 100dvh; overflow-y: auto; display: block; }
  .topbar { position: sticky; top: 0; z-index: 50; height: auto; min-height: var(--header-h); padding: 8px 12px; flex-wrap: wrap; row-gap: 6px; }
  .layout { display: flex; flex-direction: column; }
  .rack-center { order: 1; overflow: visible; }
  .rack-left, .rack-right {
    order: 2; overflow: visible;
    display: grid; grid-template-columns: 1fr 1fr; align-items: start;
    border: 0; border-top: 2px solid var(--hw-border);
  }
  .rack-right { order: 3; }
  .rack-note { grid-column: 1 / -1; }
  .stage-viewport { min-height: 46vh; flex: none; }
  .stage-empty { flex: none; min-height: 300px; }
  .drop-text { white-space: normal; }
  .screen-hud { flex-wrap: wrap; }
  .stage-foot { flex-wrap: wrap; }
  #log { white-space: normal; }
}
@media (max-width: 640px) {
  .rack-left, .rack-right { grid-template-columns: 1fr; }
  .header-badges .badge:first-of-type { display: none; }
  .side-wrap { flex-direction: column; max-height: none; }
  .stage-viewport { min-height: 40vh; }
}

/* ---- 动效偏好 ---- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
