:root {
  --mono-font: "Courier New", monospace;
  --chord-color: #1a4da3;
  --chords-hidden-line-height: 0.8; /* line-height of song text when chord lines are hidden */
}

.chords-hidden pre {
  line-height: var(--chords-hidden-line-height);
}

/* Always reserve scrollbar space to prevent layout shift on scroll start/stop */
html {
  overflow-y: scroll;
}

/* Base */
body {
  font-family: Arial, sans-serif;
  background: #fafafa;
  padding: 20px;
  width: fit-content;
  max-width: calc(100vw - 40px);
  margin: auto;
  line-height: 1.2;
}

/* In split mode: full viewport, no padding/margin gutters */
body.split-mode {
  max-width: none;
  padding: 0;
  margin: 0;
  width: 100%;
}

h1 {
  text-align: center;
}

pre {
  white-space: pre;
  font-family: var(--mono-font);
}

.score {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 0.6em 0;
}

table {
  border-collapse: collapse;
  width: 100%;
  max-width: 800px;
}
th, td {
  border: 1px solid #ccc;
  padding: 4px 12px;
  text-align: left;
}
th { background-color: #f4f4f4; }

a { color: #0366d6; text-decoration: none; }
a:hover { text-decoration: underline; }

/* Chord lines */
.chordline {
  font-family: var(--mono-font);
  color: var(--chord-color);
  font-weight: bold;
  display: none;           /* JS sets to inline-block for the active group */
  padding: 0 0 0 0px;
  line-height: 1;
  vertical-align: -0.25em;
}

/* Single-mode controls: sticky top bar (mirrors paneControls style) */
#controls {
  position: sticky;
  top: 0;
  background: rgba(255, 255, 255, 0.98);
  padding: 8px;
  border-radius: 10px;
  border: 1px solid #ddd;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  z-index: 99999;
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;

  transition: opacity 0.25s ease;
}
#controls button {
  padding: 6px 10px;
  font-size: 14px;
  border-radius: 7px;
}
#startstop {
  min-width: 4em;
}

/* Split-mode: hide master controls entirely (each pane has its own toolbar) */
body.split-mode #controls {
  display: none !important;
}

/* Hide / show master-menu buttons based on mode */
body.split-mode #controls .only-single { display: none !important; }
body:not(.split-mode) #controls .only-split { display: none !important; }

/* Edit/New/Rebuild buttons — pushed to the right end of the controls bar */
#editButtons {
  margin-left: auto;
  display: flex;
  gap: 6px;
}

/* Transpose buttons row — force onto its own line, buttons fill available width */
#transposeButtons {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  width: 100%;
}
#transposeButtons button {
  flex: 1;
}
.speed-btn {
  width: 3em;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
#transposeButtons button.active {
  background-color: #1a4da3;
  color: white;
}

/* Speed indicator toast */
#speedIndicator {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(0, 0, 0, 0.7);
  color: #fff;
  font-size: 3em;
  font-weight: bold;
  padding: 0.3em 0.6em;
  border-radius: 12px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s ease;
  z-index: 999999;
}
#speedIndicator.visible {
  opacity: 1;
}

/* Full auto-hide */
#controls.fullyHidden {
  opacity: 0;
  pointer-events: none;
}

/* Split view layout */
#splitContainer {
  display: none;                     /* hidden until enabled */
  grid-template-columns: 1fr 1fr;    /* keep 50/50; total width is controlled by --split-width */
  gap: 12px;
  width: var(--split-width, 100vw); /* dynamic total width */
  max-width: none;                   /* allow to grow beyond body max-width in split mode */
  margin: 0 auto;                    /* center the split area */
  padding-right: 0;
}
#splitContainer.active {
  display: grid;
}

.split-pane {
  height: 100vh;                  /* full viewport height for independent scrolling */
  overflow: auto;
  background: #fff;
  border: 1px solid #e6e6e6;
  border-radius: 8px;
  padding: 8px 10px 10px 10px;
  position: relative;

  /* Allow the grid column to shrink */
  min-width: 0;
}
.split-pane .paneContent {
  /* Let content expand/contract with the pane */
  max-width: none;
  width: 100%;
  margin: 0;
}

/* Per-pane toolbar (auto-hide in split mode) */
.paneControls {
  position: sticky;
  top: 6px;
  z-index: 10;
  background: rgba(255, 255, 255, 0.98);
  border: 1px solid #ddd;
  border-radius: 10px;
  padding: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  transition: opacity 0.2s ease;
}
.paneControls button {
  padding: 6px 10px;
  font-size: 14px;
  border-radius: 7px;
}

/* Transpose buttons row inside pane toolbar */
.paneTransposeButtons {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  width: 100%;
}
.paneTransposeButtons button {
  flex: 1;
}
.paneTransposeButtons button.active {
  background-color: #1a4da3;
  color: white;
}

/* Hidden state for per-pane toolbar */
.paneControls.hidden {
  opacity: 0;
  pointer-events: none;
}

/* Optional: on very small screens, stack panes */
@media (max-width: 900px) {
  #splitContainer {
    grid-template-columns: 1fr;
  }
}

/* TOC page controls bar */
#toc-controls {
  position: sticky;
  top: 0;
  background: rgba(255, 255, 255, 0.98);
  padding: 8px;
  border-radius: 10px;
  border: 1px solid #ddd;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  z-index: 99999;
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  margin-bottom: 8px;
  transition: opacity 0.25s ease;
}
#toc-controls.fullyHidden {
  opacity: 0;
  pointer-events: none;
}
#toc-nav-links {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
}
#toc-nav-links a {
  padding: 6px 10px;
  font-size: 14px;
  border-radius: 7px;
  border: 1px solid #ccc;
  text-decoration: none;
  color: #333;
  background: #f4f4f4;
}
#toc-nav-links a:hover { background: #e0e0e0; }
#toc-nav-links a.current {
  background: #1a4da3;
  color: white;
  border-color: #1a4da3;
}
#toc-edit-buttons {
  margin-left: auto;
  display: flex;
  gap: 6px;
}
#toc-controls button {
  padding: 6px 10px;
  font-size: 14px;
  border-radius: 7px;
}

/* Song editor overlay */
#editorOverlay {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 999998;
  align-items: center;
  justify-content: center;
}
#editorOverlay.active {
  display: flex;
}
#editorBox {
  background: #fff;
  border-radius: 10px;
  padding: 20px;
  width: 80vw;
  max-width: 860px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.35);
}
#editorBox h2 {
  margin: 0;
  font-size: 1.1em;
  font-family: Arial, sans-serif;
}
#editorTextarea {
  font-family: "Courier New", monospace;
  font-size: 13px;
  resize: vertical;
  border: 1px solid #ccc;
  border-radius: 6px;
  padding: 8px;
  height: 60vh;
  overflow: auto;
  white-space: pre;
}
#editorStatus {
  font-family: Arial, sans-serif;
  font-size: 13px;
  min-height: 1.4em;
  color: #1a4da3;
}
#editorButtons {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}
#editorButtons button {
  padding: 7px 18px;
  font-size: 14px;
  border-radius: 7px;
  cursor: pointer;
}

