/* PrimChat final unified pass — global UX, theme and mobile containment */
:root{--pc-surface:#fff;--pc-surface2:#f7f9fc;--pc-text:#17202a;--pc-muted:#64748b;--pc-line:#dbe3ec;--pc-shadow:0 14px 45px rgba(15,23,42,.08)}
html[data-site-theme="dark"],html[data-theme="dark"],body.dark,body.site-theme-dark{--pc-surface:#111923;--pc-surface2:#0c131c;--pc-text:#eef4fb;--pc-muted:#9aacbf;--pc-line:#29394a;--pc-shadow:0 18px 55px rgba(0,0,0,.28);background:#080e16!important;color:var(--pc-text)!important}
html[data-site-theme="dark"] body,html[data-theme="dark"] body,body.dark,body.site-theme-dark{background:#080e16!important;color:var(--pc-text)!important}
html[data-site-theme="dark"] header,html[data-theme="dark"] header,body.dark header,body.site-theme-dark header,
html[data-site-theme="dark"] main .card,html[data-theme="dark"] main .card,body.dark main .card,
html[data-site-theme="dark"] .forum-card,html[data-theme="dark"] .forum-card,body.dark .forum-card,
html[data-site-theme="dark"] .topic-list,html[data-theme="dark"] .topic-list,body.dark .topic-list,
html[data-site-theme="dark"] .profile-card,html[data-theme="dark"] .profile-card,body.dark .profile-card,
html[data-site-theme="dark"] .admin-card,html[data-theme="dark"] .admin-card,body.dark .admin-card,
html[data-site-theme="dark"] .sn-card,html[data-theme="dark"] .sn-card,body.dark .sn-card,
html[data-site-theme="dark"] .news-card,html[data-theme="dark"] .news-card,body.dark .news-card,
html[data-site-theme="dark"] .market-card,html[data-theme="dark"] .market-card,body.dark .market-card,
html[data-site-theme="dark"] .rules-card,html[data-theme="dark"] .rules-card,body.dark .rules-card,
html[data-site-theme="dark"] .profile-panel,html[data-theme="dark"] .profile-panel,body.dark .profile-panel{background:var(--pc-surface)!important;color:var(--pc-text)!important;border-color:var(--pc-line)!important}
html[data-site-theme="dark"] input,html[data-site-theme="dark"] textarea,html[data-site-theme="dark"] select,html[data-theme="dark"] input,html[data-theme="dark"] textarea,html[data-theme="dark"] select,body.dark input,body.dark textarea,body.dark select{background:#0c131c!important;color:var(--pc-text)!important;border-color:var(--pc-line)!important}
html[data-site-theme="dark"] a,html[data-theme="dark"] a,body.dark a{color:#b9d8ff}
html[data-site-theme="dark"] .muted,html[data-theme="dark"] .muted,body.dark .muted,html[data-site-theme="dark"] small,html[data-theme="dark"] small,body.dark small{color:var(--pc-muted)}
html[data-site-theme="dark"] .mobile-nav{background:rgba(9,15,24,.96)!important;border-color:var(--pc-line)!important}
/* Keep chat tall and usable. */
.chat-page .chatbox{min-height:0!important;height:calc(100dvh - 190px)!important;max-height:none!important;display:flex!important;flex-direction:column!important;overflow:visible!important}
.chat-page #messages{flex:1 1 auto!important;min-height:300px!important;max-height:none!important;overflow-y:auto!important;overflow-x:hidden!important}
.chat-page .chat-topline{display:grid!important;grid-template-columns:minmax(0,1fr) auto!important;align-items:center!important;gap:8px!important;flex:0 0 auto}
.chat-page .chat-topline .chat-tools{min-width:0!important;display:flex!important;align-items:center!important;flex-wrap:nowrap!important;gap:7px!important;background:transparent!important}
.chat-page .chat-topline .chat-search{flex:1 1 420px!important;min-width:120px!important;max-width:520px!important}
.chat-page .chat-topline .chat-search input{width:100%!important;box-sizing:border-box!important}
.chat-page .chat-topline .online-slot{justify-self:end!important;min-width:0!important}
/* Reactions and actions never float outside the message bubble. */
.chat-page #messages .chat-bubble{width:fit-content!important;max-width:min(78vw,700px)!important;overflow:visible!important}
.chat-page #messages .msg-hover-tools{position:static!important;width:100%!important;max-width:100%!important;display:flex!important;flex-wrap:wrap!important;align-items:center!important;gap:4px!important;margin:6px 0 0!important;padding:0!important;border:0!important;background:transparent!important;box-shadow:none!important;transform:none!important}
.chat-page #messages .quick-reactions{position:static!important;display:flex!important;flex-wrap:wrap!important;max-width:100%!important;gap:3px!important;padding:0!important;margin:0!important;background:transparent!important;border:0!important;box-shadow:none!important}
.chat-page #messages .msg-hover-tools .reaction,.chat-page #messages .msg-hover-tools .reply-btn{flex:0 0 auto!important;max-width:100%!important;height:30px!important;min-width:30px!important;padding:3px 7px!important;border:0!important;border-radius:9px!important;background:#17263a!important;color:#e6f1ff!important;box-shadow:none!important}
.chat-page #messages .reactions{display:flex!important;flex-wrap:wrap!important;gap:3px!important;max-width:100%!important;margin-top:5px!important}
.chat-page #messages .reactions .reaction{flex:0 0 auto!important}
/* Mobile: search stays beside online indicator, not full-width. */
@media(max-width:700px){
  body{padding-bottom:70px!important}
  main{width:calc(100% - 12px)!important}
  .chat-page .chatbox{height:calc(100dvh - 112px)!important;min-height:500px!important;border-radius:16px!important}
  .chat-page .chat-topline{grid-template-columns:minmax(0,1fr) auto!important;gap:5px!important;padding:4px!important}
  .chat-page .chat-topline .chat-tools{padding:2px!important;gap:4px!important}
  .chat-page .chat-topline .chat-search{flex:1 1 auto!important;min-width:0!important;max-width:none!important}
  .chat-page .chat-topline .chat-search input{height:34px!important;font-size:13px!important;padding:6px 9px!important}
  .chat-page .chat-topline .online-slot{max-width:110px!important}
  .chat-page .chat-topline #onlineCount{height:34px!important;max-width:110px!important;padding:5px 7px!important;font-size:10px!important;white-space:nowrap!important;overflow:hidden!important;text-overflow:ellipsis!important}
  .chat-page #messages{min-height:0!important;padding:8px 6px!important}
  .chat-page #messages .chat-bubble{max-width:calc(100vw - 62px)!important;padding:9px 10px!important}
  .chat-page #messages .msg-hover-tools{opacity:1!important;pointer-events:auto!important}
  .chat-page #messages .msg-hover-tools .reaction,.chat-page #messages .msg-hover-tools .reply-btn{height:28px!important;min-width:28px!important;font-size:12px!important;padding:2px 6px!important}
  .mobile-nav{display:flex!important}
}
@media(max-width:390px){.chat-page .chat-topline #onlineCount{max-width:92px!important;font-size:9px!important}.chat-page .chat-topline .chat-search input{font-size:12px!important}}
/* Navigation badges */
.badge-count{display:inline-flex!important;align-items:center;justify-content:center;min-width:18px;height:18px;padding:0 5px;margin-left:5px;border-radius:999px;background:#ef4444;color:#fff!important;font-size:10px;font-weight:900;line-height:1;vertical-align:middle;box-shadow:0 2px 8px rgba(239,68,68,.28)}
.mobile-nav .badge-count{position:absolute;top:4px;right:calc(50% - 22px);margin:0;min-width:16px;height:16px;font-size:9px}
.mobile-nav a{position:relative}
/* Prevent long Russian labels from breaking the layout. */
header,.topnav,main,.card,.forum-card,.topic-list,.profile-card,.admin-card,.news-card,.market-card,.sn-card,.profile-panel{min-width:0;max-width:100%}
h1,h2,h3,p,b,span,a,button,label{overflow-wrap:anywhere}
