/* "Ask about the Acharyas" chat: floating button + side panel (acharyas home page).
   Uses the --ac-* tokens from acharyas.css. Sits above the site header/bottom nav (z-50). */

.ach-chat-launch {
  position: fixed; right: 22px; bottom: 24px; z-index: 10040;
  display: inline-flex; align-items: center; gap: .55rem;
  justify-content: center; width: 3.4rem; height: 3.4rem;
  border: 0; border-radius: 50%; padding: 0; cursor: pointer;
  background: var(--ac-dark); color: #fff; font: 600 .95rem/1 Inter, system-ui, sans-serif;
  box-shadow: 0 6px 20px rgba(15, 77, 74, .32);
  transition: transform .2s ease, opacity .2s ease;
}
.ach-chat-launch i { font-size: 1.4rem; color: var(--ac-cream-2); }
.ach-chat-launch:hover { background: #0b3b39; transform: translateY(-2px); }
.ach-chat-open .ach-chat-launch { opacity: 0; pointer-events: none; transform: scale(.9); }

.ach-chat-backdrop { position: fixed; inset: 0; z-index: 10045; background: rgba(20, 25, 24, .35); }

.ach-chat {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 10050;
  width: min(420px, 100vw); display: flex; flex-direction: column;
  background: var(--ac-bg); border-left: 1px solid var(--ac-line);
  box-shadow: -12px 0 40px rgba(15, 77, 74, .18);
  transform: translateX(105%); visibility: hidden;
  transition: transform .28s ease, visibility 0s linear .28s;
  font-family: Inter, system-ui, -apple-system, "Segoe UI", sans-serif; color: var(--ac-ink);
}
.ach-chat-open .ach-chat { transform: none; visibility: visible; transition: transform .28s ease; }

.ach-chat-head {
  flex: none; display: flex; align-items: center; gap: .7rem;
  padding: .9rem .8rem .9rem 1rem; background: var(--ac-dark); color: #fff;
}
.ach-chat-logo { flex: none; width: 2.6rem; height: 2.6rem; display: block; }
.ach-chat-titles { flex: 1; min-width: 0; }
.ach-chat-titles h2 { margin: 0; font-size: 1.02rem; font-weight: 700; color: #fff; }
.ach-chat-titles p { margin: .12rem 0 0; font-size: .78rem; color: rgba(255, 255, 255, .75); }
.ach-chat-hbtn {
  flex: none; width: 2.2rem; height: 2.2rem; border: 0; border-radius: 50%; cursor: pointer;
  background: transparent; color: rgba(255, 255, 255, .85); font-size: 1rem;
}
.ach-chat-hbtn:hover { background: rgba(255, 255, 255, .14); color: #fff; }
#achChatClose { font-size: 1.2rem; }

.ach-chat-body { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 1rem; display: flex; flex-direction: column; gap: .75rem; }
.ach-chat-log { display: flex; flex-direction: column; gap: .75rem; }
.ach-chat-log:empty { display: none; }

.ach-chat-msg { padding: .7rem .9rem; border-radius: 14px; font-size: .94rem; line-height: 1.6; overflow-wrap: anywhere; }
.ach-chat-msg.is-you { align-self: flex-end; max-width: 85%; background: var(--ac-dark); color: #fff; border-bottom-right-radius: 4px; white-space: pre-wrap; }
.ach-chat-msg.is-bot { align-self: flex-start; max-width: 94%; background: #fff; border: 1px solid var(--ac-line); color: #2c2924; border-bottom-left-radius: 4px; }
.ach-chat-msg.is-bot p { margin: 0 0 .55rem; }
.ach-chat-msg.is-bot p:last-child, .ach-chat-msg.is-bot ul:last-child, .ach-chat-msg.is-bot ol:last-child { margin-bottom: 0; }
.ach-chat-msg.is-bot ul, .ach-chat-msg.is-bot ol { margin: 0 0 .55rem 1.15rem; padding: 0; }
.ach-chat-msg.is-bot li { margin: .2rem 0; }
.ach-chat-msg.is-bot a { color: var(--ac-dark); font-weight: 600; text-decoration: underline; text-underline-offset: 2px; }
.ach-chat-msg.is-bot h2, .ach-chat-msg.is-bot h3 { font-size: .98rem; margin: .4rem 0; color: var(--ac-dark); }
.ach-chat-welcome { background: var(--ac-cream) !important; }
.ach-chat-msg.is-error { background: #fff4f2; border-color: #f0c9bf; color: #7a2e1d; }
.ach-chat-msg.is-wait { color: var(--ac-muted); font-style: italic; }
.ach-chat-msg.is-wait::after { content: ""; display: inline-block; width: 1.2em; text-align: left; animation: ach-chat-dots 1.2s steps(4, end) infinite; }
@keyframes ach-chat-dots { 0% { content: ""; } 25% { content: "."; } 50% { content: ".."; } 75% { content: "..."; } }

.ach-chat-suggest { display: flex; flex-direction: column; align-items: flex-start; gap: .45rem; }
.ach-chat-chip {
  border: 1px solid var(--ac-line); background: #fff; color: var(--ac-dark); text-align: left;
  border-radius: 999px; padding: .45rem .85rem; font: inherit; font-size: .85rem; cursor: pointer;
}
.ach-chat-chip:hover { border-color: var(--ac-accent); background: var(--ac-cream-2); }
.ach-chat-has-log .ach-chat-suggest { display: none; }

.ach-chat-foot { flex: none; padding: .7rem .8rem calc(.6rem + env(safe-area-inset-bottom)); border-top: 1px solid var(--ac-line); background: #fff; }
.ach-chat-form { display: flex; gap: .5rem; align-items: flex-end; position: relative; }
.ach-chat-form textarea {
  flex: 1; min-width: 0; resize: none; max-height: 8rem;
  border: 1px solid var(--ac-line); border-radius: 12px; padding: .65rem .8rem;
  font: inherit; font-size: 1rem; line-height: 1.4; color: var(--ac-ink); background: var(--ac-bg);
}
.ach-chat-form textarea:focus { outline: 2px solid var(--ac-dark); outline-offset: 1px; background: #fff; }
.ach-chat-form button {
  flex: none; width: 2.75rem; height: 2.75rem; border: 0; border-radius: 50%; cursor: pointer;
  background: var(--ac-dark); color: #fff; font-size: 1rem;
}
.ach-chat-form button:hover { background: #0b3b39; }
.ach-chat-form button:disabled { opacity: .5; cursor: wait; }
.ach-chat-note { margin: .45rem 0 0; font-size: .72rem; color: var(--ac-muted); text-align: center; }
.ach-chat-hp, .ach-chat-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Phones: full-screen panel, button sits above the site's bottom nav. */
@media (max-width: 640px) {
  .ach-chat { width: 100vw; border-left: 0; }
  .ach-chat-launch { right: 12px; bottom: calc(80px + env(safe-area-inset-bottom)); width: 2.9rem; height: 2.9rem; }
  .ach-chat-launch i { font-size: 1.2rem; }
  .ach-chat-launch.is-tucked { opacity: 0; transform: translateY(14px) scale(.85); pointer-events: none; }
  html.ach-chat-open, html.ach-chat-open body { overflow: hidden; }
}
@media (min-width: 641px) { .ach-chat-backdrop { display: none; } }
@media (prefers-reduced-motion: reduce) { .ach-chat, .ach-chat-launch { transition: none; } }
