.ufo-assistant-root {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 9999;
  font-family: "Inter", "PingFang SC", "Microsoft YaHei", sans-serif;
  pointer-events: none;
}

.ufo-assistant-root * {
  box-sizing: border-box;
}

.ufo-launcher {
  pointer-events: auto;
  width: 64px;
  height: 64px;
  border: 0;
  border-radius: 20px;
  background: linear-gradient(160deg, #e8f8fc, #cdeef4);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.28);
  display: grid;
  place-items: center;
  cursor: pointer;
  position: absolute;
  right: 0;
  bottom: 0;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  animation: ufo-float 3.1s ease-in-out infinite;
}

.ufo-launcher:hover {
  transform: translateY(-2px);
  box-shadow: 0 24px 56px rgba(0, 0, 0, 0.3);
}

.ufo-launcher:focus-visible {
  outline: 3px solid rgba(27, 148, 166, 0.45);
  outline-offset: 3px;
}

.ufo-launcher svg {
  width: 38px;
  height: 38px;
}

.ufo-launcher .ufo-signal {
  position: absolute;
  inset: -4px;
  border-radius: 24px;
  border: 1px solid rgba(31, 154, 174, 0.62);
  opacity: 0.65;
  animation: ufo-ping 2s linear infinite;
  pointer-events: none;
}

.ufo-panel {
  pointer-events: auto;
  width: min(420px, calc(100vw - 24px));
  height: min(72vh, 580px);
  border-radius: 20px;
  overflow: hidden;
  background: linear-gradient(180deg, #f5fbff 0%, #f1f8ff 100%);
  border: 1px solid rgba(8, 36, 68, 0.12);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.3);
  position: absolute;
  right: 0;
  bottom: 82px;
  display: flex;
  flex-direction: column;
  opacity: 0;
  transform: translateY(12px) scale(0.98);
  visibility: hidden;
  transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s ease;
}

.ufo-assistant-root.open .ufo-panel {
  opacity: 1;
  transform: translateY(0) scale(1);
  visibility: visible;
}

.ufo-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  background: linear-gradient(140deg, #072040, #0a4a6b);
  color: #fff;
}

.ufo-header-copy {
  min-width: 0;
}

.ufo-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.ufo-title {
  margin: 0;
  font-size: 15px;
  line-height: 1.3;
  letter-spacing: 0.2px;
}

.ufo-subtitle {
  margin: 1px 0 0;
  font-size: 12px;
  opacity: 0.86;
}

.ufo-resize,
.ufo-close {
  height: 32px;
  border: 0;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
  cursor: pointer;
}

.ufo-resize {
  min-width: 52px;
  padding: 0 10px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.2px;
}

.ufo-close {
  width: 32px;
  height: 32px;
  font-size: 19px;
  line-height: 1;
}

.ufo-resize:hover,
.ufo-close:hover {
  background: rgba(255, 255, 255, 0.24);
}

.ufo-assistant-root.expanded .ufo-panel {
  width: min(900px, calc(100vw - 32px));
  height: min(88vh, 820px);
}

.ufo-message-list {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ufo-row {
  display: flex;
}

.ufo-row.assistant {
  justify-content: flex-start;
}

.ufo-row.user {
  justify-content: flex-end;
}

.ufo-bubble {
  max-width: 85%;
  border-radius: 14px;
  padding: 10px 12px;
  font-size: 14px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}

.ufo-row.assistant .ufo-bubble {
  color: #0c2442;
  background: #ffffff;
  border: 1px solid rgba(7, 24, 45, 0.1);
}

.ufo-row.user .ufo-bubble {
  color: #fff;
  background: linear-gradient(150deg, #0a4b7a, #138385);
  box-shadow: 0 8px 22px rgba(14, 60, 93, 0.24);
}

.ufo-audio {
  display: grid;
  gap: 8px;
  min-width: min(280px, 70vw);
}

.ufo-audio-label {
  font-size: 12px;
  line-height: 1.2;
  opacity: 0.88;
}

.ufo-audio audio {
  width: 100%;
  min-width: 220px;
  max-width: min(320px, 72vw);
  height: 36px;
}

.ufo-row.user .ufo-audio-label {
  color: rgba(255, 255, 255, 0.92);
}

.ufo-text.is-typing::after {
  content: "▍";
  margin-left: 2px;
  animation: ufo-cursor 0.9s steps(1, end) infinite;
}

.ufo-text p,
.ufo-text ul,
.ufo-text ol,
.ufo-text pre,
.ufo-text blockquote,
.ufo-text h1,
.ufo-text h2,
.ufo-text h3,
.ufo-text h4,
.ufo-text h5,
.ufo-text h6 {
  margin: 0 0 8px;
}

.ufo-text p:last-child,
.ufo-text ul:last-child,
.ufo-text ol:last-child,
.ufo-text pre:last-child,
.ufo-text blockquote:last-child,
.ufo-text h1:last-child,
.ufo-text h2:last-child,
.ufo-text h3:last-child,
.ufo-text h4:last-child,
.ufo-text h5:last-child,
.ufo-text h6:last-child {
  margin-bottom: 0;
}

.ufo-text h1,
.ufo-text h2,
.ufo-text h3,
.ufo-text h4,
.ufo-text h5,
.ufo-text h6 {
  line-height: 1.3;
}

.ufo-text h1 {
  font-size: 18px;
}

.ufo-text h2 {
  font-size: 17px;
}

.ufo-text h3 {
  font-size: 16px;
}

.ufo-text h4,
.ufo-text h5,
.ufo-text h6 {
  font-size: 15px;
}

.ufo-text ul,
.ufo-text ol {
  padding-left: 20px;
}

.ufo-text code {
  font-family: "SFMono-Regular", Menlo, Consolas, monospace;
  font-size: 0.92em;
  padding: 1px 5px;
  border-radius: 6px;
  background: rgba(10, 36, 66, 0.08);
}

.ufo-text pre {
  overflow: auto;
  border-radius: 10px;
  padding: 10px 12px;
  background: rgba(6, 23, 41, 0.9);
}

.ufo-text pre code {
  display: block;
  padding: 0;
  color: #f5faff;
  background: transparent;
  white-space: pre;
}

.ufo-text blockquote {
  border-left: 3px solid rgba(16, 118, 151, 0.5);
  padding-left: 10px;
  color: rgba(12, 36, 66, 0.86);
}

.ufo-text a {
  color: #0c77a5;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.ufo-text .ufo-footnote-ref {
  font-size: 0.76em;
  line-height: 0;
  vertical-align: super;
  margin-left: 1px;
  color: rgba(12, 119, 165, 0.95);
  font-weight: 600;
}

.ufo-composer {
  border-top: 1px solid rgba(11, 44, 76, 0.1);
  background: #fff;
  padding: 10px;
}

.ufo-form {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

.ufo-input {
  flex: 1;
  min-height: 42px;
  max-height: 110px;
  resize: vertical;
  border-radius: 12px;
  border: 1px solid rgba(9, 46, 74, 0.2);
  padding: 10px 12px;
  font-size: 14px;
  line-height: 1.4;
  color: #0c2442;
  outline: none;
}

.ufo-input:focus {
  border-color: rgba(15, 110, 152, 0.7);
  box-shadow: 0 0 0 3px rgba(15, 110, 152, 0.16);
}

.ufo-send {
  flex: 0 0 auto;
  height: 42px;
  border: 0;
  border-radius: 12px;
  background: linear-gradient(150deg, #0a4b7a, #138385);
  color: #fff;
  min-width: 78px;
  padding: 0 16px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}

.ufo-ptt {
  flex: 0 0 auto;
  height: 42px;
  border: 1px solid rgba(9, 46, 74, 0.24);
  border-radius: 12px;
  background: linear-gradient(180deg, #ffffff, #edf7fb);
  color: #0d4f74;
  min-width: 94px;
  padding: 0 12px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  touch-action: none;
  user-select: none;
}

.ufo-ptt:hover {
  border-color: rgba(12, 114, 147, 0.45);
  background: linear-gradient(180deg, #ffffff, #e5f5fb);
}

.ufo-ptt:disabled {
  opacity: 0.56;
  cursor: not-allowed;
}

.ufo-assistant-root.voice-active .ufo-ptt {
  color: #fff;
  border-color: rgba(12, 97, 129, 0.74);
  background: linear-gradient(150deg, #0c6d87, #1599aa);
  box-shadow: 0 10px 24px rgba(15, 104, 132, 0.34);
}

.ufo-send[disabled] {
  opacity: 0.55;
  cursor: not-allowed;
}

.ufo-tip {
  margin-top: 8px;
  font-size: 12px;
  color: rgba(12, 36, 66, 0.68);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.ufo-voice-status {
  min-height: 16px;
  color: rgba(12, 86, 121, 0.82);
}

.ufo-voice-status[data-kind="active"] {
  color: rgba(12, 99, 130, 0.9);
}

.ufo-voice-status[data-kind="error"] {
  color: rgba(170, 42, 53, 0.95);
}

@keyframes ufo-float {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-5px);
  }
}

@keyframes ufo-ping {
  0% {
    transform: scale(1);
    opacity: 0.72;
  }
  80% {
    transform: scale(1.12);
    opacity: 0;
  }
  100% {
    transform: scale(1.12);
    opacity: 0;
  }
}

@keyframes ufo-cursor {
  0%,
  45% {
    opacity: 1;
  }
  46%,
  100% {
    opacity: 0;
  }
}

@media (max-width: 640px) {
  .ufo-assistant-root {
    right: 12px;
    bottom: 12px;
  }

  .ufo-panel {
    width: min(96vw, 420px);
    height: min(74vh, 560px);
  }

  .ufo-launcher {
    width: 58px;
    height: 58px;
    border-radius: 18px;
  }

  .ufo-resize {
    min-width: 48px;
    padding: 0 8px;
    font-size: 11px;
  }

  .ufo-ptt {
    min-width: 82px;
    padding: 0 10px;
    font-size: 12px;
  }

  .ufo-audio {
    min-width: min(220px, 74vw);
  }

  .ufo-audio audio {
    min-width: 180px;
    max-width: 72vw;
  }

  .ufo-assistant-root.expanded {
    right: 0;
    bottom: 0;
  }

  .ufo-assistant-root.expanded .ufo-panel {
    width: 100vw;
    height: 100dvh;
    max-height: 100dvh;
    right: 0;
    bottom: 0;
    border-radius: 0;
  }

  .ufo-assistant-root.expanded .ufo-header {
    padding-top: max(12px, env(safe-area-inset-top));
  }

  .ufo-assistant-root.expanded .ufo-composer {
    padding-bottom: calc(10px + env(safe-area-inset-bottom));
  }

  .ufo-assistant-root.expanded.open .ufo-launcher {
    opacity: 0;
    pointer-events: none;
  }
}
