:root {
  --bg: #07111f;
  --panel: #101d31;
  --panel-soft: rgba(16, 29, 49, .88);
  --muted: #8fa3bd;
  --primary: #6c63ff;
  --primary-2: #4f9bff;
  --cyan: #23d5e7;
  --danger: #ff5470;
  --text: #f7f9ff;
  --line: rgba(255, 255, 255, .09);
  --sidebar-width: 240px;
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--bg); }
body {
  margin: 0;
  overflow-x: hidden;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: radial-gradient(circle at 10% 5%, #20245a 0, transparent 32%), radial-gradient(circle at 95% 85%, #123d55 0, transparent 30%), var(--bg);
  color: var(--text);
  min-height: 100vh;
}
button, input { font: inherit; }
button:disabled { opacity: .48; cursor: not-allowed; }
a { color: inherit; }

.shell { display: grid; grid-template-columns: var(--sidebar-width) minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 28px 18px;
  background: rgba(5, 13, 25, .82);
  border-right: 1px solid var(--line);
  backdrop-filter: blur(16px);
  z-index: 20;
}
.brand { margin: 0 10px 34px; font-size: 24px; font-weight: 800; letter-spacing: -.03em; }
.brand span { color: var(--cyan); }
nav a {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 13px 14px;
  margin: 8px 0;
  border-radius: 13px;
  color: #bfd0e5;
  text-decoration: none;
  transition: background .2s ease, color .2s ease, transform .2s ease;
}
nav a:hover, nav a.active { background: linear-gradient(110deg, var(--primary), var(--primary-2)); color: white; box-shadow: 0 8px 24px #6c63ff38; }
nav a:hover { transform: translateX(2px); }
nav a:first-letter { font-size: 1.15em; }
.logout { margin-top: 35px; }

.main { width: 100%; max-width: 1240px; min-width: 0; margin: 0 auto; padding: clamp(20px, 4vw, 40px); padding-bottom: 190px; }
#page-app { min-width: 0; }
.top { display: flex; justify-content: space-between; align-items: center; gap: 18px; margin-bottom: 28px; }
.top h1 { margin: 0; font-size: clamp(25px, 3vw, 34px); letter-spacing: -.03em; }
.welcome { color: #c9d8e9; white-space: nowrap; }
.muted { color: var(--muted); }
.eyebrow, .player-eyebrow { display: block; color: var(--cyan); font-size: 11px; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; }

.grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.dashboard-stats { margin-top: 18px; }
.card {
  min-width: 0;
  overflow: hidden;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--panel-soft);
  box-shadow: 0 18px 50px #0004;
}
.hero { position: relative; overflow: hidden; padding: clamp(26px, 5vw, 40px); background: linear-gradient(120deg, #6c63ff, #248fc7); }
.hero:after { content: '♫'; position: absolute; right: 30px; top: -38px; font-size: 190px; opacity: .14; pointer-events: none; }
.hero h2 { position: relative; z-index: 1; max-width: 620px; margin: 0 0 8px; font-size: clamp(28px, 4vw, 38px); letter-spacing: -.04em; }
.hero p { position: relative; z-index: 1; max-width: 560px; margin: 0; color: #eef4ff; line-height: 1.6; }
.hero-btn { position: relative; z-index: 1; margin-top: 18px; background: #fff; color: #4f54c8; }
.stat { margin-top: 8px; font-size: 34px; font-weight: 800; }

.btn {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 12px;
  padding: 10px 16px;
  background: linear-gradient(110deg, var(--primary), var(--primary-2));
  color: white;
  text-decoration: none;
  font-weight: 700;
  cursor: pointer;
  transition: transform .2s ease, filter .2s ease, background .2s ease;
}
.btn:hover { filter: brightness(1.08); transform: translateY(-1px); }
.btn-danger { background: #ff547022; color: #ffadba; }
.btn-danger:hover { background: var(--danger); color: white; }

input {
  width: 100%;
  min-height: 46px;
  border: 1px solid #2a3b54;
  border-radius: 12px;
  padding: 13px 14px;
  outline: none;
  background: #091526;
  color: white;
}
input[type="checkbox"] { width: auto; min-height: 0; vertical-align: middle; }
input:focus { border-color: var(--cyan); box-shadow: 0 0 0 3px #23d5e722; }
label { display: block; margin: 16px 0 7px; color: #c9d8e9; }
.alert { margin-bottom: 18px; border-radius: 12px; padding: 12px 15px; }
.alert-success { background: #24c48e22; color: #7ff0c6; }
.alert-danger { background: #ff547022; color: #ff9aac; }
.form-help { margin: 18px 0 0; color: var(--muted); font-size: 13px; }

.add-card { max-width: 720px; }
.section-heading, .playlist-toolbar { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; }
.section-heading h2, .playlist-toolbar h2 { margin: 5px 0 8px; font-size: clamp(23px, 3vw, 30px); letter-spacing: -.03em; }
.section-icon { display: grid; width: 46px; height: 46px; place-items: center; border-radius: 14px; background: #23d5e71c; color: var(--cyan); font-size: 25px; }
.playlist-toolbar { margin-bottom: 18px; }
.playlist-toolbar p { max-width: 640px; margin: 0; line-height: 1.55; }
.playlist-card { padding: 10px 18px; }
.song-list { display: grid; }
.song { display: grid; grid-template-columns: 58px minmax(0, 1fr) auto; gap: 15px; align-items: center; padding: 14px 6px; border-bottom: 1px solid #ffffff12; }
.song:last-child { border-bottom: 0; }
.cover { display: grid; width: 58px; height: 58px; place-items: center; border-radius: 14px; background: linear-gradient(135deg, #6c63ff, #23d5e7); font-size: 24px; }
.song-info { min-width: 0; }
.song-title { overflow-wrap: anywhere; font-weight: 700; }
.song-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; align-items: center; }
.song-actions form { margin: 0; }
.song-play { min-width: 76px; padding: 8px 12px; }
.song-download { min-width: 42px; padding: 8px 12px; font-size: 18px; line-height: 1; }
.song-download-disabled { background: #ffffff12; color: var(--muted); }
.song-meta { line-height: 1.45; }
.empty { padding: 55px 20px; text-align: center; }
.empty-icon { font-size: 48px; color: var(--cyan); }

.player {
  border: 1px solid #ffffff18;
  border-radius: 14px;
  padding: 9px 10px;
  background: #152641;
  box-shadow: 0 10px 28px #0008;
}
.global-player {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 50;
  width: 100%;
  max-width: none;
  border-right: 0;
  border-bottom: 0;
  border-left: 0;
  border-radius: 0;
  padding: 12px max(14px, env(safe-area-inset-right)) calc(12px + env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
}
.player-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.player-heading { min-width: 0; }
.player-heading strong { display: block; max-width: min(80vw, 900px); overflow: hidden; margin-top: 2px; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.player-source { display: block; margin-top: 2px; color: var(--muted); font-size: 10px; }
.icon-btn { border: 0; padding: 0 2px; background: transparent; color: #d9e8fb; font-size: 19px; line-height: 1; cursor: pointer; }
.player-controls { display: flex; flex-wrap: nowrap; align-items: center; gap: 8px; margin-top: 9px; }
.player-btn { display: grid; flex: 0 0 30px; width: 30px; height: 30px; place-items: center; border: 1px solid #ffffff20; border-radius: 50%; background: #ffffff0d; color: white; font-size: 12px; cursor: pointer; }
.player-btn-primary { background: linear-gradient(110deg, var(--primary), var(--primary-2)); border-color: transparent; }
#global-audio { flex: 1 1 auto; width: auto; min-width: 0; height: 34px; margin-left: 2px; }
.audio-hidden { display: none; }
.player-status { min-height: 13px; margin-top: 4px; color: var(--muted); font-size: 10px; }
.youtube-audio-host { position: fixed; top: -10px; left: -10px; width: 1px; height: 1px; overflow: hidden; opacity: 0; pointer-events: none; clip-path: inset(50%); }
.hidden { display: none !important; }

.auth { width: min(430px, calc(100% - 32px)); margin: 7vh auto; }
.auth-links { margin-top: 18px; text-align: center; }
.auth-links a { color: var(--cyan); }

@media (max-width: 900px) {
  :root { --sidebar-width: 210px; }
  .main { padding-left: 24px; padding-right: 24px; }
}

@media (max-width: 760px) {
  .shell { display: block; }
  .sidebar { position: sticky; top: 0; width: 100%; height: auto; padding: 12px; border-right: 0; border-bottom: 1px solid var(--line); }
  .brand { margin: 0 8px 10px; font-size: 20px; }
  nav { display: flex; gap: 4px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: thin; }
  nav a { flex: 0 0 auto; margin: 2px 0; padding: 10px 12px; white-space: nowrap; }
  nav a:hover { transform: none; }
  .logout { margin-top: 2px; }
  .main { padding: 20px 14px 230px; }
  .top { align-items: flex-start; margin-bottom: 20px; }
  .top h1 { font-size: 26px; }
  .welcome { font-size: 13px; text-align: right; }
  .grid { grid-template-columns: 1fr; gap: 12px; }
  .dashboard-stats { margin-top: 12px; }
  .card { padding: 18px; border-radius: 17px; }
  .hero { padding: 25px 20px; }
  .hero:after { right: 2px; font-size: 130px; }
  .playlist-toolbar { align-items: center; }
  .playlist-toolbar .btn { flex: 0 0 auto; }
  .playlist-card { padding: 8px 12px; }
  .song { grid-template-columns: 48px minmax(0, 1fr) auto; gap: 11px; padding: 13px 2px; }
  .cover { width: 48px; height: 48px; border-radius: 12px; font-size: 20px; }
  .song-actions { gap: 5px; }
  .song-actions .btn { min-height: 36px; padding: 7px 9px; font-size: 13px; }
  .global-player { right: 0; bottom: 0; left: 0; width: 100%; padding: 10px max(10px, env(safe-area-inset-right)) calc(10px + env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left)); }
  .player-controls { flex-wrap: nowrap; gap: 6px; }
  #global-audio { flex: 1 1 auto; width: auto; min-width: 0; margin: 0 0 0 2px; }
}

@media (max-width: 470px) {
  .top { display: block; }
  .welcome { margin-top: 6px; text-align: left; }
  .section-heading, .playlist-toolbar { display: block; }
  .section-icon { display: none; }
  .playlist-toolbar .btn { margin-top: 12px; }
  .song { grid-template-columns: 44px minmax(0, 1fr); align-items: start; }
  .cover { width: 44px; height: 44px; }
  .song-actions { grid-column: 2; justify-content: flex-start; }
  .song-actions .btn { min-height: 34px; }
  .player-heading strong { max-width: 210px; }
}
