:root {
  --bg: #0c0a0f;
  --surface: #16121c;
  --surface-hover: #1f1a26;
  --border: #2a2433;
  --text: #f4f0f8;
  --text-muted: #9b92a8;
  --accent: #f97316;
  --accent-glow: rgba(249, 115, 22, 0.35);
  --accent-soft: rgba(249, 115, 22, 0.15);
  --radius: 14px;
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
  --header-h: auto;
  --footer-h: 28px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: "DM Sans", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

.splash {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  transition: opacity 0.6s ease, visibility 0.6s ease;
}

.splash.splash-hide {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.splash-inner {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 28px;
  padding: 24px;
}

.splash-top,
.splash-bottom {
  font-size: clamp(1.35rem, 5vw, 1.85rem);
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -0.02em;
  color: var(--accent);
}

.splash-icon {
  width: clamp(120px, 32vw, 180px);
  height: clamp(120px, 32vw, 180px);
  display: grid;
  place-items: center;
  font-size: clamp(72px, 18vw, 110px);
  color: var(--accent);
  border: 3px solid var(--accent);
  border-radius: 28px;
  background: rgba(249, 115, 22, 0.08);
  font-family: "Segoe UI Symbol", "Noto Music", "Apple Symbols", serif;
  line-height: 1;
}

.app.app-hidden {
  opacity: 0;
  pointer-events: none;
}

.app {
  transition: opacity 0.6s ease;
}

.app:not(.app-hidden) {
  opacity: 1;
  pointer-events: auto;
}

.bg-glow {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 50% at 20% -10%, var(--accent-glow), transparent),
    radial-gradient(ellipse 60% 40% at 90% 100%, rgba(120, 80, 200, 0.12), transparent);
  pointer-events: none;
  z-index: 0;
}

.app {
  position: relative;
  z-index: 1;
  max-width: 1100px;
  margin: 0 auto;
  padding: 16px 20px;
  padding-bottom: calc(16px + env(safe-area-inset-bottom));
  padding-top: calc(16px + env(safe-area-inset-top));
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow: hidden;
}

.header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-shrink: 0;
}

.logo {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.logo-icon {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  background: var(--accent-soft);
  border: 1px solid rgba(249, 115, 22, 0.3);
  border-radius: 12px;
  font-size: 20px;
  color: var(--accent);
  flex-shrink: 0;
}

.logo h1 {
  font-size: clamp(1rem, 2.5vw, 1.3rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.25;
}

.subtitle {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 2px;
  word-break: break-all;
}

.subtitle a {
  color: var(--accent);
  text-decoration: none;
}

.subtitle a:hover {
  text-decoration: underline;
}

.header-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.btn {
  border: none;
  border-radius: 10px;
  padding: 9px 14px;
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
  white-space: nowrap;
}

.btn:active {
  transform: scale(0.97);
}

.btn-ghost {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-ghost:hover {
  background: var(--surface-hover);
}

.install-btn.hidden {
  display: none;
}

.main {
  display: grid;
  grid-template-columns: minmax(260px, 320px) 1fr;
  gap: 16px;
  flex: 1;
  min-height: 0;
  align-items: stretch;
}

.playlist-panel,
.player-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  min-height: 0;
  overflow: hidden;
}

.playlist-panel {
  padding: 16px;
  display: flex;
  flex-direction: column;
}

.playlist-panel h2 {
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.badge {
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.75rem;
  padding: 2px 8px;
  border-radius: 999px;
}

.track-list-wrap {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  margin: 0 -6px;
  padding: 0 6px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.track-list-wrap::-webkit-scrollbar {
  width: 6px;
}

.track-list-wrap::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 999px;
}

.track-list {
  list-style: none;
}

.track-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 8px;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.15s;
  position: relative;
}

.new-badge {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1.5px solid var(--accent);
  background: rgba(249, 115, 22, 0.12);
  color: var(--accent);
  font-size: 0.68rem;
  font-weight: 700;
  display: grid;
  place-items: center;
  line-height: 1;
  margin-left: auto;
  cursor: default;
}

.track-item:hover {
  background: var(--surface-hover);
}

.track-item.active {
  background: var(--accent-soft);
  border: 1px solid rgba(249, 115, 22, 0.25);
}

.track-thumb {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  object-fit: cover;
  background: var(--border);
  flex-shrink: 0;
}

.track-meta {
  min-width: 0;
}

.track-meta .title {
  font-weight: 600;
  font-size: 0.88rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.track-meta .artist {
  font-size: 0.78rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.empty-state {
  color: var(--text-muted);
  font-size: 0.9rem;
  text-align: center;
  padding: 40px 12px;
}

.empty-state.hidden {
  display: none;
}

.player-panel {
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.now-playing {
  display: flex;
  gap: 20px;
  align-items: center;
  flex-shrink: 0;
}

.cover-wrap {
  width: 140px;
  height: 140px;
  flex-shrink: 0;
}

.cover {
  width: 100%;
  height: 100%;
  border-radius: 14px;
  object-fit: cover;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
}

.cover.hidden {
  display: none;
}

.cover-placeholder {
  width: 100%;
  height: 100%;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--accent-soft), var(--border));
  display: grid;
  place-items: center;
  font-size: 42px;
  color: var(--accent);
}

.cover-placeholder.hidden {
  display: none;
}

.track-info {
  min-width: 0;
}

.track-info h2 {
  font-size: clamp(1.1rem, 2.5vw, 1.5rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 4px;
  line-height: 1.2;
}

.track-info .artist {
  color: var(--text-muted);
  font-size: 0.95rem;
}

.visualizer-wrap {
  flex: 1;
  min-height: 100px;
  max-height: 180px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border);
  overflow: hidden;
  position: relative;
}

#visualizer {
  display: block;
  width: 100%;
  height: 100%;
}

.controls {
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex-shrink: 0;
}

.progress-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}

.time {
  font-size: 0.78rem;
  color: var(--text-muted);
  min-width: 34px;
  font-variant-numeric: tabular-nums;
}

.progress,
.volume {
  -webkit-appearance: none;
  appearance: none;
  height: 5px;
  border-radius: 999px;
  background: var(--border);
  outline: none;
  cursor: pointer;
}

.progress {
  flex: 1;
}

.progress::-webkit-slider-thumb,
.volume::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
}

.buttons {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

.ctrl-btn {
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 50%;
  background: var(--surface-hover);
  color: var(--text);
  font-size: 1rem;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}

.ctrl-btn:hover {
  background: var(--border);
}

.ctrl-btn:active {
  transform: scale(0.95);
}

.play-btn {
  width: 54px;
  height: 54px;
  background: var(--accent);
  font-size: 1.15rem;
}

.play-btn:hover {
  background: #ea580c;
}

.shuffle-btn.active {
  background: var(--accent-soft);
  color: var(--accent);
}

.volume-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 200px;
  margin: 0 auto;
}

.volume {
  flex: 1;
}

.footer {
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-muted);
  flex-shrink: 0;
  padding-bottom: 2px;
}

.footer #status.loading {
  color: var(--accent);
}

@media (max-width: 800px) {
  .app {
    padding: 10px 12px;
    gap: 8px;
    padding-bottom: calc(8px + env(safe-area-inset-bottom));
    padding-top: calc(10px + env(safe-area-inset-top));
  }

  .header {
    gap: 8px;
    align-items: center;
  }

  .logo {
    gap: 10px;
  }

  .logo-icon {
    width: 36px;
    height: 36px;
    font-size: 16px;
    border-radius: 10px;
  }

  .logo h1 {
    font-size: 0.88rem;
    line-height: 1.2;
  }

  .subtitle {
    font-size: 0.68rem;
    margin-top: 1px;
  }

  .btn {
    padding: 7px 10px;
    font-size: 0.78rem;
  }

  .header-actions .install-btn {
    display: none;
  }

  .main {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr 1fr;
    gap: 10px;
  }

  .playlist-panel,
  .player-panel {
    min-height: 0;
  }

  .playlist-panel {
    padding: 10px 12px;
  }

  .playlist-panel h2 {
    font-size: 0.82rem;
    margin-bottom: 6px;
  }

  .badge {
    font-size: 0.68rem;
    padding: 1px 6px;
  }

  .track-item {
    padding: 4px 6px;
    gap: 8px;
    border-radius: 8px;
  }

  .track-thumb {
    width: 32px;
    height: 32px;
    border-radius: 6px;
  }

  .track-meta .title {
    font-size: 0.78rem;
    line-height: 1.15;
  }

  .track-meta .artist {
    font-size: 0.65rem;
    line-height: 1.15;
  }

  .new-badge {
    width: 18px;
    height: 18px;
    font-size: 0.58rem;
  }

  .player-panel {
    padding: 10px 12px;
    gap: 8px;
    justify-content: flex-start;
  }

  .now-playing {
    gap: 10px;
    flex-shrink: 0;
  }

  .cover-wrap {
    width: 64px;
    height: 64px;
  }

  .cover,
  .cover-placeholder {
    border-radius: 10px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
  }

  .cover-placeholder {
    font-size: 26px;
  }

  .track-info h2 {
    font-size: 0.92rem;
    margin-bottom: 2px;
  }

  .track-info .artist {
    font-size: 0.72rem;
  }

  .visualizer-wrap {
    flex: 1 1 auto;
    min-height: 44px;
    max-height: 72px;
    border-radius: 10px;
  }

  .controls {
    gap: 6px;
    flex-shrink: 0;
    margin-top: auto;
  }

  .progress-wrap {
    gap: 8px;
  }

  .time {
    font-size: 0.7rem;
    min-width: 30px;
  }

  .buttons {
    gap: 10px;
  }

  .ctrl-btn {
    width: 38px;
    height: 38px;
    font-size: 0.85rem;
  }

  .play-btn {
    width: 46px;
    height: 46px;
    font-size: 1rem;
  }

  .volume-wrap {
    max-width: 150px;
    gap: 8px;
  }

  .volume-wrap span {
    font-size: 0.85rem;
  }

  .footer {
    font-size: 0.62rem;
    line-height: 1.2;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex-shrink: 0;
  }
}

@media (max-width: 380px) {
  .logo h1 {
    font-size: 0.8rem;
  }

  .cover-wrap {
    width: 56px;
    height: 56px;
  }

  .track-info h2 {
    font-size: 0.85rem;
  }

  .visualizer-wrap {
    min-height: 36px;
    max-height: 56px;
  }

  .ctrl-btn {
    width: 34px;
    height: 34px;
    font-size: 0.8rem;
  }

  .play-btn {
    width: 42px;
    height: 42px;
  }

  .buttons {
    gap: 8px;
  }
}
