:root {
  --bg-color: #f8f9fa;
  --card-bg: #ffffff;
  --text-main: #212529;
  --text-muted: #6c757d;
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --border: #e9ecef;
  --radius: 16px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background-color: var(--bg-color);
  color: var(--text-main);
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100vh;
  padding: 16px;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
  width: 100%;
}

.header-logo {
  width: 32px;
  height: 32px;
  object-fit: cover;
  border-radius: 6px;
}

.disc-art {
  width: 80px;
  height: 80px;
  background: url('private-player.png') no-repeat center/cover;
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0;
  animation: spinDisc 4s linear infinite;
  animation-play-state: paused;
}

.app-container {
  width: 100%;
  max-width: 540px;
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow:
    0 10px 25px -5px rgba(0, 0, 0, 0.05),
    0 8px 10px -6px rgba(0, 0, 0, 0.05);
  padding: 24px;
  margin-top: 20px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.yt-player-wrapper {
  margin-top: 12px;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #111;
  border-radius: 12px;
  overflow: hidden;
  position: relative;
}

.drive-visualizer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, #4f46e5, #070428);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  animation: pulseBg 8s ease-in-out infinite alternate;
  color: white;
}

.visualizer-bars {
  display: flex;
  gap: 4px;
  height: 30px;
  align-items: flex-end;
  margin-top: 16px;
}

.v-bar {
  width: 4px;
  background: #fff;
  border-radius: 2px;
}
.v-bar:nth-child(1) {
  height: 60%;
  animation: v-bounce 0.5s ease-in-out infinite alternate;
}
.v-bar:nth-child(2) {
  height: 90%;
  animation: v-bounce 0.7s ease-in-out infinite alternate;
  animation-delay: 0.2s;
}
.v-bar:nth-child(3) {
  height: 40%;
  animation: v-bounce 0.6s ease-in-out infinite alternate;
  animation-delay: 0.4s;
}
.v-bar:nth-child(4) {
  height: 75%;
  animation: v-bounce 0.8s ease-in-out infinite alternate;
  animation-delay: 0.1s;
}

.source-tabs {
  display: flex;
  gap: 8px;
  margin-top: 16px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.tab-btn {
  flex: 1;
  padding: 8px;
  border-radius: 8px;
  border: 1px solid #e9ecef;
  background: #ffffff;
  color: #212529;
  cursor: pointer;
  white-space: nowrap;
}
.tab-btn.is-shorts {
  min-width: 100px;
}
.tab-btn.active {
  border-color: var(--primary);
  background: var(--primary);
  color: var(--oshi-text);
  font-weight: bold;
}

.track-list-container {
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

@media (max-width: 480px) {
  body {
    padding: 8px;
  }
  .app-container {
    padding: 20px;
    margin-top: 8px;
    border-radius: 20px;
  }
}

h1 {
  font-size: 1.5rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}

.player-header {
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--bg-color);
  padding: 16px;
  border-radius: 12px;
  border: 1px solid var(--border);
}

.current-title {
  font-size: 1rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text-main);
}

audio {
  width: 100%;
  height: 40px;
}

.section-title {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  font-weight: 700;
}

.track-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 380px;
  overflow-y: auto;
  padding-right: 4px;
}

.track-list::-webkit-scrollbar {
  width: 6px;
}
.track-list::-webkit-scrollbar-track {
  background: transparent;
}
.track-list::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 3px;
}

.track-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 52px;
  padding: 0 16px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: default;
  font-size: 0.95rem;
  font-weight: 500;
  transition: all 0.2s ease;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.track-item.playing {
  background: var(--primary-light) !important;
  border-color: var(--primary) !important;
  color: var(--primary) !important;
  font-weight: 700;
}

.equalizer {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  width: 16px;
  height: 16px;
  margin-right: 12px;
  flex-shrink: 0;
}

.equalizer-bar {
  width: 3px;
  height: 100%;
  background-color: var(--primary);
  border-radius: 2px;
  transform-origin: bottom;
  animation: bounce 1s ease-in-out infinite alternate;
}

.equalizer-bar:nth-child(2) {
  animation-delay: 0.2s;
  animation-duration: 0.8s;
}
.equalizer-bar:nth-child(3) {
  animation-delay: 0.4s;
  animation-duration: 1.1s;
}

.audio-paused .equalizer-bar {
  animation-play-state: paused;
  height: 30% !important;
}

@keyframes bounce {
  0% {
    transform: scaleY(0.2);
  }
  100% {
    transform: scaleY(1);
  }
}

.track-info {
  display: flex;
  align-items: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex-grow: 1;
  cursor: pointer;
}

.download-btn {
  background: transparent;
  border: none;
  font-size: 1.1rem;
  cursor: pointer;
  padding: 8px;
  margin-left: 8px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
  flex-shrink: 0;
}

.download-btn:hover {
  background: rgba(0, 0, 0, 0.05);
}

.download-btn.saved {
  color: #10b981;
  cursor: default;
}

.download-btn.saved:hover {
  background: transparent;
}

.download-btn.spin {
  animation: spin 1s linear infinite;
  pointer-events: none;
  color: var(--primary);
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

.tracks-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  width: 100%;
}

.bulk-download-btn {
  background-color: transparent;
  border: 1px solid var(--primary);
  color: var(--primary);
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.bulk-download-btn:hover {
  background-color: var(--primary);
  color: white;
}

.bulk-download-btn:disabled {
  border-color: var(--border);
  color: var(--text-muted);
  cursor: not-allowed;
  background-color: transparent;
}

@media (hover: hover) {
  .track-item:hover {
    background: #f4f4ff;
    border-color: #c7d2fe;
    color: var(--primary);
    transform: translateY(-1px);
  }
}

.track-item:active {
  background: #e0e7ff;
  transform: scale(0.98);
}

.auth-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  text-align: center;
  gap: 16px;
}

.auth-box p {
  color: var(--text-muted);
  font-size: 0.95rem;
}

.hidden {
  display: none !important;
}

.error {
  color: #dc2626;
  font-size: 0.9rem;
  background: #fef2f2;
  padding: 12px;
  border-radius: 8px;
  border: 1px solid #fca5a5;
}

@keyframes pulseBg {
  0% {
    filter: hue-rotate(0deg);
    opacity: 0.9;
  }
  100% {
    filter: hue-rotate(45deg);
    opacity: 1;
  }
}
@keyframes spinDisc {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}
@keyframes v-bounce {
  0% {
    height: 20%;
  }
  100% {
    height: 100%;
  }
}

/* 再生・停止にあわせた波形連動用のクラス */
.audio-paused .v-bar {
  animation-play-state: paused !important;
  height: 30% !important;
}

.reset-cache-btn {
  margin-left: auto;
  background: var(--bg-color);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s ease;
}

.reset-cache-btn:hover {
  background: #fee2e2;
  border-color: #fca5a5;
  color: #dc2626;
}

footer {
  margin-top: auto;
  padding: 24px 0 12px;
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-muted);
  width: 100%;
}
