:root {
  color-scheme: dark;
  --app-bg: #101214;
  --surface: #1b1f23;
  --surface-strong: #24282d;
  --line: rgba(255, 255, 255, 0.14);
  --text-soft: #b9c1cc;
  --accent: #d17a19;
  --playhead: #f0c859;
  --blue: #57b7c5;
}

body {
  min-height: 100vh;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 14% 0%, rgba(87, 183, 197, 0.16), transparent 23rem),
    linear-gradient(145deg, var(--app-bg), #171a1e 58%, #101214);
}

.app-nav {
  min-height: 3rem;
  border-bottom: 1px solid var(--line);
  background: rgba(25, 28, 32, 0.94);
  backdrop-filter: blur(0.75rem);
}

.brand-mark {
  width: 1.8rem;
  height: 1.8rem;
  border-radius: 0.35rem;
}

.navbar-brand {
  font-size: 0.92rem;
  font-weight: 800;
}

.page-title {
  color: #fff;
  font-size: 0.88rem;
  font-weight: 900;
}

.chords-shell {
  width: min(100%, 76rem);
  margin: 0 auto;
  padding: 1rem;
}

.chords-top,
.control-panel,
.instrument-heading,
.instrument-grid,
.favorites-heading {
  display: grid;
  gap: 1rem;
}

.chords-top {
  align-items: end;
  margin: 0.6rem 0 1rem;
}

.chords-title h1 {
  margin: 0;
  font-size: clamp(2.35rem, 14vw, 5rem);
  line-height: 0.96;
}

.chords-title p {
  margin: 0.45rem 0 0;
  color: #fff;
  font-size: 1.05rem;
  font-weight: 900;
}

.selection-kicker {
  display: block;
  color: var(--playhead);
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.08rem;
  text-transform: uppercase;
}

.top-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.play-icon-button {
  display: grid;
  place-items: center;
  width: 2.75rem;
  min-width: 2.75rem;
  height: 2.75rem;
  padding: 0;
  border-radius: 0.3rem;
}

.play-icon {
  width: 0;
  height: 0;
  border-top: 0.48rem solid transparent;
  border-bottom: 0.48rem solid transparent;
  border-left: 0.75rem solid currentColor;
  transform: translateX(0.08rem);
}

.control-panel,
.instrument-panel,
.favorites-panel {
  margin-top: 1rem;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  background: rgba(27, 31, 35, 0.88);
  box-shadow: 0 0.85rem 2.2rem rgba(0, 0, 0, 0.22);
}

.control-field,
.type-field {
  display: grid;
  gap: 0.35rem;
}

.control-field span,
.type-field legend {
  margin: 0;
  color: var(--text-soft);
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
}

.type-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.type-heading .btn {
  min-height: 2rem;
  border-radius: 0.3rem;
  font-size: 0.76rem;
  font-weight: 850;
}

.type-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.type-button {
  display: grid;
  place-items: center;
  min-height: 2.45rem;
  min-width: 3.75rem;
  padding: 0.4rem 0.7rem;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 0.38rem;
  background: rgba(255, 255, 255, 0.055);
  color: #fff;
  font-weight: 850;
}

.type-button.active {
  border-color: rgba(240, 200, 89, 0.86);
  background: rgba(209, 122, 25, 0.24);
  color: #fff;
}

.instrument-heading {
  align-items: start;
  margin-bottom: 1rem;
}

.instrument-heading h2,
.favorites-heading h2 {
  margin: 0;
  font-size: clamp(1.35rem, 7vw, 2.35rem);
}

.voicing-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.voicing-controls .btn {
  display: grid;
  place-items: center;
  width: 2.15rem;
  min-width: 2.15rem;
  height: 2.15rem;
  padding: 0;
  border-radius: 0.28rem;
  font-size: 1.2rem;
  font-weight: 900;
}

#voicingLabel {
  color: var(--text-soft);
  font-size: 0.82rem;
  font-weight: 850;
}

.instrument-block {
  display: grid;
  gap: 0.75rem;
  min-width: 0;
}

.instrument-block h3 {
  margin: 0;
  font-size: 0.92rem;
  font-weight: 900;
}

.ear-piano {
  position: relative;
  width: 100%;
  max-width: 50rem;
  aspect-ratio: 15 / 3.4;
  margin: 0 auto;
  touch-action: manipulation;
}

.piano-whites {
  display: grid;
  grid-template-columns: repeat(15, minmax(0, 1fr));
  height: 100%;
}

.piano-key {
  position: relative;
  border: 1px solid #29313b;
  color: #12161c;
  font-weight: 800;
  line-height: 1;
}

.piano-key.white {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0 0.1rem 0.45rem;
  border-radius: 0 0 0.28rem 0.28rem;
  background: linear-gradient(#f8f7ee, #d7d5c9);
  font-size: clamp(0.62rem, 2.4vw, 0.84rem);
}

.piano-key.black {
  position: absolute;
  top: 0;
  z-index: 3;
  width: 5.25%;
  height: 61%;
  padding: 0 0.05rem 0.35rem;
  border-color: #06080a;
  border-radius: 0 0 0.24rem 0.24rem;
  background: linear-gradient(#252b32, #050607);
  color: #f3f5f7;
  font-size: clamp(0.52rem, 1.9vw, 0.72rem);
}

.piano-key.is-highlighted {
  border-color: #ffe27a;
  outline: 0.28rem solid #ffe27a;
  outline-offset: -0.34rem;
  box-shadow:
    inset 0 0 0 999rem rgba(255, 226, 122, 0.34),
    0 0 1.15rem rgba(255, 226, 122, 0.86);
  transform: translateY(-0.16rem);
}

.piano-key.is-root {
  border-color: #61d9ff;
  outline-color: #61d9ff;
  box-shadow:
    inset 0 0 0 999rem rgba(97, 217, 255, 0.34),
    0 0 1.15rem rgba(97, 217, 255, 0.84);
}

.piano-key:focus-visible {
  outline: 0.2rem solid var(--accent);
  outline-offset: -0.2rem;
}

.piano-key.is-flashing {
  animation: piano-key-flash 220ms ease-out;
}

@keyframes piano-key-flash {
  50% {
    filter: brightness(1.38);
    box-shadow: 0 0 1rem rgba(255, 255, 255, 0.8);
  }
}

.guitar-diagram {
  display: grid;
  gap: 0.45rem;
  width: min(100%, 27rem);
  margin: 0 auto;
}

.guitar-neck {
  position: relative;
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  min-height: 12rem;
  border-top: 0.38rem solid rgba(255, 255, 255, 0.62);
  border-right: 1px solid rgba(255, 255, 255, 0.18);
  border-bottom: 1px solid rgba(255, 255, 255, 0.18);
  border-left: 1px solid rgba(255, 255, 255, 0.18);
  background:
    repeating-linear-gradient(180deg, transparent 0 calc(20% - 1px), rgba(255, 255, 255, 0.2) calc(20% - 1px) 20%),
    linear-gradient(90deg, rgba(255, 255, 255, 0.11) 0 1px, transparent 1px);
  background-size: 100% 100%, calc(100% / 12) 100%;
}

.guitar-string {
  position: relative;
  border-left: 1px solid rgba(255, 255, 255, 0.3);
}

.guitar-string:last-child {
  border-right: 1px solid rgba(255, 255, 255, 0.3);
}

.fret-marker {
  position: absolute;
  left: 50%;
  display: grid;
  place-items: center;
  width: 1.7rem;
  height: 1.7rem;
  border: 2px solid rgba(16, 18, 20, 0.8);
  border-radius: 999rem;
  color: #101214;
  background: #ffe27a;
  box-shadow: 0 0 0.75rem rgba(255, 226, 122, 0.55);
  font-size: 0.82rem;
  font-weight: 950;
  transform: translate(-50%, -50%);
}

.fret-marker,
.open-muted-row button {
  cursor: pointer;
}

.fret-marker:focus-visible,
.open-muted-row button:focus-visible {
  outline: 0.2rem solid var(--blue);
  outline-offset: 0.12rem;
}

.fret-marker.is-playing,
.open-muted-row button.is-playing {
  filter: brightness(1.3);
  box-shadow: 0 0 1rem rgba(255, 226, 122, 0.88);
}

.fret-marker.is-root {
  background: #61d9ff;
  box-shadow: 0 0 0.75rem rgba(97, 217, 255, 0.6);
}

.open-muted-row,
.string-name-row {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 0;
  text-align: center;
}

.open-muted-row span,
.open-muted-row button,
.string-name-row span {
  color: var(--text-soft);
  font-size: 0.75rem;
  font-weight: 900;
}

.open-muted-row button {
  display: grid;
  place-items: center;
  width: 1.7rem;
  height: 1.7rem;
  margin: 0 auto;
  border: 2px solid rgba(16, 18, 20, 0.8);
  border-radius: 999rem;
  color: #101214;
  background: #ffe27a;
  box-shadow: 0 0 0.75rem rgba(255, 226, 122, 0.55);
}

.open-muted-row span.is-played,
.open-muted-row button.is-played {
  color: #ffe27a;
}

.open-muted-row button.is-played {
  color: #101214;
}

.guitar-empty {
  margin: 0;
  padding: 2rem 1rem;
  border: 1px dashed rgba(255, 255, 255, 0.18);
  border-radius: 0.5rem;
  color: var(--text-soft);
  text-align: center;
}

.favorite-list {
  display: grid;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.favorite-row {
  display: grid;
  gap: 0.75rem;
  padding: 0.75rem;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 0.45rem;
  background: rgba(255, 255, 255, 0.045);
}

.favorite-title {
  color: #fff;
  font-weight: 900;
}

.favorite-meta {
  color: var(--text-soft);
  font-size: 0.82rem;
}

.favorite-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

@media (min-width: 48rem) {
  .chords-top,
  .instrument-heading,
  .favorites-heading {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .control-panel {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    align-items: start;
  }

  .type-field {
    grid-column: 1 / -1;
  }

  .favorite-row {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
  }
}

@media (min-width: 62rem) {
  .instrument-grid {
    grid-template-columns: minmax(0, 1fr) minmax(18rem, 28rem);
    align-items: start;
  }
}
