/* MelodyStream — YouTube-style application styles */
:root {
  --bg: #0f0f0f;
  --bg-elevated: #181818;
  --surface: #212121;
  --surface-2: #272727;
  --surface-3: #303030;
  --text: #f1f1f1;
  --muted: #aaa;
  --muted-2: #717171;
  --border: #3a3a3a;
  --accent: #ff2d55;
  --accent-2: #ff5c7a;
  --blue: #3ea6ff;
  --green: #22c55e;
  --topbar-h: 56px;
  --sidebar-w: 240px;
  --player-h: 86px;
  --radius: 12px;
  --shadow: 0 18px 48px rgba(0, 0, 0, .55);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  padding-bottom: var(--player-h);
}
a { color: inherit; text-decoration: none; }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
img { display: block; max-width: 100%; }
ul { list-style: none; margin: 0; padding: 0; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #4a4a4a; border-radius: 10px; border: 2px solid var(--bg); }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- Top bar ---------- */
.topbar {
  position: fixed; inset: 0 0 auto 0; height: var(--topbar-h); z-index: 90;
  display: flex; align-items: center; gap: 16px; padding: 0 20px;
  background: rgba(15, 15, 15, .96); backdrop-filter: blur(14px);
  border-bottom: 1px solid #242424;
}
.icon-btn {
  width: 40px; height: 40px; flex: 0 0 40px; display: grid; place-items: center;
  border: 0; border-radius: 50%; background: transparent; color: var(--text); font-size: 17px;
  transition: background .18s, transform .18s;
}
.icon-btn:hover { background: var(--surface-2); }
.icon-btn:active { transform: scale(.92); }
.brand { display: flex; align-items: center; gap: 8px; font-size: 19px; font-weight: 800; letter-spacing: -.6px; white-space: nowrap; }
.brand-mark {
  width: 32px; height: 32px; display: grid; place-items: center; border-radius: 9px;
  background: linear-gradient(145deg, var(--accent), #ff7a3d); color: #fff; font-size: 14px;
  box-shadow: 0 4px 14px rgba(255, 45, 85, .35);
}
.brand span:last-child { color: var(--accent); }
.search-bar {
  flex: 1 1 640px; max-width: 720px; margin: 0 auto; display: flex; height: 40px;
  background: #121212; border: 1px solid #303030; border-radius: 22px; overflow: hidden;
  transition: border-color .2s, box-shadow .2s;
}
.search-bar:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(255, 45, 85, .12); }
.search-bar input { flex: 1; min-width: 0; padding: 0 18px; border: 0; outline: 0; background: transparent; color: var(--text); }
.search-bar input::placeholder { color: var(--muted-2); }
.search-submit { width: 64px; border: 0; border-left: 1px solid #303030; background: var(--surface-2); color: var(--text); font-size: 16px; }
.search-submit:hover { background: var(--surface-3); }
.top-actions { display: flex; align-items: center; gap: 6px; }
.pill {
  height: 36px; padding: 0 14px; display: inline-flex; align-items: center; gap: 7px;
  border: 1px solid var(--border); border-radius: 20px; background: var(--surface);
  color: var(--text); font-size: 13px; font-weight: 600; white-space: nowrap;
}
.pill:hover { background: var(--surface-2); }
.pill.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.pill.primary:hover { background: var(--accent-2); }
.badge { position: absolute; top: 4px; right: 3px; min-width: 15px; height: 15px; padding: 0 3px; border-radius: 8px; background: var(--accent); color: #fff; font-size: 9px; line-height: 15px; text-align: center; }
.icon-btn { position: relative; }
.avatar-btn {
  width: 36px; height: 36px; flex: 0 0 36px; border: 0; border-radius: 50%; margin-left: 4px;
  background: linear-gradient(145deg, #6d28d9, #2563eb); color: #fff; font-weight: 700; font-size: 13px;
  display: grid; place-items: center; overflow: hidden;
}
.avatar-btn img { width: 100%; height: 100%; object-fit: cover; }

/* ---------- Sidebar ---------- */
.sidebar {
  position: fixed; top: var(--topbar-h); left: 0; bottom: 0; width: var(--sidebar-w); z-index: 80;
  overflow-y: auto; padding: 12px 12px 110px; background: var(--bg);
  scrollbar-width: thin; transition: transform .25s ease;
}
.sidebar-group { padding: 12px 0; border-bottom: 1px solid #272727; }
.sidebar-group:last-child { border-bottom: 0; }
.sidebar-title { padding: 0 12px 8px; color: var(--muted); font-size: 12px; font-weight: 700; letter-spacing: .4px; }
.sidebar-link {
  display: flex; align-items: center; gap: 16px; height: 40px; padding: 0 12px;
  border-radius: 10px; color: var(--text); font-size: 14px; transition: background .18s;
}
.sidebar-link i { width: 20px; text-align: center; font-size: 16px; color: #d0d0d0; }
.sidebar-link:hover { background: var(--surface); }
.sidebar-link.active { background: var(--surface-2); font-weight: 600; }
.sidebar-link.active i { color: var(--accent); }
.sidebar-footer { padding: 18px 12px; color: var(--muted-2); font-size: 11px; line-height: 1.7; }
.scrim { display: none; position: fixed; inset: var(--topbar-h) 0 0; background: rgba(0,0,0,.6); z-index: 75; }
body.sidebar-open .scrim { display: block; }

/* ---------- Main ---------- */
.main { margin-left: var(--sidebar-w); padding: 20px 28px 60px; min-height: calc(100vh - var(--topbar-h)); }
.chips { display: flex; gap: 10px; overflow-x: auto; padding: 4px 0 18px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  height: 34px; padding: 0 15px; border: 1px solid var(--border); border-radius: 18px;
  background: var(--surface); color: var(--text); font-size: 13px; font-weight: 500; white-space: nowrap;
  display: inline-flex; align-items: center; gap: 7px;
}
.chip:hover { background: var(--surface-2); }
.chip.active { background: var(--text); color: #0f0f0f; border-color: var(--text); font-weight: 700; }
.section { margin-bottom: 38px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
.section-head h2 { margin: 0; font-size: 21px; font-weight: 750; letter-spacing: -.3px; }
.section-head p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.link-btn { border: 0; background: transparent; color: var(--blue); font-size: 13px; font-weight: 600; }
.link-btn:hover { text-decoration: underline; }

/* ---------- Hero ---------- */
.hero {
  position: relative; overflow: hidden; display: flex; align-items: center; gap: 30px;
  min-height: 240px; padding: 32px; margin-bottom: 28px; border-radius: 18px;
  background: radial-gradient(circle at 80% 20%, rgba(255, 45, 85, .28), transparent 45%),
              linear-gradient(120deg, #241226, #151a30 60%, #101010);
  border: 1px solid #362334;
}
.hero-copy { max-width: 560px; position: relative; z-index: 1; }
.hero-kicker { color: var(--accent-2); font-weight: 800; letter-spacing: 1.4px; font-size: 11px; text-transform: uppercase; }
.hero h1 { margin: 10px 0 8px; font-size: clamp(28px, 4vw, 46px); line-height: 1.05; letter-spacing: -1.5px; }
.hero p { margin: 0 0 20px; color: #d4d4d4; font-size: 15px; line-height: 1.55; }
.hero-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.hero-art { position: absolute; right: 5%; top: 50%; transform: translateY(-50%); width: 260px; height: 260px; border-radius: 50%; background: conic-gradient(from 20deg, #ff2d55, #7c3aed, #3ea6ff, #ff2d55); filter: blur(2px); opacity: .6; }
.hero-art::after { content: '\f04b'; font-family: "Font Awesome 6 Free"; font-weight: 900; position: absolute; inset: 28px; display: grid; place-items: center; border-radius: 50%; background: #12121a; color: #fff; font-size: 64px; }

/* ---------- Cards & grids ---------- */
.grid { display: grid; gap: 22px 16px; }
.grid-videos { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.grid-music { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
.grid-channels { grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); }
.grid-playlists { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.yt-playlist { padding: 12px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); cursor: pointer; transition: background .2s, border-color .2s; }
.yt-playlist:hover { background: var(--surface-2); border-color: var(--accent); }
.yt-playlist .playlist-cover { aspect-ratio: 16/9; border-radius: 10px; overflow: hidden; background: var(--surface-2); }
.yt-playlist .playlist-cover img { width: 100%; height: 100%; object-fit: cover; }
.yt-playlist h3 { margin: 10px 0 4px; font-size: 14px; line-height: 1.3; }
.yt-playlist p { margin: 0; color: var(--muted); font-size: 12px; }
.yt-playlist-videos { margin-top: 12px; }
.yt-playlist-videos .grid-videos { grid-template-columns: 1fr; gap: 10px; }
.yt-playlist-videos .video-meta { padding-top: 8px; }
.yt-playlist-videos .video-title { font-size: 13px; }
.yt-connect { display: flex; align-items: center; gap: 18px; padding: 20px; margin-bottom: 28px; border: 1px solid var(--border); border-radius: 16px; background: var(--surface); }
.yt-connect h2 { margin: 0 0 6px; font-size: 19px; }
.yt-connect p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.5; }
.yt-connect .yt-note { margin-top: 8px; color: var(--accent-2); }
.yt-connect-icon, .yt-avatar { width: 54px; height: 54px; flex: 0 0 54px; display: grid; place-items: center; border-radius: 50%; background: rgba(255,45,85,.12); color: var(--accent); font-size: 26px; object-fit: cover; }
.yt-channel { padding: 12px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); cursor: pointer; transition: background .2s, border-color .2s; }
.yt-channel:hover { background: var(--surface-2); border-color: var(--accent); }
.yt-channel-img { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; border-radius: 10px; margin-bottom: 10px; background: var(--surface-2); }
.yt-channel strong { display: block; font-size: 14px; line-height: 1.3; }
.yt-channel > span { display: block; margin-top: 4px; color: var(--muted); font-size: 12px; }
.yt-channel-videos { margin-top: 12px; }
.yt-channel-videos .grid-videos { grid-template-columns: 1fr; gap: 10px; }
.yt-channel-videos .video-meta { padding-top: 8px; }
.yt-channel-videos .video-title { font-size: 13px; }
.yt-more { margin-top: 10px; width: 100%; padding: 7px; border: 1px solid var(--border); border-radius: 8px; background: transparent; color: var(--blue); font-size: 12px; font-weight: 600; cursor: pointer; }
.yt-more:hover { background: var(--surface-2); }
.video-card { min-width: 0; cursor: pointer; }
.thumb { position: relative; aspect-ratio: 16/9; border-radius: 12px; overflow: hidden; background: var(--surface); }
.thumb img { width: 100%; height: 100%; object-fit: cover; transition: transform .35s ease; }
.video-card:hover .thumb img { transform: scale(1.045); }
.thumb .duration { position: absolute; right: 8px; bottom: 8px; padding: 2px 6px; border-radius: 4px; background: rgba(0,0,0,.82); color: #fff; font-size: 12px; font-weight: 600; }
.thumb .play-hover { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(0,0,0,.28); opacity: 0; transition: opacity .2s; }
.thumb .play-hover i { width: 50px; height: 50px; display: grid; place-items: center; border-radius: 50%; background: var(--accent); color: #fff; font-size: 18px; }
.video-card:hover .play-hover { opacity: 1; }
.video-meta { display: flex; gap: 10px; padding-top: 11px; }
.channel-avatar { width: 36px; height: 36px; flex: 0 0 36px; border-radius: 50%; display: grid; place-items: center; background: linear-gradient(145deg, #7c3aed, #3ea6ff); color: #fff; font-size: 13px; font-weight: 700; overflow: hidden; }
.channel-avatar img { width: 100%; height: 100%; object-fit: cover; }
.video-info { min-width: 0; }
.video-title { font-size: 14px; font-weight: 600; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.video-sub { margin-top: 5px; color: var(--muted); font-size: 12px; line-height: 1.4; }
.video-sub .verified { color: var(--muted); margin-left: 3px; }
.video-reason { color: var(--blue); font-size: 11px; font-weight: 600; }
.video-reason i { margin-right: 4px; }
.music-card { background: var(--surface); border: 1px solid transparent; border-radius: 14px; padding: 12px; cursor: pointer; transition: background .2s, border-color .2s, transform .2s; }
.music-card:hover { background: var(--surface-2); border-color: var(--border); transform: translateY(-3px); }
.music-art { position: relative; aspect-ratio: 1; border-radius: 10px; overflow: hidden; background: var(--surface-2); margin-bottom: 12px; }
.music-art img { width: 100%; height: 100%; object-fit: cover; }
.music-art .play-hover { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(0,0,0,.45); opacity: 0; transition: opacity .2s; }
.music-art .play-hover i { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 50%; background: var(--accent); color: #fff; }
.music-card:hover .play-hover, .music-card.playing .play-hover { opacity: 1; }
.music-card h3 { margin: 0 0 4px; font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.music-card p { margin: 0; color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.channel-card { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 20px 10px; background: var(--surface); border-radius: 14px; text-align: center; }
.channel-card .channel-avatar { width: 76px; height: 76px; flex-basis: 76px; font-size: 26px; }
.channel-card strong { font-size: 14px; }
.channel-card span { color: var(--muted); font-size: 12px; }

/* ---------- Watch page ---------- */
.watch-layout { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 24px; }
.player-frame { width: 100%; aspect-ratio: 16/9; border: 0; border-radius: 14px; background: #000; overflow: hidden; }
.local-player { width: 100%; aspect-ratio: 16/9; border-radius: 14px; background: #000; object-fit: contain; }
.watch-title { margin: 16px 0 12px; font-size: 20px; font-weight: 700; line-height: 1.35; }
.watch-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 16px; }
.action-btn {
  height: 36px; padding: 0 14px; display: inline-flex; align-items: center; gap: 8px;
  border: 0; border-radius: 20px; background: var(--surface-2); color: var(--text); font-size: 13px; font-weight: 600;
}
.action-btn:hover { background: var(--surface-3); }
.action-btn.active { background: var(--accent); color: #fff; }
.channel-row { display: flex; align-items: center; gap: 12px; padding: 14px 0; border-top: 1px solid #2c2c2c; border-bottom: 1px solid #2c2c2c; }
.channel-row .channel-avatar { width: 44px; height: 44px; flex-basis: 44px; font-size: 16px; }
.channel-row strong { display: block; font-size: 15px; }
.channel-row small { color: var(--muted); font-size: 12px; }
.description { margin-top: 14px; padding: 14px; border-radius: 12px; background: var(--surface); font-size: 13px; line-height: 1.6; cursor: pointer; }
.description.clamped { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.description b { display: block; margin-bottom: 4px; }
.comments { margin-top: 26px; }
.comments h3 { font-size: 17px; margin-bottom: 18px; }
.comment-form { display: flex; gap: 12px; margin-bottom: 22px; }
.comment-form input { flex: 1; height: 42px; padding: 0 14px; border: 1px solid var(--border); border-radius: 22px; background: var(--surface); color: var(--text); outline: none; }
.comment-form input:focus { border-color: var(--accent); }
.comment { display: flex; gap: 12px; margin-bottom: 20px; }
.comment-body strong { font-size: 13px; }
.comment-body small { color: var(--muted); margin-left: 8px; font-size: 11px; }
.comment-body p { margin: 5px 0 0; line-height: 1.5; font-size: 13px; }
.side-list { display: flex; flex-direction: column; gap: 12px; }
.side-list .video-card { display: grid; grid-template-columns: 168px 1fr; gap: 10px; }
.side-list .video-meta { padding-top: 0; }

/* ---------- Search / list results ---------- */
.result-list { display: flex; flex-direction: column; gap: 18px; max-width: 980px; }
.result-item { display: grid; grid-template-columns: 360px 1fr; gap: 16px; cursor: pointer; }
.result-item .thumb { aspect-ratio: 16/9; }
.result-item h3 { margin: 0 0 8px; font-size: 17px; font-weight: 600; line-height: 1.35; }
.tabs { display: flex; gap: 8px; border-bottom: 1px solid #2c2c2c; margin-bottom: 20px; }
.tab { padding: 10px 14px; border: 0; border-bottom: 2px solid transparent; background: transparent; color: var(--muted); font-weight: 600; }
.tab.active { color: var(--text); border-bottom-color: var(--accent); }

/* ---------- Playlists & library ---------- */
.playlist-card { padding: 14px; background: var(--surface); border-radius: 14px; cursor: pointer; }
.playlist-cover { aspect-ratio: 16/9; border-radius: 10px; background: linear-gradient(145deg, #3b1d4f, #12284d); display: grid; place-items: center; font-size: 42px; color: #ffffffb0; margin-bottom: 12px; }
.playlist-card h3 { margin: 0 0 5px; font-size: 15px; }
.playlist-card p { margin: 0; color: var(--muted); font-size: 12px; }
.list-row { display: flex; align-items: center; gap: 14px; padding: 10px 12px; border-radius: 10px; }
.list-row:hover { background: var(--surface); }
.list-row .thumb { width: 150px; flex: 0 0 150px; }
.list-row .row-info { flex: 1; min-width: 0; }
.list-row .row-actions { display: flex; gap: 6px; }
.item-index { width: 28px; color: var(--muted); text-align: center; }

/* ---------- Uploads ---------- */
.dropzone {
  display: grid; place-items: center; gap: 10px; min-height: 190px; padding: 28px;
  border: 2px dashed var(--border); border-radius: 16px; background: var(--surface);
  text-align: center; cursor: pointer; transition: border-color .2s, background .2s;
}
.dropzone:hover, .dropzone.dragover { border-color: var(--accent); background: #2a1a22; }
.dropzone i { font-size: 34px; color: var(--accent); }
.dropzone strong { font-size: 16px; }
.dropzone span { color: var(--muted); font-size: 13px; }
.upload-form { display: flex; gap: 12px; margin-top: 16px; }
.upload-form input { flex: 1; height: 42px; padding: 0 14px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); color: var(--text); outline: none; }

/* ---------- Modal, toast, states ---------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 150; display: grid; place-items: center; padding: 20px;
  background: rgba(0,0,0,.72); backdrop-filter: blur(4px);
}
.modal {
  width: min(480px, 100%); max-height: calc(100vh - 40px); overflow-y: auto;
  background: var(--bg-elevated); border: 1px solid var(--border); border-radius: 18px;
  box-shadow: var(--shadow); padding: 24px;
}
.modal.wide { width: min(720px, 100%); }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.modal-head h2 { margin: 0; font-size: 20px; }
.field { margin-bottom: 14px; }
.field label { display: block; margin-bottom: 6px; color: var(--muted); font-size: 12px; font-weight: 600; }
.field input, .field textarea, .field select {
  width: 100%; padding: 12px 14px; border: 1px solid var(--border); border-radius: 10px;
  background: #121212; color: var(--text); outline: none;
}
.field input:focus, .field textarea:focus { border-color: var(--accent); }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; }
.modal-note { margin-top: 16px; color: var(--muted); font-size: 12px; line-height: 1.6; }
.divider-text { display: flex; align-items: center; gap: 12px; margin: 18px 0; color: var(--muted-2); font-size: 11px; }
.divider-text::before, .divider-text::after { content: ''; flex: 1; height: 1px; background: var(--border); }
.toast-host { position: fixed; right: 20px; bottom: calc(var(--player-h) + 20px); z-index: 200; display: flex; flex-direction: column; gap: 10px; }
.toast {
  min-width: 260px; max-width: 380px; padding: 13px 16px; border-radius: 10px;
  background: #2c2c2c; border-left: 4px solid var(--accent); box-shadow: var(--shadow);
  font-size: 13px; animation: toast-in .22s ease;
}
.toast.success { border-left-color: var(--green); }
.toast.error { border-left-color: #ef4444; }
@keyframes toast-in { from { transform: translateX(30px); opacity: 0; } to { transform: none; opacity: 1; } }
.empty { padding: 70px 20px; text-align: center; color: var(--muted); }
.empty i { display: block; margin-bottom: 16px; font-size: 46px; color: var(--surface-3); }
.empty h3 { margin: 0 0 8px; color: var(--text); font-size: 18px; }
.skeleton { border-radius: 12px; background: linear-gradient(90deg, #1d1d1d 25%, #292929 50%, #1d1d1d 75%); background-size: 200% 100%; animation: shimmer 1.3s infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }
.skeleton-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 22px 16px; }
.skeleton-card .skeleton:first-child { aspect-ratio: 16/9; margin-bottom: 12px; }
.skeleton-card .skeleton { height: 14px; margin-bottom: 8px; }

/* ---------- Bottom player ---------- */
.player {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 120; height: var(--player-h);
  display: grid; grid-template-columns: minmax(180px, 1fr) minmax(320px, 2fr) minmax(180px, 1fr);
  align-items: center; gap: 18px; padding: 0 18px;
  background: #181818; border-top: 1px solid #2d2d2d;
}
.player-track { display: flex; align-items: center; gap: 12px; min-width: 0; }
.player-track img { width: 56px; height: 56px; border-radius: 8px; object-fit: cover; background: var(--surface-2); }
.player-track-info { min-width: 0; }
.player-track-info strong { display: block; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.player-track-info span { display: block; color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.player-center { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.player-controls { display: flex; align-items: center; gap: 14px; }
.player-controls .icon-btn { width: 34px; height: 34px; flex-basis: 34px; font-size: 15px; }
.player-controls .play-main { width: 40px; height: 40px; flex-basis: 40px; background: var(--text); color: #0f0f0f; font-size: 16px; }
.player-controls .play-main:hover { background: #fff; }
.player-controls .icon-btn.on { color: var(--accent); }
.progress-wrap { display: flex; align-items: center; gap: 10px; width: 100%; max-width: 620px; color: var(--muted); font-size: 11px; }
input[type="range"] { -webkit-appearance: none; appearance: none; height: 4px; border-radius: 4px; background: #4a4a4a; outline: none; }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 12px; height: 12px; border-radius: 50%; background: #fff; }
input[type="range"]::-moz-range-thumb { width: 12px; height: 12px; border: 0; border-radius: 50%; background: #fff; }
#seek { flex: 1; }
.player-right { display: flex; align-items: center; justify-content: flex-end; gap: 8px; }
#volume { width: 100px; }
.queue-panel {
  position: fixed; right: 14px; bottom: calc(var(--player-h) + 14px); z-index: 130; width: 340px; max-height: 420px;
  overflow-y: auto; padding: 14px; border-radius: 14px; background: var(--bg-elevated); border: 1px solid var(--border); box-shadow: var(--shadow);
}
.queue-panel h3 { margin: 0 0 12px; font-size: 15px; }
.queue-row { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 8px; cursor: pointer; }
.queue-row:hover { background: var(--surface); }
.queue-row.active { background: var(--surface-2); }
.queue-row img { width: 38px; height: 38px; border-radius: 6px; object-fit: cover; }
.queue-row div { min-width: 0; }
.queue-row strong, .queue-row span { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 12px; }
.queue-row span { color: var(--muted); }

/* ---------- Light theme ---------- */
body.theme-light {
  --bg: #f5f5f5; --bg-elevated: #ffffff; --surface: #eaeaea; --surface-2: #dedede; --surface-3: #d2d2d2;
  --text: #161616; --muted: #5c5c5c; --muted-2: #8a8a8a; --border: #c9c9c9;
}
body.theme-light .topbar { background: rgba(255,255,255,.96); border-bottom-color: #ddd; }
body.theme-light .sidebar { background: #fafafa; }
body.theme-light .sidebar-group { border-bottom-color: #e0e0e0; }
body.theme-light .search-bar { background: #fff; border-color: #ccc; }
body.theme-light .search-submit { background: #eee; border-left-color: #ccc; }
body.theme-light .player { background: #fff; border-top-color: #ddd; }
body.theme-light .hero { background: radial-gradient(circle at 80% 20%, rgba(255,45,85,.14), transparent 45%), linear-gradient(120deg, #ffe9ee, #eef2ff 60%, #f5f5f5); border-color: #e6c8d0; }
body.theme-light .hero p { color: #444; }
body.theme-light .playlist-cover { color: #333; }
body.theme-light .channel-avatar { color: #fff; }
body.theme-light .description, body.theme-light .dropzone, body.theme-light .modal { background: #fff; }
body.theme-light .field input, body.theme-light .field textarea, body.theme-light .comment-form input { background: #fafafa; }
body.theme-light .skeleton { background: linear-gradient(90deg, #e4e4e4 25%, #efefef 50%, #e4e4e4 75%); background-size: 200% 100%; }
body.theme-light .toast { background: #fff; color: #161616; }

/* ---------- Autoplay countdown (starts only after video ends) ---------- */
.autoplay-overlay {
  position: absolute; right: 16px; bottom: 16px; z-index: 5; display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; border-radius: 12px; background: rgba(15,15,15,.92); color: #fff; box-shadow: var(--shadow);
  font-size: 13px; animation: rise .2s ease-out;
}
.autoplay-overlay strong { color: var(--accent-2); }
.player-frame-wrap { position: relative; overflow: hidden; border-radius: 12px; background: #000; }
#youtubePlayer { position: relative; z-index: 1; width: 100%; aspect-ratio: 16 / 9; border: 0; display: block; }
.player-poster { position: absolute; inset: 0; z-index: 2; pointer-events: none; overflow: hidden; background: #000; transition: opacity .3s ease; }
.player-poster.hidden { opacity: 0; }
.player-poster img { width: 100%; height: 100%; object-fit: cover; opacity: .7; }
.player-poster::after { content: ''; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(0,0,0,.15), rgba(0,0,0,.65)); }
.poster-loader { position: absolute; inset: 0; z-index: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; color: #fff; font-size: 12px; font-weight: 600; text-shadow: 0 1px 4px rgba(0,0,0,.8); }
.poster-loader i { font-size: 28px; color: var(--accent-2); }
.player-frame-wrap:fullscreen .player-poster, .main.mini-watch-host .player-poster { display: none; }
.card-preview {
  position: absolute; right: 10px; bottom: 10px; z-index: 3; width: 30px; height: 30px; border-radius: 50%;
  border: 1px solid rgba(255,255,255,.24); background: rgba(0,0,0,.72); color: #fff; font-size: 11px;
  display: grid; place-items: center; opacity: 0; transition: opacity .18s, transform .18s; cursor: pointer;
}
.music-card:hover .card-preview, .card-preview:focus-visible { opacity: 1; }
.card-preview:hover { background: var(--accent); transform: scale(1.08); }

/* ---------- Compact player tools below the video; settings opens upward ---------- */
.player-tools { position: relative; display: flex; align-items: center; justify-content: flex-end; flex-wrap: nowrap; gap: 3px; height: 34px; margin: 3px 0 7px; }
.player-tool { position: relative; display: inline-grid; place-items: center; width: 30px; height: 30px; padding: 0; border: 0; border-radius: 50%; background: transparent; color: var(--muted); font-size: 12px; font-weight: 700; cursor: pointer; transition: background .15s, color .15s; }
.player-tool:hover, .player-tool.on { color: var(--text); background: var(--surface); }
.player-tool i { font-size: 13px; }
.player-tool.cc-tool { font-size: 10px; letter-spacing: .02em; }
.player-menu { position: absolute; bottom: calc(100% + 8px); right: 0; z-index: 70; width: 210px; max-height: min(62vh, 430px); overflow-y: auto; padding: 6px; border-radius: 12px; background: var(--bg-elevated); border: 1px solid var(--border); box-shadow: var(--shadow); color: var(--text); }
.player-menu-title { padding: 7px 9px 5px; font-size: 10px; letter-spacing: .09em; text-transform: uppercase; color: var(--muted-2); }
.player-menu button { width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 7px 9px; border-radius: 8px; color: var(--text); font-size: 12px; background: transparent; border: 0; cursor: pointer; text-align: left; }
.player-menu button:hover { background: var(--surface); }
.player-menu button.active { color: var(--accent); }
.player-menu small { color: var(--muted); font-weight: 500; }
.player-menu .divider { height: 1px; background: var(--border); margin: 5px 3px; }

/* YouTube-style theater and full screen */
body.theater-mode .watch-layout { display: block; max-width: 1500px; margin: 0 auto; }
body.theater-mode .side-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 14px; margin-top: 20px; }
body.theater-mode .player-frame { max-height: calc(100vh - 220px); }
.player-frame-wrap:fullscreen { width: 100vw; height: 100vh; display: grid; place-items: center; background: #000; }
.player-frame-wrap:fullscreen .player-frame,
.player-frame-wrap:fullscreen .local-player { width: 100vw; height: 100vh; max-height: none; aspect-ratio: auto; border-radius: 0; }

/* ---------- Persistent mini player (no iframe remount) ---------- */
#miniPlayerHost:empty { display: none; }
.main.mini-watch-host {
  position: static !important;
  width: 0 !important;
  height: 0 !important;
  min-height: 0 !important;
  margin: 0 !important;
  padding: 0 !important;
  overflow: visible !important;
  pointer-events: none;
}
.main.mini-watch-host .watch-layout { display: block; width: 0; height: 0; }
.main.mini-watch-host .watch-layout > div:first-child > * { display: none !important; }
.main.mini-watch-host .watch-layout > div:first-child > .player-frame-wrap { display: block !important; }
.main.mini-watch-host .watch-layout > aside { display: none !important; }
.main.mini-watch-host .player-tools { display: none !important; }
.main.mini-watch-host .player-frame-wrap {
  position: fixed;
  right: 20px;
  bottom: 134px;
  z-index: 60;
  width: 340px;
  height: 191px;
  overflow: hidden;
  border-radius: 12px;
  background: #000;
  box-shadow: 0 18px 50px rgba(0,0,0,.55);
  pointer-events: auto;
  animation: miniIn .22s ease-out;
}
.main.mini-watch-host .player-frame-wrap .player-frame,
.main.mini-watch-host .player-frame-wrap .local-player {
  width: 100%;
  height: 100%;
  aspect-ratio: auto;
  border-radius: 0;
}
.mini-bar {
  position: fixed;
  right: 20px;
  bottom: 96px;
  z-index: 61;
  width: 340px;
  height: 38px;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 0 9px;
  border-radius: 0 0 12px 12px;
  background: #101010;
  border: 1px solid rgba(255,255,255,.16);
  border-top: 0;
  box-shadow: 0 18px 50px rgba(0,0,0,.55);
  color: #fff;
  animation: miniIn .22s ease-out;
}
.mini-copy { flex: 1; min-width: 0; }
.mini-copy strong, .mini-copy span { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mini-copy strong { font-size: 12px; }
.mini-copy span { font-size: 10px; color: #aaa; }
.mini-bar button { width: 28px; height: 28px; flex: 0 0 28px; border-radius: 50%; border: 0; background: rgba(255,255,255,.1); color: #fff; cursor: pointer; display: grid; place-items: center; }
.mini-bar button:hover, .mini-bar button.on { background: var(--accent); }
@keyframes miniIn { from { opacity: 0; transform: translateY(16px) scale(.97); } to { opacity: 1; transform: none; } }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

@media (max-width: 760px) {
  .main.mini-watch-host .player-frame-wrap { right: 10px; bottom: 126px; width: min(300px, calc(100vw - 20px)); height: auto; aspect-ratio: 16 / 9; }
  .mini-bar { right: 10px; bottom: 88px; width: min(300px, calc(100vw - 20px)); }
  .player-tools { flex-wrap: nowrap; justify-content: flex-end; }
}

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .watch-layout { grid-template-columns: 1fr; }
  .side-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
  .side-list .video-card { display: block; }
  .side-list .video-meta { padding-top: 10px; }
}
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); box-shadow: var(--shadow); }
  body.sidebar-open .sidebar { transform: none; }
  .main { margin-left: 0; padding: 18px 18px 60px; }
  .player { grid-template-columns: minmax(140px, 1fr) minmax(260px, 2fr); }
  .player-right { display: none; }
  .result-item { grid-template-columns: 280px 1fr; }
}
@media (max-width: 700px) {
  .topbar { gap: 8px; padding: 0 10px; }
  .brand { font-size: 0; gap: 0; }
  .brand-mark { font-size: 14px; }
  .top-actions .pill, .top-actions [data-action="voice-search"], .top-actions [data-action="open-notifications"] { display: none; }
  .search-bar { height: 38px; }
  .search-submit { width: 48px; }
  .main { padding: 14px 12px 60px; }
  .hero { padding: 24px 20px; min-height: 200px; }
  .hero-art { display: none; }
  .watch-title { font-size: 17px; }
  .result-item { grid-template-columns: 1fr; }
  .result-item .thumb { width: 100%; }
  .grid-videos { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 18px 10px; }
  .video-title { font-size: 12px; }
  .video-sub, .video-meta .channel-avatar { display: none; }
  .grid-music { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
  .player { grid-template-columns: 1fr auto; gap: 8px; padding: 0 10px; }
  .player-track img { width: 44px; height: 44px; }
  .player-center { align-items: flex-end; }
  .player-controls { gap: 4px; }
  .player-controls [data-action="prev"], .player-controls [data-action="next"] { display: none; }
  .progress-wrap { width: 100%; }
  .progress-wrap .time { display: none; }
  .queue-panel { width: calc(100% - 28px); }
  .toast-host { left: 12px; right: 12px; bottom: calc(var(--player-h) + 12px); }
  .toast { max-width: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
}
