
:root {
  --background: #f8f6f0;
  --paper: #ffffff;
  --ink: #272a35;
  --muted: #777987;
  --accent: #477b68;
  --accent-light: #e7f0e9;
  --staff: #c8c9ce;
  --border: #e8e5dc;
  --note: #303747;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--background);
  color: var(--ink);
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  line-height: 1.6;
}

button,
a {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

.app {
  width: min(100% - 36px, 900px);
  margin: 0 auto;
}

.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 24px 0;
  border-bottom: 1px solid var(--border);
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  font-size: 1.1rem;
  font-weight: 750;
  text-decoration: none;
}

.brand-icon {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  background: var(--accent);
  color: white;
  border-radius: 12px;
  font-size: 1.7rem;
}

.header-label,
.eyebrow,
.selected-label {
  font-size: 0.7rem;
  letter-spacing: 0.14em;
  font-weight: 750;
}

.header-label {
  color: var(--muted);
  text-align: right;
}

.intro {
  padding: 46px 0 30px;
  max-width: 620px;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--accent);
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 14px;
  font-size: clamp(2.2rem, 6vw, 3.6rem);
  letter-spacing: -0.055em;
  line-height: 1.1;
}

h1 span {
  color: var(--accent);
}

.description {
  max-width: 540px;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 1.03rem;
}

.lesson-card {
  padding: clamp(18px, 4vw, 34px);
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: 24px;
  box-shadow: 0 10px 35px rgb(30 35 40 / 4%);
}

.card-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
}

.card-heading .eyebrow {
  margin-bottom: 4px;
}

.card-heading h2,
.guide-heading h2 {
  margin-bottom: 0;
  font-size: 1.35rem;
  letter-spacing: -0.03em;
}

.scale-tag {
  padding: 7px 11px;
  background: var(--accent-light);
  color: var(--accent);
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 750;
  white-space: nowrap;
}

.instruction {
  margin: 22px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.staff-container {
  width: 100%;
  margin: 12px 0 0;
  overflow-x: auto;
  overflow-y: hidden;
}

#music-staff {
  display: block;
  width: 100%;
  min-width: 490px;
  height: auto;
}

.staff-lines line {
  stroke: var(--staff);
  stroke-width: 1.6;
}

.ledger-line {
  stroke: var(--note);
  stroke-width: 1.8;
}

.clef {
  fill: var(--note);
  font-family: "Noto Music", "Segoe UI Symbol", serif;
  font-size: 85px;
}

.note {
  cursor: pointer;
  outline: none;
}

.note .notehead {
  fill: var(--note);
  stroke: var(--note);
  stroke-width: 1.5;
  transition: fill 140ms ease, stroke 140ms ease;
}

.note .stem {
  stroke: var(--note);
  stroke-width: 2;
  stroke-linecap: round;
}

.note .hit-area {
  fill: transparent;
  stroke: none;
}

.note .note-label {
  fill: var(--muted);
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  font-size: 14px;
  font-weight: 650;
  text-anchor: middle;
}

.note.selected .notehead {
  fill: var(--accent);
  stroke: var(--accent);
}

.note.selected .stem {
  stroke: var(--accent);
}

.note.selected .note-label {
  fill: var(--accent);
  font-weight: 800;
}

.note:focus-visible .notehead {
  stroke: #d18c45;
  stroke-width: 4;
}

.selection-panel {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  margin-top: 12px;
  padding: 18px 20px;
  background: #f8f8f5;
  border: 1px solid var(--border);
  border-radius: 16px;
}

.selected-label {
  display: block;
  color: var(--muted);
  font-size: 0.62rem;
}

.selected-main {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-top: 3px;
}

#selected-solfa {
  color: var(--accent);
  font-size: 1.8rem;
  font-weight: 800;
}

#selected-pitch {
  color: var(--muted);
  font-size: 0.95rem;
}

.play-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 12px 18px;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  font-weight: 700;
  transition: background 150ms ease, transform 150ms ease;
}

.play-button:hover {
  background: #356551;
}

.play-button:active {
  transform: scale(0.97);
}

.play-button:focus-visible,
.note-button:focus-visible {
  outline: 3px solid #d18c45;
  outline-offset: 3px;
}

.status {
  min-height: 24px;
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.note-guide {
  padding: 35px 0 42px;
}

.guide-heading {
  margin-bottom: 18px;
}

.guide-heading p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.note-list {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.note-button {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  padding: 16px;
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: 15px;
  cursor: pointer;
  text-align: left;
  transition: border-color 150ms ease, background 150ms ease;
}

.note-button:hover {
  border-color: var(--accent);
}

.note-button.selected {
  background: var(--accent-light);
  border-color: var(--accent);
}

.note-button .note-name {
  font-weight: 800;
  font-size: 1rem;
}

.note-button .note-pitch {
  color: var(--muted);
  font-size: 0.8rem;
}

.footer {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding: 20px 0 30px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.76rem;
}

.footer p {
  margin: 0;
}

@media (max-width: 560px) {
  .app {
    width: min(100% - 24px, 900px);
  }

  .header {
    padding: 17px 0;
  }

  .header-label {
    max-width: 120px;
    font-size: 0.58rem;
  }

  .intro {
    padding-top: 34px;
  }

  .lesson-card {
    border-radius: 18px;
  }

  .card-heading {
    align-items: flex-start;
  }

  .scale-tag {
    font-size: 0.62rem;
  }

  .selection-panel {
    align-items: flex-start;
    flex-direction: column;
  }

  .play-button {
    width: 100%;
  }

  .note-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .footer {
    flex-direction: column;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
  }
}

.pitch-checker {
  margin-top: 22px;
  padding: 22px;
  background: #f8f8f5;
  border: 1px solid var(--border);
  border-radius: 16px;
}

.pitch-checker h3 {
  margin: 0 0 6px;
  font-size: 1.25rem;
}

.pitch-description,
.pitch-hint {
  color: var(--muted);
  font-size: 0.85rem;
}

.pitch-description {
  margin-bottom: 18px;
}

.mic-button {
  width: 100%;
  padding: 13px 18px;
  border: 0;
  border-radius: 12px;
  background: var(--accent);
  color: white;
  font-weight: 750;
  cursor: pointer;
}

.mic-button:hover {
  background: #356551;
}

.mic-button:focus-visible {
  outline: 3px solid #d18c45;
  outline-offset: 3px;
}

.pitch-reading {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 18px;
}

.reading-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 14px;
  background: white;
  border: 1px solid var(--border);
  border-radius: 12px;
}

.reading-label {
  color: var(--muted);
  font-size: 0.65rem;
  font-weight: 750;
  letter-spacing: 0.08em;
}

.reading-item strong {
  font-size: 1.15rem;
  font-variant-numeric: tabular-nums;
}

.pitch-meter {
  position: relative;
  height: 12px;
  margin: 26px 8px 18px;
  border-radius: 999px;
  background: linear-gradient(
    to right,
    #d87569 0%,
    #e8c66a 30%,
    #77ad86 50%,
    #e8c66a 70%,
    #d87569 100%
  );
}

.meter-center {
  position: absolute;
  top: -5px;
  left: 50%;
  width: 2px;
  height: 22px;
  background: var(--ink);
  transform: translateX(-50%);
}

.pitch-marker {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 16px;
  height: 16px;
  background: white;
  border: 3px solid var(--ink);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  transition: left 100ms linear;
}

.pitch-feedback {
  padding: 12px;
  background: white;
  border: 1px solid var(--border);
  border-radius: 10px;
  text-align: center;
  font-weight: 750;
}

.pitch-feedback.good {
  color: #267448;
}

.pitch-feedback.high {
  color: #a45d18;
}

.pitch-feedback.low {
  color: #a64a43;
}

.pitch-hint {
  margin: 12px 0 0;
  font-size: 0.78rem;
}

@media (max-width: 560px) {
  .pitch-checker {
    padding: 16px;
  }

  .pitch-reading {
    grid-template-columns: 1fr 1fr;
  }
}
