:root {
  --msg-surface: #fff;
  --msg-surface-soft: #f7f8fa;
  --msg-surface-hover: #f0f2f5;
  --msg-border: #e6e8ec;
  --msg-text: #1c2430;
  --msg-muted: #78818d;
  --msg-accent: var(--link-color, #e74c3c);
  --msg-accent-soft: rgba(231, 76, 60, .1);
}
body.night-mode {
  --msg-surface: var(--card-dark-color, #262d34);
  --msg-surface-soft: var(--card-dark-input, #1e252b);
  --msg-surface-hover: var(--card-dark-hover, #2b3843);
  --msg-border: var(--card-dark-divider, #2e3f4d);
  --msg-text: #eef2f6;
  --msg-muted: #91a0ae;
  --msg-accent-soft: rgba(231, 76, 60, .16);
}
.sgh-messenger-shell { max-width: 1500px; margin-inline: auto; }
.sgh-messenger-grid { display: grid; grid-template-columns: minmax(280px, 330px) minmax(440px, 1fr) minmax(220px, 270px); gap: 14px; align-items: stretch; min-height: 650px; }
.sgh-messenger-grid > * { min-width: 0; }
.sgh-messenger-card, .sgh-messenger-main > .card { height: 100%; border: 1px solid var(--msg-border); background: var(--msg-surface); box-shadow: none; overflow: hidden; }
.sgh-messenger-card .card-header, .sgh-messenger-main .card-header { min-height: 62px; display: flex; align-items: center; padding: 16px 18px; border-bottom: 1px solid var(--msg-border); font-size: 16px; font-weight: 700; }
.sgh-messenger-search { position: relative; padding: 12px 14px 8px; }
.sgh-messenger-search i { position: absolute; left: 28px; top: 50%; transform: translateY(-40%); color: var(--msg-muted); }
.sgh-messenger-search input { width: 100%; height: 42px; border: 1px solid transparent; border-radius: 10px; background: var(--msg-surface-soft); color: var(--msg-text); padding: 0 14px 0 40px; outline: none; }
.sgh-messenger-search input:focus { border-color: var(--msg-accent); background: var(--msg-surface); }
.sgh-messenger-filters, .sgh-recent-filters { display: flex; gap: 4px; padding: 4px 14px 10px; border-bottom: 1px solid var(--msg-border); }
.sgh-messenger-filters button, .sgh-recent-filters button { border: 0; background: transparent; color: var(--msg-muted); border-radius: 8px; padding: 7px 10px; font-size: 12px; font-weight: 700; cursor: pointer; }
.sgh-messenger-filters button.active, .sgh-recent-filters button.active { background: var(--msg-accent-soft); color: var(--msg-accent); }
.sgh-messenger-list .js_live-messages-alt ul { margin: 0; padding: 0; }
.tg-conv-item { list-style: none; display: block; }
.tg-conv-item[hidden], .sgh-recent-item[hidden] { display: none !important; }
.tg-conv-link { display: flex; align-items: center; gap: 12px; min-height: 72px; padding: 10px 14px; border-bottom: 1px solid var(--msg-border); color: var(--msg-text); text-decoration: none; transition: background-color .16s ease; }
.tg-conv-link:hover { background: var(--msg-surface-hover); color: var(--msg-text); }
.tg-conv-unread .tg-conv-link { background: var(--msg-accent-soft); }
.tg-conv-avatar { position: relative; width: 48px; height: 48px; min-width: 48px; display: block; }
.tg-conv-avatar > img { width: 48px; height: 48px; border-radius: 50%; object-fit: cover; display: block; }
.tg-conv-avatar > .tg-conv-avatar-left, .tg-conv-avatar > .tg-conv-avatar-right { position: absolute; width: 32px; height: 32px; border: 2px solid var(--msg-surface); }
.tg-conv-avatar-left { inset: 0 auto auto 0; }.tg-conv-avatar-right { inset: auto 0 0 auto; }
.tg-conv-online { position: absolute; right: 0; bottom: 1px; width: 12px; height: 12px; border: 2px solid var(--msg-surface); border-radius: 50%; background: #2ecc71; }
.tg-conv-body { display: block; min-width: 0; flex: 1; }
.tg-conv-heading, .tg-conv-summary { display: flex; align-items: center; gap: 8px; min-width: 0; }
.tg-conv-heading { justify-content: space-between; }
.tg-conv-heading .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; color: var(--msg-text); }
.tg-conv-time { color: var(--msg-muted); font-size: 11px; white-space: nowrap; }
.tg-conv-summary { margin-top: 3px; }
.tg-conv-preview { color: var(--msg-muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.tg-conv-counter { min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--msg-accent); color: #fff; font-size: 11px; font-weight: 800; display: inline-flex; align-items: center; justify-content: center; }
.sgh-messenger-main .panel-messages { border: 1px solid var(--msg-border); background: var(--msg-surface); box-shadow: none; overflow: hidden; }
.sgh-messenger-main .panel-messages .card-body { padding: 0; display: flex; flex: 1 1 auto; min-height: 0; flex-direction: column; }
.sgh-messenger-main .chat-conversations { flex: 1 1 auto; min-height: 420px; padding: 18px; background: var(--msg-surface-soft); }
.sgh-messenger-main .conversation-body .text { border-radius: 16px 16px 16px 5px; padding: 9px 13px; line-height: 1.45; box-shadow: none; }
.sgh-messenger-main .conversation.right .conversation-body .text { border-radius: 16px 16px 5px 16px; }
.sgh-messenger-main .chat-form { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 6px; min-height: 54px; margin: auto 14px 14px; padding: 5px 7px 5px 14px; border: 1px solid var(--msg-border); border-radius: 14px; background: var(--msg-surface-soft); overflow: visible; }
.sgh-messenger-main .chat-form-message { min-width: 0; }
.sgh-messenger-main .chat-form textarea { display: block; width: 100%; min-height: 38px !important; max-height: 104px; padding: 9px 2px !important; border: 0 !important; background: transparent !important; box-shadow: none !important; resize: none; line-height: 20px; }
.sgh-messenger-main .x-form-tools { display: flex; align-items: center; gap: 2px; margin: 0; padding: 0; border-top: 0; }
.sgh-messenger-main .x-form-tools li { width: 34px; height: 34px; margin: 0 !important; display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; color: var(--msg-muted); }
.sgh-messenger-main .x-form-tools li:hover { background: var(--msg-accent-soft); }
.sgh-messenger-main .x-form-tools-post { color: var(--msg-muted) !important; opacity: .48; transform: scale(.92); transition: color 150ms ease, background-color 150ms ease, opacity 150ms ease, transform 150ms ease; }
.sgh-messenger-main .chat-form.sgh-has-message .x-form-tools-post { display: inline-flex !important; background: var(--msg-accent) !important; color: #fff !important; opacity: 1; transform: scale(1); }
.sgh-messenger-main .chat-form.sgh-has-message .x-form-tools-post:hover { filter: brightness(.94); }
.sgh-messenger-main .x-form-tools-post i { transform: translateX(-1px); }
.sgh-send-options { position: absolute; right: 4px; bottom: calc(100% + 8px); z-index: 30; display: none; width: 245px; padding: 6px; border: 1px solid var(--msg-border); border-radius: 12px; background: var(--msg-surface); color: var(--msg-text); box-shadow: 0 14px 36px rgba(25, 31, 38, .18); }
.sgh-send-options.is-visible { display: block; }
.sgh-send-option { display: grid; grid-template-columns: 28px minmax(0, 1fr) auto; align-items: center; gap: 8px; width: 100%; min-height: 44px; padding: 7px 9px; border: 0; border-radius: 9px; background: transparent; color: var(--msg-text); text-align: left; }
.sgh-send-option + .sgh-send-option { margin-top: 2px; }
.sgh-send-option i { color: var(--msg-muted); text-align: center; }
.sgh-send-option span { display: flex; flex-direction: column; min-width: 0; font-size: 13px; font-weight: 700; }
.sgh-send-option small { color: var(--msg-muted); font-size: 10px; font-weight: 500; line-height: 1.25; }
.sgh-send-option em { padding: 3px 6px; border-radius: 7px; background: var(--msg-surface-hover); color: var(--msg-muted); font-size: 9px; font-style: normal; font-weight: 700; }
.sgh-send-option[disabled] { cursor: default; opacity: .72; }
body.night-mode .sgh-send-options { box-shadow: 0 16px 42px rgba(0, 0, 0, .38); }
.sgh-messenger-recent .sgh-messenger-card { height: auto; min-height: 310px; }
.sgh-messenger-main .panel-messages .card-header .row { width: 100%; display: flex; align-items: center; flex-wrap: nowrap; }
.sgh-messenger-main .panel-messages .card-header .row > div:first-child { width: auto; flex: 1 1 auto; min-width: 0; margin-bottom: 0 !important; }
.sgh-messenger-main .panel-messages .card-header .row > div:last-child { width: auto; flex: 0 0 auto; white-space: nowrap; }
.sgh-recent-filters { flex-direction: column; align-items: stretch; padding: 10px; }
.sgh-recent-filters button { text-align: left; }
.sgh-recent-list { padding: 5px 10px 12px; }
.sgh-recent-item { display: flex; align-items: center; gap: 10px; color: var(--msg-text); padding: 9px 8px; border-radius: 9px; text-decoration: none; }
.sgh-recent-item:hover { background: var(--msg-surface-hover); color: var(--msg-text); }
.sgh-recent-item.tg-conv-unread { background: var(--msg-accent-soft); }
.sgh-recent-avatar { position: relative; width: 34px; height: 34px; min-width: 34px; }
.sgh-recent-avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
.sgh-recent-avatar i { position: absolute; right: -1px; bottom: -1px; width: 9px; height: 9px; border: 2px solid var(--msg-surface); border-radius: 50%; background: #2ecc71; }
.sgh-recent-copy { min-width: 0; flex: 1; display: flex; flex-direction: column; }
.sgh-recent-copy strong, .sgh-recent-copy small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sgh-recent-copy strong { font-size: 13px; }.sgh-recent-copy small { color: var(--msg-muted); font-size: 10px; }
.sgh-recent-arrow { color: var(--msg-muted); font-size: 10px; }
.sgh-recent-empty { color: var(--msg-muted); font-size: 12px; padding: 18px 8px; text-align: center; }
@media (max-width: 1199px) { .sgh-messenger-grid { grid-template-columns: minmax(270px, 320px) minmax(0, 1fr); } .sgh-messenger-recent { display: none; } }
@media (max-width: 767px) { .sgh-messenger-shell { margin-top: 10px !important; } .sgh-messenger-grid { display: block; min-height: 600px; } .sgh-messenger-list, .sgh-messenger-main { width: 100%; } .sgh-messenger-main .chat-conversations { min-height: 390px; } .sgh-messenger-main .chat-form { margin-inline: 8px; padding-left: 10px; } .sgh-messenger-main .x-form-tools-attach, .sgh-messenger-main .x-form-tools-colors { display: none !important; } }
@media (prefers-reduced-motion: reduce) { .tg-conv-link, .sgh-recent-item { transition: none; } }
