.aiv-chat [hidden],
.aiv-chat-suggest[hidden],
.aiv-chat-form[hidden] { display: none !important; }

.aiv-chat-btn {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 400;
  height: 46px;
  padding: 0 18px;
  border: 0;
  border-radius: 999px;
  background: #f4f4f5;
  color: #18181b;
  font: 650 0.92rem/1 inherit;
  cursor: pointer;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.45);
}
.aiv-chat-btn:hover { background: #27272a; }
.aiv-chat {
  position: fixed;
  right: 20px;
  bottom: 72px;
  z-index: 400;
  width: min(400px, calc(100vw - 24px));
  height: min(640px, calc(100vh - 96px));
  display: none;
  flex-direction: column;
  background: #0c0c0e;
  color: #f4f4f5;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 14px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.45);
  overflow: hidden;
}
.aiv-chat.is-open { display: flex; }
.aiv-chat.is-empty .aiv-chat-log { display: none; }
.aiv-chat.is-empty .aiv-chat-suggest {
  flex: 1;
  align-content: center;
  justify-content: center;
  padding: 28px 18px;
}
.aiv-chat-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 12px 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.aiv-chat-head h2 {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}
.aiv-chat-head p {
  margin: 2px 0 0;
  color: #a1a1aa;
  font-size: 0.75rem;
}
.aiv-chat-head select {
  max-width: 118px;
  background: transparent;
  color: #d4d4d8;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  padding: 4px 6px;
  font: inherit;
  font-size: 0.75rem;
}
.aiv-chat-head-text { min-width: 0; flex: 1; }
.aiv-chat-iconbtn {
  border: 0;
  background: transparent;
  color: #d4d4d8;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  cursor: pointer;
  font: inherit;
  font-size: 0.85rem;
}
.aiv-chat-iconbtn:hover { background: rgba(255, 255, 255, 0.06); }
.aiv-chat-log {
  flex: 1;
  overflow-y: auto;
  padding: 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.aiv-msg { max-width: 92%; }
.aiv-msg-user { align-self: flex-end; }
.aiv-msg-assistant { align-self: flex-start; }
.aiv-msg-bubble {
  padding: 10px 12px;
  border-radius: 12px;
  font-size: 0.9rem;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}
.aiv-msg-user .aiv-msg-bubble { background: #27272a; }
.aiv-msg-assistant .aiv-msg-bubble {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
}
.aiv-msg-meta {
  margin-top: 4px;
  color: #71717a;
  font-size: 0.7rem;
}
.aiv-msg-bubble a {
  color: #e7ecff;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.aiv-links {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}
.aiv-links a {
  text-decoration: none;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.06);
}
.aiv-msg-bubble code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.84em;
  background: rgba(255, 255, 255, 0.06);
  padding: 1px 5px;
  border-radius: 4px;
}
.aiv-msg-meta { display: none; }
.aiv-chat-suggest {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0 12px 8px;
}
.aiv-chat-suggest button {
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: transparent;
  color: #e4e4e7;
  border-radius: 999px;
  padding: 6px 10px;
  font: inherit;
  font-size: 0.78rem;
  cursor: pointer;
}
.aiv-chat-suggest button:hover { background: rgba(255, 255, 255, 0.05); }
.aiv-chat-form {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  padding: 10px 12px 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}
.aiv-chat-form textarea {
  flex: 1;
  resize: none;
  min-height: 42px;
  max-height: 120px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  background: #18181b;
  color: #f4f4f5;
  padding: 10px 12px;
  font: inherit;
  font-size: 0.9rem;
}
.aiv-chat-attach {
  position: relative;
  height: 42px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  padding: 0 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  background: #18181b;
  color: #f4f4f5;
  cursor: pointer;
  font-size: 0.82rem;
}
.aiv-chat-file {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}
.aiv-chat-attach:hover { background: #27272a; }
.aiv-shot-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 0 12px 8px;
}
.aiv-shot-row p {
  margin: 0;
  color: #a1a1aa;
  font-size: 0.78rem;
}
.aiv-shot {
  position: relative;
  width: 56px;
  height: 56px;
}
.aiv-shot img,
.aiv-msg-shot {
  display: block;
  width: 56px;
  height: 56px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}
.aiv-msg-shot {
  width: auto;
  height: auto;
  max-width: 220px;
  max-height: 180px;
  margin-top: 8px;
}
.aiv-shot button {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 18px;
  height: 18px;
  border: 0;
  border-radius: 999px;
  background: #f4f4f5;
  color: #18181b;
  font: 600 0.75rem/1 inherit;
  cursor: pointer;
}
.aiv-chat-form textarea:focus { outline: 1px solid rgba(255, 255, 255, 0.28); }
.aiv-msg-live {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 22px;
}
.aiv-live-label {
  color: #a1a1aa;
  font-size: 0.82rem;
}
.aiv-typing {
  display: inline-flex;
  gap: 4px;
  align-items: center;
  height: 12px;
}
.aiv-typing i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #e4e4e7;
  animation: aiv-blink 1.05s infinite ease-in-out;
}
.aiv-typing i:nth-child(2) { animation-delay: 0.15s; }
.aiv-typing i:nth-child(3) { animation-delay: 0.3s; }
@keyframes aiv-blink {
  0%, 70%, 100% { opacity: 0.25; transform: translateY(0); }
  35% { opacity: 1; transform: translateY(-3px); }
}
.aiv-chat-send {
  height: 42px;
  padding: 0 12px;
  border: 0;
  border-radius: 10px;
  background: #f4f4f5;
  color: #18181b;
  font: 600 0.85rem/1 inherit;
  cursor: pointer;
}
.aiv-chat-send:disabled { opacity: 0.45; cursor: default; }
.aiv-chat-foot {
  padding: 0 12px 10px;
  color: #71717a;
  font-size: 0.72rem;
  display: flex;
  justify-content: space-between;
  gap: 12px;
}
.aiv-consent {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px 16px 8px;
  min-height: 0;
}
.aiv-consent h3 {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
}
.aiv-consent-terms {
  max-height: 280px;
  overflow: auto;
  padding-right: 6px;
  color: #d4d4d8;
  font-size: 0.84rem;
  line-height: 1.45;
}
.aiv-consent-terms p { margin: 0 0 8px; }
.aiv-consent-terms ol { margin: 0; padding-left: 1.15rem; }
.aiv-consent-terms li { margin: 0 0 8px; }
.aiv-consent-terms a { color: #f4f4f5; }
.aiv-consent-name,
.aiv-consent-check {
  display: flex;
  flex-direction: column;
  gap: 6px;
  color: #e4e4e7;
  font-size: 0.84rem;
}
.aiv-consent-check { flex-direction: row; align-items: flex-start; }
.aiv-consent-name input {
  border: 1px solid rgba(255,255,255,0.14);
  background: #18181b;
  color: #fafafa;
  border-radius: 8px;
  padding: 8px 10px;
  font: inherit;
}
.aiv-consent button {
  align-self: flex-start;
  border: 0;
  border-radius: 8px;
  background: #f4f4f5;
  color: #18181b;
  font: 600 0.88rem/1 inherit;
  padding: 8px 12px;
  cursor: pointer;
}
.aiv-consent-err { margin: 0; color: #fca5a5; font-size: 0.8rem; }
.aiv-chat-foot a { color: #d4d4d8; }
.aiv-chat-gate {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 12px;
  padding: 24px;
}
.aiv-chat-gate p { margin: 0; color: #d4d4d8; line-height: 1.5; }
.aiv-chat-gate a {
  align-self: flex-start;
  background: #f4f4f5;
  color: #18181b;
  text-decoration: none;
  font-weight: 600;
  font-size: 0.88rem;
  padding: 8px 12px;
  border-radius: 8px;
}
@media (max-width: 900px) {
  body:has(.app-shell) .aiv-chat-btn {
    bottom: calc(76px + env(safe-area-inset-bottom));
  }
}
@media (max-width: 640px) {
  .aiv-chat {
    right: 0;
    bottom: 0;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    border-radius: 0;
  }
  .aiv-chat-btn { right: 12px; bottom: 12px; }
}
