/* Learn V2: stable Academy navigation and community panes. */
body.vix-learn-nav-v2 #mobileCommunityOverlay {
  display: none !important;
}

body.vix-learn-nav-v2 .education-member-content[style*="display: flex"] {
  display: grid !important;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr);
  min-width: 0;
  min-height: 0;
}

body.vix-learn-nav-v2 .education-subtabs {
  display: flex;
  min-width: 0;
  min-height: 0;
  padding: 16px 12px;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  overflow-x: auto;
  overflow-y: hidden;
  border-right: 0;
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-secondary);
}

body.vix-learn-nav-v2 .education-subtab {
  width: auto;
  flex: 0 0 auto;
  min-height: 48px;
  padding: 10px 12px;
  justify-content: flex-start;
  border-radius: 12px;
}

body.vix-learn-nav-v2 .education-subtab-content {
  grid-column: 1;
  grid-row: 2;
  min-width: 0;
  min-height: 0;
}

body.vix-learn-nav-v2 .education-chat {
  min-width: 0;
  min-height: 0;
}

/* The Community surface is a nested flex column. Every flex boundary must be
   allowed to shrink; otherwise chat messages grow the panel instead of owning
   the available space and their overflow is clipped by Learn's page shell. */
body.vix-learn-nav-v2 .education-chat .chat-area,
body.vix-learn-nav-v2 .education-chat .chat-messages {
  min-height: 0;
}

body.vix-learn-nav-v2 .starthere-header,
body.vix-learn-nav-v2 .resource-page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  text-align: left;
}

body.vix-learn-nav-v2 .resource-page-header {
  margin-bottom: 20px;
}

body.vix-learn-nav-v2 .resource-page-header h2,
body.vix-learn-nav-v2 .resource-page-header p {
  margin: 0;
}

body.vix-learn-nav-v2 .resource-page-header p {
  margin-top: 5px;
  color: var(--text-secondary);
}

body.vix-learn-nav-v2 .learn-admin-actions {
  display: flex;
  flex: 0 0 auto;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

body.vix-learn-nav-v2 .learn-admin-actions .admin-resources-btn,
body.vix-learn-nav-v2 .learn-admin-actions .admin-preview-toggle,
body.vix-learn-nav-v2 .learn-admin-actions .admin-starthere-btn {
  position: static;
  inset: auto;
  z-index: auto;
  min-height: 44px;
  padding: 10px 14px;
  border-radius: 12px;
  box-shadow: none;
}

.vix-learn-context {
  display: none;
}

.vix-primary-parent-row {
  display: contents;
}

.vix-primary-disclosure {
  display: none;
}

@media (max-width: 1179px) {
  body.vix-learn-nav-v2 .education-member-content[style*="display: flex"] {
    /* Keep the member panel as the constrained two-row grid from the wide
       layout. The compact navigation hides the visible tab strip, but the
       active content still needs the grid's minmax(0, 1fr) row. Turning this
       into a block makes its `flex: 1` child expand to its full content
       height, which is then clipped by the panel's overflow: hidden on
       phones. That left Start Here, Community, Resources, and Admin stuck at
       their top edge. */
    display: grid !important;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
    height: 100%;
    min-height: 0;
  }

  body.vix-learn-nav-v2 .education-subtabs {
    display: none !important;
  }

  body.vix-learn-nav-v2 .education-subtab-content {
    width: 100%;
    min-width: 0;
    min-height: 0;
  }

  body.vix-learn-nav-v2 .education-subtab-content.active {
    min-height: 0;
  }

  body.vix-learn-nav-v2 #communityContent .channel-sidebar {
    display: none !important;
  }

  body.vix-learn-nav-v2 #communityContent .chat-area,
  body.vix-learn-nav-v2 #communityContent .education-chat {
    display: flex !important;
    width: 100% !important;
    min-width: 0;
    min-height: 0;
  }

  body.vix-learn-nav-v2 #communityContent .chat-back-btn {
    display: none !important;
  }

  body.vix-app-shell-v2 .vix-primary-parent-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 44px;
    align-items: center;
    gap: 2px;
  }

  body.vix-app-shell-v2 .vix-primary-parent-row > .nav-tab {
    min-width: 0;
  }

  body.vix-app-shell-v2 .vix-primary-disclosure {
    display: inline-grid;
    width: 44px;
    min-height: 44px;
    place-items: center;
    padding: 0;
    border: 1px solid transparent;
    border-radius: 10px;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
  }

  body.vix-app-shell-v2 .vix-primary-disclosure:hover,
  body.vix-app-shell-v2 .vix-primary-disclosure:focus-visible {
    border-color: rgba(255,46,187,0.32);
    background: rgba(255,255,255,0.06);
    color: var(--text-primary);
  }

  body.vix-app-shell-v2 .vix-primary-disclosure::before {
    content: '\203A';
    font-size: 1.35rem;
    line-height: 1;
    transform: rotate(0deg);
    transition: transform 160ms ease;
  }

  body.vix-app-shell-v2 .vix-primary-disclosure[aria-expanded="true"]::before {
    transform: rotate(90deg);
  }

  body.vix-app-shell-v2.vix-learn-nav-v2 .vix-learn-context.is-open {
    display: flex;
  }

  body.vix-app-shell-v2.vix-learn-nav-v2 .vix-learn-context[hidden] {
    display: none !important;
  }

  body.vix-app-shell-v2 .vix-learn-context {
    margin: 4px 2px 10px 14px;
    padding: 10px 8px 10px 12px;
    flex: 0 0 auto;
    flex-direction: column;
    gap: 4px;
    max-height: none;
    overflow: visible;
    border-left: 2px solid rgba(255, 46, 187, 0.32);
    scrollbar-gutter: auto;
  }

  body.vix-app-shell-v2 .vix-learn-context-heading,
  body.vix-app-shell-v2 .vix-learn-channel-heading {
    padding: 6px 8px;
    color: #96909f;
    font-size: 0.68rem;
    font-weight: 900;
    letter-spacing: 0.14em;
    text-transform: uppercase;
  }

  body.vix-app-shell-v2 .vix-learn-context-item,
  body.vix-app-shell-v2 .vix-learn-channel-item {
    display: flex;
    width: 100%;
    min-height: 44px;
    padding: 9px 10px;
    align-items: center;
    gap: 10px;
    border: 1px solid transparent;
    border-radius: 10px;
    background: transparent;
    color: var(--text-secondary);
    font: inherit;
    text-align: left;
    cursor: pointer;
  }

  body.vix-app-shell-v2 .vix-learn-context-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 44px;
    align-items: center;
    gap: 2px;
  }

  body.vix-app-shell-v2 .vix-learn-context-row > .vix-learn-context-item {
    min-width: 0;
  }

  body.vix-app-shell-v2 .vix-learn-disclosure {
    display: inline-grid;
    width: 44px;
    min-height: 44px;
    place-items: center;
    border: 1px solid transparent;
    border-radius: 10px;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
  }

  body.vix-app-shell-v2 .vix-learn-disclosure:hover,
  body.vix-app-shell-v2 .vix-learn-disclosure:focus-visible {
    border-color: rgba(255,46,187,0.32);
    background: rgba(255,255,255,0.06);
    color: var(--text-primary);
  }

  body.vix-app-shell-v2 .vix-learn-disclosure::before {
    content: '\203A';
    font-size: 1.35rem;
    line-height: 1;
    transform: rotate(0deg);
    transition: transform 160ms ease;
  }

  body.vix-app-shell-v2 .vix-learn-disclosure[aria-expanded="true"]::before {
    transform: rotate(90deg);
  }

  body.vix-app-shell-v2 .vix-learn-context-item:hover,
  body.vix-app-shell-v2 .vix-learn-channel-item:hover {
    background: rgba(255,255,255,0.06);
    color: var(--text-primary);
  }

  body.vix-app-shell-v2 .vix-learn-context-item.active,
  body.vix-app-shell-v2 .vix-learn-channel-item.active {
    border-color: rgba(255,46,187,0.32);
    background: linear-gradient(90deg, rgba(255,46,187,0.17), rgba(39,165,255,0.1));
    color: var(--text-primary);
  }

  body.vix-app-shell-v2 .vix-learn-channel-tree {
    display: none;
    padding: 2px 0 4px 10px;
  }

  body.vix-app-shell-v2 .vix-learn-channel-tree.is-open {
    display: block;
  }

  body.vix-app-shell-v2 .vix-learn-channel-group + .vix-learn-channel-group {
    margin-top: 8px;
  }

  body.vix-app-shell-v2 .vix-learn-channel-item {
    min-height: 40px;
    font-size: 0.86rem;
  }

  body.vix-app-shell-v2 .vix-learn-channel-item > span:nth-child(2) {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  body.vix-app-shell-v2 .vix-learn-channel-badge {
    min-width: 21px;
    margin-left: auto;
    padding: 2px 5px;
    border-radius: 999px;
    background: #ff2ebb;
    color: #fff;
    font-size: 0.68rem;
    font-weight: 900;
    text-align: center;
  }
}

@media (max-width: 767px) {
  body.vix-admin-sheet-open .admin-sidebar {
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    overflow: hidden;
  }

  body.vix-admin-sheet-open .admin-sidebar-header {
    position: absolute;
    z-index: 3;
    top: 12px;
    right: 12px;
    left: auto;
    width: auto;
    margin: 0;
    padding: 0;
    border: 0;
    pointer-events: none;
  }

  body.vix-admin-sheet-open .admin-sidebar-title {
    display: none;
  }

  body.vix-admin-sheet-open .admin-sidebar-close {
    display: inline-grid;
    pointer-events: auto;
  }

  body.vix-admin-sheet-open .admin-sidebar-nav {
    width: 100%;
    min-width: 0;
    margin: 0;
    padding: 20px 18px max(20px, env(safe-area-inset-bottom));
    padding-top: 68px;
    align-items: stretch;
    box-sizing: border-box;
  }

  body.vix-admin-sheet-open .admin-nav-group,
  body.vix-admin-sheet-open .admin-nav-item {
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
  }

  body.vix-learn-nav-v2 .starthere-header,
  body.vix-learn-nav-v2 .resource-page-header {
    align-items: stretch;
    flex-direction: column;
  }

  body.vix-learn-nav-v2 .learn-admin-actions {
    justify-content: flex-start;
  }

  body.vix-learn-nav-v2 #educationSection,
  body.vix-learn-nav-v2 .education-page,
  body.vix-learn-nav-v2 .education-member-content,
  body.vix-learn-nav-v2 .education-subtab-content.active {
    min-height: 0;
  }

  body.vix-app-shell-v2.vix-learn-nav-v2 #educationSection > .education-page {
    height: 100%;
    max-height: 100%;
    overflow: hidden !important;
  }

  body.vix-app-shell-v2.vix-learn-nav-v2 .education-subtab-content.active,
  body.vix-app-shell-v2.vix-learn-nav-v2 .resource-library,
  body.vix-app-shell-v2.vix-learn-nav-v2 .education-chat,
  body.vix-app-shell-v2.vix-learn-nav-v2 .chat-area,
  body.vix-app-shell-v2.vix-learn-nav-v2 .admin-panel-mount,
  body.vix-app-shell-v2.vix-learn-nav-v2 .admin-panel-layout {
    height: 100%;
    max-height: 100%;
    min-height: 0;
    overflow: hidden;
  }

  body.vix-app-shell-v2.vix-learn-nav-v2 :is(
    .starthere-container,
    .resource-grid-container,
    #chatMessages,
    #policiesContent .admin-content-area
  ) {
    min-height: 0;
    max-height: 100%;
    overflow-y: auto !important;
    overflow-x: hidden;
    overscroll-behavior-y: contain;
    touch-action: pan-y;
    -webkit-overflow-scrolling: touch;
  }

  body.vix-learn-nav-v2 #communityContent .chat-header-actions {
    gap: 4px;
  }

  body.vix-learn-nav-v2 #communityContent .chat-call-btn,
  body.vix-learn-nav-v2 #communityContent .chat-rules-btn {
    min-width: 44px;
    min-height: 44px;
  }
}

@media (forced-colors: active) {
  body.vix-app-shell-v2 .vix-learn-context-item.active,
  body.vix-app-shell-v2 .vix-learn-channel-item.active {
    border: 2px solid Highlight;
  }
}
