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

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background-color: #0a0a0a;
  color: #e0e0e0;
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

input, textarea, button, select {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

a {
  color: #1565c0;
  text-decoration: none;
}

.app-container {
  max-width: 100vw;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.app-header {
  text-align: center;
  padding: 24px 16px;
  border-bottom: 1px solid #2a2a2a;
}
.app-header h1 {
  font-size: 1.5rem;
  font-weight: 600;
  margin-bottom: 4px;
}
.app-header__subtitle {
  font-size: 0.875rem;
  color: #888;
}

.editor-layout {
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 16px;
}
@media (min-width: 768px) {
  .editor-layout {
    flex-direction: row;
    align-items: flex-start;
  }
}
.editor-layout > * {
  flex: 1;
  min-width: 0;
}

.tab-bar {
  display: flex;
  gap: 4px;
  padding: 8px;
  background: #1a1a1a;
  border-bottom: 1px solid #2a2a2a;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.tab-bar__tab {
  padding: 8px 16px;
  border: none;
  background: transparent;
  color: #888;
  border-radius: 4px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s;
}
.tab-bar__tab:hover {
  background: #2a2a2a;
  color: #e0e0e0;
}
.tab-bar__tab--active {
  background: #1565c0;
  color: white;
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 64px;
  color: #888;
  text-align: center;
}
.empty-state__title {
  font-size: 1.25rem;
  margin-bottom: 8px;
}
.empty-state__description {
  font-size: 0.875rem;
}

.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px;
  color: #888;
}
.loading__spinner {
  width: 24px;
  height: 24px;
  border: 2px solid #2a2a2a;
  border-top-color: #1565c0;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-right: 8px;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
.error {
  padding: 16px;
  background: rgba(255, 74, 74, 0.1);
  border: 1px solid #c62828;
  border-radius: 8px;
  color: #c62828;
  margin: 16px 0;
}
.error__message {
  font-size: 0.875rem;
}

.abc-editor {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 16px;
}
.abc-editor__header {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
@media (min-width: 768px) {
  .abc-editor__header {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }
}
.abc-editor__title {
  flex: 1;
  padding: 8px;
  background: #1a1a1a;
  border: 1px solid #2a2a2a;
  border-radius: 4px;
  color: #e0e0e0;
  font-size: 1rem;
  font-weight: 600;
}
.abc-editor__title:focus {
  outline: none;
  border-color: #1565c0;
}
.abc-editor__title::placeholder {
  color: #888;
}
.abc-editor__actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.abc-editor__save-btn {
  padding: 8px 16px;
  background: #1565c0;
  color: white;
  border: none;
  border-radius: 4px;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}
.abc-editor__save-btn:hover {
  background: #104d92;
}
.abc-editor__save-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.abc-editor__save-status {
  font-size: 0.75rem;
}
.abc-editor__save-status--saving {
  color: #888;
}
.abc-editor__save-status--saved {
  color: #4aff6a;
}
.abc-editor__save-status--error {
  color: #c62828;
}
.abc-editor__label {
  font-weight: 600;
  font-size: 0.875rem;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.abc-editor__textarea {
  width: 100%;
  padding: 8px;
  background: #1a1a1a;
  border: 1px solid #2a2a2a;
  border-radius: 4px;
  color: #e0e0e0;
  font-family: monospace;
  font-size: 0.875rem;
  resize: vertical;
  min-height: 200px;
}
.abc-editor__textarea:focus {
  outline: none;
  border-color: #1565c0;
}
.abc-editor__textarea::placeholder {
  color: #888;
}
.abc-editor__output {
  min-height: 200px;
  overflow: auto;
}
.abc-editor__parsed {
  padding: 8px;
  background: #1a1a1a;
  border: 1px solid #2a2a2a;
  border-radius: 4px;
  font-family: monospace;
  font-size: 0.75rem;
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 400px;
  overflow: auto;
}

.notation-view {
  padding: 16px;
}
.notation-view__title {
  font-size: 1rem;
  font-weight: 600;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 16px;
}
.notation-view__container {
  background: #1a1a1a;
  border: 1px solid #2a2a2a;
  border-radius: 8px;
  min-height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.notation-view__svg {
  width: 100%;
  overflow-x: auto;
  padding: 16px;
}
.notation-view__svg svg {
  max-width: 100%;
  height: auto;
}

.lsdj-grid {
  padding: 16px;
}
.lsdj-grid__title {
  font-size: 1rem;
  font-weight: 600;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 16px;
}
.lsdj-grid__content {
  background: #1a1a1a;
  border: 1px solid #2a2a2a;
  border-radius: 8px;
  min-height: 200px;
  padding: 16px;
}
.lsdj-grid__phrases, .lsdj-grid__chains {
  display: flex;
  flex-direction: column;
  gap: 24px;
}
.lsdj-grid__phrase, .lsdj-grid__chain {
  background: #0a0a0a;
  border-radius: 4px;
  padding: 8px;
}
.lsdj-grid__phrase-title, .lsdj-grid__chain-title {
  font-size: 0.875rem;
  font-weight: 600;
  color: #1565c0;
  margin-bottom: 8px;
  font-family: monospace;
}
.lsdj-grid__steps {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 4px;
}
@media (min-width: 768px) {
  .lsdj-grid__steps {
    grid-template-columns: repeat(4, 1fr);
  }
}
.lsdj-grid__step {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 4px 8px;
  background: #1a1a1a;
  border-radius: 4px;
  font-family: monospace;
  font-size: 0.75rem;
}
.lsdj-grid__step--beat {
  background: #272727;
  border-left: 2px solid #1565c0;
}
.lsdj-grid__step-num {
  color: #888;
  font-size: 0.625rem;
  margin-bottom: 2px;
}
.lsdj-grid__note {
  color: #4aff6a;
  font-weight: 600;
}
.lsdj-grid__duration {
  color: #888;
  font-size: 0.625rem;
}
.lsdj-grid__rest {
  color: #888;
  opacity: 0.5;
}
.lsdj-grid__chain-phrase {
  color: #1565c0;
  font-weight: 600;
}
.lsdj-grid__song {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.lsdj-grid__song-header {
  display: grid;
  grid-template-columns: 3rem repeat(4, 1fr);
  gap: 4px;
  padding: 8px;
  background: #0a0a0a;
  border-radius: 4px;
  font-family: monospace;
  font-size: 0.75rem;
  font-weight: 600;
  color: #888;
}
.lsdj-grid__song-header-cell {
  text-align: center;
}
.lsdj-grid__song-rows {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.lsdj-grid__song-row {
  display: grid;
  grid-template-columns: 3rem repeat(4, 1fr);
  gap: 4px;
  padding: 8px;
  background: #1a1a1a;
  border-radius: 4px;
  font-family: monospace;
  font-size: 0.75rem;
}
.lsdj-grid__song-cell {
  text-align: center;
  color: #e0e0e0;
}
.lsdj-grid__song-cell:first-child {
  color: #888;
}

.song-card {
  width: 100%;
  padding: 16px;
  background: #1a1a1a;
  border: 1px solid #2a2a2a;
  border-radius: 8px;
  cursor: pointer;
  text-align: left;
  transition: border-color 0.15s, background 0.15s;
}
.song-card:hover {
  border-color: #1565c0;
  background: #222222;
}
.song-card__header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 8px;
}
.song-card__title {
  font-size: 1rem;
  font-weight: 600;
  color: #e0e0e0;
  margin: 0;
}
.song-card__date {
  font-size: 0.75rem;
  color: #888;
}
.song-card__preview {
  font-family: monospace;
  font-size: 0.75rem;
  color: #888;
  background: #0a0a0a;
  padding: 8px;
  border-radius: 4px;
  margin: 0;
  white-space: pre-wrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-height: 4.5rem;
}

.library-list__grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}
@media (min-width: 768px) {
  .library-list__grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

.library-page {
  padding: 16px;
}
.library-page__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}
.library-page__title {
  font-size: 1.25rem;
  font-weight: 600;
  color: #e0e0e0;
  margin: 0;
}
.library-page__new-btn {
  padding: 8px 16px;
  background: #1565c0;
  color: white;
  border-radius: 4px;
  font-size: 0.875rem;
  font-weight: 600;
  text-decoration: none;
  transition: background 0.15s;
}
.library-page__new-btn:hover {
  background: #104d92;
}

.song-page {
  padding: 16px;
}
.song-page__content {
  display: flex;
  flex-direction: column;
  gap: 24px;
}
.song-page__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}
.song-page__title {
  font-size: 1.5rem;
  font-weight: 700;
  color: #e0e0e0;
  margin: 0;
}
.song-page__actions {
  display: flex;
  gap: 8px;
}
.song-page__edit-btn {
  padding: 8px 16px;
  background: #1565c0;
  color: white;
  border-radius: 4px;
  font-size: 0.875rem;
  font-weight: 600;
  text-decoration: none;
  transition: background 0.15s;
}
.song-page__edit-btn:hover {
  background: #104d92;
}
.song-page__delete-btn {
  padding: 8px 16px;
  background: transparent;
  color: #c62828;
  border: 1px solid #c62828;
  border-radius: 4px;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.song-page__delete-btn:hover {
  background: #c62828;
  color: white;
}
.song-page__section-title {
  font-size: 0.875rem;
  font-weight: 600;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 8px;
}
.song-page__abc-code {
  padding: 16px;
  background: #1a1a1a;
  border: 1px solid #2a2a2a;
  border-radius: 8px;
  font-family: monospace;
  font-size: 0.875rem;
  white-space: pre-wrap;
  word-break: break-all;
  color: #e0e0e0;
  max-height: 300px;
  overflow: auto;
}
