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

body {
  font-family: -apple-system, sans-serif;
  margin: 2rem auto;
  padding: 0 1rem;
  color: #111;
}

section {
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  padding: 1rem;
  margin-bottom: 1rem;
}

section h2 {
  font-size: .7rem;
  font-weight: 600;
  color: #888;
  text-transform: uppercase;
  letter-spacing: .08em;
  margin: 0 0 .75rem;
}

input,
select,
button {
  padding: .45rem .65rem;
  font-size: .9rem;
  line-height: 1.4;
  height: 2.1rem;
  border: 1px solid #d0d0d0;
  border-radius: 6px;
  background: #fff;
  color: #111;
}

button {
  cursor: pointer;
}

button:disabled,
input:disabled {
  opacity: .4;
  cursor: default;
}

/* Sign-in card (shown instead of the tracks list when logged out) */
.recently-signin {
  text-align: center;
  padding: 2rem 1rem;
}

.recently-signin-icon {
  width: 52px;
  height: 52px;
  border-radius: 26px;
  background: #f2f2f4;
  color: #666;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto .9rem;
}

.recently-signin-title {
  font-size: .95rem;
  font-weight: 700;
  color: #111;
  margin-bottom: .25rem;
}

.recently-signin-sub {
  font-size: .8rem;
  color: #888;
  line-height: 1.4;
  margin-bottom: 1.1rem;
}

.recently-signin-btn {
  background: #111;
  color: #fff;
  border-color: #111;
  border-radius: 22px;
  font-weight: 600;
  padding: .6rem 1.6rem;
  height: auto;
}

/* Notification banner */
.notification-banner {
  position: fixed;
  top: 14px;
  left: 14px;
  right: 14px;
  max-width: 480px;
  margin: 0 auto;
  background: #2b2b2f;
  color: #fff;
  border-radius: 10px;
  padding: .6rem .75rem;
  font-size: .8rem;
  box-shadow: 0 6px 16px rgba(0, 0, 0, .25);
  z-index: 20;
  transform: translateY(-140%);
  opacity: 0;
  pointer-events: none;
}

.notification-banner.show {
  animation: notification-banner-show 5s ease-in-out 1;
}

@keyframes notification-banner-show {
  0%   { transform: translateY(-140%); opacity: 0; }
  8%   { transform: translateY(0);      opacity: 1; }
  78%  { transform: translateY(0);      opacity: 1; }
  100% { transform: translateY(-140%); opacity: 0; }
}

/* Player */
#player-section {
  border: none;
  padding: 0;
}

.player-layout {
  text-align: center;
  max-width: 280px;
  margin: 0 auto;
  padding-top: 6px;
}

#artwork {
  width: 170px;
  height: 170px;
  border-radius: 12px;
  object-fit: cover;
  display: block;
  margin: 0 auto .6rem;
  box-shadow: 0 6px 16px rgba(0, 0, 0, .15);
  background: linear-gradient(135deg, #d9d9de, #b8b8c0);
}

#now-playing-title {
  font-size: .95rem;
  font-weight: 700;
  color: #111;
  line-height: 1.2;
  min-height: 1.2em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#now-playing-artist {
  font-size: .8rem;
  color: #888;
  margin-top: .1rem;
  margin-bottom: .7rem;
  line-height: 1.1;
  min-height: 1.1em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.player-seek {
  margin-bottom: .7rem;
}

.player-seek input[type="range"] {
  width: 100%;
  height: auto;
  padding: 0;
  border: none;
  background: transparent;
  cursor: pointer;
  display: block;
}

.seek-times {
  display: flex;
  justify-content: space-between;
  font-size: .7rem;
  color: #aaa;
  margin-top: .15rem;
}

.player-buttons {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2rem;
  margin-bottom: .7rem;
}

.player-icon-btn {
  border: none;
  background: none;
  padding: 0;
  height: auto;
  color: #111;
  display: flex;
}

.player-icon-btn:disabled {
  opacity: .3;
}

.player-volume {
  display: flex;
  align-items: center;
  gap: .5rem;
  color: #999;
  margin-bottom: .6rem;
}

#volume {
  flex: 1;
  height: auto;
  padding: 0;
  border: none;
  background: transparent;
  cursor: pointer;
}

.airplay-row {
  display: flex;
  align-items: center;
  justify-content: center;
  width: auto;
  height: auto;
  margin: 0 auto;
  padding: .3rem .5rem;
  border: none;
  background: none;
  color: #555;
}

.airplay-row:disabled {
  opacity: .4;
}

/* Recently Played Tracks list */
.recently-header {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: .75rem;
}

.recently-header h2 {
  margin: 0;
}

.icon-btn {
  width: 1.8rem;
  height: 1.8rem;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: #f2f2f4;
  color: #666;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sort-sheet {
  position: absolute;
  top: 2.2rem;
  right: 0;
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 10px;
  box-shadow: 0 8px 20px rgba(0, 0, 0, .12);
  overflow: hidden;
  z-index: 10;
  min-width: 180px;
}

.sort-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  width: 100%;
  padding: .55rem .8rem;
  border: none;
  border-bottom: 1px solid #f0f0f0;
  border-radius: 0;
  background: #fff;
  font-size: .85rem;
  text-align: left;
  height: auto;
}

.sort-option:last-child {
  border-bottom: none;
}

.sort-option-indicator {
  font-size: .8rem;
  color: #666;
}

.track-row {
  display: flex;
  align-items: center;
  gap: .65rem;
  padding: .5rem 0;
  border-bottom: 1px solid #f0f0f0;
  cursor: pointer;
}

.track-row:focus-visible {
  outline: 2px solid #007aff;
  outline-offset: -2px;
}

.track-row:last-child {
  border-bottom: none;
}

.track-artwork {
  width: 44px;
  height: 44px;
  border-radius: 6px;
  object-fit: cover;
  flex-shrink: 0;
  background: linear-gradient(135deg, #d9d9de, #b8b8c0);
  display: block;
}

.track-info {
  min-width: 0;
  flex: 1;
}

.track-title {
  font-size: .875rem;
  font-weight: 600;
  color: #111;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.track-subtitle {
  font-size: .775rem;
  color: #888;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.track-duration {
  font-size: .775rem;
  color: #aaa;
  flex-shrink: 0;
}

#recently-played-tracks-empty {
  color: #aaa;
  font-size: .875rem;
  margin: .5rem 0;
}

.tracks-sentinel {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: .75rem 0;
}

.spinner {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid #e0e0e0;
  border-top-color: #888;
}

.spinner.spin {
  animation: spin .7s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.pull-refresh-indicator {
  position: fixed;
  top: 14px;
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  z-index: 15;
}

/* Responsive */
@media (max-width: 540px) {
  body {
    margin: 1rem auto;
  }

  input,
  select,
  button {
    height: 2.75rem;
    font-size: 1rem;
  }
}
