:root {
  color-scheme: light;
  --bg: #f4f7fb;
  --surface: #ffffff;
  --ink: #101828;
  --muted: #667085;
  --line: #d0d7e2;
  --accent: #2563eb;
  --accent-strong: #1e3a8a;
  --root: #ec4899;
  --third: #7c3aed;
  --fifth: #059669;
  --seventh: #f59e0b;
  --scale: #0ea5e9;
  --empty: #e8edf5;
  --shadow: 0 18px 42px rgba(16, 24, 40, 0.1);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(100%, 760px);
  min-height: 100vh;
  margin: 0 auto;
  padding: 18px 14px 32px;
}

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

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

.top-actions {
  display: flex;
  align-items: center;
  flex: 0 0 auto;
  gap: 8px;
}

.icon-button {
  display: grid;
  gap: 4px;
  place-content: center;
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 8px 18px rgba(16, 24, 40, 0.06);
}

.icon-button span {
  display: block;
  width: 18px;
  height: 2px;
  background: var(--ink);
  border-radius: 999px;
}

.title-block p,
.drawer-header p,
.challenge-item span {
  margin: 0 0 3px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.title-block h1 {
  margin: 0;
  font-size: 1.06rem;
  line-height: 1.25;
}

.prompt-panel {
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.practice-row,
.mode-row {
  margin-bottom: 12px;
}

.reference-panel {
  display: grid;
  gap: 10px;
  margin-bottom: 14px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

@media (min-width: 560px) {
  .reference-panel {
    grid-template-columns: 0.8fr 1.6fr;
  }
}

.select-field {
  display: grid;
  gap: 6px;
}

.select-field span {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
  text-transform: uppercase;
}

.select-field select {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--ink);
  font: inherit;
  font-weight: 750;
  padding: 0 10px;
}

.challenge-grid {
  display: grid;
  gap: 14px;
}

.challenge-item {
  min-width: 0;
}

.challenge-detail-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.challenge-item span,
.challenge-item strong {
  display: block;
}

.challenge-item strong {
  color: var(--ink);
  font-size: clamp(1.18rem, 5.6vw, 1.86rem);
  line-height: 1.18;
  overflow-wrap: anywhere;
}

.tone-item strong {
  color: var(--accent-strong);
  font-size: clamp(2.8rem, 18vw, 4.8rem);
  line-height: 0.98;
}

.controls-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 14px 0;
}

.audio-row {
  display: grid;
  margin: 0 0 14px;
}

.primary-button,
.secondary-button {
  min-height: 48px;
  border-radius: 8px;
  font-weight: 800;
}

.primary-button {
  border: 1px solid var(--accent-strong);
  background: var(--accent);
  color: white;
}

.secondary-button {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
}

.primary-button:disabled,
.secondary-button:disabled {
  cursor: default;
  opacity: 0.56;
}

.quick-settings {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-bottom: 14px;
}

.display-toggles {
  display: grid;
  gap: 10px;
}

.segmented-control {
  display: grid;
  grid-template-columns: repeat(var(--segment-count, 2), 1fr);
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #e8edf5;
}

.segmented-control button {
  min-height: 38px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
}

.segmented-control button[aria-pressed="true"] {
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 4px 12px rgba(16, 24, 40, 0.08);
}

.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  font-weight: 750;
}

.switch-row input {
  width: 22px;
  height: 22px;
  accent-color: var(--accent);
}

.answer-region {
  padding: 14px 0 0;
}

.fretboard-wrap {
  overflow-x: auto;
  padding-bottom: 4px;
}

.fretboard {
  display: grid;
  grid-template-columns: 44px repeat(var(--fret-count), minmax(48px, 1fr));
  min-width: calc(44px + var(--fret-count) * 54px);
  border: 1px solid #2f343c;
  border-radius: 8px;
  overflow: hidden;
  background: #343a46;
}

.string-label,
.fret-label,
.note-cell {
  min-height: 45px;
  display: grid;
  place-items: center;
}

.fret-label,
.string-label {
  background: #f8fafc;
  color: #475467;
  font-size: 0.72rem;
  font-weight: 850;
}

.string-label {
  border-top: 1px solid var(--line);
}

.fret-label {
  min-height: 30px;
  border-left: 1px solid var(--line);
}

.fret-label.octave-fret {
  color: var(--accent-strong);
  background: #edf4ff;
  border-left-color: rgba(37, 99, 235, 0.45);
}

.note-cell {
  position: relative;
  border-top: 1px solid rgba(203, 213, 225, 0.28);
  border-left: 4px solid rgba(180, 188, 200, 0.82);
  background:
    linear-gradient(transparent 48%, rgba(207, 213, 222, 0.58) 48%, rgba(207, 213, 222, 0.58) 52%, transparent 52%),
    #424957;
}

.note-cell.octave-fret {
  border-left-color: rgba(37, 99, 235, 0.5);
  box-shadow: inset 2px 0 0 rgba(37, 99, 235, 0.16);
}

.note-marker {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  border: 2px solid rgba(255, 255, 255, 0.86);
  background: var(--scale);
  color: white;
  font-size: 0.78rem;
  font-weight: 900;
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.16), 0 3px 8px rgba(0, 0, 0, 0.14);
}

.note-marker.empty {
  border-color: transparent;
  background: transparent;
  box-shadow: none;
}

.note-marker.root {
  background: var(--root);
}

.note-marker.third {
  background: var(--third);
}

.note-marker.fifth {
  background: var(--fifth);
}

.note-marker.seventh {
  background: var(--seventh);
}

.note-marker.muted {
  background: #94a3b8;
  color: #0f172a;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 28px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 750;
}

.legend-dot {
  width: 12px;
  height: 12px;
  border-radius: 999px;
  background: var(--scale);
}

.drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 10;
  background: rgba(16, 24, 40, 0.34);
}

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 11;
  width: min(88vw, 390px);
  height: 100vh;
  padding: 18px;
  overflow-y: auto;
  background: var(--surface);
  box-shadow: -20px 0 40px rgba(16, 24, 40, 0.18);
  transform: translateX(105%);
  transition: transform 180ms ease;
}

.drawer.open {
  transform: translateX(0);
}

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.drawer-header h2 {
  margin: 0;
  font-size: 1.35rem;
}

.close-button {
  flex: 0 0 42px;
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  color: var(--ink);
  font-size: 1.6rem;
  line-height: 1;
}

.drawer-content {
  display: grid;
  gap: 20px;
}

.drawer-content h3 {
  margin: 0 0 8px;
  font-size: 0.95rem;
}

.checkbox-grid {
  display: grid;
  gap: 8px;
}

.checkbox-grid.compact {
  grid-template-columns: repeat(3, 1fr);
}

.check-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  font-size: 0.9rem;
  font-weight: 750;
}

.check-pill input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.empty-state {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  font-weight: 750;
}

@media (min-width: 560px) {
  .app-shell {
    padding-inline: 22px;
  }

  .quick-settings {
    grid-template-columns: 1fr 1fr;
  }

  .display-toggles {
    grid-column: 1 / -1;
    grid-template-columns: 1fr 1fr;
  }

  .challenge-detail-row {
    grid-template-columns: 1.55fr 1fr;
    align-items: end;
  }
}
