.chat-toggle {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 50;
  border: 0;
  padding: 13px 20px;
  background: var(--ink);
  color: var(--bg);
  font: 500 13.5px var(--sans);
  cursor: pointer;
}
.chat-panel[hidden], .chat-toggle[hidden] { display: none; }
.chat-panel {
  position: fixed;
  z-index: 51;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(440px, 100%);
  display: flex;
  flex-direction: column;
  color: var(--ink);
  background: var(--surface);
  border-left: 1px solid #343430;
  box-shadow: -12px 0 40px #0004;
  font: 14px/1.5 var(--sans);
}
.chat-header {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 68px;
  padding: 0 20px 0 24px;
  border-bottom: 1px solid var(--line);
}
.chat-title { font-size: 14px; font-weight: 500; }
.chat-close {
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  font: 26px/1 var(--sans);
  cursor: pointer;
}
.chat-close:hover { color: var(--ink); background: #ffffff0d; }
.chat-history {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 24px;
  scrollbar-width: thin;
  scrollbar-color: #ffffff35 transparent;
}
.chat-history::-webkit-scrollbar { width: 5px; }
.chat-history::-webkit-scrollbar-track { background: transparent; }
.chat-history::-webkit-scrollbar-thumb { background: #ffffff35; border-radius: 5px; }
.chat-welcome { margin: 30px 0; max-width: 300px; }
.chat-welcome h2 { margin: 0 0 10px; font-size: 22px; line-height: 1.2; font-weight: 500; letter-spacing: -.02em; }
.chat-welcome p { margin: 0; color: var(--muted); line-height: 1.6; }
.chat-bubble {
  width: fit-content;
  max-width: 88%;
  margin: 0 0 12px;
  padding: 11px 14px;
  border-radius: 16px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.chat-bubble--assistant { background: #242421; border-bottom-left-radius: 4px; }
.chat-bubble--user { margin-left: auto; background: #e6e6e1; color: #111110; border-bottom-right-radius: 4px; }
.chat-sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.chat-thinking { margin: 10px 0; color: var(--muted); font-size: 12px; }
.chat-form { flex: none; padding: 0 20px max(20px, env(safe-area-inset-bottom)); }
.chat-status { margin: 0; color: #ccc; font-size: 12px; }
.chat-status:not(:empty) { margin: 0 4px 8px; }
.chat-composer {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  padding: 9px;
  border: 1px solid #454541;
  border-radius: 16px;
  background: #1c1c1a;
}
.chat-composer:focus-within { border-color: #85857f; }
.chat-input {
  flex: 1;
  min-width: 0;
  min-height: 34px;
  max-height: 160px;
  resize: vertical;
  padding: 7px 5px;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  font: inherit;
  line-height: 20px;
  scrollbar-width: thin;
  scrollbar-color: #ffffff35 transparent;
}
.chat-input::placeholder { color: #92928c; }
.chat-send {
  flex: none;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 50%;
  background: var(--ink);
  color: var(--bg);
  font: 20px/1 var(--sans);
  cursor: pointer;
}
.chat-send:disabled { opacity: .35; cursor: default; }
.chat-toggle:focus-visible, .chat-close:focus-visible, .chat-send:focus-visible, .chat-history:focus-visible { outline: 2px solid #aaa; outline-offset: 3px; }
@media (max-width: 600px) {
  body.chat-open { overflow: hidden; }
  .chat-toggle { right: 20px; bottom: 20px; }
  .chat-panel { width: 100%; height: 100vh; height: 100dvh; border: 0; box-shadow: none; }
  .chat-header { padding-top: env(safe-area-inset-top); }
  .chat-history { padding: 20px; }
}
