@import url('https://fonts.googleapis.com/css2?family=Bebas+Neue&family=Space+Mono:wght@400;700&family=DM+Sans:wght@300;400;500&display=swap');

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

:root {
  --bg: #08090d;
  --surface: rgba(16, 17, 24, 0.78);
  --surface2: rgba(25, 27, 38, 0.82);
  --surface3: rgba(35, 38, 52, 0.9);
  --border: rgba(255, 255, 255, 0.09);
  --border2: rgba(255, 255, 255, 0.15);
  --mel: #e8c547;
  --mel-dim: #806c1f;
  --chd: #47c5e8;
  --chd-dim: #1a6579;
  --pink: #f05a9d;
  --green: #64d98b;
  --text: #eceaf7;
  --muted: #9b99ad;
  --muted2: #615f72;
  --danger: #ff6b6b;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.38);
  --font-display: 'Bebas Neue', sans-serif;
  --font-mono: 'Space Mono', monospace;
  --font-body: 'DM Sans', sans-serif;
}

html, body {
  min-height: 100%;
  background:
    linear-gradient(120deg, rgba(232, 197, 71, 0.12), transparent 28%),
    linear-gradient(240deg, rgba(71, 197, 232, 0.13), transparent 32%),
    linear-gradient(180deg, #08090d 0%, #0e1017 46%, #090a0f 100%);
  background-size: 180% 180%;
  animation: bgShift 14s ease-in-out infinite;
  color: var(--text);
  font-family: var(--font-body);
}

body { overflow-x: hidden; }

button, select, input { font: inherit; }
button { min-height: 42px; }

.noise {
  position: fixed; inset: 0; pointer-events: none; z-index: 9999; opacity: 0.035;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.75' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 160px;
}

.app {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0 40px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.header, .transport-bar, .track, .module-card {
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px;
  border-radius: 8px;
}

.logo-block { display: flex; align-items: center; gap: 14px; min-width: 0; }
.logo-link { display: flex; align-items: center; gap: 14px; text-decoration: none; }
.logo-mark {
  width: 46px;
  height: 46px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--mel), #fff1a5);
  color: #08090d;
  font-family: var(--font-display);
  font-size: 30px;
  line-height: 1;
  box-shadow: 0 0 28px rgba(232, 197, 71, 0.32);
}

.logo-words { display: flex; flex-direction: column; line-height: 1; }
.logo-main { font-family: var(--font-display); font-size: 34px; color: var(--mel); letter-spacing: 0.04em; }
.logo-studio { font-family: var(--font-mono); font-size: 10px; color: var(--muted); letter-spacing: 0.2em; }
.logo-badge {
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--muted);
  border: 1px solid var(--border2);
  border-radius: 6px;
  padding: 5px 8px;
  letter-spacing: 0.08em;
  white-space: nowrap;
}

.header-right { display: flex; align-items: center; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }
.nav-link {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--muted);
  text-decoration: none;
  letter-spacing: 0.08em;
  padding: 8px 10px;
  border: 1px solid var(--border2);
  border-radius: 6px;
  transition: transform 0.18s, border-color 0.18s, color 0.18s;
}
.nav-link:hover { color: var(--chd); border-color: var(--chd); transform: translateY(-1px); }

.status-bar {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--mel);
  background: rgba(232, 197, 71, 0.09);
  border: 1px solid rgba(232, 197, 71, 0.26);
  border-radius: 6px;
  padding: 8px 10px;
  letter-spacing: 0.08em;
  max-width: 320px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.status-bar.playing { color: var(--chd); background: rgba(71, 197, 232, 0.09); border-color: rgba(71, 197, 232, 0.28); }
.status-bar.error { color: var(--danger); background: rgba(255, 107, 107, 0.08); border-color: rgba(255, 107, 107, 0.28); }

.led { width: 10px; height: 10px; border-radius: 50%; background: var(--muted2); transition: all 0.1s; }
.led.on { background: var(--mel); box-shadow: 0 0 14px var(--mel); }
.led.chd-on { background: var(--chd); box-shadow: 0 0 14px var(--chd); }
.mono { font-family: var(--font-mono); }

.transport-bar {
  display: flex;
  align-items: center;
  gap: 14px;
  border-radius: 8px;
  padding: 14px;
  flex-wrap: wrap;
}
.t-ctrl { display: flex; align-items: center; gap: 8px; }
.t-ctrl label, .sel-group label, .seed-group label {
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--muted);
  letter-spacing: 0.1em;
  white-space: nowrap;
}
.t-ctrl input[type=range] { width: 118px; accent-color: var(--mel); }
.t-ctrl select, .sel-group select, .selects-panel select, .seed-row input {
  background: rgba(8, 9, 13, 0.7);
  border: 1px solid var(--border2);
  color: var(--text);
  border-radius: 6px;
  padding: 9px 10px;
  outline: none;
}
.t-ctrl select:focus, .sel-group select:focus, .seed-row input:focus { border-color: var(--mel); }
.t-ctrl .mono { font-size: 12px; color: var(--mel); min-width: 32px; }
.t-buttons { display: flex; gap: 8px; margin-left: auto; flex-wrap: wrap; }
.t-btn, .mini-btn {
  font-family: var(--font-display);
  font-size: 17px;
  letter-spacing: 0.05em;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border2);
  color: var(--text);
  border-radius: 6px;
  padding: 9px 16px;
  cursor: pointer;
  transition: transform 0.16s, border-color 0.16s, background 0.16s, box-shadow 0.16s;
}
.t-btn:hover, .mini-btn:hover { transform: translateY(-1px); border-color: var(--mel); background: rgba(232, 197, 71, 0.08); }
.t-btn-play { border-color: rgba(232, 197, 71, 0.72); color: var(--mel); }
.t-btn-play.playing { background: var(--mel); color: #08090d; box-shadow: 0 0 24px rgba(232, 197, 71, 0.36); }
.mini-btn { min-height: 34px; padding: 6px 10px; font-size: 13px; }

.tracks-wrap { display: flex; flex-direction: column; gap: 14px; }
.track {
  border-radius: 8px;
  overflow: hidden;
  transition: border-color 0.2s, transform 0.2s;
}
.track-mel { border-left: 3px solid var(--mel-dim); }
.track-chd { border-left: 3px solid var(--chd-dim); }
.track-mel.track-active { border-left-color: var(--mel); }
.track-chd.track-active { border-left-color: var(--chd); }
.track-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px 10px;
  border-bottom: 1px solid var(--border);
}
.track-name { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.t-label { font-family: var(--font-display); font-size: 25px; color: var(--mel); letter-spacing: 0.05em; }
.chd-label { color: var(--chd); }
.t-sub { font-family: var(--font-mono); font-size: 9px; color: var(--muted); letter-spacing: 0.12em; }

.toggler { cursor: pointer; display: inline-flex; }
.toggler input { display: none; }
.tog-ui {
  display: block;
  width: 42px;
  height: 24px;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid var(--border2);
  border-radius: 999px;
  position: relative;
  transition: background 0.2s;
}
.tog-ui::after {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  background: var(--muted);
  border-radius: 50%;
  top: 3px;
  left: 3px;
  transition: all 0.2s;
}
.toggler input:checked + .tog-ui { background: rgba(232, 197, 71, 0.24); }
.toggler input:checked + .tog-ui::after { background: var(--mel); transform: translateX(18px); }
.toggler input:checked + .chd-tog { background: rgba(71, 197, 232, 0.22); }
.toggler input:checked + .chd-tog::after { background: var(--chd); }

.ctrl-panel {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 18px;
  padding: 16px;
  align-items: start;
}
.knobs {
  display: grid;
  grid-template-columns: repeat(3, 86px);
  gap: 16px;
}
.knob-ctrl { display: flex; flex-direction: column; align-items: center; gap: 5px; user-select: none; }
.knob-svg { width: 66px; height: 66px; touch-action: none; }
.k-bg { fill: rgba(8, 9, 13, 0.78); stroke: var(--border2); stroke-width: 1.5; }
.k-arc { fill: none; stroke-width: 4; stroke-linecap: round; }
.mel-arc { stroke: var(--mel); filter: drop-shadow(0 0 5px rgba(232, 197, 71, 0.5)); }
.chd-arc { stroke: var(--chd); filter: drop-shadow(0 0 5px rgba(71, 197, 232, 0.5)); }
.k-val { font-family: var(--font-mono); font-size: 9px; fill: var(--text); text-anchor: middle; dominant-baseline: middle; }
.k-label { font-family: var(--font-mono); font-size: 8px; color: var(--text); letter-spacing: 0.1em; text-align: center; }
.helper-label { font-family: var(--font-mono); font-size: 8px; color: var(--muted2); text-align: center; line-height: 1.2; min-height: 18px; }
.hidden-range { display: none; }

.selects-panel {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  padding-left: 18px;
  border-left: 1px solid var(--border);
}
.sel-group, .seed-group { display: flex; flex-direction: column; gap: 6px; }
.sel-group select { min-width: 0; width: 100%; font-size: 12px; }
.seed-row { display: flex; gap: 7px; }
.seed-row input { min-width: 0; width: 100%; font-family: var(--font-mono); font-size: 12px; }
.toggles { display: flex; flex-direction: column; gap: 8px; padding-top: 4px; }
.tog-row {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--muted);
  letter-spacing: 0.08em;
}

.chord-intervals {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-family: var(--font-mono);
  font-size: 9px;
  padding: 10px;
  background: rgba(8, 9, 13, 0.52);
  border: 1px solid var(--border2);
  border-radius: 6px;
}
.interval-label { color: var(--muted); letter-spacing: 0.1em; }
#interval-vals { color: var(--chd); font-size: 11px; }

.seq-wrap { padding: 0 16px 10px; }
.seq-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(22px, 1fr));
  gap: 4px;
  padding: 10px 0 4px;
}
.piano-roll {
  min-height: 118px;
  align-items: stretch;
  background:
    linear-gradient(rgba(255,255,255,0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.035) 1px, transparent 1px);
  background-size: 100% 24px, 48px 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px;
}
.seq-step {
  min-height: 78px;
  border-radius: 5px;
  background: rgba(8, 9, 13, 0.62);
  border: 1px solid var(--border2);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 3px;
  cursor: pointer;
  transition: transform 0.08s, border-color 0.08s, box-shadow 0.08s;
  position: relative;
  overflow: hidden;
}
.seq-step .step-fill {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(180deg, var(--mel), rgba(232, 197, 71, 0.26));
  opacity: 0.72;
  border-radius: 4px;
  transition: height 0.1s;
}
.seq-step .step-note {
  font-family: var(--font-mono);
  font-size: 8px;
  color: var(--text);
  position: relative;
  z-index: 1;
  white-space: nowrap;
  text-shadow: 0 1px 2px #000;
}
.seq-step.active { border-color: var(--mel); box-shadow: 0 0 18px rgba(232, 197, 71, 0.42); transform: translateY(-1px); }

.note-pills { display: flex; flex-wrap: wrap; gap: 6px; padding: 6px 16px 14px; min-height: 36px; }
.pill {
  font-family: var(--font-mono);
  font-size: 10px;
  padding: 4px 9px;
  border-radius: 6px;
  background: rgba(232, 197, 71, 0.09);
  border: 1px solid rgba(232, 197, 71, 0.24);
  color: var(--mel);
}
.chd-pills .pill { background: rgba(71, 197, 232, 0.09); border-color: rgba(71, 197, 232, 0.24); color: var(--chd); }

.progression-display { padding: 18px 16px; }
.prog-bar { display: flex; gap: 8px; align-items: stretch; }
.prog-chord {
  background: rgba(8, 9, 13, 0.58);
  border: 1px solid var(--border2);
  border-left: 3px solid var(--chd-dim);
  border-radius: 8px;
  padding: 13px;
  min-width: 120px;
  transition: all 0.18s;
}
.prog-chord:hover, .prog-chord.active { border-left-color: var(--chd); box-shadow: 0 0 18px rgba(71, 197, 232, 0.22); background: rgba(71, 197, 232, 0.08); }
.prog-chord-name { font-family: var(--font-display); font-size: 25px; color: var(--chd); letter-spacing: 0.04em; }
.prog-chord-duration { font-family: var(--font-mono); font-size: 9px; color: var(--muted); letter-spacing: 0.08em; }
.prog-chord-notes { font-family: var(--font-mono); font-size: 10px; color: var(--muted); margin-top: 7px; overflow-wrap: anywhere; }

.saved-ideas { padding: 12px 16px 16px; display: flex; flex-direction: column; gap: 8px; }
.saved-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(8, 9, 13, 0.5);
}
.saved-row strong { display: block; font-family: var(--font-display); font-size: 20px; color: var(--text); letter-spacing: 0.04em; }
.saved-row span, .saved-empty { display: block; font-family: var(--font-mono); font-size: 10px; color: var(--muted); line-height: 1.5; }

.footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 2px 0;
  border-top: 1px solid var(--border);
  font-size: 10px;
  color: var(--muted);
  letter-spacing: 0.06em;
}

.landing-page { justify-content: center; }
.landing-content { display: flex; flex-direction: column; gap: 28px; flex: 1; justify-content: center; padding: 28px 0; }
.landing-hero {
  min-height: 34vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  border-radius: 8px;
  position: relative;
  overflow: hidden;
}
.landing-hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    linear-gradient(100deg, rgba(8, 9, 13, 0.2), rgba(8, 9, 13, 0.85)),
    repeating-linear-gradient(90deg, rgba(232,197,71,0.12) 0 1px, transparent 1px 54px),
    repeating-linear-gradient(0deg, rgba(71,197,232,0.08) 0 1px, transparent 1px 36px);
  border: 1px solid var(--border);
  border-radius: 8px;
  transform: perspective(800px) rotateX(58deg) translateY(26%);
  transform-origin: bottom center;
}
.hero-kicker, .hero-title, .hero-subtitle { position: relative; z-index: 1; }
.hero-kicker { font-family: var(--font-mono); color: var(--chd); font-size: 11px; letter-spacing: 0.16em; margin-bottom: 8px; }
.hero-title { font-family: var(--font-display); font-size: clamp(62px, 13vw, 150px); color: var(--mel); letter-spacing: 0.04em; line-height: 0.88; text-shadow: 0 0 36px rgba(232, 197, 71, 0.2); }
.hero-subtitle { max-width: 650px; font-size: 17px; color: var(--text); line-height: 1.6; margin-top: 18px; }
.module-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.module-card {
  min-height: 310px;
  border-radius: 8px;
  padding: 22px;
  text-decoration: none;
  display: flex;
  flex-direction: column;
  gap: 14px;
  transition: transform 0.22s, border-color 0.22s, box-shadow 0.22s;
  position: relative;
  overflow: hidden;
}
.module-card::before { content: ''; position: absolute; inset: 0; opacity: 0; transition: opacity 0.22s; pointer-events: none; }
.module-card:hover { transform: translateY(-5px); }
.module-card:hover::before { opacity: 1; }
.mel-card { border-left: 3px solid var(--mel-dim); }
.mel-card::before { background: linear-gradient(135deg, rgba(232, 197, 71, 0.12), transparent); }
.mel-card:hover { border-left-color: var(--mel); box-shadow: 0 22px 70px rgba(232, 197, 71, 0.12); }
.chd-card { border-left: 3px solid var(--chd-dim); }
.chd-card::before { background: linear-gradient(135deg, rgba(71, 197, 232, 0.12), transparent); }
.chd-card:hover { border-left-color: var(--chd); box-shadow: 0 22px 70px rgba(71, 197, 232, 0.12); }
.studio-card { border-left: 3px solid var(--pink); }
.studio-card::before { background: linear-gradient(135deg, rgba(240, 90, 157, 0.13), transparent); }
.studio-card:hover { border-left-color: var(--pink); box-shadow: 0 22px 70px rgba(240, 90, 157, 0.12); }
.card-icon { font-family: var(--font-display); font-size: 42px; color: var(--muted2); line-height: 1; }
.card-content { flex: 1; position: relative; z-index: 1; }
.card-content h2 { font-family: var(--font-display); font-size: 30px; letter-spacing: 0.04em; margin-bottom: 8px; color: var(--text); }
.mel-card h2 { color: var(--mel); }
.chd-card h2 { color: var(--chd); }
.studio-card h2 { color: var(--pink); }
.card-content p { font-size: 13px; color: var(--muted); line-height: 1.55; margin-bottom: 14px; }
.card-features { list-style: none; display: flex; flex-direction: column; gap: 6px; font-family: var(--font-mono); font-size: 10px; color: var(--muted); }
.card-features li::before { content: '>'; color: var(--mel); margin-right: 8px; }
.chd-card .card-features li::before { color: var(--chd); }
.studio-card .card-features li::before { color: var(--pink); }
.card-arrow { font-family: var(--font-display); font-size: 20px; color: var(--muted); text-align: right; position: relative; z-index: 1; }

.studio-app { width: min(1240px, calc(100% - 32px)); }
.studio-transport .keep-floor { margin-left: 4px; }
.sample-grid {
  padding: 16px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.sample-slot {
  min-height: 98px;
  border: 1px solid var(--border2);
  border-radius: 8px;
  background: rgba(8, 9, 13, 0.5);
  padding: 13px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 9px;
  cursor: pointer;
  transition: transform 0.16s, border-color 0.16s;
}
.sample-slot:hover { transform: translateY(-1px); border-color: var(--mel); }
.sample-slot span { font-family: var(--font-display); font-size: 22px; color: var(--text); letter-spacing: 0.04em; }
.sample-slot em { font-family: var(--font-mono); font-style: normal; font-size: 10px; color: var(--muted); overflow-wrap: anywhere; }
.sample-slot input { width: 100%; color: var(--muted); font-family: var(--font-mono); font-size: 10px; }
.timeline {
  padding: 16px;
  display: flex;
  gap: 7px;
  min-height: 84px;
}
.timeline-section {
  border: 1px solid var(--border2);
  border-radius: 8px;
  background: linear-gradient(135deg, rgba(232, 197, 71, 0.12), rgba(71, 197, 232, 0.08));
  padding: 12px;
  min-width: 90px;
}
.timeline-section strong { display: block; font-family: var(--font-display); font-size: 23px; color: var(--mel); letter-spacing: 0.04em; }
.timeline-section span { font-family: var(--font-mono); font-size: 10px; color: var(--muted); }
.arrangement-length { color: var(--mel); }
.visualizer {
  display: block;
  width: calc(100% - 32px);
  height: 220px;
  margin: 0 16px 16px;
  border: 1px solid var(--border2);
  border-radius: 8px;
  background: rgba(8, 9, 13, 0.64);
}
.studio-lanes { padding: 0 16px 16px; display: flex; flex-direction: column; gap: 7px; }
.studio-lane { display: grid; grid-template-columns: 84px 1fr; gap: 10px; align-items: center; }
.studio-lane span { font-family: var(--font-mono); font-size: 10px; color: var(--muted); }
.lane-steps {
  display: grid;
  grid-template-columns: repeat(128, 1fr);
  gap: 2px;
  min-height: 12px;
}
.lane-steps i {
  display: block;
  min-width: 2px;
  height: 12px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.08);
}
.lane-steps i.on { background: var(--mel); box-shadow: 0 0 8px rgba(232, 197, 71, 0.35); }
.lane-steps i.barline { border-left: 1px solid rgba(71, 197, 232, 0.4); }

@keyframes bgShift {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}

@media (max-width: 920px) {
  .ctrl-panel { grid-template-columns: 1fr; }
  .selects-panel { border-left: none; padding-left: 0; border-top: 1px solid var(--border); padding-top: 14px; }
  .module-cards { grid-template-columns: 1fr; }
  .sample-grid { grid-template-columns: repeat(2, 1fr); }
  .prog-bar { flex-wrap: wrap; }
}

@media (max-width: 680px) {
  .app, .studio-app { width: min(100% - 20px, 1180px); padding-top: 10px; }
  .header { align-items: flex-start; flex-direction: column; }
  .header-right { justify-content: flex-start; width: 100%; }
  .transport-bar { align-items: stretch; }
  .t-ctrl { width: 100%; justify-content: space-between; }
  .t-ctrl input[type=range] { flex: 1; width: auto; }
  .t-buttons { width: 100%; margin-left: 0; }
  .t-btn { flex: 1 1 130px; padding-inline: 10px; }
  .knobs { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .knob-svg { width: 62px; height: 62px; }
  .selects-panel { grid-template-columns: 1fr; }
  .sample-grid { grid-template-columns: 1fr; }
  .timeline { overflow-x: auto; }
  .timeline-section { min-width: 135px; }
  .studio-lane { grid-template-columns: 62px 1fr; }
  .lane-steps { grid-template-columns: repeat(64, 1fr); }
  .footer { flex-direction: column; align-items: flex-start; }
  .logo-main { font-size: 30px; }
  .hero-title { font-size: 64px; }
  .hero-subtitle { font-size: 15px; }
}
