/* ===================== CHART HEADER ===================== */

* {
  color: #aaa;
}

@font-face {
  font-family: 'Neucha';
  src: url('../fonts/neucha.otf') format('opentype');
}

/* Disable Mode button */
#btn-mode.disabled,
#btn-instrument-settings.disabled,
#btn-poly-form.disabled,
#btn-poly-bysection.disabled {
    pointer-events: none;
    opacity: 0.4;
}

.chart-header {
  display: flex;
  align-items: flex-end;           
  justify-content: space-between;
  padding: 0.6rem 0.6rem;
  background-color: #fff;
  font-family: 'Neucha', sans-serif;
  width: 100%;
  max-width: 100vw;
  box-sizing: border-box;
  gap: 1rem;
}

.chart-header__toggle {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
}

.chart-header__toggle img {
  height: 28px;
  width: 28px;
}

.chart-header__title {
  flex: 1;
  text-align: center;
  font-size: 1.7rem;
  font-weight: bold;
  color: #111;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 0 1rem;
  font-family: 'Neucha', sans-serif;
}

.chart-header__composer {
  font-size: 1rem;
  color: #555;
  white-space: nowrap;
  font-family: 'Neucha', sans-serif;
}


/* ===================== CONTROL PANEL =================                 ==== */

.control-panel__section {width: 100%;box-sizing: border-box;padding: 0.4rem;background-color: #090909;display: flex;flex-direction: column;gap: 0.3rem;max-width: 100vw;}

.control-panel__row {display: flex;justify-content: space-between;gap: 0.3rem;}

.control-panel__btn {
flex: 1;
padding: 0.5rem;
font-size: 0.9rem;
background-color: #222;
border: none;
color: #fff;
border-radius: 6px;
display: flex;
align-items: center;
justify-content: center;
gap: 0.2rem;
cursor: pointer;
border: 1px solid transparent;
/* transition: background 0.2s ease; */
}

.control-panel__btn--selected {
background-color: #444;
border: 1px solid #888;
}

.control-panel__btn:hover {
background-color: #444;
}

.control-panel__btn--play {
padding: 0.3rem 0.6rem;
max-width: 280px;
border: 1px solid #545353;
}

.control-panel__icon {
width: 20px;
height: 20px;
object-fit: contain;
}

.control-panel__labels-row {
display: flex;
justify-content: space-between;
margin-bottom: 0;
line-height: 1;
}

.control-panel__label {flex: 1;font-size: 0.6rem;text-align: center;color: #aaa;text-transform: uppercase;letter-spacing: 0.05em;}

.control-panel__section--top {padding: 0.3rem;}

/*.control-panel__section--bottom {position: fixed;bottom: 0;}*/


/* ===================== RADIO SECTION ===================== */

.control-panel__section--radio {
padding: 0.6rem;
gap: 0.2rem;
}

.control-panel__row--radio {
display: flex;
justify-content: space-between;
gap: 0.4rem;
}

.control-panel__column {
display: flex;
flex-direction: column;
align-items: center;
gap: 0.1rem;
}

.control-panel__column--expand {
flex: 1;
}

.control-panel__column--fixed {
flex: 0 0 auto;
width: 100px;
}

.fixed-width {
width: 100px;
}

/* ===================== MODAL BASE ===================== */

.control-modal {
position: fixed;
inset: 0;
background-color: rgba(0, 0, 0, 0.45);
display: flex;
justify-content: center;
align-items: center;
z-index: 1000;
backdrop-filter: blur(10px);
}

.control-modal.hidden {
display: none;
}

.control-modal__content {
background-color: #1f1f1f;
color: #fff;
width: 90%;
max-width: 520px;
border-radius: 8px;
padding: 1.6rem;
box-shadow: 0 20px 40px rgba(0, 0, 0, 0.25);
display: flex;
flex-direction: column;
gap: 1.5rem;
transition: all 0.3s ease;
text-align: center;
}

.control-modal__title {
font-size: 1.2rem;
font-weight: 600;
text-align: center;
color: #f0f0f0;
margin: 0;
}

/* ===== TOP CONTROL PANEL (SINGLE ROW) ===== */

.control-panel__section--top {
  display: flex;
  flex-direction: column;
  width: 100%;
  background-color: #090909;
  box-sizing: border-box;
}

/* === Button Row Layout === */
.control-panel__row--top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.4rem;
}

/* === Common Button Style (text or icon) === */
.control-panel__btn,
.control-panel__btn--top,
.control-panel__btn--icon,
.control-panel__btn-dual,
.control-panel__btn-inner {
  padding: 0.5rem;
  font-size: 0.9rem;
  background-color: #222;
  border: 1px solid transparent;
  color: #fff;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.2rem;
  cursor: pointer;
  transition: background 0.2s ease;
  height: 2rem;
}

/* === Text buttons expand equally === */
.control-panel__btn--top {
  flex: 1;
}

/* === Small icon buttons === */
.control-panel__btn--icon {
  flex: 0.6;
}

/* === Dual poly button wrapper === */
.control-panel__btn-dual {
  flex: 0.6;
  padding: 0;
}

/* === Two buttons inside dual poly wrapper === */
.control-panel__btn-dual-inner {
  display: flex;
  width: 100%;
  height: 100%;
}

.control-panel__btn-inner {
  flex: 1;
  padding: 0;
}

/* === Icons inside buttons === */
.control-panel__btn img,
.control-panel__btn-inner img {
  width: 16px;
  height: 20px;
  opacity: 0.8;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.control-panel__btn:hover,
.control-panel__btn--top:hover,
.control-panel__btn--icon:hover,
.control-panel__btn-inner:hover {
  background-color: #444;
}

.control-panel__btn-inner:hover img {
  opacity: 1;
  transform: scale(1.1);
}

/* === Selected State (unified for all buttons) === */
.control-panel__btn--selected,
.control-panel__btn-inner--selected {
  background-color: #444;
  border: 1px solid #888;
}

.control-panel__btn-inner--selected img {
  opacity: 1;
  filter: brightness(1.2);
}

/* === Labels below buttons === */
.control-panel__labels-row--top {
  display: flex;
  justify-content: space-between;
  margin-top: 0rem;
  font-size: 0.6rem;
  color: #aaa;
  text-align: center;
  margin-bottom: 0;
  line-height: 1;
}

.control-panel__label--top {
  flex: 1;
  text-align: center;
}

.control-panel__label--icon {
  flex: 0.6;
  text-align: center;
}

/* ===================== Floating Style Selector ===================== */
.style-selector {
  position: fixed;
  top: 20%;
  left: 20%;
  background: #1e1e1e;
  color: #aaa;
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  z-index: 1000;
  transition: opacity 0.3s ease;
  width: 580px;
  height: 60vh; /* fixed height for the modal */
  display: flex;
  flex-direction: column;
  z-index: 9999;
  overflow: hidden; /* prevent overflow outside the modal */
}

.style-selector.hidden {
  display: none;
}

/* ===== Floating Panel Header (for dragging) ===== */
.style-selector__header {
  font-weight: bold;
  font-size: 1rem;
  padding: 0.6rem;
  background: #333;
  border-top-left-radius: 10px;
  border-top-right-radius: 10px;
  text-align: center;
  user-select: none;
  cursor: move;
  flex-shrink: 0;
}

/* ===== Scrollable container ===== */
.style-selector__container {
  overflow-y: auto;
  padding: 1rem;
  flex-grow: 1;
}

/* ===== Category Headers ===== */
.style-selector__category {
  font-size: 0.7rem;
  font-weight: 500;
  color: #aaa;
  text-transform: uppercase;
  padding: 0.3rem 0.5rem;
  margin-top: 1rem;
  letter-spacing: 0.05em;
}

/* ===== Grid for Buttons ===== */
.style-selector__grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.6rem;
  padding-bottom: 1rem;
}

/* ===== Style Buttons ===== */
.style-selector__btn {
  padding: 0.5rem;
  border: none;
  border-radius: 6px;
  background: #444;
  color: #fff;
  font-size: 0.9rem;
  text-align: center;
  cursor: pointer;
  transition: background-color 0.15s ease;
}

.style-selector__btn:hover {
  background: #555;
}

.style-selector__btn--selected {
  background: #eb870f;
  font-weight: bold;
}

/* ===================== Floating Harmony Panel ===================== */

.harmony-selector {
position: fixed;
top: 25%;
left: 25%;
width: 300px;
background: #1e1e1e;
color: #aaa;
border-radius: 8px;
box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
padding: 1rem;
z-index: 9999;
transition: opacity 0.3s ease;
}

.harmony-selector.hidden {
display: none;
}

.harmony-selector__header {
font-weight: bold;
font-size: 1rem;
margin-bottom: 1rem;
cursor: move;
background: #333;
padding: 0.5rem;
border-radius: 8px;
text-align: center;
user-select: none;
}

.harmony-selector__grid {
display: flex;
flex-direction: column;
gap: 0.6rem;
}

.harmony-selector__btn {
width: 100%;
background: #444;
color: #aaa;
border: none;
padding: 0.4rem;
border-radius: 6px;
font-size: 0.9rem;
cursor: pointer;
transition: background 0.2s ease;
}

.harmony-selector__btn:hover {
background: #666;
}

/* ============ Floating Key Selector ============ */
.key-selector {
position: fixed;
top: 25%;
left: 25%;
max-width: 90vw;
background: #1e1e1e;
color: #aaa;
border-radius: 8px;
box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
padding: 1rem;
z-index: 9999;
transition: opacity 0.3s ease;
}
.key-selector.hidden {
display: none;
}
.key-selector__header {
font-weight: bold;
font-size: 1rem;
margin-bottom: 1rem;
cursor: move;
background: #333;
padding: 0.5rem;
border-radius: 8px;
text-align: center;
user-select: none;
}
.key-selector__grid {
display: grid;
grid-template-columns: repeat(6, 1fr);
gap: 0.6rem;
justify-items: center;
}
.key-selector__btn {
width: 100%;
min-width: 72px;
max-width: 100px;
padding: 0.6rem 0;
font-size: 1rem;
font-weight: 500;
border-radius: 8px;
background: #2c2c2e;
border: none;
color: #fff;
text-align: center;
cursor: pointer;
transition: background-color 0.15s ease, transform 0.1s ease;
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.15);
}
.key-selector__btn:hover {
background-color: #3a3a3c;
}
.key-selector__btn:active {
transform: scale(0.97);
background-color: #48484a;
}

.key-selector__instrument-dropdown {
  background: transparent;
  border: 1px solid rgb(88 88 88);
  border-radius: 4px;
  padding: 4px 12px;
  color: #dddcdc;
  font-size: 12px;
  font-weight: 500;
  outline: none;
  cursor: pointer;
  appearance: none;
  margin-top: 11px;
  margin-right: 20px;
}

/* ===================== Floating tempo panel ===================== */

.tempo-selector {
position: fixed;
top: 25%;
left: 25%;
width: 300px;
background: #1e1e1e;
color: #aaa;
border-radius: 8px;
box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
padding: 1rem;
z-index: 9999;
transition: opacity 0.3s ease;
}

.tempo-selector.hidden {
display: none;
}

.tempo-selector__header {
font-weight: bold;
font-size: 1rem;
margin-bottom: 1rem;
cursor: move;
background: #333;
padding: 0.5rem;
border-radius: 8px;
text-align: center;
user-select: none;
}

.tempo-selector__slider {
width: 100%;
appearance: none;
height: 24px;
background: #444;
border-radius: 8px;
outline: none;
margin: 0;
}

/* Centered label below */
.tempo-selector__value {
font-size: 1.2rem;
font-weight: 600;
color: #fff;
margin-top: 0.8rem;
text-align: center;
}

/* === WebKit Browsers (Chrome, Safari) === */
.tempo-selector__slider::-webkit-slider-thumb {
-webkit-appearance: none;
appearance: none;
width: 16px;
height: 16px;
background: #eb870f;
border-radius: 50%;
border: none;
cursor: pointer;
box-shadow: 0 0 2px rgba(0, 0, 0, 0.5);
}

/* === Firefox === */
.tempo-selector__slider::-moz-range-thumb {
width: 16px;
height: 16px;
background: #eb870f;
border-radius: 50%;
border: none;
cursor: pointer;
box-shadow: 0 0 2px rgba(0, 0, 0, 0.5);
}

/* ===================== Floating Time Signature Panel ===================== */

.timesig-selector {
position: fixed;
top: 20%;
left: 50%;
transform: translateX(-50%);
width: auto;
max-width: 90vw;
background: #1e1e1e;
color: #aaa;
border-radius: 8px;
box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
padding: 1rem;
z-index: 9999;
transition: opacity 0.3s ease;
}

.timesig-selector.hidden {
display: none;
}

.timesig-selector__header {
font-weight: bold;
font-size: 1rem;
margin-bottom: 1rem;
cursor: move;
background: #333;
padding: 0.5rem;
border-radius: 8px;
text-align: center;
user-select: none;
}

/* Grid with 2 rows × 7 columns */
.timesig-selector__grid {
display: grid;
grid-template-columns: repeat(7, 1fr);
gap: 0.8rem 0.6rem;
justify-items: center;
}

/* Responsive button size, fixed width */
.timesig-selector__btn {
width: 80px;
padding: 0.6rem 0;
font-size: 1rem;
font-weight: 500;
border-radius: 8px;
background: #2c2c2e;
border: none;
color: #fff;
text-align: center;
cursor: pointer;
transition: background-color 0.15s ease, transform 0.1s ease;
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.15);
}

.timesig-selector__btn:hover {
background-color: #3a3a3c;
}

.timesig-selector__btn:active {
transform: scale(0.97);
background-color: #48484a;
}

/* ===================== Floating Mixer Panel ===================== */

.mixer-selector {
position: fixed;
top: 25%;
left: 25%;
width: auto;
background: #1e1e1e;
color: #aaa;
border-radius: 12px;
box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
padding: 1rem;
z-index: 9999;
transition: opacity 0.3s ease;
}

.mixer-selector.hidden {
display: none;
}

.mixer-selector__header {
font-weight: bold;
font-size: 1rem;
margin-bottom: 1rem;
cursor: move;
background: #333;
padding: 0.5rem;
border-radius: 8px;
text-align: center;
user-select: none;
}

.mixer-selector__grid {
display: flex;
justify-content: center;
gap: 2.5rem;
padding: 0.5rem 0;
}

.mixer-selector__column {
display: flex;
flex-direction: column;
align-items: center;
gap: 0.5rem;
}

.mixer-selector__slider {
writing-mode: vertical-lr;
direction: rtl;
height: 200px;
width: 24px;
background: #444;
border-radius: 6px;
appearance: none;
}

.mixer-selector__label {
font-size: 0.85rem;
font-weight: 500;
color: #ccc;
text-align: center;
}

/* === WebKit Browsers (Chrome, Safari) === */
.mixer-selector__slider::-webkit-slider-thumb {
-webkit-appearance: none;
appearance: none;
width: 16px;
height: 16px;
background: #eb870f;
border-radius: 50%;
border: none;
cursor: pointer;
box-shadow: 0 0 2px rgba(0, 0, 0, 0.5);
}

/* === Firefox === */
.mixer-selector__slider::-moz-range-thumb {
width: 16px;
height: 16px;
background: #eb870f;
border-radius: 50%;
border: none;
cursor: pointer;
box-shadow: 0 0 2px rgba(0, 0, 0, 0.5);
}

/* .mixer-selector__slider::-webkit-slider-runnable-track {
background: #444;
border-radius: 6px;
}

.mixer-selector__slider::-moz-range-track {
background: #444;
border-radius: 6px;
} */

/* ===================== Floating Offset Panel (Styled Like Tempo) ===================== */

.offset-selector {
position: fixed;
top: 25%;
left: 25%;
width: 300px;
background: #1e1e1e;
color: #aaa;
border-radius: 8px;
box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
padding: 1rem;
z-index: 9999;
transition: opacity 0.3s ease;
}

.offset-selector.hidden {
display: none;
}

.offset-selector__header {
font-weight: bold;
font-size: 1rem;
margin-bottom: 1.5rem;
cursor: move;
background: #333;
padding: 0.5rem;
border-radius: 8px;
text-align: center;
user-select: none;
}

.offset-selector__row {
display: flex;
flex-direction: column;
gap: 0.6rem;
margin-bottom: 1rem;
}

.offset-selector__label {
font-size: 0.9rem;
font-weight: 500;
color: #ccc;
text-align: center;
}

.offset-selector__slider {
width: 100%;
appearance: none;
height: 24px;
background: #444;
border-radius: 8px;
outline: none;
margin: 0;
}

/* === WebKit Browsers (Chrome, Safari) === */
.offset-selector__slider::-webkit-slider-thumb {
-webkit-appearance: none;
appearance: none;
width: 16px;
height: 16px;
background: #eb870f;
border-radius: 50%;
border: none;
cursor: pointer;
box-shadow: 0 0 2px rgba(0, 0, 0, 0.5);
}

/* === Firefox === */
.offset-selector__slider::-moz-range-thumb {
width: 16px;
height: 16px;
background: #eb870f;
border-radius: 50%;
border: none;
cursor: pointer;
box-shadow: 0 0 2px rgba(0, 0, 0, 0.5);
}

/* ===================== Floating Repeats slider ===================== */

/* Floating draggable panel */
.repeats-selector {
position: fixed;
top: 20%;
left: 20%;
width: 300px;
background: #1e1e1e;
color: #aaa;
border-radius: 8px;
box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
padding: 1rem;
z-index: 9999;
transition: opacity 0.3s ease;
}

.repeats-selector.hidden {
display: none;
}

.repeats-selector__header {
font-weight: bold;
font-size: 1rem;
margin-bottom: 1rem;
cursor: move;
background: #333;
padding: 0.5rem;
border-radius: 8px;
text-align: center;
user-select: none;
}

/* Slider */
.repeats-selector__slider {
width: 100%;
appearance: none;
height: 24px;
background: #444;
border-radius: 8px;
outline: none;
margin: 0;
}

/* Label */
.repeats-selector__value {
font-size: 1.2rem;
font-weight: 600;
color: #fff;
margin-top: 0.8rem;
text-align: center;
}

/* === WebKit Browsers (Chrome, Safari) === */
.repeats-selector__slider::-webkit-slider-thumb {
-webkit-appearance: none;
appearance: none;
width: 16px;
height: 16px;
background: #eb870f;
border-radius: 50%;
border: none;
cursor: pointer;
box-shadow: 0 0 2px rgba(0, 0, 0, 0.5);
}

/* === Firefox === */
.repeats-selector__slider::-moz-range-thumb {
width: 16px;
height: 16px;
background: #eb870f;
border-radius: 50%;
border: none;
cursor: pointer;
box-shadow: 0 0 2px rgba(0, 0, 0, 0.5);
}

/* ===================== Instrument Settings Modal ===================== */

.instrument-settings {
position: fixed;
top: 15%;
left: 25%;
width: 440px;
max-height: 70%;
background: #1e1e1e;
color: #aaa;
border-radius: 12px;
box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
z-index: 1000;
transition: opacity 0.3s ease;
display: flex;
flex-direction: column;
overflow: hidden;
}

.instrument-settings.hidden {
display: none;
}

.instrument-settings__header-modal {
font-weight: bold;
font-size: 1rem;
margin-bottom: 1rem;
cursor: move;
background: #333;
padding: 0.5rem;
text-align: center;
user-select: none;
}

.instrument-settings__scrollable {
overflow-y: auto;
padding: 1rem;
flex-grow: 1;
}

.instrument-settings__section {border-bottom: 1px solid transparent;padding-bottom: 2rem;}

.instrument-settings__dropdown-header {
    width: 100%;
    font-size: 0.9rem;
    padding: 0.4rem;
    margin-bottom: 1rem;
    background: transparent;
    color: #dadada;
    border: 1px solid #ec8711;
    border-radius: 4px;
    text-transform: capitalize; /* ✅ First letter uppercase */
    font-weight: bold;
}
.instrument-settings__control-group {
margin-bottom: 1.6rem;
}

.instrument-settings__range-label-row {
  display: flex;

  margin-bottom: 0.4rem;
  gap: 0.5rem;
}

.instrument-settings__range-semitones {
  font-size: 0.95rem;
  color: #cccccc;
}

.instrument-settings__setting-label {
margin-bottom: 0.3rem;
font-size: 0.9rem;
font-weight: 500;
color: #aaa;
}

.instrument-settings__slider-wrap {
display: flex;
align-items: center;
gap: 12px;
}

.instrument-settings__slider-value {
font-size: 0.9rem;
font-weight: 600;
min-width: 32px;
text-align: right;
}

.instrument-settings__slider {
width: 100%;
appearance: none;
height: 24px;
background: #444;
border-radius: 8px;
outline: none;
margin: 0;
}

/* === WebKit Browsers (Chrome, Safari) === */
.instrument-settings__slider::-webkit-slider-thumb {
-webkit-appearance: none;
appearance: none;
width: 16px;
height: 16px;
background: #eb870f;
border-radius: 50%;
border: none;
cursor: pointer;
box-shadow: 0 0 2px rgba(0, 0, 0, 0.5);
}

/* === Firefox === */
.instrument-settings__slider::-moz-range-thumb {
width: 16px;
height: 16px;
background: #eb870f;
border-radius: 50%;
border: none;
cursor: pointer;
box-shadow: 0 0 2px rgba(0, 0, 0, 0.5);
}

.instrument-settings__dropdown-poly {
    width: calc(100% - 44px);
    font-size: 0.9rem;
    padding: 0.3rem;
    background: #2a2a2a;
    color: #aaa;
    border: 1px solid #444;
    border-radius: 6px;
}

.instrument-settings__extra-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.8rem;
  margin-bottom: 1.6rem;
}

.instrument-settings__extra-group .instrument-settings__control-group {
  flex: 1 1 auto;
  min-width: 150px;
  max-width: 100%;
}

.instrument-settings__dropdown-extra {
    width: 10rem;
    font-size: 0.9rem;
    padding: 0.3rem;
    background: #2a2a2a;
    color: #aaa;
    border: 1px solid #444;
    border-radius: 6px;
}

.instrument-settings__range-rows {
display: flex;
align-items: center;
gap: 8px;
flex-wrap: wrap;
margin-top: 0.3rem;
}

.instrument-settings__range-rows select {padding: 0.3rem;font-size: 0.9rem;background: #2a2a2a;color: #aaa;border: 1px solid #444;border-radius: 6px;width: 10rem;}

.instrument-settings__range-rows div {
font-size: 0.85rem;
color: #aaa;
}

.instrument-settings__range-semitones {
    margin-bottom: 0.3rem;
    font-size: 0.9rem;
    font-weight: 500;
    color: #aaa;
}

.instrument-settings__reset {margin-right: 0.2rem;padding: 0.5rem 1rem;color: #aaaaaa;background: none;border: none;font-weight: 400;cursor: pointer;text-align: right;display: block;}

.instrument-settings__reset:hover {
color: #aaa;
}

/* ===================== Mode Selector Modal ===================== */
.mode-selector {
  position: fixed;
  top: 15%;
  left: 20%;
  background: #1e1e1e;
  color: #fff;
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  z-index: 1000;
  width: 560px;
  height: 65vh;
  display: flex;
  flex-direction: column;
  z-index: 9999;
  overflow: hidden;
}

.mode-selector__header {
  font-weight: bold;
  font-size: 1.1rem;
  text-align: center;
  background: #333;
  padding: 0.5rem;
  border-top-left-radius: 12px;
  border-top-right-radius: 12px;
  position: sticky;
  top: 0;
  z-index: 10;
}

.mode-selector__scrollable {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  scroll-behavior: smooth;
  border-top: 1px solid #333;
  border-bottom: 1px solid #333;
}

.mode-selector.hidden {
  display: none;
}

.mode-selector__top-controls {
  padding: 1rem;
  background: #1e1e1e;
}

/* ===================== Switch Row ===================== */
.mode-selector__switch-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.2rem;
}

.mode-selector__switch-label {
  font-size: 0.9rem;
  color: #ccc;
}

/* Switch Styling */
.mode-selector__switch {
  position: relative;
  display: inline-block;
  width: 42px;
  height: 22px;
}

.mode-selector__switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.mode-selector__slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #666;
  border-radius: 34px;
  transition: 0.3s;
}

.mode-selector__slider:before {
  position: absolute;
  content: "";
  height: 16px;
  width: 16px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  border-radius: 50%;
  transition: 0.3s;
}

.mode-selector__switch input:checked + .mode-selector__slider {
  background-color: #eb870f;
}

.mode-selector__switch input:checked + .mode-selector__slider:before {
  transform: translateX(20px);
}

/* ===================== Style Row ===================== */
.mode-selector__style-row {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.mode-selector__style-label {
  font-size: 0.85rem;
  font-weight: 500;
  color: #aaa;
  cursor: pointer;
}

.mode-selector__style-dropdown {
  font-size: 0.85rem;
  padding: 0.3rem 0.5rem;
  border-radius: 6px;
  border: none;
  background: #2a2a2a;
  color: #fff;
  outline: none;
}

.mode-selector__style-dropdown.hidden {
  display: none;
}

/* ===================== Mode Groups ===================== */
.mode-selector__group {
  margin-bottom: 1.5rem;
}

.mode-selector__group-title {
  font-size: 0.8rem;
  font-weight: bold;
  text-transform: uppercase;
  color: #bbb;
  margin-bottom: 0.5rem;
  padding-left: 0.25rem;
}

/* Mode Buttons Grid */
.mode-selector__buttons-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.6rem;
}

.mode-selector__option {
  padding: 0.5rem;
  border: none;
  border-radius: 6px;
  background: #444;
  color: #fff;
  font-size: 0.85rem;
  cursor: pointer;
  text-align: center;
  transition: background-color 0.2s ease;
}

.mode-selector__option:hover {
  background: #666;
}

/* ===================== Footer ===================== */
.mode-selector__footer {
  padding: 1rem;
  background: #1e1e1e;
  border-top: 1px solid #333;
  text-align: center;
}

.mode-selector__custom-button {
  padding: 0.5rem 1rem;
  border-radius: 6px;
  background: #eb870f;
  color: #000;
  border: none;
  font-weight: bold;
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.mode-selector__custom-button:hover {
  background: #ff9e33;
}

/* ===================== Floating Custom Mode View ===================== */

.mode-custom-form,
.mode-custom-by-section {
  display: none;
}

.hidden {
  display: none;
}

.mode-custom__header {
  background-color: #333;
  color: #eee;
  font-weight: bold;
  padding: 0.5rem 1rem;
  font-size: 1.1rem;
}


.mode-custom-form,
.mode-custom-by-section {
  position: fixed;
  top: 20%;
  left: 20%;
  width: 600px;
  height: 60vh;
  background: #1e1e1e;
  color: #aaa;
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  z-index: 1000;
  /* padding: 1rem; */
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

/* ===== Scrollable Content ===== */
.mode-custom__content {
  overflow-y: auto;
  padding: 1rem;
  flex-grow: 1;
}

/* Visibility Toggles (BEM modifiers) */
.mode-custom__content-form--hidden {
  display: none;
} */

/* ===================== Custom Form View ===================== */

.mode-custom__form-section {
  margin-bottom: 0.2rem;
}

/* ===== Polyrhythm Section Header ===== */
.mode-custom__poly-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

.mode-custom__poly-title {
  font-size: 1.5rem;
  font-weight: bold;
  color: #ccc;
}

.mode-custom__poly-link-toggle {
  width: 16px;
  height: 16px;
  accent-color: #eb870f;
  cursor: pointer;
}

/* ===== Instrument Row ===== */
.mode-custom__poly-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.6rem;
}

.mode-custom__poly-label {
  flex: 1;
  font-size: 0.9rem;
  color: #ccc;
  text-transform: capitalize;
}

.mode-custom__poly-select {
  flex: 1;
  background: #2b2b2b;
  color: #fff;
  border: 1px solid #444;
  border-radius: 6px;
  padding: 0.4rem 0.5rem;
  font-size: 0.9rem;
}

/* ===== Style Selector ===== */
.mode-custom__style-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 1.2rem;
}

.mode-custom__style-label {
  font-size: 0.9rem;
  color: #ccc;
  margin-right: 1rem;
}

.mode-custom__style-select {
  flex: 1;
  background: #2b2b2b;
  color: #fff;
  border: 1px solid #444;
  border-radius: 6px;
  padding: 0.4rem 0.5rem;
  font-size: 0.9rem;
}

/* ===================== By Section View ===================== */

.mode-custom__header {
  position: relative;
  text-align: center;
  font-weight: bold;
  font-size: 15px;
  padding: 12px 36px 12px 12px;
}

/* 3-dot menu button on the right */
.mode-custom__menu-button {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  padding: 4px;
}

.mode-custom__by-section-container {
  overflow-y: auto;
  padding: 0rem 1rem 1rem 1rem;
  flex-grow: 1;
}

.mode-custom__by-section-container--hidden {
  display: none;
}

.mode-custom__by-section-content {
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
}

/* ===== Head Toggle ===== */
.mode-custom__head-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 1.5rem;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 10;
  background: #1e1e1e;
  padding: 0.6rem 0rem 0.2rem 0rem;
}

.mode-custom__head-label {
  flex: 1; /* takes left half */
  display: flex;
  /* justify-content: center; */ /* center within the left half */
  font-size: 1.5rem;
  color: #ccc;
  font-weight: bold;
}

.mode-custom__head-row--form {
  justify-content: flex-end;
  position: static;
  background: none;
  padding: 0;
}

.mode-custom__poly-link-label {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.4rem;
  font-size: 0.85rem;
  color: #ccc;
  cursor: pointer;
  flex: 1;
}

.mode-custom__head-checkbox {
  width: 16px;
  height: 16px;
  accent-color: #eb870f;
  cursor: pointer;
}

.mode-custom__by-section-controls {
  display: flex;
  justify-content: space-between;
  margin-top: 2rem;
}

.bySection-style-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 2.2rem;
}

.bySection-style-label {
  font-weight: 500;
  min-width: 60px;
  color: #ccc;
}

.bySection-style-dropdown {
  flex: 1;
  padding: 6px 10px;
  border-radius: 6px;
  background: #222;
  color: #fff;
  border: 1px solid #444;
}

/* ===================== Reuse Existing Styles ===================== */
.btn-sm {
  background: #444;
  color: #eee;
  border: none;
  border-radius: 4px;
  padding: 0.3rem 0.8rem;
  cursor: pointer;
  transition: background 0.2s;
  font-size: 0.85rem;
}

.btn-sm:disabled {
  opacity: 0.4;
  cursor: default;
}

.mode-custom__chorus-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 1.5rem;
  gap: 1rem;
}

.mode-custom__add-chorus,
.mode-custom__remove-chorus {
  background: #2b2b2b;
  color: white;
  cursor: pointer;
  transition: background 0.2s ease;
}

.mode-custom__add-chorus:hover,
.mode-custom__remove-chorus:hover {
  background: #555;
}

.mode-custom__tab {
  flex: 1;
  border: none;
  box-shadow: none;
  outline: none;
  margin: 0;
  padding: 8px 12px;
  background: transparent;
  color: #aaa;
  font-size: 0.9rem;
  font-weight: 500;
  border-radius: 0;
  cursor: pointer;
  text-align: center;
  transition: background-color 0.2s;
}

.mode-custom__tab:hover {
  background: #b66c15;
  color: #fbfbfb;
}

.mode-custom__tab--selected {
  background: #eb870f;
  color: #fbfbfb;
  font-weight: bold;
}

.bySection-instrument-polys {
    margin-bottom: 0.5rem;
}

/* ===================== Floating Custom Mode View ===================== */

.mode-custom-form,
.mode-custom-by-section {
  display: none;
  position: fixed;
  top: 20%;
  left: 20%;
  width: 600px;
  height: 60vh;
  background: #1e1e1e;
  color: #aaa;
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.hidden {
  display: none;
}

.mode-custom__header {
  font-weight: bold;
  font-size: 1rem;
  padding: 0.6rem;
  background: #333;
  border-top-left-radius: 10px;
  border-top-right-radius: 10px;
  text-align: center;
  user-select: none;
  cursor: move;
  flex-shrink: 0;
}

/* ===== Polyrhythm Section Header ===== */
.mode-custom__poly-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

.mode-custom__poly-title {
  font-size: 1.5rem;
  font-weight: bold;
  color: #ccc;
}

/* ===== Instrument Row ===== */
.mode-custom__poly-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.6rem;
}

.mode-custom__poly-label {
  flex: 1;
  font-size: 0.9rem;
  color: #ccc;
  text-transform: capitalize;
}

.mode-custom__poly-select {
  flex: 1;
  background: #2b2b2b;
  color: #fff;
  border: 1px solid #444;
  border-radius: 6px;
  padding: 0.4rem 0.5rem;
  font-size: 0.9rem;
}

/* ===== Style Selector ===== */
.mode-custom__style-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 1.2rem;
}

.mode-custom__style-label {
  font-size: 0.9rem;
  color: #ccc;
  margin-right: 1rem;
}

.mode-custom__style-select {
  flex: 1;
  background: #2b2b2b;
  color: #fff;
  border: 1px solid #444;
  border-radius: 6px;
  padding: 0.4rem 0.5rem;
  font-size: 0.9rem;
}

/* ===================== By Section View ===================== */
.mode-custom__by-section-content {
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
  padding: 1rem;
}

.mode-custom__menu {
  position: relative;
  display: inline-block;
  float: right;
  margin-top: -2px;
}

.mode-custom__menu-btn {
  background: none;
  border: none;
  font-size: 22px;
  cursor: pointer;
  color: #fff;
  padding: 0 10px;
}

.mode-custom__menu-dropdown {
  position: absolute;
  right: 0;
  top: 100%;
  margin-top: 7px;
  background: #333333;
  border: 1px solid #333;
  border-radius: 6px;
  z-index: 1001;
  min-width: 220px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.mode-custom__menu-item {
  padding:8px 14px;
  cursor: pointer;
  font-size: 12px;
  color: #ffffff;
}

.mode-custom__menu-item:hover {
  background-color: #1e1e1e;
}

.mode-custom__head-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 1.5rem;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 10;
  background: #1e1e1e;
  padding: 0.6rem 0rem 0.2rem 0rem;
}

.mode-custom__head-row--form {
  justify-content: flex-end;
  position: static;
  background: none;
  padding: 0;
}

.mode-custom__poly-link-label {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.4rem;
  font-size: 0.85rem;
  color: #ccc;
  cursor: pointer;
  flex: 1;
}

.mode-custom__head-checkbox {
  width: 16px;
  height: 16px;
  accent-color: #eb870f;
  cursor: pointer;
}

.bySection-style-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 2.2rem;
}

.bySection-style-label {
  font-weight: 500;
  min-width: 60px;
  color: #ccc;
}

.bySection-style-dropdown {
  flex: 1;
  padding: 6px 10px;
  border-radius: 6px;
  background: #222;
  color: #fff;
  border: 1px solid #444;
}

.btn-sm {
  background: #444;
  color: #eee;
  border: none;
  border-radius: 4px;
  padding: 0.3rem 0.8rem;
  cursor: pointer;
  transition: background 0.2s;
  font-size: 0.85rem;
}

.btn-sm:disabled {
  opacity: 0.4;
  cursor: default;
}

.mode-custom__chorus-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 1.5rem;
  gap: 1rem;
}

.mode-custom__add-chorus,
.mode-custom__remove-chorus {
  background: #2b2b2b;
  color: white;
  cursor: pointer;
  transition: background 0.2s ease;
}

.mode-custom__add-chorus:hover,
.mode-custom__remove-chorus:hover {
  background: #555;
}

.bySection-instrument-polys {
  margin-bottom: 0.5rem;
}


/* ===================== SAVE IMPORT template ===================== */

.mode-custom__header {
  display: flex;
  align-items: center;
  position: relative;
}

.mode-custom__menu-heading {
  font-weight: bold;
  font-size: 14px;
  padding: 8px 12px 7px;
  color: #444;
  border-bottom: 1px solid #8b8b8b;
  /* background: #f9f9f9; */
  text-align: left;
  color: #ffffff;
}

.mode-custom__menu-button {
  background: none;
  border: none;
  color: white;
  font-size: 22px;
  cursor: pointer;
  padding: 4px 8px;
  line-height: 1;
  margin-left: auto;
}

.mode-custom__menu {
  position: absolute;
  top: 100%;
  right: 10px;
  background-color: #333333;
  border-radius: 6px;
  min-width: 220px;
  box-shadow: 0 4px 8px rgba(0,0,0,0.3);
  z-index: 1000;
  text-align: left; /* ✅ align items to the left */
}

.mode-custom__menu-item {
  padding: 8px 14px;
  margin-left: 2px;
  color: white;
  cursor: pointer;
  font-size: 12px;
  white-space: nowrap;
  transition: background 0.2s;
  text-align: left;
  font-weight: normal;
}

.mode-custom__menu-item:hover {
  background: #1e1e1e;
}

.hidden {
  display: none !important;
}

/* === Menu Field Containers === */
.mode-custom__menu-save-field,
.mode-custom__menu-import-field {
  display: flex;
  background: white;
  padding: 6px;
  margin: 4px 12px;
  border-radius: 2px;
}

/* Save input and button */
.mode-custom__menu-save-field input {
  width: 70%;
  padding: 6px 8px;
  margin-right: 8px;
  font-size: 12px;
  border: 1px solid #ccc;
  border-radius: 4px;
}

.mode-custom__menu-btn {
  background: #eb870f;
  color: white;
  font-size: 13px;
  border: none;
  padding: 6px 10px;
  border-radius: 4px;
  cursor: pointer;
}

/* Import template list */
.template-list-box {
  max-height: 150px;
  overflow-y: auto;
  border-radius: 4px;
  font-size: 13px;
  color: black;
}

.template-list-box {
  width: 100%;
  max-height: 150px;
  overflow-y: auto;
  border-radius: 4px;
  font-size: 13px;
  background: white;
}

/* Template rows used in import list */
.template-row {
  display: flex;
  font-weight: normal;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 4px;

  font-size: 13px;
  color: black;
}

.template-row.empty {
  justify-content: flex-start;
  color: gray;
  border-bottom: none;
}

.template-list-box div {
  /* border-bottom: 1px solid #eee; */
  cursor: pointer;
}

.template-list-box div:hover {
  background: #f4f4f4;
}

.mode-custom__menu-saved-list {
  background: white;
  border-top: 1px solid #ccc;
  margin: 6px 12px;
  border-radius: 2px;
}

.saved-template-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  font-weight: normal; /* not bold */
}

/* Template name (span or input) */
.saved-template-row span:first-child,
.saved-template-row input {
  flex: 1;
  font-weight: normal;
  padding: 4px 6px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  border: none;
  background: none;
}

/* Icon container */
.saved-template-row .saved-template-icon {
  flex: 0 0 auto;
  margin-right: 6px;
  font-size: 0.9em;
  cursor: pointer;
}