:root {
  color-scheme: light;
  --ink: #17211f;
  --muted: #66716e;
  --panel: #fffdf7;
  --paper: #f5f0e6;
  --line: #d2c4ad;
  --fret: #8d8174;
  --nut: #242424;
  --string: rgba(42, 47, 45, 0.48);
  --wood-a: #b7743c;
  --wood-b: #d69a58;
  --root: #d5333f;
  --scale: #f0c93b;
  --interval: #2c8bbd;
  --gb: #7a4cc2;
  --shadow: 0 18px 50px rgba(34, 30, 24, 0.18);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.58), rgba(255, 255, 255, 0)),
    #e8ece6;
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
select {
  font: inherit;
}

.app-shell {
  display: grid;
  gap: 18px;
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 24px;
}

.control-panel {
  display: grid;
  grid-template-columns: 1fr;
  gap: 22px;
  align-items: end;
  padding: 20px;
  background: var(--panel);
  border: 1px solid rgba(23, 33, 31, 0.12);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.mode-row,
.mode-controls {
  grid-column: 1;
}

.mode-row {
  display: grid;
  grid-template-columns: 64px minmax(260px, 420px);
  gap: 10px;
  align-items: center;
}

.mode-row > span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.mode-controls {
  min-width: 0;
}

.sub-controls {
  display: none;
  gap: 14px;
  align-items: end;
}

.sub-controls.is-active {
  display: grid;
  grid-template-columns: repeat(3, minmax(140px, 1fr)) minmax(220px, 1.35fr);
}

.sub-controls[data-mode-controls="scale"].is-active {
  grid-template-columns: 1fr;
}

.sub-copy {
  align-self: center;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.brand-block {
  min-width: 0;
}

.eyebrow {
  margin: 0 0 8px;
  color: #4c6f67;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  max-width: 760px;
  font-size: clamp(1.7rem, 3vw, 3rem);
  line-height: 0.98;
  letter-spacing: 0;
}

.controls-grid {
  display: grid;
  grid-template-columns: 120px minmax(190px, 1fr) minmax(250px, 1.2fr) minmax(260px, 1.25fr);
  gap: 14px;
  align-items: end;
}

.field {
  display: grid;
  gap: 7px;
  min-width: 0;
}

.field > span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

select {
  width: 100%;
  min-height: 42px;
  padding: 0 34px 0 12px;
  border: 1px solid rgba(23, 33, 31, 0.18);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
}

.segmented {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  min-height: 42px;
  overflow: hidden;
  border: 1px solid rgba(23, 33, 31, 0.18);
  border-radius: 8px;
  background: #ffffff;
}

.segment {
  min-width: 0;
  border: 0;
  border-right: 1px solid rgba(23, 33, 31, 0.14);
  background: transparent;
  color: #40504c;
  cursor: pointer;
  font-weight: 750;
  line-height: 1;
}

.segment:last-child {
  border-right: 0;
}

.segment.is-active {
  background: #1f5950;
  color: #ffffff;
}

.legend-row {
  display: flex;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
  min-height: 52px;
}

.scale-summary {
  display: flex;
  gap: 12px;
  align-items: baseline;
  min-width: 0;
}

.scale-summary span {
  color: var(--muted);
  overflow-wrap: anywhere;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  color: var(--muted);
  font-size: 0.92rem;
  white-space: nowrap;
}

.legend span {
  display: inline-flex;
  gap: 7px;
  align-items: center;
}

.legend-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid rgba(0, 0, 0, 0.58);
}

.root-dot {
  background: var(--root);
}

.scale-dot {
  background: var(--scale);
}

.muted-dot {
  background: #cfd8d4;
}

.gb-dot {
  background: var(--gb);
}

.fretboard-wrap {
  border-radius: 8px;
  background: #25302d;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.fretboard-scroll {
  overflow-x: auto;
  padding: 28px 18px 48px;
}

.fretboard {
  position: relative;
  display: grid;
  grid-template-columns: 66px repeat(22, 58px);
  grid-template-rows: repeat(6, 54px) 46px;
  min-width: 1342px;
  isolation: isolate;
}

.fretboard::before {
  content: "";
  position: absolute;
  inset: 0 0 46px 0;
  z-index: -2;
  border: 2px solid rgba(255, 255, 255, 0.62);
  border-radius: 8px;
  background:
    radial-gradient(circle at 20% 45%, rgba(255, 255, 255, 0.12) 0 2px, transparent 3px),
    linear-gradient(90deg, var(--wood-a), var(--wood-b) 45%, #c58b4d);
}

.open-cell,
.note-cell {
  position: relative;
  display: grid;
  place-items: center;
  min-width: 0;
}

.note-cell {
  border-left: 3px solid var(--fret);
}

.note-cell.fret-12,
.note-cell.fret-24 {
  background: rgba(76, 111, 103, 0.22);
}

.note-cell.in-position {
  background: rgba(255, 241, 152, 0.2);
}

.note-cell::after,
.open-cell::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  height: var(--string-height);
  transform: translateY(-50%);
  background: var(--string);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.28);
}

.open-cell {
  border-right: 8px solid var(--nut);
  background: rgba(245, 240, 230, 0.28);
}

.string-name {
  position: absolute;
  left: 8px;
  top: 50%;
  z-index: 2;
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  transform: translateY(-50%);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.92);
  border: 2px solid rgba(0, 0, 0, 0.55);
  font-size: 0.82rem;
  font-weight: 900;
}

.marker {
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  border: 3px solid rgba(0, 0, 0, 0.78);
  background: var(--scale);
  color: #141414;
  font-size: 0.82rem;
  font-weight: 950;
  line-height: 1;
  box-shadow: 0 3px 7px rgba(0, 0, 0, 0.34);
}

.marker.root {
  background: var(--root);
  color: #ffffff;
}

.marker.interval-label {
  background: var(--interval);
  color: #ffffff;
}

.marker.featured {
  width: 39px;
  height: 39px;
  border-width: 4px;
  box-shadow: 0 0 0 5px rgba(255, 255, 255, 0.32), 0 5px 10px rgba(0, 0, 0, 0.38);
}

.marker.gb-adjusted {
  box-shadow: 0 0 0 5px rgba(122, 76, 194, 0.42), 0 5px 10px rgba(0, 0, 0, 0.38);
}

.marker.gb-adjusted::after {
  content: "+1";
  position: absolute;
  right: -11px;
  top: -11px;
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--gb);
  color: #ffffff;
  font-size: 0.62rem;
  font-weight: 950;
  border: 2px solid #ffffff;
}

.muted .marker,
.muted .string-name {
  opacity: 0.22;
}

.muted::before {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.28);
}

.fret-label {
  display: grid;
  place-items: start center;
  padding-top: 10px;
  color: #ffffff;
  font-size: 0.82rem;
  font-weight: 900;
  line-height: 1.05;
  text-align: center;
}

.position-dot {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: -1;
  width: 16px;
  height: 16px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.4);
}

.double-dot-top,
.double-dot-bottom {
  position: absolute;
  left: 50%;
  z-index: -1;
  width: 14px;
  height: 14px;
  transform: translateX(-50%);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.42);
}

.double-dot-top {
  top: 88px;
}

.double-dot-bottom {
  bottom: 88px;
}

.practice-strip {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr) 46px;
  gap: 12px;
  align-items: center;
  padding: 14px;
  background: #ffffff;
  border: 1px solid rgba(23, 33, 31, 0.12);
  border-radius: 8px;
}

.icon-button {
  width: 46px;
  height: 46px;
  border: 1px solid rgba(23, 33, 31, 0.16);
  border-radius: 8px;
  background: #f6f8f6;
  color: #1f5950;
  cursor: pointer;
  font-size: 2rem;
  line-height: 1;
}

.practice-copy {
  display: grid;
  gap: 3px;
  min-width: 0;
  text-align: center;
}

.practice-copy span {
  font-weight: 900;
}

.practice-copy small {
  color: var(--muted);
}

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

  .sub-controls.is-active {
    grid-template-columns: 1fr 1fr;
  }
}

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

  .control-panel {
    padding: 16px;
  }

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

  .mode-row {
    grid-template-columns: 1fr;
  }

  .sub-controls.is-active {
    grid-template-columns: 1fr;
  }

  .legend-row,
  .scale-summary {
    align-items: flex-start;
    flex-direction: column;
  }

  .fretboard-scroll {
    padding: 18px 10px 38px;
  }
}
