.ai-widget {
  position: fixed;
  right: 92px;
  bottom: 30px;
  z-index: 99990;
  pointer-events: none;
  font-family: inherit;
  transition: bottom 0.3s ease, right 0.3s ease;
}

@media (max-width: 768px) {
  body.mobile-app #ai-widget.ai-widget,
  body.mobile-app .ai-widget {
    right: 12px !important;
    bottom: calc(66px + env(safe-area-inset-bottom) + 10px) !important;
  }

  body.mobile-app:has(#global-player:not(.hidden)) #ai-widget.ai-widget,
  body.mobile-app:has(#global-player:not(.hidden)) .ai-widget {
    bottom: calc(66px + 90px + env(safe-area-inset-bottom) + 8px) !important;
  }

  body.mobile-app .ai-widget-fab {
    width: 44px;
    height: 44px;
    padding: 0;
    border-radius: 999px;
    justify-content: center;
  }

  body.mobile-app .ai-widget-fab-label {
    display: none;
  }

  body.mobile-app .ai-widget-fab-icon {
    width: 26px;
    height: 26px;
    border-radius: 999px;
  }
}

.ai-widget * { box-sizing: border-box; }

.ai-widget-fab {
  pointer-events: auto;
  height: 36px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, .22);
  background: rgba(2, 6, 23, .78);
  color: #e5e7eb;
  box-shadow: 0 18px 40px rgba(0,0,0,.45);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  position: relative;
  transform: translateZ(0);
  backdrop-filter: blur(10px);
}

.ai-widget-fab:hover { filter: brightness(1.04); }
.ai-widget-fab:active { transform: translateY(1px); }

.ai-widget-fab-icon {
  width: 22px;
  height: 22px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: rgba(var(--primary-rgb, 34, 197, 94), .16);
  border: 1px solid rgba(var(--primary-rgb, 34, 197, 94), .22);
  color: rgba(226,232,240,.95);
}
.ai-widget-fab-label {
  font-weight: 800;
  font-size: 12px;
  letter-spacing: .2px;
  color: rgba(226,232,240,.92);
}

.ai-widget.ai-widget--open .ai-widget-fab {
  border-color: rgba(var(--primary-rgb, 34, 197, 94), .42);
  box-shadow: 0 20px 52px rgba(0,0,0,.55);
}

.ai-widget-panel {
  pointer-events: auto;
  position: absolute;
  right: 0;
  bottom: 46px;
  width: min(460px, calc(100vw - 24px));
  max-height: min(70vh, 560px);
  display: none;
  flex-direction: column;
  overflow: hidden;
  border-radius: 18px;
  border: 1px solid rgba(148, 163, 184, .18);
  background: rgba(15, 23, 42, .96);
  backdrop-filter: blur(10px);
  box-shadow: 0 22px 60px rgba(0,0,0,.55);
  transform: translateY(10px);
  opacity: 0;
  transition: transform .18s ease, opacity .18s ease;
}

body.ai-has-player-queue-panel #ai-widget {
  right: 460px !important;
}

.ai-widget.ai-widget--open .ai-widget-panel {
  display: flex;
  transform: translateY(0);
  opacity: 1;
}
.ai-widget.ai-widget--open { pointer-events: none; }
.ai-widget.ai-widget--open .ai-widget-panel,
.ai-widget.ai-widget--open .ai-widget-fab { pointer-events: auto; }

.ai-widget-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 12px;
  border-bottom: 1px solid rgba(148, 163, 184, .14);
}
.ai-widget-title { display: flex; gap: 10px; align-items: center; }
.ai-widget-badge {
  width: 34px;
  height: 34px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: rgba(var(--primary-rgb, 34, 197, 94), .16);
  border: 1px solid rgba(var(--primary-rgb, 34, 197, 94), .22);
}
.ai-widget-kicker { font-size: 12px; color: rgba(226,232,240,.7); line-height: 1.1; }
.ai-widget-name { font-weight: 800; font-size: 14px; color: #e5e7eb; line-height: 1.2; }
.ai-widget-close {
  width: 34px;
  height: 34px;
  border-radius: 12px;
  border: 1px solid rgba(148, 163, 184, .18);
  background: rgba(2,6,23,.25);
  color: rgba(226,232,240,.86);
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
}
.ai-widget-close:hover { filter: brightness(1.06); }

.ai-widget-tabs {
  display: flex;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid rgba(148, 163, 184, .12);
}
.ai-widget-tab {
  flex: 1;
  height: 34px;
  border-radius: 12px;
  border: 1px solid rgba(148, 163, 184, .18);
  background: rgba(2,6,23,.2);
  color: rgba(226,232,240,.86);
  cursor: pointer;
  font-weight: 700;
}
.ai-widget-tab.active {
  border-color: rgba(var(--primary-rgb, 34, 197, 94), .35);
  background: rgba(var(--primary-rgb, 34, 197, 94), .16);
}

.ai-widget-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
  overflow: hidden;
}
.ai-widget-hint {
  font-size: 12px;
  color: rgba(226,232,240,.72);
  padding: 10px 10px;
  border: 1px dashed rgba(148, 163, 184, .2);
  border-radius: 14px;
  background: rgba(2,6,23,.14);
  margin-bottom: 10px;
}
.ai-widget-hint { margin-bottom: 0; }

.ai-widget-scroll {
  flex: 1;
  min-height: 220px;
  overflow: auto;
  overflow-x: hidden;
  padding: 2px 2px 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
}

.ai-widget-messages {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ai-widget-msg {
  display: flex;
  width: 100%;
}
.ai-widget-msg--user { justify-content: flex-end; }
.ai-widget-msg--bot { justify-content: flex-start; }

.ai-widget-bubble {
  max-width: 86%;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid rgba(148, 163, 184, .14);
  background: rgba(2, 6, 23, .18);
  color: rgba(226,232,240,.92);
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
  box-shadow: 0 10px 24px rgba(0,0,0,.18);
  animation: aiMsgIn .12s ease both;
}
.ai-widget-msg--user .ai-widget-bubble {
  border-color: rgba(var(--primary-rgb, 34, 197, 94), .26);
  background: rgba(var(--primary-rgb, 34, 197, 94), .14);
}

.ai-widget-msg-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
  max-width: 86%;
}
.ai-widget-msg-action-link {
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  border-radius: 10px;
  background: rgba(56, 189, 248, .12);
  color: rgba(125, 211, 252, .95);
  text-decoration: none;
  font-size: 12px;
  font-weight: 700;
  border: 1px solid rgba(56, 189, 248, .32);
}
.ai-widget-msg-action-link:hover {
  background: rgba(56, 189, 248, .2);
  color: #fff;
}

@keyframes aiMsgIn {
  from { transform: translateY(4px); opacity: .0; }
  to   { transform: translateY(0); opacity: 1; }
}

.ai-widget-composer {
  flex: 0 0 auto;
  padding-top: 10px;
  border-top: 1px solid rgba(148, 163, 184, .10);
  background: rgba(15, 23, 42, .96);
}
.ai-widget-label { display: none; }
.ai-widget-input {
  width: 100%;
  min-height: 44px;
  resize: vertical;
  border-radius: 14px;
  border: 1px solid rgba(148, 163, 184, .18);
  background: rgba(2,6,23,.25);
  color: #e5e7eb;
  padding: 10px 12px;
  outline: none;
}
.ai-widget-input:focus {
  border-color: rgba(var(--primary-rgb, 34, 197, 94), .45);
  box-shadow: 0 0 0 4px rgba(var(--primary-rgb, 34, 197, 94), .14);
}
.ai-widget-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
}
.ai-widget-send {
  height: 36px;
  border-radius: 12px;
  padding: 0 14px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.ai-widget-send .fa-circle-notch { animation: aiSpin 1s linear infinite; }
.ai-widget-send-loading { display: none; }
.ai-widget.ai-widget--busy .ai-widget-send-loading { display: inline-flex; }
.ai-widget.ai-widget--busy .ai-widget-send-label { opacity: .75; }
.ai-widget-status { font-size: 12px; color: rgba(226,232,240,.72); }

@keyframes aiSpin { to { transform: rotate(360deg); } }

.ai-widget-output { display: none !important; }

.ai-widget-tracks { margin-top: 10px; }
.ai-widget-tracks-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}
.ai-widget-tracks-title {
  margin: 0;
  font-weight: 800;
  font-size: 13px;
  color: rgba(226,232,240,.92);
}
.ai-widget-tracks-actions { display: flex; gap: 8px; }
.ai-widget-tracks-btn {
  height: 30px;
  border-radius: 12px;
  border: 1px solid rgba(148, 163, 184, .18);
  background: rgba(2,6,23,.18);
  color: rgba(226,232,240,.86);
  cursor: pointer;
  padding: 0 10px;
  font-weight: 700;
  font-size: 12px;
}
.ai-widget-track-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.ai-widget-track-item {
  display: block;
  padding: 8px 10px;
  border-radius: 14px;
  border: 1px solid rgba(148, 163, 184, .14);
  background: rgba(2,6,23,.14);
  position: relative;
  overflow: hidden;
}
.ai-widget-track-item.playing {
  border-color: rgba(var(--primary-rgb, 34, 197, 94), .46);
  background: rgba(var(--primary-rgb, 34, 197, 94), .10);
}
.ai-widget-track-main {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.ai-widget-hover-left{
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 0;
  min-width: 0;
  max-width: 0;
  opacity: 0;
  overflow: hidden;
  pointer-events: none;
  transition: opacity .18s ease, min-width .2s ease, max-width .2s ease;
}
.ai-widget-track-item:hover .ai-widget-hover-left,
.ai-widget-track-item:focus-within .ai-widget-hover-left{
  width: 32px;
  min-width: 32px;
  max-width: 32px;
  opacity: 1;
  pointer-events: auto;
}
.ai-widget-track-item.playing .ai-widget-hover-left{
  width: 32px;
  min-width: 32px;
  max-width: 32px;
  opacity: 1;
  pointer-events: auto;
}
.ai-widget-play-btn{
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: rgba(231,238,247,.92);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform .12s ease, color .15s ease, opacity .15s ease;
  opacity: .92;
}
.ai-widget-play-btn:hover{
  color: rgba(255,255,255,0.98);
  transform: scale(1.08);
  opacity: 1;
}
.ai-widget-play-btn i{
  font-size: 14px;
  margin-left: 1px;
  text-shadow: 0 6px 14px rgba(0,0,0,0.35);
}
.ai-widget-play-btn.playing {
  color: rgba(110, 255, 174, .98);
}

.ai-widget-track-link { color: inherit; text-decoration: none; display: flex; gap: 10px; align-items: center; min-width: 0; overflow: hidden; flex: 1 1 auto; }
.ai-widget-track-cover { width: 36px; height: 36px; border-radius: 12px; object-fit: cover; border: 1px solid rgba(148,163,184,.18); }
.ai-widget-track-meta { display: flex; flex-direction: column; gap: 2px; min-width: 0; overflow: hidden; }
.ai-widget-track-title { font-weight: 800; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ai-widget-track-artist { font-size: 12px; color: rgba(226,232,240,.7); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ai-widget-track-why {
  margin-top: 6px;
  margin-left: 0;
  font-size: 11px;
  line-height: 1.45;
  color: rgba(148, 255, 196, .92);
  white-space: normal;
  word-break: break-word;
  overflow-wrap: anywhere;
}
.ai-widget-track-actions-row {
  margin-left: 0;
  margin-top: 6px;
}
.ai-widget-track-action-btn {
  height: 24px;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, .20);
  background: rgba(2,6,23,.16);
  color: rgba(226,232,240,.75);
  padding: 0 9px;
  font-size: 11px;
  cursor: pointer;
}
.ai-widget-track-action-btn:hover {
  border-color: rgba(248, 113, 113, .45);
  color: rgba(254, 202, 202, .95);
}

@media (max-width: 420px) {
  .ai-widget { right: 12px; bottom: calc(66px + env(safe-area-inset-bottom) + 10px); }
  .ai-widget-panel { width: min(360px, calc(100vw - 16px)); }
}

