* {
  box-sizing: border-box;
}

body {
  font-family: 'Segoe UI', 'Yu Gothic UI', sans-serif;
  background: #111827;
  color: #f3f4f6;
  min-height: 100vh;
  margin: 0;
  padding: 20px;
  line-height: 1.5;
}

.page-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.page-header-row h2 {
  margin: 0;
  color: #00d9ff;
  text-shadow: 0 0 10px rgba(0, 217, 255, 0.5);
  font-size: 28px;
}

.home-link-btn {
  padding: 8px 12px;
  font-size: 13px;
  background: #111827;
  border: 1px solid #4b5563;
  border-radius: 6px;
  color: #f3f4f6;
  text-decoration: none;
  white-space: nowrap;
  transition: all 0.2s ease;
}

.home-link-btn:hover {
  background: #1f2937;
  border-color: #6b7280;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.toolbar {
  background: #1f2937;
  border: 1px solid #374151;
  border-radius: 12px;
  padding: 12px 16px;
  margin-bottom: 12px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  overflow: visible;
}

.toolbar-group {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.divider {
  border-left: 1px solid #374151;
  height: 28px;
  margin: 0 4px;
}

label {
  color: #9ca3af;
  font-size: 13px;
}

input[type="number"],
input[type="text"],
select {
  padding: 6px 8px;
  border: 1px solid #4b5563;
  border-radius: 6px;
  background: #111827;
  color: #fff;
  font-size: 13px;
}

input[type="number"] {
  width: 64px;
}

input[type="text"] {
  width: 140px;
}

input[type="range"] {
  width: 90px;
  accent-color: #3b82f6;
}

input:focus,
select:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

button {
  padding: 6px 12px;
  font-size: 13px;
  background: #111827;
  border: 1px solid #4b5563;
  border-radius: 6px;
  color: #f3f4f6;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

button:hover {
  background: #1f2937;
  border-color: #6b7280;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

button.active,
button.primary {
  background: #1d4ed8;
  border-color: #3b82f6;
  color: #fff;
}

button.danger:hover {
  border-color: #ef4444;
  color: #fecaca;
}

.workspace {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 12px;
  min-height: calc(100vh - 220px);
}

.side-panel,
.roll-panel {
  background: #1f2937;
  border: 1px solid #374151;
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.side-panel {
  padding: 12px;
}

.side-panel h3 {
  margin: 0 0 10px;
  font-size: 14px;
  color: #93c5fd;
}

.track-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
  overflow-y: auto;
  margin-bottom: 12px;
}

.track-item {
  border: 1px solid #4b5563;
  border-radius: 8px;
  padding: 8px;
  background: #111827;
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.track-item:hover {
  border-color: #6b7280;
}

.track-item.selected {
  border-color: #3b82f6;
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.25);
}

.track-item-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 6px;
}

.track-name {
  font-size: 13px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.track-meta {
  font-size: 11px;
  color: #9ca3af;
  margin-bottom: 6px;
}

.track-controls {
  display: flex;
  align-items: center;
  gap: 6px;
}

.track-controls button {
  padding: 3px 7px;
  font-size: 11px;
}

.track-controls input[type="range"] {
  width: 70px;
}

.side-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.instrument-panel,
.generate-panel {
  margin-top: 8px;
  padding-top: 10px;
  border-top: 1px solid #374151;
}

.instrument-panel .field,
.generate-panel .field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 8px;
}

.generate-panel .side-actions {
  margin-top: 2px;
}

.generate-panel .side-actions button.primary {
  font-weight: 600;
}

.gen-checks {
  gap: 6px !important;
}

.check-row {
  display: flex !important;
  flex-direction: row !important;
  align-items: center;
  gap: 8px;
  color: #d1d5db;
  font-size: 12px;
  cursor: pointer;
}

.check-row input {
  accent-color: #3b82f6;
}

.gen-hint {
  margin: 8px 0 0;
  font-size: 11px;
  color: #6b7280;
  line-height: 1.4;
}

.roll-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid #374151;
  background: #111827;
}

.roll-wrap {
  position: relative;
  flex: 1;
  overflow: auto;
  background: #0b1220;
  outline: none;
}

.roll-panel.score-focused {
  box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.55);
}

.roll-wrap:focus {
  outline: none;
}

#pianoRoll {
  display: block;
  cursor: crosshair;
}

.status-bar {
  margin-top: 12px;
  padding: 8px 12px;
  background: #1f2937;
  border: 1px solid #374151;
  border-radius: 8px;
  font-size: 12px;
  color: #9ca3af;
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
}

.status-bar strong {
  color: #e5e7eb;
  font-weight: 600;
}

.file-actions {
  position: relative;
  z-index: 20;
}

.tb-dropdown {
  position: relative;
  display: inline-flex;
}

.tb-dropdown-toggle {
  min-width: 118px;
}

.tb-dropdown-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  min-width: 160px;
  padding: 6px;
  background: #111827;
  border: 1px solid #4b5563;
  border-radius: 8px;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.45);
  display: flex;
  flex-direction: column;
  gap: 4px;
  z-index: 40;
}

.tb-dropdown-menu[hidden] {
  display: none !important;
}

.tb-dropdown-item {
  width: 100%;
  text-align: left;
  justify-content: flex-start;
  background: #1f2937;
  border-color: #374151;
}

.tb-dropdown-item:hover {
  background: #274060;
  border-color: #60a5fa;
}

.tb-dropdown.open .tb-dropdown-toggle {
  background: #1d4ed8;
  border-color: #3b82f6;
  color: #fff;
}

.hint {
  font-size: 12px;
  color: #6b7280;
  margin: 0;
}

@media (max-width: 900px) {
  .workspace {
    grid-template-columns: 1fr;
  }

  .side-panel {
    max-height: 320px;
  }
}
