/* chat */
.chat-fab { position: fixed; right: var(--pad); bottom: 24px; z-index: 75; display: grid; place-items: center; width: 56px; height: 56px; border-radius: 50%; background: #f5f5f7; color: #000; box-shadow: 0 0 0 1px rgba(255, 255, 255, .2), 0 14px 40px -10px rgba(0, 0, 0, .9); transition: transform .3s var(--ease), background .2s, opacity .6s; }
.chat-fab:hover { background: #fff; transform: scale(1.05); }
.chat-fab svg { width: 24px; height: 24px; }
.chat-fab .x, .chat-open .chat-fab .bub { display: none; }
.chat-open .chat-fab .x { display: block; }
.badge { position: absolute; right: -2px; top: -2px; min-width: 21px; height: 21px; padding: 0 6px; border: 2px solid #000; border-radius: 11px; background: #ff453a; color: #fff; font: 600 .7rem/17px var(--sans); }
.badge[hidden] { display: none; }

.chat-tease { position: fixed; right: calc(var(--pad) + 70px); bottom: 32px; z-index: 74; display: flex; align-items: center; gap: 6px; padding: 9px 8px 9px 14px; border: 1px solid rgba(255, 255, 255, .12); border-radius: 14px 14px 4px 14px; background: #161618; box-shadow: 0 12px 40px -12px rgba(0, 0, 0, .9); font-size: .9rem; font-weight: 500; cursor: pointer; transition: opacity .6s; }
.js .chat-tease { animation: chat-in .4s var(--ease); }
.chat-tease[hidden], .chat-open .chat-tease { display: none; }
.chat-tease button { width: 22px; height: 22px; border-radius: 50%; color: #6e6e73; font-size: 1rem; line-height: 1; }
.chat-tease button:hover { color: #fff; }
.js:not(.loaded) .chat-fab, .js:not(.loaded) .chat-tease, .menu-open .chat-fab, .menu-open .chat-tease { opacity: 0; pointer-events: none; }

.chat { position: fixed; right: var(--pad); bottom: 92px; z-index: 80; display: flex; flex-direction: column; width: min(372px, 100vw - 2 * var(--pad)); height: min(600px, 100dvh - 124px); overflow: hidden; border: 1px solid rgba(255, 255, 255, .1); border-radius: 20px; background: #0b0b0d; color: var(--ink); font-family: var(--sans); box-shadow: 0 0 0 1px #000, 0 30px 80px -20px #000;
  opacity: 0; visibility: hidden; transform: translateY(10px) scale(.985); transform-origin: 100% 100%; transition: opacity .2s, transform .3s var(--ease), visibility 0s .3s; }
.chat-open .chat { opacity: 1; visibility: visible; transform: none; transition: opacity .2s, transform .3s var(--ease); }

.chat-head { position: relative; display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 12px 10px 12px 14px; border-bottom: 1px solid rgba(255, 255, 255, .07); }
.chat-who { display: flex; align-items: center; gap: 10px; min-width: 0; }
.avatar { position: relative; flex: none; width: 34px; height: 34px; }
.avatar img { display: block; width: 100%; height: 100%; border-radius: 50%; }
.avatar i { position: absolute; right: -1px; bottom: -1px; width: 11px; height: 11px; border: 2px solid #0b0b0d; border-radius: 50%; background: #48484a; transition: background .3s; }
.chat-who b { display: block; font: 600 .95rem/1.2 var(--sans); letter-spacing: -.01em; }
.chat-state { display: flex; align-items: center; gap: 6px; font-size: .78rem; color: #86868b; }
.dots { display: none; gap: 3px; align-items: center; }
.dots i { width: 4px; height: 4px; border-radius: 50%; background: currentColor; animation: chat-dot 1.2s ease-in-out infinite; }
.dots i:nth-child(2) { animation-delay: .15s; } .dots i:nth-child(3) { animation-delay: .3s; }
.chat[data-s="waiting"] .avatar i { background: #ffd60a; }
.chat[data-s="waiting"] .dots { display: inline-flex; }
.chat[data-s="connected"] .avatar i { background: #30d158; }
.chat[data-s="connected"] .chat-state { color: #30d158; }
.chat-tools { display: flex; }
.chat-tools > button { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 9px; color: #86868b; transition: background .15s, color .15s; }
.chat-tools > button:hover { background: rgba(255, 255, 255, .07); color: #fff; }
.chat-tools svg { width: 18px; height: 18px; }
.chat-menu { position: absolute; right: 10px; top: 52px; z-index: 2; min-width: 196px; padding: 5px; border: 1px solid rgba(255, 255, 255, .1); border-radius: 12px; background: #161618; box-shadow: 0 16px 40px -10px #000; }
.chat-menu[hidden] { display: none; }
.chat-menu button { display: block; width: 100%; padding: 9px 11px; border-radius: 8px; text-align: left; font-size: .9rem; }
.chat-menu button:hover { background: rgba(255, 255, 255, .07); }

.chat-log { flex: 1; min-height: 0; display: flex; flex-direction: column; overflow-y: auto; padding: 18px 14px 6px; scrollbar-width: thin; scrollbar-color: rgba(255, 255, 255, .15) transparent; }
.chat-home[hidden] { display: none; }

/* start screen */
.hello { position: relative; padding-left: 34px; max-width: 92%; }
.hello::before, .msg.club:not(.grp)::before { content: ""; position: absolute; left: 0; bottom: 0; width: 26px; height: 26px; border-radius: 50%; background: url(mark.svg?v=2) center / cover; }
.hello p { padding: 10px 14px; border-radius: 18px 18px 18px 6px; background: #1a1a1d; font-size: .94rem; line-height: 1.42; }
.chat-pre { display: grid; gap: 12px; margin-top: 18px; }
.pre-fields { overflow: hidden; border: 1px solid rgba(255, 255, 255, .1); border-radius: 14px; transition: border-color .15s; }
.pre-fields:focus-within { border-color: rgba(255, 255, 255, .28); }
.pre-fields label { display: grid; gap: 2px; padding: 9px 14px 10px; cursor: text; transition: background .15s; }
.pre-fields label + label { border-top: 1px solid rgba(255, 255, 255, .08); }
.pre-fields label:focus-within { background: rgba(255, 255, 255, .03); }
.pre-fields span { font-size: .72rem; font-weight: 500; color: #86868b; }
.pre-fields label:has(.bad) span { color: #ff8f8f; }
.chat-pre input, .chat-pre textarea { width: 100%; border: 0; background: none; color: var(--ink); font: 400 .98rem/1.4 var(--sans); }
.chat-pre input:focus, .chat-pre textarea:focus { outline: none; }
.chat-pre input::placeholder, .chat-pre textarea::placeholder { color: #5a5a5f; }
.chat-pre textarea { min-height: 88px; padding: 11px 14px; border: 1px solid rgba(255, 255, 255, .1); border-radius: 14px; resize: none; transition: border-color .15s; }
.chat-pre textarea:focus { border-color: rgba(255, 255, 255, .28); }
.chat-pre textarea.bad { border-color: #ff8f8f; }
.pre-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.pre-chips button { padding: 6px 11px; border: 1px solid rgba(255, 255, 255, .12); border-radius: 99px; font-size: .82rem; font-weight: 500; color: #c7c7cc; transition: background .15s, border-color .15s, color .15s; }
.pre-chips button:hover { border-color: rgba(255, 255, 255, .3); color: #fff; }
.pre-chips button[aria-pressed="true"] { border-color: #f5f5f7; background: #f5f5f7; color: #000; }
.pre-err { font-size: .84rem; color: #ff8f8f; }
.pre-err[hidden] { display: none; }
.pre-go { display: flex; justify-content: center; align-items: center; gap: 7px; height: 46px; border-radius: 12px; background: #f5f5f7; color: #000; font-size: .95rem; font-weight: 600; transition: background .15s; }
.pre-go:hover { background: #fff; }
.pre-go svg { width: 15px; height: 15px; transition: transform .3s var(--ease); }
.pre-go:hover svg { transform: translateX(3px); }
.pre-note { text-align: center; font-size: .74rem; color: #6e6e73; }
.pre-note a { color: #a1a1a6; text-decoration: underline; text-underline-offset: 2px; }

/* conversation */
.chat:not([data-ready]) .chat-form, .chat:not([data-ready]) .chat-hint { display: none; }
.day { align-self: center; margin: 0 0 8px; font-size: .72rem; color: #6e6e73; }
.msg { display: flex; flex-direction: column; max-width: 82%; margin-top: 10px; }
.msg.grp { margin-top: 3px; }
.msg p { padding: 9px 14px; border-radius: 18px; font-size: .95rem; line-height: 1.42; overflow-wrap: anywhere; white-space: pre-wrap; }
.msg small { margin: 4px 4px 0; font-size: .7rem; color: #6e6e73; }
.msg.club { position: relative; align-self: flex-start; max-width: calc(82% + 34px); padding-left: 34px; }
.msg.club:not(.grp)::before { bottom: auto; top: 2px; }
.msg.club p { border-bottom-left-radius: 6px; background: #1a1a1d; }
.msg.me { align-self: flex-end; align-items: flex-end; }
.msg.me p { border-bottom-right-radius: 6px; background: var(--acc); color: #fff; }
.msg.me.failed p { background: #3a1f24; color: #ffb4b4; cursor: pointer; }
.msg.me.failed small { color: #ff8f8f; }
.msg.sys { align-self: stretch; max-width: none; margin: 14px 0 4px; padding: 10px 12px; border: 1px solid rgba(255, 255, 255, .08); border-radius: 12px; font-size: .82rem; line-height: 1.45; color: #a1a1a6; }
.js .msg { animation: chat-in .3s var(--ease); }

.chat-form { display: flex; align-items: flex-end; gap: 8px; margin: 8px 12px 12px; padding: 5px 5px 5px 14px; border: 1px solid rgba(255, 255, 255, .12); border-radius: 16px; transition: border-color .15s; }
.chat-form:focus-within { border-color: rgba(255, 255, 255, .3); }
.chat-form textarea { flex: 1; min-width: 0; max-height: 116px; padding: 8px 0; border: 0; background: none; color: inherit; font: 400 .98rem/1.4 var(--sans); resize: none; scrollbar-width: none; }
.chat-form textarea:focus { outline: none; }
.chat-form textarea::placeholder { color: #6e6e73; }
.chat-form button { display: grid; place-items: center; flex: none; width: 36px; height: 36px; border-radius: 11px; background: var(--acc); color: #fff; transition: background .15s; }
.chat-form button:disabled { background: rgba(255, 255, 255, .07); color: #5a5a5f; cursor: default; }
.chat-form button svg { width: 17px; height: 17px; }
.chat-hint { margin: -6px 0 10px; text-align: center; font-size: .7rem; color: #5a5a5f; }
@media (hover: none) { .chat-hint { display: none; } }
.chat-offline { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 0 12px; padding: 10px 12px; border: 1px solid rgba(255, 255, 255, .1); border-radius: 12px; color: #d2d2d7; font-size: .86rem; }
.chat-offline[hidden] { display: none; }
.chat-offline button { flex: none; padding: 7px 12px; border-radius: 8px; background: #f5f5f7; color: #000; font-size: .84rem; font-weight: 600; }

@keyframes chat-in { from { opacity: 0; transform: translateY(8px); } }
@keyframes chat-dot { 0%, 60%, 100% { transform: none; opacity: .35; } 30% { transform: translateY(-3px); opacity: 1; } }

@media (max-width: 520px) {
  .chat { inset: 0; width: 100%; height: 100dvh; border: 0; border-radius: 0; transform: translateY(20px); }
  .chat-head { padding-top: max(12px, env(safe-area-inset-top)); }
  .chat-form { margin-bottom: max(12px, env(safe-area-inset-bottom)); }
  .chat-open .chat-fab, .chat-tease { display: none; }
}
