/* One opt-in music control for public, member and admin site pages. */
body.miki-pulse .miki-music-widget {
  position: fixed;
  z-index: 990;
  right: max(12px, env(safe-area-inset-right));
  bottom: max(var(--miki-music-footer-clearance, 64px), calc(12px + env(safe-area-inset-bottom)));
  width: 44px;
  height: 44px;
  font-family: inherit;
}

body.miki-pulse .miki-music-widget__launcher {
  position: relative;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid rgba(164, 137, 255, .46);
  border-radius: 14px;
  background: #18192b;
  color: #c7b2ff;
  box-shadow: 0 8px 28px rgba(0, 0, 0, .3);
  cursor: pointer;
  touch-action: none;
  user-select: none;
}

body.miki-pulse .miki-music-widget__launcher.is-dragging {
  cursor: grabbing;
}

body.miki-pulse .miki-music-widget__launcher:hover,
body.miki-pulse .miki-music-widget__launcher[aria-expanded="true"] {
  border-color: #a98bff;
  background: #27213d;
}

body.miki-pulse .miki-music-widget__launcher:focus-visible,
body.miki-pulse .miki-music-widget__head :focus-visible,
body.miki-pulse .miki-music-widget__head:focus-visible {
  outline: 2px solid #be9cff;
  outline-offset: 3px;
}

body.miki-pulse .miki-music-widget__launcher svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

body.miki-pulse .miki-music-widget__panel[hidden] {
  display: none !important;
}

body.miki-pulse .miki-music-widget__panel {
  /* Center independently of the launcher: it may move above the footer. */
  position: fixed;
  z-index: 1;
  top: 50%;
  right: max(12px, env(safe-area-inset-right));
  bottom: auto;
  display: flex;
  flex-direction: column;
  width: min(614px, calc(100vw - 24px));
  height: min(556px, calc(100dvh - 32px));
  min-height: min(240px, calc(100dvh - 32px));
  transform: translateY(-50%);
  overflow: hidden;
  border: 1px solid #39334f;
  border-radius: 16px;
  background: #121320;
  color: #f3efff;
  box-shadow: 0 18px 70px rgba(0, 0, 0, .66);
}

/* Keep the iframe rendered and intersecting the viewport while minimized so
   the external player can continue audio. Never use display/visibility hidden
   after its first load; aria-hidden + inert handle keyboard/accessibility. */
body.miki-pulse .miki-music-widget__panel.is-minimized {
  opacity: 0;
  pointer-events: none;
}

body.miki-pulse .miki-music-widget__head {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 4px 8px 4px 14px;
  border-bottom: 1px solid #343044;
  font-size: 13px;
  cursor: grab;
  touch-action: none;
  user-select: none;
}

body.miki-pulse .miki-music-widget__head.is-dragging {
  cursor: grabbing;
}

body.miki-pulse .miki-music-widget__head a,
body.miki-pulse .miki-music-widget__head button {
  touch-action: auto;
  cursor: pointer;
}

body.miki-pulse .miki-music-widget__head span {
  flex: 1;
  font-weight: 700;
}

body.miki-pulse .miki-music-widget__head a {
  color: #c4afff;
  font-size: 12px;
  text-decoration: none;
}

body.miki-pulse .miki-music-widget__head button {
  width: 36px;
  height: 36px;
  padding: 0;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: #f3efff;
  font-size: 25px;
  line-height: 1;
  cursor: pointer;
}

body.miki-pulse .miki-music-widget__head button:hover {
  background: #25243a;
}

body.miki-pulse .miki-music-widget__panel iframe {
  display: block;
  flex: 1 1 auto;
  width: 100%;
  min-height: 0;
  border: 0;
  background: #121320;
}

/* A cross-origin iframe can eat pointerup when the header is dragged over it. */
body.miki-pulse .miki-music-widget__panel.is-dragging iframe {
  pointer-events: none;
}

@media (max-width: 640px) {
  body.miki-pulse .miki-music-widget {
    right: max(8px, env(safe-area-inset-right));
    bottom: max(var(--miki-music-footer-clearance, 58px), calc(8px + env(safe-area-inset-bottom)));
  }

  body.miki-pulse .miki-music-widget__panel {
    right: 18px;
    /* Leave room for the vertical scrollbar as well as the outer gutter. */
    width: calc(100vw - 36px);
  }

  /* The home promo has actions at the viewport bottom; keep its music tab clear. */
  body.miki-pulse:has(.home-main) .miki-music-widget {
    top: calc(64px + env(safe-area-inset-top));
    bottom: auto;
  }

}

/* On short home screens the default top launcher would overlap the close
   control; keep the untouched panel below it. Saved drag positions override. */
@media (max-width: 640px) and (max-height: 780px) {
  body.miki-pulse:has(.home-main) .miki-music-widget__panel {
    top: auto;
    bottom: 8px;
    height: min(556px, calc(100dvh - 128px));
    transform: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  body.miki-pulse .miki-music-widget * {
    scroll-behavior: auto;
    transition: none;
  }
}
