:root {
  --ink: #172039;
  --muted: #667085;
  --paper: #fffdf8;
  --cream: #f4efe5;
  --navy: #101b3f;
  --blue: #246bce;
  --blue-deep: #174f9c;
  --blue-soft: #dcecff;
  --gold: #f3b63f;
  --gold-soft: #ffe7a8;
  --line: #d9dfeb;
  --shadow: 0 18px 50px rgba(23, 32, 57, 0.11);
  --radius: 22px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 8% 6%, rgba(36, 107, 206, 0.09), transparent 28rem),
    linear-gradient(180deg, #f8f5ee 0%, var(--cream) 100%);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
  min-height: 100vh;
}

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

a {
  color: inherit;
}

.skip-link {
  position: fixed;
  left: 1rem;
  top: -5rem;
  z-index: 100;
  padding: 0.7rem 1rem;
  border-radius: 10px;
  color: white;
  background: var(--blue);
  font-weight: 800;
}

.skip-link:focus {
  top: 1rem;
}

.site-header {
  color: white;
  background:
    radial-gradient(circle at 80% -30%, rgba(73, 145, 255, 0.55), transparent 32rem),
    var(--navy);
  border-bottom: 4px solid var(--gold);
}

.header-inner,
.page-shell {
  width: min(1180px, calc(100% - 2rem));
  margin: 0 auto;
}

.header-inner {
  padding: 1.35rem 0 1.1rem;
}

.brand-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding-bottom: 1.15rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.14);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.85rem;
  text-decoration: none;
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.2rem, 2vw, 1.55rem);
  letter-spacing: 0.01em;
}

.brand small {
  margin-top: 0.15rem;
  color: #b9caea;
  font-size: 0.78rem;
}

.brand-mark {
  display: flex;
  align-items: flex-start;
  width: 46px;
  height: 40px;
  padding: 0 4px 4px;
  border-radius: 8px;
  background: white;
  box-shadow: inset 0 -3px 0 #dfe5ef;
}

.brand-mark i {
  position: relative;
  flex: 1;
  height: 100%;
  border-right: 1px solid #aab5c6;
}

.brand-mark i:last-child {
  border-right: 0;
}

.brand-mark i::after {
  content: "";
  position: absolute;
  right: -28%;
  top: 0;
  z-index: 1;
  width: 55%;
  height: 62%;
  border-radius: 0 0 3px 3px;
  background: var(--navy);
}

.brand-mark i:last-child::after {
  display: none;
}

.progressions-link {
  flex: none;
  padding: 0.65rem 0.9rem;
  border: 1px solid rgba(255, 255, 255, 0.32);
  border-radius: 999px;
  color: white;
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 800;
}

.progressions-link:hover,
.progressions-link:focus-visible {
  border-color: var(--gold);
  color: var(--gold-soft);
}

.catalog-nav {
  padding-top: 1rem;
}

.nav-group {
  display: grid;
  grid-template-columns: 4.5rem 1fr;
  gap: 0.65rem;
  align-items: start;
}

.nav-group + .nav-group {
  margin-top: 0.65rem;
}

.nav-label {
  padding-top: 0.35rem;
  color: #91abda;
  font-size: 0.7rem;
  font-weight: 900;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.nav-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.nav-links a {
  padding: 0.32rem 0.58rem;
  border-radius: 7px;
  color: #dbe6f9;
  text-decoration: none;
  font-size: 0.79rem;
  font-weight: 700;
  transition: color 150ms ease, background 150ms ease;
}

.nav-links a:hover,
.nav-links a:focus-visible {
  color: white;
  background: rgba(255, 255, 255, 0.12);
}

.nav-links a.active {
  color: #172039;
  background: var(--gold);
}

.page-shell {
  padding: 3rem 0 4rem;
}

.intro {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 2rem;
  align-items: end;
  margin-bottom: 2rem;
}

.eyebrow {
  margin: 0 0 0.35rem;
  color: var(--blue-deep);
  font-size: 0.71rem;
  font-weight: 900;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

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

h1,
h2,
h3 {
  line-height: 1.12;
}

h1 {
  max-width: 15ch;
  margin-bottom: 0.7rem;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2.55rem, 7vw, 5.25rem);
  font-weight: 700;
  letter-spacing: -0.045em;
}

h2 {
  margin-bottom: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.45rem, 2.8vw, 2rem);
}

.intro-copy {
  max-width: 66ch;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 1.02rem;
}

.scale-summary {
  min-width: 220px;
  padding: 1rem 1.15rem;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 253, 248, 0.7);
}

.scale-summary strong,
.summary-label {
  display: block;
}

.summary-label {
  margin-bottom: 0.3rem;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 900;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.scale-summary strong {
  font-size: 0.92rem;
}

.variant-pill {
  display: inline-block;
  margin-top: 0.65rem;
  padding: 0.25rem 0.5rem;
  border-radius: 999px;
  color: #684b08;
  background: var(--gold-soft);
  font-size: 0.72rem;
  font-weight: 800;
}

.root-panel,
.practice-card,
.info-card,
.fingering-section {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
  box-shadow: var(--shadow);
}

.root-panel {
  margin-bottom: 1.25rem;
  padding: 1.25rem;
}

.section-heading,
.practice-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.section-heading {
  margin-bottom: 1.25rem;
}

.section-heading.compact {
  margin-bottom: 0.9rem;
}

.section-heading .eyebrow,
.practice-heading .eyebrow {
  margin-bottom: 0.25rem;
}

.shortcut-help {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.78rem;
}

kbd {
  display: inline-flex;
  min-width: 1.45rem;
  justify-content: center;
  padding: 0.08rem 0.3rem;
  border: 1px solid #bfc8d7;
  border-bottom-width: 2px;
  border-radius: 5px;
  color: #4c5870;
  background: white;
  font-family: inherit;
  font-size: 0.68rem;
  font-weight: 800;
}

.root-picker {
  display: grid;
  grid-template-columns: repeat(12, minmax(64px, 1fr));
  gap: 0.45rem;
}

.root-button {
  display: flex;
  min-height: 54px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.2rem;
  padding: 0.45rem 0.2rem;
  border: 1px solid var(--line);
  border-radius: 11px;
  color: var(--ink);
  background: #f8fafc;
  cursor: pointer;
  font: inherit;
  font-weight: 850;
  transition: transform 140ms ease, border-color 140ms ease, background 140ms ease;
}

.root-button:hover {
  transform: translateY(-2px);
  border-color: #8aa9d8;
}

.root-button.selected {
  border-color: var(--blue);
  color: white;
  background: var(--blue);
  box-shadow: 0 6px 18px rgba(36, 107, 206, 0.26);
}

.root-button.selected kbd {
  border-color: rgba(255, 255, 255, 0.35);
  color: white;
  background: rgba(255, 255, 255, 0.13);
}

.practice-card {
  overflow: hidden;
  margin-bottom: 1.25rem;
  padding: 1.4rem;
}

.practice-heading {
  margin-bottom: 1.3rem;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.9rem;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 750;
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.legend-key {
  width: 18px;
  height: 18px;
  border: 1px solid rgba(23, 32, 57, 0.14);
  border-radius: 4px;
  background: var(--blue-soft);
}

.legend-key.tonic {
  background: var(--gold);
}

.piano-scroll {
  overflow-x: auto;
  padding: 0.2rem 0.15rem 0.8rem;
  scrollbar-color: #9db0ce transparent;
}

.piano-scroll:focus-visible {
  outline: 3px solid rgba(36, 107, 206, 0.35);
  outline-offset: 5px;
}

.piano {
  position: relative;
  display: flex;
  min-width: 720px;
  height: 250px;
  border: 5px solid var(--navy);
  border-top-width: 11px;
  border-radius: 9px 9px 14px 14px;
  background: var(--navy);
  box-shadow: 0 14px 30px rgba(16, 27, 63, 0.18);
  overflow: hidden;
}

.piano-key {
  position: relative;
  transition: background 160ms ease, box-shadow 160ms ease;
}

.white-key {
  flex: 1;
  height: 100%;
  border-right: 1px solid #929daf;
  border-radius: 0 0 5px 5px;
  background: linear-gradient(90deg, #f5f2ea, #fff 28%, #fff 76%, #e7e4dd);
  box-shadow: inset 0 -7px 0 #d8d8d2;
}

.white-key:last-child {
  border-right: 0;
}

.black-key {
  position: absolute;
  left: calc(var(--key-left) - 2.15%);
  z-index: 2;
  width: 4.3%;
  height: 61%;
  border: 1px solid #050916;
  border-radius: 0 0 5px 5px;
  background: linear-gradient(90deg, #070b17, #26314c 65%, #090d1a);
  box-shadow: inset 0 -8px 0 #050914, 0 4px 5px rgba(0, 0, 0, 0.38);
}

.white-key.scale-key {
  background: linear-gradient(90deg, #c8e1ff, #e7f2ff 36%, #d9ebff 78%, #afcff7);
  box-shadow: inset 0 -7px 0 #83afe8, inset 0 0 0 2px rgba(36, 107, 206, 0.12);
}

.black-key.scale-key {
  border-color: #0b3f84;
  background: linear-gradient(90deg, #123e79, #2f84ed 60%, #0c3970);
  box-shadow: inset 0 -8px 0 #0a3470, 0 4px 5px rgba(0, 0, 0, 0.3);
}

.white-key.tonic-key {
  background: linear-gradient(90deg, #e8a724, #ffd472 38%, #f7c451 77%, #d8920f);
  box-shadow: inset 0 -7px 0 #c78000, inset 0 0 0 2px rgba(104, 75, 8, 0.14);
}

.black-key.tonic-key {
  border-color: #805b05;
  background: linear-gradient(90deg, #a56e05, #f3b63f 62%, #845703);
  box-shadow: inset 0 -8px 0 #7e5200, 0 4px 5px rgba(0, 0, 0, 0.3);
}

.key-label {
  position: absolute;
  left: 50%;
  bottom: 13px;
  transform: translateX(-50%);
  color: var(--blue-deep);
  font-size: 0.68rem;
  font-weight: 900;
  white-space: nowrap;
}

.black-key .key-label {
  bottom: 9px;
  color: white;
  font-size: 0.57rem;
}

.tonic-key .key-label {
  color: #4f3702;
}

.black-key.tonic-key .key-label {
  color: #342300;
}

.mobile-scroll-hint {
  display: none;
  margin: 0.45rem 0 0;
  color: var(--muted);
  font-size: 0.72rem;
  text-align: center;
}

.theory-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(260px, 0.8fr);
  gap: 1.25rem;
  margin-bottom: 1.25rem;
}

.info-card {
  padding: 1.4rem;
}

.note-sequence {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.note-chip {
  display: inline-flex;
  width: 54px;
  height: 54px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border: 1px solid #b7c9e5;
  border-radius: 14px;
  color: var(--blue-deep);
  background: var(--blue-soft);
}

.note-chip strong {
  line-height: 1;
}

.note-chip small {
  margin-top: 0.25rem;
  color: #465a7c;
  font-size: 0.62rem;
  font-weight: 800;
}

.note-chip.root-note {
  border-color: #d89a18;
  color: #684b08;
  background: var(--gold-soft);
}

.note-arrow {
  color: #8c98aa;
  font-size: 1.2rem;
}

.formula-row {
  display: flex;
  gap: 1rem;
  align-items: baseline;
  margin-top: 1.2rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
}

.formula-row span {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.formula-row strong {
  font-size: 0.85rem;
}

.guidance-card {
  color: white;
  background: var(--navy);
}

.guidance-card .eyebrow {
  color: #90b8f0;
}

.guidance-card h2 {
  margin-bottom: 0.8rem;
}

.guidance-card p:not(.eyebrow) {
  color: #c7d6ef;
  font-size: 0.9rem;
}

.source-note {
  margin-bottom: 0 !important;
  padding-top: 0.8rem;
  border-top: 1px solid rgba(255, 255, 255, 0.15);
  font-size: 0.77rem !important;
}

.fingering-section {
  padding: 1.4rem;
}

.confidence-badge {
  padding: 0.38rem 0.7rem;
  border-radius: 999px;
  color: #18573c;
  background: #daf5e7;
  font-size: 0.72rem;
  font-weight: 850;
}

.confidence-badge[data-level="derived-standard"],
.confidence-badge[data-level="derived"] {
  color: #174f9c;
  background: var(--blue-soft);
}

.confidence-badge[data-level="suggested"] {
  color: #684b08;
  background: var(--gold-soft);
}

.confidence-badge[data-level="unavailable"] {
  color: #7b2430;
  background: #ffe1e4;
}

.fingering-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.hand-card {
  min-width: 0;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 17px;
  background: #f8fafc;
}

.hand-title {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  margin-bottom: 0.9rem;
}

.hand-title > span {
  display: inline-grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 10px;
  color: white;
  background: var(--blue);
  font-size: 0.7rem;
  font-weight: 900;
}

.hand-title h3 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.25rem;
}

.direction-row + .direction-row {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
}

.direction-row > strong {
  display: block;
  margin-bottom: 0.5rem;
  color: var(--muted);
  font-size: 0.68rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.finger-sequence {
  display: flex;
  flex-wrap: wrap;
  gap: 0.32rem;
}

.finger-chip {
  position: relative;
  display: inline-flex;
  width: 32px;
  height: 42px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border: 1px solid #c7d3e4;
  border-radius: 9px;
  background: white;
}

.finger-chip b {
  color: var(--blue-deep);
  font-size: 0.9rem;
  line-height: 1;
}

.finger-chip small {
  max-width: 30px;
  margin-top: 0.22rem;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.48rem;
  font-weight: 750;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.finger-chip.octave-start {
  margin-left: 0.4rem;
}

.finger-chip.octave-start::before {
  content: "";
  position: absolute;
  left: -0.45rem;
  top: 5px;
  bottom: 5px;
  width: 1px;
  background: #aebdd2;
}

.empty-state {
  grid-column: 1 / -1;
  margin: 0;
  padding: 1rem;
  border-radius: 12px;
  color: #7b2430;
  background: #fff0f2;
}

.site-footer {
  padding: 1.4rem 1rem;
  color: #b7c7e4;
  background: var(--navy);
  text-align: center;
}

.site-footer p {
  margin: 0;
  font-size: 0.78rem;
}

.noscript-message {
  width: min(680px, calc(100% - 2rem));
  margin: 3rem auto;
  padding: 1rem 1.2rem;
  border: 1px solid #efb6bd;
  border-radius: 12px;
  color: #7b2430;
  background: #fff0f2;
  text-align: center;
}

button:focus-visible,
a:focus-visible {
  outline: 3px solid rgba(243, 182, 63, 0.8);
  outline-offset: 3px;
}

@media (max-width: 925px) {
  .root-picker {
    grid-template-columns: repeat(6, 1fr);
  }

  .theory-grid,
  .fingering-grid {
    grid-template-columns: 1fr;
  }

  .mobile-scroll-hint {
    display: block;
  }
}

@media (max-width: 680px) {
  .header-inner,
  .page-shell {
    width: min(100% - 1.1rem, 1180px);
  }

  .header-inner {
    padding-top: 1rem;
  }

  .brand-row {
    align-items: flex-start;
  }

  .brand small {
    display: none;
  }

  .brand-mark {
    width: 39px;
    height: 35px;
  }

  .progressions-link {
    padding: 0.5rem 0.65rem;
    font-size: 0.7rem;
  }

  .nav-group {
    display: block;
  }

  .nav-label {
    display: block;
    margin-bottom: 0.35rem;
  }

  .nav-links {
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 0.35rem;
    scrollbar-width: thin;
  }

  .nav-links a {
    flex: none;
  }

  .page-shell {
    padding-top: 2rem;
  }

  .intro {
    grid-template-columns: 1fr;
    gap: 1rem;
    align-items: start;
  }

  h1 {
    font-size: clamp(2.45rem, 14vw, 4rem);
  }

  .scale-summary {
    width: 100%;
  }

  .section-heading,
  .practice-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .shortcut-help {
    display: none;
  }

  .root-picker {
    grid-template-columns: repeat(4, 1fr);
  }

  .root-button {
    min-height: 50px;
    font-size: 0.82rem;
  }

  .root-button kbd {
    display: none;
  }

  .practice-card,
  .root-panel,
  .info-card,
  .fingering-section {
    padding: 1rem;
    border-radius: 17px;
  }

  .piano {
    min-width: 640px;
    height: 215px;
  }

  .note-chip {
    width: 48px;
    height: 48px;
  }

  .note-arrow {
    display: none;
  }

  .finger-chip {
    width: 30px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition: none !important;
  }
}
