/* Meetzen — AI Friend (FocusAI) */
.aif-root { display: block; }

/* `.btn`, `.aif-video` and `.aif-cam-off` all set an explicit `display`, which
   beats the UA `[hidden] { display:none }` rule. Without this the camera-off
   overlay never lifts and the snapshot button never appears. */
.aif-root [hidden] { display: none !important; }

.aif-wrap {
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: var(--s-5);
  align-items: stretch;
  /* A bounded height is what lets the thread below actually scroll. */
  height: calc(100vh - 260px);
  min-height: 520px;
  max-height: 820px;
}
@media (max-width: 880px) {
  .aif-wrap {
    grid-template-columns: 1fr;
    height: auto;
    max-height: none;
    min-height: 0;
  }
}

/* ── Camera stage ── */
.aif-stage { display: flex; flex-direction: column; gap: var(--s-3); min-height: 0; }
.aif-cam {
  position: relative;
  aspect-ratio: 4 / 3;
  background: var(--c-bg-soft);
  border: 1px solid var(--c-line);
  border-radius: var(--r-lg);
  overflow: hidden;
  flex: 0 0 auto;
}
.aif-video {
  width: 100%; height: 100%;
  object-fit: cover;
  transform: scaleX(-1); /* mirror like a webcam */
  display: block;
  background: #000;
}
.aif-cam-off {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: var(--s-3); padding: var(--s-5); text-align: center;
}
.aif-cam-emoji { font-size: 40px; }
.aif-cam-hint { color: var(--c-text-mute); font-size: var(--fs-sm); max-width: 240px; line-height: var(--lh-snug); }
.aif-cam-badge {
  position: absolute; top: 10px; left: 10px;
  background: rgba(0,0,0,.55);
  font-size: var(--fs-xs); font-weight: 600;
  padding: 3px 9px; border-radius: var(--r-pill);
  color: var(--c-err);
}

.aif-controls { display: flex; flex-wrap: wrap; gap: var(--s-2); }
.aif-btn { flex: 1 1 auto; white-space: nowrap; }
/* Mic actively listening — same red language as the "live" camera badge. */
.aif-btn[data-mic].is-live,
.aif-btn[data-mic][aria-pressed="true"] {
  border-color: var(--c-err); color: var(--c-err);
}
.aif-btn[data-mic].is-live { animation: aif-pulse 1.6s infinite ease-in-out; }
@keyframes aif-pulse { 0%,100% { opacity: 1; } 50% { opacity: .6; } }

/* Page-level AI disclosure (sits in the page header, outside .aif-root) */
.aif-page-note {
  margin: var(--s-2) 0 0;
  max-width: 68ch;
  font-size: var(--fs-xs);
  color: var(--c-text-mute);
  line-height: var(--lh-snug);
}
h1 .aif-ai-badge { vertical-align: middle; margin-left: 6px; }

.aif-note {
  margin: 0;
  font-size: var(--fs-xs);
  color: var(--c-text-mute);
  line-height: var(--lh-snug);
}

/* ── Chat ── */
.aif-chat {
  display: flex; flex-direction: column;
  border: 1px solid var(--c-line);
  border-radius: var(--r-lg);
  background: var(--c-surface);
  overflow: hidden;
  min-height: 0;   /* lets .aif-thread shrink so overflow-y kicks in */
}
@media (max-width: 880px) {
  .aif-chat { height: 65vh; min-height: 420px; }
}

/* AI disclosure strip above the conversation */
.aif-chat-head {
  flex: 0 0 auto;
  display: flex; align-items: center; gap: var(--s-2);
  padding: 8px var(--s-5);
  border-bottom: 1px solid var(--c-line);
  background: var(--c-bg-soft);
  color: var(--c-text-mute);
  font-size: var(--fs-xs);
  line-height: var(--lh-snug);
}
.aif-ai-badge {
  flex: 0 0 auto;
  font-size: 10px; font-weight: 700; letter-spacing: .04em;
  padding: 2px 6px; border-radius: var(--r-pill);
  background: var(--c-brand-100, var(--c-bg-soft));
  color: var(--c-brand-700, var(--c-text));
}

.aif-thread {
  flex: 1 1 auto;
  min-height: 0;             /* required for the scrollbar to appear */
  overflow-y: scroll;        /* reserve the gutter so it never jumps */
  overscroll-behavior: contain;
  padding: var(--s-5);
  display: flex; flex-direction: column; gap: var(--s-3);
  scrollbar-width: thin;
  scrollbar-color: var(--c-line) transparent;
}
.aif-thread:focus-visible { outline: 2px solid var(--c-brand-500); outline-offset: -2px; }

/* Visible, quiet scrollbar (WebKit/Blink) */
.aif-thread::-webkit-scrollbar { width: 10px; }
.aif-thread::-webkit-scrollbar-track { background: transparent; }
.aif-thread::-webkit-scrollbar-thumb {
  background: var(--c-line);
  border-radius: var(--r-pill);
  border: 3px solid transparent;
  background-clip: content-box;
}
.aif-thread::-webkit-scrollbar-thumb:hover { background: var(--c-text-faint); background-clip: content-box; }

.aif-msg { display: flex; gap: var(--s-2); align-items: flex-end; max-width: 86%; flex: 0 0 auto; }
.aif-me { align-self: flex-end; flex-direction: row-reverse; }
.aif-avatar {
  flex: 0 0 auto;
  width: 30px; height: 30px; border-radius: var(--r-pill);
  display: grid; place-items: center; font-size: 16px;
  background: var(--c-bg-soft);
}
.aif-bubble {
  padding: 9px 13px;
  border-radius: var(--r-md);
  font-size: var(--fs-base);
  line-height: var(--lh-snug);
  white-space: pre-wrap; word-break: break-word;
}
.aif-ai .aif-bubble { background: var(--c-bg-soft); color: var(--c-text); border-bottom-left-radius: 4px; }
.aif-me .aif-bubble { background: var(--c-brand-500); color: #fff; border-bottom-right-radius: 4px; }
.aif-tag { font-size: var(--fs-xs); opacity: .8; }

/* typing dots */
.aif-typing .aif-bubble { display: flex; gap: 4px; align-items: center; }
.aif-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--c-text-faint);
  animation: aif-bounce 1.2s infinite ease-in-out;
}
.aif-dot:nth-child(2) { animation-delay: .15s; }
.aif-dot:nth-child(3) { animation-delay: .3s; }
@keyframes aif-bounce { 0%,60%,100% { transform: translateY(0); opacity:.5; } 30% { transform: translateY(-4px); opacity:1; } }

.aif-compose {
  flex: 0 0 auto;
  display: flex; gap: var(--s-2);
  padding: var(--s-3);
  border-top: 1px solid var(--c-line);
  background: var(--c-surface);
}
.aif-input { flex: 1 1 auto; }
.aif-send { flex: 0 0 auto; }

.aif-disclaimer {
  flex: 0 0 auto;
  margin: 0;
  padding: 0 var(--s-3) var(--s-3);
  font-size: var(--fs-xs);
  color: var(--c-text-mute);
  line-height: var(--lh-snug);
  background: var(--c-surface);
}

/* ─────────────────────────────────────────────────────────────────
   Compact mode — AI Friend inside the focus room's right rail.
   Themed with the room's own --rm-* variables so it blends in.
   ───────────────────────────────────────────────────────────────── */
.aif-root-compact { display: flex; flex: 1 1 auto; min-height: 0; }
.aif-compact-wrap {
  display: flex; flex-direction: column;
  flex: 1 1 auto; min-height: 0; width: 100%;
}
.aif-bar {
  display: flex; align-items: center; gap: 8px;
  padding: 2px 6px 10px;
  border-bottom: 1px solid var(--rm-line);
  margin-bottom: 10px;
  flex: 0 0 auto;
}
.aif-bar-title { font-weight: 700; font-size: 14px; color: var(--rm-text); flex: 1 1 auto; }
.aif-bar-actions { display: flex; gap: 4px; flex: 0 0 auto; }
.aif-icon-btn {
  width: 30px; height: 30px; border-radius: 8px;
  background: transparent; border: 1px solid transparent;
  color: var(--rm-text-mute); cursor: pointer; font-size: 15px;
  display: grid; place-items: center; padding: 0;
}
.aif-icon-btn:hover { background: var(--rm-panel-2); color: var(--rm-text); }
.aif-icon-btn[aria-pressed="false"] { opacity: .6; }
.aif-icon-btn[data-mic][aria-pressed="true"] { opacity: 1; border-color: var(--rm-red, #ef4444); }
.aif-icon-btn[data-mic].is-live { animation: aif-pulse 1.6s infinite ease-in-out; }

.aif-compact-wrap .aif-ai-badge {
  background: var(--rm-panel-2); color: var(--rm-text-mute);
  margin-left: 4px; vertical-align: middle;
}

/* Reuse the chat thread styling but route the colors through room vars. */
.aif-compact-wrap .aif-thread {
  flex: 1 1 auto; min-height: 60px;
  overflow-y: auto; padding: 0 6px 6px 4px;
  display: flex; flex-direction: column; gap: 10px;
  scrollbar-color: var(--rm-line) transparent;
}
.aif-compact-wrap .aif-thread::-webkit-scrollbar { width: 8px; }
.aif-compact-wrap .aif-thread::-webkit-scrollbar-thumb {
  background: var(--rm-line); background-clip: content-box;
  border: 2px solid transparent; border-radius: 999px;
}
.aif-compact-wrap .aif-thread::-webkit-scrollbar-thumb:hover {
  background: var(--rm-text-mute); background-clip: content-box;
}
.aif-compact-wrap .aif-msg { max-width: 92%; }
.aif-compact-wrap .aif-avatar { width: 26px; height: 26px; font-size: 14px; background: var(--rm-panel-2); }
.aif-compact-wrap .aif-bubble { font-size: 13.5px; padding: 8px 11px; }
.aif-compact-wrap .aif-ai .aif-bubble { background: var(--rm-panel-2); color: var(--rm-text); }
.aif-compact-wrap .aif-me .aif-bubble {
  background: linear-gradient(135deg, var(--rm-purple), var(--rm-purple-2)); color: #fff;
}
.aif-compact-wrap .aif-dot { background: var(--rm-text-mute); }

.aif-compact-wrap .aif-compose {
  border: 1px solid var(--rm-line);
  background: var(--rm-panel);
  border-radius: 999px;
  padding: 6px 8px; margin-top: 10px;
  align-items: center;
}
.aif-compact-wrap .aif-input { background: transparent; border: 0; }
.aif-compact-wrap .aif-disclaimer {
  padding: 8px 4px 0;
  background: transparent;
  color: var(--rm-text-mute);
  font-size: 11px;
}

/* ── Locked state (AI Friend plan required) ───────────────────────── */
.aif-locked {
  display: flex; flex-direction: column; align-items: center;
  gap: var(--s-4); text-align: center;
  max-width: 520px; margin: 0 auto; padding: var(--s-8) var(--s-5);
}
.aif-locked-ico { font-size: 52px; line-height: 1; }
.aif-locked h2 { margin: 0; font-size: var(--fs-lg); }
.aif-locked p { margin: 0; color: var(--c-text-mute); line-height: var(--lh-base); }
.aif-locked-list {
  list-style: none; margin: 0; padding: 0;
  display: grid; gap: 8px; text-align: left;
}
.aif-locked-list li {
  display: flex; align-items: center; gap: 9px;
  color: var(--c-text-soft); font-size: var(--fs-sm);
}
.aif-locked-list li::before {
  content: '✓'; color: var(--c-ok); font-weight: 800; flex: 0 0 auto;
}
.aif-locked-note { font-size: var(--fs-xs); }
