.ai-overlay {
  position: fixed;
  inset: 0;
  z-index: 3000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  background: rgba(5, 7, 20, 0.72);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  animation: aiFade 0.18s ease-out;
}

.ai-overlay[hidden] { display: none; }

body.ai-open { overflow: hidden; }

.ai-chat {
  position: relative;
  width: min(760px, 100%);
  height: min(820px, 100%);
  display: flex;
  flex-direction: column;
  border-radius: 22px;
  border: 1px solid rgba(129, 140, 248, 0.28);
  background:
    radial-gradient(120% 55% at 50% -12%, rgba(168, 85, 247, 0.2) 0%, rgba(168, 85, 247, 0) 62%),
    linear-gradient(165deg, #151b42 0%, #0f1330 100%);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.06);
  color: #fff;
  overflow: hidden;
  animation: aiRise 0.22s cubic-bezier(0.2, 0.8, 0.2, 1);
}

@keyframes aiFade {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes aiRise {
  from { opacity: 0; transform: translateY(14px) scale(0.985); }
  to { opacity: 1; transform: none; }
}

.ai-avatar {
  flex: none;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6366f1 0%, #a855f7 52%, #ec4899 100%);
  box-shadow: 0 6px 18px rgba(168, 85, 247, 0.35);
  color: #fff;
}

.ai-avatar svg { width: 20px; height: 20px; }

.ai-avatar-sm {
  width: 28px;
  height: 28px;
  box-shadow: none;
}

.ai-avatar-sm svg { width: 14px; height: 14px; }

.ai-avatar-lg {
  width: 64px;
  height: 64px;
  box-shadow: 0 0 0 8px rgba(168, 85, 247, 0.1), 0 14px 40px rgba(168, 85, 247, 0.4);
}

.ai-avatar-lg svg { width: 30px; height: 30px; }

.ai-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 14px 14px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}

.ai-head-text {
  flex: 1;
  min-width: 0;
}

.ai-head h3 {
  margin: 0;
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: 0.01em;
}

.ai-sub {
  margin: 2px 0 0;
  color: rgba(255, 255, 255, 0.55);
  font-size: 0.78rem;
}

.ai-icon-btn {
  flex: none;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 12px;
  background: transparent;
  color: rgba(255, 255, 255, 0.7);
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.ai-icon-btn:hover {
  border-color: rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
}

.ai-overlay.is-empty .ai-reset { visibility: hidden; }

.ai-log {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 20px 18px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.16) transparent;
}

.ai-log::-webkit-scrollbar { width: 8px; }
.ai-log::-webkit-scrollbar-thumb {
  border: 2px solid transparent;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.16) padding-box;
}

.ai-empty {
  margin: auto 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 12px 8px 20px;
}

.ai-empty h4 {
  margin: 20px 0 6px;
  font-size: 1.35rem;
  font-weight: 800;
}

.ai-empty p {
  max-width: 420px;
  margin: 0 0 22px;
  color: rgba(255, 255, 255, 0.62);
  font-size: 0.92rem;
  line-height: 1.5;
}

.ai-suggest {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  width: 100%;
  max-width: 540px;
}

.ai-suggestion {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.035);
  color: rgba(255, 255, 255, 0.88);
  font: inherit;
  font-size: 0.86rem;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.15s;
}

.ai-suggestion:hover {
  border-color: rgba(167, 139, 250, 0.45);
  background: rgba(167, 139, 250, 0.1);
  transform: translateY(-1px);
}

.ai-suggestion-icon {
  flex: none;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.06);
  font-size: 1rem;
}

.ai-msg {
  font-size: 0.92rem;
  line-height: 1.45;
}

.ai-new { animation: aiIn 0.2s ease-out; }

@keyframes aiIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

.ai-user {
  align-self: flex-end;
  max-width: 78%;
  padding: 10px 15px;
  border-radius: 18px 18px 6px 18px;
  background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 60%, #a855f7 100%);
  box-shadow: 0 6px 18px rgba(99, 102, 241, 0.25);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.ai-bot {
  align-self: stretch;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.ai-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
}

.ai-text {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  max-width: 100%;
  padding: 10px 15px;
  border-radius: 6px 18px 18px 18px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.05);
  overflow-wrap: anywhere;
}

.ai-error .ai-text {
  border-color: rgba(248, 113, 113, 0.35);
  background: rgba(248, 113, 113, 0.08);
}

.ai-error .ai-text svg {
  flex: none;
  margin-top: 1px;
  color: #fca5a5;
}

.ai-results {
  width: 100%;
  overflow: hidden;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.025);
}

.ai-results-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px 4px;
  color: rgba(255, 255, 255, 0.55);
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.ai-results-head svg { width: 15px; height: 15px; }

.ai-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  transition: background 0.15s;
}

.ai-row + .ai-row { border-top: 1px solid rgba(255, 255, 255, 0.06); }

.ai-row:hover { background: rgba(255, 255, 255, 0.04); }

.ai-cover {
  position: relative;
  flex: none;
  width: 46px;
  height: 46px;
  border-radius: 11px;
  background-color: rgba(99, 102, 241, 0.25);
  background-size: cover;
  background-position: center;
  overflow: hidden;
}

.ai-cover-empty {
  display: grid;
  place-items: center;
  background-image: linear-gradient(135deg, rgba(99, 102, 241, 0.55) 0%, rgba(236, 72, 153, 0.45) 100%);
  color: rgba(255, 255, 255, 0.85);
}

.ai-play {
  position: absolute;
  inset: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: #fff;
  cursor: pointer;
  transition: background 0.15s;
}

.ai-play svg {
  position: absolute;
  right: 3px;
  bottom: 3px;
  width: 22px;
  height: 22px;
  padding: 6px 5px 6px 7px;
  border-radius: 50%;
  background: rgba(8, 10, 28, 0.78);
  transition: transform 0.15s, background 0.15s;
}

.ai-play:hover,
.ai-play:focus-visible { background: rgba(8, 10, 28, 0.45); }

.ai-play:hover svg,
.ai-play:focus-visible svg {
  background: linear-gradient(135deg, #6366f1 0%, #a855f7 55%, #ec4899 100%);
  transform: translate(-9px, -9px) scale(1.25);
}

.ai-meta {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.ai-title {
  overflow: hidden;
  color: #fff;
  font-weight: 700;
  text-decoration: none;
  text-overflow: ellipsis;
  white-space: nowrap;
}

a.ai-title:hover { text-decoration: underline; }

.ai-sub-line {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.ai-artist {
  min-width: 0;
  overflow: hidden;
  color: rgba(255, 255, 255, 0.58);
  font-size: 0.8rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ai-lyric {
  display: -webkit-box;
  overflow: hidden;
  color: rgba(196, 181, 253, 0.9);
  font-size: 0.78rem;
  font-style: italic;
  line-height: 1.35;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow-wrap: anywhere;
}

.ai-genre {
  flex: none;
  padding: 1px 8px;
  border-radius: 999px;
  border: 1px solid rgba(52, 211, 153, 0.4);
  color: rgba(255, 255, 255, 0.82);
  font-size: 0.68rem;
  font-weight: 700;
  white-space: nowrap;
}

.ai-copy {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 64px;
  height: 34px;
  padding: 0 12px;
  border-radius: 10px;
  border: 1px solid rgba(129, 140, 248, 0.38);
  background: rgba(99, 102, 241, 0.14);
  color: #fff;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 800;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.ai-copy svg { width: 15px; height: 15px; }

.ai-copy:hover {
  border-color: rgba(167, 139, 250, 0.7);
  background: rgba(99, 102, 241, 0.26);
}

.ai-copy.is-done {
  border-color: rgba(52, 211, 153, 0.55);
  background: rgba(52, 211, 153, 0.16);
  color: #a7f3d0;
}

.ai-more {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 36px;
  padding: 0 16px 0 12px;
  border-radius: 999px;
  border: 1px solid rgba(167, 139, 250, 0.4);
  background: rgba(167, 139, 250, 0.08);
  color: #fff;
  font: inherit;
  font-size: 0.84rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s;
}

.ai-more:hover { background: rgba(167, 139, 250, 0.18); }

.ai-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.ai-link {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 14px;
  border: 1px solid rgba(129, 140, 248, 0.35);
  border-radius: 999px;
  background: rgba(99, 102, 241, 0.12);
  color: #e0e7ff;
  font-size: 0.85rem;
  font-weight: 600;
  text-decoration: none;
}

.ai-link:hover { background: rgba(99, 102, 241, 0.22); }

.ai-text a { color: #c7d2fe; text-underline-offset: 2px; }

.ai-typing {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 14px 16px;
  border-radius: 6px 18px 18px 18px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.05);
}

.ai-typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.75);
  animation: aiDot 1.2s ease-in-out infinite;
}

.ai-typing span:nth-child(2) { animation-delay: 0.15s; }
.ai-typing span:nth-child(3) { animation-delay: 0.3s; }

@keyframes aiDot {
  0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-3px); }
}

.ai-slow {
  color: rgba(255, 255, 255, 0.55);
  font-size: 0.8rem;
}

.ai-bar {
  padding: 12px 16px 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.07);
}

.ai-field {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 6px 6px 16px;
  border-radius: 18px;
  border: 1px solid rgba(129, 140, 248, 0.3);
  background: rgba(255, 255, 255, 0.045);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.ai-field:focus-within {
  border-color: rgba(167, 139, 250, 0.75);
  box-shadow: 0 0 0 4px rgba(139, 92, 246, 0.15);
}

.ai-input {
  flex: 1;
  min-width: 0;
  padding: 8px 0;
  border: 0;
  background: transparent;
  color: #fff;
  font: inherit;
  font-size: 16px;
}

.ai-input::placeholder { color: rgba(255, 255, 255, 0.45); }

.ai-input:focus { outline: none; }

.ai-send {
  flex: none;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 0;
  border-radius: 13px;
  background: linear-gradient(135deg, #6366f1 0%, #a855f7 55%, #ec4899 100%);
  color: #fff;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.15s;
}

.ai-send:not(:disabled):hover { transform: translateY(-1px); }

.ai-send:disabled {
  opacity: 0.35;
  cursor: default;
}

.ai-quota {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 4px 6px;
  margin-top: -6px;
  padding: 0 16px 12px;
  color: rgba(255, 255, 255, 0.5);
  font-size: 0.76rem;
}

.ai-quota[hidden] { display: none; }

.ai-quota a {
  color: #c4b5fd;
  font-weight: 700;
  text-decoration: none;
}

.ai-quota a:hover { text-decoration: underline; }

.ai-quota.is-empty span:first-child { color: #fca5a5; }

.ai-quota-dot { opacity: 0.5; }

.ai-input:disabled { cursor: not-allowed; }

.ai-cta {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 38px;
  padding: 0 16px;
  border-radius: 12px;
  background: linear-gradient(135deg, #6366f1 0%, #a855f7 55%, #ec4899 100%);
  color: #fff;
  font-size: 0.86rem;
  font-weight: 800;
  text-decoration: none;
  box-shadow: 0 8px 20px rgba(168, 85, 247, 0.3);
}

.ai-cta:hover { filter: brightness(1.1); }

.ai-login p { margin-bottom: 16px; }

.ai-draft {
  max-width: 420px;
  margin: 0 0 18px;
  padding: 10px 14px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.05);
  color: rgba(255, 255, 255, 0.85);
  font-size: 0.9rem;
  overflow-wrap: anywhere;
}

.ai-login-cta {
  min-height: 44px;
  padding: 0 28px;
  border-radius: 999px;
  font-size: 0.95rem;
}

.ai-chat button:focus-visible,
.ai-chat a:focus-visible {
  outline: 2px solid rgba(196, 181, 253, 0.9);
  outline-offset: 2px;
}

.ai-entry {
  display: flex;
  gap: 8px;
  width: 100%;
  max-width: 520px;
  min-width: 0;
  margin-top: 16px;
}

.ai-entry input {
  flex: 1;
  width: 100%;
  min-width: 0;
  padding: 11px 14px;
  border-radius: 14px;
  border: 1px solid rgba(167, 139, 250, 0.45);
  background: rgba(255, 255, 255, 0.05);
  color: #fff;
  font: inherit;
  font-size: 16px;
}

.ai-entry input::placeholder { color: rgba(255, 255, 255, 0.5); }

.ai-entry button,
.ai-open-btn {
  flex: none;
  padding: 0 16px;
  border: 0;
  border-radius: 14px;
  background: linear-gradient(135deg, #6366f1 0%, #a855f7 55%, #ec4899 100%);
  color: #fff;
  font: inherit;
  font-weight: 800;
  white-space: nowrap;
  cursor: pointer;
}

.ai-open-btn {
  height: 44px;
  margin-left: 8px;
}

@media (max-width: 560px) {
  .ai-entry { flex-direction: column; }
  .ai-entry button { height: 44px; }
  .ai-open-btn { width: 100%; margin-left: 0; }
  .ai-overlay { padding: 0; }
  .ai-chat {
    width: 100%;
    height: 100%;
    border: 0;
    border-radius: 0;
  }
  .ai-head { padding: max(10px, env(safe-area-inset-top)) 8px 10px 14px; }
  .ai-avatar:not(.ai-avatar-sm):not(.ai-avatar-lg) { width: 34px; height: 34px; }
  .ai-log { gap: 14px; padding: 16px 12px; }
  .ai-suggest { grid-template-columns: minmax(0, 1fr); }
  .ai-user { max-width: 86%; }
  .ai-bot { gap: 8px; }
  .ai-avatar-sm { display: none; }
  .ai-row { gap: 10px; padding: 9px 10px; }
  .ai-cover { width: 42px; height: 42px; }
  .ai-copy { min-width: 56px; padding: 0 10px; }
  .ai-bar { padding: 10px 12px max(12px, env(safe-area-inset-bottom)); }
  .ai-quota { padding: 0 12px max(10px, env(safe-area-inset-bottom)); }
}

@media (prefers-reduced-motion: reduce) {
  .ai-overlay,
  .ai-chat,
  .ai-new { animation: none; }
  .ai-typing span { animation-duration: 2.4s; }
}
