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

:root {
  --primary: #064E5B;
  --primary-light: #17A2B8;
  --primary-dark: #0B7285;
  --bg: #F5F7FA;
  --card: #FFFFFF;
  --text: #1A1A2E;
  --text-secondary: #6B7280;
  --text-light: #9CA3AF;
  --border: #E5E7EB;
  --red: #E65100;
  --radius: 12px;
  --shadow: 0 2px 8px rgba(0,0,0,0.08);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  padding-bottom: 70px;
  width: 100%;
  max-width: 600px;
  margin: 0 auto;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* Header */
.header {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  padding: 12px 12px;
  position: sticky;
  top: 0;
  z-index: 100;
}
.header-inner { display: flex; align-items: center; gap: 10px; }
.logo {
  display: flex; align-items: center; gap: 6px;
  color: #fff; font-size: 18px; font-weight: 800;
  text-decoration: none; white-space: nowrap;
  flex-shrink: 0;
}
.logo svg { width: 24px; height: 24px; }

.search-bar {
  flex: 1; display: flex; align-items: center;
  background: rgba(255,255,255,0.15);
  border-radius: 24px; padding: 7px 12px; gap: 6px;
  min-width: 0;
}
.search-bar input {
  flex: 1; border: none; background: none;
  color: #fff; font-size: 14px; outline: none;
  min-width: 0;
}
.search-bar input::placeholder { color: rgba(255,255,255,0.6); }
.search-bar svg { width: 18px; height: 18px; color: rgba(255,255,255,0.7); flex-shrink: 0; }
.search-bar .clear-btn {
  background: rgba(255,255,255,0.2); border: none; color: #fff;
  width: 20px; height: 20px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; font-size: 14px; line-height: 1; flex-shrink: 0;
}
.search-icon { color: rgba(255,255,255,0.6) !important; }
.voice-icon { color: rgba(255,255,255,0.6) !important; cursor: pointer; }
.cancel-btn {
  color: #fff; background: none; border: none;
  font-size: 14px; cursor: pointer; white-space: nowrap; flex-shrink: 0;
}

/* Page sections */
.page-title-bar {
  padding: 14px 12px 6px;
  display: flex; align-items: center; justify-content: space-between;
}
.page-title-bar h2 { font-size: 15px; font-weight: 700; }
.page-title-bar .view-all {
  color: var(--primary-light); font-size: 13px;
  text-decoration: none; font-weight: 600; flex-shrink: 0;
}
.result-count { color: var(--text-secondary); font-size: 13px; flex-shrink: 0; }
.section { padding: 6px 12px 14px; }

/* Song cards */
.card-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.song-card {
  background: var(--card); border-radius: var(--radius);
  overflow: hidden; box-shadow: var(--shadow);
  text-decoration: none; color: var(--text);
  display: flex; flex-direction: column;
  transition: transform 0.15s;
}
.song-card:active { transform: scale(0.97); }
.card-thumb {
  position: relative; width: 100%;
  aspect-ratio: 16/10;
  background: linear-gradient(135deg, #2c3e50, #4ca1af);
  overflow: hidden;
}
.card-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.card-thumb .play-btn {
  position: absolute; bottom: 6px; right: 6px;
  width: 28px; height: 28px;
  background: rgba(230,81,0,0.9); border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
}
.card-thumb .play-btn svg { width: 12px; height: 12px; color: #fff; margin-left: 2px; }
.card-thumb .new-badge {
  position: absolute; top: 6px; left: 6px;
  background: #22C55E; color: #fff;
  font-size: 9px; font-weight: 700;
  padding: 2px 5px; border-radius: 4px;
}
.card-body { padding: 8px; flex: 1; display: flex; flex-direction: column; }
.card-title {
  font-size: 12px; font-weight: 700; line-height: 1.3;
  display: -webkit-box; -webkit-line-clamp: 2;
  -webkit-box-orient: vertical; overflow: hidden;
  margin-bottom: 3px;
}
.card-artist { font-size: 11px; color: var(--text-secondary); margin-bottom: 2px; }
.card-meta {
  font-size: 10px; color: var(--text-light);
  display: flex; align-items: center; gap: 2px; margin-bottom: 1px;
}
.card-meta svg { width: 10px; height: 10px; }
.card-views {
  font-size: 10px; color: var(--primary-light);
  display: flex; align-items: center; gap: 2px; font-weight: 600;
}
.card-views svg { width: 10px; height: 10px; }
.has-chord {
  display: inline-block; font-size: 9px;
  background: rgba(23,162,184,0.1); color: var(--primary-light);
  padding: 1px 6px; border-radius: 10px;
  margin-top: 5px; font-weight: 600;
}

/* Category tiles - 4 columns fixed row */
.category-tiles {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  width: 100%;
}
.category-tile {
  border-radius: 14px;
  padding: 14px 6px;
  text-align: center;
  color: #fff;
  text-decoration: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: transform 0.15s;
  box-shadow: 0 2px 10px rgba(0,0,0,0.12);
  min-height: 105px;
}
.category-tile:active { transform: scale(0.96); }
.category-tile svg { width: 26px; height: 26px; opacity: 0.95; }
.category-tile .tile-name { font-size: 11px; font-weight: 700; line-height: 1.2; }
.category-tile .tile-count { font-size: 9px; opacity: 0.8; }
.tile-blue { background: linear-gradient(135deg, #0891B2, #06B6D4); }
.tile-green { background: linear-gradient(135deg, #16A34A, #4ADE80); }
.tile-purple { background: linear-gradient(135deg, #7C3AED, #A78BFA); }
.tile-orange { background: linear-gradient(135deg, #EA580C, #FB923C); }
.tile-pink { background: linear-gradient(135deg, #DB2777, #F472B6); }
.tile-teal { background: linear-gradient(135deg, #0D9488, #5EEAD4); }
.tile-indigo { background: linear-gradient(135deg, #4F46E5, #818CF8); }

/* Bottom nav */
.bottom-nav {
  position: fixed; bottom: 0; left: 0;
  width: 100%; max-width: 100%;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  display: flex; border-top: 1px solid rgba(255,255,255,0.1);
  z-index: 100;
  padding-bottom: env(safe-area-inset-bottom, 0);
}
.bottom-nav a {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; padding: 8px 0 10px;
  text-decoration: none; color: rgba(255,255,255,0.5);
  font-size: 10px; font-weight: 600; gap: 2px;
  transition: color 0.2s;
}
.bottom-nav a.active { color: #fff; }
.bottom-nav a svg { width: 20px; height: 20px; }

/* Song detail */
.song-detail-header {
  padding: 14px 12px; background: var(--card);
  border-radius: 0 0 var(--radius) var(--radius);
  box-shadow: var(--shadow);
}
.song-title { font-size: 18px; font-weight: 800; margin-bottom: 8px; }
.song-meta-row {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
}
.song-meta-item {
  display: flex; align-items: center; gap: 3px;
  font-size: 11px; color: var(--text-secondary);
  max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.song-meta-item svg { width: 14px; height: 14px; color: var(--primary-light); flex-shrink: 0; }
.song-meta-item a {
  color: var(--primary-light); text-decoration: none; font-weight: 600;
  overflow: hidden; text-overflow: ellipsis;
}
.song-meta-item a:hover { text-decoration: underline; }

/* Video */
.video-container {
  margin: 10px 12px; border-radius: var(--radius);
  overflow: hidden; background: #000;
  aspect-ratio: 16/9; display: flex;
  align-items: center; justify-content: center;
  position: relative; cursor: pointer;
}
.video-container img { width: 100%; height: 100%; object-fit: cover; display: block; }
.video-container .big-play {
  position: absolute; width: 56px; height: 56px;
  background: rgba(230,81,0,0.9); border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
}
.video-container .big-play svg { width: 24px; height: 24px; color: #fff; margin-left: 4px; }
.video-container iframe { width: 100%; height: 100%; border: none; }

/* Singer list */
.singer-list {
  margin: 0 12px 10px; background: var(--card);
  border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden;
}
.singer-item {
  display: flex; align-items: center; padding: 10px 12px;
  border-bottom: 1px solid var(--border); gap: 10px;
}
.singer-item:last-child { border-bottom: none; }
.singer-num { font-size: 13px; font-weight: 700; color: var(--text-secondary); width: 18px; text-align: center; flex-shrink: 0; }
.singer-play {
  width: 28px; height: 28px; border-radius: 50%;
  background: rgba(23,162,184,0.1); display: flex;
  align-items: center; justify-content: center;
  border: none; cursor: pointer; flex-shrink: 0;
}
.singer-play svg { width: 10px; height: 10px; color: var(--primary-light); margin-left: 1px; }
.singer-name { flex: 1; font-size: 13px; font-weight: 600; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.singer-tone-tag {
  background: rgba(23,162,184,0.1); color: var(--primary-light);
  padding: 2px 8px; border-radius: 6px;
  font-size: 11px; font-weight: 600;
  border: 1px solid rgba(23,162,184,0.2); flex-shrink: 0;
}

/* Toolbar */
.chord-toolbar {
  margin: 0 12px 10px;
  display: flex; flex-wrap: nowrap; gap: 4px; align-items: center;
  overflow-x: auto; padding-bottom: 4px;
}
.toolbar-btn {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 6px; padding: 5px 7px;
  font-size: 12px; font-weight: 700; cursor: pointer; color: var(--text);
  white-space: nowrap; flex-grow: 1; min-width: 32px; text-align: center;
}
.toolbar-btn:active { transform: scale(0.95); }
.toolbar-btn.active {
  background: var(--primary-light); color: #fff;
  border-color: var(--primary-light);
}
.tone-display {
  background: var(--primary-light); color: #fff;
  border-color: var(--primary-light); cursor: default;
  min-width: 40px;
}

/* Lyrics */
.lyrics-container {
  margin: 0 12px 14px; background: var(--card);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px;
  overflow-x: auto;
}
.lyrics-content {
  font-size: 13px; line-height: 1.9; white-space: pre-wrap;
  word-break: break-word;
}
.chord { color: #E65100; font-weight: 700; }

/* Category header */
.category-header {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: #fff; padding: 20px 12px; text-align: center;
}
.category-header h1 { font-size: 20px; font-weight: 800; }
.category-header .count { font-size: 12px; opacity: 0.8; margin-top: 4px; }

/* Pagination */
.pagination {
  display: flex; justify-content: center; gap: 6px; padding: 14px 12px;
}
.pagination button {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 8px; padding: 6px 12px;
  font-size: 12px; font-weight: 600; cursor: pointer; color: var(--text);
}
.pagination button.active {
  background: var(--primary-light); color: #fff;
  border-color: var(--primary-light);
}
.pagination button:disabled { opacity: 0.4; cursor: default; }

/* Loading / Empty */
.loading {
  text-align: center; padding: 40px;
  color: var(--text-light); font-size: 14px;
}
.loading::after {
  content: ''; display: inline-block;
  width: 20px; height: 20px;
  border: 2px solid var(--border); border-top-color: var(--primary-light);
  border-radius: 50%; animation: spin 0.8s linear infinite;
  margin-left: 8px; vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }
.empty-state {
  text-align: center; padding: 50px 16px; color: var(--text-light);
}
.empty-state svg { width: 40px; height: 40px; margin-bottom: 10px; }
.empty-state p { font-size: 13px; }
::-webkit-scrollbar { width: 0; height: 0; }

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

/* Tablets and up (601px+) */
@media (min-width: 601px) {
  body {
    border-left: 1px solid var(--border);
    border-right: 1px solid var(--border);
  }
  .bottom-nav {
    max-width: 600px;
    left: 50%;
    transform: translateX(-50%);
  }
  .card-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 14px;
  }
  .song-card {
    border-radius: 14px;
  }
  .card-body { padding: 12px; }
  .card-title { font-size: 13px; }
  .card-artist { font-size: 12px; }
  .card-views { font-size: 11px; }
  .song-detail-header { padding: 18px 20px; }
  .song-title { font-size: 22px; }
  .singer-list { margin: 0 20px 14px; }
  .chord-toolbar { margin: 0 20px 14px; }
  .lyrics-container { margin: 0 20px 18px; padding: 18px; }
  .video-container { margin: 14px 20px; }
  .singer-item { padding: 12px 16px; }
  .singer-name { font-size: 14px; }
  .lyrics-content { font-size: 14px; }
  .category-header { padding: 28px 20px; }
  .category-header h1 { font-size: 24px; }
  .category-tiles { gap: 14px; }
  .category-tile { min-height: 120px; padding: 16px 10px; }
  .category-tile svg { width: 30px; height: 30px; }
  .category-tile .tile-name { font-size: 13px; }
  .category-tile .tile-count { font-size: 11px; }
}

/* Desktop (900px+) */
@media (min-width: 900px) {
  .card-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

/* Small phones (360px and below) */
@media (max-width: 360px) {
  .header { padding: 10px 8px; }
  .logo { font-size: 16px; }
  .logo svg { width: 22px; height: 22px; }
  .search-bar { padding: 6px 10px; }
  .search-bar input { font-size: 13px; }
  .card-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }
  .card-thumb .play-btn { width: 24px; height: 24px; }
  .card-thumb .play-btn svg { width: 10px; height: 10px; }
  .card-body { padding: 6px; }
  .card-title { font-size: 11px; }
  .card-artist { font-size: 10px; }
  .card-views { font-size: 9px; }
  .has-chord { font-size: 8px; }
  .category-tiles { gap: 6px; }
  .category-tile { min-height: 85px; padding: 10px 4px; }
  .category-tile svg { width: 20px; height: 20px; }
  .category-tile .tile-name { font-size: 10px; }
  .category-tile .tile-count { font-size: 8px; }
  .song-title { font-size: 16px; }
  .song-meta-row { gap: 6px; }
  .song-meta-item { font-size: 10px; }
  .singer-item { padding: 8px 10px; gap: 8px; }
  .singer-name { font-size: 12px; }
  .singer-tone-tag { font-size: 10px; padding: 2px 6px; }
  .chord-toolbar { gap: 3px; margin: 0 8px 8px; }
  .toolbar-btn { font-size: 11px; padding: 4px 5px; min-width: 28px; }
  .lyrics-content { font-size: 12px; }
  .page-title-bar { padding: 12px 8px 6px; }
  .section { padding: 6px 8px 12px; }
}

/* Very small phones (320px and below) */
@media (max-width: 320px) {
  .card-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 6px;
  }
  .card-title { font-size: 10px; -webkit-line-clamp: 1; }
  .card-artist { font-size: 9px; }
  .card-views { font-size: 9px; }
  .category-tiles { gap: 4px; }
  .category-tile { min-height: 72px; padding: 6px 2px; }
  .category-tile svg { width: 16px; height: 16px; }
  .category-tile .tile-name { font-size: 9px; }
  .category-tile .tile-count { font-size: 7px; }
}
