.ai-assistant-root {
  position: fixed;
  right: max(104px, calc(env(safe-area-inset-right) + 104px));
  bottom: max(22px, env(safe-area-inset-bottom));
  z-index: 1200;
  color: #2a211d;
  font-family: "Microsoft YaHei", Arial, sans-serif;
  --ai-theme: #9f3f2f;
  --ai-paper: #fffaf2;
  --ai-line: rgba(71, 48, 38, 0.16);
  --ai-shadow: 0 24px 70px rgba(39, 27, 21, 0.24);
}

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

.ai-assistant-toggle {
  width: 64px;
  height: 64px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.55);
  border-radius: 50%;
  background: var(--ai-theme);
  color: #fff;
  box-shadow: 0 16px 38px rgba(38, 24, 17, 0.28);
  cursor: pointer;
  overflow: hidden;
}

.ai-assistant-hide-toggle {
  position: absolute;
  right: -4px;
  top: -8px;
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.8);
  border-radius: 50%;
  background: rgba(42, 33, 29, 0.78);
  color: #fff;
  box-shadow: 0 8px 18px rgba(38, 24, 17, 0.2);
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  z-index: 2;
}

.ai-assistant-show-toggle {
  width: 42px;
  height: 42px;
  display: none;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.66);
  border-radius: 50%;
  background: rgba(159, 63, 47, 0.92);
  color: #fff;
  box-shadow: 0 12px 30px rgba(38, 24, 17, 0.24);
  cursor: pointer;
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0;
}

.ai-assistant-root.pet-sleeping .ai-assistant-show-toggle {
  display: grid;
  width: 52px;
  height: 52px;
  background: var(--ai-theme);
  color: #fff;
  box-shadow: var(--ai-shadow);
}

.ai-assistant-root.pet-sleeping .ai-assistant-show-toggle::after {
  content: '唤醒';
  position: absolute;
  top: -22px;
  padding: 3px 7px;
  border-radius: 99px;
  background: rgba(45,28,20,.86);
  color: #fff;
  font-size: 10px;
  opacity: 0;
  transition: .18s;
}

.ai-assistant-root.pet-sleeping .ai-assistant-show-toggle:hover::after { opacity: 1; }

.ai-assistant-root.launcher-hidden .ai-assistant-toggle,
.ai-assistant-root.launcher-hidden .ai-assistant-hide-toggle,
.ai-assistant-root.launcher-hidden .ai-assistant-panel {
  display: none !important;
}

.ai-assistant-root.launcher-hidden .ai-assistant-show-toggle {
  display: grid;
}

.ai-voice-float {
  position: fixed;
  right: max(86px, calc(env(safe-area-inset-right) + 86px));
  bottom: max(24px, env(safe-area-inset-bottom));
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.58);
  border-radius: 50%;
  background: #2f6f68;
  color: #fff;
  box-shadow: 0 18px 40px rgba(28, 48, 45, 0.3);
  cursor: grab;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  overflow: visible;
}

.ai-voice-float i {
  margin-top: 0;
  font-size: 22px;
  line-height: 1;
}

.ai-voice-float-label {
  display: none;
}

.ai-voice-float-text {
  position: absolute;
  right: 0;
  bottom: calc(100% + 8px);
  max-width: min(280px, calc(100vw - 28px));
  border: 1px solid rgba(47, 111, 104, 0.18);
  border-radius: 999px;
  background: rgba(255, 250, 242, 0.98);
  color: #2f6f68;
  box-shadow: 0 14px 36px rgba(38, 24, 17, 0.16);
  padding: 8px 12px;
  font-size: 12px;
  line-height: 1.35;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ai-voice-float.active {
  cursor: grabbing;
  background: var(--ai-theme);
  animation: aiVoiceFloatBeat 0.9s ease-in-out infinite alternate;
}

.ai-voice-float.active::before,
.ai-voice-float.active::after {
  content: "";
  position: absolute;
  inset: -8px;
  border-radius: 50%;
  border: 1px solid rgba(159, 63, 47, 0.28);
  animation: aiVoiceRing 1.2s ease-out infinite;
}

.ai-voice-float.active::after {
  animation-delay: 0.35s;
}

.ai-voice-float.active .ai-voice-float-text {
  color: var(--ai-theme);
  border-color: rgba(159, 63, 47, 0.24);
}

.ai-assistant-toggle img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.ai-assistant-toggle span {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: 0;
}

.ai-pet {
  position: fixed;
  z-index: 2147483002;
  right: max(18px, env(safe-area-inset-right));
  bottom: max(18px, env(safe-area-inset-bottom));
  width: 122px;
  height: 172px;
  cursor: grab;
  touch-action: none;
  user-select: none;
  filter: drop-shadow(0 18px 18px rgba(45, 27, 18, 0.28));
  animation: aiPetFloat 3.4s ease-in-out infinite;
}

.ai-pet:active { cursor: grabbing; }
.ai-pet.no-idle { animation: none; }
.ai-pet-stage { position: absolute; inset: 0; }
.ai-pet-base { width: 100%; height: 100%; object-fit: contain; pointer-events: none; }
.ai-pet-video { background: transparent; mix-blend-mode: normal; }
.ai-assistant-root.pet-speaking .ai-pet-stage { animation: aiPetTalk .34s ease-in-out infinite alternate; }

.ai-pet-eye {
  position: absolute;
  top: 37.4%;
  width: 11.2%;
  height: 1.7%;
  border-radius: 100%;
  background: #291812;
  opacity: 0;
  transform: scaleY(.15);
  transform-origin: center;
  animation: aiPetBlink 5.2s infinite;
  pointer-events: none;
}

.ai-pet-eye.left { left: 34.7%; transform: rotate(7deg) scaleY(.15); }
.ai-pet-eye.right { left: 53.5%; transform: rotate(-7deg) scaleY(.15); }

.ai-pet-mouth {
  position: absolute;
  left: 45.4%;
  top: 50.8%;
  width: 9%;
  height: 2.4%;
  border-radius: 40% 40% 55% 55%;
  background: #6e221d;
  box-shadow: inset 0 -2px 0 #ef8f8a;
  opacity: 0;
  transform-origin: center top;
  pointer-events: none;
}

.pet-speaking .ai-pet-mouth,
.pet-speaking .ai-pet-eye,
.pet-speaking .ai-pet-gesture { display: none; }

.ai-pet-gesture {
  position: absolute;
  z-index: 3;
  right: 4.5%;
  top: 42%;
  width: 22%;
  height: 28%;
  transform-origin: 50% 88%;
  animation: aiPetVictoryGesture 4.4s ease-in-out infinite;
  pointer-events: none;
}

.ai-pet-gesture i {
  position: absolute;
  left: 42%;
  bottom: 0;
  width: 30%;
  height: 72%;
  border-radius: 999px;
  background: linear-gradient(90deg, #ecb296, #ffd3b6 52%, #d78c74);
  box-shadow: inset -2px 0 2px rgba(112,45,34,.2);
  transform: rotate(-10deg);
}

.ai-pet-gesture b,
.ai-pet-gesture b::before {
  content: "";
  position: absolute;
  top: 0;
  width: 24%;
  height: 46%;
  border-radius: 999px;
  background: linear-gradient(90deg, #f0b89d, #ffd7ba);
  transform-origin: bottom center;
}

.ai-pet-gesture b { left: 30%; transform: rotate(-17deg); }
.ai-pet-gesture b::before { left: 145%; width: 100%; height: 100%; transform: rotate(32deg); }

.ai-pet.no-face-animation .ai-pet-eye, .ai-pet.no-face-animation .ai-pet-mouth { display: none; }
.ai-pet.no-hand-animation .ai-pet-gesture { display: none; }

.ai-pet-hover-tip {
  position: absolute;
  right: 92%;
  bottom: 35%;
  width: 174px;
  padding: 9px 12px;
  border: 1px solid rgba(159,63,47,.18);
  border-radius: 10px;
  background: rgba(255,252,246,.97);
  box-shadow: 0 12px 30px rgba(42,25,18,.17);
  color: #39261e;
  opacity: 0;
  transform: translateX(8px);
  transition: .18s ease;
  pointer-events: none;
}

.ai-pet-hover-tip strong, .ai-pet-hover-tip span { display: block; }
.ai-pet-hover-tip strong { font-size: 13px; }
.ai-pet-hover-tip span { margin-top: 3px; color: #80685c; font-size: 11px; }
.ai-pet:hover .ai-pet-hover-tip { opacity: 1; transform: none; }
.ai-assistant-root.interaction-started .ai-pet-hover-tip { display: none; }

.ai-pet-hover-tools {
  position: absolute;
  right: 2px;
  top: 8px;
  display: none;
  gap: 5px;
  opacity: 0;
  transform: translateX(7px);
  transition: .18s ease;
}

.ai-pet:hover .ai-pet-hover-tools { opacity: 1; transform: none; }
.ai-pet-hover-tools button { width: 27px; height: 27px; display: grid; place-items: center; border: 1px solid rgba(255,255,255,.72); border-radius: 50%; background: rgba(72,39,26,.88); color: #fff; box-shadow: 0 6px 14px rgba(39,22,15,.2); cursor: pointer; }
.ai-pet-hover-tools button:hover { background: var(--ai-theme); transform: scale(1.08); }

.ai-pet-bubble {
  position: absolute;
  right: 82%;
  bottom: 76%;
  width: min(290px, calc(100vw - 220px));
  padding: 11px 14px;
  border: 1px solid rgba(159, 63, 47, .22);
  border-radius: 15px 15px 4px 15px;
  background: rgba(255, 252, 246, .97);
  color: #382820;
  box-shadow: 0 14px 34px rgba(43, 26, 18, .18);
  font-size: 13px;
  line-height: 1.55;
  opacity: 0;
  transform: translateY(8px) scale(.96);
  transform-origin: right bottom;
  transition: .2s ease;
  pointer-events: none;
}

.ai-pet-bubble.show { opacity: 1; transform: none; }

.ai-pet-status {
  position: absolute;
  left: 50%;
  bottom: 1px;
  transform: translateX(-50%);
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 9px;
  border-radius: 99px;
  background: rgba(39, 25, 19, .82);
  color: white;
  font-size: 10px;
  white-space: nowrap;
}

.ai-pet-status i { width: 6px; height: 6px; border-radius: 50%; background: #62d585; box-shadow: 0 0 0 3px rgba(98,213,133,.17); }

.ai-voice-cancel {
  position: absolute;
  z-index: 8;
  right: -7px;
  bottom: 9px;
  width: 32px;
  height: 32px;
  display: none;
  place-items: center;
  border: 2px solid #fff;
  border-radius: 50%;
  background: #c94636;
  color: #fff;
  box-shadow: 0 7px 18px rgba(107, 26, 20, .32);
  cursor: pointer;
}

.ai-voice-cancel.show { display: grid; animation: aiVoiceCancelIn .16s ease-out; }
.ai-voice-cancel:hover { background: #a92f24; transform: scale(1.06); }

.ai-assistant-root.voice-listening .ai-pet-status {
  background: rgba(159, 63, 47, .92);
}

.ai-assistant-root.voice-listening .ai-pet-status i {
  background: #fff;
  animation: aiVoicePulse .8s ease-out infinite;
}

@keyframes aiVoiceCancelIn {
  from { opacity: 0; transform: scale(.72); }
  to { opacity: 1; transform: scale(1); }
}

.ai-pet-menu {
  position: fixed;
  z-index: 2147483004;
  right: 170px;
  bottom: 90px;
  width: 162px;
  display: none;
  padding: 7px;
  border: 1px solid var(--ai-line);
  border-radius: 12px;
  background: rgba(255, 251, 244, .98);
  box-shadow: 0 18px 48px rgba(40, 23, 16, .24);
}

.ai-pet-menu.open { display: grid; }
.ai-pet-menu.open::before {
  content: '轻点选择功能';
  padding: 4px 8px 6px;
  color: rgba(59, 43, 35, .58);
  font-size: 10px;
  text-align: center;
}
.ai-pet-menu button { display: flex; align-items: center; gap: 8px; padding: 9px 10px; border: 0; border-radius: 8px; background: transparent; color: #3b2b23; text-align: left; cursor: pointer; }
.ai-pet-menu button:hover { background: rgba(159, 63, 47, .09); color: var(--ai-theme); }

@keyframes aiPetFloat { 0%,100% { transform: translateY(var(--pet-tilt-y, 0)) rotate(calc(-.6deg + var(--pet-tilt-x, 0deg))); } 50% { transform: translateY(calc(-8px + var(--pet-tilt-y, 0px))) rotate(calc(.8deg + var(--pet-tilt-x, 0deg))); } }
@keyframes aiPetTalk { from { transform: translateY(-3px) scale(1); } to { transform: translateY(-7px) scale(1.025); } }
@keyframes aiPetBlink { 0%,44%,48%,100% { opacity: 0; transform: scaleY(.15); } 45%,47% { opacity: .92; transform: scaleY(1); } }
@keyframes aiPetMouth { from { transform: scale(.85,.45); } to { transform: scale(1.08,1.7); } }
@keyframes aiPetVictoryGesture {
  0%, 66%, 100% { opacity: 0; transform: rotate(4deg) translateY(5px) scale(.9); }
  70% { opacity: .96; transform: rotate(-12deg) translateY(0) scale(1); }
  77% { opacity: .96; transform: rotate(9deg) translateY(-3px) scale(1.04); }
  84% { opacity: .96; transform: rotate(-8deg) translateY(0) scale(1); }
  91% { opacity: 0; transform: rotate(3deg) translateY(4px) scale(.92); }
}

.ai-human-float {
  position: fixed;
  right: max(18px, env(safe-area-inset-right));
  bottom: max(96px, calc(env(safe-area-inset-bottom) + 96px));
  width: 74px;
  min-height: 86px;
  display: grid;
  place-items: center;
  gap: 5px;
  border: 1px solid rgba(255, 255, 255, 0.64);
  border-radius: 8px;
  background: rgba(255, 250, 242, 0.96);
  color: var(--ai-theme);
  box-shadow: 0 18px 42px rgba(38, 24, 17, 0.22);
  cursor: grab;
  touch-action: none;
  user-select: none;
}

.ai-human-float:active {
  cursor: grabbing;
}

.ai-human-float.cutout-mode {
  width: 152px;
  min-height: 238px;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
  filter: drop-shadow(0 18px 24px rgba(38, 24, 17, 0.28));
}

.ai-human-float.cutout-mode .ai-human-avatar {
  width: 152px;
  height: 206px;
  border-radius: 0;
  background: transparent;
  overflow: visible;
}

.ai-human-float.cutout-mode .ai-human-avatar img {
  object-fit: contain;
}

.ai-human-float.cutout-mode .ai-human-avatar span {
  display: block;
}

.ai-human-float.cutout-mode strong {
  max-width: 128px;
  padding: 5px 9px;
  border-radius: 999px;
  background: rgba(255, 250, 242, 0.95);
  box-shadow: 0 10px 24px rgba(38, 24, 17, 0.14);
}

.ai-human-avatar {
  width: 54px;
  height: 54px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--ai-theme);
  color: #fff;
  overflow: hidden;
  font-size: 12px;
  font-weight: 800;
  line-height: 1.15;
  text-align: center;
}

.ai-human-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.ai-human-float.cutout-mode .ai-human-avatar img {
  width: 152px;
  height: 206px;
  object-fit: contain;
}

.ai-human-default {
  position: relative;
  width: 96px;
  height: 138px;
  filter: drop-shadow(0 18px 18px rgba(38, 24, 17, 0.22));
}

.ai-human-default::before {
  content: "";
  position: absolute;
  left: 18px;
  top: 0;
  width: 60px;
  height: 34px;
  border-radius: 22px 22px 12px 12px;
  background: linear-gradient(135deg, #2f6f68, #b8432d);
  transform: rotate(-2deg);
}

.ai-human-default-head {
  position: absolute;
  left: 21px;
  top: 22px;
  width: 54px;
  height: 48px;
  border-radius: 22px 22px 24px 24px;
  background: #fff4df;
  box-shadow: inset 0 -5px 0 rgba(184, 67, 45, 0.12);
}

.ai-human-default-head::before,
.ai-human-default-head::after {
  content: "";
  position: absolute;
  top: 19px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #473026;
}

.ai-human-default-head::before {
  left: 16px;
}

.ai-human-default-head::after {
  right: 16px;
}

.ai-human-default-body {
  position: absolute;
  left: 18px;
  top: 64px;
  width: 60px;
  height: 58px;
  border-radius: 24px 24px 28px 28px;
  background: linear-gradient(180deg, #2f6f68, #235b76);
}

.ai-human-default-body::before {
  content: "AI";
  position: absolute;
  left: 50%;
  top: 15px;
  transform: translateX(-50%);
  color: #fff7e8;
  font-size: 13px;
  font-weight: 800;
}

.ai-human-default-body::after {
  content: "";
  position: absolute;
  left: 10px;
  bottom: -16px;
  width: 40px;
  height: 22px;
  border-radius: 0 0 18px 18px;
  background: inherit;
}

.ai-human-default-arm {
  position: absolute;
  top: 75px;
  width: 18px;
  height: 46px;
  border-radius: 999px;
  background: #2f6f68;
}

.ai-human-default-arm.left {
  left: 4px;
  transform: rotate(18deg);
}

.ai-human-default-arm.right {
  right: 4px;
  transform: rotate(-18deg);
}

.ai-human-float strong {
  max-width: 64px;
  color: #3a2b24;
  font-size: 12px;
  line-height: 1.2;
  text-align: center;
  word-break: break-word;
}

.ai-human-hide {
  position: absolute;
  top: -8px;
  right: -8px;
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(42, 33, 29, 0.82);
  color: #fff;
  font-size: 14px;
}

.ai-human-frame-wrap {
  position: fixed;
  right: max(96px, calc(env(safe-area-inset-right) + 96px));
  bottom: max(22px, env(safe-area-inset-bottom));
  width: min(var(--ai-human-width, 430px), calc(100vw - 34px));
  height: min(var(--ai-human-height, 720px), calc(100vh - 44px));
  display: none;
  grid-template-rows: auto 1fr;
  border: 1px solid rgba(71, 48, 38, 0.18);
  border-radius: 8px;
  background: #1f2452;
  box-shadow: 0 26px 78px rgba(39, 27, 21, 0.32);
  overflow: hidden;
}

.ai-human-frame-wrap.open {
  display: grid;
}

.ai-human-frame-wrap header {
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  background: rgba(255, 250, 242, 0.96);
  color: #2a211d;
}

.ai-human-frame-wrap header strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
}

.ai-human-frame-close {
  width: 30px;
  height: 30px;
  border: 1px solid var(--ai-line);
  border-radius: 50%;
  background: #fff;
  color: #2a211d;
  cursor: pointer;
}

.ai-human-frame-wrap iframe {
  width: 100%;
  height: 100%;
  border: 0;
  background: #1f2452;
}

.ai-assistant-panel {
  position: absolute;
  right: 0;
  bottom: 78px;
  width: min(390px, calc(100vw - 28px));
  max-height: min(720px, calc(100vh - 118px));
  display: none;
  grid-template-rows: auto minmax(160px, 1fr) auto;
  border: 1px solid var(--ai-line);
  border-radius: 8px;
  background: rgba(255, 250, 242, 0.96);
  box-shadow: var(--ai-shadow);
  backdrop-filter: blur(14px);
  overflow: hidden;
}

.ai-assistant-root.open .ai-assistant-panel {
  display: grid;
}

.ai-assistant-root.has-pet .ai-assistant-toggle,
.ai-assistant-root.has-pet .ai-assistant-hide-toggle,
.ai-assistant-root.has-pet .ai-voice-float { display: none; }

.ai-assistant-root.has-pet .ai-assistant-panel { right: 176px; bottom: 24px; }

.ai-page-preview {
  position: fixed;
  z-index: 2147482998;
  inset: 16px 16px 16px auto;
  width: min(680px, calc(100vw - 450px));
  min-width: 420px;
  display: none;
  grid-template-rows: 48px 1fr;
  overflow: hidden;
  border: 1px solid var(--ai-line);
  border-radius: 12px;
  background: #fffaf2;
  box-shadow: 0 24px 80px rgba(38, 23, 17, 0.28);
}

.ai-page-preview.open { display: grid; }

.ai-page-preview header {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  border-bottom: 1px solid var(--ai-line);
  background: linear-gradient(135deg, #fff8ec, #f1dfc3);
}

.ai-page-preview header button {
  width: 32px;
  height: 32px;
  border: 1px solid var(--ai-line);
  border-radius: 50%;
  background: #fff;
  cursor: pointer;
}

.ai-page-preview-frame { width: 100%; height: 100%; border: 0; background: #fff; }
.ai-assistant-root.preview-open .ai-assistant-panel { right: min(696px, calc(100vw - 434px)); }

.ai-assistant-head {
  display: grid;
  grid-template-columns: 48px 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 14px;
  background: #f5ead8;
  border-bottom: 1px solid var(--ai-line);
}

.ai-assistant-avatar {
  width: 48px;
  height: 48px;
  border-radius: 8px;
  background: var(--ai-theme);
  color: #fff;
  display: grid;
  place-items: center;
  overflow: hidden;
  font-weight: 800;
}

.ai-assistant-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.ai-assistant-title {
  margin: 0;
  font-size: 16px;
  line-height: 1.3;
}

.ai-assistant-subtitle {
  display: block;
  margin-top: 2px;
  color: rgba(42, 33, 29, 0.66);
  font-size: 12px;
  line-height: 1.35;
}

.ai-assistant-close {
  width: 34px;
  height: 34px;
  border: 1px solid var(--ai-line);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.78);
  color: #3a2b24;
  cursor: pointer;
}

.ai-assistant-log {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
  padding: 14px;
  overflow: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}

.ai-assistant-controls {
  min-height: 0;
  max-height: min(58dvh, 470px);
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: rgba(255, 252, 246, 0.96);
}

.ai-message {
  max-width: 88%;
  border-radius: 8px;
  padding: 10px 12px;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.62;
  font-size: 14px;
}

.ai-message.assistant {
  align-self: flex-start;
  background: #fff;
  border: 1px solid rgba(159, 63, 47, 0.14);
}

.ai-message.user {
  align-self: flex-end;
  background: var(--ai-theme);
  color: #fff;
}

.ai-message.system {
  align-self: center;
  max-width: 100%;
  color: rgba(42, 33, 29, 0.62);
  background: transparent;
  padding: 2px 0;
  font-size: 12px;
}

.ai-result-list {
  display: grid;
  gap: 8px;
  width: 100%;
}

.ai-result-card {
  display: grid;
  grid-template-columns: 72px 1fr;
  gap: 10px;
  align-items: start;
  border: 1px solid rgba(159, 63, 47, 0.14);
  border-radius: 8px;
  background: #fff;
  padding: 9px;
  cursor: pointer;
}

.ai-result-card img,
.ai-result-card video {
  width: 72px;
  height: 72px;
  border-radius: 6px;
  object-fit: cover;
  background: #f4eadc;
}

.ai-result-card video { background: #120f0d; }

.ai-selected-result video {
  width: min(220px, 42%);
  max-height: 180px;
  object-fit: cover;
  border-radius: 12px;
  background: #120f0d;
}

.ai-result-card > div {
  min-width: 0;
}

.ai-result-card span {
  display: block;
  color: rgba(42, 33, 29, 0.55);
  font-size: 11px;
  line-height: 1.3;
}

.ai-result-card strong {
  display: block;
  margin-top: 2px;
  color: #2a211d;
  font-size: 14px;
  line-height: 1.35;
}

.ai-result-card p {
  margin: 5px 0 8px;
  color: rgba(42, 33, 29, 0.72);
  font-size: 12px;
  line-height: 1.55;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.ai-result-card button {
  min-height: 30px;
  border: 1px solid rgba(159, 63, 47, 0.2);
  border-radius: 999px;
  background: rgba(159, 63, 47, 0.08);
  color: var(--ai-theme);
  padding: 5px 10px;
  cursor: pointer;
  font-size: 12px;
}

.ai-selected-result {
  display: grid;
  grid-template-columns: 76px 1fr;
  gap: 10px;
  width: 100%;
  border: 1px solid rgba(159, 63, 47, 0.24);
  border-left: 4px solid var(--ai-theme);
  border-radius: 8px;
  background: rgba(159, 63, 47, 0.07);
  padding: 10px;
}

.ai-selected-result img {
  width: 76px;
  height: 76px;
  border-radius: 6px;
  object-fit: cover;
  background: #f4eadc;
}

.ai-selected-result span,
.ai-selected-result small {
  display: block;
  color: rgba(42, 33, 29, 0.56);
  font-size: 11px;
  line-height: 1.35;
  word-break: break-all;
}

.ai-selected-result strong {
  display: block;
  margin: 2px 0 5px;
  color: #2a211d;
  font-size: 14px;
}

.ai-selected-result p {
  margin: 0 0 6px;
  color: rgba(42, 33, 29, 0.72);
  font-size: 12px;
  line-height: 1.55;
}

.ai-quick-list {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  padding: 0 14px 10px;
}

.ai-quick-list button,
.ai-tool-btn,
.ai-send-btn {
  border: 1px solid var(--ai-line);
  border-radius: 999px;
  background: #fff;
  color: #3a2b24;
  cursor: pointer;
}

.ai-quick-list button {
  padding: 7px 10px;
  font-size: 12px;
}

.ai-assistant-compose {
  border-top: 1px solid var(--ai-line);
  padding: 12px;
  background: rgba(255, 252, 246, 0.96);
}

.ai-attachment-list {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.ai-attachment {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  border: 1px solid var(--ai-line);
  border-radius: 999px;
  background: #fff;
  padding: 5px 8px;
  color: rgba(42, 33, 29, 0.78);
  font-size: 12px;
}

.ai-attachment img {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  object-fit: cover;
}

.ai-camera-preview {
  display: none;
  margin-bottom: 8px;
  border: 1px solid var(--ai-line);
  border-radius: 8px;
  overflow: visible;
  background: #17120f;
}

.ai-camera-preview.active {
  display: block;
}

.ai-camera-preview video {
  width: 100%;
  max-height: 210px;
  display: block;
  object-fit: cover;
}

.ai-camera-status {
  min-height: 32px;
  padding: 7px 10px;
  background: rgba(20, 18, 16, 0.88);
  color: #e8f8f4;
  font-size: 12px;
  line-height: 1.45;
}
.ai-camera-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px;
  background: rgba(255, 250, 242, 0.92);
}

.ai-camera-actions .ai-tool-btn:disabled {
  opacity: .42;
  cursor: not-allowed;
}

.ai-input-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: end;
}

.ai-assistant-input {
  width: 100%;
  min-height: 42px;
  max-height: 130px;
  resize: vertical;
  border: 1px solid var(--ai-line);
  border-radius: 8px;
  background: #fff;
  color: #2a211d;
  padding: 10px 12px;
  outline: none;
  line-height: 1.5;
}

.ai-send-btn {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-color: transparent;
  background: var(--ai-theme);
  color: #fff;
}

.ai-tool-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.ai-tool-btn {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 7px 10px;
  font-size: 12px;
}

.ai-tool-btn.active {
  border-color: rgba(159, 63, 47, 0.36);
  color: var(--ai-theme);
}

.ai-voice-btn.active {
  position: relative;
  border-color: rgba(159, 63, 47, 0.58);
  background: rgba(159, 63, 47, 0.1);
  color: var(--ai-theme);
}

.ai-voice-btn.active::after {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ai-theme);
  box-shadow: 0 0 0 0 rgba(159, 63, 47, 0.32);
  animation: aiVoicePulse 1s ease-out infinite;
}

.ai-voice-status {
  display: none;
  flex: 1 0 100%;
  margin-top: 2px;
  border: 1px solid rgba(159, 63, 47, 0.16);
  border-radius: 999px;
  background: rgba(159, 63, 47, 0.07);
  color: var(--ai-theme);
  padding: 7px 10px;
  font-size: 12px;
  line-height: 1.35;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ai-voice-status.active {
  display: block;
}

@keyframes aiVoicePulse {
  0% {
    box-shadow: 0 0 0 0 rgba(159, 63, 47, 0.32);
  }
  80%,
  100% {
    box-shadow: 0 0 0 10px rgba(159, 63, 47, 0);
  }
}

@keyframes aiVoiceRing {
  0% {
    opacity: 0.9;
    transform: scale(0.92);
  }
  100% {
    opacity: 0;
    transform: scale(1.32);
  }
}

@keyframes aiVoiceFloatBeat {
  from {
    transform: scale(1);
  }
  to {
    transform: scale(1.045);
  }
}

.ai-assistant-hidden {
  display: none !important;
}

@media (max-width: 1024px) and (orientation: portrait) {
  .ai-assistant-root { right: 0; bottom: 0; }
  .ai-pet { width: 96px; height: 138px; right: max(8px, env(safe-area-inset-right)); bottom: max(8px, env(safe-area-inset-bottom)); }
  .ai-pet-bubble { right: 70%; bottom: 80%; width: min(260px, calc(100vw - 108px)); }
  .ai-pet-menu { right: 104px; bottom: 74px; }
  .ai-assistant-root.has-pet .ai-assistant-panel,
  .ai-assistant-panel {
    position: fixed;
    left: max(8px, env(safe-area-inset-left));
    right: max(8px, env(safe-area-inset-right));
    bottom: calc(146px + env(safe-area-inset-bottom));
    width: auto;
    height: min(72dvh, 680px);
    max-height: calc(100dvh - 166px - env(safe-area-inset-bottom));
  }
  .ai-assistant-controls { max-height: 48dvh; }
  .ai-camera-preview video { max-height: min(32dvh, 280px); object-fit: contain; }
  .ai-page-preview { inset: 8px; width: auto; min-width: 0; }
  .ai-assistant-root.preview-open .ai-assistant-panel { right: max(8px, env(safe-area-inset-right)); }
}

@media (max-width: 640px) {
  .ai-pet { width: 92px; height: 132px; right: 6px; bottom: 6px; }
  .ai-pet-bubble { right: 66%; bottom: 79%; width: min(230px, calc(100vw - 100px)); }
  .ai-pet-menu { right: 96px; bottom: 70px; }
  .ai-assistant-root.has-pet .ai-assistant-panel { right: max(6px, env(safe-area-inset-right)); bottom: calc(142px + env(safe-area-inset-bottom)); }
  .ai-page-preview {
    inset: 8px;
    width: auto;
    min-width: 0;
  }

  .ai-assistant-root.preview-open .ai-assistant-panel { right: max(6px, env(safe-area-inset-right)); }
  .ai-assistant-root {
    right: max(104px, calc(env(safe-area-inset-right) + 104px));
    bottom: 14px;
  }

  .ai-assistant-toggle {
    width: 56px;
    height: 56px;
  }

  .ai-voice-float {
    width: 48px;
    height: 48px;
    right: 72px;
    bottom: 14px;
  }

  .ai-human-float {
    width: 64px;
    min-height: 76px;
    right: 12px;
    bottom: 82px;
  }

  .ai-human-float.cutout-mode {
    width: 94px;
    min-height: 136px;
  }

  .ai-human-float.cutout-mode .ai-human-avatar {
    width: 94px;
    height: 116px;
  }

  .ai-human-avatar {
    width: 46px;
    height: 46px;
  }

  .ai-human-frame-wrap {
    right: 12px;
    bottom: 12px;
    width: calc(100vw - 24px);
    height: min(680px, calc(100vh - 24px));
  }

  .ai-voice-float-text {
    max-width: calc(100vw - 32px);
  }

  .ai-assistant-panel {
    left: max(6px, env(safe-area-inset-left));
    right: max(6px, env(safe-area-inset-right));
    width: auto;
    height: min(76dvh, 620px);
    max-height: calc(100dvh - 154px - env(safe-area-inset-bottom));
  }

  .ai-assistant-head { grid-template-columns: 40px 1fr auto; padding: 10px; }
  .ai-assistant-avatar { width: 40px; height: 40px; }
  .ai-assistant-log { padding: 10px; }
  .ai-assistant-controls { max-height: 54dvh; }
  .ai-assistant-compose { padding: 9px; }
  .ai-camera-preview video { max-height: 27dvh; }
  .ai-camera-actions { gap: 6px; }
  .ai-camera-actions .ai-tool-btn { flex: 1 1 calc(50% - 6px); justify-content: center; }

  .ai-result-card {
    grid-template-columns: 58px 1fr;
  }

  .ai-result-card img {
    width: 58px;
    height: 58px;
  }
}

@media (max-width: 920px) and (orientation: landscape) {
  .ai-assistant-panel { max-height: calc(var(--ai-vh, 1vh) * 92); bottom: 4px; }
  .ai-pet { width: 82px; height: 118px; }
  .ai-camera-preview video { max-height: calc(var(--ai-vh, 1vh) * 48); object-fit: contain; }
}

/* AI brown avatar background */
.ai-assistant-toggle,
.ai-assistant-avatar {
  background: linear-gradient(145deg, #2f1a13 0%, #694029 50%, #b77a43 100%);
  box-shadow: 0 16px 38px rgba(55, 31, 20, 0.36), inset 0 0 18px rgba(255, 218, 164, 0.18);
}

.ai-assistant-toggle img,
.ai-assistant-avatar img {
  object-fit: contain;
  padding: 3px;
}
