/* FL Studio Web — Studio Music */
:root {
  --fl-bg-dark: #1a1a1a;
  --fl-bg: #2b2b2b;
  --fl-bg-light: #383838;
  --fl-bg-lighter: #454545;
  --fl-border: #1e1e1e;
  --fl-border-light: #555;
  --fl-orange: #ff8c00;
  --fl-orange-bright: #ffa500;
  --fl-orange-dim: #cc7000;
  --fl-text: #ccc;
  --fl-text-dim: #888;
  --fl-text-bright: #eee;
  --fl-green: #4caf50;
  --fl-red: #e53935;
  --fl-blue: #42a5f5;
  --fl-selected: #ff8c00;
  --fl-step-on: #ff8c00;
  --fl-step-active: #fff;
  --fl-grid: #333;
  --fl-grid-bar: #444;
  --fl-fader: #666;
  --fl-header-h: 22px;
  --fl-transport-h: 36px;
  --fl-status-h: 20px;
  --fl-mixer-h: 180px;
  --fl-browser-w: 220px;
  --fl-channel-h: 200px;
  --font: 'Segoe UI', Tahoma, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  overflow: hidden;
  font-family: var(--font);
  font-size: 12px;
  color: var(--fl-text);
  background: var(--fl-bg-dark);
  user-select: none;
}

.hidden { display: none !important; }

/* Splash */
.splash {
  position: fixed; inset: 0;
  background: linear-gradient(135deg, #1a1a1a 0%, #2b2b2b 50%, #1a1a1a 100%);
  display: flex; align-items: center; justify-content: center;
  z-index: 9999;
}
.splash-inner { text-align: center; }
.splash-logo {
  width: 80px; height: 80px;
  background: var(--fl-orange);
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 32px; font-weight: 700; color: #000;
  margin: 0 auto 1rem;
  box-shadow: 0 0 40px rgba(255,140,0,0.4);
}
.splash h1 { font-size: 1.8rem; color: var(--fl-text-bright); margin-bottom: 0.25rem; }
.splash p { color: var(--fl-text-dim); margin-bottom: 1.5rem; }
.splash-btn {
  background: var(--fl-orange); color: #000; border: none;
  padding: 0.6rem 2rem; font-size: 14px; font-weight: 600;
  border-radius: 4px; cursor: pointer; transition: background 0.15s;
}
.splash-btn:hover { background: var(--fl-orange-bright); }
.splash-hint { margin-top: 1rem; font-size: 11px; color: var(--fl-text-dim); }

/* App Layout */
.app {
  display: grid;
  grid-template-rows: var(--fl-header-h) var(--fl-transport-h) 1fr var(--fl-mixer-h) var(--fl-status-h);
  height: 100vh;
}

/* Menu Bar */
.menu-bar {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--fl-bg-dark);
  border-bottom: 1px solid var(--fl-border);
  padding: 0 8px;
  font-size: 11px;
}
.menu-items { display: flex; gap: 2px; }
.menu-item {
  padding: 2px 8px; cursor: pointer; border-radius: 2px;
  color: var(--fl-text-dim);
}
.menu-item:hover { background: var(--fl-bg-light); color: var(--fl-text); }
.menu-right { display: flex; gap: 16px; align-items: center; }
.project-name { color: var(--fl-orange); font-weight: 600; }
.cpu-meter { color: var(--fl-text-dim); font-size: 10px; }

/* Transport */
.transport-bar {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--fl-bg);
  border-bottom: 1px solid var(--fl-border);
  padding: 0 8px;
}
.transport-left, .transport-right { display: flex; align-items: center; gap: 4px; }
.tbtn {
  width: 28px; height: 28px;
  background: var(--fl-bg-light); border: 1px solid var(--fl-border);
  color: var(--fl-text); font-size: 12px;
  cursor: pointer; border-radius: 3px;
  display: flex; align-items: center; justify-content: center;
}
.tbtn:hover { background: var(--fl-bg-lighter); }
.tbtn-play { color: var(--fl-green); font-size: 14px; }
.tbtn-play.playing { color: var(--fl-orange); }
#btn-record { color: var(--fl-red); }
.tbtn-mode { width: 36px; font-size: 10px; font-weight: 600; }
.tbtn-mode.active { background: var(--fl-orange); color: #000; border-color: var(--fl-orange-dim); }
.transport-divider { width: 1px; height: 20px; background: var(--fl-border-light); margin: 0 4px; }
.bpm-control {
  display: flex; align-items: center; gap: 4px; font-size: 11px;
}
.bpm-control input {
  width: 48px; background: var(--fl-bg-dark); border: 1px solid var(--fl-border-light);
  color: var(--fl-orange); text-align: center; padding: 2px 4px; border-radius: 2px;
  font-family: var(--font); font-size: 12px; font-weight: 600;
}
.time-display {
  font-family: 'Courier New', monospace; font-size: 13px;
  color: var(--fl-orange-bright); min-width: 70px; text-align: center;
  background: var(--fl-bg-dark); padding: 2px 8px; border-radius: 2px;
  border: 1px solid var(--fl-border);
}
.pattern-selector { display: flex; align-items: center; gap: 4px; }
.pat-btn {
  background: var(--fl-bg-light); border: 1px solid var(--fl-border);
  color: var(--fl-text); width: 22px; height: 22px; cursor: pointer; border-radius: 2px;
  font-size: 10px;
}
.pat-label { font-size: 11px; min-width: 70px; text-align: center; }
.pat-label strong { color: var(--fl-orange); }
.snap-control { display: flex; align-items: center; gap: 4px; font-size: 11px; }
.snap-control select {
  background: var(--fl-bg-dark); border: 1px solid var(--fl-border-light);
  color: var(--fl-text); padding: 2px 4px; border-radius: 2px; font-size: 11px;
}

/* Workspace */
.workspace {
  display: flex; overflow: hidden;
  min-height: 0;
}
.center-area {
  flex: 1; display: flex; flex-direction: column;
  min-width: 0; overflow: hidden;
}

/* Panels */
.panel {
  display: flex; flex-direction: column;
  background: var(--fl-bg);
  border: 1px solid var(--fl-border);
  overflow: hidden;
}
.panel-header {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--fl-bg-dark);
  border-bottom: 1px solid var(--fl-border);
  padding: 2px 8px;
  font-size: 11px; font-weight: 600;
  color: var(--fl-text-dim);
  min-height: 22px;
  flex-shrink: 0;
}
.panel-toggle {
  background: none; border: none; color: var(--fl-text-dim);
  cursor: pointer; font-size: 14px; padding: 0 4px;
}
.panel-toggle:hover { color: var(--fl-text); }
.panel-body { flex: 1; overflow: hidden; min-height: 0; }
.panel-tabs { display: flex; gap: 2px; margin-left: auto; margin-right: 8px; }
.ptab {
  background: var(--fl-bg-light); border: 1px solid var(--fl-border);
  color: var(--fl-text-dim); padding: 1px 8px; font-size: 10px;
  cursor: pointer; border-radius: 2px 2px 0 0;
}
.ptab.active { background: var(--fl-bg); color: var(--fl-orange); border-bottom-color: var(--fl-bg); }

/* Browser */
.browser-panel {
  width: var(--fl-browser-w); flex-shrink: 0;
  border-right: none;
}
.browser-search { padding: 4px; }
.browser-search input {
  width: 100%; background: var(--fl-bg-dark); border: 1px solid var(--fl-border-light);
  color: var(--fl-text); padding: 3px 6px; border-radius: 2px; font-size: 11px;
}
.browser-tree { overflow-y: auto; height: 100%; padding: 2px 0; }
.browser-folder {
  padding: 2px 8px; cursor: pointer; font-size: 11px;
  display: flex; align-items: center; gap: 4px;
}
.browser-folder:hover { background: var(--fl-bg-light); }
.browser-folder.open > .browser-children { display: block; }
.browser-folder-icon { font-size: 10px; width: 12px; }
.browser-children { display: none; padding-left: 16px; }
.browser-item {
  padding: 2px 8px; cursor: pointer; font-size: 11px;
  display: flex; align-items: center; gap: 4px;
}
.browser-item:hover { background: var(--fl-orange-dim); color: #000; }
.browser-item.selected { background: var(--fl-orange); color: #000; }

/* Playlist */
.playlist-panel { flex: 1; min-height: 0; }
.playlist-toolbar, .pianoroll-toolbar {
  display: flex; align-items: center; gap: 2px;
  padding: 2px 4px; background: var(--fl-bg-dark);
  border-bottom: 1px solid var(--fl-border);
}
.tool-btn {
  background: var(--fl-bg-light); border: 1px solid var(--fl-border);
  color: var(--fl-text-dim); padding: 2px 8px; font-size: 11px;
  cursor: pointer; border-radius: 2px;
}
.tool-btn:hover, .tool-btn.active { background: var(--fl-bg-lighter); color: var(--fl-text); }
.zoom-control { margin-left: auto; display: flex; align-items: center; gap: 4px; font-size: 10px; }
.zoom-control button {
  background: var(--fl-bg-light); border: 1px solid var(--fl-border);
  color: var(--fl-text); width: 20px; height: 20px; cursor: pointer; border-radius: 2px;
}
.playlist-scroll, .pianoroll-scroll {
  overflow: auto; height: 100%; position: relative;
}
.playlist-scroll canvas, .pianoroll-scroll canvas {
  display: block;
}

/* Channel Rack */
.channel-rack-panel {
  height: var(--fl-channel-h); flex-shrink: 0;
  border-top: none;
}
.channel-rack-body { overflow: auto; }
.channel-row {
  display: flex; align-items: center;
  height: 28px; border-bottom: 1px solid var(--fl-border);
}
.channel-row:hover { background: rgba(255,140,0,0.05); }
.channel-row.selected { background: rgba(255,140,0,0.12); }
.channel-info {
  width: 140px; flex-shrink: 0;
  display: flex; align-items: center; gap: 4px;
  padding: 0 4px; overflow: hidden;
}
.channel-color {
  width: 4px; height: 20px; border-radius: 1px; flex-shrink: 0;
}
.channel-name {
  font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  flex: 1; cursor: pointer;
}
.channel-name:hover { color: var(--fl-orange); }
.channel-mute, .channel-solo {
  width: 18px; height: 16px; font-size: 9px; font-weight: 700;
  border: 1px solid var(--fl-border); background: var(--fl-bg-dark);
  color: var(--fl-text-dim); cursor: pointer; border-radius: 2px;
  display: flex; align-items: center; justify-content: center;
}
.channel-mute.active { background: var(--fl-orange); color: #000; }
.channel-solo.active { background: var(--fl-green); color: #000; }
.step-grid {
  display: flex; flex: 1; gap: 1px; padding: 2px 4px;
}
.step {
  flex: 1; min-width: 14px; max-width: 28px; height: 20px;
  background: var(--fl-bg-dark); border: 1px solid var(--fl-border);
  border-radius: 2px; cursor: pointer; transition: background 0.05s;
}
.step:hover { border-color: var(--fl-border-light); }
.step.on { background: var(--fl-step-on); border-color: var(--fl-orange-dim); }
.step.on.alt { background: var(--fl-orange-dim); }
.step.playhead { box-shadow: inset 0 0 0 2px var(--fl-step-active); }
.step.beat { border-left-color: var(--fl-border-light); }

/* Mixer */
.mixer-panel {
  border-top: none;
  height: var(--fl-mixer-h);
}
.mixer-body {
  display: flex; overflow-x: auto; overflow-y: hidden;
  padding: 4px; gap: 2px;
}
.mixer-strip {
  width: 56px; flex-shrink: 0;
  display: flex; flex-direction: column; align-items: center;
  background: var(--fl-bg-dark);
  border: 1px solid var(--fl-border);
  border-radius: 3px;
  padding: 4px 2px;
}
.mixer-strip.master { width: 64px; border-color: var(--fl-orange-dim); }
.strip-label {
  font-size: 9px; color: var(--fl-text-dim);
  text-align: center; width: 100%;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  margin-bottom: 2px;
}
.strip-fader-wrap {
  flex: 1; width: 24px; position: relative;
  display: flex; justify-content: center;
}
.strip-fader {
  -webkit-appearance: slider-vertical;
  appearance: slider-vertical;
  width: 24px; height: 100%;
  cursor: pointer;
  writing-mode: vertical-lr;
  direction: rtl;
}
.strip-pan {
  width: 40px; height: 16px; margin: 2px 0;
  -webkit-appearance: none; appearance: none;
  background: var(--fl-bg-light); border-radius: 2px;
  cursor: pointer;
}
.strip-pan::-webkit-slider-thumb {
  -webkit-appearance: none; width: 8px; height: 14px;
  background: var(--fl-orange); border-radius: 1px; cursor: pointer;
}
.strip-buttons { display: flex; gap: 2px; margin-top: 2px; }
.strip-btn {
  width: 18px; height: 14px; font-size: 8px; font-weight: 700;
  border: 1px solid var(--fl-border); background: var(--fl-bg);
  color: var(--fl-text-dim); cursor: pointer; border-radius: 2px;
}
.strip-btn.m-active { background: var(--fl-orange); color: #000; }
.strip-btn.s-active { background: var(--fl-green); color: #000; }
.strip-meter {
  width: 6px; height: 60px; background: var(--fl-bg);
  border: 1px solid var(--fl-border); border-radius: 1px;
  position: relative; overflow: hidden; margin: 2px 0;
}
.strip-meter-fill {
  position: absolute; bottom: 0; left: 0; right: 0;
  background: linear-gradient(to top, var(--fl-green), var(--fl-orange), var(--fl-red));
  transition: height 0.05s;
}

/* Status Bar */
.status-bar {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--fl-bg-dark);
  border-top: 1px solid var(--fl-border);
  padding: 0 8px; font-size: 10px; color: var(--fl-text-dim);
}
.status-right { display: flex; gap: 12px; }

/* Context Menu */
.ctx-menu {
  position: fixed; z-index: 10000;
  background: var(--fl-bg-light); border: 1px solid var(--fl-border-light);
  border-radius: 3px; padding: 2px 0; min-width: 160px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.5);
}
.ctx-item {
  padding: 4px 16px; font-size: 11px; cursor: pointer;
}
.ctx-item:hover { background: var(--fl-orange); color: #000; }
.ctx-sep { height: 1px; background: var(--fl-border); margin: 2px 0; }

/* Scrollbars */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--fl-bg-dark); }
::-webkit-scrollbar-thumb { background: var(--fl-bg-lighter); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #555; }

/* Modal */
.modal { position: fixed; inset: 0; z-index: 20000; display: flex; align-items: center; justify-content: center; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,0.6); }
.modal-box {
  position: relative; background: var(--fl-bg); border: 1px solid var(--fl-border-light);
  border-radius: 6px; width: 480px; max-width: 90vw; max-height: 80vh;
  display: flex; flex-direction: column; box-shadow: 0 8px 32px rgba(0,0,0,0.6);
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px; border-bottom: 1px solid var(--fl-border);
  background: var(--fl-bg-dark);
}
.modal-header h2 { font-size: 14px; color: var(--fl-text-bright); font-weight: 600; }
.modal-close {
  background: none; border: none; color: var(--fl-text-dim); font-size: 16px; cursor: pointer;
}
.modal-close:hover { color: var(--fl-text); }
.modal-body { padding: 14px; overflow-y: auto; flex: 1; }
.modal-actions { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.modal-btn {
  background: var(--fl-bg-light); border: 1px solid var(--fl-border-light);
  color: var(--fl-text); padding: 6px 14px; font-size: 11px; cursor: pointer; border-radius: 3px;
}
.modal-btn:hover { background: var(--fl-bg-lighter); }
.modal-btn.primary { background: var(--fl-orange); color: #000; border-color: var(--fl-orange-dim); font-weight: 600; }
.modal-btn.primary:hover { background: var(--fl-orange-bright); }
.modal-btn.danger { color: var(--fl-red); }
.modal-btn.danger:hover { background: rgba(229,57,53,0.15); }
.project-list { list-style: none; }
.project-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 10px; border-radius: 3px; cursor: pointer; font-size: 12px;
  border: 1px solid transparent;
}
.project-item:hover { background: var(--fl-bg-light); border-color: var(--fl-border); }
.project-item.active { background: rgba(255,140,0,0.12); border-color: var(--fl-orange-dim); }
.project-item-info { flex: 1; }
.project-item-name { color: var(--fl-text-bright); font-weight: 500; }
.project-item-date { color: var(--fl-text-dim); font-size: 10px; margin-top: 2px; }
.project-item-actions { display: flex; gap: 4px; }
.project-item-actions button {
  background: none; border: none; color: var(--fl-text-dim); cursor: pointer; font-size: 11px; padding: 2px 6px;
}
.project-item-actions button:hover { color: var(--fl-orange); }
.modal-field { margin-bottom: 12px; }
.modal-field label { display: block; font-size: 11px; color: var(--fl-text-dim); margin-bottom: 4px; }
.modal-field input {
  width: 100%; background: var(--fl-bg-dark); border: 1px solid var(--fl-border-light);
  color: var(--fl-text); padding: 6px 10px; border-radius: 3px; font-size: 12px;
}
.modal-empty { text-align: center; color: var(--fl-text-dim); padding: 24px; font-size: 12px; }

/* Responsive collapse */
@media (max-width: 900px) {
  :root {
    --fl-browser-w: 160px;
    --fl-mixer-h: 140px;
    --fl-channel-h: 160px;
  }
}
