/* ============================================================
   PartyKeys — styles (v2)
   ============================================================ */

:root {
  --bg-0: #080a1f;
  --bg-1: #121435;
  --bg-2: #1a1042;
  --ink: #eef1ff;
  --ink-dim: #9aa3c7;
  --ink-mute: #6d76a0;
  --pink: #f472b6;
  --pink-deep: #ec4899;
  --blue: #38bdf8;
  --cyan: #22d3ee;
  --purple: #a78bfa;
  --green: #34d399;
  --amber: #fbbf24;
  --red: #ef4444;
  --panel: rgba(22, 25, 60, 0.66);
  --panel-strong: rgba(22, 25, 60, 0.86);
  --stroke: rgba(255, 255, 255, 0.09);
  --stroke-strong: rgba(255, 255, 255, 0.18);
  --grad-brand: linear-gradient(90deg, #f472b6 0%, #a78bfa 60%, #38bdf8 100%);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

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

html, body {
  height: 100%;
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(ellipse at 20% 0%, rgba(244, 114, 182, 0.20), transparent 55%),
    radial-gradient(ellipse at 85% 15%, rgba(56, 189, 248, 0.18), transparent 55%),
    radial-gradient(ellipse at 50% 100%, rgba(167, 139, 250, 0.18), transparent 55%),
    linear-gradient(180deg, var(--bg-0), var(--bg-1) 55%, var(--bg-2));
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  -webkit-font-smoothing: antialiased;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100%;
}

/* ---------- 顶栏 ---------- */
#topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 22px;
  gap: 16px;
  background: linear-gradient(180deg, rgba(8, 10, 31, 0.85), rgba(8, 10, 31, 0.55));
  border-bottom: 1px solid var(--stroke);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  z-index: 50;
}

.brand {
  display: flex; align-items: center; gap: 10px;
  font-weight: 700;
}
.brand-logo {
  width: 32px; height: 32px;
  object-fit: contain;
  filter: drop-shadow(0 4px 14px rgba(167, 139, 250, 0.45));
}
.brand-name {
  font-size: 17px; letter-spacing: 0.3px;
  background: var(--grad-brand);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
}
.brand-tag {
  font-size: 10px; text-transform: uppercase;
  letter-spacing: 2px; color: var(--ink-mute);
  padding-left: 10px; margin-left: 2px;
  border-left: 1px solid var(--stroke);
}

.status { display: flex; gap: 6px; flex-wrap: wrap; }

.chip {
  padding: 5px 11px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid var(--stroke);
  background: rgba(255, 255, 255, 0.03);
  color: var(--ink-dim);
  white-space: nowrap;
  transition: all 0.25s;
}
.chip-ok   { color: var(--green); border-color: rgba(52, 211, 153, 0.4); background: rgba(52, 211, 153, 0.08); }
.chip-warn { color: var(--amber); border-color: rgba(251, 191, 36, 0.4); background: rgba(251, 191, 36, 0.06); }
.chip-err  { color: var(--red);   border-color: rgba(239, 68, 68, 0.45); background: rgba(239, 68, 68, 0.08); }
.chip-mode {
  color: #fff;
  border-color: rgba(244, 114, 182, 0.5);
  background: linear-gradient(90deg, rgba(244, 114, 182, 0.18), rgba(167, 139, 250, 0.18));
  font-weight: 700;
  letter-spacing: 0.5px;
}

.controls { display: flex; gap: 8px; }
.btn {
  padding: 7px 15px;
  border-radius: 9px;
  border: 1px solid var(--stroke-strong);
  background: rgba(255, 255, 255, 0.06);
  color: var(--ink);
  font-size: 13px; font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  transition: transform 0.12s, background 0.15s, border-color 0.15s, box-shadow 0.15s;
}
.btn:hover { background: rgba(255, 255, 255, 0.12); border-color: rgba(255, 255, 255, 0.28); }
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary {
  background: var(--grad-brand);
  border: none; color: #0a0b1e;
  box-shadow: 0 6px 20px rgba(167, 139, 250, 0.45);
  letter-spacing: 1px;
}
.btn-primary:hover { filter: brightness(1.05); }
.btn-ghost {
  padding: 0; width: 32px; height: 32px; border-radius: 50%;
  font-weight: 400; font-size: 15px;
}

/* ---------- 控制条（顶栏下方，横向铺满） ---------- */
#controlbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 20px 32px;
  padding: 14px 40px;
  background: linear-gradient(180deg, rgba(18, 20, 53, 0.78), rgba(18, 20, 53, 0.45));
  border-bottom: 1px solid var(--stroke);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  z-index: 49;
  font-size: 13px;
}
.cb-group {
  display: flex;
  align-items: center;
  gap: 12px;
}
.cb-group-wide { flex: 1 1 280px; max-width: 420px; min-width: 240px; }
.cb-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1.6px;
  color: var(--ink);
  font-weight: 700;
}
.cb-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px; height: 28px;
  border-radius: 9px;
  background: linear-gradient(135deg, rgba(244,114,182,0.22), rgba(167,139,250,0.22));
  border: 1px solid rgba(167,139,250,0.35);
  color: #fff;
  box-shadow: 0 3px 12px rgba(167,139,250,0.22), inset 0 1px 0 rgba(255,255,255,0.12);
  flex-shrink: 0;
}
.cb-icon svg { display: block; }
.cb-icon-oct    { color: #f9a8d4; }
.cb-icon-vol    { color: #93c5fd; }
.cb-icon-voice  { color: #c4b5fd; }
.cb-icon-rhythm { color: #fcd34d; }
.cb-stepper {
  display: flex; align-items: center; gap: 4px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--stroke);
  border-radius: 12px;
  padding: 4px;
}
.cb-step {
  width: 34px; height: 34px;
  border-radius: 9px;
  border: none;
  background: rgba(255, 255, 255, 0.06);
  color: var(--ink);
  font-size: 18px; font-weight: 700;
  cursor: pointer;
  transition: all 0.15s;
}
.cb-step:hover { background: rgba(167, 139, 250, 0.25); }
.cb-step:active { transform: scale(0.92); }
.cb-stepper-val {
  min-width: 82px;
  text-align: center;
  font-weight: 700;
  font-family: var(--font-mono);
  font-size: 14px;
  color: #fff;
}
.cb-slider-wrap {
  display: flex; align-items: center; gap: 12px;
  flex: 1;
}
.cb-slider-wrap input[type="range"] {
  flex: 1;
  appearance: none;
  -webkit-appearance: none;
  height: 8px;
  background: linear-gradient(90deg, var(--blue), var(--pink));
  border-radius: 999px;
  outline: none;
  cursor: pointer;
}
.cb-slider-wrap input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid var(--purple);
  box-shadow: 0 2px 12px rgba(167, 139, 250, 0.65);
  cursor: grab;
}
.cb-slider-wrap input[type="range"]::-moz-range-thumb {
  width: 22px; height: 22px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid var(--purple);
  box-shadow: 0 2px 12px rgba(167, 139, 250, 0.65);
  cursor: grab;
}
.cb-slider-val {
  min-width: 34px;
  text-align: right;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 13px;
  color: #fff;
}
.cb-pills {
  display: flex; gap: 4px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--stroke);
  border-radius: 12px;
  padding: 4px;
}
.cb-pill {
  padding: 8px 16px;
  border-radius: 9px;
  border: none;
  background: transparent;
  color: var(--ink-dim);
  font-size: 13px;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  transition: all 0.18s;
  white-space: nowrap;
}
.cb-pill:hover { color: #fff; background: rgba(255, 255, 255, 0.06); }
.cb-pill.active {
  background: var(--grad-brand);
  color: #0a0b1e;
  box-shadow: 0 4px 12px rgba(167, 139, 250, 0.4);
}

/* ---------- 开机 Hero 屏 ---------- */
#hero-screen {
  position: absolute;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px;
  background:
    radial-gradient(ellipse at 20% 30%, rgba(244, 114, 182, 0.28), transparent 55%),
    radial-gradient(ellipse at 80% 20%, rgba(56, 189, 248, 0.25), transparent 55%),
    radial-gradient(ellipse at 50% 100%, rgba(167, 139, 250, 0.32), transparent 60%),
    linear-gradient(180deg, rgba(8, 10, 31, 0.92), rgba(18, 16, 66, 0.95));
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  transition: opacity 0.6s cubic-bezier(0.22, 1, 0.36, 1), transform 0.6s;
  overflow: hidden;
}
#hero-screen::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(circle at 50% 50%, rgba(255,255,255,0.06) 1px, transparent 1.5px);
  background-size: 26px 26px;
  opacity: 0.5;
  pointer-events: none;
}
#hero-screen.hidden {
  opacity: 0;
  pointer-events: none;
  transform: scale(1.04);
}
/* hero 隐藏时彻底停掉彩虹键盘的 CSS 动画，避免继续吃合成线程 */
#hero-screen.hidden .hk-glow,
#hero-screen.hidden .hero-start-ring,
#hero-screen.hidden .hero-start-ring::after {
  animation: none !important;
}

.hero-inner {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 26px;
  max-width: 760px;
  text-align: center;
  animation: hero-fade-up 0.8s cubic-bezier(0.22, 1, 0.36, 1);
}
@keyframes hero-fade-up {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}

.hero-logo-row {
  display: flex; align-items: center; gap: 16px;
}
.hero-logo {
  width: 68px; height: 68px;
  object-fit: contain;
  filter: drop-shadow(0 8px 30px rgba(167, 139, 250, 0.55));
}
.hero-brand {
  text-align: center;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.hero-brand-name {
  font-size: 32px;
  font-weight: 800;
  letter-spacing: 0.5px;
  background: var(--grad-brand);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
  line-height: 1;
}
.hero-brand-sub {
  font-size: 11px;
  /* letter-spacing 自适应 —— 让 9 字母的 ChordHand 宽度接近 4 个 CJK 字或 9 拉丁字母的标题 */
  letter-spacing: 4px;
  padding-left: 4px; /* 抵消 letter-spacing 导致的右侧偏移，让视觉居中 */
  text-transform: uppercase;
  color: var(--ink-mute);
  font-weight: 700;
  line-height: 1;
}

.hero-slogan {
  margin: 6px 0 4px;
  display: flex; flex-direction: column; gap: 8px;
  align-items: center;
  font-weight: 400; /* reset h1 default */
}
.hero-slogan-main, .hero-slogan-sub { display: block; }
.hero-slogan-main {
  font-size: 30px;
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: 0.3px;
  color: #fff;
  text-shadow: 0 4px 24px rgba(167, 139, 250, 0.35);
}
.hero-slogan-sub {
  font-size: 15px;
  color: var(--ink-dim);
  letter-spacing: 1px;
  font-weight: 500;
}

/* 彩虹键盘 */
.hero-keyboard {
  position: relative;
  width: min(560px, 80vw);
  height: 160px;
  margin: 10px 0 6px;
  display: flex;
  gap: 4px;
  padding: 8px;
  background: linear-gradient(180deg, rgba(10, 12, 34, 0.5), rgba(10, 12, 34, 0.25));
  border: 1px solid var(--stroke);
  border-radius: 14px;
  box-shadow: 0 30px 60px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255,255,255,0.04);
}
.hero-keyboard::after {
  /* 上方打在键盘上的环境光 */
  content: "";
  position: absolute;
  inset: -10px -10px 40% -10px;
  background: radial-gradient(ellipse at 50% 100%, rgba(167, 139, 250, 0.2), transparent 70%);
  pointer-events: none;
  border-radius: 14px;
}
.hk-key {
  position: relative;
  flex: 1;
  border-radius: 0 0 8px 8px;
  overflow: hidden;
}
.hk-white {
  background: linear-gradient(180deg, #f5f6ff 0%, #d8dcf5 85%, #b6bce0 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.9),
    inset 0 -6px 14px rgba(60, 70, 120, 0.25),
    0 4px 0 rgba(0, 0, 0, 0.4);
}
.hk-blacks {
  position: absolute;
  inset: 8px 8px auto 8px;
  display: flex;
  height: 62%;
  pointer-events: none;
}
/* 8 white keys. Black keys sit at positions: between keys 0-1, 1-2, 3-4, 4-5, 5-6
   相对白键 index (0..7): skip gap after 2 and after 6 → blacks at slot boundaries 1, 2, 4, 5, 6 */
.hk-blacks .hk-key {
  position: absolute;
  width: 7.2%;
  height: 100%;
  border-radius: 0 0 6px 6px;
  flex: none;
}
.hk-blacks .hk-black:nth-child(1) { left: calc(12.5% * 1 - 3.6%); }
.hk-blacks .hk-black:nth-child(2) { left: calc(12.5% * 2 - 3.6%); }
.hk-blacks .hk-black:nth-child(3) { left: calc(12.5% * 4 - 3.6%); }
.hk-blacks .hk-black:nth-child(4) { left: calc(12.5% * 5 - 3.6%); }
.hk-blacks .hk-black:nth-child(5) { left: calc(12.5% * 6 - 3.6%); }
.hk-black {
  background: linear-gradient(180deg, #24263e 0%, #0e0f22 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.15),
    inset 0 -4px 8px rgba(0, 0, 0, 0.6),
    0 4px 0 rgba(0, 0, 0, 0.5);
}
/* 彩虹光照：铺满整个键 · 黑白键同色相 —— 固定色，不再呼吸 */
.hk-glow {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  opacity: 0.92;
}
.hk-white .hk-glow {
  background:
    linear-gradient(
      180deg,
      hsla(calc(var(--chroma) * 30deg), 95%, 72%, 0.55) 0%,
      hsla(calc(var(--chroma) * 30deg), 95%, 60%, 0.9) 70%,
      hsla(calc(var(--chroma) * 30deg), 95%, 50%, 0.95) 100%
    );
  box-shadow:
    inset 0 -22px 34px hsla(calc(var(--chroma) * 30deg), 95%, 55%, 0.45),
    inset 0 6px 12px   hsla(calc(var(--chroma) * 30deg), 95%, 82%, 0.4);
}
.hk-black .hk-glow {
  background:
    linear-gradient(
      180deg,
      hsla(calc(var(--chroma) * 30deg), 92%, 58%, 0.7) 0%,
      hsla(calc(var(--chroma) * 30deg), 92%, 42%, 0.92) 70%,
      hsla(calc(var(--chroma) * 30deg), 92%, 32%, 0.98) 100%
    );
  box-shadow:
    inset 0 -14px 22px hsla(calc(var(--chroma) * 30deg), 92%, 42%, 0.55),
    inset 0 4px 10px   hsla(calc(var(--chroma) * 30deg), 92%, 70%, 0.45);
}

/* 中央启动按钮 */
.hero-start {
  position: relative;
  width: 160px; height: 160px;
  border-radius: 50%;
  border: none;
  background: radial-gradient(circle at 35% 30%, #fef3ff, #f472b6 35%, #a78bfa 68%, #4338ca 100%);
  color: #fff;
  cursor: pointer;
  margin-top: 4px;
  box-shadow:
    0 20px 60px rgba(167, 139, 250, 0.55),
    0 0 0 4px rgba(167, 139, 250, 0.18),
    inset 0 2px 0 rgba(255, 255, 255, 0.35);
  transition: transform 0.18s ease, box-shadow 0.2s;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
}
.hero-start:hover {
  transform: translateY(-2px) scale(1.03);
  box-shadow:
    0 28px 80px rgba(167, 139, 250, 0.75),
    0 0 0 6px rgba(167, 139, 250, 0.25),
    inset 0 2px 0 rgba(255, 255, 255, 0.35);
}
.hero-start:active { transform: scale(0.97); }
.hero-start:disabled { opacity: 0.75; cursor: wait; }
.hero-start-ring {
  position: absolute;
  inset: -14px;
  border-radius: 50%;
  border: 2px solid rgba(244, 114, 182, 0.35);
  pointer-events: none;
}
.hero-start-ring::after {
  content: "";
  position: absolute;
  inset: -12px;
  border-radius: 50%;
  border: 1px solid rgba(167, 139, 250, 0.25);
}
.hero-start-text {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: 4px;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}
.hero-start-hint {
  font-size: 10px;
  letter-spacing: 3px;
  text-transform: uppercase;
  opacity: 0.75;
  font-weight: 700;
}

.hero-foot {
  margin-top: 2px;
  font-size: 12px;
  color: var(--ink-mute);
  letter-spacing: 0.5px;
}
.hero-foot b { color: var(--ink-dim); font-weight: 600; }

/* 小屏适配 */
@media (max-width: 640px) {
  .hero-slogan-en { font-size: 22px; }
  .hero-slogan-zh { font-size: 12px; }
  .hero-keyboard { height: 120px; }
  .hero-start { width: 130px; height: 130px; }
  .hero-start-text { font-size: 22px; }
  .hero-brand-name { font-size: 24px; }
  .hero-logo { width: 52px; height: 52px; }
}

/* ---------- 舞台 ---------- */
#stage {
  position: relative;
  flex: 1;
  overflow: hidden;
}

#camera-video {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  opacity: 0.22;
  transform: scaleX(-1) translateZ(0);
  will-change: opacity, transform;
  z-index: 1;
}
#camera-overlay {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  z-index: 2;
  pointer-events: none;
  transform: translateZ(0);
}

/* ---------- 中央控制台 ---------- */
#console-wrap {
  position: absolute;
  inset: 0 0 170px 0;  /* 留出底部键盘高度 + bottom offset */
  display: flex; align-items: center; justify-content: center;
  z-index: 8;
  pointer-events: none;
}

.overlay {
  transition: opacity 0.3s ease, transform 0.3s cubic-bezier(0.22, 1, 0.36, 1);
}
.overlay.hidden {
  opacity: 0; pointer-events: none;
  transform: scale(0.95);
}

#chord-dial {
  position: relative;
  width: min(62vh, 540px);
  aspect-ratio: 1 / 1;
  /* 横向偏移跟随 --dial-shift 变量（左/中/右三档） */
  transform: translateX(var(--dial-shift, 0));
  transition: transform 0.45s cubic-bezier(0.22, 1, 0.36, 1);
}
/* 重写 .overlay.hidden 对 #chord-dial 的 scale，保留 translateX */
#chord-dial.hidden {
  transform: translateX(var(--dial-shift, 0)) scale(0.95);
  opacity: 0;
  pointer-events: none;
}
#chord-dial canvas {
  width: 100%; height: 100%;
  display: block;
}

.dial-caption {
  position: absolute;
  bottom: -44px; left: 50%;
  transform: translateX(-50%);
  display: flex; gap: 10px; align-items: center;
  padding: 8px 16px;
  background: rgba(10, 11, 30, 0.6);
  border: 1px solid var(--stroke);
  border-radius: 999px;
  backdrop-filter: blur(8px);
  font-size: 12px;
  color: var(--ink-dim);
  white-space: nowrap;
}
.cap-hand { color: #fff; font-weight: 600; }
.cap-sep { color: var(--ink-mute); }
.cap-gesture { color: var(--pink); font-weight: 500; }

/* ---------- 底部键盘（居中偏下，比例对齐 hero 键盘） ---------- */
#keybed {
  position: absolute;
  left: 0; right: 0;
  bottom: 24px;               /* 居中偏下：离底 24px */
  height: 130px;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 20px;
  pointer-events: none;
}
#keybed-inner {
  width: min(520px, 72vw);    /* 和 hero 键盘同尺寸级别 */
  height: 100%;
  position: relative;
  padding: 6px;
  background: linear-gradient(180deg, rgba(10, 12, 34, 0.65), rgba(10, 12, 34, 0.35));
  border: 1px solid var(--stroke);
  border-radius: 12px;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.04);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
#keybed-canvas {
  width: 100%; height: 100%;
  display: block;
}

/* ---------- 加载遮罩 ---------- */
.loading-overlay {
  position: fixed; inset: 0;
  z-index: 200;
  display: flex; align-items: center; justify-content: center;
  background: rgba(8, 10, 31, 0.75);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  transition: opacity 0.25s;
}
.loading-overlay.hidden {
  opacity: 0; pointer-events: none;
}
.loading-card {
  min-width: 360px;
  max-width: 440px;
  padding: 26px 30px;
  background: var(--panel-strong);
  border: 1px solid var(--stroke-strong);
  border-radius: 18px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6);
}
.loading-brand {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 18px;
  letter-spacing: 0.5px;
  background: var(--grad-brand);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
}
.loading-steps {
  list-style: none;
  display: flex; flex-direction: column; gap: 10px;
}
.loading-step {
  display: flex; align-items: center; gap: 12px;
  padding: 9px 12px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--stroke);
  border-radius: 10px;
  font-size: 13px;
  color: var(--ink-dim);
  transition: all 0.3s;
}
.loading-step .step-dot {
  width: 10px; height: 10px; flex-shrink: 0;
  border-radius: 50%;
  border: 2px solid var(--ink-mute);
  background: transparent;
  transition: all 0.25s;
  position: relative;
}
.loading-step .step-text { flex: 1; }
.loading-step .step-sub { color: var(--ink-mute); font-size: 11px; margin-left: 4px; }

.loading-step.active {
  color: #fff;
  border-color: rgba(167, 139, 250, 0.5);
  background: rgba(167, 139, 250, 0.12);
}
.loading-step.active .step-dot {
  border-color: var(--purple);
  background: var(--purple);
  box-shadow: 0 0 14px rgba(167, 139, 250, 0.7);
  animation: pulse 1.1s ease-in-out infinite;
}
.loading-step.done {
  color: var(--green);
  border-color: rgba(52, 211, 153, 0.3);
  background: rgba(52, 211, 153, 0.06);
}
.loading-step.done .step-dot {
  border-color: var(--green);
  background: var(--green);
  box-shadow: 0 0 8px rgba(52, 211, 153, 0.6);
  animation: none;
}
.loading-step.fail {
  color: var(--red);
  border-color: rgba(239, 68, 68, 0.4);
  background: rgba(239, 68, 68, 0.08);
}
.loading-step.fail .step-dot {
  border-color: var(--red); background: var(--red);
  animation: none;
}
@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.25); opacity: 0.6; }
}

.loading-hint {
  margin-top: 16px;
  font-size: 11px;
  color: var(--ink-mute);
  text-align: center;
  line-height: 1.5;
}

/* ---------- 帮助面板 ---------- */
.panel {
  position: fixed; inset: 0;
  z-index: 150;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(6px);
  transition: opacity 0.2s;
}
.panel.hidden { opacity: 0; pointer-events: none; }
.panel-card {
  max-width: 560px; width: 92%;
  padding: 28px 32px;
  background: var(--panel-strong);
  border: 1px solid var(--stroke-strong);
  border-radius: 18px;
  color: var(--ink);
  line-height: 1.55;
}
.panel-card h2 {
  margin-bottom: 18px;
  font-size: 20px;
  background: var(--grad-brand);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
}
.help-grid {
  display: flex; flex-direction: column; gap: 12px;
  margin-bottom: 14px;
}
.help-row {
  display: flex; gap: 14px; align-items: flex-start;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--stroke);
  border-radius: 12px;
}
.help-badge {
  flex-shrink: 0;
  width: 54px;
  padding: 4px 0;
  text-align: center;
  border-radius: 8px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.2px;
}
.help-badge.normal { background: rgba(255, 255, 255, 0.08); color: var(--ink-dim); }
.help-badge.chord  { background: rgba(56, 189, 248, 0.18); color: var(--blue); }
.help-badge.melody { background: rgba(244, 114, 182, 0.18); color: var(--pink); }
.help-desc { font-size: 13px; }
.help-desc small {
  display: block;
  font-size: 12px;
  color: var(--ink-dim);
  margin-top: 4px;
  line-height: 1.6;
}
.panel-card .tag {
  display: inline-block;
  padding: 1px 7px;
  margin: 0 2px;
  border-radius: 999px;
  background: rgba(244, 114, 182, 0.18);
  border: 1px solid rgba(244, 114, 182, 0.4);
  font-size: 11px;
  font-weight: 600;
  color: #fff;
}
.panel-card kbd {
  display: inline-block;
  padding: 1px 6px;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--stroke);
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: #fff;
}
.panel-card .small {
  font-size: 12px;
  color: var(--ink-dim);
  margin: 14px 0 16px;
  line-height: 1.6;
}
.panel-card button { margin-top: 4px; }

/* ---------- 语言切换 ---------- */
.lang-switch {
  display: inline-flex;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--stroke);
  border-radius: 10px;
  padding: 3px;
  gap: 2px;
}
.lang-pill {
  padding: 5px 12px;
  border: none;
  border-radius: 7px;
  background: transparent;
  color: var(--ink-dim);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  font-family: var(--font);
  transition: all 0.18s;
  letter-spacing: 0.5px;
  min-width: 36px;
}
.lang-pill:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
}
.lang-pill.active {
  background: var(--grad-brand);
  color: #0a0b1e;
  box-shadow: 0 3px 10px rgba(167, 139, 250, 0.4);
}

/* ---------- 键盘模式 悬浮提示 ---------- */
.btn-with-tip {
  position: relative;
}
.kbd-tip {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  min-width: 300px;
  padding: 14px 16px;
  background: rgba(14, 16, 42, 0.96);
  border: 1px solid var(--stroke-strong);
  border-radius: 12px;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  opacity: 0;
  transform: translateY(-6px);
  transition: opacity 0.18s, transform 0.18s;
  pointer-events: none;
  z-index: 70;
}
.btn-with-tip:hover .kbd-tip,
.btn-with-tip:focus-within .kbd-tip {
  opacity: 1;
  transform: translateY(0);
}
.kbd-tip::before {
  content: "";
  position: absolute;
  top: -6px;
  right: 32px;
  width: 10px;
  height: 10px;
  background: rgba(14, 16, 42, 0.96);
  border-left: 1px solid var(--stroke-strong);
  border-top: 1px solid var(--stroke-strong);
  transform: rotate(45deg);
}
.kbd-tip-title {
  font-size: 11px;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--ink-dim);
  font-weight: 700;
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--stroke);
}
.kbd-tip-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}
.kbd-tip-row:last-of-type { margin-bottom: 0; }
.kbd-tip-label {
  font-size: 10px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--ink-mute);
  min-width: 42px;
  font-weight: 700;
}
.kbd-tip-keys {
  display: flex;
  gap: 3px;
}
.kbd-tip-keys kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid var(--stroke);
  border-radius: 5px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.3);
}
.kbd-tip-keys kbd.spacer {
  background: transparent;
  border-color: transparent;
  box-shadow: none;
  width: 12px;
}
.kbd-tip-legend {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid var(--stroke);
  font-size: 10px;
  letter-spacing: 1px;
  font-family: var(--font-mono);
  color: var(--ink-mute);
  text-align: center;
}

/* ---------- 侧边浮动面板（左右对称） ---------- */
#left-controls {
  position: absolute;
  left: 18px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 10;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
#cam-opacity-panel {
  position: absolute;
  right: 18px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 14px 10px 12px;
  background: rgba(14, 16, 42, 0.72);
  border: 1px solid var(--stroke);
  border-radius: 14px;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  font-family: var(--font);
}

/* 通用 side-panel 卡片（左侧栈里的每一个） */
.side-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 14px 10px 12px;
  background: rgba(14, 16, 42, 0.72);
  border: 1px solid var(--stroke);
  border-radius: 14px;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  font-family: var(--font);
}
.side-panel-icon {
  color: var(--ink);
  opacity: 0.85;
}
.side-panel-pills {
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--stroke);
  border-radius: 10px;
  padding: 3px;
}
.side-panel-label {
  font-size: 9px;
  letter-spacing: 1.8px;
  text-transform: uppercase;
  color: var(--ink-mute);
  font-weight: 700;
}

/* 左侧 pill 统一（pad-pos + ring-mode 共用） */
.pad-pos-pill,
.ring-mode-pill {
  padding: 6px 10px;
  min-width: 60px;
  border: none;
  border-radius: 7px;
  background: transparent;
  color: var(--ink-dim);
  font-size: 11px;
  font-weight: 700;
  font-family: var(--font);
  letter-spacing: 0.5px;
  cursor: pointer;
  transition: all 0.15s;
  text-align: center;
}
.pad-pos-pill:hover,
.ring-mode-pill:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.06);
}
.pad-pos-pill.active,
.ring-mode-pill.active {
  background: var(--grad-brand);
  color: #0a0b1e;
  box-shadow: 0 2px 8px rgba(167, 139, 250, 0.35);
}
.cam-op-icon {
  color: var(--ink);
  opacity: 0.85;
}
#cam-opacity {
  -webkit-appearance: slider-vertical;
  appearance: slider-vertical;
  width: 10px;
  height: 130px;
  background: transparent;
  outline: none;
  cursor: pointer;
  writing-mode: vertical-lr;
  direction: rtl;
}
/* WebKit thumb/track */
#cam-opacity::-webkit-slider-runnable-track {
  width: 6px;
  background: linear-gradient(180deg, var(--pink), var(--purple), var(--blue));
  border-radius: 999px;
}
#cam-opacity::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid var(--purple);
  box-shadow: 0 2px 10px rgba(167, 139, 250, 0.65);
  cursor: grab;
  margin-left: -6px;
}
/* Firefox */
#cam-opacity::-moz-range-track {
  width: 6px;
  background: linear-gradient(180deg, var(--pink), var(--purple), var(--blue));
  border-radius: 999px;
}
#cam-opacity::-moz-range-thumb {
  width: 18px; height: 18px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid var(--purple);
  box-shadow: 0 2px 10px rgba(167, 139, 250, 0.65);
  cursor: grab;
}
.cam-op-val {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  min-width: 36px;
  text-align: center;
  letter-spacing: 0.5px;
}
.cam-op-label {
  font-size: 9px;
  letter-spacing: 1.8px;
  text-transform: uppercase;
  color: var(--ink-mute);
  font-weight: 700;
}

/* ---------- 入门引导面板 ---------- */
.onboarding-card {
  max-width: 580px;
  padding: 32px 36px 28px;
}
.onboarding-card h2 {
  text-align: center;
  font-size: 24px;
  margin-bottom: 8px;
}
.onboarding-subtitle {
  text-align: center;
  color: var(--ink-dim);
  font-size: 14px;
  margin-bottom: 22px;
  line-height: 1.5;
}
.onboarding-steps {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 22px;
}
.onboard-step {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 14px 16px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--stroke);
  border-radius: 12px;
}
.onboard-step-num {
  flex-shrink: 0;
  width: 32px; height: 32px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--grad-brand);
  color: #0a0b1e;
  font-weight: 900;
  font-size: 15px;
  box-shadow: 0 4px 14px rgba(167, 139, 250, 0.4);
}
.onboard-step-text {
  font-size: 14px;
  line-height: 1.55;
  color: var(--ink);
}
.onboard-step-text b {
  display: block;
  color: #fff;
  margin-bottom: 3px;
  font-weight: 700;
}
.onboard-step-text span {
  color: var(--ink-dim);
  font-size: 13px;
}
.onboarding-card > button {
  display: block;
  margin: 0 auto;
  padding: 11px 36px;
  font-size: 14px;
  letter-spacing: 2px;
}
