/* Internal navigation: back control + centered title/subtitle + optional trailing action. */
@media (max-width: 1199px) {
  :is(
      .book-detail-top,
      .author-detail-top,
      .ser-detail-top,
      .col-detail-top,
      .profile-page-header
    ).compact-entity-header:has(> .history-back) {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 36px 36px;
    align-items: start;
    gap: 0 12px;
    min-width: 0;
    position: sticky;
    top: 0;
    z-index: 30;
    /* Side gutter is on .app-shell; top gap before the panel is on the layout below. */
    margin-bottom: 0;
    padding-top: 8px;
    padding-bottom: 0;
    overflow: visible;
    background: var(--color-background, var(--soft, #f4f4f2));
  }

  .compact-entity-header:has(> .history-back) > .history-back {
    grid-column: 3;
    grid-row: 1;
    position: relative;
    z-index: 2;
    flex: none;
  }

  .compact-entity-header:has(> .history-back) > .compact-entity-identity {
    grid-column: 1;
    grid-row: 1;
    align-self: start;
    justify-self: start;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    flex: none;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    text-align: left;
    pointer-events: none;
  }

  .compact-entity-header:has(> .history-back) > .compact-entity-identity :is(h1, h2) {
    margin: 0;
    width: 100%;
    text-align: left;
    -webkit-box-pack: start;
    color: var(--color-text);
    font-family: var(--font-head);
    font-size: var(--type-display-size);
    line-height: var(--type-display-line);
    font-weight: var(--weight-semibold);
    overflow-wrap: anywhere;
    display: block;
    overflow: visible;
  }

  .compact-entity-header:has(> .history-back)
    > .compact-entity-identity
    :is(p, .bd-author, .ser-detail-authors, .author-profile-english) {
    margin: 6px 0 0;
    width: 100%;
    max-width: 100%;
    text-align: left;
    color: var(--muted, var(--color-text-secondary));
    font-size: 16px;
    line-height: 22px;
    font-weight: var(--weight-regular);
    font-family: var(--font-body);
    overflow-wrap: anywhere;
    pointer-events: auto;
  }

  .compact-entity-header:has(> .history-back) .bd-left-identity {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    min-width: 0;
    width: 100%;
  }

  .compact-entity-header:has(> .history-back)
    > :is(
      details,
      .bd-more,
      #author-profile-actions,
      .ser-detail-actions
    ) {
    grid-column: 2;
    grid-row: 1;
    justify-self: end;
    align-self: start;
    position: relative;
    z-index: 2;
    margin-left: 0;
    flex: none;
  }

  .compact-entity-header:has(> .history-back)
    :is(.bd-menu-list, .author-profile-menu-list, .ser-detail-menu-list) {
    right: 0;
    left: auto;
    max-width: calc(100vw - 24px);
  }

  .compact-entity-header:has(> .history-back)
    :is(.bd-more > summary, .author-profile-menu, .ser-detail-menu) {
    background: transparent;
    box-shadow: none;
    border: 0;
  }
}

@media (max-width: 767px) {
  .compact-entity-header:has(> .history-back) > .compact-entity-identity :is(h1, h2),
  .ds-book-detail .compact-entity-header:has(> .history-back) #book-drawer-title {
    font-size: var(--type-panel-size);
    line-height: var(--type-panel-line);
  }
}
