:root {
  color-scheme: dark;
  font-family: Arial, Helvetica, sans-serif;
  --bg: #cfd6df;
  --panel: rgba(242, 245, 249, 0.92);
  --panel-strong: rgba(248, 250, 253, 0.97);
  --panel-soft: rgba(255, 255, 255, 0.86);
  --panel-raised: rgba(255, 255, 255, 0.94);
  --toolbar: rgba(112, 124, 138, 0.86);
  --border: rgba(95, 109, 126, 0.26);
  --border-strong: rgba(95, 109, 126, 0.42);
  --section-rule: rgba(112, 127, 145, 0.18);
  --text: #31465d;
  --muted: #637489;
  --muted-strong: #5b6d82;
  --accent: #4fa3ff;
  --control-bg: rgba(255, 255, 255, 0.94);
  --control-bg-hover: rgba(255, 255, 255, 0.99);
  --control-border: rgba(255, 255, 255, 0.82);
  --control-border-soft: rgba(116, 131, 148, 0.24);
  --control-shadow: 0 1px 0 rgba(255, 255, 255, 0.72) inset, 0 2px 10px rgba(36, 52, 68, 0.08);
  --control-shadow-hover: 0 1px 0 rgba(255, 255, 255, 0.8) inset, 0 4px 14px rgba(36, 52, 68, 0.12);
  --shadow: 0 12px 32px rgba(34, 49, 63, 0.17);
  --shadow-soft: 0 8px 20px rgba(34, 49, 63, 0.10);
  --touch-target: 44px;
  --score-stage-empty-bg: linear-gradient(180deg, rgba(255,255,255,0.58) 0%, rgba(245,248,252,0.82) 100%);
}


* {
  box-sizing: border-box;
}

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

body {
  height: 100vh;
  height: 100dvh;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
}

button,
input,
select {
  font: inherit;
}

button,
select,
input[type='text'],
input[type='number'] {
  border: 1px solid var(--control-border);
  border-color: var(--control-border-soft);
  border-radius: 14px;
  background: var(--control-bg);
  color: var(--text);
  box-shadow: var(--control-shadow);
  transition: background-color 0.14s ease, border-color 0.14s ease, box-shadow 0.14s ease, transform 0.14s ease;
}

button {
  min-height: var(--touch-target);
  padding: 8px 14px;
  font-weight: 700;
  cursor: pointer;
  touch-action: manipulation;
}

button:hover:not(:disabled) {
  background: var(--control-bg-hover);
  border-color: rgba(255, 255, 255, 0.92);
  box-shadow: var(--control-shadow-hover);
  transform: translateY(-1px);
}

button:disabled {
  opacity: 0.55;
  cursor: default;
}

button:active:not(:disabled) {
  transform: translateY(0);
  box-shadow: inset 0 1px 2px rgba(34, 48, 62, 0.12);
}

button:focus-visible,
select:focus-visible,
input[type='text']:focus-visible,
input[type='number']:focus-visible,
input[type='checkbox']:focus-visible {
  outline: none;
  border-color: rgba(79, 163, 255, 0.82);
  box-shadow: 0 0 0 3px rgba(79, 163, 255, 0.18), var(--control-shadow);
}

select,
input[type='text'],
input[type='number'] {
  min-height: var(--touch-target);
  padding: 9px 14px;
}

select {
  appearance: none;
  -webkit-appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, rgba(63, 81, 101, 0.85) 50%), linear-gradient(135deg, rgba(63, 81, 101, 0.85) 50%, transparent 50%);
  background-position: calc(100% - 18px) calc(50% - 3px), calc(100% - 12px) calc(50% - 3px);
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
  padding-right: 34px;
}

select:hover,
input[type='text']:hover,
input[type='number']:hover {
  background-color: rgba(255, 255, 255, 0.98);
  border-color: rgba(125, 139, 156, 0.34);
  box-shadow: var(--control-shadow-hover);
}

.hidden,
.is-hidden {
  display: none !important;
}


input[type='checkbox'] {
  -webkit-appearance: none;
  appearance: none;
  inline-size: 24px;
  block-size: 24px;
  margin: 0;
  border: 1.5px solid rgba(125, 139, 156, 0.42);
  border-radius: 7px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.98) 0%, rgba(248, 250, 252, 0.96) 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9), 0 1px 3px rgba(28, 42, 56, 0.08);
  display: inline-grid;
  place-content: center;
  flex: 0 0 24px;
  cursor: pointer;
  touch-action: manipulation;
  transition: background-color 0.14s ease, border-color 0.14s ease, box-shadow 0.14s ease, transform 0.14s ease;
}

input[type='checkbox']:hover {
  border-color: rgba(79, 163, 255, 0.56);
  background: linear-gradient(180deg, rgba(255, 255, 255, 1) 0%, rgba(250, 252, 255, 0.98) 100%);
}

input[type='checkbox']::before {
  content: '';
  width: 13px;
  height: 9px;
  border-left: 3px solid transparent;
  border-bottom: 3px solid transparent;
  transform: rotate(-45deg) scale(0.75);
  transform-origin: center;
  margin-top: -1px;
  opacity: 0;
  transition: opacity 0.12s ease, border-color 0.12s ease, transform 0.12s ease;
}

input[type='checkbox']:checked {
  background: linear-gradient(180deg, #4fa3ff 0%, #2f90ff 100%);
  border-color: #2f90ff;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.34), 0 2px 6px rgba(47, 144, 255, 0.22);
}

input[type='checkbox']:checked::before {
  opacity: 1;
  border-left-color: #ffffff;
  border-bottom-color: #ffffff;
  transform: rotate(-45deg) scale(1);
}

input[type='checkbox']:disabled {
  cursor: default;
  opacity: 0.78;
}

input[type='checkbox']:disabled:not(:checked) {
  background: rgba(255, 255, 255, 0.86);
  border-color: rgba(125, 139, 156, 0.42);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.76);
}

input[type='checkbox']:disabled:checked {
  background: linear-gradient(180deg, rgba(79, 163, 255, 0.96) 0%, rgba(47, 144, 255, 0.96) 100%);
  border-color: rgba(47, 144, 255, 0.92);
}

.popup-surface {
  opacity: 0;
  pointer-events: none;
  transform: translateY(-8px);
  transition: opacity 0.16s ease, transform 0.16s ease;
}

.popup-surface.is-open {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

/* Keep centered toolbar popups centered when open/closing. */
.toolbar-popup.popup-surface {
  transform: translateX(-50%) translateY(-8px);
}

.toolbar-popup.popup-surface.is-open {
  transform: translateX(-50%) translateY(0);
}

.toolbar-popup.popup-surface.is-closing {
  transform: translateX(-50%) translateY(-8px);
}

.app-toolbar {
  position: relative;
  z-index: 120;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 4px 14px;
  background: rgba(114, 126, 140, 0.88);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.22);
  box-shadow: 0 3px 12px rgba(44, 58, 74, 0.14);
}

.toolbar-side,
.toolbar-group,
.toolbar-center {
  display: flex;
  align-items: center;
  gap: 8px;
}

.toolbar-center {
  min-width: 0;
}

.toolbar-score-group {
  gap: 6px;
  min-width: 0;
  color: rgba(255,255,255,0.92);
  font-weight: 700;
}

.toolbar-score-label {
  font-size: 0.96rem;
}

.toolbar-score-value {
  min-width: 1.5ch;
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: rgba(255,255,255,0.96);
}


.toolbar-side {
  flex: 0 0 auto;
}

.toolbar-center {
  flex: 1 1 auto;
  justify-content: center;
}

.toolbar-separator {
  width: 1px;
  height: 18px;
  background: linear-gradient(to bottom, rgba(255, 255, 255, 0.10), rgba(255, 255, 255, 0.34), rgba(255, 255, 255, 0.10));
}

.app-toolbar button {
  min-height: 38px;
  padding: 6px 14px;
  white-space: nowrap;
  border-radius: 14px;
}

.app-toolbar button.is-open {
  border-color: rgba(79, 163, 255, 0.75);
  box-shadow: 0 0 0 3px rgba(79, 163, 255, 0.18), inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

.toolbar-backdrop {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(69, 82, 96, 0.14);
}

.toolbar-popup {
  position: fixed;
  top: 64px;
  left: 50%;
  z-index: 130;
  width: min(980px, calc(100vw - 32px));
  max-height: min(calc(100vh - 96px), calc(100dvh - 96px));
  overflow: auto;
  transform: translateX(-50%) translateY(-8px);
  border: 1px solid rgba(255,255,255,0.54);
  border-radius: 24px;
  background: linear-gradient(180deg, rgba(255,255,255,0.18) 0%, rgba(255,255,255,0.05) 100%), var(--panel-strong);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

#scores-panel,
#practice-popup,
#options-overlay {
  width: min(1120px, calc(100vw - 32px));
}

#more-popup {
  width: min(520px, calc(100vw - 32px));
}

#options-overlay,
#scores-panel {
  border: 1px solid rgba(255,255,255,0.56);
  border-radius: 24px;
  background: linear-gradient(180deg, rgba(255,255,255,0.16) 0%, rgba(255,255,255,0.04) 100%), var(--panel-strong);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

#tempo-popup,
#looper-popup,
#audio-popup,
#transpose-popup,
#help-popup {
  width: min(620px, calc(100vw - 32px));
}

#display-popup {
  width: min(900px, calc(100vw - 32px));
}


.panel {
  border: 1px solid rgba(255, 255, 255, 0.68);
  border-radius: 24px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.20) 0%, rgba(255, 255, 255, 0.06) 100%),
    var(--panel);
  box-shadow: var(--shadow);
}

.panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 22px 0;
}

.compact-header h2 {
  margin: 0;
  font-size: 1.8rem;
  line-height: 1.2;
  color: var(--text);
}

.panel-kicker {
  margin-bottom: 8px;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted-strong);
}

.popup-panel-grid {
  display: grid;
  gap: 16px;
  padding: 18px 22px 22px;
}

.popup-panel-grid--two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.popup-card {
  display: grid;
  gap: 14px;
  padding: 16px 18px;
  border: 1px solid rgba(112, 127, 145, 0.22);
  border-radius: 18px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.34) 0%, rgba(255, 255, 255, 0.12) 100%),
    var(--panel-soft);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.52), var(--shadow-soft);
}

.popup-card-title,
.midi-panel-title {
  font-size: 1.08rem;
  font-weight: 800;
  color: var(--text);
}

.placeholder-card {
  min-height: 120px;
  align-content: start;
}

.placeholder,
.viewer-hint,
.help-text,
.track-meta {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.viewer-hint--left {
  text-align: left;
}

.file-picker {
  display: inline-grid;
  gap: 10px;
  justify-items: start;
}

.file-picker input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

.button-like {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 10px 16px;
  border: 1px solid var(--control-border);
  border-radius: 14px;
  background: var(--control-bg);
  color: var(--text);
  font-weight: 700;
  box-shadow: var(--control-shadow);
  cursor: pointer;
  transition: background-color 0.14s ease, border-color 0.14s ease, box-shadow 0.14s ease, transform 0.14s ease;
}

.button-like:hover {
  background: var(--control-bg-hover);
  border-color: rgba(255, 255, 255, 0.92);
  box-shadow: 0 1px 10px rgba(36, 52, 68, 0.10), inset 0 1px 0 rgba(255, 255, 255, 0.72);
  transform: translateY(-1px);
}

.form-grid {
  display: grid;
  gap: 14px;
  align-items: end;
}

.form-grid--practice {
  grid-template-columns: minmax(0, 1fr) minmax(240px, 260px);
}

.field-group {
  display: grid;
  gap: 8px;
  min-width: 0;
  align-content: start;
}

.field-group > select,
.field-group > input[type='text'],
.field-group > input[type='number'] {
  width: 100%;
}

.field-group--compact {
  width: 100%;
  max-width: 260px;
  justify-self: end;
}

.field-group--compact select {
  min-width: 0;
}

.field-label,
.status-label {
  display: block;
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--muted-strong);
}


.field-group {
  align-content: start;
}

.field-group .field-help {
  display: block;
  margin-top: 4px;
}

.field-help {
  font-size: 0.84rem;
  line-height: 1.4;
  color: var(--muted);
}

.toggle-grid,
.status-stack,
.info-stack {
  display: grid;
  gap: 12px;
}

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

.toggle-row {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 52px;
  padding: 10px 14px;
  border: 1px solid rgba(125, 139, 156, 0.24);
  border-radius: 14px;
  background: var(--control-bg);
  color: var(--text);
  box-shadow: var(--control-shadow);
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition: background-color 0.14s ease, border-color 0.14s ease, box-shadow 0.14s ease, transform 0.14s ease;
}

.toggle-row:hover {
  background: var(--control-bg-hover);
  border-color: rgba(125, 139, 156, 0.34);
  box-shadow: var(--control-shadow-hover);
  transform: translateY(-1px);
}

.toggle-row:active {
  transform: translateY(0);
  box-shadow: inset 0 1px 2px rgba(34, 48, 62, 0.12);
}


.toggle-row:focus-within {
  border-color: rgba(79, 163, 255, 0.64);
  box-shadow: 0 0 0 3px rgba(79, 163, 255, 0.14), var(--control-shadow);
}

.toggle-row > span {
  flex: 1 1 auto;
}

.toggle-row-text {
  display: grid;
  gap: 3px;
}

.toggle-row-title {
  font-weight: 700;
  color: var(--text);
}

.toggle-row-help {
  font-size: 0.84rem;
  line-height: 1.35;
  color: var(--muted);
}

.toggle-row input {
  cursor: inherit;
}

.status-value,
.viewer-title {
  margin-top: 4px;
  font-size: 1rem;
  color: var(--text);
}

.status-grid {
  display: grid;
  gap: 14px;
}

.status-grid > div,
.info-stack > div {
  display: grid;
  gap: 6px;
}

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

.midi-panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.status-pill {
  align-self: start;
  min-height: 36px;
  padding: 7px 13px;
  border: 1px solid rgba(112, 127, 145, 0.24);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.82);
  color: var(--muted-strong);
  font-size: 0.86rem;
  font-weight: 700;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.7);
}

.midi-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(240px, 260px);
  gap: 14px;
  align-items: end;
}

.midi-mode-section,
.midi-debug-details,
.midi-debug-card,
.midi-last-event-block {
  display: grid;
  gap: 12px;
}

.midi-mode-section > .field-group {
  max-width: 260px;
}

.debug-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 0;
}

.debug-grid div {
  padding: 10px 12px;
  border: 1px solid rgba(112, 127, 145, 0.22);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.62);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.42);
}

.debug-grid dt {
  margin: 0 0 4px;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.debug-grid dd {
  margin: 0;
  color: var(--text);
}

.midi-event-list,
.track-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 10px;
}

.midi-event-item,
.midi-placeholder,
.track-item,
.track-placeholder {
  padding: 12px 14px;
  border: 1px solid rgba(112, 127, 145, 0.22);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.66);
  color: var(--text);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.42);
}

.track-item.is-practice {
  border-color: rgba(79, 163, 255, 0.62);
  box-shadow: inset 0 0 0 1px rgba(79, 163, 255, 0.48);
}

.track-name {
  font-weight: 700;
}


.panel-section + .panel-section,
.popup-card + .popup-card {
  margin-top: 2px;
}

.section-heading,
.card-heading,
.popup-subheading {
  margin: 0;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--muted-strong);
}

.section-divider {
  height: 1px;
  border: 0;
  margin: 2px 0 0;
  background: linear-gradient(to right, transparent, var(--section-rule), transparent);
}

fieldset {
  margin: 0;
  padding: 0;
  border: 0;
  min-width: 0;
}

legend {
  padding: 0;
}

.app-main {
  flex: 1 1 auto;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
  display: grid;
  grid-template-rows: minmax(0, 1fr);
  gap: 10px;
  padding: 10px;
}

body.fretboard-visible .app-main {
  grid-template-rows: minmax(0, 1fr) auto;
}

.score-stage.viewer-panel {
  position: relative;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
  padding: 0;
  display: flex;
  flex-direction: column;
  background: rgba(244, 247, 250, 0.58);
  isolation: isolate;
}

.score-stage.viewer-panel:fullscreen {
  background: var(--bg);
  padding: 10px;
}

.score-stage.viewer-panel:fullscreen .alphatab-wrapper {
  min-height: 0;
}

.alphatab-wrapper {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  max-height: 100%;
  min-width: 0;
  overflow: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable both-edges;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-x pan-y;
  background: var(--score-stage-empty-bg);
  border-radius: 24px;
  border: 1px solid rgba(255,255,255,0.58);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.55);
}


#alphatab-container {
  position: relative;
  display: block;
  width: 100%;
  min-width: 0;
  min-height: 100%;
  z-index: 1;
  overflow: visible;
}

#alphatab-container .at-surface,
#alphatab-container .at-surface-svg {
  display: block;
  width: 100% !important;
  max-width: 100%;
}

.score-empty-state {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 10px;
  padding: 40px 24px;
  text-align: center;
  color: var(--muted);
  z-index: 0;
  pointer-events: none;
}

.score-empty-icon {
  width: 64px;
  height: 64px;
  margin: 0 auto;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(255,255,255,0.64);
  border: 1px solid rgba(255,255,255,0.72);
  box-shadow: var(--shadow-soft);
  font-size: 1.8rem;
  color: rgba(79, 163, 255, 0.9);
}

.score-empty-title {
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--text);
}

.score-empty-copy {
  max-width: 420px;
  line-height: 1.5;
}

body.has-score .score-empty-state {
  display: none;
}

body.has-score .alphatab-wrapper {
  background: #ffffff;
}

.score-overlay-controls {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 4;
}

.score-fullscreen-toggle {
  width: 44px;
  min-width: 44px;
  height: 44px;
  min-height: 44px;
  padding: 0;
  border-radius: 16px;
  display: inline-grid;
  place-items: center;
  background: rgba(255,255,255,0.96);
  border-color: rgba(116, 131, 148, 0.18);
  box-shadow: 0 10px 24px rgba(34, 49, 63, 0.12), inset 0 1px 0 rgba(255,255,255,0.9);
}

.score-fullscreen-toggle:hover:not(:disabled) {
  background: rgba(255,255,255,1);
}

.score-fullscreen-toggle.is-active {
  border-color: rgba(79, 163, 255, 0.5);
}

.fullscreen-corners {
  position: relative;
  width: 16px;
  height: 16px;
  color: var(--text);
}

.fullscreen-corners::before,
.fullscreen-corners::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(currentColor 0 0) left top / 6px 1.8px no-repeat,
    linear-gradient(currentColor 0 0) left top / 1.8px 6px no-repeat,
    linear-gradient(currentColor 0 0) right top / 6px 1.8px no-repeat,
    linear-gradient(currentColor 0 0) right top / 1.8px 6px no-repeat,
    linear-gradient(currentColor 0 0) left bottom / 6px 1.8px no-repeat,
    linear-gradient(currentColor 0 0) left bottom / 1.8px 6px no-repeat,
    linear-gradient(currentColor 0 0) right bottom / 6px 1.8px no-repeat,
    linear-gradient(currentColor 0 0) right bottom / 1.8px 6px no-repeat;
  opacity: 0.88;
}

.fretboard-panel {
  min-height: 0;
  padding: 8px 10px;
}

#fretboard-container {
  overflow: hidden;
}

#fretboard-container.hidden {
  display: none !important;
}


.more-popup-grid {
  display: grid;
  gap: 14px;
  padding: 0 22px 22px;
}

.panel-header--more {
  padding-bottom: 14px;
}

.more-shortcut-button {
  width: 100%;
}

.app-toolbar.is-compact {
  gap: 10px;
  padding: 7px 12px;
}

.app-toolbar.is-compact .toolbar-center {
  gap: 10px;
}

.app-toolbar.is-compact .toolbar-group {
  gap: 8px;
}

.app-toolbar.is-compact .toolbar-side {
  gap: 8px;
}

.app-toolbar.is-compact button {
  padding: 8px 12px;
}

.app-toolbar.is-condensed .toolbar-score-group,
.app-toolbar.is-condensed .toolbar-separator--score {
  display: none;
}

.app-toolbar.is-collapse-to-more [data-toolbar-collapse="more"] {
  display: none;
}

.app-toolbar.is-stacked {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  grid-template-areas:
    'left . right'
    'center center center';
  align-items: center;
  gap: 10px 12px;
  padding: 8px 12px;
}

.app-toolbar.is-stacked .toolbar-left {
  grid-area: left;
  width: auto;
  justify-self: start;
}

.app-toolbar.is-stacked .toolbar-right {
  grid-area: right;
  width: auto;
  justify-self: end;
}

.app-toolbar.is-stacked .toolbar-center {
  grid-area: center;
  width: 100%;
  justify-content: center;
  flex-wrap: wrap;
}

.app-toolbar.is-stacked .toolbar-separator {
  display: none;
}

.app-toolbar.is-stacked + .toolbar-backdrop + .toolbar-popup,
.app-toolbar.is-stacked ~ .toolbar-popup {
  top: 122px;
}

@media (max-width: 480px) {
  .app-toolbar.is-stacked {
    grid-template-columns: 1fr;
    grid-template-areas:
      'left'
      'center'
      'right';
  }

  .app-toolbar.is-stacked .toolbar-left,
  .app-toolbar.is-stacked .toolbar-right,
  .app-toolbar.is-stacked .toolbar-center {
    width: 100%;
    justify-content: center;
  }
}

@media (max-width: 1366px) {
  #scores-panel,
  #practice-popup,
  #more-popup,
  #options-overlay {
    width: min(1080px, calc(100vw - 28px));
  }

  .toolbar-popup {
    width: min(940px, calc(100vw - 28px));
  }
}

@media (max-width: 1180px) {
  .app-main {
    gap: 8px;
    padding: 8px;
  }

  .panel-header {
    padding: 18px 18px 0;
  }

  .popup-panel-grid {
    gap: 12px;
    padding: 16px 18px 18px;
  }

  .popup-card {
    padding: 14px 16px;
  }

  .midi-grid {
    grid-template-columns: minmax(0, 1fr) minmax(220px, 240px);
  }

  .form-grid--practice {
    grid-template-columns: minmax(0, 1fr) minmax(220px, 240px);
  }

  #scores-panel,
  #practice-popup,
  #more-popup,
  #options-overlay {
    width: min(1020px, calc(100vw - 20px));
  }

  #tempo-popup,
  #looper-popup {
    width: min(560px, calc(100vw - 20px));
  }

  .toolbar-popup {
    top: 66px;
    max-height: min(calc(100vh - 88px), calc(100dvh - 88px));
  }
}

@media (max-width: 980px) {
  .popup-panel-grid--two,
  .midi-grid,
  .form-grid--practice,
  .toggle-grid,
  .status-grid--two,
  .debug-grid {
    grid-template-columns: 1fr;
  }

  .field-group--compact,
  .midi-mode-section > .field-group {
    max-width: none;
    justify-self: stretch;
  }

  .midi-panel-header,
  .panel-header {
    gap: 12px;
  }

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

  .status-pill {
    align-self: flex-start;
  }

  #scores-panel,
  #practice-popup,
  #more-popup,
  #options-overlay,
  #tempo-popup,
  #looper-popup,
  .toolbar-popup {
    width: min(calc(100vw - 18px), 920px);
  }
}

@media (max-width: 860px) {
  .toolbar-popup {
    max-height: min(calc(100vh - 126px), calc(100dvh - 126px));
  }

  .app-main {
    padding: 6px;
  }

  .more-shortcuts {
    grid-template-columns: 1fr;
  }
}

@media (max-height: 820px) {
  .toolbar-popup {
    max-height: min(calc(100vh - 82px), calc(100dvh - 82px));
  }
}

@media (max-width: 760px) {
  .panel-header,
  .popup-panel-grid {
    padding-left: 16px;
    padding-right: 16px;
  }

  .compact-header h2 {
    font-size: 1.35rem;
  }
}


/* alphaTab playback cursor */
.at-cursor-bar {
  background: transparent !important;
}

.at-cursor-beat {
  /* Width is set by the alphaTab cursor container in vendor code. */
  overflow: visible;
  background: transparent !important;
  border-radius: 0;
  box-shadow: none;
}

.at-cursor-beat::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 0;
  width: 16px;
  height: 100%;
  margin-left: -8px;
  /* alphaTab scales this cursor element down by 100 after layout. Cancel that scale for the halo width. */
  transform: scaleX(100);
  transform-origin: center;
  border-radius: 4px;
  pointer-events: none;
  background:
    linear-gradient(to right, rgba(77, 174, 234, 0) 0%, rgba(77, 174, 234, 0.16) 22%, rgba(77, 174, 234, 0.22) 50%, rgba(77, 174, 234, 0.16) 78%, rgba(77, 174, 234, 0) 100%),
    linear-gradient(to bottom, rgba(77, 174, 234, 0.04) 0%, rgba(77, 174, 234, 0.2) 18%, rgba(77, 174, 234, 0.28) 50%, rgba(77, 174, 234, 0.2) 82%, rgba(77, 174, 234, 0.04) 100%);
}

.at-highlight * {
  fill: rgba(46, 204, 113, 0.92) !important;
  stroke: rgba(46, 204, 113, 0.92) !important;
}

@media (max-width: 1120px) {
  .toolbar-score-group,
  .toolbar-separator--score {
    display: none;
  }
}


.more-popup-grid .more-shortcut-button {
  width: 100%;
  justify-content: flex-start;
  min-height: 52px;
  padding: 12px 18px;
  border-radius: 14px;
  text-align: left;
}

#more-popup .compact-header h2 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--muted-strong);
}

#more-popup .panel-kicker {
  margin-bottom: 2px;
}

/* Stage 6 practice feedback overlays */
.feedback-group--tabs { border-top:1px solid #dbe3eb; margin-top:16px; padding-top:16px; }
.notation-feedback-overlay { position:absolute; inset:0; width:100%; height:100%; overflow:visible; pointer-events:none; z-index:1001; }
.loop-shading-overlay { position:absolute; inset:0; width:100%; height:100%; overflow:visible; pointer-events:none; z-index:3; }
.loop-shading-overlay rect { fill:#59616b; fill-opacity:0.18; }
.notation-feedback-overlay rect { fill:transparent; stroke-width:2.5; vector-effect:non-scaling-stroke; }
.notation-feedback-overlay [data-state='expected'] { stroke:#2563eb; }
.notation-feedback-overlay [data-state='correct'] { stroke:#16803d; }
.notation-feedback-overlay [data-state='missed'] { stroke:#dc2626; stroke-dasharray:4 2; }
.fretboard-scroll { overflow-x:auto; }
.fretboard-scroll svg { display:block; width:100%; }
.fretboard-neck { fill:#303944; stroke:#202934; stroke-width:1; }
.fretboard-fret { stroke:#a9b3bf; stroke-width:2; }
.fretboard-nut { stroke:#eee8d9; stroke-width:7; }
.fretboard-inlay { fill:#b0bac5; opacity:.65; }
.fretboard-string { stroke:#d6dce3; }
.fretboard-label { fill:#334155; font-size:12px; }
.fretboard-marker { color:#7c3aed; }
.fretboard-marker[data-state='expected'] { color:#2563eb; }
.fretboard-marker[data-state='correct'] { color:#16803d; }
.fretboard-marker[data-state='missed'],.fretboard-marker[data-state='wrong'],.fretboard-marker[data-state='completed-with-errors'] { color:#dc2626; }
.fretboard-marker-target circle { fill:currentColor; stroke:white; stroke-width:1; }
.fretboard-marker-target text { fill:white; font-size:12px; font-weight:bold; }
.fretboard-marker-played circle { fill:transparent; stroke:currentColor; stroke-width:2.5; }
.fretboard-marker-context circle { fill:#303944; stroke:currentColor; stroke-width:1.5; }
.fretboard-marker-context text { fill:currentColor; font-size:12px; font-weight:bold; }
.fretboard-capo rect { fill:#eee8d9; stroke:#64748b; }
.fretboard-capo text { fill:#334155; font-size:12px; font-weight:bold; }
.fretboard-marker[data-state='future'] { color:#ebc66a; }
.fretboard-marker-alternative { color:#a9c4ff; }
.fretboard-marker-alternative circle { fill:#303944; stroke:currentColor; stroke-opacity:.7; stroke-width:1.8; stroke-dasharray:3 2; }
.fretboard-marker-alternative text { fill:#c4d7ff; opacity:.9; font-size:12px; font-weight:bold; }
.fretboard-marker[data-state='past'] { color:#b0bac5; opacity:.4; }
.fretboard-marker text.fretboard-feedback-accent { fill:currentColor; stroke:white; stroke-width:2px; paint-order:stroke; font-size:10px; }
.fretboard-tools { position:absolute; top:28px; left:8px; display:flex; flex-direction:column; gap:4px; z-index:5; }
.fretboard-tools > button { width:32px; min-height:32px; padding:2px; }
#fretboard-content { margin-left:34px; }
#fretboard-options { position:fixed; inset:auto; margin:0; z-index:130; width:260px; max-width:calc(100vw - 32px); padding:10px; border:1px solid #cbd5e1; border-radius:8px; background:#f8fafc; color:#334155; box-shadow:0 4px 12px #0003; max-height:70vh; overflow:auto; }
#fretboard-options[hidden] { display:none; }
#fretboard-options label { display:flex; align-items:center; gap:8px; margin-bottom:8px; }
#fretboard-options select { min-width:0; max-width:100%; }
#fretboard-options p { font-size:12px; margin:8px 0 0; }
#fretboard-container { max-height:32vh; overflow-y:auto; }

/* Stage 8 feedback additions: native score remains untouched. */
.notation-feedback-overlay [data-state='completed-with-errors'],
.notation-feedback-overlay [data-state='wrong'] { stroke:#dc2626; }
.notation-feedback-overlay .tab-error-highlight { fill:#dc2626; fill-opacity:0.16; stroke:none; }
.notation-feedback-overlay .tab-correct-highlight { fill:#08783d; fill-opacity:0.34; stroke:none; }
.notation-feedback-overlay .target-notehead { fill:transparent; stroke-width:1.5; vector-effect:non-scaling-stroke; }
.notation-feedback-overlay .target-notehead[data-state='correct'] { fill:#16803d; fill-opacity:0.8; }
.notation-feedback-overlay .target-notehead[data-state='missed'],
.notation-feedback-overlay .target-notehead[data-state='wrong'],
.notation-feedback-overlay .target-notehead[data-state='completed-with-errors'] { fill:#dc2626; fill-opacity:0.7; stroke-dasharray:none; }
.notation-feedback-overlay .wrong-notehead { fill:#dc2626; fill-opacity:0.65; stroke:#dc2626; stroke-width:1; }
.notation-feedback-overlay .wrong-ledger { stroke:#dc2626; stroke-width:1; }
.notation-feedback-overlay .wrong-accidental { fill:none; stroke:#dc2626; stroke-width:0.16; stroke-linecap:round; stroke-linejoin:round; }
.trainer-error-history { color:#b91c1c; font-size:12px; max-height:150px; overflow:auto; padding-left:18px; }

.notation-feedback-overlay .wrong-fret-background { fill:#fff; fill-opacity:0.72; stroke:none; }
.notation-feedback-overlay .wrong-fret-number { fill:#dc2626; font-family:Arial,sans-serif; font-weight:600; }

.notation-feedback-overlay .wrong-fret-feedback[data-retained='true'] .wrong-fret-number { fill-opacity:0.8; }
