:root {
  --bg: #080906;
  --surface: rgba(18, 20, 15, 0.94);
  --surface-2: rgba(28, 31, 23, 0.94);
  --line: rgba(235, 240, 213, 0.13);
  --line-hot: rgba(125, 240, 138, 0.48);
  --text: #f4f5e8;
  --muted: #aeb5a1;
  --accent: #7df08a;
  --accent-2: #ffcf5a;
  --accent-3: #f46d8b;
  --shadow: 0 18px 48px rgba(0, 0, 0, 0.38);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background-color: var(--bg);
  background-image:
    linear-gradient(90deg, rgba(125, 240, 138, 0.045) 1px, transparent 1px),
    linear-gradient(0deg, rgba(255, 207, 90, 0.035) 1px, transparent 1px),
    linear-gradient(180deg, #080906 0%, #11130d 52%, #080906 100%);
  background-size: 48px 48px, 48px 48px, auto;
}

button,
select,
input {
  font: inherit;
}

.app-shell {
  max-width: 1540px;
  margin: 0 auto;
  padding: 12px;
}

.panel {
  background: linear-gradient(180deg, var(--surface), rgba(13, 15, 11, 0.97));
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.topbar {
  display: grid;
  grid-template-columns: minmax(220px, 0.85fr) minmax(420px, 1.55fr) auto;
  gap: 10px;
  align-items: center;
  padding: 10px;
}

.brand-wrap h1 {
  margin: 2px 0 0;
  font-size: clamp(25px, 3.1vw, 42px);
  line-height: 0.98;
}

.eyebrow,
.section-title,
.knob-label,
.mini-select span,
.status-item span {
  letter-spacing: 0;
  text-transform: uppercase;
}

.eyebrow {
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
}

.brand-link {
  text-decoration: none;
  display: inline-block;
}

.brand-link:hover {
  color: var(--accent-2);
}

.top-corner-tools,
.transport-cluster,
.sequence-tools,
.scene-row,
.export-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.transport-cluster {
  justify-content: center;
}

.top-corner-tools {
  justify-content: flex-end;
}

button,
.file-button,
.download-link {
  appearance: none;
  border: 1px solid rgba(244, 245, 232, 0.16);
  background: linear-gradient(180deg, rgba(244, 245, 232, 0.12), rgba(244, 245, 232, 0.045));
  color: var(--text);
  padding: 9px 11px;
  border-radius: 8px;
  font-weight: 800;
  cursor: pointer;
  text-decoration: none;
  min-height: 38px;
}

button:hover,
.file-button:hover,
.download-link:hover {
  border-color: rgba(125, 240, 138, 0.5);
}

button:disabled {
  opacity: 0.52;
  cursor: not-allowed;
}

button.primary {
  background: linear-gradient(135deg, rgba(125, 240, 138, 0.24), rgba(255, 207, 90, 0.14));
  border-color: var(--line-hot);
}

button.active,
.recording {
  border-color: rgba(244, 109, 139, 0.78) !important;
  background: linear-gradient(135deg, rgba(244, 109, 139, 0.28), rgba(255, 207, 90, 0.14)) !important;
}

.download-link.disabled {
  opacity: 0.45;
  pointer-events: none;
}

.file-button input {
  display: none;
}

.compact-file {
  display: inline-flex;
  align-items: center;
}

.status-strip {
  display: grid;
  grid-template-columns: auto auto minmax(160px, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 8px 10px;
  margin-top: 10px;
}

.status-item {
  display: grid;
  gap: 2px;
  min-width: 92px;
}

.status-item span,
.section-note,
.lane-header {
  color: var(--muted);
}

.status-item span {
  font-size: 10px;
  font-weight: 800;
}

.status-item strong {
  font-size: 13px;
}

.meter {
  height: 12px;
  border: 1px solid rgba(244, 245, 232, 0.14);
  border-radius: 999px;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.24);
}

.meter span {
  display: block;
  height: 100%;
  width: 100%;
  transform: scaleX(0);
  transform-origin: left center;
  background: linear-gradient(90deg, var(--accent), var(--accent-2), var(--accent-3));
}

.render-status {
  color: var(--muted);
  font-size: 12px;
  min-width: 72px;
}

.main-grid {
  display: grid;
  grid-template-columns: 1.5fr 0.82fr;
  gap: 12px;
  margin-top: 12px;
  align-items: start;
}

.left-column,
.right-column {
  display: grid;
  gap: 12px;
}

.visual-panel,
.morph-panel,
.quick-panel,
.performance-panel,
.sequence-panel,
.dial-panel {
  padding: 12px;
}

.panel-head,
.compact-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: flex-start;
}

.section-title {
  color: var(--accent);
  font-size: 13px;
  font-weight: 900;
}

.section-note {
  margin: 4px 0 0;
  font-size: 12px;
  line-height: 1.35;
}

.mini-readouts {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}

.mini-readouts span,
.mini-select {
  padding: 6px 8px;
  border-radius: 8px;
  background: rgba(244, 245, 232, 0.055);
  color: var(--muted);
  font-size: 12px;
  border: 1px solid rgba(244, 245, 232, 0.08);
}

.mini-select {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.mini-select span {
  font-size: 10px;
  color: var(--muted);
  font-weight: 900;
}

select {
  background: transparent;
  color: var(--text);
  border: none;
  outline: none;
  font-weight: 800;
}

option {
  color: #11130d;
}

.visualizer-canvas {
  width: 100%;
  height: 468px;
  min-height: 0;
  display: block;
  margin-top: 10px;
  border-radius: 8px;
  background-color: #090b07;
  background-image:
    linear-gradient(90deg, rgba(125, 240, 138, 0.08) 1px, transparent 1px),
    linear-gradient(0deg, rgba(255, 207, 90, 0.055) 1px, transparent 1px);
  background-size: 32px 32px;
  border: 1px solid rgba(244, 245, 232, 0.08);
}

.morph-pad {
  position: relative;
  height: 248px;
  margin-top: 10px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid rgba(244, 245, 232, 0.1);
  background:
    linear-gradient(135deg, rgba(125, 240, 138, 0.2), rgba(255, 207, 90, 0.12) 48%, rgba(244, 109, 139, 0.18)),
    #12140f;
  touch-action: none;
}

.morph-grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(244, 245, 232, 0.16) 1px, transparent 1px),
    linear-gradient(90deg, rgba(244, 245, 232, 0.16) 1px, transparent 1px);
  background-size: 25% 25%;
}

.morph-cursor {
  position: absolute;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  background: var(--text);
  border: 6px solid var(--accent);
  box-shadow: 0 0 22px rgba(125, 240, 138, 0.72);
  left: 50%;
  top: 50%;
}

.knob-grid,
.dial-grid,
.mini-dial-row {
  display: grid;
  gap: 10px;
}

.knob-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-top: 10px;
}

.performance-panel {
  min-height: 242px;
}

.performance-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.performance-grid button {
  width: 100%;
}

.mix-info {
  min-height: 58px;
  margin-top: 10px;
  padding: 10px;
  border: 1px solid rgba(244, 245, 232, 0.08);
  border-radius: 8px;
  background: rgba(244, 245, 232, 0.045);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.dial-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 10px;
}

.atmosphere-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.mini-dial-row {
  grid-template-columns: repeat(3, 1fr);
}

.knob {
  display: grid;
  justify-items: center;
  gap: 5px;
  position: relative;
  user-select: none;
  min-width: 0;
}

.knob input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: ns-resize;
}

.knob-dial {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  position: relative;
  background:
    linear-gradient(145deg, rgba(244, 245, 232, 0.16), rgba(0, 0, 0, 0.38)),
    #171a12;
  border: 1px solid rgba(244, 245, 232, 0.14);
  box-shadow: inset 0 0 18px rgba(0, 0, 0, 0.35), 0 7px 16px rgba(0, 0, 0, 0.32);
}

.knob-big .knob-dial {
  width: 78px;
  height: 78px;
}

.mini-knob .knob-dial {
  width: 56px;
  height: 56px;
}

.knob-indicator {
  position: absolute;
  left: 50%;
  top: 8px;
  width: 4px;
  height: 23px;
  border-radius: 4px;
  background: linear-gradient(180deg, var(--accent), var(--text));
  transform: translateX(-50%) rotate(-135deg);
  transform-origin: 50% 27px;
  box-shadow: 0 0 10px rgba(125, 240, 138, 0.6);
}

.knob-label {
  color: var(--muted);
  font-size: 10px;
  font-weight: 900;
}

.knob-value {
  color: var(--text);
  font-size: 12px;
  min-height: 15px;
}

.dial-card {
  padding: 10px;
  border-radius: 8px;
  background: var(--surface-2);
  border: 1px solid rgba(244, 245, 232, 0.075);
}

.dial-card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.strip-name {
  font-weight: 900;
}

.scene-row {
  margin-top: 10px;
}

.compact-sequence-panel {
  padding-top: 10px;
}

.lane-header,
.seq-row {
  display: grid;
  grid-template-columns: 104px 1fr;
  gap: 8px;
  align-items: center;
}

.lane-header {
  padding: 9px 2px 7px;
  font-size: 11px;
}

.step-labels,
.steps {
  display: grid;
  grid-template-columns: repeat(16, minmax(20px, 1fr));
  gap: 5px;
}

.step-labels span {
  text-align: center;
  opacity: 0.76;
}

.seq-row {
  margin-bottom: 7px;
}

.seq-name {
  padding: 9px 10px;
  border-radius: 8px;
  background: rgba(244, 245, 232, 0.055);
  border: 1px solid rgba(244, 245, 232, 0.07);
  font-weight: 900;
}

.step-cell {
  min-height: 32px;
  border-radius: 7px;
  border: 1px solid rgba(244, 245, 232, 0.1);
  background: linear-gradient(180deg, rgba(244, 245, 232, 0.08), rgba(244, 245, 232, 0.02));
  color: transparent;
  box-shadow: inset 0 1px 0 rgba(244, 245, 232, 0.06);
}

.step-cell.soft {
  background: linear-gradient(180deg, rgba(125, 240, 138, 0.32), rgba(125, 240, 138, 0.09));
  border-color: rgba(125, 240, 138, 0.46);
}

.step-cell.full {
  background: linear-gradient(180deg, rgba(255, 207, 90, 0.58), rgba(244, 109, 139, 0.18));
  border-color: rgba(255, 207, 90, 0.52);
  box-shadow: inset 0 0 18px rgba(244, 245, 232, 0.08), 0 0 18px rgba(255, 207, 90, 0.08);
}

.step-cell.playing {
  outline: 2px solid var(--text);
  outline-offset: 1px;
}

.step-cell:nth-child(4n),
.step-labels span:nth-child(4n) {
  position: relative;
}

.step-cell:nth-child(4n)::after {
  content: "";
  position: absolute;
  right: -3px;
  top: 14%;
  bottom: 14%;
  width: 1px;
  background: rgba(244, 245, 232, 0.12);
}

.bottom-dials-grid {
  display: grid;
  grid-template-columns: 1.03fr 1.03fr 1.05fr;
  gap: 12px;
  margin-top: 12px;
}

.mute-btn {
  min-width: 62px;
  padding: 7px 9px;
  min-height: 32px;
}

.mute-btn.active {
  border-color: rgba(244, 109, 139, 0.78) !important;
  background: linear-gradient(135deg, rgba(244, 109, 139, 0.28), rgba(255, 207, 90, 0.14)) !important;
}

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

  .transport-cluster,
  .top-corner-tools {
    justify-content: flex-start;
  }

  .main-grid,
  .bottom-dials-grid {
    grid-template-columns: 1fr;
  }

  .right-column {
    grid-template-columns: 1fr 1fr;
    align-items: start;
  }
}

@media (max-width: 860px) {
  .status-strip {
    grid-template-columns: 1fr 1fr;
  }

  .export-tools {
    grid-column: 1 / -1;
  }

  .right-column {
    grid-template-columns: 1fr;
  }

  .knob-grid,
  .dial-grid,
  .atmosphere-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .panel-head,
  .compact-head {
    display: grid;
  }

  .mini-readouts {
    justify-content: flex-start;
  }

  .visualizer-canvas {
    height: 360px;
  }
}

@media (max-width: 640px) {
  .app-shell {
    padding: 8px;
  }

  .lane-header,
  .seq-row {
    grid-template-columns: 1fr;
  }

  .step-labels,
  .steps {
    gap: 4px;
  }

  .step-cell {
    min-height: 27px;
  }

  .knob-grid,
  .dial-grid,
  .atmosphere-grid,
  .mini-dial-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .visualizer-canvas {
    height: 300px;
  }

  button,
  .file-button,
  .download-link {
    width: 100%;
    justify-content: center;
  }

  .transport-cluster,
  .top-corner-tools,
  .sequence-tools,
  .scene-row,
  .export-tools {
    width: 100%;
  }
}
