/* ==========================================================================
   Raio Studio — widgets dùng chung mọi trang: hoa/sao bay, trình phát nhạc,
   mascot Kuromi + khung hỏi đáp, hiệu ứng lấp lánh theo chuột.
   Tông hồng pastel · tím lavender · trắng.
   ========================================================================== */
:root {
  --w-pink: #f47fb8;
  --w-pink-soft: #ffe3f0;
  --w-lav: #a57bf0;
  --w-lav-soft: #efe5ff;
  --w-ink: #3e2a62;
  --w-ink-soft: #6f5a93;
  --w-glass: rgba(255, 255, 255, 0.82);
  --w-shadow: 0 10px 30px rgba(165, 123, 240, 0.28);
}

/* ---------- Hoa / sao / dấu chân bay lơ lửng ---------- */
.fx-layer { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }
.fx-item { position: absolute; opacity: 0.7; animation: fx-float var(--d, 14s) ease-in-out infinite; animation-delay: var(--delay, 0s); will-change: transform; }
.fx-item svg { width: 100%; height: 100%; display: block; filter: drop-shadow(0 4px 8px rgba(244, 127, 184, 0.25)); }
@keyframes fx-float {
  0%, 100% { transform: translate3d(0, 0, 0) rotate(0deg) scale(1); }
  25% { transform: translate3d(14px, -26px, 0) rotate(10deg) scale(1.06); }
  50% { transform: translate3d(-10px, -48px, 0) rotate(-8deg) scale(0.96); }
  75% { transform: translate3d(12px, -22px, 0) rotate(6deg) scale(1.04); }
}
@keyframes fx-spin { to { transform: rotate(360deg); } }
.fx-spark { position: fixed; z-index: 9999; pointer-events: none; width: 14px; height: 14px; animation: spark-out 0.9s ease-out forwards; }
@keyframes spark-out { 0% { opacity: 1; transform: translate(0, 0) scale(1) rotate(0deg); } 100% { opacity: 0; transform: translate(var(--dx, 0), var(--dy, 20px)) scale(0.2) rotate(120deg); } }
@media (prefers-reduced-motion: reduce) { .fx-item, .fx-spark { animation: none !important; } }

/* ---------- Trình phát nhạc (góc trái dưới) ---------- */
.mp { position: fixed; left: 16px; bottom: 16px; z-index: 900; font-family: "Baloo 2", "Inter", system-ui, sans-serif; color: var(--w-ink); }
.mp-pill {
  display: flex; align-items: center; gap: 10px; max-width: 232px; padding: 7px 12px 7px 7px; border-radius: 999px;
  background: var(--w-glass); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border: 1px solid rgba(255, 255, 255, 0.9); box-shadow: var(--w-shadow); cursor: pointer; transition: transform 0.2s;
}
.mp-pill:hover { transform: translateY(-2px); }
.mp-disc {
  width: 34px; height: 34px; border-radius: 50%; flex-shrink: 0; display: grid; place-items: center; color: #fff;
  background: linear-gradient(135deg, #b891f7, #f08cc2); box-shadow: 0 4px 12px rgba(165, 123, 240, 0.45);
}
.mp.is-playing .mp-disc { animation: fx-spin 5s linear infinite; }
.mp-disc svg { width: 16px; height: 16px; }
.mp-meta { min-width: 0; line-height: 1.15; }
.mp-title { font-size: 13px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 130px; }
.mp-artist { font-size: 11px; color: var(--w-ink-soft); }
.mp-eq { display: flex; align-items: flex-end; gap: 2px; height: 14px; margin-left: auto; }
.mp-eq i { width: 3px; border-radius: 2px; background: var(--w-pink); height: 4px; }
.mp.is-playing .mp-eq i { animation: mp-bar 0.9s ease-in-out infinite; }
.mp.is-playing .mp-eq i:nth-child(2) { animation-delay: 0.2s; }
.mp.is-playing .mp-eq i:nth-child(3) { animation-delay: 0.4s; }
@keyframes mp-bar { 0%, 100% { height: 4px; } 50% { height: 14px; } }
.mp-hint { position: absolute; left: 4px; bottom: 56px; padding: 6px 12px; border-radius: 12px; font-size: 12px; font-weight: 600; color: #fff; background: linear-gradient(135deg, #b891f7, #f08cc2); box-shadow: var(--w-shadow); white-space: nowrap; animation: hint-bounce 1.8s ease-in-out infinite; }
.mp-hint::after { content: ""; position: absolute; left: 18px; bottom: -5px; width: 10px; height: 10px; background: #f08cc2; transform: rotate(45deg); }
@keyframes hint-bounce { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-4px); } }

.mp-panel {
  position: absolute; left: 0; bottom: 56px; width: 300px; padding: 14px; border-radius: 22px;
  background: var(--w-glass); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.95); box-shadow: var(--w-shadow);
  opacity: 0; transform: translateY(10px) scale(0.97); pointer-events: none; transition: opacity 0.2s, transform 0.2s;
}
.mp.is-open .mp-panel { opacity: 1; transform: none; pointer-events: auto; }
.mp-now { display: flex; align-items: center; gap: 12px; }
.mp-cover { width: 56px; height: 56px; border-radius: 16px; object-fit: cover; box-shadow: 0 6px 16px rgba(165, 123, 240, 0.35); }
.mp-now b { display: block; font-size: 15px; }
.mp-now span { font-size: 12px; color: var(--w-ink-soft); }
.mp-bar { margin: 12px 0 4px; height: 6px; border-radius: 3px; background: var(--w-lav-soft); cursor: pointer; position: relative; }
.mp-bar > i { position: absolute; inset: 0 auto 0 0; width: 0; border-radius: 3px; background: linear-gradient(90deg, #b891f7, #f08cc2); }
.mp-times { display: flex; justify-content: space-between; font-size: 11px; color: var(--w-ink-soft); }
.mp-ctrl { display: flex; align-items: center; justify-content: center; gap: 10px; margin: 8px 0; }
.mp-btn { width: 36px; height: 36px; border-radius: 50%; border: 0; display: grid; place-items: center; cursor: pointer; background: var(--w-lav-soft); color: var(--w-lav); transition: transform 0.15s, background 0.15s; }
.mp-btn:hover { transform: scale(1.08); background: #e4d4ff; }
.mp-btn.big { width: 46px; height: 46px; color: #fff; background: linear-gradient(135deg, #b891f7, #f08cc2); box-shadow: 0 6px 16px rgba(165, 123, 240, 0.45); }
.mp-btn svg { width: 18px; height: 18px; }
.mp-vol { display: flex; align-items: center; gap: 8px; font-size: 11px; color: var(--w-ink-soft); }
.mp-vol input { flex: 1; accent-color: var(--w-lav); }
.mp-list { margin: 10px 0 0; padding: 8px 0 0; border-top: 1px dashed rgba(165, 123, 240, 0.3); list-style: none; }
.mp-list li { padding: 6px 8px; border-radius: 10px; font-size: 13px; cursor: pointer; display: flex; justify-content: space-between; gap: 8px; }
.mp-list li:hover { background: var(--w-lav-soft); }
.mp-list li.is-on { background: var(--w-pink-soft); font-weight: 700; color: #c2417f; }
.mp-credit { margin-top: 8px; font-size: 10.5px; color: var(--w-ink-soft); line-height: 1.4; }
.mp-credit a { color: var(--w-lav); text-decoration: underline; }

/* ---------- Mascot Kuromi + hỏi đáp (góc phải dưới) ---------- */
.mc { position: fixed; right: 16px; bottom: 16px; z-index: 900; font-family: "Baloo 2", "Inter", system-ui, sans-serif; }
.mc-avatar {
  position: relative; width: 74px; height: 74px; border-radius: 50%; padding: 0; border: 0; cursor: pointer; background: none;
  animation: mc-bob 3.2s ease-in-out infinite; filter: drop-shadow(0 8px 16px rgba(165, 123, 240, 0.45));
}
.mc-avatar img { width: 100%; height: 100%; border-radius: 50%; display: block; transition: transform 0.2s; }
.mc-avatar:hover img { transform: scale(1.08) rotate(-4deg); }
.mc-avatar::after { content: ""; position: absolute; right: 2px; bottom: 6px; width: 15px; height: 15px; border-radius: 50%; background: #4fcf93; border: 3px solid #fff; }
@keyframes mc-bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }
.mc-bubble {
  position: absolute; right: 70px; bottom: 54px; white-space: nowrap; padding: 8px 14px; border-radius: 16px 16px 4px 16px;
  font-size: 13px; font-weight: 600; color: var(--w-ink); background: #fff; box-shadow: var(--w-shadow); cursor: pointer;
  animation: bubble-pop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.mc-bubble button { margin-left: 8px; border: 0; background: var(--w-lav-soft); color: var(--w-lav); border-radius: 50%; width: 18px; height: 18px; font-size: 11px; line-height: 1; cursor: pointer; }
@keyframes bubble-pop { from { opacity: 0; transform: scale(0.6) translateY(8px); } to { opacity: 1; transform: none; } }

.mc-chat {
  position: absolute; right: 0; bottom: 88px; width: min(360px, calc(100vw - 32px)); height: 470px; max-height: calc(100vh - 130px);
  display: flex; flex-direction: column; overflow: hidden; border-radius: 24px; background: #fff;
  border: 1px solid rgba(255, 255, 255, 0.95); box-shadow: 0 20px 50px rgba(165, 123, 240, 0.35);
  opacity: 0; transform: translateY(14px) scale(0.96); transform-origin: bottom right; pointer-events: none; transition: opacity 0.22s, transform 0.22s;
}
.mc.is-open .mc-chat { opacity: 1; transform: none; pointer-events: auto; }
.mc-head { display: flex; align-items: center; gap: 10px; padding: 12px 14px; color: #fff; background: linear-gradient(135deg, #b891f7, #f08cc2); }
.mc-head img { width: 38px; height: 38px; border-radius: 50%; border: 2px solid #fff; }
.mc-head b { display: block; font-size: 15px; line-height: 1.1; }
.mc-head span { font-size: 11px; opacity: 0.9; }
.mc-close { margin-left: auto; border: 0; background: rgba(255, 255, 255, 0.25); color: #fff; width: 28px; height: 28px; border-radius: 50%; cursor: pointer; font-size: 14px; }
.mc-msgs { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 10px; background: linear-gradient(180deg, #fff8fc, #f7f0ff); }
.mc-msg { max-width: 86%; padding: 9px 13px; border-radius: 16px; font-size: 13.5px; line-height: 1.5; animation: bubble-pop 0.25s ease-out; word-wrap: break-word; }
.mc-msg code { background: rgba(165, 123, 240, 0.15); color: #7a4fc4; padding: 1px 6px; border-radius: 6px; font-size: 12.5px; }
.mc-msg a { color: var(--w-lav); font-weight: 700; text-decoration: underline; }
.mc-msg.bot { align-self: flex-start; background: #fff; color: var(--w-ink); border-bottom-left-radius: 4px; box-shadow: 0 2px 8px rgba(165, 123, 240, 0.15); }
.mc-msg.me { align-self: flex-end; color: #fff; background: linear-gradient(135deg, #b891f7, #f08cc2); border-bottom-right-radius: 4px; }
.mc-typing { align-self: flex-start; display: flex; gap: 4px; padding: 12px 14px; background: #fff; border-radius: 16px; }
.mc-typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--w-lav); animation: mc-dot 1s infinite; }
.mc-typing i:nth-child(2) { animation-delay: 0.15s; }
.mc-typing i:nth-child(3) { animation-delay: 0.3s; }
@keyframes mc-dot { 0%, 60%, 100% { transform: translateY(0); opacity: 0.5; } 30% { transform: translateY(-5px); opacity: 1; } }
.mc-chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px 12px 0; background: #f7f0ff; }
.mc-chips button { border: 1px solid rgba(165, 123, 240, 0.35); background: #fff; color: var(--w-lav); border-radius: 999px; padding: 4px 11px; font-size: 12px; font-weight: 600; cursor: pointer; font-family: inherit; }
.mc-chips button:hover { background: var(--w-lav-soft); }
.mc-form { display: flex; gap: 8px; padding: 10px 12px; background: #f7f0ff; }
.mc-form input { flex: 1; min-width: 0; border: 1px solid rgba(165, 123, 240, 0.3); border-radius: 999px; padding: 9px 14px; font-size: 13.5px; outline: none; font-family: inherit; color: var(--w-ink); background: #fff; }
.mc-form input:focus { border-color: var(--w-lav); box-shadow: 0 0 0 3px rgba(165, 123, 240, 0.15); }
.mc-form button { border: 0; width: 40px; height: 40px; border-radius: 50%; color: #fff; cursor: pointer; background: linear-gradient(135deg, #b891f7, #f08cc2); display: grid; place-items: center; }
.mc-form button svg { width: 18px; height: 18px; }

@media (max-width: 640px) {
  .mp-pill { max-width: 150px; }
  .mp-title { max-width: 70px; }
  .mp-eq { display: none; }
  .mc-avatar { width: 60px; height: 60px; }
  .mc-bubble { display: none; }
  .mp-panel { width: min(300px, calc(100vw - 32px)); }
}

/* ---------- Hiện dần khi cuộn tới ---------- */
[data-rv] { opacity: 0; transform: translateY(26px); transition: opacity 0.7s ease, transform 0.7s cubic-bezier(0.16, 1, 0.3, 1); }
[data-rv].in { opacity: 1; transform: none; }
.no-js [data-rv], .rv-off [data-rv] { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) { [data-rv] { opacity: 1; transform: none; transition: none; } }

/* ---------- Thanh menu: không xuống dòng ---------- */
.nav-links a { white-space: nowrap; }
.nav-links { gap: clamp(14px, 2.2vw, 32px); }
@media (max-width: 1100px) { .ver { display: none; } .nav-actions .btn span { display: none; } }

@media (max-width: 700px) {
  .nav-actions .btn { display: none; }
  .mp-pill { padding: 6px; max-width: none; }
  .mp-meta, .mp-eq { display: none; }
  .mp { left: 12px; bottom: 12px; } .mc { right: 12px; bottom: 12px; }
}

/* ---------- Quản lý nhạc (admin) ---------- */
.mp-manage { margin-top: 10px; width: 100%; border: 1px dashed rgba(165, 123, 240, 0.5); background: transparent; color: var(--w-lav); border-radius: 12px; padding: 6px; font: 600 12px inherit; font-family: inherit; cursor: pointer; }
.mp-manage:hover { background: var(--w-lav-soft); }
.mp-modal { position: fixed; inset: 0; z-index: 2000; display: grid; place-items: center; padding: 16px; background: rgba(90, 60, 140, 0.35); backdrop-filter: blur(3px); font-family: "Baloo 2", "Inter", system-ui, sans-serif; }
.mp-card { position: relative; width: min(420px, 100%); max-height: 90vh; overflow-y: auto; padding: 22px; border-radius: 24px; background: #fff; box-shadow: 0 24px 60px rgba(165, 123, 240, 0.45); color: var(--w-ink); }
.mp-card h3 { margin: 0 0 8px; font-size: 20px; } .mp-card h4 { margin: 16px 0 6px; font-size: 14px; } .mp-card p { font-size: 13.5px; color: var(--w-ink-soft); margin: 0 0 12px; }
.mp-x { position: absolute; top: 12px; right: 12px; border: 0; width: 30px; height: 30px; border-radius: 50%; background: var(--w-lav-soft); color: var(--w-lav); cursor: pointer; }
.mp-in { display: block; width: 100%; margin-bottom: 10px; padding: 10px 14px; border: 1px solid rgba(165, 123, 240, 0.35); border-radius: 12px; font: inherit; font-size: 14px; color: var(--w-ink); outline: none; }
.mp-in:focus { border-color: var(--w-lav); box-shadow: 0 0 0 3px rgba(165, 123, 240, 0.18); }
.mp-file { display: block; width: 100%; margin-bottom: 10px; font-size: 13px; }
.mp-go, .mp-out { width: 100%; border: 0; border-radius: 12px; padding: 11px; font: 700 14px inherit; font-family: inherit; cursor: pointer; color: #fff; background: linear-gradient(135deg, #b891f7, #f08cc2); }
.mp-out { margin-top: 14px; background: var(--w-lav-soft); color: var(--w-lav); }
.mp-prog { margin-top: 10px; height: 6px; border-radius: 3px; background: var(--w-lav-soft); overflow: hidden; } .mp-prog i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #b891f7, #f08cc2); transition: width 0.15s; }
.mp-msg { margin-top: 8px; font-size: 13px; color: #1f9d68; min-height: 18px; } .mp-msg.bad { color: #d9548a; }
.mp-mine { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; } .mp-mine li { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 8px 12px; border-radius: 12px; background: #f7f0ff; font-size: 13.5px; }
.mp-mine button { border: 0; background: transparent; cursor: pointer; font-size: 15px; }

/* Mobile: nút nhạc + mascot nổi nhỏ gọn và không che chữ cuối trang */
@media (max-width: 640px) {
  body { padding-bottom: 84px; }
  .mp { left: 10px; bottom: 10px; }
  .mc { right: 10px; bottom: 10px; transform: scale(0.82); transform-origin: right bottom; }
  .fx-layer { display: none; }   /* hoa văn bay: tắt trên điện thoại cho cuộn mượt hơn */
}
@media (prefers-reduced-motion: reduce) { .fx-layer, .fx-spark { display: none !important; } }
