:root {
  color-scheme: dark;
  --bg: #0f1115;
  --panel: #171a21;
  --text: #e8eaef;
  --muted: #9aa3b2;
  --chord: #7dd3fc;
  --section: #fbbf24;
  --accent: #6366f1;
  --error: #f87171;
  font-family: "SF Pro Text", "Segoe UI", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
}

.setup {
  max-width: 42rem;
  margin: 0 auto;
  padding: 2.5rem 1.25rem 4rem;
}

.setup__header h1 {
  margin: 0 0 0.5rem;
  font-size: 1.75rem;
  letter-spacing: -0.02em;
}

.setup__header p {
  margin: 0 0 1.5rem;
  color: var(--muted);
  line-height: 1.5;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 1rem;
}

.field span {
  font-size: 0.85rem;
  color: var(--muted);
}

input[type="url"],
textarea {
  width: 100%;
  border: 1px solid #2a3140;
  border-radius: 0.5rem;
  background: var(--panel);
  color: var(--text);
  padding: 0.65rem 0.75rem;
  font: inherit;
}

textarea {
  resize: vertical;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 0.9rem;
  line-height: 1.45;
}

.btn {
  border: 1px solid #3b4254;
  background: var(--panel);
  color: var(--text);
  border-radius: 0.5rem;
  padding: 0.55rem 0.9rem;
  font: inherit;
  cursor: pointer;
}

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

.btn:hover {
  filter: brightness(1.08);
}

.error {
  color: var(--error);
  margin: 0.75rem 0 0;
  line-height: 1.4;
}

.search-box {
  margin-bottom: 1.25rem;
}

.search-row {
  display: flex;
  gap: 0.5rem;
}

.search-row input {
  flex: 1;
  border: 1px solid #2a3140;
  border-radius: 0.5rem;
  background: var(--panel);
  color: var(--text);
  padding: 0.65rem 0.75rem;
  font: inherit;
}

.search-results {
  list-style: none;
  margin: 0.65rem 0 0;
  padding: 0;
  border: 1px solid #2a3140;
  border-radius: 0.5rem;
  max-height: 16rem;
  overflow-y: auto;
  background: var(--panel);
}

.search-results__empty {
  padding: 0.75rem 1rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.search-hit {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.15rem;
  width: 100%;
  border: 0;
  border-bottom: 1px solid #252b38;
  background: transparent;
  color: var(--text);
  text-align: left;
  padding: 0.65rem 0.85rem;
  cursor: pointer;
  font: inherit;
}

.search-hit:last-child {
  border-bottom: 0;
}

.search-hit:hover {
  background: #1e2430;
}

.search-hit__title {
  font-weight: 600;
}

.search-hit__meta {
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.35;
  white-space: normal;
}

.stage {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
}

.stage__toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1rem;
  padding: 0.65rem 1rem;
  background: var(--panel);
  border-bottom: 1px solid #252b38;
}

.stage__meta {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 12rem;
}

#stage-sub {
  color: var(--muted);
  font-size: 0.85rem;
}

.stage__controls {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 0.65rem 1rem;
}

.control {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  font-size: 0.75rem;
  color: var(--muted);
}

.control select,
.control input[type="range"] {
  min-width: 7rem;
}

.transpose-stepper__row {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.btn--step {
  min-width: 2.25rem;
  padding: 0.35rem 0.55rem;
  font-size: 1.1rem;
  line-height: 1;
  font-weight: 600;
}

.transpose-stepper__key {
  min-width: 3.5rem;
  text-align: center;
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text);
}

.stage__viewport {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  position: relative;
  padding: 0.75rem 1.25rem 0.5rem;
}

.stage__viewport--scroll {
  overflow-y: auto;
  scroll-behavior: auto;
  padding-bottom: 2.75rem;
}

.stage__viewport--scroll .chart {
  max-width: 48rem;
  margin: 0 auto;
}

.chart {
  max-width: 56rem;
  margin: 0 auto;
  padding-bottom: 0.75rem;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  line-height: 1.35;
}

.chart--fit {
  transform-origin: top center;
  max-width: none;
  width: 100%;
  column-gap: 2.75rem;
  line-height: 1.2;
}

.chart--fit .line {
  margin: 0.05em 0;
  break-inside: avoid;
}

.chart--fit .line--blank {
  display: none;
}

.chart--fit .line--section {
  margin-top: 0.35em;
}

.stanza {
  break-inside: avoid-column;
  page-break-inside: avoid;
  margin-bottom: 0.4em;
}

.chart--fit .stanza {
  break-inside: avoid;
}

.chart--fit .line--chorded,
.chart--fit .line--aligned {
  break-inside: avoid;
}

.line--aligned {
  margin: 0.2em 0 0.45em;
}

.line__chords,
.line__lyrics {
  white-space: pre;
  line-height: 1.2;
}

.line__chords {
  min-height: 1.15em;
}

.line__lyrics {
  color: var(--text);
}

.line--aligned .line__chords,
.line--aligned .line__lyrics {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0;
}

.line {
  margin: 0.15em 0;
}

.line--chorded {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: flex-end;
  gap: 0;
  width: 100%;
}

.segment {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  flex: 0 0 auto;
}

.segment .chord {
  display: block;
  color: var(--chord);
  font-weight: 700;
  line-height: 1.05;
  min-height: 1.05em;
  white-space: nowrap;
}

.segment .lyric {
  display: block;
  white-space: pre;
  line-height: 1.25;
}

.line--section {
  color: var(--section);
  font-weight: 700;
  margin-top: 0.65em;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 0.85em;
}

.line--meta {
  color: var(--muted);
  white-space: pre-wrap;
}

.stage__footer {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
  padding: 0.35rem 1rem 0.55rem;
  background: var(--panel);
  border-top: 1px solid #252b38;
}

.stage__source {
  font-size: 0.75rem;
  color: var(--chord);
  text-decoration: none;
}

.stage__source:hover {
  text-decoration: underline;
}

.stage__hint {
  margin: 0;
  font-size: 0.75rem;
  color: var(--muted);
  text-align: center;
}

@media (max-width: 640px) {
  .stage__toolbar {
    align-items: stretch;
  }
  .stage__controls {
    width: 100%;
  }
}
