:root {
  --bg: #0f1117;
  --surface: #181c27;
  --surface-raised: #222836;
  --border: #2e3548;
  --text: #e8ecf4;
  --text-muted: #8b95ad;
  --accent: #f0a030;
  --accent-soft: rgba(240, 160, 48, 0.15);
  --root: #f0a030;
  --root-glow: rgba(240, 160, 48, 0.45);
  --scale-note: #4ecdc4;
  --scale-soft: rgba(78, 205, 196, 0.18);
  --major: #6c9cff;
  --minor: #c084fc;
  --radius: 12px;
  --font: "DM Sans", system-ui, sans-serif;
  --mono: "JetBrains Mono", monospace;
}

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

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  background:
    radial-gradient(ellipse 80% 50% at 50% -20%, rgba(108, 156, 255, 0.12), transparent),
    radial-gradient(ellipse 60% 40% at 100% 100%, rgba(192, 132, 252, 0.08), transparent),
    var(--bg);
  color: var(--text);
  line-height: 1.5;
}

.app {
  max-width: 1100px;
  margin: 0 auto;
  padding: 2rem 1.25rem 4rem;
}

.header {
  margin-bottom: 2.5rem;
}

.header__brand {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.header__icon {
  display: grid;
  place-items: center;
  width: 3rem;
  height: 3rem;
  border-radius: var(--radius);
  background: var(--surface-raised);
  border: 1px solid var(--border);
  font-size: 1.4rem;
  color: var(--accent);
}

.header h1 {
  margin: 0;
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.header__subtitle {
  margin: 0.15rem 0 0;
  color: var(--text-muted);
  font-size: 0.95rem;
}

.main {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) + 4px);
  padding: 1.5rem;
}

.panel--controls {
  display: flex;
  flex-direction: column;
  gap: 1.75rem;
}

.control-group--hidden {
  display: none;
}

.control-label {
  margin: 0 0 0.75rem;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

.btn-group {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.btn {
  cursor: pointer;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-raised);
  color: var(--text);
  padding: 0.65rem 1.25rem;
  transition: border-color 0.15s, background 0.15s, transform 0.1s;
}

.btn:hover {
  border-color: var(--text-muted);
}

.btn:active {
  transform: scale(0.98);
}

.btn--family[data-family="major"].is-active {
  background: rgba(108, 156, 255, 0.18);
  border-color: var(--major);
  color: #a8c4ff;
}

.btn--family[data-family="minor"].is-active {
  background: rgba(192, 132, 252, 0.18);
  border-color: var(--minor);
  color: #ddb8ff;
}

.mode-grid,
.key-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.btn--mode,
.btn--key {
  min-width: 7rem;
}

.btn--mode.is-active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}

.btn--key.is-active {
  background: var(--scale-soft);
  border-color: var(--scale-note);
  color: var(--scale-note);
}

.mode-btn__alias {
  display: block;
  font-size: 0.72rem;
  font-weight: 400;
  color: var(--text-muted);
  margin-top: 0.1rem;
}

.btn--mode.is-active .mode-btn__alias {
  color: inherit;
  opacity: 0.75;
}

.results-header {
  margin-bottom: 1.5rem;
}

#scale-title {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 700;
}

.results-description {
  margin: 0.35rem 0 0;
  color: var(--text-muted);
}

.positions {
  display: grid;
  gap: 1.25rem;
  margin-bottom: 2rem;
}

.position-card {
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1rem 1.25rem;
  overflow-x: auto;
}

.position-card__title {
  margin: 0 0 0.75rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
}

.fretboard {
  display: inline-grid;
  gap: 0;
  min-width: min-content;
}

.fretboard__string {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 3.25rem;
  align-items: center;
  position: relative;
}

.fretboard__string::before {
  content: "";
  position: absolute;
  left: 1.6rem;
  right: 0;
  top: 50%;
  height: 2px;
  background: linear-gradient(90deg, #5a6278, #3d4458);
  z-index: 0;
}

.fretboard__string-label {
  width: 1.4rem;
  font-family: var(--mono);
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted);
  text-align: right;
  padding-right: 0.35rem;
  z-index: 1;
}

.fretboard__cell {
  position: relative;
  height: 2.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1;
}

.fretboard__cell::after {
  content: "";
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: #4a5168;
  border-radius: 1px;
}

.fretboard__cell:last-child::after {
  display: none;
}

.fretboard__fret-num {
  position: absolute;
  top: -1.1rem;
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--mono);
  font-size: 0.65rem;
  color: var(--text-muted);
}

.fretboard__note {
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-family: var(--mono);
  font-size: 0.62rem;
  font-weight: 500;
  background: var(--scale-soft);
  color: var(--scale-note);
  border: 2px solid var(--scale-note);
}

.fretboard__note--root {
  background: var(--accent-soft);
  color: var(--root);
  border-color: var(--root);
  box-shadow: 0 0 12px var(--root-glow);
  font-weight: 700;
}

.fretboard-legend {
  display: flex;
  gap: 1.25rem;
  margin-top: 0.85rem;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.legend-dot {
  width: 0.75rem;
  height: 0.75rem;
  border-radius: 50%;
  border: 2px solid;
}

.legend-dot--root {
  background: var(--accent-soft);
  border-color: var(--root);
}

.legend-dot--scale {
  background: var(--scale-soft);
  border-color: var(--scale-note);
}

.chords-section h3 {
  margin: 0 0 0.35rem;
  font-size: 1.1rem;
}

.chords-hint {
  margin: 0 0 1rem;
  font-size: 0.88rem;
  color: var(--text-muted);
}

.chords-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(5.5rem, 1fr));
  gap: 0.65rem;
}

.chord-card {
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 0.5rem;
  text-align: center;
}

.chord-card__degree {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 0.2rem;
}

.chord-card__name {
  font-family: var(--mono);
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text);
}

.chord-card__quality {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
}

.empty-state__content {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-muted);
  border: 1px dashed var(--border);
  border-radius: calc(var(--radius) + 4px);
}

.empty-state--hidden {
  display: none;
}

@media (max-width: 600px) {
  .app {
    padding: 1.25rem 1rem 3rem;
  }

  .header h1 {
    font-size: 1.4rem;
  }

  .fretboard__string {
    grid-auto-columns: 2.75rem;
  }

  .fretboard__note {
    width: 1.75rem;
    height: 1.75rem;
    font-size: 0.55rem;
  }
}
