/* BolsaHoy community — mobile chat-first layout.
   This file is intentionally loaded after the shared mobile polish so the
   community page owns its mobile layout without changing desktop. */

@media (max-width: 768px) {
  html,
  body {
    max-width: 100%;
    overflow-x: clip;
  }

  body[data-community-focus="true"] main.shell {
    width: calc(100% - 24px) !important;
    max-width: 100% !important;
    min-width: 0 !important;
    padding-bottom: 24px;
  }

  body[data-community-focus="true"] .comm-hero {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) !important;
    width: 100% !important;
    min-height: 0 !important;
    margin-bottom: 10px;
    padding: 14px !important;
    border-radius: 18px;
    background: radial-gradient(circle at 100% 0%, rgba(31,128,255,.2), transparent 44%), linear-gradient(145deg, rgba(8,24,50,.98), rgba(6,15,30,.98));
  }

  [data-theme="light"] body[data-community-focus="true"] .comm-hero {
    background: radial-gradient(circle at 100% 0%, rgba(31,128,255,.16), transparent 44%), linear-gradient(145deg, #f8fbff, #eaf3ff);
  }

  body[data-community-focus="true"] .comm-hero > div:first-child,
  body[data-community-focus="true"] .comm-shell,
  body[data-community-focus="true"] .comm-main,
  body[data-community-focus="true"] #chatSection.layout,
  body[data-community-focus="true"] #threads.sidebar,
  body[data-community-focus="true"] .chat {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
  }

  body[data-community-focus="true"] .comm-hero h1 {
    margin: 7px 0 0;
    font-size: 25px !important;
    line-height: 1.04;
    letter-spacing: -.04em;
  }

  body[data-community-focus="true"] .comm-live-badge {
    min-height: 22px;
    padding-inline: 8px;
    font-size: 9px;
  }

  body[data-community-focus="true"] .comm-hero > div:first-child > p,
  body[data-community-focus="true"] .comm-hero-side,
  body[data-community-focus="true"] .comm-chips,
  body[data-community-focus="true"] .comm-nav,
  body[data-community-focus="true"] .comm-metrics,
  body[data-community-focus="true"] #commPanelLive,
  body[data-community-focus="true"] #commPanelExplore,
  body[data-community-focus="true"] #commPanelMine,
  body[data-community-focus="true"] #commPanelRecent,
  body[data-community-focus="true"] .comm-right {
    display: none !important;
  }

  /* La regla tablet del layout antiguo usa #chatSection > .comm-right y
     tiene más especificidad; la ocultamos explícitamente para que en móvil
     la conversación sea la única superficie principal. */
  body[data-community-focus="true"] #chatSection.layout > .comm-right {
    display: none !important;
  }

  body[data-community-focus="true"] .comm-search-wrap {
    margin-top: 11px;
  }

  body[data-community-focus="true"] .comm-search {
    min-height: 44px;
    border-radius: 13px;
  }

  body[data-community-focus="true"] .comm-search input {
    min-width: 0;
    font-size: 14px;
  }

  body[data-community-focus="true"] .comm-shell,
  body[data-community-focus="true"] .comm-main {
    display: block !important;
  }

  body[data-community-focus="true"] #chatSection.layout {
    display: flex !important;
    flex-direction: column !important;
    gap: 8px !important;
    min-height: 0 !important;
  }

  body[data-community-focus="true"] #threads.sidebar {
    position: relative;
    z-index: 4;
    order: 0;
    display: flex !important;
    flex-direction: column;
    height: auto !important;
    min-height: 0 !important;
    max-height: none !important;
    margin: 0;
    padding: 8px;
    overflow: visible;
    border: 1px solid rgba(124,190,255,.18);
    border-radius: 16px;
    background: rgba(8,20,39,.9);
    box-shadow: 0 10px 24px rgba(0,0,0,.14);
  }

  [data-theme="light"] body[data-community-focus="true"] #threads.sidebar {
    border-color: rgba(31,128,255,.15);
    background: rgba(255,255,255,.9);
    box-shadow: 0 10px 24px rgba(36,88,145,.1);
  }

  body[data-community-focus="true"] .threads-view-toggle {
    display: flex !important;
    flex: 0 0 auto;
    width: 100%;
    margin: 0 0 8px;
    padding: 3px;
    border-radius: 11px;
  }

  body[data-community-focus="true"] .threads-view-btn {
    min-height: 32px;
    padding: 0 8px;
    border-radius: 8px;
    font-size: 11px;
  }

  body[data-community-focus="true"] #threadsDefaultView,
  body[data-community-focus="true"] #threadsDynamicView:not([hidden]) {
    display: block !important;
    width: 100%;
    min-width: 0;
  }

  body[data-community-focus="true"] #threadsDefaultView > div:first-child,
  body[data-community-focus="true"] #threadsDynamicList {
    display: flex !important;
    align-items: stretch;
    gap: 7px;
    width: 100%;
    min-width: 0;
    overflow-x: auto;
    overflow-y: hidden;
    padding-bottom: 2px;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }

  body[data-community-focus="true"] #threadsDefaultView > div:first-child::-webkit-scrollbar,
  body[data-community-focus="true"] #threadsDynamicList::-webkit-scrollbar {
    display: none;
  }

  body[data-community-focus="true"] #threadsDefaultView h3,
  body[data-community-focus="true"] #threadsDynamicView h3,
  body[data-community-focus="true"] #threadsDefaultView > div:nth-child(2),
  body[data-community-focus="true"] .threads-mini-leaderboard {
    display: none !important;
  }

  body[data-community-focus="true"] .sidebar .thread {
    flex: 0 0 auto;
    width: auto;
    min-width: 104px;
    height: 48px;
    min-height: 48px;
    padding: 0 10px;
    gap: 7px;
    border: 1px solid rgba(var(--fg-rgb),.09);
    border-radius: 12px;
    background: rgba(var(--fg-rgb),.045);
    font-size: 12px;
  }

  body[data-community-focus="true"] .sidebar .thread.active {
    border-color: rgba(31,128,255,.42);
    background: linear-gradient(135deg, rgba(31,128,255,.2), rgba(31,128,255,.08));
    box-shadow: inset 0 1px 0 rgba(255,255,255,.1);
  }

  body[data-community-focus="true"] .sidebar .thread small {
    display: block;
    font-size: 9px;
  }

  body[data-community-focus="true"] .chat {
    order: 1;
    height: min(700px, calc(100dvh - 218px)) !important;
    min-height: 500px !important;
    overflow: hidden !important;
    border-radius: 18px;
    border-color: rgba(124,190,255,.18);
    background: rgba(7,18,36,.96);
    box-shadow: 0 14px 32px rgba(0,0,0,.18);
  }

  [data-theme="light"] body[data-community-focus="true"] .chat {
    border-color: rgba(31,128,255,.14);
    background: rgba(255,255,255,.96);
    box-shadow: 0 14px 32px rgba(36,88,145,.1);
  }

  body[data-community-focus="true"] .chat-head {
    flex: 0 0 auto;
    min-height: 58px;
    padding: 9px 11px;
  }

  body[data-community-focus="true"] .chat-head h2 {
    max-width: 190px;
    overflow: hidden;
    font-size: 15px;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  body[data-community-focus="true"] .chat-head p {
    font-size: 10px;
  }

  body[data-community-focus="true"] .chat-room-icon {
    width: 32px;
    height: 32px;
    flex-basis: 32px;
    border-radius: 10px;
  }

  body[data-community-focus="true"] .room-save-btn {
    display: none;
  }

  body[data-community-focus="true"] #reloadBtn {
    width: 34px;
    min-width: 34px;
    height: 34px;
  }

  body[data-community-focus="true"] .posts {
    flex: 1 1 auto;
    min-height: 0;
    padding: 12px 10px;
    overflow-y: auto;
    overscroll-behavior: contain;
  }

  body[data-community-focus="true"] .post {
    max-width: 96%;
    margin-bottom: 11px;
  }

  body[data-community-focus="true"] .message-bubble {
    max-width: calc(100vw - 100px);
    font-size: 14px;
    overflow-wrap: anywhere;
  }

  body[data-community-focus="true"] .chat-chart {
    flex: 0 0 auto;
    margin: 0 9px 7px;
    overflow: hidden;
    border: 1px solid rgba(31,128,255,.18);
    border-radius: 14px;
    background: rgba(31,128,255,.055);
  }

  body[data-community-focus="true"] .chat-chart-toggle {
    min-height: 44px;
    padding: 0 12px;
    font-size: 12px;
  }

  body[data-community-focus="true"] .chat-chart-panel {
    max-height: 360px;
    padding: 9px;
    overflow: auto;
  }

  body[data-community-focus="true"] #chatChartTabs {
    display: none;
  }

  body[data-community-focus="true"] #chatChartWidget {
    min-height: 250px;
  }

  body[data-community-focus="true"] .replying,
  body[data-community-focus="true"] .composer-preview {
    flex: 0 0 auto;
    margin-inline: 10px;
    padding-inline: 0;
  }

  body[data-community-focus="true"] #postForm {
    flex: 0 0 auto;
    position: relative;
    width: 100% !important;
    margin: 0 !important;
    padding: 7px 8px calc(7px + env(safe-area-inset-bottom));
    border-right: 0;
    border-bottom: 0;
    border-left: 0;
    border-radius: 0;
    background: rgba(7,18,36,.98);
  }

  [data-theme="light"] body[data-community-focus="true"] #postForm {
    background: rgba(255,255,255,.98);
  }

  body[data-community-focus="true"] .composer-field {
    min-width: 0;
  }

  body[data-community-focus="true"] .composer-field #postBody {
    min-height: 36px;
    font-size: 14px;
  }
}

/* Mobile v9: identidad del activo y widgets contenidos en el ancho disponible. */
@media (max-width: 768px) {
  body[data-community-focus="true"] #chatSection.layout > #chatChart:not([hidden]) .chat-chart-title {
    display: flex;
    align-items: center;
    min-width: 0;
    gap: 9px;
  }

  body[data-community-focus="true"] #chatSection.layout > #chatChart:not([hidden]) .chat-chart-asset-logo {
    display: grid;
    place-items: center;
    flex: 0 0 34px;
    width: 34px;
    height: 34px;
    overflow: hidden;
    border: 1px solid rgba(31,128,255,.22);
    border-radius: 11px;
    background: rgba(31,128,255,.12);
  }

  body[data-community-focus="true"] .chat-chart-asset-logo .bh-asset-logo,
  body[data-community-focus="true"] .chat-chart-asset-logo .bh-asset-logo img {
    display: block;
    width: 100%;
    height: 100%;
  }

  body[data-community-focus="true"] .chat-chart-asset-logo .bh-asset-logo {
    border-radius: 10px;
  }

  body[data-community-focus="true"] .chat-chart-copy {
    display: grid;
    min-width: 0;
    gap: 2px;
    text-align: left;
  }

  body[data-community-focus="true"] .chat-chart-copy strong,
  body[data-community-focus="true"] .chat-chart-copy small {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  body[data-community-focus="true"] .chat-chart-copy strong {
    color: var(--bh-ink, var(--fg));
    font-size: 13px;
    line-height: 1.1;
  }

  body[data-community-focus="true"] .chat-chart-copy small {
    color: var(--bh-ink-muted, rgba(var(--fg-rgb), .56));
    font-size: 10px;
    font-weight: 600;
    line-height: 1.1;
  }

  body[data-community-focus="true"] #chatChartPanel {
    min-width: 0;
    max-width: 100%;
    overflow-x: hidden !important;
  }

  body[data-community-focus="true"] #chatChartPanel .bh-tv-company-grid {
    display: block;
    min-width: 0;
    max-width: 100%;
    padding: 0;
    overflow: hidden;
  }

  body[data-community-focus="true"] #chatChartPanel .bh-tv-widget {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box;
    overflow: hidden;
    border-radius: 12px;
  }

  body[data-community-focus="true"] #chatChartPanel #chatChartWidget {
    --tv-mobile-height: 320px;
    height: 320px !important;
    min-height: 320px !important;
    padding: 5px !important;
  }

  body[data-community-focus="true"] #chatChartPanel #chatChartTechnical {
    --tv-mobile-height: 350px;
    height: 350px !important;
    min-height: 350px !important;
    padding: 5px !important;
  }

  body[data-community-focus="true"] #chatChartPanel #chatChartProfile {
    --tv-mobile-height: 250px;
    height: 250px !important;
    min-height: 250px !important;
    padding: 5px !important;
  }

  body[data-community-focus="true"] #chatChartPanel #chatChartFundamentals {
    --tv-mobile-height: 350px;
    height: 350px !important;
    min-height: 350px !important;
    padding: 5px !important;
  }

  [data-theme="light"] body[data-community-focus="true"] #chatSection.layout > #chatChart:not([hidden]) .chat-chart-asset-logo {
    border-color: rgba(31,128,255,.18);
    background: rgba(31,128,255,.08);
  }
}

/* Mobile v6: lista de salas clara, sin carruseles horizontales. */
@media (max-width: 768px) {
  /* Orden móvil: hero/buscador → foro → datos del activo → salas. */
  body[data-community-focus="true"] #chatSection.layout > .chat {
    order: 0 !important;
  }

  body[data-community-focus="true"] #chatSection.layout > #chatChart:not([hidden]) {
    order: 1 !important;
  }

  body[data-community-focus="true"] #chatSection.layout > #threads.sidebar {
    order: 2 !important;
  }

  body[data-community-focus="true"] #chatSection.layout > .comm-right {
    display: none !important;
  }

  /* El selector de salas queda debajo del foro y nunca crea un carrusel. */
  body[data-community-focus="true"] #threads.sidebar {
    max-height: none !important;
  }

  body[data-community-focus="true"] #threadsDefaultView > div:first-child,
  body[data-community-focus="true"] #threadsDynamicList {
    max-height: none !important;
    overflow: visible !important;
  }

  body[data-community-focus="true"] #threadsDynamicList {
    max-height: 190px !important;
    overflow-y: auto !important;
    overscroll-behavior: contain;
    scrollbar-width: thin;
  }

  body[data-community-focus="true"] #threadsDynamicList .thread {
    width: 100% !important;
    min-width: 0 !important;
  }

  /* Al abrir Datos del activo se mantienen los cuatro widgets accesibles,
     sin hacer que sus pestañas se corten horizontalmente. */
  body[data-community-focus="true"] #chatSection.layout > #chatChart:not([hidden]) #chatChartTabs {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
    padding: 0;
  }

  body[data-community-focus="true"] #chatSection.layout > #chatChart:not([hidden]) #chatChartTabs .bh-tv-tab {
    min-width: 0;
    min-height: 36px;
    padding: 0 7px;
    border-radius: 10px;
    font-size: 11px;
    white-space: normal;
    line-height: 1.15;
  }

  body[data-community-focus="true"] #chatSection.layout > #chatChart:not([hidden]) .chat-chart-panel {
    max-height: 520px;
  }

  body[data-community-focus="true"] #chatSection.layout {
    display: flex !important;
    flex-direction: column !important;
    gap: 10px !important;
    height: auto !important;
    min-height: 0 !important;
  }

  body[data-community-focus="true"] #threads.sidebar {
    order: 0 !important;
    display: flex !important;
    width: 100% !important;
    max-height: none !important;
    padding: 10px !important;
    overflow: visible !important;
  }

  body[data-community-focus="true"] .threads-view-toggle {
    display: flex !important;
    overflow: visible !important;
    margin-bottom: 9px !important;
  }

  body[data-community-focus="true"] #threadsDefaultView,
  body[data-community-focus="true"] #threadsDynamicView:not([hidden]) {
    display: block !important;
    width: 100% !important;
    overflow: visible !important;
  }

  body[data-community-focus="true"] #threadsDefaultView > div:first-child,
  body[data-community-focus="true"] #threadsDynamicList {
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 5px !important;
    width: 100% !important;
    overflow: visible !important;
    padding: 0 !important;
  }

  body[data-community-focus="true"] #threadsDefaultView h3,
  body[data-community-focus="true"] #threadsDynamicView h3 {
    display: block !important;
    margin: 1px 2px 7px !important;
    color: var(--muted) !important;
    font-size: 10px !important;
    letter-spacing: .1em;
    text-transform: uppercase;
  }

  body[data-community-focus="true"] #threadsDefaultView > div:nth-child(2),
  body[data-community-focus="true"] .threads-mini-leaderboard {
    display: none !important;
  }

  body[data-community-focus="true"] .sidebar .thread {
    display: flex !important;
    flex: 0 0 auto !important;
    width: 100% !important;
    min-width: 0 !important;
    height: 44px !important;
    min-height: 44px !important;
    padding: 0 10px !important;
    border: 1px solid rgba(var(--fg-rgb), .09) !important;
    border-left-width: 1px !important;
    border-radius: 11px !important;
    background: rgba(var(--fg-rgb), .045) !important;
    transform: none !important;
  }

  body[data-community-focus="true"] .sidebar .thread:hover {
    transform: none !important;
    background: rgba(31,128,255,.1) !important;
  }

  body[data-community-focus="true"] .sidebar .thread.active {
    border-color: rgba(31,128,255,.42) !important;
    border-left-color: rgba(31,128,255,.42) !important;
    background: linear-gradient(90deg, rgba(31,128,255,.18), rgba(31,128,255,.06)) !important;
  }

  body[data-community-focus="true"] .chat {
    order: 1 !important;
    height: min(640px, calc(100dvh - 300px)) !important;
    min-height: 460px !important;
  }

  body[data-community-focus="true"] #chatSection.layout > #chatChart:not([hidden]) {
    display: block !important;
    order: 2 !important;
    width: 100% !important;
    margin: 0 !important;
    overflow: hidden !important;
    border: 1px solid rgba(31,128,255,.2) !important;
    border-radius: 16px !important;
    background: rgba(31,128,255,.055) !important;
    box-shadow: 0 12px 26px rgba(0,0,0,.12);
  }

  body[data-community-focus="true"] #chatSection.layout > #chatChart:not([hidden]) .chat-chart-toggle {
    width: 100%;
    min-height: 48px;
    padding: 0 13px;
    font-size: 13px;
  }

  body[data-community-focus="true"] #chatSection.layout > #chatChart:not([hidden]) .chat-chart-panel {
    max-height: 390px;
    padding: 9px;
    overflow: auto;
  }

  body[data-community-focus="true"] #chatSection.layout > #chatChart:not([hidden]) #chatChartTabs {
    display: none !important;
  }

  body[data-community-focus="true"] #chatSection.layout > #chatChart:not([hidden]) #chatChartWidget {
    min-height: 250px;
  }

  [data-theme="light"] body[data-community-focus="true"] #chatSection.layout > #chatChart:not([hidden]) {
    border-color: rgba(31,128,255,.16) !important;
    background: rgba(255,255,255,.82) !important;
    box-shadow: 0 12px 26px rgba(36,88,145,.1);
  }
}

/* Mobile v7 final cascade: hero → chat → asset data → rooms. */
@media (max-width: 768px) {
  body[data-community-focus="true"] #chatSection.layout > .chat {
    order: 0 !important;
  }

  body[data-community-focus="true"] #chatSection.layout > #chatChart:not([hidden]) {
    order: 1 !important;
  }

  body[data-community-focus="true"] #chatSection.layout > #threads.sidebar {
    order: 2 !important;
  }

  body[data-community-focus="true"] #chatSection.layout > .comm-right {
    display: none !important;
  }

  body[data-community-focus="true"] #threads.sidebar {
    max-height: none !important;
    overflow: visible !important;
  }

  body[data-community-focus="true"] #threadsDefaultView > div:first-child,
  body[data-community-focus="true"] #threadsDynamicList {
    flex-direction: column !important;
    width: 100% !important;
    max-height: none !important;
    overflow: visible !important;
  }

  body[data-community-focus="true"] #threadsDynamicList {
    max-height: 190px !important;
    overflow-y: auto !important;
    overscroll-behavior: contain;
    scrollbar-width: thin;
  }

  body[data-community-focus="true"] #threadsDynamicList .thread {
    width: 100% !important;
    min-width: 0 !important;
  }

  body[data-community-focus="true"] #chatSection.layout > #chatChart:not([hidden]) #chatChartTabs {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
    padding: 0;
  }

  body[data-community-focus="true"] #chatSection.layout > #chatChart:not([hidden]) #chatChartTabs .bh-tv-tab {
    min-width: 0;
    min-height: 36px;
    padding: 0 7px;
    border-radius: 10px;
    font-size: 11px;
    line-height: 1.15;
    white-space: normal;
  }

  body[data-community-focus="true"] #chatSection.layout > #chatChart:not([hidden]) .chat-chart-panel {
    max-height: 520px !important;
  }
}

/* Mobile v8: las listas de salas aparecen al final y son compactas. */
@media (max-width: 768px) {
  body[data-community-focus="true"] #chatSection.layout > #threads.sidebar {
    display: none !important;
  }

  body[data-community-focus="true"] #chatSection.layout > .mobile-room-panel {
    display: block !important;
    width: 100% !important;
    min-width: 0 !important;
    margin: 0 !important;
    padding: 12px !important;
    border: 1px solid rgba(124,190,255,.16);
    border-radius: 16px;
    background: rgba(var(--fg-rgb), .045);
    box-shadow: 0 10px 24px rgba(0,0,0,.1);
  }

  body[data-community-focus="true"] #chatSection.layout > #commPanelRecent.mobile-room-panel {
    order: 2 !important;
  }

  body[data-community-focus="true"] #chatSection.layout > #commPanelMine.mobile-room-panel {
    order: 3 !important;
  }

  body[data-community-focus="true"] .mobile-room-panel .comm-panel-title {
    display: block;
    margin: 0 0 9px;
  }

  body[data-community-focus="true"] .mobile-room-panel .comm-panel-title h2 {
    margin: 0;
    font-size: 15px;
  }

  body[data-community-focus="true"] .mobile-room-panel .comm-panel-title span {
    display: block;
    margin-top: 3px;
    font-size: 11px !important;
  }

  body[data-community-focus="true"] .mobile-room-panel .comm-rooms-grid {
    display: flex !important;
    flex-direction: column !important;
    gap: 6px !important;
    max-height: 246px;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
  }

  body[data-community-focus="true"] .mobile-room-panel .comm-room-card {
    display: grid !important;
    grid-template-columns: 32px minmax(0, 1fr) auto;
    grid-template-rows: auto auto;
    align-items: center;
    min-height: 58px;
    padding: 8px 9px;
    gap: 0 8px;
    border-radius: 12px;
  }

  body[data-community-focus="true"] .mobile-room-panel .comm-room-card > div:first-child {
    grid-column: 1;
    grid-row: 1 / 3;
    align-self: center;
  }

  body[data-community-focus="true"] .mobile-room-panel .comm-room-card > div:first-child button {
    display: none;
  }

  body[data-community-focus="true"] .mobile-room-panel .comm-room-card h4 {
    grid-column: 2;
    grid-row: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 13px;
  }

  body[data-community-focus="true"] .mobile-room-panel .comm-room-card p {
    display: none;
  }

  body[data-community-focus="true"] .mobile-room-panel .comm-room-card .comm-room-meta {
    grid-column: 2;
    grid-row: 2;
    min-width: 0;
    margin-top: 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 10px;
  }

  body[data-community-focus="true"] .mobile-room-panel .comm-room-enter {
    grid-column: 3;
    grid-row: 1 / 3;
    align-self: center;
    min-height: 32px;
    padding: 0 10px;
    border-radius: 10px;
    font-size: 11px;
  }

  [data-theme="light"] body[data-community-focus="true"] #chatSection.layout > .mobile-room-panel {
    border-color: rgba(31,128,255,.14);
    background: rgba(255,255,255,.82);
    box-shadow: 0 10px 24px rgba(36,88,145,.1);
  }
}

/* Mobile v9 final: el widget crece con su contenido, sin scroll interno doble. */
@media (max-width: 768px) {
  body[data-community-focus="true"] #chatSection.layout > #chatChart:not([hidden]) .chat-chart-panel {
    max-height: 620px !important;
    overflow: visible !important;
  }

  body[data-community-focus="true"] .mobile-room-panel .comm-room-icon .bh-asset-logo {
    width: 28px;
    height: 28px;
    flex-basis: 28px;
  }
}

/* Mobile v11: composer y acciones táctiles estables, sin saltos al actualizar. */
@media (max-width: 768px) {
  body[data-community-focus="true"] #chatSection.layout > .chat {
    display: flex !important;
    flex-direction: column !important;
  }

  body[data-community-focus="true"] .posts {
    flex: 1 1 auto !important;
    min-height: 0 !important;
    overscroll-behavior-y: contain;
  }

  body[data-community-focus="true"] .message-actions {
    opacity: 1;
  }

  body[data-community-focus="true"] .message-action {
    min-height: 30px;
    padding: 5px 9px;
  }

  body[data-community-focus="true"] #postForm {
    position: relative;
    z-index: 5;
    flex: 0 0 auto !important;
  }

  body[data-community-focus="true"] .composer-field #postBody {
    height: auto !important;
    max-height: 108px;
    overflow-y: auto;
  }
}

/* Composer final: una sola burbuja alineada con el ancho del chat en ambos
   temas y en escritorio/movil. Este bloque queda al final para ganar a las
   reglas historicas acumuladas en community.html. */
body[data-community-focus="true"] .chat {
  min-width: 0;
  display: flex !important;
  flex-direction: column !important;
  overflow: hidden;
}

body[data-community-focus="true"] #postForm {
  display: grid !important;
  grid-template-columns: minmax(0, 1fr) 48px;
  align-items: center !important;
  gap: 10px !important;
  width: auto !important;
  min-width: 0 !important;
  margin: 0 14px 14px !important;
  padding: 7px !important;
  border: 1px solid rgba(124, 190, 255, .24) !important;
  border-radius: 19px !important;
  background:
    linear-gradient(135deg, rgba(31,128,255,.12), rgba(0,196,140,.04) 58%, rgba(var(--fg-rgb),.06)),
    rgba(7, 18, 38, .62) !important;
  box-shadow: 0 14px 30px rgba(0,0,0,.22), inset 0 1px 0 rgba(255,255,255,.1) !important;
  backdrop-filter: blur(20px) saturate(145%);
  -webkit-backdrop-filter: blur(20px) saturate(145%);
}

[data-theme="light"] body[data-community-focus="true"] #postForm {
  border-color: rgba(31,128,255,.2) !important;
  background: linear-gradient(135deg, rgba(255,255,255,.92), rgba(224,240,255,.68)) !important;
  box-shadow: 0 12px 26px rgba(36,88,145,.13), inset 0 1px 0 rgba(255,255,255,.95) !important;
}

body[data-community-focus="true"] .composer-field {
  display: grid !important;
  grid-template-columns: 36px minmax(0, 1fr);
  align-items: center !important;
  width: 100%;
  min-width: 0;
  min-height: 42px;
  padding: 3px 6px 3px 4px !important;
  gap: 4px;
  border: 0 !important;
  border-radius: 14px;
  background: rgba(var(--fg-rgb), .055);
  box-shadow: inset 0 0 0 1px rgba(var(--fg-rgb), .06);
}

body[data-community-focus="true"] .composer-field:focus-within {
  background: rgba(31,128,255,.07);
  box-shadow: inset 0 0 0 1px rgba(31,128,255,.2), 0 0 0 3px rgba(31,128,255,.08);
}

body[data-community-focus="true"] .composer-attach-btn {
  width: 34px !important;
  height: 34px !important;
  flex: 0 0 34px !important;
  align-self: center;
  border: 0 !important;
  border-radius: 10px !important;
  background: transparent !important;
}

body[data-community-focus="true"] .composer-field #postBody {
  width: 100%;
  min-width: 0;
  min-height: 36px;
  max-height: 108px;
  align-self: center;
  padding: 8px 5px !important;
  border: 0 !important;
  border-radius: 10px !important;
  background: transparent !important;
  box-shadow: none !important;
  font-size: 14px;
  line-height: 1.4;
}

body[data-community-focus="true"] .composer-send-btn {
  width: 48px !important;
  height: 48px !important;
  min-width: 48px;
  flex: 0 0 48px !important;
  align-self: center;
  border-radius: 14px !important;
}

body[data-community-focus="true"] .replying,
body[data-community-focus="true"] .composer-preview {
  width: auto;
  margin-inline: 14px;
  padding-inline: 0;
}

body[data-community-focus="true"] .replying {
  margin-bottom: 8px;
  border-radius: 12px;
  border-right: 1px solid rgba(31,128,255,.18);
  border-bottom: 1px solid rgba(31,128,255,.18);
}

body[data-community-focus="true"] .composer-preview { margin-bottom: 8px; }

@media (max-width: 680px) {
  body[data-community-focus="true"] #postForm {
    grid-template-columns: minmax(0, 1fr) 42px;
    gap: 7px !important;
    margin: 0 10px 10px !important;
    padding: 5px !important;
    border-radius: 17px !important;
  }

  body[data-community-focus="true"] .composer-field {
    grid-template-columns: 32px minmax(0, 1fr);
    min-height: 40px;
    padding-left: 3px !important;
  }

  body[data-community-focus="true"] .composer-attach-btn {
    width: 30px !important;
    height: 30px !important;
    flex-basis: 30px !important;
  }

  body[data-community-focus="true"] .composer-send-btn {
    width: 42px !important;
    height: 42px !important;
    min-width: 42px;
    flex-basis: 42px !important;
    border-radius: 12px !important;
  }

  body[data-community-focus="true"] .replying,
  body[data-community-focus="true"] .composer-preview {
    margin-inline: 10px;
  }
}

/* Composer v16: override definitivo al final del archivo para conservar una
   cápsula única y controles circulares después de los estilos históricos. */
body[data-community-focus="true"] #postForm {
  display: flex !important;
  flex-direction: row !important;
  align-items: center !important;
  gap: 8px !important;
  width: auto !important;
  min-width: 0 !important;
  margin: 0 14px 14px !important;
  padding: 6px 7px !important;
  border: 1px solid rgba(124,190,255,.28) !important;
  border-top-color: rgba(124,190,255,.28) !important;
  border-radius: 999px !important;
  background: linear-gradient(135deg, rgba(31,128,255,.13), rgba(0,196,140,.04) 58%, rgba(var(--fg-rgb),.07)), rgba(7,18,38,.72) !important;
  box-shadow: 0 12px 28px rgba(0,0,0,.22), inset 0 1px 0 rgba(255,255,255,.12) !important;
  backdrop-filter: blur(18px) saturate(145%) !important;
  -webkit-backdrop-filter: blur(18px) saturate(145%) !important;
}

body[data-community-focus="true"] #postForm:focus-within {
  border-color: rgba(31,128,255,.62) !important;
  box-shadow: 0 12px 28px rgba(0,0,0,.22), 0 0 0 3px rgba(31,128,255,.1), inset 0 1px 0 rgba(255,255,255,.14) !important;
}

[data-theme="light"] body[data-community-focus="true"] #postForm {
  border-color: rgba(31,128,255,.24) !important;
  border-top-color: rgba(31,128,255,.24) !important;
  background: linear-gradient(135deg, rgba(255,255,255,.94), rgba(224,240,255,.74)) !important;
  box-shadow: 0 12px 28px rgba(36,88,145,.14), inset 0 1px 0 rgba(255,255,255,.96) !important;
}

body[data-community-focus="true"] .composer-field {
  display: flex !important;
  flex: 1 1 auto !important;
  flex-direction: row !important;
  align-items: center !important;
  min-width: 0 !important;
  min-height: 42px !important;
  padding: 0 3px 0 1px !important;
  gap: 4px !important;
  border: 0 !important;
  border-radius: 999px !important;
  background: transparent !important;
  box-shadow: none !important;
}

body[data-community-focus="true"] .composer-attach-btn {
  grid-column: auto !important;
  width: 36px !important;
  height: 36px !important;
  min-width: 36px !important;
  flex: 0 0 36px !important;
  align-self: center !important;
  border: 1px solid rgba(var(--fg-rgb),.12) !important;
  border-radius: 50% !important;
  background: rgba(var(--fg-rgb),.08) !important;
}

body[data-community-focus="true"] .composer-field #postBody {
  grid-column: auto !important;
  flex: 1 1 auto !important;
  width: 100% !important;
  min-width: 0 !important;
  height: 40px;
  min-height: 40px !important;
  max-height: 92px !important;
  align-self: center !important;
  padding: 9px 8px !important;
  border: 0 !important;
  border-radius: 999px !important;
  background: transparent !important;
  box-shadow: none !important;
  font-size: 14px !important;
  line-height: 22px !important;
  text-align: left !important;
  resize: none !important;
}

body[data-community-focus="true"] .composer-field #postBody:focus {
  border: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
}

body[data-community-focus="true"] .composer-send-btn {
  grid-column: auto !important;
  width: 46px !important;
  height: 46px !important;
  min-width: 46px !important;
  flex: 0 0 46px !important;
  align-self: center !important;
  border-radius: 50% !important;
  box-shadow: 0 8px 18px rgba(31,128,255,.3), inset 0 1px 0 rgba(255,255,255,.24) !important;
}

@media (max-width: 680px) {
  body[data-community-focus="true"] #postForm {
    gap: 6px !important;
    margin: 0 10px 10px !important;
    padding: 5px 6px !important;
  }

  body[data-community-focus="true"] .composer-field {
    min-height: 38px !important;
    padding-left: 0 !important;
  }

  body[data-community-focus="true"] .composer-attach-btn {
    width: 32px !important;
    height: 32px !important;
    min-width: 32px !important;
    flex-basis: 32px !important;
  }

  body[data-community-focus="true"] .composer-field #postBody {
    height: 38px;
    min-height: 38px !important;
    max-height: 82px !important;
    padding: 8px 7px !important;
    font-size: 14px !important;
    line-height: 22px !important;
  }

  body[data-community-focus="true"] .composer-send-btn {
    width: 40px !important;
    height: 40px !important;
    min-width: 40px !important;
    flex-basis: 40px !important;
  }
}

/* Composer v15: regla final. Una sola cápsula, sin caja rectangular interior,
   con ambos controles circulares y la misma lectura en escritorio y móvil. */
body[data-community-focus="true"] #postForm {
  display: flex !important;
  flex-direction: row !important;
  align-items: center !important;
  gap: 8px !important;
  width: auto !important;
  min-width: 0 !important;
  margin: 0 14px 14px !important;
  padding: 6px 7px !important;
  border: 1px solid rgba(124,190,255,.28) !important;
  border-top-color: rgba(124,190,255,.28) !important;
  border-radius: 999px !important;
  background: linear-gradient(135deg, rgba(31,128,255,.13), rgba(0,196,140,.04) 58%, rgba(var(--fg-rgb),.07)), rgba(7,18,38,.72) !important;
  box-shadow: 0 12px 28px rgba(0,0,0,.22), inset 0 1px 0 rgba(255,255,255,.12) !important;
  backdrop-filter: blur(18px) saturate(145%) !important;
  -webkit-backdrop-filter: blur(18px) saturate(145%) !important;
}

body[data-community-focus="true"] #postForm:focus-within {
  border-color: rgba(31,128,255,.62) !important;
  box-shadow: 0 12px 28px rgba(0,0,0,.22), 0 0 0 3px rgba(31,128,255,.1), inset 0 1px 0 rgba(255,255,255,.14) !important;
}

[data-theme="light"] body[data-community-focus="true"] #postForm {
  border-color: rgba(31,128,255,.24) !important;
  border-top-color: rgba(31,128,255,.24) !important;
  background: linear-gradient(135deg, rgba(255,255,255,.94), rgba(224,240,255,.74)) !important;
  box-shadow: 0 12px 28px rgba(36,88,145,.14), inset 0 1px 0 rgba(255,255,255,.96) !important;
}

body[data-community-focus="true"] .composer-field {
  display: flex !important;
  flex: 1 1 auto !important;
  flex-direction: row !important;
  align-items: center !important;
  min-width: 0 !important;
  min-height: 42px !important;
  padding: 0 3px 0 1px !important;
  gap: 4px !important;
  border: 0 !important;
  border-radius: 999px !important;
  background: transparent !important;
  box-shadow: none !important;
}

body[data-community-focus="true"] .composer-attach-btn {
  grid-column: auto !important;
  width: 36px !important;
  height: 36px !important;
  min-width: 36px !important;
  flex: 0 0 36px !important;
  align-self: center !important;
  border: 1px solid rgba(var(--fg-rgb),.12) !important;
  border-radius: 50% !important;
  background: rgba(var(--fg-rgb),.08) !important;
}

body[data-community-focus="true"] .composer-field #postBody {
  grid-column: auto !important;
  flex: 1 1 auto !important;
  width: 100% !important;
  min-width: 0 !important;
  height: 40px;
  min-height: 40px !important;
  max-height: 92px !important;
  align-self: center !important;
  padding: 9px 8px !important;
  border: 0 !important;
  border-radius: 999px !important;
  background: transparent !important;
  box-shadow: none !important;
  font-size: 14px !important;
  line-height: 22px !important;
  text-align: left !important;
  resize: none !important;
}

body[data-community-focus="true"] .composer-field #postBody:focus {
  border: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
}

body[data-community-focus="true"] .composer-send-btn {
  grid-column: auto !important;
  width: 46px !important;
  height: 46px !important;
  min-width: 46px !important;
  flex: 0 0 46px !important;
  align-self: center !important;
  border-radius: 50% !important;
  box-shadow: 0 8px 18px rgba(31,128,255,.3), inset 0 1px 0 rgba(255,255,255,.24) !important;
}

@media (max-width: 680px) {
  body[data-community-focus="true"] #postForm {
    gap: 6px !important;
    margin: 0 10px 10px !important;
    padding: 5px 6px !important;
  }

  body[data-community-focus="true"] .composer-field {
    min-height: 38px !important;
    padding-left: 0 !important;
  }

  body[data-community-focus="true"] .composer-attach-btn {
    width: 32px !important;
    height: 32px !important;
    min-width: 32px !important;
    flex-basis: 32px !important;
  }

  body[data-community-focus="true"] .composer-field #postBody {
    height: 38px;
    min-height: 38px !important;
    max-height: 82px !important;
    padding: 8px 7px !important;
    font-size: 14px !important;
  }

  body[data-community-focus="true"] .composer-send-btn {
    width: 40px !important;
    height: 40px !important;
    min-width: 40px !important;
    flex-basis: 40px !important;
  }
}

/* Composer v14: cápsula redondeada, limpia y consistente en todas las
   anchuras. El campo de texto deja de ser una segunda caja dentro de la
   burbuja; solo quedan los controles y el contenido perfectamente centrados. */
body[data-community-focus="true"] #postForm {
  display: flex !important;
  align-items: center !important;
  gap: 8px !important;
  width: auto !important;
  margin: 0 14px 14px !important;
  padding: 6px 7px !important;
  border: 1px solid rgba(124,190,255,.28) !important;
  border-top-color: rgba(124,190,255,.28) !important;
  border-radius: 999px !important;
  background:
    linear-gradient(135deg, rgba(31,128,255,.13), rgba(0,196,140,.04) 58%, rgba(var(--fg-rgb),.07)),
    rgba(7,18,38,.72) !important;
  box-shadow: 0 12px 28px rgba(0,0,0,.22), inset 0 1px 0 rgba(255,255,255,.12) !important;
  backdrop-filter: blur(18px) saturate(145%);
  -webkit-backdrop-filter: blur(18px) saturate(145%);
}

body[data-community-focus="true"] #postForm:focus-within {
  border-color: rgba(31,128,255,.62) !important;
  box-shadow: 0 12px 28px rgba(0,0,0,.22), 0 0 0 3px rgba(31,128,255,.1), inset 0 1px 0 rgba(255,255,255,.14) !important;
}

[data-theme="light"] body[data-community-focus="true"] #postForm {
  border-color: rgba(31,128,255,.24) !important;
  border-top-color: rgba(31,128,255,.24) !important;
  background: linear-gradient(135deg, rgba(255,255,255,.94), rgba(224,240,255,.74)) !important;
  box-shadow: 0 12px 28px rgba(36,88,145,.14), inset 0 1px 0 rgba(255,255,255,.96) !important;
}

body[data-community-focus="true"] .composer-field {
  display: flex !important;
  flex: 1 1 auto !important;
  align-items: center !important;
  min-width: 0;
  min-height: 42px;
  padding: 0 3px 0 1px !important;
  gap: 4px;
  border: 0 !important;
  border-radius: 999px !important;
  background: transparent !important;
  box-shadow: none !important;
}

body[data-community-focus="true"] .composer-field:focus-within {
  background: rgba(31,128,255,.055) !important;
  box-shadow: none !important;
}

body[data-community-focus="true"] .composer-attach-btn {
  width: 36px !important;
  height: 36px !important;
  flex: 0 0 36px !important;
  border: 1px solid rgba(var(--fg-rgb),.12) !important;
  border-radius: 50% !important;
  background: rgba(var(--fg-rgb),.08) !important;
}

body[data-community-focus="true"] .composer-field #postBody {
  flex: 1 1 auto !important;
  width: 100%;
  min-width: 0;
  height: 40px;
  min-height: 40px;
  max-height: 92px;
  align-self: center;
  padding: 9px 8px !important;
  border: 0 !important;
  border-radius: 999px !important;
  background: transparent !important;
  box-shadow: none !important;
  font-size: 14px;
  line-height: 1.4;
}

body[data-community-focus="true"] .composer-field #postBody:focus {
  border: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
}

body[data-community-focus="true"] .composer-send-btn {
  width: 46px !important;
  height: 46px !important;
  min-width: 46px;
  flex: 0 0 46px !important;
  border-radius: 50% !important;
  box-shadow: 0 8px 18px rgba(31,128,255,.3), inset 0 1px 0 rgba(255,255,255,.24) !important;
}

@media (max-width: 680px) {
  body[data-community-focus="true"] #postForm {
    gap: 6px !important;
    margin: 0 10px 10px !important;
    padding: 5px 6px !important;
  }

  body[data-community-focus="true"] .composer-field {
    min-height: 38px;
    padding-left: 0 !important;
  }

  body[data-community-focus="true"] .composer-attach-btn {
    width: 32px !important;
    height: 32px !important;
    flex-basis: 32px !important;
  }

  body[data-community-focus="true"] .composer-field #postBody {
    height: 38px;
    min-height: 38px;
    max-height: 82px;
    padding: 8px 7px !important;
    font-size: 14px;
  }

  body[data-community-focus="true"] .composer-send-btn {
    width: 40px !important;
    height: 40px !important;
    min-width: 40px;
    flex-basis: 40px !important;
  }
}

/* Composer v13: barra integrada en la base del chat. Evita la doble burbuja
   que dejaba un marco flotante dentro del panel y descentraba los controles. */
body[data-community-focus="true"] #postForm {
  display: flex !important;
  flex-direction: row !important;
  align-items: center !important;
  gap: 8px !important;
  width: auto !important;
  min-width: 0 !important;
  margin: 0 14px 14px !important;
  padding: 6px 7px !important;
  border: 1px solid rgba(124,190,255,.28) !important;
  border-top-color: rgba(124,190,255,.28) !important;
  border-radius: 999px !important;
  background: linear-gradient(135deg, rgba(31,128,255,.13), rgba(0,196,140,.04) 58%, rgba(var(--fg-rgb),.07)), rgba(7,18,38,.72) !important;
  box-shadow: 0 12px 28px rgba(0,0,0,.22), inset 0 1px 0 rgba(255,255,255,.12) !important;
  backdrop-filter: blur(18px) saturate(145%) !important;
  -webkit-backdrop-filter: blur(18px) saturate(145%) !important;
}

body[data-community-focus="true"] #postForm:focus-within {
  border-color: rgba(31,128,255,.62) !important;
  box-shadow: 0 12px 28px rgba(0,0,0,.22), 0 0 0 3px rgba(31,128,255,.1), inset 0 1px 0 rgba(255,255,255,.14) !important;
}

[data-theme="light"] body[data-community-focus="true"] #postForm {
  border-color: rgba(31,128,255,.24) !important;
  border-top-color: rgba(31,128,255,.24) !important;
  background: linear-gradient(135deg, rgba(255,255,255,.94), rgba(224,240,255,.74)) !important;
  box-shadow: 0 12px 28px rgba(36,88,145,.14), inset 0 1px 0 rgba(255,255,255,.96) !important;
}

body[data-community-focus="true"] .composer-field {
  display: flex !important;
  flex: 1 1 auto !important;
  flex-direction: row !important;
  align-items: center !important;
  min-width: 0 !important;
  min-height: 42px !important;
  padding: 0 3px 0 1px !important;
  gap: 4px !important;
  border: 0 !important;
  border-radius: 999px !important;
  background: transparent !important;
  box-shadow: none !important;
}

body[data-community-focus="true"] .composer-attach-btn {
  grid-column: auto !important;
  width: 36px !important;
  height: 36px !important;
  min-width: 36px !important;
  flex: 0 0 36px !important;
  align-self: center !important;
  border: 1px solid rgba(var(--fg-rgb),.12) !important;
  border-radius: 50% !important;
  background: rgba(var(--fg-rgb),.08) !important;
}

body[data-community-focus="true"] .composer-field #postBody {
  grid-column: auto !important;
  flex: 1 1 auto !important;
  width: 100% !important;
  min-width: 0 !important;
  height: 40px;
  min-height: 40px !important;
  max-height: 92px !important;
  align-self: center !important;
  padding: 9px 8px !important;
  border: 0 !important;
  border-radius: 999px !important;
  background: transparent !important;
  box-shadow: none !important;
  font-size: 14px !important;
  line-height: 22px !important;
  text-align: left !important;
  resize: none !important;
}

body[data-community-focus="true"] .composer-field #postBody:focus {
  border: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
}

body[data-community-focus="true"] .composer-send-btn {
  grid-column: auto !important;
  width: 46px !important;
  height: 46px !important;
  min-width: 46px !important;
  flex: 0 0 46px !important;
  align-self: center !important;
  border-radius: 50% !important;
  box-shadow: 0 8px 18px rgba(31,128,255,.3), inset 0 1px 0 rgba(255,255,255,.24) !important;
}

body[data-community-focus="true"] .replying,
body[data-community-focus="true"] .composer-preview {
  margin-inline: 14px;
}

@media (max-width: 680px) {
  body[data-community-focus="true"] #postForm {
    gap: 6px !important;
    margin: 0 10px 10px !important;
    padding: 5px 6px !important;
  }

  body[data-community-focus="true"] .composer-attach-btn {
    width: 32px !important;
    height: 32px !important;
    min-width: 32px !important;
    flex-basis: 32px !important;
    border-radius: 50% !important;
  }

  body[data-community-focus="true"] .composer-field #postBody {
    height: 38px;
    min-height: 38px !important;
    max-height: 82px !important;
    padding: 8px 7px !important;
    font-size: 14px !important;
  }

  body[data-community-focus="true"] .composer-send-btn {
    width: 40px !important;
    height: 40px !important;
    min-width: 40px !important;
    flex-basis: 40px !important;
    border-radius: 50% !important;
  }

  body[data-community-focus="true"] .replying,
  body[data-community-focus="true"] .composer-preview {
    margin-inline: 10px;
  }
}
