/* ==========================================================================
   AIHUB assistant — chat surface only.
   Kept in its own file so the rest of the site's styling is untouched.
   Uses the existing design tokens (--accent, --surface, --line, --muted).
   ========================================================================== */

.chat-dialog { width: 540px; display: flex; flex-direction: column; max-height: 86dvh; }

.chat-head { padding: 26px 30px 16px; border-bottom: 1px solid var(--line); flex-shrink: 0; }
.chat-head h2 { font-size: 28px; margin-bottom: 10px; }
.chat-head .assistant-brand { margin-bottom: 18px; }
.chat-disclaimer { font-size: 10px; color: var(--muted); line-height: 1.6; }

/* ----- message list ----- */
.chat-messages {
  flex: 1 1 auto;
  min-height: 210px;
  max-height: min(46dvh, 420px);
  overflow-y: auto;
  overscroll-behavior: contain;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 20px 30px;
  scrollbar-width: thin;
}
.chat-messages::-webkit-scrollbar { width: 7px; }
.chat-messages::-webkit-scrollbar-thumb { background: var(--line); border-radius: 4px; }

.chat-msg { max-width: 86%; font-size: 13px; line-height: 1.68; }
.chat-msg .chat-body {
  padding: 12px 15px;
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow-wrap: anywhere;
}
.chat-user { align-self: flex-end; }
.chat-user .chat-body { background: var(--accent); color: #fff4ea; border-color: transparent; border-bottom-right-radius: 5px; }
.chat-ai { align-self: flex-start; }
.chat-ai .chat-body { background: var(--surface2); border-bottom-left-radius: 5px; }

.chat-intro { align-self: flex-start; max-width: 86%; }
.chat-intro .chat-body { background: var(--surface2); border: 1px solid var(--line); border-radius: 14px; border-bottom-left-radius: 5px; padding: 12px 15px; font-size: 13px; line-height: 1.68; }

.chat-tag {
  display: inline-block;
  font: 8px ui-monospace, monospace;
  letter-spacing: .14em;
  color: var(--accent);
  margin: 0 0 5px 4px;
}

/* formatting inside a reply */
.chat-body p + p { margin-top: 9px; }
.chat-body .chat-heading { display: block; margin: 10px 0 5px; font-size: 13px; }
.chat-body .chat-heading:first-child { margin-top: 0; }
.chat-body .chat-list { margin: 8px 0 0; padding-left: 19px; display: grid; gap: 5px; }
.chat-body .chat-list li { line-height: 1.6; }
.chat-body code {
  font: 11px/1.5 ui-monospace, monospace;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 1px 5px;
}
.chat-body a { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }
.chat-user .chat-body a { color: #fff; }

/* ----- typing indicator ----- */
.chat-typing .chat-dots {
  display: inline-flex;
  gap: 5px;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 14px;
  border-bottom-left-radius: 5px;
  background: var(--surface2);
}
.chat-dots i {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--accent);
  opacity: .35;
  animation: chat-pulse 1.1s infinite;
}
.chat-dots i:nth-child(2) { animation-delay: .18s; }
.chat-dots i:nth-child(3) { animation-delay: .36s; }
@keyframes chat-pulse { 0%, 60%, 100% { opacity: .3; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-3px); } }
@media (prefers-reduced-motion: reduce) { .chat-dots i { animation: none; opacity: .6; } }

/* ----- action cards (a tool actually did something) ----- */
.chat-effect {
  align-self: stretch;
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: 10px;
  background: var(--surface);
  padding: 14px 16px;
  display: grid;
  gap: 7px;
}
.chat-effect strong { font-size: 12px; }
.chat-effect p { font-size: 11px; color: var(--muted); line-height: 1.6; }
.chat-effect > a:not(.chat-effect-btn) { font-size: 11px; color: var(--accent); text-decoration: underline; }
.chat-effect.is-done { border-left-color: #2f7d4f; }
.chat-effect-btn {
  justify-self: start;
  margin-top: 3px;
  font-size: 11px;
  font-weight: 700;
  padding: 10px 15px;
  border-radius: 7px;
  border: 1px solid var(--line);
  background: var(--surface2);
}
.chat-effect-btn:hover { border-color: var(--accent); color: var(--accent); }
.chat-effect-btn.is-primary { background: var(--accent); color: #fff; border-color: transparent; }
.chat-effect-btn.is-primary:hover { background: var(--bright); color: #fff; }

/* ----- starter prompts ----- */
.chat-starters { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 4px; }
.chat-chip {
  font-size: 11px;
  text-align: left;
  padding: 9px 13px;
  border-radius: 20px;
  border: 1px solid var(--line);
  background: var(--surface2);
  color: var(--muted);
  transition: border-color .2s, color .2s;
}
.chat-chip:hover { border-color: var(--accent); color: var(--accent); }

/* ----- composer ----- */
.chat-foot { flex-shrink: 0; padding: 16px 30px 22px; border-top: 1px solid var(--line); }
#chatForm { display: flex; align-items: flex-end; gap: 9px; }
#chatForm .brief-textarea {
  flex: 1;
  margin: 0;
  min-height: 46px;
  max-height: 160px;
  resize: none;
  overflow-y: auto;
  line-height: 1.55;
}
#chatForm button[type="submit"] { flex-shrink: 0; height: 46px; }
.chat-hint { font-size: 9px; color: var(--muted); margin-top: 9px; }

.brief-error .chat-retry {
  margin-left: 9px;
  font-size: 11px;
  font-weight: 700;
  text-decoration: underline;
  background: none;
  color: var(--accent);
}
#chatError:empty { display: none; }
#chatError { margin-top: 10px; }

.chat-foot .brief-controls { margin-top: 12px; gap: 16px; flex-wrap: wrap; }

@media (max-width: 560px) {
  .chat-dialog { width: 100%; max-height: 92dvh; }
  .chat-head { padding: 22px 20px 14px; }
  .chat-head h2 { font-size: 23px; }
  .chat-messages { padding: 16px 20px; max-height: 52dvh; }
  .chat-msg { max-width: 93%; }
  .chat-foot { padding: 14px 20px 18px; }
}

/* product card shown under a reply */
.chat-status {
  justify-self: start;
  font: 9px ui-monospace, monospace;
  letter-spacing: .14em;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 4px 10px;
}
.chat-status.is-ready { color: #2f7d4f; border-color: #2f7d4f55; }
.chat-effect button.chat-effect-btn { font: inherit; font-size: 11px; font-weight: 700; }

/* voice: speak to the assistant, hear it answer */
.voice-bar { display: flex; align-items: center; gap: 8px; margin-top: 10px; }
.voice-btn {
  width: 36px; height: 36px;
  display: grid; place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--surface2);
  font-size: 15px; line-height: 1;
  transition: border-color .2s, background .2s;
}
.voice-btn:hover { border-color: var(--accent); }
.voice-btn.is-on { background: var(--accent); border-color: transparent; }
.voice-btn.is-live {
  background: var(--accent); border-color: transparent;
  animation: voice-pulse 1.3s ease-in-out infinite;
}
@keyframes voice-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(147, 2, 40, .45); }
  50%      { box-shadow: 0 0 0 7px rgba(147, 2, 40, 0); }
}
@media (prefers-reduced-motion: reduce) { .voice-btn.is-live { animation: none; } }
.voice-status { font-size: 10px; color: var(--muted); }

.voice-btn.voice-talk { width:auto; border-radius:18px; padding:0 12px; gap:6px; font-size:12px; display:inline-flex; align-items:center; }
.voice-lang { font:inherit; font-size:12px; padding:6px 8px; border-radius:8px; border:1px solid var(--line, #ccc); background:transparent; color:inherit; }

/* A closed dialog must stay hidden: `display:flex` above would otherwise show it. */
dialog:not([open]) { display: none !important; }

/* keep the voice controls on one tidy line on phones */
.voice-bar { flex-wrap: wrap; }
.voice-btn.voice-talk { white-space: nowrap; height: 36px; }
.voice-btn.voice-talk .voice-icon { font-size: 15px; }
