/* Shared authenticated support chat. Navigation returns when the chat closes. */
.nav-support { display: grid; place-items: center; }
.nav-support::before, .nav-support::after { content: none !important; }
.nav-support svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
@media (max-width: 1099px) {
  body[data-lk-page] .bottom-nav:has([data-tab="support"]) { grid-template-columns: repeat(6,minmax(0,1fr)); gap: 2px; }
  body[data-lk-page] .bottom-nav:has([data-tab="support"]) button { min-width: 0; padding-inline: 0; font-size: clamp(8px,2.25vw,10px); letter-spacing: -.1px; }
  body[data-lk-page] .bottom-nav:has([data-tab="support"]) button > span:last-child { width: 100%; font-weight: 650; letter-spacing: -.35px; white-space: nowrap; }
  body[data-lk-page] .bottom-nav:has([data-tab="support"]) .bottom-nav-lens { left: 6px; width: calc((100% - 22px) / 6); }
}

body.cs-chat-open .bottom-nav { visibility: hidden !important; pointer-events: none !important; }
body.cs-chat-open #modalRoot.cs-modal-root[data-open="1"] {
  position: fixed; inset: auto !important; top: var(--cs-viewport-top,0px) !important; left: 0 !important; right: 0 !important;
  width: 100% !important; height: var(--cs-viewport-height,100dvh) !important; max-height: none;
  box-sizing: border-box; padding: 0 !important; z-index: 90; overflow: hidden;
  grid-template-rows: minmax(0,1fr); align-items: stretch !important; justify-items: center !important;
  background: rgba(0,7,24,.55) !important; overscroll-behavior: none;
}
#modalRoot .support-modal.modal-sheet {
  --cs-border: rgba(157,181,229,.2); --cs-muted: #9dadc6; --cs-accent: #38a6d6; --cs-surface: #0c1a33;
  display: flex; flex-direction: column; width: 100%; max-width: none; height: 100%; max-height: none;
  min-height: 0; margin: 0; padding: 0; border: 0; border-radius: 0; overflow: hidden;
  background: var(--cs-surface); scroll-padding: 0; box-sizing: border-box;
}
#modalRoot .support-modal > .modal-header {
  position: relative; top: auto; display: flex; align-items: center; flex: 0 0 auto; gap: 8px;
  margin: 0; padding: max(8px,env(safe-area-inset-top)) max(12px,env(safe-area-inset-right)) 8px max(16px,env(safe-area-inset-left));
  z-index: 2; background: var(--cs-surface); border-bottom: 1px solid var(--cs-border);
}
.support-modal .modal-header h2 { margin: 0; font-size: 19px; line-height: 1.2; }
.cs-header-actions { display: flex; align-items: center; flex: 0 0 auto; gap: 6px; }
.cs-header-actions .cs-close { display: grid; place-items: center; min-height: 44px; width: 44px; padding: 0; border: 0; border-radius: 12px; background: transparent; color: var(--cs-muted); font-size: 30px; font-weight: 400; line-height: 1; }
.cs-header-actions .cs-telegram-button { display: flex; justify-content: center; align-items: center; gap: 6px; min-height: 44px; padding: 8px 10px; border: 1px solid rgba(109,199,242,.28); border-radius: 12px; background: rgba(31,131,173,.15); color: #71c9ed; text-decoration: none; font: inherit; font-size: 12px; font-weight: 650; cursor: pointer; }
.cs-header-actions .cs-telegram-button:disabled { opacity: .5; cursor: default; }
.cs-header-actions .cs-telegram-button.is-ready { color: #fff; background: #1f83ad; }
.cs-header-actions [hidden], .cs-panel [hidden] { display: none !important; }
.cs-telegram-icon { display: inline-grid; place-items: center; width: 22px; height: 22px; }
.cs-telegram-icon svg { width: 22px; height: 22px; }
.cs-panel, .cs-panel * { box-sizing: border-box; min-width: 0; }
.cs-panel { display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; padding: 0; letter-spacing: normal; }
.cs-panel p { margin: 0; font-size: 13px; line-height: 1.45; overflow-wrap: anywhere; }
.cs-context { flex: 0 0 auto; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 3px 12px; padding: 9px max(16px,env(safe-area-inset-right)) 8px max(16px,env(safe-area-inset-left)); }
.cs-panel .cs-identity { color: var(--cs-muted); font-size: 12px; }
.cs-panel .cs-mode { font-size: 11px; color: #7ac8ae; }
.cs-panel .cs-mode[data-mode="off"] { color: #dfbc7a; }
.cs-panel > .cs-note { flex: 0 0 auto; padding: 0 max(16px,env(safe-area-inset-right)) 8px max(16px,env(safe-area-inset-left)); }
.cs-panel .cs-note { color: var(--cs-muted); font-size: 11px; }
.cs-note:empty, .cs-notice:empty { display: none; }
.cs-chat { display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; overflow: hidden; }
.cs-messages { flex: 1 1 auto; min-height: 0; max-height: none; overflow: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; display: flex; flex-direction: column; gap: 10px; padding: 12px max(14px,env(safe-area-inset-right)) 16px max(14px,env(safe-area-inset-left)); scrollbar-width: thin; }
.cs-panel .cs-empty { color: var(--cs-muted); margin: auto; padding: 28px 18px; max-width: 360px; text-align: center; font-size: 14px; }
.cs-message { flex: 0 0 auto; max-width: 88%; width: fit-content; border: 1px solid var(--cs-border); border-radius: 16px 16px 16px 4px; padding: 10px 12px; background: rgba(47,63,95,.43); align-self: flex-start; }
.cs-message.is-client { align-self: flex-end; border-radius: 16px 16px 4px 16px; background: rgba(37,110,153,.34); }
.cs-message-meta { color: var(--cs-muted); font-size: 10px; line-height: 1.4; margin-bottom: 4px; }
.cs-panel .cs-message-text { font-size: 15px; white-space: pre-wrap; line-height: 1.45; }
.cs-message-image { display: block; max-width: 100%; max-height: 300px; height: auto; border-radius: 8px; object-fit: contain; margin-top: 8px; }
.cs-form { display: flex; flex-direction: column; flex: 0 0 auto; min-height: 0; max-height: 60%; overflow: hidden; gap: 7px; margin: 0; padding: 10px max(12px,env(safe-area-inset-right)) max(10px,env(safe-area-inset-bottom)) max(12px,env(safe-area-inset-left)); border-top: 1px solid var(--cs-border); background: var(--cs-surface); overscroll-behavior: contain; }
.cs-form.has-pending { max-height: 85%; }
.cs-compose-info { display: flex; flex-direction: column; flex: 0 1 auto; min-height: 0; gap: 7px; overflow: auto; overscroll-behavior: contain; }
.cs-compose-actions { display: flex; align-items: flex-end; flex: 0 0 auto; gap: 8px; }
.cs-panel .cs-input { display: block; flex: 1 1 auto; width: 0; min-width: 0; min-height: 44px; max-height: 132px; margin: 0; resize: none; border: 1px solid var(--cs-border); border-radius: 15px; padding: 10px 12px; font: inherit; font-size: 16px; line-height: 22px; color: inherit; background: rgba(5,14,31,.55); }
.cs-input::placeholder { color: var(--cs-muted); opacity: .8; }
.cs-input:focus-visible, .cs-panel button:focus-visible, .cs-header-actions button:focus-visible, .cs-header-actions a:focus-visible { outline: 2px solid #70c8ec; outline-offset: 2px; }
.cs-panel button { font: inherit; cursor: pointer; }
.cs-panel button:disabled { cursor: default; opacity: .52; }
.cs-panel .cs-attach, .cs-panel .cs-send { position: relative; display: grid; place-items: center; flex: 0 0 44px; width: 44px; min-height: 44px; height: 44px; padding: 0; border-radius: 14px; }
.cs-attach { border: 1px solid var(--cs-border); color: #b9c9df; background: transparent; }
.cs-send { border: 1px solid rgba(109,199,242,.35); background: #1f83ad; color: #fff; }
.cs-attach svg, .cs-send svg { width: 23px; height: 23px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.cs-send.is-sending svg { visibility: hidden; }
.cs-send.is-sending::after { position: absolute; width: 17px; height: 17px; border: 2px solid rgba(255,255,255,.35); border-top-color: #fff; border-radius: 50%; content: ''; animation: cs-spin .8s linear infinite; }
.cs-retry { flex: 0 0 auto; min-height: 44px; border: 1px solid var(--cs-border); border-radius: 12px; color: inherit; background: transparent; padding: 8px 12px; font-size: 13px !important; }
.cs-panel .cs-pending { flex: 0 0 auto; color: #dfbc7a; font-size: 12px; }
.cs-panel .cs-notice { flex: 0 0 auto; color: #8fceb9; font-size: 11px; }
.cs-panel .cs-notice.is-error { color: #f0aaa3; }
.cs-previews { display: flex; flex: 0 0 auto; gap: 8px; padding: 6px 4px 0; }
.cs-preview { position: relative; width: 58px; height: 58px; flex: 0 0 58px; }
.cs-preview img { width: 100%; height: 100%; object-fit: cover; border-radius: 10px; border: 1px solid var(--cs-border); }
.cs-panel .cs-remove-image { position: absolute; top: -6px; right: -6px; display: grid; place-items: center; width: 28px; height: 28px; min-height: 28px; border-radius: 50%; border: 1px solid var(--cs-border); padding: 0; color: #fff; background: #233b5a; font-size: 21px; }
.cs-sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
.cs-keyboard-open .support-modal > .modal-header { padding-top: 6px !important; }
.cs-keyboard-open .cs-form { padding-bottom: 8px; }
.cs-keyboard-open .cs-input { max-height: 66px; }
.cs-keyboard-open .cs-preview { width: 46px; height: 46px; flex-basis: 46px; }
:root[data-theme="light"] .support-modal { --cs-border: rgba(65,99,138,.19) !important; --cs-muted: #62758a !important; --cs-surface: #f1f8ff !important; }
:root[data-theme="light"] .cs-input { background: rgba(255,255,255,.9); }
:root[data-theme="light"] .cs-message { background: #e9eff7; }
:root[data-theme="light"] .cs-message.is-client { background: #dceff8; }
:root[data-theme="light"] .cs-header-actions .cs-telegram-button { color: #19799e; }
:root[data-theme="light"] .cs-header-actions .cs-telegram-button.is-ready { color: #fff; }
:root[data-theme="light"] .cs-attach { color: #476780; }
:root[data-theme="light"] .cs-mode, :root[data-theme="light"] .cs-notice { color: #25765e; }
:root[data-theme="light"] .cs-mode[data-mode="off"], :root[data-theme="light"] .cs-pending { color: #8b6429; }
:root[data-theme="light"] .cs-notice.is-error { color: #ad3d35; }
@keyframes cs-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .cs-send.is-sending::after { animation: none; } }
@media (max-width: 359px) {
  body[data-lk-page] .bottom-nav:has([data-tab="support"]) button { font-size: 7px; }
  .cs-message { max-width: 94%; }
  .cs-messages { padding-inline: 10px; }
  .cs-compose-actions { gap: 6px; }
}
@media (min-width: 700px) {
  body.cs-chat-open #modalRoot.cs-modal-root[data-open="1"] { padding: 24px !important; align-items: center !important; }
  #modalRoot .support-modal.modal-sheet { width: min(800px,100%); max-height: 850px; border: 1px solid var(--cs-border); border-radius: 22px; }
  .cs-messages { padding: 20px 24px; }
  .cs-message { max-width: 80%; }
  .cs-panel .cs-message-text { font-size: 16px; }
  .cs-form { padding: 12px 18px max(12px,env(safe-area-inset-bottom)); }
}
@media (max-height: 440px) { .cs-panel .cs-input { max-height: 66px; } .cs-context { padding-block: 5px; } }

/* Observable support work, independent of message delivery and connection notices. */
.cs-progress { flex: 0 0 auto; align-self: center; display: grid; grid-template-columns: 7px minmax(0,1fr) auto; gap: 3px 7px; width: fit-content; max-width: 100%; margin: 2px 0 4px; padding: 7px 11px; border: 1px solid var(--cs-border); border-radius: 12px; background: rgba(56,166,214,.05); }
.cs-progress-dot { width: 7px; height: 7px; margin-top: 5px; border-radius: 50%; background: #63bfe8; }
.cs-panel .cs-progress-title { grid-column: 2; font-size: 12px; font-weight: 600; line-height: 1.35; }
.cs-panel .cs-progress-detail { grid-column: 2 / -1; color: var(--cs-muted); font-size: 11px; line-height: 1.4; }
.cs-progress-time { align-self: start; padding-top: 1px; color: var(--cs-muted); font-size: 11px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.cs-progress[data-state="answered"] .cs-progress-dot, .cs-progress[data-state="resolved"] .cs-progress-dot { background: #7ac8ae; }
.cs-progress[data-state="paused"] .cs-progress-dot, .cs-progress[data-state="waiting"] .cs-progress-dot, .cs-progress[data-state="delayed"] .cs-progress-dot { background: #dfbc7a; }
.cs-progress[data-state="unavailable"] .cs-progress-dot, .cs-progress[data-state="closed"] .cs-progress-dot { background: var(--cs-muted); }

/* Delivered reply provenance; unknown historical messages retain a neutral label. */
.cs-message-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 5px; }
.cs-message-author { font-weight: 600; }
.cs-agent-logo { display: block; flex: 0 0 16px; width: 16px; height: 16px; object-fit: contain; border-radius: 4px; background: white; }
.cs-agent-logo[data-agent="kimi"] { background: black; }
.cs-agent-logo[hidden] { display: none; }

/* Exact own-turn agent identity, including a truthful pause/last-agent state. */
.cs-panel .cs-current-agent { display: flex; align-items: center; gap: 6px; margin-top: 4px; font-size: 12px; line-height: 1.4; }
.cs-current-agent > span { min-width: 0; overflow-wrap: anywhere; }
.cs-current-agent[hidden] { display: none !important; }

/* Explicit authenticated appeal boundary; the history stays in this chat. */
.cs-new-appeal{grid-column:2/-1;justify-self:start;margin-top:8px;padding:9px 13px;border:1px solid currentColor;border-radius:10px;background:transparent;color:inherit;font:inherit;font-weight:600;cursor:pointer}
.cs-new-appeal:disabled{opacity:.55;cursor:wait}
.cs-new-appeal:focus-visible{outline:2px solid currentColor;outline-offset:3px}
.cs-new-appeal[hidden]{display:none}
