/* App Header & Eagle View Music Navigation */
.app-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  width: 100%;
  z-index: 9999;
  background-color: #141b91;
  padding: 6px 14px;
  display: flex;
  justify-content: center;
  align-items: center;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
  box-sizing: border-box;
  min-height: 44px;
}

.app-header-title {
  font-family: 'Dancing Script', cursive;
  margin: 0;
  font-size: 24px;
  font-weight: 700;
  color: white;
  text-align: center;
}

.app-home-link {
  position: absolute;
  left: 14px;
  color: #ffffff;
  text-decoration: none;
  font-size: 13px;
  font-family: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.18);
  padding: 4px 12px;
  border-radius: 9999px;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
}

.app-home-link:hover {
  background: rgba(255, 255, 255, 0.32);
  color: #fde047;
}

/* Hide back button when embedded inside an iframe */
.in-iframe .app-home-link {
  display: none !important;
}

body { margin: 0; padding: 46px 0 0 0; }
#poem { font-size: 1.2em; line-height: 2em; padding: 20px; }
.line { display: block; margin-bottom: 16px; text-align: center; }
.measure { display: inline-block; vertical-align: top; }
.measure-divider { display: inline-block; width: 2px; background-color: #666; margin: 0 8px; vertical-align: top; position: relative; }
.final-measure-divider { display: inline-block; width: 6px; background: linear-gradient(to right, #666 0%, #666 25%, transparent 25%, transparent 75%, #666 75%, #666 100%); margin: 0 8px; vertical-align: top; position: relative; }
.group { display: inline-block; vertical-align: top; margin-right: 8px; text-align: center; }
.notes-box { display: flex; justify-content: center; align-items: center; margin-bottom: 4px; border: none; padding: 4px; transition: background-color 0.1s ease; }
.notes-box.playing, .notes-box.selected { background-color: #ffff99; border-radius: 4px; }
.notes-box svg, .notes-box img { margin: 0 4px; }
.notes-box.compound svg, .notes-box.compound img { }
.notes-box.sixteenth svg, .notes-box.sixteenth img { }
.circles { 
  display: flex; 
  justify-content: center; 
  align-items: center;
  margin-bottom: 4px; 
  border: 1px solid #c0c0c0; 
  padding: 6px 8px 6px 18px; 
  background-color: #f5f5f5; 
  border-radius: 8px; 
  transition: opacity 0.3s ease; 
  position: relative;
  min-height: 20px;
  box-sizing: border-box;
}
.circles.circles-hidden { opacity: 0; pointer-events: none; }
.circles.pickup {
    background-color: #90EE90; /* Brighter Green */
}
.circles.linked {
    background-color: #fff3e0; /* Very light orange background */
    border-color: #ffcc80;
}

/* Chain Link button between 8th-note beat boxes */
.beat-link-btn {
  position: absolute;
  right: -14px;
  top: -8px;
  width: 18px;
  height: 18px;
  background: transparent;
  border: none;
  outline: none;
  cursor: pointer;
  padding: 0;
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #999;
  z-index: 10;
  transition: color 0.15s ease, transform 0.1s ease;
}

.beat-link-btn svg {
  width: 14px;
  height: 14px;
  pointer-events: none;
  filter: drop-shadow(0 1px 1px rgba(255, 255, 255, 0.9));
}

.beat-link-btn:hover {
  color: #555;
  transform: scale(1.15);
}

.beat-link-btn.active {
  color: #fd7e14; /* Orange */
}

.beat-link-btn.active:hover {
  color: #e8590c;
  transform: scale(1.15);
}

/* Beat box subdivision controls on far left */
.beat-subdivision-controls {
  position: absolute;
  left: 3px;
  top: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 0;
  z-index: 2;
}

.subdivision-btn {
  background: transparent;
  border: none;
  outline: none;
  padding: 0;
  margin: 0;
  width: 11px;
  height: 11px;
  line-height: 11px;
  font-size: 13px;
  font-weight: bold;
  color: #888;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
  transition: color 0.15s ease, transform 0.1s ease;
  font-family: inherit;
}

.subdivision-btn:hover {
  color: #333;
  transform: scale(1.2);
}

.subdivision-btn.plus-btn.active {
  color: #28a745;
  font-weight: 900;
}

.subdivision-btn.plus-btn.active:hover {
  color: #218838;
}

.subdivision-btn.minus-btn {
  color: #888;
}

.subdivision-btn.minus-btn:hover {
  color: #333;
}

.circle { margin: 0 2px; border-radius: 50%; background-color: grey; cursor: pointer; }
.circle.active { background-color: #007bff; }
.circle.sustain, .circle.light-blue, .circle.yellow { background-color: #70b5ff; }
.circle.sustain-green, .circle.light-green { background-color: #70db8f; }
.circle.syncopated { background-color: #28a745; } /* Green for syncopated */
.words { display: flex; justify-content: center; }
.word-container { display: inline-block; margin: 0 4px; text-align: center; }
.word, .word-input { display: block; cursor: pointer; }
.word.rest { color: #d3d3d3; }
.word-input { font-size: 1em; width: auto; padding: 2px 4px; box-sizing: border-box; border-color: black; }

/* Floating bottom panel - redesigned with two-row drawer */
.floating-panel { 
  position: fixed; 
  bottom: 0; 
  left: 0; 
  right: 0; 
  background-color: #e6f3ff; 
  border-top: 2px solid #0066cc; 
  display: flex; 
  flex-direction: column;
  align-items: center; 
  justify-content: center; 
  gap: 8px;
  padding: 10px 15px; 
  z-index: 1000;
  transition: transform 0.3s ease-in-out;
  min-height: 60px;
}

.floating-panel.collapsed {
  transform: translateY(100%);
}

.settings-upper-row {
  display: none;
  width: 100%;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(0, 102, 204, 0.2);
  animation: slideDownSettings 0.2s ease-out;
}

.settings-upper-row.open {
  display: flex;
}

.library-upper-row {
  gap: 8px;
}

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

.settings-base-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
}

.settings-gear-button {
  width: 40px;
  height: 40px;
  background-color: #f0f8ff;
  border: 1px solid #007bff;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #007bff;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.settings-gear-button:hover {
  background-color: #e6f3ff;
}

.settings-gear-button.active {
  background-color: #007bff;
  border-color: #0056b3;
  color: white;
}

.settings-gear-button svg {
  transition: transform 0.3s ease;
}

.settings-gear-button.active svg {
  transform: rotate(45deg);
}

.save-button.active {
  background-color: #007bff;
  border-color: #0056b3;
}

.save-button.active .save-icon {
  filter: brightness(0) invert(1);
}

/* Panel Toggle Button */
.panel-toggle-button {
  position: absolute;
  top: -22px; /* Positioned right on top of the panel's border */
  left: 50%;
  transform: translateX(-50%);
  width: 44px;
  height: 22px;
  background-color: #0066cc;
  border: none;
  border-top-left-radius: 10px;
  border-top-right-radius: 10px;
  cursor: pointer;
  z-index: 1001;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: background-color 0.2s ease;
}

.panel-toggle-button:hover {
  background-color: #0056b3;
}

.panel-toggle-button::after {
  content: '▼'; /* Down arrow */
  color: white;
  font-size: 13px;
  line-height: 1;
}

.panel-toggle-button.collapsed::after {
  content: '▲'; /* Up arrow */
}


/* Base style for control buttons */
.control-button {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 40px;
  padding: 0 12px;
  background-color: #f0f8ff;
  border: 1px solid #007bff;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 14px;
  color: #007bff;
  font-weight: bold;
  font-family: inherit;
  white-space: nowrap;
}

.control-button:hover {
  background-color: #e6f3ff;
}

.control-button input {
  width: 40px;
  font-size: 14px;
  font-weight: bold;
  color: #007bff;
  border: none;
  background: transparent;
  text-align: center;
}

/* Lyrics dropdown - make it more compact */
.lyrics-dropdown,
.rhythm-systems-dropdown {
  min-width: 120px;
  max-width: 200px;
  flex-shrink: 1;
}

.hidden {
  display: none !important;
}

/* Copy Visual Button */
.copy-visual-button {
    font-size: 18px;
    padding: 0 12px;
    min-width: 40px;
}

/* Save Button */
.save-button {
    padding: 0 12px;
    min-width: 40px;
}

.save-icon {
    width: 20px;
    height: 20px;
    background-color: #007bff;
    border-radius: 2px;
    position: relative;
    border: 1px solid #0056b3;
    box-sizing: border-box;
}

.save-icon::before {
    content: '';
    position: absolute;
    top: 0;
    left: 3px;
    width: 10px;
    height: 10px;
    background-color: #e6f3ff;
    border-bottom-left-radius: 2px;
    border-bottom-right-radius: 2px;
    border: 1px solid #0056b3;
    border-top: none;
}

.save-icon::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 2px;
    right: 2px;
    height: 6px;
    background-color: #a9cce3;
    border-top: 1px solid #0056b3;
}

/* Circle icon button */
.icon-button { 
  display: flex; 
  align-items: center; 
  justify-content: center; 
  width: 40px; 
  height: 40px;
  border-radius: 6px; 
  cursor: pointer; 
  transition: all 0.2s ease; 
  flex-shrink: 0;
}

.icon-button.active { 
  background-color: #f0f8ff; 
  border: 1px solid #007bff; 
}

.icon-button.inactive { 
  background-color: #f8f8f8; 
  border: 1px solid #999; 
}

.icon-circles { 
  display: flex; 
  gap: 2px; 
}

.icon-circle { 
  width: 8px; 
  height: 8px; 
  border-radius: 50%; 
}

.icon-button.active .icon-circle { 
  background-color: #007bff; 
}

.icon-button.inactive .icon-circle { 
  background-color: #999; 
}

/* Time signature button */
.ts-button-wrapper {
  position: relative;
  flex-shrink: 0;
}
.time-signature-button {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  background-color: #f0f8ff;
  border: 1px solid #007bff;
  border-radius: 6px;
  font-family: 'Times New Roman', serif;
  font-weight: bold;
  line-height: 1;
  transition: all 0.2s ease;
  cursor: pointer;
}

.time-signature-button:hover {
  background-color: #e6f3ff;
}

.time-signature-top {
  font-size: 16px;
  color: #007bff;
  margin: 0;
  padding: 0;
}

.time-signature-bottom {
  font-size: 16px;
  color: #333;
  margin: 0;
  padding: 0;
}

/* Styles for compound time signature */
.time-signature-button.compound .time-signature-top {
  color: #28a745; /* Green */
}

.time-signature-button.compound .time-signature-bottom {
  color: #007bff; /* Blue */
}


/* Play button */
.play-button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 50px;
  height: 40px;
  background-color: #f4f4f4;
  border: 1.5px solid #c0392b;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 20px;
  color: #c0392b;
  flex-shrink: 0;
}

.play-button:hover {
  background-color: #e9e9e9;
  border-color: #a93226;
  color: #a93226;
}

.play-button.playing {
  background-color: #ffffff;
  border-color: #ff2a2a;
  color: #ff2a2a;
  box-shadow: 0 0 8px rgba(255, 42, 42, 0.35);
  font-size: 26px;
  line-height: 1;
}

.play-button.playing:hover {
  background-color: #ffffff;
  border-color: #e60000;
  color: #e60000;
}

/* 16th Note Button */
.sixteenth-note-button {
    padding: 0 8px;
    min-width: 40px;
    flex-shrink: 0;
}
.sixteenth-note-button img {
    height: 80%;
    filter: grayscale(1);
    opacity: 0.7;
    transition: all 0.2s ease;
}
.sixteenth-note-button.active {
    background-color: #28a745; /* Green for active */
}

.sixteenth-note-button.active img {
    filter: none;
    opacity: 1;
}

.sixteenth-note-button.disabled {
    cursor: not-allowed;
    background-color: #f0f0f0;
    border-color: #ccc;
}
.sixteenth-note-button.disabled img {
    filter: grayscale(1);
    opacity: 0.5;
}


/* Sound Toggle Grid */
.sound-toggle-grid {
  display: grid;
  grid-template-columns: repeat(2, 80px);
  grid-template-rows: repeat(2, 20px);
  gap: 0;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid #ccc;
  flex-shrink: 0;
}

.sound-toggle-btn {
  background-color: #f0f0f0; /* Default grey */
  border: none;
  cursor: pointer;
  font-size: 12px;
  font-weight: bold;
  color: #555;
  transition: background-color 0.2s ease, color 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #ccc;
  margin: -0.5px;
}

.sound-toggle-btn:hover {
  background-color: #e0e0e0;
}

.sound-toggle-btn.active {
  color: white;
}

#beat-toggle.active {
  background-color: #ffc107; /* Yellow */
}

#rhythm-toggle.active {
  background-color: #fd7e14; /* Orange */
}

#intro-toggle.active {
  background-color: #ffc107; /* Yellow */
}

#pitch-toggle.pitch {
  background-color: #28a745; /* Green */
  color: white;
}

#pitch-toggle.drum {
  background-color: #d6b4fc; /* Light Purple */
  color: white;
}

/* Modal Styles */
.modal-backdrop {
    display: none; /* Hidden by default */
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0,0,0,0.4);
    justify-content: center;
    align-items: center;
}

.modal-content {
    background-color: #fefefe;
    margin: auto;
    padding: 20px;
    border: 1px solid #888;
    border-radius: 8px;
    width: 80%;
    max-width: 500px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.modal-content h2 {
    margin: 0;
    font-size: 1.5em;
    color: #333;
}

#multi-line-input {
    width: 100%;
    height: 200px;
    padding: 10px;
    box-sizing: border-box;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 1em;
    resize: vertical;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 10px;
}

.modal-buttons {
    display: flex;
    gap: 8px;
    align-items: center;
}

.modal-button {
    padding: 10px 20px;
    border-radius: 5px;
    border: none;
    cursor: pointer;
    font-size: 1em;
    font-weight: bold;
    transition: background-color 0.2s ease;
}

.modal-button.submit {
    background-color: #007bff;
    color: white;
}

.modal-button.submit:hover {
    background-color: #0056b3;
}

.modal-button:not(.submit):not(.copy-button) {
    background-color: #e7e7e7;
    color: black;
}

.modal-button:not(.submit):not(.copy-button):hover {
    background-color: #ddd;
}

/* Copy Button Styles */
.copy-button {
    background-color: #6c757d;
    color: white;
    padding: 10px 12px;
    position: relative;
    min-width: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.copy-button:hover {
    background-color: #5a6268;
}

.copy-icon {
    position: relative;
    width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.copy-square {
    position: absolute;
    width: 10px;
    height: 10px;
    border: 2px solid white;
    border-radius: 2px;
    background-color: transparent;
}

.copy-square-back {
    top: 2px;
    left: 2px;
}

.copy-square-front {
    top: -2px;
    left: -2px;
    background-color: #6c757d;
}

.copy-button:hover .copy-square-front {
    background-color: #5a6268;
}

/* Success and error states for copy button */
.copy-icon.copied,
.copy-icon.error {
    font-size: 14px;
    font-weight: bold;
}

.toggle-container {
    display: none;
    border: 1px solid #007bff;
    border-radius: 5px;
    overflow: hidden;
}

.toggle-button {
    padding: 10px 20px;
    border: none;
    cursor: pointer;
    font-size: 1em;
    background-color: white;
    color: #007bff;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.toggle-button.active {
    background-color: #007bff;
    color: white;
}

/* Styles for capturing (temporarily hide interactive elements) */
.capturing .circle {
    cursor: default;
}

.capturing .word {
    cursor: default;
}

.capturing .notes-box.playing {
    background-color: transparent;
}

.capturing .delete-measure-btn,
.capturing #floating-panel,
.capturing #zoom-controls,
.capturing .popup-modal {
    display: none !important;
}

/* Mode Toggle Switch */
.control-button-group {
  display: flex;
  border: 1px solid #007bff;
  border-radius: 6px;
  overflow: hidden;
  flex-shrink: 0;
}

.mode-button {
  background-color: white;
  border: none;
  padding: 0 12px;
  height: 40px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 14px;
  color: #007bff;
  font-weight: bold;
  font-family: inherit;
  display: flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
}

.mode-button.active {
  background-color: #007bff;
  color: white;
}

.mode-button:not(.active):hover {
  background-color: #e6f3ff;
}

/* Responsive adjustments - improved layout strategy */
@media (max-width: 900px) {
  .floating-panel {
    gap: 6px;
    padding: 8px 10px;
  }
  
  /* Make dropdowns more compact */
  .lyrics-dropdown,
  .rhythm-systems-dropdown {
    min-width: 100px;
    max-width: 150px;
    font-size: 12px;
  }
}

@media (max-width: 720px) {
  .floating-panel {
    gap: 5px;
    padding: 8px 8px;
  }
  
  /* Further compress elements */
  .control-button {
    height: 36px;
    padding: 0 8px;
    font-size: 12px;
  }
  
  .play-button {
    width: 45px;
    height: 36px;
  }

  .play-button.playing {
    font-size: 23px;
  }
  
  .sound-toggle-grid {
    grid-template-columns: repeat(2, 70px);
    grid-template-rows: repeat(2, 18px);
  }
  
  .sound-toggle-btn {
    font-size: 11px;
  }
  
  .mode-button {
    height: 36px;
    padding: 0 8px;
    font-size: 12px;
  }

  .settings-gear-button {
    width: 36px;
    height: 36px;
  }
  
  .lyrics-dropdown,
  .rhythm-systems-dropdown {
    min-width: 90px;
    max-width: 120px;
    font-size: 11px;
  }
}

@media (max-width: 500px) {
  .floating-panel {
    gap: 4px;
    padding: 6px 6px;
  }
  
  /* Compact everything further */
  .control-button {
    height: 32px;
    padding: 0 6px;
    font-size: 11px;
  }
  
  .play-button {
    width: 40px;
    height: 32px;
    font-size: 16px;
  }

  .play-button.playing {
    font-size: 20px;
  }
  
  .icon-button,
  .time-signature-button,
  .settings-gear-button {
    width: 36px;
    height: 32px;
  }
  
  .sound-toggle-grid {
    grid-template-columns: repeat(2, 60px);
    grid-template-rows: repeat(2, 16px);
  }
  
  .sound-toggle-btn {
    font-size: 10px;
  }
  
  .mode-button {
    height: 32px;
    padding: 0 6px;
    font-size: 11px;
  }
  
  .lyrics-dropdown,
  .rhythm-systems-dropdown {
    min-width: 80px;
    max-width: 100px;
    font-size: 10px;
  }
  
  /* Make BPM display more compact */
  #bpm-button {
    min-width: 60px;
  }
}

/* Zoom Controls - adjusted positioning to avoid overlap */
#zoom-controls {
  position: fixed;
  bottom: 80px; /* Raised to avoid panel */
  left: 20px;
  z-index: 999; /* Below panel */
  transition: bottom 0.3s ease;
}

.floating-panel:has(.settings-upper-row.open) ~ #zoom-controls {
  bottom: 130px;
}

/* Adjust zoom controls when panel is collapsed */
.floating-panel.collapsed ~ #zoom-controls {
  bottom: 30px;
}

.fab {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: none;
  background-color: #007bff;
  color: white;
  font-size: 24px;
  line-height: 56px;
  text-align: center;
  cursor: pointer;
  box-shadow: 0 2px 5px rgba(0,0,0,0.25);
  transition: all 0.3s ease;
}

.fab:hover {
  background-color: #0056b3;
}

.sub-button {
  width: 40px;
  height: 40px;
  font-size: 20px;
  line-height: 40px;
  position: absolute;
  bottom: 8px; /* (56-40)/2 */
  left: 8px; /* (56-40)/2 */
  transition: transform 0.3s ease, opacity 0.3s ease;
  opacity: 0;
  transform: translateY(0);
  pointer-events: none;
}

.sub-button:disabled {
    background-color: #ccc;
    cursor: not-allowed;
}

#zoom-in-btn.visible {
  transform: translateY(-110px);
  opacity: 1;
  pointer-events: auto;
}

#zoom-out-btn.visible {
  transform: translateY(-60px);
  opacity: 1;
  pointer-events: auto;
}

/* Adjust zoom controls on mobile */
@media (max-width: 720px) {
  #zoom-controls {
    bottom: 110px; /* Higher to avoid multi-row panel */
  }
  
  .floating-panel.collapsed ~ #zoom-controls {
    bottom: 30px;
  }
}

/* Zoom level styles */
#poem {
  transition: font-size 0.3s ease;
}

.word, .word-input {
    font-size: 1em; /* Inherit from #poem */
}
.notes-box svg, .notes-box img, .notes-box-spacer {
    width: 3em;
    height: 2.5em;
}
.notes-box-spacer {
    visibility: hidden;
}
.notes-box.compound svg, .notes-box.compound img {
    width: 4.5em;
}
.notes-box.sixteenth svg, .notes-box.sixteenth img {
    width: 6em;
}
.circle {
    width: 1em;
    height: 1em;
}
.measure-divider, .final-measure-divider {
    height: 5em;
    top: 1.5em;
}

/* Base font-size for poem is 1.2em, so we adjust based on that */
#poem.zoom-level-0 { font-size: 0.9em; }  /* 1.2em * 0.75 = 0.9em */
#poem.zoom-level-1 { font-size: 1.2em; }  /* 1.2em * 1.0  = 1.2em (Default) */
#poem.zoom-level-2 { font-size: 1.32em; } /* 1.2em * 1.1  = 1.32em */
#poem.zoom-level-3 { font-size: 1.5em; }  /* 1.2em * 1.25 = 1.5em */
#poem.zoom-level-4 { font-size: 1.8em; }  /* 1.2em * 1.5  = 1.8em */
#poem.zoom-level-5 { font-size: 2.1em; }  /* 1.2em * 1.75 = 2.1em */


.words.sixteenth-chant {
    width: 6em;
    justify-content: space-between;
    position: relative;
    left: 0.3em;
}

.words.single-syllable-whole {
    justify-content: center;
}

.add-measure-btn {
    display: none;
    position: absolute;
    top: calc(50% + 12px); /* Position it below the delete button */
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: rgba(0, 128, 0, 0.7);
    color: white;
    border: 1px solid rgba(0, 100, 0, 0.9);
    border-radius: 50%;
    width: 22px;
    height: 22px;
    text-align: center;
    line-height: 20px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    font-family: 'Courier New', Courier, monospace;
    transition: all 0.2s ease;
    z-index: 1;
}

.final-measure-divider:hover .add-measure-btn {
    display: block;
}

.add-measure-btn:hover {
    background-color: rgba(0, 128, 0, 1);
}

/* Delete measure button on final divider */
.final-measure-divider {
    position: relative; /* Ensure the button is positioned relative to the divider */
}

/* Create a larger, invisible hover area */
.final-measure-divider::before {
    content: '';
    position: absolute;
    top: -10px;
    bottom: -10px;
    left: -10px;
    right: -10px;
    background-color: transparent; /* Make it invisible */
}

.delete-measure-btn {
    display: none; /* Hidden by default */
    position: absolute;
    top: calc(50% - 12px); /* Move it up */
    left: 50%;
    transform: translate(-50%, -50%); /* Center it perfectly */
    background-color: rgba(255, 0, 0, 0.7);
    color: white;
    border: 1px solid rgba(200, 0, 0, 0.9);
    border-radius: 50%;
    width: 22px;
    height: 22px;
    text-align: center;
    line-height: 20px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    font-family: 'Courier New', Courier, monospace;
    transition: all 0.2s ease;
    z-index: 1; /* Ensure button is on top of the pseudo-element */
}

.final-measure-divider:hover .delete-measure-btn {
    display: block; /* Show on hover */
}

.delete-measure-btn:hover {
    background-color: rgba(255, 0, 0, 1);
}

.words.triplet-chant {
    width: 4.5em;
    justify-content: space-between;
    position: relative;
    left: 0.3em;
}

.words.eighth-chant {
    width: 3em;
    justify-content: space-between;
    position: relative;
    left: 0.3em;
}

/* ===== ICON BUTTONS (Drawer & Panels) ===== */
.icon-btn {
  background-color: #f8f9fa;
  border: 1px solid #ced4da;
  cursor: pointer;
  padding: 4px 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  transition: all 0.2s ease;
  outline: none;
  min-width: 36px;
  height: 36px;
  color: #495057;
  user-select: none;
}

.icon-btn:hover {
  background-color: #e9ecef;
  border-color: #007bff;
  color: #007bff;
  transform: translateY(-1px);
}

.icon-btn:active {
  transform: translateY(1px);
}

.library-selector-group {
  display: flex;
  align-items: center;
}

.library-selector {
  min-width: 140px;
  max-width: 220px;
  height: 36px;
  padding: 4px 8px;
  border-radius: 6px;
  border: 1px solid #ced4da;
  background-color: #f8f9fa;
  font-size: 13px;
  font-weight: 600;
  color: #495057;
  cursor: pointer;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.library-selector:hover, .library-selector:focus {
  border-color: #007bff;
  box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.2);
}

/* ===== POPUP OVERLAY & MODAL SYSTEM ===== */
.popup-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100000;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease, visibility 0.25s ease;
}

.popup-overlay.show {
  opacity: 1;
  visibility: visible;
}

.popup-content {
  background: #fff;
  padding: 24px;
  border-radius: 12px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.25);
  width: 90%;
  max-width: 520px;
  transform: scale(0.94);
  transition: transform 0.25s ease;
  box-sizing: border-box;
}

.popup-overlay.show .popup-content {
  transform: scale(1);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.modal-header h3, .popup-content h3 {
  margin: 0;
  color: #212529;
  font-size: 18px;
  font-weight: 700;
}

.modal-close-btn {
  background: none;
  border: none;
  font-size: 24px;
  line-height: 1;
  color: #6c757d;
  cursor: pointer;
  padding: 0 4px;
  transition: color 0.2s ease;
}

.modal-close-btn:hover {
  color: #dc3545;
}

.popup-subtext {
  font-size: 13px;
  color: #6c757d;
  margin: 4px 0 16px 0;
  line-height: 1.4;
}

.song-title-input {
  width: 100%;
  padding: 10px 12px;
  border: 1.5px solid #ced4da;
  border-radius: 6px;
  font-size: 15px;
  color: #212529;
  box-sizing: border-box;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.song-title-input:focus {
  border-color: #007bff;
  box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.2);
}

.song-title-input.input-error {
  border-color: #dc3545 !important;
  box-shadow: 0 0 0 3px rgba(220, 53, 69, 0.25) !important;
}

@keyframes modalShake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-8px); }
  40%, 80% { transform: translateX(8px); }
}

.popup-content.shake {
  animation: modalShake 0.4s ease-in-out;
}

.popup-buttons {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  margin-top: 18px;
}

.popup-action-buttons {
  display: flex;
  gap: 10px;
  align-items: center;
}

.popup-btn {
  padding: 8px 16px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  transition: background-color 0.2s ease, transform 0.15s ease;
}

.popup-btn.cancel-btn {
  background-color: #6c757d;
  color: white;
}

.popup-btn.cancel-btn:hover {
  background-color: #5a6268;
}

.popup-btn.save-as-btn {
  background-color: #28a745;
  color: white;
}

.popup-btn.save-as-btn:hover {
  background-color: #218838;
}

.popup-btn.submit-btn {
  background-color: #007bff;
  color: white;
}

.popup-btn.submit-btn:hover {
  background-color: #0056b3;
}

.popup-btn:active {
  transform: scale(0.97);
}

/* ===== MANAGE LIBRARY MODAL ===== */
.manage-library-content {
  max-width: 540px;
}

.library-song-list {
  max-height: 280px;
  overflow-y: auto;
  border: 1.5px solid #dee2e6;
  border-radius: 8px;
  background: #f8f9fa;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.library-song-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #fff;
  border: 1px solid #dee2e6;
  border-radius: 6px;
  padding: 8px 12px;
  transition: all 0.2s ease;
}

.library-song-item:hover {
  border-color: #007bff;
  box-shadow: 0 2px 6px rgba(0, 123, 255, 0.12);
}

.library-song-item.active-song {
  border-color: #007bff;
  background: #f0f7ff;
}

.library-song-info {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
}

.library-song-badge {
  background: #007bff;
  color: white;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  flex-shrink: 0;
  transition: background-color 0.2s ease;
}

.library-song-badge.badge-poetry {
  background-color: #007bff; /* Blue for Poetry */
}

.library-song-badge.badge-rhythm {
  background-color: #28a745; /* Green for Rhythm */
}

.library-song-title {
  font-size: 14px;
  font-weight: 600;
  color: #212529;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.library-song-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.lib-action-btn {
  padding: 4px 10px;
  border: 1px solid #ced4da;
  border-radius: 4px;
  background: #fff;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  color: #495057;
  transition: all 0.2s ease;
}

.lib-action-btn:hover {
  background: #e9ecef;
  color: #212529;
  border-color: #adb5bd;
}

.lib-action-btn.load-btn {
  background-color: #007bff;
  color: white;
  border-color: #007bff;
}

.lib-action-btn.load-btn:hover {
  background-color: #0069d9;
}

.lib-action-btn.delete-btn-item {
  color: #dc3545;
  font-size: 14px;
  line-height: 1;
  padding: 4px 8px;
  font-weight: 700;
}

.lib-action-btn.delete-btn-item:hover {
  background-color: #dc3545;
  color: white;
  border-color: #dc3545;
}

/* ===== IMPORT / EXPORT MODAL STYLES ===== */
.import-export-content {
  max-width: 580px;
  max-height: 88vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.modal-section-card {
  background: #f8f9fa;
  border: 1.5px solid #dee2e6;
  border-radius: 8px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.modal-section-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  font-weight: 700;
  color: #212529;
}

.section-desc {
  font-size: 13px;
  color: #6c757d;
  margin: 0;
  line-height: 1.3;
}

.share-link-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.share-link-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  background-color: #6f42c1;
  color: white;
  font-size: 13px;
  padding: 8px 14px;
}

.share-link-btn:hover {
  background-color: #59339d;
}

.share-link-input-container {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 4px;
}

.share-link-input-wrap {
  display: flex;
  align-items: center;
  background: #fff;
  border: 1.5px solid #ced4da;
  border-radius: 6px;
  overflow: hidden;
}

.share-link-input {
  flex: 1;
  border: none;
  outline: none;
  padding: 6px 10px;
  font-size: 13px;
  color: #495057;
  background: #fff;
  text-overflow: ellipsis;
}

.copy-link-btn {
  background-color: #007bff;
  color: white;
  font-size: 12px;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: 0;
  white-space: nowrap;
}

.copy-link-btn:hover {
  background-color: #0069d9;
}

.copy-link-btn.copied {
  background-color: #28a745;
}

.share-link-feedback {
  font-size: 12px;
  font-weight: 600;
  color: #28a745;
}

.upload-action-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.upload-trigger-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  background-color: #28a745;
  color: white;
  font-size: 13px;
  padding: 8px 14px;
}

.upload-trigger-btn:hover {
  background-color: #218838;
}

.upload-status-msg {
  font-size: 13px;
  font-weight: 600;
  color: #28a745;
}

.upload-status-msg.error {
  color: #dc3545;
}

.export-selection-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 4px;
}

.export-select-tools {
  display: flex;
  gap: 8px;
}

.text-tool-btn {
  background: none;
  border: none;
  color: #007bff;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
}

.text-tool-btn:hover {
  color: #0056b3;
}

.export-song-list {
  max-height: 170px;
  overflow-y: auto;
  border: 1px solid #ced4da;
  border-radius: 6px;
  background: #fff;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.export-song-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px;
  border-radius: 4px;
  cursor: pointer;
  user-select: none;
  transition: background-color 0.15s ease;
}

.export-song-item:hover {
  background-color: #f0f7ff;
}

.export-song-item input[type="checkbox"] {
  display: inline-block !important;
  width: 16px;
  height: 16px;
  cursor: pointer;
}

.export-song-item-info {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
}

.export-song-title {
  font-size: 14px;
  font-weight: 500;
  color: #212529;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.export-filename-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 2px;
}

.filename-label {
  font-size: 13px;
  font-weight: 600;
  color: #495057;
  flex-shrink: 0;
}

.filename-input-wrap {
  display: flex;
  align-items: center;
  flex: 1;
  background: #fff;
  border: 1.5px solid #ced4da;
  border-radius: 6px;
  overflow: hidden;
}

.export-filename-input {
  flex: 1;
  border: none;
  outline: none;
  padding: 6px 10px;
  font-size: 14px;
  font-weight: 500;
  color: #212529;
}

.filename-ext {
  padding: 0 10px;
  background: #e9ecef;
  color: #6c757d;
  font-size: 13px;
  font-weight: 600;
  line-height: 32px;
  user-select: none;
}

.export-download-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  margin-top: 4px;
}

/* ===== RESET ALL USER DATA ===== */
.reset-data-card {
  border-color: #f8d7da !important;
  background: #fff8f8;
}

.reset-title {
  color: #dc3545 !important;
}

.reset-data-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.delete-all-data-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  background-color: #dc3545;
  color: white;
  font-size: 13px;
  font-weight: 600;
  padding: 8px 14px;
}

.delete-all-data-btn:hover {
  background-color: #bd2130;
}

.reset-status-msg {
  font-size: 13px;
  font-weight: 600;
  color: #dc3545;
}

.reset-status-msg.success {
  color: #28a745;
}
