/* VLM Q&A: photo on the left, a conversation about it on the right. */

.vlm-page { position: relative; }
.vlm {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
  gap: 22px;
  align-items: stretch;
}

/* ---------- media column ---------- */
.vlm-media { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.vlm-file { display: none; }
.vlm-stage {
  position: relative;
  aspect-ratio: 4 / 3.3;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface-2);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  display: grid;
  place-items: center;
  isolation: isolate;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.vlm-stage.is-hot { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.vlm-stage.is-hot::after {
  content: "Drop to use this photo";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: color-mix(in srgb, var(--surface) 72%, transparent);
  backdrop-filter: blur(6px);
  font-weight: 600;
  color: var(--accent-ink);
  z-index: 5;
}
.vlm-stage__backdrop {
  position: absolute;
  inset: -8%;
  width: 116%;
  height: 116%;
  object-fit: cover;
  filter: blur(28px) saturate(1.25);
  opacity: 0.55;
  z-index: -1;
}
.vlm-photo {
  max-width: 100%;
  max-height: 100%;
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  animation: vlm-in 0.35s cubic-bezier(0.2, 0.7, 0.2, 1);
}
.vlm-stage__caption {
  position: absolute;
  left: 14px;
  bottom: 14px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--badge-bg);
  color: var(--badge-ink);
  font-size: 12.5px;
  font-weight: 600;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.16);
  max-width: calc(100% - 28px);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  backdrop-filter: blur(8px);
}
.vlm-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); flex-shrink: 0; animation: blink 1s ease-in-out infinite; }

/* A soft band sweeping down the photo while the vision tower runs. */
.vlm-scan {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(180deg, transparent 0%, rgba(255, 140, 90, 0) 38%, rgba(255, 140, 90, 0.28) 50%, rgba(255, 140, 90, 0) 62%, transparent 100%);
  background-size: 100% 260%;
  animation: vlm-scan 2.2s cubic-bezier(0.45, 0, 0.55, 1) infinite;
  mix-blend-mode: screen;
}
.vlm-scan[hidden] { display: none; }
.vlm-stage.is-busy .vlm-photo { filter: saturate(0.85); }

.vlm-drop {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 8px;
  padding: 28px;
  max-width: 420px;
}
.vlm-drop__glyph {
  width: 64px;
  height: 64px;
  border-radius: 20px;
  display: grid;
  place-items: center;
  background: var(--surface);
  color: var(--text-2);
  box-shadow: var(--shadow-sm), inset 0 0 0 1px var(--border);
  margin-bottom: 6px;
}
.vlm-drop__title { font-size: 19px; font-weight: 700; letter-spacing: -0.015em; }
.vlm-drop__sub { color: var(--text-3); font-size: 14px; }
.vlm-drop__actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; margin-top: 10px; }
.vlm-ico { display: inline-flex; }

.vlm-camera { position: absolute; inset: 0; background: #000; display: grid; place-items: center; }
.vlm-video { width: 100%; height: 100%; object-fit: cover; display: block; }
.vlm-camera__wait { position: absolute; color: rgba(255, 255, 255, 0.8); font-size: 14px; }
.vlm-camera__bar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 18px 20px;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.55));
}
.vlm-camera__cancel {
  justify-self: start;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 0;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
  backdrop-filter: blur(6px);
}
.vlm-camera__cancel:hover { background: rgba(255, 255, 255, 0.26); }
.vlm-camera__spacer { display: block; }
.vlm-shutter {
  width: 66px;
  height: 66px;
  border-radius: 50%;
  border: 4px solid #fff;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: inset 0 0 0 3px rgba(0, 0, 0, 0.35), 0 6px 20px rgba(0, 0, 0, 0.35);
  transition: transform 0.12s ease;
}
.vlm-shutter:hover:not(:disabled) { transform: scale(1.05); }
.vlm-shutter:active:not(:disabled) { transform: scale(0.94); }
.vlm-shutter:disabled { opacity: 0.4; }

.vlm-tray { display: flex; gap: 10px; overflow-x: auto; padding: 2px 2px 4px; scrollbar-width: thin; }
.vlm-thumb {
  flex-shrink: 0;
  width: 74px;
  height: 58px;
  padding: 0;
  border-radius: 12px;
  overflow: hidden;
  border: 0;
  background: var(--surface-3);
  box-shadow: inset 0 0 0 1px var(--border);
  position: relative;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.vlm-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.vlm-thumb:hover { transform: translateY(-2px); }
.vlm-thumb.is-active { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--accent); }
.vlm-tray__btn {
  flex-shrink: 0;
  height: 58px;
  min-width: 74px;
  padding: 0 14px;
  border-radius: 12px;
  border: 1px dashed var(--border-strong);
  background: transparent;
  color: var(--text-2);
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  font-size: 12px;
  font-weight: 600;
}
.vlm-tray__btn:hover { border-color: var(--accent); color: var(--accent-ink); background: var(--accent-soft); }
.vlm-tray__btn.is-active { border-style: solid; border-color: var(--accent); color: var(--accent-ink); }
.vlm-privacy { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--text-3); }

/* ---------- chat column ---------- */
.vlm-chat {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 520px;
  max-height: min(720px, calc(100vh - 170px));
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.vlm-chat__head { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.vlm-chat__head .btn[hidden] { display: none; }
.vlm-chat__who { display: flex; flex-direction: column; line-height: 1.25; flex: 1; min-width: 0; }
.vlm-chat__who strong { font-size: 14.5px; font-weight: 600; }
.vlm-avatar {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  color: #fff;
  background: linear-gradient(140deg, #ff8a4c, var(--accent) 55%, #c43c7a);
  box-shadow: 0 6px 14px -8px rgba(198, 46, 16, 0.8);
}
.vlm-avatar--sm { width: 26px; height: 26px; border-radius: 8px; margin-top: 2px; }
.vlm-status { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--text-3); }
.vlm-status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--text-3); }
.vlm-status--ready { color: var(--live); }
.vlm-status--ready::before { background: var(--live-dot); box-shadow: 0 0 0 3px var(--live-soft); }
.vlm-status--busy::before { background: var(--accent); animation: blink 1s ease-in-out infinite; }
.vlm-status--bad { color: var(--danger); }
.vlm-status--bad::before { background: var(--danger); }
.vlm-status--idle { color: var(--text-3); }

.vlm-chat__body { flex: 1; overflow-y: auto; padding: 22px 20px; display: flex; flex-direction: column; }
.vlm-chat__body > .preload,
.vlm-chat__body > .loader,
.vlm-chat__body > .ready-empty { margin: auto; }
.vlm-hero .fallback { text-align: left; }
.vlm-reasons { margin: 4px 0 0; padding: 0; list-style: none; font-size: 13px; color: var(--text-3); display: flex; flex-direction: column; gap: 2px; }

.vlm-thread { display: flex; flex-direction: column; gap: 18px; }
.vlm-context {
  align-self: center;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 12px 4px 4px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-3);
  font-weight: 600;
}
.vlm-context__thumb { width: 24px; height: 24px; border-radius: 50%; object-fit: cover; display: block; }
.vlm-turn { display: flex; flex-direction: column; gap: 12px; animation: vlm-in 0.25s ease; }
.vlm-q {
  align-self: flex-end;
  max-width: 85%;
  padding: 10px 15px;
  border-radius: 18px 18px 6px 18px;
  background: var(--accent);
  color: var(--on-accent);
  font-size: 15px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}
.vlm-a { display: flex; gap: 10px; align-items: flex-start; max-width: 94%; }
.vlm-answer { display: flex; flex-direction: column; gap: 6px; min-width: 0; padding-top: 4px; }
.vlm-answer__text { font-size: 15.5px; line-height: 1.6; white-space: pre-wrap; overflow-wrap: anywhere; color: var(--text); }
.vlm-stat { font-size: 12px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.vlm-typing { display: inline-flex; align-items: center; gap: 10px; font-size: 14px; color: var(--text-3); padding-top: 2px; }
.vlm-typing__dots { display: inline-flex; gap: 4px; }
.vlm-typing__dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--text-3); animation: vlm-bounce 1.2s ease-in-out infinite; }
.vlm-typing__dots i:nth-child(2) { animation-delay: 0.15s; }
.vlm-typing__dots i:nth-child(3) { animation-delay: 0.3s; }

.vlm-chat__foot { border-top: 1px solid var(--border); padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 10px; background: var(--surface); }
.vlm-chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; margin: 0 -14px; padding: 0 14px; mask-image: linear-gradient(90deg, transparent, #000 14px, #000 calc(100% - 36px), transparent); }
.vlm-chips::-webkit-scrollbar { display: none; }
.vlm-chips[hidden] { display: none; }
.vlm-chip { flex-shrink: 0; white-space: nowrap; }
.vlm-chip:disabled { opacity: 0.5; cursor: not-allowed; }
.vlm-chip:disabled:hover { border-color: var(--border); color: var(--text-2); background: var(--surface-2); }
.vlm-composer {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 5px 5px 16px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.vlm-composer:focus-within { border-color: color-mix(in srgb, var(--accent) 55%, transparent); box-shadow: var(--focus); }
.vlm-input { flex: 1; min-width: 0; border: 0; background: transparent; outline: none; font-size: 15px; padding: 8px 0; }
.vlm-input:focus-visible { box-shadow: none; }
.vlm-input::placeholder { color: var(--text-3); }
.vlm-input:disabled { cursor: not-allowed; }
.vlm-composer .send-btn:disabled { background: var(--surface-3); color: var(--text-3); cursor: not-allowed; }

@keyframes vlm-scan { from { background-position: 0 100%; } to { background-position: 0 0%; } }
@keyframes vlm-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes vlm-bounce { 0%, 80%, 100% { transform: translateY(0); opacity: 0.45; } 40% { transform: translateY(-4px); opacity: 1; } }

@media (prefers-reduced-motion: reduce) {
  .vlm-scan, .vlm-photo, .vlm-turn, .vlm-typing__dots i { animation: none; }
  .vlm-scan { background: rgba(255, 140, 90, 0.12); }
}

@media (max-width: 980px) {
  .vlm { grid-template-columns: minmax(0, 1fr); }
  .vlm-chat { max-height: none; min-height: 460px; }
  .vlm-chat__body { max-height: 70vh; }
}
@media (max-width: 560px) {
  .vlm { gap: 14px; }
  .vlm-stage { aspect-ratio: 4 / 3.6; }
  .vlm-tray { gap: 6px; }
  .vlm-thumb { width: 50px; height: 48px; border-radius: 10px; }
  .vlm-tray__btn { height: 48px; min-width: 54px; padding: 0 4px; border-radius: 10px; font-size: 11px; }
  .vlm-chat__body { padding: 18px 14px; }
  .vlm-q { max-width: 92%; }
}
