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

html,
body {
  margin: 0;
  min-height: 100%;
  background: #0a0a0a;
  color: #f0f0f0;
  font-family:
    system-ui,
    -apple-system,
    "Segoe UI",
    Roboto,
    Ubuntu,
    sans-serif;
  -webkit-tap-highlight-color: transparent;
}

#app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

#app.app--with-signout {
  padding-top: 3.25rem;
}

.app-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 50;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  padding: 0.65rem 1rem 0.5rem;
  pointer-events: none;
}

.app-header > * {
  pointer-events: auto;
}

.btn-signout {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 0.85rem;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(24, 24, 24, 0.85);
  color: #b8b8b8;
  font-size: 0.9rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition:
    color 0.15s ease,
    border-color 0.15s ease,
    background 0.15s ease,
    transform 0.08s ease;
  backdrop-filter: blur(8px);
}

.btn-signout:hover {
  color: #fff;
  border-color: rgba(255, 255, 255, 0.22);
  background: rgba(40, 40, 40, 0.9);
}

.btn-signout:active {
  transform: scale(0.98);
}

.btn-signout-icon {
  flex-shrink: 0;
  opacity: 0.9;
}

.banner {
  background: #2a1f00;
  color: #ffe6a8;
  padding: 0.75rem 1rem;
  text-align: center;
  font-size: 1rem;
}

.hidden {
  display: none !important;
}

.screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 0;
  width: 100%;
  padding: 1.5rem;
  gap: 1rem;
}

.brand {
  font-size: 2rem;
  font-weight: 700;
  margin: 0;
  letter-spacing: -0.02em;
}

.tagline {
  margin: 0 0 1rem;
  font-size: 1.125rem;
  color: #b8b8b8;
}

.welcome {
  font-size: 1.25rem;
  margin: 0;
  text-align: center;
}

.hint {
  font-size: 1rem;
  color: #b8b8b8;
  text-align: center;
  max-width: 28rem;
  margin: 0;
}

.status-msg {
  font-size: 1.25rem;
}

.btn {
  min-height: 56px;
  min-width: 200px;
  padding: 0 1.5rem;
  border-radius: 999px;
  border: none;
  font-size: 1.125rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.08s ease, opacity 0.15s ease;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: #1db954;
  color: #0a0a0a;
}

.btn-primary:hover {
  opacity: 0.92;
}

.btn-secondary {
  background: #2a2a2a;
  color: #f0f0f0;
  border: 1px solid #3a3a3a;
}

.btn-secondary:hover {
  background: #333;
}

.btn-ghost {
  background: transparent;
  color: #b8b8b8;
  border: 1px solid #3a3a3a;
  min-height: 48px;
}

.btn-ghost:hover {
  color: #f0f0f0;
  border-color: #5a5a5a;
}

.error-text {
  font-size: 1.125rem;
  text-align: center;
  max-width: 32rem;
  line-height: 1.5;
  color: #f0f0f0;
}

/* Player layout — landscape-first */
#state-player {
  align-items: stretch;
  justify-content: flex-start;
  min-width: 0;
  width: 100%;
  padding: 1.25rem 1.5rem 1rem;
  gap: 1.25rem;
  /* Match `.meta` column width so lyrics align with title + progress */
  --lyrics-track: 100%;
}

@media (min-width: 900px) {
  #state-player {
    --lyrics-track: calc(min(1200px, 100%) - 140px - 1.25rem);
  }
}

@media (min-width: 1200px) {
  #state-player {
    --lyrics-track: calc(min(1200px, 100%) - 180px - 1.25rem);
  }
}

.player-top {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 1.25rem;
  align-items: start;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
}

.art-wrap {
  width: 140px;
  height: 140px;
  border-radius: 12px;
  overflow: hidden;
  background: #1a1a1a;
  flex-shrink: 0;
}

.album-art {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.album-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3rem;
  color: #444;
}

.meta {
  min-width: 0;
}

.track-title {
  margin: 0 0 0.35rem;
  font-size: 1.375rem;
  font-weight: 700;
  line-height: 1.2;
  color: #f0f0f0;
}

.track-artist {
  margin: 0 0 0.75rem;
  font-size: 1.125rem;
  color: #c8c8c8;
}

.progress-row {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.progress-bar {
  height: 8px;
  background: #2a2a2a;
  border-radius: 4px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: #1db954;
  border-radius: 4px;
  transition: width 0.1s linear;
}

.time-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.95rem;
  color: #a8a8a8;
}

.transport-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.25rem;
  margin-top: 0.85rem;
}

.transport-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: #e8e8e8;
  cursor: pointer;
  transition:
    color 0.15s ease,
    transform 0.08s ease,
    opacity 0.15s ease;
}

.transport-btn:hover:not(:disabled) {
  color: #fff;
  transform: scale(1.06);
}

.transport-btn:active:not(:disabled) {
  transform: scale(1);
}

.transport-btn:disabled {
  opacity: 0.28;
  cursor: not-allowed;
}

.transport-skip {
  width: 40px;
  height: 40px;
}

.transport-skip:hover:not(:disabled) {
  color: #fff;
}

.transport-play {
  width: 56px;
  height: 56px;
  background: #fff;
  color: #121212;
  flex-shrink: 0;
}

.transport-play:hover:not(:disabled) {
  transform: scale(1.05);
  background: #fff;
  color: #121212;
}

.transport-play:disabled {
  background: #3a3a3a;
  color: #888;
}

.transport-play .transport-icon-play.hidden,
.transport-play .transport-icon-pause.hidden {
  display: none;
}

.paused-badge {
  margin: 0.5rem 0 0;
  font-size: 0.95rem;
  color: #888;
  font-weight: 600;
}

.lyrics-panel {
  flex: 1;
  max-width: 1200px;
  width: 100%;
  min-width: 0;
  margin: 0 auto;
  min-height: 200px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
}

.lyrics-loading {
  font-size: 1.05rem;
  color: #a8a8a8;
}

.lyrics-content {
  width: 100%;
  max-height: min(55vh, 520px);
  overflow-y: auto;
  padding: 0.5rem 0.25rem;
  scrollbar-width: thin;
  scrollbar-color: #333 transparent;
}

/* After generic `.lyrics-content` so track cap wins over `width: 100%` (same width, max-width limits). */
#state-player .lyrics-panel > .lyrics-loading,
#state-player .lyrics-panel > .lyrics-content,
#state-player .lyrics-panel > .lyrics-pre,
#state-player .lyrics-panel > .lyrics-empty {
  width: 100%;
  max-width: var(--lyrics-track);
  min-width: 0;
  margin-inline: auto;
}

.lyrics-content--sync {
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 0;
  max-width: 100%;
  min-height: min(42vh, 420px);
  max-height: min(58vh, 640px);
  padding: 1rem 0.75rem;
  box-sizing: border-box;
}

.lyrics-sync-stack {
  position: relative;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 1.25rem;
  text-align: center;
}

.lyrics-sync-current {
  margin: 0;
  width: 100%;
  max-width: 70%;
  margin-inline: auto;
  position: relative;
  z-index: 1;
  font-size: clamp(2.22rem, min(6.25vmin, 6.6vw), 3.6rem);
  line-height: 1.45;
  font-weight: 600;
  color: #f0f0f0;
  min-height: 1.45em;
  white-space: nowrap;
  overflow-x: auto;
  overflow-y: hidden;
  text-align: center;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.22) transparent;
  transition:
    color 0.45s cubic-bezier(0.22, 1, 0.36, 1),
    opacity 0.45s cubic-bezier(0.22, 1, 0.36, 1);
}

.lyrics-sync-current::-webkit-scrollbar {
  height: 5px;
}

.lyrics-sync-current::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.28);
  border-radius: 3px;
}

.lyrics-sync-next {
  margin: 0;
  width: 100%;
  max-width: 50%;
  margin-inline: auto;
  font-size: clamp(1.74rem, min(4.8vmin, 5.05vw), 2.7rem);
  line-height: 1.45;
  font-weight: 500;
  color: #7a7a7a;
  min-height: 1.45em;
  white-space: nowrap;
  overflow-x: auto;
  overflow-y: hidden;
  text-align: center;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.15) transparent;
  transition:
    transform 0.5s cubic-bezier(0.22, 1, 0.36, 1),
    opacity 0.5s cubic-bezier(0.22, 1, 0.36, 1),
    color 0.45s cubic-bezier(0.22, 1, 0.36, 1);
}

.lyrics-sync-next::-webkit-scrollbar {
  height: 5px;
}

.lyrics-sync-next::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 3px;
}

.lyrics-sync-outgoing {
  position: absolute;
  left: 50%;
  top: 0;
  z-index: 2;
  width: 100%;
  max-width: 70%;
  margin: 0;
  padding: 0;
  pointer-events: none;
  font-size: clamp(2.22rem, min(6.25vmin, 6.6vw), 3.6rem);
  line-height: 1.45;
  font-weight: 600;
  color: #f0f0f0;
  text-align: center;
  opacity: 0;
  transform: translateX(-50%) translateY(0);
  white-space: nowrap;
  overflow: hidden;
}

.lyrics-sync-outgoing.lyrics-sync-outgoing--visible {
  opacity: 1;
}

.lyrics-sync-outgoing.lyrics-sync-outgoing--visible:not(.lyrics-sync-outgoing--exit) {
  transition: none;
}

.lyrics-sync-outgoing.lyrics-sync-outgoing--exit {
  opacity: 0;
  transform: translateX(-50%) translateY(-0.65em);
  transition:
    transform 0.5s cubic-bezier(0.22, 1, 0.36, 1),
    opacity 0.5s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes lyrics-next-promote {
  from {
    transform: translateY(0.85rem);
    opacity: 0.55;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.lyrics-sync-next.lyrics-sync-next--promote {
  animation: lyrics-next-promote 0.5s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.lyrics-sync-next.lyrics-sync-next--empty {
  visibility: hidden;
}

.lyrics-content::-webkit-scrollbar {
  width: 6px;
}

.lyrics-content::-webkit-scrollbar-thumb {
  background: #333;
  border-radius: 3px;
}

.lyrics-line {
  margin: 0 0 0.65rem;
  font-size: 1.35rem;
  line-height: 1.45;
  color: #f0f0f0;
}

.lyrics-pre {
  width: 100%;
  max-height: min(55vh, 520px);
  overflow-y: auto;
  margin: 0;
  font-family: inherit;
  font-size: 1.35rem;
  line-height: 1.45;
  white-space: pre-wrap;
  word-wrap: break-word;
  color: #f0f0f0;
}

.lyrics-empty {
  padding: 1rem 0;
}

@media (max-width: 899px) {
  .player-top {
    grid-template-columns: 1fr;
    justify-items: center;
    text-align: center;
  }

  .meta {
    width: 100%;
  }

  .progress-row {
    max-width: 100%;
  }

  .transport-row {
    gap: 1rem;
    margin-top: 0.75rem;
  }

  .transport-play {
    width: 52px;
    height: 52px;
  }

  .track-title {
    font-size: 1.25rem;
  }

  .lyrics-line,
  .lyrics-pre {
    font-size: 1.2rem;
  }
}

@media (min-width: 1200px) {
  .player-top {
    grid-template-columns: 180px 1fr;
  }

  .art-wrap {
    width: 180px;
    height: 180px;
  }

  .track-title {
    font-size: 1.5rem;
  }

  .lyrics-line,
  .lyrics-pre {
    font-size: 1.45rem;
  }
}
