/* Copyright © 2026 MELDIX. TrioSoft. All rights reserved. */
/* TrioSoft OS — global community chat (bottom-right of the desktop) */

.os-chat.open { z-index: 890; }
.os-chat { --chat-right: 16px; --chat-bottom: calc(var(--os-dock-h) + 26px); position: fixed; right: var(--chat-right); bottom: var(--chat-bottom); z-index: 880; font-family: var(--os-ui); }
body.has-os-chat .arsyusha-root:not(.left) { bottom: calc(var(--os-dock-h) + 26px + 66px); transition: opacity .2s var(--os-ease), transform .3s var(--os-out); }
body.os-chat-open .arsyusha-root { opacity: 0; pointer-events: none; transform: translateY(8px); }

/* ---------- launcher ---------- */
.os-chat-launcher {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  height: 54px;
  padding: 0 14px 0 7px;
  border: 0;
  border-radius: 18px;
  color: var(--os-ink);
  background: color-mix(in srgb, var(--os-window) 86%, transparent);
  -webkit-backdrop-filter: blur(18px) saturate(1.6);
  backdrop-filter: blur(18px) saturate(1.6);
  box-shadow: var(--os-pop-shadow);
  cursor: pointer;
  transition: transform .35s var(--os-spring), box-shadow .2s var(--os-ease);
}
.os-chat-launcher:hover { transform: translateY(-3px); }
.os-chat-launcher:focus-visible { outline: 2px solid var(--os-accent); outline-offset: 3px; }
.os-chat.open .os-chat-launcher { box-shadow: var(--os-pop-shadow), 0 0 0 2px var(--os-accent); }
.os-chat-launcher-icon {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 13px;
  color: #fff;
  background: linear-gradient(145deg, var(--os-coral), var(--os-violet) 60%, #4b6bff);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .35), 0 8px 16px -8px rgba(var(--os-violet-rgb), .9);
}
.os-chat-launcher-icon .ui-icon { width: 20px; height: 20px; }
.os-chat-launcher-copy { display: grid; gap: 1px; text-align: left; line-height: 1.15; }
.os-chat-launcher-copy strong { font-family: var(--os-display); font-size: 14px; font-weight: 750; letter-spacing: -.01em; }
.os-chat-launcher-copy small { display: inline-flex; align-items: center; gap: 5px; color: var(--os-ink-3); font-size: 11.5px; white-space: nowrap; }
.os-chat-launcher-copy small i, .os-chat-online-pill i { width: 7px; height: 7px; border-radius: 50%; background: var(--os-success); box-shadow: 0 0 0 3px rgba(15, 180, 137, .18); }
.os-chat-faces { display: flex; padding-left: 4px; }
.os-chat-faces:empty { display: none; }
.os-chat-faces .deco-avatar { margin-left: -7px; }
.os-chat-faces .deco-face { box-shadow: 0 0 0 2px var(--os-window); }
.os-chat-faces .deco-layer { display: none; }
.os-chat-unread {
  position: absolute;
  top: -7px;
  right: -6px;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 11px;
  color: #fff;
  background: var(--os-danger);
  box-shadow: 0 0 0 3px var(--os-wall);
  font: 800 11.5px/22px var(--os-ui);
  text-align: center;
  animation: os-pop .35s var(--os-spring);
}
.os-chat.has-unread .os-chat-launcher-icon { animation: os-chat-nudge 2.8s var(--os-ease) infinite; }
@keyframes os-chat-nudge { 0%, 70%, 100% { transform: none; } 76% { transform: rotate(-9deg) scale(1.06); } 84% { transform: rotate(7deg) scale(1.06); } 92% { transform: rotate(-3deg); } }

/* ---------- panel ---------- */
.os-chat-panel {
  position: absolute;
  right: 0;
  bottom: 66px;
  display: flex;
  flex-direction: column;
  width: min(410px, calc(100vw - 32px));
  height: min(640px, calc(100vh - var(--os-bar-h) - var(--os-dock-h) - 120px));
  min-height: 360px;
  overflow: hidden;
  border-radius: var(--os-r-win);
  background: var(--os-window);
  box-shadow: var(--os-pop-shadow);
  transform-origin: bottom right;
  animation: os-chat-in .42s var(--os-out);
}
.os-chat-panel[hidden] { display: none; }
.os-chat.max .os-chat-panel { width: min(760px, calc(100vw - 32px)); height: calc(100vh - var(--os-bar-h) - var(--os-dock-h) - 110px); }
@keyframes os-chat-in { from { opacity: 0; transform: translateY(14px) scale(.96); } }

.os-chat-titlebar { position: relative; display: flex; align-items: center; gap: 10px; min-height: 42px; padding: 0 12px; border-bottom: 1px solid var(--os-line); background: var(--os-pane); }
.os-chat-titlebar .os-title { position: absolute; left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 4px; font-family: var(--os-display); font-size: 13.5px; font-weight: 750; white-space: nowrap; }
.os-chat-hash { color: var(--os-ink-3); font-size: 17px; font-weight: 600; }
.os-chat-online-pill { display: inline-flex; align-items: center; gap: 6px; margin-left: auto; padding: 3px 9px; border-radius: var(--os-pill); color: var(--os-ink-2); background: var(--os-hover); font-size: 11.5px; font-weight: 600; }
.os-chat-topic { display: flex; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; align-items: center; gap: 8px; padding: 8px 14px; border-bottom: 1px solid var(--os-line); color: var(--os-ink-3); font-size: 12px; line-height: 1.35; }
.os-chat-topic .ui-icon { width: 15px; height: 15px; flex: none; }

.os-chat-scroll { position: relative; flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 6px 0 14px; scrollbar-width: thin; scrollbar-color: var(--os-line-2) transparent; }
.os-chat-scroll:focus { outline: none; }
.os-chat-intro { display: grid; justify-items: start; gap: 6px; padding: 18px 16px 10px; }
.os-chat-intro.hidden { display: none; }
.os-chat-intro-mark { display: grid; place-items: center; width: 54px; height: 54px; margin-bottom: 4px; border-radius: 50%; color: #fff; background: linear-gradient(145deg, var(--os-coral), var(--os-violet) 58%, var(--os-mint)); font: 800 30px/1 var(--os-display); }
.os-chat-intro h3 { margin: 0; font-family: var(--os-display); font-size: 19px; font-weight: 800; letter-spacing: -.02em; }
.os-chat-intro p { margin: 0; color: var(--os-ink-2); font-size: 13px; line-height: 1.45; }
.os-chat-older { display: flex; align-items: center; justify-content: center; gap: 6px; margin: 8px auto; padding: 6px 12px; border: 0; border-radius: var(--os-pill); color: var(--os-ink-2); background: var(--os-hover); font: 600 12px var(--os-ui); cursor: pointer; }
.os-chat-older:hover { background: var(--os-hover-2); color: var(--os-ink); }
.os-chat-older .ui-icon { width: 14px; height: 14px; }
.os-chat-older.hidden, .os-chat .hidden { display: none !important; }

/* day divider */
.chat-day { display: flex; align-items: center; gap: 10px; margin: 16px 14px 6px; color: var(--os-ink-3); font-size: 11px; font-weight: 700; letter-spacing: .02em; }
.chat-day::before, .chat-day::after { content: ''; flex: 1; height: 1px; background: var(--os-line); }

/* messages */
.chat-msg { position: relative; display: grid; grid-template-columns: 46px minmax(0, 1fr); column-gap: 10px; padding: 2px 14px 2px 12px; transition: background-color .15s; }
.chat-msg.head { margin-top: 10px; padding-top: 4px; }
.chat-msg:hover { background: var(--os-hover); }
.chat-msg.mention { background: rgba(255, 178, 63, .09); box-shadow: inset 2px 0 0 var(--os-amber); }
.chat-msg.mention:hover { background: rgba(255, 178, 63, .14); }
.chat-msg.pending { opacity: .5; }
.chat-msg.flash { animation: os-chat-flash 1.6s var(--os-ease); }
@keyframes os-chat-flash { 0%, 40% { background: rgba(var(--os-accent-rgb), .18); } }
.chat-avatar { grid-row: span 2; padding-top: 2px; justify-self: center; }
.chat-avatar .deco-avatar { --deco-size: 38px; }
.chat-gutter-time { align-self: center; justify-self: center; color: var(--os-ink-3); font: 500 10px/1 var(--os-mono); opacity: 0; transition: opacity .12s; }
.chat-msg:hover .chat-gutter-time { opacity: 1; }
.chat-body { min-width: 0; }
.chat-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 5px 7px; min-height: 20px; }
.chat-name { color: color-mix(in srgb, var(--chat-name, var(--os-ink)) 62%, var(--os-ink)); font-size: 14px; font-weight: 750; text-decoration: none; }
a.chat-name:hover { text-decoration: underline; }
.chat-meta time { color: var(--os-ink-3); font-size: 11px; }
.chat-badge { display: inline-grid; place-items: center; height: 16px; padding: 0 5px; border-radius: 5px; color: #fff; font: 800 9.5px/16px var(--os-ui); letter-spacing: .04em; }
.chat-badge.role-moderator { background: #2f9bff; }
.chat-badge.role-developer { background: var(--os-violet); }
.chat-badge.role-tester { background: var(--os-mint); }
.chat-badge.premium { padding: 0 3px; color: #8a5a00; background: linear-gradient(135deg, #fff1a8, #ffc93c); }
.chat-badge.premium .ui-icon { width: 11px; height: 11px; }
.chat-text { color: var(--os-ink); font-size: 14.5px; line-height: 1.45; overflow-wrap: anywhere; white-space: normal; }
.chat-text a { color: var(--os-accent); text-decoration: none; }
.chat-text a:hover { text-decoration: underline; }
.chat-text.jumbo { font-size: 36px; line-height: 1.25; }
.chat-mention { padding: 0 3px; border-radius: 4px; color: var(--os-accent); background: rgba(var(--os-accent-rgb), .14); font-weight: 600; }
.chat-mention.self { color: #9a6200; background: rgba(255, 178, 63, .24); }
:root[data-theme="dark"] .chat-mention.self { color: #ffc861; }

.chat-reply-ref { grid-column: 2; position: relative; display: flex; align-items: center; gap: 6px; min-width: 0; margin: 2px 0 1px; color: var(--os-ink-3); font-size: 12.5px; cursor: pointer; }
.chat-reply-ref b { flex: none; color: var(--os-ink-2); font-weight: 700; }
.chat-reply-ref span:not(.chat-reply-curve) { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-reply-ref:hover span:not(.chat-reply-curve) { color: var(--os-ink); }
.chat-reply-curve { position: absolute; left: -36px; top: 50%; width: 30px; height: 12px; border: 2px solid var(--os-line-2); border-right: 0; border-bottom: 0; border-top-left-radius: 7px; }

.chat-actions { position: absolute; top: -13px; right: 12px; z-index: 2; display: flex; gap: 2px; padding: 2px; border-radius: 9px; background: var(--os-window); box-shadow: var(--os-soft-shadow), 0 0 0 1px var(--os-line); opacity: 0; transform: translateY(3px); pointer-events: none; transition: opacity .12s, transform .12s; }
.chat-actions:empty { display: none; }
.chat-msg:hover .chat-actions, .chat-msg:focus-within .chat-actions { opacity: 1; transform: none; pointer-events: auto; }
.chat-actions button { display: grid; place-items: center; width: 28px; height: 26px; border: 0; border-radius: 7px; color: var(--os-ink-2); background: transparent; cursor: pointer; }
.chat-actions button:hover { color: var(--os-ink); background: var(--os-hover-2); }
.chat-actions button.danger:hover { color: #fff; background: var(--os-danger); }
.chat-actions .ui-icon { width: 15px; height: 15px; }
.chat-actions [data-chat-reply] .ui-icon { transform: scaleY(-1) rotate(-30deg); }

.os-chat-jump { position: absolute; left: 50%; bottom: 138px; z-index: 3; display: inline-flex; align-items: center; gap: 6px; padding: 7px 13px; border: 0; border-radius: var(--os-pill); color: #fff; background: var(--os-accent); box-shadow: 0 10px 22px -10px rgba(var(--os-accent-rgb), .9); font: 700 12px var(--os-ui); transform: translateX(-50%); cursor: pointer; animation: os-pop .3s var(--os-spring); }
.os-chat-jump .ui-icon { width: 14px; height: 14px; }

/* composer */
.os-chat-composer { position: relative; padding: 8px 12px 10px; border-top: 1px solid var(--os-line); background: var(--os-window); }
.chat-replying { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 0 0 6px; padding: 6px 8px 6px 12px; border-radius: 10px; color: var(--os-ink-2); background: var(--os-pane); font-size: 12.5px; }
.chat-replying b { color: var(--os-ink); }
.chat-replying button { display: grid; place-items: center; width: 24px; height: 24px; border: 0; border-radius: 50%; color: var(--os-ink-2); background: var(--os-hover-2); cursor: pointer; }
.chat-replying .ui-icon { width: 12px; height: 12px; }
.chat-form { position: relative; display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: end; gap: 8px; }
.chat-form-avatar { padding-bottom: 6px; }
.chat-form-avatar .deco-layer { display: none; }
.chat-input-wrap { position: relative; display: block; min-width: 0; border-radius: 13px; background: var(--os-pane); box-shadow: inset 0 0 0 1px var(--os-line); transition: box-shadow .15s; }
.chat-input-wrap:focus-within { box-shadow: inset 0 0 0 1.5px var(--os-accent), 0 0 0 4px rgba(var(--os-accent-rgb), .12); }
.chat-input-wrap textarea { display: block; width: 100%; min-height: 42px; max-height: 120px; padding: 11px 44px 10px 13px; border: 0; outline: 0; resize: none; color: var(--os-ink); background: transparent; font: 14.5px/1.4 var(--os-ui); }
.chat-input-wrap textarea::placeholder { color: var(--os-ink-3); }
.chat-counter { position: absolute; right: 10px; bottom: 11px; color: var(--os-ink-3); font: 600 11px/1 var(--os-mono); }
.chat-counter.low { color: var(--os-danger); }
.chat-tools { display: flex; align-items: center; gap: 4px; padding-bottom: 2px; }
.chat-tool, .chat-send { display: grid; place-items: center; width: 38px; height: 38px; border: 0; border-radius: 12px; cursor: pointer; transition: transform .2s var(--os-spring), background-color .15s, opacity .15s; }
.chat-tool { font-size: 19px; background: transparent; filter: grayscale(.4); }
.chat-tool:hover, .chat-tool[aria-expanded="true"] { background: var(--os-hover-2); filter: none; transform: scale(1.08); }
.chat-send { color: #fff; background: linear-gradient(180deg, color-mix(in srgb, var(--os-accent) 82%, white), var(--os-accent)); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .3), 0 8px 18px -8px rgba(var(--os-accent-rgb), .85); }
.chat-send:hover:not(:disabled) { transform: translateY(-1px); }
.chat-send:disabled { opacity: .38; cursor: default; box-shadow: none; }
.chat-send .ui-icon { width: 18px; height: 18px; }
.chat-emoji { position: absolute; right: 0; bottom: calc(100% + 8px); z-index: 4; display: grid; grid-template-columns: repeat(8, 34px); gap: 2px; padding: 8px; border-radius: 14px; background: var(--os-window); box-shadow: var(--os-pop-shadow); animation: os-pop .22s var(--os-out); }
.chat-emoji button { width: 34px; height: 34px; border: 0; border-radius: 9px; background: transparent; font-size: 20px; cursor: pointer; transition: transform .15s var(--os-spring); }
.chat-emoji button:hover { background: var(--os-hover-2); transform: scale(1.18); }
.chat-hint { display: flex; justify-content: space-between; gap: 10px; margin-top: 6px; padding: 0 2px; color: var(--os-ink-3); font-size: 11px; }
.chat-hint span { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }
.chat-hint .ui-icon { width: 12px; height: 12px; }
.chat-hint kbd { padding: 0 4px; border-radius: 4px; background: var(--os-hover-2); font: 600 10px/16px var(--os-mono); }
.chat-notice { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 12px; color: var(--os-ink-2); background: var(--os-pane); font-size: 13px; }
.chat-notice > .ui-icon { width: 18px; height: 18px; flex: none; }
.chat-notice.guest > span { display: grid; place-items: center; width: 36px; height: 36px; flex: none; border-radius: 11px; color: #fff; background: linear-gradient(145deg, var(--os-violet), var(--os-mint)); }
.chat-notice.guest > span .ui-icon { width: 18px; height: 18px; }
.chat-notice.guest div { display: grid; flex: 1; gap: 1px; min-width: 0; }
.chat-notice.guest strong { color: var(--os-ink); font-size: 13.5px; }
.chat-notice.guest small { color: var(--os-ink-3); font-size: 12px; }
.chat-notice .button { min-height: 34px; padding: 0 14px; }

.os-chat-toast { position: absolute; left: 50%; bottom: 120px; z-index: 5; max-width: calc(100% - 40px); padding: 9px 14px; border-radius: 12px; color: #fff; background: rgba(20, 17, 24, .92); font-size: 13px; text-align: center; opacity: 0; transform: translate(-50%, 8px); pointer-events: none; transition: opacity .2s, transform .25s var(--os-out); }
.os-chat-toast.show { opacity: 1; transform: translate(-50%, 0); }

.os-chat .visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- small screens ---------- */
@media (max-width: 720px) {
  .os-chat-launcher { height: 50px; padding: 0 5px; }
  .os-chat-launcher-copy, .os-chat-faces { display: none; }
  .os-chat-launcher-icon { width: 40px; height: 40px; }
  body.has-os-chat .arsyusha-root:not(.left) { bottom: calc(var(--os-dock-h) + 26px + 60px); }
  .os-chat-panel, .os-chat.max .os-chat-panel { position: fixed; inset: calc(var(--os-bar-h) + 8px) 8px 8px; width: auto; height: auto; min-height: 0; }
  .os-chat.open .os-chat-launcher { opacity: 0; pointer-events: none; }
  .chat-hint span:first-child { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .os-chat-panel, .os-chat-launcher-icon, .os-chat-unread { animation: none !important; }
}
