/* ===== RESET & BASE ===== */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --bg: #0a0a0a;
  --bg-secondary: #141414;
  --bg-card: #1a1a1a;
  --bg-elevated: #242424;
  --text-primary: #ffffff;
  --text-secondary: #a0a0a0;
  --text-muted: #666666;
  --accent: #1db954;
  --accent-hover: #1ed760;
  --accent-dim: rgba(29, 185, 84, 0.15);
  --border: #2a2a2a;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 4px 24px rgba(0,0,0,0.4);
  --header-h: 56px;
  --nav-h: 64px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg);
  color: var(--text-primary);
  line-height: 1.5;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  padding-top: var(--header-h);
  padding-bottom: calc(var(--nav-h) + var(--safe-bottom));
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  font-family: inherit;
}

/* ===== HEADER — fixed top ===== */
.header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  background: rgba(10, 10, 10, 0.5);
  backdrop-filter: blur(40px) saturate(200%);
  -webkit-backdrop-filter: blur(40px) saturate(200%);
  border-bottom: 1px solid rgba(255,255,255,0.08);
  height: var(--header-h);
  display: flex;
  align-items: center;
}

.header-inner {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  max-width: 600px;
  margin: 0 auto;
  padding: 0 12px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 16px;
  font-weight: 800;
  color: var(--accent);
  white-space: nowrap;
  flex-shrink: 0;
  letter-spacing: -0.3px;
}

.logo svg {
  width: 20px;
  height: 20px;
}

.search-bar {
  flex: 1;
  display: flex;
  align-items: center;
  background: var(--bg-elevated);
  border-radius: 20px;
  padding: 6px 12px;
  gap: 6px;
  border: 1px solid transparent;
  transition: border-color 0.2s;
  min-width: 0;
}

.search-bar:focus-within {
  border-color: var(--accent);
}

.search-bar input {
  flex: 1;
  border: none;
  background: none;
  color: var(--text-primary);
  font-size: 13px;
  outline: none;
  min-width: 0;
}

.search-bar input::placeholder {
  color: var(--text-muted);
}

.search-bar svg {
  width: 15px;
  height: 15px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.search-bar .clear-btn {
  background: var(--bg-card);
  border: none;
  color: var(--text-secondary);
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 12px;
  line-height: 1;
  flex-shrink: 0;
}

/* ===== PAGE CONTENT ===== */
.page {
  max-width: 600px;
  margin: 0 auto;
  padding: 16px 12px;
  animation: fadeIn 0.25s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ===== SECTION TITLE ===== */
.section-title {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 16px;
  letter-spacing: -0.3px;
}

/* ===== SONG LIST (Trending) ===== */
.song-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.song-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  transition: background 0.15s;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.song-item:active {
  background: var(--bg-elevated);
}

.song-rank {
  width: 22px;
  text-align: center;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-muted);
  flex-shrink: 0;
}

.song-item:nth-child(-n+3) .song-rank {
  color: var(--accent);
}

.song-thumb {
  width: 46px;
  height: 46px;
  border-radius: 6px;
  background: var(--bg-elevated);
  overflow: hidden;
  flex-shrink: 0;
  position: relative;
}

.song-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.song-thumb .placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1a3a2a, #0d2818);
}

.song-thumb .placeholder svg {
  width: 18px;
  height: 18px;
  color: var(--accent);
  opacity: 0.5;
}

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

.song-title {
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 2px;
}

.song-artist {
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.song-views {
  font-size: 11px;
  color: var(--text-muted);
  flex-shrink: 0;
}

/* ===== SEARCH RESULTS ===== */
.search-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.search-header h2 {
  font-size: 18px;
  font-weight: 700;
}

.search-count {
  font-size: 13px;
  color: var(--text-secondary);
}

/* ===== SONG DETAIL ===== */
.song-detail {
  animation: slideUp 0.3s ease;
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

.song-title-main {
  font-size: 22px;
  font-weight: 800;
  line-height: 1.2;
  margin-bottom: 8px;
  letter-spacing: -0.3px;
}

.song-meta-main {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
  margin-bottom: 16px;
}

.song-meta-main span {
  font-size: 13px;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 4px;
}

.song-meta-main a {
  color: var(--accent);
}

.song-meta-main svg {
  width: 14px;
  height: 14px;
  color: var(--accent);
  flex-shrink: 0;
}

/* ===== TOOLBAR ===== */
.toolbar {
  display: flex;
  gap: 6px;
  margin-bottom: 14px;
  overflow-x: auto;
  padding-bottom: 4px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.toolbar::-webkit-scrollbar {
  display: none;
}

.toolbar-btn {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: all 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.toolbar-btn:active {
  transform: scale(0.95);
}

.toolbar-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* ===== LYRICS ===== */
.lyrics-box {
  background: var(--bg-secondary);
  border-radius: var(--radius);
  padding: 14px;
  border: 1px solid var(--border);
  overflow-x: auto;
}

.lyrics-content {
  font-size: 14px;
  line-height: 2;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: 'JetBrains Mono', 'Fira Code', 'SF Mono', 'Cascadia Code', 'Consolas', monospace;
}

.chord {
  color: var(--accent);
  font-weight: 700;
}

.chord-hidden .chord {
  display: none;
}

/* ===== SINGER LIST ===== */
.singer-section {
  margin-bottom: 14px;
}

.singer-section-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.singer-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.singer-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: var(--bg-card);
  border-radius: var(--radius-sm);
}

.singer-name {
  flex: 1;
  font-size: 13px;
  font-weight: 600;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.singer-tone {
  background: var(--accent-dim);
  color: var(--accent);
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
}

.singer-play-btn {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--accent);
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}

.singer-play-btn svg {
  width: 11px;
  height: 11px;
  color: #fff;
  margin-left: 1px;
}

/* ===== VIDEO ===== */
.video-box {
  margin-bottom: 14px;
  border-radius: var(--radius);
  overflow: hidden;
  background: #000;
  aspect-ratio: 16/9;
  position: relative;
  cursor: pointer;
}

.video-box img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.video-box .play-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.3);
}

.video-box .play-circle {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
}

.video-box .play-circle svg {
  width: 22px;
  height: 22px;
  color: #fff;
  margin-left: 3px;
}

.video-box iframe {
  width: 100%;
  height: 100%;
  border: none;
}

/* ===== LOADING / EMPTY ===== */
.loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  gap: 12px;
}

.spinner {
  width: 30px;
  height: 30px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.loading-text {
  font-size: 13px;
  color: var(--text-muted);
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  gap: 12px;
  text-align: center;
}

.empty-state svg {
  width: 44px;
  height: 44px;
  color: var(--text-muted);
  opacity: 0.4;
}

.empty-state p {
  font-size: 14px;
  color: var(--text-secondary);
}

/* ===== BOTTOM NAV — fixed bottom ===== */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(10, 10, 10, 0.5);
  backdrop-filter: blur(40px) saturate(200%);
  -webkit-backdrop-filter: blur(40px) saturate(200%);
  border-top: 1px solid rgba(255,255,255,0.08);
  display: flex;
  z-index: 100;
  height: var(--nav-h);
  padding-bottom: var(--safe-bottom);
}

.bottom-nav a {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 600;
  gap: 3px;
  transition: color 0.2s;
  -webkit-tap-highlight-color: transparent;
}

.bottom-nav a.active {
  color: var(--accent);
}

.bottom-nav a svg {
  width: 22px;
  height: 22px;
}

/* ===== RESPONSIVE ===== */

/* Tablet (601px+) */
@media (min-width: 601px) {
  .page {
    padding: 20px 24px;
  }

  .song-title-main {
    font-size: 26px;
  }

  .lyrics-content {
    font-size: 15px;
  }

  .song-item {
    padding: 8px 10px;
  }

  .song-thumb {
    width: 52px;
    height: 52px;
  }

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

  .song-artist {
    font-size: 13px;
  }
}

/* Desktop (900px+) */
@media (min-width: 900px) {
  body {
    border-left: 1px solid var(--border);
    border-right: 1px solid var(--border);
    max-width: 600px;
    margin: 0 auto;
  }

  .header {
    left: 50%;
    transform: translateX(-50%);
    max-width: 600px;
  }

  .bottom-nav {
    left: 50%;
    transform: translateX(-50%);
    max-width: 600px;
  }
}

/* Small phones (360px and below) */
@media (max-width: 360px) {
  .header-inner {
    padding: 0 8px;
    gap: 8px;
  }

  .logo {
    font-size: 14px;
  }

  .logo svg {
    width: 18px;
    height: 18px;
  }

  .search-bar {
    padding: 5px 10px;
  }

  .search-bar input {
    font-size: 12px;
  }

  .page {
    padding: 12px 8px;
  }

  .section-title {
    font-size: 18px;
  }

  .song-title-main {
    font-size: 20px;
  }

  .song-item {
    padding: 4px 6px;
    gap: 8px;
  }

  .song-rank {
    width: 18px;
    font-size: 12px;
  }

  .song-thumb {
    width: 40px;
    height: 40px;
  }

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

  .song-artist {
    font-size: 11px;
  }

  .song-views {
    font-size: 10px;
  }

  .toolbar-btn {
    font-size: 12px;
    padding: 5px 10px;
  }

  .lyrics-content {
    font-size: 13px;
  }

  .singer-name {
    font-size: 12px;
  }

  .singer-tone {
    font-size: 10px;
    padding: 2px 6px;
  }
}

/* Very small phones (320px) */
@media (max-width: 320px) {
  .logo span {
    display: none;
  }

  .song-title-main {
    font-size: 18px;
  }

  .lyrics-content {
    font-size: 12px;
  }
}
