:root {
  --bg-base: #0b0e14;
  --bg-panel: #131822;
  --bg-panel-alt: #1a202c;
  --bg-elevated: #222a3a;
  --bg-input: #0e121a;
  --border-subtle: #263042;
  --border-focus: #6366f1;
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --accent-primary: #6366f1;
  --accent-primary-hover: #818cf8;
  --accent-secondary: #10b981;
  --accent-amber: #f59e0b;
  --accent-rose: #f43f5e;
  --accent-cyan: #06b6d4;
  --accent-purple: #a855f7;
  --sheet-bg: #fcfaf2;
  --sheet-ink: #18181b;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --shadow-lg: 0 10px 30px -5px rgba(0, 0, 0, 0.5);
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', Consolas, monospace;
}

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

body {
  background-color: var(--bg-base);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  overflow-x: hidden;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* TOP TRANSPORT & HEADER BAR */
.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 18px;
  background: linear-gradient(180deg, #171d2b 0%, #111620 100%);
  border-bottom: 1px solid var(--border-subtle);
  gap: 16px;
  flex-wrap: wrap;
  position: sticky;
  top: 0;
  z-index: 100;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-logo {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-cyan));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 18px;
  color: #fff;
  box-shadow: 0 0 16px rgba(99, 102, 241, 0.45);
}

.brand-title {
  font-weight: 700;
  font-size: 16px;
  letter-spacing: -0.02em;
}

.brand-subtitle {
  font-size: 11px;
  color: var(--text-secondary);
}

/* Transport Controls */
.transport-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-input);
  padding: 6px 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 13px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  background: var(--bg-elevated);
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}

.btn:hover {
  background: #2c364a;
  border-color: #3b4963;
}

.btn:active {
  transform: translateY(1px);
}

.btn-primary {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
  color: #fff;
}

.btn-primary:hover {
  background: var(--accent-primary-hover);
  border-color: var(--accent-primary-hover);
}

.btn-success {
  background: var(--accent-secondary);
  border-color: var(--accent-secondary);
  color: #052e16;
  font-weight: 600;
}

.btn-success:hover {
  background: #34d399;
}

.btn-amber {
  background: rgba(245, 158, 11, 0.16);
  border-color: rgba(245, 158, 11, 0.45);
  color: #fcd34d;
}

.btn-amber:hover {
  background: rgba(245, 158, 11, 0.28);
}

.btn-danger {
  background: rgba(244, 63, 94, 0.15);
  border-color: rgba(244, 63, 94, 0.4);
  color: #fda4af;
}

.btn-danger:hover {
  background: rgba(244, 63, 94, 0.28);
}

.btn-sm {
  padding: 4px 9px;
  font-size: 12px;
}

.btn-icon {
  width: 34px;
  height: 34px;
  padding: 0;
  border-radius: var(--radius-sm);
}

.btn-play.playing {
  background: var(--accent-rose);
  border-color: var(--accent-rose);
  color: white;
  box-shadow: 0 0 12px rgba(244, 63, 94, 0.5);
}

.transport-metric {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 8px;
  border-left: 1px solid var(--border-subtle);
  font-size: 12px;
  color: var(--text-secondary);
}

.transport-metric input,
.transport-metric select {
  background: var(--bg-panel);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  padding: 3px 6px;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 12px;
  width: 62px;
}

.transport-metric select {
  width: auto;
}

#oscilloscope {
  width: 110px;
  height: 30px;
  background: #080b10;
  border-radius: 4px;
  border: 1px solid var(--border-subtle);
}

/* MAIN WORKSPACE GRID */
.workspace {
  display: grid;
  grid-template-columns: 1.25fr 1fr;
  gap: 14px;
  padding: 14px;
  flex: 1;
  min-height: 0;
}

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

.column {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
}

.panel {
  background: var(--bg-panel);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--bg-panel-alt);
  border-bottom: 1px solid var(--border-subtle);
  gap: 10px;
  flex-wrap: wrap;
}

.panel-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 14px;
}

.badge {
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(99, 102, 241, 0.18);
  color: #a5b4fc;
  border: 1px solid rgba(99, 102, 241, 0.35);
  font-weight: 500;
}

.badge-green {
  background: rgba(16, 185, 129, 0.16);
  color: #6ee7b7;
  border-color: rgba(16, 185, 129, 0.35);
}

.panel-body {
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* SHEET MUSIC (NODEARK) STUDIO */
.sheet-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  padding: 8px 12px;
  background: var(--bg-input);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
}

.note-palette {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
}

.note-btn {
  padding: 4px 8px;
  font-size: 12px;
  font-family: var(--font-mono);
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  border-radius: 4px;
  cursor: pointer;
}

.note-btn.active {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
  color: #fff;
}

.note-btn:hover {
  border-color: var(--accent-primary-hover);
}

.sheet-split-container {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.sheet-split-container.has-reference {
  grid-template-columns: 1fr 1fr;
}

@media (max-width: 900px) {
  .sheet-split-container.has-reference {
    grid-template-columns: 1fr;
  }
}

.sheet-canvas-wrapper {
  background: var(--sheet-bg);
  color: var(--sheet-ink);
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  min-height: 230px;
  max-height: 440px;
  overflow-y: auto;
  border: 2px solid #d6d3c4;
  box-shadow: inset 0 2px 6px rgba(0,0,0,0.08);
  position: relative;
}

.sheet-canvas-wrapper svg {
  width: 100% !important;
  height: auto !important;
}

/* Highlight currently playing note in abcjs */
.abcjs-note_selected,
.abcjs-highlight {
  fill: #e11d48 !important;
  stroke: #e11d48 !important;
}

.abcjs-cursor {
  stroke: #6366f1;
  stroke-width: 2px;
}

/* Uploaded Sheet Music Reference Box */
.reference-sheet-box {
  background: var(--bg-input);
  border: 1px dashed var(--accent-cyan);
  border-radius: var(--radius-sm);
  padding: 10px;
  display: none;
  flex-direction: column;
  gap: 8px;
  max-height: 440px;
  overflow: auto;
}

.reference-sheet-box.visible {
  display: flex;
}

.reference-sheet-box img {
  width: 100%;
  height: auto;
  border-radius: 4px;
  object-fit: contain;
  background: #fff;
}

/* ABC Code Collapsible Drawer */
.abc-drawer {
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 10px;
}

.abc-textarea {
  width: 100%;
  min-height: 110px;
  background: #070a0f;
  color: #e2e8f0;
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
  padding: 8px 10px;
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.45;
  resize: vertical;
}

.abc-textarea:focus {
  outline: none;
  border-color: var(--accent-primary);
}

/* SECTIONS & CHORD PROGRESSION ARRANGER */
.section-strip {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.section-card {
  min-width: 155px;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 9px 11px;
  cursor: pointer;
  transition: all 0.15s ease;
  position: relative;
}

.section-card:hover {
  border-color: #475569;
}

.section-card.active {
  border-color: var(--accent-primary);
  background: rgba(99, 102, 241, 0.11);
  box-shadow: 0 0 0 1px var(--accent-primary);
}

.section-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 600;
  font-size: 12.5px;
  margin-bottom: 4px;
}

.section-chords-preview {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--accent-cyan);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.section-meta-preview {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 3px;
}

/* Chord Pills & Progression Builder */
.chord-slots {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.chord-slot {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  min-width: 68px;
  position: relative;
}

.chord-slot.active-bar {
  border-color: var(--accent-amber);
  background: rgba(245, 158, 11, 0.12);
}

.chord-slot-bar {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
}

.chord-slot-input {
  background: transparent;
  border: none;
  color: var(--accent-cyan);
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 14px;
  text-align: center;
  width: 60px;
}

.chord-slot-input:focus {
  outline: none;
  border-bottom: 1px solid var(--accent-cyan);
}

.chord-suggestions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.chord-chip {
  padding: 3px 8px;
  font-size: 11.5px;
  font-family: var(--font-mono);
  border-radius: 4px;
  background: rgba(6, 182, 212, 0.12);
  border: 1px solid rgba(6, 182, 212, 0.3);
  color: #67e8f9;
  cursor: pointer;
}

.chord-chip:hover {
  background: rgba(6, 182, 212, 0.25);
}

/* INTERACTIVE PIANO ROLL / STEP SEQUENCER */
.piano-roll-wrapper {
  background: #090c12;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  overflow-x: auto;
  overflow-y: auto;
  max-height: 280px;
}

.piano-roll-grid {
  display: grid;
  min-width: 640px;
  user-select: none;
}

.pr-row {
  display: grid;
  grid-template-columns: 56px repeat(16, 1fr);
  border-bottom: 1px solid #161d2a;
  height: 22px;
}

.pr-row.black-key {
  background: #0d121b;
}

.pr-row.root-key {
  background: rgba(99, 102, 241, 0.06);
}

.pr-key-label {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 8px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--text-secondary);
  background: #121722;
  border-right: 2px solid var(--border-subtle);
  cursor: pointer;
}

.pr-key-label.black {
  background: #090b10;
  color: var(--text-muted);
}

.pr-key-label:hover {
  color: #fff;
  background: var(--accent-primary);
}

.pr-cell {
  border-right: 1px solid #151c28;
  cursor: pointer;
  position: relative;
  transition: background 0.08s;
}

.pr-cell:nth-child(4n+1) {
  border-right: 1px solid #2a364f;
}

.pr-cell:hover {
  background: rgba(99, 102, 241, 0.22);
}

.pr-cell.active {
  background: linear-gradient(90deg, var(--accent-primary), var(--accent-cyan));
  border-radius: 3px;
  box-shadow: 0 0 8px rgba(99, 102, 241, 0.5);
}

.pr-cell.playing-step {
  box-shadow: inset 0 0 0 1px var(--accent-amber);
  background: rgba(245, 158, 11, 0.18);
}

.pr-cell.active.playing-step {
  background: var(--accent-amber);
}

/* TABS */
.tabs {
  display: flex;
  gap: 4px;
  background: var(--bg-input);
  padding: 4px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
}

.tab-btn {
  flex: 1;
  padding: 6px 10px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-secondary);
  background: transparent;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s;
}

.tab-btn.active {
  background: var(--bg-elevated);
  color: var(--text-primary);
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

.tab-pane {
  display: none;
  flex-direction: column;
  gap: 12px;
}

.tab-pane.active {
  display: flex;
}

/* CONTROLS & KNOBS / SLIDERS */
.control-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
}

.control-group {
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 9px 11px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.control-label {
  display: flex;
  justify-content: space-between;
  font-size: 11.5px;
  color: var(--text-secondary);
}

.control-value {
  font-family: var(--font-mono);
  color: var(--accent-cyan);
}

input[type="range"] {
  width: 100%;
  accent-color: var(--accent-primary);
  cursor: pointer;
}

input[type="text"],
select,
textarea {
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  font-family: var(--font-sans);
  font-size: 13px;
}

input[type="text"]:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent-primary);
}

/* AI BRIDGE & PROMPT STUDIO */
.ai-task-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

@media (max-width: 640px) {
  .ai-task-grid {
    grid-template-columns: 1fr;
  }
}

.ai-task-card {
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 9px 11px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 3px;
  transition: all 0.15s;
}

.ai-task-card:hover {
  border-color: var(--accent-primary);
}

.ai-task-card.active {
  border-color: var(--accent-primary);
  background: rgba(99, 102, 241, 0.14);
}

.ai-task-title {
  font-weight: 600;
  font-size: 12.5px;
  color: var(--text-primary);
}

.ai-task-desc {
  font-size: 11px;
  color: var(--text-secondary);
}

.prompt-output-box {
  width: 100%;
  min-height: 210px;
  background: #070a0f;
  color: #cbd5e1;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.5;
  resize: vertical;
}

/* Dropzone for Nodeark upload */
.upload-dropzone {
  border: 1.5px dashed var(--accent-cyan);
  background: rgba(6, 182, 212, 0.05);
  border-radius: var(--radius-sm);
  padding: 12px;
  text-align: center;
  cursor: pointer;
  transition: all 0.15s;
}

.upload-dropzone:hover,
.upload-dropzone.dragover {
  background: rgba(6, 182, 212, 0.14);
  border-color: #22d3ee;
}

.toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: var(--bg-elevated);
  border: 1px solid var(--accent-secondary);
  color: var(--text-primary);
  padding: 10px 16px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  font-size: 13px;
  z-index: 999;
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: all 0.2s ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.row-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.tag-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag-pill {
  padding: 4px 9px;
  border-radius: 999px;
  font-size: 11.5px;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  cursor: pointer;
}

.tag-pill.active {
  background: rgba(168, 85, 247, 0.2);
  border-color: var(--accent-purple);
  color: #e9d5ff;
}
