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

html {
  overflow-x: hidden;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  background: #fff;
  color: #000;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

header {
  padding: 20px;
  border-bottom: 2px solid #000;
  background: #fff;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

h1 {
  font-size: 24px;
  font-weight: 600;
  margin: 0;
}

h5 {
  font-size: 11px;
  font-weight: 400;
  margin: 0;
  margin-top: 5px;
  opacity: 0.7;
}

.tool-section {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.tool-section > label {
  font-size: 12px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.controls {
  display: flex;
  flex-wrap: nowrap;
  gap: 15px;
  align-items: center;
  overflow-x: auto;
  padding: 10px 0;
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: auto;
}

/* Tool buttons group */
.control-group.tools-group {
  display: flex;
  flex-direction: row;
  gap: 5px;
}

/* Compact select groups */
.control-group.compact {
  min-width: 80px;
}

/* Slider groups with inline labels */
.control-group.slider-group {
  min-width: 100px;
}

.control-group.slider-group label {
  font-size: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.control-group.slider-group input[type="range"] {
  width: 100px;
}

/* Button group */
.control-group.button-group {
  display: flex;
  flex-direction: row;
  gap: 8px;
  margin-left: auto;
}

label {
  font-size: 12px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Icon buttons */
.icon-button {
  background: #fff;
  border: 2px solid #000;
  padding: 8px;
  cursor: pointer;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease-out;
}

.icon-button:hover {
  background: #000;
}

.icon-button:hover svg {
  fill: #fff;
}

.icon-button svg {
  fill: #000;
  transition: fill 0.2s ease-out;
}

input[type="range"] {
  width: 100%;
  height: 2px;
  background: #000;
  outline: none;
  -webkit-appearance: none;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 12px;
  height: 12px;
  background: #000;
  cursor: pointer;
}

input[type="range"]::-moz-range-thumb {
  width: 12px;
  height: 12px;
  background: #000;
  cursor: pointer;
  border: none;
}

select {
  padding: 7px;
  border: 2px solid #000;
  background: #fff;
  font-size: 14px;
  cursor: pointer;
  font-family: inherit;
  height: 36px;
  box-sizing: border-box;
}

button {
  padding: 8px 16px;
  border: 2px solid #000;
  background: #fff;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  transition: all 0.2s ease-out;
  white-space: nowrap;
}

button:hover {
  background: #000;
  color: #fff;
}

button:active {
  transform: translateY(1px);
}

.canvas-container {
  flex: 1;
  position: relative;
  background: #fff;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 20px;
  padding-bottom: 100px; /* Space for preset buttons */
  overflow: hidden;
  min-height: 0;
}

canvas {
  border: 2px solid #000;
  cursor: crosshair;
  background: #fff;
  margin-right: 50px; /* Space for the mod wheel fader */
}

/* Custom tool cursors - using 32x32 cursor images */
.cursor-draw {
  /* Hotspot at pencil tip (bottom-left area) */
  cursor: url('./tool-icons/cursors/draw.png') 4 28, crosshair;
}


.cursor-move {
  /* Hotspot at center for grab/move */
  cursor: url('./tool-icons/cursors/move.png') 16 16, move;
}

.value-display {
  font-size: 11px;
  font-weight: 600;
  margin-top: 2px;
}

.status {
  position: absolute;
  top: 20px;
  right: 70px; /* Move left to stay inside canvas, matching channel selector */
  padding: 10px 15px;
  background: #000;
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  opacity: 0;
  transition: opacity 0.3s ease-out;
}

.status.active {
  opacity: 1;
}

.midi-indicator {
  display: inline-block;
  width: 8px;
  height: 8px;
  background: #ff0000;
  margin-right: 8px;
  transition: background 0.2s ease-out;
}

.midi-indicator.connected {
  background: #00ff00;
}

/* Tool buttons */
.tool-buttons {
  display: flex;
  gap: 0;
}

.tool-button {
  padding: 7px 12px;
  border: 2px solid #000;
  background: #fff;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  transition: all 0.2s ease-out;
  position: relative;
  height: 36px;
  box-sizing: border-box;
}

.tool-button + .tool-button {
  margin-left: -2px;
}

.tool-button:hover {
  background: #0f0f0f;
}

.tool-button.active {
  background: #b4d7ff;
  color: #fff;
}

.tool-button .shortcut {
  position: absolute;
  top: -8px;
  right: -8px;
  background: #000;
  color: #fff;
  font-size: 9px;
  padding: 2px 4px;
  font-weight: 700;
  z-index: 10;
}

.tool-button.active .shortcut {
  background: #fff;
  color: #000;
}

/* Transpose fader */
.transpose-container {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 0 1 450px;
  min-width: 0;
}

.transpose-label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #000;
  flex-shrink: 0;
}

.transpose-slider {
  position: relative;
  flex: 1;
  min-width: 200px;
  height: 40px;
  background: #f0f0f0;
  border: 2px solid #000;
  cursor: ew-resize;
  box-sizing: border-box;
}

.transpose-track {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 100%;
  height: 2px;
  background: #000;
}

.transpose-center {
  position: absolute;
  left: 50%;
  top: 0;
  bottom: 0;
  width: 2px;
  background: #000;
}

.transpose-handle {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 24px;
  height: 36px;
  background: #000;
  cursor: ew-resize;
  transition: left 0.1s ease-out;
}

.transpose-value {
  font-size: 14px;
  font-weight: 700;
  min-width: 45px;
  text-align: center;
  flex-shrink: 0;
}

/* Transpose Presets */
.transpose-presets {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 80px;
  background: #fff;
  border-top: 2px solid #000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 40px;
  gap: 40px;
  box-sizing: border-box;
}

.preset-buttons-container {
  display: flex;
  gap: 8px;
  flex: 0 1 auto;
  justify-content: center;
  flex-wrap: wrap;
  max-width: 700px;
}

.preset-button {
  flex: 0 0 75px;
  height: 40px;
  background: #fff;
  border: 2px solid #000;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 6px;
  cursor: pointer;
  transition: background-color 0.1s;
  position: relative;
  box-sizing: border-box;
}

.preset-button:hover {
  background: #f0f0f0;
}

.preset-button.active {
  background: #000;
  color: #fff;
}

.preset-button.active .preset-key {
  color: #fff;
}

.preset-button.active .preset-value {
  background: #fff;
  color: #000;
}

.preset-key {
  font-size: 16px;
  font-weight: 700;
  color: #000;
  min-width: 15px;
}

.preset-value {
  width: 45px;
  height: 24px;
  border: 1px solid #000;
  background: #fff;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 4px;
  cursor: pointer;
  outline: none;
}

.preset-value:focus {
  border: 2px solid #000;
}

/* Responsive Design */
@media (max-width: 1200px) {
  .transpose-presets {
    gap: 30px;
    padding: 0 30px;
  }
  
  .preset-button {
    flex: 0 0 70px;
  }
  
  .preset-buttons-container {
    gap: 6px;
  }
}

@media (max-width: 900px) {
  .transpose-presets {
    flex-direction: column;
    height: 120px;
    padding: 15px 20px;
    gap: 15px;
  }
  
  .preset-buttons-container {
    width: 100%;
    max-width: none;
    justify-content: center;
  }
  
  .transpose-container {
    width: 100%;
    max-width: 600px;
    flex: 0 1 100%;
  }
  
  .canvas-container {
    padding-bottom: 140px;
  }
}

/* Channel Selector - minimal in corner */
/* Octave Spread Selector - positioned to the left of channel selector */
.octave-selector {
  position: absolute;
  bottom: 70px;
  right: 140px; /* Positioned to the left of channel selector */
  background: #000;
  color: #fff;
  padding: 8px 12px;
  font-size: 14px;
  font-weight: bold;
  border: 2px solid #fff;
  cursor: pointer;
  z-index: 100;
  font-family: monospace;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.15s ease;
  user-select: none;
}

.octave-selector:hover {
  background: #fff;
  color: #000;
  transform: scale(1.05);
}

.octave-selector.active {
  background: #fff;
  color: #000;
  transform: scale(1.1);
}

.octave-label {
  opacity: 0.7;
  font-size: 12px;
}

.octave-value {
  font-size: 16px;
  min-width: 12px;
  text-align: center;
}

/* Octave Drop-up Menu */
.octave-menu {
  position: absolute;
  bottom: 115px; /* Above the octave selector */
  right: 140px; /* Aligned with octave selector */
  background: #000;
  border: 2px solid #fff;
  display: grid;
  grid-template-columns: 1fr;
  gap: 0;
  z-index: 101;
  min-width: 60px;
}

.octave-menu-item {
  padding: 8px 16px;
  color: #fff;
  cursor: pointer;
  font-family: monospace;
  font-size: 14px;
  font-weight: bold;
  text-align: center;
  transition: all 0.15s ease;
  border-bottom: 1px solid #333;
}

.octave-menu-item:last-child {
  border-bottom: none;
}

.octave-menu-item:hover {
  background: #fff;
  color: #000;
}

.octave-menu-item.active {
  background: #333;
}

.channel-selector {
  position: absolute;
  bottom: 70px; /* Equal distance from bottom as from right */
  right: 70px; /* Move left to be inside canvas corner, away from mod wheel */
  background: #000;
  color: #fff;
  padding: 8px 12px;
  font-size: 14px;
  font-weight: bold;
  border: 2px solid #fff;
  cursor: pointer;
  z-index: 100;
  font-family: monospace;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.15s ease;
  user-select: none;
}

.channel-selector:hover {
  background: #fff;
  color: #000;
  transform: scale(1.05);
}

.channel-selector.active {
  background: #fff;
  color: #000;
  transform: scale(1.1);
}

.channel-label {
  opacity: 0.7;
  font-size: 12px;
}

.channel-value {
  font-size: 16px;
  min-width: 20px;
  text-align: center;
}

/* Channel Drop-up Menu */
.channel-menu {
  position: absolute;
  bottom: 110px; /* Adjust to follow selector */
  right: 70px; /* Match the selector position */
  background: #000;
  border: 2px solid #fff;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0;
  z-index: 101;
  font-family: monospace;
}

.channel-menu-item {
  padding: 8px 12px;
  color: #fff;
  text-align: center;
  cursor: pointer;
  font-size: 14px;
  font-weight: bold;
  border: 1px solid #333;
  transition: all 0.1s ease;
  user-select: none;
}

.channel-menu-item:hover {
  background: #fff;
  color: #000;
}

.channel-menu-item.active {
  background: #fff;
  color: #000;
}

/* Channel Indicator - floating cursor indicator */
.channel-indicator {
  position: fixed;
  background: #000;
  color: #fff;
  padding: 4px 8px;
  font-size: 12px;
  font-weight: bold;
  border: 2px solid #fff;
  pointer-events: none;
  z-index: 10000;
  font-family: monospace;
  letter-spacing: 1px;
  transition: opacity 0.2s ease;
}

@media (max-width: 600px) {
  .controls {
    gap: 15px;
  }
  
  .control-group {
    min-width: 100px;
  }
  
  .preset-button {
    flex: 0 0 65px;
  }
  
  .preset-buttons-container {
    gap: 4px;
  }
  
  .transpose-presets {
    padding: 10px 15px;
  }
  
  .octave-selector {
    bottom: 120px;
    right: 120px; /* Adjust for mobile */
    padding: 6px 10px;
    font-size: 12px;
  }
  
  .octave-value {
    font-size: 14px;
  }
  
  .octave-menu {
    bottom: 160px;
    right: 120px;
  }
  
  .channel-selector {
    bottom: 120px;
    right: 60px; /* Adjust for mobile too */
    padding: 6px 10px;
    font-size: 12px;
  }
  
  .channel-value {
    font-size: 14px;
  }
  
  .channel-menu {
    bottom: 160px;
    right: 60px; /* Match mobile selector position */
    grid-template-columns: repeat(4, 1fr);
  }
  
  .channel-menu-item {
    padding: 6px 10px;
    font-size: 12px;
  }
}

/* Rename Input Styles */
.rename-input {
  position: absolute;
  background: #fff;
  border: 2px solid #000;
  padding: 0;
  z-index: 10001;
  transform: translate(-50%, 0);
}

.rename-input input {
  width: 150px;
  padding: 5px 8px;
  border: none;
  outline: none;
  font-family: monospace;
  font-size: 12px;
  background: #fff;
  color: #000;
}

/* Context Menu Styles */
.context-menu {
  position: fixed;
  background: #fff;
  border: 2px solid #000;
  min-width: 200px;
  z-index: 10000;
  padding: 0;
  font-size: 14px;
}

.context-menu-item {
  padding: 10px 15px;
  cursor: pointer;
  transition: background-color 0.1s ease;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  position: relative;
}

.context-menu-item:hover {
  background: #000;
  color: #fff;
}

.context-menu-item:hover .menu-checkbox {
  border-color: #fff;
}

.context-menu-item:hover .menu-checkbox:checked {
  background-color: #fff;
}

.context-menu-item:hover .menu-checkbox:checked::after {
  border-color: #000;
}

/* Menu dividers */
.context-menu-divider {
  height: 1px;
  background: #000;
  margin: 0;
}

/* Checkbox styling */
.context-menu-item.checkbox-item {
  padding-left: 15px;
  gap: 8px;
}

.menu-checkbox {
  position: relative;
  width: 14px;
  height: 14px;
  appearance: none;
  -webkit-appearance: none;
  border: 2px solid #000;
  background: #fff;
  cursor: pointer;
  margin: 0;
  flex-shrink: 0;
}

.menu-checkbox:checked {
  background: #000;
  position: relative;
}

.menu-checkbox:checked::after {
  content: '';
  position: absolute;
  left: 2px;
  top: -1px;
  width: 3px;
  height: 7px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.context-menu-item.checkbox-item label {
  cursor: pointer;
  flex: 1;
  margin: 0;
  user-select: none;
  text-transform: none;
  font-size: 14px;
  font-weight: normal;
  letter-spacing: normal;
}

/* Shortcut keys */
.shortcut {
  font-size: 12px;
  opacity: 0.6;
  font-family: monospace;
  margin-left: auto;
}

.context-menu-item:hover .shortcut {
  opacity: 1;
}

/* Danger zone */
.context-menu-item.danger {
  color: #d00;
}

.context-menu-item.danger:hover {
  background: #d00;
  color: #fff;
}

.context-menu-item[data-disabled="true"] {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}

.context-menu-item.has-submenu {
  position: relative;
}

.context-menu-item.has-submenu::after {
  content: "";
  position: absolute;
  right: 15px;
  top: 50%;
  transform: translateY(-50%);
}

/* Submenu Styles */
.context-submenu {
  position: fixed;
  background: #fff;
  border: 2px solid #000;
  min-width: 60px;
  z-index: 10001;
  padding: 0;
  font-size: 14px;
}

.context-submenu .context-menu-item {
  text-align: center;
  min-width: 60px;
  padding: 10px 15px;
  border: none;
}

.context-submenu .context-menu-item.active {
  background: #000;
  color: #fff;
}

.context-submenu .context-menu-item:hover {
  background: #333;
  color: #fff;
}

.context-submenu .context-menu-item.active:hover {
  background: #000;
}

/* Tooltip Styles */
.shape-tooltip {
  position: fixed;
  background: #fff;
  border: 1px solid #000;
  padding: 4px 8px;
  font-size: 12px;
  font-weight: 500;
  z-index: 9999;
  pointer-events: none;
  white-space: nowrap;
}

/* Mod Wheel Fader Styles */
.mod-wheel-container {
  position: absolute;
  right: 10px;
  top: 10px;
  bottom: 90px; /* Leave room for status bar and bottom controls */
  width: 40px;
  display: flex;
  flex-direction: column;
  align-items: center;
  z-index: 100;
}

.mod-wheel-track {
  position: relative;
  width: 8px;
  flex: 1;
  background: #e0e0e0;
  border: 2px solid #000;
  cursor: pointer;
  margin-bottom: 10px;
}

.mod-wheel-handle {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  width: 24px;
  height: 24px;
  background: #fff;
  border: 2px solid #000;
  cursor: grab;
  transition: none;
}

.mod-wheel-handle:active {
  cursor: grabbing;
  background: #f0f0f0;
}

.mod-wheel-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-align: center;
  user-select: none;
}

/* Density control in context menu */
.context-menu-item.density-control {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 15px;
}

.context-menu-item.density-control:hover {
  background: #000;
  color: #fff;
}

.density-slider {
  width: 60px;
  height: 20px;
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
  outline: none;
}

.density-slider::-webkit-slider-track {
  width: 100%;
  height: 2px;
  background: #ddd;
}

.context-menu-item.density-control:hover .density-slider::-webkit-slider-track {
  background: rgba(255, 255, 255, 0.3);
}

.density-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 12px;
  height: 12px;
  border-radius: 0;
  background: #000;
  cursor: pointer;
}

.context-menu-item.density-control:hover .density-slider::-webkit-slider-thumb {
  background: #fff;
}

.density-slider::-moz-range-track {
  width: 100%;
  height: 2px;
  background: #ddd;
}

.context-menu-item.density-control:hover .density-slider::-moz-range-track {
  background: rgba(255, 255, 255, 0.3);
}

.density-slider::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border-radius: 0;
  border: none;
  background: #000;
  cursor: pointer;
}

.context-menu-item.density-control:hover .density-slider::-moz-range-thumb {
  background: #fff;
}

.density-value {
  color: #000;
  font-size: 11px;
  min-width: 35px;
  text-align: right;
}

.context-menu-item.density-control:hover .density-value {
  color: #fff;
}

/* Velocity Control - identical to density but for velocity */
.context-menu-item.velocity-control {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 15px;
}

.context-menu-item.velocity-control:hover {
  background: #000;
  color: #fff;
}

.velocity-slider {
  width: 60px;
  height: 20px;
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
  outline: none;
}

.velocity-slider::-webkit-slider-track {
  width: 100%;
  height: 2px;
  background: #ddd;
}

.context-menu-item.velocity-control:hover .velocity-slider::-webkit-slider-track {
  background: rgba(255, 255, 255, 0.3);
}

.velocity-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 12px;
  height: 12px;
  border-radius: 0;
  background: #000;
  cursor: pointer;
}

.context-menu-item.velocity-control:hover .velocity-slider::-webkit-slider-thumb {
  background: #fff;
}

.velocity-slider::-moz-range-track {
  width: 100%;
  height: 2px;
  background: #ddd;
}

.context-menu-item.velocity-control:hover .velocity-slider::-moz-range-track {
  background: rgba(255, 255, 255, 0.3);
}

.velocity-slider::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border-radius: 0;
  border: none;
  background: #000;
  cursor: pointer;
}

.context-menu-item.velocity-control:hover .velocity-slider::-moz-range-thumb {
  background: #fff;
}

.velocity-value {
  color: #000;
  font-size: 11px;
  min-width: 35px;
  text-align: right;
}

.context-menu-item.velocity-control:hover .velocity-value {
  color: #fff;
}

/* Visual feedback for keyboard shortcuts */
@keyframes fadeOut {
  0% {
    opacity: 1;
    transform: translateY(0);
  }
  100% {
    opacity: 0;
    transform: translateY(-10px);
  }
}

.shortcut-feedback {
  animation: fadeOut 0.5s ease-out forwards;
}

