.sidebar {
  overflow: auto;
  border-top: 1px solid var(--grey-30);
  background: var(--grey-10);
  font-size: 11px;

  --sidebar-indent: 16px;
}

.sidebar-contents-wrapper {
  /* Allow absolute positioning that is dependent of the scrolling. */
  position: relative;
  margin: 16px;
  line-height: 1.5;

  /* Subtract the splitter size. */
  margin-inline-start: calc(16px - 5px);
}

.sidebar-calltree .sidebar-contents-wrapper {
  display: grid;
  align-content: start; /* the grid isn't vertically stretched */
  align-items: center;
  gap: 2px 5px;
  grid-template-columns:
    /* Label */
    1fr
    /* Value */
    min-content
    /* Percentage */
    min-content;
}

.sidebar-titlegroup,
.sidebar-title2,
.sidebar-title3 {
  min-width: 0; /* With this, the cell's minimum size is 0 instead of min-content */
  grid-column-start: span 3;
}

/* Truncate the text with an ellipse */
.sidebar-label,
.sidebar-title2,
.sidebar-title3,
.sidebar-title-label > :nth-child(2) {
  overflow: hidden;
  min-width: 0;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-title-label {
  display: grid;
  gap: 5px;
  grid-template-columns: min-content 1fr;
}

.sidebar-title-label > :nth-child(2) {
  color: var(--grey-50);
  text-align: end;
}

.sidebar-titlegroup {
  margin: 0 0 1em;
  line-height: unset;
}

.sidebar-title,
.sidebar-subtitle {
  padding: 0;
  margin: 0;
  font-weight: normal;
}

/* This will be used on both the title and the subtitle */
.can-select-content-input {
  all: unset;
  width: 100%;
  text-overflow: ellipsis;
}

.can-select-content-input:focus-visible {
  text-overflow: unset;
}

.sidebar-title {
  margin-bottom: 0.3em;
  font-size: 1.2em;
  font-weight: 500;
}

.sidebar-subtitle {
  color: var(--grey-50);
  font-size: inherit; /* reset browser styles */
}

.sidebar-title2,
.sidebar-title3 {
  font-weight: normal;
}

.sidebar-title2 {
  margin: 0.9em 0 0.4em;
}

.sidebar-title3 {
  margin: 0.7em 0 0.3em;
}

.sidebar-label {
  color: var(--grey-50);
  grid-column-start: 1;
  margin-inline-start: var(--sidebar-indent);
  white-space: nowrap;
}

.sidebar-label-indent {
  margin-inline-start: calc(var(--sidebar-indent) * 2);
}

.sidebar-value,
.sidebar-percentage {
  text-align: end;
  white-space: nowrap;
}

.sidebar-histogram-bar {
  background-color: var(--grey-30);
  grid-column-start: span 3;
  margin-inline-start: var(--sidebar-indent);
}

.sidebar-histogram-bar-color {
  height: 5px;
}

.sidebar-histogram-bar-color.category-color-transparent {
  /* A white bar does not show up well here */
  background-color: var(--grey-50);
}

.sidebar-histogram-bar-color.category-color-grey {
  /* The grey category color is the same our background color, choose a darker grey instead. */
  background-color: var(--grey-50);
}

.sidebar-toggle {
  padding: 0;
  border: 0;
  background: 0;
  color: var(--grey-50);
  font-size: inherit;
}

/* Opt out of the default photon styling, as it doesn't look very nice with the
   overflow: hidden of the container */
.sidebar-toggle:focus-visible {
  border: 0;
  border-radius: 2px;
  box-shadow: none;
  color: var(--blue-60);
  text-decoration: underline;
}

/* This is the twisty arrow */
.sidebar-toggle::before {
  position: absolute;
  width: 0;
  height: 0;
  border-style: solid;
  border-color: transparent;
  margin-top: 1px;
  background: none;
  border-block-width: 5px;
  border-inline-end-width: 4px;
  border-inline-start-color: currentcolor;
  border-inline-start-width: 8px;
  content: '';

  /* Make sure the arrow is visible in High Contrast Mode */
  forced-color-adjust: none;
  margin-inline-start: -11px;
}

.sidebar-toggle:active:hover {
  color: var(--grey-60);
}

.sidebar-toggle.expanded::before {
  border-width: 8px 5px 4px;
  border-style: solid;
  border-color: currentcolor transparent transparent;
  margin-top: 3px;
  margin-inline-start: -12px;
}

@media (forced-colors: active) {
  .sidebar-toggle,
  .sidebar-toggle::before {
    color: ButtonText;
  }

  .sidebar-label:hover .sidebar-toggle,
  .sidebar-label:hover .sidebar-toggle::before {
    color: SelectedItem;
  }
}
