/* =========================
   THEME VARIABLES
========================= */

/* Default = LIGHT */
:root {
  --bg: #f6f7f9;
  --text: #111;

  --toolbar-bg: #d8dade;
  --panel-bg: #ffffff;

  --button-bg: #e5e7ea;
  --button-text: #111;

  --tab-bg: #e0e3e8;
  --tab-hover: #cfd3d8;
  --tab-active: #ffffff;

  --border: #ccc;
  --border-light: #eee;

  --accent: #007aff;

  --note-color: #000;
}

/* DARK THEME */
:root[data-theme="dark"] {
  --bg: #111418;
  --text: #f2f3f4;

  --toolbar-bg: #1c1f24;
  --panel-bg: #1c1f24;

  --button-bg: #2b2f36;
  --button-text: #eee;

  --tab-bg: #1c1f24;
  --tab-hover: #2b2f36;
  --tab-active: #333842;

  --border: #444;
  --border-light: #2a2a2a;

  --accent: #3ea6ff;

  --note-color: #fff;
}

/* =========================
   BASE
========================= */

html, body {
  margin: 0;
  font-family: system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
}

/* Smooth transitions AFTER load */
html.ready *, body.ready * {
  transition:
    background-color 0.3s ease,
    color 0.3s ease,
    border-color 0.3s ease;
}

/* =========================
   TABS
========================= */

#tabBar {
  display: flex;
  background: var(--tab-bg);
  border-bottom: 1px solid var(--border);
}

#tabBar button {
  flex: 1;
  background: var(--tab-bg);
  color: var(--text);
  border: none;
  padding: 8px 0;
  cursor: pointer;
  border-bottom: 2px solid transparent;
}

#tabBar button:hover {
  background: var(--tab-hover);
  color: var(--accent);
}

#tabBar button.active {
  background: var(--tab-active);
  color: var(--accent);
  border-bottom: 2px solid var(--accent);
}

/* =========================
   TOOLBAR (clean version)
========================= */

.practice-group {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
}

.nav-center {
  justify-content: center;
}

/* row 1 */
.toolbar-row.top {
  position: relative;
}

.left-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* row 2 */
.toolbar-row.bottom {
  position: relative;
  justify-content: space-between;
}

.toolbar-row.playback.nav-row {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
}

.nav-left {
  justify-self: start;
}

.nav-center {
  justify-self: center;
}

.nav-right {
  justify-self: end;
}

.playback-group {
  display: flex;
  flex-direction: column;
  align-items: center;   /* ← centers label + buttons horizontally */
  gap: 4px;              /* optional spacing */
}

.transport {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 8px;
}

.right-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* =========================
   BUTTONS
========================= */

button {
  background: var(--button-bg);
  color: var(--button-text);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 6px 10px;
  cursor: pointer;
}

button:hover {
  background: var(--tab-hover);
  color: var(--accent);
}

button:disabled {
  opacity: 0.5;
  pointer-events: none;
}

/* play highlight */
#playPauseBtn.playing {
  box-shadow: 0 0 6px var(--accent);
}

/* =========================
   MODE SEGMENT
========================= */

.mode-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.mode-segment {
  display: flex;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}

.mode-segment button {
  border: none;
  padding: 5px 10px;
  background: var(--button-bg);
  color: var(--button-text);
}

.mode-segment button.active {
  background: var(--accent);
  color: #fff;
}

.mode-label {
  font-size: 12px;
  color: var(--text);
  text-align: center;
  width: 100%;
}

/* SECTION BOX */
.settings-section {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  margin-top: 16px;
  max-width: 420px;
}

/* SECTION TITLE */
.section-title {
  font-weight: 600;
  margin-bottom: 10px;
  color: var(--text);
}

/* ROWS */
.form-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
  flex-wrap: nowrap;
}

.form-row label {
  width: 70px;
}

.form-row select {
  min-width: 110px;
}

.slider-row label {
  min-width: 140px;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;        /*  prevents it from collapsing */
  min-width: 120px;
}

.checkbox-row span {
  white-space: nowrap;   /*  prevents Count-in from breaking */
}

.checkbox-label {
  white-space: nowrap; /* prevents Count- / in split */
}

/* SUBTEXT */
.subtext {
  font-size: 12px;
  opacity: 0.7;
  margin-left: 22px; /* aligns under checkbox text */
}

/* SLIDER ROW (fix spacing issue) */
.slider-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 6px;
}

.slider-row input[type="range"] {
  flex: 1;
  max-width: 160px;
}

input[type="checkbox"] {
  margin-right: 6px;
}
/* =========================
   STATUS
========================= */

#statusMsg {
  font-size: 13px;
  color: var(--text);
}

#statusMsg.playing {
  color: #4caf50;
}

/* =========================
   TABLE (results)
========================= */

#resultsTable {
  border-collapse: collapse;
  width: 100%;
}

#resultsTable th,
#resultsTable td {
  border: 1px solid var(--border);
  padding: 6px 10px;
  text-align: center;
}

#resultsTable th {
  background: var(--toolbar-bg);
}

/* =========================
   LIBRARY SELECT
========================= */

.library-control {
  display: flex;
  align-items: center;
  gap: 6px;
}

.library-label {
  font-size: 13px;
}

#librarySelect {
  background: var(--button-bg);
  color: var(--button-text);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 5px 8px;
}

/* =========================
   UTIL COLORS
========================= */
.correct {
  color: #00c853 !important;
  fill: #00c853;
  stroke: #00c853;
}

.early {
  color: #ffb300 !important;
  fill: #ffb300;
  stroke: #ffb300;
}

.late {
  color: #ff9800 !important;
  fill: #ff9800;
  stroke: #ff9800;
}

.wrong {
  color: #ff5252 !important;
  fill: #ff5252;
  stroke: #ff5252;
}

.miss {
  color: #888 !important;
  fill: #888;
  stroke: #888;
}

/* Results table colors */
#resultsTable td.red {
  color: #ff5252;
}

#resultsTable td.green {
  color: #00c853;
}

#resultsTable td.yellow {
  color: #ffb300;
}

/* =========================
   TAB PANES
========================= */

.tab-pane {
  display: none;
  height: calc(100% - 2em);
}

.tab-pane.active {
  display: block;
}

/* Base theme color for score */
#osmdCanvasPage1 svg {
  color: var(--note-color);
}

/* Only override elements that DON'T already have a result class */
#osmdCanvasPage1 svg *:not(.correct):not(.wrong):not(.early):not(.late):not(.miss) {
  fill: currentColor;
  stroke: currentColor;
}
/*.pulse-note {*/
  /*animation-name: pulseHold;*/
  /*animation-timing-function: ease-out;*/
  /*transform-origin: center;*/
  /*transform-box: fill-box;*/
  /*animation-fill-mode: none; /* ensures clean reset */*/
  /*will-change: transform;*/
/*}*/
.pulse-note {
  animation-name: pulseHold;
  animation-timing-function: ease-out;
  will-change: transform;
}
@keyframes pulseHold {
  0%   { stroke-width: 1; filter: brightness(1); }
  20%  { stroke-width: 3; filter: brightness(1.8); }
  80%  { stroke-width: 3; filter: brightness(1.8); }
  100% { stroke-width: 1; filter: brightness(1); }
}
/*@keyframes pulseHold {*/
  /*0%   { transform: scale(1); }*/
  /*20%  { transform: scale(1.3); }*/
  /*80%  { transform: scale(1.3); }*/
  /*100% { transform: scale(1); }*/
/*}*/
.vf-note path.pulse-note {
  transform-box: fill-box;
  transform-origin: center;
}
#resetTempo {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  color: var(--text-color);
}

#resetTempo:hover {
  color: orange;
}

#resetTempo:disabled {
  opacity: 0.4;
  cursor: default;
}

#tempo.tempo-overridden {
  color: white;
  border-color: orange;
  box-shadow: 0 0 6px rgba(255,165,0,0.5);
  background-color: rgba(83,92,84,0.7);
}
.nowrap {
  white-space: nowrap;
}

#partIndicator {
  min-width: 90px;
  text-align: center;
}

.action-row {
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
}

.perform-group,
.listen-group,
.tempo-group {
  display: flex;
  align-items: center;
}

#toolbar button,
#toolbar select,
#toolbar input {
  padding-top: 3px;
  padding-bottom: 3px;
}

#toolbar button {
  padding: 2px 8px;
  height: 28px;
}

#toolbar select,
#toolbar input {
  /*height: 24px;*/
}

.action-row {
  gap: 1px;
}

.perform-group,
.listen-group {
  height: 28px;
}

#recordBtn.recording:disabled {
  opacity: 1;          /* keep children controllable */
}

#recordBtn.recording #recordIcon {
  color: red;
  opacity: 1;
}

#recordBtn.recording #recordText {
  opacity: 0.3;
}

#recordIcon {
  font-size: 1.6em;
}
.listenMode.active {
  background: #2b7cff;
  color: white;
  box-shadow: inset 0 0 4px #000;
}
#toolbar {
  padding: 6px 12px;
}

.toolbar-row {
  display: flex;
  align-items: center;
  min-height: 30px;
  margin: 2px 0;
}


/* Shared label column */

.section-label {
  width: 102px;
  flex: 0 0 102px;
  box-sizing: border-box;

  text-align: right;
  white-space: nowrap;

  margin-right: 0;
}


/* Score source */

.library-control {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-left: 8px;
}


/* Part navigation */
.part-nav {
  display: flex;
  align-items: center;
  gap: 4px;
}

#partIndicator {
  min-width: 92px;
  text-align: center;
}


/* Perform and Listen */

.action-row {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
}

.perform-group,
.listen-group {
  display: flex;
  align-items: center;
  gap: 6px;
}



/* Tempo and status */

.bottom-row {
  justify-content: space-between;
}

.tempo-group {
  display: flex;
  align-items: center;
  gap: 6px;
}


/* Toolbar controls */

#toolbar button {
  height: 28px;
  padding: 2px 8px;
}

#toolbar select,
#toolbar input {
  /*height: 28px;*/
  box-sizing: border-box;
}

#tempo {
  width: 4em;
}

.perform-group .section-label,
.listen-group .section-label {
    width: 95px;
}
.bottom-row {
    justify-content: space-between;
}

.tempo-group {
    display: flex;
    align-items: center;
    gap: 6px;
}

.tempo-group label {
    display: flex;
    align-items: center;
    gap: 6px;
}
#toolbar button {
    height: 28px;
    padding: 2px 8px;
}
.load-row,
.part-row,
.perform-group,
.listen-group,
.tempo-group {
  gap: 8px;
}

#recordBtn,
#playScoreBtn {
    width: 120px;     /* or whatever Record naturally is */
    text-align: left;
}
