/* The complete panel fits the viewport; only the conversation scrolls. */
.chat-widget {
  --chat-top: max(16px, env(safe-area-inset-top));
  --chat-bottom: max(16px, env(safe-area-inset-bottom));
  right: max(16px, env(safe-area-inset-right));
  bottom: calc(var(--chat-bottom) + var(--chat-keyboard-offset, 0px));
  max-width: calc(100% - 32px);
}
.chat-panel {
  display: flex;
  flex-direction: column;
  width: min(380px, calc(100vw - 32px));
  max-width: 100%;
  height: min(500px, calc(100vh - var(--chat-top) - var(--chat-bottom)));
  height: min(500px, calc(var(--chat-viewport-height, 100dvh) - var(--chat-top) - var(--chat-bottom)));
  min-height: 0;
  overflow: hidden;
}
.chat-panel[hidden], .chat-toggle[hidden] { display: none; }
.chat-head {
  flex: 0 0 auto;
  align-items: flex-start;
  gap: 10px;
  padding: 12px;
}
.chat-head > div { min-width: 0; }
.chat-head strong { font-size: 14px; }
.chat-head span { font-size: 12px; line-height: 1.45; }
.chat-head #chatClose {
  flex: 0 0 auto;
  width: auto;
  min-width: 72px;
  height: 44px;
  min-height: 44px;
  padding: 8px 10px;
  border: 1px solid #ffffff70;
  border-radius: 6px;
  background: #ffffff18;
  color: #fff;
  font-size: 13px;
  line-height: 1.2;
  transform: none;
}
.chat-head #chatClose:hover { background: #ffffff30; }
.chat-head #chatClose:focus-visible { outline-color: #fff; outline-offset: 2px; }
.chat-availability {
  flex: 0 0 auto;
  margin: 0;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  background: #edf2e5;
  color: var(--ink);
  font-size: 12px;
  line-height: 1.5;
}
.chat-availability a { font-weight: 600; }
.chat-messages {
  flex: 1 1 0;
  min-height: 0;
  max-height: none;
  overflow-y: auto;
  overscroll-behavior: contain;
  overflow-wrap: anywhere;
  padding: 12px;
}
.chat-form {
  flex: 0 0 auto;
  align-items: stretch;
  padding: 10px;
  background: #fff;
}
.chat-form textarea {
  height: 60px;
  min-height: 44px;
  max-height: 80px;
  padding: 10px;
  font-size: 14px;
  line-height: 1.4;
}
.chat-form button { min-height: 44px; border-radius: 6px; }
.chat-form :disabled { opacity: .6; cursor: not-allowed; }
@media (max-width: 600px) {
  .chat-form textarea { font-size: 16px; }
}
@media (max-height: 360px) {
  .chat-head { padding: 8px 10px; }
  .chat-head span { display: none; }
  .chat-availability { padding: 6px 10px; }
  .chat-form { padding: 6px 10px; }
  .chat-form textarea { height: 44px; }
}
