:root {
  --bg-1: #f3f4f7;
  --bg-2: #f3f4f7;
  --paper: #ffffff;
  --ink: #202532;
  --muted: #6b7280;
  --accent: #5b5bd6;
  --accent-2: #e5a24f;
  --error: #a73737;
  --ok: #1c6a42;
  --card-shadow: 0 10px 24px rgba(26, 31, 48, 0.06);
}

* {
  box-sizing: border-box;
}

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

.app-shell {
  width: min(1400px, 90vw);
  margin: 1.35rem auto 1rem;
}

.hero {
  margin-bottom: 0.55rem;
}

.top-controls {
  display: grid;
  gap: 0.6rem;
  margin-bottom: 0.85rem;
}

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

h1,
h2 {
  font-family: "Fraunces", Georgia, serif;
}

h1 {
  margin: 0.1rem 0 0.2rem;
  font-size: clamp(1.6rem, 2.5vw, 2.5rem);
  line-height: 1.1;
}

.intro {
  margin: 0;
  color: var(--muted);
  max-width: 70ch;
  font-size: 0.93rem;
}

.trainer-card {
  background: var(--paper);
  border: 1px solid rgba(32, 37, 50, 0.08);
  box-shadow: var(--card-shadow);
  border-radius: 20px;
  padding: 0.95rem;
  display: grid;
  gap: 0.8rem;
}

.scoreboard {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.question-tabs {
  display: inline-flex;
  gap: 0.35rem;
  padding: 0.25rem;
  border: 1px solid rgba(32, 37, 50, 0.08);
  border-radius: 12px;
  background: #f8f9fc;
}

.question-tab {
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  font-size: 0.95rem;
  font-weight: 700;
  padding: 0.5rem 0.8rem;
}

.question-tab:hover {
  filter: none;
  color: var(--ink);
  background: rgba(91, 91, 214, 0.08);
}

.question-tab[aria-selected="true"] {
  background: var(--paper);
  color: var(--ink);
  box-shadow: 0 1px 2px rgba(26, 31, 48, 0.08);
}

.question-tab:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--accent) 25%, white);
  outline-offset: 1px;
}

#score-label {
  font-weight: 700;
}

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

.toggle-label {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.55rem 0.7rem;
  border: 1px solid #9eb0ab;
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  font-size: 0.96rem;
}

.toggle-label input {
  width: auto;
  margin: 0;
  padding: 0;
  border: 0;
  accent-color: var(--accent);
}

.difficulty-panel {
  border: 1px solid #9eb0ab;
  border-radius: 10px;
  background: #fff;
  overflow: hidden;
}

.difficulty-panel summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  list-style: none;
  cursor: pointer;
  padding: 0.55rem 0.7rem;
  border-radius: 10px;
}

.difficulty-panel summary:hover {
  background: #f8f9fc;
}

.difficulty-panel summary::-webkit-details-marker {
  display: none;
}

.difficulty-summary-copy {
  display: grid;
  gap: 0.1rem;
}

.difficulty-panel[open] summary {
  border-bottom: 1px solid rgba(32, 37, 50, 0.08);
  border-radius: 10px 10px 0 0;
}

.difficulty-chevron {
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1;
  transition: transform 120ms ease;
}

.difficulty-panel[open] .difficulty-chevron {
  transform: rotate(180deg);
}

.difficulty-panel-body {
  display: grid;
  gap: 0.7rem;
  padding: 0.7rem;
  min-width: min(420px, 78vw);
}

.difficulty-label {
  font-size: 0.92rem;
  color: var(--muted);
}

#scale-select {
  border: 1px solid #9eb0ab;
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  font-size: 0.96rem;
  padding: 0.55rem 0.7rem;
}

#scale-select:focus {
  outline: 2px solid color-mix(in srgb, var(--accent) 25%, white);
  outline-offset: 1px;
  border-color: var(--accent);
}

#difficulty-summary-text {
  color: var(--ink);
  font-size: 0.92rem;
  font-weight: 600;
}

.difficulty-presets {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.difficulty-preset {
  border: 1px solid rgba(32, 37, 50, 0.1);
  border-radius: 9px;
  background: #f8f9fc;
  color: var(--ink);
  padding: 0.45rem 0.75rem;
}

.difficulty-preset:hover {
  filter: none;
  background: rgba(91, 91, 214, 0.08);
}

.difficulty-preset.active {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, white);
}

.difficulty-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.55rem 0.9rem;
}

.difficulty-option {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.94rem;
}

.difficulty-option input {
  width: auto;
  margin: 0;
}

#question-prompt {
  margin: 0;
  padding: 0.5rem 0.6rem;
  border: 1px solid rgba(32, 37, 50, 0.12);
  border-radius: 10px;
  background: #f8f9fc;
  color: var(--ink);
  font-weight: 600;
  font-size: 1.08rem;
}

button {
  border: 0;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  padding: 0.65rem 0.95rem;
  cursor: pointer;
  transition: transform 120ms ease, filter 120ms ease;
}

button:hover {
  filter: brightness(1.06);
}

button:active {
  transform: translateY(1px) scale(0.99);
}

.notation-wrap,
.keyboard-wrap {
  border: 1px solid rgba(32, 37, 50, 0.08);
  border-radius: 14px;
  padding: 0.55rem;
  background: #fff;
}

.keyboard-wrap {
  padding-top: 1.15rem;
}

#notation {
  width: 100%;
  min-height: 205px;
  overflow-x: auto;
}

.keyboard {
  position: relative;
  height: 156px;
  width: 100%;
  margin-top: 0.55rem;
  border: 1px solid #bac7c4;
  border-radius: 10px;
  overflow: hidden;
  background: #f8f8f6;
}

.key {
  position: absolute;
  border: 1px solid #111;
  border-radius: 0 0 6px 6px;
  transition: background-color 150ms ease;
}

.keyboard.complete-mode .key {
  cursor: pointer;
}

.keyboard.complete-mode .key:hover {
  background: color-mix(in srgb, var(--accent) 35%, white);
}

.keyboard.complete-mode .key.black:hover {
  background: color-mix(in srgb, var(--accent) 55%, black);
}

.key.white {
  background: #fff;
  width: var(--white-width);
  height: 100%;
  z-index: 1;
}

.key.white.edge-left {
  border-left: 0;
  border-bottom-left-radius: 10px;
}

.key.white.edge-right {
  border-right: 0;
  border-bottom-right-radius: 10px;
}

.key.black {
  background: #181818;
  width: var(--black-width);
  height: 62%;
  z-index: 3;
}

.key.active.white {
  background: color-mix(in srgb, var(--accent-2) 55%, white);
}

.key.active.black {
  background: color-mix(in srgb, var(--accent-2) 80%, black);
}

.key.guessed-wrong {
  box-shadow: inset 0 0 0 3px var(--error);
}

.key.black.guessed-wrong {
  box-shadow: inset 0 0 0 2px var(--error);
}

#answer-form {
  display: grid;
  gap: 0.35rem;
}

#answer-form.complete-mode #answer-label,
#answer-form.complete-mode #answer-row {
  display: none;
}

label {
  font-weight: 700;
}

.answer-row {
  display: grid;
  grid-template-columns: minmax(220px, 30%) auto;
  gap: 0.6rem;
  align-items: start;
}

.answer-row button {
  justify-self: start;
}

.autocomplete-wrap {
  position: relative;
}

input {
  width: 100%;
  border: 1px solid #9eb0ab;
  border-radius: 10px;
  font-size: 1.12rem;
  padding: 0.52rem 2.3rem 0.52rem 0.65rem;
}

input:focus {
  outline: 2px solid color-mix(in srgb, var(--accent) 25%, white);
  outline-offset: 1px;
  border-color: var(--accent);
}

.answer-expand-btn {
  position: absolute;
  top: 50%;
  right: 0.35rem;
  transform: translateY(-50%);
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  padding: 0.2rem 0.35rem;
  line-height: 1;
}

.answer-expand-btn:hover {
  filter: none;
  background: #f1f3f8;
  color: var(--ink);
}

.suggestions {
  position: absolute;
  top: calc(100% + 0.3rem);
  left: 0;
  right: 0;
  z-index: 30;
  margin: 0;
  padding: 0.2rem;
  list-style: none;
  background: #fff;
  border: 1px solid #b9c8c4;
  border-radius: 10px;
  box-shadow: 0 10px 25px rgba(16, 36, 32, 0.16);
  max-height: 160px;
  overflow-y: auto;
}

.suggestions[hidden] {
  display: none;
}

.suggestion-item {
  border-radius: 8px;
  padding: 0.42rem 0.5rem;
  cursor: pointer;
  font-size: 1.02rem;
}

.suggestion-item:hover,
.suggestion-item.active {
  background: color-mix(in srgb, var(--accent) 16%, white);
}

#feedback {
  margin: 0;
  min-height: 1.1rem;
  color: var(--muted);
  font-size: 0.93rem;
}

#feedback.good {
  color: var(--ok);
  font-weight: 700;
}

#feedback.bad {
  color: var(--error);
  font-weight: 700;
}

.chord-token {
  display: inline-block;
  font-size: 1.32em;
  line-height: 1;
}

#bass-pattern-info {
  margin: 0;
  min-height: 1rem;
  color: var(--muted);
  font-size: 0.88rem;
}

@media (min-width: 780px) {
  .trainer-card {
    grid-template-columns: fit-content(420px) minmax(0, 1fr);
    grid-template-areas:
      "notation keyboard"
      "notation prompt"
      "notation answer";
    align-items: start;
  }

  .notation-wrap {
    grid-area: notation;
    width: fit-content;
    max-width: 100%;
    justify-self: start;
  }

  .keyboard-wrap {
    grid-area: keyboard;
    min-width: 0;
  }

  #question-prompt {
    grid-area: prompt;
    min-width: 0;
  }

  #answer-form {
    grid-area: answer;
    min-width: 0;
  }
}

@media (max-width: 760px) {
  .app-shell {
    margin: 0.65rem auto 1rem;
  }

  .trainer-card {
    padding: 0.7rem;
    border-radius: 16px;
  }

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

  .controls-group {
    width: 100%;
  }

  .difficulty-panel {
    width: 100%;
  }

  .difficulty-panel-body {
    min-width: 0;
  }

  .difficulty-options {
    grid-template-columns: 1fr;
  }

  .question-tabs {
    width: 100%;
  }

  .question-tab {
    flex: 1;
  }

  #scale-select,
  #next-btn {
    flex: 1;
  }
}
