:root {
  --bg: #0b0d12;
  --bg-2: #141821;
  --fg: #e9ecf1;
  --muted: #8b95a7;
  --accent: #1db954;
  --accent-2: #1ed760;
  --danger: #ff5577;
  --radius: 14px;
  --pad: 16px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--fg);
  min-height: 100dvh;
}

.btn {
  display: inline-block;
  padding: 12px 20px;
  background: var(--bg-2);
  color: var(--fg);
  text-decoration: none;
  border-radius: 999px;
  border: 1px solid #2a2f3c;
}
.btn.primary { background: var(--accent); color: #04130a; border-color: transparent; font-weight: 600; }
.btn.primary:hover { background: var(--accent-2); }
.btn.big { padding: 16px 28px; font-size: 1.1rem; }

.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.hidden { display: none !important; }

/* ---------- Home ---------- */
.home { padding: 48px 24px; max-width: 720px; margin: 0 auto; text-align: center; }
.home h1 { font-size: 3rem; margin: 0 0 8px; }
.home .tag { color: var(--muted); margin-bottom: 32px; }
.home .cta { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin-bottom: 16px; }
.home .hint { color: var(--muted); font-size: 0.9rem; }

/* ---------- Console ---------- */
.page-console { background: #000; }
#console { position: relative; width: 100vw; height: 100dvh; overflow: hidden; }
.pair-overlay {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  background: radial-gradient(circle at center, #1a1f2c 0%, #06080d 70%);
  z-index: 5;
}
.pair-card { background: #0e1118; padding: 32px 40px; border-radius: 24px; text-align: center; box-shadow: 0 30px 80px rgba(0,0,0,0.6); }
.pair-card h1 { font-size: 2.5rem; margin: 0 0 4px; }
.pair-card .qr { width: 320px; height: 320px; image-rendering: pixelated; background: #fff; padding: 12px; border-radius: 16px; margin: 16px 0; }
.pair-card .code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: 0.1em; }

.player { position: absolute; inset: 0; }
.video-wrap { position: absolute; inset: 0; }
.video-wrap iframe, .video-wrap > div, .video-wrap .yt-pane > div { width: 100%; height: 100%; }
/* Two stacked YT players — opacity-driven so the inactive iframe stays loaded
   (display:none would unload it and defeat the pre-buffer). */
.video-wrap .yt-pane { position: absolute; inset: 0; opacity: 0; pointer-events: none; }
.video-wrap .yt-pane.active { opacity: 1; pointer-events: auto; }
.screensaver {
  position: absolute; inset: 0;
  width: 100%; height: 100%; border: 0;
  background: #000; z-index: 6;
}
.now-playing {
  position: absolute; left: 32px; bottom: 32px; right: 32px;
  display: flex; align-items: center; gap: 16px;
  background: rgba(0,0,0,0.55); padding: 16px 20px; border-radius: 16px;
  backdrop-filter: blur(10px);
}
.np-art img { width: 80px; height: 80px; border-radius: 8px; object-fit: cover; background: #222; }
.np-track { font-size: 1.6rem; font-weight: 600; }
.np-artist { color: var(--muted); }

.status-pill {
  position: absolute; top: 16px; right: 16px;
  padding: 6px 10px; background: rgba(0,0,0,0.6); border-radius: 999px;
  font-size: 0.8rem; color: var(--muted);
}
.status-pill.warn { background: #4a2d0a; color: #ffd07a; }
.status-pill.ok   { background: #0e3a1c; color: #b6f0c4; }
/* phone header pill */
.ph-header .status-pill { position: static; }

/* ---------- Phone ---------- */
.page-phone { padding-bottom: 24px; }
#phone { max-width: 520px; margin: 0 auto; padding: 16px; }
.ph-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
#btn-console.alert { color: var(--danger); box-shadow: inset 0 0 0 1px var(--danger); }

/* ---------- Modal / popover ---------- */
.modal { position: fixed; inset: 0; z-index: 200; display: flex;
         align-items: center; justify-content: center; }
.modal.hidden { display: none !important; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,0.6); }
.modal-card {
  position: relative; background: var(--bg-2); color: var(--fg);
  border-radius: 16px; padding: 20px; width: min(440px, 92vw);
  box-shadow: 0 30px 80px rgba(0,0,0,0.5);
}
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.modal-head h3 { margin: 0; font-size: 1.1rem; }
.modal-x {
  background: transparent; border: none; color: var(--muted);
  font-size: 1.2rem; cursor: pointer; padding: 4px 8px;
}
.kiosk-vol { margin: 16px 0; }
.kiosk-vol label { display: flex; justify-content: space-between;
                   color: var(--muted); font-size: 0.85rem; margin-bottom: 6px; }
.kiosk-vol input[type=range] { width: 100%; }
.tune-readout { font-size: 2rem; text-align: center; margin: 12px 0 6px;
                font-variant-numeric: tabular-nums; }
#tune-slider { width: 100%; }
.tune-nudge { display: flex; gap: 10px; margin-top: 10px; }
.tune-nudge .kiosk-action { margin: 0; flex: 1; }
.kiosk-action {
  display: block; width: 100%; padding: 12px; margin: 8px 0;
  background: #1f2937; color: var(--fg); border: 1px solid #2a2f3c;
  border-radius: 12px; font-size: 1rem; cursor: pointer;
}
.kiosk-action:active { background: #2a2f3c; }
.kiosk-action.danger { background: #7a1c2b; border-color: transparent; }
.kiosk-action:disabled { opacity: 0.4; cursor: not-allowed; }
.kiosk-gap { height: 14px; }
.kiosk-danger-stripe {
  display: flex; align-items: center; gap: 10px;
  margin: 28px 0 10px;
}
.kiosk-danger-stripe .ds-bar {
  flex: 1; height: 1px;
  background: repeating-linear-gradient(
    90deg, var(--danger) 0 8px, transparent 8px 14px
  );
  opacity: 0.7;
}
.kiosk-danger-stripe .ds-label {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.7rem; letter-spacing: 0.15em;
  color: var(--danger); text-transform: uppercase;
  animation: ds-pulse 2.4s ease-in-out infinite;
}
@keyframes ds-pulse {
  0%, 100% { opacity: 0.55; }
  50%      { opacity: 1; }
}
.kiosk-status { min-height: 1.2em; margin: 10px 0 4px; }
.kiosk-footer { margin: 14px 0 0; }
.kiosk-footer a { color: var(--accent-2); }
.ph-title { font-weight: 700; font-size: 1.2rem; }
.ph-code { color: var(--muted); font-family: ui-monospace, monospace; font-weight: 400; margin-left: 6px; font-size: 0.9rem; }

.np { display: flex; gap: 12px; align-items: center; background: var(--bg-2); padding: 12px; border-radius: var(--radius); margin-bottom: 16px; }
.np .np-art img { width: 64px; height: 64px; border-radius: 8px; object-fit: cover; background: #222; }
.np .np-text { flex: 1; min-width: 0; }
.np .np-track { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.np .np-artist { color: var(--muted); font-size: 0.9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.np .dislike-video {
  background: transparent; border: 1px solid #2a2f3c; color: var(--muted);
  border-radius: 999px; width: 40px; height: 40px; font-size: 1.1rem;
  cursor: pointer; flex-shrink: 0;
}
.np .dislike-video:active { background: #2a2f3c; color: var(--danger); }

.controls { display: flex; gap: 12px; justify-content: center; margin-bottom: 20px; }
.ctl { background: var(--bg-2); color: var(--fg); border: none; border-radius: 999px; width: 56px; height: 56px; font-size: 1.4rem; }
.ctl.big { width: 72px; height: 72px; background: var(--accent); color: #04130a; }
.ctl:active { transform: scale(0.96); }

.search input {
  width: 100%; padding: 12px 14px; border-radius: 12px; border: 1px solid #2a2f3c;
  background: var(--bg-2); color: var(--fg); font-size: 1rem; margin-bottom: 8px;
}
.results { list-style: none; padding: 0; margin: 0; }
.results li {
  display: flex; gap: 10px; align-items: center; padding: 8px;
  background: var(--bg-2); border-radius: 10px; margin-bottom: 6px;
}
.results img { width: 44px; height: 44px; border-radius: 6px; object-fit: cover; background: #222; }
.results .meta { flex: 1; min-width: 0; }
.results .t { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.results .a { color: var(--muted); font-size: 0.85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.results button { border: none; border-radius: 999px; font-weight: 700; }
.results button.primary { background: var(--accent); color: #04130a; padding: 10px 16px; font-size: 0.95rem; }
.results button.primary:active { background: var(--accent-2); }
.results button.secondary {
  background: #d97706; color: #1a0e00;
  padding: 6px 10px; font-size: 0.8rem; min-width: 36px;
}
.results button.secondary:active { background: #f59e0b; }
.results button.qdel {
  background: #2a2f3c; color: #ff8b8b;
  width: 36px; height: 36px; padding: 0;
  font-size: 1.3rem; line-height: 1;
}
.results button.qdel:active { background: #7a1c2b; color: #fff; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 24px;
  transform: translate(-50%, 30px);
  background: #1f2937; color: var(--fg);
  padding: 10px 16px; border-radius: 999px;
  font-size: 0.9rem; max-width: 90vw;
  box-shadow: 0 10px 30px rgba(0,0,0,0.4);
  opacity: 0; pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 100;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: #7a1c2b; color: #ffd7df; }

.queue { margin-top: 18px; }
.queue h2 { font-size: 1rem; color: var(--muted); margin: 0; text-transform: uppercase; letter-spacing: 0.08em; }
.queue-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.link-btn {
  background: transparent; border: none; color: var(--muted);
  font-size: 0.85rem; padding: 4px 6px; text-decoration: underline;
}
.link-btn:active { color: var(--danger); }

/* ---------- Link page ---------- */
.link { padding: 48px 24px; max-width: 520px; margin: 0 auto; text-align: center; }
.link h1 { margin-bottom: 8px; }
.link p { color: var(--muted); margin: 8px 0 24px; }
