:root {
  --bg: #0f1114;
  --surface: #181c22;
  --border: #2a313c;
  --text: #e8eaee;
  --muted: #8b939f;
  --accent: #e8a849;
  --accent-dim: #c7842e;
  --code-bg: #0c0e11;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "DM Sans", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
}

.skip-link {
  position: absolute;
  left: -999rem;
  top: 0.5rem;
  padding: 0.5rem 1rem;
  background: var(--accent);
  color: #111;
  z-index: 100;
}

.skip-link:focus {
  left: 0.5rem;
}

.app {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: min(320px, 92vw);
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  max-height: 100vh;
  position: sticky;
  top: 0;
}

.sidebar-head {
  padding: 1.25rem 1rem;
  border-bottom: 1px solid var(--border);
}

.sidebar-head h1 {
  margin: 0 0 0.35rem;
  font-size: 1.15rem;
  font-weight: 650;
  letter-spacing: -0.02em;
}

.small {
  font-size: 0.82rem;
  line-height: 1.4;
}

.muted {
  color: var(--muted);
}

.field-label {
  display: block;
  margin-bottom: 0.35rem;
}

.set-wrap {
  display: block;
  margin-top: 0.75rem;
}

#set-picker {
  width: 100%;
  padding: 0.5rem 0.65rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font: inherit;
  cursor: pointer;
}

#set-picker:focus {
  outline: 2px solid var(--accent-dim);
  outline-offset: 1px;
}

.search-wrap {
  display: block;
  margin-top: 0.65rem;
}

#song-filter {
  width: 100%;
  padding: 0.5rem 0.65rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font: inherit;
}

#song-filter::placeholder {
  color: var(--muted);
}

#song-filter:focus {
  outline: 2px solid var(--accent-dim);
  outline-offset: 1px;
}

#song-list {
  overflow-y: auto;
  padding: 0.35rem 0 1rem;
}

.song-list-heading {
  margin: 0;
  padding: 0.45rem 1rem 0.25rem;
  font-size: 0.72rem;
  font-weight: 650;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--muted);
}

.song-btn {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.55rem 1rem;
  border: none;
  background: transparent;
  color: var(--text);
  font: inherit;
  cursor: pointer;
  border-left: 3px solid transparent;
}

.song-btn:hover {
  background: rgba(232, 168, 73, 0.08);
}

.song-btn[aria-current="true"] {
  border-left-color: var(--accent);
  background: rgba(232, 168, 73, 0.12);
}

.song-num {
  display: inline-block;
  min-width: 1.6rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  font-size: 0.78rem;
}

.song-meta {
  display: block;
  font-size: 0.76rem;
  color: var(--muted);
}

.content {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.content-head {
  padding: 0.75rem 1.25rem;
  border-bottom: 1px solid var(--border);
  background: rgba(24, 28, 34, 0.85);
  backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.menu-toggle {
  display: none;
  padding: 0.35rem 0.75rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font: inherit;
  cursor: pointer;
}

.content-title-row h2 {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 650;
}

.content-title-row .artist-line {
  margin: 0.15rem 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.chart-main {
  flex: 1;
  padding: 1.25rem 1.5rem 3rem;
  /* Use full width of .content so chord monospace blocks span the main column. */
  max-width: none;
  width: 100%;
}

.welcome {
  max-width: 28rem;
}

.error-banner {
  padding: 1rem;
  border-radius: 10px;
  background: rgba(180, 60, 60, 0.2);
  border: 1px solid rgba(230, 100, 100, 0.45);
  color: #f0c8c8;
}

.footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border);
}

.footer code {
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 0.76rem;
  word-break: break-all;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Markdown body */
.prose {
  font-size: 1rem;
}

.prose > * + * {
  margin-top: 0.75em;
}

.prose h1 {
  margin: 0 0 0.5rem;
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.2;
}

.prose h2 {
  margin: 1.75rem 0 0.5rem;
  font-size: 1.1rem;
  font-weight: 650;
  color: var(--accent);
}

.prose p {
  margin: 0.65em 0;
}

.prose a {
  color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

.prose a:hover {
  color: #f5bd6a;
}

.prose hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 1.25rem 0;
}

.prose ul {
  padding-left: 1.35rem;
}

.prose strong {
  font-weight: 600;
}

/* Italic disclaimers em */
.prose em {
  color: var(--muted);
}

/* Chord blocks: fenced ```text in markdown becomes code.language-text */
.prose pre:has(> code.language-text) {
  box-sizing: border-box;
  width: 100%;
  max-width: 100%;
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem 1.1rem;
  /* Preserve monospace columns (chords above lyrics): reflow differs per-line with pre-wrap +
   * overflow-wrap:anywhere and misaligns timing. Scroll instead on narrow screens. */
  overflow-x: auto;
}

.prose pre:has(> code.language-text) code {
  display: block;
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 1.14rem; /* was 1.52rem; 25% smaller */
  line-height: 1.38;
  font-weight: 400;
  background: transparent;
  padding: 0;
  white-space: pre;
  overflow-wrap: normal;
  word-break: normal;
  letter-spacing: 0.015em;
}

/** Markdown **…** cues in charts — keep default code colour (distinct from chord highlight). */
.prose pre:has(> code.language-text) strong.md-cue {
  font-weight: 600;
  color: inherit;
}

/** Recognised chords: span (not strong) so weight matches lyrics; accent colour only. */
.prose pre:has(> code.language-text) .chart-chord {
  font-weight: inherit;
  color: color-mix(in srgb, var(--accent), #fff 12%);
  text-shadow: 0 0 1px rgba(232, 168, 73, 0.35);
}

.prose code:not(pre code) {
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 1.32em; /* was 1.76em; 25% smaller */
  background: rgba(255, 255, 255, 0.06);
  padding: 0.1em 0.35em;
  border-radius: 4px;
}

.prose pre:not(:has(> code.language-text)) {
  box-sizing: border-box;
  width: 100%;
  max-width: 100%;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.85rem 1rem;
  overflow-x: hidden;
}

.prose pre:not(:has(> code.language-text)) code {
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 1.17rem; /* was 1.56rem; 25% smaller */
  background: transparent;
  padding: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* Mobile sidebar */
@media (max-width: 820px) {
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    z-index: 40;
    transform: translateX(-104%);
    transition: transform 0.2s ease;
    box-shadow: 8px 0 28px rgba(0, 0, 0, 0.45);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .menu-toggle {
    display: inline-flex;
  }

  body.sidebar-open-overlay::after {
    content: "";
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 30;
  }

  .chart-main {
    padding-inline: 1rem;
  }

  /* Quick bar map only: wrap + slightly smaller type. Full "Chords over lyrics" block stays pre + scroll. */
  .prose pre.chart-pre-quick-bar:has(> code.language-text) {
    overflow-x: hidden;
  }

  .prose pre.chart-pre-quick-bar:has(> code.language-text) code {
    font-size: 0.8rem;
    line-height: 1.42;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    word-break: break-word;
  }

  /* Full chord chart: same small body type as before, still no wrap / horizontal scroll */
  .prose pre:not(.chart-pre-quick-bar):has(> code.language-text) code {
    font-size: 0.8rem;
    line-height: 1.42;
  }

  .prose pre:not(:has(> code.language-text)) code {
    font-size: 0.78rem;
  }

  .prose code:not(pre code) {
    font-size: 0.95em;
  }
}
