/* Hallmark · component: chat panel · genre: editorial · theme: custom (tokens.css)
 * states: default · hover · focus · active · disabled · loading · error · success
 * The Mainline front-desk chat. Reads every colour and font from tokens.css.
 */
.chat-launch {
  position: fixed; right: max(var(--space-md), env(safe-area-inset-right)); bottom: max(var(--space-md), env(safe-area-inset-bottom));
  z-index: var(--z-sticky);
  display: inline-flex; align-items: center; gap: 0.55em;
  min-height: 48px; padding: 0.65rem 1.1rem 0.65rem 0.95rem;
  background: var(--color-ink); color: var(--color-paper);
  border: var(--rule-hair) solid var(--color-ink); border-radius: var(--radius-pill);
  font: inherit; font-size: var(--text-sm); font-weight: 500; white-space: nowrap; cursor: pointer;
  box-shadow: 0 1px 2px var(--color-shadow);
  transition: background-color var(--dur-short) var(--ease-out), transform 100ms var(--ease-out);
}
.chat-launch:hover { background: var(--color-accent-2); border-color: var(--color-accent-2); }
.chat-launch:active { transform: translateY(1px); }
.chat-launch svg { width: 1.15em; height: 1.15em; }
.chat-launch[aria-expanded="true"] { visibility: hidden; }

.chat {
  position: fixed; z-index: var(--z-modal);
  right: max(var(--space-md), env(safe-area-inset-right)); bottom: max(var(--space-md), env(safe-area-inset-bottom));
  width: min(24rem, 100% - 2 * var(--space-md));
  height: min(38rem, 100dvh - 2 * var(--space-md));
  display: grid; grid-template-rows: auto auto minmax(0, 1fr) auto;
  background: var(--color-paper); color: var(--color-ink);
  border: var(--rule-hair) solid var(--color-rule); border-radius: 10px;
  box-shadow: 0 1px 2px var(--color-shadow), 0 0 0 1px var(--color-shadow);
  transform-origin: bottom right;
  animation: chat-in var(--dur-long) var(--ease-out);
}
@keyframes chat-in { from { opacity: 0; transform: scale(0.97); } to { opacity: 1; transform: none; } }
@media (max-width: 30rem) {
  .chat { right: 0; bottom: 0; width: 100%; height: 100dvh; border-radius: 0; border: 0; }
}

.chat__head { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: var(--space-sm); align-items: start; padding: var(--space-md) var(--space-md) var(--space-sm); border-bottom: var(--rule-hair) solid var(--color-rule-2); }
.chat__title { font-family: var(--font-display); font-weight: 600; font-size: var(--text-md); line-height: 1.15; }
.chat__sub { font-size: var(--text-xs); color: var(--color-muted); margin-top: var(--space-3xs); }
.chat__close { background: none; border: var(--rule-hair) solid transparent; border-radius: var(--radius-pill); color: var(--color-muted); font: inherit; font-size: var(--text-sm); min-height: 40px; min-width: 40px; padding: 0 var(--space-sm); cursor: pointer; }
.chat__close:hover { color: var(--color-ink); border-color: var(--color-rule); }

.chat__notice { font-size: var(--text-xs); color: var(--color-ink-2); background: var(--color-alert-wash); padding: var(--space-xs) var(--space-md); line-height: 1.45; }
.chat__notice strong { color: var(--color-alert); font-weight: 600; }

.chat__log { overflow-y: auto; overscroll-behavior: contain; padding: var(--space-md); display: flex; flex-direction: column; gap: var(--space-sm); scroll-behavior: smooth; }
.chat__msg { max-width: 88%; padding: var(--space-xs) var(--space-sm); border-radius: 10px; font-size: var(--text-sm); line-height: 1.5; overflow-wrap: anywhere; }
.chat__msg--agent { align-self: flex-start; background: var(--color-paper-2); border-bottom-left-radius: 3px; }
.chat__msg--user { align-self: flex-end; background: var(--color-accent); color: var(--color-accent-ink); border-bottom-right-radius: 3px; }
.chat__msg--system { align-self: stretch; max-width: none; background: none; color: var(--color-muted); font-size: var(--text-xs); text-align: center; padding-block: var(--space-2xs); }
.chat__msg--error { color: var(--color-alert); }
.chat__msg--system a { color: inherit; }
.chat__typing { align-self: flex-start; display: inline-flex; gap: 4px; padding: var(--space-sm); background: var(--color-paper-2); border-radius: 10px; border-bottom-left-radius: 3px; }
.chat__typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--color-muted); animation: chat-dot 1.2s var(--ease-in-out) infinite; }
.chat__typing i:nth-child(2) { animation-delay: 0.15s; }
.chat__typing i:nth-child(3) { animation-delay: 0.3s; }
@keyframes chat-dot { 0%, 60%, 100% { opacity: 0.35; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-3px); } }

.chat__chips { display: flex; flex-wrap: wrap; gap: var(--space-xs); padding: 0 var(--space-md) var(--space-xs); }
.chat__chip { font: inherit; font-size: var(--text-xs); background: none; border: var(--rule-hair) solid var(--color-rule); border-radius: var(--radius-pill); color: var(--color-ink-2); padding: var(--space-2xs) var(--space-sm); min-height: 34px; cursor: pointer; }
.chat__chip:hover { border-color: var(--color-ink); color: var(--color-ink); }

.chat__form { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: var(--space-xs); padding: var(--space-sm) var(--space-md) var(--space-md); border-top: var(--rule-hair) solid var(--color-rule-2); align-items: end; }
.chat__input {
  font: inherit; font-size: var(--text-sm); line-height: 1.4; color: var(--color-ink); background: var(--color-paper);
  border: var(--rule-hair) solid var(--color-rule); border-radius: var(--radius-input); padding: var(--space-xs) var(--space-sm);
  resize: none; min-height: 44px; max-height: 8rem; width: 100%;
  transition: border-color var(--dur-short) var(--ease-out);
}
.chat__input:hover { border-color: var(--color-muted); }
.chat__input:focus-visible { border-color: var(--color-accent); outline-offset: 1px; }
.chat__input:disabled { background: var(--color-paper-2); color: var(--color-muted); }
.chat__send { min-height: 44px; padding-inline: var(--space-md); }
.chat__send[data-state="loading"] { opacity: 0.6; cursor: progress; }
.chat__foot { grid-column: 1 / -1; font-size: var(--text-xs); color: var(--color-muted); display: flex; justify-content: space-between; gap: var(--space-sm); flex-wrap: wrap; }
.chat__foot button { font: inherit; font-size: inherit; background: none; border: 0; padding: 0; color: var(--color-accent); cursor: pointer; text-decoration: underline; text-underline-offset: 0.14em; }
.chat__foot button:hover { color: var(--color-accent-2); }

@media (prefers-reduced-motion: reduce) {
  .chat { animation: chat-in 150ms linear; }
  .chat__typing i { animation: none; opacity: 0.7; }
  .chat__log { scroll-behavior: auto; }
}
