body {
  font-family: Arial, sans-serif;
  background: #f7f7fb;
  color: #222;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}
header, footer {
  background: #4b2e83;
  color: #fff;
  text-align: center;
  padding: 1em 0;
}
main {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

/* Collapsible Sections */
.collapsible-section {
  width: 100%;
  max-width: 400px;
  margin: 0.5em auto;
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 8px;
  overflow: hidden;
}

.collapsible-section summary {
  padding: 0.8em 1em;
  background: #f5f5f5;
  cursor: pointer;
  font-weight: 600;
  color: #4b2e83;
  display: flex;
  align-items: center;
  justify-content: space-between;
  user-select: none;
  list-style: none;
}

.collapsible-section summary::-webkit-details-marker {
  display: none;
}

.collapsible-section summary::after {
  content: '▶';
  font-size: 0.8em;
  transition: transform 0.2s;
}

.collapsible-section[open] summary::after {
  transform: rotate(90deg);
}

.collapsible-section summary:hover {
  background: #ebebeb;
}

.collapsible-section .section-content {
  padding: 1em;
}

#note-display {
  max-width: 400px;
}
#note-display .section-content {
  text-align: center;
}
#frequency {
  font-size: 2.5em;
  margin-bottom: 0.5em;
}
#string-name {
  font-size: 2em;
  color: #4b2e83;
}

#averages {
  margin-top: 1em;
  font-size: 1.1em;
  color: #333;
}
#averages span {
  display: inline-block;
  min-width: 4em;
}

#freq-graph {
  display: block;
  margin: 0 auto;
  background: #f0f0f0;
  border: 1px solid #ccc;
  border-radius: 6px;
}
#volume-section {
  max-width: 400px;
}
#volume-section .section-content {
  text-align: center;
}
#volume-bar-container {
  width: 100%;
  height: 28px;
  margin: 0.5em 0 1em 0;
  position: relative;
}
#volume-bar-bg {
  width: 100%;
  height: 16px;
  background: #e0e0e0;
  border-radius: 8px;
  position: relative;
  overflow: hidden;
}
#volume-bar {
  height: 100%;
  background: #4b2e83;
  border-radius: 8px 0 0 8px;
  width: 0%;
  transition: width 0.1s;
}
#threshold-marker {
  position: absolute;
  top: -4px;
  width: 2px;
  height: 24px;
  background: #ff9800;
  left: 20%; /* Default at 20% */
  transition: left 0.1s;
}
/* Input source dropdown */
#input-source {
  font-size: 1em;
  padding: 0.3em 1em;
  margin: 0 0.5em;
  border-radius: 0.3em;
  border: 1px solid #ccc;
}

/* Tuning Table Layout */
#tuning-table-container {
  max-width: 400px;
}
#tuning-table {
  width: 100%;
  border-collapse: collapse;
}
#tuning-table th, #tuning-table td {
  padding: 0.4em 0.6em;
  text-align: center;
}
#tuning-table th {
  background: #e9eaf6;
  color: #333;
  font-weight: 600;
}
#tuning-table tr:nth-child(even) td {
  background: #f5f6fa;
}
.freq {
  font-size: 0.95em;
  color: #888;
}

.proximity-bar {
  width: 120px;
  height: 18px;
  background: linear-gradient(
    to right,
    #e0e0e0 0%,
    #e0e0e0 49%,
    #666 49%,
    #666 51%,
    #e0e0e0 51%,
    #e0e0e0 100%
  );
  border-radius: 9px;
  margin: 0 auto;
  position: relative;
  overflow: visible;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}
/* +/- labels under the bar */
.proximity-bar::before,
.proximity-bar::after {
  position: absolute;
  bottom: -16px;
  font-size: 0.9em;
  color: #666;
}
.proximity-bar::before {
  content: '-';
  left: 2px;
}
.proximity-bar::after {
  content: '+';
  right: 2px;
}

.proximity-diff {
  position: absolute;
  bottom: -32px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.85em;
  color: #444;
  white-space: nowrap;
}
/* Movable indicator */
.proximity-indicator {
  position: absolute;
  top: 1px;
  width: 6px;
  height: 16px;
  background: #4b2e83;
  border-radius: 3px;
  box-shadow: 0 0 2px #2222;
  z-index: 3;
  transition: left 0.15s cubic-bezier(.4,2,.6,1);
  border: 2px solid #fff;
}
.proximity-bar.in-tune .proximity-indicator {
  background: #27ae60;
}
.proximity-bar.too-low .proximity-indicator {
  background: #f1c40f;
}
.proximity-bar.too-high .proximity-indicator {
  background: #c0392b;
}

/* ===== Dark Mode ===== */
@media (prefers-color-scheme: dark) {
  body {
    background: #1a1a2e;
    color: #e0e0e0;
  }
  
  header, footer {
    background: #2d1f4e;
  }
  
  .collapsible-section {
    background: #252538;
    border-color: #444;
  }
  
  .collapsible-section summary {
    background: #353550;
    color: #9d7fd4;
  }
  
  .collapsible-section summary:hover {
    background: #404060;
  }
  
  #string-name {
    color: #9d7fd4;
  }
  
  #averages {
    color: #bbb;
  }
  
  #freq-graph {
    background: #2a2a3a;
    border-color: #444;
  }
  
  #volume-bar-bg {
    background: #3a3a4a;
  }
  
  #volume-bar {
    background: #7c5cbf;
  }
  
  #input-source {
    background: #2a2a3a;
    color: #e0e0e0;
    border-color: #555;
  }
  
  #tuning-table-container {
    background: #252538;
    border-color: #444;
  }
  
  #tuning-table th {
    background: #353550;
    color: #ddd;
  }
  
  #tuning-table tr:nth-child(even) td {
    background: #2d2d40;
  }
  
  #tuning-table td {
    color: #ccc;
  }
  
  .freq {
    color: #888;
  }
  
  .proximity-bar {
    background: linear-gradient(
      to right,
      #3a3a4a 0%,
      #3a3a4a 49%,
      #888 49%,
      #888 51%,
      #3a3a4a 51%,
      #3a3a4a 100%
    );
  }
  
  .proximity-bar::before,
  .proximity-bar::after {
    color: #888;
  }
  
  .proximity-diff {
    color: #aaa;
  }
  
  .proximity-indicator {
    background: #7c5cbf;
    border-color: #333;
  }
}
