/* Chat dock inside a lab bot panel. Copy this file with engine.js and ui.js.
   Voice Lab maps campus tokens onto the names this file already uses. */
.py-chat {
  --ink: var(--ink, #102033);
  --bg: var(--cc-surface, var(--bg, #fff));
  --bg-elev: var(--cc-bg, var(--bg-elev, #f4f7fb));
  --accent: var(--cc-accent-1, var(--accent, #0f766e));
  --line: var(--line, #c5d0dc);
}
.guide-panel.has-voicebot {
  display: flex;
  flex-direction: column;
  max-height: min(78dvh, 640px);
}
.guide-panel.has-voicebot .guide-form { display: none; }
.guide-panel.has-voicebot .guide-log { max-height: 96px; min-height: 0; }
.py-chat button:focus-visible,
.py-chat input:focus-visible,
.py-chat a:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}
@media (max-width: 800px) {
  body:has(#guide-panel:not([hidden])) {
    display: flex;
    flex-direction: column;
    height: 100dvh;
    overflow: hidden;
  }
  body:has(#guide-panel:not([hidden])) .top,
  body:has(#guide-panel:not([hidden])) .readbar { flex: 0 0 auto; }
  body:has(#guide-panel:not([hidden])) .shell {
    flex: 1 1 auto;
    min-height: 0;
    max-height: none;
    overflow: auto;
  }
  body:has(#guide-panel:not([hidden])) .site-foot,
  body:has(#guide-panel:not([hidden])) #sources,
  body:has(#guide-panel:not([hidden])) .dock { display: none; }
  body:has(#guide-panel:not([hidden])) .bottom-nav {
    position: static;
    flex: 0 0 auto;
    order: 8;
  }
  body:has(#guide-panel:not([hidden])) .guide {
    position: static;
    order: 7;
    flex: 0 0 auto;
    align-items: stretch;
    width: 100%;
    max-width: 100%;
    max-height: 42dvh;
    left: auto;
    right: auto;
    bottom: auto;
    overflow: hidden;
  }
  body:has(#guide-panel:not([hidden])) .guide-launch { display: none; }
  body:has(#guide-panel:not([hidden])) .guide-panel.has-voicebot {
    display: flex;
    flex-direction: column;
    width: 100%;
    max-height: 42dvh;
    min-height: 0;
    overflow: hidden;
  }
  body:has(#guide-panel:not([hidden])) .py-chat {
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
  }
  body:has(#guide-panel:not([hidden])) .py-chat-log {
    flex: 1 1 auto;
    min-height: 0;
    max-height: none;
    overflow: auto;
  }
  body:has(#guide-panel:not([hidden])) .py-chat-form { flex: 0 0 auto; }
  body:has(#guide-panel:not([hidden])) .py-chat-examples,
  body:has(#guide-panel:not([hidden])) .py-chat-chips,
  body:has(#guide-panel:not([hidden])) .guide-chips,
  body:has(#guide-panel:not([hidden])) .guide-log { display: none; }
}
@media (max-width: 390px) {
  .py-chat-log { max-height: 38dvh; }
}
@media (prefers-reduced-motion: reduce) {
  .py-chat, .py-chat * { scroll-behavior: auto; }
}
.py-chat {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
  background: var(--bg-elev);
  flex: 0 0 auto;
}
.bot-panel {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  max-height: calc(100dvh - var(--top-h, 60px) - var(--bar-h, 64px) - 16px);
}
.bp-head,
.bp-bot,
.py-chat-beta,
.py-chat-try,
.py-chat-examples,
.py-chat-chips,
.py-chat-form,
.py-chat > .bp-link { flex: 0 0 auto; }
.bp-scroll { overflow: auto; min-height: 0; flex: 1 1 auto; }
.py-chat-log {
  max-height: 112px;
  min-height: 0;
  flex: 0 1 auto;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg);
}
.py-msg { max-width: 95%; padding: 6px 8px; border-radius: 12px; font-size: 0.88rem; line-height: 1.35; }
.py-msg p { margin: 0; }
.py-msg-user { align-self: flex-end; background: color-mix(in srgb, var(--accent) 22%, var(--bg)); }
.py-msg-bot { align-self: flex-start; background: color-mix(in srgb, var(--accent-2, var(--accent)) 12%, var(--bg)); border: 1px solid var(--line); }
.py-msg-link { display: inline-flex; margin-top: 4px; font-weight: 700; }
.py-msg-code { margin: 6px 0 0; padding: 6px; overflow: auto; border-radius: 8px; background: var(--code-bg, var(--bg)); font-size: 0.75rem; }
.py-chat-try { margin: 0; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.py-chat-examples, .py-chat-chips { display: flex; gap: 6px; overflow-x: auto; }
.py-chat-form { display: flex; gap: 6px; align-items: center; }
.py-chat-form input {
  flex: 1;
  min-width: 0;
  min-height: 44px;
  padding: 6px 10px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--ink);
  font: inherit;
}
.py-chat-form button, .py-mic {
  min-height: 44px;
  min-width: 44px;
  padding: 6px 10px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--ink);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}
.py-chat-form button[type="submit"] { background: var(--accent); color: var(--btn-ink); border-color: var(--accent); }
.py-chat-form button:focus-visible, .py-mic:focus-visible, #py-chat-input:focus-visible, .py-read:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
@media (min-width: 900px) {
  .py-chat-log { max-height: 168px; }
}
@media (max-width: 420px) {
  .py-chat-log { max-height: 88px; }
  .py-chat-form button[type="submit"] { padding-inline: 8px; }
}
@media (max-height: 560px) {
  .bot-panel { padding: 4px 8px; }
  .bp-head,
  .bp-bot,
  .bp-scroll { display: none; }
  .py-chat {
    flex: 1 1 auto;
    min-height: 0;
    margin-top: 0;
    padding-top: 0;
    border-top: 0;
    gap: 4px;
    overflow: hidden;
  }
  .py-chat-try,
  .py-chat-examples,
  .py-chat-chips { display: none; }
  .py-chat > .bp-link {
    display: inline-flex;
    margin: 0;
    font-size: 0.75rem;
    line-height: 1.2;
  }
  .py-chat-log {
    flex: 1 1 auto;
    min-height: 48px;
    max-height: none;
    overflow: auto;
    padding: 4px 6px;
    border-width: 0;
  }
  .py-chat-form button,
  .py-mic,
  .py-chat-form input { min-height: 40px; }
}
@media (max-width: 800px) and (max-height: 520px) {
  body:has(#guide-panel:not([hidden])) .top,
  body:has(#guide-panel:not([hidden])) .readbar,
  body:has(#guide-panel:not([hidden])) .bottom-nav { display: none; }
  body:has(#guide-panel:not([hidden])) .shell {
    flex: 0 1 auto;
    max-height: 22dvh;
  }
  body:has(#guide-panel:not([hidden])) .guide,
  body:has(#guide-panel:not([hidden])) .guide-panel.has-voicebot {
    flex: 1 1 auto;
    max-height: none;
    min-height: 0;
  }
  body:has(#guide-panel:not([hidden])) .py-chat-log {
    flex: 1 1 120px;
    min-height: 120px;
    max-height: none;
  }
}
@media (prefers-reduced-motion: reduce) {
  .bot-panel { animation: none; }
  .py-chat-log { scroll-behavior: auto; }
}

.py-chat-beta { margin: 0; font-size: 0.75rem; line-height: 1.3; color: var(--muted); }
.py-beta-badge { display: inline-block; padding: 1px 7px; margin-right: 4px; border-radius: 999px; border: 1px solid var(--accent); background: var(--accent); color: var(--btn-ink); font-weight: 700; font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.06em; }
@media (max-height: 559px) { .py-chat-beta { font-size: 0.7rem; } }
