/* PrimChat v298: unified mobile theme + performance + safe cards */
:root{color-scheme:dark;--pc-bg:#070b14;--pc-card:#0f172a;--pc-card2:#111c2e;--pc-text:#e7eef8;--pc-muted:#94a3b8;--pc-line:#263448;--pc-input:#0b1321}
html,html.site-theme-dark,html[data-site-theme="dark"],html[data-theme="dark"]{background:#070b14!important;color-scheme:dark}
body,body.dark,body.site-theme-dark{background:#070b14!important;color:#e7eef8!important}
body.dark header,body.site-theme-dark header,html[data-site-theme="dark"] body header{background:rgba(8,15,28,.96)!important;border-color:#263448!important}
body.dark main,body.site-theme-dark main,html[data-site-theme="dark"] main{background:transparent!important}
/* Force dark surfaces across every section, including cards added by older builds. */
body.dark .card,body.dark .panel,body.dark .box,body.dark .section,body.dark .section-card,body.dark .content-box,body.dark .surface,body.dark .sheet,
body.dark .forum-card,body.dark .topic-list,body.dark .topic-row,body.dark .market-card,body.dark .announcement-card,body.dark .news-card,body.dark .social-card,
body.dark .feed-card,body.dark .notification-card,body.dark .friend-card,body.dark .user-card,body.dark .admin-card,body.dark .admin-section,body.dark .rules-card,
body.dark .profile-card,body.dark .profile-panel,body.dark .profile-story-block,body.dark .profile-stats div,body.dark .activity-item,body.dark .contact-chip,
body.dark .quick-panel,body.dark .quote-panel,body.dark .profile-content,body.dark .profile-sections-host,
html[data-site-theme="dark"] .card,html[data-site-theme="dark"] .panel,html[data-site-theme="dark"] .box,html[data-site-theme="dark"] .section,html[data-site-theme="dark"] .section-card,
html[data-site-theme="dark"] .content-box,html[data-site-theme="dark"] .surface,html[data-site-theme="dark"] .sheet,html[data-site-theme="dark"] .forum-card,
html[data-site-theme="dark"] .topic-list,html[data-site-theme="dark"] .topic-row,html[data-site-theme="dark"] .market-card,html[data-site-theme="dark"] .announcement-card,
html[data-site-theme="dark"] .news-card,html[data-site-theme="dark"] .social-card,html[data-site-theme="dark"] .feed-card,html[data-site-theme="dark"] .notification-card,
html[data-site-theme="dark"] .friend-card,html[data-site-theme="dark"] .user-card,html[data-site-theme="dark"] .admin-card,html[data-site-theme="dark"] .admin-section,
html[data-site-theme="dark"] .rules-card,html[data-site-theme="dark"] .profile-card,html[data-site-theme="dark"] .profile-panel,html[data-site-theme="dark"] .profile-story-block,
html[data-site-theme="dark"] .profile-stats div,html[data-site-theme="dark"] .activity-item,html[data-site-theme="dark"] .contact-chip{background:#0f172a!important;color:#e7eef8!important;border-color:#263448!important}
body.dark .card *,body.dark .panel *,body.dark .box *,body.dark .section-card *,body.dark .profile-panel *,body.dark .admin-card *{max-width:100%}
body.dark input,body.dark textarea,body.dark select,body.site-theme-dark input,body.site-theme-dark textarea,body.site-theme-dark select,
html[data-site-theme="dark"] input,html[data-site-theme="dark"] textarea,html[data-site-theme="dark"] select{background:#0b1321!important;color:#e7eef8!important;border-color:#263448!important;color-scheme:dark}
body.dark input::placeholder,body.dark textarea::placeholder,html[data-site-theme="dark"] input::placeholder,html[data-site-theme="dark"] textarea::placeholder{color:#718198!important}
body.dark a,html[data-site-theme="dark"] a{color:#dbeafe}
body.dark .muted,body.dark small,body.dark .muted-text,html[data-site-theme="dark"] .muted,html[data-site-theme="dark"] small{color:#94a3b8}
body.dark .chatbox{background:#0b1321!important;border-color:#263448!important}
body.dark #messages{background:#070b14!important}
body.dark .composer,body.dark .v27-composer,body.dark .chat-tools,body.dark .chat-topline,body.dark .replybar{background:#0b1321!important;border-color:#263448!important}
body.dark .message-body,body.dark .msg-body,body.dark .chat-bubble{background:#0f172a!important;color:#e7eef8!important;border-color:#263448!important}
body.dark .message.mine .message-body,body.dark .message.mine .msg-body{background:#172554!important}
/* Never allow any page component to create horizontal overflow. */
html,body{overflow-x:hidden!important;max-width:100vw!important}
main,header,footer,.chat-layout,.chatbox,.users-panel,.profile-shell,.profile-modern,.profile-card,.profile-content,.profile-panel,.profile-head,.profile-tabs,.profile-section-nav,
.grid,[class*="grid"],.card,.panel,.box,.section,.section-card,.content-box,.surface,.sheet{min-width:0!important;max-width:100%!important;box-sizing:border-box!important}
img,video,canvas,svg,iframe{max-width:100%!important;height:auto}
pre,code,.message-text,.post-text,.wall-post-text,.topic-title,.profile-name-row,.profile-title p{overflow-wrap:anywhere!important;word-break:break-word!important}
/* Mobile: keep the chat composer visible and reserve space for it. */
@media(max-width:700px){
  body{padding-bottom:calc(72px + env(safe-area-inset-bottom))!important}
  main{width:100%!important;padding-left:8px!important;padding-right:8px!important}
  header{width:100%!important;max-width:100%!important}
  .topnav{max-width:100vw!important;overflow-x:auto!important;overflow-y:hidden!important}
  .chat-layout{display:block!important;width:100%!important}
  .users-panel{display:none!important}
  .chatbox{width:100%!important;max-width:100%!important;margin:0!important;min-height:calc(100dvh - 150px)!important}
  #messages{width:100%!important;max-width:100%!important;min-height:calc(100dvh - 285px)!important;max-height:none!important;padding-bottom:110px!important;overflow-y:auto!important}
  .v27-composer{position:fixed!important;left:8px!important;right:8px!important;bottom:calc(64px + env(safe-area-inset-bottom))!important;width:auto!important;max-width:none!important;z-index:10000!important;margin:0!important;border:1px solid #263448!important;border-radius:16px!important;box-shadow:0 10px 35px rgba(0,0,0,.45)!important}
  .v27-composer-row{width:100%!important;min-width:0!important}
  .v27-composer textarea{min-width:0!important;width:auto!important;max-width:none!important;flex:1 1 auto!important}
  .v27-composer button{flex:0 0 auto!important}
  .mobile-nav{z-index:10001!important}
  .profile-content{display:block!important;width:100%!important}
  .profile-card,.profile-panel{width:100%!important;overflow:hidden!important}
  .profile-head{grid-template-columns:minmax(0,1fr)!important}
  .profile-head-actions,.profile-stats,.contact-list{max-width:100%!important;flex-wrap:wrap!important}
  .profile-stats{grid-template-columns:repeat(3,minmax(0,1fr))!important}
  .profile-tabs{max-width:100%!important;overflow-x:auto!important}
  .profile-tabs a{flex:0 0 auto!important}
}
@media(max-width:380px){.profile-stats{grid-template-columns:1fr!important}.profile-stats div{width:100%!important}.v27-composer{left:5px!important;right:5px!important}.v27-composer-row{gap:4px!important}}
@media(prefers-reduced-motion:reduce){*,*::before,*::after{animation-duration:.001ms!important;transition-duration:.001ms!important;scroll-behavior:auto!important}}
