/* ==========================================================================
   KAI WANG PORTFOLIO — MINIMAL KIMI + CLAUDE CODE FLOATING 1/3 CHAT OVERLAY
   - Clean typography (13.5px / 22px), balanced icon sizes (13px–14px), airy spacing
   - 1/3 Viewport Floating Panel (width: 33.333vw), Non-navigating Overlay
   ========================================================================== */

:root {
  --kimi-ink: #18181b;
  --kimi-ink-secondary: #52525b;
  --kimi-ink-muted: #a1a1aa;
  --kimi-surface: #ffffff;
  --kimi-canvas: #f4f4f5;
  --kimi-border: rgba(24, 24, 27, 0.07);
  --kimi-red: #ff1b46;
  --kimi-blue: #4c88ff;
}

/* 1. BOTTOM-RIGHT 3D AVATAR FLOATING LAUNCHER (#tn-ai-launcher — 全页面悬浮) */
.tn-ai-launcher {
  position: fixed;
  right: 28px;
  bottom: 24px;
  z-index: 125;
  display: flex;
  align-items: center;
  gap: 12px;
  user-select: none;
  pointer-events: auto;
  transition: opacity 0.22s ease, transform 0.24s cubic-bezier(0.22, 1, 0.36, 1);
}

body.jv-chat-open .tn-ai-launcher,
body.lightbox-open .tn-ai-launcher {
  opacity: 0;
  transform: scale(0.92);
  pointer-events: none;
}

.tn-ai-launcher__bubble {
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  color: #18181b;
  padding: 10px 16px;
  border-radius: 20px 20px 4px 20px;
  border: 1px solid rgba(255, 255, 255, 0.88);
  box-shadow:
    0 10px 28px rgba(18, 18, 18, 0.08),
    0 2px 6px rgba(18, 18, 18, 0.04),
    inset 0 1px 0 rgba(255, 255, 255, 0.92);
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transform-origin: right bottom;
  transition:
    transform 0.32s cubic-bezier(0.22, 1, 0.36, 1),
    background-color 0.25s ease,
    box-shadow 0.25s ease,
    opacity 0.25s ease;
}

.tn-ai-launcher__bubble:hover {
  transform: translateY(-2px) scale(1.02);
  background: rgba(255, 255, 255, 0.88);
  box-shadow:
    0 14px 34px rgba(18, 18, 18, 0.12),
    0 3px 8px rgba(18, 18, 18, 0.05),
    inset 0 1px 0 #ffffff;
}

.tn-ai-launcher__bubble-text {
  font-family: var(--tn-font-display, "Inter", sans-serif);
  font-size: 13.5px;
  font-weight: 500;
  letter-spacing: -0.01em;
  white-space: nowrap;
}

/* 3D Plush Character Pedestal Button (睁眼 + 打招呼动作) */
.tn-ai-launcher__avatar-btn {
  width: 82px;
  height: 82px;
  border-radius: 50%;
  padding: 0;
  border: none;
  background: transparent;
  position: relative;
  cursor: pointer;
  perspective: 600px;
  transition: transform 0.34s cubic-bezier(0.22, 1, 0.36, 1);
  animation: tnAiFloat 4.8s ease-in-out infinite;
}

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

.tn-ai-launcher:hover .tn-ai-launcher__avatar-btn {
  animation-play-state: paused;
  transform: scale(1.07) translateY(-3px);
}

.tn-ai-launcher__avatar-ring {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: transparent;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  transform-style: preserve-3d;
  transition: transform 0.2s ease-out;
}

.tn-ai-launcher__char-stage {
  position: relative;
  width: 82px;
  height: 82px;
  pointer-events: none;
  filter: drop-shadow(0 10px 20px rgba(20, 20, 20, 0.22));
  animation: tnPlushHeadGreet 4.8s ease-in-out infinite;
}

.tn-ai-launcher:hover .tn-ai-launcher__char-stage {
  animation: tnPlushHeadHover 1.1s ease-in-out infinite alternate;
}

.tn-ai-launcher__head {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  pointer-events: none;
  user-select: none;
}

/* Open-eyes layer: periodically opens eyes during greeting cycle, and stays open on hover */
.tn-ai-launcher__head--open {
  opacity: 0;
  animation: tnPlushEyeOpen 4.8s steps(1, end) infinite;
}

.tn-ai-launcher:hover .tn-ai-launcher__head--open {
  animation: tnPlushHoverBlink 3.2s steps(1, end) infinite;
  opacity: 1;
}

/* 3D Plush Waving Hand (pops out by right cheek and waves hello) */
.tn-ai-launcher__hand {
  position: absolute;
  width: 31px;
  height: 31px;
  right: -6px;
  bottom: 4px;
  object-fit: contain;
  pointer-events: none;
  user-select: none;
  transform-origin: 52% 86%;
  filter: drop-shadow(0 4px 8px rgba(20, 20, 20, 0.18));
  animation: tnPlushHandWave 4.8s ease-in-out infinite;
}

.tn-ai-launcher:hover .tn-ai-launcher__hand {
  animation: tnPlushHandWaveHover 0.42s ease-in-out infinite alternate;
}

/* Keyframes: Periodic Eye-Opening (睁眼) */
@keyframes tnPlushEyeOpen {
  0%, 36% {
    opacity: 0;
  }
  37%, 82% {
    opacity: 1;
  }
  83%, 100% {
    opacity: 0;
  }
}

/* Keyframes: Natural quick blink while hovering with eyes open */
@keyframes tnPlushHoverBlink {
  0%, 92%, 100% {
    opacity: 1;
  }
  94%, 97% {
    opacity: 0;
  }
}

/* Keyframes: Head perk-up & cheerful tilt when opening eyes and waving */
@keyframes tnPlushHeadGreet {
  0%, 34%, 86%, 100% {
    transform: rotate(0deg) scale(1);
  }
  37% {
    transform: translateY(1px) scale(1.03, 0.96);
  }
  42%, 78% {
    transform: translateY(-2px) rotate(-4deg) scale(1.02);
  }
  60% {
    transform: translateY(-3px) rotate(3deg) scale(1.02);
  }
}

@keyframes tnPlushHeadHover {
  0% {
    transform: translateY(-2px) rotate(-3.5deg) scale(1.03);
  }
  100% {
    transform: translateY(-4px) rotate(3.5deg) scale(1.03);
  }
}

/* Keyframes: 3D Plush Hand Waving Hello (打招呼) */
@keyframes tnPlushHandWave {
  0%, 34% {
    opacity: 0;
    transform: translateY(8px) scale(0.55) rotate(-20deg);
  }
  40% {
    opacity: 1;
    transform: translateY(0px) scale(1) rotate(-18deg);
  }
  48% {
    opacity: 1;
    transform: translateY(-1px) scale(1.04) rotate(22deg);
  }
  56% {
    opacity: 1;
    transform: translateY(0px) scale(1) rotate(-18deg);
  }
  64% {
    opacity: 1;
    transform: translateY(-1px) scale(1.04) rotate(22deg);
  }
  72% {
    opacity: 1;
    transform: translateY(0px) scale(1) rotate(-14deg);
  }
  80% {
    opacity: 1;
    transform: translateY(0px) scale(1) rotate(16deg);
  }
  87%, 100% {
    opacity: 0;
    transform: translateY(8px) scale(0.55) rotate(-15deg);
  }
}

@keyframes tnPlushHandWaveHover {
  0% {
    opacity: 1;
    transform: translateY(-1px) scale(1.05) rotate(-20deg);
  }
  100% {
    opacity: 1;
    transform: translateY(-2px) scale(1.08) rotate(24deg);
  }
}

.tn-ai-launcher__status-badge {
  position: absolute;
  right: 6px;
  bottom: 6px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: rgb(15, 122, 252);
  border: 2.5px solid #ffffff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
  z-index: 3;
}

/* 2. FLOATING 1/3-PAGE CHAT OVERLAY (#jv-chat-overlay — 玻璃白色透明) */
.jv-chat-overlay {
  position: fixed;
  top: 74px;
  right: 28px;
  bottom: 24px;
  width: 33.333vw;
  min-width: 360px;
  max-width: 480px;
  background-color: rgba(255, 255, 255, 0.74);
  backdrop-filter: blur(28px) saturate(180%);
  -webkit-backdrop-filter: blur(28px) saturate(180%);
  border: 1px solid rgba(255, 255, 255, 0.85);
  border-radius: 20px;
  box-shadow:
    0 20px 50px -12px rgba(18, 18, 18, 0.12),
    0 4px 14px -2px rgba(18, 18, 18, 0.04),
    inset 0 1px 0 rgba(255, 255, 255, 0.92);
  z-index: 130;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(10px) scale(0.985);
  transform-origin: bottom right;
  pointer-events: none;
  transition:
    opacity 0.22s cubic-bezier(0.22, 1, 0.36, 1),
    transform 0.24s cubic-bezier(0.22, 1, 0.36, 1);
}

.jv-chat-overlay.is-open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* 3. MINIMAL HEADER BAR */
.jv-chat-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid rgba(24, 24, 27, 0.05);
  flex-shrink: 0;
}

.jv-chat-topbar__brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.jv-chat-topbar__logo {
  height: 18px;
  width: auto;
  display: block;
  object-fit: contain;
}

.jv-chat-topbar__tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-family: "Inter", "PingFang SC", sans-serif;
  font-size: 11.5px;
  font-weight: 400;
  color: var(--kimi-ink-muted);
}

.jv-chat-topbar__dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background-color: #22c55e;
}

.jv-chat-topbar__actions {
  display: inline-flex;
  align-items: center;
  gap: 2px;
}

.jv-chat-icon-btn,
.jv-chat-close-btn {
  appearance: none;
  border: none;
  background: transparent;
  width: 26px;
  height: 26px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--kimi-ink-muted);
  cursor: pointer;
  transition: background-color 0.16s ease, color 0.16s ease;
}

.jv-chat-icon-btn:hover,
.jv-chat-close-btn:hover {
  background-color: var(--kimi-canvas);
  color: var(--kimi-ink);
}

/* 4. CHAT BODY & MESSAGE THREAD */
.jv-chat-page {
  width: 100%;
  height: 100%;
  flex: 1;
  min-height: 0;
  margin: 0;
  padding: 0 16px 14px;
  position: relative;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-sizing: border-box;
}

.jv-chat-thread {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 16px 0 12px;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.jv-chat-thread::-webkit-scrollbar {
  display: none;
}

.jv-chat-row {
  width: 100%;
  display: flex;
}

.jv-chat-row-assistant {
  max-width: 100%;
  gap: 10px;
  align-items: flex-start;
}

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

/* Clean 26x26 Avatar */
.jv-chat-avatar {
  width: 26px;
  height: 26px;
  border-radius: 6px;
  flex: 0 0 auto;
  margin-top: 1px;
  background: #f4f4f5 url("../media/work/kai-avatar.png") center / cover no-repeat;
}

.jv-chat-assistant-body {
  flex: 1 0 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

/* Ultra-clean borderless tool trace caption */
.jv-chat-trace-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-family: "SF Mono", "PingFang SC", monospace;
  font-size: 11px;
  line-height: 15px;
  color: var(--kimi-ink-muted);
  user-select: none;
}

.jv-chat-trace-pill__dot {
  width: 4.5px;
  height: 4.5px;
  border-radius: 50%;
  background: #d4d4d8;
  flex-shrink: 0;
}

.jv-chat-trace-pill--guard {
  color: #d97706;
}

.jv-chat-trace-pill--guard .jv-chat-trace-pill__dot {
  background: #f59e0b;
}

.jv-chat-trace-pill--running .jv-chat-trace-pill__dot {
  background: var(--kimi-ink);
  animation: jvThinkingPulse 1s ease-in-out infinite;
}

.jv-chat-trace-pill__meta {
  color: #c4c4cc;
}

.jv-chat-interrupted-tag {
  display: inline-block;
  margin-left: 6px;
  color: var(--kimi-ink-muted);
  font-size: 11.5px;
}

.jv-chat-text {
  margin: 0;
  font-family: "Inter", "PingFang SC", "Noto Sans SC", system-ui, -apple-system, sans-serif;
  font-size: 13.5px;
  line-height: 22px;
  letter-spacing: -0.005em;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--kimi-ink);
}

.jv-chat-assistant-text strong {
  font-weight: 600;
  color: #09090b;
}

.jv-chat-assistant-text code {
  font-family: "SF Mono", "Menlo", monospace;
  font-size: 12px;
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--kimi-canvas);
  color: var(--kimi-ink);
}

/* User Message Bubble */
.jv-chat-user-bubble {
  max-width: 82%;
  padding: 7px 12px;
  border-radius: 14px 14px 4px 14px;
  background: var(--kimi-canvas);
  color: var(--kimi-ink);
  font-size: 13.5px;
  line-height: 21px;
}

/* 5. PROJECT REFERENCE CARDS */
.jv-chat-proj-cards {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 6px;
}

.jv-chat-proj-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid rgba(24, 24, 27, 0.07);
  background: #fafafa;
  text-decoration: none !important;
  color: var(--kimi-ink);
  transition: border-color 0.18s ease, background-color 0.18s ease;
}

.jv-chat-proj-card:hover {
  border-color: rgba(24, 24, 27, 0.28);
  background: #ffffff;
}

.jv-chat-proj-card svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  color: var(--kimi-ink-muted);
  transition: color 0.18s ease, transform 0.18s ease;
}

.jv-chat-proj-card:hover svg {
  color: var(--kimi-ink);
  transform: translateX(2px);
}

.jv-chat-proj-card__info {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.jv-chat-proj-card__kicker {
  font-size: 10.5px;
  line-height: 14px;
  color: var(--kimi-ink-muted);
}

.jv-chat-proj-card__title {
  font-size: 12.5px;
  font-weight: 500;
  line-height: 17px;
  color: var(--kimi-ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* 6. QUICK PROMPT PILLS */
.jv-chat-prompts {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 4px 0 8px;
  flex-shrink: 0;
}

.jv-chat-prompts.is-hidden {
  display: none;
}

.jv-chat-prompt-pill {
  appearance: none;
  border: 1px solid rgba(24, 24, 27, 0.08);
  background: #ffffff;
  color: var(--kimi-ink-secondary);
  border-radius: 999px;
  padding: 4px 10px;
  font-family: "Inter", "PingFang SC", sans-serif;
  font-size: 12px;
  font-weight: 400;
  line-height: 16px;
  cursor: pointer;
  transition: border-color 0.16s ease, background-color 0.16s ease, color 0.16s ease;
}

.jv-chat-prompt-pill:hover {
  border-color: rgba(24, 24, 27, 0.3);
  background: var(--kimi-canvas);
  color: var(--kimi-ink);
}

/* 7. THINKING & STREAMING CURSOR */
.jv-chat-thinking {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 0;
}

.jv-chat-thinking-dots span {
  display: inline-block;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--kimi-ink-muted);
  animation: jvThinkingPulse 1.2s ease-in-out infinite;
}

.jv-chat-thinking-dots span:nth-child(2) {
  animation-delay: 0.2s;
}

.jv-chat-thinking-dots span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes jvThinkingPulse {
  0%, 80%, 100% {
    opacity: 0.25;
  }
  40% {
    opacity: 0.9;
  }
}

.jv-chat-assistant-typing::after {
  content: "";
  display: inline-block;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  margin-left: 4px;
  vertical-align: 2px;
  background: var(--kimi-ink);
  animation: jv-chat-cursor-blink 0.9s ease-in-out infinite;
}

@keyframes jv-chat-cursor-blink {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.2;
  }
}

/* 8. CLEAN INPUT COMPOSER */
.jv-chat-composer-wrap {
  position: relative;
  width: 100%;
  padding-top: 2px;
  background: transparent;
  flex-shrink: 0;
}

.jv-chat-composer {
  border: 1px solid rgba(24, 24, 27, 0.09);
  border-radius: 16px;
  background: var(--kimi-canvas);
  min-height: 44px;
  padding: 7px 8px 7px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  box-sizing: border-box;
  transition: background-color 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}

.jv-chat-composer-default:hover {
  background: #ffffff;
  border-color: rgba(24, 24, 27, 0.2);
}

.jv-chat-composer-active,
.jv-chat-composer-input {
  background: #ffffff;
  border-color: var(--kimi-ink);
  box-shadow: 0 4px 14px rgba(18, 18, 18, 0.06);
}

.jv-chat-composer-generate {
  background: var(--kimi-canvas);
  border-color: rgba(24, 24, 27, 0.09);
}

.jv-chat-input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  resize: none;
  min-height: 20px;
  max-height: 108px;
  padding: 0;
  margin: 0;
  color: var(--kimi-ink);
  font-family: "Inter", "PingFang SC", "Noto Sans SC", system-ui, -apple-system, sans-serif;
  font-size: 13.5px;
  line-height: 20px;
}

.jv-chat-input::placeholder {
  color: var(--kimi-ink-muted);
}

/* 28x28 Circular Send / Stop Button */
.jv-chat-send {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  padding: 0;
  border: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: background-color 0.18s ease, opacity 0.18s ease;
}

.jv-chat-send svg {
  width: 12px;
  height: 13px;
}

.jv-chat-send-disabled {
  background: #e4e4e7;
  opacity: 0.65;
  cursor: default;
}

.jv-chat-send-active {
  background: var(--kimi-ink);
  opacity: 1;
}

.jv-chat-send-generate {
  background: var(--kimi-ink);
  opacity: 1;
  cursor: pointer;
}

.jv-chat-send-stop {
  width: 8px;
  height: 8px;
  border-radius: 1.5px;
  background: #ffffff;
}

.jv-chat-error {
  margin: 6px 4px 0;
  font-size: 11.5px;
  line-height: 15px;
  color: var(--kimi-red);
}

@media (max-width: 1100px) {
  .jv-chat-overlay {
    width: 40vw;
    min-width: 340px;
    right: 20px;
  }
}

@media (max-width: 768px) {
  .tn-ai-launcher {
    right: 16px;
    bottom: 16px;
  }
  .tn-ai-launcher__bubble {
    display: none;
  }
  .jv-chat-overlay {
    top: 68px;
    right: 12px;
    left: 12px;
    bottom: 12px;
    width: auto;
    min-width: 0;
    max-width: none;
  }
  .jv-chat-input {
    font-size: 16px;
  }
}
