/* music-in-bg — video.phanxa.com
   Shared styles: main app, pop-out window, Document-PiP floating window. */

:root {
  --bg: #0b0d12;
  --bg2: #0f1219;
  --panel: #141824;
  --panel2: #1a1f2e;
  --border: #232a3c;
  --text: #e7ecf6;
  --muted: #8b94ab;
  --accent: #7c5cff;
  --accent2: #00d4ff;
  --grad: linear-gradient(135deg, #7c5cff 0%, #00d4ff 100%);
  --danger: #ff4d6d;
  --ok: #2ee6a8;
  --radius: 14px;
  --shadow: 0 10px 34px rgba(0, 0, 0, .45);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

button { font: inherit; color: inherit; }

::selection { background: rgba(124, 92, 255, .4); }

/* ---------------- top bar ---------------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 22px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(124, 92, 255, .07), transparent);
  position: sticky;
  top: 0;
  z-index: 30;
  backdrop-filter: blur(8px);
}

.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }

.logo {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  background: var(--grad);
  color: #0b0d12;
  display: grid;
  place-items: center;
  font-size: 16px;
  font-weight: 800;
  box-shadow: 0 6px 18px rgba(124, 92, 255, .45);
  flex: none;
}

.brand h1 { margin: 0; font-size: 17px; letter-spacing: .2px; }
.brand p { margin: 1px 0 0; font-size: 12px; color: var(--muted); }

.top-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* ---------------- buttons ---------------- */
.btn {
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  border-radius: 10px;
  padding: 8px 13px;
  cursor: pointer;
  transition: .15s;
  white-space: nowrap;
}

.btn:hover { background: var(--panel2); border-color: #31394f; transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn.primary { background: var(--grad); border: none; color: #0b0d12; font-weight: 700; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; }
.btn.danger:hover { border-color: var(--danger); color: var(--danger); }
.btn.on { border-color: var(--accent); color: var(--accent); background: rgba(124, 92, 255, .12); }
.btn:disabled { opacity: .45; cursor: default; transform: none; }

/* ---------------- dropdown (sleep timer) ---------------- */
.dropdown { position: relative; }
.dropdown .menu {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  background: var(--panel2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 6px;
  display: none;
  flex-direction: column;
  min-width: 150px;
  box-shadow: var(--shadow);
  z-index: 60;
}
.dropdown.open .menu { display: flex; }
.dropdown .menu button {
  text-align: left;
  background: none;
  border: 0;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
}
.dropdown .menu button:hover { background: rgba(124, 92, 255, .18); }
.dropdown .menu .sep { height: 1px; background: var(--border); margin: 4px 2px; }
.dropdown .menu .lbl { font-size: 11px; text-transform: uppercase; letter-spacing: .8px; color: var(--muted); padding: 6px 10px 2px; }

/* ---------------- layout ---------------- */
.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 350px;
  gap: 18px;
  padding: 18px 22px 8px;
  max-width: 1320px;
  margin: 0 auto;
}

@media (max-width: 980px) {
  .layout { grid-template-columns: 1fr; }
}

/* ---------------- player card ---------------- */
.player-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.stage {
  position: relative;
  aspect-ratio: 16 / 9;
  background: #000;
}

.yt-mount { position: absolute; inset: 0; }
.yt-mount:empty { display: block; }
.yt-mount iframe {
  position: absolute;
  inset: 0;
  width: 100% !important;
  height: 100% !important;
  border: 0;
}

/* overlay panels (empty / remote / floating) */
.stage-overlay {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: grid;
  place-items: center;
  text-align: center;
  background: radial-gradient(120% 120% at 50% 0%, #171c2b 0%, #0c0f16 70%);
  padding: 24px;
}
.stage-overlay[hidden] { display: none; }
.stage-overlay .big { font-size: 44px; line-height: 1; margin-bottom: 12px; }
.stage-overlay h3 { margin: 0 0 6px; font-size: 16px; }
.stage-overlay p { margin: 0; color: var(--muted); font-size: 13px; max-width: 420px; }
.stage-overlay .btn { margin-top: 14px; }

/* control bar */
.controlbar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 6;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 26px 12px 10px;
  background: linear-gradient(180deg, transparent, rgba(0, 0, 0, .82));
  opacity: 0;
  transition: opacity .18s;
}
.stage:hover .controlbar,
.stage:focus-within .controlbar,
.controlbar.always { opacity: 1; }

.ctrl {
  background: rgba(255, 255, 255, .08);
  border: 0;
  color: #fff;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  cursor: pointer;
  display: grid;
  place-items: center;
  font-size: 13px;
  flex: none;
  transition: .15s;
}
.ctrl:hover { background: rgba(255, 255, 255, .22); }
.ctrl.big { width: 42px; height: 42px; font-size: 16px; background: var(--grad); color: #0b0d12; }
.ctrl.big:hover { filter: brightness(1.1); background: var(--grad); }
.ctrl.on { color: var(--accent2); background: rgba(0, 212, 255, .18); }

.time { font-size: 12px; color: #cfd6e6; font-variant-numeric: tabular-nums; flex: none; min-width: 40px; }
.time.dur { text-align: right; }

/* sliders */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
  cursor: pointer;
  height: 18px;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 3px;
  background: rgba(255, 255, 255, .22);
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--grad);
  margin-top: -4.5px;
  box-shadow: 0 0 0 3px rgba(124, 92, 255, .25);
}
input[type="range"]::-moz-range-track { height: 4px; border-radius: 3px; background: rgba(255, 255, 255, .22); }
input[type="range"]::-moz-range-thumb {
  width: 13px; height: 13px; border: 0; border-radius: 50%;
  background: var(--grad); box-shadow: 0 0 0 3px rgba(124, 92, 255, .25);
}

#seek { flex: 1; min-width: 60px; }
#vol { width: 84px; }

/* ---------------- add row ---------------- */
.add-row { display: flex; gap: 8px; margin-top: 14px; }
.add-row input {
  flex: 1;
  min-width: 0;
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 10px;
  padding: 11px 13px;
  outline: none;
  transition: .15s;
}
.add-row input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(124, 92, 255, .18); }
.add-row input::placeholder { color: #5f687e; }

.hint { color: var(--muted); font-size: 12.5px; margin: 12px 2px 0; }
.hint b { color: var(--text); }

/* ---------------- side panels ---------------- */
.side-col { display: flex; flex-direction: column; gap: 14px; min-width: 0; }

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 13px;
}
.panel-head .count { color: var(--muted); font-weight: 400; }
.panel-head .btn { padding: 4px 9px; font-size: 12px; border-radius: 8px; }

/* now playing */
.now { display: flex; gap: 12px; padding: 13px 14px; align-items: center; }
.now img {
  width: 84px;
  height: 47px;
  object-fit: cover;
  border-radius: 8px;
  background: #000;
  flex: none;
}
.now .meta { min-width: 0; }
.now .t { font-weight: 600; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.now .a { color: var(--muted); font-size: 12px; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.now a { color: var(--accent2); font-size: 12px; text-decoration: none; }
.now a:hover { text-decoration: underline; }

/* queue / recent lists */
.list { list-style: none; margin: 0; padding: 6px; max-height: 340px; overflow-y: auto; }
.list::-webkit-scrollbar { width: 8px; }
.list::-webkit-scrollbar-thumb { background: #2a3247; border-radius: 4px; }
.list li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 8px;
  border-radius: 9px;
  cursor: pointer;
  transition: background .12s;
}
.list li:hover { background: rgba(124, 92, 255, .1); }
.list li.current { background: rgba(124, 92, 255, .17); }
.list li img { width: 56px; height: 32px; object-fit: cover; border-radius: 6px; background: #000; flex: none; }
.list li .meta { min-width: 0; flex: 1; }
.list li .t {
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.list li .a { font-size: 11.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list li .del {
  border: 0;
  background: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 15px;
  padding: 2px 5px;
  border-radius: 6px;
  opacity: 0;
  flex: none;
}
.list li:hover .del { opacity: 1; }
.list li .del:hover { color: var(--danger); background: rgba(255, 77, 109, .12); }
.list .empty { padding: 18px 12px; text-align: center; color: var(--muted); font-size: 12.5px; cursor: default; }
.list li:hover .empty { background: none; }

/* now-playing equalizer */
.eq { display: inline-flex; gap: 2px; align-items: flex-end; height: 12px; flex: none; margin-right: 2px; }
.eq i { width: 3px; background: var(--accent2); border-radius: 2px; animation: eq .9s ease-in-out infinite; }
.eq i:nth-child(1) { height: 6px; animation-delay: 0s; }
.eq i:nth-child(2) { height: 12px; animation-delay: .25s; }
.eq i:nth-child(3) { height: 8px; animation-delay: .5s; }
@keyframes eq { 0%, 100% { transform: scaleY(.4); } 50% { transform: scaleY(1); } }

.note { padding: 10px 14px; font-size: 12.5px; color: var(--muted); border-top: 1px solid var(--border); }
.note b { color: var(--text); }

/* ---------------- status bar ---------------- */
.statusbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  padding: 12px 22px 20px;
  max-width: 1320px;
  margin: 0 auto;
  color: var(--muted);
  font-size: 12px;
}

.role-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 11px;
  border-radius: 999px;
  background: var(--panel);
  border: 1px solid var(--border);
}
.role-pill .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.role-pill.playing .dot { background: var(--ok); box-shadow: 0 0 8px var(--ok); animation: pulse 1.6s infinite; }
.role-pill.remote .dot { background: var(--accent2); }
@keyframes pulse { 50% { opacity: .45; } }

.kbd-hints b, .kbd-hints kbd {
  background: var(--panel2);
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 5px;
  padding: 1px 5px;
  font: 11px ui-monospace, Consolas, monospace;
  color: var(--text);
}

/* ---------------- toasts ---------------- */
#toasts {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 200;
  align-items: center;
  pointer-events: none;
}
.toast {
  background: var(--panel2);
  border: 1px solid var(--border);
  padding: 10px 16px;
  border-radius: 11px;
  box-shadow: var(--shadow);
  font-size: 13px;
  animation: toast-in .25s ease;
  max-width: 80vw;
  text-align: center;
}
.toast a { color: var(--accent2); margin-left: 8px; }
.toast.out { opacity: 0; transform: translateY(8px); transition: .35s; }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } }

/* ---------------- help overlay ---------------- */
.help-overlay {
  position: fixed;
  inset: 0;
  background: rgba(5, 7, 12, .72);
  backdrop-filter: blur(4px);
  display: grid;
  place-items: center;
  z-index: 150;
  padding: 20px;
}
.help-overlay[hidden] { display: none; }
.help-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 22px 24px;
  max-width: 560px;
  width: 100%;
  box-shadow: var(--shadow);
  max-height: 86vh;
  overflow-y: auto;
}
.help-card h2 { margin: 0 0 4px; font-size: 17px; }
.help-card h4 { margin: 18px 0 8px; font-size: 12px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); }
.help-card table { width: 100%; border-collapse: collapse; font-size: 13px; }
.help-card td { padding: 5px 6px; border-bottom: 1px solid rgba(35, 42, 60, .6); }
.help-card td:first-child { width: 150px; }
.help-card ul { margin: 6px 0; padding-left: 18px; color: var(--muted); }
.help-card li { margin: 4px 0; }
.help-card .close { margin-top: 16px; float: right; }

/* ---------------- pop-out window ---------------- */
body.popout { background: #000; overflow: hidden; user-select: none; }

.pop-shell { display: flex; flex-direction: column; height: 100vh; }

.pop-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 8px 6px 12px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  -webkit-app-region: drag;
  flex: none;
}
.pop-head .t {
  font-size: 12.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
}
.pop-head button {
  -webkit-app-region: no-drag;
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 14px;
  cursor: pointer;
  padding: 3px 7px;
  border-radius: 6px;
  flex: none;
}
.pop-head button:hover { background: rgba(255, 255, 255, .1); color: var(--text); }

.pop-stage { position: relative; flex: 1; background: #000; min-height: 0; }
.pop-stage .yt-mount { position: absolute; inset: 0; }

.pop-overlay {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: grid;
  place-items: center;
  text-align: center;
  background: #0b0d12;
  padding: 18px;
  font-size: 13px;
  color: var(--muted);
}
.pop-overlay[hidden] { display: none; }

.pop-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  background: var(--panel);
  border-top: 1px solid var(--border);
  flex: none;
}
.pop-controls .ctrl { width: 30px; height: 30px; font-size: 12px; background: rgba(255, 255, 255, .06); }
.pop-controls .ctrl.big { background: var(--grad); color: #0b0d12; width: 36px; height: 36px; font-size: 14px; }
.pop-controls #seek { flex: 1; }
.pop-controls #vol { width: 64px; }

/* ---------------- Document PiP floating window ---------------- */
body.pip-body { margin: 0; background: #000; overflow: hidden; user-select: none; }

.pip-shell { display: flex; flex-direction: column; height: 100vh; }
.pip-stage { position: relative; flex: 1; background: #000; min-height: 0; }
.pip-stage .yt-mount { position: absolute; inset: 0; }

.pip-bar {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 6px 9px;
  background: rgba(12, 15, 22, .96);
  border-top: 1px solid var(--border);
  flex: none;
}
.pip-bar .ctrl { width: 28px; height: 28px; font-size: 11px; }
.pip-bar .ctrl.big { width: 34px; height: 34px; font-size: 13px; }
.pip-bar .pip-time { font-size: 11.5px; color: #cfd6e6; font-variant-numeric: tabular-nums; flex: 1; text-align: center; }
.pip-bar .pip-title {
  font-size: 11.5px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 2;
  min-width: 0;
}
