/* ================================================================
   toolkit-piano.css — ChordStar Piano v3
   Layout: topbar → stage (panel + keys + note display)
================================================================ */

/* ── Modal ──────────────────────────────────────────────────────── */
#tkModal-piano {
  display: none;
  position: fixed !important;
  inset: 0 !important;
  z-index: 10000 !important;
  background: #05010d;
  padding: 0 !important;
  flex-direction: column !important;
  align-items: stretch !important;
  justify-content: flex-start !important;
  overflow: hidden !important;
}
#tkModal-piano.open { display: flex !important; }

/* ── Root ───────────────────────────────────────────────────────── */
#csp-root {
  display: flex; flex-direction: column;
  width: 100%; height: 100%; overflow: hidden;
  font-family: 'Outfit', sans-serif; color: #f0e7ff;
  position: relative;
  background:
    radial-gradient(ellipse 90% 55% at 50% 100%, rgba(139,92,246,0.2) 0%, transparent 65%),
    radial-gradient(ellipse 50% 35% at 18% 18%, rgba(217,70,239,0.08) 0%, transparent 55%),
    radial-gradient(ellipse 45% 30% at 82% 12%, rgba(99,102,241,0.07) 0%, transparent 55%),
    #05010d;
}

/* spotlight glow under keys */
#csp-root::before {
  content: ''; position: absolute; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 1000px; height: 380px;
  background: radial-gradient(ellipse 80% 100% at 50% 100%,
    rgba(168,85,247,0.18) 0%, rgba(139,92,246,0.06) 50%, transparent 70%);
  pointer-events: none; z-index: 0;
}

/* ── Floating Close Button ──────────────────────────────────────── */
.csp-float-close-btn {
  position: fixed;
  top: 60px;
  right: 18px;
  z-index: 99999;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(239, 68, 68, 0.15);
  border: 1.5px solid rgba(239, 68, 68, 0.5);
  color: #fca5a5;
  font-size: 1.1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 2px 16px rgba(239,68,68,0.25);
  line-height: 1;
  padding: 0;
  font-family: 'Outfit', sans-serif;
}
.csp-float-close-btn:hover {
  background: rgba(239, 68, 68, 0.35);
  border-color: rgba(239, 68, 68, 0.8);
  color: #fff;
  transform: scale(1.1);
  box-shadow: 0 4px 20px rgba(239,68,68,0.45);
}

/* ── Topbar ─────────────────────────────────────────────────────── */
.csp-topbar {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.55rem 1.25rem;
  flex-shrink: 0; position: relative; z-index: 10;
  background: rgba(255,255,255,0.02);
  border-bottom: 1px solid rgba(168,85,247,0.1);
  backdrop-filter: blur(16px);
}
.csp-back-btn {
  background: rgba(168,85,247,0.1); border: 1px solid rgba(168,85,247,0.22);
  color: rgba(196,181,212,0.65); font-family: 'Outfit', sans-serif;
  font-size: 0.75rem; padding: 0.28rem 0.7rem; border-radius: 7px;
  cursor: pointer; transition: all 0.2s; flex-shrink: 0;
}
.csp-back-btn:hover { background: rgba(168,85,247,0.2); color: #e8d5ff; border-color: rgba(168,85,247,0.4); }
.csp-close-btn {
  background: rgba(239,68,68,0.08); border: 1px solid rgba(239,68,68,0.25);
  color: rgba(239,68,68,0.7); font-family: 'Outfit', sans-serif;
  font-size: 1rem; width: 30px; height: 30px; border-radius: 8px;
  cursor: pointer; transition: all 0.2s; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  line-height: 1; padding: 0;
}
.csp-close-btn:hover { background: rgba(239,68,68,0.22); color: #fca5a5; border-color: rgba(239,68,68,0.5); transform: scale(1.08); }
.csp-brand { display: flex; align-items: center; gap: 0.4rem; flex: 1; }
.csp-brand-icon { font-size: 1.2rem; }
.csp-brand-name {
  font-family: 'Space Grotesk', sans-serif; font-size: 0.95rem; font-weight: 700;
  background: linear-gradient(130deg, #e879f9, #a855f7 55%, #818cf8);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}
.csp-brand-sep { color: rgba(168,85,247,0.3); font-size: 0.8rem; -webkit-text-fill-color: rgba(168,85,247,0.3); }
.csp-brand-sub { font-size: 0.6rem; color: rgba(196,181,212,0.3); letter-spacing: 0.1em; text-transform: uppercase; -webkit-text-fill-color: rgba(196,181,212,0.3); }
.csp-vol-wrap { display: flex; align-items: center; gap: 0.35rem; flex-shrink: 0; }
.csp-vol-icon { font-size: 0.9rem; opacity: 0.5; }
.csp-vol-slider {
  -webkit-appearance: none; width: 75px; height: 3px; border-radius: 2px;
  background: rgba(168,85,247,0.25); outline: none; cursor: pointer;
}
.csp-vol-slider::-webkit-slider-thumb {
  -webkit-appearance: none; width: 12px; height: 12px; border-radius: 50%;
  background: #a855f7; box-shadow: 0 0 7px rgba(168,85,247,0.7); cursor: pointer;
}

/* ── Stage ──────────────────────────────────────────────────────── */
.csp-stage {
  flex: 1; display: flex; flex-direction: column;
  align-items: stretch; overflow: hidden;
  position: relative; z-index: 1;
  min-height: 0;
  justify-content: flex-end;
}

/* ── Desktop Visual Fill Area ───────────────────────────────────── */
.csp-visual-fill {
  display: none; /* hidden on mobile by default */
  flex: 1;
  min-height: 0;
  position: relative;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

/* Animated note visualizer bars */
.csp-viz-bars {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 5px;
  height: 120px;
  padding: 0 2rem;
  position: absolute;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%);
}
.csp-viz-bar {
  width: 5px;
  border-radius: 3px 3px 0 0;
  background: linear-gradient(180deg, #e879f9, #a855f7 60%, rgba(99,102,241,0.4));
  opacity: 0.35;
  animation: cspBarIdle var(--dur, 2.4s) ease-in-out infinite;
  animation-delay: var(--delay, 0s);
  height: var(--h, 20px);
}
@keyframes cspBarIdle {
  0%, 100% { transform: scaleY(1); opacity: 0.35; }
  50%       { transform: scaleY(var(--peak, 1.8)); opacity: 0.6; }
}
.csp-viz-bar.csp-viz-active {
  opacity: 1 !important;
  animation: cspBarActive 0.12s ease-out forwards !important;
}
@keyframes cspBarActive {
  0%   { transform: scaleY(1); }
  40%  { transform: scaleY(3.5); opacity: 1; }
  100% { transform: scaleY(2.2); opacity: 0.85; }
}

/* Big note name in center */
.csp-viz-note {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-family: 'Space Grotesk', sans-serif;
  font-size: 6rem;
  font-weight: 900;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, rgba(232,121,249,0.12) 0%, rgba(168,85,247,0.08) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  user-select: none;
  pointer-events: none;
  transition: all 0.15s ease;
  white-space: nowrap;
}
.csp-viz-note.csp-viz-note--active {
  background: linear-gradient(130deg, #e879f9 0%, #a855f7 50%, #818cf8 100%);
  -webkit-background-clip: text;
  background-clip: text;
  filter: drop-shadow(0 0 40px rgba(168,85,247,0.6));
  font-size: 7rem;
}

/* Circular glow ring */
.csp-viz-ring {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%) scale(0.85);
  width: 280px; height: 280px;
  border-radius: 50%;
  border: 1px solid rgba(168,85,247,0.1);
  box-shadow:
    0 0 0 1px rgba(168,85,247,0.05),
    0 0 60px rgba(168,85,247,0.05);
  pointer-events: none;
  transition: all 0.2s ease;
}
.csp-viz-ring-inner {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 180px; height: 180px;
  border-radius: 50%;
  border: 1px solid rgba(217,70,239,0.07);
  pointer-events: none;
}
.csp-viz-ring.csp-viz-pulse {
  border-color: rgba(168,85,247,0.5);
  box-shadow: 0 0 0 1px rgba(168,85,247,0.2), 0 0 80px rgba(168,85,247,0.25);
  animation: cspRingPulse 0.6s ease-out;
}
@keyframes cspRingPulse {
  0%   { transform: translate(-50%, -50%) scale(0.85); }
  40%  { transform: translate(-50%, -50%) scale(1.05); }
  100% { transform: translate(-50%, -50%) scale(0.85); }
}

/* Hint text */
.csp-viz-hint {
  position: absolute;
  bottom: 8px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.65rem;
  color: rgba(196,181,212,0.2);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  white-space: nowrap;
  pointer-events: none;
}

/* ── Control Panel ──────────────────────────────────────────────── */
.csp-panel {
  display: flex; align-items: center; flex-wrap: wrap;
  gap: 0.4rem; padding: 0.5rem 1.25rem;
  flex-shrink: 0; width: 100%; box-sizing: border-box;
  background: rgba(10,2,28,0.65);
  border-bottom: 1px solid rgba(168,85,247,0.15);
  backdrop-filter: blur(20px);
  justify-content: center;
  box-shadow: 0 2px 20px rgba(0,0,0,0.4);
}

.csp-panel-group {
  display: flex; align-items: center; gap: 0.28rem;
}

.csp-panel-divider {
  width: 1px; height: 20px;
  background: rgba(168,85,247,0.18);
  flex-shrink: 0; margin: 0 0.1rem;
}

.csp-panel-label {
  font-size: 0.62rem; font-weight: 600; letter-spacing: 0.08em;
  text-transform: uppercase; color: rgba(196,181,212,0.35);
  flex-shrink: 0;
}

/* Styled select */
.csp-select-wrap { position: relative; display: flex; align-items: center; }
.csp-select-wrap::after {
  content: '▾'; position: absolute; right: 7px; top: 50%; transform: translateY(-50%);
  font-size: 0.55rem; color: rgba(168,85,247,0.6); pointer-events: none;
}
.csp-select {
  -webkit-appearance: none; appearance: none;
  background: rgba(168,85,247,0.1);
  border: 1px solid rgba(168,85,247,0.28);
  color: rgba(220,200,255,0.9);
  font-family: 'Outfit', sans-serif; font-size: 0.72rem;
  padding: 0.28rem 1.4rem 0.28rem 0.6rem;
  border-radius: 8px; cursor: pointer; outline: none;
  transition: all 0.18s;
}
.csp-select:hover, .csp-select:focus {
  border-color: rgba(168,85,247,0.55); background: rgba(168,85,247,0.16);
}
.csp-select option { background: #1a0840; color: #e8d5ff; }

/* Label buttons */
.csp-label-btn {
  background: rgba(255,255,255,0.03); border: 1px solid rgba(168,85,247,0.18);
  color: rgba(196,181,212,0.45); font-family: 'Outfit', sans-serif;
  font-size: 0.68rem; padding: 0.25rem 0.6rem; border-radius: 20px;
  cursor: pointer; transition: all 0.16s; letter-spacing: 0.02em;
}
.csp-label-btn.active, .csp-label-btn:hover {
  background: rgba(168,85,247,0.18); border-color: rgba(168,85,247,0.5); color: #d946ef;
}

/* Octave controls */
.csp-oct-group { gap: 0.22rem; }
.csp-oct-btn {
  background: rgba(168,85,247,0.08); border: 1px solid rgba(168,85,247,0.2);
  color: rgba(196,181,212,0.55); font-family: 'Outfit', sans-serif;
  font-size: 0.65rem; padding: 0.25rem 0.5rem; border-radius: 6px;
  cursor: pointer; transition: all 0.16s;
}
.csp-oct-btn:hover { background: rgba(168,85,247,0.18); color: #e8d5ff; }
.csp-oct-display {
  font-family: 'Space Grotesk', sans-serif; font-size: 0.68rem;
  color: rgba(196,181,212,0.4); min-width: 66px; text-align: center;
}

/* Sustain button */
.csp-sustain-btn {
  display: flex; align-items: center; gap: 0.28rem;
  background: rgba(255,255,255,0.03); border: 1px solid rgba(168,85,247,0.18);
  color: rgba(196,181,212,0.45); font-family: 'Outfit', sans-serif;
  font-size: 0.68rem; padding: 0.25rem 0.65rem; border-radius: 20px;
  cursor: pointer; transition: all 0.18s;
}
.csp-sustain-btn.active { background: rgba(30,215,96,0.1); border-color: rgba(30,215,96,0.45); color: #1ed760; }
.csp-sustain-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: rgba(196,181,212,0.18); transition: all 0.2s; flex-shrink: 0;
}
.csp-sustain-dot.active { background: #1ed760; box-shadow: 0 0 6px rgba(30,215,96,0.9); }

/* ── Keys area ──────────────────────────────────────────────────── */
.csp-keys-scroll {
  flex: 1; min-height: 0; max-height: 260px;
  display: flex; align-items: flex-end; justify-content: center;
  overflow-x: auto; overflow-y: hidden;
  padding: 0 1.5rem 0.5rem;
  scrollbar-width: thin; scrollbar-color: rgba(168,85,247,0.25) transparent;
  position: relative; width: 100%; box-sizing: border-box;
}
.csp-keys-scroll::-webkit-scrollbar { height: 4px; }
.csp-keys-scroll::-webkit-scrollbar-thumb { background: rgba(168,85,247,0.25); border-radius: 2px; }

/* ambient orbs */
.csp-keys-scroll::before {
  content: ''; position: absolute; top: 10%; left: 8%;
  width: 200px; height: 200px; border-radius: 50%;
  background: radial-gradient(circle, rgba(217,70,239,0.07) 0%, transparent 70%);
  pointer-events: none; animation: cspFloat 9s ease-in-out infinite;
}
.csp-keys-scroll::after {
  content: ''; position: absolute; top: 15%; right: 8%;
  width: 160px; height: 160px; border-radius: 50%;
  background: radial-gradient(circle, rgba(99,102,241,0.08) 0%, transparent 70%);
  pointer-events: none; animation: cspFloat 12s ease-in-out infinite reverse;
}
@keyframes cspFloat {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-16px) scale(1.04); }
}

/* ── Keys Bed ───────────────────────────────────────────────────── */
.csp-keys-bed {
  position: relative; display: flex; flex-shrink: 0;
  user-select: none; margin: 0 auto;
  width: calc(var(--total-whites, 21) * var(--wkey-w));
  height: 100%;
  max-height: 320px;
  align-self: flex-end;
}

/* ── Key labels ─────────────────────────────────────────────────── */
.csp-key-label {
  font-family: 'Space Grotesk', sans-serif; font-size: 0.58rem; font-weight: 700;
  pointer-events: none; display: none; text-align: center; line-height: 1;
}
[data-label-mode="note"] .csp-key-label--note { display: block; }
[data-label-mode="swar"] .csp-key-label--swar  { display: block; }

/* ── Black key positioning ──────────────────────────────────────── */
.csp-black[data-after-white] {
  left: calc((var(--aw, 0) + 1) * var(--wkey-w) - var(--bkey-w) / 2);
}

/* ── Note display ───────────────────────────────────────────────── */
.csp-note-display {
  flex-shrink: 0; text-align: center;
  padding: 0.75rem 1rem 1rem;
  border-top: 1px solid rgba(168,85,247,0.08);
  position: relative; z-index: 5;
  width: 100%; box-sizing: border-box;
}
.csp-now-playing {
  font-family: 'Space Grotesk', sans-serif; font-size: 1.8rem; font-weight: 700;
  letter-spacing: 0.04em; min-height: 2.4rem; line-height: 1;
  margin-bottom: 0.3rem;
  background: linear-gradient(130deg, #e879f9 0%, #a855f7 50%, #818cf8 100%);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
  filter: drop-shadow(0 0 14px rgba(168,85,247,0.4));
  transition: filter 0.1s;
}
.csp-hint { font-size: 0.62rem; color: rgba(196,181,212,0.22); letter-spacing: 0.06em; text-transform: uppercase; }
.csp-hint-mobile { display: none; }
.csp-hint-desktop { display: inline; }

/* ════════════════════════════════════════════════════════════════
   DESKTOP KEYS (≥901px)
════════════════════════════════════════════════════════════════ */
@media (min-width: 901px) {
  /* Show the visual fill area on desktop */
  .csp-visual-fill {
    display: flex;
  }
  /* Stage no longer pushes to bottom — fill area takes remaining space */
  .csp-stage {
    justify-content: flex-start;
  }
  .csp-keys-bed {
    --wkey-w: 56px; --bkey-w: 36px; --bkey-ratio: 0.625;
    filter: drop-shadow(0 18px 55px rgba(139,92,246,0.3)) drop-shadow(0 6px 20px rgba(0,0,0,0.65));
  }
  .csp-white {
    position: relative; width: var(--wkey-w); height: 100%; flex-shrink: 0;
    background: linear-gradient(180deg, #dcd3ef 0%, #f4efff 25%, #fefcff 60%, #f8f4ff 100%);
    border: 1px solid rgba(140,80,200,0.2); border-top: 2px solid rgba(175,135,235,0.18);
    border-radius: 0 0 10px 10px; cursor: pointer;
    display: flex; flex-direction: column; align-items: center; justify-content: flex-end;
    padding-bottom: 10px; box-sizing: border-box; z-index: 1;
    transition: background 0.06s, transform 0.06s;
    box-shadow: inset 0 -5px 0 rgba(168,85,247,0.1), inset 2px 0 0 rgba(255,255,255,0.55),
      inset -2px 0 0 rgba(0,0,0,0.04), 0 5px 16px rgba(0,0,0,0.28);
    -webkit-tap-highlight-color: transparent; touch-action: none;
  }
  .csp-white:hover {
    background: linear-gradient(180deg, #cdc3eb 0%, #ebe2ff 25%, #f3eeff 60%, #ece3ff 100%);
  }
  .csp-white.csp-pressed {
    background: linear-gradient(180deg, #9c6edf 0%, #bea0f5 30%, #d4b8ff 60%, #c8a8f0 100%);
    transform: scaleY(0.975); transform-origin: top;
    box-shadow: inset 0 -2px 0 rgba(168,85,247,0.45), 0 3px 8px rgba(0,0,0,0.38),
      0 0 22px rgba(168,85,247,0.38);
  }
  .csp-white .csp-key-label { color: rgba(85,35,155,0.65); font-size: 0.62rem; font-weight: 700; }

  .csp-black {
    position: absolute; top: 0; width: var(--bkey-w); height: 62.5%;
    background: linear-gradient(180deg, #09011a 0%, #130430 30%, #1b0742 65%, #240a52 100%);
    border-radius: 0 0 7px 7px; cursor: pointer; z-index: 2;
    display: flex; flex-direction: column; align-items: center; justify-content: flex-end;
    padding-bottom: 6px; box-sizing: border-box;
    border: 1px solid rgba(110,55,190,0.22); border-top: none;
    transition: background 0.06s, transform 0.06s;
    box-shadow: inset -1px 0 0 rgba(255,255,255,0.05), inset 0 -4px 0 rgba(0,0,0,0.5),
      3px 5px 15px rgba(0,0,0,0.7), 0 0 0 1px rgba(0,0,0,0.3);
    -webkit-tap-highlight-color: transparent; touch-action: none;
  }
  .csp-black:hover {
    background: linear-gradient(180deg, #120430 0%, #1e084e 35%, #2c1165 70%, #381878 100%);
  }
  .csp-black.csp-pressed {
    background: linear-gradient(180deg, #5b21b6 0%, #7c3aed 30%, #9d5af5 65%, #8b3fe0 100%);
    transform: scaleY(0.963); transform-origin: top;
    box-shadow: inset 0 -1px 0 rgba(200,150,255,0.4), 0 2px 5px rgba(0,0,0,0.5),
      0 0 26px rgba(139,92,246,0.65), 0 0 55px rgba(139,92,246,0.2);
  }
  .csp-black .csp-key-label { color: rgba(210,180,255,0.75); font-size: 0.52rem; font-weight: 700; }

  .csp-now-playing { font-size: 2.2rem; min-height: 2.8rem; }
  .csp-note-display { padding: 0.85rem 1rem 1.1rem; }
}

/* ════════════════════════════════════════════════════════════════
   TABLET (601–900px)
════════════════════════════════════════════════════════════════ */
@media (min-width: 601px) and (max-width: 900px) {
  .csp-keys-scroll { padding: 0.4rem 1rem 0; }
  .csp-keys-bed {
    --wkey-w: 46px; --bkey-w: 30px;
  }
  .csp-white {
    position: relative; width: var(--wkey-w); height: 100%; flex-shrink: 0;
    background: linear-gradient(180deg, #e8dff5 0%, #fff 40%, #f8f4ff 100%);
    border: 1px solid rgba(120,70,180,0.22); border-top: 2px solid rgba(168,85,247,0.15);
    border-radius: 0 0 8px 8px; cursor: pointer;
    display: flex; flex-direction: column; align-items: center; justify-content: flex-end;
    padding-bottom: 8px; box-sizing: border-box; z-index: 1;
    transition: background 0.06s, transform 0.06s;
    box-shadow: inset 0 -4px 0 rgba(168,85,247,0.1), 0 4px 12px rgba(0,0,0,0.25);
    -webkit-tap-highlight-color: transparent; touch-action: none;
  }
  .csp-white:hover { background: linear-gradient(180deg, #ddd0f5 0%, #f0e8ff 40%, #ede4ff 100%); }
  .csp-white.csp-pressed {
    background: linear-gradient(180deg, #b794e8 0%, #d4b8ff 40%, #c9a8f4 100%);
    transform: scaleY(0.97); transform-origin: top;
    box-shadow: inset 0 -2px 0 rgba(168,85,247,0.3), 0 2px 6px rgba(0,0,0,0.3);
  }
  .csp-black {
    position: absolute; top: 0; width: var(--bkey-w); height: 62.5%;
    background: linear-gradient(180deg, #120630 0%, #1e0848 50%, #2a0c5c 100%);
    border-radius: 0 0 6px 6px; cursor: pointer; z-index: 2;
    display: flex; flex-direction: column; align-items: center; justify-content: flex-end;
    padding-bottom: 6px; box-sizing: border-box;
    border: 1px solid rgba(150,100,220,0.2); border-top: none;
    transition: background 0.06s, transform 0.06s;
    box-shadow: inset 0 -3px 0 rgba(0,0,0,0.4), 3px 4px 10px rgba(0,0,0,0.5);
    -webkit-tap-highlight-color: transparent; touch-action: none;
  }
  .csp-black:hover { background: linear-gradient(180deg, #1e0848 0%, #2d1068 50%, #3d1880 100%); }
  .csp-black.csp-pressed {
    background: linear-gradient(180deg, #7c3aed 0%, #a855f7 60%, #9333ea 100%);
    transform: scaleY(0.96); transform-origin: top;
    box-shadow: inset 0 -1px 0 rgba(168,85,247,0.4), 0 2px 6px rgba(0,0,0,0.4);
  }
  .csp-white .csp-key-label { color: rgba(80,30,140,0.6); }
  .csp-black .csp-key-label { color: rgba(210,180,255,0.6); font-size: 0.5rem; }
  .csp-now-playing { font-size: 1.4rem; }
}

/* ════════════════════════════════════════════════════════════════
   MOBILE (≤600px)
════════════════════════════════════════════════════════════════ */
@media (max-width: 600px) {
  .csp-panel {
    padding: 0.38rem 0.75rem;
    gap: 0.3rem;
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    justify-content: flex-start;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }
  .csp-panel::-webkit-scrollbar { display: none; }
  .csp-panel-divider { display: none; }
  .csp-panel-group { flex-shrink: 0; }
  .csp-select { font-size: 0.64rem; padding: 0.22rem 1.1rem 0.22rem 0.48rem; }
  .csp-label-btn { font-size: 0.62rem; padding: 0.2rem 0.48rem; white-space: nowrap; flex-shrink: 0; }
  .csp-oct-display { min-width: 52px; font-size: 0.62rem; }
  .csp-oct-btn { font-size: 0.62rem; padding: 0.2rem 0.45rem; }
  .csp-sustain-btn { font-size: 0.62rem; padding: 0.2rem 0.5rem; white-space: nowrap; flex-shrink: 0; }
  .csp-panel-label { font-size: 0.58rem; white-space: nowrap; flex-shrink: 0; }

  .csp-topbar { padding: 0.4rem 0.75rem; }
  .csp-brand-sub, .csp-brand-sep { display: none; }
  .csp-brand-name { font-size: 0.85rem; }
  .csp-vol-slider { width: 60px; }

  .csp-keys-scroll {
    justify-content: flex-start; align-items: flex-end;
    padding: 0 0.75rem 0.3rem;
    touch-action: pan-x;
  }
  .csp-keys-scroll::before, .csp-keys-scroll::after { display: none; }

  .csp-keys-bed {
    --wkey-w: 44px; --bkey-w: 29px;
    max-height: 200px;
  }
  .csp-white {
    position: relative; width: var(--wkey-w); height: 100%; flex-shrink: 0;
    background: linear-gradient(180deg, #e8dff5 0%, #fff 40%, #f8f4ff 100%);
    border: 1px solid rgba(120,70,180,0.22); border-top: 2px solid rgba(168,85,247,0.15);
    border-radius: 0 0 6px 6px; cursor: pointer;
    display: flex; flex-direction: column; align-items: center; justify-content: flex-end;
    padding-bottom: 7px; box-sizing: border-box; z-index: 1;
    transition: background 0.06s, transform 0.06s;
    box-shadow: inset 0 -4px 0 rgba(168,85,247,0.1), 0 4px 12px rgba(0,0,0,0.25);
    -webkit-tap-highlight-color: transparent; touch-action: none;
  }
  .csp-white:hover { background: linear-gradient(180deg, #ddd0f5 0%, #f0e8ff 40%, #ede4ff 100%); }
  .csp-white.csp-pressed {
    background: linear-gradient(180deg, #b794e8 0%, #d4b8ff 40%, #c9a8f4 100%);
    transform: scaleY(0.97); transform-origin: top;
    box-shadow: inset 0 -2px 0 rgba(168,85,247,0.3), 0 2px 6px rgba(0,0,0,0.3);
  }
  .csp-black {
    position: absolute; top: 0; width: var(--bkey-w); height: 62.5%;
    background: linear-gradient(180deg, #120630 0%, #1e0848 50%, #2a0c5c 100%);
    border-radius: 0 0 5px 5px; cursor: pointer; z-index: 2;
    display: flex; flex-direction: column; align-items: center; justify-content: flex-end;
    padding-bottom: 5px; box-sizing: border-box;
    border: 1px solid rgba(150,100,220,0.2); border-top: none;
    transition: background 0.06s, transform 0.06s;
    box-shadow: inset 0 -3px 0 rgba(0,0,0,0.4), 3px 4px 10px rgba(0,0,0,0.5);
    -webkit-tap-highlight-color: transparent; touch-action: none;
  }
  .csp-black:hover { background: linear-gradient(180deg, #1e0848 0%, #2d1068 50%, #3d1880 100%); }
  .csp-black.csp-pressed {
    background: linear-gradient(180deg, #7c3aed 0%, #a855f7 60%, #9333ea 100%);
    transform: scaleY(0.96); transform-origin: top;
    box-shadow: inset 0 -1px 0 rgba(168,85,247,0.4), 0 2px 6px rgba(0,0,0,0.4);
  }
  .csp-white .csp-key-label { color: rgba(80,30,140,0.6); font-size: 0.52rem; }
  .csp-black .csp-key-label { color: rgba(210,180,255,0.6); font-size: 0.45rem; }

  .csp-note-display { padding: 0.45rem 0.75rem 0.6rem; }
  .csp-now-playing { font-size: 1.5rem; min-height: 1.8rem; }
  .csp-hint-mobile { display: inline; }
  .csp-hint-desktop { display: none; }
}

/* ≤375px */
@media (max-width: 375px) {
  .csp-keys-bed { --wkey-w: 38px; --bkey-w: 25px; }
}

/* ── Landscape / short height fix ──────────────────────────────── */
@media (max-height: 480px) {
  .csp-keys-bed { --wkey-w: 38px; --bkey-w: 25px; }
  .csp-topbar { padding: 0.28rem 0.75rem; }
  .csp-brand-sub, .csp-brand-sep { display: none; }
  .csp-panel { padding: 0.28rem 0.75rem; gap: 0.2rem; }
  .csp-panel-divider { display: none; }
  .csp-keys-scroll { padding-bottom: 0.3rem; }
  .csp-note-display { padding: 0.3rem 0.75rem 0.35rem; border-top: none; }
  .csp-now-playing { font-size: 1.1rem; min-height: 1.4rem; margin-bottom: 0.1rem; }
  .csp-hint { display: none; }
}

/* ── Toolkit card badge ─────────────────────────────────────────── */
.tk-card[data-tool="piano"] .tk-card-icon-wrap { --tk-color: #ec4899; }
