/* ========== RESET & BASE ========== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Segoe UI', -apple-system, sans-serif;
  background: #1c1c1c;
  color: #d0d0d0;
  overflow: hidden;
  height: 100vh;
  display: flex;
  flex-direction: column;
  user-select: none;
}

/* ========== KEYBIND LEGEND ========== */
#keybind-bar {
  display: flex;
  gap: 4px;
  padding: 4px 16px;
  background: #141414;
  border-bottom: 1px solid #2a2a2a;
  flex-shrink: 0;
  align-items: center;
  flex-wrap: wrap;
}

#keybind-bar .kb {
  font-size: 11px;
  color: #707070;
  white-space: nowrap;
  padding: 0 6px;
  border-right: 1px solid #2a2a2a;
}

#keybind-bar .kb:last-child {
  border-right: none;
}

#keybind-bar .kb-divider {
  width: 1px;
  height: 16px;
  background: #444;
  margin: 0 4px;
}

#keybind-bar .kb-event {
  border-right: none;
  border-left: 2px solid;
  padding-left: 6px;
  margin-left: 2px;
}

#keybind-bar kbd {
  display: inline-block;
  background: #252525;
  border: 1px solid #3a3a3a;
  border-radius: 3px;
  padding: 1px 5px;
  font-family: 'Consolas', monospace;
  font-size: 10px;
  color: #aaa;
  margin-right: 4px;
}

/* ========== META BAR ========== */
#meta-bar {
  display: flex;
  gap: 12px;
  padding: 8px 16px;
  background: #1e1e1e;
  border-bottom: 1px solid #2a2a2a;
  flex-shrink: 0;
  align-items: center;
  flex-wrap: wrap;
}

#meta-bar label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: #909090;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

#meta-bar input {
  background: #151515;
  border: 1px solid #3a3a3a;
  color: #d0d0d0;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 13px;
  outline: none;
  transition: border-color 0.2s;
}

#meta-bar input:focus {
  border-color: #c0005e;
}

#meta-bar input[type="text"] {
  width: 140px;
}

#meta-bar input[type="number"] {
  width: 80px;
}

#btn-detect-bpm {
  font-size: 11px;
  padding: 4px 10px;
  background: #1a1a2e;
  border: 1px solid #4a4a8a;
  border-radius: 4px;
  color: #9090d0;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}
#btn-detect-bpm:hover {
  border-color: #7070c0;
  background: #252550;
}
#btn-detect-bpm:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ========== TOOLBAR ========== */
#toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 16px;
  background: #1e1e1e;
  border-bottom: 1px solid #2a2a2a;
  flex-shrink: 0;
  gap: 12px;
}

#toolbar-left,
#toolbar-center,
#toolbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

#toolbar-center {
  gap: 6px;
}

button {
  background: #272727;
  color: #d0d0d0;
  border: 1px solid #3a3a3a;
  padding: 6px 14px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
  transition: all 0.15s;
  white-space: nowrap;
}

button:hover {
  background: #333;
  border-color: #c0005e;
}

button:active {
  background: #a00050;
  border-color: #a00050;
  color: #fff;
}

#btn-play {
  background: #272727;
  border-color: #b0005a;
  color: #e8609a;
  min-width: 90px;
  font-weight: 700;
}

#btn-play:hover {
  background: #a00050;
  color: #fff;
  border-color: #c0005e;
}

#btn-play.playing {
  background: #8a0048;
  border-color: #c0005e;
  color: #fff;
}

#btn-stop {
  background: #272727;
  border-color: #3a3a3a;
}

#btn-stop:hover {
  background: #3a3a3a;
}

#time-display {
  font-family: 'Consolas', 'Courier New', monospace;
  font-size: 13px;
  color: #999;
  min-width: 140px;
  text-align: center;
}

.info-text {
  font-size: 12px;
  color: #707070;
}

select {
  background: #151515;
  color: #d0d0d0;
  border: 1px solid #3a3a3a;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 13px;
  outline: none;
  cursor: pointer;
}

select:focus {
  border-color: #c0005e;
}

#toolbar-right label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: #909090;
  text-transform: uppercase;
}

.vol-label {
  text-transform: none !important;
  gap: 3px !important;
  font-size: 13px !important;
}

.vol-label input[type="range"] {
  width: 60px;
  height: 4px;
  -webkit-appearance: none;
  appearance: none;
  background: #3a3a3a;
  border-radius: 2px;
  outline: none;
  cursor: pointer;
}

.vol-label input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #999;
  border: none;
  cursor: pointer;
}

.vol-label input[type="range"]::-webkit-slider-thumb:hover {
  background: #e8609a;
}

/* ========== OVERVIEW MINIMAP ========== */
#overview-lane {
  height: 40px;
  background: #141414;
  border-bottom: 1px solid #2a2a2a;
  flex-shrink: 0;
  cursor: pointer;
}

#overview-canvas {
  display: block;
  width: 100%;
  height: 100%;
}

/* ========== TIMELINE CONTAINER ========== */
#timeline-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

/* ========== LANES ========== */
#section-lane {
  height: 28px;
  background: #181818;
  border-bottom: 1px solid #2a2a2a;
  flex-shrink: 0;
}

#waveform-lane {
  flex: 1;
  min-height: 80px;
  background: #161616;
  border-bottom: 1px solid #2a2a2a;
}

#beat-lane,
#event-lane {
  position: relative;
  flex-shrink: 0;
  border-bottom: 1px solid #2a2a2a;
}

#beat-lane {
  height: 100px;
  background: #181818;
}

#event-lane {
  height: 140px;
  background: #161616;
}

/* Lane labels */
#beat-lane::before,
#event-lane::before {
  content: attr(data-label);
  position: absolute;
  left: 6px;
  top: 4px;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: #505050;
  z-index: 1;
  pointer-events: none;
}

#ruler-lane {
  height: 28px;
  background: #181818;
  flex-shrink: 0;
}

/* ========== CANVASES ========== */
#section-canvas,
#waveform-canvas,
#beat-canvas,
#event-canvas,
#ruler-canvas {
  display: block;
  width: 100%;
  height: 100%;
}

/* ========== EVENT EDIT POPUP ========== */
#event-popup {
  position: fixed;
  z-index: 1000;
  background: #222;
  border: 1px solid #b0005a;
  border-radius: 6px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 220px;
  box-shadow: 0 4px 20px rgba(160, 0, 80, 0.12), 0 4px 16px rgba(0, 0, 0, 0.4);
}

#event-popup label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 11px;
  color: #909090;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

#event-popup select,
#event-popup input[type="text"] {
  background: #181818;
  border: 1px solid #3a3a3a;
  color: #d0d0d0;
  padding: 5px 8px;
  border-radius: 4px;
  font-size: 13px;
  outline: none;
  width: 100%;
}

#event-popup select:focus,
#event-popup input[type="text"]:focus {
  border-color: #c0005e;
}

#event-popup-buttons {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
  margin-top: 4px;
}

#event-popup-buttons button {
  padding: 4px 12px;
  font-size: 12px;
}

#event-popup-delete {
  background: #351515 !important;
  border-color: #552828 !important;
  margin-right: auto;
}

#event-popup-delete:hover {
  background: #552828 !important;
}

/* ========== EVENT NODE LIST POPUP ========== */
#event-node-popup {
  position: fixed;
  z-index: 999;
  background: #222;
  border: 1px solid #3a3a3a;
  border-radius: 6px;
  padding: 0;
  display: flex;
  flex-direction: column;
  min-width: 240px;
  max-width: 320px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
  overflow: hidden;
}

.event-node-header {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #e8609a;
  padding: 8px 12px 6px;
  border-bottom: 1px solid #2a2a2a;
}

#event-node-list {
  display: flex;
  flex-direction: column;
  max-height: 200px;
  overflow-y: auto;
}

.event-node-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-bottom: 1px solid #1e1e1e;
  transition: background 0.1s;
}

.event-node-row:hover {
  background: #2a2a2a;
}

.event-node-row:last-child {
  border-bottom: none;
}

.event-node-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.event-node-label {
  flex: 1;
  font-size: 12px;
  color: #d0d0d0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.event-node-btn {
  background: none;
  border: 1px solid #3a3a3a;
  color: #909090;
  padding: 2px 6px;
  font-size: 12px;
  border-radius: 3px;
  cursor: pointer;
  min-width: 24px;
  text-align: center;
}

.event-node-btn:hover {
  background: #333;
  color: #ffffff;
  border-color: #c0005e;
}

.event-node-btn-del:hover {
  background: #401515;
  border-color: #552828;
  color: #ff6666;
}

.event-node-footer {
  display: flex;
  gap: 6px;
  padding: 8px 12px;
  border-top: 1px solid #2a2a2a;
  justify-content: space-between;
}

.event-node-footer button {
  padding: 4px 12px;
  font-size: 12px;
}

#event-node-add {
  background: #272727;
  border-color: #b0005a;
  color: #e8609a;
}

#event-node-add:hover {
  background: #a00050;
  color: #fff;
}

/* ========== SCROLLBAR STYLING ========== */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: #1c1c1c;
}

::-webkit-scrollbar-thumb {
  background: #3a3a3a;
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: #555;
}
