/* ==========================================================================
   NEXT DIGITAL LEVEL — Assistant
   Floating launcher + conversation panel. Same tokens as style.css.
   ========================================================================== */
.chat { position: fixed; right: 22px; bottom: 22px; z-index: 300; font-family: var(--font-body); }
.chat * { box-sizing: border-box; }

/* Launcher */
.chat__launch {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  padding: 10px 18px 10px 10px;
  border: 1px solid var(--hairline);
  border-radius: var(--radius-pill);
  background: rgba(253, 252, 249, 0.92);
  backdrop-filter: saturate(160%) blur(14px);
  -webkit-backdrop-filter: saturate(160%) blur(14px);
  box-shadow: 0 18px 44px -20px rgba(20, 17, 14, 0.45);
  color: var(--ink);
  font: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: transform 0.45s var(--ease-ui), box-shadow 0.45s var(--ease-ui), opacity 0.3s;
}
.chat__launch:hover { transform: translateY(-2px); box-shadow: 0 24px 50px -22px rgba(20, 17, 14, 0.5); }
.chat__avatar {
  position: relative;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: var(--accent);
  flex-shrink: 0;
}
.chat__avatar svg { width: 22px; height: 22px; }
.chat__avatar::after {
  content: "";
  position: absolute;
  right: -3px;
  bottom: -3px;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--accent-bright);
  border: 2px solid var(--canvas-card);
}
.chat__launch-text { display: flex; flex-direction: column; line-height: 1.15; text-align: left; }
.chat__launch-text small { font-size: 0.7rem; font-weight: 400; color: var(--body-mid); }
.chat.is-open .chat__launch { opacity: 0; pointer-events: none; transform: translateY(10px); }
.js .chat__launch { animation: chatLaunchIn 0.9s var(--ease-reveal) 1.8s both; }
@keyframes chatLaunchIn { from { opacity: 0; transform: translateY(20px) scale(0.96); } }

/* Panel */
.chat__panel {
  position: absolute;
  right: 0;
  bottom: 0;
  width: min(390px, calc(100vw - 32px));
  height: min(640px, calc(100dvh - 110px));
  display: flex;
  flex-direction: column;
  border: 1px solid var(--hairline);
  border-radius: 26px;
  background: var(--canvas-card);
  box-shadow: 0 40px 90px -40px rgba(20, 17, 14, 0.55);
  overflow: hidden;
  transform-origin: bottom right;
  opacity: 0;
  transform: translateY(16px) scale(0.96);
  pointer-events: none;
  transition: opacity 0.4s var(--ease-ui), transform 0.5s var(--ease-reveal);
}
.chat.is-open .chat__panel { opacity: 1; transform: none; pointer-events: auto; }

.chat__head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 16px 16px 18px;
  background: linear-gradient(155deg, var(--panel-soft), var(--panel));
  color: var(--panel-ink);
}
.chat__head .chat__avatar { background: rgba(255, 255, 255, 0.1); }
.chat__head .chat__avatar::after { border-color: var(--panel); }
.chat__title { display: flex; flex-direction: column; line-height: 1.2; }
.chat__title b { font-family: var(--font-display); font-weight: 400; font-size: 1.1rem; letter-spacing: -0.01em; }
.chat__title small { font-size: 0.72rem; color: var(--panel-body); }
.chat__close {
  margin-left: auto;
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border: 1px solid var(--panel-line-strong);
  border-radius: 50%;
  background: transparent;
  color: var(--panel-ink);
  font-size: 1.1rem;
  cursor: pointer;
  transition: background 0.3s;
}
.chat__close:hover { background: rgba(255, 255, 255, 0.1); }

.chat__log {
  flex: 1;
  overflow-y: auto;
  padding: 20px 16px 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
  overscroll-behavior: contain;
}
.chat__msg {
  max-width: 86%;
  padding: 12px 15px;
  border-radius: 18px;
  font-size: 0.92rem;
  line-height: 1.55;
  animation: msgIn 0.45s var(--ease-reveal) both;
}
@keyframes msgIn { from { opacity: 0; transform: translateY(8px); } }
.chat__msg--bot { align-self: flex-start; background: var(--canvas-soft); color: var(--body); border-bottom-left-radius: 6px; }
.chat__msg--bot b { color: var(--ink); font-weight: 500; }
.chat__msg--bot a { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }
.chat__msg--user { align-self: flex-end; background: var(--accent); color: #fff; border-bottom-right-radius: 6px; }
.chat__msg p + p { margin-top: 8px; }
.chat__time { display: block; margin: -4px 0 0 4px; font-family: var(--font-mono); font-size: 0.6rem; letter-spacing: 0.1em; color: var(--body-dim); }

.chat__typing { display: inline-flex; gap: 4px; align-items: center; padding: 4px 2px; }
.chat__typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); opacity: 0.4; animation: typingBounce 1.3s ease-in-out infinite; }
.chat__typing i:nth-child(2) { animation-delay: 0.18s; }
.chat__typing i:nth-child(3) { animation-delay: 0.36s; }

.chat__chips { display: flex; flex-wrap: wrap; gap: 8px; padding: 4px 16px 12px; }
.chat__chip {
  padding: 8px 13px;
  border: 1px solid var(--hairline-strong);
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 0.8rem;
  cursor: pointer;
  transition: background 0.3s, border-color 0.3s, transform 0.3s var(--ease-ui);
  animation: msgIn 0.5s var(--ease-reveal) both;
}
.chat__chip:nth-child(2) { animation-delay: 60ms; }
.chat__chip:nth-child(3) { animation-delay: 120ms; }
.chat__chip:nth-child(4) { animation-delay: 180ms; }
.chat__chip:hover { background: var(--accent-wash); border-color: var(--accent); transform: translateY(-1px); }
.chat__chip--act { background: var(--accent); color: #fff; border-color: var(--accent); }
.chat__chip--act:hover { background: var(--accent-soft); }

.chat__form {
  display: flex;
  gap: 8px;
  padding: 12px 12px 12px 16px;
  border-top: 1px solid var(--hairline);
  background: var(--canvas-card);
}
.chat__input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  font: inherit;
  font-size: 16px;
  color: var(--ink);
  padding: 8px 0;
  outline: none;
}
.chat__input::placeholder { color: var(--body-dim); }
.chat__send {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  transition: transform 0.3s var(--ease-ui), background 0.3s;
  flex-shrink: 0;
}
.chat__send:hover { background: var(--accent-soft); transform: translateY(-1px); }
.chat__send:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }
.chat__foot { padding: 0 16px 10px; font-size: 0.66rem; color: var(--body-dim); text-align: center; }

@media (max-width: 720px) {
  .chat { right: 14px; bottom: calc(76px + env(safe-area-inset-bottom)); }
  .chat__launch { padding: 8px 14px 8px 8px; font-size: 0.84rem; }
  .chat__launch-text small { display: none; }
  .chat__panel { width: calc(100vw - 28px); height: min(600px, calc(100dvh - 160px)); }
  body.is-locked .chat { visibility: hidden; }
}
@media (prefers-reduced-motion: reduce) {
  .chat__msg, .chat__chip, .js .chat__launch { animation: none !important; }
  .chat__panel { transition: none; }
}
