/**
 * BLIP — Main Styles
 * Base structure, will be refined with style guide
 */

/* ============================================
   RESET & BASE
   ============================================ */

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: #0e0e0e;
  color: #d0d0d0;
  line-height: 1.6;
  overflow: hidden;
  min-width: 1440px;
}

/* ============================================
   TOP BAR
   ============================================ */

.topbar {
  height: 80px;
  background: #1a1a1a;
  border-bottom: 2px solid #2a2a2a;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  padding: 0 24px;
  gap: 24px;
}

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

.topbar__logo {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  transition: transform 0.3s ease;
}

.topbar__logo-ascii {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 40px;
  transition: transform 0.3s ease;
}

.topbar__logo-ascii svg {
  height: 100%;
  width: auto;
  color: #d4a574;
  filter: drop-shadow(0 2px 4px rgba(212, 165, 116, 0.3));
}

.topbar__logo-ascii rect {
  transition: transform 0.1s ease-out;
}

.topbar__logo-ascii:hover {
  transform: translateY(-2px);
}

.topbar__logo-ascii:hover svg {
  color: #e0b585;
  filter: drop-shadow(0 2px 6px rgba(212, 165, 116, 0.5));
}

.topbar__logo:hover {
  transform: translateY(-2px);
}

.topbar__logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 2px 4px rgba(212, 165, 116, 0.3));
}

.topbar__logo svg {
  filter: drop-shadow(0 2px 4px rgba(255, 255, 255, 0.2));
}

.topbar__brand {
  font-size: 18px;
  font-weight: 600;
  color: #f0f0f0;
}

.topbar__separator {
  color: #555;
}

.topbar__subtitle {
  font-size: 14px;
  color: #888;
}

.topbar__center {
  flex: 1;
  max-width: 400px;
}

.topbar__project-name {
  width: 100%;
  background: #252525;
  border: 1px solid #333;
  color: #f0f0f0;
  padding: 8px 12px;
  border-radius: 4px;
  font-size: 14px;
  text-align: center;
}

.topbar__project-name:focus {
  outline: none;
  border-color: #555;
}

.topbar__right {
  display: flex;
  gap: 12px;
}

.topbar__template-select {
  background: #252525;
  border: 1px solid #333;
  color: #f0f0f0;
  padding: 8px 12px;
  border-radius: 4px;
  font-size: 14px;
  cursor: pointer;
}

/* ============================================
   AUDIO INIT OVERLAY
   ============================================ */

.audio-init-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.95);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.audio-init-card {
  background: #1a1a1a;
  border: 2px solid #d4a574;
  border-radius: 12px;
  padding: 48px;
  text-align: center;
  max-width: 400px;
}

.audio-init-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 32px;
}

.audio-init-logo svg {
  height: 64px;
  width: auto;
  color: #d4a574;
  filter: drop-shadow(0 4px 8px rgba(212, 165, 116, 0.4));
}

.audio-init-logo rect {
  transition: transform 0.1s ease-out;
}

.audio-init-password {
  margin: 0 auto 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  text-align: left;
}

.audio-init-password label {
  color: #f0f0f0;
  font-size: 14px;
}

.audio-init-password input {
  width: 100%;
  background: #0d0d0d;
  border: 1px solid #333;
  color: #f0f0f0;
  padding: 12px 14px;
  border-radius: 10px;
  font-size: 14px;
}

.audio-init-message {
  min-height: 20px;
  color: #f08f8f;
  font-size: 14px;
  margin-bottom: 12px;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.audio-init-card p {
  font-size: 16px;
  color: #aaa;
  margin-bottom: 32px;
}

.btn--large {
  padding: 16px 32px;
  font-size: 16px;
}

/* ============================================
   LAYOUT
   ============================================ */

.layout {
  display: grid;
  grid-template-columns: 320px 1fr 320px;
  height: calc(100vh - 80px);
  overflow: hidden;
}

/* ============================================
   LEFT SIDEBAR: Quick Presets
   ============================================ */

.left-sidebar {
  background: #1a1a1a;
  border-right: 1px solid #2a2a2a;
  padding: 20px 16px 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.presets-scroll-area {
  flex: 1;
  overflow-y: auto;
  padding-bottom: 20px;
}

/* Variants section in left sidebar - LOCKED (non-scrolling) */
.left-variants {
  padding-bottom: 16px;
  margin-bottom: 16px;
  border-bottom: 1px solid #2a2a2a;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-shrink: 0; /* Prevent shrinking */
}

.variants-controls {
  display: flex;
  gap: 8px;
  align-items: center;
}

.variants__list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 200px; /* Limit height to prevent taking too much space */
  overflow-y: auto;
  padding-right: 4px;
}

/* Scrollbar styling for variants list */
.variants__list::-webkit-scrollbar {
  width: 6px;
}

.variants__list::-webkit-scrollbar-track {
  background: #1a1a1a;
  border-radius: 3px;
}

.variants__list::-webkit-scrollbar-thumb {
  background: #3a3a3a;
  border-radius: 3px;
}

.variants__list::-webkit-scrollbar-thumb:hover {
  background: #4a4a4a;
}

.btn--variants-toggle {
  padding: 6px 10px;
  background: #222;
  border: 1px solid #3a3a3a;
  color: #777;
  border-radius: 6px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.05em;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: all 0.2s;
}

.btn--variants-toggle:hover {
  background: #2a2a2a;
  border-color: #555;
  color: #aaa;
}

.btn--variants {
  flex: 1;
  padding: 10px 16px;
  background: #4a3a6a;
  border: 1px solid #6a4fa0;
  color: #c0a8e8;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
}

.btn--variants:hover {
  background: #5a4a80;
  border-color: #8060c0;
  color: #d4b8f8;
}

.btn--variants.generating {
  background: #9d8ec7;
  border-color: #9d8ec7;
  color: #1a1a1a;
}

/* Playback Controls in Sidebar */
.playback-controls {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
  padding-bottom: 20px;
  border-bottom: 1px solid #2a2a2a;
}

.playback-btn {
  flex: 1;
  height: 60px;
  background: #2a2a2a;
  border: 2px solid #3a3a3a;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #888;
}

.playback-btn:hover {
  background: #333;
  border-color: #4a4a4a;
  color: #bbb;
  transform: translateY(-1px);
}

.playback-btn:active {
  transform: scale(0.95) translateY(0);
}

.playback-btn--active-play {
  background: #4a8f4d !important;
  border-color: #6fbf73 !important;
  color: #fff !important;
  box-shadow: 0 4px 16px rgba(111, 191, 115, 0.5);
  transform: scale(1.05);
}

.playback-btn--active-loop {
  background: #5a7fb8 !important;
  border-color: #7ba3d4 !important;
  color: #fff !important;
  box-shadow: 0 4px 16px rgba(123, 163, 212, 0.5);
  animation: pulse-loop 2s infinite;
}

@keyframes pulse-loop {
  0%, 100% { 
    opacity: 1;
    box-shadow: 0 4px 16px rgba(123, 163, 212, 0.5);
  }
  50% { 
    opacity: 0.9;
    box-shadow: 0 6px 20px rgba(123, 163, 212, 0.7);
  }
}

.quick-presets {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.quick-presets h3 {
  font-size: 14px;
  font-weight: 600;
  color: #f0f0f0;
  margin-bottom: 8px;
  text-align: center;
}

.preset-select {
  width: 100%;
  background: #1e1e1e;
  border: 1px solid #333;
  color: #ccc;
  padding: 9px 28px 9px 11px;
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23666'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  transition: border-color 0.2s, color 0.2s;
}

.preset-select:hover {
  border-color: #555;
  color: #eee;
}

.preset-select:focus {
  outline: none;
}

.preset-select option,
.preset-select optgroup {
  background: #1e1e1e;
  color: #ccc;
}

.preset-select--texture:focus,
.preset-select--texture:hover { border-color: #d4a574; }

.preset-select--auto:focus,
.preset-select--auto:hover { border-color: #d4a574; }

.preset-select--phone:focus,
.preset-select--phone:hover { border-color: #7ba3d4; }

.preset-select--home:focus,
.preset-select--home:hover { border-color: #8fb694; }

/* Preset Categories */
.preset-category {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 0;
  border-top: 1px solid #333;
}

.preset-category:first-of-type {
  border-top: none;
  padding-top: 0;
}

.preset-category__label {
  font-size: 11px;
  font-weight: 700;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 0 4px;
  margin-bottom: 2px;
}

.preset-category--auto .preset-category__label {
  color: #d4a574;
}

.preset-category--phone .preset-category__label {
  color: #7ba3d4;
}

.preset-category--home .preset-category__label {
  color: #8fb694;
}

.preset-category--saved .preset-category__label {
  color: #6fc4c0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.dice-btn {
  background: none;
  border: none;
  font-size: 14px;
  cursor: pointer;
  padding: 0 2px;
  line-height: 1;
  opacity: 0.6;
  transition: opacity 0.15s;
  flex-shrink: 0;
}

.dice-btn:hover {
  opacity: 1;
}

@keyframes dice-spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

.dice-btn--spin {
  animation: dice-spin 0.35s ease-out forwards;
}

.save-row {
  display: flex;
  gap: 6px;
}

.save-input {
  flex: 1;
  min-width: 0;
  background: #1e1e1e;
  border: 1px solid #333;
  color: #ddd;
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 12px;
  outline: none;
  transition: border-color 0.2s;
}

.save-input:focus {
  border-color: #6fc4c0;
}

.save-input::placeholder {
  color: #4a4a4a;
}

.save-btn {
  padding: 8px 12px;
  background: #6fc4c0;
  border: none;
  color: #111;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.2s;
  flex-shrink: 0;
}

.save-btn:hover { background: #82d0cc; }
.save-btn:active { background: #5ab8b4; }

.load-row {
  display: flex;
  gap: 6px;
  align-items: stretch;
}

.load-row .preset-select {
  flex: 1;
  min-width: 0;
}

.delete-btn {
  width: 32px;
  background: #1e1e1e;
  border: 1px solid #333;
  color: #666;
  border-radius: 6px;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: border-color 0.2s, color 0.2s;
}

.delete-btn:hover {
  border-color: #c96060;
  color: #c96060;
}

/* Export/Import Row */
.export-import-row {
  display: flex;
  gap: 6px;
  margin-top: 6px;
}

.export-btn,
.import-btn {
  flex: 1;
  padding: 8px 12px;
  background: #2a2a2a;
  border: 1px solid #3a3a3a;
  color: #d0d0d0;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

.export-btn:hover,
.import-btn:hover {
  background: #333;
  border-color: #d4a574;
  color: #d4a574;
}

.export-btn:active,
.import-btn:active {
  background: #252525;
}

.preset-select--saved:focus,
.preset-select--saved:hover { border-color: #6fc4c0; }

/* Sequence Presets Section */
.seq-presets {
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid #2a2a2a;
}

.seq-presets h3 {
  font-size: 14px;
  font-weight: 600;
  color: #f0f0f0;
  margin-bottom: 8px;
  text-align: center;
}

.seq-presets .preset-category {
  border-top: none;
  padding-top: 0;
}

.seq-presets .preset-category__label {
  color: #9d8ec7;
}

.preset-select--seq:focus,
.preset-select--seq:hover { border-color: #9d8ec7; }

/* ============================================
   CENTER: Function Editor
   ============================================ */

.center {
  padding: 24px;
  overflow-y: auto;
  background: #0e0e0e;
  display: flex;
  justify-content: center;
}

.center__content {
  width: 100%;
  padding: 0 8px;
  box-sizing: border-box;
}

.modules-container {
  width: 100%;
  zoom: 1.1;
}

.center__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}

.center__header h2 {
  font-size: 20px;
  font-weight: 600;
  color: #f0f0f0;
}

/* ============================================
   SEQUENCER
   ============================================ */

.sequencer {
  background: #1a1a1a;
  border: 1px solid #2a2a2a;
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 24px;
}

.sequencer__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.sequencer__header h3 {
  font-size: 16px;
  font-weight: 600;
  color: #f0f0f0;
}

.sequencer__controls {
  display: flex;
  gap: 20px;
  align-items: center;
  margin-bottom: 20px;
  flex-wrap: nowrap;
}

.sequencer__controls label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: #aaa;
  position: relative; /* For absolute positioning of warning */
}

.sequencer__controls select {
  background: #252525;
  border: 1px solid #333;
  color: #f0f0f0;
  padding: 6px 10px;
  border-radius: 4px;
  font-size: 13px;
  cursor: pointer;
}

.sequencer__controls select:hover {
  border-color: #555;
}

.sequencer__controls input[type="range"] {
  width: 100px;
  height: 4px;
  background: #333;
  border-radius: 2px;
  outline: none;
  -webkit-appearance: none;
}

.sequencer__controls input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  background: #d4a574;
  border-radius: 50%;
  cursor: pointer;
}

.sequencer__controls input[type="range"]::-moz-range-thumb {
  width: 14px;
  height: 14px;
  background: #d4a574;
  border-radius: 50%;
  cursor: pointer;
  border: none;
}

.sequencer__grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(50px, 1fr));
  gap: 8px;
  max-width: 100%;
}

.sequencer__step {
  background: #252525;
  border: 2px solid #333;
  border-radius: 6px;
  padding: 10px 8px;
  cursor: default;
  transition: transform 0.2s;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 120px;
  position: relative;
}

.sequencer__step:hover {
  transform: translateY(-2px);
}

.sequencer__step--active {
  background: #d4a574;
  border-color: #d4a574;
  color: #1a1a1a;
  box-shadow: 0 4px 12px rgba(212, 165, 116, 0.3);
}

.sequencer__step-number {
  font-size: 12px;
  font-weight: 600;
  text-align: center;
  opacity: 0.7;
  cursor: cell;
  padding: 4px;
  border-radius: 3px;
  transition: background 0.2s, opacity 0.2s;
  user-select: none;
}

.sequencer__step-number:hover {
  background: rgba(255, 255, 255, 0.15);
  opacity: 1;
}

/* Clickable edges */
.sequencer__step-edge {
  position: absolute;
  top: 0;
  bottom: 20%;
  width: 30px;
  cursor: cell;
  transition: background 0.2s;
  z-index: 10;
  border-radius: 6px;
}

.sequencer__step-edge--left {
  left: 0;
}

.sequencer__step-edge--right {
  right: 0;
}

.sequencer__step-edge:hover {
  background: rgba(255, 255, 255, 0.08);
}

/* Note Selection Knob */
.sequencer__step-knob-container {
  display: flex;
  justify-content: center;
  align-items: center;
  flex: 1;
  padding: 12px 0;
  cursor: default;
  pointer-events: auto;
}

.knob--note .knob__fill {
  stroke: #7ba3d4;
}

.knob--note .knob__thumb {
  fill: #7ba3d4;
  filter: drop-shadow(0 0 4px rgba(123, 163, 212, 0.6));
}

.knob--note:hover .knob__thumb {
  fill: #92b8e8;
  filter: drop-shadow(0 0 8px rgba(123, 163, 212, 0.8));
}

.knob--note:active .knob__thumb {
  fill: #a8ceff;
  filter: drop-shadow(0 0 12px rgba(123, 163, 212, 1));
}

.sequencer__step--active .knob--note .knob__fill {
  stroke: rgba(0, 0, 0, 0.5);
}

.sequencer__step--active .knob--note .knob__thumb {
  fill: rgba(0, 0, 0, 0.7);
  filter: drop-shadow(0 0 4px rgba(0, 0, 0, 0.4));
}

.sequencer__step-note-label {
  font-size: 11px;
  text-align: center;
  font-weight: 600;
  opacity: 0.9;
  padding: 4px 0;
  cursor: default;
  pointer-events: none;
}

.sequencer__step-velocity {
  height: 20px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
  overflow: hidden;
  position: relative;
  border: 1px solid rgba(255, 255, 255, 0.1);
  cursor: ew-resize;
  transition: background 0.2s;
}

.sequencer__step-velocity:hover {
  background: rgba(255, 255, 255, 0.15);
  border-color: rgba(255, 255, 255, 0.2);
}

.sequencer__step-velocity-bar {
  height: 100%;
  background: currentColor;
  opacity: 0.5;
  transition: width 0.1s;
  pointer-events: none;
}

.sequencer__step--active .sequencer__step-velocity-bar {
  opacity: 0.8;
  background: rgba(0, 0, 0, 0.4);
}

/* ============================================
   SYNTH CONTROLS - 3 CHAIN LAYOUT
   ============================================ */

.synth-controls {
  display: flex;
  flex-direction: column;
  gap: 24px;
  margin-bottom: 24px;
}

/* Audio Modules (Oscillators) - 3 wide modules in a row, aligned to columns */
.audio-modules {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.audio-module {
  background: #1a1a1a;
  border: 1px solid #2a2a2a;
  border-radius: 8px;
  padding: 16px;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.audio-module h3 {
  font-size: 14px;
  font-weight: 600;
  color: #f0f0f0;
  margin-bottom: 16px;
  text-align: center;
}

.audio-module__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.audio-module__header h3 {
  margin-bottom: 0;
  flex: 1;
  text-align: center;
}

.module-controls {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 12px;
}

.module-controls--row {
  flex-direction: row;
  justify-content: center;
  align-items: flex-start;
  gap: 16px;
}

.waveform-select {
  display: flex;
  align-items: center;
  gap: 6px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: auto;
  padding-top: 8px;
}

/* Envelopes - 3 columns */
.envelopes {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.envelope {
  background: #1a1a1a;
  border: 1px solid #2a2a2a;
  border-radius: 8px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.envelope h3 {
  font-size: 14px;
  font-weight: 600;
  color: #f0f0f0;
  margin-bottom: 12px;
  text-align: center;
}

.envelope__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.envelope__header h3 {
  margin-bottom: 0;
}

.envelope__visual {
  background: #0e0e0e;
  border: 1px solid #2a2a2a;
  border-radius: 4px;
  padding: 15px;
  margin-bottom: 12px;
  height: 120px;
  position: relative;
}

.envelope__visual svg {
  width: 100%;
  height: 100%;
}

.envelope__controls {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

/* Filters - 3 columns (after ADSR) */
.filters {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.filters__title {
  display: none;
}

.filters__grid {
  display: contents;
}

.filter {
  background: #1a1a1a;
  border: 1px solid #2a2a2a;
  border-radius: 8px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  min-width: 0;
  transition: all 0.3s ease;
}

.filter.inactive {
  background: #141414;
  border-color: #222;
  opacity: 0.5;
}

.filter.inactive * {
  color: #555 !important;
}

.filter.inactive h3,
.filter.inactive label,
.filter.inactive span,
.filter.inactive .filter-type-btn {
  color: #555 !important;
}

.filter.inactive .knob__track,
.filter.inactive .knob__fill {
  stroke: #333 !important;
}

.filter.inactive .knob__thumb {
  fill: #444 !important;
}

.filter.inactive .filter-type-btn {
  background: #1a1a1a !important;
  border-color: #2a2a2a !important;
}

.filter.inactive .filter-type-btn.active {
  background: #333 !important;
  border-color: #333 !important;
  box-shadow: none !important;
}

.filter.inactive .filter-switch-slider {
  background-color: #2a2a2a !important;
}

.filter.inactive input:checked + .filter-switch-slider {
  background-color: #444 !important;
}

.filter h3 {
  font-size: 14px;
  font-weight: 600;
  color: #f0f0f0;
  margin-bottom: 12px;
  text-align: center;
}

.filter__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  padding: 0 8px;
}

.filter__header h3 {
  margin-bottom: 0;
  text-align: left;
}

.filter__controls {
  display: flex;
  gap: 12px;
  margin-bottom: 12px;
  justify-content: center;
}

.filter__type {
  display: flex;
  gap: 4px;
  justify-content: center;
}

.filter-type-btn {
  flex: 1;
  padding: 8px 4px;
  background: #2a2a2a;
  border: 1px solid #3a3a3a;
  border-radius: 4px;
  color: #888;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.filter-type-btn:hover {
  background: #333;
  border-color: #555;
  color: #aaa;
}

.filter-type-btn.active {
  background: #d4a574;
  border-color: #d4a574;
  color: #1a1a1a;
  box-shadow: 0 2px 8px rgba(212, 165, 116, 0.4);
}

.filter-type-btn--wave {
  flex: none;
  width: 44px;
  height: 32px;
  padding: 0;
  border-width: 2px;
}

.note-mode-btn {
  background: none;
  border: none;
  color: #555;
  font-size: 16px;
  cursor: pointer;
  padding: 2px 4px;
  line-height: 1;
  transition: color 0.2s;
}

.note-mode-btn:hover {
  color: #888;
}

.note-mode-btn.active {
  color: #4caf50;
}

.knob-note-btn {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: none;
  border: none;
  color: #444;
  font-size: 28px;
  cursor: pointer;
  padding: 0;
  line-height: 1;
  z-index: 2;
  transition: color 0.2s;
}

.knob-note-btn:hover {
  color: #888;
}

.knob-note-btn.active {
  color: #4caf50;
  text-shadow: 0 0 8px rgba(76, 175, 80, 0.6);
}

/* Effects - 3 columns for each effect type */
.effects {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.effects__title {
  display: none;
}

.effects__grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.effect {
  background: #1a1a1a;
  border: 1px solid #2a2a2a;
  border-radius: 8px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  min-width: 0;
  transition: all 0.3s ease;
}

.effect.inactive {
  background: #141414;
  border-color: #222;
  opacity: 0.5;
}

.effect.inactive * {
  color: #555 !important;
}

.effect.inactive h3,
.effect.inactive label,
.effect.inactive span,
.effect.inactive .wave-btn,
.effect.inactive .target-btn {
  color: #555 !important;
}

.effect.inactive .knob__track,
.effect.inactive .knob__fill {
  stroke: #333 !important;
}

.effect.inactive .knob__thumb {
  fill: #444 !important;
}

.effect.inactive .wave-btn svg path {
  stroke: #444 !important;
}

.effect.inactive .wave-btn {
  background: #1a1a1a !important;
  border-color: #2a2a2a !important;
}

.effect.inactive .wave-btn.active {
  background: #333 !important;
  border-color: #333 !important;
  box-shadow: none !important;
}

.effect.inactive .target-btn {
  background: transparent !important;
  border-color: transparent !important;
}

.effect.inactive .target-btn.active {
  background: #333 !important;
  border-color: #333 !important;
  box-shadow: none !important;
}

.effect.inactive .target-toggle {
  background: #1a1a1a !important;
  border-color: #2a2a2a !important;
}

.effect.inactive .effect-switch-slider {
  background-color: #2a2a2a !important;
}

.effect.inactive input:checked + .effect-switch-slider {
  background-color: #444 !important;
}

.effect.inactive .link-btn {
  background: #1a1a1a !important;
  border-color: #2a2a2a !important;
  color: #444 !important;
}

.effect.inactive .link-btn.linked {
  background: #333 !important;
  border-color: #333 !important;
  color: #555 !important;
  box-shadow: none !important;
}

.effect.inactive .link-btn svg {
  fill: #444 !important;
}

.effect h3 {
  font-size: 14px;
  font-weight: 600;
  color: #f0f0f0;
  margin-bottom: 12px;
  text-align: center;
}

.effect__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  padding: 0 8px;
}

.effect__header h3 {
  margin-bottom: 0;
  text-align: left;
}

.effect__controls {
  display: flex;
  gap: 12px;
  margin-bottom: 12px;
  justify-content: center;
}

.effect__waveform {
  display: flex;
  gap: 4px;
  justify-content: center;
}

/* Effect Target Toggle */
.effect__target {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  margin-top: 12px;
}

.effect__target label {
  font-size: 11px;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.target-toggle {
  display: flex;
  gap: 4px;
  background: #1a1a1a;
  padding: 3px;
  border-radius: 6px;
  border: 1px solid #2a2a2a;
}

.target-btn {
  padding: 6px 12px;
  background: transparent;
  border: none;
  color: #888;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.5px;
  cursor: pointer;
  border-radius: 4px;
  transition: all 0.2s;
  text-transform: uppercase;
}

.target-btn:hover {
  background: #252525;
  color: #aaa;
}

.target-btn.active {
  background: #d4a574;
  color: #1a1a1a;
  box-shadow: 0 2px 6px rgba(212, 165, 116, 0.3);
}

.target-btn.active:hover {
  background: #e0b585;
}

/* ============================================
   LINK BUTTON
   ============================================ */

.link-btn {
  width: 28px;
  height: 28px;
  background: #2a2a2a;
  border: 1px solid #3a3a3a;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #888;
  padding: 0;
}

.link-btn:hover {
  background: #333;
  border-color: #555;
  color: #aaa;
}

.link-btn.linked {
  background: #4d9ef6;
  border-color: #4d9ef6;
  color: #fff;
  box-shadow: 0 2px 8px rgba(77, 158, 246, 0.4);
}

.link-btn.linked:hover {
  background: #6aafe8;
}

/* ============================================
   RIGHT: Context & Variants
   ============================================ */

.right {
  background: #1a1a1a;
  border-left: 1px solid #2a2a2a;
  padding: 16px;
  overflow-y: hidden;
  display: flex;
  flex-direction: column;
}

.right__section {
  margin-bottom: 14px;
}

.right__section h3 {
  font-size: 14px;
  font-weight: 600;
  color: #f0f0f0;
  margin-bottom: 8px;
}

.master-volume-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.master-volume-controls {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100px;
}

.volume-knob-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.volume-knob-container label {
  font-size: 13px;
  color: #aaa;
  text-align: center;
}

.knob--volume {
  width: 64px;
  height: 64px;
}

/* Loudness Meter */
.loudness-meter-container {
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.loudness-meter {
  position: relative;
  width: 40px;
  height: 120px;
  background: #1a1a1a;
  border: 2px solid #2a2a2a;
  border-radius: 8px;
  padding: 4px;
  display: flex;
  align-items: flex-end;
}

.loudness-meter__bar {
  position: absolute;
  bottom: 4px;
  left: 4px;
  width: calc(100% - 8px);
  height: 0%;
  background: linear-gradient(to top, 
    #2d5f2d 0%,      /* Dark green at -50 dB */
    #4a9d4a 20%,     /* Green at -40 dB */
    #7ab84a 40%,     /* Yellow-green at -30 dB */
    #b8b84a 60%,     /* Yellow at -20 dB */
    #d4a574 75%,     /* Gold at -12 dB */
    #d47474 85%,     /* Orange at -6 dB */
    #c44 95%,        /* Red at -3 dB */
    #a00 100%        /* Dark red at 0 dB (saturation) */
  );
  border-radius: 4px;
  transition: height 0.05s ease-out;
}

.loudness-meter__peak {
  position: absolute;
  bottom: 4px;
  left: 4px;
  width: calc(100% - 8px);
  height: 2px;
  background: #fff;
  opacity: 0;
  transition: bottom 0.1s ease-out, opacity 0.3s ease-out;
}

.loudness-meter__peak.visible {
  opacity: 1;
}

.context,
.variants,
.record,
.export,
.project {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.btn--rec {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: 600;
}

.btn--rec.recording {
  background: #c44;
  color: #fff;
  border-color: #c44;
  animation: pulse-rec 1.5s infinite;
}

@keyframes pulse-rec {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

.rec-indicator {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #666;
  transition: background 0.3s;
}

.btn--rec.recording .rec-indicator {
  background: #fff;
  animation: blink-rec 1s infinite;
}

@keyframes blink-rec {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

.rec-status {
  font-size: 12px;
  color: #888;
  text-align: center;
}

.rec-status.recording {
  color: #c44;
  font-weight: 600;
}

.rec-timer {
  font-size: 18px;
  font-weight: 600;
  color: #d4a574;
  text-align: center;
  font-family: 'Courier New', monospace;
}

.context label,
.export label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 14px;
  color: #aaa;
}

.export input[type="text"] {
  background: #252525;
  border: 1px solid #333;
  color: #f0f0f0;
  padding: 8px 12px;
  border-radius: 4px;
  font-size: 14px;
}

.export input[type="text"]:focus {
  outline: none;
  border-color: #d4a574;
}

.context select,
.export select {
  background: #252525;
  border: 1px solid #333;
  color: #f0f0f0;
  padding: 8px 12px;
  border-radius: 4px;
  font-size: 14px;
}

.context input[type="checkbox"] {
  width: 18px;
  height: 18px;
}

.variant {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #252525;
  padding: 10px 12px;
  border-radius: 4px;
  border: 1px solid #333;
  gap: 8px;
  transition: border-color 0.15s, background 0.15s;
}

.variant__name {
  font-size: 13px;
  font-weight: 600;
  color: #ddd;
}

.variant__info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  min-width: 0;
}

.variant__desc {
  font-size: 11px;
  color: #777;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.variant__actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.variant--active {
  border-color: #d4a574;
  background: #2a2218;
}

.variant__btn-play,
.variant__btn-load,
.variant__btn-save {
  padding: 5px 8px;
  font-size: 11px;
}

.variant__btn-play {
  background: #2a2a2a;
  border: 1px solid #444;
  color: #bbb;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s;
}

.variant__btn-play:hover {
  background: #3a3a3a;
  color: #f0f0f0;
}

.variant__btn-save {
  background: #2a2a2a;
  border: 1px solid #444;
  color: #bbb;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s;
}

.variant__btn-save:hover {
  background: #3a3a3a;
  color: #f0f0f0;
}

/* Cinematic category accent */
.preset-category--cinema .preset-category__label {
  color: #a888d4;
}

/* ============================================
   VARIANTS PANEL — collapsible
   ============================================ */

.variants-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  background: none;
  border: none;
  padding: 0 0 16px 0;
  cursor: pointer;
  color: #f0f0f0;
  font-size: 16px;
  font-weight: 600;
  font-family: inherit;
  gap: 8px;
}

.variants-toggle > span {
  color: #a888d4;
}

.variants-toggle:hover > span {
  color: #c0a0e8;
}

.variants-toggle:hover {
  color: #d4a574;
}

.variants-toggle__chevron {
  flex-shrink: 0;
  transition: transform 0.22s ease;
  color: #888;
}

.variants-toggle[aria-expanded="true"] .variants-toggle__chevron {
  transform: rotate(180deg);
  color: #d4a574;
}

.variants-panel {
  overflow: hidden;
  max-height: 0;
  /* on close: overflow reverts to hidden immediately */
  transition: max-height 0.28s ease, overflow 0s 0s;
}

.variants-panel--open {
  max-height: 800px;
  overflow: visible;
  /* on open: overflow becomes visible only after the height animation finishes */
  transition: max-height 0.28s ease, overflow 0s 0.28s;
}

/* Hover tooltip on variant cards */
.variant[data-tooltip] {
  position: relative;
}

.variant[data-tooltip]:hover::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 0;
  right: 0;
  background: #141414;
  border: 1px solid #3a3a3a;
  border-radius: 6px;
  padding: 10px 12px;
  font-size: 11px;
  line-height: 1.6;
  color: #b0b0b0;
  white-space: normal;
  z-index: 100;
  pointer-events: none;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.65);
}

/* Generate Variants button flash while generating */
#generateVariants.generating {
  background: #d4a574;
  color: #1a1a1a;
  border-color: #d4a574;
}

/* ============================================
   BUTTONS
   ============================================ */

.btn {
  padding: 10px 20px;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.btn--primary {
  background: #d4a574;
  color: #1a1a1a;
}

.btn--primary:hover {
  background: #e0b585;
}

.btn--secondary {
  background: #2a2a2a;
  color: #f0f0f0;
  border: 1px solid #3a3a3a;
}

.btn--secondary:hover {
  background: #333;
}

.btn--small {
  padding: 6px 12px;
  font-size: 12px;
}

/* ============================================
   SCROLLBAR
   ============================================ */

::-webkit-scrollbar {
  display: none;
}

* {
  scrollbar-width: none;
}

/* ============================================
   TONAL MODE BUTTON
   ============================================ */

.tonal-btn {
  width: 24px;
  height: 24px;
  background: #2a2a2a;
  border: 1px solid #3a3a3a;
  border-radius: 4px;
  color: #888;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-left: 4px;
}

.tonal-btn:hover {
  background: #333;
  border-color: #555;
  color: #aaa;
}

.tonal-btn.active {
  background: #d4a574;
  border-color: #d4a574;
  color: #1a1a1a;
  box-shadow: 0 2px 8px rgba(212, 165, 116, 0.4);
}

/* Octave buttons */
.octave-buttons {
  display: flex;
  gap: 4px;
  margin-top: 4px;
}

.octave-btn {
  flex: 1;
  height: 22px;
  background: #2a2a2a;
  border: 1px solid #3a3a3a;
  border-radius: 4px;
  color: #888;
  font-size: 10px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  padding: 0 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.octave-btn:hover {
  background: #333;
  border-color: #555;
  color: #d4a574;
}

.octave-btn:active {
  background: #d4a574;
  border-color: #d4a574;
  color: #1a1a1a;
  transform: scale(0.95);
}

/* ============================================
   MODULE TOGGLE SWITCHES - Collapsible Modules
   ============================================ */

/* Toggle Switch Container */
.effect-switch,
.filter-switch {
  position: relative;
  display: inline-block;
  width: 56px;
  height: 28px;
}

.effect-switch input,
.filter-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

/* Toggle Slider */
.effect-switch-slider,
.filter-switch-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #2a2a2a;
  border: 2px solid #3a3a3a;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  border-radius: 28px;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.3);
}

.effect-switch-slider:before,
.filter-switch-slider:before {
  position: absolute;
  content: "";
  height: 20px;
  width: 20px;
  left: 2px;
  bottom: 2px;
  background-color: #666;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  border-radius: 50%;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.4);
}

/* Hover State */
.effect-switch-slider:hover,
.filter-switch-slider:hover {
  border-color: #4a4a4a;
}

.effect-switch-slider:hover:before,
.filter-switch-slider:hover:before {
  background-color: #777;
}

/* Checked State - ON */
.effect-switch input:checked + .effect-switch-slider,
.filter-switch input:checked + .filter-switch-slider {
  background-color: #d4a574;
  border-color: #d4a574;
  box-shadow: 0 0 12px rgba(212, 165, 116, 0.4), inset 0 2px 4px rgba(0, 0, 0, 0.2);
}

.effect-switch input:checked + .effect-switch-slider:before,
.filter-switch input:checked + .filter-switch-slider:before {
  transform: translateX(28px);
  background-color: #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

/* Focus State */
.effect-switch input:focus + .effect-switch-slider,
.filter-switch input:focus + .filter-switch-slider {
  box-shadow: 0 0 0 3px rgba(212, 165, 116, 0.2), inset 0 2px 4px rgba(0, 0, 0, 0.3);
}

/* ============================================
   COLLAPSIBLE MODULE STATES
   ============================================ */

/* Module Container */
.effect,
.filter {
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
}

/* Collapsed State - Module is OFF */
.effect.collapsed,
.filter.collapsed {
  opacity: 0.5;
  max-height: 60px !important;
  min-height: 60px !important;
}

.effect.collapsed:hover,
.filter.collapsed:hover {
  opacity: 0.7;
}

/* Hide controls when collapsed */
.effect.collapsed .effect__controls,
.effect.collapsed .effect__waveform,
.effect.collapsed .effect__target,
.filter.collapsed .filter__controls,
.filter.collapsed .filter__type {
  display: none;
}

/* Header stays visible when collapsed */
.effect__header,
.filter__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  min-height: 60px;
  transition: all 0.3s ease;
}

/* Collapsed header styling */
.effect.collapsed .effect__header,
.filter.collapsed .filter__header {
  background: linear-gradient(135deg, #1a1a1a 0%, #252525 100%);
  border-radius: 8px;
}

/* Module title */
.effect__header h3,
.filter__header h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: #f0f0f0;
  transition: color 0.3s ease;
}

.effect.collapsed .effect__header h3,
.filter.collapsed .filter__header h3 {
  color: #666;
}

/* Expanded State - Module is ON */
.effect:not(.collapsed),
.filter:not(.collapsed) {
  opacity: 1;
}

/* Smooth height transitions */
.effect__controls,
.effect__waveform,
.effect__target,
.filter__controls,
.filter__type {
  transition: opacity 0.3s ease, transform 0.3s ease;
  transform-origin: top;
}

.effect:not(.collapsed) .effect__controls,
.effect:not(.collapsed) .effect__waveform,
.effect:not(.collapsed) .effect__target,
.filter:not(.collapsed) .filter__controls,
.filter:not(.collapsed) .filter__type {
  opacity: 1;
  transform: scaleY(1);
}

/* Add subtle animation when expanding */
@keyframes expandModule {
  from {
    opacity: 0;
    transform: scaleY(0.95);
  }
  to {
    opacity: 1;
    transform: scaleY(1);
  }
}

.effect:not(.collapsed) .effect__controls,
.filter:not(.collapsed) .filter__controls {
  animation: expandModule 0.3s ease;
}

/* === DEGRADATION MODULE (right sidebar, compact) === */
.deg-section {
  transition: opacity 0.3s ease;
  border-top: 1px solid #3a3a3a;
  border-bottom: 1px solid #3a3a3a;
  padding-top: 20px;
  padding-bottom: 30px;
  margin-top: 10px;
  margin-bottom: 10px;
}

.deg-section.inactive {
  opacity: 0.45;
}

.deg-section__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.deg-section__header h3 {
  margin: 0;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #aaa;
}

.deg-section__body {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.deg-sliders {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.deg-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.deg-label {
  font-size: 10px;
  color: #888;
  width: 30px;
  flex-shrink: 0;
  letter-spacing: 0.03em;
}

.deg-slider {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 3px;
  background: #333;
  border-radius: 2px;
  outline: none;
  cursor: pointer;
}

.deg-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: #4f8eff;
  cursor: pointer;
  border: none;
  box-shadow: 0 0 4px rgba(79, 142, 255, 0.45);
}

.deg-slider::-moz-range-thumb {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: #4f8eff;
  cursor: pointer;
  border: none;
}

.deg-slider.mix::-webkit-slider-thumb {
  background: #5fc96a;
  box-shadow: 0 0 4px rgba(95, 201, 106, 0.45);
}

.deg-slider.mix::-moz-range-thumb {
  background: #5fc96a;
}

.deg-slider:hover::-webkit-slider-thumb {
  background: #6b9cff;
  box-shadow: 0 0 6px rgba(79, 142, 255, 0.65);
}

.deg-val {
  font-size: 10px;
  color: #aaa;
  width: 26px;
  text-align: right;
  flex-shrink: 0;
}

.deg-section__btns {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.deg-section__type,
.deg-section__mode {
  display: flex;
  gap: 4px;
}

.deg-type-btn,
.deg-mode-btn {
  background: #1a1a1a;
  border: 1px solid #333;
  border-radius: 4px;
  color: #777;
  font-size: 10px;
  padding: 3px 7px;
  cursor: pointer;
  transition: all 0.15s ease;
  font-family: inherit;
  letter-spacing: 0.03em;
}

.deg-type-btn:hover,
.deg-mode-btn:hover {
  border-color: #b06040;
  color: #ccc;
}

.deg-type-btn.active,
.deg-mode-btn.active {
  border-color: #c06840;
  background: rgba(192, 104, 64, 0.15);
  color: #d47850;
}

.deg-bits-display {
  font-size: 11px;
  color: #d47850;
  align-self: center;
  white-space: nowrap;
}
