:root {
  color-scheme: dark;
  --bg: #080b0e;
  --panel: #11161b;
  --control: #17130b;
  --text: #edf4f6;
  --muted: #8f9da7;
  --line: rgba(239, 186, 88, 0.18);
  --teal: #43d9bd;
  --teal-soft: rgba(67, 217, 189, 0.14);
  --coral: #ff725e;
  --gold: #efba58;
  --radius-lg: 24px;
  --radius-md: 12px;
  --theme: #efba58;
  --theme-rgb: 239, 186, 88;
  --theme-soft: rgba(239, 186, 88, 0.16);
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
}

body {
  display: flow-root;
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(
      circle at 14% -12%,
      rgba(239, 186, 88, 0.13),
      transparent 32%
    ),
    radial-gradient(
      circle at 88% 2%,
      rgba(224, 132, 48, 0.055),
      transparent 27%
    ),
    linear-gradient(145deg, #17140c 0%, #17130e 48%, #100e0b 100%);
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
    "PingFang SC", "Microsoft YaHei", sans-serif;
  line-height: 1.5;
}

button,
select {
  font: inherit;
}

button {
  color: inherit;
}

button,
select {
  touch-action: manipulation;
}

button:focus-visible,
select:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 3px;
}

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

.app-shell {
  display: flex;
  width: min(calc(100% - 48px), 1600px);
  min-height: calc(100vh - 48px);
  margin: 24px auto;
  overflow: hidden;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: radial-gradient( circle at 8% 0%, rgba(239, 186, 88, 0.075), transparent 25% ), linear-gradient( 180deg, rgba(28, 25, 17, 0.97), rgba(17, 14, 10, 0.98) );
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.28);
  border-color: rgba(var(--theme-rgb), 0.24);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 20px 22px;
  border-bottom: 1px solid var(--line);
  background: rgba(25, 21, 14, 0.52);
  backdrop-filter: blur(18px);
  min-height: 98px;
}

.brand {
  display: flex;
  align-items: center;
  min-width: 280px;
  gap: 18px;
}

.brand h1 {
  margin: 0;
  color: #edf4f6;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
    "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: clamp(1.24rem, 2vw, 1.68rem);
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.025em;
}

.brand p {
  margin: 4px 0 0;
  color: #8f9da7;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
    "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 0.9rem;
  font-weight: 400;
  line-height: 1.5;
}

.top-controls,
.toolbar-controls {
  display: flex;
  align-items: end;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 12px;
}

.control {
  display: grid;
  min-width: 100px;
  grid-template-rows: 18px 43px;
  gap: 6px;
}

.control-wide {
  min-width: 150px;
}

.control > span,
.segmented > .control-label,
.meta-label {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 740;
  letter-spacing: 0.04em;
}

.control > span,
.segmented > .control-label {
  display: flex;
  min-height: 18px;
  align-items: center;
  line-height: 18px;
}

select,
.segment {
  min-height: 43px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: var(--radius-md);
  background: var(--control);
  transition:
    border-color 150ms ease,
    background 150ms ease,
    color 150ms ease,
    transform 150ms ease;
}

select {
  width: 100%;
  padding: 0 36px 0 12px;
  color: var(--text);
}

select:hover,
.segment:hover {
  border-color: rgba(255, 255, 255, 0.28);
  background: #151c21;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  grid-template-rows: 18px 43px;
  gap: 4px;
  margin: 0;
  padding: 0;
  border: 0;
}

.segmented > .control-label {
  grid-column: 1 / -1;
  margin-bottom: 2px;
}

.segment {
  min-width: 70px;
  padding: 0 12px;
  color: var(--muted);
  cursor: pointer;
}

.segment:active {
  transform: translateY(1px);
}

.segment.is-active {
  border-color: rgba(67, 217, 189, 0.66);
  background: var(--teal-soft);
  color: var(--text);
}

.training-surface {
  display: flex;
  width: 100%;
  flex: 1;
  flex-direction: column;
}

.scale-strip {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 22px;
  border-bottom: 1px solid var(--line);
  background: rgba(var(--theme-rgb), 0.025);
  min-height: 102px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
}

.scale-summary {
  display: grid;
  grid-template-rows: 18px 43px;
  align-items: stretch;
  min-width: 0;
  gap: 6px;
}

.scale-summary .meta-label {
  display: flex;
  min-height: 18px;
  align-items: center;
  line-height: 18px;
}

.scale-summary strong {
  display: flex;
  min-height: 43px;
  padding: 0 12px;
  align-items: center;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: var(--radius-md);
  background: var(--control);
  color: var(--text);
  font-size: 0.92rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.scale-strip .top-controls {
  flex: 1;
}

.keyboard-panel {
  flex: 1;
  padding: 24px 28px 28px;
  overflow: hidden;
}

.compact-chord-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.compact-chord-heading p {
  margin: 0;
  color: var(--muted);
  font-size: 0.72rem;
}

.eyebrow {
  color: var(--teal);
  font-size: 0.68rem;
  font-weight: 820;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.chord-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 7px;
  margin-top: 12px;
  scrollbar-color: rgba(255, 255, 255, 0.24) transparent;
}

.chord-card {
  position: relative;
  display: flex;
  min-width: 0;
  min-height: 84px;
  padding: 9px 10px 8px;
  flex-direction: column;
  align-items: flex-start;
  border: 1px solid rgba(255, 255, 255, 0.11);
  border-radius: 11px;
  background: #0d1216;
  color: var(--text);
  cursor: pointer;
  text-align: left;
  transition:
    transform 160ms ease,
    border-color 160ms ease,
    background 160ms ease,
    box-shadow 160ms ease;
}

.chord-card:hover {
  transform: translateY(-1px);
  border-color: rgba(255, 255, 255, 0.26);
  background: #141a1f;
}

.chord-card.is-active {
  transform: translateY(-1px);
  border-color: rgba(67, 217, 189, 0.64);
  background:
    radial-gradient(
      circle at 100% 0%,
      rgba(67, 217, 189, 0.17),
      transparent 48%
    ),
    #121a1e;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.18);
}

.chord-card .roman {
  color: var(--teal);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.72rem;
  font-weight: 760;
}

.chord-card strong {
  margin-top: 2px;
  overflow: hidden;
  font-size: clamp(0.94rem, 1.5vw, 1.12rem);
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chord-notes {
  width: 100%;
  margin-top: auto;
  overflow: hidden;
  color: rgba(237, 244, 246, 0.72);
  font-size: 0.66rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.inversion-control .segment,
.label-control .segment {
  min-width: 58px;
}

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

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 20px;
  margin: 22px 0 12px;
  color: var(--muted);
  font-size: 0.73rem;
  font-weight: 680;
}

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

.legend-dot {
  width: 11px;
  height: 11px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 50%;
}

.root-dot {
  border-color: var(--coral);
  background: var(--coral);
  box-shadow: 0 0 9px rgba(255, 114, 94, 0.34);
}

.left-root-dot {
  border-color: var(--teal);
  background: var(--teal);
  box-shadow: 0 0 9px rgba(67, 217, 189, 0.34);
}

.chord-dot {
  border-color: var(--gold);
  background: var(--gold);
  box-shadow: 0 0 9px rgba(239, 186, 88, 0.28);
}

.playing-dot {
  background: #fff;
  box-shadow: 0 0 10px rgba(255, 255, 255, 0.55);
}

.scroll-hint {
  display: none;
  margin: 0 2px 8px;
  color: var(--muted);
  font-size: 0.72rem;
}

.keyboard-shell {
  overflow-x: auto;
  overscroll-behavior-inline: contain;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 18px;
  background: #080a0b;
  box-shadow:
    0 26px 60px rgba(0, 0, 0, 0.3),
    inset 0 1px rgba(255, 255, 255, 0.06);
  scrollbar-color: rgba(255, 255, 255, 0.24) transparent;
}

.piano {
  position: relative;
  display: flex;
  min-width: 1140px;
  height: clamp(220px, 25vw, 308px);
  padding: 10px 10px 14px;
}

.piano-key {
  position: relative;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0 4px 19px;
  border: 0;
  cursor: pointer;
  transition:
    transform 80ms ease,
    background 140ms ease,
    box-shadow 140ms ease;
}

.white-key {
  width: calc(100% / var(--white-key-count));
  height: 100%;
  border-right: 1px solid #afb3b4;
  border-bottom: 5px solid #b9bbba;
  border-radius: 0 0 7px 7px;
  background: linear-gradient(
    95deg,
    #e8e8e4 0%,
    #fff 50%,
    #d9dbd8 100%
  );
  color: #182026;
  box-shadow:
    inset 0 -10px 16px rgba(0, 0, 0, 0.06),
    inset 0 1px #fff;
}

.white-key:first-child {
  border-radius: 8px 0 7px 7px;
}

.white-key:last-of-type {
  border-radius: 0 8px 7px 7px;
}

.black-key {
  position: absolute;
  z-index: 3;
  top: 10px;
  width: var(--black-key-width);
  height: 62%;
  padding-bottom: 15px;
  border: 1px solid #050607;
  border-bottom: 8px solid #090b0c;
  border-radius: 0 0 7px 7px;
  background: linear-gradient(100deg, #121518, #30363a 58%, #080a0b);
  color: #f7f9f8;
  box-shadow:
    0 10px 12px rgba(0, 0, 0, 0.44),
    inset 0 1px rgba(255, 255, 255, 0.12);
}

.piano-key:active,
.piano-key.is-playing {
  transform: translateY(4px);
}

.white-key.is-right-chord {
  background: linear-gradient(
    180deg,
    #fffdf6 0%,
    #f8dfa1 66%,
    #efb94f 100%
  );
  color: #20170a;
  box-shadow:
    inset 0 -12px 0 #d89a2d,
    inset 0 0 0 2px rgba(126, 81, 10, 0.34),
    0 0 22px rgba(239, 186, 88, 0.18);
}

.black-key.is-right-chord {
  border-color: #d99e35;
  background: linear-gradient(100deg, #2c210e, #d49b35 58%, #5d3e0d);
  color: #fff8e9;
  box-shadow:
    0 10px 12px rgba(0, 0, 0, 0.4),
    inset 0 -8px 0 #7a4d0c,
    0 0 20px rgba(239, 186, 88, 0.22);
}

.piano-key.is-right-chord .key-marker {
  border-color: #6f4b12;
  background: #fff2c7;
  color: #2b1d08;
  box-shadow:
    0 0 0 3px rgba(255, 246, 216, 0.36),
    0 4px 12px rgba(65, 40, 4, 0.2);
}

.white-key.is-right-root {
  background: linear-gradient(
    180deg,
    #fff8f5 0%,
    #ffb1a4 66%,
    #ff725e 100%
  );
  color: #2a0b07;
  box-shadow:
    inset 0 -12px 0 #d74a38,
    inset 0 0 0 2px rgba(136, 36, 23, 0.38),
    0 0 24px rgba(255, 114, 94, 0.2);
}

.black-key.is-right-root {
  border-color: #ff8b7a;
  background: linear-gradient(100deg, #35110d, #e75c49 58%, #681a11);
  color: #fff5f2;
  box-shadow:
    0 10px 12px rgba(0, 0, 0, 0.4),
    inset 0 -8px 0 #8e2418,
    0 0 22px rgba(255, 114, 94, 0.25);
}

.piano-key.is-right-root .key-marker {
  border-color: #8d2417;
  background: #fff0ec;
  color: #4b120b;
  box-shadow:
    0 0 0 3px rgba(255, 224, 218, 0.38),
    0 4px 12px rgba(92, 20, 11, 0.22);
}

.white-key.is-left-root {
  background: linear-gradient(
    180deg,
    #f4fffc 0%,
    #9cebdc 66%,
    #43d9bd 100%
  );
  color: #06231e;
  box-shadow:
    inset 0 -12px 0 #20ad94,
    inset 0 0 0 2px rgba(7, 104, 87, 0.38),
    0 0 24px rgba(67, 217, 189, 0.2);
}

.black-key.is-left-root {
  border-color: #69e8d0;
  background: linear-gradient(100deg, #08241f, #2bc5a9 58%, #0b5e50);
  color: #effffb;
  box-shadow:
    0 10px 12px rgba(0, 0, 0, 0.4),
    inset 0 -8px 0 #107866,
    0 0 22px rgba(67, 217, 189, 0.25);
}

.piano-key.is-left-root .key-marker {
  border-color: #126e5e;
  background: #e7fff9;
  color: #063c32;
  box-shadow:
    0 0 0 3px rgba(211, 255, 246, 0.38),
    0 4px 12px rgba(4, 69, 58, 0.22);
}

.piano-key.is-playing {
  filter: brightness(1.16);
  box-shadow:
    inset 0 -80px 70px rgba(255, 255, 255, 0.28),
    0 0 22px rgba(255, 255, 255, 0.3);
}

.key-marker {
  display: grid;
  min-width: 30px;
  min-height: 30px;
  place-items: center;
  border: 1px solid rgba(20, 28, 33, 0.15);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.55);
  font-size: 0.68rem;
  font-weight: 820;
}

.black-key .key-marker {
  min-width: 27px;
  min-height: 27px;
  border-color: rgba(255, 255, 255, 0.18);
  background: rgba(0, 0, 0, 0.38);
}

.hand-badge {
  position: absolute;
  top: 12px;
  display: grid;
  min-width: 25px;
  min-height: 22px;
  padding: 0 5px;
  place-items: center;
  border: 1px solid currentColor;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.76);
  color: #172027;
  font-size: 0.62rem;
  font-weight: 850;
  line-height: 1;
}

.white-key .hand-badge {
  top: auto;
  bottom: 58px;
}

.black-key .hand-badge {
  top: 9px;
  bottom: auto;
  background: rgba(5, 8, 10, 0.72);
  color: #fff;
}

.is-left-root .hand-badge {
  color: #075747;
}

.is-right-chord .hand-badge {
  color: #6f4310;
}

.is-right-root .hand-badge {
  color: #8d2417;
}

.black-key.is-left-root .hand-badge,
.black-key.is-right-chord .hand-badge,
.black-key.is-right-root .hand-badge {
  color: #fff;
}

.piano-key small {
  position: absolute;
  bottom: 1px;
  color: rgba(24, 32, 38, 0.44);
  font-size: 0.58rem;
  font-weight: 760;
}

.status-message {
  margin: 12px 0 0;
  color: var(--gold);
  font-size: 0.78rem;
}

.site-footer {
  display: flex;
  width: 100%;
  min-height: 64px;
  margin-top: auto;
  padding: 0 12px;
  align-items: center;
  justify-content: center;
  flex: 0 0 64px;
  color: #9ca3af;
  font-size: 12px;
  line-height: 1.5;
  letter-spacing: 0.01em;
  text-align: center;
}

.site-footer small {
  font: inherit;
}

@media (max-width: 1060px) {
  .topbar {
    align-items: flex-start;
  }

  .top-controls {
    max-width: 520px;
  }

  .chord-grid {
    grid-template-columns: repeat(7, minmax(92px, 1fr));
    overflow-x: auto;
    padding-bottom: 6px;
  }

  .toolbar-controls {
    width: 100%;
    justify-content: flex-start;
  }
}

@media (max-width: 900px) {
  .app-shell {
    width: calc(100% - 28px);
    min-height: calc(100vh - 28px);
    margin: 14px auto;
  }
}

@media (max-width: 760px) {
  .topbar,
  .scale-strip {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar {
    padding: 18px;
  }

  .brand {
    min-width: 0;
  }

  .top-controls {
    display: grid;
    grid-template-columns: 0.8fr 1.2fr;
    max-width: none;
  }

  .top-controls .segmented {
    grid-column: auto;
  }

  .top-controls .label-control {
    grid-column: 1 / -1;
  }

  .scale-strip {
    padding: 16px 18px;
  }

  .scale-summary {
    padding-bottom: 0;
    gap: 6px;
  }

  .keyboard-panel {
    padding: 18px;
  }

  .compact-chord-heading {
    align-items: flex-start;
    flex-direction: column;
    gap: 3px;
  }

  .compact-chord-heading p {
    font-size: 0.68rem;
  }

  .chord-grid {
    grid-template-columns: repeat(7, 112px);
    margin-right: -18px;
    padding-right: 18px;
  }

  .toolbar-controls {
    display: grid;
  }

  .inversion-control,
  .label-control {
    width: 100%;
  }

  .segment {
    min-width: 0;
  }

  .scroll-hint {
    display: block;
  }

}

@media (max-width: 620px) {
  .app-shell {
    width: calc(100% - 20px);
    min-height: calc(100vh - 20px);
    margin: 10px auto;
  }
}

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

  .top-controls .segmented {
    grid-column: auto;
  }
}

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

/* Keep native Safari select metrics from changing the control row. */
select {
  height: 43px;
  min-height: 43px;
  appearance: none;
  -webkit-appearance: none;
}

.control {
  position: relative;
}

.control::after {
  position: absolute;
  right: 14px;
  bottom: 18px;
  width: 7px;
  height: 7px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  color: #cbd4da;
  content: "";
  pointer-events: none;
  transform: rotate(45deg);
  transform-origin: center;
}

/* Present related choices as one segmented control. */
.segmented {
  grid-template-columns: minmax(0, 1fr);
  gap: 6px;
}

.segmented > .control-label {
  grid-column: 1;
  margin-bottom: 0;
}

.segment-group {
  display: grid;
  gap: 4px;
  width: 100%;
  min-height: 43px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: rgba(7, 9, 11, 0.46);
}

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

.segment-group-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

/* Match the harmonica project's primary-header geometry and typography. */


.brand {
  flex: 1 1 auto;
  min-width: 0;
  gap: 18px;
}

.brand > div {
  min-width: 0;
}

.brand-icon-slot {
  display: grid;
  width: 66px;
  height: 58px;
  place-items: center;
  flex: 0 0 66px;
}

.brand h1 {
  color: #edf4f6;
  font-size: clamp(1.24rem, 2vw, 1.68rem);
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.025em;
}

.brand p {
  margin: 4px 0 0;
  color: #8f9da7;
  font-size: 0.9rem;
  font-weight: 400;
  line-height: 1.5;
}

@media (max-width: 760px) {
  .topbar {
    min-height: 0;
    gap: 14px;
    padding: 16px;
  }
}

@media (max-width: 680px) {
  .brand-icon-slot {
    width: 52px;
    height: 50px;
    flex-basis: 52px;
  }

}

/* Make scheduled chord tones read as physical key presses. */
.piano-key.is-playing {
  transform: translateY(5px);
  filter: brightness(1.18);
  transition-duration: 60ms;
}

.white-key.is-playing {
  border-bottom-width: 2px;
}

.black-key.is-playing {
  border-bottom-width: 4px;
}

.segment-group-4 {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.segment-group .segment {
  width: 100%;
  min-width: 0;
  min-height: 0;
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: 9px;
  background: transparent;
  box-shadow: none;
}

.segment-group .segment:hover {
  border-color: transparent;
  background: rgba(139, 163, 188, 0.08);
}

.segment-group .segment.is-active,
.segment-group .segment.is-active:hover {
  border-color: rgba(67, 217, 189, 0.66);
  background: var(--teal-soft);
  color: var(--text);
  box-shadow: inset 0 0 0 1px rgba(67, 217, 189, 0.08);
}

/* Match the harmonica project's secondary-bar control system. */


.scale-strip .scale-summary {
  width: 320px;
  min-width: 320px;
  flex: 0 0 320px;
  grid-template-rows: 17px 42px;
}

.scale-strip .top-controls {
  gap: 12px;
}

.scale-strip .top-controls .control,
.scale-strip .top-controls .segmented {
  grid-template-rows: 17px 42px;
  gap: 6px;
}

.scale-strip .meta-label,
.scale-strip .control > span,
.scale-strip .segmented > .control-label {
  display: block;
  height: 17px;
  min-height: 17px;
  margin: 0;
  padding: 0;
  color: #87929d;
  font-size: 0.7rem;
  font-weight: 760;
  line-height: 1.5;
  letter-spacing: 0.03em;
}

.scale-strip .scale-summary strong,
.scale-strip select {
  height: 42px;
  min-height: 42px;
  border: 1px solid rgba(219, 227, 232, 0.22);
  border-radius: 10px;
  background: #0c0f12;
  color: #f2f5f6;
}

.scale-strip .scale-summary strong {
  font-size: 0.82rem;
  font-weight: 650;
}

.scale-strip select,
.scale-strip .segment {
  font-size: 1rem;
  font-weight: 400;
}

.scale-strip .segment-group {
  width: 100%;
  height: 42px;
  min-height: 42px;
  gap: 4px;
  padding: 3px;
  border: 1px solid rgba(219, 227, 232, 0.13);
  border-radius: 12px;
  background: rgba(7, 9, 11, 0.46);
}

.scale-strip .segment-group .segment {
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: #87929d;
  box-shadow: none;
}

.scale-strip .segment-group .segment.is-active,
.scale-strip .segment-group .segment.is-active:hover {
  border-color: rgba(72, 216, 188, 0.46);
  background: rgba(72, 216, 188, 0.16);
  color: #f2f5f6;
  box-shadow: none;
}

.scale-strip .label-control,
.scale-strip .label-control .segment-group {
  width: 200px;
  min-width: 200px;
}

@media (max-width: 760px) {
  .scale-strip {
    padding: 18px 22px;
  }

  .scale-strip .scale-summary {
    width: 100%;
    min-width: 0;
    flex-basis: auto;
  }

  .scale-strip .label-control,
  .scale-strip .label-control .segment-group {
    width: 100%;
    min-width: 0;
  }
}

/* Shared legend typography and solid-dot geometry. */
.keyboard-panel .legend {
  gap: 10px 20px;
  color: #87929d;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
    "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 0.73rem;
  font-weight: 650;
  line-height: 1.5;
}

.keyboard-panel .legend > span {
  gap: 7px;
}

.keyboard-panel .legend-dot {
  width: 11px;
  height: 11px;
  flex: 0 0 11px;
  border: 0;
  border-radius: 50%;
  box-shadow: none;
}

.keyboard-panel .left-root-dot {
  background: #48d8bc;
}

.keyboard-panel .root-dot {
  background: #ff775f;
}

.keyboard-panel .chord-dot {
  background: #efbe67;
}

.keyboard-panel .playing-dot {
  background: #fff;
}

/* Shared scale-summary treatment across the three learning tools. */
.scale-strip .scale-summary strong {
  border-color: rgba(72, 216, 188, 0.46);
  background: rgba(72, 216, 188, 0.16);
  color: #f2f5f6;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
    "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 0.82rem;
  font-weight: 650;
  line-height: 1.5;
  letter-spacing: 0.03em;
  box-shadow: none;
}

/* Chord playback selector, aligned with the harmonica header tabs. */
.header-actions {
  display: flex;
  align-items: stretch;
  flex: 0 0 auto;
  gap: 12px;
}

.play-style-tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(92px, 1fr));
  gap: 5px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(7, 9, 11, 0.48);
}

.play-style-tabs > button {
  --tab-rgb: 72, 216, 188;
  --tab-color: rgb(var(--tab-rgb));
  display: flex;
  min-width: 0;
  min-height: 46px;
  padding: 6px 9px;
  align-items: center;
  gap: 8px;
  border: 1px solid rgba(var(--tab-rgb), 0.24);
  border-radius: 10px;
  background:
    linear-gradient(
      145deg,
      rgba(var(--tab-rgb), 0.09),
      rgba(13, 16, 19, 0.9) 70%
    );
  cursor: pointer;
  text-align: left;
  transition:
    transform 160ms ease,
    border-color 160ms ease,
    background 160ms ease,
    box-shadow 160ms ease;
}

.play-style-tabs > button:nth-child(2) {
  --tab-rgb: 126, 151, 255;
}

.play-style-tabs > button:nth-child(3) {
  --tab-rgb: 239, 190, 103;
}

.play-style-tabs > button:hover {
  transform: translateY(-1px);
  border-color: rgba(var(--tab-rgb), 0.58);
  background:
    linear-gradient(
      145deg,
      rgba(var(--tab-rgb), 0.16),
      rgba(18, 22, 26, 0.96) 70%
    );
}

.play-style-tabs > button.is-active {
  border-color: rgba(var(--tab-rgb), 0.82);
  background:
    linear-gradient(
      145deg,
      rgba(var(--tab-rgb), 0.26),
      rgba(18, 22, 26, 0.98) 76%
    );
  box-shadow:
    inset 0 0 0 1px rgba(var(--tab-rgb), 0.12),
    0 5px 18px rgba(var(--tab-rgb), 0.1);
}

.play-style-accent {
  width: 5px;
  height: 28px;
  flex: 0 0 auto;
  border-radius: 999px;
  background: var(--tab-color);
  box-shadow: 0 0 10px rgba(var(--tab-rgb), 0.28);
}

.play-style-tabs button > span:last-child {
  display: grid;
  min-width: 0;
}

.play-style-tabs strong {
  color: #dce2e5;
  font-size: 0.74rem;
  line-height: 1.25;
  white-space: nowrap;
}

.play-style-tabs small {
  color: var(--muted);
  font-size: 0.56rem;
  line-height: 1.15;
  white-space: nowrap;
}

.play-style-tabs button.is-active strong {
  color: var(--text);
}

.play-style-tabs button.is-active small {
  color: var(--tab-color);
}

@media (max-width: 820px) {
  .topbar {
    display: grid;
    gap: 14px;
  }

  .header-actions {
    justify-content: flex-end;
    width: 100%;
  }

  .play-style-tabs {
    grid-template-columns: repeat(3, minmax(76px, 90px));
  }

  .play-style-tabs small {
    display: none;
  }
}

@media (max-width: 680px) {
  .play-style-tabs {
    grid-template-columns: repeat(3, minmax(68px, 82px));
  }

  .play-style-tabs > button {
    min-height: 42px;
    padding-inline: 7px;
  }
}

/* Keep all three project marks inside the same transparent circular bounds. */
.brand-icon-slot {
  width: 58px;
  height: 58px;
  flex: 0 0 58px;
  overflow: hidden;
  border: 0;
  border-radius: 50%;
  background: transparent;
  box-shadow: none;
}

.brand-icon-slot .brand-icon {
  display: block;
  width: 58px;
  height: 58px;
  object-fit: contain;
}

@media (max-width: 680px) {
  .brand-icon-slot {
    width: 50px;
    height: 50px;
    flex-basis: 50px;
  }

  .brand-icon-slot .brand-icon {
    width: 50px;
    height: 50px;
  }
}

/* Keyboard UI theme: warm amber chrome with preserved key-state colors. */


/* The complete brand lockup is the consistent route back to the tool index. */
.brand {
  border-radius: 12px;
  color: inherit;
  cursor: pointer;
  flex: 0 1 auto;
  justify-self: start;
  max-width: 100%;
  text-decoration: none;
  width: fit-content;
  -webkit-tap-highlight-color: rgba(var(--theme-rgb), 0.14);
  transition: filter 160ms ease, transform 160ms ease;
}

.brand .brand-icon {
  transition: transform 160ms ease;
}

.brand:hover {
  filter: brightness(1.08);
  transform: translateY(-1px);
}

.brand:hover .brand-icon {
  transform: scale(1.04);
}

.brand:active {
  transform: translateY(0);
}

.brand:focus-visible {
  outline: 2px solid var(--theme);
  outline-offset: 6px;
}



.topbar,
.scale-strip {
  border-bottom-color: rgba(var(--theme-rgb), 0.18);
}





.play-style-tabs {
  border-color: rgba(var(--theme-rgb), 0.2);
  background: rgba(var(--theme-rgb), 0.045);
}

.play-style-tabs > button:nth-child(1) {
  --tab-rgb: 72, 216, 188;
}

.play-style-tabs > button:nth-child(2) {
  --tab-rgb: 126, 151, 255;
}

.play-style-tabs > button:nth-child(3) {
  --tab-rgb: 239, 190, 103;
}

.scale-strip .scale-summary strong,
.scale-strip select {
  border-color: rgba(var(--theme-rgb), 0.38);
  background: rgba(31, 25, 13, 0.92);
}

.scale-strip .scale-summary strong {
  border-color: rgba(var(--theme-rgb), 0.38);
  background: color-mix(in srgb, #0c0f12 90%, var(--theme) 10%);
}

.scale-strip .segment-group {
  border-color: rgba(var(--theme-rgb), 0.22);
  background: rgba(var(--theme-rgb), 0.045);
}

.segment-group .segment:hover {
  background: rgba(var(--theme-rgb), 0.09);
}

.segment-group .segment.is-active,
.segment-group .segment.is-active:hover,
.scale-strip .segment-group .segment.is-active,
.scale-strip .segment-group .segment.is-active:hover {
  border-color: rgba(var(--theme-rgb), 0.54);
  background: var(--theme-soft);
  box-shadow: inset 0 0 0 1px rgba(var(--theme-rgb), 0.08);
}

select:hover {
  border-color: rgba(var(--theme-rgb), 0.54);
  background: rgba(40, 31, 15, 0.96);
}

.eyebrow,
.chord-card .roman {
  color: var(--theme);
}

.chord-card {
  border-color: rgba(var(--theme-rgb), 0.18);
  background: rgba(26, 21, 12, 0.9);
}

.chord-card:hover {
  border-color: rgba(var(--theme-rgb), 0.44);
  background: rgba(36, 29, 15, 0.96);
}

.chord-card.is-active {
  border-color: rgba(var(--theme-rgb), 0.66);
  background:
    radial-gradient(
      circle at 100% 0%,
      rgba(var(--theme-rgb), 0.2),
      transparent 48%
    ),
    rgba(35, 28, 14, 0.96);
  box-shadow:
    0 8px 20px rgba(0, 0, 0, 0.18),
    0 0 22px rgba(var(--theme-rgb), 0.06);
}

.keyboard-shell {
  border-color: rgba(var(--theme-rgb), 0.3);
  background: #100d08;
  box-shadow:
    0 26px 60px rgba(0, 0, 0, 0.3),
    inset 0 1px rgba(var(--theme-rgb), 0.08),
    0 0 28px rgba(var(--theme-rgb), 0.055);
  scrollbar-color: rgba(var(--theme-rgb), 0.38) transparent;
}

/* Portrait layout: prioritize chord choices and the playable keyboard. */
@media (orientation: portrait), (max-aspect-ratio: 1/1) {
  .app-shell {
    width: calc(100% - 24px);
    min-height: calc(100dvh - 24px);
    margin: 12px auto;
  }

  .topbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 14px;
    padding: 18px;
  }

  .header-actions,
  .play-style-tabs {
    width: 100%;
  }

  .play-style-tabs {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .scale-strip {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 12px;
    min-height: 0;
    padding: 16px 18px;
  }

  .scale-strip .scale-summary {
    width: min(100%, 360px);
    min-width: 0;
  }

  .scale-strip .top-controls {
    display: grid;
    width: 100%;
    max-width: none;
    grid-template-columns: 108px minmax(210px, 1.35fr) minmax(180px, 1fr) minmax(220px, 1.15fr) 200px;
    align-items: end;
  }

  .scale-strip .top-controls .label-control,
  .scale-strip .label-control .segment-group {
    width: 200px;
    min-width: 0;
  }

  .keyboard-panel {
    padding: 18px;
  }

  .chord-grid {
    grid-template-columns: repeat(7, minmax(124px, 1fr));
    overflow-x: auto;
    scroll-snap-type: x proximity;
    scrollbar-width: thin;
  }

  .chord-card {
    min-height: 78px;
    scroll-snap-align: start;
  }

  .keyboard-panel .legend {
    overflow-x: auto;
    flex-wrap: nowrap;
    scrollbar-width: none;
  }

  .keyboard-panel .legend::-webkit-scrollbar {
    display: none;
  }

  .keyboard-panel .legend > span {
    flex: 0 0 auto;
  }

  .keyboard-shell {
    scroll-snap-type: x proximity;
  }

  .piano {
    min-width: 980px;
    height: 260px;
  }
}

@media (max-width: 680px) {
  .app-shell {
    width: 100%;
    min-height: 100dvh;
    margin: 0;
    border-inline: 0;
    border-radius: 0;
  }

  .topbar {
    gap: 12px;
    padding: 14px 12px 12px;
  }

  .brand {
    gap: 12px;
  }

  .brand-icon-slot,
  .brand-icon-slot .brand-icon {
    width: 44px;
    height: 44px;
  }

  .brand-icon-slot {
    flex-basis: 44px;
  }

  .brand h1 {
    font-size: 1.14rem;
  }

  .brand p {
    overflow: hidden;
    font-size: 0.76rem;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .play-style-tabs {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .play-style-tabs > button {
    justify-content: center;
    min-height: 44px;
    padding: 6px;
  }

  .play-style-tabs small {
    display: none;
  }

  .scale-strip {
    gap: 10px;
    padding: 12px;
  }

  .scale-strip .scale-summary {
    width: 100%;
  }

  .scale-strip .top-controls {
    grid-template-columns: minmax(0, 0.72fr) minmax(0, 1.28fr);
    gap: 10px;
  }

  .scale-strip .top-controls .segmented,
  .scale-strip .top-controls .label-control,
  .scale-strip .label-control .segment-group {
    width: 100%;
    min-width: 0;
  }

  .scale-strip .top-controls .inversion-control,
  .scale-strip .top-controls .label-control {
    grid-column: 1 / -1;
  }

  .scale-strip .chord-size-control .segment {
    padding-inline: 6px;
    font-size: 0.9rem;
    white-space: nowrap;
  }

  .keyboard-panel {
    padding: 14px 12px 16px;
  }

  .compact-chord-heading p {
    display: none;
  }

  .chord-grid {
    grid-template-columns: repeat(7, 104px);
    gap: 8px;
    margin-right: -12px;
    padding-right: 12px;
  }

  .chord-card {
    min-height: 72px;
    padding: 8px;
  }

  .keyboard-panel .legend {
    margin-block: 16px 10px;
  }

  .scroll-hint {
    display: block;
  }

  .keyboard-shell {
    border-radius: 14px;
  }

  .piano {
    min-width: 860px;
    height: 236px;
    padding: 8px 8px 12px;
  }

  .site-footer {
    min-height: 52px;
    flex-basis: 52px;
  }
}

/* Tablet portrait: keep every control in bounds and show all seven chords. */
@media (min-width: 681px) and (max-width: 900px) {
  .scale-strip .scale-summary {
    width: 100%;
  }

  .scale-strip .top-controls {
    grid-template-columns: minmax(0, 0.72fr) minmax(0, 1.28fr);
    gap: 12px;
  }

  .scale-strip .top-controls .control,
  .scale-strip .top-controls .segmented,
  .scale-strip .top-controls .segment-group {
    width: 100%;
    min-width: 0;
  }

  .scale-strip .top-controls .label-control {
    width: 100%;
    grid-column: 1 / -1;
  }

  .chord-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
    margin-right: 0;
    padding-right: 0;
    overflow: visible;
  }

  .chord-card {
    min-height: 72px;
  }
}
