body { margin: 0; padding: 46px 0 0 0;  }
#poem { font-size: 1.2em; line-height: 1.5em; padding: 10px; }
.line {
  display: flex; /* Use flexbox for alignment */
  align-items: center; /* Vertically center items in the line */
  margin-bottom: 7px;
  justify-content: center; /* Horizontally center the content */
}

.sound-selector {
  display: flex;
  align-items: center;
  margin-right: 15px;
  min-width: 108px; /* Give it a fixed width */
  justify-content: space-between;
}

.selector-button {
  background-color: #f0f8ff;
  border: 1px solid #007bff;
  border-radius: 50%; /* Make it circular */
  width: 30px;
  height: 30px;
  font-size: 16px;
  font-weight: bold;
  color: #007bff;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

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

.sound-image {
  width: 58px;
  height: 58px;
  object-fit: contain;
  cursor: pointer;
}

.sound-image.muted {
  filter: grayscale(100%);
}

.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 { width: 6em; }
.beat-bar {
  display: flex;
  height: 10px;
  width: 2.4em;
  background-color: #e0e0e0;
  border: 1px solid #c0c0c0;
  border-radius: 4px;
  margin: 0 auto 4px auto; /* Center the bar and give space below */
  overflow: hidden;
  cursor: pointer;
  transition: opacity 0.3s ease;
}
.beat-bar.hidden {
  opacity: 0;
  pointer-events: none;
}
.group.sixteenth .beat-bar {
    width: 5.25em;
}
.group.sixteenth .words {
    width: 5.4em;
}
.beat-bar-half {
  width: 50%;
  height: 100%;
  transition: background-color 0.1s ease;
}
.beat-bar-half.active {
  background-color: #ff8c00; /* Vibrant Orange */
}
.words { 
  display: flex; 
  justify-content: space-between; 
  width: 2.65em; 
  margin: 0 auto; 
  transform: translateX(-0.156em);
}
.words.center-text {
  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 */
.floating-panel { 
  position: fixed; 
  bottom: 0; 
  left: 0; 
  right: 0; 
  height: 60px; 
  background-color: #e6f3ff; 
  border-top: 2px solid #0066cc; 
  display: flex; 
  align-items: center; 
  justify-content: center; 
  gap: 15px;
  padding: 0 20px; 
  z-index: 1000;
  transition: bottom 0.3s ease-in-out;
}

.floating-panel.collapsed {
  bottom: -50px;
}

/* Panel Toggle Button */
.panel-toggle-button {
  position: fixed;
  bottom: 60px; /* Positioned on top of the panel's border */
  left: 50%;
  transform: translateX(-50%);
  width: 40px;
  height: 20px;
  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;
  transition: bottom 0.3s ease-in-out;
}

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

.panel-toggle-button.collapsed {
  bottom: 10px; /* Moves with the panel but stays visible */
}

.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;
}

.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 */
.lyrics-dropdown {
  /* Inherits styles from .control-button */
}

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

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

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

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

.icon-beat-bar {
  width: 16px;
  height: 6px;
  border-radius: 2px;
}

.icon-button.active .icon-beat-bar {
  background-color: #ff8c00; /* Vibrant Orange */
}

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

/* Time signature button */
.ts-button-wrapper {
  position: relative;
}
.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: #f0f8ff;
  border: 1px solid #007bff;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 20px;
  color: #007bff;
}

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

.play-button.playing {
  background-color: #007bff;
  color: white;
}

/* Paragraph Button */
.paragraph-button {
    font-size: 20px;
    padding: 0 15px;
}

/* 16th Note Button */
.sixteenth-note-button { padding: 0 8px; }
.sixteenth-note-button img { height: 80%; filter: grayscale(1); opacity: 0.7; transition: all 0.2s ease; }
.sixteenth-note-button.active { background-color: #28a745; }
.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; }



/* Modal Styles */
.modal-backdrop {
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.4);
    display: flex;
    justify-content: center;
    align-items: center;
    visibility: hidden;
    opacity: 0;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.modal-backdrop.visible {
    visibility: visible;
    opacity: 1;
}

.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;
}

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

.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;
}

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

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

/* Toggle Button Group */
.toggle-button-group {
  display: grid;
  grid-template-columns: repeat(2, 60px);
  grid-template-rows: repeat(2, 24px);
  gap: 0;
}

.toggle-button {
  padding: 5px;
  border: 1px solid #ccc;
  border-radius: 4px;
  background-color: #f0f0f0;
  cursor: pointer;
  font-size: 12px;
  font-family: Arial, sans-serif;
  display: flex;
  align-items: center;
  justify-content: center;
}

.toggle-button.active {
  color: white;
}

.toggle-button.beat-button.active,
#count-button.active {
  background-color: #007bff;
  border-color: #0056b3;
}

.toggle-button.rhythm-button.active {
  background-color: #28a745;
  border-color: #1e7e34;
}

#one-button.color-1 { background-color: #ffc107; border-color: #d39e00; color: #212529; }
#one-button.color-2 { background-color: #fd7e14; border-color: #c7610a; color: white; }
#one-button.color-3 { background-color: #28a745; border-color: #1e7e34; color: white; }
#one-button.color-4 { background-color: #dc3545; border-color: #b02a37; color: white; }

/* Responsive adjustments for smaller screens */
@media (max-width: 720px) {
  .floating-panel {
    height: 90px; /* Reduced height */
    display: grid;
    grid-template-areas:
      "play ts note para camera circle"
      ". bpm toggle-group lyrics . .";
    grid-template-columns: 1fr repeat(4, auto) 1fr;
    grid-template-rows: auto auto;
    gap: 5px 10px; /* Reduced row gap */
    padding: 5px 10px; /* Reduced top/bottom padding */
    align-items: center;
    justify-content: center;
  }

  .floating-panel.collapsed {
    bottom: -90px; /* Adjusted for new height */
  }

  .panel-toggle-button {
    bottom: 100px; /* Sit on top of the 100px panel */
  }
  
  .panel-toggle-button.collapsed {
    bottom: 10px; /* Sit on top of the visible part of the collapsed panel */
  }

  /* Assign items to grid areas */
  #play-button { grid-area: play; justify-self: end; }
  .ts-button-wrapper { grid-area: ts; }
  #sixteenth-note-btn { grid-area: note; }
  #paragraph-btn { grid-area: para; }
  #copy-visual-btn { grid-area: camera; }
  #circle-icon { grid-area: circle; justify-self: start; }
  #bpm-button { grid-area: bpm; justify-self: end; }
  .toggle-button-group { grid-area: toggle-group; }
  #lyrics-dropdown { grid-area: lyrics; justify-self: start;}

  /* Ensure all direct children of the panel are considered grid items */
  .floating-panel > * {
    min-width: 0;
  }
}

/* Zoom Controls */
#zoom-controls {
  position: fixed;
  bottom: 20px;
  left: 20px;
  z-index: 1002;
}

.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;
}

/* 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 {
    width: 3em;
    height: 2.5em;
}
.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 */

/* Lyrics dropdown */
.lyrics-dropdown {
  -webkit-appearance: none;
  appearance: none;
  background-color: transparent;
  border: none;
  font-family: inherit;
  font-size: 14px;
  font-weight: bold;
  color: #007bff;
  padding: 0 8px;
  cursor: pointer;
  width: 100%;
  height: 100%;
}

.control-button:has(> .lyrics-dropdown) {
  padding: 0;
}

/* Rhythm System Fonts */
#poem[data-rhythm-system="simple-kodaly"] .word,
#poem[data-rhythm-system="beat-centered-kodaly"] .word {
  font-family: 'Lexend', sans-serif;
}

#poem[data-rhythm-system="fruit-rhythms"] .word {
  font-family: 'Caveat', cursive;
  font-size: 1.3em;
}

#poem[data-rhythm-system="gordon-system"] .word {
  font-family: 'Permanent Marker', cursive;
  line-height: 1;
}

#poem[data-rhythm-system="takadimi-system"] .word {
  font-family: "Comic Sans MS", cursive, sans-serif;
}
