/* --- Chaos Synth Styling System --- */
:root {
  --bg-deep: #020306;
  --bg-surface: rgba(7, 9, 18, 0.72);
  --bg-card: rgba(18, 14, 38, 0.45);
  --border-light: rgba(255, 255, 255, 0.08);
  
  --color-accent: #a855f7;      /* Pure Purple */
  --color-accent-glow: rgba(168, 85, 247, 0.35);
  --color-cyan: #06b6d4;
  --color-cyan-glow: rgba(6, 182, 212, 0.25);
  
  --text-main: #f3f4f6;
  --text-muted: #9ca3af;
  
  --font-family-body: 'Outfit', sans-serif;
  --font-family-mono: 'Space Mono', monospace;
  
  color-scheme: dark;
}

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

body {
  background-color: var(--bg-deep);
  color: var(--text-main);
  font-family: var(--font-family-body);
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

#app-container {
  display: grid;
  grid-template-rows: auto 1fr;
  height: 100vh;
  width: 100vw;
}

/* Header style */
#app-header {
  background: rgba(6, 8, 15, 0.9);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border-light);
  padding: 0.8rem 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 10;
  
  .logo-area {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    
    h1 {
      font-size: 1.4rem;
      font-weight: 800;
      background: linear-gradient(135deg, #ffffff 40%, #e8b3ff);
      -webkit-background-clip: text;
      -webkit-text-fill-color: transparent;
    }
    
    .icon {
      font-size: 1.5rem;
    }
  }
}

.badge {
  font-family: var(--font-family-mono);
  font-size: 0.65rem;
  font-weight: 700;
  padding: 0.2rem 0.5rem;
  background: rgba(168, 85, 247, 0.12);
  color: #d8b4fe;
  border: 1px solid rgba(168, 85, 247, 0.3);
  border-radius: 4px;
}

.header-stats {
  display: flex;
  gap: 1.5rem;
}

.header-stat-box {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  
  .label {
    font-size: 0.65rem;
    color: var(--text-muted);
    text-transform: uppercase;
  }
  
  .value {
    font-family: var(--font-family-mono);
    font-size: 1.1rem;
    font-weight: 700;
  }
}

/* App Body Grid */
#app-body {
  display: grid;
  grid-template-columns: 290px 1fr 290px;
  overflow: hidden;
  height: 100%;
}

/* Sidebars */
aside {
  background: var(--bg-surface);
  backdrop-filter: blur(16px);
  border-inline-end: 1px solid var(--border-light);
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

#sidebar-synth {
  border-inline-end: none;
  border-inline-start: 1px solid var(--border-light);
}

.control-card {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: 12px;
  padding: 1rem;
  
  h2 {
    font-size: 0.85rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.8rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    padding-bottom: 0.4rem;
  }
}

/* Selectors */
.equation-selector-stack {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.eqn-btn {
  background: rgba(255,255,255,0.02);
  border: 1px solid var(--border-light);
  color: var(--text-muted);
  text-align: left;
  padding: 0.6rem;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
  
  &:hover {
    background: rgba(255,255,255,0.06);
    color: var(--text-main);
  }
  
  &.active {
    background: rgba(168, 85, 247, 0.12);
    border-color: var(--color-accent);
    color: var(--text-main);
  }
}

.formula-display {
  background: rgba(0,0,0,0.25);
  border: 1px solid rgba(255,255,255,0.03);
  padding: 0.6rem;
  border-radius: 6px;
  font-size: 0.7rem;
  margin-top: 0.8rem;
  
  h3 {
    font-size: 0.75rem;
    margin-bottom: 0.3rem;
    color: var(--color-accent);
  }
  
  .math {
    font-family: var(--font-family-mono);
    color: var(--text-muted);
    margin-bottom: 0.15rem;
    
    &:last-child {
      margin-bottom: 0;
    }
  }
}

/* Controls */
.control-group {
  margin-bottom: 0.8rem;
  
  &:last-child {
    margin-bottom: 0;
  }
}

.control-header {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  margin-bottom: 0.3rem;
  color: var(--text-muted);
  
  label {
    font-weight: 600;
  }
  
  .control-val {
    font-family: var(--font-family-mono);
    color: var(--color-accent);
    font-weight: 700;
  }
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 2px;
  outline: none;
  margin: 6px 0;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--color-accent);
  cursor: pointer;
}

.btn {
  font-family: var(--font-family-body);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.15s ease;
  outline: none;
}

.btn-primary {
  background: var(--color-accent);
  color: #fff;
  box-shadow: 0 4px 10px rgba(168, 85, 247, 0.2);
  
  &:hover {
    background: #9333ea;
    box-shadow: 0 4px 15px rgba(168, 85, 247, 0.35);
  }
  
  &.active {
    background: #7e22ce;
    box-shadow: 0 0 10px rgba(168, 85, 247, 0.5);
  }
}

.btn-warning {
  background: rgba(234, 179, 8, 0.12);
  border-color: rgba(234, 179, 8, 0.3);
  color: #fef08a;
  &:hover { background: #eab308; color: #000; }
}

.btn-block {
  width: 100%;
  display: block;
}

.btn-audio-large {
  padding: 0.8rem;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.8rem;
}

/* Sound Waveform Grid */
.section-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  display: block;
  margin-bottom: 0.4rem;
}

.waveform-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.3rem;
}

.wave-btn {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-light);
  border-radius: 4px;
  color: var(--text-muted);
  padding: 0.4rem 0.2rem;
  font-size: 0.65rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
  
  &:hover {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-main);
  }
  
  &.active {
    background: rgba(168, 85, 247, 0.12);
    border-color: var(--color-accent);
    color: var(--text-main);
  }
}

/* Table */
.mapping-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.7rem;
  text-align: left;
  
  th, td {
    padding: 0.4rem;
  }
  
  thead th {
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.6rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  }
  
  tbody tr {
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    
    &:last-child {
      border-bottom: none;
    }
    
    td:last-child {
      font-family: var(--font-family-mono);
      font-weight: 700;
      color: var(--color-accent);
    }
  }
}

/* Center canvas */
#viewport-container {
  display: flex;
  position: relative;
  background-color: #000103;
  overflow: hidden;
  height: 100%;
}

.canvas-wrapper {
  position: relative;
  width: 100%;
  height: 100%;
  
  canvas {
    display: block;
    width: 100%;
    height: 100%;
    cursor: grab;
    
    &:active {
      cursor: grabbing;
    }
  }
}

#view-controls-hint {
  position: absolute;
  bottom: 1rem;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(7, 9, 18, 0.75);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border-light);
  font-family: var(--font-family-mono);
  font-size: 0.65rem;
  padding: 0.35rem 1rem;
  border-radius: 20px;
  pointer-events: none;
  letter-spacing: 0.03em;
  color: var(--text-muted);
  box-shadow: 0 4px 10px rgba(0,0,0,0.5);
  text-align: center;
}

.hidden {
  display: none !important;
}
