body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  /*background: #f5f5f5;*/
}

/* Wrap everything so the score scrolls but toolbox is fixed */
#page {
  min-height: 100vh;
}

html, body {
  /*height: 100%;*/
  /*overflow: hidden;*/
}
html, body {
  height: auto !important;
  min-height: 100%;
  overflow-y: auto !important;
}

/* Score area */
#scoreContainer {
  border: 1px solid #ddd;
  background: #fff;
  padding: 0.5rem;
  margin: 0.5rem;
  box-sizing: border-box;
  max-width: 100%;
  
  /*overflow: auto;*/
  overflow: visible;
  
}

#osmdCanvasPage1 {
  max-width: 100%;
}
@media (pointer: coarse) {
  #osmdCanvasPage1,
  svg.osmd-svg {
    max-width: none !important;
    width: auto !important;
  }
}

/* Floating toolbox panel */
#toolboxPanel {
  position: fixed;
  top: calc(env(safe-area-inset-top) + 6px);
  right: 0;
   /*calc(env(safe-area-inset-right) + 6px);*/
  left:0;
   
  /*overflow: hidden;*/
  width: 100vw;
  max-width: 100vw;

  background: rgba(150, 250, 250, .6);
  /*backdrop-filter: blur(2px);   /* optional, looks great on mobile */*/
  border: 1px solid #ccc;
  border-radius: 8px;
  box-shadow: 0 3px 6px rgba(0,0,0,0.25);

  padding: 4px 6px;
  z-index: 1000;
}

/*#toolboxPanel {*/
  /*position: sticky;*/
  /*top: 0;*/
  /*z-index: 10;*/
  /*background: white;*/
  /*padding: 6px 8px;*/
/*}*/

@media (pointer: coarse) {
  #toolboxPanel {
    position: fixed;
    top: calc(env(safe-area-inset-top) + 6px);
    left: 50%;
    transform: translateX(-50%);
    right: auto;
    bottom: auto;
    
    padding: 0px 6px;

  }

  #toolboxPanel button {
    font-size: 16px;
    padding: 2px 8px;
  }
}

/* Toolbox header */
#toolboxPanel h3 {
  margin: 0 0 0.25rem 0;
  font-size: 0.95rem;
}

#toolbox {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  gap: 8px;
  flex-shrink: 0;
  flex: 0 0 auto;
  
}

/* Toolbox buttons */
#toolbox button.note-btn,
#toolbox button.letter-btn,
#toolbox button.accidentalBtn,
#toolbox button.interval-done-btn {
  /*padding: 10px 14px;*/
  font-size: 1.4rem;
  min-width: 32px;
  min-height: 32px;
  width: 32px;
  height: 32px;
  font-size: 1.2rem;
  margin: 0;
  background:rgba(250, 250, 250, .6)
}
#toolbox button {
  display: flex;
  align-items: center;     /*  vertical centering */
  justify-content: center; /*  horizontal centering */
  line-height: 0;          /*  critical */
  padding: 0;
}
#toolbox button {
  min-width: 24px;
}
#toolbox button span,
#toolbox button {
  transform: translateY(1px);
}

#toolbox button svg {
  display: block;
}
#toolbox button {
  font-weight: 800;          /* heavier glyph */
  line-height: 1;
}

/* Chrome / Edge / Safari */
#toolbox button {
  -webkit-text-stroke: 0.6px currentColor;
}

@media (pointer: coarse) {
  #toolbox button {
    /*padding: 14px 18px;*/
    font-size: 1.6rem;
  }
  #feedback {
    width: 160px;
    min-width: 160px;
    max-width: 160px;
  }

  #toolboxPanel {
    max-width: 96vw;
  }
}

#toolboxMessage {
  min-width: 240px;   /* wide enough for “Incorrect” */
  text-align: center;
  white-space: nowrap;
}
/* Feedback + progress inside the panel */
/*#feedback {*/
  /*padding: 0;*/
  /*line-height: 1.1;*/
  /*font-size: 12px;*/
  /*width: 200px;          /* reserve max message width */*/
  /*min-width: 110px;*/
  /*text-align: right;*/
  /*font-size: 0.9rem;*/
/*}*/

#feedback {
  flex: 1 1 auto;
  width: 180px;        /* fixed width */
  min-width: 120px;
  max-width: 260px;
  text-align: right;
  white-space: nowrap;
  font-weight: bold;
  font-size: 0.9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;

  font-weight: 600;
  /*text-overflow: ellipsis;*/
  /*flex-shrink: 0;     */
}

#progress {
  /*margin-top: 0.1rem;*/
  display: flex;   
  align-items: center;             /* Enables flex properties */
  flex: 0 0 auto;
  justify-content: flex-start; /* Pushes the first item to the left and the second item to the right */
  /*width: auto;        */          
  /* Ensures the container takes up the full width */
  font-size: 0.55rem;
  color: #555; 
  margin-top: -5px;
  padding: 0;
  line-height: 1.05;
  flex-shrink: 0;
  gap: 8px;
}
#progress {
  min-width: 0;
  white-space: nowrap;
  text-align: right;
  overflow: hidden;
  text-overflow: ellipsis;

  font-size: 0.85rem;
}

#toolboxRow {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 6px;
  flex-wrap: nowrap;
  white-space: nowrap;
  overflow: hidden;
  width: 100%;
  max-width: 100%;
}

/* Correct / wrong colors */
#feedback.correct {
  color: #0a8a1f;
}
#feedback.wrong {
  color: #b80000;
}

/* No longer used */
#results {
//  margin: 0.5rem;
  font-size: 0.55rem;
  float: right;
  
}


/* Active beat: size pulse, but stays in place */
.pulse-note path {
  transform-box: fill-box;
  transform-origin: center center;   /* ✅ anchor properly */
  animation: pulseSize 1.2s ease-in-out infinite;
}

@keyframes pulseSize {
  0%   { transform: scale(1);   }
  50%  { transform: scale(1.25); }
  100% { transform: scale(1);   }
}
#muteToggle {
   flex-shrink: 0;
   font-size: 1.6rem;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  margin-top: 0 2px;
  width: 22px;
  height: 22px;
}
#muteToggle svg {
  width: 18px;
  height: 18px;
}

@media (pointer: coarse) {
  #muteToggle {
    width: 34px;
    height: 34px;
  }
  #muteToggle svg {
    width: 28px;
    height: 28px;
  }
}
@media (pointer: coarse) and (orientation: portrait) {
  #muteToggle {
    width: 38px;
    height: 38px;
  }
  #muteToggle svg {
    width: 30px;
    height: 30px;
  }
}

.mute-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 2px;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #333; /* icon color (via currentColor) */
}

.mute-btn:hover {
  color: #0077ff;
}

#scoreWrapper {
  position: relative;
  min-height: auto;
  overflow: visible;   /*  MUST be visible */
}


.click-label {
  font-size: 16px;
  font-family: "Times New Roman", serif;
  font-weight: bold;
  color: #000;
  pointer-events: none;
  user-select: none;
  white-space: nowrap;
}

#clickOverlay {
    pointer-events: all;
    z-index: 1000;
    position: absolute;
}
.click-rect {
    pointer-events: all;
    fill: transparent;
}
/* POSITIONING ONLY */
.click-label {
  position: absolute;
  transform: translateX(-50%);
  pointer-events: none;
  z-index: 10;
}

/* HARD CENTERING BOX (does not scale) */
.label-center {
  display: flex;
  align-items: center;
  justify-content: center;
}

/* SCALING ELEMENT ONLY */
.label-inner {
  display: inline-block;
  transform-origin: center center;
}

/* PULSE */
.click-label.pulse-label .label-inner {
  animation: pulseLabel 1.2s ease-in-out infinite;
}

.click-label-svg.pulse-label {
  transform-origin: center center;
  animation: pulseLabel 1.2s ease-in-out infinite;
}

@keyframes pulseLabel {
  0%   { transform: scale(1); }
  50%  { transform: scale(1.25); }
  100% { transform: scale(1); }
}


.active-label {
  color: #2a7cff;
}

@media (pointer: coarse) {
  #scoreContainer {
    max-width: 92vw;
    margin-left: 0;
    margin-right: 0;
    overflow-x: auto;
    overflow-y: visible;

  }
}
@media (pointer: coarse) {
  #osmdCanvasPage1,
  svg.osmd-svg {
    max-width: none !important;
  }
}

#scoreContainer svg {
  position: relative;
  display: block;
}

/*Shrink headings on mobile devices:*/
@media (pointer: coarse) {
  h1 {
    font-size: 1.2rem;
    line-height: 1;
    margin: 0.3rem 0 0.2rem 0;
  }

  h2, h3 {
    font-size: .75rem;
    line-height: 1;
    margin: 0 0 0.2rem 0;
  }

  /* If subtitle is a <p> or custom element */
  .subtitle,
  .worksheet-subtitle {
    font-size: 0.7rem;
    margin: 0 0 0.3rem 0;
  }
  #scoreContainer svg {
    margin-top: -70px; /* tune */
    display: block;
  }
  #toolboxRow {
    gap: 8px;
  }

  #feedback {
    width: 160px;
    font-size: 0.9rem;
  }

  #progress {
    font-size: 0.8rem;
  }

}
.exercise-toast {
  position: fixed;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,0.85);
  color: white;
  padding: 8px 12px;
  border-radius: 6px;
  z-index: 9999;
  font-size: 0.9rem;
}
#exerciseTitleOverlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
}

.exercise-title-box {
  background: white;
  padding: 16px 20px;
  border-radius: 10px;
  text-align: center;
  max-width: 90vw;
}

.exercise-title {
  font-size: 1.3rem;
  font-weight: 600;
}

.exercise-subtitle {
  font-size: 0.95rem;
  opacity: 0.75;
  margin-top: 4px;
}

.exercise-device-instr {
  font-size: 0.95rem;
  opacity: 0.75;
  margin-top: 4px;
  font-style: italic;
  
}

.exercise-title-box button {
  margin-top: 12px;
  padding: 6px 14px;
  font-size: 1rem;
}
.click-label-svg {
  font-family: "Times New Roman", serif;
  font-weight: bold;
  user-select: none;
  transform-box: fill-box;      /* critical for SVG */
  transform-origin: center;     /* critical for SVG */

}
@media (pointer: coarse) {
  .click-label-svg {
    font-size: 12px;
  }
}
.click-label-svg.active-label {
  fill: #2a7cff;
  animation: pulseLabel 1.2s ease-in-out infinite;
}
/*
@media (pointer: coarse) {
  #toolboxRow {
    display: flex;
    align-items: center;
    flex-wrap: nowrap;
    gap: 8px;
    overflow: hidden;
  }
  
  #toolbox {
    flex: 0 0 auto;
  }
  
  #progress {
    flex: 1;
    white-space: nowrap;
  }
  
  #feedback {
    flex: 0 0 160px;   
    width: 160px;
    max-width: 160px;
  
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  
    text-align: right;
  }
}
*/
#toolboxPanel {
  background-color: rgba(150, 250, 250, 0.6) ;
}

body.click-staff-mode #osmdCanvasPage1 svg {
  transform: translateY(48px);
}

.interval-done-btn {
  /* margin-left: 24px; */
  background: #666;
  color: #fff;
  margin-right: 30px;
}
.interval-done-btn:hover {
  background: #444;
}

.toolbox-right {
  display: flex;
  align-items: center;
  margin-left: auto;       /* pins it to the right */
}

/* =========================
   Base label
   ========================= */

text.interval-label-svg {
  font-family: "Segoe UI Symbol", "Arial Unicode MS", sans-serif;
  fill: #000;
  font-size: 14px;          /* BASE size */
}

/* =========================
   Arrow + number (relative)
   ========================= */

/* Arrow: bigger + bolder */
text.interval-label-svg .interval-arrow {
  font-size: 1.3em;         /* relative to parent */
  font-weight: 800;
}

/* Number: smaller + calmer */
text.interval-label-svg .interval-number {
  font-size: 1em;
  font-weight: 500;
}

/* =========================
   Active / pulsing state
   ========================= */

text.interval-label-svg.active-label {
  fill: #1e88e5;
  font-size: 18px;          /* scales arrow + number proportionally */
  font-weight: 700;
}

text.interval-label-svg.pulse-label {
  animation: svg-pulse 1s ease-in-out infinite;
}

/* =========================
   Pulse animation (SVG-safe)
   ========================= */

@keyframes svg-pulse {
  0%   { opacity: 1; }
  50%  { opacity: 0.4; }
  100% { opacity: 1; }
}

/* Base dot (if not already defined) */
.feedback-dot {
  pointer-events: none;
}

/* Blue placement dot */
.feedback-dot-blue {
  fill: #1e88e5;
}

/* Pulse animation */
@keyframes dot-pulse {
  0%   { opacity: 1; }
  50%  { opacity: 0.35; }
  100% { opacity: 1; }
}

.feedback-dot.pulse-dot {
  animation: dot-pulse 0.8s ease-in-out infinite;
}

text.interval-label-svg {
  fill: #000;
  font-family: "Segoe UI Symbol", "Arial Unicode MS", sans-serif;
}

text.interval-label-svg.correct {
  fill: #2e7d32;   /* green */
  font-weight: 700;
}

text.interval-label-svg.wrong {
  fill: #c62828;   /* red */
  font-weight: 700;
}
.toolbox-section.disabled {
  opacity: 0.5;
  pointer-events: none;
}

.note-btn.correct { background: #3fa93f; }
.note-btn.wrong   { background: #c83b3b; }

select.correct { border-color: #3fa93f; }
select.wrong   { border-color: #c83b3b; }

.dropdown-group select {
  min-width: 4.5em;
}
/* Restore native select appearance ONLY for chord tool */
#chordNamesToolbox select {
  all: revert;
  appearance: auto;
  -webkit-appearance: menulist;
  -moz-appearance: menulist;

  background: white;
  color: black;
  border: 1px solid #666;
  padding: 2px 6px;
  font-size: 0.9em;
  min-width: 4.5em;
}
#chordNamesToolbox .dropdown-group {
  display: flex;
  align-items: center;
  gap: 0.4em;
  margin-bottom: 0.25em;
}
#chordNamesToolbox label {
  min-width: 3em;
}

#chordNamesToolbox .toolbox-hint {
  position: static;          /* critical */
  margin-top: 2px;
  margin-bottom: 4px;
  font-size: 0.85em;
  opacity: 0.75;
  pointer-events: none;      /* hint should never block UI */
}
#chordNamesToolbox .chord-dropdowns {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 10px;
  flex-wrap: nowrap;   /* keep on one line */
}
#chordNamesToolbox .dropdown-group {
  display: flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}
#chordNamesToolbox .dropdown-group label {
  font-size: 0.85em;
  opacity: 0.8;
}

/* Fix hint overlap */
#chordNamesToolbox .toolbox-hint {
  position: static;
  margin: 2px 0 4px;
  font-size: 0.85em;
  opacity: 0.75;
  pointer-events: none;
}

/* One-line dropdowns */
#chordNamesToolbox .chord-dropdowns {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: nowrap;
}

/* Compact dropdown groups */
#chordNamesToolbox .dropdown-group {
  display: flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}

/* Group chord dropdowns + button */
#chordNamesToolbox .chord-controls {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Keep dropdowns compact */
#chordNamesToolbox select {
  font-size: 0.85em;
  padding: 2px 4px;
  height: 1.8em;
}
#chordNamesToolbox #submitChordBtn {
  font-size: 0.8em;
  padding: 2px 8px;
  height: 1.8em;
  line-height: 1;
  opacity: 0.85;
}

#chordNamesToolbox #submitChordBtn:disabled {
  opacity: 0.4;
}
#chordNamesToolbox #submitChordBtn.primary {
  background: #ddd;
  color: #333;
}

#progress {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;   /* THIS is the key */
  white-space: nowrap;
}
#chordNamesToolbox .toolbox-title {
  margin-right: 6px;
  font-size: 0.85em;
  opacity: 0.8;
}
#chordNamesToolbox #submitChordBtn {
  font-size: 0.75em;
  padding: 1px 6px;
  height: 1.6em;
  line-height: 1;
  min-width: unset;
  opacity: 0.85;
}
#chordNamesToolbox #submitChordBtn:hover:not(:disabled) {
  opacity: 1;
}
#chordNamesToolbox select {
  min-width: 3.2em;
  padding: 1px 2px;
  font-size: 0.8em;
}
#chordNamesToolbox #submitChordBtn {
  font-size: 0.7em;      /* smaller than note buttons */
  padding: 1px 5px;
  height: 1.4em;
  line-height: 1;
  font-weight: normal;
}
.accidentalBtn {
    padding: 6px 10px;
    font-size: 14px;
}
@media (orientation: landscape) and (max-height: 500px) {

  #scoreContainer {
    padding-top: 80px; /* adjust as needed */
  }

}

#toolboxPanel.phase-note {
 background-color: rgba(150, 250, 250, 0.6) ;
}

#toolboxPanel.phase-chord {
  background-color: #e8f7f3;  /* subtle green tint */
}

.phase-active {
  font-weight: bold;
  text-decoration: underline;
}

.phase-inactive {
  opacity: 0.5;
}

.note-btn.selected-root {
  background-color: black !important;
  color: white;
  border: 2px solid orange;
}

.disabled-btn {
  opacity: 0.4;
  cursor: not-allowed;
}

/* 3-state sound button */
.mute-btn{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  width:42px;
  height:42px;
  border-radius:10px;
  border:1px solid rgba(0,0,0,0.25);
  background: rgba(255,255,255,0.85);
  cursor:pointer;
  user-select:none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  padding:0;
  line-height:1;
}

.mute-btn .mute-icon{
  font-size:20px;
  transform: translateY(1px);
}

/* Unset (neutral) – draws attention gently */
.mute-unset{
  border-style:dashed;
  opacity:0.95;
  animation: mutePulse 1.6s ease-in-out infinite;
}

@keyframes mutePulse{
  0%, 100% { transform: scale(1.00); opacity:0.92; }
  50%      { transform: scale(1.06); opacity:1.00; }
}

/* Sound ON */
.mute-on{
  border-style:solid;
  opacity:1;
  animation:none;
}

/* Sound OFF */
.mute-off{
  border-style:solid;
  opacity:0.85;
  animation:none;
}

/* Optional: if you want it smaller on mobile toolbars */
@media (pointer:coarse){
  .mute-btn{ width:46px; height:46px; }
  .mute-btn .mute-icon{ font-size:22px; }
}
.mute-unset {
  opacity: 0.9;
  border: 1px dashed rgba(0,0,0,0.3);
  animation: pulseSound 1.6s ease-in-out infinite;
}

@keyframes pulseSound {
  0%,100% { transform: scale(1); }
  50% { transform: scale(1.08); }
}


.sound-choice-label {
  font-weight: 600;
  font-size: 0.95rem;
  margin-right: 4px;
}


/* Temporary centered layout while choosing sound */
#toolboxRow.sound-mode {
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px 0 24px 0;
}

.sound-choice-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.sound-choice-title {
  font-size: 1.05rem;
  font-weight: 600;
  margin-bottom: 6px;
}


.sound-choice-buttons {
  display: flex;
  flex-direction: column;
  gap: 14px;
  align-items: center;
}

/* =========================
   Sound choice buttons (override toolbox defaults)
   ========================= */
#toolbox .sound-choice-btn {
  /* undo toolbox button constraints */
  width: auto !important;
  height: auto !important;
  min-width: 260px !important;
  min-height: 44px !important;

  /* undo toolbox "square button" styling */
  padding: 12px 18px !important;
  line-height: 1.2 !important;
  transform: none !important;
  -webkit-text-stroke: 0 !important;

  display: flex !important;
  flex-direction: column !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 6px !important;

  border-radius: 999px !important;
  border: 1px solid rgba(0,0,0,0.25) !important;

  font-size: 1.05rem !important;
  font-weight: 650 !important;

  cursor: pointer;
  user-select: none;
}
#toolbox .sound-choice-btn .btn-main {
  display: flex;
  align-items: center;
  gap: 10px;
}
/* remove the global translateY on spans inside toolbox buttons */
#toolbox .sound-choice-btn span {
  transform: none !important;
}

/* make sure SVG aligns and inherits color */
#toolbox .sound-choice-btn svg {
  width: 22px;
  height: 22px;
  flex: 0 0 auto;
  display: block;
}

/* ON button – colored */
#toolbox .sound-choice-btn.sound-on {
  background: linear-gradient(180deg, #e6fffa, #c9f3ee) !important;
  border-color: #2c7a7b !important;
  color: #0b5f60 !important;
}
#toolbox .sound-choice-btn.sound-on:hover {
  background: linear-gradient(180deg, #d7fbf7, #b9efe9) !important;
}

/* OFF button – neutral */
#toolbox .sound-choice-btn.sound-off {
  background: #f2f2f2 !important;
  border-color: rgba(0,0,0,0.22) !important;
  color: #333 !important;
}
#toolbox .sound-choice-btn.sound-off:hover {
  background: #e8e8e8 !important;
}

/* Recommended badge (clean + aligned) */
#toolbox .recommended {
  font-size: 0.72rem !important;
  font-weight: 600 !important;
  padding: 2px 8px !important;
  border-radius: 999px !important;
  background: rgba(44,122,123,0.18) !important;
  color: #2c7a7b !important;

  margin-top: 2px;
}
#soundModeContainer.hidden {
  display: none;
}
.accidental-btn {
  font-size:16px;
}
.sound-choice-btn:focus {
  outline: 3px solid #2ca7db;
  outline-offset: 3px;
}
.exercise-subtitle {
  white-space: pre-line;
}
.accidental-hint {
  background: #ffeaa7;
  box-shadow: 0 0 6px #fdcb6e;
}
/* Pulse for toolbox buttons */
.pulse-btn {
  animation: pulseBtn 1.2s ease-in-out infinite;
}

@keyframes pulseBtn {
  0%   { transform: scale(1); }
  50%  { transform: scale(1.15); }
  100% { transform: scale(1); }
}