body { margin: 0; padding: 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; height: 80px; background-color: #666; margin: 0 8px; vertical-align: top; position: relative; top: 24px; }
.final-measure-divider { display: inline-block; width: 6px; height: 80px; 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; top: 24px; }
.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 { background-color: #ffff99; border-radius: 4px; }
.notes-box svg, .notes-box img { width: 48px; height: 40px; margin: 0 4px; }
.notes-box.compound svg, .notes-box.compound img {
  width: 72px; 
}
.notes-box.sixteenth svg, .notes-box.sixteenth img {
  width: 96px;
}
.circles { display: flex; justify-content: center; margin-bottom: 4px; border: 1px solid #c0c0c0; padding: 6px 8px; background-color: #f5f5f5; border-radius: 8px; transition: opacity 0.3s ease; }
.circles.hidden { opacity: 0; pointer-events: none; }
.circles.pickup {
    background-color: #90EE90; /* Brighter Green */
}
.circle { width: 16px; height: 16px; margin: 0 2px; border-radius: 50%; background-color: grey; cursor: pointer; }
.circle.active { background-color: #007bff; }
.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 */
.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-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;
}
.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;
}


/* Audio checkboxes */
.audio-controls {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 500;
}

.checkbox-row input[type="checkbox"] {
  width: 14px;
  height: 14px;
  accent-color: #28a745; /* Green for beat */
}

.checkbox-row.rhythm input[type="checkbox"] {
  accent-color: #007bff; /* Blue for rhythm */
}

.checkbox-row label {
  color: #333;
  cursor: pointer;
  user-select: none;
}

.checkbox-row.beat label {
  color: #28a745;
}

.checkbox-row.rhythm label {
  color: #007bff;
}

/* 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;
}

/* 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 audio-ctrl 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; }
  .audio-controls { grid-area: audio-ctrl; }
  #lyrics-dropdown { grid-area: lyrics; justify-self: start;}

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