:root {
  --bg: #0b1324;
  --bg-soft: #111c33;
  --panel: #0f1f36;
  --border: rgba(255, 255, 255, 0.08);
  --text: #e8f0fb;
  --muted: #9fb2c9;
  --accent: #ff7a4a;
  --accent-2: #2dd7a3;
  --shadow: 0 16px 40px rgba(0, 0, 0, 0.45);
}

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

body {
  margin: 0;
  font-family: "Avenir Next", "Futura", "Trebuchet MS", sans-serif;
  background: radial-gradient(120% 140% at 20% 20%, #11294e, #0b1324 60%),
    radial-gradient(80% 80% at 80% 0%, rgba(255, 122, 74, 0.22), transparent 50%),
    var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
}

.background {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(50% 50% at 70% 20%, rgba(45, 215, 163, 0.15), transparent 50%);
  z-index: 0;
}

.shell {
  position: relative;
  z-index: 1;
  max-width: 1100px;
  margin: 0 auto;
  padding: 48px 22px 72px;
}

.hero {
  margin-bottom: 28px;
}

.hero h1 {
  font-size: 38px;
  margin: 6px 0 10px;
  letter-spacing: -0.02em;
}

.hero .lede {
  color: var(--muted);
  max-width: 760px;
  margin: 0;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 12px;
  color: var(--accent-2);
  margin: 0;
}

.panel {
  background: linear-gradient(120deg, rgba(255, 255, 255, 0.02), transparent),
    var(--panel);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  border-radius: 18px;
  padding: 22px 22px 18px;
  margin-bottom: 18px;
}

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

.panel h2 {
  margin: 4px 0 0;
  letter-spacing: -0.01em;
}

.control-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}

.control {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
}

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

.slider-labels {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 12px;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

.label {
  font-weight: 700;
  display: block;
  margin-bottom: 6px;
}

.row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

select,
button,
input {
  font-family: inherit;
}

select {
  background: #0b162a;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  min-width: 120px;
  font-size: 15px;
}

select:focus {
  outline: 1px solid var(--accent-2);
  box-shadow: 0 0 0 3px rgba(45, 215, 163, 0.2);
}

.input {
  width: 100%;
  background: #0b162a;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 15px;
}

.input:focus {
  outline: 1px solid var(--accent-2);
  box-shadow: 0 0 0 3px rgba(45, 215, 163, 0.2);
}

button {
  border: none;
  cursor: pointer;
}

.primary {
  background: linear-gradient(120deg, var(--accent), #ff9d60);
  color: #0c0c0c;
  border-radius: 12px;
  padding: 10px 16px;
  font-weight: 700;
  transition: transform 120ms ease, box-shadow 120ms ease;
  box-shadow: 0 8px 20px rgba(255, 122, 74, 0.35);
}

.primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 24px rgba(255, 122, 74, 0.4);
}

.ghost {
  background: transparent;
  color: var(--muted);
  border: 1px dashed var(--border);
  border-radius: 12px;
  padding: 10px 14px;
  transition: color 120ms ease, border-color 120ms ease, transform 120ms ease;
}

.ghost:hover {
  color: var(--text);
  border-color: rgba(255, 255, 255, 0.25);
  transform: translateY(-1px);
}

.note-form {
  display: flex;
  gap: 8px;
  align-items: center;
}

.hint {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.note-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 10px 2px 4px;
  min-height: 52px;
}

.note-list.slim {
  min-height: 0;
  padding: 8px 2px 0;
}

.note-list.empty-state {
  border: 1px dashed var(--border);
  border-radius: 12px;
  padding: 18px;
  color: var(--muted);
}

.note-chip {
  position: relative;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 14px;
  padding: 8px 12px 8px 12px;
  display: flex;
  gap: 8px;
  align-items: center;
  min-width: 72px;
  transition: border-color 120ms ease, background 120ms ease, transform 120ms ease;
}

.note-chip .note-label {
  font-weight: 800;
  letter-spacing: 0.01em;
}

.note-chip .chip-meta {
  color: var(--muted);
  font-size: 13px;
}

.note-chip .chip-remove {
  background: rgba(255, 255, 255, 0.08);
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  font-weight: 800;
  transition: background 120ms ease;
}

.note-chip:hover {
  border-color: rgba(255, 255, 255, 0.18);
  transform: translateY(-1px);
}

.note-chip:hover .chip-remove {
  background: rgba(255, 255, 255, 0.16);
}

.note-chip.active {
  border-color: var(--accent-2);
  background: linear-gradient(120deg, rgba(45, 215, 163, 0.12), rgba(255, 255, 255, 0.03));
}

.context-summary {
  margin-top: 6px;
  color: var(--muted);
  font-size: 14px;
}

.key-pill {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
  font-size: 14px;
}

.key-pill strong {
  color: var(--text);
}

.status {
  margin-bottom: 6px;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 12px;
}

.chord-card {
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
  border-radius: 16px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 140px;
  transition: border-color 120ms ease, transform 120ms ease;
}

.chord-card:hover {
  border-color: rgba(255, 255, 255, 0.18);
  transform: translateY(-2px);
}

.chord-heading {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.chord-name {
  font-size: 22px;
  margin: 0;
  letter-spacing: -0.01em;
}

.chord-sub {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.tone-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  font-weight: 700;
}

.tone-row .tone {
  background: rgba(45, 215, 163, 0.14);
  color: var(--text);
  padding: 6px 8px;
  border-radius: 10px;
  font-size: 14px;
}

.tag-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.tag {
  padding: 6px 8px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.tag.family {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  color: var(--text);
}

.tag.inkey {
  background: rgba(45, 215, 163, 0.16);
  border: 1px solid rgba(45, 215, 163, 0.4);
  color: #0f2a21;
}

.tag.colorful {
  background: rgba(255, 122, 74, 0.22);
  border: 1px solid rgba(255, 122, 74, 0.5);
  color: #2b1107;
}

.tag.outkey {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border);
  color: var(--muted);
}

.tag.voice {
  background: rgba(45, 215, 163, 0.12);
  border: 1px solid rgba(45, 215, 163, 0.3);
  color: #0f2a21;
}

.tag.dissonance {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border);
}

.tag.diss-low {
  color: #0f2a21;
  background: rgba(45, 215, 163, 0.18);
  border-color: rgba(45, 215, 163, 0.4);
}

.tag.diss-mid {
  color: #2b1107;
  background: rgba(255, 122, 74, 0.2);
  border-color: rgba(255, 122, 74, 0.5);
}

.tag.diss-high {
  color: #250c2a;
  background: rgba(178, 102, 255, 0.22);
  border-color: rgba(178, 102, 255, 0.45);
}

.play-btn {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 10px;
  padding: 6px 10px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.play-btn:hover {
  border-color: rgba(255, 255, 255, 0.2);
}

.results-toolbar {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.chip-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.chip {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 12px;
  padding: 6px 10px;
  cursor: pointer;
}

.chip.active {
  outline: 2px solid rgba(255, 255, 255, 0.25);
}

.next-chips {
  margin-bottom: 10px;
}

.tone-row.compact {
  opacity: 0.9;
}

.tone-row .tone.more {
  background: rgba(255, 255, 255, 0.08);
  color: var(--muted);
}

.tone-details summary {
  margin-top: 8px;
}

.inline-details summary {
  cursor: pointer;
}

.keyboard {
  position: relative;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  margin-top: 10px;
  height: 150px;
}

.keyboard-inner {
  position: relative;
  height: 100%;
  display: flex;
}

.white-key {
  position: relative;
  flex: 1 1 0;
  margin: 0 2px;
  background: linear-gradient(180deg, #f7f7f7, #e4e4e4);
  border: 1px solid #cfcfcf;
  border-radius: 6px;
  box-shadow: inset 0 -3px 6px rgba(0, 0, 0, 0.25);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  font-weight: 700;
  color: #111;
  padding-bottom: 6px;
  cursor: pointer;
}

.white-key.palette {
  outline: 2px solid var(--accent-2);
}

.white-key.chord {
  outline: 2px solid var(--accent);
}

.white-key.active {
  box-shadow: 0 0 0 2px var(--accent), inset 0 -3px 6px rgba(0, 0, 0, 0.25);
}

.white-key.scale {
  background: linear-gradient(180deg, #e8fff6, #d6f6eb);
}

.white-key .degree {
  position: absolute;
  top: 6px;
  font-size: 11px;
  color: #444;
}

.black-key {
  position: absolute;
  width: 60%;
  height: 60%;
  top: 0;
  left: 70%;
  transform: translateX(-50%);
  background: linear-gradient(180deg, #222, #000);
  border-radius: 6px;
  box-shadow: inset 0 -3px 6px rgba(0, 0, 0, 0.45);
  z-index: 2;
  border: 1px solid #111;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  color: #eee;
  font-size: 12px;
  padding-bottom: 4px;
  cursor: pointer;
}

.black-key.palette {
  outline: 2px solid var(--accent-2);
}

.black-key.chord {
  outline: 2px solid var(--accent);
}

.black-key.active {
  box-shadow: 0 0 0 2px var(--accent), inset 0 -3px 6px rgba(0, 0, 0, 0.45);
}

.black-key.scale {
  background: linear-gradient(180deg, #3b6252, #19382c);
}

.tone .tone-label {
  display: block;
  font-size: 11px;
  color: var(--muted);
}

@media (max-width: 720px) {
  .hero h1 {
    font-size: 30px;
  }

  .panel-title {
    flex-direction: column;
    align-items: flex-start;
  }

  .note-form,
  .row {
    flex-direction: column;
  }

  select,
  .primary,
  .ghost {
    width: 100%;
  }

  .card-grid {
    grid-template-columns: 1fr;
  }
}
