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

:root {
  color-scheme: dark;
  --bg: #000;
  --text: #f5f5f7;
  --text-soft: #9a9a9a;
  --text-muted: #6a6a6a;
  --text-dim: #3d3d3d;
  --line: #141414;
  --line-strong: #202020;
  --panel: #0d0d0d;
  --panel-strong: #111;
  --green: #30d158;
  --red: #ff453a;
  --yellow: #ffd60a;
  --blue: #64d2ff;
  --row-grid: 34px minmax(0, 1fr) minmax(220px, 0.35fr);
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Helvetica Neue", Arial, sans-serif;
  font-weight: 300;
  padding: 32px 40px 48px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

.app-shell {
  width: 100%;
}

.app-header {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: flex-start;
  margin-bottom: 22px;
}

.title-block {
  display: flex;
  align-items: flex-start;
  gap: 28px;
  min-width: 0;
}

.header-image {
  width: 180px;
  height: 96px;
  object-fit: contain;
  opacity: 0.48;
  flex: 0 0 auto;
  margin-top: 2px;
}

h1 {
  margin: 0;
  font-size: 18px;
  font-weight: 400;
  letter-spacing: 0;
  text-transform: uppercase;
  color: var(--text-muted);
}

.subtitle {
  margin: 10px 0 0;
  font-size: 44px;
  line-height: 1.08;
  font-weight: 200;
  color: var(--text);
}

.toolbar {
  display: flex;
  gap: 14px;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  padding-top: 2px;
}

.action-btn {
  appearance: none;
  background: transparent;
  border: 0;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 15px;
  font-weight: 400;
  letter-spacing: 0;
  line-height: 1;
  padding: 8px 0;
  text-transform: uppercase;
  transition: color 0.2s ease;
}

.action-btn:hover,
.action-btn:focus-visible {
  color: #b8b8b8;
  outline: none;
}

.quiet-danger:hover,
.quiet-danger:focus-visible {
  color: var(--red);
}

.search-panel {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  align-items: center;
  column-gap: 12px;
  row-gap: 10px;
  margin-bottom: 16px;
  padding: 0 0 18px;
  border-bottom: 1px solid var(--line-strong);
}

.search-label,
.field-label {
  color: var(--text-muted);
  font-size: 15px;
  font-weight: 400;
  letter-spacing: 0;
  text-transform: uppercase;
}

#search-input,
#tag-filter-input,
.text-field,
.meta-field,
.chord-field,
.notes-field,
.setlist-select {
  width: 100%;
  background: transparent;
  border: 0;
  color: var(--text);
  outline: none;
}

#search-input {
  font-size: 40px;
  font-weight: 200;
  padding: 0;
}

#tag-filter-input {
  font-size: 20px;
  font-weight: 300;
  padding: 0;
}

#search-input::placeholder,
#tag-filter-input::placeholder,
.text-field::placeholder,
.meta-field::placeholder,
.chord-field::placeholder,
.notes-field::placeholder {
  color: #252525;
}

.tag-chip-list {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding-top: 4px;
}

.tag-chip,
.song-tag {
  border: 1px solid #2f2f2f;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 13px;
  font-weight: 400;
  color: #c8c8c8;
  letter-spacing: 0.01em;
  text-transform: lowercase;
}

.tag-chip {
  background: transparent;
  cursor: pointer;
  transition: border-color 0.2s ease, color 0.2s ease;
}

.tag-chip:hover,
.tag-chip:focus-visible {
  color: #fff;
  border-color: #4a4a4a;
  outline: none;
}

.tag-chip.active {
  color: #fff;
  border-color: var(--blue);
}

.tag-chip-empty {
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 300;
}

.setlist-panel {
  margin-bottom: 24px;
  border-bottom: 1px solid var(--line-strong);
  padding-bottom: 16px;
}

.setlist-header-row {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr) auto auto;
  gap: 10px;
  align-items: center;
}

.setlist-select {
  background: #090909;
  border: 1px solid #242424;
  border-radius: 8px;
  min-height: 40px;
  font-size: 18px;
  font-weight: 300;
  padding: 6px 12px;
}

.setlist-song-list {
  margin: 12px 0 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 8px;
}

.setlist-song-item {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  border: 1px solid #1d1d1d;
  border-radius: 8px;
  padding: 8px 10px;
  background: #090909;
}

.setlist-index {
  color: var(--text-muted);
  font-size: 14px;
  text-align: right;
}

.setlist-song-title {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--song-title-color, var(--text));
  text-align: left;
  cursor: pointer;
  font-size: 16px;
  font-weight: 300;
  padding: 0;
  transition: filter 0.2s ease;
}

.setlist-song-title:hover,
.setlist-song-title:focus-visible {
  filter: brightness(1.12);
  outline: none;
}

.setlist-song-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.setlist-empty {
  color: var(--text-muted);
  font-size: 15px;
  font-weight: 300;
  padding: 6px 2px 2px;
}

.list-header {
  display: grid;
  grid-template-columns: var(--row-grid);
  gap: 0;
  padding: 0 0 12px;
  border-bottom: 1px solid var(--line);
}

.list-header span {
  color: var(--text-muted);
  font-size: 15px;
  font-weight: 400;
  letter-spacing: 0;
  text-transform: uppercase;
}

.song-list {
  min-height: 120px;
}

.song-item {
  border-bottom: 1px solid #0d0d0d;
}

.song-row {
  appearance: none;
  width: 100%;
  display: grid;
  grid-template-columns: var(--row-grid);
  align-items: center;
  gap: 0;
  padding: 20px 0;
  background: transparent;
  border: 0;
  color: inherit;
  cursor: pointer;
  text-align: left;
  transition: border-color 0.2s ease;
}

.song-row:hover .song-title,
.song-row:focus-visible .song-title {
  filter: brightness(1.12);
}

.song-row:focus-visible {
  outline: 1px solid #262626;
  outline-offset: -1px;
}

.expand-glyph {
  color: var(--text-dim);
  font-size: 22px;
  justify-self: center;
  transform: rotate(-90deg);
  transition: transform 0.2s ease, color 0.2s ease;
}

.song-item.expanded .expand-glyph {
  color: var(--text-muted);
  transform: rotate(0deg);
}

.song-title {
  color: var(--song-title-color, var(--text));
  font-size: 46px;
  font-weight: 200;
  line-height: 1.12;
  transition: filter 0.2s ease;
}

.alphabet-rail {
  position: fixed;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 10;
  display: grid;
  gap: 3px;
  min-width: 36px;
  padding: 8px 6px;
  border: 1px solid #1f1f1f;
  border-radius: 10px;
  background: rgba(7, 7, 7, 0.82);
  backdrop-filter: blur(4px);
  touch-action: none;
  user-select: none;
}

.alpha-btn {
  appearance: none;
  width: 22px;
  min-height: clamp(16px, 2.1vh, 22px);
  border: 0;
  border-radius: 6px;
  padding: 0;
  background: transparent;
  color: #767676;
  font-size: 11px;
  font-weight: 500;
  line-height: 1;
  cursor: pointer;
  text-transform: uppercase;
  transition: color 0.15s ease, background-color 0.15s ease;
}

.alpha-btn:hover,
.alpha-btn:focus-visible {
  color: #e2e2e2;
  background: #1b1b1b;
  outline: none;
}

.alpha-btn:disabled {
  color: #3a3a3a;
  cursor: default;
}

.alpha-btn.active {
  color: #fff;
  background: #252525;
}

.alphabet-rail.scrubbing {
  border-color: #2a2a2a;
  background: rgba(12, 12, 12, 0.94);
}

.alpha-btn.scrub {
  color: #fff;
  background: #2d2d2d;
}

.alphabet-popout {
  position: fixed;
  z-index: 18;
  width: 64px;
  height: 64px;
  display: grid;
  place-items: center;
  border: 1px solid #333;
  border-radius: 14px;
  background: rgba(20, 20, 20, 0.96);
  color: #fff;
  font-size: 34px;
  font-weight: 500;
  line-height: 1;
  pointer-events: none;
  opacity: 0;
  transform: translateY(-50%) scale(0.86);
  transition: opacity 0.08s ease, transform 0.08s ease;
}

.alphabet-popout.visible {
  opacity: 1;
  transform: translateY(-50%) scale(1);
}

@media (pointer: coarse) {
  .alphabet-rail {
    right: 6px;
    min-width: 40px;
    padding: 10px 6px;
  }

  .alpha-btn {
    width: 26px;
    min-height: clamp(18px, 2.2vh, 24px);
  }

  .alphabet-popout {
    width: 72px;
    height: 72px;
    font-size: 38px;
  }
}

.song-title-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex-wrap: wrap;
}

.song-row-tags {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.song-row-tag {
  border: 1px solid #2f2f2f;
  border-radius: 999px;
  padding: 2px 8px;
  color: var(--text-soft);
  font-size: 11px;
  font-weight: 400;
  letter-spacing: 0.02em;
  text-transform: lowercase;
}

.song-meta {
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 400;
  letter-spacing: 0;
  justify-self: end;
  text-transform: uppercase;
  text-align: right;
}

.song-detail {
  display: none;
  padding: 0 56px 24px 28px;
}

.song-item.expanded .song-detail {
  display: block;
}

.song-aux-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.transpose-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.transpose-value {
  color: var(--text-soft);
  font-size: 14px;
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.capo-control {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.capo-input {
  width: 88px;
  border: 1px solid #2b2b2b;
  border-radius: 8px;
  background: #090909;
  color: var(--text);
  min-height: 32px;
  padding: 4px 8px;
  font-size: 16px;
  font-weight: 300;
}

.capo-input:focus {
  border-color: #3e3e3e;
  outline: none;
}

.chord-display {
  margin: 0;
  width: 100%;
  color: #e8e8ea;
  font-family: "SF Mono", ui-monospace, Menlo, Consolas, monospace;
  font-size: var(--fitted-chord-size, 36px);
  font-weight: 400;
  line-height: 1.35;
  white-space: pre;
  overflow-wrap: normal;
  tab-size: 4;
}

.chord-display.compact {
  line-height: 1.18;
}

.chord-token {
  color: #ffffff;
  font-weight: 600;
}

.section-label {
  color: #79bcff;
  font-weight: 600;
}

.practice-notes {
  margin-top: 14px;
  border-left: 2px solid #2b2b2b;
  padding-left: 10px;
}

.practice-notes h4 {
  margin: 0 0 6px;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.practice-notes p {
  margin: 0;
  color: #d4d4d4;
  font-size: 16px;
  line-height: 1.35;
  white-space: pre-wrap;
}

.song-tags {
  margin-top: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.detail-actions {
  display: flex;
  gap: 14px;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 18px;
}

.inline-btn {
  appearance: none;
  background: transparent;
  border: 0;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 14px;
  font-weight: 400;
  letter-spacing: 0;
  padding: 4px 0;
  text-transform: uppercase;
  transition: color 0.2s ease;
}

.inline-btn:hover,
.inline-btn:focus-visible {
  color: #b8b8b8;
  outline: none;
}

.inline-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.inline-btn.delete:hover,
.inline-btn.delete:focus-visible {
  color: var(--red);
}

.empty-state {
  color: var(--text-muted);
  font-size: 36px;
  font-weight: 200;
  padding: 34px 0;
}

.footer {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid #0d0d0d;
  color: var(--text-muted);
  font-size: 15px;
  font-weight: 400;
  letter-spacing: 0;
  text-transform: uppercase;
}

.backup-reminder.warning {
  color: var(--yellow);
}

#status-msg.success {
  color: var(--green);
}

#status-msg.error {
  color: var(--red);
}

.modal-overlay,
.performance-overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 22px;
  background: rgba(0, 0, 0, 0.72);
}

.modal-overlay.visible,
.performance-overlay.visible {
  display: flex;
}

.editor-modal {
  width: min(960px, 100%);
  max-height: min(860px, calc(100vh - 44px));
  overflow: auto;
  background: var(--panel-strong);
  border: 1px solid #242424;
  border-radius: 8px;
  padding: 22px;
}

.editor-modal h2 {
  margin: 0 0 20px;
  color: var(--text-muted);
  font-size: 16px;
  font-weight: 400;
  letter-spacing: 0;
  text-transform: uppercase;
}

.field-label {
  display: block;
  margin: 16px 0 8px;
}

.text-field,
.meta-field,
.chord-field,
.notes-field {
  border: 1px solid #242424;
  border-radius: 8px;
  background: #090909;
  color: var(--text);
}

.text-field {
  min-height: 50px;
  padding: 10px 12px;
  font-size: 36px;
  font-weight: 200;
}

.meta-field,
select.meta-field {
  min-height: 44px;
  padding: 8px 10px;
  font-size: 20px;
  font-weight: 300;
}

.chord-field {
  min-height: 300px;
  resize: vertical;
  padding: 14px;
  font-family: "SF Mono", ui-monospace, Menlo, Consolas, monospace;
  font-size: 24px;
  font-weight: 400;
  line-height: 1.45;
}

.notes-field {
  min-height: 120px;
  resize: vertical;
  padding: 12px;
  font-size: 18px;
  font-weight: 300;
  line-height: 1.4;
}

.text-field:focus,
.meta-field:focus,
.chord-field:focus,
.notes-field:focus,
.setlist-select:focus {
  border-color: #3a3a3a;
}

.meta-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.display-settings {
  margin: 18px 0 0;
  padding: 0;
  border: 0;
}

.checkbox-row {
  margin-top: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: #c7c7c7;
  font-size: 16px;
  font-weight: 300;
}

.editor-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
}

.modal-btn {
  appearance: none;
  background: transparent;
  border: 1px solid #2a2a2a;
  border-radius: 8px;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 16px;
  font-weight: 400;
  letter-spacing: 0;
  padding: 10px 14px;
  text-transform: uppercase;
  transition: border-color 0.2s ease, color 0.2s ease;
}

.modal-btn:hover,
.modal-btn:focus-visible {
  border-color: #444;
  color: #b8b8b8;
  outline: none;
}

.modal-btn.primary {
  border-color: #3a3a3a;
  color: var(--text);
}

.performance-stage {
  width: min(1600px, 100%);
  height: min(980px, calc(100vh - 44px));
  display: flex;
  flex-direction: column;
  gap: 16px;
  background: #030303;
  border: 1px solid #151515;
  border-radius: 10px;
  padding: 16px 20px 18px;
}

.performance-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

#performance-title {
  margin: 0;
  color: #f6f6f7;
  font-size: clamp(26px, 3.5vw, 52px);
  font-weight: 300;
  line-height: 1.1;
}

#performance-title.hidden {
  display: none;
}

.performance-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

.performance-btn {
  appearance: none;
  border: 1px solid #2f2f2f;
  border-radius: 8px;
  background: #0a0a0a;
  color: #d8d8d8;
  padding: 8px 12px;
  min-height: 40px;
  cursor: pointer;
  text-transform: uppercase;
  font-size: 14px;
  font-weight: 400;
  letter-spacing: 0.04em;
}

.performance-btn:hover,
.performance-btn:focus-visible {
  border-color: #4f4f4f;
  color: #fff;
  outline: none;
}

.performance-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.performance-chords {
  margin: 0;
  flex: 1;
  min-height: 0;
  overflow: auto;
  color: #f2f2f4;
  font-family: "SF Mono", ui-monospace, Menlo, Consolas, monospace;
  font-size: var(--performance-font-size, 72px);
  font-weight: 500;
  line-height: 1.3;
  white-space: pre;
  tab-size: 4;
}

.performance-chords.compact {
  line-height: 1.1;
}

.performance-meta {
  color: #a7a7a7;
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  min-height: 20px;
}

@media print {
  .app-header,
  .search-panel,
  .setlist-panel,
  .list-header,
  .detail-actions,
  .song-aux-row,
  .alphabet-rail,
  .alphabet-popout,
  .footer,
  .modal-overlay,
  .performance-overlay {
    display: none !important;
  }

  body {
    background: #fff;
    color: #000;
    padding: 0;
    font-size: 12pt;
  }

  .song-item,
  .song-detail,
  .song-item.expanded .song-detail {
    display: block !important;
    border: 0;
    padding: 0;
  }

  .song-title {
    font-size: 16pt;
    font-weight: 700;
    color: #000;
  }

  .chord-display {
    color: #000;
    font-size: 12pt;
    line-height: 1.3;
    overflow: visible;
  }
}

@media (max-width: 980px) {
  body {
    padding: 20px 16px 36px;
  }

  .app-header {
    display: block;
  }

  .title-block {
    justify-content: space-between;
    gap: 16px;
  }

  .header-image {
    width: clamp(84px, 24vw, 120px);
    height: auto;
    opacity: 0.4;
  }

  .subtitle {
    font-size: 34px;
  }

  .toolbar {
    justify-content: flex-start;
    margin-top: 16px;
    gap: 12px;
  }

  .search-panel {
    grid-template-columns: 1fr;
    gap: 8px;
    margin-bottom: 14px;
  }

  #search-input {
    font-size: 34px;
  }

  .setlist-header-row {
    grid-template-columns: 1fr;
  }

  .list-header {
    grid-template-columns: 24px minmax(0, 1fr);
  }

  .list-header span:nth-child(3) {
    display: none;
  }

  .song-row {
    grid-template-columns: 24px minmax(0, 1fr);
    row-gap: 6px;
    padding: 18px 0;
  }

  .song-title {
    font-size: 36px;
  }

  .song-meta {
    grid-column: 2;
    justify-self: start;
    text-align: left;
  }

  .song-detail {
    padding-left: 24px;
  }

  .chord-display {
    line-height: 1.45;
  }

  .meta-row {
    grid-template-columns: 1fr;
  }

  .editor-modal {
    padding: 18px;
  }

  .text-field {
    font-size: 32px;
  }

  .chord-field {
    min-height: 260px;
    font-size: 22px;
  }

  .performance-stage {
    height: calc(100vh - 24px);
    width: calc(100vw - 24px);
    border-radius: 0;
    padding: 14px;
  }

  .performance-header {
    flex-direction: column;
    align-items: stretch;
  }

  .performance-controls {
    width: 100%;
    justify-content: space-between;
    gap: 8px;
  }

  .performance-btn {
    flex: 1;
  }
}
