/**
 * /charts/ personal DM: PC list stays in the left sidebar;
 * mobile + PWA hide the top list when a thread is open and show a back link.
 * Marker: chartsopenchat20260903a
 */
#cotinder-charts-page .cotinder-chat-back-to-list {
  display: none;
  align-items: center;
  gap: 6px;
  margin: 0 0 10px;
  padding: 0;
  border: 0;
  background: none;
  color: #fd7728;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}

#cotinder-charts-page .cotinder-chat-back-to-list:hover,
#cotinder-charts-page .cotinder-chat-back-to-list:focus {
  color: #e0651c;
  text-decoration: underline;
}

/* PC: chat list only in the left block, never above the thread */
@media (min-width: 1200px) {
  #cotinder-charts-page .charts-mobile-sidebar--inline {
    display: none !important;
  }

  #cotinder-charts-page .cotinder-chat-back-to-list {
    display: none !important;
  }
}

/* Phone / tablet: inline list is the picker; hide it once a thread is open */
@media (max-width: 1199.98px) {
  #cotinder-charts-page .charts-mobile-sidebar--inline {
    display: block;
    margin-top: 16px;
    padding: 14px 16px 16px;
    border: 1px solid #ececec;
    border-radius: 14px;
    background: #fff;
    width: 100%;
    box-sizing: border-box;
  }

  #cotinder-charts-page .charts-mobile-sidebar--inline .charts-sidebar-chats {
    margin-bottom: 0;
    width: 100%;
  }

  #cotinder-charts-page .charts-mobile-sidebar--inline .arena-filter__label {
    display: block;
    width: 100%;
    box-sizing: border-box;
    margin: 0 0 10px;
    padding-bottom: 10px;
    border-bottom: 1px solid #ececec;
  }

  #cotinder-charts-page .charts-mobile-sidebar--inline .charts-sidebar-chats__list {
    max-height: min(42vh, 320px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  #cotinder-charts-page .cotinder-messages--split .js-cotinder-chat-placeholder {
    display: none !important;
  }

  #cotinder-charts-page:not(.is-dm-thread-open) .cotinder-messages--split .cotinder-messages__main:has(.js-cotinder-chat-thread[hidden]) {
    display: none;
  }

  #cotinder-charts-page.is-dm-thread-open .charts-mobile-sidebar--inline,
  #cotinder-charts-page.is-dm-thread-open .cotinder-messages--split .cotinder-messages__head {
    display: none !important;
  }

  #cotinder-charts-page.is-dm-thread-open .cotinder-chat-back-to-list {
    display: inline-flex;
  }
}

/* PWA (iframe gets html.cotinder-in-pwa): same as phone even if the viewport is wide */
html.cotinder-in-pwa #cotinder-charts-page.is-dm-thread-open .charts-mobile-sidebar--inline,
html.cotinder-in-pwa #cotinder-charts-page.is-dm-thread-open .cotinder-messages--split .cotinder-messages__head,
html.cotinder-pwa-standalone #cotinder-charts-page.is-dm-thread-open .charts-mobile-sidebar--inline,
html.cotinder-pwa-standalone #cotinder-charts-page.is-dm-thread-open .cotinder-messages--split .cotinder-messages__head {
  display: none !important;
}

html.cotinder-in-pwa #cotinder-charts-page.is-dm-thread-open .cotinder-chat-back-to-list,
html.cotinder-pwa-standalone #cotinder-charts-page.is-dm-thread-open .cotinder-chat-back-to-list {
  display: inline-flex !important;
}

@media (display-mode: standalone), (display-mode: fullscreen) {
  #cotinder-charts-page.is-dm-thread-open .charts-mobile-sidebar--inline,
  #cotinder-charts-page.is-dm-thread-open .cotinder-messages--split .cotinder-messages__head {
    display: none !important;
  }

  #cotinder-charts-page.is-dm-thread-open .cotinder-chat-back-to-list {
    display: inline-flex !important;
  }
}
