/* ============================================================
   ChankArts Piano — Controls
   Toolbars, steppers, sliders, pills, transport, MIDI panel,
   settings modal, toasts.
   ============================================================ */

/* --- Toolbars --- */
.toolbar {
  flex: 0 0 auto;
  display: flex;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 12px 16px;
  padding: 11px 13px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.ctl {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.ctl__label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.63rem;
  font-weight: 700;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--muted);
}

.ctl__num {
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 0.72rem;
}

.ctl--select { min-width: 178px; }
.ctl--slider { flex: 1 1 150px; max-width: 220px; min-width: 130px; }
.ctl--toggles { flex-direction: row; align-items: center; gap: 7px; flex-wrap: wrap; }

/* --- Steppers --- */
.stepper {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line-strong);
  border-radius: 9px;
}

.stepper__btn {
  width: 34px;
  height: 31px;
  border: none;
  border-radius: 7px;
  background: transparent;
  color: var(--text);
  font-size: 1.15rem;
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.stepper__btn:hover { background: var(--accent-soft); color: var(--accent); }
.stepper__btn:active { transform: translateY(1px); }

.stepper__value {
  min-width: 46px;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 0.95rem;
  font-weight: 700;
  color: #fff;
}
.stepper__value--btn {
  border: none;
  background: transparent;
  cursor: pointer;
  height: 31px;
  border-radius: 7px;
}
.stepper__value--btn:hover { background: var(--accent-soft); color: var(--accent); }

/* --- Sliders --- */
.slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 5px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.11);
  outline-offset: 5px;
  cursor: pointer;
}

.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid #0b0b14;
  box-shadow: 0 0 0 1px var(--accent), 0 2px 6px rgba(0, 0, 0, 0.55);
  cursor: grab;
}
.slider::-webkit-slider-thumb:active { cursor: grabbing; }

.slider::-moz-range-thumb {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid #0b0b14;
  box-shadow: 0 0 0 1px var(--accent);
  cursor: grab;
}
.slider::-moz-range-track {
  height: 5px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.11);
}

.slider--bend { background: linear-gradient(90deg, rgba(255, 255, 255, 0.05) 49.6%, rgba(255, 255, 255, 0.28) 50%, rgba(255, 255, 255, 0.05) 50.4%); }
.slider--mod { background: linear-gradient(90deg, rgba(255, 255, 255, 0.07), var(--accent-soft)); }

/* --- Selects --- */
.select {
  position: relative;
  display: block;
  width: 100%;
}

.select__input {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  padding: 8px 30px 8px 11px;
  border-radius: 8px;
  border: 1px solid var(--line-strong);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  font-family: inherit;
  font-size: 0.86rem;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}
.select__input:hover { border-color: rgba(255, 255, 255, 0.24); }
.select__input:focus-visible { border-color: var(--accent); }
.select__input:disabled { opacity: 0.5; cursor: not-allowed; }
.select__input option { background: #13131f; color: var(--text); }

.select__chev {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
}

.select--sm .select__input { padding: 6px 26px 6px 9px; font-size: 0.76rem; }
.statusbar__edu .select--sm { width: auto; }
.statusbar__edu .select__input { white-space: nowrap; }

/* --- Sustain toggle --- */
.toggle {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-height: 36px;
  padding: 8px 15px;
  border-radius: 9px;
  border: 1px solid var(--line-strong);
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s, color 0.2s, box-shadow 0.2s;
}

.toggle__dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.45;
}

.toggle:hover { border-color: rgba(255, 255, 255, 0.26); color: var(--text); }

.toggle.is-on,
.toggle[aria-pressed="true"] {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: #fff;
  box-shadow: 0 0 18px var(--accent-soft);
}
.toggle.is-on .toggle__dot,
.toggle[aria-pressed="true"] .toggle__dot {
  background: var(--accent);
  opacity: 1;
  box-shadow: 0 0 9px var(--accent);
}

/* --- Pills --- */
.pill {
  min-height: 33px;
  padding: 7px 13px;
  border-radius: 99px;
  border: 1px solid var(--line-strong);
  background: rgba(255, 255, 255, 0.03);
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}
.pill:hover { color: var(--text); border-color: rgba(255, 255, 255, 0.25); }
.pill[aria-pressed="true"] {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}

/* --- Generic buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 9px 18px;
  border-radius: 8px;
  border: 1px solid transparent;
  font-size: 0.86rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  cursor: pointer;
  transition: all 0.2s var(--ease);
}
.btn--primary { background: var(--grad); color: #fff; }
.btn--primary:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 8px 22px var(--accent-soft); }
.btn--primary:disabled { opacity: 0.45; cursor: not-allowed; }
.btn--ghost {
  background: transparent;
  border-color: var(--line-strong);
  color: var(--muted);
}
.btn--ghost:hover { color: var(--text); border-color: rgba(255, 255, 255, 0.3); }

.iconbtn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.2s;
}
.iconbtn:hover { color: var(--text); background: rgba(255, 255, 255, 0.06); }

/* --- Transport --- */
.transport {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 11px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  flex-wrap: wrap;
}

.tbtn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 36px;
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid var(--line-strong);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  font-size: 0.73rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  cursor: pointer;
  transition: all 0.2s;
}
.tbtn:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.tbtn:disabled { opacity: 0.38; cursor: not-allowed; }

.tbtn__dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--danger);
  box-shadow: 0 0 6px rgba(255, 84, 112, 0.6);
}

.tbtn--rec.is-active {
  background: rgba(255, 84, 112, 0.16);
  border-color: var(--danger);
  color: #fff;
}
.tbtn--rec.is-active .tbtn__dot { animation: recPulse 1.1s ease-in-out infinite; }

.tbtn--ghost { color: var(--muted); border-style: dashed; }

.tbtn__pip {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--muted);
  opacity: 0.45;
}
.tbtn__pip.is-on { background: var(--ok); opacity: 1; box-shadow: 0 0 8px var(--ok); }
.tbtn__pip.is-flash { animation: pipFlash 0.16s ease-out; }

@keyframes pipFlash {
  from { transform: scale(1.7); background: #fff; }
  to { transform: scale(1); }
}

.transport__sep {
  width: 1px;
  height: 24px;
  background: var(--line-strong);
  margin: 0 3px;
}

.transport__meta {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 0.73rem;
  color: var(--muted);
  white-space: nowrap;
}

/* --- MIDI panel --- */
.panel {
  position: fixed;
  top: calc(var(--topbar-h) + 12px);
  right: 14px;
  z-index: 90;
  width: min(350px, calc(100vw - 28px));
  max-height: calc(100vh - var(--topbar-h) - 34px);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 13px;
  padding: 17px;
  background: var(--panel-2);
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  box-shadow: 0 26px 70px rgba(0, 0, 0, 0.65);
  animation: panelIn 0.24s var(--ease);
}

@keyframes panelIn {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: none; }
}

.panel__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.panel__title {
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--brand);
}

.panel__status {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 0.85rem;
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 10px 12px;
}

.statusdot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--muted);
  flex: 0 0 auto;
}
.statusdot.is-on { background: var(--ok); box-shadow: 0 0 9px var(--ok); }
.statusdot.is-err { background: var(--danger); box-shadow: 0 0 9px var(--danger); }

.panel__note {
  font-size: 0.76rem;
  line-height: 1.6;
  color: var(--muted);
}

.field { display: flex; flex-direction: column; gap: 6px; }
.field__label {
  font-size: 0.64rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

/* --- Settings modal --- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 160;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(4, 4, 10, 0.74);
  backdrop-filter: blur(7px);
  -webkit-backdrop-filter: blur(7px);
  animation: fadeIn 0.2s var(--ease);
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal__card {
  width: min(660px, 100%);
  max-height: min(86vh, 800px);
  display: flex;
  flex-direction: column;
  background: var(--panel-2);
  border: 1px solid var(--line-strong);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 34px 90px rgba(0, 0, 0, 0.7);
  animation: panelIn 0.26s var(--ease);
}

.modal__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}

.modal__title {
  font-size: 0.86rem;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--brand);
}

.modal__body {
  padding: 6px 18px 14px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.modal__foot {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 18px;
  border-top: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.2);
}

.setgroup {
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}
.setgroup:last-child { border-bottom: none; }

.setgroup__title {
  font-size: 0.66rem;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 12px;
}

.setgroup__help {
  margin-top: 10px;
  font-size: 0.76rem;
  line-height: 1.7;
  color: var(--muted);
}
.setgroup__help .mono { color: var(--text); }

.setrow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 7px 0;
}
.setrow > label {
  font-size: 0.87rem;
  color: var(--text);
}
.setrow .slider { max-width: 190px; }

/* Checkbox switch */
.switch {
  -webkit-appearance: none;
  appearance: none;
  position: relative;
  flex: 0 0 auto;
  width: 42px;
  height: 23px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.13);
  cursor: pointer;
  transition: background 0.2s;
}
.switch::after {
  content: "";
  position: absolute;
  top: 2.5px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.2s var(--ease);
}
.switch:checked { background: var(--accent); }
.switch:checked::after { transform: translateX(18px); }

/* --- Toast --- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%);
  z-index: 300;
  max-width: min(92vw, 460px);
  padding: 11px 19px;
  border-radius: 99px;
  background: #16161f;
  border: 1px solid var(--line-strong);
  color: var(--text);
  font-size: 0.84rem;
  font-weight: 600;
  text-align: center;
  box-shadow: 0 16px 44px rgba(0, 0, 0, 0.6);
  animation: toastIn 0.26s var(--ease);
}

.toast[data-kind="error"] { border-color: rgba(255, 84, 112, 0.55); }
.toast[data-kind="warn"] { border-color: rgba(255, 180, 84, 0.55); }

@keyframes toastIn {
  from { opacity: 0; transform: translate(-50%, 12px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

/* --- Compact mode --- */
body.is-compact .toolbar--perf,
body.is-compact .statusbar__edu {
  display: none;
}
body.is-compact .stage { gap: 7px; padding-top: 8px; padding-bottom: 10px; }
