:root {
  color-scheme: dark;
  --bg: #080b0e;
  --panel: rgba(19, 23, 27, 0.88);
  --panel-solid: #12161a;
  --panel-soft: #0f1215;
  --control: #0b1514;
  --text: #f2f5f6;
  --muted: #87929d;
  --line: rgba(72, 216, 188, 0.18);
  --line-strong: rgba(72, 216, 188, 0.32);
  --teal: #48d8bc;
  --teal-soft: rgba(72, 216, 188, 0.16);
  --coral: #ff775f;
  --coral-soft: rgba(255, 119, 95, 0.18);
  --amber: #efbe67;
  --control-height: 42px;
  --label-width: 98px;
  --radius-lg: 24px;
  --radius-md: 12px;
  --theme: #48d8bc;
  --theme-rgb: 72, 216, 188;
  --theme-soft: rgba(72, 216, 188, 0.16);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--bg);
}

body {
  display: flow-root;
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 14% -12%, rgba(67, 217, 189, 0.13), transparent 32%),
    radial-gradient(circle at 88% 2%, rgba(52, 168, 184, 0.055), transparent 27%),
    linear-gradient(145deg, #0c1616 0%, #0d1718 48%, #0b1113 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,
input,
output {
  font: inherit;
}

button,
select {
  color: inherit;
}

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

.app-shell {
  width: min(calc(100% - 48px), 1600px);
  min-height: calc(100vh - 48px);
  margin: 24px auto;
}

.app-frame {
  display: flex;
  width: 100%;
  min-height: calc(100vh - 48px);
  overflow: hidden;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: radial-gradient(circle at 8% 0%, rgba(67, 217, 189, 0.075), transparent 25%), linear-gradient(180deg, rgba(15, 28, 27, 0.97), rgba(9, 17, 18, 0.98));
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(18px);
  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);
  min-height: 98px;
}

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

.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-subtitle {
  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;
}

.header-actions {
  display: flex;
  align-items: stretch;
  flex: 0 0 auto;
  gap: 12px;
}

.instrument-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);
}

.instrument-tabs > button {
  --tab-rgb: 72, 216, 188;
  --tab-color: rgb(var(--tab-rgb));
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  min-height: 46px;
  padding: 6px 9px;
  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%);
  text-align: left;
  cursor: pointer;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease, box-shadow 160ms ease;
}

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

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

.instrument-tabs > button:hover {
  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%);
  transform: translateY(-1px);
}

.instrument-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);
}

.tab-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);
}

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

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

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

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

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

.workspace {
  flex: 1;
}

.control-panel {
  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;
}

.primary-controls {
  display: flex;
  align-items: end;
  justify-content: flex-end;
  flex: 1;
  flex-wrap: wrap;
  gap: 12px;
}

.scale-summary,
.select-control,
.static-control,
.switch-control,
.segmented-control {
  display: grid;
  gap: 6px;
  min-width: 128px;
  margin: 0;
  padding: 0;
  border: 0;
}

.scale-summary {
  flex: 0 1 320px;
  min-width: 240px;
}

.select-control[data-field="position"] {
  min-width: 230px;
}

.scale-summary > span,
.select-control > span,
.static-control > span,
.switch-control > span,
.segmented-control > .segment-label {
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 760;
  letter-spacing: 0.03em;
}

.scale-summary strong,
select,
.static-control strong,
.segmented-control button,
.switch-control button {
  min-height: var(--control-height);
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--control);
}

.scale-summary strong {
  display: flex;
  min-width: 0;
  padding: 0 12px;
  align-items: center;
  overflow: hidden;
  color: var(--text);
  font-size: 0.82rem;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

select {
  width: 100%;
  padding: 0 36px 0 12px;
  outline: none;
}

.static-control strong {
  display: flex;
  align-items: center;
  padding: 0 12px;
  font-size: 0.82rem;
  font-weight: 650;
}

.segmented-control > div {
  display: flex;
  gap: 4px;
  height: var(--control-height);
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(7, 9, 11, 0.46);
}

.segmented-control button {
  min-height: 0;
  min-width: 62px;
  padding: 0 11px;
  border-color: transparent;
  background: transparent;
  box-shadow: none;
  color: var(--muted);
  cursor: pointer;
}

.segmented-control button.is-active {
  border-color: rgba(72, 216, 188, 0.46);
  background: var(--teal-soft);
  color: var(--text);
}

.switch-control button {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 11px;
  color: var(--muted);
  cursor: pointer;
}

.switch-control button i {
  position: relative;
  width: 30px;
  height: 18px;
  border-radius: 10px;
  background: #2a3035;
}

.switch-control button i::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #89939c;
  transition: transform 150ms ease, background 150ms ease;
}

.switch-control button[aria-checked="true"] i {
  background: rgba(72, 216, 188, 0.28);
}

.switch-control button[aria-checked="true"] i::after {
  background: var(--teal);
  transform: translateX(12px);
}

.switch-control button b {
  font-size: 0.78rem;
}

.board-section {
  padding: 0 22px clamp(18px, 3vw, 28px);
  overflow: hidden;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.012), transparent 24%),
    rgba(10, 13, 15, 0.26);
}

.board-scroll {
  overflow-x: auto;
  overflow-y: visible;
  overscroll-behavior-inline: contain;
  padding: 12px 12px 20px;
  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(72, 216, 188, 0.34) rgba(255, 255, 255, 0.03);
  scrollbar-width: thin;
}

.note-board {
  --lane-height: 72px;
  --body-height: 92px;
  position: relative;
  display: grid;
  grid-template-columns: var(--label-width) repeat(var(--hole-count), minmax(78px, 1fr));
  min-width: calc(var(--label-width) + var(--hole-count) * 78px);
  overflow: visible;
  isolation: isolate;
}

.chromatic-board {
  grid-template-columns: var(--label-width) repeat(var(--hole-count), minmax(76px, 1fr));
  min-width: calc(var(--label-width) + var(--hole-count) * 76px + 36px);
  padding-right: 36px;
}

.chromatic-board .tone-cell.is-slide-note {
  background: linear-gradient(180deg, rgba(126, 151, 255, 0.025), transparent);
}

.tremolo-board {
  --lane-height: 68px;
  --body-height: 104px;
  grid-template-columns: var(--label-width) repeat(var(--hole-count), minmax(46px, 1fr));
  min-width: calc(var(--label-width) + var(--hole-count) * 46px);
}

.row-label,
.tone-cell,
.hole-number {
  height: var(--lane-height);
  min-height: var(--lane-height);
}

.row-label {
  position: sticky;
  left: 0;
  z-index: 8;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 10px 14px 10px 2px;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  background: linear-gradient(90deg, #0c1013 76%, rgba(12, 16, 19, 0));
  box-shadow: 16px 0 20px rgba(5, 7, 8, 0.36);
}

.row-label strong {
  color: #d8e0e4;
  font-size: 0.76rem;
  letter-spacing: 0.02em;
}

.row-label span {
  margin-top: 2px;
  color: #697680;
  font-size: 0.54rem;
  letter-spacing: 0.11em;
}

.tone-cell {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: stretch;
  justify-content: center;
  gap: 4px;
  padding: 7px 5px;
  background: transparent;
}

.tone-cell.has-stack {
  flex-direction: row;
  gap: 2px;
  padding-inline: 4px;
}

.tone-cell.has-stack .note-button {
  flex: 1 1 0;
  padding-inline: 1px;
  border-radius: 7px;
}

.tone-cell.has-stack .note-button > strong {
  font-size: 0.78rem;
  letter-spacing: -0.02em;
}

.tone-cell.has-stack .note-button > strong.is-numbered {
  padding-block: 4px;
}

.tone-cell.has-stack .note-button > .secondary-label {
  margin-top: 3px;
  font-size: 0.52rem;
}

.note-button {
  display: grid;
  place-content: center;
  flex: 1;
  min-width: 0;
  min-height: 52px;
  padding: 5px 3px;
  border: 1px solid rgba(195, 207, 213, 0.13);
  border-radius: 11px;
  background:
    linear-gradient(150deg, rgba(255, 255, 255, 0.045), transparent 48%),
    rgba(15, 20, 24, 0.84);
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.035), 0 4px 12px rgba(0, 0, 0, 0.16);
  backdrop-filter: blur(8px);
  cursor: pointer;
  transition: transform 130ms ease, border-color 130ms ease, background 130ms ease, box-shadow 130ms ease, opacity 130ms ease;
}

.note-button:hover {
  z-index: 4;
  border-color: rgba(255, 255, 255, 0.34);
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.06), 0 8px 18px rgba(0, 0, 0, 0.28);
  transform: translateY(-2px);
}

.note-button:active {
  transform: translateY(1px) scale(0.98);
}

.note-button > strong {
  font-size: 0.95rem;
  line-height: 1;
}

.note-button > strong small {
  margin-left: 1px;
  color: currentColor;
  font-size: 0.56em;
  opacity: 0.62;
}

.note-button > .secondary-label {
  margin-top: 4px;
  color: currentColor;
  font-size: 0.6rem;
  font-weight: 720;
  opacity: 0.65;
}

.note-button > strong.is-numbered {
  display: grid;
  place-items: center;
  padding-block: 5px;
}

.numbered-note {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1em;
  line-height: 1;
}

.numbered-accidental {
  margin-right: 1px;
  font-size: 0.62em;
  transform: translateY(-0.06em);
}

.numbered-core {
  position: relative;
  display: inline-grid;
  place-items: center;
  min-width: 0.72em;
}

.numbered-digit {
  display: block;
}

.octave-dots {
  position: absolute;
  left: 50%;
  display: flex;
  flex-direction: column;
  gap: 1px;
  transform: translateX(-50%);
}

.octave-dots.is-high {
  bottom: calc(100% + 2px);
  flex-direction: column-reverse;
}

.octave-dots.is-low {
  top: calc(100% + 2px);
}

.octave-dots i {
  display: block;
  width: 3px;
  height: 3px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: currentColor;
}

.secondary-label .numbered-note {
  min-width: 0.9em;
}

.secondary-label .octave-dots {
  gap: 0.5px;
}

.secondary-label .octave-dots i {
  width: 2px;
  height: 2px;
}

.note-button.is-in-scale {
  border-color: rgba(72, 216, 188, 0.34);
  background:
    linear-gradient(150deg, rgba(130, 255, 230, 0.09), transparent 52%),
    var(--teal-soft);
  color: #a8f3e4;
}

.note-button.is-root {
  border-color: rgba(255, 119, 95, 0.64);
  background:
    linear-gradient(150deg, rgba(255, 210, 198, 0.1), transparent 52%),
    var(--coral-soft);
  color: #ffd3cb;
  box-shadow: inset 0 0 0 1px rgba(255, 119, 95, 0.08), 0 5px 15px rgba(81, 24, 17, 0.18);
}

.note-button.is-outside {
  color: #838d96;
  opacity: 0.54;
}

.note-button:focus-visible,
.instrument-tabs button:focus-visible,
select:focus-visible,
.segmented-control button:focus-visible,
.switch-control button:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
  box-shadow: 0 0 0 5px rgba(9, 11, 13, 0.9);
}

.empty-note {
  align-self: center;
  color: rgba(255, 255, 255, 0.12);
}

.hole-label,
.hole-number {
  height: var(--body-height);
  min-height: var(--body-height);
}

.hole-label {
  position: sticky;
  left: 0;
  z-index: 9;
  overflow: hidden;
  justify-content: center;
  padding: 10px 14px;
  border: 1px solid #707980;
  border-right: 0;
  border-radius: 17px 0 0 17px;
  background:
    linear-gradient(176deg, rgba(255, 255, 255, 0.55) 0 4%, transparent 5% 100%),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.025) 0 1px, rgba(0, 0, 0, 0.025) 1px 3px),
    linear-gradient(180deg, #aeb6bb 0%, #657077 15%, #343c42 43%, #11161a 49%, #181e22 69%, #4c565c 88%, #899297 100%);
  box-shadow:
    inset 0 2px rgba(255, 255, 255, 0.42),
    inset 0 -2px rgba(255, 255, 255, 0.13),
    -5px 9px 24px rgba(0, 0, 0, 0.32);
}

.hole-label::before {
  content: "";
  position: absolute;
  left: 10px;
  width: 8px;
  height: 8px;
  border: 1px solid #adb5b9;
  border-radius: 50%;
  background: radial-gradient(circle at 38% 35%, #d9dcde 0 12%, #666e72 28%, #202529 66%, #a0a7aa 72%, #363d41 100%);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.45);
}

.hole-number {
  position: relative;
  z-index: 6;
  display: grid;
  grid-template-rows: 18px 1fr;
  place-items: center;
  gap: 5px;
  padding: 8px 5px 10px;
  border-top: 1px solid #737d83;
  border-bottom: 1px solid #525c62;
  background:
    linear-gradient(176deg, rgba(255, 255, 255, 0.55) 0 4%, transparent 5% 100%),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.025) 0 1px, rgba(0, 0, 0, 0.025) 1px 3px),
    linear-gradient(180deg, #aeb6bb 0%, #657077 15%, #343c42 43%, #11161a 49%, #181e22 69%, #4c565c 88%, #899297 100%);
  box-shadow:
    inset 0 2px rgba(255, 255, 255, 0.42),
    inset 0 -2px rgba(255, 255, 255, 0.13),
    0 12px 22px rgba(0, 0, 0, 0.28);
}

.hole-number.is-last {
  border-right: 1px solid #707980;
  border-radius: 0 17px 17px 0;
}

.hole-number.is-last::after {
  content: "";
  position: absolute;
  right: 9px;
  top: 11px;
  width: 8px;
  height: 8px;
  border: 1px solid #adb5b9;
  border-radius: 50%;
  background: radial-gradient(circle at 38% 35%, #d9dcde 0 12%, #666e72 28%, #202529 66%, #a0a7aa 72%, #363d41 100%);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.45);
}

.hole-index {
  position: relative;
  z-index: 2;
  color: #151a1d;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.68rem;
  font-weight: 800;
  line-height: 1;
  text-shadow: 0 1px rgba(255, 255, 255, 0.28);
}

.hole-apertures {
  display: grid;
  width: 100%;
  height: 46px;
  padding: 4px;
  border: 1px solid rgba(214, 221, 224, 0.23);
  border-radius: 5px 5px 10px 10px;
  background:
    linear-gradient(110deg, rgba(255, 255, 255, 0.06), transparent 24%),
    #080a0b;
  box-shadow:
    inset 0 8px 13px rgba(0, 0, 0, 0.9),
    inset 0 -2px rgba(255, 255, 255, 0.055),
    0 1px rgba(255, 255, 255, 0.14);
}

.hole-apertures i {
  display: block;
  min-width: 0;
  min-height: 0;
  border-radius: 2px 2px 7px 7px;
  background:
    linear-gradient(90deg, transparent, rgba(153, 119, 66, 0.2) 48%, transparent),
    linear-gradient(180deg, #020303, #0e1113);
  box-shadow: inset 0 5px 8px #000;
}

.chromatic-board .hole-label,
.chromatic-board .hole-number {
  background:
    linear-gradient(176deg, rgba(255, 255, 255, 0.64) 0 4%, transparent 5% 100%),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.032) 0 1px, rgba(0, 0, 0, 0.022) 1px 4px),
    linear-gradient(180deg, #c1c8cc 0%, #7d878d 17%, #40494f 43%, #171d21 49%, #21282d 69%, #626d73 88%, #9ea6aa 100%);
}

.chromatic-board .hole-apertures {
  border-radius: 4px;
}

.slide-assembly {
  position: absolute;
  top: calc(var(--top-lanes) * var(--lane-height) + 23px);
  right: 3px;
  z-index: 7;
  width: 39px;
  height: 26px;
  border: 1px solid #798389;
  border-radius: 0 9px 9px 0;
  background: linear-gradient(180deg, #b8c0c4, #5b656b 38%, #252c30 58%, #879197);
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.62), 5px 5px 12px rgba(0, 0, 0, 0.3);
}

.slide-assembly i {
  position: absolute;
  top: 6px;
  right: -7px;
  place-items: center;
  width: 15px;
  height: 15px;
  border: 1px solid #aeb6ba;
  border-radius: 50%;
  background: radial-gradient(circle at 38% 32%, #e8ecee 0 8%, #8e989d 32%, #30373b 70%, #aeb6ba 76%, #4b5357 100%);
  box-shadow: 2px 3px 6px rgba(0, 0, 0, 0.38);
}

.tremolo-board .hole-label,
.tremolo-board .hole-number {
  background:
    linear-gradient(176deg, rgba(255, 255, 255, 0.36) 0 4%, transparent 5% 100%),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.022) 0 1px, rgba(0, 0, 0, 0.025) 1px 3px),
    linear-gradient(180deg, #8f999f 0%, #566168 14%, #252d32 35%, #151a1e 50%, #262e33 70%, #5b666c 90%, #858f94 100%);
}

.tremolo-board .hole-number {
  grid-template-rows: 15px 1fr;
  gap: 4px;
  padding: 6px 3px 8px;
}

.tremolo-board .hole-index {
  font-size: 0.58rem;
}

.tremolo-board .hole-apertures {
  grid-template-rows: repeat(2, 1fr);
  gap: 3px;
  height: 68px;
  padding: 3px;
  border-radius: 4px 4px 7px 7px;
}

.tremolo-board .hole-apertures i {
  border-radius: 2px 2px 4px 4px;
}

.board-notes {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 0.7rem;
}

.board-notes span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.board-notes i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.legend-root {
  background: var(--coral);
}

.legend-scale {
  background: var(--teal);
}

.legend-muted {
  background: #66717a;
}

.board-notes p {
  margin: 0 0 0 auto;
}

.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: 900px) {
  .app-shell {
    width: calc(100% - 28px);
    min-height: calc(100vh - 28px);
    margin: 14px auto;
  }

  .app-frame {
    min-height: calc(100vh - 28px);
  }

  .control-panel {
    align-items: stretch;
    flex-direction: column;
  }

  .scale-summary {
    width: 100%;
    min-width: 0;
  }

  .control-panel > .segmented-control {
    align-self: flex-start;
  }
}

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

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

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

  .instrument-tabs small {
    display: none;
  }

}

@media (max-width: 680px) {
  :root {
    --label-width: 82px;
  }

  .topbar {
    align-items: flex-start;
    padding: 16px;
  }

  .control-panel {
    padding: 16px;
  }

  .instrument-tabs {
    grid-template-columns: repeat(3, minmax(68px, 82px));
  }

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

  .primary-controls {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .select-control,
  .select-control[data-field="position"],
  .static-control,
  .switch-control,
  .segmented-control {
    min-width: 0;
  }

  .board-section {
    padding: 0 16px 17px;
  }

  .board-notes p {
    flex-basis: 100%;
    margin-left: 0;
  }
}

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

  .app-frame {
    min-height: calc(100vh - 20px);
  }

  .board-section {
    padding-right: 10px;
    padding-left: 10px;
  }
}

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

}

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

.noscript-message {
  margin: 0;
  padding: 12px 18px;
  background: #4a241d;
  color: #ffe5df;
  text-align: center;
}

.app-loading {
  min-height: 180px;
}

/* Keep selects aligned with the segmented controls across browser engines. */
select {
  height: var(--control-height);
  min-height: var(--control-height);
  appearance: none;
  -webkit-appearance: none;
}

.select-control {
  position: relative;
}

.select-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;
}

/* Shared primary-header baseline for all three learning tools. */


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

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

/* Fixed widths shared by the three learning tools' secondary bars. */
.control-panel .scale-summary {
  width: 320px;
  min-width: 320px;
  flex: 0 0 320px;
}



.control-panel > .segmented-control {
  width: 200px;
  min-width: 200px;
  flex: 0 0 200px;
}

.control-panel > .segmented-control > div {
  width: 200px;
}

.control-panel > .segmented-control button {
  min-width: 0;
  flex: 1 1 0;
}

@media (max-width: 900px) {
  .control-panel .scale-summary {
    width: min(100%, 320px);
    min-width: 0;
    flex-basis: auto;
  }
}

/* Place the legend above the note map and share the solid-dot system. */
.board-notes {
  min-height: 52px;
  padding: 12px 0;
  gap: 10px 20px;
  margin: 0;
  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;
}

.board-notes span {
  gap: 7px;
}

.board-notes i {
  width: 11px;
  height: 11px;
  flex: 0 0 11px;
  border: 0;
  border-radius: 50%;
  box-shadow: none;
}

.board-notes + .board-scroll {
  margin-top: 0;
}

.board-footnote {
  margin: 10px 0 0;
  color: #87929d;
  font-size: 0.7rem;
  text-align: right;
}

/* Shared scale-summary treatment across the three learning tools. */
.control-panel .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;
}

/* 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;
  }
}

/* Harmonica UI theme: blue-green chrome with preserved note-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,
.control-panel {
  border-bottom-color: rgba(var(--theme-rgb), 0.18);
}

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

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

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

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



.scale-summary strong,
select,
.static-control strong,
.switch-control button {
  border-color: rgba(var(--theme-rgb), 0.32);
  background: rgba(11, 27, 24, 0.92);
}

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

.segmented-control > div {
  border-color: rgba(var(--theme-rgb), 0.2);
  background: rgba(var(--theme-rgb), 0.045);
}

.segmented-control button:hover {
  background: rgba(var(--theme-rgb), 0.09);
}

.segmented-control button.is-active,
.segmented-control button.is-active:hover {
  border-color: rgba(var(--theme-rgb), 0.52);
  background: var(--theme-soft);
  box-shadow: inset 0 0 0 1px rgba(var(--theme-rgb), 0.08);
}

select:hover,
.switch-control button:hover {
  border-color: rgba(var(--theme-rgb), 0.54);
  background: rgba(14, 38, 33, 0.96);
}

.board-section {
  background:
    linear-gradient(180deg, rgba(var(--theme-rgb), 0.025), transparent 24%),
    rgba(8, 19, 17, 0.28);
}

.board-scroll {
  border-color: rgba(var(--theme-rgb), 0.28);
  background: #07100f;
  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);
}

.note-button {
  border-color: rgba(var(--theme-rgb), 0.18);
  background:
    linear-gradient(150deg, rgba(var(--theme-rgb), 0.06), transparent 48%),
    rgba(12, 27, 24, 0.86);
}

.note-button:hover {
  border-color: rgba(var(--theme-rgb), 0.5);
}

/* Portrait layout: controls form a compact toolbar instead of a tall panel. */
@media (orientation: portrait), (max-aspect-ratio: 1/1) {
  .app-shell {
    width: calc(100% - 24px);
    min-height: calc(100dvh - 24px);
    margin: 12px auto;
  }

  .app-frame {
    min-height: calc(100dvh - 24px);
  }

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

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

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

  .control-panel {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 200px;
    align-items: end;
    gap: 12px;
    min-height: 0;
    padding: 16px 18px;
  }

  .control-panel .scale-summary {
    width: min(100%, 360px);
    min-width: 0;
    grid-column: 1 / -1;
  }

  .primary-controls {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    justify-content: stretch;
  }

  .primary-controls .select-control[data-field="position"] {
    grid-column: span 2;
  }

  .control-panel > .segmented-control {
    width: 200px;
    min-width: 0;
  }

  .board-section {
    padding: 0 18px 22px;
  }

  .board-notes {
    overflow-x: auto;
    flex-wrap: nowrap;
    scrollbar-width: none;
  }

  .board-notes::-webkit-scrollbar {
    display: none;
  }

  .board-notes span {
    flex: 0 0 auto;
  }

  .board-scroll {
    scroll-snap-type: x proximity;
  }
}

@media (max-width: 680px) {
  :root {
    --label-width: 72px;
  }

  .app-shell {
    width: 100%;
    min-height: 100dvh;
    margin: 0;
  }

  .app-frame {
    min-height: 100dvh;
    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-subtitle {
    overflow: hidden;
    font-size: 0.76rem;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

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

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

  .instrument-tabs small {
    display: none;
  }

  .control-panel {
    grid-template-columns: minmax(0, 1fr);
    gap: 10px;
    padding: 12px;
  }

  .control-panel .scale-summary,
  .primary-controls,
  .control-panel > .segmented-control {
    width: 100%;
    grid-column: 1;
  }

  .primary-controls {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .primary-controls .select-control[data-field="position"] {
    grid-column: 1 / -1;
  }

  .control-panel > .segmented-control,
  .control-panel > .segmented-control > div {
    width: 100%;
    min-width: 0;
  }

  .board-section {
    padding: 0 10px 16px;
  }

  .board-notes {
    min-height: 44px;
    padding-block: 9px;
  }

  .board-scroll {
    padding: 8px 8px 14px;
    border-radius: 14px;
  }

  .note-board {
    --lane-height: 64px;
  }

  .tremolo-board {
    --lane-height: 60px;
  }

  .board-footnote {
    text-align: left;
  }

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