:root {
  --bg: #0a0a1a;
  --bg2: #0f0f2a;
  --accent1: #00d4ff;
  --accent2: #ff2d95;
  --accent3: #39ff14;
  --text: #e0e0f0;
  --text-dim: #6a6a8a;
  --glass: rgba(15, 15, 42, 0.85);
  --key-white: #1a1a35;
  --key-black: #0d0d20;
  --grid: rgba(255,255,255,0.04);
}

[data-theme="classic"] {
  --bg: #1a1a1a;
  --bg2: #222;
  --accent1: #ffffff;
  --accent2: #aaaaaa;
  --accent3: #cccccc;
  --text: #ffffff;
  --text-dim: #777;
  --glass: rgba(30,30,30,0.9);
  --key-white: #2a2a2a;
  --key-black: #111;
}

[data-theme="ocean"] {
  --bg: #051525;
  --bg2: #0a2040;
  --accent1: #00bcd4;
  --accent2: #4fc3f7;
  --accent3: #80deea;
  --text: #b2ebf2;
  --text-dim: #4a7a8a;
  --glass: rgba(5,21,37,0.9);
  --key-white: #0c2a45;
  --key-black: #061a30;
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Chakra Petch', sans-serif;
  overflow: hidden;
  height: 100vh;
  width: 100vw;
}

#app-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  width: 100vw;
}

/* Header */
#header {
  position: relative;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 8px 16px;
  background: var(--bg2);
  border-bottom: 1px solid rgba(0,212,255,0.15);
  z-index: 10;
  flex-shrink: 0;
  height: 52px;
  overflow: hidden;
}

#header-bg-pulse {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: linear-gradient(90deg, transparent, rgba(0,212,255,0.03), transparent);
  animation: headerPulse 4s ease-in-out infinite;
  pointer-events: none;
}

@keyframes headerPulse {
  0%, 100% { opacity: 0.3; transform: translateX(-100%); }
  50% { opacity: 1; transform: translateX(100%); }
}

#logo {
  font-family: 'Chakra Petch', sans-serif;
  font-weight: 800;
  font-size: 24px;
  letter-spacing: 3px;
  color: var(--text);
  text-shadow: 0 0 20px var(--accent1), 0 0 40px rgba(0,212,255,0.3);
  white-space: nowrap;
}

#logo .accent {
  color: var(--accent1);
}

#subtitle {
  font-family: 'JetBrains Mono', monospace;
  font-size: 9px;
  font-weight: 200;
  letter-spacing: 4px;
  color: var(--text-dim);
  white-space: nowrap;
}

#title-area {
  display: flex;
  flex-direction: column;
  gap: 0;
  flex-shrink: 0;
}

#file-area {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

#load-btn {
  font-family: 'Chakra Petch', sans-serif;
  font-weight: 600;
  font-size: 12px;
  padding: 6px 16px;
  border-radius: 20px;
  border: 1px solid var(--accent1);
  background: rgba(0,212,255,0.1);
  color: var(--accent1);
  cursor: pointer;
  transition: all 0.3s;
  white-space: nowrap;
}

#load-btn:hover {
  background: rgba(0,212,255,0.25);
  box-shadow: 0 0 15px rgba(0,212,255,0.3);
}

#file-info {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--text-dim);
  white-space: nowrap;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
}

#header-stats {
  display: flex;
  gap: 12px;
  margin-left: auto;
  flex-shrink: 0;
}

.stat-box {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.stat-label {
  font-size: 8px;
  font-weight: 300;
  letter-spacing: 2px;
  color: var(--text-dim);
}

.stat-val {
  font-family: 'JetBrains Mono', monospace;
  font-size: 14px;
  font-weight: 700;
  color: var(--accent1);
}

#stats-toggle {
  background: none;
  border: 1px solid var(--text-dim);
  color: var(--text);
  font-size: 16px;
  padding: 4px 8px;
  border-radius: 4px;
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.2s;
}
#stats-toggle:hover {
  border-color: var(--accent1);
  color: var(--accent1);
}

/* Canvas Area */
#canvas-wrap {
  flex: 1;
  position: relative;
  overflow: hidden;
  min-height: 0;
}

#piano-canvas {
  position: absolute;
  top: 0; left: 0;
  width: 60px;
  height: 100%;
  z-index: 2;
}

#roll-canvas {
  position: absolute;
  top: 0; left: 60px;
  width: calc(100% - 60px);
  height: 100%;
  z-index: 1;
}

#drop-overlay {
  display: none;
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,212,255,0.1);
  border: 3px dashed var(--accent1);
  z-index: 20;
  align-items: center;
  justify-content: center;
}

#drop-overlay.active { display: flex; }

#drop-text {
  font-size: 24px;
  font-weight: 700;
  color: var(--accent1);
  text-shadow: 0 0 20px var(--accent1);
}

#tooltip {
  position: absolute;
  background: var(--glass);
  border: 1px solid var(--accent1);
  padding: 6px 10px;
  border-radius: 6px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--text);
  pointer-events: none;
  z-index: 30;
  backdrop-filter: blur(8px);
  white-space: nowrap;
}

#tooltip.hidden { display: none; }

/* Transport */
#transport {
  flex-shrink: 0;
  background: var(--glass);
  border-top: 1px solid rgba(0,212,255,0.15);
  backdrop-filter: blur(10px);
}

#seekbar-wrap {
  position: relative;
  height: 28px;
  cursor: pointer;
  background: rgba(0,0,0,0.3);
}

#minimap-canvas {
  width: 100%;
  height: 100%;
}

#seek-cursor {
  position: absolute;
  top: 0; bottom: 0;
  width: 2px;
  background: var(--accent2);
  box-shadow: 0 0 8px var(--accent2);
  pointer-events: none;
  left: 0;
}

#transport-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 6px 16px;
  flex-wrap: wrap;
}

.tbtn {
  font-size: 16px;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.1);
  color: var(--text);
  padding: 6px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
}

.tbtn:hover {
  background: rgba(0,212,255,0.15);
  border-color: var(--accent1);
  box-shadow: 0 0 10px rgba(0,212,255,0.2);
}

.tbtn.big {
  font-size: 22px;
  padding: 8px 20px;
  border-color: var(--accent1);
  color: var(--accent1);
}

.tbtn.big.playing {
  color: var(--accent2);
  border-color: var(--accent2);
  box-shadow: 0 0 15px rgba(255,45,149,0.3);
}

#time-display {
  font-family: 'JetBrains Mono', monospace;
  font-size: 14px;
  font-weight: 700;
  min-width: 100px;
  text-align: right;
}

#tempo-area, #vol-area {
  display: flex;
  align-items: center;
  gap: 6px;
}

#bpm-display, #speed-display {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--accent3);
  min-width: 50px;
}

input[type="range"] {
  -webkit-appearance: none;
  height: 4px;
  background: rgba(255,255,255,0.15);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent1);
  box-shadow: 0 0 6px var(--accent1);
  cursor: pointer;
}

#speed-slider { width: 80px; }
#vol-slider { width: 60px; }

/* Demo Bar */
#demo-bar {
  display: flex;
  justify-content: center;
  gap: 10px;
  padding: 6px;
  background: var(--bg2);
  border-top: 1px solid rgba(255,255,255,0.05);
  flex-shrink: 0;
}

.demo-btn {
  font-family: 'Chakra Petch', sans-serif;
  font-size: 11px;
  font-weight: 600;
  padding: 5px 14px;
  border-radius: 14px;
  border: 1px solid var(--accent3);
  background: rgba(57,255,20,0.08);
  color: var(--accent3);
  cursor: pointer;
  transition: all 0.3s;
}

.demo-btn:hover {
  background: rgba(57,255,20,0.2);
  box-shadow: 0 0 12px rgba(57,255,20,0.2);
}

/* Stats Panel */
#stats-panel {
  position: absolute;
  top: 52px;
  right: 0;
  width: 280px;
  bottom: 0;
  background: var(--glass);
  backdrop-filter: blur(12px);
  border-left: 1px solid rgba(0,212,255,0.15);
  z-index: 15;
  padding: 16px;
  overflow-y: auto;
  transition: transform 0.3s ease;
}

#stats-panel.hidden {
  transform: translateX(100%);
}

#stats-panel h3 {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 2px;
  color: var(--accent1);
  margin: 12px 0 8px;
  border-bottom: 1px solid rgba(0,212,255,0.1);
  padding-bottom: 4px;
}

#stats-panel h3:first-child { margin-top: 0; }

#perf-stats {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  line-height: 1.8;
  color: var(--text-dim);
}

#track-list {
  max-height: 200px;
  overflow-y: auto;
}

.track-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 3px 0;
  font-size: 11px;
}

.track-color {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  flex-shrink: 0;
}

.track-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-dim);
}

.track-mute, .track-solo {
  font-size: 9px;
  padding: 2px 6px;
  border-radius: 3px;
  border: 1px solid var(--text-dim);
  background: none;
  color: var(--text-dim);
  cursor: pointer;
  font-family: 'JetBrains Mono', monospace;
}

.track-mute.active { border-color: var(--accent2); color: var(--accent2); }
.track-solo.active { border-color: var(--accent3); color: var(--accent3); }

#theme-btns {
  display: flex;
  gap: 6px;
}

.theme-btn {
  font-family: 'Chakra Petch', sans-serif;
  font-size: 10px;
  padding: 4px 10px;
  border-radius: 10px;
  border: 1px solid var(--text-dim);
  background: none;
  color: var(--text-dim);
  cursor: pointer;
  transition: all 0.2s;
}

.theme-btn.active {
  border-color: var(--accent1);
  color: var(--accent1);
  background: rgba(0,212,255,0.1);
}

#screenshot-btn {
  margin-top: 12px;
  width: 100%;
  font-family: 'Chakra Petch', sans-serif;
  font-size: 12px;
  padding: 8px;
  border-radius: 8px;
  border: 1px solid var(--accent1);
  background: rgba(0,212,255,0.08);
  color: var(--accent1);
  cursor: pointer;
  transition: all 0.3s;
}

#screenshot-btn:hover {
  background: rgba(0,212,255,0.2);
}

/* Parse Overlay */
#parse-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(5,5,15,0.95);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
}

#parse-overlay.hidden { display: none; }

#parse-content {
  text-align: center;
  position: relative;
}

#parse-particles {
  position: absolute;
  top: -100px; left: -100px; right: -100px; bottom: -100px;
  pointer-events: none;
}

#parse-title {
  font-size: 28px;
  font-weight: 700;
  margin-bottom: 20px;
  color: var(--accent1);
  text-shadow: 0 0 30px var(--accent1);
}

#parse-bar-wrap {
  width: 300px;
  height: 6px;
  background: rgba(255,255,255,0.1);
  border-radius: 3px;
  margin: 0 auto 16px;
  overflow: hidden;
}

#parse-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent1), var(--accent2));
  border-radius: 3px;
  transition: width 0.2s;
}

#parse-text {
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  color: var(--text-dim);
  margin-bottom: 16px;
}

#parse-cancel {
  font-family: 'Chakra Petch', sans-serif;
  padding: 8px 24px;
  border-radius: 16px;
  border: 1px solid var(--accent2);
  background: rgba(255,45,149,0.1);
  color: var(--accent2);
  cursor: pointer;
  font-size: 13px;
}

/* Footer */
#footer {
  text-align: center;
  padding: 4px;
  font-size: 10px;
  color: var(--text-dim);
  background: var(--bg);
  flex-shrink: 0;
}

#footer a {
  color: var(--accent1);
  text-decoration: none;
}

#footer a:hover {
  text-decoration: underline;
}

/* Mobile */
@media (max-width: 768px) {
  #header { gap: 8px; padding: 6px 10px; height: 48px; }
  #logo { font-size: 18px; }
  #subtitle { display: none; }
  #header-stats { gap: 6px; }
  .stat-box { display: none; }
  .stat-box:first-child, .stat-box:last-child { display: flex; }
  #transport-controls { gap: 8px; padding: 4px 8px; }
  #tempo-area, #vol-area { display: none; }
  #demo-bar { gap: 6px; }
  .demo-btn { font-size: 10px; padding: 4px 10px; }
  #stats-panel { width: 220px; }
}