:root {
  color-scheme: light dark;

  --bg: #f5f4ef;
  --surface: #ffffff;
  --surface-2: #faf9f5;
  --text: #211f1a;
  --text-muted: #6b6a61;
  --border: #dedad0;
  --border-strong: #c7c1b3;
  --accent: #2f6e46;
  --accent-hover: #255939;
  --accent-soft: rgba(47, 110, 70, 0.1);
  --accent-contrast: #ffffff;
  --danger: #ab3428;
  --danger-soft: #f7dedc;
  --ok-soft: #dcefdf;
  --radius-sm: 6px;
  --radius: 10px;
  --shadow-sm: 0 1px 2px rgba(30, 28, 20, 0.07);
  --shadow: 0 2px 10px rgba(30, 28, 20, 0.08), 0 1px 2px rgba(30, 28, 20, 0.06);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1a1a17;
    --surface: #232420;
    --surface-2: #28291f;
    --text: #ece9e0;
    --text-muted: #a3a294;
    --border: #3a3830;
    --border-strong: #4c493d;
    --accent: #6fbf6f;
    --accent-hover: #82cc82;
    --accent-soft: rgba(111, 191, 111, 0.15);
    --accent-contrast: #12200e;
    --danger: #e2897c;
    --danger-soft: #3a201d;
    --ok-soft: #1e3a24;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow: 0 2px 12px rgba(0, 0, 0, 0.4), 0 1px 2px rgba(0, 0, 0, 0.3);
  }
}

* {
  box-sizing: border-box;
}

body {
  font-family: system-ui, -apple-system, sans-serif;
  margin: 0 auto;
  padding: 32px 24px 48px;
  max-width: 940px;
  line-height: 1.5;
  background: var(--bg);
  color: var(--text);
  transition: background-color 0.2s ease, color 0.2s ease;
}

header {
  margin-bottom: 28px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

h1 {
  margin: 0 0 6px;
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.01em;
}

h2 {
  font-size: 17px;
  letter-spacing: -0.005em;
}

.subtitle {
  color: var(--text-muted);
  margin: 0;
  font-size: 14.5px;
}

/* Card treatment shared by the toolbar-style panels (#fileBar, #toolbar,
   #playerControls) - purely decorative grouping (background/border/shadow),
   never affects layout geometry the staff's click-to-pitch math depends on
   (that reads #staffWrap/#staffContainer directly, neither of which is in
   this list). */
#fileBar,
#toolbar,
#playerControls {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 14px 16px;
}

#fileBar {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 20px;
}

#compositionNameInput,
#composerInput {
  font-size: 14px;
  font-weight: 600;
  padding: 6px 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text);
  min-width: 160px;
}

#savedSelect,
#exampleSelect,
#tuningSelect,
#capoSelect,
#timeSigSelect,
#tempoInput,
#exportFormatSelect,
#outputDeviceSelect,
#soundSelect,
#loopFromSelect,
#loopToSelect {
  padding: 6px 10px;
  font-size: 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text);
}

#compositionNameInput,
#composerInput,
#savedSelect,
#exampleSelect,
#tuningSelect,
#capoSelect,
#timeSigSelect,
#tempoInput,
#exportFormatSelect,
#outputDeviceSelect,
#soundSelect,
#loopFromSelect,
#loopToSelect {
  transition: border-color 0.15s ease;
}

#compositionNameInput:hover,
#composerInput:hover,
#savedSelect:hover,
#exampleSelect:hover,
#tuningSelect:hover,
#capoSelect:hover,
#timeSigSelect:hover,
#tempoInput:hover,
#exportFormatSelect:hover,
#outputDeviceSelect:hover,
#soundSelect:hover,
#loopFromSelect:hover,
#loopToSelect:hover {
  border-color: var(--border-strong);
  filter: brightness(0.98);
}

#tempoInput {
  width: 68px;
}

#fileStatus {
  font-size: 13px;
  color: var(--accent);
  font-weight: 500;
}

#composerInput {
  font-weight: 400;
}

#exampleCredit {
  font-size: 12px;
  color: var(--text-muted);
}

#toolbar {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 10px;
}

.toolbar-row {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.toolbar-label {
  font-size: 11.5px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 600;
}

/* Gives every row in the composer toolbar (Duration/Layout/Edit/Convert) a
   matching-width label column, right-aligned against its buttons, so the
   buttons themselves start at the same X across rows instead of each row's
   label pushing them over by a different amount. */
.toolbar-row .toolbar-label {
  min-width: 72px;
  text-align: right;
  flex-shrink: 0;
}

button {
  padding: 6px 13px;
  font-size: 14px;
  font-family: inherit;
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text);
  transition: background-color 0.12s ease, border-color 0.12s ease, box-shadow 0.12s ease,
    transform 0.06s ease;
}

button:hover:not(:disabled) {
  background: var(--accent-soft);
  border-color: var(--accent);
}

button:active:not(:disabled) {
  transform: translateY(1px);
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

button.active {
  background: var(--accent);
  color: var(--accent-contrast);
  border-color: var(--accent);
}

button.active:hover:not(:disabled) {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

button.primary {
  background: var(--accent);
  color: var(--accent-contrast);
  border-color: var(--accent);
  font-weight: 600;
}

button.primary:hover:not(:disabled) {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

/* A single consistent focus ring for every interactive control, instead of
   relying on each browser's own default (which varies and looks
   inconsistent against a custom palette) - :focus-visible so it only
   appears for keyboard/programmatic focus, not every mouse click. */
button:focus-visible,
select:focus-visible,
input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

#hint {
  font-size: 13px;
  color: var(--text-muted);
  margin: 16px 0;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
}

#hint p {
  margin: 0 0 8px;
}

#hint ul {
  margin: 0;
  padding-left: 18px;
}

#hint li {
  margin-bottom: 5px;
}

#hint li:last-child {
  margin-bottom: 0;
}

#hint strong {
  color: var(--text);
}

#staffWrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

#staffWrap:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--shadow), 0 0 0 3px var(--accent-soft);
}

/* Dashed guide lines toggled by "Guide Lines" - distinct from VexFlow's own
   solid black staff/ledger lines so they read as an aid, not real notation. */
.ledger-guide-line {
  stroke: #2a6f2a;
  stroke-opacity: 0.45;
  stroke-width: 1;
  stroke-dasharray: 4 3;
}

#measureInfo {
  font-size: 13px;
  color: var(--text-muted);
  margin: 8px 0 0;
}

#warning {
  color: var(--danger);
  font-size: 13px;
  min-height: 18px;
  margin: 2px 0 0;
  font-weight: 500;
}

#noteList {
  font-family: ui-monospace, monospace;
  font-size: 12px;
  margin-top: 8px;
  color: var(--text);
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  cursor: text;
  white-space: pre-wrap;
  transition: border-color 0.15s ease;
}

#noteList:hover {
  border-color: var(--border-strong);
}

#noteList:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--surface);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.note-token {
  cursor: pointer;
  border-radius: 3px;
  padding: 0 1px;
}
.note-token:hover {
  background: var(--accent-soft);
}
.note-token.selected {
  background: var(--accent);
  color: var(--accent-contrast);
}

#editStatus {
  font-size: 13px;
  color: var(--accent);
  min-height: 18px;
  margin: 4px 0 0;
  font-weight: 500;
}

#playback {
  margin-top: 36px;
  padding-top: 8px;
}

#status {
  padding: 10px 14px;
  margin-bottom: 14px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 14px;
  font-weight: 500;
}

#status.ok {
  background: var(--ok-soft);
  border-color: var(--accent);
  color: var(--text);
}

#status.error {
  background: var(--danger-soft);
  border-color: var(--danger);
  color: var(--text);
}

#playerControls {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
  /* Stays at the top of the window while scrolling through the tab (and
     while playback scrolls it), so Play/Stop/Speed are always in reach */
  position: sticky;
  top: 0;
  z-index: 10;
}

/* Audio effects panel (js/effects.js renders the cards into #effectsRack) */
#effectsPanel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 10px 16px;
  margin-bottom: 16px;
}

#effectsPanel summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 14px;
}

#effectsRack {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
  margin: 12px 0;
}

.fx-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  opacity: 0.6;
}

.fx-card.on {
  opacity: 1;
  border-color: var(--border-strong);
}

.fx-head {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  font-size: 13px;
  margin-bottom: 4px;
}

.fx-param {
  display: grid;
  grid-template-columns: 70px 1fr 58px;
  align-items: center;
  gap: 6px;
  font-size: 12px;
}

.fx-param input[type="range"] {
  width: 100%;
}

.fx-value {
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
}

.fx-footer {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.fx-note {
  font-size: 12px;
  color: var(--text-muted);
}

#alphaTab {
  border: 1px solid var(--border);
  min-height: 150px;
  border-radius: var(--radius);
  background: #fff;
  box-shadow: var(--shadow);
}

/* alphaTab renders its playback cursor/highlight elements unstyled by
   design (so integrators can match their own theme) - without this, the
   bar wash, beat line, and "currently playing" note color are all present
   in the DOM but invisible. Tinted to the app's green accent. */
.at-cursor-bar {
  background: rgba(42, 111, 42, 0.12);
}
.at-cursor-beat {
  background: rgba(42, 111, 42, 0.85);
  width: 3px;
}
.at-highlight * {
  fill: #2a6f2a;
  stroke: #2a6f2a;
}
.at-selection div {
  background: rgba(42, 111, 42, 0.08);
}

#logDetails {
  margin-top: 14px;
  font-size: 13px;
  color: var(--text-muted);
}

#log {
  white-space: pre-wrap;
  font-family: ui-monospace, monospace;
  font-size: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px;
  max-height: 200px;
  overflow: auto;
  border-radius: var(--radius-sm);
}
