:root {
  --bg: #000000;
  --panel: transparent;
  --panel-border: transparent;
  --text-primary: #f2f2f2;
  --text-secondary: #c6c6c6;
  --text-muted: #6f6f6f;
  --accent: #76b6bc;
  --accent-subtle: #35555b;
  --danger-text: #ffb8b8;
  --danger-border: #ff00008c;
  --note-cell-ink: rgba(0, 0, 0, 0.82);
  --note-dot-off: rgba(0, 0, 0, 0);
  --shadow-note-soft: rgba(0, 0, 0, 0.45);
  --shadow-dot-soft: rgba(255, 255, 255, 0.3);
  --shadow-dot-strong: rgba(0, 0, 0, 0.6);
  --note-fallback: #dddddd;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  font-family: "IBM Plex Mono", "SFMono-Regular", Menlo, Consolas, monospace;
  background: var(--bg);
  color: var(--text-primary);
}

:is(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
  outline: 0.1rem solid var(--accent) !important;
  outline-offset: 0.1rem;
}

body.home-open {
  overflow: hidden;
}

body.mouse-idle,
body.mouse-idle * {
  cursor: none !important;
}

.app {
  max-width: 90.0rem;
  margin: 0 auto;
  padding: 0.8rem;
}

body.home-open .app {
  user-select: none;
  filter: none;
  opacity: 0.96;
}

.homeOverlay[hidden] {
  display: none;
}

.homeOverlay {
  position: fixed;
  inset: 0;
  z-index: 500;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 0.85rem;
  background: rgba(0, 0, 0, 0.75);
}

#homeOverlay {
  pointer-events: none;
}

#homeOverlay .homePanel {
  pointer-events: auto;
}

.homePanel {
  width: min(42rem, 100%);
  margin-top: 0;
  border: 0.1rem solid rgba(255, 255, 255, 0.24);
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(2px);
  padding: 3rem;
  position: relative;
}

.homeEyebrow {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.58rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.homeTitle {
  margin: 0.24rem 0 0.16rem;
  font-size: clamp(1rem, 2vw, 1.4rem);
  font-weight: 500;
  letter-spacing: 0.03em;
}

.homeSubtitle {
  margin: 0;
  color: var(--text-secondary);
  font-size: 0.68rem;
  letter-spacing: 0.06em;
}

.homeHint {
  /* margin: 0.2rem 0 0; */
  color: var(--text-secondary);
  font-size: 0.7rem;
}

.homeActions {
  margin-top: 0.3rem;
  display: block;
}

.homeActionBtn {
  appearance: none;
  border: 0.1rem solid var(--text-muted);
  background: rgba(0, 0, 0, 0.5);
  color: var(--text-secondary);
  text-decoration: none;
  cursor: pointer;
  font: inherit;
  font-size: 0.62rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 0.45rem 0.72rem;
  margin: .25rem 0;
}

.homeActionGhost {
  font-size: 50% !important;
}

.homeActionBtn:hover,
.homeActionBtn:focus-visible {
  border-color: var(--text-primary);
  color: var(--text-primary);
  outline: none;
}

.homeActionPrimary {
  border-color: var(--accent);
  color: var(--text-primary);
}

.modalCloseBtn {
  appearance: none;
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  width: 1.5rem;
  height: 1.5rem;
  border: 0.1rem solid var(--text-muted);
  background: var(--bg);
  color: var(--text-secondary);
  font: inherit;
  line-height: 1;
  cursor: pointer;
  display: inline-grid;
  place-items: center;
}

.modalCloseBtn:hover,
.modalCloseBtn:focus-visible {
  border-color: var(--text-primary);
  color: var(--text-primary);
  outline: none;
}

.guideModalPanel {
  width: min(44rem, 100%);
}

.midiInspectorPanel {
  width: min(56rem, 100%);
}

.midiInspectorControls {
  margin-top: 0.7rem;
  display: grid;
  grid-template-columns: minmax(8rem, 11rem) auto auto;
  gap: 0.45rem;
  align-items: end;
}

.midiInspectorControl {
  display: grid;
  gap: 0.2rem;
}

.midiInspectorControl > span {
  font-size: 0.58rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.midiInspectorAutoScroll {
  justify-self: start;
  align-self: center;
  margin: 0;
}

.midiInspectorStats {
  margin-top: 0.45rem;
  color: var(--text-secondary);
  font-size: 0.58rem;
  letter-spacing: 0.03em;
}

.midiInspectorLog {
  margin-top: 0.45rem;
  border: 0.1rem solid var(--accent-subtle);
  min-height: 14rem;
  max-height: min(58vh, 25rem);
  overflow: auto;
  font-size: 0.56rem;
  line-height: 1.35;
  background: rgba(0, 0, 0, 0.28);
}

.midiInspectorRow {
  display: grid;
  grid-template-columns: 4.3rem 2.2rem 5.6rem 1fr 7.6rem;
  gap: 0.35rem;
  align-items: center;
  padding: 0.2rem 0.35rem;
  color: var(--text-secondary);
  border-bottom: 0.06rem solid rgba(118, 182, 188, 0.18);
  white-space: nowrap;
}

.midiInspectorRow:last-child {
  border-bottom: 0;
}

.midiInspectorRow strong {
  color: var(--text-primary);
  font-weight: 500;
}

.midiInspectorRowType-noteon strong {
  color: #95f6a5;
}

.midiInspectorRowType-noteoff strong {
  color: #f0d78f;
}

.midiInspectorRowType-cc strong {
  color: #9bc7ff;
}

.midiInspectorRowType-clock strong {
  color: #d5a5ff;
}

.guideMap {
  margin-top: 0.6rem;
  display: grid;
  gap: 0.35rem;
}

.guideItem {
  display: grid;
  grid-template-columns: auto auto 1fr;
  align-items: start;
  gap: 0.45rem;
  font-size: 0.64rem;
  color: var(--text-secondary);
}

.guideIndex {
  color: var(--text-muted);
  font-size: 0.58rem;
  line-height: 1.6;
  min-width: 0.9rem;
  text-align: right;
}

.guideBadge {
  display: inline-grid;
  place-items: center;
  width: auto;
  min-height: 1.05rem;
  padding: 0.15rem 0.35rem;
  border: 0.1rem solid var(--accent);
  color: var(--text-primary);
  font-size: 0.56rem;
  line-height: 1;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.visualModeToggle {
  background: var(--bg);
  color: var(--text-muted);
  width: auto;
}

.visualModeToggle:hover {
  border-color: var(--text-primary);
}

.topActions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.25rem;
  width: 100%;
  grid-column: 1 / -1;
  justify-self: end;
}

.sessionActions {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
}

.sessionActions .btn {
  padding: 0.3rem 0.42rem;
  font-size: 0.54rem;
  line-height: 1;
}

.langSwitch {
  display: inline-flex;
  border: 0.1rem solid var(--text-muted);
}

.modalLangSwitch {
  position: relative;
  top: auto;
  left: auto;
  z-index: 2;
  margin-bottom: 0.5rem;
  margin-left: 0.5rem;
  float: inline-end;
}

.langBtn {
  appearance: none;
  border: 0;
  background: var(--bg);
  color: var(--text-secondary);
  font: inherit;
  font-size: 0.55rem;
  line-height: 1;
  letter-spacing: 0.08em;
  padding: 0.35rem 0.45rem;
  cursor: pointer;
}

.langBtn + .langBtn {
  border-left: 0.1rem solid var(--text-muted);
}

.langBtn:hover {
  color: var(--text-primary);
}

.langBtn.active {
  color: var(--text-primary);
  background: rgba(118, 182, 188, 0.1);
}

.secondScreenToggle {
  font-size: 0.75rem;
}

  body.visual-only .visualModeToggle {
    color: var(--text-muted);
    width: 2.4rem;
    height: 2.4rem;
    padding: 0;
  }

  body.visual-only .langSwitch {
    display: none;
  }

  body.visual-only .sessionActions {
    display: none;
  }

  body.visual-only #secondScreenToggle {
    display: none;
  }

  body.visual-only #noteAnnotationsToggle {
    display: none;
  }

  .title {
    font-size: 0.9rem;
    letter-spacing: 0.08em;
    color: var(--text-primary);
  }

  .title a,
  .title a:link,
  .title a:visited,
  .title a:hover,
  .title a:focus,
  .title a:active {
    color: var(--text-primary);
    text-decoration: none;
  }

  .title-left {
    border: 0;
    background: var(--panel);
    padding: 0.25rem;
    text-align: center;
  }

  .kitbar {
    display: flex;
    gap: 0;
    flex-wrap: wrap;
    justify-content: space-evenly;
  }

  .kitbtn {
    width: auto;
    height: 2rem;
    border: 0;
    background: var(--bg);
    color: var(--text-muted);
    cursor: pointer;
    font-weight: 700;
  }

  .kitbtn:hover {
    color: var(--text-secondary);
  }

  .kitbtn.active {
    background: var(--bg);
    color: var(--text-primary);
    text-decoration: underline;
    text-underline-offset: 0.2rem;
  }

  .layout {
    display: grid;
    grid-template-columns: minmax(16.9rem, 20.0rem) minmax(26.2rem, 1fr) minmax(15.6rem, 18.8rem);
    gap: 0.8rem;
    align-items: stretch;
    min-height: calc(100vh - 1.5rem);
  }

  .left,
  .right {
    display: grid;
    align-self: start;
    align-content: start;
    justify-content: end;
    gap: 0.25rem;
  }

  /* .right .kitbar {
  justify-content: center;
} */

  .panel {
    border: 0;
    background: var(--panel);
    padding: 0.5rem 0;
  }

  .paneltitle {
    font-size: 0.6rem;
    letter-spacing: 0.2em;
    color: var(--text-muted);
    /* margin-bottom: 0.5rem; */
    text-transform: uppercase;
  }

  .panelHelpTarget {
    cursor: help;
  }

  .panelHelpTarget:hover {
    color: var(--text-primary);
  }

  .paneltitle-inline {
    display: flex;
    align-items: baseline;
    justify-content: start;
    gap: 0.5rem;
  }

  .paneltitle-meta {
    font-size: 0.6rem;
    letter-spacing: 0.03em;
    color: var(--text-primary);
    border: solid 0.0rem var(--text-muted);
    padding: 0.2rem;
  }

  .kitbig {
    font-size: 3.2rem;
    line-height: 1;
    font-weight: 700;
    text-align: center;
    padding: 0.5rem 1rem;
  }

  .kitmeta {
    border-top: 0.0rem solid var(--text-muted);
    border-bottom: 0.0rem solid var(--text-muted);
    background: var(--panel);
    /* padding: 0.6rem; */
    min-height: 90px;
  }

  .kitname {
    font-size: 0.8rem;
  }

  .kitdesc {
    line-height: 1.35;
    color: var(--text-secondary);
  }

  .row {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    margin: 0.25rem 0;
    font-size: 0.8rem;
  }

  .row:last-child {
    margin-bottom: 0;
  }

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

  .grid2>label:not(.kbdslider) {
    grid-template-columns: minmax(5.4rem, auto) 1fr;
    align-items: center;
    gap: 0.5rem;
  }

.grid2>label:not(.kbdslider)>input[type="number"] {
  width: 6rem;
  justify-self: start;
}

.grid2>label:not(.kbdslider) .numberStepper {
  width: 5rem;
  justify-self: start;
}

  .midiRoutingGrid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.45rem;
    margin: 0.2rem 0 0.35rem;
  }

  .midiRoutingGrid>label {
    display: grid;
    gap: 0.2rem;
  }

  .midiRoutingGrid>label>span {
    font-size: 0.62rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-muted);
  }

.midiRoutingGrid select,
.midiRoutingGrid input[type="number"] {
  width: 100%;
}

.midiRoutingGrid .numberStepper {
  width: 100%;
  max-width: 5rem;
}

.numberStepper {
  display: grid;
  grid-template-columns: 1.3rem minmax(0, 1fr) 1.3rem;
  gap: 0.18rem;
  align-items: center;
}

.numberStepper .stepperBtn {
  appearance: none;
  -webkit-appearance: none;
  width: 1.3rem;
  height: 1.3rem;
  min-width: 1.3rem;
  display: inline-grid;
  place-items: center;
  padding: 0;
  background: transparent;
  color: var(--text-secondary);
  border: 0.1rem solid var(--text-muted);
  cursor: pointer;
}

.numberStepper .stepperBtn:hover {
  border-color: var(--text-primary);
  color: var(--text-primary);
}

.numberStepper .stepperBtn:disabled {
  opacity: 0.4;
  cursor: default;
  border-color: var(--text-muted);
  color: var(--text-muted);
}

.numberStepper .stepperBtn .icon {
  width: 0.58rem;
  height: 0.58rem;
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.numberStepper input[type="number"] {
  width: 100%;
  text-align: center;
  -moz-appearance: textfield;
}

.numberStepper input[type="number"]::-webkit-outer-spin-button,
.numberStepper input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.patternOctStepper {
  width: 5.8rem;
  justify-self: end;
}

.patternOctStepper #patternOctShiftValue {
  min-height: 1.3rem;
  border: 0.1rem solid var(--text-muted);
  display: inline-grid;
  place-items: center;
  line-height: 1;
  color: var(--accent);
  font-size: 0.68rem;
  padding: 0 0.2rem;
}

  label {
    display: grid;
    gap: 0.2rem;
    font-size: 0.7rem;
    color: var(--text-secondary);
  }

  select,
  input[type="number"],
  button.btn {
    background: var(--bg);
    color: var(--text-secondary);
    border: 0;
    padding: 0.4rem 0.4rem;
    font: inherit;
  }

  .visualModeBar {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    grid-auto-flow: row;
    gap: 0.2rem;
  }

  .scaleMiniBar {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(12, minmax(0, 1fr));
    gap: 0.15rem;
    margin-bottom: 0.3rem;
  }

  .scaleModeBar {
    width: 100%;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.15rem;
    margin-bottom: 0.2rem;
  }

  .keyboardMapModeBar {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin-top: 0.25rem;
  }

  .scaleMiniBtn {
    font-size: 0.45rem;
    padding: 0.2rem 0.05rem;
    min-height: 1.35rem;
  }

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

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

  .visualModeBtn {
    appearance: none;
    border: 0.1rem solid var(--text-muted);
    background: var(--bg);
    color: var(--text-secondary);
    font: inherit;
    font-size: 0.55rem;
    line-height: 1.1;
    padding: 0.3rem 0.2rem;
    text-align: center;
    cursor: pointer;
  }

  .visualModeBtn:hover {
    border-color: var(--text-primary);
    color: var(--text-primary);
  }

  .visualModeBtn.active {
    border-color: var(--accent);
    color: var(--text-primary);
  }

  button.btn {
    cursor: pointer;
  }

  button.btn:hover {
    color: var(--text-primary);
  }

  button.btn.iconbtn {
    width: 1.9rem;
    min-width: 1.9rem;
    height: 1.9rem;
    padding: 0;
    display: inline-grid;
    place-items: center;
    font-size: 0.9rem;
    line-height: 1;
  }

  button.btn.iconbtn .icon {
    width: 0.78rem;
    height: 0.78rem;
    display: block;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.9;
    stroke-linecap: round;
    stroke-linejoin: round;
  }

  button.btn.danger {
    color: var(--danger-text);
    border: 0.1rem solid var(--danger-border);
    font-size: 0.6rem;
  }

  input[type="range"] {
    width: 100%;
    --range-pct: 0%;
    appearance: none;
    -webkit-appearance: none;
    background: var(--panel);
    accent-color: var(--accent);
  }

  input[type="range"]::-webkit-slider-runnable-track {
    height: 0.2rem;
    border: 0;
    border-radius: 999.0rem;
    background: linear-gradient(to right,
        var(--accent) 0,
        var(--accent) var(--range-pct),
        var(--accent-subtle) var(--range-pct),
        var(--accent-subtle) 100%);
  }

  input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    height: 0.8rem;
    width: 0.8rem;
    margin-top: -0.2rem;
    border: 0;
    border-radius: 50%;
    background: var(--accent);
  }

  input[type="range"]::-moz-range-track {
    height: 0.2rem;
    border: 0;
    border-radius: 999.0rem;
    background: var(--text-muted);
  }

  input[type="range"]::-moz-range-progress {
    height: 0.2rem;
    border-radius: 999.0rem;
    background: var(--accent);
  }

  input[type="range"]::-moz-range-thumb {
    width: 0.8rem;
    height: 0.8rem;
    border: 0;
    border-radius: 50%;
    background: var(--accent);
  }

  input[type="range"]:focus-visible {
    outline: none;
  }

  .status {
    font-size: 0.7rem;
    color: var(--text-muted);
  }

  .check {
    display: flex;
    align-items: center;
    gap: 0.5rem;
  }

  .check input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    width: 0.9rem;
    height: 0.9rem;
    margin: 0;
    border: 0.1rem solid var(--text-secondary);
    border-radius: 0.0rem;
    background: var(--bg);
    cursor: pointer;
  }

  .check input[type="checkbox"]:hover {
    border-color: var(--accent);
  }

  .check input[type="checkbox"]:checked {
    border-color: var(--text-muted);
    background: var(--accent);
  }

  .check input[type="checkbox"]:focus-visible {
    outline: none;
    box-shadow: 0 0 0 0.1rem var(--accent-subtle);
  }

  .hint {
    margin-top: 0.4rem;
    color: var(--text-muted);
    font-size: 0.6rem;
  }

  .center {
    border: 0;
    background: var(--bg);
    position: relative;
    display: block;
    max-height: calc(100vh - 1.5rem);
  }

  body.visual-only {
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
  }

  body.visual-only .app {
    max-width: none;
    margin: 0;
    padding: 0;
    min-height: 100vh;
    min-height: 100dvh;
    height: 100vh;
    height: 100dvh;
  }

  body.visual-only .layout {
    grid-template-columns: 1fr;
    gap: 0;
    min-height: 100vh;
    min-height: 100dvh;
    height: 100vh;
    height: 100dvh;
  }

  body.visual-only .left,
  body.visual-only .noteStripWrap {
    display: none;
  }

  body.visual-only .right {
    display: block;
    position: fixed;
    top: 0.8rem;
    right: 0.8rem;
    z-index: 200;
  }

  body.visual-only .right .panel {
    display: none;
    padding: 0;
  }

  body.visual-only .right .panel:first-child {
    display: block;
  }

  body.visual-only .center {
    min-height: 100vh;
    min-height: 100dvh;
    height: 100vh;
    height: 100dvh;
  }

  body.visual-only .visualWrap {
    position: relative;
    inset: auto;
    min-height: 100vh;
    min-height: 100dvh;
    height: 100vh;
    height: 100dvh;
  }

  body.pattern-visual-hidden #visualCanvas,
  body.pattern-visual-hidden #rgbCube {
    opacity: 0;
  }

  body.note-annotations-hidden .noteStripWrap {
    display: none;
  }

  .noteStripWrap {
    position: relative;
    z-index: 1;
    height: 100%;
    display: flex;
    flex-direction: column;
  }

  .noteStripTitle {
    display: none;
  }

  .noteStrip {
    border: 0;
    background: var(--panel);
    overflow: hidden;
    flex: 1;
    height: 100%;
    display: flex;
    flex-direction: column;
  }

  .noteCell {
    min-height: 0;
    flex: 1;
    border-bottom: 0;
    display: grid;
    grid-template-columns: auto 1.1rem auto;
    justify-content: center;
    align-items: center;
    gap: 0.6rem;
    padding: 0.0rem 0.0rem;
    color: var(--note-cell-ink);
    font-size: 0.6rem;
    font-weight: 700;
    background: var(--panel);
  }

  .noteCell .note-name {
    appearance: none;
    border: 0.5px solid var(--text-muted);
    background: var(--panel);
    justify-self: center;
    padding: 0.25rem;
    color: var(--text-primary);
    font: inherit;
    line-height: 1;
    font-weight: lighter;
    cursor: pointer;
    text-shadow: 0 0 0.1rem var(--shadow-note-soft);
    min-width: 1.75rem;
    text-align: center;
  }

  .noteCell .scale-dot-btn {
    width: 0.9rem;
    height: 0.9rem;
    margin: 0 auto;
    border: 0;
    padding: 0;
    background: var(--panel);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font: inherit;
    font-size: 0.7rem;
    line-height: 1;
    color: var(--note-dot-off);
    text-shadow: 0 0 0.1rem var(--shadow-dot-soft);
  }

  .noteCell .scale-dot-btn.on {
    color: var(--text-primary);
    text-shadow: 0 0 0.1rem var(--shadow-dot-strong);
  }

  .noteCell .scale-dot-btn:focus-visible {
    outline: none;
  }

  .noteCell .tag {
    justify-self: center;
    font-size: 0.6rem;
    opacity: 0.86;
    color: var(--note-color, var(--note-fallback));
    text-shadow: 0 0 0.1rem var(--shadow-note-soft);
  }

  .stripFooter {
    display: none;
  }

  .visualWrap {
    border: 0;
    background: var(--bg);
    min-height: 0;
    display: flex;
    position: absolute;
    inset: 0;
    z-index: 0;
  }

  .visualDetachHint {
    position: absolute;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-size: 0.65rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    pointer-events: none;
    z-index: 2;
  }

  body.second-screen-on .visualDetachHint {
    display: flex;
  }

  #visualCanvas {
    flex: 1;
    width: 100%;
    height: 100%;
    min-height: 0;
    display: block;
  }

  #rgbCube {
    width: 100%;
    height: auto;
    aspect-ratio: 3 / 1;
    border: 0;
    background: var(--bg);
  }

  .chords {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 0.2rem;
  }

  .chordControls {
    margin-top: 0.35rem;
  }

  .chordbox {
    appearance: none;
    border: 0.5px solid var(--text-muted);
    background: var(--bg);
    min-height: 2.8rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.1rem;
    width: 100%;
    padding: 0.2rem 0;
    font-size: 0.6rem;
    font-family: inherit;
    color: var(--text-secondary);
    text-align: center;
    cursor: pointer;
    transition: border-color 120ms linear, color 120ms linear;
  }

  .chord-degree {
    color: var(--text-muted);
    font-size: 0.5rem;
    min-width: 0;
    line-height: 1;
  }

  .chord-label {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.1rem;
    width: 100%;
  }

  .chord-name {
    color: var(--text-primary);
    line-height: 1;
  }

  .chord-tones {
    color: var(--text-muted);
    font-size: 0.5rem;
    line-height: 1;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0;
  }

  .chord-tone-note {
    display: block;
    line-height: 1;
  }

  .chordbox:hover {
    border-color: var(--text-primary);
  }

  .chordbox:hover .chord-degree,
  .chordbox:hover .chord-name {
    color: var(--text-primary);
  }

  .chordbox.active {
    border: 0.5px solid var(--accent);
    background: var(--bg);
    box-shadow: none;
  }

  .chordbox.active .chord-degree,
  .chordbox.active .chord-name {
    color: var(--text-primary);
  }

  .patternList {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.2rem;
    margin-top: 0.4rem;
  }

  .patternRandomControls {
    padding-top: 0.5rem;
  }

  .sequenceTabs {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.2rem;
    margin-top: 0.2rem;
    margin-bottom: 0.35rem;
  }

  .sequenceTransport {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.65rem;
    margin-top: 0.2rem;
    margin-bottom: 0.35rem;
  }

  .sequenceTransportGroup {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
  }

  .sequenceTransport .btn {
    appearance: none;
    -webkit-appearance: none;
    background: transparent;
    color: var(--text-secondary);
    border: 0.1rem solid var(--text-muted);
    box-shadow: none;
    padding: 0;
    font-size: 0.78rem;
    width: 1.9rem;
    min-width: 1.9rem;
    height: 1.9rem;
    display: inline-grid;
    place-items: center;
  }

  .sequenceTransport .btn .icon {
    width: 0.72rem;
    height: 0.72rem;
    display: block;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.9;
    stroke-linecap: round;
    stroke-linejoin: round;
  }

  .sequenceTransport .btn:active,
  .sequenceTransport .btn:focus {
    background: transparent;
  }

  .sequenceTransport .btn.active {
    border-color: var(--accent);
    color: var(--text-primary);
    background: transparent;
  }

  .sequenceTransport .btn.danger {
    color: var(--text-secondary);
    border-color: var(--text-muted);
  }

  .homeActionBtn .icon-inline {
    width: 0.74rem;
    height: 0.74rem;
    display: inline-block;
    margin-left: 0.1rem;
    vertical-align: middle;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.9;
    stroke-linecap: round;
    stroke-linejoin: round;
  }

  .modalCloseBtn .icon {
    width: 0.74rem;
    height: 0.74rem;
    display: block;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
  }

  .sequenceSlot {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto auto auto;
    row-gap: 0.1rem;
    align-items: center;
  }

  .sequenceChannelStepper {
    grid-column: 1;
    grid-row: 2;
    width: 100%;
  }

  .sequenceChannelStepper input[type="number"] {
    font-size: 0.58rem;
  }

  .sequenceMuteBtn {
    grid-column: 1;
    grid-row: 3;
    align-self: center;
    appearance: none;
    border: 0.1rem solid var(--text-muted);
    background: var(--bg);
    color: var(--text-secondary);
    font: inherit;
    font-size: 0.52rem;
    line-height: 1;
    padding: 0.16rem 0.08rem;
    text-align: center;
    cursor: pointer;
  }

  .sequenceMuteBtn:hover {
    border-color: var(--text-primary);
    color: var(--text-primary);
  }

  .sequenceMuteBtn.active {
    border-color: var(--danger-border);
    color: var(--danger-text);
  }

  .sequenceTabBtn {
    grid-column: 1;
    grid-row: 1;
    justify-self: stretch;
    appearance: none;
    border: 0.1rem solid var(--text-muted);
    background: var(--bg);
    color: var(--text-secondary);
    font: inherit;
    font-size: 0.58rem;
    line-height: 1.1;
    padding: 0.28rem 0.1rem;
    text-align: center;
    cursor: pointer;
  }

  .sequenceTabBtn:hover {
    border-color: var(--text-primary);
    color: var(--text-primary);
  }

  .sequenceTabBtn.active {
    border-color: var(--accent);
    color: var(--text-primary);
  }

  .patternItem {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    gap: 0.4rem;
    width: 100%;
    border: 0.1rem solid var(--text-muted);
    background: var(--bg);
    color: var(--text-secondary);
    text-align: left;
    cursor: pointer;
    padding: 0.3rem 0.4rem;
    font-size: 0.6rem;
    line-height: 1.2;
  }

  .patternItem:hover {
    border-color: var(--text-primary);
  }

  .patternItem:disabled {
    opacity: 0.5;
    cursor: not-allowed;
  }

  .patternItem.active {
    border-color: var(--accent);
    color: var(--text-primary);
  }

  .patternName {
    display: block;
    color: var(--text-primary);
  }

  .patternMeta {
    display: block;
    color: var(--text-muted);
    font-size: 0.5rem;
  }

  .patternState {
    color: var(--text-muted);
    font-size: 0.58rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.2rem;
    min-width: 1.2rem;
    line-height: 1;
    white-space: nowrap;
    flex-shrink: 0;
  }

  .patternState .icon {
    width: 0.62rem;
    height: 0.62rem;
    display: block;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.9;
    stroke-linecap: round;
    stroke-linejoin: round;
  }

  .patternItem.active .patternState {
    color: var(--accent);
  }

  .midiEditorPanel {
    margin: 0.35rem 0;
    display: grid;
    gap: 0.24rem;
  }

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

  .midiEditorControls {
    display: flex;
    flex-wrap: wrap;
    gap: 0.2rem;
    align-items: center;
  }

  .midiEditorControls > label {
    display: grid;
    gap: 0.12rem;
    min-width: 0;
    flex: 0 0 auto;
  }

  .midiEditorControls > .kbdslider {
    flex: 1 1 10.5rem;
    min-width: 8.8rem;
  }

  .midiEditorControls > label > span {
    font-size: 0.55rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-muted);
  }

  .midiEditorOptionBar {
    margin-top: 0.02rem;
  }

  .midiEditorControls .midiEditorOptionBar {
    width: max-content;
  }

  .midiEditorActionWrap {
    margin-left: auto;
    display: grid;
    gap: 0.12rem;
    min-width: 0;
    flex: 0 0 auto;
    align-self: center;
    justify-items: end;
  }

  .midiEditorActionLabel {
    display: block;
    min-height: 0.62rem;
    font-size: 0.55rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: transparent;
    user-select: none;
  }

  .midiEditorActionGroup {
    display: inline-flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.2rem;
  }

  #midiEditorRateBar {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }

  #midiEditorModeBar {
    width: fit-content;
    grid-template-columns: repeat(2, max-content);
  }

  .midiEditorGrid {
    --midi-editor-cols: 32;
    --midi-playhead-progress: 0;
    --midi-playhead-x: 0px;
    --midi-label-col: 2.2rem;
    --midi-grid-gap: 0;
    --midi-line-base: color-mix(in srgb, var(--text-primary) 20%, transparent);
    --midi-line-half: color-mix(in srgb, var(--text-primary) 30%, transparent);
    --midi-line-bar: color-mix(in srgb, var(--text-primary) 38%, transparent);
    display: grid;
    grid-template-columns: var(--midi-label-col) repeat(var(--midi-editor-cols), minmax(0, 1fr));
    gap: var(--midi-grid-gap);
    max-height: 12.8rem;
    overflow: auto;
    padding-right: 0.1rem;
    position: relative;
  }

  .midiEditorGrid::after {
    content: "";
    position: absolute;
    top: 0;
    bottom: 0;
    width: 0.1rem;
    left: var(--midi-playhead-x);
    transform: translateX(-0.05rem);
    background: color-mix(in srgb, var(--text-primary) 92%, transparent);
    box-shadow: 0 0 0.28rem color-mix(in srgb, var(--accent) 35%, transparent);
    pointer-events: none;
    opacity: 0;
    transition: opacity 120ms ease;
    z-index: 3;
  }

  .midiEditorGrid.playhead-visible::after {
    opacity: 1;
  }

  .midiEditorRowLabel {
    display: inline-grid;
    place-items: center;
    min-height: 0.88rem;
    border: 0;
    border-right: 1px solid var(--midi-line-bar);
    border-bottom: 1px solid var(--midi-line-base);
    color: var(--text-secondary);
    font-size: 0.48rem;
    line-height: 1;
    letter-spacing: 0.04em;
    padding: 0 0.2rem;
  }

  .midiEditorCell {
    appearance: none;
    border: 0;
    border-right: 1px solid var(--midi-line-base);
    border-bottom: 1px solid var(--midi-line-base);
    background: transparent;
    min-height: 0.88rem;
    padding: 0;
    margin: 0;
    cursor: pointer;
  }

  .midiEditorCell.stepBar {
    border-left: 1px solid var(--midi-line-bar);
  }

  .midiEditorCell.halfBar {
    border-left: 1px solid var(--midi-line-half);
  }

  .midiEditorCell.active {
    background: color-mix(in srgb, var(--accent) 28%, transparent);
    border-right-color: color-mix(in srgb, var(--accent) 55%, transparent);
    border-bottom-color: color-mix(in srgb, var(--accent) 55%, transparent);
  }

  .midiEditorSlotBtn.armed:not(.active) {
    border-color: var(--accent-subtle);
    color: var(--text-primary);
  }

  .kbd {
    display: grid;
    gap: 0.5rem;
  }

  .kbdslider {
    display: grid;
    grid-template-columns: minmax(3.4rem, auto) 1fr auto;
    align-items: center;
    gap: 0.5rem;
  }

  .kbdslider span:last-child {
    min-width: 2.1rem;
    text-align: right;
    color: var(--accent);
  }

  .bpmStepper {
    display: grid;
    grid-template-columns: 1.3rem auto 1.3rem;
    gap: 0.18rem;
    align-items: center;
    justify-items: center;
  }

  .bpmStepper .stepperBtn {
    appearance: none;
    -webkit-appearance: none;
    width: 1.3rem;
    height: 1.3rem;
    min-width: 1.3rem;
    display: inline-grid;
    place-items: center;
    padding: 0;
    background: transparent;
    color: var(--text-secondary);
    border: 0.1rem solid var(--text-muted);
    cursor: pointer;
  }

  .bpmStepper .stepperBtn:hover {
    border-color: var(--text-primary);
    color: var(--text-primary);
  }

  .bpmStepper .stepperBtn:disabled {
    opacity: 0.4;
    cursor: default;
    border-color: var(--text-muted);
    color: var(--text-muted);
  }

  .bpmStepper .stepperBtn .icon {
    width: 0.58rem;
    height: 0.58rem;
    display: block;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
  }

  .bpmStepper #patternBpmValue {
    min-width: 2.1rem;
    text-align: center;
    color: var(--accent);
  }

  .small {
    color: var(--text-secondary);
    font-size: 0.6rem;
  }

  .log {
    border: 0;
    background: var(--bg);
    height: 10rem;
    overflow: auto;
    padding: 0.4rem;
    font-size: 0.6rem;
  }

  .logline {
    margin-bottom: 0.1rem;
    color: var(--text-secondary);
    white-space: pre-wrap;
  }

  .panelPopover {
    position: fixed;
    z-index: 700;
    max-width: min(22rem, calc(100vw - 1.5rem));
    border: 0.1rem solid var(--accent);
    background: rgba(0, 0, 0, 0.93);
    color: var(--text-primary);
    font-size: 0.62rem;
    line-height: 1.35;
    padding: 0.4rem 0.5rem;
    pointer-events: none;
    opacity: 0;
    transform: translateY(0.15rem);
    transition: opacity 120ms linear, transform 120ms linear;
  }

  .panelPopover.visible {
    opacity: 1;
    transform: translateY(0);
  }

  .guideKeymaps {
    margin-top: 0.6rem;
    border-top: 0.1rem solid var(--text-muted);
    padding-top: 0.5rem;
  }

  .guideKeymapsTitle {
    margin: 0 0 0.3rem;
    font-size: 0.62rem;
    color: var(--text-primary);
    font-weight: 500;
  }

  .guideKeymapsLine {
    margin: 0.12rem 0;
    font-size: 0.54rem;
    color: var(--text-secondary);
  }

  .guideKeyboardSim {
    margin-top: 0.35rem;
    display: grid;
    gap: 0.16rem;
  }

  .guideKeyboardRow {
    display: flex;
    flex-wrap: wrap;
    gap: 0.14rem;
  }

  .guideKeycap {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.32rem;
    height: 1.16rem;
    padding: 0 0.24rem;
    border: 0.1rem solid var(--text-muted);
    color: var(--text-primary);
    font-size: 0.56rem;
    line-height: 1;
    background: rgba(255, 255, 255, 0.03);
  }

  .guideKeycap.wide {
    min-width: 2.6rem;
  }

  .guideKeycap.wider {
    min-width: 3.9rem;
  }

  @media (max-width: 75em) {
    .scaleMiniBar {
      grid-template-columns: repeat(6, minmax(0, 1fr));
    }

    .homePanel {
      width: min(36rem, 100%);
    }

    .layout {
      grid-template-columns: 17.5rem 1fr;
    }

    .right {
      grid-column: 1 / -1;
      grid-template-columns: repeat(3, minmax(0, 1fr));
    }
  }

  @media (max-width: 56.25em) {
    .scaleMiniBar {
      grid-template-columns: repeat(4, minmax(0, 1fr));
    }

    .midiRoutingGrid {
      grid-template-columns: 1fr;
    }

    .homePanel {
      margin-top: 0;
      padding: 0.75rem 0.65rem 0.8rem;
    }

    .homeOverlay {
      padding: 0.55rem;
    }

    .layout {
      grid-template-columns: 1fr;
    }

    .center {
      min-height: calc(100vh - 1.5rem);
    }

    .right {
      grid-template-columns: 1fr;
    }

    .midiInspectorControls {
      grid-template-columns: 1fr;
      align-items: stretch;
    }

    .midiInspectorRow {
      grid-template-columns: 3.8rem 1.9rem 4.8rem 1fr;
      font-size: 0.54rem;
    }

    .midiInspectorRow > :last-child {
      display: none;
    }
  }

  .d-flex {
    display: flex;
  }

  .justify-content-between {
    justify-content: space-between;
  }

  .align-items-center {
    align-items: center;
  }

  .border-top {
    border-top: 0.1rem solid var(--text-muted);
  }

  .py-2 {
    padding-top: 0.5rem;
    padding-bottom: 0.5rem;
  }

  .italic {
    font-style: italic;
  }

  .fs-xs {
    font-size: x-small;
  }
