/* NightForward: website chat widget */
.chat-launch {
  position: fixed; right: max(16px, env(safe-area-inset-right)); bottom: max(16px, env(safe-area-inset-bottom)); z-index: 60;
  display: inline-flex; align-items: center; gap: .55rem;
  min-height: 3rem; padding: .7rem 1.15rem .7rem .95rem;
  font: 600 .95rem/1 var(--sans); color: var(--paper); background: var(--ink);
  border: 1px solid var(--line-dark); border-radius: 999px; cursor: pointer;
  box-shadow: var(--shadow); transition: transform .3s var(--ease-out), background .2s;
}
.chat-launch:hover { background: var(--ink-2); transform: translateY(-2px); }
.chat-launch svg { width: 1.2rem; height: 1.2rem; fill: none; stroke: var(--amber); stroke-width: 2; stroke-linejoin: round; }

.chat {
  position: fixed; right: max(16px, env(safe-area-inset-right)); bottom: calc(max(16px, env(safe-area-inset-bottom)) + 3.75rem); z-index: 61;
  width: min(24rem, calc(100vw - 32px)); height: min(36rem, calc(100dvh - 6.5rem));
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--paper); color: var(--ink); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow);
  font-size: .95rem; line-height: 1.5;
}
.chat[hidden] { display: none; }
.chat__head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; padding: .9rem 1rem .8rem; background: var(--ink); color: var(--paper); }
.chat__title { font: 600 1.05rem/1.2 var(--serif); }
.chat__sub { font-size: .8rem; color: #B9C1CE; margin-top: .15rem; }
.chat__icon-btn { background: none; border: 0; color: var(--paper); font-size: 1.6rem; line-height: 1; width: 2.25rem; height: 2.25rem; border-radius: 8px; cursor: pointer; }
.chat__icon-btn:hover { background: var(--ink-3); }

.chat__consent, .chat__ended { padding: 1.1rem 1rem; display: flex; flex-direction: column; gap: .85rem; overflow-y: auto; }
.chat__consent[hidden], .chat__ended[hidden], .chat__body[hidden] { display: none; }
.chat__disclosure { background: var(--paper-2); border-radius: 10px; padding: .85rem .95rem; }
.chat__disclosure a, .chat__bubble a { color: var(--amber-ink); font-weight: 600; }
.chat__ts { min-height: 65px; }
.chat__start { align-self: flex-start; }
.chat__note { color: #9B2C2C; font-size: .88rem; }
.chat__note:empty { display: none; }
.chat__small { font-size: .8rem; color: var(--slate); }

.chat__body { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.chat__log { flex: 1; overflow-y: auto; padding: 1rem; display: flex; flex-direction: column; gap: .6rem; overscroll-behavior: contain; }
.chat__msg { display: flex; max-width: 88%; }
.chat__msg--assistant { align-self: flex-start; }
.chat__msg--visitor { align-self: flex-end; }
.chat__bubble { padding: .6rem .8rem; border-radius: 14px; white-space: pre-wrap; overflow-wrap: anywhere; }
.chat__msg--assistant .chat__bubble { background: #fff; border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.chat__msg--visitor .chat__bubble { background: var(--ink); color: var(--paper); border-bottom-right-radius: 4px; }
.chat__msg.is-typing .chat__bubble::after { content: "…"; display: inline-block; animation: chat-dots 1.2s steps(3) infinite; width: 1.2em; }
@keyframes chat-dots { 0% { opacity: .3; } 50% { opacity: 1; } 100% { opacity: .3; } }
.chat__tool { align-self: center; font-size: .78rem; color: var(--slate); background: var(--paper-2); padding: .2rem .65rem; border-radius: 999px; }

.chat__form { display: flex; align-items: flex-end; gap: .5rem; padding: .6rem .75rem; border-top: 1px solid var(--line); background: #fff; }
.chat__input { flex: 1; resize: none; border: 1px solid var(--line); border-radius: 10px; padding: .6rem .7rem; font: inherit; color: inherit; background: var(--paper); max-height: 140px; }
.chat__input:focus-visible { outline: 2px solid var(--amber); outline-offset: 1px; }
.chat__send { flex: none; width: 2.6rem; height: 2.6rem; border-radius: 10px; border: 0; background: var(--ink); cursor: pointer; display: grid; place-items: center; }
.chat__send svg { width: 1.2rem; height: 1.2rem; fill: none; stroke: var(--amber); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.chat__send:disabled { opacity: .5; cursor: progress; }
.chat__foot { display: flex; justify-content: space-between; padding: .35rem .9rem .6rem; background: #fff; font-size: .8rem; }
.chat__link { background: none; border: 0; padding: .25rem 0; font: inherit; color: var(--slate); text-decoration: underline; cursor: pointer; }
.chat__link:hover { color: var(--ink); }
.chat__sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

@media (max-width: 520px) {
  .chat-launch__label { font-size: .9rem; }
  .chat { height: calc(100dvh - 6rem); }
}
@media (prefers-reduced-motion: reduce) {
  .chat-launch, .chat-launch:hover { transition: none; transform: none; }
  .chat__msg.is-typing .chat__bubble::after { animation: none; }
}
