/* Note Probabilities Section */
.note-probabilities-section {
  margin: 1.2rem 0 1.5rem 0;
  padding: 1rem 1.2rem 1.2rem 1.2rem;
  background: #181f2e;
  border: 1px solid #374151;
  border-radius: 0.7rem;
  box-shadow: 0 2px 12px rgba(0,0,0,0.13);
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow-x: auto;
  min-width: 0;
}

.note-probabilities-title {
  color: #fbbf24;
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 0.7rem;
}

#note-probabilities-canvas {
  background: #0b1220;
  border: 1px solid #334155;
  border-radius: 0.5rem;
  width: 100%;
  max-width: 600px;
  height: 180px;
  display: block;
  margin-bottom: 0.5rem;
  cursor: grab;
  outline: none;
}

#note-probabilities-canvas:active {
  cursor: grabbing;
}

.note-probabilities-help {
  color: #a1a1aa;
  font-size: 0.92rem;
  margin-top: 0.2rem;
  text-align: center;
}

.note-probabilities-list {
  position: relative;
  display: flex;
  flex-direction: row;
  align-items: flex-end;
  width: 100%;
  max-width: 100%;
  margin: 0 auto;
  min-height: 220px;
  height: 220px;
  background: linear-gradient(to top, #232b3a 0%, #334155 100%);
  border-left: 2px solid #475569;
  border-right: 2px solid #475569;
  border-radius: 0.5rem;
  box-sizing: border-box;
  min-width: 650px;
  overflow-x: auto;
}

.note-probability-row {
  position: absolute;
  left: 0;
  width: 48px;
  z-index: 1;
  transition: box-shadow 0.15s, background 0.15s;
  cursor: grab;
  user-select: none;
}

.note-probability-row.dragging {
  opacity: 0.7;
  z-index: 10;
  box-shadow: 0 0 0 2px #fbbf24;
}

.note-probability-label {
  display: block;
  font-size: 1.05rem;
  font-weight: 600;
  color: #fbbf24;
  letter-spacing: 0.04em;
  text-align: center;
  background: #232b3a;
  border-radius: 0.4rem;
  padding: 0.7rem 0.2rem 0.3rem 0.2rem;
  min-width: 2.7rem;
  min-height: 2.7rem;
  box-shadow: 0 1px 4px rgba(0,0,0,0.07);
  user-select: none;
  cursor: inherit;
  transition: background 0.15s, color 0.15s;
}

.note-probability-label:active {
  background: #fbbf24;
  color: #232b3a;
}

.note-probability-value {
  display: block;
  font-size: 0.85rem;
  color: #a1a1aa;
  text-align: center;
  margin-top: 0.1rem;
}

.note-probabilities-axis {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 100%;
  pointer-events: none;
  z-index: 0;
}

.note-probabilities-axis-label {
  position: absolute;
  left: -2.2rem;
  color: #a1a1aa;
  font-size: 0.85rem;
  font-weight: 600;
  user-select: none;
}

.note-probabilities-axis-label.top {
  top: 0;
}

.note-probabilities-axis-label.bottom {
  bottom: 0;
}

/* ==========================================================================
   Author's custom styles
   ========================================================================== */

body {
  margin: 0;
  min-height: 100vh;
  display: grid;
  place-items: start center;
  padding: 1.5rem 1rem;
  box-sizing: border-box;
  font-family: "Inter", "Segoe UI", Roboto, Arial, sans-serif;
  background: #111827;
  color: #f9fafb;
}

.app {
  text-align: center;
  padding: 1.5rem 2rem 2rem;
  width: 100%;
  max-width: 1100px;
  box-sizing: border-box;
  background: #1a2235;
  border: 1px solid #1e3a5f;
  border-radius: 1rem;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.55);
  position: relative;
}

.description {
  color: #d1d5db;
  margin-bottom: 1rem;
  font-size: 0.95rem;
}

#status {
  color: #bfdbfe;
  margin-bottom: 1rem;
  font-size: 0.9rem;
  text-align: left;
  padding-right: 4.25rem;
}

.global-transport {
  position: absolute;
  top: 1.35rem;
  right: 1.35rem;
  display: flex;
  justify-content: flex-end;
  gap: 0.3rem;
  margin: 0;
  z-index: 1;
}

.transport-btn {
  width: 1.7rem;
  min-width: 1.7rem;
  height: 1.7rem;
  padding: 0;
  border: 1px solid #475569;
  border-radius: 0.4rem;
  background: #0f172a;
  color: #e2e8f0;
  font-size: 0.8rem;
  font-weight: 800;
  line-height: 1;
  cursor: pointer;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.transport-btn:hover:not(:disabled) {
  transform: translateY(-1px);
}

.transport-btn:focus-visible {
  outline: 2px solid #93c5fd;
  outline-offset: 2px;
}

.transport-btn:disabled {
  cursor: not-allowed;
  opacity: 0.56;
  transform: none;
}

.transport-btn--play {
  border-color: #22c55e;
  background: #14532d;
  color: #dcfce7;
}

.transport-btn--play:hover:not(:disabled),
.transport-btn--play.is-active {
  border-color: #4ade80;
  background: #166534;
  box-shadow: 0 0 0 1px rgba(74, 222, 128, 0.28), 0 0 16px rgba(34, 197, 94, 0.18);
}


.transport-btn--stop {
  border-color: #ef4444;
  background: #7f1d1d;
  color: #fee2e2;
}

.transport-btn--stop:hover:not(:disabled),
.transport-btn--stop.is-active {
  border-color: #f87171;
  background: #991b1b;
  box-shadow: 0 0 0 1px rgba(248, 113, 113, 0.24), 0 0 16px rgba(239, 68, 68, 0.16);
}

.mixer {
  margin-bottom: 1.5rem;
  padding: 0.75rem;
  background: #0f172a;
  border-radius: 0.75rem;
  border: 1px solid #1e3a8a;
}

.mixer-channels {
  display: flex;
  gap: 0.5rem;
  padding: 0.25rem;
}

.channel-strip {
  flex: 1;
  min-width: 0;
  padding: 0.6rem 0.4rem;
  background: linear-gradient(135deg, #1f2937 0%, #111827 100%);
  border: 1px solid #374151;
  border-radius: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  align-items: center;
  cursor: pointer;
}

.channel-strip.is-current {
  border-color: #fcd34d;
  box-shadow: 0 0 0 2px rgba(252, 211, 77, 0.3), inset 0 0 0 1px #fcd34d;
}

.channel-strip.is-muted:not(.is-current) {
  border-color: #64748b;
  box-shadow: inset 0 0 0 1px rgba(148, 163, 184, 0.18);
}

.channel-instrument-select {
  width: 100%;
  padding: 0.35rem 0.45rem;
  border: 1px solid #475569;
  border-radius: 0.35rem;
  background: #0f172a;
  color: #e2e8f0;
  font-size: 0.72rem;
  font-weight: 600;
}

.channel-instrument-select:focus-visible {
  outline: 2px solid #93c5fd;
  outline-offset: 2px;
}

.channel-name {
  font-size: 0.75rem;
  font-weight: 600;
  color: #d1d5db;
  text-align: center;
  word-break: break-word;
  min-height: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.channel-indicator {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #374151;
  border: 1px solid #4b5563;
  transition: all 0.1s ease;
}

.channel-indicator.is-playing {
  background: #dc2626;
  box-shadow: 0 0 8px rgba(220, 38, 38, 0.6);
  border-color: #ef4444;
}

.channel-buttons {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  width: 100%;
}

.channel-play-btn,
.channel-variation-btn,
.channel-mute-btn {
  width: 100%;
  padding: 0.4rem 0.3rem;
  font-size: 0.7rem;
  font-weight: 600;
  border: 1px solid #4b5563;
  border-radius: 0.3rem;
  cursor: pointer;
  transition: all 0.15s ease;
}


.channel-play-btn {
  background: #374151;
  color: #d1d5db;
}

.channel-play-btn:hover {
  background: #4b5563;
  color: #e5e7eb;
}

.channel-play-btn.is-playing {
  background: #dc2626;
  border-color: #ef4444;
  color: #fecaca;
}

.channel-play-btn.is-playing:hover {
  background: #b91c1c;
}

.channel-variation-btn {
  background: #0f766e;
  border-color: #14b8a6;
  color: #ccfbf1;
}

.channel-variation-btn:hover {
  background: #0f5f58;
  border-color: #2dd4bf;
}

.channel-mute-btn {
  background: #334155;
  border-color: #64748b;
  color: #e2e8f0;
}

.channel-mute-btn:hover {
  background: #475569;
  border-color: #94a3b8;
}

.channel-mute-btn.is-muted,
.channel-mute-btn[aria-pressed="true"] {
  background: #7c2d12;
  border-color: #fb923c;
  color: #ffedd5;
  box-shadow: 0 0 0 1px rgba(251, 146, 60, 0.28), 0 0 14px rgba(249, 115, 22, 0.18);
}

.channel-mute-btn.is-muted:hover,
.channel-mute-btn[aria-pressed="true"]:hover {
  background: #9a3412;
}

.channel-note-length-btn {
  width: 100%;
  padding: 0.4rem 0.3rem;
  font-size: 0.7rem;
  font-weight: 700;
  border: 1px solid #3b82f6;
  border-radius: 0.3rem;
  cursor: pointer;
  transition: all 0.15s ease;
  background: #1e3a8a;
  color: #bfdbfe;
}

.channel-note-length-btn:hover {
  background: #1d4ed8;
  border-color: #60a5fa;
  color: #e0f2fe;
}

.channel-note-sustain-btn {
  width: 100%;
  padding: 0.4rem 0.3rem;
  font-size: 0.7rem;
  font-weight: 700;
  border: 1px solid #8b5cf6;
  border-radius: 0.3rem;
  cursor: pointer;
  transition: all 0.15s ease;
  background: #3b0764;
  color: #ddd6fe;
}

.channel-note-sustain-btn:hover {
  background: #6d28d9;
  border-color: #a78bfa;
  color: #ede9fe;
}

.channel-volume-slider {
  width: 100%;
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  border-radius: 2px;
  background: #374151;
  outline: none;
  cursor: pointer;
  margin-top: 0.15rem;
}

.channel-volume-slider.is-muted {
  opacity: 0.58;
}

.channel-volume-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #60a5fa;
  cursor: pointer;
  border: 1px solid #3b82f6;
}

.channel-volume-slider::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #60a5fa;
  cursor: pointer;
  border: 1px solid #3b82f6;
}

.channel-midi-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 0.25rem;
  align-items: center;
}

.channel-midi-channel-select {
  min-width: 0;
  padding: 0.3rem 0.35rem;
  border: 1px solid #475569;
  border-radius: 0.3rem;
  background: #0f172a;
  color: #dbeafe;
  font-size: 0.66rem;
  font-weight: 600;
}

.channel-midi-toggle-btn {
  min-width: 0;
  padding: 0.32rem 0.45rem;
  border: 1px solid #475569;
  border-radius: 0.3rem;
  background: #1e293b;
  color: #cbd5e1;
  font-size: 0.65rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
}

.channel-midi-toggle-btn:hover {
  border-color: #93c5fd;
  background: #1d4ed8;
  color: #eff6ff;
}

.channel-midi-toggle-btn.is-active,
.channel-midi-toggle-btn[aria-pressed="true"] {
  border-color: #22c55e;
  background: #14532d;
  color: #dcfce7;
}

.controls {
  margin-top: 1rem;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  padding: 1.25rem 1.5rem;
  background: #1f2937;
  border: 1px solid #374151;
  border-radius: 0.75rem;
}

.controls-top-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem;
}

.controls-main-panel {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.controls-section-separator {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  margin: 0.15rem 0 0.1rem;
}

.controls-section-separator::before,
.controls-section-separator::after {
  content: "";
  flex: 1 1 auto;
  height: 1px;
  background: linear-gradient(90deg, rgba(96, 165, 250, 0.18) 0%, rgba(96, 165, 250, 0.52) 100%);
}

.controls-section-separator::after {
  background: linear-gradient(90deg, rgba(96, 165, 250, 0.52) 0%, rgba(96, 165, 250, 0.18) 100%);
}

.controls-section-separator-label {
  flex: 0 0 auto;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #93c5fd;
  white-space: nowrap;
}

@media (min-width: 900px) {
  .controls-top-row {
    display: grid;
    grid-template-columns: 3fr 1fr;
    column-gap: 0.75rem;
    row-gap: 0.75rem;
    align-items: start;
  }

  .controls-top-row > * {
    min-width: 0;
  }

  .controls-top-row > .mixer {
    grid-column: 1;
    grid-row: 1;
  }

  .controls-top-row > .controls-global-panel {
    grid-column: 2;
    grid-row: 1 / span 4;
    position: static;
    width: auto;
    margin: 0;
    overflow: hidden;
  }


  .controls-top-row > .note-selector {
    grid-column: 1;
    grid-row: 2;
  }

  .controls-top-row > .rhythm-section {
    grid-column: 1;
    grid-row: 3;
  }

  .controls-top-row > .note-probabilities-section {
    grid-column: 1;
    grid-row: 4;
  }

  .controls-main-panel {
    margin-top: 0.15rem;
  }
}

.controls-global-panel {
  margin-top: 0;
  padding: 0.8rem 1rem;
  gap: 0.4rem;
}

.controls-global-panel .control-group-items {
  grid-template-columns: 1fr;
  gap: 0.3rem 0.5rem;
}

.controls-global-panel .control-item {
  min-width: 0;
}

.controls-global-panel h2 {
  margin: 0 0 0.2rem;
  font-size: 0.9rem;
  color: #dbeafe;
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
}

.controls--global {
  background: #1a1f2e;
  border-color: #2d3f5a;
}

.controls--global .control-group {
  background: #0f172a;
  border-color: #1e3a5f;
  padding: 0.45rem 0.65rem 0.55rem;
}

.controls--global .control-group-title {
  color: #f59e0b;
  margin: 0 0 0.3rem;
  font-size: 0.62rem;
}

.control-group--global-key {
  overflow: hidden;
}

.global-key-panel {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.global-key-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
}

.global-key-tonic-label {
  font-size: 0.76rem;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.global-key-tonic-value {
  font-size: 1rem;
  font-weight: 800;
  color: #f8fafc;
}

.global-key-note-list {
  display: flex;
  flex-wrap: nowrap;
  gap: 0.28rem;
  min-width: 0;
}

.global-key-note-chip {
  flex: 1 1 0;
  min-width: 0;
  padding: 0.28rem 0.1rem;
  border: 1px solid #334155;
  border-radius: 0.4rem;
  background: #111827;
  color: #dbeafe;
  font-size: 0.68rem;
  font-weight: 700;
  line-height: 1;
  text-align: center;
  white-space: nowrap;
}

.seed-panel {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.seed-label {
  font-size: 0.76rem;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.seed-input {
  width: 100%;
  min-height: 4.75rem;
  box-sizing: border-box;
  resize: vertical;
  padding: 0.55rem 0.65rem;
  border: 1px solid #334155;
  border-radius: 0.45rem;
  background: #020617;
  color: #e2e8f0;
  font: inherit;
  font-size: 0.76rem;
  line-height: 1.4;
}

.seed-input:focus-visible {
  outline: 2px solid #93c5fd;
  outline-offset: 2px;
}

.seed-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.seed-action-btn {
  min-width: 0;
  flex: 1 1 0;
  justify-content: center;
}

.controls h2 {
  margin: 0 0 0.4rem;
  font-size: 1rem;
  color: #dbeafe;
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
}

.controls-scope {
  font-size: 0.7rem;
  font-weight: 400;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.note-selector {
  /* visual styling handled below */
}

.control-item {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.control-group {
  background: #111827;
  border: 1px solid #2d3f5a;
  border-radius: 0.5rem;
  padding: 0.65rem 0.9rem 0.75rem;
}

.control-group-title {
  margin: 0 0 0.55rem;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: #60a5fa;
}

.control-group-items {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 0.5rem 1.25rem;
}

.controls label,
.control-label {
  font-size: 0.9rem;
  color: #d1d5db;
}

.controls input[type="range"] {
  width: 100%;
  accent-color: #60a5fa;
  margin-bottom: 0.2rem;
}

.controls select {
  width: 100%;
  padding: 0.45rem 0.55rem;
  border: 1px solid #475569;
  border-radius: 0.45rem;
  background: #0f172a;
  color: #dbeafe;
  font-size: 0.86rem;
}

.controls select:focus-visible {
  outline: 2px solid #93c5fd;
  outline-offset: 2px;
}

.control-item--midi-status {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.midi-status-label {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #94a3b8;
}

.midi-status-value {
  min-height: 1.25rem;
  color: #dbeafe;
  font-size: 0.86rem;
  font-weight: 600;
}

.midi-status-value.is-active {
  color: #fde68a;
  text-shadow: 0 0 10px rgba(245, 158, 11, 0.22);
}

.midi-refresh-btn {
  width: 100%;
}

.control-button-group {
  display: grid;
  gap: 0.35rem;
}

.control-toggle-btn {
  width: fit-content;
  min-width: 4.5rem;
  padding: 0.45rem 0.8rem;
  border: 1px solid #4b5563;
  border-radius: 0.45rem;
  background: #0f172a;
  color: #dbeafe;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
}

.control-toggle-btn:hover {
  border-color: #60a5fa;
  background: #1e3a8a;
}

.control-toggle-btn:focus-visible {
  outline: 2px solid #93c5fd;
  outline-offset: 2px;
}

.cycle-btn {
  width: fit-content;
  min-width: 5.5rem;
  padding: 0.45rem 0.9rem;
  border: 1px solid #6366f1;
  border-radius: 0.45rem;
  background: #1e1b4b;
  color: #c7d2fe;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
}

.cycle-btn:hover {
  border-color: #818cf8;
  background: #312e81;
  color: #e0e7ff;
}

.cycle-btn:focus-visible {
  outline: 2px solid #818cf8;
  outline-offset: 2px;
}

.button-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.45rem;
}

.preset-button {
  border: 1px solid #4b5563;
  border-radius: 0.45rem;
  background: #111827;
  color: #d1d5db;
  padding: 0.5rem 0.6rem;
  text-align: left;
  cursor: pointer;
  font-size: 0.85rem;
}
.preset-button:hover {
  border-color: #93c5fd;
}

.preset-button.is-playing {
  background: #1d4ed8;
  border-color: #60a5fa;
  color: #dbeafe;
}

.preset-button.is-current {
  border-color: #fcd34d;
  box-shadow: 0 0 0 1px rgba(252, 211, 77, 0.65);
}

.preset-button:focus-visible {
  outline: 2px solid #93c5fd;
  outline-offset: 2px;
}

.hint {
  margin: 0 0 0.35rem;
  font-size: 0.78rem;
  color: #9ca3af;
}


.note-selector {
  margin: 0 0 0.6rem;
  padding: 0.7rem;
  border: 1px solid #374151;
  border-radius: 0.5rem;
}

.note-selector legend {
  padding: 0 0.35rem;
  color: #dbeafe;
  font-size: 0.9rem;
}

.note-grid-rows {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.note-row {
  display: grid;
  grid-template-columns: 1fr minmax(4.4rem, auto);
  gap: 0.6rem;
  align-items: stretch;
}

.note-row-side {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  align-items: stretch;
  justify-content: center;
  order: 2;
}

.note-row-label {
  font-size: 0.76rem;
  font-weight: 700;
  color: #cbd5e1;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  text-align: right;
}

.note-row-toggle {
  width: 100%;
  min-width: 0;
  padding-inline: 0.6rem;
}

.note-row-toggle.is-active,
.note-row-toggle[aria-pressed="true"] {
  border-color: #22c55e;
  background: #14532d;
  color: #dcfce7;
  box-shadow: 0 0 0 1px rgba(34, 197, 94, 0.35), 0 0 14px rgba(34, 197, 94, 0.16);
}

.note-row-buttons {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 0.45rem;
  order: 1;
}

.note-row.is-disabled .note-row-label {
  color: #64748b;
}

.note-row.is-disabled .note-row-buttons {
  opacity: 0.7;
}

@media (max-width: 760px) {
  .note-row {
    grid-template-columns: 1fr;
  }

  .note-row-side {
    flex-direction: row;
    align-items: center;
    justify-content: flex-end;
  }

  .note-row-buttons {
    grid-template-columns: repeat(auto-fit, minmax(3.1rem, 1fr));
  }
}

.note-selector-actions {
  margin-top: 0.7rem;
  display: flex;
  justify-content: flex-start;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.note-settings-toggle {
  margin-left: auto;
  border-color: #6366f1;
  background: #1e1b4b;
  color: #c7d2fe;
}

.note-settings-toggle:hover {
  border-color: #818cf8;
  background: #312e81;
  color: #e0e7ff;
}

/* Rhythm Definition Section */
.rhythm-section {
  margin: 0.6rem 0;
  padding: 0.7rem;
  border: 1px solid #374151;
  border-radius: 0.5rem;
  background: #111827;
}

.rhythm-section-title {
  margin: 0 0 0.6rem;
  font-size: 0.9rem;
  font-weight: 700;
  color: #dbeafe;
}

.rhythm-buttons {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 0.45rem;
}

.rhythm-button {
  width: 100%;
  min-width: 0;
  padding: 0.5rem 0.25rem;
  border: 1px solid #334155;
  border-radius: 0.4rem;
  background: #111827;
  color: #94a3b8;
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1;
  text-align: center;
  white-space: nowrap;
  cursor: pointer;
  transition: all 0.15s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 2.5rem;
}

.rhythm-button:hover {
  border-color: #60a5fa;
  background: #1e293b;
  color: #e2e8f0;
}

.rhythm-button:focus-visible {
  outline: 2px solid #93c5fd;
  outline-offset: 2px;
}

.rhythm-button.is-active,
.rhythm-button[aria-pressed="true"] {
  border-color: #ec4899;
  background: #831843;
  color: #fbcfe8;
  box-shadow: 0 0 0 1px rgba(236, 72, 153, 0.35), 0 0 14px rgba(236, 72, 153, 0.16);
}

.settings-dialog {
  width: min(54rem, calc(100vw - 2rem));
  padding: 0;
  border: 1px solid #3b82f6;
  border-radius: 0.8rem;
  background: #0f172a;
  color: #f8fafc;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
}

.settings-dialog::backdrop {
  background: rgba(2, 6, 23, 0.72);
}

.settings-dialog-content {
  padding: 1rem 1.05rem 1.1rem;
}

.settings-dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.settings-dialog-header h2 {
  margin: 0;
  font-size: 1rem;
  color: #dbeafe;
}

.settings-dialog-close {
  width: 2rem;
  height: 2rem;
  border: 1px solid #475569;
  border-radius: 999px;
  background: #111827;
  color: #e2e8f0;
  font-size: 1.15rem;
  line-height: 1;
  cursor: pointer;
}

.settings-dialog-close:hover {
  border-color: #93c5fd;
  background: #1e293b;
}

.settings-dialog-close:focus-visible {
  outline: 2px solid #93c5fd;
  outline-offset: 2px;
}

.settings-dialog-copy {
  margin: 0;
  color: #cbd5e1;
  font-size: 0.95rem;
}

.settings-dialog-section {
  margin-top: 1rem;
}

.settings-dialog-section-title {
  margin: 0 0 0.55rem;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #93c5fd;
}

.settings-channel-selector {
  margin-bottom: 0.7rem;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.settings-channel-selector-label {
  font-size: 0.72rem;
  font-weight: 700;
  color: #cbd5e1;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.settings-channel-button-row {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 0.35rem;
}

.settings-channel-btn {
  width: 100%;
  min-width: 0;
  min-height: 2.2rem;
  padding: 0.35rem 0;
  border-color: #334155;
  background: #111827;
  color: #94a3b8;
  font-size: 0.82rem;
}

.settings-channel-btn:hover {
  border-color: #60a5fa;
  background: #1e293b;
  color: #e2e8f0;
}

.settings-channel-btn.is-active,
.settings-channel-btn[aria-pressed="true"] {
  border-color: #60a5fa;
  background: #1d4ed8;
  color: #eff6ff;
  box-shadow: 0 0 0 1px rgba(96, 165, 250, 0.3), 0 0 16px rgba(37, 99, 235, 0.18);
}

.settings-note-grid {
  display: flex;
  flex-wrap: nowrap;
  gap: 0.35rem;
  overflow-x: auto;
  padding-bottom: 0.1rem;
}

.settings-note-toggle {
  flex: 0 0 2.7rem;
  padding: 0.45rem 0;
}

.settings-note-toggle.is-in-key {
  border-color: #38bdf8;
  background: #0f2740;
  color: #dbeafe;
  box-shadow: 0 0 0 1px rgba(56, 189, 248, 0.28);
}

.settings-note-toggle.is-in-key.is-active,
.settings-note-toggle.is-in-key[aria-pressed="true"] {
  border-color: #fde68a;
  box-shadow:
    0 0 0 1px rgba(252, 211, 77, 0.55),
    0 0 0 3px rgba(56, 189, 248, 0.2),
    0 0 16px rgba(245, 158, 11, 0.35);
}

.settings-key-controls {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0.65rem;
  align-items: center;
}

.settings-key-step-btn {
  min-width: 2.5rem;
  padding-inline: 0;
  font-size: 1rem;
}

.settings-key-display {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 3rem;
  padding: 0.45rem 0.75rem;
  border: 1px solid #334155;
  border-radius: 0.65rem;
  background: #111827;
}

.settings-key-value {
  font-size: 1.15rem;
  font-weight: 800;
  color: #f8fafc;
}

.settings-key-caption {
  font-size: 0.72rem;
  color: #94a3b8;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.settings-key-transpose {
  margin-top: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.settings-key-transpose-label {
  font-size: 0.72rem;
  font-weight: 700;
  color: #cbd5e1;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.settings-key-transpose-actions {
  display: flex;
  gap: 0.45rem;
}

.settings-key-transpose-btn {
  flex: 1 1 0;
  width: auto;
  min-width: 0;
  min-height: 2.25rem;
  padding-inline: 0.55rem;
  text-align: center;
  font-size: 0.92rem;
  font-weight: 800;
  border-color: #0ea5e9;
  background: #082f49;
  color: #e0f2fe;
}

.settings-key-transpose-btn:hover {
  border-color: #38bdf8;
  background: #0c4a6e;
  color: #f0f9ff;
}

.settings-key-transpose-btn:focus-visible {
  outline: 2px solid #7dd3fc;
  outline-offset: 2px;
}

.settings-dialog-actions {
  margin-top: 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.65rem;
  flex-wrap: wrap;
}

.settings-dialog-history-actions {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.settings-history-btn {
  min-width: 4.2rem;
}

.settings-history-position {
  min-width: 4.9rem;
  padding: 0.25rem 0.45rem;
  border: 1px solid #334155;
  border-radius: 0.45rem;
  background: #0b1220;
  color: #cbd5e1;
  font-size: 0.78rem;
  font-weight: 700;
  text-align: center;
  white-space: nowrap;
}

.settings-history-position.is-live {
  border-color: #0ea5e9;
  color: #e0f2fe;
  box-shadow: 0 0 0 1px rgba(14, 165, 233, 0.22);
}

.settings-history-btn:disabled {
  cursor: not-allowed;
  border-color: #334155;
  background: #0b1220;
  color: #64748b;
  box-shadow: none;
}

.settings-apply-btn {
  border-color: #10b981;
  background: #064e3b;
  color: #d1fae5;
}

.settings-apply-btn:hover {
  border-color: #34d399;
  background: #065f46;
  color: #ecfdf5;
}

.note-toggle--pause {
  min-width: 2.4rem;
  position: relative;
}

.note-toggle--pause::before {
  content: "";
  display: inline-block;
  width: 0.75rem;
  height: 0.75rem;
  border: 1px dashed #64748b;
  border-radius: 0.2rem;
}

.note-toggle--pause.is-active,
.note-toggle--pause[aria-pressed="true"] {
  border-color: #22d3ee;
  background: #164e63;
  box-shadow: 0 0 0 1px rgba(34, 211, 238, 0.28), 0 0 14px rgba(34, 211, 238, 0.16);
}

.note-toggle--pause.is-active::before,
.note-toggle--pause[aria-pressed="true"]::before {
  border-color: #a5f3fc;
  background: rgba(165, 243, 252, 0.28);
}

.note-toggle--pause:hover {
  border-color: #67e8f9;
}

.dead-note-toggle.is-active,
.dead-note-toggle[aria-pressed="true"] {
  border-color: #f59e0b;
  background: #78350f;
  color: #fde68a;
  box-shadow: 0 0 0 1px rgba(245, 158, 11, 0.35), 0 0 14px rgba(245, 158, 11, 0.18);
}

.delay-enabled-toggle {
  min-width: 3.35rem;
  padding: 0.3rem 0.55rem;
  font-size: 0.76rem;
}

.delay-enabled-toggle.is-active,
.delay-enabled-toggle[aria-pressed="true"] {
  border-color: #22c55e;
  background: #14532d;
  color: #dcfce7;
  box-shadow: 0 0 0 1px rgba(34, 197, 94, 0.35), 0 0 14px rgba(34, 197, 94, 0.16);
}

.delay-enabled-toggle:not(.is-active):not([aria-pressed="true"]) {
  border-color: #4b5563;
  background: #111827;
  color: #cbd5e1;
}

.pitch-shift-mode-toggle {
  min-width: 6.4rem;
}

.pitch-shift-mode-toggle.is-active,
.pitch-shift-mode-toggle[aria-pressed="true"] {
  border-color: #0ea5e9;
  background: #082f49;
  color: #e0f2fe;
  box-shadow: 0 0 0 1px rgba(14, 165, 233, 0.32), 0 0 14px rgba(14, 165, 233, 0.14);
}

.dead-note-toggle:hover {
  border-color: #fbbf24;
}

.dead-note-count-toggle.is-muted {
  opacity: 0.68;
  border-color: #4b5563;
  background: #111827;
  color: #94a3b8;
}

.dead-note-count-toggle:not(.is-muted) {
  border-color: #60a5fa;
  background: #1e3a8a;
  color: #dbeafe;
}

.dead-note-count-toggle:hover {
  border-color: #93c5fd;
}

.note-toggle {
  border: 1px solid #374151;
  background: #0b1220;
  color: #94a3b8;
  border-radius: 0.45rem;
  padding: 0.35rem 0;
  cursor: pointer;
  font-size: 0.85rem;
}

.note-toggle:hover {
  border-color: #60a5fa;
  color: #e5e7eb;
}

.note-toggle--pause {
  min-width: 2.4rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.note-toggle--pause::before {
  content: "";
  display: inline-block;
  width: 0.72rem;
  height: 0.72rem;
  border: 1px dashed #64748b;
  border-radius: 0.2rem;
}

.note-toggle--pause.is-active,
.note-toggle--pause[aria-pressed="true"] {
  border-color: #22d3ee;
  background: #164e63;
  color: #cffafe;
  box-shadow: 0 0 0 1px rgba(34, 211, 238, 0.28), 0 0 14px rgba(34, 211, 238, 0.16);
}

.note-toggle--pause.is-active::before,
.note-toggle--pause[aria-pressed="true"]::before {
  border-color: #a5f3fc;
  background: rgba(165, 243, 252, 0.28);
}

.settings-pause-note-toggle {
  flex: 0 0 2.7rem;
}

.note-toggle.is-in-key {
  border-color: #38bdf8;
  background: #0f2740;
  color: #dbeafe;
  box-shadow: 0 0 0 1px rgba(56, 189, 248, 0.28);
}

.note-toggle.is-active:not(.note-toggle--pause),
.note-toggle[aria-pressed="true"]:not(.note-toggle--pause) {
  background: #f59e0b;
  color: #1f2937;
  border-color: #fcd34d;
  box-shadow: 0 0 0 1px rgba(252, 211, 77, 0.5), 0 0 16px rgba(245, 158, 11, 0.35);
  font-weight: 700;
}

.note-toggle.is-in-key.is-active:not(.note-toggle--pause),
.note-toggle.is-in-key[aria-pressed="true"]:not(.note-toggle--pause) {
  background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 72%, #67e8f9 100%);
  color: #0f172a;
  border-color: #fef08a;
  box-shadow:
    inset 0 0 0 1px rgba(224, 242, 254, 0.32),
    0 0 0 1px rgba(254, 240, 138, 0.7),
    0 0 0 3px rgba(56, 189, 248, 0.24),
    0 0 18px rgba(245, 158, 11, 0.38),
    0 0 10px rgba(103, 232, 249, 0.18);
}

.note-toggle.is-disabled-row,
.note-toggle:disabled {
  cursor: not-allowed;
  border-color: #1f2937;
  background: #0a0f1a;
  color: #475569;
  box-shadow: none;
  opacity: 0.82;
}

.note-toggle.is-disabled-row:hover,
.note-toggle:disabled:hover {
  border-color: #1f2937;
  color: #475569;
}


.note-toggle:focus-visible {
  outline: 2px solid #93c5fd;
  outline-offset: 2px;
}

/* ==========================================================================
   Helper classes
   ========================================================================== */

/*
 * Hide visually and from screen readers
 */

.hidden,
[hidden] {
  display: none !important;
}

/*
 * Hide only visually, but have it available for screen readers:
 * https://snook.ca/archives/html_and_css/hiding-content-for-accessibility
 *
 * 1. For long content, line feeds are not interpreted as spaces and small width
 *    causes content to wrap 1 word per line:
 *    https://medium.com/@jessebeach/beware-smushed-off-screen-accessible-text-5952a4c2cbfe
 */

.visually-hidden {
  border: 0;
  clip: rect(0, 0, 0, 0);
  height: 1px;
  margin: -1px;
  overflow: hidden;
  padding: 0;
  position: absolute;
  white-space: nowrap;
  width: 1px;
  /* 1 */
}

/*
 * Extends the .visually-hidden class to allow the element
 * to be focusable when navigated to via the keyboard:
 * https://www.drupal.org/node/897638
 */

.visually-hidden.focusable:active,
.visually-hidden.focusable:focus {
  clip: auto;
  height: auto;
  margin: 0;
  overflow: visible;
  position: static;
  white-space: inherit;
  width: auto;
}

/*
 * Hide visually and from screen readers, but maintain layout
 */

.invisible {
  visibility: hidden;
}

/*
 * Clearfix: contain floats
 *
 * The use of `table` rather than `block` is only necessary if using
 * `::before` to contain the top-margins of child elements.
 */

.clearfix::before,
.clearfix::after {
  content: "";
  display: table;
}

.clearfix::after {
  clear: both;
}
